finished last of the compile errors
authoradam <adam@megacz.com>
Mon, 12 Apr 2004 03:12:54 +0000 (03:12 +0000)
committeradam <adam@megacz.com>
Mon, 12 Apr 2004 03:12:54 +0000 (03:12 +0000)
darcs-hash:20040412031254-5007d-cbff51f85df65c2e15eb6f99a8cb6222882dd13c.gz

src/org/ibex/crypto/DER.java
src/org/ibex/crypto/Digest.java
src/org/ibex/crypto/HMAC.java
src/org/ibex/crypto/MD2.java
src/org/ibex/crypto/MD5.java
src/org/ibex/crypto/RSA.java
src/org/ibex/crypto/SHA1.java
src/org/ibex/crypto/X509.java
src/org/ibex/net/SSL.java
src/org/ibex/net/ssl/GenCompactCAList.java
src/org/ibex/net/ssl/SwingVerifyCallback.java

index 6e3ca1a..c313bd9 100644 (file)
@@ -19,7 +19,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * AUTHORS OR COPYRIGHT HOLDER.S BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
  * DEALINGS IN THE SOFTWARE.
@@ -33,25 +33,25 @@ import java.util.*;
 import java.math.BigInteger;
 
 public class DER {
-    public class Null {
+    public static class Null {
         final static Null instance = new Null();
         private Null() { /* noop */ }
         public boolean equals(Object o) { return o == this; }
     }
 
-    public class TaggedObject {
+    public static class TaggedObject {
         public final Object object;
         public final int tag;
         public TaggedObject(int tag, Object object) { this.tag = tag; this.object = object; }
     }
 
-    public class UnknownObject {
+    public static class UnknownObject {
         public final byte[] data;
         public final int tag;
         public UnknownObject(int tag,byte[] data) { this.tag = tag; this.data = data; }
     }
 
-    public class BitString {
+    public static class BitString {
         public final int paddingBits;
         public final byte[] data;
     
@@ -61,11 +61,11 @@ public class DER {
         }
     }
 
-    public class Exception extends java.io.IOException {
+    public static class Exception extends java.io.IOException {
         public Exception(String s) { super(s); }
     }
 
-    public class InputStream extends FilterInputStream {
+    public static class InputStream extends FilterInputStream {
         private static final int MAX_OBJECT_SIZE = 4*1024*1024;
     
         private int limit;
@@ -73,8 +73,8 @@ public class DER {
         private int pos;
         public int getPos() { return pos; }
     
-        public InputStream(InputStream is) { this(is,-1); } 
-        public InputStream(InputStream is, int limit) {
+        public InputStream(java.io.InputStream is) { this(is,-1); } 
+        public InputStream(java.io.InputStream is, int limit) {
             super(is);
             this.limit = limit;
         }
index 3b71fe8..c487ae8 100644 (file)
@@ -14,7 +14,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * AUTHORS OR COPYRIGHT HOLDER.S BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
  * DEALINGS IN THE SOFTWARE.
@@ -26,108 +26,63 @@ package org.ibex.crypto;
  * base implementation of MD4 family style digest as outlined in
  * "Handbook of Applied Cryptography", pages 344 - 347.
  */
-abstract class Digest
-{
+public abstract class Digest {
     private byte[]  xBuf;
     private int     xBufOff;
-
     private long    byteCount;
 
-    /**
-     * Standard constructor
-     */
-    protected Digest()
-    {
-        xBuf = new byte[4];
-        xBufOff = 0;
-    }
-
-    public void update(
-        byte in)
-    {
+    protected Digest() { xBuf = new byte[4]; xBufOff = 0; }
+    public void update(byte in) {
         xBuf[xBufOff++] = in;
-
-        if (xBufOff == xBuf.length)
-        {
+        if (xBufOff == xBuf.length) {
             processWord(xBuf, 0);
             xBufOff = 0;
         }
-
         byteCount++;
     }
 
-    public void update(
-        byte[]  in,
-        int     inOff,
-        int     len)
-    {
-        //
+    public void update(byte[] in, int inOff, int len) {
         // fill the current word
-        //
-        while ((xBufOff != 0) && (len > 0))
-        {
+        while ((xBufOff != 0) && (len > 0)) {
             update(in[inOff]);
-
             inOff++;
             len--;
         }
 
-        //
         // process whole words.
-        //
-        while (len > xBuf.length)
-        {
+        while (len > xBuf.length) {
             processWord(in, inOff);
-
             inOff += xBuf.length;
             len -= xBuf.length;
             byteCount += xBuf.length;
         }
 
-        //
         // load in the remainder.
-        //
-        while (len > 0)
-        {
+        while (len > 0) {
             update(in[inOff]);
-
             inOff++;
             len--;
         }
     }
 
-    protected void finish()
-    {
+    protected void finish() {
         long    bitLength = (byteCount << 3);
-
-        //
         // add the pad bytes.
-        //
         update((byte)128);
-
-        while (xBufOff != 0)
-        {
-            update((byte)0);
-        }
-
+        while (xBufOff != 0) update((byte)0);
         processLength(bitLength);
-
         processBlock();
     }
 
-    public void reset()
-    {
+    public void reset() {
         byteCount = 0;
-
         xBufOff = 0;
-        for ( int i = 0; i < xBuf.length; i++ ) {
-            xBuf[i] = 0;
-        }
+        for ( int i = 0; i < xBuf.length; i++) xBuf[i] = 0;
     }
 
     protected abstract void processWord(byte[] in, int inOff);
-
     protected abstract void processLength(long bitLength);
-
     protected abstract void processBlock();
+    public abstract int getDigestSize();
+    public abstract void doFinal(byte[] out, int outOff);
 }
index d7da4c8..22fb126 100644 (file)
@@ -35,4 +35,7 @@ public class HMAC extends Digest {
         h.doFinal(out,off);
         reset();
     }
+    protected void processWord(byte[] in, int inOff) {}
+    protected void processLength(long bitLength) {}
+    protected void processBlock() {}
 }
index 700824c..1f546a2 100644 (file)
@@ -14,7 +14,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * AUTHORS OR COPYRIGHT HOLDER.S BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
  * DEALINGS IN THE SOFTWARE.
@@ -25,18 +25,18 @@ package org.ibex.crypto;
 /* implementation of MD2
  * as outlined in RFC1319 by B.Kaliski from RSA Laboratories April 1992
  */
-public class MD2 implements Digest
+public class MD2 extends Digest
 {
     private static final int DIGEST_LENGTH = 16;
 
     /* X buffer */
     private byte[]   X = new byte[48];
     private int     xOff;
-\r    /* M buffer */
-\r    private byte[]   M = new byte[16];
+    /* M buffer */
+    private byte[]   M = new byte[16];
     private int     mOff;
-\r    /* check sum */
-\r    private byte[]   C = new byte[16];
+    /* check sum */
+    private byte[]   C = new byte[16];
     //private int COff;
 
     public MD2()
@@ -227,4 +227,9 @@ public class MD2 implements Digest
       (byte)237,(byte)31,(byte)26,(byte)219,(byte)153,(byte)141,(byte)51,
       (byte)159,(byte)17,(byte)131,(byte)20
     };
+
+
+    protected void processWord(byte[] in, int inOff) {}
+    protected void processLength(long bitLength) {}
+    protected void processBlock() {}
 }
index 1aa50da..66f79b0 100644 (file)
@@ -14,7 +14,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * AUTHORS OR COPYRIGHT HOLDER.S BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
  * DEALINGS IN THE SOFTWARE.
index 1740d1b..bc15cef 100644 (file)
@@ -1,5 +1,6 @@
 package org.ibex.crypto;
 import java.math.BigInteger;
+import java.util.*;
 
 public class RSA {
     private final BigInteger pq;
index 234a8b8..ab1af7e 100644 (file)
@@ -14,7 +14,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * AUTHORS OR COPYRIGHT HOLDER.S BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
  * DEALINGS IN THE SOFTWARE.
index 2c1326d..c283aaf 100644 (file)
@@ -19,7 +19,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+ * AUTHORS OR COPYRIGHT HOLDER.S BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
  * DEALINGS IN THE SOFTWARE.
@@ -45,20 +45,20 @@ public class X509 {
     
         public final Number version;    
         public final Number serialNo;
-        public final X509Name issuer;
+        public final X509.Name issuer;
         public final Date startDate;
         public final Date endDate;
-        public final X509Name subject;
+        public final X509.Name subject;
     
         public final AlgorithmIdentifier publicKeyAlgorithm;
-        public final DERBitString publicKey;
+        public final DER.BitString publicKey;
     
         public final Object issuerUniqueID;
         public final Object subjectUniqueID;
     
         public final Vector extensions;
     
-        public final DERBitString signature;
+        public final DER.BitString signature;
         public final AlgorithmIdentifier signatureAlgorithm;
     
         public final BC basicContraints;
@@ -67,41 +67,41 @@ public class X509 {
         public Certificate(InputStream is) throws IOException {
             int i;
             RecordingInputStream certIS = new RecordingInputStream(is);
-            DERInputStream certSequence = new DERInputStream(certIS).getSequenceStream();
+            DER.InputStream certSequence = new DER.InputStream(certIS).getSequenceStream();
             RecordingInputStream tbsCertIS = new RecordingInputStream(certSequence);
         
             try {
-                Vector tbsSequence = (Vector) new DERInputStream(tbsCertIS).readObject();
+                Vector tbsSequence = (Vector) new DER.InputStream(tbsCertIS).readObject();
                 tbsCertBytes = tbsCertIS.getBytes();
                 signatureAlgorithm = new AlgorithmIdentifier(certSequence.readObject());
-                signature = (DERBitString) certSequence.readObject();
+                signature = (DER.BitString) certSequence.readObject();
             
                 i=0;
-                if(tbsSequence.elementAt(i) instanceof DERTaggedObject)
-                    version = (Number)((DERTaggedObject)tbsSequence.elementAt(i++)).object;
+                if(tbsSequence.elementAt(i) instanceof DER.TaggedObject)
+                    version = (Number)((DER.TaggedObject)tbsSequence.elementAt(i++)).object;
                 else
                     version = new Integer(0);
             
                 serialNo = (Number) tbsSequence.elementAt(i++);
                 AlgorithmIdentifier signatureAlgorithm2 = new AlgorithmIdentifier(tbsSequence.elementAt(i++));
                 if(!signatureAlgorithm2.equals(signatureAlgorithm))
-                    throw new DERException("AlgoritmIdentifier mismatch " + signatureAlgorithm + " vs " + signatureAlgorithm2);
-                issuer = new X509Name(tbsSequence.elementAt(i++));
+                    throw new DER.Exception("AlgoritmIdentifier mismatch " + signatureAlgorithm + " vs " + signatureAlgorithm2);
+                issuer = new X509.Name(tbsSequence.elementAt(i++));
             
                 Vector validity = (Vector) tbsSequence.elementAt(i++);
                 startDate = (Date) validity.elementAt(0);
                 endDate = (Date) validity.elementAt(1);
             
-                subject = new X509Name(tbsSequence.elementAt(i++));
+                subject = new X509.Name(tbsSequence.elementAt(i++));
             
                 Vector publicKeyInfo = (Vector) tbsSequence.elementAt(i++);
                 publicKeyAlgorithm = new AlgorithmIdentifier(publicKeyInfo.elementAt(0));
-                publicKey = (DERBitString) publicKeyInfo.elementAt(1);
+                publicKey = (DER.BitString) publicKeyInfo.elementAt(1);
           
                 Object issuerUniqueID_=null,subjectUniqueID_=null;
                 Vector extensions_=null;
                 for(;i < tbsSequence.size();i++) {
-                    DERTaggedObject to = (DERTaggedObject) tbsSequence.elementAt(i);
+                    DER.TaggedObject to = (DER.TaggedObject) tbsSequence.elementAt(i);
                     switch(to.tag) {
                         case 1: issuerUniqueID_ = to.object; break;
                         case 2: subjectUniqueID_ = to.object; break;
@@ -120,52 +120,52 @@ public class X509 {
                         String oid = (String) extension.elementAt(0);
                         byte[] data = (byte[]) extension.elementAt(extension.size()-1);
                         if(oid.equals(BASIC_CONSTRAINTS))
-                            bc = new BC(new DERInputStream(new ByteArrayInputStream(data)).readObject());
+                            bc = new BC(new DER.InputStream(new ByteArrayInputStream(data)).readObject());
                     }
                 }
                 basicContraints = bc;
             } catch(RuntimeException e) {
                 e.printStackTrace();
-                throw new DERException("Invalid x509 Certificate");
+                throw new DER.Exception("Invalid x509 Certificate");
             }
             certBytes = certIS.getBytes();
         }
     
     
         public String getSubjectField(String fieldID) { return subject.get(fieldID); }
-        public String getCN() { return getSubjectField(X509Name.CN); }
+        public String getCN() { return getSubjectField(X509.Name.CN); }
     
         public boolean isValid() {
             Date now = new Date();
             return !now.after(endDate) && !now.before(startDate);
         }
     
-        public RSAPublicKey getRSAPublicKey() throws DERException {
-            if(!RSA_ENCRYPTION.equals(publicKeyAlgorithm.id)) throw new DERException("This isn't an RSA public key");
+        public RSA.PublicKey getRSAPublicKey() throws DER.Exception {
+            if(!RSA_ENCRYPTION.equals(publicKeyAlgorithm.id)) throw new DER.Exception("This isn't an RSA public key");
             try {
-                return new RSAPublicKey(new DERInputStream(new ByteArrayInputStream(publicKey.data)).readObject());
+                return new RSA.PublicKey(new DER.InputStream(new ByteArrayInputStream(publicKey.data)).readObject());
             } catch(IOException e) {
-                throw new DERException(e.getMessage());
+                throw new DER.Exception(e.getMessage());
             } catch(RuntimeException e) {
-                throw new DERException("Invalid RSA Public Key " + e.getMessage());
+                throw new DER.Exception("Invalid RSA Public Key " + e.getMessage());
             }
         }
     
-        public boolean isSignedBy(Certificate signer) throws DERException {
+        public boolean isSignedBy(Certificate signer) throws DER.Exception {
             return isSignedWith(signer.getRSAPublicKey());
         }
-        public boolean isSignedWith(RSAPublicKey rsapk) throws DERException {
+        public boolean isSignedWith(RSA.PublicKey rsapk) throws DER.Exception {
             try {
                 Digest digest;
                 if(signatureAlgorithm.id.equals(MD5_WITH_RSA_ENCRYPTION)) digest = new MD5();
                 else if(signatureAlgorithm.id.equals(SHA1_WITH_RSA_ENCRYPTION)) digest = new SHA1();
                 else if(signatureAlgorithm.id.equals(MD2_WITH_RSA_ENCRYPTION)) digest = new MD2();
-                else throw new DERException("Unknown signing algorithm: " + signatureAlgorithm.id);
+                else throw new DER.Exception("Unknown signing algorithm: " + signatureAlgorithm.id);
                         
                 PKCS1 pkcs1 = new PKCS1(new RSA(rsapk.modulus,rsapk.exponent,true));
                 byte[] d = pkcs1.decode(signature.data);
             
-                Vector v = (Vector) new DERInputStream(new ByteArrayInputStream(d)).readObject();
+                Vector v = (Vector) new DER.InputStream(new ByteArrayInputStream(d)).readObject();
                 byte[] signedDigest = (byte[]) v.elementAt(1);
                             
                 if(signedDigest.length != digest.getDigestSize()) return false;
@@ -246,7 +246,7 @@ public class X509 {
           System.err.println("Start Date: " + cert.startDate);
           System.err.println("End Date: " + cert.endDate);
           System.err.println("SHA1 Fingerprint: " + prettyBytes(cert.getSHA1Fingerprint()));
-          RSAPublicKey key = cert.getRSAPublicKey();
+          RSA.PublicKey key = cert.getRSA.PublicKey();
           System.err.println("Modulus: " + prettyBytes(key.modulus.toByteArray()));
           System.err.println("Exponent: " + key.exponent);
           System.err.println("Signature: " + prettyBytes(cert.signature.data));
@@ -278,7 +278,7 @@ public class X509 {
         private final Vector keys = new Vector();
         private final Vector values = new Vector();
     
-        public Name(Object seq_) throws DERException {
+        public Name(Object seq_) throws DER.Exception {
             try {
                 Vector seq = (Vector) seq_;
                 for(Enumeration e = seq.elements();e.hasMoreElements();) {
@@ -288,7 +288,7 @@ public class X509 {
                 }
             } catch(RuntimeException e) {
                 e.printStackTrace();
-                throw new DERException("Invalid Name " + e.toString());
+                throw new DER.Exception("Invalid Name " + e.toString());
             }
         }
     
index 7078e81..04519cd 100644 (file)
 
 package org.ibex.net;
 
-import org.ibex.der.DER.Exception;
-import org.ibex.der.DER.InputStream;
-import org.ibex.x509.X509Certificate;
-import org.ibex.x509.RSAPublicKey;
-import org.ibex.x509.X509Name;
-import org.ibex.crypto.HMAC;
-import org.ibex.crypto.PKCS1;
-import org.ibex.crypto.RC4;
-import org.ibex.crypto.RSA;
-import org.ibex.crypto.Digest;
-import org.ibex.crypto.MD5;
-import org.ibex.crypto.SHA1;
-
+import org.ibex.crypto.*;
 import java.security.SecureRandom;
 
 import java.net.Socket;
@@ -183,7 +171,7 @@ public class SSL extends Socket {
     }
     
     private void negotiateNew() throws IOException {
-        X509Certificate[] certs = receiveServerCertificates();
+        X509.Certificate[] certs = receiveServerCertificates();
         debug("got Certificate");
         
         boolean gotCertificateRequest = false;
@@ -309,7 +297,7 @@ public class SSL extends Socket {
         if(buf[p++] != 0x0) throw new Exn("unsupported compression " + buf[p-1]);
     }
     
-    private X509Certificate[] receiveServerCertificates() throws IOException {
+    private X509.Certificate[] receiveServerCertificates() throws IOException {
         byte[] buf = readHandshake();
         if(buf[0] != 11) throw new Exn("expected a Certificate message");
         if((((buf[4]&0xff)<<16)|((buf[5]&0xff)<<8)|((buf[6]&0xff)<<0)) != buf.length-7) throw new Exn("size mismatch in Certificate message");
@@ -318,21 +306,21 @@ public class SSL extends Socket {
         
         for(int i=p;i<buf.length-3;i+=((buf[p+0]&0xff)<<16)|((buf[p+1]&0xff)<<8)|((buf[p+2]&0xff)<<0)) count++;
         if(count == 0) throw new Exn("server didn't provide any certificates");
-        X509Certificate[] certs = new X509Certificate[count];
+        X509.Certificate[] certs = new X509.Certificate[count];
         count = 0;
         while(p < buf.length) {
             int len = ((buf[p+0]&0xff)<<16)|((buf[p+1]&0xff)<<8)|((buf[p+2]&0xff)<<0);
             p += 3;
             if(p + len > buf.length) throw new Exn("Certificate message cut short");
-            certs[count++] = new X509Certificate(new ByteArrayInputStream(buf,p,len));
+            certs[count++] = new X509.Certificate(new ByteArrayInputStream(buf,p,len));
             p += len;
         }
         return certs;
     }
     
-    private void sendClientKeyExchange(X509Certificate serverCert) throws IOException {
+    private void sendClientKeyExchange(X509.Certificate serverCert) throws IOException {
         byte[] encryptedPreMasterSecret;
-        RSAPublicKey pks = serverCert.getRSAPublicKey();
+        RSA.PublicKey pks = serverCert.getRSAPublicKey();
         PKCS1 pkcs1 = new PKCS1(new RSA(pks.modulus,pks.exponent,false),random);
         encryptedPreMasterSecret = pkcs1.encode(preMasterSecret);
         byte[] buf;
@@ -733,7 +721,7 @@ public class SSL extends Socket {
         return ret;
     }
 
-    public static class SSLv3HMAC implements Digest {
+    public static class SSLv3HMAC extends Digest {
         private final Digest h;
         private final byte[] digest;
         private final byte[] key;
@@ -766,6 +754,9 @@ public class SSL extends Socket {
             h.doFinal(out,off);
             reset();
         }
+        protected void processWord(byte[] in, int inOff) {}
+        protected void processLength(long bitLength) {}
+        protected void processBlock() {}
     }
     
     //
@@ -907,7 +898,7 @@ public class SSL extends Socket {
     private static void debug(Object o) { if(debugOn) System.err.println("[BriSSL-Debug] " + o.toString()); }
     private static void log(Object o) { System.err.println("[BriSSL] " + o.toString()); }
             
-    private static void verifyCerts(X509Certificate[] certs) throws DER.Exception, Exn {
+    private static void verifyCerts(X509.Certificate[] certs) throws DER.Exception, Exn {
         try {
             verifyCerts_(certs);
         } catch(RuntimeException e) {
@@ -916,14 +907,14 @@ public class SSL extends Socket {
         }
     }
     
-    private static void verifyCerts_(X509Certificate[] certs) throws DER.Exception, Exn {
+    private static void verifyCerts_(X509.Certificate[] certs) throws DER.Exception, Exn {
         boolean ignoreLast = false;
         for(int i=0;i<certs.length;i++) {
             debug("Cert " + i + ": " + certs[i].subject + " ok");
             if(!certs[i].isValid())
                 throw new Exn("Certificate " + i + " in certificate chain is not valid (" + certs[i].startDate + " - " + certs[i].endDate + ")");
             if(i != 0) {
-                X509Certificate.BC bc = certs[i].basicContraints;
+                X509.Certificate.BC bc = certs[i].basicContraints;
                 if(bc == null) {
                     if(i == certs.length - 1) {
                         ignoreLast = true;
@@ -943,18 +934,18 @@ public class SSL extends Socket {
             }
         }
         
-        X509Certificate cert = certs[ignoreLast ? certs.length - 2 : certs.length-1];
+        X509.Certificate cert = certs[ignoreLast ? certs.length - 2 : certs.length-1];
         
-        RSAPublicKey pks = (RSAPublicKey) caKeys.get(cert.issuer);
+        RSA.PublicKey pks = (RSA.PublicKey) caKeys.get(cert.issuer);
         if(pks == null) throw new Exn("Certificate is signed by an unknown CA (" + cert.issuer + ")");
         if(!cert.isSignedWith(pks)) throw new Exn("Certificate is not signed by its CA");
         log("" + cert.subject + " is signed by " + cert.issuer);
     }
     
     public static void addCACert(byte[] b) throws IOException { addCACert(new ByteArrayInputStream(b)); }
-    public static void addCACert(InputStream is) throws IOException { addCACert(new X509Certificate(is)); }
-    public static void addCACert(X509Certificate cert) throws DER.Exception { addCAKey(cert.subject,cert.getRSAPublicKey()); }
-    public static void addCAKey(X509Name subject, RSAPublicKey pks)  {
+    public static void addCACert(InputStream is) throws IOException { addCACert(new X509.Certificate(is)); }
+    public static void addCACert(X509.Certificate cert) throws DER.Exception { addCAKey(cert.subject,cert.getRSAPublicKey()); }
+    public static void addCAKey(X509.Name subject, RSA.PublicKey pks)  {
         synchronized(caKeys) {
             if(caKeys.get(subject) != null)
                 throw new IllegalArgumentException(subject.toString() + " already exists!");
@@ -986,8 +977,8 @@ public class SSL extends Socket {
                 Vector seq = (Vector) new DER.InputStream(is).readObject();
                 for(Enumeration e = seq.elements(); e.hasMoreElements();) {
                     Vector seq2 = (Vector) e.nextElement();
-                    X509Name subject = new X509Name(seq2.elementAt(0));
-                    RSAPublicKey pks = new RSAPublicKey(seq2.elementAt(1));
+                    X509.Name subject = new X509.Name(seq2.elementAt(0));
+                    RSA.PublicKey pks = new RSA.PublicKey(seq2.elementAt(1));
                     addCAKey(subject,pks);
                 }
                 return seq.size();
@@ -1011,7 +1002,7 @@ public class SSL extends Socket {
     }
     
     public interface VerifyCallback {
-        public boolean checkCerts(X509Certificate[] certs, String hostname, Exn exn);
+        public boolean checkCerts(X509.Certificate[] certs, String hostname, Exn exn);
     }
     
     // Helper methods
index 51dd29e..e15a194 100644 (file)
@@ -9,24 +9,24 @@ public class GenCompactCAList {
     public static void main(String[] args) throws Exception {
         if(args.length < 2) throw new Exception("Usage: GenCAList format file(s)");
         String format = args[0];
-        DEREncodableVector vec = new DEREncodableVector();
+        DER.EncodableVector vec = new DEREncodableVector();
         for(int i=1;i<args.length;i++) {
-            X509CertificateStructure x509 = new X509CertificateStructure((ASN1Sequence) new ASN1InputStream(new FileInputStream(args[i])).readObject());
-            X509Name subject = x509.getSubject();
+            X509.CertificateStructure x509 = new X509.CertificateStructure((ASN1Sequence) new ASN1InputStream(new FileInputStream(args[i])).readObject());
+            X509.Name subject = x509.getSubject();
             SubjectPublicKeyInfo pki = x509.getSubjectPublicKeyInfo();
-            RSAPublicKeyStructure rsa = new RSAPublicKeyStructure((ASN1Sequence) pki.getPublicKey());
-            DEREncodableVector vec2 = new DEREncodableVector();
+            RSA.PublicKeyStructure rsa = new RSA.PublicKeyStructure((ASN1Sequence) pki.getPublicKey());
+            DER.EncodableVector vec2 = new DEREncodableVector();
             vec2.add(subject);
             vec2.add(rsa);
             vec.add(new DERSequence(vec2));
         }
         if(format.equals("binary")) {
-            DEROutputStream dos = new DEROutputStream(System.out);
+            DER.OutputStream dos = new DEROutputStream(System.out);
             dos.writeObject(new DERSequence(vec));
             dos.close();
         } else if(format.equals("class")){
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            DEROutputStream dos = new DEROutputStream(baos);
+            DER.OutputStream dos = new DEROutputStream(baos);
             dos.writeObject(new DERSequence(vec));
             dos.close();
             baos.close();            
index 3d2d5bb..832ef2f 100644 (file)
@@ -5,7 +5,7 @@ import javax.swing.*;
 import java.awt.*;
 
 import org.ibex.net.SSL;
-import org.ibex.x509.X509Certificate;
+import org.ibex.crypto.*;
 
 public class SwingVerifyCallback extends JDialog implements SSL.VerifyCallback {
     private Component owner;
@@ -53,7 +53,7 @@ public class SwingVerifyCallback extends JDialog implements SSL.VerifyCallback {
         return sb.toString();
     }
     
-    public synchronized boolean checkCerts(X509Certificate[] certs, String hostname, SSL.Exn exn) {
+    public synchronized boolean checkCerts(X509.Certificate[] certs, String hostname, SSL.Exn exn) {
         final boolean[] ret = new boolean[1];
         JTextArea ta = new JTextArea();
         ta.append("Subject: " + certs[0].subject + "\n");