hello there,

this is a patch that fixes a wrong OID string used in GnuDSAPublicKey 
and replaces OID strings use in both the DSA and RSA public and private 
keys (under the gnu.java.secuity.provider hierarchy by their Registry 
equivalent.

ChangeLog entry is:

2006-02-06  Raif S. Naffah  <[EMAIL PROTECTED]>

        * gnu/java/security/provider/GnuDSAPublicKey.java (getEncoded): Use
        Registry constant.
        * gnu/java/security/provider/GnuDSAPrivateKey.java (getEncoded):
        Likewise.
        * gnu/java/security/provider/GnuRSAPrivateKey.java (getEncoded):
        Likewise.
        * gnu/java/security/provider/GnuRSAPublicKey.java (getEncoded):
        Likewise.
        * gnu/java/security/provider/EncodedKeyFactory.java
        (ID_DSA): Redefined in terms of Registry constant.
        (ID_DSA): Redefined in terms of Registry constant.
        (ID_DH): Redefined in terms of Registry constant.
        * gnu/java/security/Registry.java (X509_ENCODING): New constant.
        (PKCS8_ENCODING): Likewise.
        (ASN1_ENCODING): Likewise.
        (RAW_ENCODING_SHORT_NAME): Likewise.
        (X509_ENCODING_SORT_NAME): Likewise.
        (PKCS8_ENCODING_SHORT_NAME): Likewise.
        (ASN1_ENCODING_SHORT_NAME): Likewise.
        (X509_ENCODING_ID): Likewise.
        (PKCS8_ENCODING_ID): Likewise.
        (ASN1_ENCODING_ID): Likewise.
        (DSA_OID_STRING): Likewise.
        (RSA_OID_STRING): Likewise.
        (DH_OID_STRING): Likewise.


ok to commit?

 
cheers;
rsn
Index: EncodedKeyFactory.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/provider/EncodedKeyFactory.java,v
retrieving revision 1.4
diff -u -r1.4 EncodedKeyFactory.java
--- EncodedKeyFactory.java	2 Jul 2005 20:32:14 -0000	1.4
+++ EncodedKeyFactory.java	6 Feb 2006 09:16:45 -0000
@@ -39,6 +39,7 @@
 package gnu.java.security.provider;

 import gnu.java.security.OID;
+import gnu.java.security.Registry;
 import gnu.java.security.der.BitString;
 import gnu.java.security.der.DERReader;
 import gnu.java.security.der.DERValue;
@@ -75,9 +76,9 @@
   // Constants.
   // ------------------------------------------------------------------------

-  private static final OID ID_DSA = new OID("1.2.840.10040.4.1");
-  private static final OID ID_RSA = new OID("1.2.840.113549.1.1.1");
-  private static final OID ID_DH  = new OID("1.2.840.10046.2.1");
+  private static final OID ID_DSA = new OID(Registry.DSA_OID_STRING);
+  private static final OID ID_RSA = new OID(Registry.RSA_OID_STRING);
+  private static final OID ID_DH  = new OID(Registry.DH_OID_STRING);

   // Instance methods.
   // ------------------------------------------------------------------------
Index: GnuDSAPrivateKey.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/provider/GnuDSAPrivateKey.java,v
retrieving revision 1.7
diff -u -r1.7 GnuDSAPrivateKey.java
--- GnuDSAPrivateKey.java	2 Jul 2005 20:32:14 -0000	1.7
+++ GnuDSAPrivateKey.java	6 Feb 2006 09:17:12 -0000
@@ -39,6 +39,7 @@
 package gnu.java.security.provider;

 import gnu.java.security.OID;
+import gnu.java.security.Registry;
 import gnu.java.security.der.DER;
 import gnu.java.security.der.DERValue;
 import gnu.java.security.der.DERWriter;
@@ -110,7 +111,7 @@
         pki.add(new DERValue(DER.INTEGER, BigInteger.ZERO));
         ArrayList algId = new ArrayList(2);
         algId.add(new DERValue(DER.OBJECT_IDENTIFIER,
-                  new OID("1.2.840.10040.4.1")));
+                               new OID(Registry.DSA_OID_STRING)));
         ArrayList algParams = new ArrayList(3);
         algParams.add(new DERValue(DER.INTEGER, p));
         algParams.add(new DERValue(DER.INTEGER, q));
Index: GnuDSAPublicKey.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/provider/GnuDSAPublicKey.java,v
retrieving revision 1.7
diff -u -r1.7 GnuDSAPublicKey.java
--- GnuDSAPublicKey.java	2 Jul 2005 20:32:14 -0000	1.7
+++ GnuDSAPublicKey.java	6 Feb 2006 09:17:33 -0000
@@ -39,6 +39,7 @@
 package gnu.java.security.provider;

 import gnu.java.security.OID;
+import gnu.java.security.Registry;
 import gnu.java.security.der.BitString;
 import gnu.java.security.der.DER;
 import gnu.java.security.der.DERValue;
@@ -97,7 +98,7 @@
         ArrayList spki = new ArrayList(2);
         ArrayList alg = new ArrayList(2);
         alg.add(new DERValue(DER.OBJECT_IDENTIFIER,
-                new OID("1.2.840.113549.1.1.1")));
+                             new OID(Registry.DSA_OID_STRING)));
         ArrayList params = new ArrayList(3);
         params.add(new DERValue(DER.INTEGER, p));
         params.add(new DERValue(DER.INTEGER, q));
Index: Registry.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/security/Registry.java,v
retrieving revision 1.2
diff -u -r1.2 Registry.java
--- Registry.java	28 Jan 2006 02:47:57 -0000	1.2
+++ Registry.java	6 Feb 2006 09:17:59 -0000
@@ -263,9 +263,28 @@
   //   String TMMH32 = "tmmh32";

   // Format IDs used to identify how we externalise asymmetric keys ..........
+  // fully-qualified names of the supported codecs
   String RAW_ENCODING = "gnu.crypto.raw.format";
+  String X509_ENCODING = "gnu.crypto.x509.format";
+  String PKCS8_ENCODING = "gnu.crypto.pkcs8.format";
+  String ASN1_ENCODING = "gnu.crypto.asn1.format";
+
+  // short names of the same.  used by JCE adapters
+  String RAW_ENCODING_SHORT_NAME = "RAW";
+  String X509_ENCODING_SORT_NAME = "X.509";
+  String PKCS8_ENCODING_SHORT_NAME = "PKCS#8";
+  String ASN1_ENCODING_SHORT_NAME = "ASN.1";

+  // unique identifiers of the same
   int RAW_ENCODING_ID = 1;
+  int X509_ENCODING_ID = 2;
+  int PKCS8_ENCODING_ID = 3;
+  int ASN1_ENCODING_ID = 4;
+
+  // OID strings used in encoding/decoding keys
+  String DSA_OID_STRING = "1.2.840.10040.4.1";
+  String RSA_OID_STRING = "1.2.840.113549.1.1.1";
+  String DH_OID_STRING =  "1.2.840.10046.2.1";

   // Magic bytes we generate/expect in externalised asymmetric keys ..........
   // the four bytes represent G (0x47) for GNU, 1 (0x01) for Raw format,

Attachment: pgpzYn38kOAnA.pgp
Description: PGP signature

Reply via email to