public class Session extends Object
TokenInfo tokenInfo = token.getTokenInfo();
// check, if login of the user is required at all
if (tokenInfo.isLoginRequired()) {
// check, if the token has own means to authenticate the user; e.g. a PIN-pad on the reader
if (tokenInfo.isProtectedAuthenticationPath()) {
System.out.println("Please enter the user PIN at the PIN-pad of your reader.");
session.login(CKU_USER, null); // the token prompts the PIN by other means; e.g. PIN-pad
} else {
System.out.print("Enter user-PIN and press [return key]: ");
System.out.flush();
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String userPINString = input.readLine();
session.login(CKU_USER, userPINString.toCharArray());
}
}
If the application does not need the session any longer, it should close the
session.
session.closeSession();
| Modifier and Type | Field and Description |
|---|---|
protected Token |
token
The token to perform the operations on.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Session(Token token,
long sessionHandle)
Constructor taking the token and the session handle.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancelFunction()
Legacy function that will normally throw an PKCS11Exception with the error-code
CKR_FUNCTION_NOT_PARALLEL.
|
void |
closeSession()
Closes this session.
|
long |
copyObject(long sourceObjectHandle,
AttributeVector template)
Copy an existing object.
|
long |
createECPrivateKeyObject(AttributeVector template,
byte[] ecPoint)
Create EC private key object in the PKCS#11 device.
|
long |
createObject(AttributeVector template)
Create a new object on the token (or in the session).
|
long |
createPrivateKeyObject(AttributeVector template,
PublicKey publicKey) |
byte[] |
decrypt(byte[] ciphertext)
Decrypts the given data with the key and mechanism given to the decryptInit method.
|
byte[] |
decryptDigestUpdate(byte[] part)
Dual-function.
|
byte[] |
decryptFinal()
This method finalizes a decryption operation and returns the final result.
|
void |
decryptInit(Mechanism mechanism,
long keyHandle)
Initializes a new decryption operation.
|
byte[] |
decryptMessage(CkParams params,
byte[] associatedData,
byte[] ciphertext)
Decrypts the given message with the key and mechanism given to the MessageDecryptInit method.
|
void |
decryptMessageBegin(CkParams params,
byte[] associatedData)
Starts a multipart message-decryption operation.
|
byte[] |
decryptMessageNext(CkParams params,
byte[] ciphertext,
boolean isLastOperation)
Decrypts one part of a multipart decryption operation.
|
byte[] |
decryptSingle(Mechanism mechanism,
long keyHandle,
byte[] ciphertext) |
byte[] |
decryptUpdate(byte[] ciphertextPart)
This method can be used to decrypt multiple pieces of data; e.g.
|
byte[] |
decryptVerifyUpdate(byte[] encryptedPart)
Dual-function.
|
long |
deriveKey(Mechanism mechanism,
long baseKeyHandle,
AttributeVector template)
Derives a new key from a specified base key using the given mechanism.
|
void |
destroyObject(long objectHandle)
Destroy a certain object on the token (or in the session).
|
byte[] |
digest(byte[] data)
Digests the given data with the mechanism given to the digestInit method.
|
byte[] |
digestEncryptedUpdate(byte[] part)
Dual-function.
|
byte[] |
digestFinal()
This method finalizes a digesting operation and returns the final result.
|
int |
digestFinal(byte[] out,
int outOfs,
int outLen)
This method finalizes a digesting operation and returns the final result.
|
void |
digestInit(Mechanism mechanism)
Initializes a new digesting operation.
|
void |
digestKey(long keyHandle)
This method is similar to digestUpdate and can be combined with it during one digesting
operation.
|
byte[] |
digestSingle(Mechanism mechanism,
byte[] data) |
void |
digestUpdate(byte[] dataPart)
This method can be used to digest multiple pieces of data; e.g.
|
byte[] |
encrypt(byte[] plaintext)
Encrypts the given data with the key and mechanism given to the encryptInit method.
|
byte[] |
encryptFinal()
This method finalizes an encryption operation and returns the final result.
|
void |
encryptInit(Mechanism mechanism,
long keyHandle)
Initializes a new encryption operation.
|
byte[] |
encryptMessage(CkParams params,
byte[] associatedData,
byte[] plaintext)
Encrypts the given message with the key and mechanism given to the MessageEncryptInit method.
|
void |
encryptMessageBegin(CkParams params,
byte[] associatedData)
Starts a multipart message-encryption operation.
|
byte[] |
encryptMessageNext(CkParams params,
byte[] plaintext,
boolean isLastOperation)
Encrypts one part of a multipart encryption operation.
|
byte[] |
encryptSingle(Mechanism mechanism,
long keyHandle,
byte[] plaintext) |
byte[] |
encryptUpdate(byte[] plaintextPat)
This method can be used to encrypt multiple pieces of data; e.g.
|
long[] |
findAllObjectsSingle(AttributeVector template) |
long[] |
findObjects(int maxObjectCount)
Finds objects that match the template object passed to findObjectsInit.
|
void |
findObjectsFinal()
Finalizes a find operation.
|
void |
findObjectsInit(AttributeVector template)
Initializes a find operations that provides means to find objects by passing a template object.
|
long[] |
findObjectsSingle(AttributeVector template,
int maxObjectCount) |
long |
generateKey(Mechanism mechanism,
AttributeVector template)
Generate a new secret key or a set of domain parameters.
|
PKCS11KeyPair |
generateKeyPair(Mechanism mechanism,
KeyPairTemplate template)
Generate a new public key - private key key-pair and use the set attributes of the template
objects for setting the attributes of the new public key and private key objects.
|
byte[] |
generateRandom(int numberOfBytesToGenerate)
Generates a certain number of random bytes.
|
AttributeVector |
getAttrValues(long objectHandle,
List<Long> attributeTypes) |
AttributeVector |
getAttrValues(long objectHandle,
long... attributeTypes) |
AttributeVector |
getDefaultAttrValues(long objectHandle)
Return the default attributes, but without attributes which contain the sensitive values.
|
AttributeVector |
getDefaultAttrValues(long objectHandle,
boolean withSensitiveVAttributes)
Return the default attributes
|
void |
getFunctionStatus()
Legacy function that will normally throw an PKCS11Exception with the error-code
CKR_FUNCTION_NOT_PARALLEL.
|
PKCS11Module |
getModule()
Get the Module which this Session object operates with.
|
long |
getObjectSize(long objectHandle)
Get the size of the specified object in bytes.
|
byte[] |
getOperationState()
Get the current operation state.
|
long |
getSessionHandle()
Get the handle of this session.
|
SessionInfo |
getSessionInfo()
Get information about this session.
|
String |
getStringAttrValue(long objectHandle,
long attributeType) |
Token |
getToken()
Get the token that created this Session object.
|
void |
initPIN(char[] pin)
Initializes the user-PIN.
|
boolean |
isRwSession()
Determines if this session is an R/W session.
|
boolean |
isSetUtf8Encoding()
Returns whether UTF8 encoding is set.
|
void |
login(long userType,
char[] pin)
Logs in the user or the security officer to the session.
|
void |
loginUser(long userType,
char[] pin,
char[] username)
Logs in the user or the security officer to the session.
|
void |
logout()
Logs out this session.
|
void |
messageDecryptFinal()
finishes multipart message decryption operation.
|
void |
messageDecryptInit(Mechanism mechanism,
long keyHandle)
Initializes a new message decryption operation.
|
void |
messageEncryptFinal()
Finishes a Message Encryption Operation which has previously been started with messageEncryptInit.
|
void |
messageEncryptInit(Mechanism mechanism,
long keyHandle)
Initializes a new message encryption operation.
|
void |
messageSignFinal()
finishes a message-based signing process.
|
void |
messageSignInit(Mechanism mechanism,
long keyHandle) |
void |
messageVerifyFinal()
finishes a message-based verification process.
|
void |
messageVerifyInit(Mechanism mechanism,
long keyHandle)
Initiates a message verification operation, preparing a session for one or
more verification operations (where the signature is an appendix to the data) that use the same
verification mechanism and verification key.
|
void |
seedRandom(byte[] seed)
Mixes additional seeding material into the random number generator.
|
void |
sessionCancel()
terminates active session based operations.
|
void |
setAttributeValues(long objectToUpdateHandle,
AttributeVector template)
Gets all present attributes of the given template object and writes them to the object to update
on the token (or in the session).
|
void |
setOperationState(byte[] operationState,
long encryptionKeyHandle,
long authenticationKeyHandle)
Sets the operation state of this session to a previously saved one.
|
void |
setPIN(char[] oldPin,
char[] newPin)
Set the user-PIN to a new value.
|
void |
setSessionHandle(long sessionHandle) |
byte[] |
sign(byte[] data)
Signs the given data with the key and mechanism given to the signInit method.
|
byte[] |
signEncryptUpdate(byte[] part)
Dual-function.
|
byte[] |
signFinal()
This method finalizes a signing operation and returns the final result.
|
void |
signInit(Mechanism mechanism,
long keyHandle)
Initializes a new signing operation.
|
byte[] |
signMessage(CkParams params,
byte[] data) |
void |
signMessageBegin(CkParams params)
SignMessageBegin begins a multiple-part message signature operation, where the signature is an
appendix to the message.
|
byte[] |
signMessageNext(CkParams params,
byte[] data,
boolean isLastOperation)
SignMessageNext continues a multiple-part message signature operation, processing another data
part, or finishes a multiple-part message signature operation, returning the signature.
|
byte[] |
signRecover(byte[] data)
Signs the given data with the key and mechanism given to the signRecoverInit method.
|
void |
signRecoverInit(Mechanism mechanism,
long keyHandle)
Initializes a new signing operation for signing with recovery.
|
byte[] |
signRecoverSingle(Mechanism mechanism,
long keyHandle,
byte[] data) |
byte[] |
signSingle(Mechanism mechanism,
long keyHandle,
byte[] data) |
void |
signUpdate(byte[] dataPart)
This method can be used to sign multiple pieces of data; e.g.
|
void |
signUpdate(byte[] in,
int inOfs,
int inLen)
This method can be used to sign multiple pieces of data; e.g.
|
String |
toString()
Returns the string representation of this object.
|
long |
unwrapKey(Mechanism mechanism,
long unwrappingKeyHandle,
byte[] wrappedKey,
AttributeVector keyTemplate)
Unwraps (decrypts) the given encrypted key with the unwrapping key using the given mechanism.
|
void |
verify(byte[] data,
byte[] signature)
Verifies the given signature against the given data with the key and mechanism given to the
verifyInit method.
|
void |
verifyFinal(byte[] signature)
This method finalizes a verification operation.
|
void |
verifyInit(Mechanism mechanism,
long keyHandle)
Initializes a new verification operation.
|
void |
verifyMessage(CkParams params,
byte[] data,
byte[] signature)
Verifies a signature on a message in a single part operation.
|
void |
verifyMessageBegin(CkParams params)
Begins a multipart message verification operation.
|
void |
verifyMessageNext(CkParams params,
byte[] data,
byte[] signature)
continues a multiple-part message verification operation, processing another data
part, or finishes a multiple-part message verification operation, checking the signature.
|
byte[] |
verifyRecover(byte[] data)
Verifies the given data with the key and mechanism given to the verifyRecoverInit method.
|
void |
verifyRecoverInit(Mechanism mechanism,
long keyHandle)
Initializes a new verification operation for verification with data recovery.
|
byte[] |
verifyRecoverSingle(Mechanism mechanism,
long keyHandle,
byte[] data) |
void |
verifySingle(Mechanism mechanism,
long keyHandle,
byte[] data,
byte[] signature) |
void |
verifyUpdate(byte[] dataPart)
This method can be used to verify a signature with multiple pieces of data; e.g.
|
byte[] |
wrapKey(Mechanism mechanism,
long wrappingKeyHandle,
long keyHandle)
Wraps (encrypts) the given key with the wrapping key using the given mechanism.
|
protected final Token token
protected Session(Token token, long sessionHandle)
token - The token this session operates with.sessionHandle - The session handle to perform the operations with.public void initPIN(char[] pin)
throws PKCS11Exception
pin - The new user-PIN. This parameter may be null, if the token has a protected
authentication path. Refer to the PKCS#11 standard for details.PKCS11Exception - If the session has not the right to set the PIN of if the operation fails for some
other reason.public void setPIN(char[] oldPin,
char[] newPin)
throws PKCS11Exception
oldPin - The old (current) user-PIN.newPin - The new value for the user-PIN.PKCS11Exception - If setting the new PIN fails.public void closeSession()
throws PKCS11Exception
PKCS11Exception - If closing the session failed.public long getSessionHandle()
public SessionInfo getSessionInfo() throws PKCS11Exception
PKCS11Exception - If getting the information failed.public void sessionCancel()
throws PKCS11Exception
PKCS11Exception - If terminating operations failedpublic PKCS11Module getModule()
public Token getToken()
public byte[] getOperationState()
throws PKCS11Exception
PKCS11Exception - If saving the state fails or is not possible.public void setOperationState(byte[] operationState,
long encryptionKeyHandle,
long authenticationKeyHandle)
throws PKCS11Exception
operationState - The previously saved state as returned by getOperationState().encryptionKeyHandle - An encryption or decryption key handle, if an encryption or
decryption operation was saved which should be continued, but
the keys could not be saved.authenticationKeyHandle - A signing, verification of MAC key handle, if a signing,
verification or MAC operation needs to be restored that could
not save the key.PKCS11Exception - If restoring the state fails.public void setSessionHandle(long sessionHandle)
public boolean isSetUtf8Encoding()
public void login(long userType,
char[] pin)
throws PKCS11Exception
userType - CKU_SO for the security officer or CKU_USER to login the user.pin - The PIN. The security officer-PIN or the user-PIN depending on the userType parameter.PKCS11Exception - If login fails.public void loginUser(long userType,
char[] pin,
char[] username)
throws PKCS11Exception
userType - CKU_SO for the security officer or CKU_USER to log in the user.pin - The PIN. The security officer-PIN or the user-PIN depending on the userType parameter.username - The username of the user.PKCS11Exception - If login fails.public void logout()
throws PKCS11Exception
PKCS11Exception - If logging out the session fails.public long createObject(AttributeVector template) throws PKCS11Exception
AttributesTemplate desKeyTemplate = AttributesTemplate.newSecretKey(CKK_DES3);
// the key type is set by the DESSecretKey's constructor, so you need not do it
desKeyTemplate.value(myDesKeyValueAs8BytesLongByteArray)
.token(true)
.private(true);
.encrypt(true);
.decrypt(true);
...
long theCreatedDESKeyObjectHandle = userSession.createObject(desKeyTemplate);
Refer to the PKCS#11 standard to find out what attributes must be set for certain types
of objects to create them on the token.template - The template object that holds all values that the new object on the token should
contain.PKCS11Exception - If the creation of the new object fails. If it fails, the no new object was
created on the token.public long createPrivateKeyObject(AttributeVector template, PublicKey publicKey) throws PKCS11Exception
PKCS11Exceptionpublic long createECPrivateKeyObject(AttributeVector template, byte[] ecPoint) throws PKCS11Exception
template - Template of the EC private key.ecPoint - The encoded EC-Point. May be null.PKCS11Exception - If creating the object fails for some reason.public long copyObject(long sourceObjectHandle,
AttributeVector template)
throws PKCS11Exception
sourceObjectHandle - The source object of the copy operation.template - A template object whose attribute values are used for the new object; i.e. they have
higher priority than the attribute values from the source object. May be null; in that
case the new object is just a one-to-one copy of the sourceObject.PKCS11Exception - If copying the object fails for some reason.public void setAttributeValues(long objectToUpdateHandle,
AttributeVector template)
throws PKCS11Exception
objectToUpdateHandle - The attributes of this object get updated.template - Gets all present attributes of this template object and sets this
attributes at the objectToUpdate.PKCS11Exception - If updating the attributes fails. All or no attributes are updated.public void destroyObject(long objectHandle)
throws PKCS11Exception
objectHandle - The object handle that should be destroyed.PKCS11Exception - If the object could not be destroyed.public long getObjectSize(long objectHandle)
throws PKCS11Exception
objectHandle - The object to get the size for.PKCS11Exception - If determining the size fails.public void findObjectsInit(AttributeVector template) throws PKCS11Exception
template - The object that serves as a template for searching. If this object is null, the find
operation will find all objects that this session can see. Notice, that only a user
session will see private objects.PKCS11Exception - If initializing the find operation fails.public long[] findObjects(int maxObjectCount)
throws PKCS11Exception
maxObjectCount - Specifies how many objects to return with this call.PKCS11Exception - A plain PKCS11Exception if something during PKCS11 FindObject went wrong, a
PKCS11Exception with a nested PKCS11Exception if the Exception is raised during
object parsing.public void findObjectsFinal()
throws PKCS11Exception
PKCS11Exception - If finalizing the current find operation was not possible.public long[] findAllObjectsSingle(AttributeVector template) throws PKCS11Exception
PKCS11Exceptionpublic long[] findObjectsSingle(AttributeVector template, int maxObjectCount) throws PKCS11Exception
PKCS11Exceptionpublic void encryptInit(Mechanism mechanism, long keyHandle) throws PKCS11Exception
mechanism - The mechanism to use; e.g. Mechanism.DES_CBC.keyHandle - The decryption key to use.PKCS11Exception - If initializing this operation failed.public byte[] encrypt(byte[] plaintext)
throws PKCS11Exception
plaintext - the to-be-encrypted datanull.PKCS11Exception - If encrypting failed.public byte[] encryptSingle(Mechanism mechanism, long keyHandle, byte[] plaintext) throws PKCS11Exception
PKCS11Exceptionpublic byte[] encryptUpdate(byte[] plaintextPat)
throws PKCS11Exception
plaintextPat - Piece of the to-be-encrypted datanull.PKCS11Exception - If encrypting the data failed.public byte[] encryptFinal()
throws PKCS11Exception
null.PKCS11Exception - If calculating the final result failed.public void messageEncryptInit(Mechanism mechanism, long keyHandle) throws PKCS11Exception
mechanism - The mechanism to use; e.g. Mechanism.DES_CBC.keyHandle - The decryption key to use.PKCS11Exception - If initializing this operation failed.public byte[] encryptMessage(CkParams params, byte[] associatedData, byte[] plaintext) throws PKCS11Exception
params - The parameter objectassociatedData - The associated Data for AEAD Mechanismsplaintext - The plaintext getting encryptednull.PKCS11Exception - If encrypting failed.public void encryptMessageBegin(CkParams params, byte[] associatedData) throws PKCS11Exception
params - The IV or nonceassociatedData - The associated Data for AEAD MechanismsPKCS11Exception - in case of error.public byte[] encryptMessageNext(CkParams params, byte[] plaintext, boolean isLastOperation) throws PKCS11Exception
params - The parameter objectplaintext - The associated Data for AEAD MechanismsisLastOperation - If this is the last part of the multipart message encryption, this should be truenull.PKCS11Exception - in case of error.public void messageEncryptFinal()
throws PKCS11Exception
PKCS11Exception - in case of error.public void decryptInit(Mechanism mechanism, long keyHandle) throws PKCS11Exception
mechanism - The mechanism to use; e.g. Mechanism.DES_CBC.keyHandle - The decryption key to use.PKCS11Exception - If initializing this operation failed.public byte[] decrypt(byte[] ciphertext)
throws PKCS11Exception
ciphertext - the to-be-decrypted datanull.PKCS11Exception - If decrypting failed.public byte[] decryptSingle(Mechanism mechanism, long keyHandle, byte[] ciphertext) throws PKCS11Exception
PKCS11Exceptionpublic byte[] decryptUpdate(byte[] ciphertextPart)
throws PKCS11Exception
ciphertextPart - Piece of the to-be-decrypted data for this updatenull.PKCS11Exception - If decrypting the data failed.public byte[] decryptFinal()
throws PKCS11Exception
null.PKCS11Exception - If calculating the final result failed.public void messageDecryptInit(Mechanism mechanism, long keyHandle) throws PKCS11Exception
mechanism - The mechanism to use; e.g. Mechanism.DES_CBC.keyHandle - The decryption key to use.PKCS11Exception - If initializing this operation failed.public byte[] decryptMessage(CkParams params, byte[] associatedData, byte[] ciphertext) throws PKCS11Exception
params - The parameter objectassociatedData - The associated Data for AEAD Mechanismsciphertext - The to-be-decrypted datanull.PKCS11Exception - If encrypting failed.public void decryptMessageBegin(CkParams params, byte[] associatedData) throws PKCS11Exception
params - The parameter objectassociatedData - The associated Data for AEAD MechanismsPKCS11Exception - in case of error.public byte[] decryptMessageNext(CkParams params, byte[] ciphertext, boolean isLastOperation) throws PKCS11Exception
params - The parameter objectciphertext - The ciphertext getting decryptedisLastOperation - If this is the last part of the multipart message encryption, this should be truenull.PKCS11Exception - in case of error.public void messageDecryptFinal()
throws PKCS11Exception
PKCS11Exception - in case of error.public void digestInit(Mechanism mechanism) throws PKCS11Exception
mechanism - The mechanism to use; e.g. Mechanism.SHA_1.PKCS11Exception - If initializing this operation failed.public byte[] digest(byte[] data)
throws PKCS11Exception
data - the to-be-digested datanull.PKCS11Exception - If digesting the data failed.public byte[] digestSingle(Mechanism mechanism, byte[] data) throws PKCS11Exception
PKCS11Exceptionpublic void digestUpdate(byte[] dataPart)
throws PKCS11Exception
dataPart - Piece of the to-be-digested dataPKCS11Exception - If digesting the data failed.public void digestKey(long keyHandle)
throws PKCS11Exception
keyHandle - The key to digest the value of.PKCS11Exception - If digesting the key failed.public byte[] digestFinal()
throws PKCS11Exception
null.PKCS11Exception - If calculating the final message digest failed.public int digestFinal(byte[] out,
int outOfs,
int outLen)
throws PKCS11Exception
out - buffer for the message digestoutOfs - buffer offset for the message digestoutLen - buffer size for the message digestPKCS11Exception - If calculating the final message digest failed.public void signInit(Mechanism mechanism, long keyHandle) throws PKCS11Exception
mechanism - The mechanism to use; e.g. Mechanism.RSA_PKCS.keyHandle - The signing key to use.PKCS11Exception - If initializing this operation failed.public byte[] sign(byte[] data)
throws PKCS11Exception
data - The data to sign.null.PKCS11Exception - If signing the data failed.public byte[] signSingle(Mechanism mechanism, long keyHandle, byte[] data) throws PKCS11Exception
PKCS11Exceptionpublic void signUpdate(byte[] dataPart)
throws PKCS11Exception
dataPart - Piece of the to-be-signed dataPKCS11Exception - If signing the data failed.public void signUpdate(byte[] in,
int inOfs,
int inLen)
throws PKCS11Exception
in - buffer containing the to-be-signed datainOfs - buffer offset of the to-be-signed datainLen - length of the to-be-signed dataPKCS11Exception - If signing the data failed.public byte[] signFinal()
throws PKCS11Exception
null.PKCS11Exception - If calculating the final signature value failed.public void signRecoverInit(Mechanism mechanism, long keyHandle) throws PKCS11Exception
mechanism - The mechanism to use; e.g. Mechanism.RSA_9796.keyHandle - The signing key to use.PKCS11Exception - If initializing this operation failed.public byte[] signRecover(byte[] data)
throws PKCS11Exception
data - the to-be-signed datanull.PKCS11Exception - If signing the data failed.public byte[] signRecoverSingle(Mechanism mechanism, long keyHandle, byte[] data) throws PKCS11Exception
PKCS11Exceptionpublic void messageSignInit(Mechanism mechanism, long keyHandle) throws PKCS11Exception
mechanism - the mechanism parameter to usekeyHandle - the key to sign the data withPKCS11Exception - in case of error.public byte[] signMessage(CkParams params, byte[] data) throws PKCS11Exception
params - the mechanism parameter to usedata - the data to signnull.PKCS11Exception - if signing failed.public void signMessageBegin(CkParams params) throws PKCS11Exception
params - the mechanism parameter to usePKCS11Exception - in case of error.public byte[] signMessageNext(CkParams params, byte[] data, boolean isLastOperation) throws PKCS11Exception
params - the mechanism parameter to usedata - the message to signisLastOperation - specifies if this is the last part of this message.null.PKCS11Exception - in case of error.public void messageSignFinal()
throws PKCS11Exception
PKCS11Exception - in case of error.public void verifyInit(Mechanism mechanism, long keyHandle) throws PKCS11Exception
mechanism - The mechanism to use; e.g. Mechanism.RSA_PKCS.keyHandle - The verification key to use.PKCS11Exception - If initializing this operation failed.public void verify(byte[] data,
byte[] signature)
throws PKCS11Exception
data - The data that was signed.signature - The signature or MAC to verify.PKCS11Exception - If verifying the signature fails. This is also the case, if the signature is
forged.public void verifySingle(Mechanism mechanism, long keyHandle, byte[] data, byte[] signature) throws PKCS11Exception
PKCS11Exceptionpublic void verifyUpdate(byte[] dataPart)
throws PKCS11Exception
dataPart - Piece of the to-be-verified data.PKCS11Exception - If verifying (e.g. digesting) the data failed.public void verifyFinal(byte[] signature)
throws PKCS11Exception
signature - The signature value.PKCS11Exception - If verifying the signature fails. This is also the case, if the signature is
forged.public void verifyRecoverInit(Mechanism mechanism, long keyHandle) throws PKCS11Exception
mechanism - The mechanism to use; e.g. Mechanism.RSA_9796.keyHandle - The verification key to use.PKCS11Exception - If initializing this operation failed.public byte[] verifyRecover(byte[] data)
throws PKCS11Exception
data - the to-be-verified datanull.PKCS11Exception - If signing the data failed.public byte[] verifyRecoverSingle(Mechanism mechanism, long keyHandle, byte[] data) throws PKCS11Exception
PKCS11Exceptionpublic void messageVerifyInit(Mechanism mechanism, long keyHandle) throws PKCS11Exception
mechanism - the mechanism to usekeyHandle - the verification key to usePKCS11Exception - in case of error.public void verifyMessage(CkParams params, byte[] data, byte[] signature) throws PKCS11Exception
params - the mechanism parameter to usedata - the message to verify with the signaturesignature - the signature of the messagePKCS11Exception - if the message cant be verifiedpublic void verifyMessageBegin(CkParams params) throws PKCS11Exception
params - the mechanism parameter to usePKCS11Exception - in case of error.public void verifyMessageNext(CkParams params, byte[] data, byte[] signature) throws PKCS11Exception
params - the mechanism parameter to usedata - the data to be verifiedsignature - NUll if there is data follow, the signature if it is the last part of the signing operationPKCS11Exception - if The Signature is invalidpublic void messageVerifyFinal()
throws PKCS11Exception
PKCS11Exception - in case of error.public byte[] digestEncryptedUpdate(byte[] part)
throws PKCS11Exception
part - The piece of data to digest and encrypt.null.PKCS11Exception - If digesting or encrypting the data failed.public byte[] decryptDigestUpdate(byte[] part)
throws PKCS11Exception
part - The piece of data to decrypt and digest.null.PKCS11Exception - If decrypting or digesting the data failed.public byte[] signEncryptUpdate(byte[] part)
throws PKCS11Exception
part - The piece of data to sign and encrypt.null.PKCS11Exception - If signing or encrypting the data failed.public byte[] decryptVerifyUpdate(byte[] encryptedPart)
throws PKCS11Exception
encryptedPart - The piece of data to decrypt and verify.null.PKCS11Exception - If decrypting or verifying the data failed.public long generateKey(Mechanism mechanism, AttributeVector template) throws PKCS11Exception
mechanism - The mechanism to generate a key for; e.g. Mechanism.DES to generate a DES key.template - The template for the new key or domain parameters; e.g. a DESSecretKey object which
has set certain attributes.PKCS11Exception - If generating a new secret key or domain parameters failed.public PKCS11KeyPair generateKeyPair(Mechanism mechanism, KeyPairTemplate template) throws PKCS11Exception
mechanism - The mechanism to generate a key for; e.g. Mechanism.RSA to generate a new RSA
key-pair.template - The template for the new keypair.PKCS11Exception - If generating a new key-pair failed.public byte[] wrapKey(Mechanism mechanism, long wrappingKeyHandle, long keyHandle) throws PKCS11Exception
mechanism - The mechanism to use for wrapping the key.wrappingKeyHandle - The key to use for wrapping (encrypting).keyHandle - The key to wrap (encrypt).null.PKCS11Exception - If wrapping the key failed.public long unwrapKey(Mechanism mechanism, long unwrappingKeyHandle, byte[] wrappedKey, AttributeVector keyTemplate) throws PKCS11Exception
mechanism - The mechanism to use for unwrapping the key.unwrappingKeyHandle - The key to use for unwrapping (decrypting).wrappedKey - The encrypted key to unwrap (decrypt).keyTemplate - The template for creating the new key object.PKCS11Exception - If unwrapping the key or creating a new key object failed.public long deriveKey(Mechanism mechanism, long baseKeyHandle, AttributeVector template) throws PKCS11Exception
mechanism - The mechanism to use for deriving the new key from the base key.baseKeyHandle - The key to use as base for derivation.template - The template for creating the new key object.PKCS11Exception - If deriving the key or creating a new key object failed.public void seedRandom(byte[] seed)
throws PKCS11Exception
seed - The seed bytes to mix in.PKCS11Exception - If mixing in the seed failed.public byte[] generateRandom(int numberOfBytesToGenerate)
throws PKCS11Exception
numberOfBytesToGenerate - The number of random bytes to generate.PKCS11Exception - If generating random bytes failed.public void getFunctionStatus()
throws PKCS11Exception
PKCS11Exception - Throws always a PKCS11Exception.public void cancelFunction()
throws PKCS11Exception
PKCS11Exception - Throws always a PKCS11Exception.public boolean isRwSession()
throws PKCS11Exception
PKCS11Exception - in case of error.public String toString()
public String getStringAttrValue(long objectHandle, long attributeType) throws PKCS11Exception
PKCS11Exceptionpublic AttributeVector getAttrValues(long objectHandle, long... attributeTypes) throws PKCS11Exception
PKCS11Exceptionpublic AttributeVector getAttrValues(long objectHandle, List<Long> attributeTypes) throws PKCS11Exception
PKCS11Exceptionpublic AttributeVector getDefaultAttrValues(long objectHandle) throws PKCS11Exception
objectHandle - the object handle.PKCS11Exception - If getting attributes failed.public AttributeVector getDefaultAttrValues(long objectHandle, boolean withSensitiveVAttributes) throws PKCS11Exception
objectHandle - the object handle.withSensitiveVAttributes - whether to get the attributes which contain sensitive values.PKCS11Exception - If getting attributes failed.Copyright © 2023. All rights reserved.