protected void engineInitVerify( PublicKey publicKey) throws InvalidKeyException { if (!(publicKey instanceof RSAPublicKey)) { throw new InvalidKeyException("Supplied key is not a RSAPublicKey instance"); } pss = new org.spongycastle.crypto.signers.PSSSigner(signer, contentDigest, mgfDigest, saltLength, trailer); pss.init(false, RSAUtil.generatePublicKeyParameter((RSAPublicKey)publicKey)); }
protected void engineUpdate( byte[] b, int off, int len) throws SignatureException { pss.update(b, off, len); }
protected boolean engineVerify( byte[] sigBytes) throws SignatureException { return pss.verifySignature(sigBytes); }
if (salt == null) { signer = new PSSSigner( RSAEngineFactory.make(), primaryDigest, state.mgf1HashType.makeDigest(), } else { signer = new PSSSigner( RSAEngineFactory.make(), primaryDigest, state.mgf1HashType.makeDigest(), signer.init(true, new ParametersWithRandom(state.keyParameters, state.rng)); done = true; } else { signer.update(buffer, 0, howManyBytesRead); return signer.generateSignature(); } catch (CryptoException e) { throw new IOException(String.format("Cannot sign data: %s", e.toString()));
clearBlock(block); return false; byte[] dbMask = maskGeneratorFunction1(block, block.length - hLen - 1, hLen, block.length - hLen - 1); clearBlock(block); return false; clearBlock(block); return false; clearBlock(mDash); clearBlock(block); return false; clearBlock(mDash); clearBlock(block);
final Signer signatureChecker = new PSSSigner( RSAEngineFactory.make(), primaryDigest, state.mgf1HashType.makeDigest(),
protected byte[] engineSign() throws SignatureException { try { return pss.generateSignature(); } catch (CryptoException e) { throw new SignatureException(e.getMessage()); } }
clearBlock(block); return false; byte[] dbMask = maskGeneratorFunction1(block, block.length - hLen - 1, hLen, block.length - hLen - 1); clearBlock(block); return false; clearBlock(block); return false; clearBlock(mDash); clearBlock(block); return false; clearBlock(mDash); clearBlock(block);
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; }
protected byte[] engineSign() throws SignatureException { try { return pss.generateSignature(); } catch (CryptoException e) { throw new SignatureException(e.getMessage()); } }
protected void engineInitSign( PrivateKey privateKey) throws InvalidKeyException { if (!(privateKey instanceof RSAPrivateKey)) { throw new InvalidKeyException("Supplied key is not a RSAPrivateKey instance"); } pss = new org.spongycastle.crypto.signers.PSSSigner(signer, contentDigest, mgfDigest, saltLength, trailer); pss.init(true, RSAUtil.generatePrivateKeyParameter((RSAPrivateKey)privateKey)); }
/** * generate a signature for the message we've been loaded with using * the key we were initialised with. */ public byte[] generateSignature() throws CryptoException, DataLengthException { contentDigest.doFinal(mDash, mDash.length - hLen - sLen); if (sLen != 0) { random.nextBytes(salt); System.arraycopy(salt, 0, mDash, mDash.length - sLen, sLen); } byte[] h = new byte[hLen]; contentDigest.update(mDash, 0, mDash.length); contentDigest.doFinal(h, 0); block[block.length - sLen - 1 - hLen - 1] = 0x01; System.arraycopy(salt, 0, block, block.length - sLen - hLen - 1, sLen); byte[] dbMask = maskGeneratorFunction1(h, 0, h.length, block.length - hLen - 1); for (int i = 0; i != dbMask.length; i++) { block[i] ^= dbMask[i]; } block[0] &= (0xff >> ((block.length * 8) - emBits)); System.arraycopy(h, 0, block, block.length - hLen - 1, hLen); block[block.length - 1] = trailer; byte[] b = cipher.processBlock(block, 0, block.length); clearBlock(block); return b; }
protected void engineUpdate( byte[] b, int off, int len) throws SignatureException { pss.update(b, off, len); }
protected boolean engineVerify( byte[] sigBytes) throws SignatureException { return pss.verifySignature(sigBytes); }
protected void engineInitVerify( PublicKey publicKey) throws InvalidKeyException { if (!(publicKey instanceof RSAPublicKey)) { throw new InvalidKeyException("Supplied key is not a RSAPublicKey instance"); } pss = new org.spongycastle.crypto.signers.PSSSigner(signer, contentDigest, mgfDigest, saltLength, trailer); pss.init(false, RSAUtil.generatePublicKeyParameter((RSAPublicKey)publicKey)); }
System.arraycopy(salt, 0, block, block.length - sLen - hLen - 1, sLen); byte[] dbMask = maskGeneratorFunction1(h, 0, h.length, block.length - hLen - 1); for (int i = 0; i != dbMask.length; i++) clearBlock(block);