Methods Summary |
---|
protected java.lang.Object | engineGetParameter(java.lang.String param)
throw new UnsupportedOperationException("engineGetParameter unsupported");
|
protected java.security.AlgorithmParameters | engineGetParameters()
if (engineParams == null)
{
if (paramSpec != null)
{
try
{
engineParams = AlgorithmParameters.getInstance("PSS", "BC");
engineParams.init(paramSpec);
}
catch (Exception e)
{
throw new RuntimeException(e.toString());
}
}
}
return engineParams;
|
protected void | engineInitSign(java.security.PrivateKey privateKey, java.security.SecureRandom random)
if (!(privateKey instanceof RSAPrivateKey))
{
throw new InvalidKeyException("Supplied key is not a RSAPrivateKey instance");
}
pss = new PSSSigner(signer, digest, saltLength, trailer);
pss.init(true, new ParametersWithRandom(RSAUtil.generatePrivateKeyParameter((RSAPrivateKey)privateKey), random));
|
protected void | engineInitSign(java.security.PrivateKey privateKey)
if (!(privateKey instanceof RSAPrivateKey))
{
throw new InvalidKeyException("Supplied key is not a RSAPrivateKey instance");
}
pss = new PSSSigner(signer, digest, saltLength, trailer);
pss.init(true, RSAUtil.generatePrivateKeyParameter((RSAPrivateKey)privateKey));
|
protected void | engineInitVerify(java.security.PublicKey publicKey)
if (!(publicKey instanceof RSAPublicKey))
{
throw new InvalidKeyException("Supplied key is not a RSAPublicKey instance");
}
pss = new PSSSigner(signer, digest, saltLength);
pss.init(false,
RSAUtil.generatePublicKeyParameter((RSAPublicKey)publicKey));
|
protected void | engineSetParameter(java.security.spec.AlgorithmParameterSpec params)
if (params instanceof PSSParameterSpec)
{
paramSpec = (PSSParameterSpec)params;
if (originalSpec != null)
{
if (!JCEDigestUtil.isSameDigest(originalSpec.getDigestAlgorithm(), paramSpec.getDigestAlgorithm()))
{
throw new InvalidParameterException("parameter must be using " + originalSpec.getDigestAlgorithm());
}
}
if (!paramSpec.getMGFAlgorithm().equalsIgnoreCase("MGF1") && !paramSpec.getMGFAlgorithm().equals(PKCSObjectIdentifiers.id_mgf1.getId()))
{
throw new InvalidParameterException("unknown mask generation function specified");
}
if (!(paramSpec.getMGFParameters() instanceof MGF1ParameterSpec))
{
throw new InvalidParameterException("unkown MGF parameters");
}
MGF1ParameterSpec mgfParams = (MGF1ParameterSpec)paramSpec.getMGFParameters();
if (!JCEDigestUtil.isSameDigest(mgfParams.getDigestAlgorithm(), paramSpec.getDigestAlgorithm()))
{
throw new InvalidParameterException("digest algorithm for MGF should be the same as for PSS parameters.");
}
digest = JCEDigestUtil.getDigest(mgfParams.getDigestAlgorithm());
if (digest == null)
{
throw new InvalidParameterException("no match on MGF digest algorithm: "+ mgfParams.getDigestAlgorithm());
}
this.saltLength = paramSpec.getSaltLength();
this.trailer = getTrailer(paramSpec.getTrailerField());
}
else
{
throw new InvalidParameterException("Only PSSParameterSpec supported");
}
|
protected void | engineSetParameter(java.lang.String param, java.lang.Object value)
throw new UnsupportedOperationException("engineSetParameter unsupported");
|
protected byte[] | engineSign()
try
{
return pss.generateSignature();
}
catch (CryptoException e)
{
throw new SignatureException(e.getMessage());
}
|
protected void | engineUpdate(byte b)
pss.update(b);
|
protected void | engineUpdate(byte[] b, int off, int len)
pss.update(b, off, len);
|
protected boolean | engineVerify(byte[] sigBytes)
return pss.verifySignature(sigBytes);
|
private byte | getTrailer(int trailerField)
if (trailerField == 1)
{
return PSSSigner.TRAILER_IMPLICIT;
}
throw new IllegalArgumentException("unknown trailer field");
|