Example usage for org.bouncycastle.crypto.digests KeccakDigest getDigestSize

List of usage examples for org.bouncycastle.crypto.digests KeccakDigest getDigestSize

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.digests KeccakDigest getDigestSize.

Prototype

public int getDigestSize() 

Source Link

Usage

From source file:org.ethereum.crypto.Keccak256Helper.java

License:Open Source License

private static byte[] keccak256(byte[] message, int start, int length, KeccakDigest digest,
        boolean bouncyencoder) {
    byte[] hash = new byte[digest.getDigestSize()];

    if (message.length != 0) {
        digest.update(message, start, length);
    }/*from ww w  .j  a v  a  2  s .c  om*/
    digest.doFinal(hash, 0);
    return hash;
}

From source file:org.ethereum.crypto.Keccak256Helper.java

License:Open Source License

private static byte[] doKeccak256(byte[] message, KeccakDigest digest, boolean bouncyencoder) {
    byte[] hash = new byte[digest.getDigestSize()];

    if (message.length != 0) {
        digest.update(message, 0, message.length);
    }//from www  .j  av a 2s. co  m
    digest.doFinal(hash, 0);
    return hash;
}

From source file:org.ethereum.crypto.Keccak256Helper.java

License:Open Source License

private static byte[] doKeccak256(byte[] m1, byte[] m2, KeccakDigest digest, boolean bouncyencoder) {
    byte[] hash = new byte[digest.getDigestSize()];
    digest.update(m1, 0, m1.length);/*from  w ww  .j a va 2s .co  m*/
    digest.update(m2, 0, m2.length);

    digest.doFinal(hash, 0);
    return hash;
}

From source file:org.ethereum.net.rlpx.FrameCodec.java

License:Open Source License

private byte[] updateMac(KeccakDigest mac, byte[] seed, int offset, byte[] out, int outOffset, boolean egress)
        throws IOException {
    byte[] aesBlock = new byte[mac.getDigestSize()];
    doSum(mac, aesBlock);//from  www .  jav a2 s .  c  o m
    makeMacCipher().processBlock(aesBlock, 0, aesBlock, 0);
    // Note that although the mac digest size is 32 bytes, we only use 16 bytes in the computation
    int length = 16;
    for (int i = 0; i < length; i++) {
        aesBlock[i] ^= seed[i + offset];
    }
    mac.update(aesBlock, 0, length);
    byte[] result = new byte[mac.getDigestSize()];
    doSum(mac, result);
    if (egress) {
        System.arraycopy(result, 0, out, outOffset, length);
    } else {
        for (int i = 0; i < length; i++) {
            if (out[i + outOffset] != result[i]) {
                throw new IOException("MAC mismatch");
            }
        }
    }
    return result;
}

From source file:uk.co.platosys.dinigma.Digester.java

License:GNU General Public License

/**Takes a byte array and returns a string which is
 * the Base64 encoded version the digest.
 * This uses SHA3-512 as the digest algorithm.
 *
 * *//*from w ww . jav a2s  . c  om*/
public static String digest(byte[] bytes) throws MinigmaException {
    try {
        KeccakDigest digest = new SHA3Digest(512);
        for (byte byt : bytes) {
            digest.update(byt);
        }
        byte[] digested = new byte[digest.getDigestSize()];
        digest.doFinal(digested, 0);
        return (MinigmaUtils.encode(digested));
    } catch (Exception e) {

        throw new MinigmaException("error making digest", e);
    }
}