public class Session
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
CKU_CONTEXT_SPECIFIC |
static int |
CKU_SO |
static int |
CKU_USER |
Modifier and Type | Method and Description |
---|---|
int |
close()
Close the current session
Calls C_CloseSession to close a session between an application and a token
|
byte[] |
decrypt(byte[] data)
Performs an Decrypt operation
Calls C_Decrypt
|
byte[] |
decryptDigestUpdate(byte[] data)
Update a DecryptDigest operation
Calls C_DecryptDigestUpdate
|
byte[] |
decryptFinal()
Finalizes a Decrypt operation
Calls C_DecryptFinal
|
int |
decryptInit(Mechanism mech,
Key key)
Inits an Decrypt operation
Calls C_DecryptInit
|
byte[] |
decryptVerifyUpdate(byte[] data)
Update a DecryptVerify operation
Calls C_DecryptVerifyUpdate
|
Key |
deriveKey(Mechanism mechanism,
Key baseKey,
java.util.ArrayList<CryptokiAttribute> template)
Performs a Key Derivation
Calls C_DeriveKey
|
byte[] |
digest(byte[] data)
Performs a Digest operation
Calls C_Digest
|
byte[] |
digestEncryptUpdate(byte[] data,
Key key)
Update a DigestEncrypt operation
Calls C_DigestEncryptUpdate
|
byte[] |
digestFinal()
Finalize a Digest operation
Calls C_DigestFinal
|
int |
digestInit(Mechanism mech)
Inits a Digest operation
Calls C_DigestInit
|
void |
digestKey(Key key)
Digests a Key
Calls C_DigestKey
|
int |
digestUpdate(byte[] data)
Updates a Digest operation
Calls C_DigestUpdate
|
byte[] |
dignEncryptUpdate(byte[] data)
Update a SignEncrypt operation
Calls C_SignEncryptUpdate
|
byte[] |
encrypt(byte[] data)
Performs an Encrypt operation
Calls C_Encrypt
|
byte[] |
encryptFinal()
Finalizes an Encrypt operation
Calls C_EncryptFinal
|
int |
encryptInit(Mechanism mech,
Key key)
Inits an Encrypt operation
Calls C_EncryptInit
|
byte[] |
encryptUpdate(byte[] data)
Updates an Encrypt operation
Calls C_EncryptUpdate
|
Key |
generateKey(Mechanism mech,
java.util.ArrayList<CryptokiAttribute> attList)
Generate a key
Calls C_GenerateKey
|
Key[] |
generateKeyPair(Mechanism mech,
java.util.ArrayList<CryptokiAttribute> attListPub,
java.util.ArrayList<CryptokiAttribute> attListPri)
Generate a key pair
Calls C_GenerateKeyPair
|
byte[] |
generateRandom(int len)
Generate a random number
Calls C_GenerateRandom
|
int |
getFunctionStatus()
Gets Function Status
Calls C_GetFunctionStatus
|
SessionInfo |
getInfo()
Session Info
|
CryptokiObjects |
getObjects()
List of objects in the session
|
byte[] |
getOperationState()
Gets Operation State
Calls C_GetOperationState
|
Token |
getToken()
Gets the token where this session is open
|
int |
initPIN(byte[] pin)
Init the PIN
|
int |
initPIN(java.lang.String pin)
Init the PIN
|
boolean |
isLoggedIn()
Determines if a user is logged in
|
boolean |
isOpen()
Determines if a session is open
|
int |
login(int userType,
byte[] pin)
Login to the token
When the user type is either CKU_SO or CKU_USER, if theCalls succeeds, each of the
application's sessions will enter either the "R/W SO Functions" state, the "R/W User
Functions" state, or the "R/O User Functions" state.
|
int |
login(int userType,
java.lang.String pin)
Login to the token
When the user type is either CKU_SO or CKU_USER, if theCalls succeeds, each of the
application's sessions will enter either the "R/W SO Functions" state, the "R/W User
Functions" state, or the "R/O User Functions" state.
|
int |
logout()
Logout
Depending on the current user type, if theCalls succeeds, each of the application’s
sessions will enter either the “R/W Public Session” state or the “R/O Public Session” state.
|
int |
seedRandom(byte[] seed)
Seed Random number generator
Calls C_SeedRandom
|
int |
setOperationState(byte[] data,
Key encKey,
Key autKey)
Sets Operation State
Calls C_SetOperationState
|
int |
setPIN(byte[] oldPin,
byte[] newPin)
Set the PIN
SetPIN modifies the PIN of the user that is currently logged in, or the CKU_USER
PIN if the session is not logged in.
|
int |
setPIN(java.lang.String oldPin,
java.lang.String newPin)
Set the PIN
SetPIN modifies the PIN of the user that is currently logged in, or the CKU_USER
PIN if the session is not logged in.
|
byte[] |
sign(byte[] data)
Performs a Signature operation
Calls C_Sign
|
byte[] |
signFinal()
Finalizes a Signature operation
Calls C_SignFinal
|
int |
signInit(Mechanism mech,
Key key)
Inits a Signature operation
Calls C_SignInit
|
byte[] |
signRecover(byte[] data)
Performs a Sign Recover operation
Calls C_SignRecoverremarks>
|
int |
signRecoverInit(Mechanism mech,
Key key)
Inits a Sign Recoveroperation
Calls SignRecoverInit
|
int |
signUpdate(byte[] data)
Updates a Signature operation
Calls C_SignUpdate
|
Key |
unwrapKey(Mechanism mech,
Key unwrappingKey,
byte[] wrappedKey,
java.util.ArrayList<CryptokiAttribute> attList)
Unwraps a key
Calls C_UnwrapKey
|
static java.lang.String |
userTypeToString(int cku)
Convert constant value to name.
|
int |
verify(byte[] data,
byte[] signature)
Performs a Verify operation
Calls C_Verify
|
int |
verifyFinal(byte[] signature)
Finalizes a Verify operation
Calls C_VerifyFinal
|
int |
verifyInit(Mechanism mech,
Key key)
Inits a Verify operation
Calls C_VerifyInit
|
int |
verifyRecover(byte[] data,
byte[] signature)
Performs a Verify Recover operation
Calls C_VerifyRecover
|
int |
verifyRecoverInit(Mechanism mech,
Key key)
Inistializes a VerifyRecoverInit operation
Calls C_VerifyRecoverInit
|
int |
verifyUpdate(byte[] data)
Updates a Verify operation
Calls C_VerifyUpdate
|
byte[] |
wrapKey(Mechanism mech,
Key wrappingKey,
Key keyToWrap)
Wraps a key
Calls C_WrapKey
|
public static final int CKU_SO
public static final int CKU_USER
public static final int CKU_CONTEXT_SPECIFIC
public static final java.lang.String userTypeToString(int cku)
cku
- valuepublic Token getToken()
public boolean isLoggedIn()
public boolean isOpen()
public CryptokiObjects getObjects()
public SessionInfo getInfo()
public int close()
public int setPIN(java.lang.String oldPin, java.lang.String newPin)
newPin
- new pinoldPin
- old pinpublic int setPIN(byte[] oldPin, byte[] newPin)
newPin
- new pinoldPin
- old pinpublic int login(int userType, java.lang.String pin)
userType
- user typepin
- pinpublic int login(int userType, byte[] pin)
userType
- user typepin
- pinpublic int logout()
public int initPIN(java.lang.String pin)
pin
- PIN
InitPIN initializes the normal user’s PIN. hSession is the session’s handle; pin points to the normal user’s PIN;
This PIN can contain any valid UTF8 character, but the token may impose subset restrictions.public int initPIN(byte[] pin)
pin
- PIN
InitPIN initializes the normal user’s PIN. hSession is the session’s handle; pin points to the normal user’s PIN;
This PIN can contain any valid UTF8 character, but the token may impose subset restrictions.public int signInit(Mechanism mech, Key key)
key
- Key used for signaturemech
- Signature Mechanismpublic int signUpdate(byte[] data)
data
- data to signpublic byte[] sign(byte[] data)
data
- data to signCryptokiException
- if a PKCS#11 error occurspublic byte[] signFinal()
CryptokiException
- if a PKCS#11 error occurspublic int signRecoverInit(Mechanism mech, Key key)
key
- Key used for signaturemech
- Signature Mechanismpublic byte[] signRecover(byte[] data)
data
- data to signCryptokiException
- if a PKCS#11 error occurspublic int encryptInit(Mechanism mech, Key key)
key
- Key used for signaturemech
- Signature Mechanismpublic byte[] encrypt(byte[] data)
data
- clear textCryptokiException
- if a PKCS#11 error occurspublic byte[] encryptFinal()
CryptokiException
- if a PKCS#11 error occurspublic byte[] encryptUpdate(byte[] data)
data
- clear textCryptokiException
- if a PKCS#11 error occurspublic int verifyInit(Mechanism mech, Key key)
key
- Key used for signaturemech
- Signature Mechanismpublic int verifyUpdate(byte[] data)
data
- data to verifypublic int verify(byte[] data, byte[] signature)
data
- data used as input for the signaturesignature
- signaturepublic int verifyFinal(byte[] signature)
signature
- signaturepublic int verifyRecoverInit(Mechanism mech, Key key)
key
- Key used for signaturemech
- Signature Mechanismpublic int verifyRecover(byte[] data, byte[] signature)
data
- data used as input for the signaturesignature
- signaturepublic int digestInit(Mechanism mech)
mech
- Digest Mechanismpublic byte[] digest(byte[] data)
data
- data to digestCryptokiException
- if a PKCS#11 error occurspublic byte[] digestFinal()
CryptokiException
- if a PKCS#11 error occurspublic int digestUpdate(byte[] data)
data
- data to digestpublic void digestKey(Key key)
key
- Key to digestCryptokiException
- if a PKCS#11 error occurspublic byte[] digestEncryptUpdate(byte[] data, Key key)
data
- data to digest and encryptkey
- Key used for encryptionCryptokiException
- if a PKCS#11 error occurspublic int decryptInit(Mechanism mech, Key key)
key
- Key used for signaturemech
- Signature Mechanismpublic byte[] decrypt(byte[] data)
data
- cipher textCryptokiException
- if a PKCS#11 error occurspublic Key deriveKey(Mechanism mechanism, Key baseKey, java.util.ArrayList<CryptokiAttribute> template)
mechanism
- mechanism for key derivationbaseKey
- base key for derivationtemplate
- template for the new derived keyCryptokiException
- if a PKCS#11 error occurspublic byte[] decryptFinal()
CryptokiException
- if a PKCS#11 error occurspublic byte[] decryptDigestUpdate(byte[] data)
data
- data to decrypt and digestCryptokiException
- if a PKCS#11 error occurspublic byte[] decryptVerifyUpdate(byte[] data)
data
- data to decryptCryptokiException
- if a PKCS#11 error occurspublic byte[] dignEncryptUpdate(byte[] data)
data
- data sign and encryptCryptokiException
- if a PKCS#11 error occurspublic byte[] wrapKey(Mechanism mech, Key wrappingKey, Key keyToWrap)
mech
- Mechanism for wrappingwrappingKey
- Key used for wrappingkeyToWrap
- Key to wrapCryptokiException
- if a PKCS#11 error occurspublic Key unwrapKey(Mechanism mech, Key unwrappingKey, byte[] wrappedKey, java.util.ArrayList<CryptokiAttribute> attList)
mech
- Mechanism for wrappingunwrappingKey
- Key used for unwrappingwrappedKey
- Key to unwrapattList
- Attribute of the KeyCryptokiException
- if a PKCS#11 error occurspublic Key generateKey(Mechanism mech, java.util.ArrayList<CryptokiAttribute> attList)
mech
- Mechanism for generating the keyattList
- List of attribute for the keyCryptokiException
- if a PKCS#11 error occurspublic Key[] generateKeyPair(Mechanism mech, java.util.ArrayList<CryptokiAttribute> attListPub, java.util.ArrayList<CryptokiAttribute> attListPri)
mech
- Mechanism for generating the keyattListPub
- List of attribute for the public keyattListPri
- List of attribute for the private keyCryptokiException
- if a PKCS#11 error occurspublic byte[] generateRandom(int len)
len
- Length in byte of the number to generateCryptokiException
- if a PKCS#11 error occurspublic int getFunctionStatus()
public byte[] getOperationState()
CryptokiException
- if a PKCS#11 error occurspublic int seedRandom(byte[] seed)
seed
- seed