Search in sources :

Example 6 with Mechanism

use of iaik.pkcs.pkcs11.Mechanism in project xipki by xipki.

the class IaikP11Slot method singleSign.

private byte[] singleSign(Session session, long mechanism, P11Params parameters, byte[] content, IaikP11Identity identity) throws P11TokenException {
    Key signingKey = identity.getSigningKey();
    Mechanism mechanismObj = getMechanism(mechanism, parameters);
    if (LOG.isTraceEnabled()) {
        LOG.debug("sign with signing key:\n{}", signingKey);
    }
    byte[] signature;
    try {
        session.signInit(mechanismObj, signingKey);
        signature = session.sign(content);
    } catch (TokenException ex) {
        throw new P11TokenException(ex.getMessage(), ex);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("signature:\n{}", hex(signature));
    }
    return signature;
}
Also used : P11TokenException(org.xipki.security.exception.P11TokenException) TokenException(iaik.pkcs.pkcs11.TokenException) P11TokenException(org.xipki.security.exception.P11TokenException) RSAPrivateKey(iaik.pkcs.pkcs11.objects.RSAPrivateKey) ECPrivateKey(iaik.pkcs.pkcs11.objects.ECPrivateKey) SM2PrivateKey(iaik.pkcs.pkcs11.objects.SM2PrivateKey) ValuedSecretKey(iaik.pkcs.pkcs11.objects.ValuedSecretKey) Key(iaik.pkcs.pkcs11.objects.Key) DSAPublicKey(iaik.pkcs.pkcs11.objects.DSAPublicKey) RSAPublicKey(iaik.pkcs.pkcs11.objects.RSAPublicKey) SM2PublicKey(iaik.pkcs.pkcs11.objects.SM2PublicKey) ECPublicKey(iaik.pkcs.pkcs11.objects.ECPublicKey) PrivateKey(iaik.pkcs.pkcs11.objects.PrivateKey) DSAPrivateKey(iaik.pkcs.pkcs11.objects.DSAPrivateKey) PublicKey(iaik.pkcs.pkcs11.objects.PublicKey) SecretKey(iaik.pkcs.pkcs11.objects.SecretKey) Mechanism(iaik.pkcs.pkcs11.Mechanism)

Aggregations

P11TokenException (org.xipki.security.exception.P11TokenException)6 Mechanism (iaik.pkcs.pkcs11.Mechanism)5 TokenException (iaik.pkcs.pkcs11.TokenException)5 SecretKey (iaik.pkcs.pkcs11.objects.SecretKey)5 ValuedSecretKey (iaik.pkcs.pkcs11.objects.ValuedSecretKey)5 Session (iaik.pkcs.pkcs11.Session)4 DSAPrivateKey (iaik.pkcs.pkcs11.objects.DSAPrivateKey)4 ECPrivateKey (iaik.pkcs.pkcs11.objects.ECPrivateKey)4 PrivateKey (iaik.pkcs.pkcs11.objects.PrivateKey)4 RSAPrivateKey (iaik.pkcs.pkcs11.objects.RSAPrivateKey)4 SM2PrivateKey (iaik.pkcs.pkcs11.objects.SM2PrivateKey)4 DSAPublicKey (iaik.pkcs.pkcs11.objects.DSAPublicKey)3 ECPublicKey (iaik.pkcs.pkcs11.objects.ECPublicKey)3 Key (iaik.pkcs.pkcs11.objects.Key)3 PublicKey (iaik.pkcs.pkcs11.objects.PublicKey)3 RSAPublicKey (iaik.pkcs.pkcs11.objects.RSAPublicKey)3 SM2PublicKey (iaik.pkcs.pkcs11.objects.SM2PublicKey)3 P11ObjectIdentifier (org.xipki.security.pkcs11.P11ObjectIdentifier)2 X509PublicKeyCertificate (iaik.pkcs.pkcs11.objects.X509PublicKeyCertificate)1 IVParams (iaik.pkcs.pkcs11.params.IVParams)1