[java-xmltooling COMMIT] in /branches/REL_1: doc/RELEASE-NOTES.txt src/main/java/org/opensaml/xml/security/SecurityHe...

noreply at shibboleth.net noreply at shibboleth.net
Thu May 8 20:50:56 EDT 2014


Author: putmanb
Date: Thu May  8 20:50:56 2014
New Revision: 822

URL: http://svn.shibboleth.net/view/java-xmltooling?rev=822&view=rev
Log:
JXT-110: SecurityHelper derivePublicKey incorrectly derives public key for DSAPrivateKey 

Modified:
    branches/REL_1/doc/RELEASE-NOTES.txt
    branches/REL_1/src/main/java/org/opensaml/xml/security/SecurityHelper.java
    branches/REL_1/src/test/java/org/opensaml/xml/security/SecurityHelperTest.java

Modified: branches/REL_1/doc/RELEASE-NOTES.txt
URL: http://svn.shibboleth.net/view/java-xmltooling/branches/REL_1/doc/RELEASE-NOTES.txt?rev=822&r1=821&r2=822&view=diff
==============================================================================
--- branches/REL_1/doc/RELEASE-NOTES.txt (original)
+++ branches/REL_1/doc/RELEASE-NOTES.txt Thu May  8 20:50:56 2014
@@ -2,6 +2,7 @@
 =============================================
 [JXT-108] - Encrypter setKeyResolverCriteria() typo, should be getKeyResolverCriteria()
 [JXT-109] - SimpleKeyInfoReferenceEncryptedKeyResolver constructor missing 'public' modifier 
+[JXT-110] - SecurityHelper derivePublicKey incorrectly derives public key for DSAPrivateKey 
 
 Changes in Release 1.4.1
 =============================================

Modified: branches/REL_1/src/main/java/org/opensaml/xml/security/SecurityHelper.java
URL: http://svn.shibboleth.net/view/java-xmltooling/branches/REL_1/src/main/java/org/opensaml/xml/security/SecurityHelper.java?rev=822&r1=821&r2=822&view=diff
==============================================================================
--- branches/REL_1/src/main/java/org/opensaml/xml/security/SecurityHelper.java (original)
+++ branches/REL_1/src/main/java/org/opensaml/xml/security/SecurityHelper.java Thu May  8 20:50:56 2014
@@ -401,7 +401,7 @@
         if (key instanceof DSAPrivateKey) {
             DSAPrivateKey dsaKey = (DSAPrivateKey) key;
             DSAParams keyParams = dsaKey.getParams();
-            BigInteger y = keyParams.getQ().modPow(dsaKey.getX(), keyParams.getP());
+            BigInteger y = keyParams.getG().modPow(dsaKey.getX(), keyParams.getP());
             DSAPublicKeySpec pubKeySpec = new DSAPublicKeySpec(y, keyParams.getP(), keyParams.getQ(), keyParams.getG());
 
             try {

Modified: branches/REL_1/src/test/java/org/opensaml/xml/security/SecurityHelperTest.java
URL: http://svn.shibboleth.net/view/java-xmltooling/branches/REL_1/src/test/java/org/opensaml/xml/security/SecurityHelperTest.java?rev=822&r1=821&r2=822&view=diff
==============================================================================
--- branches/REL_1/src/test/java/org/opensaml/xml/security/SecurityHelperTest.java (original)
+++ branches/REL_1/src/test/java/org/opensaml/xml/security/SecurityHelperTest.java Thu May  8 20:50:56 2014
@@ -55,6 +55,12 @@
     /** Location of encrypted, PEM formatted, DSA private key. */
     private String dsaPrivKeyPEMEncrypt = "/data/dsa-privkey-changeit-pass.pem";
 
+    protected void setUp() throws Exception {
+        super.setUp();
+        org.opensaml.xml.Configuration.setGlobalSecurityConfiguration(
+                DefaultSecurityConfigurationBootstrap.buildDefaultConfig());
+    }
+
     /** Test decoding an RSA private key, in PEM format, without encryption. */
     public void testDecodeRSAPrivateKeyPEMNoEncrypt() throws Exception {
         testPrivKey(rsaPrivKeyPEMNoEncrypt, null, "RSA");
@@ -91,12 +97,14 @@
         PublicKey pubKey = SecurityHelper.derivePublicKey(privKey);
         assertNotNull(pubKey);
         assertEquals("RSA", pubKey.getAlgorithm());
+        assertTrue(SecurityHelper.matchKeyPair(pubKey, privKey));
         
         pubKey = null;
         privKey = testPrivKey(dsaPrivKeyPEMNoEncrypt, null, "DSA");
         pubKey = SecurityHelper.derivePublicKey(privKey);
         assertNotNull(pubKey);
         assertEquals("DSA", pubKey.getAlgorithm());
+        assertTrue(SecurityHelper.matchKeyPair(pubKey, privKey));
     }
     
     /** Test mapping algorithm URI's to JCA key algorithm specifiers. */
@@ -141,8 +149,6 @@
      * @throws NoSuchAlgorithmException 
      * @throws SecurityException */
     public void testKeyPairMatching() throws NoSuchAlgorithmException, NoSuchProviderException, SecurityException {
-        org.opensaml.xml.Configuration.setGlobalSecurityConfiguration(
-                DefaultSecurityConfigurationBootstrap.buildDefaultConfig());
         KeyPair kp1rsa = SecurityHelper.generateKeyPair("RSA", 1024, null);
         KeyPair kp2rsa = SecurityHelper.generateKeyPair("RSA", 1024, null);
         KeyPair kp1dsa = SecurityHelper.generateKeyPair("DSA", 1024, null);



More information about the commits mailing list