OpenSSLMessageDigestpublic class OpenSSLMessageDigest extends Object implements org.bouncycastle.crypto.ExtendedDigestImplements the BouncyCastle Digest interface using OpenSSL's EVP API. |
Fields Summary |
---|
private String | algorithmHolds the name of the hashing algorithm, e.g. "SHA-1"; | 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 OpenSSLMessageDigest(String algorithm)Creates a new OpenSSLMessageDigest instance for the given algorithm
name.
this.algorithm = algorithm;
ctx = NativeCrypto.EVP_new();
try {
NativeCrypto.EVP_DigestInit(ctx, algorithm.replace("-", "").toLowerCase());
} catch (Exception ex) {
throw new RuntimeException(ex.getMessage() + " (" + algorithm + ")");
}
|
Methods Summary |
---|
public int | doFinal(byte[] out, int outOff)
int i = NativeCrypto.EVP_DigestFinal(ctx, out, outOff);
reset();
return i;
| protected void | finalize()
super.finalize();
NativeCrypto.EVP_free(ctx);
| public java.lang.String | getAlgorithmName()
return algorithm;
| public int | getByteLength()
return NativeCrypto.EVP_DigestBlockSize(ctx);
| public int | getDigestSize()
return NativeCrypto.EVP_DigestSize(ctx);
| public static org.apache.harmony.xnet.provider.jsse.OpenSSLMessageDigest | getInstance(java.lang.String algorithm)Creates a new OpenSSLMessageDigest instance for the given algorithm
name.
return new OpenSSLMessageDigest(algorithm);
| public void | reset()
NativeCrypto.EVP_DigestInit(ctx, algorithm.replace("-", "").toLowerCase());
| public void | update(byte in)
singleByte[0] = in;
NativeCrypto.EVP_DigestUpdate(ctx, singleByte, 0, 1);
| public void | update(byte[] in, int inOff, int len)
NativeCrypto.EVP_DigestUpdate(ctx, in, inOff, len);
|
|