From 8aa540d2f783474d1d2e06f16744bf67b9c1facc Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 10 Mar 2006 21:46:48 +0000 Subject: Imported GNU Classpath 0.90 Imported GNU Classpath 0.90 * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore. * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant. * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5. * java/lang/Math.java: New override file. * java/lang/Character.java: Merged from Classpath. (start, end): Now 'int's. (canonicalName): New field. (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants. (UnicodeBlock): Added argument. (of): New overload. (forName): New method. Updated unicode blocks. (sets): Updated. * sources.am: Regenerated. * Makefile.in: Likewise. From-SVN: r111942 --- .../javax/crypto/EncryptedPrivateKeyInfo.java | 41 ++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) (limited to 'libjava/classpath/javax/crypto') diff --git a/libjava/classpath/javax/crypto/EncryptedPrivateKeyInfo.java b/libjava/classpath/javax/crypto/EncryptedPrivateKeyInfo.java index a52d7b1..0fddd54 100644 --- a/libjava/classpath/javax/crypto/EncryptedPrivateKeyInfo.java +++ b/libjava/classpath/javax/crypto/EncryptedPrivateKeyInfo.java @@ -92,6 +92,9 @@ public class EncryptedPrivateKeyInfo /** The OID of the encryption algorithm. */ private OID algOid; + /** The encryption algorithm name. */ + private String algName; + /** The encryption algorithm's parameters. */ private AlgorithmParameters params; @@ -125,7 +128,8 @@ public class EncryptedPrivateKeyInfo throw new IllegalArgumentException("0-length encryptedData"); } this.params = params; - algOid = new OID(params.getAlgorithm()); + algName = params.getAlgorithm (); + algOid = getOid (algName); this.encryptedData = (byte[]) encryptedData.clone(); } @@ -168,10 +172,36 @@ public class EncryptedPrivateKeyInfo { throw new IllegalArgumentException("0-length encryptedData"); } - this.algOid = new OID(algName); + this.algName = algName.toString (); // do NP check + this.algOid = getOid (algName); this.encryptedData = (byte[]) encryptedData.clone(); } + /** + * Return the OID for the given cipher name. + * + * @param str The string. + * @throws NoSuchAlgorithmException If the OID is not known. + */ + private static OID getOid (final String str) + throws NoSuchAlgorithmException + { + if (str.equalsIgnoreCase ("DSA")) + { + return new OID ("1.2.840.10040.4.3"); + } + // FIXME add more + + try + { + return new OID (str); + } + catch (Throwable t) + { + } + throw new NoSuchAlgorithmException ("cannot determine OID for '" + str + "'"); + } + // Instance methods. // ------------------------------------------------------------------------ @@ -196,6 +226,7 @@ public class EncryptedPrivateKeyInfo } catch (NoSuchAlgorithmException ignore) { + // FIXME throw exception? } catch (IOException ignore) { @@ -272,7 +303,11 @@ public class EncryptedPrivateKeyInfo getAlgParameters(); if (params != null) { - algId.add(DERReader.read(params.getEncoded())); + algId.add (DERReader.read (params.getEncoded())); + } + else + { + algId.add (new DERValue (DER.NULL, null)); } List epki = new ArrayList(2); epki.add(new DERValue(DER.CONSTRUCTED|DER.SEQUENCE, algId)); -- cgit v1.1