Package org.bouncycastle2.crypto

Examples of org.bouncycastle2.crypto.Digest


            CipherOutputStream  cOut = new CipherOutputStream(dOut, cipher);
            DigestOutputStream  dgOut = new DigestOutputStream(cOut, new SHA1Digest());
   
            this.saveStore(dgOut);
   
            Digest  dig = dgOut.getDigest();
            byte[]  hash = new byte[dig.getDigestSize()];
   
            dig.doFinal(hash, 0);
   
            cOut.write(hash);
   
            cOut.close();
        }
View Full Code Here


     */
    private DSAParameters generateParameters_FIPS186_3()
    {
// A.1.1.2 Generation of the Probable Primes p and q Using an Approved Hash Function
        // FIXME This should be configurable (digest size in bits must be >= N)
        Digest d = new SHA256Digest();
        int outlen = d.getDigestSize() * 8;

// 1. Check that the (L, N) pair is in the list of acceptable (L, N pairs) (see Section 4.2). If
//    the pair is not in the list, then return INVALID.
        // Note: checked at initialisation

// 2. If (seedlen < N), then return INVALID.
        // FIXME This should be configurable (must be >= N)
        int seedlen = N;
        byte[] seed = new byte[seedlen / 8];

// 3. n = ⎡L ⁄ outlen⎤ – 1.
        int n = (L - 1) / outlen;

// 4. b = L – 1 – (n ∗ outlen).
        int b = (L - 1) % outlen;

        byte[] output = new byte[d.getDigestSize()];
        for (;;)
        {
// 5. Get an arbitrary sequence of seedlen bits as the domain_parameter_seed.
            random.nextBytes(seed);

View Full Code Here

        return new SubjectKeyIdentifier(id);
    }

    private static byte[] getDigest(SubjectPublicKeyInfo spki)
    {
        Digest digest = new SHA1Digest();
        byte[]  resBuf = new byte[digest.getDigestSize()];

        byte[] bytes = spki.getPublicKeyData().getBytes();
        digest.update(bytes, 0, bytes.length);
        digest.doFinal(resBuf, 0);
        return resBuf;
    }
View Full Code Here

        {
            return new SHA1Digest();
        }
        if (md5.contains(digestName))
        {
            return new MD5Digest();
        }
        if (sha224.contains(digestName))
        {
            return new SHA224Digest();
        }
View Full Code Here

    static public class RIPEMD256WithRSAEncryption
        extends JDKDigestSignature
    {
        public RIPEMD256WithRSAEncryption()
        {
            super(TeleTrusTObjectIdentifiers.ripemd256, new RIPEMD256Digest(), new PKCS1Encoding(new RSABlindedEngine()));
        }
View Full Code Here

    {
        digestName = Strings.toUpperCase(digestName);
       
        if (sha1.contains(digestName))
        {
            return new SHA1Digest();
        }
        if (md5.contains(digestName))
        {
            return new MD5Digest();
        }
View Full Code Here

        {
            return new MD5Digest();
        }
        if (sha224.contains(digestName))
        {
            return new SHA224Digest();
        }
        if (sha256.contains(digestName))
        {
            return new SHA256Digest();
        }
View Full Code Here

        {
            return new SHA224Digest();
        }
        if (sha256.contains(digestName))
        {
            return new SHA256Digest();
        }
        if (sha384.contains(digestName))
        {
            return new SHA384Digest();
        }
View Full Code Here

        {
            return new SHA256Digest();
        }
        if (sha384.contains(digestName))
        {
            return new SHA384Digest();
        }
        if (sha512.contains(digestName))
        {
            return new SHA512Digest();
        }
View Full Code Here

        {
            return new SHA384Digest();
        }
        if (sha512.contains(digestName))
        {
            return new SHA512Digest();
        }
       
        return null;
    }
View Full Code Here

TOP

Related Classes of org.bouncycastle2.crypto.Digest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.