Add (provisional) entries for RSASHA256 and RSASHA512.

git-svn-id: https://svn.verisignlabs.com/jdnssec/tools/trunk@121 4cbd57fe-54e5-0310-bd9a-f30fe5ea5e6e
This commit is contained in:
David Blacka 2009-02-05 05:02:29 +00:00
parent 32b0f15b70
commit 49dfddb432

View File

@ -122,6 +122,17 @@ public class DnsKeyAlgorithm
// Load the (now) standard aliases // Load the (now) standard aliases
addAlias(6, "DSA-NSEC3-SHA1", DNSSEC.DSA); addAlias(6, "DSA-NSEC3-SHA1", DNSSEC.DSA);
addAlias(7, "RSA-NSEC3-SHA1", DNSSEC.RSASHA1); addAlias(7, "RSA-NSEC3-SHA1", DNSSEC.RSASHA1);
// And the hopefully-soon-to-be standard new RSA algorithms.
// see http://tools.ietf.org/wg/dnsext/draft-ietf-dnsext-dnssec-rsasha256
// NOTE: the algorithm numbers are educated guesses.
// Also NOTE: these algorithms aren't available in Java 1.4's sunprovider
// implementation.
addAlgorithm(8, new Entry("SHA256withRSA", RSA));
addMnemonic("RSASHA256", 8);
addAlgorithm(9, new Entry("SHA512withRSA", RSA));
addMnemonic("RSASHA512", 9);
} }
private void addAlgorithm(int algorithm, Entry entry) private void addAlgorithm(int algorithm, Entry entry)
@ -215,14 +226,14 @@ public class DnsKeyAlgorithm
{ {
switch (baseType(algorithm)) switch (baseType(algorithm))
{ {
case RSA: case RSA:
return DNSSEC.RSASHA1; return DNSSEC.RSASHA1;
case DSA: case DSA:
return DNSSEC.DSA; return DNSSEC.DSA;
case DH: case DH:
return DNSSEC.DH; return DNSSEC.DH;
default: default:
return UNKNOWN; return UNKNOWN;
} }
} }
@ -237,46 +248,46 @@ public class DnsKeyAlgorithm
KeyPair pair = null; KeyPair pair = null;
switch (baseType(algorithm)) switch (baseType(algorithm))
{ {
case RSA: case RSA:
if (mRSAKeyGenerator == null) if (mRSAKeyGenerator == null)
{ {
mRSAKeyGenerator = KeyPairGenerator.getInstance("RSA"); mRSAKeyGenerator = KeyPairGenerator.getInstance("RSA");
} }
RSAKeyGenParameterSpec rsa_spec; RSAKeyGenParameterSpec rsa_spec;
if (useLargeExp) if (useLargeExp)
{ {
rsa_spec = new RSAKeyGenParameterSpec(keysize, rsa_spec = new RSAKeyGenParameterSpec(keysize,
RSAKeyGenParameterSpec.F4); RSAKeyGenParameterSpec.F4);
} }
else else
{ {
rsa_spec = new RSAKeyGenParameterSpec(keysize, rsa_spec = new RSAKeyGenParameterSpec(keysize,
RSAKeyGenParameterSpec.F0); RSAKeyGenParameterSpec.F0);
} }
try try
{ {
mRSAKeyGenerator.initialize(rsa_spec); mRSAKeyGenerator.initialize(rsa_spec);
} }
catch (InvalidAlgorithmParameterException e) catch (InvalidAlgorithmParameterException e)
{ {
// Fold the InvalidAlgorithmParameterException into our existing // Fold the InvalidAlgorithmParameterException into our existing
// thrown exception. Ugly, but requires less code change. // thrown exception. Ugly, but requires less code change.
throw new NoSuchAlgorithmException("invalid key parameter spec"); throw new NoSuchAlgorithmException("invalid key parameter spec");
} }
pair = mRSAKeyGenerator.generateKeyPair(); pair = mRSAKeyGenerator.generateKeyPair();
break; break;
case DSA: case DSA:
if (mDSAKeyGenerator == null) if (mDSAKeyGenerator == null)
{ {
mDSAKeyGenerator = KeyPairGenerator.getInstance("DSA"); mDSAKeyGenerator = KeyPairGenerator.getInstance("DSA");
} }
mDSAKeyGenerator.initialize(keysize); mDSAKeyGenerator.initialize(keysize);
pair = mDSAKeyGenerator.generateKeyPair(); pair = mDSAKeyGenerator.generateKeyPair();
break; break;
default: default:
throw new NoSuchAlgorithmException("Alg " + algorithm); throw new NoSuchAlgorithmException("Alg " + algorithm);
} }
return pair; return pair;