org.bouncycastle.crypto.digests.SHA384Digest Java Examples
The following examples show how to use
org.bouncycastle.crypto.digests.SHA384Digest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PBKDF2CipherProvider.java From localization_nifi with Apache License 2.0 | 6 votes |
private Digest resolvePRF(final String prf) { if (StringUtils.isEmpty(prf)) { throw new IllegalArgumentException("Cannot resolve empty PRF"); } String formattedPRF = prf.toLowerCase().replaceAll("[\\W]+", ""); logger.debug("Resolved PRF {} to {}", prf, formattedPRF); switch (formattedPRF) { case "md5": return new MD5Digest(); case "sha1": return new SHA1Digest(); case "sha384": return new SHA384Digest(); case "sha256": return new SHA256Digest(); case "sha512": return new SHA512Digest(); default: logger.warn("Could not resolve PRF {}. Using default PRF {} instead", prf, DEFAULT_PRF); return new SHA512Digest(); } }
Example #2
Source File: BouncyCastleV1CryptoProvider.java From paseto with MIT License | 6 votes |
private PSSSigner pssSha384(boolean forSigning, byte[] key) { try { byte[] salt = new byte[SHA384_OUT_LEN]; new SecureRandom().nextBytes(salt); // RSA-PSS, SHA-384, MGF1(SHA-384), 48 byte salt length, 0xBC trailer PSSSigner pss = new PSSSigner(new RSABlindedEngine(), new SHA384Digest(), new SHA384Digest(), SHA384_OUT_LEN, (byte) 0xBC); if (forSigning) { pss.init(true, PrivateKeyFactory.createKey(key)); } else { pss.init(false, PublicKeyFactory.createKey(key)); } return pss; } catch (IOException e) { throw new CryptoProviderException("IOException", e); } }
Example #3
Source File: PBKDF2CipherProvider.java From nifi with Apache License 2.0 | 6 votes |
private Digest resolvePRF(final String prf) { if (StringUtils.isEmpty(prf)) { throw new IllegalArgumentException("Cannot resolve empty PRF"); } String formattedPRF = prf.toLowerCase().replaceAll("[\\W]+", ""); logger.debug("Resolved PRF {} to {}", prf, formattedPRF); switch (formattedPRF) { case "md5": return new MD5Digest(); case "sha1": return new SHA1Digest(); case "sha384": return new SHA384Digest(); case "sha256": return new SHA256Digest(); case "sha512": return new SHA512Digest(); default: logger.warn("Could not resolve PRF {}. Using default PRF {} instead", prf, DEFAULT_PRF); return new SHA512Digest(); } }
Example #4
Source File: CryptoUtils.java From hedera-sdk-java with Apache License 2.0 | 5 votes |
static byte[] calcHmacSha384(KeyParameter cipherKey, byte[] input) { final HMac hmacSha384 = new HMac(new SHA384Digest()); final byte[] output = new byte[hmacSha384.getMacSize()]; hmacSha384.init(new KeyParameter(cipherKey.getKey(), 16, 16)); hmacSha384.update(input, 0, input.length); hmacSha384.doFinal(output, 0); return output; }
Example #5
Source File: BouncyCastleV1CryptoProvider.java From paseto with MIT License | 5 votes |
@Override public byte[] hkdfExtractAndExpand(byte[] salt, byte[] inputKeyingMaterial, byte[] info) { validateHkdfExtractAndExpand(salt, inputKeyingMaterial, info); Digest digest = new SHA384Digest(); HKDFBytesGenerator hkdf = new HKDFBytesGenerator(digest); hkdf.init(new HKDFParameters(inputKeyingMaterial, salt, info)); byte[] out = new byte[HKDF_LEN]; hkdf.generateBytes(out, 0, out.length); return out; }
Example #6
Source File: BouncyCastleV1CryptoProvider.java From paseto with MIT License | 5 votes |
@Override public byte[] hmacSha384(byte[] m, byte[] key) { validateHmacSha384(m, key); Digest digest = new SHA384Digest(); HMac hmac = new HMac(digest); hmac.init(new KeyParameter(key)); byte[] out = new byte[hmac.getMacSize()]; hmac.update(m, 0, m.length); hmac.doFinal(out, 0); return out; }
Example #7
Source File: BouncyCastleHasher.java From hash-bench with MIT License | 4 votes |
public static final void register(final Map<String, Hasher> hashers) { hashers.put(BouncyCastleHasher.GOST, new BouncyCastleHasher(new GOST3411Digest())); hashers.put(BouncyCastleHasher.MD2, new BouncyCastleHasher(new MD2Digest())); hashers.put(BouncyCastleHasher.MD4, new BouncyCastleHasher(new MD4Digest())); hashers.put(BouncyCastleHasher.MD5, new BouncyCastleHasher(new MD5Digest())); hashers.put(BouncyCastleHasher.RIPEMD128, new BouncyCastleHasher(new RIPEMD128Digest())); hashers.put(BouncyCastleHasher.RIPEMD160, new BouncyCastleHasher(new RIPEMD160Digest())); hashers.put(BouncyCastleHasher.RIPEMD256, new BouncyCastleHasher(new RIPEMD256Digest())); hashers.put(BouncyCastleHasher.RIPEMD320, new BouncyCastleHasher(new RIPEMD320Digest())); hashers.put(BouncyCastleHasher.SHA1, new BouncyCastleHasher(new SHA1Digest())); hashers.put(BouncyCastleHasher.SHA224, new BouncyCastleHasher(new SHA224Digest())); hashers.put(BouncyCastleHasher.SHA256, new BouncyCastleHasher(new SHA256Digest())); hashers.put(BouncyCastleHasher.SHA3, new BouncyCastleHasher(new SHA3Digest())); hashers.put(BouncyCastleHasher.SHA384, new BouncyCastleHasher(new SHA384Digest())); hashers.put(BouncyCastleHasher.SHA512, new BouncyCastleHasher(new SHA512Digest())); hashers.put(BouncyCastleHasher.SHA512_T, new BouncyCastleHasher(new SHA512tDigest(7 * 8))); hashers.put(BouncyCastleHasher.SKEIN1024, new BouncyCastleHasher( new SkeinDigest(SkeinDigest.SKEIN_1024, Long.BYTES * 8))); hashers.put(BouncyCastleHasher.SKEIN256, new BouncyCastleHasher( new SkeinDigest(SkeinDigest.SKEIN_256, Long.BYTES * 8))); hashers.put(BouncyCastleHasher.SKEIN512, new BouncyCastleHasher( new SkeinDigest(SkeinDigest.SKEIN_512, Long.BYTES * 8))); hashers.put(BouncyCastleHasher.SM3, new BouncyCastleHasher(new SM3Digest())); hashers.put(BouncyCastleHasher.TIGER, new BouncyCastleHasher(new TigerDigest())); hashers.put(BouncyCastleHasher.WHIRLPOOL2, new BouncyCastleHasher(new WhirlpoolDigest())); }