Botan 3.14.1
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
FunctionList * get_functions () const
const InterfaceWrapper & get_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 1330 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 81 of file p11.cpp.

81 :
82 m_interface_wrapper([&] {
83 BOTAN_ARG_CHECK(ptr != nullptr, "Function list pointer must not be nullptr");
84 return InterfaceWrapper(Interface{
86 .pFunctionList = ptr,
87 .flags = 0,
88 });
89 }()) {}
#define BOTAN_ARG_CHECK(expr, msg)
Definition assert.h:33
static Utf8Char * p11_interface_name_ptr()
CK_INTERFACE Interface
Definition p11.h:1192

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

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

1216 {
1217 return handle_return_value(
1218 m_interface_wrapper.func_3_2().C_AsyncComplete(session, const_cast<Utf8Char*>(function_name_ptr), result_ptr),
1219 return_value);
1220}
static bool handle_return_value(CK_RV function_result, ReturnValue *return_value)
Definition p11.cpp:28
CK_UTF8CHAR Utf8Char
Definition p11.h:1209

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

1225 {
1226 return handle_return_value(
1227 m_interface_wrapper.func_3_2().C_AsyncGetID(session, const_cast<Utf8Char*>(function_name_ptr), id_ptr),
1228 return_value);
1229}

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

1236 {
1237 return handle_return_value(m_interface_wrapper.func_3_2().C_AsyncJoin(
1238 session, const_cast<Utf8Char*>(function_name_ptr), id, data_ptr, data_len),
1239 return_value);
1240}

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

1207 {
1208 return handle_return_value(m_interface_wrapper.func_2_40().C_CancelFunction(session), return_value);
1209}

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

284 {
285 return handle_return_value(m_interface_wrapper.func_2_40().C_CloseAllSessions(slot_id), return_value);
286}

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

280 {
281 return handle_return_value(m_interface_wrapper.func_2_40().C_CloseSession(session), return_value);
282}

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

369 {
370 return handle_return_value(
371 m_interface_wrapper.func_2_40().C_CopyObject(session, object, attribute_template_ptr, count, new_object_ptr),
372 return_value);
373}

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

359 {
360 return handle_return_value(
361 m_interface_wrapper.func_2_40().C_CreateObject(session, attribute_template_ptr, count, object_ptr), return_value);
362}

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

1171 {
1172 return handle_return_value(m_interface_wrapper.func_3_2().C_DecapsulateKey(session,
1173 const_cast<Mechanism*>(mechanism_ptr),
1174 private_key,
1175 template_ptr,
1176 attribute_count,
1177 const_cast<Byte*>(ciphertext_ptr),
1178 ciphertext_len,
1179 key_ptr),
1180 return_value);
1181}
CK_MECHANISM Mechanism
Definition p11.h:1207
CK_BYTE Byte
Definition p11.h:1215

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

558 {
559 return handle_return_value(
560 m_interface_wrapper.func_2_40().C_Decrypt(
561 session, const_cast<Byte*>(encrypted_data_ptr), encrypted_data_len, data_ptr, data_len_ptr),
562 return_value);
563}

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

2592 {
2593 Ulong decrypted_size = 0;
2594 if(!C_Decrypt(session,
2595 const_cast<Byte*>((encrypted_data.data())),
2596 checked_ulong_cast(encrypted_data.size()),
2597 nullptr,
2598 &decrypted_size,
2599 return_value)) {
2600 return false;
2601 }
2602
2603 decrypted_data.resize(decrypted_size);
2604 if(!C_Decrypt(session,
2605 const_cast<Byte*>(encrypted_data.data()),
2606 checked_ulong_cast(encrypted_data.size()),
2607 decrypted_data.data(),
2608 &decrypted_size,
2609 return_value)) {
2610 return false;
2611 }
2612 decrypted_data.resize(decrypted_size);
2613 return true;
2614 }
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:553
Ulong checked_ulong_cast(size_t v)
Definition p11.h:1228
CK_ULONG Ulong
Definition p11.h:1204

References C_Decrypt(), Botan::PKCS11::checked_ulong_cast(), 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 981 of file p11.cpp.

986 {
987 return handle_return_value(
988 m_interface_wrapper.func_2_40().C_DecryptDigestUpdate(
989 session, const_cast<Byte*>(encrypted_part_ptr), encrypted_part_len, part_ptr, part_len_ptr),
990 return_value);
991}

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

580 {
581 return handle_return_value(m_interface_wrapper.func_2_40().C_DecryptFinal(session, last_part_ptr, last_part_len_ptr),
582 return_value);
583}

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

548 {
549 return handle_return_value(
550 m_interface_wrapper.func_2_40().C_DecryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key), return_value);
551}

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

605 {
606 return handle_return_value(m_interface_wrapper.func_3_0().C_DecryptMessage(session,
607 const_cast<void*>(parameter_ptr),
608 parameter_len,
609 const_cast<Byte*>(associated_data_ptr),
610 associated_data_len,
611 const_cast<Byte*>(ciphertext_ptr),
612 ciphertext_len,
613 plaintext_ptr,
614 plaintext_len_ptr),
615 return_value);
616}

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

623 {
624 return handle_return_value(
625 m_interface_wrapper.func_3_0().C_DecryptMessageBegin(session,
626 const_cast<void*>(parameter_ptr),
627 parameter_len,
628 const_cast<Byte*>(associated_data_ptr),
629 associated_data_len),
630 return_value);
631}

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

641 {
642 return handle_return_value(
643 m_interface_wrapper.func_3_0().C_DecryptMessageNext(session,
644 const_cast<void*>(parameter_ptr),
645 parameter_len,
646 const_cast<Byte*>(ciphertext_part_ptr),
647 ciphertext_part_len,
648 plaintext_ptr,
649 plaintext_part_len_ptr,
650 flags),
651 return_value);
652}
Flags flags(Flag flags)
Definition p11.h:1235

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

570 {
571 return handle_return_value(
572 m_interface_wrapper.func_2_40().C_DecryptUpdate(
573 session, const_cast<Byte*>(encrypted_part_ptr), encrypted_part_len, part_ptr, part_len_ptr),
574 return_value);
575}

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

1010 {
1011 return handle_return_value(
1012 m_interface_wrapper.func_2_40().C_DecryptVerifyUpdate(
1013 session, const_cast<Byte*>(encrypted_part_ptr), encrypted_part_len, part_ptr, part_len_ptr),
1014 return_value);
1015}

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

1090 {
1091 return handle_return_value(
1092 m_interface_wrapper.func_2_40().C_DeriveKey(
1093 session, const_cast<Mechanism*>(mechanism_ptr), base_key, attribute_template_ptr, attribute_count, key_ptr),
1094 return_value);
1095}

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

375 {
376 return handle_return_value(m_interface_wrapper.func_2_40().C_DestroyObject(session, object), return_value);
377}

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

670 {
671 return handle_return_value(m_interface_wrapper.func_2_40().C_Digest(
672 session, const_cast<Byte*>(data_ptr), data_len, digest_ptr, digest_len_ptr),
673 return_value);
674}

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

974 {
975 return handle_return_value(
976 m_interface_wrapper.func_2_40().C_DigestEncryptUpdate(
977 session, const_cast<Byte*>(part_ptr), part_len, encrypted_part_ptr, encrypted_part_len_ptr),
978 return_value);
979}

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

691 {
692 return handle_return_value(m_interface_wrapper.func_2_40().C_DigestFinal(session, digest_ptr, digest_len_ptr),
693 return_value);
694}

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

660 {
661 return handle_return_value(m_interface_wrapper.func_2_40().C_DigestInit(session, const_cast<Mechanism*>(mechanism)),
662 return_value);
663}

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

684 {
685 return handle_return_value(m_interface_wrapper.func_2_40().C_DigestKey(session, key), return_value);
686}

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

679 {
680 return handle_return_value(
681 m_interface_wrapper.func_2_40().C_DigestUpdate(session, const_cast<Byte*>(part_ptr), part_len), return_value);
682}

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

1151 {
1152 return handle_return_value(m_interface_wrapper.func_3_2().C_EncapsulateKey(session,
1153 const_cast<Mechanism*>(mechanism_ptr),
1154 public_key,
1155 template_ptr,
1156 attribute_count,
1157 ciphertext_ptr,
1158 ciphertext_len_ptr,
1159 key_ptr),
1160 return_value);
1161}

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

443 {
444 return handle_return_value(
445 m_interface_wrapper.func_2_40().C_Encrypt(
446 session, nonnull_input(data_ptr, data_len), data_len, encrypted_data_ptr, encrypted_data_len_ptr),
447 return_value);
448}

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

2359 {
2360 Ulong encrypted_size = 0;
2361 if(!C_Encrypt(session,
2362 const_cast<Byte*>((plaintext_data.data())),
2363 checked_ulong_cast(plaintext_data.size()),
2364 nullptr,
2365 &encrypted_size,
2366 return_value)) {
2367 return false;
2368 }
2369
2370 encrypted_data.resize(encrypted_size);
2371 if(!C_Encrypt(session,
2372 const_cast<Byte*>(plaintext_data.data()),
2373 checked_ulong_cast(plaintext_data.size()),
2374 encrypted_data.data(),
2375 &encrypted_size,
2376 return_value)) {
2377 return false;
2378 }
2379 encrypted_data.resize(encrypted_size);
2380 return true;
2381 }
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:438

References C_Encrypt(), Botan::PKCS11::checked_ulong_cast(), 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 462 of file p11.cpp.

465 {
466 return handle_return_value(
467 m_interface_wrapper.func_2_40().C_EncryptFinal(session, last_encrypted_part_ptr, last_encrypted_part_len_ptr),
468 return_value);
469}

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

433 {
434 return handle_return_value(
435 m_interface_wrapper.func_2_40().C_EncryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key), return_value);
436}

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

491 {
492 return handle_return_value(m_interface_wrapper.func_3_0().C_EncryptMessage(session,
493 const_cast<void*>(parameter_ptr),
494 parameter_len,
495 const_cast<Byte*>(associated_data_ptr),
496 associated_data_len,
497 const_cast<Byte*>(plaintext_ptr),
498 plaintext_len,
499 ciphertext_ptr,
500 ciphertext_len_ptr),
501 return_value);
502}

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

509 {
510 return handle_return_value(
511 m_interface_wrapper.func_3_0().C_EncryptMessageBegin(session,
512 const_cast<void*>(parameter_ptr),
513 parameter_len,
514 const_cast<Byte*>(associated_data_ptr),
515 associated_data_len),
516 return_value);
517}

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

527 {
528 return handle_return_value(m_interface_wrapper.func_3_0().C_EncryptMessageNext(session,
529 const_cast<void*>(parameter_ptr),
530 parameter_len,
531 const_cast<Byte*>(plaintext_part_ptr),
532 plaintext_part_len,
533 ciphertext_ptr,
534 ciphertext_part_len_ptr,
535 flags),
536 return_value);
537}

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

455 {
456 return handle_return_value(
457 m_interface_wrapper.func_2_40().C_EncryptUpdate(
458 session, const_cast<Byte*>(part_ptr), part_len, encrypted_part_ptr, encrypted_part_len_ptr),
459 return_value);
460}

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

99 {
100 return handle_return_value(m_interface_wrapper.func_2_40().C_Finalize(reserved), return_value);
101}

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

418 {
419 return handle_return_value(
420 m_interface_wrapper.func_2_40().C_FindObjects(session, object_ptr, max_object_count, object_count_ptr),
421 return_value);
422}

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

424 {
425 return handle_return_value(m_interface_wrapper.func_2_40().C_FindObjectsFinal(session), return_value);
426}

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

409 {
410 return handle_return_value(m_interface_wrapper.func_2_40().C_FindObjectsInit(session, attribute_template_ptr, count),
411 return_value);
412}

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

1024 {
1025 return handle_return_value(
1026 m_interface_wrapper.func_2_40().C_GenerateKey(
1027 session, const_cast<Mechanism*>(mechanism_ptr), attribute_template_ptr, count, key_ptr),
1028 return_value);
1029}

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

1039 {
1040 return handle_return_value(m_interface_wrapper.func_2_40().C_GenerateKeyPair(session,
1041 const_cast<Mechanism*>(mechanism_ptr),
1042 public_key_template_ptr,
1043 public_key_attribute_count,
1044 private_key_template_ptr,
1045 private_key_attribute_count,
1046 public_key_ptr,
1047 private_key_ptr),
1048 return_value);
1049}

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

1196 {
1197 return handle_return_value(m_interface_wrapper.func_2_40().C_GenerateRandom(session, random_data_ptr, random_len),
1198 return_value);
1199}

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

390 {
391 return handle_return_value(
392 m_interface_wrapper.func_2_40().C_GetAttributeValue(session, object, attribute_template_ptr, count),
393 return_value);
394}

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

2127 {
2128 std::vector<Attribute> getter_template;
2129
2130 getter_template.reserve(attribute_values.size());
2131 for(const auto& entry : attribute_values) {
2132 getter_template.emplace_back(Attribute{static_cast<CK_ATTRIBUTE_TYPE>(entry.first), nullptr, 0});
2133 }
2134
2135 const bool success = C_GetAttributeValue(session,
2136 object,
2137 const_cast<Attribute*>(getter_template.data()),
2138 checked_ulong_cast(getter_template.size()),
2139 return_value);
2140
2141 if(!success) {
2142 return success;
2143 }
2144
2145 size_t i = 0;
2146 for(auto& entry : attribute_values) {
2147 entry.second.clear();
2148 entry.second.resize(getter_template.at(i).ulValueLen);
2149 getter_template.at(i).pValue = const_cast<uint8_t*>(entry.second.data());
2150 i++;
2151 }
2152
2153 if(!C_GetAttributeValue(session,
2154 object,
2155 const_cast<Attribute*>(getter_template.data()),
2156 checked_ulong_cast(getter_template.size()),
2157 return_value)) {
2158 return false;
2159 }
2160
2161 // The final lengths may be shorter than the ones reported by the sizing call
2162 i = 0;
2163 for(auto& entry : attribute_values) {
2164 const Ulong final_len = getter_template.at(i).ulValueLen;
2165 if(final_len < entry.second.size()) {
2166 entry.second.resize(final_len);
2167 }
2168 i++;
2169 }
2170 return true;
2171 }
bool C_GetAttributeValue(SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:386
CK_ATTRIBUTE Attribute
Definition p11.h:1213
CK_ULONG CK_ATTRIBUTE_TYPE
Definition pkcs11.h:44

References C_GetAttributeValue(), Botan::PKCS11::checked_ulong_cast(), 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 107 of file p11.cpp.

109 {
110 using get_function_list = CK_RV (*)(FunctionList**);
111
112 get_function_list get_function_list_ptr = pkcs11_module.resolve<get_function_list>("C_GetFunctionList");
113
114 return handle_return_value(get_function_list_ptr(function_list_ptr_ptr), return_value);
115}
CK_FUNCTION_LIST FunctionList
Definition p11.h:1188
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 1203 of file p11.cpp.

1203 {
1204 return handle_return_value(m_interface_wrapper.func_2_40().C_GetFunctionStatus(session), return_value);
1205}

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

103 {
104 return handle_return_value(m_interface_wrapper.func_2_40().C_GetInfo(info_ptr), return_value);
105}

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

135 {
136 using get_interface =
137 CK_RV (*)(Utf8Char* interface_name_ptr, Version* version_ptr, Interface** interface_ptr_ptr, Flags flags);
138 if(auto get_interface_ptr = pkcs11_module.try_resolve_symbol<get_interface>("C_GetInterface");
139 get_interface_ptr.has_value()) {
140 return handle_return_value(
141 get_interface_ptr.value()(
142 const_cast<Utf8Char*>(interface_name_ptr), const_cast<Version*>(version_ptr), interface_ptr_ptr, flags),
143 return_value);
144 }
145 // Loading the library function failed. Probably due to a cryptoki library with PKCS #11 < 3.0.
146 return handle_return_value(CKR_GENERAL_ERROR, return_value);
147}
const InterfaceWrapper & get_interface()
Definition p11.h:4024
CK_VERSION Version
Definition p11.h:1201
CK_FLAGS Flags
Definition p11.h:1199
#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 117 of file p11.cpp.

120 {
121 using get_interface_list = CK_RV (*)(Interface*, Ulong*);
122 if(auto get_interface_list_ptr = pkcs11_module.try_resolve_symbol<get_interface_list>("C_GetInterfaceList");
123 get_interface_list_ptr.has_value()) {
124 return handle_return_value(get_interface_list_ptr.value()(interface_list_ptr, count_ptr), return_value);
125 }
126 // Loading the library function failed. Probably due to a cryptoki library with PKCS #11 < 3.0.
127 return handle_return_value(CKR_GENERAL_ERROR, return_value);
128}

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

231 {
232 return handle_return_value(
233 m_interface_wrapper.func_2_40().C_GetMechanismInfo(slot_id, static_cast<CK_MECHANISM_TYPE>(type), info_ptr),
234 return_value);
235}
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 194 of file p11.cpp.

197 {
198 return handle_return_value(m_interface_wrapper.func_2_40().C_GetMechanismList(
199 slot_id, reinterpret_cast<CK_MECHANISM_TYPE_PTR>(mechanism_list_ptr), count_ptr),
200 return_value);
201}
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 203 of file p11.cpp.

205 {
206 mechanisms.clear();
207
208 // first get number of mechanisms
209 Ulong number_mechanisms = 0;
210
211 const bool success = C_GetMechanismList(slot_id, nullptr, &number_mechanisms, return_value);
212
213 if(!success || number_mechanisms == 0) {
214 return success;
215 }
216
217 // get actual mechanisms
218 mechanisms.resize(number_mechanisms);
220 slot_id, reinterpret_cast<MechanismType*>(mechanisms.data()), &number_mechanisms, return_value)) {
221 return false;
222 }
223 // the count may have shrunk between the calls
224 mechanisms.resize(std::min<size_t>(mechanisms.size(), number_mechanisms));
225 return true;
226}
bool C_GetMechanismList(SlotId slot_id, MechanismType *mechanism_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:194

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

382 {
383 return handle_return_value(m_interface_wrapper.func_2_40().C_GetObjectSize(session, object, size_ptr), return_value);
384}

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

299 {
300 return handle_return_value(
301 m_interface_wrapper.func_2_40().C_GetOperationState(session, operation_state_ptr, operation_state_len_ptr),
302 return_value);
303}

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

288 {
289 return handle_return_value(m_interface_wrapper.func_2_40().C_GetSessionInfo(session, info_ptr), return_value);
290}

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

348 {
349 return handle_return_value(m_interface_wrapper.func_3_2().C_GetSessionValidationFlags(session, type, flags_ptr),
350 return_value);
351}

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

181 {
182 return handle_return_value(m_interface_wrapper.func_2_40().C_GetSlotInfo(slot_id, info_ptr), return_value);
183}

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

154 {
155 return handle_return_value(m_interface_wrapper.func_2_40().C_GetSlotList(token_present, slot_list_ptr, count_ptr),
156 return_value);
157}

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

159 {
160 slot_ids.clear();
161
162 // first get available slots
163 Ulong number_slots = 0;
164
165 const bool success = C_GetSlotList(static_cast<Bbool>(token_present), nullptr, &number_slots, return_value);
166
167 if(!success || number_slots == 0) {
168 return success;
169 }
170
171 // get actual slot ids
172 slot_ids.resize(number_slots);
173 if(!C_GetSlotList(static_cast<Bbool>(token_present), slot_ids.data(), &number_slots, return_value)) {
174 return false;
175 }
176 // the count may have shrunk between the calls
177 slot_ids.resize(std::min<size_t>(slot_ids.size(), number_slots));
178 return true;
179}
bool C_GetSlotList(Bbool token_present, SlotId *slot_list_ptr, Ulong *count_ptr, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:151
CK_BBOOL Bbool
Definition p11.h:1202

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

185 {
186 return handle_return_value(m_interface_wrapper.func_2_40().C_GetTokenInfo(slot_id, info_ptr), return_value);
187}

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

95 {
96 return handle_return_value(m_interface_wrapper.func_2_40().C_Initialize(const_cast<void*>(init_args)), return_value);
97}

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

1704 {
1705 return C_InitPIN(session,
1706 reinterpret_cast<Utf8Char*>(const_cast<uint8_t*>(pin.data())),
1707 checked_ulong_cast(pin.size()),
1708 return_value);
1709 }
bool C_InitPIN(SessionHandle session, const Utf8Char *pin_ptr, Ulong pin_len, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:248

References C_InitPIN(), Botan::PKCS11::checked_ulong_cast(), 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 248 of file p11.cpp.

251 {
252 return handle_return_value(
253 m_interface_wrapper.func_2_40().C_InitPIN(session, const_cast<Utf8Char*>(pin_ptr), pin_len), return_value);
254}

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

1648 {
1649 if(label.size() > 32) {
1650 throw Invalid_Argument("PKCS #11 token label must be at most 32 bytes");
1651 }
1652
1653 std::string padded_label(label);
1654 if(label.size() < 32) {
1655 padded_label.insert(padded_label.end(), 32 - label.size(), ' ');
1656 }
1657
1658 return C_InitToken(slot_id,
1659 reinterpret_cast<Utf8Char*>(const_cast<uint8_t*>(so_pin.data())),
1660 checked_ulong_cast(so_pin.size()),
1661 reinterpret_cast<Utf8Char*>(const_cast<char*>(padded_label.c_str())),
1662 return_value);
1663 }
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:237

References C_InitToken(), Botan::PKCS11::checked_ulong_cast(), 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 237 of file p11.cpp.

241 {
242 return handle_return_value(
243 m_interface_wrapper.func_2_40().C_InitToken(
244 slot_id, const_cast<Utf8Char*>(so_pin_ptr), so_pin_len, const_cast<Utf8Char*>(label_ptr)),
245 return_value);
246}

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

1936 {
1937 return C_Login(session,
1938 user_type,
1939 reinterpret_cast<Utf8Char*>(const_cast<uint8_t*>(pin.data())),
1940 checked_ulong_cast(pin.size()),
1941 return_value);
1942 }
bool C_Login(SessionHandle session, UserType user_type, const Utf8Char *pin_ptr, Ulong pin_len, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:317

References C_Login(), Botan::PKCS11::checked_ulong_cast(), 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 317 of file p11.cpp.

318 {
319 return handle_return_value(
320 m_interface_wrapper.func_2_40().C_Login(
321 session, static_cast<CK_USER_TYPE>(user_type), const_cast<Utf8Char*>(pin_ptr), pin_len),
322 return_value);
323}
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 325 of file p11.cpp.

331 {
332 return handle_return_value(m_interface_wrapper.func_3_0().C_LoginUser(session,
333 static_cast<CK_USER_TYPE>(user_type),
334 const_cast<Utf8Char*>(pin_ptr),
335 pin_len,
336 const_cast<Utf8Char*>(username_ptr),
337 username_len),
338 return_value);
339}

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

341 {
342 return handle_return_value(m_interface_wrapper.func_2_40().C_Logout(session), return_value);
343}

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

654 {
655 return handle_return_value(m_interface_wrapper.func_3_0().C_MessageDecryptFinal(session), return_value);
656}

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

590 {
591 return handle_return_value(
592 m_interface_wrapper.func_3_0().C_MessageDecryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
593 return_value);
594}

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

539 {
540 return handle_return_value(m_interface_wrapper.func_3_0().C_MessageEncryptFinal(session), return_value);
541}

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

476 {
477 return handle_return_value(
478 m_interface_wrapper.func_3_0().C_MessageEncryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
479 return_value);
480}

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

810 {
811 return handle_return_value(m_interface_wrapper.func_3_0().C_MessageSignFinal(session), return_value);
812}

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

759 {
760 return handle_return_value(
761 m_interface_wrapper.func_3_0().C_MessageSignInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
762 return_value);
763}

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

963 {
964 return handle_return_value(m_interface_wrapper.func_3_0().C_MessageVerifyFinal(session), return_value);
965}

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

912 {
913 return handle_return_value(
914 m_interface_wrapper.func_3_0().C_MessageVerifyInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
915 return_value);
916}

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

275 {
276 return handle_return_value(
277 m_interface_wrapper.func_2_40().C_OpenSession(slot_id, flags, application, notify, session_ptr), return_value);
278}

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

1188 {
1189 return handle_return_value(
1190 m_interface_wrapper.func_2_40().C_SeedRandom(session, const_cast<Byte*>(seed_ptr), seed_len), return_value);
1191}

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

292 {
293 return handle_return_value(m_interface_wrapper.func_3_0().C_SessionCancel(session, flags), return_value);
294}

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

400 {
401 return handle_return_value(
402 m_interface_wrapper.func_2_40().C_SetAttributeValue(session, object, attribute_template_ptr, count),
403 return_value);
404}

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

2218 {
2219 std::vector<Attribute> setter_template;
2220
2221 setter_template.reserve(attribute_values.size());
2222 for(auto& entry : attribute_values) {
2223 setter_template.emplace_back(Attribute{static_cast<CK_ATTRIBUTE_TYPE>(entry.first),
2224 entry.second.data(),
2225 checked_ulong_cast(entry.second.size())});
2226 }
2227
2228 return C_SetAttributeValue(session,
2229 object,
2230 const_cast<Attribute*>(setter_template.data()),
2231 checked_ulong_cast(setter_template.size()),
2232 return_value);
2233 }
bool C_SetAttributeValue(SessionHandle session, ObjectHandle object, Attribute *attribute_template_ptr, Ulong count, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:396

References C_SetAttributeValue(), Botan::PKCS11::checked_ulong_cast(), 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 305 of file p11.cpp.

310 {
311 return handle_return_value(
312 m_interface_wrapper.func_2_40().C_SetOperationState(
313 session, const_cast<Byte*>(operation_state_ptr), operation_state_len, encryption_key, authentication_key),
314 return_value);
315}

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

1756 {
1757 return C_SetPIN(session,
1758 reinterpret_cast<Utf8Char*>(const_cast<uint8_t*>(old_pin.data())),
1759 checked_ulong_cast(old_pin.size()),
1760 reinterpret_cast<Utf8Char*>(const_cast<uint8_t*>(new_pin.data())),
1761 checked_ulong_cast(new_pin.size()),
1762 return_value);
1763 }
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:256

References C_SetPIN(), Botan::PKCS11::checked_ulong_cast(), 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 256 of file p11.cpp.

261 {
262 return handle_return_value(
263 m_interface_wrapper.func_2_40().C_SetPIN(
264 session, const_cast<Utf8Char*>(old_pin_ptr), old_len, const_cast<Utf8Char*>(new_pin_ptr), new_len),
265 return_value);
266}

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

711 {
712 return handle_return_value(
713 m_interface_wrapper.func_2_40().C_Sign(
714 session, nonnull_input(data_ptr, data_len), data_len, signature_ptr, signature_len_ptr),
715 return_value);
716}

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

2928 {
2929 Ulong signature_size = 0;
2930 if(!C_Sign(session, data.data(), checked_ulong_cast(data.size()), nullptr, &signature_size, return_value)) {
2931 return false;
2932 }
2933
2934 signature.resize(signature_size);
2935 if(!C_Sign(session,
2936 data.data(),
2937 checked_ulong_cast(data.size()),
2938 signature.data(),
2939 &signature_size,
2940 return_value)) {
2941 return false;
2942 }
2943 signature.resize(signature_size);
2944 return true;
2945 }
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:706

References C_Sign(), Botan::PKCS11::checked_ulong_cast(), 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 993 of file p11.cpp.

998 {
999 return handle_return_value(
1000 m_interface_wrapper.func_2_40().C_SignEncryptUpdate(
1001 session, const_cast<Byte*>(part_ptr), part_len, encrypted_part_ptr, encrypted_part_len_ptr),
1002 return_value);
1003}

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

729 {
730 return handle_return_value(m_interface_wrapper.func_2_40().C_SignFinal(session, signature_ptr, signature_len_ptr),
731 return_value);
732}

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

3027 {
3028 Ulong signature_size = 0;
3029 if(!C_SignFinal(session, nullptr, &signature_size, return_value)) {
3030 return false;
3031 }
3032
3033 signature.resize(signature_size);
3034 if(!C_SignFinal(session, signature.data(), &signature_size, return_value)) {
3035 return false;
3036 }
3037 signature.resize(signature_size);
3038 return true;
3039 }
bool C_SignFinal(SessionHandle session, Byte *signature_ptr, Ulong *signature_len_ptr, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:726

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

701 {
702 return handle_return_value(
703 m_interface_wrapper.func_2_40().C_SignInit(session, const_cast<Mechanism*>(mechanism_ptr), key), return_value);
704}

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

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

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

786 {
787 return handle_return_value(
788 m_interface_wrapper.func_3_0().C_SignMessageBegin(session, const_cast<void*>(parameter_ptr), parameter_len),
789 return_value);
790}

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

799 {
800 return handle_return_value(m_interface_wrapper.func_3_0().C_SignMessageNext(session,
801 const_cast<void*>(parameter_ptr),
802 parameter_len,
803 const_cast<Byte*>(data_ptr),
804 data_len,
805 signature_ptr,
806 signature_len_ptr),
807 return_value);
808}

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

748 {
749 return handle_return_value(m_interface_wrapper.func_2_40().C_SignRecover(
750 session, const_cast<Byte*>(data), data_len, signature, signature_len),
751 return_value);
752}

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

737 {
738 return handle_return_value(
739 m_interface_wrapper.func_2_40().C_SignRecoverInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
740 return_value);
741}

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

721 {
722 return handle_return_value(
723 m_interface_wrapper.func_2_40().C_SignUpdate(session, nonnull_input(part_ptr, part_len), part_len), return_value);
724}

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

2984 {
2985 return C_SignUpdate(session, part.data(), checked_ulong_cast(part.size()), return_value);
2986 }
bool C_SignUpdate(SessionHandle session, const Byte *part_ptr, Ulong part_len, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:718

References C_SignUpdate(), Botan::PKCS11::checked_ulong_cast(), 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 1064 of file p11.cpp.

1072 {
1073 return handle_return_value(m_interface_wrapper.func_2_40().C_UnwrapKey(session,
1074 const_cast<Mechanism*>(mechanism_ptr),
1075 unwrapping_key,
1076 const_cast<Byte*>(wrapped_key_ptr),
1077 wrapped_key_len,
1078 attribute_template_ptr,
1079 attribute_count,
1080 key_ptr),
1081 return_value);
1082}

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

1128 {
1129 return handle_return_value(
1130 m_interface_wrapper.func_3_2().C_UnwrapKeyAuthenticated(session,
1131 const_cast<Mechanism*>(mechanism_ptr),
1132 unwrapping_key,
1133 const_cast<Byte*>(wrapped_key_ptr),
1134 wrapped_key_len,
1135 attribute_template_ptr,
1136 attribute_count,
1137 const_cast<Byte*>(associated_data_ptr),
1138 associated_data_len,
1139 key_ptr),
1140 return_value);
1141}

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

829 {
830 return handle_return_value(
831 m_interface_wrapper.func_2_40().C_Verify(
832 session, nonnull_input(data_ptr, data_len), data_len, const_cast<Byte*>(signature_ptr), signature_len),
833 return_value);
834}

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

3249 {
3250 return C_Verify(session,
3251 data.data(),
3252 checked_ulong_cast(data.size()),
3253 signature.data(),
3254 checked_ulong_cast(signature.size()),
3255 return_value);
3256 }
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:824

References C_Verify(), Botan::PKCS11::checked_ulong_cast(), 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 845 of file p11.cpp.

848 {
849 return handle_return_value(
850 m_interface_wrapper.func_2_40().C_VerifyFinal(session, const_cast<Byte*>(signature_ptr), signature_len),
851 return_value);
852}

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

819 {
820 return handle_return_value(
821 m_interface_wrapper.func_2_40().C_VerifyInit(session, const_cast<Mechanism*>(mechanism_ptr), key), return_value);
822}

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

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

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

939 {
940 return handle_return_value(
941 m_interface_wrapper.func_3_0().C_VerifyMessageBegin(session, const_cast<void*>(parameter_ptr), parameter_len),
942 return_value);
943}

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

952 {
953 return handle_return_value(m_interface_wrapper.func_3_0().C_VerifyMessageNext(session,
954 const_cast<void*>(parameter_ptr),
955 parameter_len,
956 const_cast<Byte*>(data_ptr),
957 data_len,
958 const_cast<Byte*>(signature_ptr),
959 signature_len),
960 return_value);
961}

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

868 {
869 return handle_return_value(m_interface_wrapper.func_2_40().C_VerifyRecover(
870 session, const_cast<Byte*>(signature_ptr), signature_len, data_ptr, data_len_ptr),
871 return_value);
872}

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

857 {
858 return handle_return_value(
859 m_interface_wrapper.func_2_40().C_VerifyRecoverInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
860 return_value);
861}

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

889 {
890 return handle_return_value(
891 m_interface_wrapper.func_3_2().C_VerifySignature(session, const_cast<Byte*>(data_ptr), data_len), return_value);
892}

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

903 {
904 return handle_return_value(m_interface_wrapper.func_3_2().C_VerifySignatureFinal(session), return_value);
905}

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

879 {
880 return handle_return_value(
881 m_interface_wrapper.func_3_2().C_VerifySignatureInit(
882 session, const_cast<Mechanism*>(mechanism_ptr), key, const_cast<Byte*>(signature_ptr), signature_len),
883 return_value);
884}

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

897 {
898 return handle_return_value(
899 m_interface_wrapper.func_3_2().C_VerifySignatureUpdate(session, const_cast<Byte*>(part_ptr), part_len),
900 return_value);
901}

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

839 {
840 return handle_return_value(
841 m_interface_wrapper.func_2_40().C_VerifyUpdate(session, nonnull_input(part_ptr, part_len), part_len),
842 return_value);
843}

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

3295 {
3296 return C_VerifyUpdate(session, part.data(), checked_ulong_cast(part.size()), return_value);
3297 }
bool C_VerifyUpdate(SessionHandle session, const Byte *part_ptr, Ulong part_len, ReturnValue *return_value=ThrowException) const
Definition p11.cpp:836

References C_VerifyUpdate(), Botan::PKCS11::checked_ulong_cast(), 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 189 of file p11.cpp.

189 {
190 return handle_return_value(m_interface_wrapper.func_2_40().C_WaitForSlotEvent(flags, slot_ptr, reserved),
191 return_value);
192}

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

1057 {
1058 return handle_return_value(
1059 m_interface_wrapper.func_2_40().C_WrapKey(
1060 session, const_cast<Mechanism*>(mechanism_ptr), wrapping_key, key, wrapped_key_ptr, wrapped_key_len_ptr),
1061 return_value);
1062}

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

1105 {
1106 return handle_return_value(
1107 m_interface_wrapper.func_3_2().C_WrapKeyAuthenticated(session,
1108 const_cast<Mechanism*>(mechanism_ptr),
1109 wrapping_key,
1110 key,
1111 const_cast<Byte*>(associated_data_ptr),
1112 associated_data_len,
1113 wrapped_key_ptr,
1114 wrapped_key_len_ptr),
1115 return_value);
1116}

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

1242 {
1243 return reinterpret_cast<FunctionList*>(m_interface_wrapper.raw_interface().pFunctionList);
1244}

◆ get_interface()

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

Definition at line 4024 of file p11.h.

4024{ 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 28 of file p11.cpp.

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

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: