All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.tls.crypto.impl.jcajce.JcaTlsHash Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java APIs for the TLS, including a JSSE provider. The APIs are designed primarily to be used in conjunction with the BC LTS provider but may also be used with other providers providing cryptographic services.

There is a newer version: 2.73.7
Show newest version
package org.bouncycastle.tls.crypto.impl.jcajce;

import java.security.MessageDigest;

import org.bouncycastle.tls.crypto.TlsHash;

/**
 * Wrapper class for providing support methods for a TlsHash based on the JCA MessageDigest class.
 */
public class JcaTlsHash
    implements TlsHash
{
    private final MessageDigest digest;

    public JcaTlsHash(MessageDigest digest)
    {
        this.digest = digest;
    }

    public void update(byte[] data, int offSet, int length)
    {
        digest.update(data, offSet, length);
    }

    public byte[] calculateHash()
    {
        return digest.digest();
    }

    public TlsHash cloneHash()
    {
        try
        {
            return new JcaTlsHash((MessageDigest)digest.clone());
        }
        catch (CloneNotSupportedException e)
        {
            throw new UnsupportedOperationException("unable to clone digest");
        }
    }

    public void reset()
    {
        digest.reset();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy