use of com.github.zhenwei.core.crypto.digests.SHA512tDigest in project LinLong-Java by zhenwei1108.
the class Sphincs256KeyPairGeneratorSpi method initialize.
public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException {
if (!(params instanceof SPHINCS256KeyGenParameterSpec)) {
throw new InvalidAlgorithmParameterException("parameter object not a SPHINCS256KeyGenParameterSpec");
}
SPHINCS256KeyGenParameterSpec sphincsParams = (SPHINCS256KeyGenParameterSpec) params;
if (sphincsParams.getTreeDigest().equals(SPHINCS256KeyGenParameterSpec.SHA512_256)) {
treeDigest = NISTObjectIdentifiers.id_sha512_256;
param = new SPHINCS256KeyGenerationParameters(random, new SHA512tDigest(256));
} else if (sphincsParams.getTreeDigest().equals(SPHINCS256KeyGenParameterSpec.SHA3_256)) {
treeDigest = NISTObjectIdentifiers.id_sha3_256;
param = new SPHINCS256KeyGenerationParameters(random, new SHA3Digest(256));
}
engine.init(param);
initialised = true;
}
use of com.github.zhenwei.core.crypto.digests.SHA512tDigest in project LinLong-Java by zhenwei1108.
the class Sphincs256KeyPairGeneratorSpi method generateKeyPair.
public KeyPair generateKeyPair() {
if (!initialised) {
param = new SPHINCS256KeyGenerationParameters(random, new SHA512tDigest(256));
engine.init(param);
initialised = true;
}
AsymmetricCipherKeyPair pair = engine.generateKeyPair();
SPHINCSPublicKeyParameters pub = (SPHINCSPublicKeyParameters) pair.getPublic();
SPHINCSPrivateKeyParameters priv = (SPHINCSPrivateKeyParameters) pair.getPrivate();
return new KeyPair(new BCSphincs256PublicKey(treeDigest, pub), new BCSphincs256PrivateKey(treeDigest, priv));
}
use of com.github.zhenwei.core.crypto.digests.SHA512tDigest in project LinLong-Java by zhenwei1108.
the class Fingerprint method calculateFingerprintSHA512_160.
/**
* Return a byte array containing a calculated fingerprint for the passed in input data. The
* fingerprint is based on SHA512/160.
*
* @param input data to base the fingerprint on.
* @return a byte array containing a 20 byte fingerprint.
* @deprecated use the SHAKE based version.
*/
public static byte[] calculateFingerprintSHA512_160(byte[] input) {
SHA512tDigest digest = new SHA512tDigest(160);
digest.update(input, 0, input.length);
byte[] rv = new byte[digest.getDigestSize()];
digest.doFinal(rv, 0);
return rv;
}
Aggregations