Example usage for org.bouncycastle.crypto Digest digest

List of usage examples for org.bouncycastle.crypto Digest digest

Introduction

In this page you can find the example usage for org.bouncycastle.crypto Digest digest.

Prototype

digest

Source Link

Usage

From source file:com.github.capone.protocol.crypto.SymmetricKey.java

License:Open Source License

protected static SymmetricKey fromScalarMultiplication(PrivateKey sk, PublicKey pk, boolean localKeyFirst)
        throws InvalidKeyException {
    byte[] scalarmult = new byte[SodiumConstants.SCALAR_BYTES];
    Sodium.crypto_scalarmult_curve25519(scalarmult, sk.toBytes(), pk.toBytes());

    Digest digest = new Digest();
    digest.update(scalarmult);/*  ww  w  . j  a v  a  2s .  co m*/
    if (localKeyFirst) {
        digest.update(sk.getPublicKey().toBytes());
        digest.update(pk.toBytes());
    } else {
        digest.update(pk.toBytes());
        digest.update(sk.getPublicKey().toBytes());
    }

    return SymmetricKey.fromBytes(digest.digest());
}