Search in sources :

Example 1 with P11RSAKeyParameter

use of org.xipki.security.pkcs11.P11RSAKeyParameter in project xipki by xipki.

the class P11RSAPSSSignatureSpi method engineInitSign.

protected void engineInitSign(PrivateKey privateKey, SecureRandom random) throws InvalidKeyException {
    if (!(privateKey instanceof P11PrivateKey)) {
        throw new InvalidKeyException("privateKey is not instanceof " + P11PrivateKey.class.getName());
    }
    String algo = privateKey.getAlgorithm();
    if (!"RSA".equals(algo)) {
        throw new InvalidKeyException("privateKey is not an RSA private key: " + algo);
    }
    this.signingKey = (P11PrivateKey) privateKey;
    pss = new org.bouncycastle.crypto.signers.PSSSigner(signer, contentDigest, mgfDigest, saltLength, trailer);
    P11RSAKeyParameter p11KeyParam = P11RSAKeyParameter.getInstance(signingKey.getP11CryptService(), signingKey.getIdentityId());
    if (random == null) {
        pss.init(true, p11KeyParam);
    } else {
        pss.init(true, new ParametersWithRandom(p11KeyParam, random));
    }
}
Also used : ParametersWithRandom(org.bouncycastle.crypto.params.ParametersWithRandom) InvalidKeyException(java.security.InvalidKeyException) P11RSAKeyParameter(org.xipki.security.pkcs11.P11RSAKeyParameter)

Aggregations

InvalidKeyException (java.security.InvalidKeyException)1 ParametersWithRandom (org.bouncycastle.crypto.params.ParametersWithRandom)1 P11RSAKeyParameter (org.xipki.security.pkcs11.P11RSAKeyParameter)1