• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 12805544433

16 Jan 2025 09:08AM UTC coverage: 90.876% (-0.4%) from 91.245%
12805544433

Pull #4540

github

web-flow
Merge cc1ceff51 into 9b798efbb
Pull Request #4540: PKCS #11 Version 3.2 Support

93425 of 102805 relevant lines covered (90.88%)

11409241.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

49.75
/src/lib/prov/pkcs11/p11.cpp
1
/*
2
* PKCS#11
3
* (C) 2016 Daniel Neus, Sirrix AG
4
* (C) 2016 Philipp Weber, Sirrix AG
5
* (C) 2025 Fabian Albert, Rohde & Schwarz Cybersecurity
6
*
7
* Botan is released under the Simplified BSD License (see license.txt)
8
*/
9

10
#include <botan/p11.h>
11

12
#include <botan/p11_types.h>
13
#include <botan/internal/dyn_load.h>
14

15
#include <string>
16

17
namespace Botan::PKCS11 {
18

19
// NOLINTNEXTLINE(*-no-int-to-ptr,*-avoid-non-const-global-variables)
20
ReturnValue* ThrowException = reinterpret_cast<ReturnValue*>(-1);
21

22
/// @param function_result Return value of the PKCS11 module function
23
/// @param return_value if (`ThrowException`) is passed the function throws an exception, otherwise if a non-NULL pointer is passed:
24
/// return_value receives the return value of the PKCS#11 function and no exception is thrown.
25
/// @return true if function call was successful, false otherwise
26
bool LowLevel::handle_return_value(const CK_RV function_result, ReturnValue* return_value) {
1,081✔
27
   if(return_value == ThrowException) {
1,081✔
28
      if(static_cast<ReturnValue>(function_result) != ReturnValue::OK) {
707✔
29
         // caller wants exception
30
         throw PKCS11_ReturnError(static_cast<ReturnValue>(function_result));
4✔
31
      }
32
   } else if(return_value != nullptr) {
374✔
33
      // caller wants return value
34
      *return_value = static_cast<ReturnValue>(function_result);
54✔
35
   }
36

37
   return static_cast<ReturnValue>(function_result) == ReturnValue::OK;
1,077✔
38
}
39

40
void initialize_token(Slot& slot, std::string_view label, const secure_string& so_pin, const secure_string& pin) {
1✔
41
   slot.initialize(label, so_pin);
1✔
42
   set_pin(slot, so_pin, pin);
1✔
43
}
1✔
44

45
void change_pin(Slot& slot, const secure_string& old_pin, const secure_string& new_pin) {
2✔
46
   Session session(slot, false);
2✔
47
   session.login(UserType::User, old_pin);
2✔
48
   session.set_pin(old_pin, new_pin);
2✔
49
}
2✔
50

51
void change_so_pin(Slot& slot, const secure_string& old_so_pin, const secure_string& new_so_pin) {
2✔
52
   Session session(slot, false);
2✔
53
   session.login(UserType::SO, old_so_pin);
2✔
54
   session.set_pin(old_so_pin, new_so_pin);
2✔
55
}
2✔
56

57
void set_pin(Slot& slot, const secure_string& so_pin, const secure_string& pin) {
3✔
58
   Session session(slot, false);
3✔
59
   session.login(UserType::SO, so_pin);
3✔
60
   session.init_pin(pin);
3✔
61
}
3✔
62

63
LowLevel::LowLevel(FunctionList* ptr) {
23✔
64
   BOTAN_ARG_CHECK(ptr != nullptr, "Function list pointer must not be nullptr");
23✔
65
   m_interface_wrapper = std::make_unique<InterfaceWrapper>(Interface{
22✔
66
      .pInterfaceName = InterfaceWrapper::p11_interface_name_ptr(),
22✔
67
      .pFunctionList = ptr,
68
      .flags = 0,
69
   });
22✔
70
}
23✔
71

72
LowLevel::LowLevel(std::unique_ptr<InterfaceWrapper> interface_wrapper) {
52✔
73
   BOTAN_ARG_CHECK(interface_wrapper != nullptr, "Interface wrapper must not be nullptr");
52✔
74
   m_interface_wrapper = std::move(interface_wrapper);
52✔
75
}
52✔
76

77
/****************************** General purpose functions ******************************/
78

79
bool LowLevel::C_Initialize(const void* init_args, ReturnValue* return_value) const {
75✔
80
   return handle_return_value(m_interface_wrapper->func_2_40().C_Initialize(const_cast<void*>(init_args)),
75✔
81
                              return_value);
74✔
82
}
83

84
bool LowLevel::C_Finalize(void* reserved, ReturnValue* return_value) const {
74✔
85
   return handle_return_value(m_interface_wrapper->func_2_40().C_Finalize(reserved), return_value);
74✔
86
}
87

88
bool LowLevel::C_GetInfo(Info* info_ptr, ReturnValue* return_value) const {
5✔
89
   return handle_return_value(m_interface_wrapper->func_2_40().C_GetInfo(info_ptr), return_value);
5✔
90
}
91

92
bool LowLevel::C_GetFunctionList(const Dynamically_Loaded_Library& pkcs11_module,
78✔
93
                                 FunctionList** function_list_ptr_ptr,
94
                                 ReturnValue* return_value) {
95
   using get_function_list = CK_RV (*)(FunctionList**);
78✔
96

97
   get_function_list get_function_list_ptr = pkcs11_module.resolve<get_function_list>("C_GetFunctionList");
156✔
98

99
   return handle_return_value(get_function_list_ptr(function_list_ptr_ptr), return_value);
78✔
100
}
101

102
bool LowLevel::C_GetInterfaceList(const Dynamically_Loaded_Library& pkcs11_module,
53✔
103
                                  Interface* interface_list_ptr,
104
                                  Ulong* count_ptr,
105
                                  ReturnValue* return_value) {
106
   using get_interface_list = CK_RV (*)(Interface*, Ulong*);
53✔
107
   get_interface_list get_interface_list_ptr;
53✔
108
   try {
53✔
109
      get_interface_list_ptr = pkcs11_module.resolve<get_interface_list>("C_GetInterfaceList");
106✔
110
   } catch(Invalid_Argument&) {
53✔
111
      // Loading the library function failed. Probably due to a cryptoki library with PKCS #11 < 3.0.
112
      return handle_return_value(CKR_GENERAL_ERROR, return_value);
53✔
113
   }
53✔
114

115
   return handle_return_value(get_interface_list_ptr(interface_list_ptr, count_ptr), return_value);
×
116
}
117

118
bool LowLevel::C_GetInterface(const Dynamically_Loaded_Library& pkcs11_module,
×
119
                              const Utf8Char* interface_name_ptr,
120
                              const Version* version_ptr,
121
                              Interface* interface_ptr_ptr,
122
                              Flags flags,
123
                              ReturnValue* return_value) {
124
   using get_interface =
×
125
      CK_RV (*)(Utf8Char* interface_name_ptr, Version* version_ptr, Interface* interface_ptr_ptr, Flags flags);
126
   get_interface get_interface_ptr;
×
127
   try {
×
128
      get_interface_ptr = pkcs11_module.resolve<get_interface>("C_GetInterface");
×
129
   } catch(Invalid_Argument&) {
×
130
      // Loading the library function failed. Probably due to a cryptoki library with PKCS #11 < 3.0.
131
      return handle_return_value(CKR_GENERAL_ERROR, return_value);
×
132
   }
×
133

134
   return handle_return_value(
×
135
      get_interface_ptr(
136
         const_cast<Utf8Char*>(interface_name_ptr), const_cast<Version*>(version_ptr), interface_ptr_ptr, flags),
137
      return_value);
×
138
}
139

140
/****************************** Slot and token management functions ******************************/
141

142
bool LowLevel::C_GetSlotList(Bbool token_present,
142✔
143
                             SlotId* slot_list_ptr,
144
                             Ulong* count_ptr,
145
                             ReturnValue* return_value) const {
146
   return handle_return_value(m_interface_wrapper->func_2_40().C_GetSlotList(token_present, slot_list_ptr, count_ptr),
142✔
147
                              return_value);
142✔
148
}
149

150
bool LowLevel::C_GetSlotList(bool token_present, std::vector<SlotId>& slot_ids, ReturnValue* return_value) const {
71✔
151
   slot_ids.clear();
71✔
152

153
   // first get available slots
154
   Ulong number_slots = 0;
71✔
155

156
   bool success = C_GetSlotList(token_present, nullptr, &number_slots, return_value);
71✔
157

158
   if(!success || !number_slots) {
71✔
159
      return success;
160
   }
161

162
   // get actual slot ids
163
   slot_ids.resize(number_slots);
71✔
164
   return C_GetSlotList(token_present, slot_ids.data(), &number_slots, return_value);
71✔
165
}
166

167
bool LowLevel::C_GetSlotInfo(SlotId slot_id, SlotInfo* info_ptr, ReturnValue* return_value) const {
7✔
168
   return handle_return_value(m_interface_wrapper->func_2_40().C_GetSlotInfo(slot_id, info_ptr), return_value);
7✔
169
}
170

171
bool LowLevel::C_GetTokenInfo(SlotId slot_id, TokenInfo* info_ptr, ReturnValue* return_value) const {
4✔
172
   return handle_return_value(m_interface_wrapper->func_2_40().C_GetTokenInfo(slot_id, info_ptr), return_value);
4✔
173
}
174

175
bool LowLevel::C_WaitForSlotEvent(Flags flags, SlotId* slot_ptr, void* reserved, ReturnValue* return_value) const {
3✔
176
   return handle_return_value(m_interface_wrapper->func_2_40().C_WaitForSlotEvent(flags, slot_ptr, reserved),
3✔
177
                              return_value);
2✔
178
}
179

180
bool LowLevel::C_GetMechanismList(SlotId slot_id,
10✔
181
                                  MechanismType* mechanism_list_ptr,
182
                                  Ulong* count_ptr,
183
                                  ReturnValue* return_value) const {
184
   return handle_return_value(m_interface_wrapper->func_2_40().C_GetMechanismList(
10✔
185
                                 slot_id, reinterpret_cast<CK_MECHANISM_TYPE_PTR>(mechanism_list_ptr), count_ptr),
186
                              return_value);
10✔
187
}
188

189
bool LowLevel::C_GetMechanismList(SlotId slot_id,
5✔
190
                                  std::vector<MechanismType>& mechanisms,
191
                                  ReturnValue* return_value) const {
192
   mechanisms.clear();
5✔
193

194
   // first get number of mechanisms
195
   Ulong number_mechanisms = 0;
5✔
196

197
   bool success = C_GetMechanismList(slot_id, nullptr, &number_mechanisms, return_value);
5✔
198

199
   if(!success || !number_mechanisms) {
5✔
200
      return success;
201
   }
202

203
   // get actual mechanisms
204
   mechanisms.resize(number_mechanisms);
5✔
205
   return C_GetMechanismList(
5✔
206
      slot_id, reinterpret_cast<MechanismType*>(mechanisms.data()), &number_mechanisms, return_value);
207
}
208

209
bool LowLevel::C_GetMechanismInfo(SlotId slot_id,
4✔
210
                                  MechanismType type,
211
                                  MechanismInfo* info_ptr,
212
                                  ReturnValue* return_value) const {
213
   return handle_return_value(
4✔
214
      m_interface_wrapper->func_2_40().C_GetMechanismInfo(slot_id, static_cast<CK_MECHANISM_TYPE>(type), info_ptr),
4✔
215
      return_value);
4✔
216
}
217

218
bool LowLevel::C_InitToken(SlotId slot_id,
4✔
219
                           const Utf8Char* so_pin_ptr,
220
                           Ulong so_pin_len,
221
                           const Utf8Char* label_ptr,
222
                           ReturnValue* return_value) const {
223
   return handle_return_value(
4✔
224
      m_interface_wrapper->func_2_40().C_InitToken(
4✔
225
         slot_id, const_cast<Utf8Char*>(so_pin_ptr), so_pin_len, const_cast<Utf8Char*>(label_ptr)),
226
      return_value);
4✔
227
}
228

229
bool LowLevel::C_InitPIN(SessionHandle session,
6✔
230
                         const Utf8Char* pin_ptr,
231
                         Ulong pin_len,
232
                         ReturnValue* return_value) const {
233
   return handle_return_value(
6✔
234
      m_interface_wrapper->func_2_40().C_InitPIN(session, const_cast<Utf8Char*>(pin_ptr), pin_len), return_value);
6✔
235
}
236

237
bool LowLevel::C_SetPIN(SessionHandle session,
22✔
238
                        const Utf8Char* old_pin_ptr,
239
                        Ulong old_len,
240
                        const Utf8Char* new_pin_ptr,
241
                        Ulong new_len,
242
                        ReturnValue* return_value) const {
243
   return handle_return_value(
22✔
244
      m_interface_wrapper->func_2_40().C_SetPIN(
22✔
245
         session, const_cast<Utf8Char*>(old_pin_ptr), old_len, const_cast<Utf8Char*>(new_pin_ptr), new_len),
246
      return_value);
22✔
247
}
248

249
/****************************** Session management ******************************/
250

251
bool LowLevel::C_OpenSession(SlotId slot_id,
69✔
252
                             Flags flags,
253
                             void* application,
254
                             Notify notify,
255
                             SessionHandle* session_ptr,
256
                             ReturnValue* return_value) const {
257
   return handle_return_value(
69✔
258
      m_interface_wrapper->func_2_40().C_OpenSession(slot_id, flags, application, notify, session_ptr), return_value);
69✔
259
}
260

261
bool LowLevel::C_CloseSession(SessionHandle session, ReturnValue* return_value) const {
62✔
262
   return handle_return_value(m_interface_wrapper->func_2_40().C_CloseSession(session), return_value);
62✔
263
}
264

265
bool LowLevel::C_CloseAllSessions(SlotId slot_id, ReturnValue* return_value) const {
3✔
266
   return handle_return_value(m_interface_wrapper->func_2_40().C_CloseAllSessions(slot_id), return_value);
3✔
267
}
268

269
bool LowLevel::C_GetSessionInfo(SessionHandle session, SessionInfo* info_ptr, ReturnValue* return_value) const {
6✔
270
   return handle_return_value(m_interface_wrapper->func_2_40().C_GetSessionInfo(session, info_ptr), return_value);
6✔
271
}
272

273
bool LowLevel::C_SessionCancel(SessionHandle session, Flags flags, ReturnValue* return_value) {
×
274
   return handle_return_value(m_interface_wrapper->func_3_0().C_SessionCancel(session, flags), return_value);
×
275
}
276

277
bool LowLevel::C_GetOperationState(SessionHandle session,
×
278
                                   Byte* operation_state_ptr,
279
                                   Ulong* operation_state_len_ptr,
280
                                   ReturnValue* return_value) const {
281
   return handle_return_value(
×
282
      m_interface_wrapper->func_2_40().C_GetOperationState(session, operation_state_ptr, operation_state_len_ptr),
×
283
      return_value);
×
284
}
285

286
bool LowLevel::C_SetOperationState(SessionHandle session,
×
287
                                   const Byte* operation_state_ptr,
288
                                   Ulong operation_state_len,
289
                                   ObjectHandle encryption_key,
290
                                   ObjectHandle authentication_key,
291
                                   ReturnValue* return_value) const {
292
   return handle_return_value(
×
293
      m_interface_wrapper->func_2_40().C_SetOperationState(
×
294
         session, const_cast<Byte*>(operation_state_ptr), operation_state_len, encryption_key, authentication_key),
295
      return_value);
×
296
}
297

298
bool LowLevel::C_Login(
58✔
299
   SessionHandle session, UserType user_type, const Utf8Char* pin_ptr, Ulong pin_len, ReturnValue* return_value) const {
300
   return handle_return_value(
58✔
301
      m_interface_wrapper->func_2_40().C_Login(
58✔
302
         session, static_cast<CK_USER_TYPE>(user_type), const_cast<Utf8Char*>(pin_ptr), pin_len),
303
      return_value);
58✔
304
}
305

306
bool LowLevel::C_LoginUser(SessionHandle session,
×
307
                           UserType user_type,
308
                           const Utf8Char* pin_ptr,
309
                           Ulong pin_len,
310
                           const Utf8Char* username_ptr,
311
                           Ulong username_len,
312
                           ReturnValue* return_value) {
313
   return handle_return_value(m_interface_wrapper->func_3_0().C_LoginUser(session,
×
314
                                                                          static_cast<CK_USER_TYPE>(user_type),
315
                                                                          const_cast<Utf8Char*>(pin_ptr),
316
                                                                          pin_len,
317
                                                                          const_cast<Utf8Char*>(username_ptr),
318
                                                                          username_len),
319
                              return_value);
×
320
}
321

322
bool LowLevel::C_Logout(SessionHandle session, ReturnValue* return_value) const {
58✔
323
   return handle_return_value(m_interface_wrapper->func_2_40().C_Logout(session), return_value);
58✔
324
}
325

326
bool LowLevel::C_GetSessionValidationFlags(SessionHandle session,
×
327
                                           Ulong type,
328
                                           Flags* flags_ptr,
329
                                           ReturnValue* return_value) {
330
   return handle_return_value(m_interface_wrapper->func_3_2().C_GetSessionValidationFlags(session, type, flags_ptr),
×
331
                              return_value);
×
332
}
333

334
/****************************** Object management functions ******************************/
335

336
bool LowLevel::C_CreateObject(SessionHandle session,
23✔
337
                              Attribute* attribute_template_ptr,
338
                              Ulong count,
339
                              ObjectHandle* object_ptr,
340
                              ReturnValue* return_value) const {
341
   return handle_return_value(
23✔
342
      m_interface_wrapper->func_2_40().C_CreateObject(session, attribute_template_ptr, count, object_ptr),
23✔
343
      return_value);
23✔
344
}
345

346
bool LowLevel::C_CopyObject(SessionHandle session,
4✔
347
                            ObjectHandle object,
348
                            Attribute* attribute_template_ptr,
349
                            Ulong count,
350
                            ObjectHandle* new_object_ptr,
351
                            ReturnValue* return_value) const {
352
   return handle_return_value(
4✔
353
      m_interface_wrapper->func_2_40().C_CopyObject(session, object, attribute_template_ptr, count, new_object_ptr),
4✔
354
      return_value);
4✔
355
}
356

357
bool LowLevel::C_DestroyObject(SessionHandle session, ObjectHandle object, ReturnValue* return_value) const {
52✔
358
   return handle_return_value(m_interface_wrapper->func_2_40().C_DestroyObject(session, object), return_value);
52✔
359
}
360

361
bool LowLevel::C_GetObjectSize(SessionHandle session,
3✔
362
                               ObjectHandle object,
363
                               Ulong* size_ptr,
364
                               ReturnValue* return_value) const {
365
   return handle_return_value(m_interface_wrapper->func_2_40().C_GetObjectSize(session, object, size_ptr),
3✔
366
                              return_value);
3✔
367
}
368

369
bool LowLevel::C_GetAttributeValue(SessionHandle session,
132✔
370
                                   ObjectHandle object,
371
                                   Attribute* attribute_template_ptr,
372
                                   Ulong count,
373
                                   ReturnValue* return_value) const {
374
   return handle_return_value(
132✔
375
      m_interface_wrapper->func_2_40().C_GetAttributeValue(session, object, attribute_template_ptr, count),
132✔
376
      return_value);
132✔
377
}
378

379
bool LowLevel::C_SetAttributeValue(SessionHandle session,
4✔
380
                                   ObjectHandle object,
381
                                   Attribute* attribute_template_ptr,
382
                                   Ulong count,
383
                                   ReturnValue* return_value) const {
384
   return handle_return_value(
4✔
385
      m_interface_wrapper->func_2_40().C_SetAttributeValue(session, object, attribute_template_ptr, count),
4✔
386
      return_value);
4✔
387
}
388

389
bool LowLevel::C_FindObjectsInit(SessionHandle session,
3✔
390
                                 Attribute* attribute_template_ptr,
391
                                 Ulong count,
392
                                 ReturnValue* return_value) const {
393
   return handle_return_value(
3✔
394
      m_interface_wrapper->func_2_40().C_FindObjectsInit(session, attribute_template_ptr, count), return_value);
3✔
395
}
396

397
bool LowLevel::C_FindObjects(SessionHandle session,
3✔
398
                             ObjectHandle* object_ptr,
399
                             Ulong max_object_count,
400
                             Ulong* object_count_ptr,
401
                             ReturnValue* return_value) const {
402
   return handle_return_value(
3✔
403
      m_interface_wrapper->func_2_40().C_FindObjects(session, object_ptr, max_object_count, object_count_ptr),
3✔
404
      return_value);
3✔
405
}
406

407
bool LowLevel::C_FindObjectsFinal(SessionHandle session, ReturnValue* return_value) const {
3✔
408
   return handle_return_value(m_interface_wrapper->func_2_40().C_FindObjectsFinal(session), return_value);
3✔
409
}
410

411
/****************************** Encryption functions ******************************/
412

413
bool LowLevel::C_EncryptInit(SessionHandle session,
5✔
414
                             const Mechanism* mechanism_ptr,
415
                             ObjectHandle key,
416
                             ReturnValue* return_value) const {
417
   return handle_return_value(
5✔
418
      m_interface_wrapper->func_2_40().C_EncryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
5✔
419
      return_value);
5✔
420
}
421

422
bool LowLevel::C_Encrypt(SessionHandle session,
10✔
423
                         const Byte* data_ptr,
424
                         Ulong data_len,
425
                         Byte* encrypted_data_ptr,
426
                         Ulong* encrypted_data_len_ptr,
427
                         ReturnValue* return_value) const {
428
   return handle_return_value(
10✔
429
      m_interface_wrapper->func_2_40().C_Encrypt(
10✔
430
         session, const_cast<Byte*>(data_ptr), data_len, encrypted_data_ptr, encrypted_data_len_ptr),
431
      return_value);
10✔
432
}
433

434
bool LowLevel::C_EncryptUpdate(SessionHandle session,
×
435
                               const Byte* part_ptr,
436
                               Ulong part_len,
437
                               Byte* encrypted_part_ptr,
438
                               Ulong* encrypted_part_len_ptr,
439
                               ReturnValue* return_value) const {
440
   return handle_return_value(
×
441
      m_interface_wrapper->func_2_40().C_EncryptUpdate(
×
442
         session, const_cast<Byte*>(part_ptr), part_len, encrypted_part_ptr, encrypted_part_len_ptr),
443
      return_value);
×
444
}
445

446
bool LowLevel::C_EncryptFinal(SessionHandle session,
×
447
                              Byte* last_encrypted_part_ptr,
448
                              Ulong* last_encrypted_part_len_ptr,
449
                              ReturnValue* return_value) const {
450
   return handle_return_value(
×
451
      m_interface_wrapper->func_2_40().C_EncryptFinal(session, last_encrypted_part_ptr, last_encrypted_part_len_ptr),
×
452
      return_value);
×
453
}
454

455
/*********************** Message-based encryption functions ***********************/
456

457
bool LowLevel::C_MessageEncryptInit(SessionHandle session,
×
458
                                    const Mechanism* mechanism_ptr,
459
                                    ObjectHandle key,
460
                                    ReturnValue* return_value) {
461
   return handle_return_value(
×
462
      m_interface_wrapper->func_3_0().C_MessageEncryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
×
463
      return_value);
×
464
}
465

466
bool LowLevel::C_EncryptMessage(SessionHandle session,
×
467
                                const void* parameter_ptr,
468
                                Ulong parameter_len,
469
                                const Byte* associated_data_ptr,
470
                                Ulong associated_data_len,
471
                                const Byte* plaintext_ptr,
472
                                Ulong plaintext_len,
473
                                Byte* ciphertext_ptr,
474
                                Ulong* ciphertext_len_ptr,
475
                                ReturnValue* return_value) {
476
   return handle_return_value(m_interface_wrapper->func_3_0().C_EncryptMessage(session,
×
477
                                                                               const_cast<void*>(parameter_ptr),
478
                                                                               parameter_len,
479
                                                                               const_cast<Byte*>(associated_data_ptr),
480
                                                                               associated_data_len,
481
                                                                               const_cast<Byte*>(plaintext_ptr),
482
                                                                               plaintext_len,
483
                                                                               ciphertext_ptr,
484
                                                                               ciphertext_len_ptr),
485
                              return_value);
×
486
}
487

488
bool LowLevel::C_EncryptMessageBegin(SessionHandle session,
×
489
                                     const void* parameter_ptr,
490
                                     Ulong parameter_len,
491
                                     const Byte* associated_data_ptr,
492
                                     Ulong associated_data_len,
493
                                     ReturnValue* return_value) {
494
   return handle_return_value(
×
495
      m_interface_wrapper->func_3_0().C_EncryptMessageBegin(session,
×
496
                                                            const_cast<void*>(parameter_ptr),
497
                                                            parameter_len,
498
                                                            const_cast<Byte*>(associated_data_ptr),
499
                                                            associated_data_len),
500
      return_value);
×
501
}
502

503
bool LowLevel::C_EncryptMessageNext(SessionHandle session,
×
504
                                    const void* parameter_ptr,
505
                                    Ulong parameter_len,
506
                                    const Byte* plaintext_part_ptr,
507
                                    Ulong plaintext_part_len,
508
                                    Byte* ciphertext_ptr,
509
                                    Ulong* ciphertext_part_len_ptr,
510
                                    Flags flags,
511
                                    ReturnValue* return_value) {
512
   return handle_return_value(
×
513
      m_interface_wrapper->func_3_0().C_EncryptMessageNext(session,
×
514
                                                           const_cast<void*>(parameter_ptr),
515
                                                           parameter_len,
516
                                                           const_cast<Byte*>(plaintext_part_ptr),
517
                                                           plaintext_part_len,
518
                                                           ciphertext_ptr,
519
                                                           ciphertext_part_len_ptr,
520
                                                           flags),
521
      return_value);
×
522
}
523

524
bool LowLevel::C_MessageEncryptFinal(SessionHandle session, ReturnValue* return_value) {
×
525
   return handle_return_value(m_interface_wrapper->func_3_0().C_MessageEncryptFinal(session), return_value);
×
526
}
527

528
/****************************** Decryption functions ******************************/
529

530
bool LowLevel::C_DecryptInit(SessionHandle session,
5✔
531
                             const Mechanism* mechanism_ptr,
532
                             ObjectHandle key,
533
                             ReturnValue* return_value) const {
534
   return handle_return_value(
5✔
535
      m_interface_wrapper->func_2_40().C_DecryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
5✔
536
      return_value);
5✔
537
}
538

539
bool LowLevel::C_Decrypt(SessionHandle session,
10✔
540
                         const Byte* encrypted_data_ptr,
541
                         Ulong encrypted_data_len,
542
                         Byte* data_ptr,
543
                         Ulong* data_len_ptr,
544
                         ReturnValue* return_value) const {
545
   return handle_return_value(
10✔
546
      m_interface_wrapper->func_2_40().C_Decrypt(
10✔
547
         session, const_cast<Byte*>(encrypted_data_ptr), encrypted_data_len, data_ptr, data_len_ptr),
548
      return_value);
10✔
549
}
550

551
bool LowLevel::C_DecryptUpdate(SessionHandle session,
×
552
                               const Byte* encrypted_part_ptr,
553
                               Ulong encrypted_part_len,
554
                               Byte* part_ptr,
555
                               Ulong* part_len_ptr,
556
                               ReturnValue* return_value) const {
557
   return handle_return_value(
×
558
      m_interface_wrapper->func_2_40().C_DecryptUpdate(
×
559
         session, const_cast<Byte*>(encrypted_part_ptr), encrypted_part_len, part_ptr, part_len_ptr),
560
      return_value);
×
561
}
562

563
bool LowLevel::C_DecryptFinal(SessionHandle session,
×
564
                              Byte* last_part_ptr,
565
                              Ulong* last_part_len_ptr,
566
                              ReturnValue* return_value) const {
567
   return handle_return_value(
×
568
      m_interface_wrapper->func_2_40().C_DecryptFinal(session, last_part_ptr, last_part_len_ptr), return_value);
×
569
}
570

571
/*********************** Message-based decryption functions ***********************/
572

573
bool LowLevel::C_MessageDecryptInit(SessionHandle session,
×
574
                                    const Mechanism* mechanism_ptr,
575
                                    ObjectHandle key,
576
                                    ReturnValue* return_value) {
577
   return handle_return_value(
×
578
      m_interface_wrapper->func_3_0().C_MessageDecryptInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
×
579
      return_value);
×
580
}
581

582
bool LowLevel::C_DecryptMessage(SessionHandle session,
×
583
                                const void* parameter_ptr,
584
                                Ulong parameter_len,
585
                                const Byte* associated_data_ptr,
586
                                Ulong associated_data_len,
587
                                const Byte* ciphertext_ptr,
588
                                Ulong ciphertext_len,
589
                                Byte* plaintext_ptr,
590
                                Ulong* plaintext_len_ptr,
591
                                ReturnValue* return_value) {
592
   return handle_return_value(m_interface_wrapper->func_3_0().C_DecryptMessage(session,
×
593
                                                                               const_cast<void*>(parameter_ptr),
594
                                                                               parameter_len,
595
                                                                               const_cast<Byte*>(associated_data_ptr),
596
                                                                               associated_data_len,
597
                                                                               const_cast<Byte*>(ciphertext_ptr),
598
                                                                               ciphertext_len,
599
                                                                               plaintext_ptr,
600
                                                                               plaintext_len_ptr),
601
                              return_value);
×
602
}
603

604
bool LowLevel::C_DecryptMessageBegin(SessionHandle session,
×
605
                                     const void* parameter_ptr,
606
                                     Ulong parameter_len,
607
                                     const Byte* associated_data_ptr,
608
                                     Ulong associated_data_len,
609
                                     ReturnValue* return_value) {
610
   return handle_return_value(
×
611
      m_interface_wrapper->func_3_0().C_DecryptMessageBegin(session,
×
612
                                                            const_cast<void*>(parameter_ptr),
613
                                                            parameter_len,
614
                                                            const_cast<Byte*>(associated_data_ptr),
615
                                                            associated_data_len),
616
      return_value);
×
617
}
618

619
bool LowLevel::C_DecryptMessageNext(SessionHandle session,
×
620
                                    const void* parameter_ptr,
621
                                    Ulong parameter_len,
622
                                    const Byte* ciphertext_part_ptr,
623
                                    Ulong ciphertext_part_len,
624
                                    Byte* plaintext_ptr,
625
                                    Ulong* plaintext_part_len_ptr,
626
                                    Flags flags,
627
                                    ReturnValue* return_value) {
628
   return handle_return_value(
×
629
      m_interface_wrapper->func_3_0().C_DecryptMessageNext(session,
×
630
                                                           const_cast<void*>(parameter_ptr),
631
                                                           parameter_len,
632
                                                           const_cast<Byte*>(ciphertext_part_ptr),
633
                                                           ciphertext_part_len,
634
                                                           plaintext_ptr,
635
                                                           plaintext_part_len_ptr,
636
                                                           flags),
637
      return_value);
×
638
}
639

640
bool LowLevel::C_MessageDecryptFinal(SessionHandle session, ReturnValue* return_value) {
×
641
   return handle_return_value(m_interface_wrapper->func_3_0().C_MessageDecryptFinal(session), return_value);
×
642
}
643

644
/****************************** Message digesting functions ******************************/
645

646
bool LowLevel::C_DigestInit(SessionHandle session, const Mechanism* mechanism, ReturnValue* return_value) const {
×
647
   return handle_return_value(m_interface_wrapper->func_2_40().C_DigestInit(session, const_cast<Mechanism*>(mechanism)),
×
648
                              return_value);
×
649
}
650

651
bool LowLevel::C_Digest(SessionHandle session,
×
652
                        const Byte* data_ptr,
653
                        Ulong data_len,
654
                        Byte* digest_ptr,
655
                        Ulong* digest_len_ptr,
656
                        ReturnValue* return_value) const {
657
   return handle_return_value(m_interface_wrapper->func_2_40().C_Digest(
×
658
                                 session, const_cast<Byte*>(data_ptr), data_len, digest_ptr, digest_len_ptr),
659
                              return_value);
×
660
}
661

662
bool LowLevel::C_DigestUpdate(SessionHandle session,
×
663
                              const Byte* part_ptr,
664
                              Ulong part_len,
665
                              ReturnValue* return_value) const {
666
   return handle_return_value(
×
667
      m_interface_wrapper->func_2_40().C_DigestUpdate(session, const_cast<Byte*>(part_ptr), part_len), return_value);
×
668
}
669

670
bool LowLevel::C_DigestKey(SessionHandle session, ObjectHandle key, ReturnValue* return_value) const {
×
671
   return handle_return_value(m_interface_wrapper->func_2_40().C_DigestKey(session, key), return_value);
×
672
}
673

674
bool LowLevel::C_DigestFinal(SessionHandle session,
×
675
                             Byte* digest_ptr,
676
                             Ulong* digest_len_ptr,
677
                             ReturnValue* return_value) const {
678
   return handle_return_value(m_interface_wrapper->func_2_40().C_DigestFinal(session, digest_ptr, digest_len_ptr),
×
679
                              return_value);
×
680
}
681

682
/****************************** Signing and MACing functions ******************************/
683

684
bool LowLevel::C_SignInit(SessionHandle session,
9✔
685
                          const Mechanism* mechanism_ptr,
686
                          ObjectHandle key,
687
                          ReturnValue* return_value) const {
688
   return handle_return_value(
9✔
689
      m_interface_wrapper->func_2_40().C_SignInit(session, const_cast<Mechanism*>(mechanism_ptr), key), return_value);
9✔
690
}
691

692
bool LowLevel::C_Sign(SessionHandle session,
14✔
693
                      const Byte* data_ptr,
694
                      Ulong data_len,
695
                      Byte* signature_ptr,
696
                      Ulong* signature_len_ptr,
697
                      ReturnValue* return_value) const {
698
   return handle_return_value(m_interface_wrapper->func_2_40().C_Sign(
14✔
699
                                 session, const_cast<Byte*>(data_ptr), data_len, signature_ptr, signature_len_ptr),
700
                              return_value);
14✔
701
}
702

703
bool LowLevel::C_SignUpdate(SessionHandle session,
4✔
704
                            const Byte* part_ptr,
705
                            Ulong part_len,
706
                            ReturnValue* return_value) const {
707
   return handle_return_value(
4✔
708
      m_interface_wrapper->func_2_40().C_SignUpdate(session, const_cast<Byte*>(part_ptr), part_len), return_value);
4✔
709
}
710

711
bool LowLevel::C_SignFinal(SessionHandle session,
4✔
712
                           Byte* signature_ptr,
713
                           Ulong* signature_len_ptr,
714
                           ReturnValue* return_value) const {
715
   return handle_return_value(m_interface_wrapper->func_2_40().C_SignFinal(session, signature_ptr, signature_len_ptr),
4✔
716
                              return_value);
4✔
717
}
718

719
bool LowLevel::C_SignRecoverInit(SessionHandle session,
×
720
                                 const Mechanism* mechanism_ptr,
721
                                 ObjectHandle key,
722
                                 ReturnValue* return_value) const {
723
   return handle_return_value(
×
724
      m_interface_wrapper->func_2_40().C_SignRecoverInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
×
725
      return_value);
×
726
}
727

728
bool LowLevel::C_SignRecover(SessionHandle session,
×
729
                             const Byte* data,
730
                             Ulong data_len,
731
                             Byte* signature,
732
                             Ulong* signature_len,
733
                             ReturnValue* return_value) const {
734
   return handle_return_value(m_interface_wrapper->func_2_40().C_SignRecover(
×
735
                                 session, const_cast<Byte*>(data), data_len, signature, signature_len),
736
                              return_value);
×
737
}
738

739
/******************* Message-based signing and MACing functions *******************/
740

741
bool LowLevel::C_MessageSignInit(SessionHandle session,
×
742
                                 const Mechanism* mechanism_ptr,
743
                                 ObjectHandle key,
744
                                 ReturnValue* return_value) {
745
   return handle_return_value(
×
746
      m_interface_wrapper->func_3_0().C_MessageSignInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
×
747
      return_value);
×
748
}
749

750
bool LowLevel::C_SignMessage(SessionHandle session,
×
751
                             const void* parameter_ptr,
752
                             Ulong parameter_len,
753
                             const Byte* data_ptr,
754
                             Ulong data_len,
755
                             Byte* signature_ptr,
756
                             Ulong* signature_len_ptr,
757
                             ReturnValue* return_value) {
758
   return handle_return_value(m_interface_wrapper->func_3_0().C_SignMessage(session,
×
759
                                                                            const_cast<void*>(parameter_ptr),
760
                                                                            parameter_len,
761
                                                                            const_cast<Byte*>(data_ptr),
762
                                                                            data_len,
763
                                                                            signature_ptr,
764
                                                                            signature_len_ptr),
765
                              return_value);
×
766
}
767

768
bool LowLevel::C_SignMessageBegin(SessionHandle session,
×
769
                                  const void* parameter_ptr,
770
                                  Ulong parameter_len,
771
                                  ReturnValue* return_value) {
772
   return handle_return_value(
×
773
      m_interface_wrapper->func_3_0().C_SignMessageBegin(session, const_cast<void*>(parameter_ptr), parameter_len),
×
774
      return_value);
×
775
}
776

777
bool LowLevel::C_SignMessageNext(SessionHandle session,
×
778
                                 const void* parameter_ptr,
779
                                 Ulong parameter_len,
780
                                 const Byte* data_ptr,
781
                                 Ulong data_len,
782
                                 Byte* signature_ptr,
783
                                 Ulong* signature_len_ptr,
784
                                 ReturnValue* return_value) {
785
   return handle_return_value(m_interface_wrapper->func_3_0().C_SignMessageNext(session,
×
786
                                                                                const_cast<void*>(parameter_ptr),
787
                                                                                parameter_len,
788
                                                                                const_cast<Byte*>(data_ptr),
789
                                                                                data_len,
790
                                                                                signature_ptr,
791
                                                                                signature_len_ptr),
792
                              return_value);
×
793
}
794

795
bool LowLevel::C_MessageSignFinal(SessionHandle session, ReturnValue* return_value) {
×
796
   return handle_return_value(m_interface_wrapper->func_3_0().C_MessageSignFinal(session), return_value);
×
797
}
798

799
/****************************** Functions for verifying signatures and MACs ******************************/
800

801
bool LowLevel::C_VerifyInit(SessionHandle session,
13✔
802
                            const Mechanism* mechanism_ptr,
803
                            ObjectHandle key,
804
                            ReturnValue* return_value) const {
805
   return handle_return_value(
13✔
806
      m_interface_wrapper->func_2_40().C_VerifyInit(session, const_cast<Mechanism*>(mechanism_ptr), key), return_value);
13✔
807
}
808

809
bool LowLevel::C_Verify(SessionHandle session,
11✔
810
                        const Byte* data_ptr,
811
                        Ulong data_len,
812
                        const Byte* signature_ptr,
813
                        Ulong signature_len,
814
                        ReturnValue* return_value) const {
815
   return handle_return_value(
11✔
816
      m_interface_wrapper->func_2_40().C_Verify(
11✔
817
         session, const_cast<Byte*>(data_ptr), data_len, const_cast<Byte*>(signature_ptr), signature_len),
818
      return_value);
11✔
819
}
820

821
bool LowLevel::C_VerifyUpdate(SessionHandle session,
4✔
822
                              const Byte* part_ptr,
823
                              Ulong part_len,
824
                              ReturnValue* return_value) const {
825
   return handle_return_value(
4✔
826
      m_interface_wrapper->func_2_40().C_VerifyUpdate(session, const_cast<Byte*>(part_ptr), part_len), return_value);
4✔
827
}
828

829
bool LowLevel::C_VerifyFinal(SessionHandle session,
2✔
830
                             const Byte* signature_ptr,
831
                             Ulong signature_len,
832
                             ReturnValue* return_value) const {
833
   return handle_return_value(
2✔
834
      m_interface_wrapper->func_2_40().C_VerifyFinal(session, const_cast<Byte*>(signature_ptr), signature_len),
2✔
835
      return_value);
2✔
836
}
837

838
bool LowLevel::C_VerifyRecoverInit(SessionHandle session,
×
839
                                   const Mechanism* mechanism_ptr,
840
                                   ObjectHandle key,
841
                                   ReturnValue* return_value) const {
842
   return handle_return_value(
×
843
      m_interface_wrapper->func_2_40().C_VerifyRecoverInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
×
844
      return_value);
×
845
}
846

847
bool LowLevel::C_VerifyRecover(SessionHandle session,
×
848
                               const Byte* signature_ptr,
849
                               Ulong signature_len,
850
                               Byte* data_ptr,
851
                               Ulong* data_len_ptr,
852
                               ReturnValue* return_value) const {
853
   return handle_return_value(m_interface_wrapper->func_2_40().C_VerifyRecover(
×
854
                                 session, const_cast<Byte*>(signature_ptr), signature_len, data_ptr, data_len_ptr),
855
                              return_value);
×
856
}
857

858
bool LowLevel::C_VerifySignatureInit(SessionHandle session,
×
859
                                     const Mechanism* mechanism_ptr,
860
                                     ObjectHandle key,
861
                                     const Byte* signature_ptr,
862
                                     Ulong signature_len,
863
                                     ReturnValue* return_value) {
864
   return handle_return_value(
×
865
      m_interface_wrapper->func_3_2().C_VerifySignatureInit(
×
866
         session, const_cast<Mechanism*>(mechanism_ptr), key, const_cast<Byte*>(signature_ptr), signature_len),
867
      return_value);
×
868
}
869

870
bool LowLevel::C_VerifySignature(SessionHandle session,
×
871
                                 const Byte* data_ptr,
872
                                 Ulong data_len,
873
                                 ReturnValue* return_value) {
874
   return handle_return_value(
×
875
      m_interface_wrapper->func_3_2().C_VerifySignature(session, const_cast<Byte*>(data_ptr), data_len), return_value);
×
876
}
877

878
bool LowLevel::C_VerifySignatureUpdate(SessionHandle session,
×
879
                                       const Byte* part_ptr,
880
                                       Ulong part_len,
881
                                       ReturnValue* return_value) {
882
   return handle_return_value(
×
883
      m_interface_wrapper->func_3_2().C_VerifySignatureUpdate(session, const_cast<Byte*>(part_ptr), part_len),
×
884
      return_value);
×
885
}
886

887
bool LowLevel::C_VerifySignatureFinal(SessionHandle session, ReturnValue* return_value) {
×
888
   return handle_return_value(m_interface_wrapper->func_3_2().C_VerifySignatureFinal(session), return_value);
×
889
}
890

891
/*********** Message-based functions for verifying signatures and MACs ************/
892

893
bool LowLevel::C_MessageVerifyInit(SessionHandle session,
×
894
                                   const Mechanism* mechanism_ptr,
895
                                   ObjectHandle key,
896
                                   ReturnValue* return_value) {
897
   return handle_return_value(
×
898
      m_interface_wrapper->func_3_0().C_MessageVerifyInit(session, const_cast<Mechanism*>(mechanism_ptr), key),
×
899
      return_value);
×
900
}
901

902
bool LowLevel::C_VerifyMessage(SessionHandle session,
×
903
                               const void* parameter_ptr,
904
                               Ulong parameter_len,
905
                               const Byte* data_ptr,
906
                               Ulong data_len,
907
                               const Byte* signature_ptr,
908
                               Ulong signature_len,
909
                               ReturnValue* return_value) {
910
   return handle_return_value(m_interface_wrapper->func_3_0().C_VerifyMessage(session,
×
911
                                                                              const_cast<void*>(parameter_ptr),
912
                                                                              parameter_len,
913
                                                                              const_cast<Byte*>(data_ptr),
914
                                                                              data_len,
915
                                                                              const_cast<Byte*>(signature_ptr),
916
                                                                              signature_len),
917
                              return_value);
×
918
}
919

920
bool LowLevel::C_VerifyMessageBegin(SessionHandle session,
×
921
                                    const void* parameter_ptr,
922
                                    Ulong parameter_len,
923
                                    ReturnValue* return_value) {
924
   return handle_return_value(
×
925
      m_interface_wrapper->func_3_0().C_VerifyMessageBegin(session, const_cast<void*>(parameter_ptr), parameter_len),
×
926
      return_value);
×
927
}
928

929
bool LowLevel::C_VerifyMessageNext(SessionHandle session,
×
930
                                   const void* parameter_ptr,
931
                                   Ulong parameter_len,
932
                                   const Byte* data_ptr,
933
                                   Ulong data_len,
934
                                   const Byte* signature_ptr,
935
                                   Ulong signature_len,
936
                                   ReturnValue* return_value) {
937
   return handle_return_value(m_interface_wrapper->func_3_0().C_VerifyMessageNext(session,
×
938
                                                                                  const_cast<void*>(parameter_ptr),
939
                                                                                  parameter_len,
940
                                                                                  const_cast<Byte*>(data_ptr),
941
                                                                                  data_len,
942
                                                                                  const_cast<Byte*>(signature_ptr),
943
                                                                                  signature_len),
944
                              return_value);
×
945
}
946

947
bool LowLevel::C_MessageVerifyFinal(SessionHandle session, ReturnValue* return_value) {
×
948
   return handle_return_value(m_interface_wrapper->func_3_0().C_MessageVerifyFinal(session), return_value);
×
949
}
950

951
/****************************** Dual-purpose cryptographic functions ******************************/
952

953
bool LowLevel::C_DigestEncryptUpdate(SessionHandle session,
×
954
                                     const Byte* part_ptr,
955
                                     Ulong part_len,
956
                                     Byte* encrypted_part_ptr,
957
                                     Ulong* encrypted_part_len_ptr,
958
                                     ReturnValue* return_value) const {
959
   return handle_return_value(
×
960
      m_interface_wrapper->func_2_40().C_DigestEncryptUpdate(
×
961
         session, const_cast<Byte*>(part_ptr), part_len, encrypted_part_ptr, encrypted_part_len_ptr),
962
      return_value);
×
963
}
964

965
bool LowLevel::C_DecryptDigestUpdate(SessionHandle session,
×
966
                                     const Byte* encrypted_part_ptr,
967
                                     Ulong encrypted_part_len,
968
                                     Byte* part_ptr,
969
                                     Ulong* part_len_ptr,
970
                                     ReturnValue* return_value) const {
971
   return handle_return_value(
×
972
      m_interface_wrapper->func_2_40().C_DecryptDigestUpdate(
×
973
         session, const_cast<Byte*>(encrypted_part_ptr), encrypted_part_len, part_ptr, part_len_ptr),
974
      return_value);
×
975
}
976

977
bool LowLevel::C_SignEncryptUpdate(SessionHandle session,
×
978
                                   const Byte* part_ptr,
979
                                   Ulong part_len,
980
                                   Byte* encrypted_part_ptr,
981
                                   Ulong* encrypted_part_len_ptr,
982
                                   ReturnValue* return_value) const {
983
   return handle_return_value(
×
984
      m_interface_wrapper->func_2_40().C_SignEncryptUpdate(
×
985
         session, const_cast<Byte*>(part_ptr), part_len, encrypted_part_ptr, encrypted_part_len_ptr),
986
      return_value);
×
987
}
988

989
bool LowLevel::C_DecryptVerifyUpdate(SessionHandle session,
×
990
                                     const Byte* encrypted_part_ptr,
991
                                     Ulong encrypted_part_len,
992
                                     Byte* part_ptr,
993
                                     Ulong* part_len_ptr,
994
                                     ReturnValue* return_value) const {
995
   return handle_return_value(
×
996
      m_interface_wrapper->func_2_40().C_DecryptVerifyUpdate(
×
997
         session, const_cast<Byte*>(encrypted_part_ptr), encrypted_part_len, part_ptr, part_len_ptr),
998
      return_value);
×
999
}
1000

1001
/****************************** Key management functions ******************************/
1002

1003
bool LowLevel::C_GenerateKey(SessionHandle session,
×
1004
                             const Mechanism* mechanism_ptr,
1005
                             Attribute* attribute_template_ptr,
1006
                             Ulong count,
1007
                             ObjectHandle* key_ptr,
1008
                             ReturnValue* return_value) const {
1009
   return handle_return_value(
×
1010
      m_interface_wrapper->func_2_40().C_GenerateKey(
×
1011
         session, const_cast<Mechanism*>(mechanism_ptr), attribute_template_ptr, count, key_ptr),
1012
      return_value);
×
1013
}
1014

1015
bool LowLevel::C_GenerateKeyPair(SessionHandle session,
15✔
1016
                                 const Mechanism* mechanism_ptr,
1017
                                 Attribute* public_key_template_ptr,
1018
                                 Ulong public_key_attribute_count,
1019
                                 Attribute* private_key_template_ptr,
1020
                                 Ulong private_key_attribute_count,
1021
                                 ObjectHandle* public_key_ptr,
1022
                                 ObjectHandle* private_key_ptr,
1023
                                 ReturnValue* return_value) const {
1024
   return handle_return_value(m_interface_wrapper->func_2_40().C_GenerateKeyPair(session,
15✔
1025
                                                                                 const_cast<Mechanism*>(mechanism_ptr),
1026
                                                                                 public_key_template_ptr,
1027
                                                                                 public_key_attribute_count,
1028
                                                                                 private_key_template_ptr,
1029
                                                                                 private_key_attribute_count,
1030
                                                                                 public_key_ptr,
1031
                                                                                 private_key_ptr),
1032
                              return_value);
15✔
1033
}
1034

1035
bool LowLevel::C_WrapKey(SessionHandle session,
×
1036
                         const Mechanism* mechanism_ptr,
1037
                         ObjectHandle wrapping_key,
1038
                         ObjectHandle key,
1039
                         Byte* wrapped_key_ptr,
1040
                         Ulong* wrapped_key_len_ptr,
1041
                         ReturnValue* return_value) const {
1042
   return handle_return_value(
×
1043
      m_interface_wrapper->func_2_40().C_WrapKey(
×
1044
         session, const_cast<Mechanism*>(mechanism_ptr), wrapping_key, key, wrapped_key_ptr, wrapped_key_len_ptr),
1045
      return_value);
×
1046
}
1047

1048
bool LowLevel::C_UnwrapKey(SessionHandle session,
×
1049
                           const Mechanism* mechanism_ptr,
1050
                           ObjectHandle unwrapping_key,
1051
                           const Byte* wrapped_key_ptr,
1052
                           Ulong wrapped_key_len,
1053
                           Attribute* attribute_template_ptr,
1054
                           Ulong attribute_count,
1055
                           ObjectHandle* key_ptr,
1056
                           ReturnValue* return_value) const {
1057
   return handle_return_value(m_interface_wrapper->func_2_40().C_UnwrapKey(session,
×
1058
                                                                           const_cast<Mechanism*>(mechanism_ptr),
1059
                                                                           unwrapping_key,
1060
                                                                           const_cast<Byte*>(wrapped_key_ptr),
1061
                                                                           wrapped_key_len,
1062
                                                                           attribute_template_ptr,
1063
                                                                           attribute_count,
1064
                                                                           key_ptr),
1065
                              return_value);
×
1066
}
1067

1068
bool LowLevel::C_DeriveKey(SessionHandle session,
2✔
1069
                           const Mechanism* mechanism_ptr,
1070
                           ObjectHandle base_key,
1071
                           Attribute* attribute_template_ptr,
1072
                           Ulong attribute_count,
1073
                           ObjectHandle* key_ptr,
1074
                           ReturnValue* return_value) const {
1075
   return handle_return_value(
2✔
1076
      m_interface_wrapper->func_2_40().C_DeriveKey(
2✔
1077
         session, const_cast<Mechanism*>(mechanism_ptr), base_key, attribute_template_ptr, attribute_count, key_ptr),
1078
      return_value);
2✔
1079
}
1080

1081
bool LowLevel::C_EncapsulateKey(SessionHandle session,
×
1082
                                const Mechanism* mechanism_ptr,
1083
                                ObjectHandle public_key,
1084
                                Attribute* template_ptr,
1085
                                Ulong attribute_count,
1086
                                ObjectHandle* key_ptr,
1087
                                Byte* ciphertext_ptr,
1088
                                Ulong* ciphertext_len_ptr,
1089
                                ReturnValue* return_value) {
1090
   return handle_return_value(m_interface_wrapper->func_3_2().C_EncapsulateKey(session,
×
1091
                                                                               const_cast<Mechanism*>(mechanism_ptr),
1092
                                                                               public_key,
1093
                                                                               template_ptr,
1094
                                                                               attribute_count,
1095
                                                                               key_ptr,
1096
                                                                               ciphertext_ptr,
1097
                                                                               ciphertext_len_ptr),
1098
                              return_value);
×
1099
}
1100

1101
bool LowLevel::C_DecapsulateKey(SessionHandle session,
×
1102
                                const Mechanism* mechanism_ptr,
1103
                                ObjectHandle private_key,
1104
                                const Byte* ciphertext_ptr,
1105
                                Ulong ciphertext_len,
1106
                                Attribute* template_ptr,
1107
                                Ulong attribute_count,
1108
                                ObjectHandle* key_ptr,
1109
                                ReturnValue* return_value) {
1110
   return handle_return_value(m_interface_wrapper->func_3_2().C_DecapsulateKey(session,
×
1111
                                                                               const_cast<Mechanism*>(mechanism_ptr),
1112
                                                                               private_key,
1113
                                                                               const_cast<Byte*>(ciphertext_ptr),
1114
                                                                               ciphertext_len,
1115
                                                                               template_ptr,
1116
                                                                               attribute_count,
1117
                                                                               key_ptr),
1118
                              return_value);
×
1119
}
1120

1121
/****************************** Random number generation functions ******************************/
1122

1123
bool LowLevel::C_SeedRandom(SessionHandle session,
1✔
1124
                            const Byte* seed_ptr,
1125
                            Ulong seed_len,
1126
                            ReturnValue* return_value) const {
1127
   return handle_return_value(
1✔
1128
      m_interface_wrapper->func_2_40().C_SeedRandom(session, const_cast<Byte*>(seed_ptr), seed_len), return_value);
1✔
1129
}
1130

1131
bool LowLevel::C_GenerateRandom(SessionHandle session,
2✔
1132
                                Byte* random_data_ptr,
1133
                                Ulong random_len,
1134
                                ReturnValue* return_value) const {
1135
   return handle_return_value(m_interface_wrapper->func_2_40().C_GenerateRandom(session, random_data_ptr, random_len),
2✔
1136
                              return_value);
2✔
1137
}
1138

1139
/****************************** Parallel function management functions ******************************/
1140

1141
bool LowLevel::C_GetFunctionStatus(SessionHandle session, ReturnValue* return_value) const {
×
1142
   return handle_return_value(m_interface_wrapper->func_2_40().C_GetFunctionStatus(session), return_value);
×
1143
}
1144

1145
bool LowLevel::C_CancelFunction(SessionHandle session, ReturnValue* return_value) const {
×
1146
   return handle_return_value(m_interface_wrapper->func_2_40().C_CancelFunction(session), return_value);
×
1147
}
1148

1149
/******************* Asynchronous function management functions *******************/
1150

1151
bool LowLevel::C_AsyncComplete(SessionHandle session,
×
1152
                               const Utf8Char* function_name_ptr,
1153
                               AsyncData* result_ptr,
1154
                               ReturnValue* return_value) {
1155
   return handle_return_value(
×
1156
      m_interface_wrapper->func_3_2().C_AsyncComplete(session, const_cast<Utf8Char*>(function_name_ptr), result_ptr),
×
1157
      return_value);
×
1158
}
1159

1160
bool LowLevel::C_AsyncGetID(SessionHandle session,
×
1161
                            const Utf8Char* function_name_ptr,
1162
                            Ulong* id_ptr,
1163
                            ReturnValue* return_value) {
1164
   return handle_return_value(
×
1165
      m_interface_wrapper->func_3_2().C_AsyncGetID(session, const_cast<Utf8Char*>(function_name_ptr), id_ptr),
×
1166
      return_value);
×
1167
}
1168

1169
bool LowLevel::C_AsyncJoin(SessionHandle session,
×
1170
                           const Utf8Char* function_name_ptr,
1171
                           Ulong id,
1172
                           Byte* data_ptr,
1173
                           Ulong data_len,
1174
                           ReturnValue* return_value) {
1175
   return handle_return_value(m_interface_wrapper->func_3_2().C_AsyncJoin(
×
1176
                                 session, const_cast<Utf8Char*>(function_name_ptr), id, data_ptr, data_len),
1177
                              return_value);
×
1178
}
1179

1180
FunctionList* LowLevel::get_functions() const {
×
1181
   return reinterpret_cast<FunctionList*>(m_interface_wrapper->raw_interface().pFunctionList);
×
1182
}
1183

1184
}  // namespace Botan::PKCS11
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc