You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2013/10/22 17:06:09 UTC

svn commit: r1534652 - in /santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax: ext/XMLSecurityUtils.java impl/processor/input/AbstractDecryptInputProcessor.java

Author: coheigea
Date: Tue Oct 22 15:06:09 2013
New Revision: 1534652

URL: http://svn.apache.org/r1534652
Log:
Fixing problem with secret keys

Modified:
    santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java
    santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java?rev=1534652&r1=1534651&r2=1534652&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityUtils.java Tue Oct 22 15:06:09 2013
@@ -391,13 +391,13 @@ public class XMLSecurityUtils {
         }
         String keyAlgorithm = JCEMapper.getJCEKeyAlgorithmFromURI(symEncAlgo);
         SecretKeySpec keySpec;
-        if (size <= 0 || keyAlgorithm.startsWith("HmacSHA") && rawKey.length <= 64) {
-            keySpec = new SecretKeySpec(rawKey, keyAlgorithm);
-        } else {
+        if (size > 0 && !symEncAlgo.endsWith("gcm")) {
             keySpec = 
                 new SecretKeySpec(
                     rawKey, 0, rawKey.length > size ? size : rawKey.length, keyAlgorithm
                 );
+        } else {
+            keySpec = new SecretKeySpec(rawKey, keyAlgorithm);
         }
         return keySpec;
     }

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java?rev=1534652&r1=1534651&r2=1534652&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java Tue Oct 22 15:06:09 2013
@@ -51,6 +51,7 @@ import javax.xml.stream.XMLStreamConstan
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.events.Attribute;
+
 import java.io.*;
 import java.security.Key;
 import java.security.NoSuchAlgorithmException;
@@ -207,7 +208,10 @@ public abstract class AbstractDecryptInp
                 //create a new Thread for streaming decryption
                 DecryptionThread decryptionThread =
                         new DecryptionThread(subInputProcessorChain, isSecurityHeaderEvent);
-                decryptionThread.setSecretKey(inboundSecurityToken.getSecretKey(algorithmURI, XMLSecurityConstants.Enc, encryptedDataType.getId()));
+                Key decryptionKey = 
+                    inboundSecurityToken.getSecretKey(algorithmURI, XMLSecurityConstants.Enc, encryptedDataType.getId());
+                decryptionKey = XMLSecurityUtils.prepareSecretKey(algorithmURI, decryptionKey.getEncoded());
+                decryptionThread.setSecretKey(decryptionKey);
                 decryptionThread.setSymmetricCipher(symCipher);
                 decryptionThread.setIvLength(ivLength);
                 XMLSecStartElement parentXMLSecStartElement = xmlSecStartElement.getParentXMLSecStartElement();