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 2023/02/21 14:32:36 UTC

[santuario-xml-security-java] branch main updated: Increase TestUtils RSA key size to 2048-bit (#125)

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/santuario-xml-security-java.git


The following commit(s) were added to refs/heads/main by this push:
     new 1a01c683 Increase TestUtils RSA key size to 2048-bit (#125)
1a01c683 is described below

commit 1a01c6838fa4d9c3939c56192033d8762b5f7c4f
Author: Will Childs-Klein <wi...@gmail.com>
AuthorDate: Tue Feb 21 09:32:31 2023 -0500

    Increase TestUtils RSA key size to 2048-bit (#125)
    
    Commands run to generate new 2048 bit RSA key:
    
    ```
    $ openssl genrsa -out rsa.pem
    Generating RSA private key, 2048 bit long modulus
    ...
    
    $ openssl rsa -in rsa.pem -noout -modulus | cut -d= -f2 | python -c 'import sys; print(int(sys.stdin.read(), 16))'
    256238824275267073228663222562407414136997665555081133619751824469224184150894389364159891752960889740166155877407365742413429573930023207620104749258308391064255862074480119957488123454012307822677531893861035685028852795937346368424054616567527557029127461723390270340966818894138549557255881643469408427866307388333116680863388120489934066278758189489148193166784337844728831079471508274181127307711657264222958380652901366562043051836810623589419545446175380332033891944979173623447795 [...]
    
    $ openssl rsa -in rsa.pem -text
    ...
    
    $ echo '1bf2f1ceb238a151c4b14cfd7d752f08c58432cdf98fef591073aa9d1cd51869a66c5bc7843e610bf37737d657f0cbdbefbb12b67e595b491ebdb9dbd9a9da512db092d31b0ae2a20d74a4f21e1d80d97e7ce81ff9fdfd780f531a246d2723aad2317b2ed683a11a43e4ce51225ea4b1352061f2174d11f76bb281331cd8d0574a0c8da25b346a3bc8e5073bbbc8a09882a2212688d5f542a11080eb6560fb013281d802a0e7d9c5937100134fc1d2f4985e7d561451ed34b21fef9fb39724d2256e9975751672e1241473cdd052a6b8e8f584404abd262ecebcc9a1513a1a04a1ebbdb0ba0bd8b9fc1bc573ee0178dbb [...]
    ```
---
 src/test/java/javax/xml/crypto/test/dsig/TestUtils.java  | 16 ++++++++--------
 .../javax/xml/crypto/test/dsig/XMLSignatureTest.java     |  4 ++--
 .../javax/xml/crypto/test/dsig/keyinfo/KeyValueTest.java |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java b/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
index ed04b0c5..eb3d6194 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/TestUtils.java
@@ -107,10 +107,10 @@ public class TestUtils {
     private static final String DSA_2048_X =
         "14562787764977288900757387442281559936279834964901963465277698843172";
     private static final String RSA_MOD =
-        "010800185049102889923150759252557522305032794699952150943573164381936603255999071981574575044810461362008102247767482738822150129277490998033971789476107463";
+        "256238824275267073228663222562407414136997665555081133619751824469224184150894389364159891752960889740166155877407365742413429573930023207620104749258308391064255862074480119957488123454012307822677531893861035685028852795937346368424054616567527557029127461723390270340966818894138549557255881643469408427866307388333116680863388120489934066278758189489148193166784337844728831079471508274181127307711657264222958380652901366562043051836810623589419545446175380332033891944979173623 [...]
     private static final String RSA_PUB = "065537";
     private static final String RSA_PRIV =
-        "0161169735844219697954459962296126719476357984292128166117072108359155865913405986839960884870654387514883422519600695753920562880636800379454345804879553";
+        "352823466173308218077644219357487298041147280767971092632351261731583538730437915928739317206878415096092190768226203283570927640133745735319563797138559122474914155264981400200859487930330510366944176237881194748264395323334698510560243657766661378249057206553835817867293982590095102187264762798215960702051749403580869600071176461292850726211920212686396798214951226665697964985482836894672909188847171368605060923666080323078377935834162023109029126034135432926702347720624429230 [...]
 
     private static final DocumentBuilderFactory DBF = DocumentBuilderFactory.newInstance();
 
@@ -131,7 +131,7 @@ public class TestUtils {
         if ("DSA".equalsIgnoreCase(algo)) {
             return getPublicKey("DSA", 1024);
         } else if ("RSA".equalsIgnoreCase(algo)) {
-            return getPublicKey("RSA", 512);
+            return getPublicKey("RSA", 2048);
         } else {
             throw new RuntimeException("Unsupported key algorithm " + algo);
         }
@@ -156,7 +156,7 @@ public class TestUtils {
                 throw new RuntimeException("Unsupported keysize:" + keysize);
             }
         } else if ("RSA".equalsIgnoreCase(algo)) {
-            if (keysize == 512) {
+            if (keysize == 2048) {
                 kspec = new RSAPublicKeySpec(new BigInteger(RSA_MOD),
                                              new BigInteger(RSA_PUB));
             } else {
@@ -181,7 +181,7 @@ public class TestUtils {
         if ("DSA".equalsIgnoreCase(algo)) {
             return getPrivateKey("DSA", 1024);
         } else if ("RSA".equalsIgnoreCase(algo)) {
-            return getPrivateKey("RSA", 512);
+            return getPrivateKey("RSA", 2048);
         } else {
             throw new RuntimeException("Unsupported key algorithm " + algo);
         }
@@ -204,7 +204,7 @@ public class TestUtils {
                 throw new RuntimeException("Unsupported keysize:" + keysize);
             }
         } else if ("RSA".equalsIgnoreCase(algo)) {
-            if (keysize == 512) {
+            if (keysize == 2048) {
                 kspec = new RSAPrivateKeySpec
                     (new BigInteger(RSA_MOD), new BigInteger(RSA_PRIV));
             } else {
@@ -250,12 +250,12 @@ public class TestUtils {
             Document doc = XMLUtils.read(new FileInputStream(input), false);
             if (tag == null) {
                 return new DOMValidateContext
-                    (TestUtils.getPublicKey("RSA", 512),
+                    (TestUtils.getPublicKey("RSA", 2048),
                      doc.getDocumentElement());
             } else {
                 NodeList list = doc.getElementsByTagName(tag);
                 return new DOMValidateContext
-                    (TestUtils.getPublicKey("RSA", 512), list.item(0));
+                    (TestUtils.getPublicKey("RSA", 2048), list.item(0));
             }
         } else {
             throw new Exception("Unsupported XMLValidateContext type: " + type);
diff --git a/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java b/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java
index dd0ed251..5a2f42b6 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/XMLSignatureTest.java
@@ -87,12 +87,12 @@ public class XMLSignatureTest {
         // set up the signingKeys
         SIGN_KEYS = new Key[3];
         SIGN_KEYS[0] = TestUtils.getPrivateKey("DSA", 1024);
-        SIGN_KEYS[1] = TestUtils.getPrivateKey("RSA", 512);
+        SIGN_KEYS[1] = TestUtils.getPrivateKey("RSA", 2048);
         SIGN_KEYS[2] = new SecretKeySpec(new byte[16], "HmacSHA1");
         // set up the validatingKeys
         VALIDATE_KEYS = new Key[3];
         VALIDATE_KEYS[0] = TestUtils.getPublicKey("DSA", 1024);
-        VALIDATE_KEYS[1] = TestUtils.getPublicKey("RSA", 512);
+        VALIDATE_KEYS[1] = TestUtils.getPublicKey("RSA", 2048);
         VALIDATE_KEYS[2] = new SecretKeySpec(new byte[16], "HmacSHA1");
         defSi = createSignedInfo(SIG_METHODS[0]);
         defKi = kifac.newKeyInfo
diff --git a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyValueTest.java b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyValueTest.java
index 8e8cf3f0..4ab7388f 100644
--- a/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyValueTest.java
+++ b/src/test/java/javax/xml/crypto/test/dsig/keyinfo/KeyValueTest.java
@@ -48,7 +48,7 @@ public class KeyValueTest {
         keys = new PublicKey[ALGOS.length];
 
         for (int i = 0; i < ALGOS.length; i++) {
-            keys[i] = genPublicKey(ALGOS[i], 512);
+            keys[i] = genPublicKey(ALGOS[i], 2048);
         }
     }