Botan 3.0.0-alpha0
Crypto and TLS for C&
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
Botan::PKCS11::LowLevel Class Reference

Provides access to all PKCS#11 functions. More...

#include <p11.h>

Public Member Functions

bool C_CancelFunction (SessionHandle session, ReturnValue *return_value=ThrowException) const
 
bool C_CloseAllSessions (SlotId slot_id, ReturnValue *return_value=ThrowException) const
 
bool C_CloseSession (SessionHandle session, ReturnValue *return_value=ThrowException) const
 
bool C_CopyObject (SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ObjectHandle *new_object_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_CreateObject (SessionHandle session, Attribute *attribute_template_ptr, Ulong count, ObjectHandle *object_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_Decrypt (SessionHandle session, Byte *encrypted_data_ptr, Ulong encrypted_data_len, Byte *data_ptr, Ulong *data_len_ptr, ReturnValue *return_value=ThrowException) const
 
template<typename TAllocA , typename TAllocB >
bool C_Decrypt (SessionHandle session, const std::vector< uint8_t, TAllocA > &encrypted_data, std::vector< uint8_t, TAllocB > &decrypted_data, ReturnValue *return_value=ThrowException) const
 
bool C_DecryptDigestUpdate (SessionHandle session, Byte *encrypted_part_ptr, Ulong encrypted_part_len, Byte *part_ptr, Ulong *part_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_DecryptFinal (SessionHandle session, Byte *last_part_ptr, Ulong *last_part_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_DecryptInit (SessionHandle session, Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException) const
 
bool C_DecryptUpdate (SessionHandle session, Byte *encrypted_part_ptr, Ulong encrypted_part_len, Byte *part_ptr, Ulong *part_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_DecryptVerifyUpdate (SessionHandle session, Byte *encrypted_part_ptr, Ulong encrypted_part_len, Byte *part_ptr, Ulong *part_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_DeriveKey (SessionHandle session, Mechanism *mechanism_ptr, ObjectHandle base_key, Attribute *attribute_template_ptr, Ulong attribute_count, ObjectHandle *key_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_DestroyObject (SessionHandle session, ObjectHandle object, ReturnValue *return_value=ThrowException) const
 
bool C_Digest (SessionHandle session, Byte *data_ptr, Ulong data_len, Byte *digest_ptr, Ulong *digest_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_DigestEncryptUpdate (SessionHandle session, Byte *part_ptr, Ulong part_len, Byte *encrypted_part_ptr, Ulong *encrypted_part_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_DigestFinal (SessionHandle session, Byte *digest_ptr, Ulong *digest_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_DigestInit (SessionHandle session, Mechanism *mechanism_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_DigestKey (SessionHandle session, ObjectHandle key, ReturnValue *return_value=ThrowException) const
 
bool C_DigestUpdate (SessionHandle session, Byte *part_ptr, Ulong part_len, ReturnValue *return_value=ThrowException) const
 
bool C_Encrypt (SessionHandle session, Byte *data_ptr, Ulong data_len, Byte *encrypted_data, Ulong *encrypted_data_len_ptr, ReturnValue *return_value=ThrowException) const
 
template<typename TAllocA , typename TAllocB >
bool C_Encrypt (SessionHandle session, const std::vector< uint8_t, TAllocA > &plaintext_data, std::vector< uint8_t, TAllocB > &encrypted_data, ReturnValue *return_value=ThrowException) const
 
bool C_EncryptFinal (SessionHandle session, Byte *last_encrypted_part_ptr, Ulong *last_encrypted_part_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_EncryptInit (SessionHandle session, Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException) const
 
bool C_EncryptUpdate (SessionHandle session, Byte *part_ptr, Ulong part_len, Byte *encrypted_part_ptr, Ulong *encrypted_part_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_Finalize (VoidPtr reserved, ReturnValue *return_value=ThrowException) const
 
bool C_FindObjects (SessionHandle session, ObjectHandle *object_ptr, Ulong max_object_count, Ulong *object_count_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_FindObjectsFinal (SessionHandle session, ReturnValue *return_value=ThrowException) const
 
bool C_FindObjectsInit (SessionHandle session, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
 
bool C_GenerateKey (SessionHandle session, Mechanism *mechanism_ptr, Attribute *attribute_template_ptr, Ulong count, ObjectHandle *key_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_GenerateKeyPair (SessionHandle session, Mechanism *mechanism_ptr, Attribute *public_key_template_ptr, Ulong public_key_attribute_count, Attribute *private_key_template_ptr, Ulong private_key_attribute_count, ObjectHandle *public_key_ptr, ObjectHandle *private_key_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_GenerateRandom (SessionHandle session, Byte *random_data_ptr, Ulong random_len, ReturnValue *return_value=ThrowException) const
 
bool C_GetAttributeValue (SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
 
template<typename TAlloc >
bool C_GetAttributeValue (SessionHandle session, ObjectHandle object, std::map< AttributeType, std::vector< uint8_t, TAlloc > > &attribute_values, ReturnValue *return_value=ThrowException) const
 
bool C_GetFunctionStatus (SessionHandle session, ReturnValue *return_value=ThrowException) const
 
bool C_GetInfo (Info *info_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_GetMechanismInfo (SlotId slot_id, MechanismType type, MechanismInfo *info_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_GetMechanismList (SlotId slot_id, MechanismType *mechanism_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_GetMechanismList (SlotId slot_id, std::vector< MechanismType > &mechanisms, ReturnValue *return_value=ThrowException) const
 
bool C_GetObjectSize (SessionHandle session, ObjectHandle object, Ulong *size_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_GetOperationState (SessionHandle session, Byte *operation_state_ptr, Ulong *operation_state_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_GetSessionInfo (SessionHandle session, SessionInfo *info_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_GetSlotInfo (SlotId slot_id, SlotInfo *info_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_GetSlotList (Bbool token_present, SlotId *slot_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_GetSlotList (bool token_present, std::vector< SlotId > &slot_ids, ReturnValue *return_value=ThrowException) const
 
bool C_GetTokenInfo (SlotId slot_id, TokenInfo *info_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_Initialize (VoidPtr init_args, ReturnValue *return_value=ThrowException) const
 
template<typename TAlloc >
bool C_InitPIN (SessionHandle session, const std::vector< uint8_t, TAlloc > &pin, ReturnValue *return_value=ThrowException) const
 
bool C_InitPIN (SessionHandle session, Utf8Char *pin_ptr, Ulong pin_len, ReturnValue *return_value=ThrowException) const
 
template<typename TAlloc >
bool C_InitToken (SlotId slot_id, const std::vector< uint8_t, TAlloc > &so_pin, const std::string &label, ReturnValue *return_value=ThrowException) const
 
bool C_InitToken (SlotId slot_id, Utf8Char *so_pin_ptr, Ulong so_pin_len, Utf8Char *label_ptr, ReturnValue *return_value=ThrowException) const
 
template<typename TAlloc >
bool C_Login (SessionHandle session, UserType user_type, const std::vector< uint8_t, TAlloc > &pin, ReturnValue *return_value=ThrowException) const
 
bool C_Login (SessionHandle session, UserType user_type, Utf8Char *pin_ptr, Ulong pin_len, ReturnValue *return_value=ThrowException) const
 
bool C_Logout (SessionHandle session, ReturnValue *return_value=ThrowException) const
 
bool C_OpenSession (SlotId slot_id, Flags flags, VoidPtr application, Notify notify, SessionHandle *session_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_SeedRandom (SessionHandle session, const Byte *seed_ptr, Ulong seed_len, ReturnValue *return_value=ThrowException) const
 
bool C_SetAttributeValue (SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
 
template<typename TAlloc >
bool C_SetAttributeValue (SessionHandle session, ObjectHandle object, std::map< AttributeType, std::vector< uint8_t, TAlloc > > &attribute_values, ReturnValue *return_value=ThrowException) const
 
bool C_SetOperationState (SessionHandle session, Byte *operation_state_ptr, Ulong operation_state_len, ObjectHandle encryption_key, ObjectHandle authentication_key, ReturnValue *return_value=ThrowException) const
 
template<typename TAlloc >
bool C_SetPIN (SessionHandle session, const std::vector< uint8_t, TAlloc > &old_pin, const std::vector< uint8_t, TAlloc > &new_pin, ReturnValue *return_value=ThrowException) const
 
bool C_SetPIN (SessionHandle session, Utf8Char *old_pin_ptr, Ulong old_len, Utf8Char *new_pin_ptr, Ulong new_len, ReturnValue *return_value=ThrowException) const
 
bool C_Sign (SessionHandle session, const Byte *data_ptr, Ulong data_len, Byte *signature_ptr, Ulong *signature_len_ptr, ReturnValue *return_value=ThrowException) const
 
template<typename TAllocA , typename TAllocB >
bool C_Sign (SessionHandle session, const std::vector< uint8_t, TAllocA > &data, std::vector< uint8_t, TAllocB > &signature, ReturnValue *return_value=ThrowException) const
 
bool C_SignEncryptUpdate (SessionHandle session, Byte *part_ptr, Ulong part_len, Byte *encrypted_part_ptr, Ulong *encrypted_part_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_SignFinal (SessionHandle session, Byte *signature_ptr, Ulong *signature_len_ptr, ReturnValue *return_value=ThrowException) const
 
template<typename TAlloc >
bool C_SignFinal (SessionHandle session, std::vector< uint8_t, TAlloc > &signature, ReturnValue *return_value=ThrowException) const
 
bool C_SignInit (SessionHandle session, Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException) const
 
bool C_SignRecover (SessionHandle session, Byte *data_ptr, Ulong data_len, Byte *signature_ptr, Ulong *signature_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_SignRecoverInit (SessionHandle session, Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException) const
 
bool C_SignUpdate (SessionHandle session, const Byte *part_ptr, Ulong part_len, ReturnValue *return_value=ThrowException) const
 
template<typename TAlloc >
bool C_SignUpdate (SessionHandle session, const std::vector< uint8_t, TAlloc > &part, ReturnValue *return_value=ThrowException) const
 
bool C_UnwrapKey (SessionHandle session, Mechanism *mechanism_ptr, ObjectHandle unwrapping_key, Byte *wrapped_key_ptr, Ulong wrapped_key_len, Attribute *attribute_template_ptr, Ulong attribute_count, ObjectHandle *key_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_Verify (SessionHandle session, const Byte *data_ptr, Ulong data_len, const Byte *signature_ptr, Ulong signature_len, ReturnValue *return_value=ThrowException) const
 
template<typename TAllocA , typename TAllocB >
bool C_Verify (SessionHandle session, const std::vector< uint8_t, TAllocA > &data, std::vector< uint8_t, TAllocB > &signature, ReturnValue *return_value=ThrowException) const
 
bool C_VerifyFinal (SessionHandle session, const Byte *signature_ptr, Ulong signature_len, ReturnValue *return_value=ThrowException) const
 
bool C_VerifyInit (SessionHandle session, Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException) const
 
bool C_VerifyRecover (SessionHandle session, Byte *signature_ptr, Ulong signature_len, Byte *data_ptr, Ulong *data_len_ptr, ReturnValue *return_value=ThrowException) const
 
bool C_VerifyRecoverInit (SessionHandle session, Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException) const
 
bool C_VerifyUpdate (SessionHandle session, const Byte *part_ptr, Ulong part_len, ReturnValue *return_value=ThrowException) const
 
template<typename TAlloc >
bool C_VerifyUpdate (SessionHandle session, std::vector< uint8_t, TAlloc > part, ReturnValue *return_value=ThrowException) const
 
bool C_WaitForSlotEvent (Flags flags, SlotId *slot_ptr, VoidPtr reserved, ReturnValue *return_value=ThrowException) const
 
bool C_WrapKey (SessionHandle session, Mechanism *mechanism_ptr, ObjectHandle wrapping_key, ObjectHandle key, Byte *wrapped_key_ptr, Ulong *wrapped_key_len_ptr, ReturnValue *return_value=ThrowException) const
 
FunctionListPtr get_functions () const
 
 LowLevel (FunctionListPtr ptr)
 

Static Public Member Functions

static bool C_GetFunctionList (Dynamically_Loaded_Library &pkcs11_module, FunctionListPtr *function_list_ptr_ptr, ReturnValue *return_value=ThrowException)
 

Static Protected Member Functions

static bool handle_return_value (const CK_RV function_result, ReturnValue *return_value)
 

Detailed Description

Provides access to all PKCS#11 functions.

Definition at line 903 of file p11.h.

Constructor & Destructor Documentation

◆ LowLevel()

Botan::PKCS11::LowLevel::LowLevel ( FunctionListPtr  ptr)
explicit
Parameters
ptrthe functon list pointer to use. Can be retrieved via LowLevel::C_GetFunctionList

Definition at line 71 of file p11.cpp.

71 :
72 m_func_list_ptr(ptr)
73 {
74 if(m_func_list_ptr == nullptr)
75 {
76 throw Invalid_Argument("Invalid PKCS#11 function list ptr");
77 }
78 }

Member Function Documentation

◆ C_CancelFunction()

bool Botan::PKCS11::LowLevel::C_CancelFunction ( SessionHandle  session,
ReturnValue return_value = ThrowException 
) const

C_CancelFunction is a legacy function; it cancels a function running in parallel.

Parameters
sessionthe session's handle
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • FunctionFailed
  • FunctionNotParallel
  • GeneralError
  • HostMemory
  • SessionHandleInvalid
  • SessionClosed
Returns
true on success, false otherwise

Definition at line 767 of file p11.cpp.

769 {
770 return handle_return_value(m_func_list_ptr->C_CancelFunction(session), return_value);
771 }
static bool handle_return_value(const CK_RV function_result, ReturnValue *return_value)
Definition: p11.cpp:25

References handle_return_value().

◆ C_CloseAllSessions()

bool Botan::PKCS11::LowLevel::C_CloseAllSessions ( SlotId  slot_id,
ReturnValue return_value = ThrowException 
) const

C_CloseAllSessions closes all sessions with a token.

Parameters
slot_idthe token's slot
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • SlotIdInvalid
  • TokenNotPresent
Returns
true on success, false otherwise

Definition at line 250 of file p11.cpp.

252 {
253 return handle_return_value(m_func_list_ptr->C_CloseAllSessions(slot_id), return_value);
254 }

References handle_return_value().

◆ C_CloseSession()

bool Botan::PKCS11::LowLevel::C_CloseSession ( SessionHandle  session,
ReturnValue return_value = ThrowException 
) const

C_CloseSession closes a session between an application and a token.

Parameters
sessionthe session's handle
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 244 of file p11.cpp.

246 {
247 return handle_return_value(m_func_list_ptr->C_CloseSession(session), return_value);
248 }

References handle_return_value().

Referenced by Botan::PKCS11::Session::~Session().

◆ C_CopyObject()

bool Botan::PKCS11::LowLevel::C_CopyObject ( SessionHandle  session,
ObjectHandle  object,
Attribute attribute_template_ptr,
Ulong  count,
ObjectHandle new_object_ptr,
ReturnValue return_value = ThrowException 
) const

C_CopyObject copies an object, creating a new object for the copy.

Parameters
sessionthe session's handle
objectthe object's handle
attribute_template_ptrtemplate for new object
countattributes in template
new_object_ptrreceives handle of copy
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ActionProhibited
  • ArgumentsBad
  • AttributeReadOnly
  • AttributeTypeInvalid
  • AttributeValueInvalid
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • ObjectHandleInvalid
  • OK
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnly
  • TemplateInconsistent
  • TokenWriteProtected
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 311 of file p11.cpp.

317 {
318 return handle_return_value(m_func_list_ptr->C_CopyObject(session, object, attribute_template_ptr, count,
319 new_object_ptr), return_value);
320 }

References handle_return_value().

Referenced by Botan::PKCS11::Object::copy().

◆ C_CreateObject()

bool Botan::PKCS11::LowLevel::C_CreateObject ( SessionHandle  session,
Attribute attribute_template_ptr,
Ulong  count,
ObjectHandle object_ptr,
ReturnValue return_value = ThrowException 
) const

C_CreateObject creates a new object.

Parameters
sessionthe session's handle
attribute_template_ptrthe object's template
countattributes in template
object_ptrgets new object's handle.
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • AttributeReadOnly
  • AttributeTypeInvalid
  • AttributeValueInvalid
  • CryptokiNotInitialized
  • CurveNotSupported
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • DomainParamsInvalid
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnly
  • TemplateIncomplete
  • TemplateInconsistent
  • TokenWriteProtected
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 301 of file p11.cpp.

306 {
307 return handle_return_value(m_func_list_ptr->C_CreateObject(session, attribute_template_ptr, count, object_ptr),
308 return_value);
309 }

References handle_return_value().

◆ C_Decrypt() [1/2]

bool Botan::PKCS11::LowLevel::C_Decrypt ( SessionHandle  session,
Byte encrypted_data_ptr,
Ulong  encrypted_data_len,
Byte data_ptr,
Ulong data_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_Decrypt decrypts encrypted data in a single part.

Parameters
sessionsession's handle
encrypted_data_ptrciphertext
encrypted_data_lenciphertext length
data_ptrgets plaintext
data_len_ptrgets p-text size
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • EncryptedDataInvalid
  • EncryptedDataLenRange
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 432 of file p11.cpp.

438 {
439 return handle_return_value(m_func_list_ptr->C_Decrypt(session, encrypted_data_ptr, encrypted_data_len, data_ptr,
440 data_len_ptr), return_value);
441 }

References handle_return_value().

◆ C_Decrypt() [2/2]

template<typename TAllocA , typename TAllocB >
bool Botan::PKCS11::LowLevel::C_Decrypt ( SessionHandle  session,
const std::vector< uint8_t, TAllocA > &  encrypted_data,
std::vector< uint8_t, TAllocB > &  decrypted_data,
ReturnValue return_value = ThrowException 
) const
inline

C_Decrypt decrypts encrypted data in a single part.

Parameters
sessionsession's handle
encrypted_dataciphertext
decrypted_datagets plaintext
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • EncryptedDataInvalid
  • EncryptedDataLenRange
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 1945 of file p11.h.

1949 {
1950 Ulong decrypted_size = 0;
1951 if(!C_Decrypt(session,
1952 const_cast<Byte*>((encrypted_data.data())),
1953 static_cast<Ulong>(encrypted_data.size()),
1954 nullptr, &decrypted_size,
1955 return_value))
1956 {
1957 return false;
1958 }
1959
1960 decrypted_data.resize(decrypted_size);
1961 if(!C_Decrypt(session,
1962 const_cast<Byte*>(encrypted_data.data()),
1963 static_cast<Ulong>(encrypted_data.size()),
1964 decrypted_data.data(),
1965 &decrypted_size, return_value))
1966 {
1967 return false;
1968 }
1969 decrypted_data.resize(decrypted_size);
1970 return true;
1971 }
bool C_Decrypt(SessionHandle session, Byte *encrypted_data_ptr, Ulong encrypted_data_len, Byte *data_ptr, Ulong *data_len_ptr, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:432
CK_ULONG Ulong
Definition: p11.h:838
CK_BYTE Byte
Definition: p11.h:849

◆ C_DecryptDigestUpdate()

bool Botan::PKCS11::LowLevel::C_DecryptDigestUpdate ( SessionHandle  session,
Byte encrypted_part_ptr,
Ulong  encrypted_part_len,
Byte part_ptr,
Ulong part_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_DecryptDigestUpdate continues a multiple-part decryption and digesting operation.

Parameters
sessionsession's handle
encrypted_part_ptrciphertext
encrypted_part_lenciphertext length
part_ptrgets plaintext
part_len_ptrgets plaintext len
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • EncryptedDataInvalid
  • EncryptedDataLenRange
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 639 of file p11.cpp.

645 {
646 return handle_return_value(m_func_list_ptr->C_DecryptDigestUpdate(session, encrypted_part_ptr, encrypted_part_len,
647 part_ptr, part_len_ptr), return_value);
648 }

References handle_return_value().

◆ C_DecryptFinal()

bool Botan::PKCS11::LowLevel::C_DecryptFinal ( SessionHandle  session,
Byte last_part_ptr,
Ulong last_part_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_DecryptFinal finishes a multiple-part decryption operation.

Parameters
sessionthe session's handle
last_part_ptrgets plaintext
last_part_len_ptrp-text size
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • EncryptedDataInvalid
  • EncryptedDataLenRange
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 454 of file p11.cpp.

458 {
459 return handle_return_value(m_func_list_ptr->C_DecryptFinal(session, last_part_ptr, last_part_len_ptr), return_value);
460 }

References handle_return_value().

◆ C_DecryptInit()

bool Botan::PKCS11::LowLevel::C_DecryptInit ( SessionHandle  session,
Mechanism mechanism_ptr,
ObjectHandle  key,
ReturnValue return_value = ThrowException 
) const

C_DecryptInit initializes a decryption operation.

Parameters
sessionthe session's handle
mechanism_ptrthe decryption mechanism
keyhandle of decryption key
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • KeyFunctionNotPermitted
  • KeyHandleInvalid
  • KeySizeRange
  • KeyTypeInconsistent
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 424 of file p11.cpp.

428 {
429 return handle_return_value(m_func_list_ptr->C_DecryptInit(session, mechanism_ptr, key), return_value);
430 }

References handle_return_value().

◆ C_DecryptUpdate()

bool Botan::PKCS11::LowLevel::C_DecryptUpdate ( SessionHandle  session,
Byte encrypted_part_ptr,
Ulong  encrypted_part_len,
Byte part_ptr,
Ulong part_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_DecryptUpdate continues a multiple-part decryption operation.

Parameters
sessionsession's handle
encrypted_part_ptrencrypted data
encrypted_part_leninput length
part_ptrgets plaintext
part_len_ptrp-text size
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • EncryptedDataInvalid
  • EncryptedDataLenRange
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 443 of file p11.cpp.

449 {
450 return handle_return_value(m_func_list_ptr->C_DecryptUpdate(session, encrypted_part_ptr, encrypted_part_len, part_ptr,
451 part_len_ptr), return_value);
452 }

References handle_return_value().

◆ C_DecryptVerifyUpdate()

bool Botan::PKCS11::LowLevel::C_DecryptVerifyUpdate ( SessionHandle  session,
Byte encrypted_part_ptr,
Ulong  encrypted_part_len,
Byte part_ptr,
Ulong part_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_DecryptVerifyUpdate continues a multiple-part decryption and verify operation.

Parameters
sessionsession's handle
encrypted_part_ptrciphertext
encrypted_part_lenciphertext length
part_ptrgets plaintext
part_len_ptrgets p-text length
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • EncryptedDataInvalid
  • EncryptedDataLenRange
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 661 of file p11.cpp.

667 {
668 return handle_return_value(m_func_list_ptr->C_DecryptVerifyUpdate(session, encrypted_part_ptr, encrypted_part_len,
669 part_ptr, part_len_ptr), return_value);
670 }

References handle_return_value().

◆ C_DeriveKey()

bool Botan::PKCS11::LowLevel::C_DeriveKey ( SessionHandle  session,
Mechanism mechanism_ptr,
ObjectHandle  base_key,
Attribute attribute_template_ptr,
Ulong  attribute_count,
ObjectHandle key_ptr,
ReturnValue return_value = ThrowException 
) const

C_DeriveKey derives a key from a base key, creating a new key object.

Parameters
sessionsession's handle
mechanism_ptrkey deriv. mech.
base_keybase key
attribute_template_ptrnew key template
attribute_counttemplate length
key_ptrgets new handle
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • AttributeReadOnly
  • AttributeTypeInvalid
  • AttributeValueInvalid
  • CryptokiNotInitialized
  • CurveNotSupported
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • DomainParamsInvalid
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • KeyHandleInvalid
  • KeySizeRange
  • KeyTypeInconsistent
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnly
  • TemplateIncomplete
  • TemplateInconsistent
  • TokenWriteProtected
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 727 of file p11.cpp.

734 {
735 return handle_return_value(m_func_list_ptr->C_DeriveKey(session, mechanism_ptr, base_key, attribute_template_ptr,
736 attribute_count, key_ptr), return_value);
737 }

References handle_return_value().

◆ C_DestroyObject()

bool Botan::PKCS11::LowLevel::C_DestroyObject ( SessionHandle  session,
ObjectHandle  object,
ReturnValue return_value = ThrowException 
) const

C_DestroyObject destroys an object.

Parameters
sessionthe session's handle
objectthe object's handle
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ActionProhibited
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • ObjectHandleInvalid
  • OK
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnly
  • TokenWriteProtected
Returns
true on success, false otherwise

Definition at line 322 of file p11.cpp.

325 {
326 return handle_return_value(m_func_list_ptr->C_DestroyObject(session, object), return_value);
327 }

References handle_return_value().

Referenced by Botan::PKCS11::Object::destroy().

◆ C_Digest()

bool Botan::PKCS11::LowLevel::C_Digest ( SessionHandle  session,
Byte data_ptr,
Ulong  data_len,
Byte digest_ptr,
Ulong digest_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_Digest digests data in a single part.

Parameters
sessionthe session's handle
data_ptrdata to be digested
data_lenbytes of data to digest
digest_ptrgets the message digest
digest_len_ptrgets digest length
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 471 of file p11.cpp.

477 {
478 return handle_return_value(m_func_list_ptr->C_Digest(session, data_ptr, data_len, digest_ptr, digest_len_ptr),
479 return_value);
480 }

References handle_return_value().

◆ C_DigestEncryptUpdate()

bool Botan::PKCS11::LowLevel::C_DigestEncryptUpdate ( SessionHandle  session,
Byte part_ptr,
Ulong  part_len,
Byte encrypted_part_ptr,
Ulong encrypted_part_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_DigestEncryptUpdate continues a multiple-part digesting and encryption operation.

Parameters
sessionsession's handle
part_ptrthe plaintext data
part_lenplaintext length
encrypted_part_ptrgets ciphertext
encrypted_part_len_ptrgets c-text length
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 628 of file p11.cpp.

634 {
635 return handle_return_value(m_func_list_ptr->C_DigestEncryptUpdate(session, part_ptr, part_len, encrypted_part_ptr,
636 encrypted_part_len_ptr), return_value);
637 }

References handle_return_value().

◆ C_DigestFinal()

bool Botan::PKCS11::LowLevel::C_DigestFinal ( SessionHandle  session,
Byte digest_ptr,
Ulong digest_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_DigestFinal finishes a multiple-part message-digesting operation.

Parameters
sessionthe session's handle
digest_ptrgets the message digest
digest_len_ptrgets uint8_t count of digest
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 497 of file p11.cpp.

501 {
502 return handle_return_value(m_func_list_ptr->C_DigestFinal(session, digest_ptr, digest_len_ptr), return_value);
503 }

References handle_return_value().

◆ C_DigestInit()

bool Botan::PKCS11::LowLevel::C_DigestInit ( SessionHandle  session,
Mechanism mechanism_ptr,
ReturnValue return_value = ThrowException 
) const

C_DigestInit initializes a message-digesting operation.

Parameters
sessionthe session's handle
mechanism_ptrthe digesting mechanism
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 464 of file p11.cpp.

467 {
468 return handle_return_value(m_func_list_ptr->C_DigestInit(session, mechanism), return_value);
469 }

References handle_return_value().

◆ C_DigestKey()

bool Botan::PKCS11::LowLevel::C_DigestKey ( SessionHandle  session,
ObjectHandle  key,
ReturnValue return_value = ThrowException 
) const

C_DigestKey continues a multi-part message-digesting operation, by digesting the value of a secret key as part of the data already digested.

Parameters
sessionthe session's handle
keysecret key to digest
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • KeyHandleInvalid
  • KeyIndigestible
  • KeySizeRange
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 490 of file p11.cpp.

493 {
494 return handle_return_value(m_func_list_ptr->C_DigestKey(session, key), return_value);
495 }

References handle_return_value().

◆ C_DigestUpdate()

bool Botan::PKCS11::LowLevel::C_DigestUpdate ( SessionHandle  session,
Byte part_ptr,
Ulong  part_len,
ReturnValue return_value = ThrowException 
) const

C_DigestUpdate continues a multiple-part message-digesting operation.

Parameters
sessionthe session's handle
part_ptrdata to be digested
part_lenbytes of data to be digested
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 482 of file p11.cpp.

486 {
487 return handle_return_value(m_func_list_ptr->C_DigestUpdate(session, part_ptr, part_len), return_value);
488 }

References handle_return_value().

◆ C_Encrypt() [1/2]

bool Botan::PKCS11::LowLevel::C_Encrypt ( SessionHandle  session,
Byte data_ptr,
Ulong  data_len,
Byte encrypted_data,
Ulong encrypted_data_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_Encrypt encrypts single-part data.

Parameters
sessionsession's handle
data_ptrthe plaintext data
data_lensize of plaintext data in bytes
encrypted_datagets ciphertext
encrypted_data_len_ptrgets c-text size
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataInvalid
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 391 of file p11.cpp.

397 {
398 return handle_return_value(m_func_list_ptr->C_Encrypt(session, data_ptr, data_len, encrypted_data_ptr,
399 encrypted_data_len_ptr), return_value);
400 }

References handle_return_value().

◆ C_Encrypt() [2/2]

template<typename TAllocA , typename TAllocB >
bool Botan::PKCS11::LowLevel::C_Encrypt ( SessionHandle  session,
const std::vector< uint8_t, TAllocA > &  plaintext_data,
std::vector< uint8_t, TAllocB > &  encrypted_data,
ReturnValue return_value = ThrowException 
) const
inline

C_Encrypt encrypts single-part data.

Parameters
sessionsession's handle
plaintext_datathe plaintext data
encrypted_datagets ciphertext
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataInvalid
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 1807 of file p11.h.

1811 {
1812 Ulong encrypted_size = 0;
1813 if(!C_Encrypt(session,
1814 const_cast<Byte*>((plaintext_data.data())),
1815 static_cast<Ulong>(plaintext_data.size()),
1816 nullptr, &encrypted_size,
1817 return_value))
1818 {
1819 return false;
1820 }
1821
1822 encrypted_data.resize(encrypted_size);
1823 if (!C_Encrypt(session,
1824 const_cast<Byte*>(plaintext_data.data()),
1825 static_cast<Ulong>(plaintext_data.size()),
1826 encrypted_data.data(),
1827 &encrypted_size, return_value))
1828 {
1829 return false;
1830 }
1831 encrypted_data.resize(encrypted_size);
1832 return true;
1833 }
bool C_Encrypt(SessionHandle session, Byte *data_ptr, Ulong data_len, Byte *encrypted_data, Ulong *encrypted_data_len_ptr, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:391

◆ C_EncryptFinal()

bool Botan::PKCS11::LowLevel::C_EncryptFinal ( SessionHandle  session,
Byte last_encrypted_part_ptr,
Ulong last_encrypted_part_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_EncryptFinal finishes a multiple-part encryption operation.

Parameters
sessionsession handle
last_encrypted_part_ptrlast c-text
last_encrypted_part_len_ptrgets last size
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 413 of file p11.cpp.

417 {
418 return handle_return_value(m_func_list_ptr->C_EncryptFinal(session, last_encrypted_part_ptr,
419 last_encrypted_part_len_ptr), return_value);
420 }

References handle_return_value().

◆ C_EncryptInit()

bool Botan::PKCS11::LowLevel::C_EncryptInit ( SessionHandle  session,
Mechanism mechanism_ptr,
ObjectHandle  key,
ReturnValue return_value = ThrowException 
) const

C_EncryptInit initializes an encryption operation.

Parameters
sessionthe session's handle
mechanism_ptrthe encryption mechanism
keyhandle of encryption key
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • KeyFunctionNotPermitted
  • KeyHandleInvalid
  • KeySizeRange
  • KeyTypeInconsistent
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 383 of file p11.cpp.

387 {
388 return handle_return_value(m_func_list_ptr->C_EncryptInit(session, mechanism_ptr, key), return_value);
389 }

References handle_return_value().

◆ C_EncryptUpdate()

bool Botan::PKCS11::LowLevel::C_EncryptUpdate ( SessionHandle  session,
Byte part_ptr,
Ulong  part_len,
Byte encrypted_part_ptr,
Ulong encrypted_part_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_EncryptUpdate continues a multiple-part encryption operation.

Parameters
sessionsession's handle
part_ptrthe plaintext data
part_lenplaintext data len
encrypted_part_ptrgets ciphertext
encrypted_part_len_ptrgets c-text size
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 402 of file p11.cpp.

408 {
409 return handle_return_value(m_func_list_ptr->C_EncryptUpdate(session, part_ptr, part_len, encrypted_part_ptr,
410 encrypted_part_len_ptr), return_value);
411 }

References handle_return_value().

◆ C_Finalize()

bool Botan::PKCS11::LowLevel::C_Finalize ( VoidPtr  reserved,
ReturnValue return_value = ThrowException 
) const

C_Finalize indicates that an application is done with the Cryptoki library.

Parameters
reservedreserved. Should be nullptr
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
Returns
true on success, false otherwise

Definition at line 88 of file p11.cpp.

90 {
91 return handle_return_value(m_func_list_ptr->C_Finalize(reserved), return_value);
92 }

References handle_return_value().

◆ C_FindObjects()

bool Botan::PKCS11::LowLevel::C_FindObjects ( SessionHandle  session,
ObjectHandle object_ptr,
Ulong  max_object_count,
Ulong object_count_ptr,
ReturnValue return_value = ThrowException 
) const

C_FindObjects continues a search for token and session objects that match a template, obtaining additional object handles.

Parameters
sessionsession's handle
object_ptrgets obj. handles
max_object_countmax handles to get
object_count_ptractual # returned
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 365 of file p11.cpp.

370 {
371 return handle_return_value(m_func_list_ptr->C_FindObjects(session, object_ptr, max_object_count, object_count_ptr),
372 return_value);
373 }

References handle_return_value().

Referenced by Botan::PKCS11::ObjectFinder::find().

◆ C_FindObjectsFinal()

bool Botan::PKCS11::LowLevel::C_FindObjectsFinal ( SessionHandle  session,
ReturnValue return_value = ThrowException 
) const

C_FindObjectsFinal finishes a search for token and session objects.

Parameters
sessionthe session's handle
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 375 of file p11.cpp.

377 {
378 return handle_return_value(m_func_list_ptr->C_FindObjectsFinal(session), return_value);
379 }

References handle_return_value().

Referenced by Botan::PKCS11::ObjectFinder::finish(), and Botan::PKCS11::ObjectFinder::~ObjectFinder().

◆ C_FindObjectsInit()

bool Botan::PKCS11::LowLevel::C_FindObjectsInit ( SessionHandle  session,
Attribute attribute_template_ptr,
Ulong  count,
ReturnValue return_value = ThrowException 
) const

C_FindObjectsInit initializes a search for token and session objects that match a template.

Parameters
sessionthe session's handle
attribute_template_ptrattribute values to match
countattrs in search template
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • AttributeTypeInvalid
  • AttributeValueInvalid
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 357 of file p11.cpp.

361 {
362 return handle_return_value(m_func_list_ptr->C_FindObjectsInit(session, attribute_template_ptr, count), return_value);
363 }

References handle_return_value().

Referenced by Botan::PKCS11::ObjectFinder::ObjectFinder().

◆ C_GenerateKey()

bool Botan::PKCS11::LowLevel::C_GenerateKey ( SessionHandle  session,
Mechanism mechanism_ptr,
Attribute attribute_template_ptr,
Ulong  count,
ObjectHandle key_ptr,
ReturnValue return_value = ThrowException 
) const

C_GenerateKey generates a secret key, creating a new key object.

Parameters
sessionthe session's handle
mechanism_ptrkey generation mech.
attribute_template_ptrtemplate for new key
count# of attrs in template
key_ptrgets handle of new key
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • AttributeReadOnly
  • AttributeTypeInvalid
  • AttributeValueInvalid
  • CryptokiNotInitialized
  • CurveNotSupported
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnly
  • TemplateIncomplete
  • TemplateInconsistent
  • TokenWriteProtected
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 674 of file p11.cpp.

680 {
681 return handle_return_value(m_func_list_ptr->C_GenerateKey(session, mechanism_ptr, attribute_template_ptr, count,
682 key_ptr), return_value);
683 }

References handle_return_value().

◆ C_GenerateKeyPair()

bool Botan::PKCS11::LowLevel::C_GenerateKeyPair ( SessionHandle  session,
Mechanism mechanism_ptr,
Attribute public_key_template_ptr,
Ulong  public_key_attribute_count,
Attribute private_key_template_ptr,
Ulong  private_key_attribute_count,
ObjectHandle public_key_ptr,
ObjectHandle private_key_ptr,
ReturnValue return_value = ThrowException 
) const

C_GenerateKeyPair generates a public-key/private-key pair, creating new key objects.

Parameters
sessionsession handle
mechanism_ptrkey-gen mech.
public_key_template_ptrtemplate for pub. key
public_key_attribute_count# pub. attrs.
private_key_template_ptrtemplate for priv. key
private_key_attribute_count# priv. attrs.
public_key_ptrgets pub. key handle
private_key_ptrgets priv. key handle
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • AttributeReadOnly
  • AttributeTypeInvalid
  • AttributeValueInvalid
  • CryptokiNotInitialized
  • CurveNotSupported
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • DomainParamsInvalid
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnly
  • TemplateIncomplete
  • TemplateInconsistent
  • TokenWriteProtected
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 685 of file p11.cpp.

694 {
695 return handle_return_value(m_func_list_ptr->C_GenerateKeyPair(session, mechanism_ptr, public_key_template_ptr,
696 public_key_attribute_count, private_key_template_ptr,
697 private_key_attribute_count, public_key_ptr, private_key_ptr), return_value);
698 }

References handle_return_value().

◆ C_GenerateRandom()

bool Botan::PKCS11::LowLevel::C_GenerateRandom ( SessionHandle  session,
Byte random_data_ptr,
Ulong  random_len,
ReturnValue return_value = ThrowException 
) const

C_GenerateRandom generates random data.

Parameters
sessionthe session's handle
random_data_ptrreceives the random data
random_len# of bytes to generate
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationActive
  • RandomNoRng
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 751 of file p11.cpp.

755 {
756 return handle_return_value(m_func_list_ptr->C_GenerateRandom(session, random_data_ptr, random_len), return_value);
757 }

References handle_return_value().

Referenced by Botan::PKCS11::PKCS11_RNG::randomize().

◆ C_GetAttributeValue() [1/2]

bool Botan::PKCS11::LowLevel::C_GetAttributeValue ( SessionHandle  session,
ObjectHandle  object,
Attribute attribute_template_ptr,
Ulong  count,
ReturnValue return_value = ThrowException 
) const

C_GetAttributeValue obtains the value of one or more object attributes.

Parameters
sessionthe session's handle
objectthe object's handle
attribute_template_ptrspecifies attrs; gets vals
countattributes in template
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • AttributeSensitive
  • AttributeTypeInvalid
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • ObjectHandleInvalid
  • OK
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 337 of file p11.cpp.

342 {
343 return handle_return_value(m_func_list_ptr->C_GetAttributeValue(session, object, attribute_template_ptr, count),
344 return_value);
345 }

References handle_return_value().

Referenced by Botan::PKCS11::Object::get_attribute_value().

◆ C_GetAttributeValue() [2/2]

template<typename TAlloc >
bool Botan::PKCS11::LowLevel::C_GetAttributeValue ( SessionHandle  session,
ObjectHandle  object,
std::map< AttributeType, std::vector< uint8_t, TAlloc > > &  attribute_values,
ReturnValue return_value = ThrowException 
) const
inline

C_GetAttributeValue obtains the value of one or more object attributes.

Parameters
sessionthe session's handle
objectthe object's handle
attribute_valuesspecifies attrs; gets vals
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • AttributeSensitive
  • AttributeTypeInvalid
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • ObjectHandleInvalid
  • OK
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 1587 of file p11.h.

1591 {
1592 std::vector<Attribute> getter_template;
1593
1594 for(const auto& entry : attribute_values)
1595 {
1596 getter_template.emplace_back(Attribute{ static_cast< CK_ATTRIBUTE_TYPE >(entry.first), nullptr, 0 });
1597 }
1598
1599 bool success = C_GetAttributeValue(session,
1600 object,
1601 const_cast< Attribute* >(getter_template.data()),
1602 static_cast<Ulong>(getter_template.size()),
1603 return_value);
1604
1605 if(!success)
1606 {
1607 return success;
1608 }
1609
1610 size_t i = 0;
1611 for(auto& entry : attribute_values)
1612 {
1613 entry.second.clear();
1614 entry.second.resize(getter_template.at(i).ulValueLen);
1615 getter_template.at(i).pValue = const_cast< uint8_t* >(entry.second.data());
1616 i++;
1617 }
1618
1619 return C_GetAttributeValue(session, object,
1620 const_cast< Attribute* >(getter_template.data()),
1621 static_cast<Ulong>(getter_template.size()),
1622 return_value);
1623 }
bool C_GetAttributeValue(SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:337
CK_ATTRIBUTE Attribute
Definition: p11.h:847
CK_ULONG CK_ATTRIBUTE_TYPE
Definition: pkcs11t.h:416

◆ C_GetFunctionList()

bool Botan::PKCS11::LowLevel::C_GetFunctionList ( Dynamically_Loaded_Library pkcs11_module,
FunctionListPtr function_list_ptr_ptr,
ReturnValue return_value = ThrowException 
)
static

C_GetFunctionList returns the function list.

Parameters
pkcs11_moduleThe PKCS#11 module
function_list_ptr_ptrreceives pointer to function list
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
Returns
true on success, false otherwise

Definition at line 100 of file p11.cpp.

102 {
103 using get_function_list = CK_RV(*)(FunctionListPtr*);
104
105 get_function_list get_function_list_ptr = pkcs11_module.resolve<get_function_list>("C_GetFunctionList");
106
107 return handle_return_value(get_function_list_ptr(function_list_ptr_ptr), return_value);
108 }
CK_FUNCTION_LIST_PTR FunctionListPtr
Definition: p11.h:827
CK_ULONG CK_RV
Definition: pkcs11t.h:1036

References handle_return_value(), and Botan::Dynamically_Loaded_Library::resolve().

Referenced by Botan::PKCS11::Module::reload().

◆ C_GetFunctionStatus()

bool Botan::PKCS11::LowLevel::C_GetFunctionStatus ( SessionHandle  session,
ReturnValue return_value = ThrowException 
) const

C_GetFunctionStatus is a legacy function; it obtains an updated status of a function running in parallel with an application.

Parameters
sessionthe session's handle
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • FunctionFailed
  • FunctionNotParallel
  • GeneralError
  • HostMemory
  • SessionHandleInvalid
  • SessionClosed
Returns
true on success, false otherwise

Definition at line 761 of file p11.cpp.

763 {
764 return handle_return_value(m_func_list_ptr->C_GetFunctionStatus(session), return_value);
765 }

References handle_return_value().

◆ C_GetInfo()

bool Botan::PKCS11::LowLevel::C_GetInfo ( Info info_ptr,
ReturnValue return_value = ThrowException 
) const

C_GetInfo returns general information about Cryptoki.

Parameters
info_ptrlocation that receives information
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
Returns
true on success, false otherwise

Definition at line 94 of file p11.cpp.

96 {
97 return handle_return_value(m_func_list_ptr->C_GetInfo(info_ptr), return_value);
98 }

References handle_return_value().

◆ C_GetMechanismInfo()

bool Botan::PKCS11::LowLevel::C_GetMechanismInfo ( SlotId  slot_id,
MechanismType  type,
MechanismInfo info_ptr,
ReturnValue return_value = ThrowException 
) const

C_GetMechanismInfo obtains information about a particular mechanism possibly supported by a token.

Parameters
slot_idID of the token's slot
typetype of mechanism
info_ptrreceives mechanism info
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • MechanismInvalid
  • OK
  • SlotIdInvalid
  • TokenNotPresent
  • TokenNotRecognized
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 194 of file p11.cpp.

198 {
199 return handle_return_value(m_func_list_ptr->C_GetMechanismInfo(slot_id, static_cast< CK_MECHANISM_TYPE >(type),
200 info_ptr), return_value);
201 }
MechanismType type
CK_ULONG CK_MECHANISM_TYPE
Definition: pkcs11t.h:583

References handle_return_value(), and type.

◆ C_GetMechanismList() [1/2]

bool Botan::PKCS11::LowLevel::C_GetMechanismList ( SlotId  slot_id,
MechanismType mechanism_list_ptr,
Ulong count_ptr,
ReturnValue return_value = ThrowException 
) const

C_GetMechanismList obtains a list of mechanism types supported by a token.

Parameters
slot_idID of token's slot
mechanism_list_ptrgets mech. array
count_ptrgets # of mechs.
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • SlotIdInvalid
  • TokenNotPresent
  • TokenNotRecognized
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 163 of file p11.cpp.

167 {
168 return handle_return_value(m_func_list_ptr->C_GetMechanismList(slot_id,
169 reinterpret_cast< CK_MECHANISM_TYPE_PTR >(mechanism_list_ptr), count_ptr), return_value);
170 }
CK_MECHANISM_TYPE CK_PTR CK_MECHANISM_TYPE_PTR
Definition: pkcs11t.h:977

References handle_return_value().

Referenced by C_GetMechanismList().

◆ C_GetMechanismList() [2/2]

bool Botan::PKCS11::LowLevel::C_GetMechanismList ( SlotId  slot_id,
std::vector< MechanismType > &  mechanisms,
ReturnValue return_value = ThrowException 
) const

C_GetMechanismList obtains a list of mechanism types supported by a token.

Parameters
slot_idID of token's slot
mechanismsreceives vector of supported mechanisms
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • SlotIdInvalid
  • TokenNotPresent
  • TokenNotRecognized
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 172 of file p11.cpp.

175 {
176 mechanisms.clear();
177
178 // first get number of mechanisms
179 Ulong number_mechanisms = 0;
180
181 bool success = C_GetMechanismList(slot_id, nullptr, &number_mechanisms, return_value);
182
183 if(!success || !number_mechanisms)
184 {
185 return success;
186 }
187
188 // get actual mechanisms
189 mechanisms.resize(number_mechanisms);
190 return C_GetMechanismList(slot_id, reinterpret_cast< MechanismType* >(mechanisms.data()), &number_mechanisms,
191 return_value);
192 }
bool C_GetMechanismList(SlotId slot_id, MechanismType *mechanism_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:163
MechanismType
Definition: p11.h:338

References C_GetMechanismList().

◆ C_GetObjectSize()

bool Botan::PKCS11::LowLevel::C_GetObjectSize ( SessionHandle  session,
ObjectHandle  object,
Ulong size_ptr,
ReturnValue return_value = ThrowException 
) const

C_GetObjectSize gets the size of an object in bytes.

Parameters
sessionthe session's handle
objectthe object's handle
size_ptrreceives size of object
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • InformationSensitive
  • ObjectHandleInvalid
  • OK
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 329 of file p11.cpp.

333 {
334 return handle_return_value(m_func_list_ptr->C_GetObjectSize(session, object, size_ptr), return_value);
335 }

References handle_return_value().

◆ C_GetOperationState()

bool Botan::PKCS11::LowLevel::C_GetOperationState ( SessionHandle  session,
Byte operation_state_ptr,
Ulong operation_state_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_GetOperationState obtains the state of the cryptographic operation in a session.

Parameters
sessionsession's handle
operation_state_ptrgets state
operation_state_len_ptrgets state length
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • StateUnsaveable
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 263 of file p11.cpp.

267 {
268 return handle_return_value(m_func_list_ptr->C_GetOperationState(session, operation_state_ptr, operation_state_len_ptr),
269 return_value);
270 }

References handle_return_value().

◆ C_GetSessionInfo()

bool Botan::PKCS11::LowLevel::C_GetSessionInfo ( SessionHandle  session,
SessionInfo info_ptr,
ReturnValue return_value = ThrowException 
) const

C_GetSessionInfo obtains information about the session.

Parameters
sessionthe session's handle
info_ptrreceives session info
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • SessionClosed
  • SessionHandleInvalid
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 256 of file p11.cpp.

259 {
260 return handle_return_value(m_func_list_ptr->C_GetSessionInfo(session, info_ptr), return_value);
261 }

References handle_return_value().

Referenced by Botan::PKCS11::Session::get_info().

◆ C_GetSlotInfo()

bool Botan::PKCS11::LowLevel::C_GetSlotInfo ( SlotId  slot_id,
SlotInfo info_ptr,
ReturnValue return_value = ThrowException 
) const

C_GetSlotInfo obtains information about a particular slot in the system.

Parameters
slot_idthe ID of the slot
info_ptrreceives the slot information
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • SlotIdInvalid
Returns
true on success, false otherwise

Definition at line 141 of file p11.cpp.

144 {
145 return handle_return_value(m_func_list_ptr->C_GetSlotInfo(slot_id, info_ptr), return_value);
146 }

References handle_return_value().

◆ C_GetSlotList() [1/2]

bool Botan::PKCS11::LowLevel::C_GetSlotList ( Bbool  token_present,
SlotId slot_list_ptr,
Ulong count_ptr,
ReturnValue return_value = ThrowException 
) const

C_GetSlotList obtains a list of slots in the system.

Parameters
token_presentonly slots with tokens
slot_list_ptrreceives array of slot IDs
count_ptrreceives number of slots
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
Returns
true on success, false otherwise

Definition at line 112 of file p11.cpp.

116 {
117 return handle_return_value(m_func_list_ptr->C_GetSlotList(token_present, slot_list_ptr, count_ptr), return_value);
118 }

References handle_return_value().

Referenced by C_GetSlotList(), and Botan::PKCS11::Slot::get_available_slots().

◆ C_GetSlotList() [2/2]

bool Botan::PKCS11::LowLevel::C_GetSlotList ( bool  token_present,
std::vector< SlotId > &  slot_ids,
ReturnValue return_value = ThrowException 
) const

C_GetSlotList obtains a list of slots in the system.

Parameters
token_presentonly slots with tokens
slot_idsreceives vector of slot IDs
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
Returns
true on success, false otherwise

Definition at line 120 of file p11.cpp.

123 {
124 slot_ids.clear();
125
126 // first get available slots
127 Ulong number_slots = 0;
128
129 bool success = C_GetSlotList(token_present, nullptr, &number_slots, return_value);
130
131 if(!success || !number_slots)
132 {
133 return success;
134 }
135
136 // get actual slot ids
137 slot_ids.resize(number_slots);
138 return C_GetSlotList(token_present, slot_ids.data(), &number_slots, return_value);
139 }
bool C_GetSlotList(Bbool token_present, SlotId *slot_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:112

References C_GetSlotList().

◆ C_GetTokenInfo()

bool Botan::PKCS11::LowLevel::C_GetTokenInfo ( SlotId  slot_id,
TokenInfo info_ptr,
ReturnValue return_value = ThrowException 
) const

C_GetTokenInfo obtains information about a particular token in the system.

Parameters
slot_idID of the token's slot
info_ptrreceives the token information
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • SlotIdInvalid
  • TokenNotPresent
  • TokenNotRecognized
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 148 of file p11.cpp.

151 {
152 return handle_return_value(m_func_list_ptr->C_GetTokenInfo(slot_id, info_ptr), return_value);
153 }

References handle_return_value().

◆ C_Initialize()

bool Botan::PKCS11::LowLevel::C_Initialize ( VoidPtr  init_args,
ReturnValue return_value = ThrowException 
) const

C_Initialize initializes the Cryptoki library.

Parameters
init_argsif this is not nullptr, it gets cast to (C_InitializeArgs) and dereferenced
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CantLock
  • CryptokiAlreadyInitialized
  • FunctionFailed
  • GeneralError
  • HostMemory
  • NeedToCreateThreads
  • OK
Returns
true on success, false otherwise

Definition at line 82 of file p11.cpp.

84 {
85 return handle_return_value(m_func_list_ptr->C_Initialize(init_args), return_value);
86 }

References handle_return_value().

◆ C_InitPIN() [1/2]

template<typename TAlloc >
bool Botan::PKCS11::LowLevel::C_InitPIN ( SessionHandle  session,
const std::vector< uint8_t, TAlloc > &  pin,
ReturnValue return_value = ThrowException 
) const
inline

C_InitPIN initializes the normal user's PIN.

Parameters
sessionthe session's handle
pinthe normal user's PIN
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • PinInvalid
  • PinLenRange
  • SessionClosed
  • SessionReadOnly
  • SessionHandleInvalid
  • TokenWriteProtected
  • UserNotLoggedIn
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 1206 of file p11.h.

1209 {
1210 return C_InitPIN(session,
1211 reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(pin.data())),
1212 static_cast<Ulong>(pin.size()),
1213 return_value);
1214 }
bool C_InitPIN(SessionHandle session, Utf8Char *pin_ptr, Ulong pin_len, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:212
CK_UTF8CHAR Utf8Char
Definition: p11.h:843

◆ C_InitPIN() [2/2]

bool Botan::PKCS11::LowLevel::C_InitPIN ( SessionHandle  session,
Utf8Char pin_ptr,
Ulong  pin_len,
ReturnValue return_value = ThrowException 
) const

C_InitPIN initializes the normal user's PIN.

Parameters
sessionthe session's handle
pin_ptrthe normal user's PIN
pin_lenlength in bytes of the PIN
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • PinInvalid
  • PinLenRange
  • SessionClosed
  • SessionReadOnly
  • SessionHandleInvalid
  • TokenWriteProtected
  • UserNotLoggedIn
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 212 of file p11.cpp.

216 {
217 return handle_return_value(m_func_list_ptr->C_InitPIN(session, pin_ptr, pin_len), return_value);
218 }

References handle_return_value().

Referenced by Botan::PKCS11::Session::init_pin().

◆ C_InitToken() [1/2]

template<typename TAlloc >
bool Botan::PKCS11::LowLevel::C_InitToken ( SlotId  slot_id,
const std::vector< uint8_t, TAlloc > &  so_pin,
const std::string &  label,
ReturnValue return_value = ThrowException 
) const
inline

C_InitToken initializes a token.

Parameters
slot_idID of the token's slot
so_pinthe SO's initial PIN
labeltoken label (at max 32 bytes long)
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • PinIncorrect
  • PinLocked
  • SessionExists
  • SlotIdInvalid
  • TokenNotPresent
  • TokenNotRecognized
  • TokenWriteProtected
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 1151 of file p11.h.

1155 {
1156 std::string padded_label = label;
1157 if(label.size() < 32)
1158 {
1159 padded_label.insert(padded_label.end(), 32 - label.size(), ' ');
1160 }
1161
1162 return C_InitToken(slot_id,
1163 reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(so_pin.data())),
1164 static_cast<Ulong>(so_pin.size()),
1165 reinterpret_cast< Utf8Char* >(const_cast< char* >(padded_label.c_str())),
1166 return_value);
1167 }
bool C_InitToken(SlotId slot_id, Utf8Char *so_pin_ptr, Ulong so_pin_len, Utf8Char *label_ptr, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:203

◆ C_InitToken() [2/2]

bool Botan::PKCS11::LowLevel::C_InitToken ( SlotId  slot_id,
Utf8Char so_pin_ptr,
Ulong  so_pin_len,
Utf8Char label_ptr,
ReturnValue return_value = ThrowException 
) const

C_InitToken initializes a token.

Parameters
slot_idID of the token's slot
so_pin_ptrthe SO's initial PIN
so_pin_lenlength in bytes of the SO_PIN
label_ptr32-byte token label (blank padded)
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • PinIncorrect
  • PinLocked
  • SessionExists
  • SlotIdInvalid
  • TokenNotPresent
  • TokenNotRecognized
  • TokenWriteProtected
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 203 of file p11.cpp.

208 {
209 return handle_return_value(m_func_list_ptr->C_InitToken(slot_id, so_pin_ptr, so_pin_len, label_ptr), return_value);
210 }

References handle_return_value().

◆ C_Login() [1/2]

template<typename TAlloc >
bool Botan::PKCS11::LowLevel::C_Login ( SessionHandle  session,
UserType  user_type,
const std::vector< uint8_t, TAlloc > &  pin,
ReturnValue return_value = ThrowException 
) const
inline

C_Login logs a user into a token.

Parameters
sessionthe session's handle
user_typethe user type
pinthe user or security officer's PIN
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • PinIncorrect
  • PinLocked
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnlyExists
  • UserAlreadyLoggedIn
  • UserAnotherAlreadyLoggedIn
  • UserPinNotInitialized
  • UserTooManyTypes
  • UserTypeInvalid
Returns
true on success, false otherwise

Definition at line 1432 of file p11.h.

1436 {
1437 return C_Login(session, user_type,
1438 reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(pin.data())),
1439 static_cast<Ulong>(pin.size()),
1440 return_value);
1441 }
bool C_Login(SessionHandle session, UserType user_type, Utf8Char *pin_ptr, Ulong pin_len, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:283

◆ C_Login() [2/2]

bool Botan::PKCS11::LowLevel::C_Login ( SessionHandle  session,
UserType  user_type,
Utf8Char pin_ptr,
Ulong  pin_len,
ReturnValue return_value = ThrowException 
) const

C_Login logs a user into a token.

Parameters
sessionthe session's handle
user_typethe user type
pin_ptrthe user's PIN
pin_lenthe length of the PIN
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • PinIncorrect
  • PinLocked
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnlyExists
  • UserAlreadyLoggedIn
  • UserAnotherAlreadyLoggedIn
  • UserPinNotInitialized
  • UserTooManyTypes
  • UserTypeInvalid
Returns
true on success, false otherwise

Definition at line 283 of file p11.cpp.

288 {
289 return handle_return_value(m_func_list_ptr->C_Login(session, static_cast< CK_USER_TYPE >(user_type), pin_ptr, pin_len),
290 return_value);
291 }
CK_ULONG CK_USER_TYPE
Definition: pkcs11t.h:262

References handle_return_value().

Referenced by Botan::PKCS11::Session::login().

◆ C_Logout()

bool Botan::PKCS11::LowLevel::C_Logout ( SessionHandle  session,
ReturnValue return_value = ThrowException 
) const

C_Logout logs a user out from a token.

Parameters
sessionthe session's handle
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 293 of file p11.cpp.

295 {
296 return handle_return_value(m_func_list_ptr->C_Logout(session), return_value);
297 }

References handle_return_value().

Referenced by Botan::PKCS11::Session::logoff(), and Botan::PKCS11::Session::~Session().

◆ C_OpenSession()

bool Botan::PKCS11::LowLevel::C_OpenSession ( SlotId  slot_id,
Flags  flags,
VoidPtr  application,
Notify  notify,
SessionHandle session_ptr,
ReturnValue return_value = ThrowException 
) const

C_OpenSession opens a session between an application and a token.

Parameters
slot_idthe slot's ID
flagsfrom CK_SESSION_INFO
applicationpassed to callback
notifycallback function
session_ptrgets session handle
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • SessionCount
  • SessionParallelNotSupported
  • SessionReadWriteSoExists
  • SlotIdInvalid
  • TokenNotPresent
  • TokenNotRecognized
  • TokenWriteProtected
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 233 of file p11.cpp.

239 {
240 return handle_return_value(m_func_list_ptr->C_OpenSession(slot_id, flags, application, notify, session_ptr),
241 return_value);
242 }
Flags flags(Flag flags)
Definition: p11.h:860

References Botan::PKCS11::flags(), and handle_return_value().

Referenced by Botan::PKCS11::Session::Session().

◆ C_SeedRandom()

bool Botan::PKCS11::LowLevel::C_SeedRandom ( SessionHandle  session,
const Byte seed_ptr,
Ulong  seed_len,
ReturnValue return_value = ThrowException 
) const

C_SeedRandom mixes additional seed material into the token's random number generator.

Parameters
sessionthe session's handle
seed_ptrthe seed material
seed_lenlength of seed material
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationActive
  • RandomSeedNotSupported
  • RandomNoRng
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 741 of file p11.cpp.

745 {
746 return handle_return_value(
747 m_func_list_ptr->C_SeedRandom(session, const_cast<Byte*>(seed_ptr), seed_len),
748 return_value);
749 }

References handle_return_value().

Referenced by Botan::PKCS11::PKCS11_RNG::add_entropy().

◆ C_SetAttributeValue() [1/2]

bool Botan::PKCS11::LowLevel::C_SetAttributeValue ( SessionHandle  session,
ObjectHandle  object,
Attribute attribute_template_ptr,
Ulong  count,
ReturnValue return_value = ThrowException 
) const

C_SetAttributeValue modifies the value of one or more object attributes.

Parameters
sessionthe session's handle
objectthe object's handle
attribute_template_ptrspecifies attrs and values
countattributes in template
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ActionProhibited
  • ArgumentsBad
  • AttributeReadOnly
  • AttributeTypeInvalid
  • AttributeValueInvalid
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • ObjectHandleInvalid
  • OK
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnly
  • TemplateInconsistent
  • TokenWriteProtected
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 347 of file p11.cpp.

352 {
353 return handle_return_value(m_func_list_ptr->C_SetAttributeValue(session, object, attribute_template_ptr, count),
354 return_value);
355 }

References handle_return_value().

Referenced by Botan::PKCS11::Object::set_attribute_value().

◆ C_SetAttributeValue() [2/2]

template<typename TAlloc >
bool Botan::PKCS11::LowLevel::C_SetAttributeValue ( SessionHandle  session,
ObjectHandle  object,
std::map< AttributeType, std::vector< uint8_t, TAlloc > > &  attribute_values,
ReturnValue return_value = ThrowException 
) const
inline

C_SetAttributeValue modifies the value of one or more object attributes.

Parameters
sessionthe session's handle
objectthe object's handle
attribute_valuesspecifies attrs and values
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ActionProhibited
  • ArgumentsBad
  • AttributeReadOnly
  • AttributeTypeInvalid
  • AttributeValueInvalid
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • ObjectHandleInvalid
  • OK
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnly
  • TemplateInconsistent
  • TokenWriteProtected
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 1667 of file p11.h.

1671 {
1672 std::vector<Attribute> setter_template;
1673
1674 for(auto& entry : attribute_values)
1675 {
1676 setter_template.emplace_back(Attribute{ static_cast< CK_ATTRIBUTE_TYPE >(entry.first), entry.second.data(), static_cast<CK_ULONG>(entry.second.size()) });
1677 }
1678
1679 return C_SetAttributeValue(session, object,
1680 const_cast< Attribute* >(setter_template.data()),
1681 static_cast<Ulong>(setter_template.size()),
1682 return_value);
1683 }
bool C_SetAttributeValue(SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:347
unsigned long int CK_ULONG
Definition: pkcs11t.h:48

◆ C_SetOperationState()

bool Botan::PKCS11::LowLevel::C_SetOperationState ( SessionHandle  session,
Byte operation_state_ptr,
Ulong  operation_state_len,
ObjectHandle  encryption_key,
ObjectHandle  authentication_key,
ReturnValue return_value = ThrowException 
) const

C_SetOperationState restores the state of the cryptographic operation in a session.

Parameters
sessionsession's handle
operation_state_ptrholds state
operation_state_lenholds state length
encryption_keyen/decryption key
authentication_keysign/verify key
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionFailed
  • GeneralError
  • HostMemory
  • KeyChanged
  • KeyNeeded
  • KeyNotNeeded
  • OK
  • SavedStateInvalid
  • SessionClosed
  • SessionHandleInvalid
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 272 of file p11.cpp.

278 {
279 return handle_return_value(m_func_list_ptr->C_SetOperationState(session, operation_state_ptr, operation_state_len,
280 encryption_key, authentication_key), return_value);
281 }

References handle_return_value().

◆ C_SetPIN() [1/2]

template<typename TAlloc >
bool Botan::PKCS11::LowLevel::C_SetPIN ( SessionHandle  session,
const std::vector< uint8_t, TAlloc > &  old_pin,
const std::vector< uint8_t, TAlloc > &  new_pin,
ReturnValue return_value = ThrowException 
) const
inline

C_SetPIN modifies the PIN of the user who is logged in.

Parameters
sessionthe session's handle
old_pinthe old PIN
new_pinthe new PIN
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • PinIncorrect
  • PinInvalid
  • PinLenRange
  • PinLocked
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnly
  • TokenWriteProtected
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 1258 of file p11.h.

1262 {
1263 return C_SetPIN(session,
1264 reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(old_pin.data())),
1265 static_cast<Ulong>(old_pin.size()),
1266 reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(new_pin.data())),
1267 static_cast<Ulong>(new_pin.size()),
1268 return_value);
1269 }
bool C_SetPIN(SessionHandle session, Utf8Char *old_pin_ptr, Ulong old_len, Utf8Char *new_pin_ptr, Ulong new_len, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:220

◆ C_SetPIN() [2/2]

bool Botan::PKCS11::LowLevel::C_SetPIN ( SessionHandle  session,
Utf8Char old_pin_ptr,
Ulong  old_len,
Utf8Char new_pin_ptr,
Ulong  new_len,
ReturnValue return_value = ThrowException 
) const

C_SetPIN modifies the PIN of the user who is logged in.

Parameters
sessionthe session's handle
old_pin_ptrthe old PIN
old_lenlength of the old PIN
new_pin_ptrthe new PIN
new_lenlength of the new PIN
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • PinIncorrect
  • PinInvalid
  • PinLenRange
  • PinLocked
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnly
  • TokenWriteProtected
  • ArgumentsBad
Returns
true on success, false otherwise

Definition at line 220 of file p11.cpp.

226 {
227 return handle_return_value(m_func_list_ptr->C_SetPIN(session, old_pin_ptr, old_len, new_pin_ptr, new_len),
228 return_value);
229 }

References handle_return_value().

Referenced by Botan::PKCS11::Session::set_pin().

◆ C_Sign() [1/2]

bool Botan::PKCS11::LowLevel::C_Sign ( SessionHandle  session,
const Byte data_ptr,
Ulong  data_len,
Byte signature_ptr,
Ulong signature_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_Sign signs (encrypts with private key) data in a single part, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature.

Parameters
sessionthe session's handle
data_ptrthe data to sign
data_lencount of bytes to sign
signature_ptrgets the signature
signature_len_ptrgets signature length
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataInvalid
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
  • FunctionRejected
Returns
true on success, false otherwise

Definition at line 515 of file p11.cpp.

521 {
522 return handle_return_value(
523 m_func_list_ptr->C_Sign(session, const_cast<Byte*>(data_ptr), data_len, signature_ptr, signature_len_ptr),
524 return_value);
525 }

References handle_return_value().

◆ C_Sign() [2/2]

template<typename TAllocA , typename TAllocB >
bool Botan::PKCS11::LowLevel::C_Sign ( SessionHandle  session,
const std::vector< uint8_t, TAllocA > &  data,
std::vector< uint8_t, TAllocB > &  signature,
ReturnValue return_value = ThrowException 
) const
inline

C_Sign signs (encrypts with private key) data in a single part, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature.

Parameters
sessionthe session's handle
datathe data to sign
signaturegets the signature
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataInvalid
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
  • FunctionRejected
Returns
true on success, false otherwise

Definition at line 2188 of file p11.h.

2192 {
2193 Ulong signature_size = 0;
2194 if(!C_Sign(session,
2195 data.data(),
2196 static_cast<Ulong>(data.size()),
2197 nullptr,
2198 &signature_size,
2199 return_value))
2200 {
2201 return false;
2202 }
2203
2204 signature.resize(signature_size);
2205 if (!C_Sign(session,
2206 data.data(),
2207 static_cast<Ulong>(data.size()),
2208 signature.data(),
2209 &signature_size,
2210 return_value))
2211 {
2212 return false;
2213 }
2214 signature.resize(signature_size);
2215 return true;
2216 }
bool C_Sign(SessionHandle session, const Byte *data_ptr, Ulong data_len, Byte *signature_ptr, Ulong *signature_len_ptr, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:515

◆ C_SignEncryptUpdate()

bool Botan::PKCS11::LowLevel::C_SignEncryptUpdate ( SessionHandle  session,
Byte part_ptr,
Ulong  part_len,
Byte encrypted_part_ptr,
Ulong encrypted_part_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_SignEncryptUpdate continues a multiple-part signing and encryption operation.

Parameters
sessionsession's handle
part_ptrthe plaintext data
part_lenplaintext length
encrypted_part_ptrgets ciphertext
encrypted_part_len_ptrgets c-text length
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 650 of file p11.cpp.

656 {
657 return handle_return_value(m_func_list_ptr->C_SignEncryptUpdate(session, part_ptr, part_len, encrypted_part_ptr,
658 encrypted_part_len_ptr), return_value);
659 }

References handle_return_value().

◆ C_SignFinal() [1/2]

bool Botan::PKCS11::LowLevel::C_SignFinal ( SessionHandle  session,
Byte signature_ptr,
Ulong signature_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_SignFinal finishes a multiple-part signature operation, returning the signature.

Parameters
sessionthe session's handle
signature_ptrgets the signature
signature_len_ptrgets signature length
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
  • FunctionRejected
Returns
true on success, false otherwise

Definition at line 537 of file p11.cpp.

541 {
542 return handle_return_value(m_func_list_ptr->C_SignFinal(session, signature_ptr, signature_len_ptr), return_value);
543 }

References handle_return_value().

◆ C_SignFinal() [2/2]

template<typename TAlloc >
bool Botan::PKCS11::LowLevel::C_SignFinal ( SessionHandle  session,
std::vector< uint8_t, TAlloc > &  signature,
ReturnValue return_value = ThrowException 
) const
inline

C_SignFinal finishes a multiple-part signature operation, returning the signature.

Parameters
sessionthe session's handle
signaturegets the signature
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
  • FunctionRejected
Returns
true on success, false otherwise

Definition at line 2300 of file p11.h.

2303 {
2304 Ulong signature_size = 0;
2305 if(!C_SignFinal(session, nullptr, &signature_size, return_value))
2306 {
2307 return false;
2308 }
2309
2310 signature.resize(signature_size);
2311 if (!C_SignFinal(session, signature.data(), &signature_size, return_value))
2312 {
2313 return false;
2314 }
2315 signature.resize(signature_size);
2316 return true;
2317 }
bool C_SignFinal(SessionHandle session, Byte *signature_ptr, Ulong *signature_len_ptr, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:537

◆ C_SignInit()

bool Botan::PKCS11::LowLevel::C_SignInit ( SessionHandle  session,
Mechanism mechanism_ptr,
ObjectHandle  key,
ReturnValue return_value = ThrowException 
) const

C_SignInit initializes a signature (private key encryption) operation, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature.

Parameters
sessionthe session's handle
mechanism_ptrthe signature mechanism
keyhandle of signature key
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • KeyFunctionNotPermitted
  • KeyHandleInvalid
  • KeySizeRange
  • KeyTypeInconsistent
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 507 of file p11.cpp.

511 {
512 return handle_return_value(m_func_list_ptr->C_SignInit(session, mechanism_ptr, key), return_value);
513 }

References handle_return_value().

◆ C_SignRecover()

bool Botan::PKCS11::LowLevel::C_SignRecover ( SessionHandle  session,
Byte data_ptr,
Ulong  data_len,
Byte signature_ptr,
Ulong signature_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_SignRecover signs data in a single operation, where the data can be recovered from the signature.

Parameters
sessionthe session's handle
data_ptrthe data to sign
data_lencount of bytes to sign
signature_ptrgets the signature
signature_len_ptrgets signature length
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataInvalid
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 553 of file p11.cpp.

559 {
560 return handle_return_value(m_func_list_ptr->C_SignRecover(session, data, data_len, signature, signature_len),
561 return_value);
562 }

References handle_return_value().

◆ C_SignRecoverInit()

bool Botan::PKCS11::LowLevel::C_SignRecoverInit ( SessionHandle  session,
Mechanism mechanism_ptr,
ObjectHandle  key,
ReturnValue return_value = ThrowException 
) const

C_SignRecoverInit initializes a signature operation, where the data can be recovered from the signature.

Parameters
sessionthe session's handle
mechanism_ptrthe signature mechanism
keyhandle of the signature key
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • KeyFunctionNotPermitted
  • KeyHandleInvalid
  • KeySizeRange
  • KeyTypeInconsistent
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 545 of file p11.cpp.

549 {
550 return handle_return_value(m_func_list_ptr->C_SignRecoverInit(session, mechanism_ptr, key), return_value);
551 }

References handle_return_value().

◆ C_SignUpdate() [1/2]

bool Botan::PKCS11::LowLevel::C_SignUpdate ( SessionHandle  session,
const Byte part_ptr,
Ulong  part_len,
ReturnValue return_value = ThrowException 
) const

C_SignUpdate continues a multiple-part signature operation, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature.

Parameters
sessionthe session's handle
part_ptrthe data to sign
part_lencount of bytes to sign
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 527 of file p11.cpp.

531 {
532 return handle_return_value(
533 m_func_list_ptr->C_SignUpdate(session, const_cast<Byte*>(part_ptr), part_len),
534 return_value);
535 }

References handle_return_value().

◆ C_SignUpdate() [2/2]

template<typename TAlloc >
bool Botan::PKCS11::LowLevel::C_SignUpdate ( SessionHandle  session,
const std::vector< uint8_t, TAlloc > &  part,
ReturnValue return_value = ThrowException 
) const
inline

C_SignUpdate continues a multiple-part signature operation, where the signature is (will be) an appendix to the data, and plaintext cannot be recovered from the signature.

Parameters
sessionthe session's handle
partthe data to sign
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 2253 of file p11.h.

2256 {
2257 return C_SignUpdate(session,
2258 part.data(),
2259 static_cast<Ulong>(part.size()),
2260 return_value);
2261 }
bool C_SignUpdate(SessionHandle session, const Byte *part_ptr, Ulong part_len, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:527

◆ C_UnwrapKey()

bool Botan::PKCS11::LowLevel::C_UnwrapKey ( SessionHandle  session,
Mechanism mechanism_ptr,
ObjectHandle  unwrapping_key,
Byte wrapped_key_ptr,
Ulong  wrapped_key_len,
Attribute attribute_template_ptr,
Ulong  attribute_count,
ObjectHandle key_ptr,
ReturnValue return_value = ThrowException 
) const

C_UnwrapKey unwraps (decrypts) a wrapped key, creating a new key object.

Parameters
sessionsession's handle
mechanism_ptrunwrapping mech.
unwrapping_keyunwrapping key
wrapped_key_ptrthe wrapped key
wrapped_key_lenwrapped key len
attribute_template_ptrnew key template
attribute_counttemplate length
key_ptrgets new handle
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • AttributeReadOnly
  • AttributeTypeInvalid
  • AttributeValueInvalid
  • BufferTooSmall
  • CryptokiNotInitialized
  • CurveNotSupported
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • DomainParamsInvalid
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • SessionReadOnly
  • TemplateIncomplete
  • TemplateInconsistent
  • TokenWriteProtected
  • UnwrappingKeyHandleInvalid
  • UnwrappingKeySizeRange
  • UnwrappingKeyTypeInconsistent
  • UserNotLoggedIn
  • WrappedKeyInvalid
  • WrappedKeyLenRange
Returns
true on success, false otherwise

Definition at line 712 of file p11.cpp.

721 {
722 return handle_return_value(m_func_list_ptr->C_UnwrapKey(session, mechanism_ptr, unwrapping_key, wrapped_key_ptr,
723 wrapped_key_len, attribute_template_ptr,
724 attribute_count, key_ptr), return_value);
725 }

References handle_return_value().

◆ C_Verify() [1/2]

bool Botan::PKCS11::LowLevel::C_Verify ( SessionHandle  session,
const Byte data_ptr,
Ulong  data_len,
const Byte signature_ptr,
Ulong  signature_len,
ReturnValue return_value = ThrowException 
) const

C_Verify verifies a signature in a single-part operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature.

Parameters
sessionthe session's handle
data_ptrsigned data
data_lenlength of signed data
signature_ptrsignature
signature_lensignature length
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DataInvalid
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • SignatureInvalid
  • SignatureLenRange
Returns
true on success, false otherwise

Definition at line 574 of file p11.cpp.

580 {
581 return handle_return_value(
582 m_func_list_ptr->C_Verify(session, const_cast<Byte*>(data_ptr), data_len,
583 const_cast<Byte*>(signature_ptr), signature_len),
584 return_value);
585 }

References handle_return_value().

◆ C_Verify() [2/2]

template<typename TAllocA , typename TAllocB >
bool Botan::PKCS11::LowLevel::C_Verify ( SessionHandle  session,
const std::vector< uint8_t, TAllocA > &  data,
std::vector< uint8_t, TAllocB > &  signature,
ReturnValue return_value = ThrowException 
) const
inline

C_Verify verifies a signature in a single-part operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature.

Parameters
sessionthe session's handle
datasigned data
signaturesignature
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DataInvalid
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • SignatureInvalid
  • SignatureLenRange
Returns
true on success, false otherwise

Definition at line 2432 of file p11.h.

2436 {
2437 return C_Verify(session,
2438 data.data(),
2439 static_cast<Ulong>(data.size()),
2440 signature.data(),
2441 static_cast<Ulong>(signature.size()),
2442 return_value);
2443 }
bool C_Verify(SessionHandle session, const Byte *data_ptr, Ulong data_len, const Byte *signature_ptr, Ulong signature_len, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:574

◆ C_VerifyFinal()

bool Botan::PKCS11::LowLevel::C_VerifyFinal ( SessionHandle  session,
const Byte signature_ptr,
Ulong  signature_len,
ReturnValue return_value = ThrowException 
) const

C_VerifyFinal finishes a multiple-part verification operation, checking the signature.

Parameters
sessionthe session's handle
signature_ptrsignature to verify
signature_lensignature length
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • SignatureInvalid
  • SignatureLenRange
Returns
true on success, false otherwise

Definition at line 597 of file p11.cpp.

601 {
602 return handle_return_value(
603 m_func_list_ptr->C_VerifyFinal(session, const_cast<Byte*>(signature_ptr), signature_len),
604 return_value);
605 }

References handle_return_value().

◆ C_VerifyInit()

bool Botan::PKCS11::LowLevel::C_VerifyInit ( SessionHandle  session,
Mechanism mechanism_ptr,
ObjectHandle  key,
ReturnValue return_value = ThrowException 
) const

C_VerifyInit initializes a verification operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature (e.g. DSA).

Parameters
sessionthe session's handle
mechanism_ptrthe verification mechanism
keyverification key
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • KeyFunctionNotPermitted
  • KeyHandleInvalid
  • KeySizeRange
  • KeyTypeInconsistent
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 566 of file p11.cpp.

570 {
571 return handle_return_value(m_func_list_ptr->C_VerifyInit(session, mechanism_ptr, key), return_value);
572 }

References handle_return_value().

◆ C_VerifyRecover()

bool Botan::PKCS11::LowLevel::C_VerifyRecover ( SessionHandle  session,
Byte signature_ptr,
Ulong  signature_len,
Byte data_ptr,
Ulong data_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_VerifyRecover verifies a signature in a single-part operation, where the data is recovered from the signature.

Parameters
sessionthe session's handle
signature_ptrsignature to verify
signature_lensignature length
data_ptrgets signed data
data_len_ptrgets signed data len
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DataInvalid
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
  • SignatureLenRange
  • SignatureInvalid
Returns
true on success, false otherwise

Definition at line 615 of file p11.cpp.

621 {
622 return handle_return_value(m_func_list_ptr->C_VerifyRecover(session, signature_ptr, signature_len, data_ptr,
623 data_len_ptr), return_value);
624 }

References handle_return_value().

◆ C_VerifyRecoverInit()

bool Botan::PKCS11::LowLevel::C_VerifyRecoverInit ( SessionHandle  session,
Mechanism mechanism_ptr,
ObjectHandle  key,
ReturnValue return_value = ThrowException 
) const

C_VerifyRecoverInit initializes a signature verification operation, where the data is recovered from the signature.

Parameters
sessionthe session's handle
mechanism_ptrthe verification mechanism
keyverification key
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • KeyFunctionNotPermitted
  • KeyHandleInvalid
  • KeySizeRange
  • KeyTypeInconsistent
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
Returns
true on success, false otherwise

Definition at line 607 of file p11.cpp.

611 {
612 return handle_return_value(m_func_list_ptr->C_VerifyRecoverInit(session, mechanism_ptr, key), return_value);
613 }

References handle_return_value().

◆ C_VerifyUpdate() [1/2]

bool Botan::PKCS11::LowLevel::C_VerifyUpdate ( SessionHandle  session,
const Byte part_ptr,
Ulong  part_len,
ReturnValue return_value = ThrowException 
) const

C_VerifyUpdate continues a multiple-part verification operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature.

Parameters
sessionthe session's handle
part_ptrsigned data
part_lenlength of signed data
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 587 of file p11.cpp.

591 {
592 return handle_return_value(
593 m_func_list_ptr->C_VerifyUpdate(session, const_cast<Byte*>(part_ptr), part_len),
594 return_value);
595 }

References handle_return_value().

◆ C_VerifyUpdate() [2/2]

template<typename TAlloc >
bool Botan::PKCS11::LowLevel::C_VerifyUpdate ( SessionHandle  session,
std::vector< uint8_t, TAlloc >  part,
ReturnValue return_value = ThrowException 
) const
inline

C_VerifyUpdate continues a multiple-part verification operation, where the signature is an appendix to the data, and plaintext cannot be recovered from the signature.

Parameters
sessionthe session's handle
partsigned data
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • DataLenRange
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • OK
  • OperationNotInitialized
  • SessionClosed
  • SessionHandleInvalid
Returns
true on success, false otherwise

Definition at line 2480 of file p11.h.

2483 {
2484 return C_VerifyUpdate(session, part.data(), static_cast<Ulong>(part.size()), return_value);
2485 }
bool C_VerifyUpdate(SessionHandle session, const Byte *part_ptr, Ulong part_len, ReturnValue *return_value=ThrowException) const
Definition: p11.cpp:587

◆ C_WaitForSlotEvent()

bool Botan::PKCS11::LowLevel::C_WaitForSlotEvent ( Flags  flags,
SlotId slot_ptr,
VoidPtr  reserved,
ReturnValue return_value = ThrowException 
) const

C_WaitForSlotEvent waits for a slot event (token insertion, removal, etc.) to occur.

Parameters
flagsblocking/nonblocking flag
slot_ptrlocation that receives the slot ID
reservedreserved. Should be NULL_PTR
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • CryptokiNotInitialized
  • FunctionFailed
  • GeneralError
  • HostMemory
  • NoEvent
  • OK
Returns
true on success, false otherwise

Definition at line 155 of file p11.cpp.

159 {
160 return handle_return_value(m_func_list_ptr->C_WaitForSlotEvent(flags, slot_ptr, reserved), return_value);
161 }

References Botan::PKCS11::flags(), and handle_return_value().

◆ C_WrapKey()

bool Botan::PKCS11::LowLevel::C_WrapKey ( SessionHandle  session,
Mechanism mechanism_ptr,
ObjectHandle  wrapping_key,
ObjectHandle  key,
Byte wrapped_key_ptr,
Ulong wrapped_key_len_ptr,
ReturnValue return_value = ThrowException 
) const

C_WrapKey wraps (i.e., encrypts) a key.

Parameters
sessionthe session's handle
mechanism_ptrthe wrapping mechanism
wrapping_keywrapping key
keykey to be wrapped
wrapped_key_ptrgets wrapped key
wrapped_key_len_ptrgets wrapped key size
return_valuedefault value (ThrowException): throw exception on error. if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown. At least the following PKCS#11 return values may be returned:
  • ArgumentsBad
  • BufferTooSmall
  • CryptokiNotInitialized
  • DeviceError
  • DeviceMemory
  • DeviceRemoved
  • FunctionCanceled
  • FunctionFailed
  • GeneralError
  • HostMemory
  • KeyHandleInvalid
  • KeyNotWrappable
  • KeySizeRange
  • KeyUnextractable
  • MechanismInvalid
  • MechanismParamInvalid
  • OK
  • OperationActive
  • PinExpired
  • SessionClosed
  • SessionHandleInvalid
  • UserNotLoggedIn
  • WrappingKeyHandleInvalid
  • WrappingKeySizeRange
  • WrappingKeyTypeInconsistent
Returns
true on success, false otherwise

Definition at line 700 of file p11.cpp.

707 {
708 return handle_return_value(m_func_list_ptr->C_WrapKey(session, mechanism_ptr, wrapping_key, key, wrapped_key_ptr,
709 wrapped_key_len_ptr), return_value);
710 }

References handle_return_value().

◆ get_functions()

FunctionListPtr Botan::PKCS11::LowLevel::get_functions ( ) const
inline

Return the PKCS11 function list that this LowLevel class contains.

This is primarily useful when invoking vendor specific extension functions which are not supported directly by LowLevel or the higher level PKCS11 API.

Definition at line 2897 of file p11.h.

2897{ return m_func_list_ptr; }

◆ handle_return_value()

bool Botan::PKCS11::LowLevel::handle_return_value ( const CK_RV  function_result,
ReturnValue return_value 
)
staticprotected

A helper for error handling. This is exposed as a protected member so that it is possible for an application to inherit from LowLevel in order to implement wrappers for vendor specific extensions using the same error handling mechanisms as the rest of the library.

Parameters
function_resultReturn value of the PKCS11 module function
return_valueif (ThrowException) is passed the function throws an exception, otherwise if a non-NULL pointer is passed: return_value receives the return value of the PKCS#11 function and no exception is thrown.
Returns
true if function call was successful, false otherwise

Definition at line 25 of file p11.cpp.

26 {
27 if(return_value == ThrowException)
28 {
29 if(static_cast< ReturnValue >(function_result) != ReturnValue::OK)
30 {
31 // caller wants exception
32 throw PKCS11_ReturnError(static_cast< ReturnValue >(function_result));
33 }
34 }
35 else if(return_value != nullptr)
36 {
37 // caller wants return value
38 *return_value = static_cast< ReturnValue >(function_result);
39 }
40
41 return static_cast< ReturnValue >(function_result) == ReturnValue::OK;
42 }
ReturnValue * ThrowException
Definition: p11.cpp:19

References Botan::PKCS11::OK, and Botan::PKCS11::ThrowException.

Referenced by C_CancelFunction(), C_CloseAllSessions(), C_CloseSession(), C_CopyObject(), C_CreateObject(), C_Decrypt(), C_DecryptDigestUpdate(), C_DecryptFinal(), C_DecryptInit(), C_DecryptUpdate(), C_DecryptVerifyUpdate(), C_DeriveKey(), C_DestroyObject(), C_Digest(), C_DigestEncryptUpdate(), C_DigestFinal(), C_DigestInit(), C_DigestKey(), C_DigestUpdate(), C_Encrypt(), C_EncryptFinal(), C_EncryptInit(), C_EncryptUpdate(), C_Finalize(), C_FindObjects(), C_FindObjectsFinal(), C_FindObjectsInit(), C_GenerateKey(), C_GenerateKeyPair(), C_GenerateRandom(), C_GetAttributeValue(), C_GetFunctionList(), C_GetFunctionStatus(), C_GetInfo(), C_GetMechanismInfo(), C_GetMechanismList(), C_GetObjectSize(), C_GetOperationState(), C_GetSessionInfo(), C_GetSlotInfo(), C_GetSlotList(), C_GetTokenInfo(), C_Initialize(), C_InitPIN(), C_InitToken(), C_Login(), C_Logout(), C_OpenSession(), C_SeedRandom(), C_SetAttributeValue(), C_SetOperationState(), C_SetPIN(), C_Sign(), C_SignEncryptUpdate(), C_SignFinal(), C_SignInit(), C_SignRecover(), C_SignRecoverInit(), C_SignUpdate(), C_UnwrapKey(), C_Verify(), C_VerifyFinal(), C_VerifyInit(), C_VerifyRecover(), C_VerifyRecoverInit(), C_VerifyUpdate(), C_WaitForSlotEvent(), and C_WrapKey().


The documentation for this class was generated from the following files: