OpenSSLMessageDigestJDKpublic class OpenSSLMessageDigestJDK extends MessageDigest Implements the JDK MessageDigest interface using OpenSSL's EVP API. |
Fields Summary |
---|
private int | ctxHolds a pointer to the native message digest context. | private byte[] | singleByteHolds a dummy buffer for writing single bytes to the digest. |
Constructors Summary |
---|
private OpenSSLMessageDigestJDK(String algorithm)Creates a new OpenSSLMessageDigest instance for the given algorithm
name.
super(algorithm);
ctx = NativeCrypto.EVP_new();
try {
NativeCrypto.EVP_DigestInit(ctx, getAlgorithm().replace("-", "").toLowerCase());
} catch (Exception ex) {
throw new NoSuchAlgorithmException(ex.getMessage() + " (" + algorithm + ")");
}
|
Methods Summary |
---|
protected byte[] | engineDigest()
byte[] result = new byte[NativeCrypto.EVP_DigestSize(ctx)];
NativeCrypto.EVP_DigestFinal(ctx, result, 0);
engineReset();
return result;
| protected int | engineGetDigestLength()
return NativeCrypto.EVP_DigestSize(ctx);
| protected void | engineReset()
NativeCrypto.EVP_DigestInit(ctx, getAlgorithm().replace("-", "").toLowerCase());
| protected void | engineUpdate(byte input)
singleByte[0] = input;
engineUpdate(singleByte, 0, 1);
| protected void | engineUpdate(byte[] input, int offset, int len)
NativeCrypto.EVP_DigestUpdate(ctx, input, offset, len);
| protected void | finalize()
super.finalize();
NativeCrypto.EVP_free(ctx);
| public static org.apache.harmony.xnet.provider.jsse.OpenSSLMessageDigestJDK | getInstance(java.lang.String algorithm)Creates a new OpenSSLMessageDigestJDK instance for the given algorithm
name.
return new OpenSSLMessageDigestJDK(algorithm);
|
|