Botan 3.11.0
Crypto and TLS for C&
Botan::PKCS11::LowLevel Class Reference

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

#include <p11.h>

Public Member Functions

bool C_AsyncComplete (SessionHandle session, const Utf8Char *function_name_ptr, AsyncData *result_ptr, ReturnValue *return_value=ThrowException)
bool C_AsyncGetID (SessionHandle session, const Utf8Char *function_name_ptr, Ulong *id_ptr, ReturnValue *return_value=ThrowException)
bool C_AsyncJoin (SessionHandle session, const Utf8Char *function_name_ptr, Ulong id, Byte *data_ptr, Ulong data_len, ReturnValue *return_value=ThrowException)
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_DecapsulateKey (SessionHandle session, const Mechanism *mechanism_ptr, ObjectHandle private_key, Attribute *template_ptr, Ulong attribute_count, const Byte *ciphertext_ptr, Ulong ciphertext_len, ObjectHandle *key_ptr, ReturnValue *return_value=ThrowException)
bool C_Decrypt (SessionHandle session, const 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, const 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, const Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException) const
bool C_DecryptMessage (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, const Byte *associated_data_ptr, Ulong associated_data_len, const Byte *ciphertext_ptr, Ulong ciphertext_len, Byte *plaintext_ptr, Ulong *plaintext_len_ptr, ReturnValue *return_value=ThrowException)
bool C_DecryptMessageBegin (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, const Byte *associated_data_ptr, Ulong associated_data_len, ReturnValue *return_value=ThrowException)
bool C_DecryptMessageNext (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, const Byte *ciphertext_part_ptr, Ulong ciphertext_part_len, Byte *plaintext_ptr, Ulong *plaintext_part_len_ptr, Flags flags, ReturnValue *return_value=ThrowException)
bool C_DecryptUpdate (SessionHandle session, const 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, const 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, const 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, const Byte *data_ptr, Ulong data_len, Byte *digest_ptr, Ulong *digest_len_ptr, ReturnValue *return_value=ThrowException) const
bool C_DigestEncryptUpdate (SessionHandle session, const 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, const 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, const Byte *part_ptr, Ulong part_len, ReturnValue *return_value=ThrowException) const
bool C_EncapsulateKey (SessionHandle session, const Mechanism *mechanism_ptr, ObjectHandle public_key, Attribute *template_ptr, Ulong attribute_count, Byte *ciphertext_ptr, Ulong *ciphertext_len_ptr, ObjectHandle *key_ptr, ReturnValue *return_value=ThrowException)
bool C_Encrypt (SessionHandle session, const 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, const Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException) const
bool C_EncryptMessage (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, const Byte *associated_data_ptr, Ulong associated_data_len, const Byte *plaintext_ptr, Ulong plaintext_len, Byte *ciphertext_ptr, Ulong *ciphertext_len_ptr, ReturnValue *return_value=ThrowException)
bool C_EncryptMessageBegin (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, const Byte *associated_data_ptr, Ulong associated_data_len, ReturnValue *return_value=ThrowException)
bool C_EncryptMessageNext (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, const Byte *plaintext_part_ptr, Ulong plaintext_part_len, Byte *ciphertext_ptr, Ulong *ciphertext_part_len_ptr, Flags flags, ReturnValue *return_value=ThrowException)
bool C_EncryptUpdate (SessionHandle session, const Byte *part_ptr, Ulong part_len, Byte *encrypted_part_ptr, Ulong *encrypted_part_len_ptr, ReturnValue *return_value=ThrowException) const
bool C_Finalize (void *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, const Mechanism *mechanism_ptr, Attribute *attribute_template_ptr, Ulong count, ObjectHandle *key_ptr, ReturnValue *return_value=ThrowException) const
bool C_GenerateKeyPair (SessionHandle session, const 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_GetSessionValidationFlags (SessionHandle session, Ulong type, Flags *flags_ptr, ReturnValue *return_value=ThrowException)
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 (const void *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, const 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, std::string_view label, ReturnValue *return_value=ThrowException) const
bool C_InitToken (SlotId slot_id, const Utf8Char *so_pin_ptr, Ulong so_pin_len, const 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, const Utf8Char *pin_ptr, Ulong pin_len, ReturnValue *return_value=ThrowException) const
bool C_LoginUser (SessionHandle session, UserType user_type, const Utf8Char *pin_ptr, Ulong pin_len, const Utf8Char *username_ptr, Ulong username_len, ReturnValue *return_value=ThrowException)
bool C_Logout (SessionHandle session, ReturnValue *return_value=ThrowException) const
bool C_MessageDecryptFinal (SessionHandle session, ReturnValue *return_value=ThrowException)
bool C_MessageDecryptInit (SessionHandle session, const Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException)
bool C_MessageEncryptFinal (SessionHandle session, ReturnValue *return_value=ThrowException)
bool C_MessageEncryptInit (SessionHandle session, const Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException)
bool C_MessageSignFinal (SessionHandle session, ReturnValue *return_value=ThrowException)
bool C_MessageSignInit (SessionHandle session, const Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException)
bool C_MessageVerifyFinal (SessionHandle session, ReturnValue *return_value=ThrowException)
bool C_MessageVerifyInit (SessionHandle session, const Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException)
bool C_OpenSession (SlotId slot_id, Flags flags, void *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_SessionCancel (SessionHandle session, Flags flags, ReturnValue *return_value=ThrowException)
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, const 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, const Utf8Char *old_pin_ptr, Ulong old_len, const 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, const 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, const Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException) const
bool C_SignMessage (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, const Byte *data_ptr, Ulong data_len, Byte *signature_ptr, Ulong *signature_len_ptr, ReturnValue *return_value=ThrowException)
bool C_SignMessageBegin (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, ReturnValue *return_value=ThrowException)
bool C_SignMessageNext (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, const Byte *data_ptr, Ulong data_len, Byte *signature_ptr, Ulong *signature_len_ptr, ReturnValue *return_value=ThrowException)
bool C_SignRecover (SessionHandle session, const Byte *data_ptr, Ulong data_len, Byte *signature_ptr, Ulong *signature_len_ptr, ReturnValue *return_value=ThrowException) const
bool C_SignRecoverInit (SessionHandle session, const 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, const Mechanism *mechanism_ptr, ObjectHandle unwrapping_key, const 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_UnwrapKeyAuthenticated (SessionHandle session, const Mechanism *mechanism_ptr, ObjectHandle unwrapping_key, const Byte *wrapped_key_ptr, Ulong wrapped_key_len, Attribute *attribute_template_ptr, Ulong attribute_count, const Byte *associated_data_ptr, Ulong associated_data_len, 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, const Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException) const
bool C_VerifyMessage (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, const Byte *data_ptr, Ulong data_len, const Byte *signature_ptr, Ulong signature_len, ReturnValue *return_value=ThrowException)
bool C_VerifyMessageBegin (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, ReturnValue *return_value=ThrowException)
bool C_VerifyMessageNext (SessionHandle session, const void *parameter_ptr, Ulong parameter_len, const Byte *data_ptr, Ulong data_len, const Byte *signature_ptr, Ulong signature_len, ReturnValue *return_value=ThrowException)
bool C_VerifyRecover (SessionHandle session, const Byte *signature_ptr, Ulong signature_len, Byte *data_ptr, Ulong *data_len_ptr, ReturnValue *return_value=ThrowException) const
bool C_VerifyRecoverInit (SessionHandle session, const Mechanism *mechanism_ptr, ObjectHandle key, ReturnValue *return_value=ThrowException) const
bool C_VerifySignature (SessionHandle session, const Byte *data_ptr, Ulong data_len, ReturnValue *return_value=ThrowException)
bool C_VerifySignatureFinal (SessionHandle session, ReturnValue *return_value=ThrowException)
bool C_VerifySignatureInit (SessionHandle session, const Mechanism *mechanism_ptr, ObjectHandle key, const Byte *signature_ptr, Ulong signature_len, ReturnValue *return_value=ThrowException)
bool C_VerifySignatureUpdate (SessionHandle session, const Byte *part_ptr, Ulong part_len, ReturnValue *return_value=ThrowException)
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, void *reserved, ReturnValue *return_value=ThrowException) const
bool C_WrapKey (SessionHandle session, const Mechanism *mechanism_ptr, ObjectHandle wrapping_key, ObjectHandle key, Byte *wrapped_key_ptr, Ulong *wrapped_key_len_ptr, ReturnValue *return_value=ThrowException) const
bool C_WrapKeyAuthenticated (SessionHandle session, const Mechanism *mechanism_ptr, ObjectHandle wrapping_key, ObjectHandle key, const Byte *associated_data_ptr, Ulong associated_data_len, Byte *wrapped_key_ptr, Ulong *wrapped_key_len_ptr, ReturnValue *return_value=ThrowException) const
FunctionListget_functions () const
const InterfaceWrapperget_interface ()
 LowLevel (FunctionList *ptr)
 LowLevel (InterfaceWrapper interface_wrapper)

Static Public Member Functions

static bool C_GetFunctionList (const Dynamically_Loaded_Library &pkcs11_module, FunctionList **function_list_ptr_ptr, ReturnValue *return_value=ThrowException)
static bool C_GetInterface (const Dynamically_Loaded_Library &pkcs11_module, const Utf8Char *interface_name_ptr, const Version *version_ptr, Interface *interface_ptr_ptr, Flags flags, ReturnValue *return_value=ThrowException)
static bool C_GetInterfaceList (const Dynamically_Loaded_Library &pkcs11_module, Interface *interface_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException)

Static Protected Member Functions

static bool handle_return_value (CK_RV function_result, ReturnValue *return_value)

Detailed Description

Provides access to all PKCS #11 functions.

Definition at line 1322 of file p11.h.

Constructor & Destructor Documentation

◆ LowLevel() [1/2]

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

Definition at line 64 of file p11.cpp.

64 :
65 m_interface_wrapper([&] {
66 BOTAN_ARG_CHECK(ptr != nullptr, "Function list pointer must not be nullptr");
67 return InterfaceWrapper(Interface{
69 .pFunctionList = ptr,
70 .flags = 0,
71 });
72 }()) {}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
static Utf8Char * p11_interface_name_ptr()
CK_INTERFACE Interface
Definition p11.h:1191

References BOTAN_ARG_CHECK, and Botan::PKCS11::InterfaceWrapper::p11_interface_name_ptr().

◆ LowLevel() [2/2]

Botan::PKCS11::LowLevel::LowLevel ( InterfaceWrapper interface_wrapper)
explicit

Definition at line 74 of file p11.cpp.

74: m_interface_wrapper(interface_wrapper) {}

Member Function Documentation

◆ C_AsyncComplete()

bool Botan::PKCS11::LowLevel::C_AsyncComplete ( SessionHandle session,
const Utf8Char * function_name_ptr,
AsyncData * result_ptr,
ReturnValue * return_value = ThrowException )

C_AsyncComplete checks if the function identified by function_name_ptr has completed an asynchronous operation and, if so, returns the associated result(s).

Parameters
sessionthe session's handle
function_name_ptrpkcs11 function name
result_ptroperation result
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 1184 of file p11.cpp.

1187 {
1188 return handle_return_value(
1189 m_interface_wrapper.func_3_2().C_AsyncComplete(session, const_cast<Utf8Char*>(function_name_ptr), result_ptr),
1190 return_value);
1191}
static bool handle_return_value(CK_RV function_result, ReturnValue *return_value)
Definition p11.cpp:27
CK_UTF8CHAR Utf8Char
Definition p11.h:1208

References handle_return_value().

◆ C_AsyncGetID()

bool Botan::PKCS11::LowLevel::C_AsyncGetID ( SessionHandle session,
const Utf8Char * function_name_ptr,
Ulong * id_ptr,
ReturnValue * return_value = ThrowException )

C_AsyncGetID is used to persist an operation past a C_Finalize call and allow another instance of the client to reconnect after a call to C_Initialize. C_AsyncGetID places a module dependent identifier for the asynchronous operation being performed by the function identified by function_name_ptr.

Parameters
sessionthe session's handle
function_name_ptrpkcs11 function name
id_ptrpersistent operation id
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 1193 of file p11.cpp.

1196 {
1197 return handle_return_value(
1198 m_interface_wrapper.func_3_2().C_AsyncGetID(session, const_cast<Utf8Char*>(function_name_ptr), id_ptr),
1199 return_value);
1200}

References handle_return_value().

◆ C_AsyncJoin()

bool Botan::PKCS11::LowLevel::C_AsyncJoin ( SessionHandle session,
const Utf8Char * function_name_ptr,
Ulong id,
Byte * data_ptr,
Ulong data_len,
ReturnValue * return_value = ThrowException )

C_AsyncJoin checks if the function identified by function_name_ptr and id is a valid asynchronous operation and, if so, reconnects the client application to the module using the buffer specified by data_ptr and data_len in place of those passed into the original call to function_name_ptr.

Parameters
sessionthe session's handle
function_name_ptrpkcs11 function name
idpersistent operation id
data_ptrlocation for the data
data_lendata length
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 1202 of file p11.cpp.

1207 {
1208 return handle_return_value(m_interface_wrapper.func_3_2().C_AsyncJoin(
1209 session, const_cast<Utf8Char*>(function_name_ptr), id, data_ptr, data_len),
1210 return_value);
1211}

References handle_return_value().

◆ 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 1178 of file p11.cpp.

1178 {
1179 return handle_return_value(m_interface_wrapper.func_2_40().C_CancelFunction(session), return_value);
1180}

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 257 of file p11.cpp.

257 {
258 return handle_return_value(m_interface_wrapper.func_2_40().C_CloseAllSessions(slot_id), return_value);
259}

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 253 of file p11.cpp.

253 {
254 return handle_return_value(m_interface_wrapper.func_2_40().C_CloseSession(session), return_value);
255}

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 337 of file p11.cpp.

342 {
343 return handle_return_value(
344 m_interface_wrapper.func_2_40().C_CopyObject(session, object, attribute_template_ptr, count, new_object_ptr),
345 return_value);
346}

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 328 of file p11.cpp.

332 {
333 return handle_return_value(
334 m_interface_wrapper.func_2_40().C_CreateObject(session, attribute_template_ptr, count, object_ptr), return_value);
335}

References handle_return_value().

◆ C_DecapsulateKey()

bool Botan::PKCS11::LowLevel::C_DecapsulateKey ( SessionHandle session,
const Mechanism * mechanism_ptr,
ObjectHandle private_key,
Attribute * template_ptr,
Ulong attribute_count,
const Byte * ciphertext_ptr,
Ulong ciphertext_len,
ObjectHandle * key_ptr,
ReturnValue * return_value = ThrowException )

C_DecapsulateKey creates a new secret key object based on the private key and ciphertext generated by a prior encapsulate operation. This new key (called a ‘shared key’ in most KEM documentation) is identical to the key returned by C_EncapsulateKey when it was called with the matching public key and returned the same cipher text. This function is a KEM style function.

Parameters
sessionthe session's handle
mechanism_ptrthe decapsulation mechanism
private_keythe decapsulating key
template_ptrnew key template
attribute_counttemplate length
ciphertext_ptrthe wrapped key
ciphertext_lenthe wrapped key size
key_ptrthe decapsulated key
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 1134 of file p11.cpp.

1142 {
1143 return handle_return_value(m_interface_wrapper.func_3_2().C_DecapsulateKey(session,
1144 const_cast<Mechanism*>(mechanism_ptr),
1145 private_key,
1146 template_ptr,
1147 attribute_count,
1148 const_cast<Byte*>(ciphertext_ptr),
1149 ciphertext_len,
1150 key_ptr),
1151 return_value);
1152}
CK_MECHANISM Mechanism
Definition p11.h:1206
CK_BYTE Byte
Definition p11.h:1214

References handle_return_value().

◆ C_Decrypt() [1/2]

bool Botan::PKCS11::LowLevel::C_Decrypt ( SessionHandle session,
const 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 526 of file p11.cpp.

531 {
532 return handle_return_value(
533 m_interface_wrapper.func_2_40().C_Decrypt(
534 session, const_cast<Byte*>(encrypted_data_ptr), encrypted_data_len, data_ptr, data_len_ptr),
535 return_value);
536}

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 2564 of file p11.h.

2567 {
2568 Ulong decrypted_size = 0;
2569 if(!C_Decrypt(session,
2570 const_cast<Byte*>((encrypted_data.data())),
2571 static_cast<Ulong>(encrypted_data.size()),
2572 nullptr,
2573 &decrypted_size,
2574 return_value)) {
2575 return false;
2576 }
2577
2578 decrypted_data.resize(decrypted_size);
2579 if(!C_Decrypt(session,
2580 const_cast<Byte*>(encrypted_data.data()),
2581 static_cast<Ulong>(encrypted_data.size()),
2582 decrypted_data.data(),
2583 &decrypted_size,
2584 return_value)) {
2585 return false;
2586 }
2587 decrypted_data.resize(decrypted_size);
2588 return true;
2589 }
bool C_Decrypt(SessionHandle session, const Byte *encrypted_data_ptr, Ulong encrypted_data_len, Byte *data_ptr, Ulong *data_len_ptr, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:526
CK_ULONG Ulong
Definition p11.h:1203

References C_Decrypt(), and Botan::PKCS11::ThrowException.

◆ C_DecryptDigestUpdate()

bool Botan::PKCS11::LowLevel::C_DecryptDigestUpdate ( SessionHandle session,
const 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 952 of file p11.cpp.

957 {
958 return handle_return_value(
959 m_interface_wrapper.func_2_40().C_DecryptDigestUpdate(
960 session, const_cast<Byte*>(encrypted_part_ptr), encrypted_part_len, part_ptr, part_len_ptr),
961 return_value);
962}

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 550 of file p11.cpp.

553 {
554 return handle_return_value(m_interface_wrapper.func_2_40().C_DecryptFinal(session, last_part_ptr, last_part_len_ptr),
555 return_value);
556}

References handle_return_value().

◆ C_DecryptInit()

bool Botan::PKCS11::LowLevel::C_DecryptInit ( SessionHandle session,
const 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 518 of file p11.cpp.

521 {
522 return handle_return_value(
523 m_interface_wrapper.func_2_40().C_DecryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key), return_value);
524}

References handle_return_value().

◆ C_DecryptMessage()

bool Botan::PKCS11::LowLevel::C_DecryptMessage ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
const Byte * associated_data_ptr,
Ulong associated_data_len,
const Byte * ciphertext_ptr,
Ulong ciphertext_len,
Byte * plaintext_ptr,
Ulong * plaintext_len_ptr,
ReturnValue * return_value = ThrowException )

C_DecryptMessage decrypts an encrypted message in a single part.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
associated_data_ptrAEAD Associated data
associated_data_lenAEAD Associated data length
ciphertext_ptrcipher text
ciphertext_lencipher text length
plaintext_ptrgets plain text
plaintext_len_ptrgets plain text length
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 569 of file p11.cpp.

578 {
579 return handle_return_value(m_interface_wrapper.func_3_0().C_DecryptMessage(session,
580 const_cast<void*>(parameter_ptr),
581 parameter_len,
582 const_cast<Byte*>(associated_data_ptr),
583 associated_data_len,
584 const_cast<Byte*>(ciphertext_ptr),
585 ciphertext_len,
586 plaintext_ptr,
587 plaintext_len_ptr),
588 return_value);
589}

References handle_return_value().

◆ C_DecryptMessageBegin()

bool Botan::PKCS11::LowLevel::C_DecryptMessageBegin ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
const Byte * associated_data_ptr,
Ulong associated_data_len,
ReturnValue * return_value = ThrowException )

C_DecryptMessageBegin begins a multiple-part message decryption operation.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
associated_data_ptrAEAD Associated data
associated_data_lenAEAD Associated data length
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 591 of file p11.cpp.

596 {
597 return handle_return_value(
598 m_interface_wrapper.func_3_0().C_DecryptMessageBegin(session,
599 const_cast<void*>(parameter_ptr),
600 parameter_len,
601 const_cast<Byte*>(associated_data_ptr),
602 associated_data_len),
603 return_value);
604}

References handle_return_value().

◆ C_DecryptMessageNext()

bool Botan::PKCS11::LowLevel::C_DecryptMessageNext ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
const Byte * ciphertext_part_ptr,
Ulong ciphertext_part_len,
Byte * plaintext_ptr,
Ulong * plaintext_part_len_ptr,
Flags flags,
ReturnValue * return_value = ThrowException )

C_DecryptMessageNext continues a multiple-part message decryption operation, processing another encrypted message part.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
ciphertext_part_ptrcipher text
ciphertext_part_lencipher text length
plaintext_ptrgets plain text
plaintext_part_len_ptrgets plain text length
flagsmulti mode flag
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 606 of file p11.cpp.

614 {
615 return handle_return_value(
616 m_interface_wrapper.func_3_0().C_DecryptMessageNext(session,
617 const_cast<void*>(parameter_ptr),
618 parameter_len,
619 const_cast<Byte*>(ciphertext_part_ptr),
620 ciphertext_part_len,
621 plaintext_ptr,
622 plaintext_part_len_ptr,
623 flags),
624 return_value);
625}
Flags flags(Flag flags)
Definition p11.h:1227

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

◆ C_DecryptUpdate()

bool Botan::PKCS11::LowLevel::C_DecryptUpdate ( SessionHandle session,
const 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 538 of file p11.cpp.

543 {
544 return handle_return_value(
545 m_interface_wrapper.func_2_40().C_DecryptUpdate(
546 session, const_cast<Byte*>(encrypted_part_ptr), encrypted_part_len, part_ptr, part_len_ptr),
547 return_value);
548}

References handle_return_value().

◆ C_DecryptVerifyUpdate()

bool Botan::PKCS11::LowLevel::C_DecryptVerifyUpdate ( SessionHandle session,
const 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 976 of file p11.cpp.

981 {
982 return handle_return_value(
983 m_interface_wrapper.func_2_40().C_DecryptVerifyUpdate(
984 session, const_cast<Byte*>(encrypted_part_ptr), encrypted_part_len, part_ptr, part_len_ptr),
985 return_value);
986}

References handle_return_value().

◆ C_DeriveKey()

bool Botan::PKCS11::LowLevel::C_DeriveKey ( SessionHandle session,
const 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 1055 of file p11.cpp.

1061 {
1062 return handle_return_value(
1063 m_interface_wrapper.func_2_40().C_DeriveKey(
1064 session, const_cast<Mechanism*>(mechanism_ptr), base_key, attribute_template_ptr, attribute_count, key_ptr),
1065 return_value);
1066}

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 348 of file p11.cpp.

348 {
349 return handle_return_value(m_interface_wrapper.func_2_40().C_DestroyObject(session, object), return_value);
350}

References handle_return_value().

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

◆ C_Digest()

bool Botan::PKCS11::LowLevel::C_Digest ( SessionHandle session,
const 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 638 of file p11.cpp.

643 {
644 return handle_return_value(m_interface_wrapper.func_2_40().C_Digest(
645 session, const_cast<Byte*>(data_ptr), data_len, digest_ptr, digest_len_ptr),
646 return_value);
647}

References handle_return_value().

◆ C_DigestEncryptUpdate()

bool Botan::PKCS11::LowLevel::C_DigestEncryptUpdate ( SessionHandle session,
const 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 940 of file p11.cpp.

945 {
946 return handle_return_value(
947 m_interface_wrapper.func_2_40().C_DigestEncryptUpdate(
948 session, const_cast<Byte*>(part_ptr), part_len, encrypted_part_ptr, encrypted_part_len_ptr),
949 return_value);
950}

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 661 of file p11.cpp.

664 {
665 return handle_return_value(m_interface_wrapper.func_2_40().C_DigestFinal(session, digest_ptr, digest_len_ptr),
666 return_value);
667}

References handle_return_value().

◆ C_DigestInit()

bool Botan::PKCS11::LowLevel::C_DigestInit ( SessionHandle session,
const 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 633 of file p11.cpp.

633 {
634 return handle_return_value(m_interface_wrapper.func_2_40().C_DigestInit(session, const_cast<Mechanism*>(mechanism)),
635 return_value);
636}

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 657 of file p11.cpp.

657 {
658 return handle_return_value(m_interface_wrapper.func_2_40().C_DigestKey(session, key), return_value);
659}

References handle_return_value().

◆ C_DigestUpdate()

bool Botan::PKCS11::LowLevel::C_DigestUpdate ( SessionHandle session,
const 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 649 of file p11.cpp.

652 {
653 return handle_return_value(
654 m_interface_wrapper.func_2_40().C_DigestUpdate(session, const_cast<Byte*>(part_ptr), part_len), return_value);
655}

References handle_return_value().

◆ C_EncapsulateKey()

bool Botan::PKCS11::LowLevel::C_EncapsulateKey ( SessionHandle session,
const Mechanism * mechanism_ptr,
ObjectHandle public_key,
Attribute * template_ptr,
Ulong attribute_count,
Byte * ciphertext_ptr,
Ulong * ciphertext_len_ptr,
ObjectHandle * key_ptr,
ReturnValue * return_value = ThrowException )

C_EncapulateKey creates a new secret key object from a public key using a KEM.

Parameters
sessionthe session's handle
mechanism_ptrthe encapsulation mechanism
public_keythe encapsulating key
template_ptrnew key template
attribute_counttemplate length
ciphertext_ptrthe wrapped key
ciphertext_len_ptrthe wrapped key size
key_ptrthe encapsulated key
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 1114 of file p11.cpp.

1122 {
1123 return handle_return_value(m_interface_wrapper.func_3_2().C_EncapsulateKey(session,
1124 const_cast<Mechanism*>(mechanism_ptr),
1125 public_key,
1126 template_ptr,
1127 attribute_count,
1128 ciphertext_ptr,
1129 ciphertext_len_ptr,
1130 key_ptr),
1131 return_value);
1132}

References handle_return_value().

◆ C_Encrypt() [1/2]

bool Botan::PKCS11::LowLevel::C_Encrypt ( SessionHandle session,
const 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 411 of file p11.cpp.

416 {
417 return handle_return_value(
418 m_interface_wrapper.func_2_40().C_Encrypt(
419 session, const_cast<Byte*>(data_ptr), data_len, encrypted_data_ptr, encrypted_data_len_ptr),
420 return_value);
421}

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 2331 of file p11.h.

2334 {
2335 Ulong encrypted_size = 0;
2336 if(!C_Encrypt(session,
2337 const_cast<Byte*>((plaintext_data.data())),
2338 static_cast<Ulong>(plaintext_data.size()),
2339 nullptr,
2340 &encrypted_size,
2341 return_value)) {
2342 return false;
2343 }
2344
2345 encrypted_data.resize(encrypted_size);
2346 if(!C_Encrypt(session,
2347 const_cast<Byte*>(plaintext_data.data()),
2348 static_cast<Ulong>(plaintext_data.size()),
2349 encrypted_data.data(),
2350 &encrypted_size,
2351 return_value)) {
2352 return false;
2353 }
2354 encrypted_data.resize(encrypted_size);
2355 return true;
2356 }
bool C_Encrypt(SessionHandle session, const Byte *data_ptr, Ulong data_len, Byte *encrypted_data, Ulong *encrypted_data_len_ptr, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:411

References C_Encrypt(), and Botan::PKCS11::ThrowException.

◆ 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 435 of file p11.cpp.

438 {
439 return handle_return_value(
440 m_interface_wrapper.func_2_40().C_EncryptFinal(session, last_encrypted_part_ptr, last_encrypted_part_len_ptr),
441 return_value);
442}

References handle_return_value().

◆ C_EncryptInit()

bool Botan::PKCS11::LowLevel::C_EncryptInit ( SessionHandle session,
const 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 403 of file p11.cpp.

406 {
407 return handle_return_value(
408 m_interface_wrapper.func_2_40().C_EncryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key), return_value);
409}

References handle_return_value().

◆ C_EncryptMessage()

bool Botan::PKCS11::LowLevel::C_EncryptMessage ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
const Byte * associated_data_ptr,
Ulong associated_data_len,
const Byte * plaintext_ptr,
Ulong plaintext_len,
Byte * ciphertext_ptr,
Ulong * ciphertext_len_ptr,
ReturnValue * return_value = ThrowException )

C_EncryptMessage encrypts a message in a single part.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
associated_data_ptrAEAD Associated data
associated_data_lenAEAD Associated data length
plaintext_ptrplain text
plaintext_lenplain text length
ciphertext_ptrgets cipher text
ciphertext_len_ptrgets cipher text length
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 455 of file p11.cpp.

464 {
465 return handle_return_value(m_interface_wrapper.func_3_0().C_EncryptMessage(session,
466 const_cast<void*>(parameter_ptr),
467 parameter_len,
468 const_cast<Byte*>(associated_data_ptr),
469 associated_data_len,
470 const_cast<Byte*>(plaintext_ptr),
471 plaintext_len,
472 ciphertext_ptr,
473 ciphertext_len_ptr),
474 return_value);
475}

References handle_return_value().

◆ C_EncryptMessageBegin()

bool Botan::PKCS11::LowLevel::C_EncryptMessageBegin ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
const Byte * associated_data_ptr,
Ulong associated_data_len,
ReturnValue * return_value = ThrowException )

C_EncryptMessageBegin begins a multiple-part message encryption operation.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
associated_data_ptrAEAD Associated data
associated_data_lenAEAD Associated data length
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 477 of file p11.cpp.

482 {
483 return handle_return_value(
484 m_interface_wrapper.func_3_0().C_EncryptMessageBegin(session,
485 const_cast<void*>(parameter_ptr),
486 parameter_len,
487 const_cast<Byte*>(associated_data_ptr),
488 associated_data_len),
489 return_value);
490}

References handle_return_value().

◆ C_EncryptMessageNext()

bool Botan::PKCS11::LowLevel::C_EncryptMessageNext ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
const Byte * plaintext_part_ptr,
Ulong plaintext_part_len,
Byte * ciphertext_ptr,
Ulong * ciphertext_part_len_ptr,
Flags flags,
ReturnValue * return_value = ThrowException )

C_EncryptMessageNext continues a multiple-part message encryption operation, processing another message part.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
plaintext_part_ptrplain text
plaintext_part_lenplain text length
ciphertext_ptrgets cipher text
ciphertext_part_len_ptrgets cipher text length
flagsmulti mode flag
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 492 of file p11.cpp.

500 {
501 return handle_return_value(m_interface_wrapper.func_3_0().C_EncryptMessageNext(session,
502 const_cast<void*>(parameter_ptr),
503 parameter_len,
504 const_cast<Byte*>(plaintext_part_ptr),
505 plaintext_part_len,
506 ciphertext_ptr,
507 ciphertext_part_len_ptr,
508 flags),
509 return_value);
510}

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

◆ C_EncryptUpdate()

bool Botan::PKCS11::LowLevel::C_EncryptUpdate ( SessionHandle session,
const 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 423 of file p11.cpp.

428 {
429 return handle_return_value(
430 m_interface_wrapper.func_2_40().C_EncryptUpdate(
431 session, const_cast<Byte*>(part_ptr), part_len, encrypted_part_ptr, encrypted_part_len_ptr),
432 return_value);
433}

References handle_return_value().

◆ C_Finalize()

bool Botan::PKCS11::LowLevel::C_Finalize ( void * 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 82 of file p11.cpp.

82 {
83 return handle_return_value(m_interface_wrapper.func_2_40().C_Finalize(reserved), return_value);
84}

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 387 of file p11.cpp.

391 {
392 return handle_return_value(
393 m_interface_wrapper.func_2_40().C_FindObjects(session, object_ptr, max_object_count, object_count_ptr),
394 return_value);
395}

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 397 of file p11.cpp.

397 {
398 return handle_return_value(m_interface_wrapper.func_2_40().C_FindObjectsFinal(session), return_value);
399}

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 379 of file p11.cpp.

382 {
383 return handle_return_value(m_interface_wrapper.func_2_40().C_FindObjectsInit(session, attribute_template_ptr, count),
384 return_value);
385}

References handle_return_value().

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

◆ C_GenerateKey()

bool Botan::PKCS11::LowLevel::C_GenerateKey ( SessionHandle session,
const 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 990 of file p11.cpp.

995 {
996 return handle_return_value(
997 m_interface_wrapper.func_2_40().C_GenerateKey(
998 session, const_cast<Mechanism*>(mechanism_ptr), attribute_template_ptr, count, key_ptr),
999 return_value);
1000}

References handle_return_value().

◆ C_GenerateKeyPair()

bool Botan::PKCS11::LowLevel::C_GenerateKeyPair ( SessionHandle session,
const 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 1002 of file p11.cpp.

1010 {
1011 return handle_return_value(m_interface_wrapper.func_2_40().C_GenerateKeyPair(session,
1012 const_cast<Mechanism*>(mechanism_ptr),
1013 public_key_template_ptr,
1014 public_key_attribute_count,
1015 private_key_template_ptr,
1016 private_key_attribute_count,
1017 public_key_ptr,
1018 private_key_ptr),
1019 return_value);
1020}

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 1164 of file p11.cpp.

1167 {
1168 return handle_return_value(m_interface_wrapper.func_2_40().C_GenerateRandom(session, random_data_ptr, random_len),
1169 return_value);
1170}

References handle_return_value().

◆ 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 359 of file p11.cpp.

363 {
364 return handle_return_value(
365 m_interface_wrapper.func_2_40().C_GetAttributeValue(session, object, attribute_template_ptr, count),
366 return_value);
367}

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 2112 of file p11.h.

2115 {
2116 std::vector<Attribute> getter_template;
2117
2118 getter_template.reserve(attribute_values.size());
2119 for(const auto& entry : attribute_values) {
2120 getter_template.emplace_back(Attribute{static_cast<CK_ATTRIBUTE_TYPE>(entry.first), nullptr, 0});
2121 }
2122
2123 const bool success = C_GetAttributeValue(session,
2124 object,
2125 const_cast<Attribute*>(getter_template.data()),
2126 static_cast<Ulong>(getter_template.size()),
2127 return_value);
2128
2129 if(!success) {
2130 return success;
2131 }
2132
2133 size_t i = 0;
2134 for(auto& entry : attribute_values) {
2135 entry.second.clear();
2136 entry.second.resize(getter_template.at(i).ulValueLen);
2137 getter_template.at(i).pValue = const_cast<uint8_t*>(entry.second.data());
2138 i++;
2139 }
2140
2141 return C_GetAttributeValue(session,
2142 object,
2143 const_cast<Attribute*>(getter_template.data()),
2144 static_cast<Ulong>(getter_template.size()),
2145 return_value);
2146 }
bool C_GetAttributeValue(SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:359
CK_ATTRIBUTE Attribute
Definition p11.h:1212
CK_ULONG CK_ATTRIBUTE_TYPE
Definition pkcs11.h:44

References C_GetAttributeValue(), and Botan::PKCS11::ThrowException.

◆ C_GetFunctionList()

bool Botan::PKCS11::LowLevel::C_GetFunctionList ( const Dynamically_Loaded_Library & pkcs11_module,
FunctionList ** 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 90 of file p11.cpp.

92 {
93 using get_function_list = CK_RV (*)(FunctionList**);
94
95 get_function_list get_function_list_ptr = pkcs11_module.resolve<get_function_list>("C_GetFunctionList");
96
97 return handle_return_value(get_function_list_ptr(function_list_ptr_ptr), return_value);
98}
CK_FUNCTION_LIST FunctionList
Definition p11.h:1187
CK_ULONG CK_RV
Definition pkcs11.h:73

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

Referenced by Botan::PKCS11::InterfaceWrapper::latest_p11_interface().

◆ 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 1174 of file p11.cpp.

1174 {
1175 return handle_return_value(m_interface_wrapper.func_2_40().C_GetFunctionStatus(session), return_value);
1176}

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 86 of file p11.cpp.

86 {
87 return handle_return_value(m_interface_wrapper.func_2_40().C_GetInfo(info_ptr), return_value);
88}

References handle_return_value().

◆ C_GetInterface()

bool Botan::PKCS11::LowLevel::C_GetInterface ( const Dynamically_Loaded_Library & pkcs11_module,
const Utf8Char * interface_name_ptr,
const Version * version_ptr,
Interface * interface_ptr_ptr,
Flags flags,
ReturnValue * return_value = ThrowException )
static

C_GetInterface is used to obtain an interface supported by a Cryptoki library. pInterfaceName specifies the name of the interface, pVersion specifies the interface version, ppInterface points to the location that receives the interface, flags specifies the required interface flags. There are multiple ways for an application to specify a particular interface when calling C_GetInterface:

  1. If pInterfaceName is not nullptr, the name of the interface returned must match. If pInterfaceName is nullptr, the cryptoki library can return a default interface of its choice
  2. If pVersion is not nullptr, the version of the interface returned must match. If pVersion is nullptr, the cryptoki library can return an interface of any version
  3. If flags is non-zero, the interface returned must match all of the supplied flag values (but may include additional flags not specified). If flags is 0, the cryptoki library can return an interface with any flags
Parameters
pkcs11_moduleThe PKCS #11 module
interface_name_ptrname of the interface
version_ptrversion of the interface
interface_ptr_ptrreturned interface
flagsflags controlling the semantics of the interface
return_valuedefault value (ThrowException): throw exception on error.
Returns
true on success, false otherwise

Definition at line 113 of file p11.cpp.

118 {
119 using get_interface =
120 CK_RV (*)(Utf8Char* interface_name_ptr, Version* version_ptr, Interface* interface_ptr_ptr, Flags flags);
121 if(auto get_interface_ptr = pkcs11_module.try_resolve_symbol<get_interface>("C_GetInterface");
122 get_interface_ptr.has_value()) {
123 return handle_return_value(
124 get_interface_ptr.value()(
125 const_cast<Utf8Char*>(interface_name_ptr), const_cast<Version*>(version_ptr), interface_ptr_ptr, flags),
126 return_value);
127 }
128 // Loading the library function failed. Probably due to a cryptoki library with PKCS #11 < 3.0.
129 return handle_return_value(CKR_GENERAL_ERROR, return_value);
130}
const InterfaceWrapper & get_interface()
Definition p11.h:3999
CK_VERSION Version
Definition p11.h:1200
CK_FLAGS Flags
Definition p11.h:1198
#define CKR_GENERAL_ERROR
Definition pkcs11.h:1092

References CKR_GENERAL_ERROR, Botan::PKCS11::flags(), get_interface(), handle_return_value(), and Botan::Dynamically_Loaded_Library::try_resolve_symbol().

◆ C_GetInterfaceList()

bool Botan::PKCS11::LowLevel::C_GetInterfaceList ( const Dynamically_Loaded_Library & pkcs11_module,
Interface * interface_list_ptr,
Ulong * count_ptr,
ReturnValue * return_value = ThrowException )
static

C_GetInterfaceList is used to obtain a list of interfaces supported by a Cryptoki library. count_ptr points to the location that receives the number of interfaces. There are two ways for an application to call C_GetInterfaceList:

  1. If interface_list_ptr is nullptr, then all that C_GetInterfaceList does is return (in *count_ptr) the number of interfaces, without actually returning a list of interfaces. The contents of *count_ptr on entry to C_GetInterfaceList have no meaning in this case, and the call returns the value CKR_OK.
  2. If pIntrerfaceList is not nullptr, then *count_ptr MUST contain the size (in terms of CK_INTERFACE elements) of the buffer pointed to by interface_list_ptr. If that buffer is large enough to hold the list of interfaces, then the list is returned in it, and CKR_OK is returned. If not, then the call to C_GetInterfaceList returns the value CKR_BUFFER_TOO_SMALL. In either case, the value *count_ptr is set to hold the number of interfaces.

Because C_GetInterfaceList does not allocate any space of its own, an application will often call C_GetInterfaceList twice. However, this behavior is by no means required. C_GetInterfaceList obtains (in *pFunctionList of each interface) a pointer to the Cryptoki library’s list of function pointers. The pointer thus obtained may point into memory which is owned by the Cryptoki library, and which may or may not be writable. Whether or not this is the case, no attempt should be made to write to this memory. The same caveat applies to the interface names returned.

Parameters
pkcs11_moduleThe PKCS #11 module
interface_list_ptrreturned interfaces
count_ptrnumber of interfaces returned
return_valuedefault value (ThrowException): throw exception on error.
Returns
true on success, false otherwise

Definition at line 100 of file p11.cpp.

103 {
104 using get_interface_list = CK_RV (*)(Interface*, Ulong*);
105 if(auto get_interface_list_ptr = pkcs11_module.try_resolve_symbol<get_interface_list>("C_GetInterfaceList");
106 get_interface_list_ptr.has_value()) {
107 return handle_return_value(get_interface_list_ptr.value()(interface_list_ptr, count_ptr), return_value);
108 }
109 // Loading the library function failed. Probably due to a cryptoki library with PKCS #11 < 3.0.
110 return handle_return_value(CKR_GENERAL_ERROR, return_value);
111}

References CKR_GENERAL_ERROR, handle_return_value(), and Botan::Dynamically_Loaded_Library::try_resolve_symbol().

Referenced by Botan::PKCS11::InterfaceWrapper::latest_p11_interface().

◆ 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 201 of file p11.cpp.

204 {
205 return handle_return_value(
206 m_interface_wrapper.func_2_40().C_GetMechanismInfo(slot_id, static_cast<CK_MECHANISM_TYPE>(type), info_ptr),
207 return_value);
208}
CK_ULONG CK_MECHANISM_TYPE
Definition pkcs11.h:59

References handle_return_value().

◆ 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 172 of file p11.cpp.

175 {
176 return handle_return_value(m_interface_wrapper.func_2_40().C_GetMechanismList(
177 slot_id, reinterpret_cast<CK_MECHANISM_TYPE_PTR>(mechanism_list_ptr), count_ptr),
178 return_value);
179}
CK_MECHANISM_TYPE * CK_MECHANISM_TYPE_PTR
Definition pkcs11.h:59

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 181 of file p11.cpp.

183 {
184 mechanisms.clear();
185
186 // first get number of mechanisms
187 Ulong number_mechanisms = 0;
188
189 const bool success = C_GetMechanismList(slot_id, nullptr, &number_mechanisms, return_value);
190
191 if(!success || number_mechanisms == 0) {
192 return success;
193 }
194
195 // get actual mechanisms
196 mechanisms.resize(number_mechanisms);
197 return C_GetMechanismList(
198 slot_id, reinterpret_cast<MechanismType*>(mechanisms.data()), &number_mechanisms, return_value);
199}
bool C_GetMechanismList(SlotId slot_id, MechanismType *mechanism_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:172

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 352 of file p11.cpp.

355 {
356 return handle_return_value(m_interface_wrapper.func_2_40().C_GetObjectSize(session, object, size_ptr), return_value);
357}

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 269 of file p11.cpp.

272 {
273 return handle_return_value(
274 m_interface_wrapper.func_2_40().C_GetOperationState(session, operation_state_ptr, operation_state_len_ptr),
275 return_value);
276}

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 261 of file p11.cpp.

261 {
262 return handle_return_value(m_interface_wrapper.func_2_40().C_GetSessionInfo(session, info_ptr), return_value);
263}

References handle_return_value().

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

◆ C_GetSessionValidationFlags()

bool Botan::PKCS11::LowLevel::C_GetSessionValidationFlags ( SessionHandle session,
Ulong type,
Flags * flags_ptr,
ReturnValue * return_value = ThrowException )

C_GetSessionValidationFlags fetches the requested flags from the session. See Validation indicators (section4.15.3.1) for meaning and semantics for these flags. Applications are responsible for the appropriate locking to protect session to get a meaningful result from this call.

Parameters
sessionthe session's handle
typewhich state of flags
flags_ptrvalidation flags
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 318 of file p11.cpp.

321 {
322 return handle_return_value(m_interface_wrapper.func_3_2().C_GetSessionValidationFlags(session, type, flags_ptr),
323 return_value);
324}

References handle_return_value().

◆ 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 159 of file p11.cpp.

159 {
160 return handle_return_value(m_interface_wrapper.func_2_40().C_GetSlotInfo(slot_id, info_ptr), return_value);
161}

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 134 of file p11.cpp.

137 {
138 return handle_return_value(m_interface_wrapper.func_2_40().C_GetSlotList(token_present, slot_list_ptr, count_ptr),
139 return_value);
140}

References handle_return_value().

Referenced by C_GetSlotList().

◆ 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 142 of file p11.cpp.

142 {
143 slot_ids.clear();
144
145 // first get available slots
146 Ulong number_slots = 0;
147
148 const bool success = C_GetSlotList(static_cast<Bbool>(token_present), nullptr, &number_slots, return_value);
149
150 if(!success || number_slots == 0) {
151 return success;
152 }
153
154 // get actual slot ids
155 slot_ids.resize(number_slots);
156 return C_GetSlotList(static_cast<Bbool>(token_present), slot_ids.data(), &number_slots, return_value);
157}
bool C_GetSlotList(Bbool token_present, SlotId *slot_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:134
CK_BBOOL Bbool
Definition p11.h:1201

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 163 of file p11.cpp.

163 {
164 return handle_return_value(m_interface_wrapper.func_2_40().C_GetTokenInfo(slot_id, info_ptr), return_value);
165}

References handle_return_value().

◆ C_Initialize()

bool Botan::PKCS11::LowLevel::C_Initialize ( const void * 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 78 of file p11.cpp.

78 {
79 return handle_return_value(m_interface_wrapper.func_2_40().C_Initialize(const_cast<void*>(init_args)), return_value);
80}

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 1690 of file p11.h.

1692 {
1693 return C_InitPIN(session,
1694 reinterpret_cast<Utf8Char*>(const_cast<uint8_t*>(pin.data())),
1695 static_cast<Ulong>(pin.size()),
1696 return_value);
1697 }
bool C_InitPIN(SessionHandle session, const Utf8Char *pin_ptr, Ulong pin_len, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:221

References C_InitPIN(), and Botan::PKCS11::ThrowException.

◆ C_InitPIN() [2/2]

bool Botan::PKCS11::LowLevel::C_InitPIN ( SessionHandle session,
const 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 221 of file p11.cpp.

224 {
225 return handle_return_value(
226 m_interface_wrapper.func_2_40().C_InitPIN(session, const_cast<Utf8Char*>(pin_ptr), pin_len), return_value);
227}

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,
std::string_view 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 1637 of file p11.h.

1640 {
1641 std::string padded_label(label);
1642 if(label.size() < 32) {
1643 padded_label.insert(padded_label.end(), 32 - label.size(), ' ');
1644 }
1645
1646 return C_InitToken(slot_id,
1647 reinterpret_cast<Utf8Char*>(const_cast<uint8_t*>(so_pin.data())),
1648 static_cast<Ulong>(so_pin.size()),
1649 reinterpret_cast<Utf8Char*>(const_cast<char*>(padded_label.c_str())),
1650 return_value);
1651 }
bool C_InitToken(SlotId slot_id, const Utf8Char *so_pin_ptr, Ulong so_pin_len, const Utf8Char *label_ptr, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:210

References C_InitToken(), and Botan::PKCS11::ThrowException.

◆ C_InitToken() [2/2]

bool Botan::PKCS11::LowLevel::C_InitToken ( SlotId slot_id,
const Utf8Char * so_pin_ptr,
Ulong so_pin_len,
const 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 210 of file p11.cpp.

214 {
215 return handle_return_value(
216 m_interface_wrapper.func_2_40().C_InitToken(
217 slot_id, const_cast<Utf8Char*>(so_pin_ptr), so_pin_len, const_cast<Utf8Char*>(label_ptr)),
218 return_value);
219}

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 1921 of file p11.h.

1924 {
1925 return C_Login(session,
1926 user_type,
1927 reinterpret_cast<Utf8Char*>(const_cast<uint8_t*>(pin.data())),
1928 static_cast<Ulong>(pin.size()),
1929 return_value);
1930 }
bool C_Login(SessionHandle session, UserType user_type, const Utf8Char *pin_ptr, Ulong pin_len, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:290

References C_Login(), and Botan::PKCS11::ThrowException.

◆ C_Login() [2/2]

bool Botan::PKCS11::LowLevel::C_Login ( SessionHandle session,
UserType user_type,
const 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 290 of file p11.cpp.

291 {
292 return handle_return_value(
293 m_interface_wrapper.func_2_40().C_Login(
294 session, static_cast<CK_USER_TYPE>(user_type), const_cast<Utf8Char*>(pin_ptr), pin_len),
295 return_value);
296}
CK_ULONG CK_USER_TYPE
Definition pkcs11.h:81

References handle_return_value().

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

◆ C_LoginUser()

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

C_LoginUser 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
username_ptrthe user's name
username_lenthe length of the user's name
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 298 of file p11.cpp.

304 {
305 return handle_return_value(m_interface_wrapper.func_3_0().C_LoginUser(session,
306 static_cast<CK_USER_TYPE>(user_type),
307 const_cast<Utf8Char*>(pin_ptr),
308 pin_len,
309 const_cast<Utf8Char*>(username_ptr),
310 username_len),
311 return_value);
312}

References handle_return_value().

◆ 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 314 of file p11.cpp.

314 {
315 return handle_return_value(m_interface_wrapper.func_2_40().C_Logout(session), return_value);
316}

References handle_return_value().

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

◆ C_MessageDecryptFinal()

bool Botan::PKCS11::LowLevel::C_MessageDecryptFinal ( SessionHandle session,
ReturnValue * return_value = ThrowException )

C_MessageDecryptFinal finishes a message-based decryption process.

Parameters
sessionthe session's handle
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 627 of file p11.cpp.

627 {
628 return handle_return_value(m_interface_wrapper.func_3_0().C_MessageDecryptFinal(session), return_value);
629}

References handle_return_value().

◆ C_MessageDecryptInit()

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

C_MessageDecryptInit initializes a message-based decryption process, preparing a session for one or more decryption operations that use the same decryption mechanism and decryption key.

Parameters
sessionthe session's handle
mechanism_ptrthe decryption mechanism
keyhandle of decryption key
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 560 of file p11.cpp.

563 {
564 return handle_return_value(
565 m_interface_wrapper.func_3_0().C_MessageDecryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
566 return_value);
567}

References handle_return_value().

◆ C_MessageEncryptFinal()

bool Botan::PKCS11::LowLevel::C_MessageEncryptFinal ( SessionHandle session,
ReturnValue * return_value = ThrowException )

C_MessageDecryptFinal finishes a message-based decryption process.

Parameters
sessionthe session's handle
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 512 of file p11.cpp.

512 {
513 return handle_return_value(m_interface_wrapper.func_3_0().C_MessageEncryptFinal(session), return_value);
514}

References handle_return_value().

◆ C_MessageEncryptInit()

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

C_MessageEncryptInit prepares a session for one or more encryption operations that use the same encryption mechanism and encryption key.

Parameters
sessionthe session's handle
mechanism_ptrthe encryption mechanism
keyhandle of encryption key
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 446 of file p11.cpp.

449 {
450 return handle_return_value(
451 m_interface_wrapper.func_3_0().C_MessageEncryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
452 return_value);
453}

References handle_return_value().

◆ C_MessageSignFinal()

bool Botan::PKCS11::LowLevel::C_MessageSignFinal ( SessionHandle session,
ReturnValue * return_value = ThrowException )

C_MessageSignFinal finishes a message-based signing process.

Parameters
sessionthe session's handle
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 782 of file p11.cpp.

782 {
783 return handle_return_value(m_interface_wrapper.func_3_0().C_MessageSignFinal(session), return_value);
784}

References handle_return_value().

◆ C_MessageSignInit()

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

C_MessageSignInit initializes a message-based signature process, preparing a session for one or more signature operations (where the signature is an appendix to the data) that use the same signature mechanism and signature key.

Parameters
sessionthe session's handle
mechanism_ptrthe signing mechanism
keyhandle of signing key
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 728 of file p11.cpp.

731 {
732 return handle_return_value(
733 m_interface_wrapper.func_3_0().C_MessageSignInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
734 return_value);
735}

References handle_return_value().

◆ C_MessageVerifyFinal()

bool Botan::PKCS11::LowLevel::C_MessageVerifyFinal ( SessionHandle session,
ReturnValue * return_value = ThrowException )

C_MessageVerifyFinal finishes a message-based verification process.

Parameters
sessionthe session's handle
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 934 of file p11.cpp.

934 {
935 return handle_return_value(m_interface_wrapper.func_3_0().C_MessageVerifyFinal(session), return_value);
936}

References handle_return_value().

◆ C_MessageVerifyInit()

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

C_MessageVerifyInit initializes a message-based verification process, preparing a session for one or more verification operations (where the signature is an appendix to the data) that use the same verification mechanism and verification key.

Parameters
sessionthe session's handle
mechanism_ptrthe signing mechanism
keyhandle of signing key
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 880 of file p11.cpp.

883 {
884 return handle_return_value(
885 m_interface_wrapper.func_3_0().C_MessageVerifyInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
886 return_value);
887}

References handle_return_value().

◆ C_OpenSession()

bool Botan::PKCS11::LowLevel::C_OpenSession ( SlotId slot_id,
Flags flags,
void * 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 243 of file p11.cpp.

248 {
249 return handle_return_value(
250 m_interface_wrapper.func_2_40().C_OpenSession(slot_id, flags, application, notify, session_ptr), return_value);
251}

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 1156 of file p11.cpp.

1159 {
1160 return handle_return_value(
1161 m_interface_wrapper.func_2_40().C_SeedRandom(session, const_cast<Byte*>(seed_ptr), seed_len), return_value);
1162}

References handle_return_value().

◆ C_SessionCancel()

bool Botan::PKCS11::LowLevel::C_SessionCancel ( SessionHandle session,
Flags flags,
ReturnValue * return_value = ThrowException )

C_SessionCancel terminates active session based operations.

Parameters
sessionthe session's handle
flagsflags control which sessions are cancelled
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 265 of file p11.cpp.

265 {
266 return handle_return_value(m_interface_wrapper.func_3_0().C_SessionCancel(session, flags), return_value);
267}

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

◆ 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 369 of file p11.cpp.

373 {
374 return handle_return_value(
375 m_interface_wrapper.func_2_40().C_SetAttributeValue(session, object, attribute_template_ptr, count),
376 return_value);
377}

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 2190 of file p11.h.

2193 {
2194 std::vector<Attribute> setter_template;
2195
2196 setter_template.reserve(attribute_values.size());
2197 for(auto& entry : attribute_values) {
2198 setter_template.emplace_back(Attribute{static_cast<CK_ATTRIBUTE_TYPE>(entry.first),
2199 entry.second.data(),
2200 static_cast<CK_ULONG>(entry.second.size())});
2201 }
2202
2203 return C_SetAttributeValue(session,
2204 object,
2205 const_cast<Attribute*>(setter_template.data()),
2206 static_cast<Ulong>(setter_template.size()),
2207 return_value);
2208 }
bool C_SetAttributeValue(SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:369
unsigned long int CK_ULONG
Definition pkcs11.h:20

References C_SetAttributeValue(), and Botan::PKCS11::ThrowException.

◆ C_SetOperationState()

bool Botan::PKCS11::LowLevel::C_SetOperationState ( SessionHandle session,
const 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 278 of file p11.cpp.

283 {
284 return handle_return_value(
285 m_interface_wrapper.func_2_40().C_SetOperationState(
286 session, const_cast<Byte*>(operation_state_ptr), operation_state_len, encryption_key, authentication_key),
287 return_value);
288}

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 1741 of file p11.h.

1744 {
1745 return C_SetPIN(session,
1746 reinterpret_cast<Utf8Char*>(const_cast<uint8_t*>(old_pin.data())),
1747 static_cast<Ulong>(old_pin.size()),
1748 reinterpret_cast<Utf8Char*>(const_cast<uint8_t*>(new_pin.data())),
1749 static_cast<Ulong>(new_pin.size()),
1750 return_value);
1751 }
bool C_SetPIN(SessionHandle session, const Utf8Char *old_pin_ptr, Ulong old_len, const Utf8Char *new_pin_ptr, Ulong new_len, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:229

References C_SetPIN(), and Botan::PKCS11::ThrowException.

◆ C_SetPIN() [2/2]

bool Botan::PKCS11::LowLevel::C_SetPIN ( SessionHandle session,
const Utf8Char * old_pin_ptr,
Ulong old_len,
const 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 229 of file p11.cpp.

234 {
235 return handle_return_value(
236 m_interface_wrapper.func_2_40().C_SetPIN(
237 session, const_cast<Utf8Char*>(old_pin_ptr), old_len, const_cast<Utf8Char*>(new_pin_ptr), new_len),
238 return_value);
239}

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 679 of file p11.cpp.

684 {
685 return handle_return_value(m_interface_wrapper.func_2_40().C_Sign(
686 session, const_cast<Byte*>(data_ptr), data_len, signature_ptr, signature_len_ptr),
687 return_value);
688}

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 2900 of file p11.h.

2903 {
2904 Ulong signature_size = 0;
2905 if(!C_Sign(session, data.data(), static_cast<Ulong>(data.size()), nullptr, &signature_size, return_value)) {
2906 return false;
2907 }
2908
2909 signature.resize(signature_size);
2910 if(!C_Sign(session,
2911 data.data(),
2912 static_cast<Ulong>(data.size()),
2913 signature.data(),
2914 &signature_size,
2915 return_value)) {
2916 return false;
2917 }
2918 signature.resize(signature_size);
2919 return true;
2920 }
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:679

References C_Sign(), and Botan::PKCS11::ThrowException.

◆ C_SignEncryptUpdate()

bool Botan::PKCS11::LowLevel::C_SignEncryptUpdate ( SessionHandle session,
const 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 964 of file p11.cpp.

969 {
970 return handle_return_value(
971 m_interface_wrapper.func_2_40().C_SignEncryptUpdate(
972 session, const_cast<Byte*>(part_ptr), part_len, encrypted_part_ptr, encrypted_part_len_ptr),
973 return_value);
974}

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 698 of file p11.cpp.

701 {
702 return handle_return_value(m_interface_wrapper.func_2_40().C_SignFinal(session, signature_ptr, signature_len_ptr),
703 return_value);
704}

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 3000 of file p11.h.

3002 {
3003 Ulong signature_size = 0;
3004 if(!C_SignFinal(session, nullptr, &signature_size, return_value)) {
3005 return false;
3006 }
3007
3008 signature.resize(signature_size);
3009 if(!C_SignFinal(session, signature.data(), &signature_size, return_value)) {
3010 return false;
3011 }
3012 signature.resize(signature_size);
3013 return true;
3014 }
bool C_SignFinal(SessionHandle session, Byte *signature_ptr, Ulong *signature_len_ptr, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:698

References C_SignFinal(), and Botan::PKCS11::ThrowException.

◆ C_SignInit()

bool Botan::PKCS11::LowLevel::C_SignInit ( SessionHandle session,
const 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 671 of file p11.cpp.

674 {
675 return handle_return_value(
676 m_interface_wrapper.func_2_40().C_SignInit(session, const_cast<Mechanism*>(mechanism_ptr), key), return_value);
677}

References handle_return_value().

◆ C_SignMessage()

bool Botan::PKCS11::LowLevel::C_SignMessage ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
const Byte * data_ptr,
Ulong data_len,
Byte * signature_ptr,
Ulong * signature_len_ptr,
ReturnValue * return_value = ThrowException )

C_SignMessage signs a message in a single part, where the signature is an appendix to the message. C_MessageSignInit must previously been called on the session.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
data_ptrdata to sign
data_lendata to sign length
signature_ptrgets signature
signature_len_ptrgets signature length
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 737 of file p11.cpp.

744 {
745 return handle_return_value(m_interface_wrapper.func_3_0().C_SignMessage(session,
746 const_cast<void*>(parameter_ptr),
747 parameter_len,
748 const_cast<Byte*>(data_ptr),
749 data_len,
750 signature_ptr,
751 signature_len_ptr),
752 return_value);
753}

References handle_return_value().

◆ C_SignMessageBegin()

bool Botan::PKCS11::LowLevel::C_SignMessageBegin ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
ReturnValue * return_value = ThrowException )

C_SignMessageBegin begins a multiple-part message signature operation, where the signature is an appendix to the message. C_MessageSignInit must previously been called on the session.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 755 of file p11.cpp.

758 {
759 return handle_return_value(
760 m_interface_wrapper.func_3_0().C_SignMessageBegin(session, const_cast<void*>(parameter_ptr), parameter_len),
761 return_value);
762}

References handle_return_value().

◆ C_SignMessageNext()

bool Botan::PKCS11::LowLevel::C_SignMessageNext ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
const Byte * data_ptr,
Ulong data_len,
Byte * signature_ptr,
Ulong * signature_len_ptr,
ReturnValue * return_value = ThrowException )

C_SignMessageNext continues a multiple-part message signature operation, processing another data part, or finishes a multiple-part message signature operation, returning the signature.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
data_ptrdata to sign
data_lendata to sign length
signature_ptrgets signature
signature_len_ptrgets signature length
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 764 of file p11.cpp.

771 {
772 return handle_return_value(m_interface_wrapper.func_3_0().C_SignMessageNext(session,
773 const_cast<void*>(parameter_ptr),
774 parameter_len,
775 const_cast<Byte*>(data_ptr),
776 data_len,
777 signature_ptr,
778 signature_len_ptr),
779 return_value);
780}

References handle_return_value().

◆ C_SignRecover()

bool Botan::PKCS11::LowLevel::C_SignRecover ( SessionHandle session,
const 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 715 of file p11.cpp.

720 {
721 return handle_return_value(m_interface_wrapper.func_2_40().C_SignRecover(
722 session, const_cast<Byte*>(data), data_len, signature, signature_len),
723 return_value);
724}

References handle_return_value().

◆ C_SignRecoverInit()

bool Botan::PKCS11::LowLevel::C_SignRecoverInit ( SessionHandle session,
const 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 706 of file p11.cpp.

709 {
710 return handle_return_value(
711 m_interface_wrapper.func_2_40().C_SignRecoverInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
712 return_value);
713}

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 690 of file p11.cpp.

693 {
694 return handle_return_value(
695 m_interface_wrapper.func_2_40().C_SignUpdate(session, const_cast<Byte*>(part_ptr), part_len), return_value);
696}

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 2957 of file p11.h.

2959 {
2960 return C_SignUpdate(session, part.data(), static_cast<Ulong>(part.size()), return_value);
2961 }
bool C_SignUpdate(SessionHandle session, const Byte *part_ptr, Ulong part_len, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:690

References C_SignUpdate(), and Botan::PKCS11::ThrowException.

◆ C_UnwrapKey()

bool Botan::PKCS11::LowLevel::C_UnwrapKey ( SessionHandle session,
const Mechanism * mechanism_ptr,
ObjectHandle unwrapping_key,
const 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 1035 of file p11.cpp.

1043 {
1044 return handle_return_value(m_interface_wrapper.func_2_40().C_UnwrapKey(session,
1045 const_cast<Mechanism*>(mechanism_ptr),
1046 unwrapping_key,
1047 const_cast<Byte*>(wrapped_key_ptr),
1048 wrapped_key_len,
1049 attribute_template_ptr,
1050 attribute_count,
1051 key_ptr),
1052 return_value);
1053}

References handle_return_value().

◆ C_UnwrapKeyAuthenticated()

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

C_UnwrapKeyAuthenticated unwraps (i.e. decrypts) a wrapped key, creating a new private key or secret key object.

Parameters
sessionsession's handle
mechanism_ptrunwrapping mechanism
unwrapping_keyunwrapping key
wrapped_key_ptrwrapped key
wrapped_key_lenlength of the wrapped key
attribute_template_ptrnew key template
attribute_counttemplate length
associated_data_ptrassociated data for an AEAD mechanism
associated_data_lenlength of the associated data
key_ptrgets new key handle
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 1089 of file p11.cpp.

1099 {
1100 return handle_return_value(
1101 m_interface_wrapper.func_3_2().C_UnwrapKeyAuthenticated(session,
1102 const_cast<Mechanism*>(mechanism_ptr),
1103 unwrapping_key,
1104 const_cast<Byte*>(wrapped_key_ptr),
1105 wrapped_key_len,
1106 attribute_template_ptr,
1107 attribute_count,
1108 const_cast<Byte*>(associated_data_ptr),
1109 associated_data_len,
1110 key_ptr),
1111 return_value);
1112}

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 796 of file p11.cpp.

801 {
802 return handle_return_value(
803 m_interface_wrapper.func_2_40().C_Verify(
804 session, const_cast<Byte*>(data_ptr), data_len, const_cast<Byte*>(signature_ptr), signature_len),
805 return_value);
806}

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 3221 of file p11.h.

3224 {
3225 return C_Verify(session,
3226 data.data(),
3227 static_cast<Ulong>(data.size()),
3228 signature.data(),
3229 static_cast<Ulong>(signature.size()),
3230 return_value);
3231 }
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:796

References C_Verify(), and Botan::PKCS11::ThrowException.

◆ 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 816 of file p11.cpp.

819 {
820 return handle_return_value(
821 m_interface_wrapper.func_2_40().C_VerifyFinal(session, const_cast<Byte*>(signature_ptr), signature_len),
822 return_value);
823}

References handle_return_value().

◆ C_VerifyInit()

bool Botan::PKCS11::LowLevel::C_VerifyInit ( SessionHandle session,
const 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 788 of file p11.cpp.

791 {
792 return handle_return_value(
793 m_interface_wrapper.func_2_40().C_VerifyInit(session, const_cast<Mechanism*>(mechanism_ptr), key), return_value);
794}

References handle_return_value().

◆ C_VerifyMessage()

bool Botan::PKCS11::LowLevel::C_VerifyMessage ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
const Byte * data_ptr,
Ulong data_len,
const Byte * signature_ptr,
Ulong signature_len,
ReturnValue * return_value = ThrowException )

C_VerifyMessage verifies a signature on a message in a single part operation, where the signature is an appendix to the data. C_MessageVerifyInit must previously been called on the session.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
data_ptrdata to sign
data_lendata to sign length
signature_ptrsignature
signature_lensignature length
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 889 of file p11.cpp.

896 {
897 return handle_return_value(m_interface_wrapper.func_3_0().C_VerifyMessage(session,
898 const_cast<void*>(parameter_ptr),
899 parameter_len,
900 const_cast<Byte*>(data_ptr),
901 data_len,
902 const_cast<Byte*>(signature_ptr),
903 signature_len),
904 return_value);
905}

References handle_return_value().

◆ C_VerifyMessageBegin()

bool Botan::PKCS11::LowLevel::C_VerifyMessageBegin ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
ReturnValue * return_value = ThrowException )

C_VerifyMessageBegin begins a multiple-part message verification operation, where the signature is an appendix to the message. C_MessageVerifyInit must previously been called on the session.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 907 of file p11.cpp.

910 {
911 return handle_return_value(
912 m_interface_wrapper.func_3_0().C_VerifyMessageBegin(session, const_cast<void*>(parameter_ptr), parameter_len),
913 return_value);
914}

References handle_return_value().

◆ C_VerifyMessageNext()

bool Botan::PKCS11::LowLevel::C_VerifyMessageNext ( SessionHandle session,
const void * parameter_ptr,
Ulong parameter_len,
const Byte * data_ptr,
Ulong data_len,
const Byte * signature_ptr,
Ulong signature_len,
ReturnValue * return_value = ThrowException )

C_VerifyMessageNext continues a multiple-part message verification operation, processing another data part, or finishes a multiple-part message verification operation, checking the signature.

Parameters
sessionthe session's handle
parameter_ptrmessage specific parameter
parameter_lenlength of message specific parameter
data_ptrdata to sign
data_lendata to sign length
signature_ptrsignature
signature_lensignature length
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 916 of file p11.cpp.

923 {
924 return handle_return_value(m_interface_wrapper.func_3_0().C_VerifyMessageNext(session,
925 const_cast<void*>(parameter_ptr),
926 parameter_len,
927 const_cast<Byte*>(data_ptr),
928 data_len,
929 const_cast<Byte*>(signature_ptr),
930 signature_len),
931 return_value);
932}

References handle_return_value().

◆ C_VerifyRecover()

bool Botan::PKCS11::LowLevel::C_VerifyRecover ( SessionHandle session,
const 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 834 of file p11.cpp.

839 {
840 return handle_return_value(m_interface_wrapper.func_2_40().C_VerifyRecover(
841 session, const_cast<Byte*>(signature_ptr), signature_len, data_ptr, data_len_ptr),
842 return_value);
843}

References handle_return_value().

◆ C_VerifyRecoverInit()

bool Botan::PKCS11::LowLevel::C_VerifyRecoverInit ( SessionHandle session,
const 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 825 of file p11.cpp.

828 {
829 return handle_return_value(
830 m_interface_wrapper.func_2_40().C_VerifyRecoverInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
831 return_value);
832}

References handle_return_value().

◆ C_VerifySignature()

bool Botan::PKCS11::LowLevel::C_VerifySignature ( SessionHandle session,
const Byte * data_ptr,
Ulong data_len,
ReturnValue * return_value = ThrowException )

C_VerifySignature verifies a signature in a single-part operation, where the signature is an appendix to the data.

Parameters
sessionthe session's handle
data_ptrsigned data
data_lenlength of signed data
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 857 of file p11.cpp.

860 {
861 return handle_return_value(
862 m_interface_wrapper.func_3_2().C_VerifySignature(session, const_cast<Byte*>(data_ptr), data_len), return_value);
863}

References handle_return_value().

◆ C_VerifySignatureFinal()

bool Botan::PKCS11::LowLevel::C_VerifySignatureFinal ( SessionHandle session,
ReturnValue * return_value = ThrowException )

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

Parameters
sessionthe session's handle
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 874 of file p11.cpp.

874 {
875 return handle_return_value(m_interface_wrapper.func_3_2().C_VerifySignatureFinal(session), return_value);
876}

References handle_return_value().

◆ C_VerifySignatureInit()

bool Botan::PKCS11::LowLevel::C_VerifySignatureInit ( SessionHandle session,
const Mechanism * mechanism_ptr,
ObjectHandle key,
const Byte * signature_ptr,
Ulong signature_len,
ReturnValue * return_value = ThrowException )

C_VerifySignatureInit initializes a verification operation, where the signature is included as part of the initialization.

Parameters
sessionthe session's handle
mechanism_ptrthe verification mechanism
keyverification key
signature_ptrsignature
signature_lensignature length
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 845 of file p11.cpp.

850 {
851 return handle_return_value(
852 m_interface_wrapper.func_3_2().C_VerifySignatureInit(
853 session, const_cast<Mechanism*>(mechanism_ptr), key, const_cast<Byte*>(signature_ptr), signature_len),
854 return_value);
855}

References handle_return_value().

◆ C_VerifySignatureUpdate()

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

C_VerifySignatureUpdate continues a multiple-part verification operation, processing another data part.

Parameters
sessionthe session's handle
part_ptrsigned data
part_lenlength of signed data
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 865 of file p11.cpp.

868 {
869 return handle_return_value(
870 m_interface_wrapper.func_3_2().C_VerifySignatureUpdate(session, const_cast<Byte*>(part_ptr), part_len),
871 return_value);
872}

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 808 of file p11.cpp.

811 {
812 return handle_return_value(
813 m_interface_wrapper.func_2_40().C_VerifyUpdate(session, const_cast<Byte*>(part_ptr), part_len), return_value);
814}

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 3268 of file p11.h.

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

References C_VerifyUpdate(), and Botan::PKCS11::ThrowException.

◆ C_WaitForSlotEvent()

bool Botan::PKCS11::LowLevel::C_WaitForSlotEvent ( Flags flags,
SlotId * slot_ptr,
void * 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 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
  • NoEvent
  • OK
Returns
true on success, false otherwise

Definition at line 167 of file p11.cpp.

167 {
168 return handle_return_value(m_interface_wrapper.func_2_40().C_WaitForSlotEvent(flags, slot_ptr, reserved),
169 return_value);
170}

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

◆ C_WrapKey()

bool Botan::PKCS11::LowLevel::C_WrapKey ( SessionHandle session,
const 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 1022 of file p11.cpp.

1028 {
1029 return handle_return_value(
1030 m_interface_wrapper.func_2_40().C_WrapKey(
1031 session, const_cast<Mechanism*>(mechanism_ptr), wrapping_key, key, wrapped_key_ptr, wrapped_key_len_ptr),
1032 return_value);
1033}

References handle_return_value().

◆ C_WrapKeyAuthenticated()

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

C_WrapKeyAuthenticated wraps (i.e. encrypts) a private or secret key.

Parameters
sessionsession's handle
mechanism_ptrwrapping mechanism
wrapping_keywrapping key
keykey to be wrapped
associated_data_ptrassociated data for an AEAD mechanism
associated_data_lenlength of the associated data
wrapped_key_ptrgets the wrapped key
wrapped_key_len_ptrgets the length of the wrapped key
return_valuedefault value (ThrowException): throw exception on error
Returns
true on success, false otherwise

Definition at line 1068 of file p11.cpp.

1076 {
1077 return handle_return_value(
1078 m_interface_wrapper.func_3_2().C_WrapKeyAuthenticated(session,
1079 const_cast<Mechanism*>(mechanism_ptr),
1080 wrapping_key,
1081 key,
1082 const_cast<Byte*>(associated_data_ptr),
1083 associated_data_len,
1084 wrapped_key_ptr,
1085 wrapped_key_len_ptr),
1086 return_value);
1087}

References handle_return_value().

◆ get_functions()

FunctionList * Botan::PKCS11::LowLevel::get_functions ( ) const

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 1213 of file p11.cpp.

1213 {
1214 return reinterpret_cast<FunctionList*>(m_interface_wrapper.raw_interface().pFunctionList);
1215}

◆ get_interface()

const InterfaceWrapper & Botan::PKCS11::LowLevel::get_interface ( )
inline

Definition at line 3999 of file p11.h.

3999{ return m_interface_wrapper; }

References get_interface().

Referenced by C_GetInterface(), and get_interface().

◆ handle_return_value()

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

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 27 of file p11.cpp.

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

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

Referenced by C_AsyncComplete(), C_AsyncGetID(), C_AsyncJoin(), C_CancelFunction(), C_CloseAllSessions(), C_CloseSession(), C_CopyObject(), C_CreateObject(), C_DecapsulateKey(), C_Decrypt(), C_DecryptDigestUpdate(), C_DecryptFinal(), C_DecryptInit(), C_DecryptMessage(), C_DecryptMessageBegin(), C_DecryptMessageNext(), C_DecryptUpdate(), C_DecryptVerifyUpdate(), C_DeriveKey(), C_DestroyObject(), C_Digest(), C_DigestEncryptUpdate(), C_DigestFinal(), C_DigestInit(), C_DigestKey(), C_DigestUpdate(), C_EncapsulateKey(), C_Encrypt(), C_EncryptFinal(), C_EncryptInit(), C_EncryptMessage(), C_EncryptMessageBegin(), C_EncryptMessageNext(), 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_GetInterface(), C_GetInterfaceList(), C_GetMechanismInfo(), C_GetMechanismList(), C_GetObjectSize(), C_GetOperationState(), C_GetSessionInfo(), C_GetSessionValidationFlags(), C_GetSlotInfo(), C_GetSlotList(), C_GetTokenInfo(), C_Initialize(), C_InitPIN(), C_InitToken(), C_Login(), C_LoginUser(), C_Logout(), C_MessageDecryptFinal(), C_MessageDecryptInit(), C_MessageEncryptFinal(), C_MessageEncryptInit(), C_MessageSignFinal(), C_MessageSignInit(), C_MessageVerifyFinal(), C_MessageVerifyInit(), C_OpenSession(), C_SeedRandom(), C_SessionCancel(), C_SetAttributeValue(), C_SetOperationState(), C_SetPIN(), C_Sign(), C_SignEncryptUpdate(), C_SignFinal(), C_SignInit(), C_SignMessage(), C_SignMessageBegin(), C_SignMessageNext(), C_SignRecover(), C_SignRecoverInit(), C_SignUpdate(), C_UnwrapKey(), C_UnwrapKeyAuthenticated(), C_Verify(), C_VerifyFinal(), C_VerifyInit(), C_VerifyMessage(), C_VerifyMessageBegin(), C_VerifyMessageNext(), C_VerifyRecover(), C_VerifyRecoverInit(), C_VerifySignature(), C_VerifySignatureFinal(), C_VerifySignatureInit(), C_VerifySignatureUpdate(), C_VerifyUpdate(), C_WaitForSlotEvent(), C_WrapKey(), and C_WrapKeyAuthenticated().


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