protected Signer createSigner(AlgorithmIdentifier sigAlgId, AlgorithmIdentifier digAlgId) throws OperatorCreationException { Digest dig = digestProvider.get(digAlgId); return new RSADigestSigner(dig); } }
/** * Sign a data buffer with an RSA private key using the SHA-256 digest, and * PKCSv1.5 padding. * * @throws TelehashException */ @Override public byte[] signRSA(HashNamePrivateKey key, byte[] buffer) throws TelehashException { RSADigestSigner signer = new RSADigestSigner(new SHA256Digest()); signer.init(true, ((HashNamePrivateKeyImpl)key).getKey()); signer.update(buffer, 0, buffer.length); byte[] signature; try { signature = signer.generateSignature(); } catch (DataLengthException e) { throw new TelehashException(e); } catch (CryptoException e) { throw new TelehashException(e); } return signature; }
/** * Verify the signature of a data buffer with an RSA private key using the * SHA-256 digest, and PKCSv1.5 padding. * * @param key The RSA public key * @param buffer The buffer which was signed * @param signature The signature to verify * @return true if the signature is valid; false otherwise. * @throws TelehashException */ @Override public boolean verifyRSA( HashNamePublicKey key, byte[] buffer, byte[] signature ) throws TelehashException { RSADigestSigner signer = new RSADigestSigner(new SHA256Digest()); signer.init(false, ((HashNamePublicKeyImpl)key).getKey()); signer.update(buffer, 0, buffer.length); try { return signer.verifySignature(signature); } catch (DataLengthException e) { throw new TelehashException(e); } }
/** * Generate a signature for the message we've been loaded with using the key * we were initialised with. */ public byte[] generateSignature() throws CryptoException, DataLengthException { if (!forSigning) { throw new IllegalStateException("RSADigestSigner not initialised for signature generation."); } byte[] hash = new byte[digest.getDigestSize()]; digest.doFinal(hash, 0); try { byte[] data = derEncode(hash); return rsaEngine.processBlock(data, 0, data.length); } catch (IOException e) { throw new CryptoException("unable to encode signature: " + e.getMessage(), e); } }
/** * Generate a signature for the message we've been loaded with using the key * we were initialised with. */ public byte[] generateSignature() throws CryptoException, DataLengthException { if (!forSigning) { throw new IllegalStateException("RSADigestSigner not initialised for signature generation."); } byte[] hash = new byte[digest.getDigestSize()]; digest.doFinal(hash, 0); try { byte[] data = derEncode(hash); return rsaEngine.processBlock(data, 0, data.length); } catch (IOException e) { throw new CryptoException("unable to encode signature: " + e.getMessage(), e); } }
protected Signer createSigner(AlgorithmIdentifier sigAlgId, AlgorithmIdentifier digAlgId) throws OperatorCreationException { Digest dig = digestProvider.get(digAlgId); return new RSADigestSigner(dig); } }
expected = derEncode(hash);
protected Signer createSigner(AlgorithmIdentifier sigAlgId) throws OperatorCreationException { AlgorithmIdentifier digAlg = digestAlgorithmFinder.find(sigAlgId); Digest dig = digestProvider.get(digAlg); return new RSADigestSigner(dig); }
expected = derEncode(hash);
protected Signer createSigner(AlgorithmIdentifier sigAlgId) throws OperatorCreationException { AlgorithmIdentifier digAlg = digestAlgorithmFinder.find(sigAlgId); Digest dig = digestProvider.get(digAlg); return new RSADigestSigner(dig); }
private Signer getAsymmetricSigner(boolean forSigning, SecurityAlgorithm algorithm, CipherParameters params) throws ServiceResultException { Signer signer = null; if (algorithm.equals(SecurityAlgorithm.RsaSha1)) { signer = new RSADigestSigner(new SHA1Digest()); } else if (algorithm.equals(SecurityAlgorithm.RsaSha256)) { signer = new RSADigestSigner(new SHA256Digest()); } else if (algorithm.equals(SecurityAlgorithm.RsaPssSha256)) { signer = new PSSSigner(new RSAEngine(), new SHA256Digest(), 32); } else { throw new ServiceResultException( StatusCodes.Bad_SecurityPolicyRejected, "Unsupported asymmetric signature algorithm: " + algorithm); } signer.init(forSigning, params); return signer; }
s = new RSADigestSigner(d, TlsUtils.getOIDForHashAlgorithm(algorithm.getHash()));
static Signer createSigner(int keyAlgorithm, int hashAlgorithm) throws PGPException { switch(keyAlgorithm) { case PublicKeyAlgorithmTags.RSA_GENERAL: case PublicKeyAlgorithmTags.RSA_SIGN: return new RSADigestSigner(createDigest(hashAlgorithm)); case PublicKeyAlgorithmTags.DSA: return new DSADigestSigner(new DSASigner(), createDigest(hashAlgorithm)); case PublicKeyAlgorithmTags.ECDSA: return new DSADigestSigner(new ECDSASigner(), createDigest(hashAlgorithm)); default: throw new PGPException("cannot recognise keyAlgorithm: " + keyAlgorithm); } }
signer = new RSADigestSigner(nullDigest, TlsUtils.getOIDForHashAlgorithm(algorithm.getHash()));
signer = new RSADigestSigner(nullDigest, TlsUtils.getOIDForHashAlgorithm(algorithm.getHash()));