public static Digest getDigest(final HashAlgoType hashAlgo) throws XiSecurityException { return hashAlgo.createDigest(); }
protected P11RSADigestSignatureSpi(final HashAlgoType digestAlg) { this.digestAlgId = digestAlg.algorithmIdentifier(); this.digest = digestAlg.createDigest(); }
private static ConcurrentBag<ConcurrentBagEntry<Digest>> getMessageDigests( final HashAlgoType hashAlgo) { ConcurrentBag<ConcurrentBagEntry<Digest>> mds = new ConcurrentBag<>(); for (int i = 0; i < PARALLELISM; i++) { Digest md = hashAlgo.createDigest(); mds.add(new ConcurrentBagEntry<Digest>(md)); } return mds; }
private byte[] hmac(final byte[] contentToSign, final HashAlgoType hashAlgo) { HMac hmac = new HMac(hashAlgo.createDigest()); hmac.update(contentToSign, 0, contentToSign.length); byte[] signature = new byte[hmac.getMacSize()]; hmac.doFinal(signature, 0); return signature; }
public static Digest getDigest(final AlgorithmIdentifier hashAlgo) throws XiSecurityException { HashAlgoType hat = HashAlgoType.getHashAlgoType(hashAlgo.getAlgorithm()); if (hat != null) { return hat.createDigest(); } else { throw new XiSecurityException( "could not get digest for " + hashAlgo.getAlgorithm().getId()); } }
outputStream = new ByteArrayOutputStream(); } else { outputStream = new DigestOutputStream(hashAlgo.createDigest());
public HmacContentSigner(HashAlgoType hashAlgo, AlgorithmIdentifier algorithmIdentifier, SecretKey signingKey) throws XiSecurityException { this.algorithmIdentifier = ParamUtil.requireNonNull("algorithmIdentifier", algorithmIdentifier); try { this.encodedAlgorithmIdentifier = algorithmIdentifier.getEncoded(); } catch (IOException ex) { throw new XiSecurityException("could not encode AlgorithmIdentifier", ex); } ParamUtil.requireNonNull("signingKey", signingKey); if (hashAlgo == null) { hashAlgo = AlgorithmUtil.extractHashAlgoFromMacAlg(algorithmIdentifier); } this.hmac = new HMac(hashAlgo.createDigest()); byte[] keyBytes = signingKey.getEncoded(); this.hmac.init(new KeyParameter(keyBytes, 0, keyBytes.length)); this.outLen = hmac.getMacSize(); this.outputStream = new HmacOutputStream(); }
outputStream = new ByteArrayOutputStream(); } else { outputStream = new DigestOutputStream(hashAlgo.createDigest());