public class UnwrappedEcdsaSignature extends PKCS11BufferingSignature
byte[] data = ...; IAIKPKCS11PrivateKey privateKey = ...; IAIKPkcs11 pkcs11Prov = ...; // calculate the hash outside the Signature engine: MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(data); byte[] digest = md.digest(); // calculate the signature Signature ecdsa = Signature.getInstance("RawECDSAUnwrapped", pkcs11Prov); ecdsa.initSign(privKey); ecdsa.update(digest); byte[] sigVal = signature = ecdsa.sign();Unlike the
EcdsaSignature
engine, the signature value
calculated by this class is encoded as (r || s) and not wrapped into an ASN.1
SEQUENCE as done by ANSI X9.62. Thus the signature represents an ECDSA signature
as returned by the token and specified by PKCS#11.
Please note that this does NOT represent a plain ECDSA signature as specified by
BSI TR-03111! TR-03111 does not wrap the signature value (r || s) into an ASN.1
SEQUENCE, too, however, TR-03111 does not truncate the hash value if it is larger than the domain
parameter length; rather TR-03111 reduces it modulo the order of the base point.Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
SIGNATURE_ALGORITHM_NAME
The JCA standard name of this signature algorithm.
|
buffer_
currentKeyIsSoftwareKey_, initialized_, operationState_, pkcs11OperationInitialized_, privateKey_, publicKey_, session_, SIGN, softwareDelegate_, tokenManager_, usedMechanismInfos_, usedMechanisms_, VERIFY
Constructor and Description |
---|
UnwrappedEcdsaSignature()
Public default constructor to enable instantiation via Class.forName(String).
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
getAlgorithmName()
Get the JCA standard name of this signautre algorithm.
|
protected iaik.pkcs.pkcs11.Mechanism |
getMechanism()
Get the mechanism of this signature object.
|
protected byte[] |
pkcs11Sign()
Create the signature value (r || s).
|
protected boolean |
pkcs11Verify(byte[] signature)
Verifies the given signature (r || s).
|
pkcs11InitSign, pkcs11InitVerify, pkcs11Update
engineGetParameter, engineInitSign, engineInitVerify, engineSetParameter, engineSetParameter, engineSign, engineUpdate, engineUpdate, engineVerify, finalize, finalizePkcs11Operation, getUsedMechanismFeatures, getUsedMechanisms, initializePkcs11Operation, initializeSession, initializeSoftwareDelegate, isSupportedBy, pkcs11GetParameter, pkcs11SetParameter, pkcs11SetParameter, pkcs11Update
protected static java.lang.String SIGNATURE_ALGORITHM_NAME
public UnwrappedEcdsaSignature()
protected java.lang.String getAlgorithmName()
getAlgorithmName
in class PKCS11Signature
protected iaik.pkcs.pkcs11.Mechanism getMechanism()
getMechanism
in class PKCS11BufferingSignature
protected byte[] pkcs11Sign() throws java.security.SignatureException
pkcs11Sign
in class PKCS11BufferingSignature
java.security.SignatureException
- If an error occurs when creating the signature.protected boolean pkcs11Verify(byte[] signature) throws java.security.SignatureException
pkcs11Verify
in class PKCS11BufferingSignature
signature
- The signature bytes to be verified.true
if signature is OK, false
otherwise.java.security.SignatureException
- If an error occurs when verifying the signature.IAIK JavaSecurity Website https://jce.iaik.tugraz.at/
IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2023 IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved. Version 1.9.4