summaryrefslogtreecommitdiffstats
path: root/bcprov
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2014-02-25 14:51:56 -0800
committerKenny Root <kroot@google.com>2014-02-25 14:54:34 -0800
commitbab34fd43afe55e6eae70a6467e61cef7f79008e (patch)
tree46e11a0cf1a3b68129c34288e7d2b2de8aa22516 /bcprov
parent684e45f9b88f911c3a39aa2e2d2b559c7b1c0074 (diff)
downloadandroid_external_bouncycastle-bab34fd43afe55e6eae70a6467e61cef7f79008e.tar.gz
android_external_bouncycastle-bab34fd43afe55e6eae70a6467e61cef7f79008e.tar.bz2
android_external_bouncycastle-bab34fd43afe55e6eae70a6467e61cef7f79008e.zip
OpenSSLDigest needs to be ExtendedDigest
BcKeyStoreSpi requires an ExtendedDigest to be able to see what byte length the output is before calling it. Change-Id: Ibcade36a96d222d48b933883f9f1d653aca627f0
Diffstat (limited to 'bcprov')
-rw-r--r--bcprov/src/main/java/org/bouncycastle/crypto/digests/OpenSSLDigest.java29
1 files changed, 19 insertions, 10 deletions
diff --git a/bcprov/src/main/java/org/bouncycastle/crypto/digests/OpenSSLDigest.java b/bcprov/src/main/java/org/bouncycastle/crypto/digests/OpenSSLDigest.java
index 2846725..5aa1eec 100644
--- a/bcprov/src/main/java/org/bouncycastle/crypto/digests/OpenSSLDigest.java
+++ b/bcprov/src/main/java/org/bouncycastle/crypto/digests/OpenSSLDigest.java
@@ -16,19 +16,24 @@
package org.bouncycastle.crypto.digests;
-import org.bouncycastle.crypto.Digest;
+import org.bouncycastle.crypto.ExtendedDigest;
+import org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi;
import java.security.DigestException;
import java.security.MessageDigest;
/**
- * Implements the BouncyCastle Digest interface using OpenSSL's EVP API.
+ * Implements the BouncyCastle Digest interface using OpenSSL's EVP API. This
+ * must be an ExtendedDigest for {@link BcKeyStoreSpi} to be able to use it.
*/
-public class OpenSSLDigest implements Digest {
+public class OpenSSLDigest implements ExtendedDigest {
private final MessageDigest delegate;
- public OpenSSLDigest(String algorithm) {
+ private final int byteSize;
+
+ public OpenSSLDigest(String algorithm, int byteSize) {
try {
delegate = MessageDigest.getInstance(algorithm, "AndroidOpenSSL");
+ this.byteSize = byteSize;
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -42,6 +47,10 @@ public class OpenSSLDigest implements Digest {
return delegate.getDigestLength();
}
+ public int getByteLength() {
+ return byteSize;
+ }
+
public void reset() {
delegate.reset();
}
@@ -63,26 +72,26 @@ public class OpenSSLDigest implements Digest {
}
public static class MD5 extends OpenSSLDigest {
- public MD5() { super("MD5"); }
+ public MD5() { super("MD5", 64); }
}
public static class SHA1 extends OpenSSLDigest {
- public SHA1() { super("SHA-1"); }
+ public SHA1() { super("SHA-1", 64); }
}
public static class SHA224 extends OpenSSLDigest {
- public SHA224() { super("SHA-224"); }
+ public SHA224() { super("SHA-224", 64); }
}
public static class SHA256 extends OpenSSLDigest {
- public SHA256() { super("SHA-256"); }
+ public SHA256() { super("SHA-256", 64); }
}
public static class SHA384 extends OpenSSLDigest {
- public SHA384() { super("SHA-384"); }
+ public SHA384() { super("SHA-384", 128); }
}
public static class SHA512 extends OpenSSLDigest {
- public SHA512() { super("SHA-512"); }
+ public SHA512() { super("SHA-512", 128); }
}
}