[Webfunds-commits] java/webfunds/sox Crypto.java

Jeroen C. van Gelderen gelderen@cypherpunks.ai
Sat, 29 Jul 2000 13:15:34 -0400 (AST)


gelderen    00/07/29 13:15:34

  Modified:    webfunds/sox Crypto.java
  Log:
  Hack. Will be fixed with the move to JCE.
  
  Ensure all returned PublicKey objects are compatible with Cryptix 3.
  Cryptix 3 can only work with subclasses of PublicKey that it knows.

Revision  Changes    Path
1.40      +10 -3     java/webfunds/sox/Crypto.java

Index: Crypto.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/Crypto.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- Crypto.java	2000/07/21 21:31:18	1.39
+++ Crypto.java	2000/07/29 17:15:33	1.40
@@ -1,4 +1,4 @@
-/* $Id: Crypto.java,v 1.39 2000/07/21 21:31:18 gelderen Exp $
+/* $Id: Crypto.java,v 1.40 2000/07/29 17:15:33 gelderen Exp $
  *
  * Copyright (c) Systemics Inc. 1995-2000 on behalf of
  * The WebFunds Development Team.  All Rights Reserved.
@@ -50,7 +50,7 @@
  *
  * Centralized crypto methods. Currently being overhauled.
  *
- * @version $Revision: 1.39 $
+ * @version $Revision: 1.40 $
  */
 public final class Crypto
 {
@@ -162,7 +162,7 @@
      */
     public static PublicKey getPublicKeyFromCert(Certificate cert)
     {
-        return cert.getPublicKey();
+        return toCryptixKey( cert.getPublicKey() );
     }
 
 
@@ -1258,6 +1258,13 @@
 
     // XXX: move out of Certificate.java. Can go for JCE 1.2
     private static PublicKey toCryptixKey(PublicKey pk) {
+
+        /*
+         * Don't do conversion when the key is a Cryptix RAW-encoded key.
+         */
+        if( pk.getFormat().equals("RAW") )
+            return pk;
+
         try {
             AsnInputStream is = new AsnInputStream(pk.getEncoded());
             AsnSequence seq = (AsnSequence)is.read();