Search in sources :

Example 26 with Digest

use of org.bouncycastle.crypto.Digest in project rpki-validator-3 by RIPE-NCC.

the class Sha256 method hash.

public static byte[] hash(InputStream in) throws IOException {
    Digest digest = new SHA256Digest();
    byte[] data = new byte[8192];
    int len;
    while ((len = in.read(data)) >= 0) {
        digest.update(data, 0, len);
    }
    byte[] result = new byte[digest.getDigestSize()];
    digest.doFinal(result, 0);
    return result;
}
Also used : Digest(org.bouncycastle.crypto.Digest) SHA256Digest(org.bouncycastle.crypto.digests.SHA256Digest) SHA256Digest(org.bouncycastle.crypto.digests.SHA256Digest)

Example 27 with Digest

use of org.bouncycastle.crypto.Digest in project rpki-validator-3 by RIPE-NCC.

the class Sha256 method hash.

public static byte[] hash(InputStream in) throws IOException {
    Digest digest = new SHA256Digest();
    byte[] data = new byte[8192];
    int len;
    while ((len = in.read(data)) >= 0) {
        digest.update(data, 0, len);
    }
    byte[] result = new byte[digest.getDigestSize()];
    digest.doFinal(result, 0);
    return result;
}
Also used : Digest(org.bouncycastle.crypto.Digest) SHA256Digest(org.bouncycastle.crypto.digests.SHA256Digest) SHA256Digest(org.bouncycastle.crypto.digests.SHA256Digest)

Example 28 with Digest

use of org.bouncycastle.crypto.Digest in project vsDiaryWriter by shilongdai.

the class BCDigester method digest.

@Override
public byte[] digest(byte[] text) {
    Digest dig = Digesters.getDigester(mode);
    byte[] data = new byte[dig.getDigestSize()];
    for (byte i : text) {
        dig.update(i);
    }
    dig.doFinal(data, 0);
    return data;
}
Also used : Digest(org.bouncycastle.crypto.Digest)

Example 29 with Digest

use of org.bouncycastle.crypto.Digest in project netty by netty.

the class Digester method sha1.

public static DigestCalculator sha1() {
    Digest digest = new SHA1Digest();
    AlgorithmIdentifier algId = new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1);
    return new Digester(digest, algId);
}
Also used : Digest(org.bouncycastle.crypto.Digest) SHA1Digest(org.bouncycastle.crypto.digests.SHA1Digest) SHA256Digest(org.bouncycastle.crypto.digests.SHA256Digest) SHA1Digest(org.bouncycastle.crypto.digests.SHA1Digest) AlgorithmIdentifier(org.bouncycastle.asn1.x509.AlgorithmIdentifier)

Example 30 with Digest

use of org.bouncycastle.crypto.Digest in project netty by netty.

the class Digester method sha256.

public static DigestCalculator sha256() {
    Digest digest = new SHA256Digest();
    // The OID for SHA-256: http://www.oid-info.com/get/2.16.840.1.101.3.4.2.1
    ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier("2.16.840.1.101.3.4.2.1").intern();
    AlgorithmIdentifier algId = new AlgorithmIdentifier(oid);
    return new Digester(digest, algId);
}
Also used : Digest(org.bouncycastle.crypto.Digest) SHA1Digest(org.bouncycastle.crypto.digests.SHA1Digest) SHA256Digest(org.bouncycastle.crypto.digests.SHA256Digest) SHA256Digest(org.bouncycastle.crypto.digests.SHA256Digest) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) AlgorithmIdentifier(org.bouncycastle.asn1.x509.AlgorithmIdentifier)

Aggregations

Digest (org.bouncycastle.crypto.Digest)31 SHA256Digest (org.bouncycastle.crypto.digests.SHA256Digest)9 SHA1Digest (org.bouncycastle.crypto.digests.SHA1Digest)8 MGF1ParameterSpec (java.security.spec.MGF1ParameterSpec)5 RSABlindedEngine (org.bouncycastle.crypto.engines.RSABlindedEngine)5 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)4 OAEPEncoding (org.bouncycastle.crypto.encodings.OAEPEncoding)4 InvalidParameterException (java.security.InvalidParameterException)3 BigInteger (java.math.BigInteger)2 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)2 InvalidKeyException (java.security.InvalidKeyException)2 SecureRandom (java.security.SecureRandom)2 RSAPrivateKey (java.security.interfaces.RSAPrivateKey)2 RSAPublicKey (java.security.interfaces.RSAPublicKey)2 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)2 OAEPParameterSpec (javax.crypto.spec.OAEPParameterSpec)2 CipherParameters (org.bouncycastle.crypto.CipherParameters)2 DSAParameters (org.bouncycastle.crypto.params.DSAParameters)2 DSAValidationParameters (org.bouncycastle.crypto.params.DSAValidationParameters)2 ParametersWithRandom (org.bouncycastle.crypto.params.ParametersWithRandom)2