[Webfunds-commits] java/webfunds/sox Crypto.java
Edwin Woudt
edwin@cypherpunks.ai
Mon, 7 Aug 2000 23:30:56 -0400 (AST)
edwin 00/08/07 23:30:56
Modified: webfunds/sox Crypto.java
Log:
Support for converting OpenPGP RSA keys to a RawRSAPublicKey that webfunds
understands.
Revision Changes Path
1.46 +14 -2 java/webfunds/sox/Crypto.java
Index: Crypto.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/Crypto.java,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- Crypto.java 2000/08/03 00:59:17 1.45
+++ Crypto.java 2000/08/08 03:30:55 1.46
@@ -1,4 +1,4 @@
-/* $Id: Crypto.java,v 1.45 2000/08/03 00:59:17 gelderen Exp $
+/* $Id: Crypto.java,v 1.46 2000/08/08 03:30:55 edwin Exp $
*
* Copyright (c) Systemics Inc. 1995-2000 on behalf of
* The WebFunds Development Team. All Rights Reserved.
@@ -27,6 +27,7 @@
import java.security.cert.Certificate;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPublicKey;
+import java.security.spec.RSAPublicKeySpec;
import java.util.Date;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@@ -38,6 +39,9 @@
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
+import cryptix.openpgp.PGPPublicKey;
+import cryptix.openpgp.algorithm.PGPRSA;
+
import cryptix.provider.key.RawSecretKey;
import cryptix.provider.rsa.RawRSAPrivateKey;
import cryptix.provider.rsa.RawRSAPublicKey;
@@ -58,7 +62,7 @@
*
* Centralized crypto methods. Currently being overhauled.
*
- * @version $Revision: 1.45 $
+ * @version $Revision: 1.46 $
*/
public final class Crypto
{
@@ -1102,6 +1106,14 @@
return new RawRSAPublicKey(n, e);
}
+ if( pk.getFormat().equals("OpenPGP") ) {
+ PGPPublicKey pgppk = (PGPPublicKey)pk;
+ PGPRSA pgprsa = (PGPRSA)pgppk.getSigner();
+ RSAPublicKeySpec rsapubspec = pgprsa.getRSAPublicKeySpec();
+ BigInteger n = rsapubspec.getModulus();
+ BigInteger e = rsapubspec.getPublicExponent();
+ return new RawRSAPublicKey(n, e);
+ }
try {
AsnInputStream is = new AsnInputStream(pk.getEncoded());