Package org.conscrypt
Class OpenSSLMessageDigestJDK
- java.lang.Object
-
- java.security.MessageDigestSpi
-
- org.conscrypt.OpenSSLMessageDigestJDK
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
OpenSSLMessageDigestJDK.MD5
,OpenSSLMessageDigestJDK.SHA1
,OpenSSLMessageDigestJDK.SHA224
,OpenSSLMessageDigestJDK.SHA256
,OpenSSLMessageDigestJDK.SHA384
,OpenSSLMessageDigestJDK.SHA512
@Internal public class OpenSSLMessageDigestJDK extends java.security.MessageDigestSpi implements java.lang.Cloneable
Implements the JDK MessageDigest interface using OpenSSL's EVP API.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OpenSSLMessageDigestJDK.MD5
static class
OpenSSLMessageDigestJDK.SHA1
static class
OpenSSLMessageDigestJDK.SHA224
static class
OpenSSLMessageDigestJDK.SHA256
static class
OpenSSLMessageDigestJDK.SHA384
static class
OpenSSLMessageDigestJDK.SHA512
-
Field Summary
Fields Modifier and Type Field Description private NativeRef.EVP_MD_CTX
ctx
private boolean
digestInitializedInContext
Whether the digest struct has been initialized inside EVP_MD_CTX.private long
evp_md
Holds the EVP_MD for the hashing algorithm, e.g.private byte[]
singleByte
Holds a dummy buffer for writing single bytes to the digest.private int
size
Holds the output size of the message digest.
-
Constructor Summary
Constructors Modifier Constructor Description private
OpenSSLMessageDigestJDK(long evp_md, int size)
Creates a new OpenSSLMessageDigest instance for the given algorithm name.private
OpenSSLMessageDigestJDK(long evp_md, int size, NativeRef.EVP_MD_CTX ctx, boolean digestInitializedInContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
protected byte[]
engineDigest()
protected int
engineGetDigestLength()
protected void
engineReset()
protected void
engineUpdate(byte input)
protected void
engineUpdate(byte[] input, int offset, int len)
protected void
engineUpdate(java.nio.ByteBuffer input)
private void
ensureDigestInitializedInContext()
-
-
-
Field Detail
-
ctx
private final NativeRef.EVP_MD_CTX ctx
-
evp_md
private final long evp_md
Holds the EVP_MD for the hashing algorithm, e.g. EVP_get_digestbyname("sha1");
-
size
private final int size
Holds the output size of the message digest.
-
singleByte
private final byte[] singleByte
Holds a dummy buffer for writing single bytes to the digest.
-
digestInitializedInContext
private boolean digestInitializedInContext
Whether the digest struct has been initialized inside EVP_MD_CTX.
-
-
Constructor Detail
-
OpenSSLMessageDigestJDK
private OpenSSLMessageDigestJDK(long evp_md, int size) throws java.security.NoSuchAlgorithmException
Creates a new OpenSSLMessageDigest instance for the given algorithm name.- Throws:
java.security.NoSuchAlgorithmException
-
OpenSSLMessageDigestJDK
private OpenSSLMessageDigestJDK(long evp_md, int size, NativeRef.EVP_MD_CTX ctx, boolean digestInitializedInContext)
-
-
Method Detail
-
ensureDigestInitializedInContext
private void ensureDigestInitializedInContext()
-
engineReset
protected void engineReset()
- Specified by:
engineReset
in classjava.security.MessageDigestSpi
-
engineGetDigestLength
protected int engineGetDigestLength()
- Overrides:
engineGetDigestLength
in classjava.security.MessageDigestSpi
-
engineUpdate
protected void engineUpdate(byte input)
- Specified by:
engineUpdate
in classjava.security.MessageDigestSpi
-
engineUpdate
protected void engineUpdate(byte[] input, int offset, int len)
- Specified by:
engineUpdate
in classjava.security.MessageDigestSpi
-
engineUpdate
protected void engineUpdate(java.nio.ByteBuffer input)
- Overrides:
engineUpdate
in classjava.security.MessageDigestSpi
-
engineDigest
protected byte[] engineDigest()
- Specified by:
engineDigest
in classjava.security.MessageDigestSpi
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classjava.security.MessageDigestSpi
-
-