Java 类org.bouncycastle.crypto.digests.SHA512Digest 实例源码

项目:ipack    文件:TlsUtils.java   
public static final Digest createHash(int hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest();
    case HashAlgorithm.sha1:
        return new SHA1Digest();
    case HashAlgorithm.sha224:
        return new SHA224Digest();
    case HashAlgorithm.sha256:
        return new SHA256Digest();
    case HashAlgorithm.sha384:
        return new SHA384Digest();
    case HashAlgorithm.sha512:
        return new SHA512Digest();
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:ipack    文件:TlsUtils.java   
public static final Digest cloneHash(int hashAlgorithm, Digest hash)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest((MD5Digest)hash);
    case HashAlgorithm.sha1:
        return new SHA1Digest((SHA1Digest)hash);
    case HashAlgorithm.sha224:
        return new SHA224Digest((SHA224Digest)hash);
    case HashAlgorithm.sha256:
        return new SHA256Digest((SHA256Digest)hash);
    case HashAlgorithm.sha384:
        return new SHA384Digest((SHA384Digest)hash);
    case HashAlgorithm.sha512:
        return new SHA512Digest((SHA512Digest)hash);
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:ipack    文件:DefaultTlsCipherFactory.java   
protected Digest createHMACDigest(int macAlgorithm)
    throws IOException
{
    switch (macAlgorithm)
    {
    case MACAlgorithm._null:
        return null;
    case MACAlgorithm.hmac_md5:
        return new MD5Digest();
    case MACAlgorithm.hmac_sha1:
        return new SHA1Digest();
    case MACAlgorithm.hmac_sha256:
        return new SHA256Digest();
    case MACAlgorithm.hmac_sha384:
        return new SHA384Digest();
    case MACAlgorithm.hmac_sha512:
        return new SHA512Digest();
    default:
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }
}
项目:gwt-crypto    文件:TlsUtils.java   
public static Digest createHash(short hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest();
    case HashAlgorithm.sha1:
        return new SHA1Digest();
    case HashAlgorithm.sha224:
        return new SHA224Digest();
    case HashAlgorithm.sha256:
        return new SHA256Digest();
    case HashAlgorithm.sha384:
        return new SHA384Digest();
    case HashAlgorithm.sha512:
        return new SHA512Digest();
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:gwt-crypto    文件:TlsUtils.java   
public static Digest cloneHash(short hashAlgorithm, Digest hash)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest((MD5Digest)hash);
    case HashAlgorithm.sha1:
        return new SHA1Digest((SHA1Digest)hash);
    case HashAlgorithm.sha224:
        return new SHA224Digest((SHA224Digest)hash);
    case HashAlgorithm.sha256:
        return new SHA256Digest((SHA256Digest)hash);
    case HashAlgorithm.sha384:
        return new SHA384Digest((SHA384Digest)hash);
    case HashAlgorithm.sha512:
        return new SHA512Digest((SHA512Digest)hash);
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:Aki-SSL    文件:TlsUtils.java   
public static Digest createHash(short hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest();
    case HashAlgorithm.sha1:
        return new SHA1Digest();
    case HashAlgorithm.sha224:
        return new SHA224Digest();
    case HashAlgorithm.sha256:
        return new SHA256Digest();
    case HashAlgorithm.sha384:
        return new SHA384Digest();
    case HashAlgorithm.sha512:
        return new SHA512Digest();
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:Aki-SSL    文件:TlsUtils.java   
public static Digest cloneHash(short hashAlgorithm, Digest hash)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest((MD5Digest)hash);
    case HashAlgorithm.sha1:
        return new SHA1Digest((SHA1Digest)hash);
    case HashAlgorithm.sha224:
        return new SHA224Digest((SHA224Digest)hash);
    case HashAlgorithm.sha256:
        return new SHA256Digest((SHA256Digest)hash);
    case HashAlgorithm.sha384:
        return new SHA384Digest((SHA384Digest)hash);
    case HashAlgorithm.sha512:
        return new SHA512Digest((SHA512Digest)hash);
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:TinyTravelTracker    文件:TlsUtils.java   
public static Digest createHash(short hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest();
    case HashAlgorithm.sha1:
        return new SHA1Digest();
    case HashAlgorithm.sha224:
        return new SHA224Digest();
    case HashAlgorithm.sha256:
        return new SHA256Digest();
    case HashAlgorithm.sha384:
        return new SHA384Digest();
    case HashAlgorithm.sha512:
        return new SHA512Digest();
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:TinyTravelTracker    文件:TlsUtils.java   
public static Digest cloneHash(short hashAlgorithm, Digest hash)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest((MD5Digest)hash);
    case HashAlgorithm.sha1:
        return new SHA1Digest((SHA1Digest)hash);
    case HashAlgorithm.sha224:
        return new SHA224Digest((SHA224Digest)hash);
    case HashAlgorithm.sha256:
        return new SHA256Digest((SHA256Digest)hash);
    case HashAlgorithm.sha384:
        return new SHA384Digest((SHA384Digest)hash);
    case HashAlgorithm.sha512:
        return new SHA512Digest((SHA512Digest)hash);
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:HAP-Java    文件:FinalPairHandler.java   
private HttpResponse createUser(byte[] username, byte[] ltpk, byte[] proof) throws Exception {
    HKDFBytesGenerator hkdf = new HKDFBytesGenerator(new SHA512Digest());
    hkdf.init(new HKDFParameters(k, "Pair-Setup-Controller-Sign-Salt".getBytes(StandardCharsets.UTF_8),
            "Pair-Setup-Controller-Sign-Info".getBytes(StandardCharsets.UTF_8)));
    byte[] okm = new byte[32];
    hkdf.generateBytes(okm, 0, 32);

    byte[] completeData = ByteUtils.joinBytes(okm, username, ltpk);

    if (!new EdsaVerifier(ltpk).verify(completeData, proof)) {
        throw new Exception("Invalid signature");
    }
    authInfo.createUser(authInfo.getMac()+new String(username, StandardCharsets.UTF_8), ltpk);
    advertiser.setDiscoverable(false);
    return createResponse();
}
项目:CryptMeme    文件:TlsUtils.java   
public static final Digest createHash(short hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest();
    case HashAlgorithm.sha1:
        return new SHA1Digest();
    case HashAlgorithm.sha224:
        return new SHA224Digest();
    case HashAlgorithm.sha256:
        return new SHA256Digest();
    case HashAlgorithm.sha384:
        return new SHA384Digest();
    case HashAlgorithm.sha512:
        return new SHA512Digest();
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:CryptMeme    文件:TlsUtils.java   
public static final Digest cloneHash(short hashAlgorithm, Digest hash)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest((MD5Digest)hash);
    case HashAlgorithm.sha1:
        return new SHA1Digest((SHA1Digest)hash);
    case HashAlgorithm.sha224:
        return new SHA224Digest((SHA224Digest)hash);
    case HashAlgorithm.sha256:
        return new SHA256Digest((SHA256Digest)hash);
    case HashAlgorithm.sha384:
        return new SHA384Digest((SHA384Digest)hash);
    case HashAlgorithm.sha512:
        return new SHA512Digest((SHA512Digest)hash);
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:CryptMeme    文件:DefaultTlsCipherFactory.java   
protected Digest createHMACDigest(int macAlgorithm) throws IOException
{
    switch (macAlgorithm)
    {
    case MACAlgorithm._null:
        return null;
    case MACAlgorithm.hmac_md5:
        return new MD5Digest();
    case MACAlgorithm.hmac_sha1:
        return new SHA1Digest();
    case MACAlgorithm.hmac_sha256:
        return new SHA256Digest();
    case MACAlgorithm.hmac_sha384:
        return new SHA384Digest();
    case MACAlgorithm.hmac_sha512:
        return new SHA512Digest();
    default:
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }
}
项目:irma_future_id    文件:TlsUtils.java   
public static final Digest createHash(int hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest();
    case HashAlgorithm.sha1:
        return new SHA1Digest();
    case HashAlgorithm.sha224:
        return new SHA224Digest();
    case HashAlgorithm.sha256:
        return new SHA256Digest();
    case HashAlgorithm.sha384:
        return new SHA384Digest();
    case HashAlgorithm.sha512:
        return new SHA512Digest();
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:irma_future_id    文件:TlsUtils.java   
public static final Digest cloneHash(int hashAlgorithm, Digest hash)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest((MD5Digest)hash);
    case HashAlgorithm.sha1:
        return new SHA1Digest((SHA1Digest)hash);
    case HashAlgorithm.sha224:
        return new SHA224Digest((SHA224Digest)hash);
    case HashAlgorithm.sha256:
        return new SHA256Digest((SHA256Digest)hash);
    case HashAlgorithm.sha384:
        return new SHA384Digest((SHA384Digest)hash);
    case HashAlgorithm.sha512:
        return new SHA512Digest((SHA512Digest)hash);
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:irma_future_id    文件:DefaultTlsCipherFactory.java   
protected Digest createHMACDigest(int macAlgorithm) throws IOException
{
    switch (macAlgorithm)
    {
    case MACAlgorithm._null:
        return null;
    case MACAlgorithm.hmac_md5:
        return new MD5Digest();
    case MACAlgorithm.hmac_sha1:
        return new SHA1Digest();
    case MACAlgorithm.hmac_sha256:
        return new SHA256Digest();
    case MACAlgorithm.hmac_sha384:
        return new SHA384Digest();
    case MACAlgorithm.hmac_sha512:
        return new SHA512Digest();
    default:
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }
}
项目:irma_future_id    文件:PSSSignatureSpi.java   
private Digest guessDigest(int size)
{
    switch (size)
    {
    case 20:
        return new SHA1Digest();
    case 28:
        return new SHA224Digest();
    case 32:
        return new SHA256Digest();
    case 48:
        return new SHA384Digest();
    case 64:
        return new SHA512Digest();
    }

    return null;
}
项目:bc-java    文件:TlsUtils.java   
public static final Digest createHash(int hashAlgorithm)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest();
    case HashAlgorithm.sha1:
        return new SHA1Digest();
    case HashAlgorithm.sha224:
        return new SHA224Digest();
    case HashAlgorithm.sha256:
        return new SHA256Digest();
    case HashAlgorithm.sha384:
        return new SHA384Digest();
    case HashAlgorithm.sha512:
        return new SHA512Digest();
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:bc-java    文件:TlsUtils.java   
public static final Digest cloneHash(int hashAlgorithm, Digest hash)
{
    switch (hashAlgorithm)
    {
    case HashAlgorithm.md5:
        return new MD5Digest((MD5Digest)hash);
    case HashAlgorithm.sha1:
        return new SHA1Digest((SHA1Digest)hash);
    case HashAlgorithm.sha224:
        return new SHA224Digest((SHA224Digest)hash);
    case HashAlgorithm.sha256:
        return new SHA256Digest((SHA256Digest)hash);
    case HashAlgorithm.sha384:
        return new SHA384Digest((SHA384Digest)hash);
    case HashAlgorithm.sha512:
        return new SHA512Digest((SHA512Digest)hash);
    default:
        throw new IllegalArgumentException("unknown HashAlgorithm");
    }
}
项目:bc-java    文件:DefaultTlsCipherFactory.java   
protected Digest createHMACDigest(int macAlgorithm)
    throws IOException
{
    switch (macAlgorithm)
    {
    case MACAlgorithm._null:
        return null;
    case MACAlgorithm.hmac_md5:
        return new MD5Digest();
    case MACAlgorithm.hmac_sha1:
        return new SHA1Digest();
    case MACAlgorithm.hmac_sha256:
        return new SHA256Digest();
    case MACAlgorithm.hmac_sha384:
        return new SHA384Digest();
    case MACAlgorithm.hmac_sha512:
        return new SHA512Digest();
    default:
        throw new TlsFatalAlert(AlertDescription.internal_error);
    }
}
项目:bc-java    文件:PSSSignatureSpi.java   
private Digest guessDigest(int size)
{
    switch (size)
    {
    case 20:
        return new SHA1Digest();
    case 28:
        return new SHA224Digest();
    case 32:
        return new SHA256Digest();
    case 48:
        return new SHA384Digest();
    case 64:
        return new SHA512Digest();
    }

    return null;
}
项目:ipack    文件:DigestFactory.java   
public static Digest getDigest(
    String digestName) 
{
    digestName = Strings.toUpperCase(digestName);

    if (sha1.contains(digestName))
    {
        return new SHA1Digest();
    }
    if (md5.contains(digestName))
    {
        return new MD5Digest();
    }
    if (sha224.contains(digestName))
    {
        return new SHA224Digest();
    }
    if (sha256.contains(digestName))
    {
        return new SHA256Digest();
    }
    if (sha384.contains(digestName))
    {
        return new SHA384Digest();
    }
    if (sha512.contains(digestName))
    {
        return new SHA512Digest();
    }

    return null;
}
项目:ipack    文件:SHA512.java   
public Object clone()
    throws CloneNotSupportedException
{
    Digest d = (Digest)super.clone();
    d.digest = new SHA512Digest((SHA512Digest)digest);

    return d;
}
项目:xitk    文件:DSAParameterCache.java   
public static DSAParameterSpec getNewDSAParameterSpec(int plength, int qlength,
        SecureRandom random) {
    final int certainty = 80;
    SecureRandom tmpRandom = (random == null) ? new SecureRandom() : random;
    DSAParametersGenerator paramGen = new DSAParametersGenerator(new SHA512Digest());
    DSAParameterGenerationParameters genParams = new DSAParameterGenerationParameters(
            plength, qlength, certainty, tmpRandom);
    paramGen.init(genParams);
    DSAParameters dsaParams = paramGen.generateParameters();
    return new DSAParameterSpec(dsaParams.getP(), dsaParams.getQ(), dsaParams.getG());
}
项目:gwt-crypto    文件:BcImplProvider.java   
static Digest createDigest(int algorithm)
    throws PGPException
{
    switch (algorithm)
    {
    case HashAlgorithmTags.SHA1:
        return new SHA1Digest();
    case HashAlgorithmTags.SHA224:
        return new SHA224Digest();
    case HashAlgorithmTags.SHA256:
        return new SHA256Digest();
    case HashAlgorithmTags.SHA384:
        return new SHA384Digest();
    case HashAlgorithmTags.SHA512:
        return new SHA512Digest();
    case HashAlgorithmTags.MD2:
        return new MD2Digest();
    case HashAlgorithmTags.MD5:
        return new MD5Digest();
    case HashAlgorithmTags.RIPEMD160:
        return new RIPEMD160Digest();
    case HashAlgorithmTags.TIGER_192:
        return new TigerDigest();
    default:
        throw new PGPException("cannot recognise digest");
    }
}
项目:vsDiaryWriter    文件:Digesters.java   
private static void initDigesters() {
    digesters.put("Blake2b", Blake2bDigest.class);
    digesters.put("GOST3411", GOST3411Digest.class);
    digesters.put("Keccak", KeccakDigest.class);
    digesters.put("MD2", MD2Digest.class);
    digesters.put("MD4", MD4Digest.class);
    digesters.put("MD5", MD5Digest.class);
    digesters.put("RIPEMD128", RIPEMD128Digest.class);
    digesters.put("RIPEMD160", RIPEMD160Digest.class);
    digesters.put("RIPEMD256", RIPEMD256Digest.class);
    digesters.put("RIPEMD320", RIPEMD320Digest.class);
    digesters.put("SHA1", SHA1Digest.class);
    digesters.put("SHA224", SHA224Digest.class);
    digesters.put("SHA256", SHA256Digest.class);
    digesters.put("SHA384", SHA384Digest.class);
    digesters.put("SHA3-512", SHA3Digest.class);
    digesters.put("SHA3-256", SHA3Digest.class);
    digesters.put("SHA3-224", SHA3Digest.class);
    digesters.put("SHA3-384", SHA3Digest.class);
    digesters.put("SHA512", SHA512Digest.class);
    digesters.put("SHAKE-128", SHAKEDigest.class);
    digesters.put("SHAKE-256", SHAKEDigest.class);
    digesters.put("Skein256", SkeinDigest.class);
    digesters.put("Skein512", SkeinDigest.class);
    digesters.put("Skein1024", SkeinDigest.class);
    digesters.put("SM3", SM3Digest.class);
    digesters.put("Tiger", TigerDigest.class);
    digesters.put("Whirlpool", WhirlpoolDigest.class);
}
项目:Aki-SSL    文件:DigestFactory.java   
public static Digest getDigest(
    String digestName) 
{
    digestName = Strings.toUpperCase(digestName);

    if (sha1.contains(digestName))
    {
        return new SHA1Digest();
    }
    if (md5.contains(digestName))
    {
        return new MD5Digest();
    }
    if (sha224.contains(digestName))
    {
        return new SHA224Digest();
    }
    if (sha256.contains(digestName))
    {
        return new SHA256Digest();
    }
    if (sha384.contains(digestName))
    {
        return new SHA384Digest();
    }
    if (sha512.contains(digestName))
    {
        return new SHA512Digest();
    }
    if (sha512_224.contains(digestName))
    {
        return new SHA512tDigest(224);
    }
    if (sha512_256.contains(digestName))
    {
        return new SHA512tDigest(256);
    }

    return null;
}
项目:Aki-SSL    文件:SHA512.java   
public Object clone()
    throws CloneNotSupportedException
{
    Digest d = (Digest)super.clone();
    d.digest = new SHA512Digest((SHA512Digest)digest);

    return d;
}
项目:secrete    文件:Curve25519PrivateKey.java   
private static byte[] deriveKey(char[] password, byte[] salt) throws UnsupportedEncodingException {

        // generate key using PBKDF2
        PKCS5S2ParametersGenerator gen = new PKCS5S2ParametersGenerator(new SHA512Digest());
        gen.init(new String(password).getBytes("UTF-8"), salt, PBKDF2_ITERATIONS);

        return ((KeyParameter) gen.generateDerivedParameters(AES_KEY_SIZE_BITS)).getKey();
    }
项目:runrightfast-vertx    文件:SHA512DigestCalculator.java   
@Override
public byte[] getDigest() {
    final byte[] bytes = bos.toByteArray();
    bos.reset();
    final Digest sha512 = new SHA512Digest();
    sha512.update(bytes, 0, bytes.length);
    byte[] digest = new byte[sha512.getDigestSize()];
    sha512.doFinal(digest, 0);
    return digest;
}
项目:InflatableDonkey    文件:RFC6637Factory.java   
public static synchronized RFC6637 secp521r1() {
    if (SECP521R1 == null) {
        SECP521R1 = create(
                "secp521r1",
                SHA512Digest::new,
                () -> new RFC3394WrapEngine(new AESFastEngine()),
                RFC6637Constants.ECDH,
                RFC6637Constants.AES_256,
                0x20,
                RFC6637Constants.SHA512);
    }

    return SECP521R1;
}
项目:InflatableDonkey    文件:SignatureAssistant.java   
static Optional<Digest> digest(Signature signature) {
    switch (signature.type()) {
        case 0x01:
            return Optional.ofNullable(new SHA256Digest());
        case 0x02:
            return Optional.ofNullable(new SHA512Digest());
        default:
            logger.warn("-- digest() - unsupported signature type: {}", signature);
            return Optional.empty();
    }
}
项目:HAP-Java    文件:FinalPairHandler.java   
public HttpResponse handle(PairSetupRequest req) throws Exception {
    HKDFBytesGenerator hkdf = new HKDFBytesGenerator(new SHA512Digest());
    hkdf.init(new HKDFParameters(k, "Pair-Setup-Encrypt-Salt".getBytes(StandardCharsets.UTF_8), 
            "Pair-Setup-Encrypt-Info".getBytes(StandardCharsets.UTF_8)));
    byte[] okm = hkdf_enc_key = new byte[32];
    hkdf.generateBytes(okm, 0, 32);

    return decrypt((Stage3Request) req, okm);
}
项目:HAP-Java    文件:FinalPairHandler.java   
private HttpResponse createResponse() throws Exception {
    HKDFBytesGenerator hkdf = new HKDFBytesGenerator(new SHA512Digest());
    hkdf.init(new HKDFParameters(k, "Pair-Setup-Accessory-Sign-Salt".getBytes(StandardCharsets.UTF_8),
            "Pair-Setup-Accessory-Sign-Info".getBytes(StandardCharsets.UTF_8)));
    byte[] okm = new byte[32];
    hkdf.generateBytes(okm, 0, 32);

    EdsaSigner signer = new EdsaSigner(authInfo.getPrivateKey());

    byte[] material = ByteUtils.joinBytes(okm, authInfo.getMac().getBytes(StandardCharsets.UTF_8), signer.getPublicKey());

    byte[] proof = signer.sign(material);

    Encoder encoder = TypeLengthValueUtils.getEncoder();
    encoder.add(MessageType.USERNAME, authInfo.getMac().getBytes(StandardCharsets.UTF_8));
    encoder.add(MessageType.PUBLIC_KEY, signer.getPublicKey());
    encoder.add(MessageType.SIGNATURE, proof);
    byte[] plaintext = encoder.toByteArray();

    ChachaEncoder chacha = new ChachaEncoder(hkdf_enc_key, "PS-Msg06".getBytes(StandardCharsets.UTF_8));
    byte[] ciphertext = chacha.encodeCiphertext(plaintext);

    encoder = TypeLengthValueUtils.getEncoder();
    encoder.add(MessageType.STATE, (short) 6);
    encoder.add(MessageType.ENCRYPTED_DATA, ciphertext);

    return new PairingResponse(encoder.toByteArray());
}
项目:HAP-Java    文件:PairVerificationManager.java   
private HttpResponse stage1(Stage1Request request) throws Exception {
    logger.debug("Starting pair verification for "+registry.getLabel());
    clientPublicKey = request.getClientPublicKey();
    publicKey = new byte[32];
    byte[] privateKey = new byte[32];
    getSecureRandom().nextBytes(privateKey);
    Curve25519.keygen(publicKey, null, privateKey);

    sharedSecret = new byte[32];
    Curve25519.curve(sharedSecret, privateKey, clientPublicKey);

    byte[] material = ByteUtils.joinBytes(publicKey, authInfo.getMac().getBytes(StandardCharsets.UTF_8),
            clientPublicKey);

    byte[] proof = new EdsaSigner(authInfo.getPrivateKey()).sign(material);

    HKDFBytesGenerator hkdf = new HKDFBytesGenerator(new SHA512Digest());
    hkdf.init(new HKDFParameters(sharedSecret, "Pair-Verify-Encrypt-Salt".getBytes(StandardCharsets.UTF_8),
            "Pair-Verify-Encrypt-Info".getBytes(StandardCharsets.UTF_8)));
    hkdfKey = new byte[32];
    hkdf.generateBytes(hkdfKey, 0, 32);

    Encoder encoder = TypeLengthValueUtils.getEncoder();
    encoder.add(MessageType.USERNAME, authInfo.getMac().getBytes(StandardCharsets.UTF_8));
    encoder.add(MessageType.SIGNATURE, proof);
    byte[] plaintext = encoder.toByteArray();

    ChachaEncoder chacha = new ChachaEncoder(hkdfKey, "PV-Msg02".getBytes(StandardCharsets.UTF_8));
    byte[] ciphertext = chacha.encodeCiphertext(plaintext);

    encoder = TypeLengthValueUtils.getEncoder();
    encoder.add(MessageType.STATE, (short) 2);
    encoder.add(MessageType.ENCRYPTED_DATA, ciphertext);
    encoder.add(MessageType.PUBLIC_KEY, publicKey);
    return new PairingResponse(encoder.toByteArray());
}
项目:HAP-Java    文件:PairVerificationManager.java   
private byte[] createKey(String info) {
    HKDFBytesGenerator hkdf = new HKDFBytesGenerator(new SHA512Digest());
    hkdf.init(new HKDFParameters(sharedSecret, "Control-Salt".getBytes(StandardCharsets.UTF_8),
            info.getBytes(StandardCharsets.UTF_8)));
    byte[] key = new byte[32];
    hkdf.generateBytes(key, 0, 32);
    return key;
}
项目:africhat-platform-0.1    文件:BouncyCastleRuntime.java   
@Override
public byte[] SHA512(byte[] data) {
    SHA512Digest digest = new SHA512Digest();
    digest.update(data, 0, data.length);
    byte[] res = new byte[64];
    digest.doFinal(res, 0);
    return res;
}
项目:BitcoinCore    文件:Utils.java   
/**
 * Calculate the HMAC-SHA512 digest for use with BIP 32
 *
 * @param       key             Key
 * @param       input           Bytes to be hashed
 * @return                      Hashed result
 */
public static byte[] hmacSha512(byte[] key, byte[] input) {
    HMac hmac = new HMac(new SHA512Digest());
    hmac.init(new KeyParameter(key));
    hmac.update(input, 0, input.length);
    byte[] out = new byte[64];
    hmac.doFinal(out, 0);
    return out;
}
项目:Java-Security    文件:SHA512.java   
/**
 * Creates a new SHA512 digest that may optionally be initialized with
 * random data.
 *
 * @param randomize
 *            True to randomize initial state of digest, false otherwise.
 */
public SHA512(final boolean randomize) {
    super(new SHA512Digest());
    if (randomize) {
        setRandomProvider(new SecureRandom());
        setSalt(getRandomSalt());
    }
}
项目:CryptMeme    文件:BcImplProvider.java   
static Digest createDigest(int algorithm)
    throws PGPException
{
    switch (algorithm)
    {
    case HashAlgorithmTags.SHA1:
        return new SHA1Digest();
    case HashAlgorithmTags.SHA224:
        return new SHA224Digest();
    case HashAlgorithmTags.SHA256:
        return new SHA256Digest();
    case HashAlgorithmTags.SHA384:
        return new SHA384Digest();
    case HashAlgorithmTags.SHA512:
        return new SHA512Digest();
    case HashAlgorithmTags.MD2:
        return new MD2Digest();
    case HashAlgorithmTags.MD5:
        return new MD5Digest();
    case HashAlgorithmTags.RIPEMD160:
        return new RIPEMD160Digest();
    case HashAlgorithmTags.TIGER_192:
        return new TigerDigest();
    default:
        throw new PGPException("cannot recognise digest");
    }
}