1 /* 2 * Copyright (c) 2016 Red Hat, Inc 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * * Redistributions of source code must retain the above 9 * copyright notice, this list of conditions and the 10 * following disclaimer. 11 * * Redistributions in binary form must reproduce the 12 * above copyright notice, this list of conditions and 13 * the following disclaimer in the documentation and/or 14 * other materials provided with the distribution. 15 * * The names of contributors to this software may not be 16 * used to endorse or promote products derived from this 17 * software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 29 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 30 * DAMAGE. 31 * 32 * Author: Daiki Ueno 33 */ 34 35 #ifndef __P11_VIRTUAL_FIXED_H__ 36 #define __P11_VIRTUAL_FIXED_H__ 37 38 #define P11_VIRTUAL_FIXED_FUNCTIONS(fixed_index) \ 39 static CK_RV \ 40 fixed ## fixed_index ## _C_Initialize (CK_VOID_PTR init_args) \ 41 { \ 42 CK_FUNCTION_LIST *bound; \ 43 Wrapper *wrapper; \ 44 CK_X_FUNCTION_LIST *funcs; \ 45 bound = fixed_closures[fixed_index]; \ 46 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 47 wrapper = (Wrapper *) bound; \ 48 funcs = &wrapper->virt->funcs; \ 49 return funcs->C_Initialize (funcs, init_args); \ 50 } \ 51 \ 52 static CK_RV \ 53 fixed ## fixed_index ## _C_Finalize (CK_VOID_PTR reserved) \ 54 { \ 55 CK_FUNCTION_LIST *bound; \ 56 Wrapper *wrapper; \ 57 CK_X_FUNCTION_LIST *funcs; \ 58 bound = fixed_closures[fixed_index]; \ 59 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 60 wrapper = (Wrapper *) bound; \ 61 funcs = &wrapper->virt->funcs; \ 62 return funcs->C_Finalize (funcs, reserved); \ 63 } \ 64 \ 65 static CK_RV \ 66 fixed ## fixed_index ## _C_GetInfo (CK_INFO_PTR info) \ 67 { \ 68 CK_FUNCTION_LIST *bound; \ 69 Wrapper *wrapper; \ 70 CK_X_FUNCTION_LIST *funcs; \ 71 bound = fixed_closures[fixed_index]; \ 72 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 73 wrapper = (Wrapper *) bound; \ 74 funcs = &wrapper->virt->funcs; \ 75 return funcs->C_GetInfo (funcs, info); \ 76 } \ 77 \ 78 static CK_RV \ 79 fixed ## fixed_index ## _C_GetSlotList (CK_BBOOL token_present, \ 80 CK_SLOT_ID_PTR slot_list, \ 81 CK_ULONG_PTR count) \ 82 { \ 83 CK_FUNCTION_LIST *bound; \ 84 Wrapper *wrapper; \ 85 CK_X_FUNCTION_LIST *funcs; \ 86 bound = fixed_closures[fixed_index]; \ 87 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 88 wrapper = (Wrapper *) bound; \ 89 funcs = &wrapper->virt->funcs; \ 90 return funcs->C_GetSlotList (funcs, token_present, slot_list, count); \ 91 } \ 92 \ 93 static CK_RV \ 94 fixed ## fixed_index ## _C_GetSlotInfo (CK_SLOT_ID slot_id, \ 95 CK_SLOT_INFO_PTR info) \ 96 { \ 97 CK_FUNCTION_LIST *bound; \ 98 Wrapper *wrapper; \ 99 CK_X_FUNCTION_LIST *funcs; \ 100 bound = fixed_closures[fixed_index]; \ 101 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 102 wrapper = (Wrapper *) bound; \ 103 funcs = &wrapper->virt->funcs; \ 104 return funcs->C_GetSlotInfo (funcs, slot_id, info); \ 105 } \ 106 \ 107 static CK_RV \ 108 fixed ## fixed_index ## _C_GetTokenInfo (CK_SLOT_ID slot_id, \ 109 CK_TOKEN_INFO_PTR info) \ 110 { \ 111 CK_FUNCTION_LIST *bound; \ 112 Wrapper *wrapper; \ 113 CK_X_FUNCTION_LIST *funcs; \ 114 bound = fixed_closures[fixed_index]; \ 115 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 116 wrapper = (Wrapper *) bound; \ 117 funcs = &wrapper->virt->funcs; \ 118 return funcs->C_GetTokenInfo (funcs, slot_id, info); \ 119 } \ 120 \ 121 static CK_RV \ 122 fixed ## fixed_index ## _C_GetMechanismList (CK_SLOT_ID slot_id, \ 123 CK_MECHANISM_TYPE_PTR mechanism_list, \ 124 CK_ULONG_PTR count) \ 125 { \ 126 CK_FUNCTION_LIST *bound; \ 127 Wrapper *wrapper; \ 128 CK_X_FUNCTION_LIST *funcs; \ 129 bound = fixed_closures[fixed_index]; \ 130 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 131 wrapper = (Wrapper *) bound; \ 132 funcs = &wrapper->virt->funcs; \ 133 return funcs->C_GetMechanismList (funcs, slot_id, mechanism_list, count); \ 134 } \ 135 \ 136 static CK_RV \ 137 fixed ## fixed_index ## _C_GetMechanismInfo (CK_SLOT_ID slot_id, \ 138 CK_MECHANISM_TYPE type, \ 139 CK_MECHANISM_INFO_PTR info) \ 140 { \ 141 CK_FUNCTION_LIST *bound; \ 142 Wrapper *wrapper; \ 143 CK_X_FUNCTION_LIST *funcs; \ 144 bound = fixed_closures[fixed_index]; \ 145 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 146 wrapper = (Wrapper *) bound; \ 147 funcs = &wrapper->virt->funcs; \ 148 return funcs->C_GetMechanismInfo (funcs, slot_id, type, info); \ 149 } \ 150 \ 151 static CK_RV \ 152 fixed ## fixed_index ## _C_InitToken (CK_SLOT_ID slot_id, \ 153 CK_BYTE_PTR pin, \ 154 CK_ULONG pin_len, \ 155 CK_BYTE_PTR label) \ 156 { \ 157 CK_FUNCTION_LIST *bound; \ 158 Wrapper *wrapper; \ 159 CK_X_FUNCTION_LIST *funcs; \ 160 bound = fixed_closures[fixed_index]; \ 161 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 162 wrapper = (Wrapper *) bound; \ 163 funcs = &wrapper->virt->funcs; \ 164 return funcs->C_InitToken (funcs, slot_id, pin, pin_len, label); \ 165 } \ 166 \ 167 static CK_RV \ 168 fixed ## fixed_index ## _C_InitPIN (CK_SESSION_HANDLE session, \ 169 CK_BYTE_PTR pin, \ 170 CK_ULONG pin_len) \ 171 { \ 172 CK_FUNCTION_LIST *bound; \ 173 Wrapper *wrapper; \ 174 CK_X_FUNCTION_LIST *funcs; \ 175 bound = fixed_closures[fixed_index]; \ 176 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 177 wrapper = (Wrapper *) bound; \ 178 funcs = &wrapper->virt->funcs; \ 179 return funcs->C_InitPIN (funcs, session, pin, pin_len); \ 180 } \ 181 \ 182 static CK_RV \ 183 fixed ## fixed_index ## _C_SetPIN (CK_SESSION_HANDLE session, \ 184 CK_BYTE_PTR old_pin, \ 185 CK_ULONG old_len, \ 186 CK_BYTE_PTR new_pin, \ 187 CK_ULONG new_len) \ 188 { \ 189 CK_FUNCTION_LIST *bound; \ 190 Wrapper *wrapper; \ 191 CK_X_FUNCTION_LIST *funcs; \ 192 bound = fixed_closures[fixed_index]; \ 193 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 194 wrapper = (Wrapper *) bound; \ 195 funcs = &wrapper->virt->funcs; \ 196 return funcs->C_SetPIN (funcs, session, old_pin, old_len, new_pin, new_len); \ 197 } \ 198 \ 199 static CK_RV \ 200 fixed ## fixed_index ## _C_OpenSession (CK_SLOT_ID slot_id, \ 201 CK_FLAGS flags, \ 202 CK_VOID_PTR application, \ 203 CK_NOTIFY notify, \ 204 CK_SESSION_HANDLE_PTR session) \ 205 { \ 206 CK_FUNCTION_LIST *bound; \ 207 Wrapper *wrapper; \ 208 CK_X_FUNCTION_LIST *funcs; \ 209 bound = fixed_closures[fixed_index]; \ 210 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 211 wrapper = (Wrapper *) bound; \ 212 funcs = &wrapper->virt->funcs; \ 213 return funcs->C_OpenSession (funcs, slot_id, flags, application, notify, session); \ 214 } \ 215 \ 216 static CK_RV \ 217 fixed ## fixed_index ## _C_CloseSession (CK_SESSION_HANDLE session) \ 218 { \ 219 CK_FUNCTION_LIST *bound; \ 220 Wrapper *wrapper; \ 221 CK_X_FUNCTION_LIST *funcs; \ 222 bound = fixed_closures[fixed_index]; \ 223 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 224 wrapper = (Wrapper *) bound; \ 225 funcs = &wrapper->virt->funcs; \ 226 return funcs->C_CloseSession (funcs, session); \ 227 } \ 228 \ 229 static CK_RV \ 230 fixed ## fixed_index ## _C_CloseAllSessions (CK_SLOT_ID slot_id) \ 231 { \ 232 CK_FUNCTION_LIST *bound; \ 233 Wrapper *wrapper; \ 234 CK_X_FUNCTION_LIST *funcs; \ 235 bound = fixed_closures[fixed_index]; \ 236 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 237 wrapper = (Wrapper *) bound; \ 238 funcs = &wrapper->virt->funcs; \ 239 return funcs->C_CloseAllSessions (funcs, slot_id); \ 240 } \ 241 \ 242 static CK_RV \ 243 fixed ## fixed_index ## _C_GetSessionInfo (CK_SESSION_HANDLE session, \ 244 CK_SESSION_INFO_PTR info) \ 245 { \ 246 CK_FUNCTION_LIST *bound; \ 247 Wrapper *wrapper; \ 248 CK_X_FUNCTION_LIST *funcs; \ 249 bound = fixed_closures[fixed_index]; \ 250 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 251 wrapper = (Wrapper *) bound; \ 252 funcs = &wrapper->virt->funcs; \ 253 return funcs->C_GetSessionInfo (funcs, session, info); \ 254 } \ 255 \ 256 static CK_RV \ 257 fixed ## fixed_index ## _C_GetOperationState (CK_SESSION_HANDLE session, \ 258 CK_BYTE_PTR operation_state, \ 259 CK_ULONG_PTR operation_state_len) \ 260 { \ 261 CK_FUNCTION_LIST *bound; \ 262 Wrapper *wrapper; \ 263 CK_X_FUNCTION_LIST *funcs; \ 264 bound = fixed_closures[fixed_index]; \ 265 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 266 wrapper = (Wrapper *) bound; \ 267 funcs = &wrapper->virt->funcs; \ 268 return funcs->C_GetOperationState (funcs, session, operation_state, operation_state_len); \ 269 } \ 270 \ 271 static CK_RV \ 272 fixed ## fixed_index ## _C_SetOperationState (CK_SESSION_HANDLE session, \ 273 CK_BYTE_PTR operation_state, \ 274 CK_ULONG operation_state_len, \ 275 CK_OBJECT_HANDLE encryption_key, \ 276 CK_OBJECT_HANDLE authentiation_key) \ 277 { \ 278 CK_FUNCTION_LIST *bound; \ 279 Wrapper *wrapper; \ 280 CK_X_FUNCTION_LIST *funcs; \ 281 bound = fixed_closures[fixed_index]; \ 282 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 283 wrapper = (Wrapper *) bound; \ 284 funcs = &wrapper->virt->funcs; \ 285 return funcs->C_SetOperationState (funcs, session, operation_state, operation_state_len, encryption_key, authentiation_key); \ 286 } \ 287 \ 288 static CK_RV \ 289 fixed ## fixed_index ## _C_Login (CK_SESSION_HANDLE session, \ 290 CK_USER_TYPE user_type, \ 291 CK_BYTE_PTR pin, \ 292 CK_ULONG pin_len) \ 293 { \ 294 CK_FUNCTION_LIST *bound; \ 295 Wrapper *wrapper; \ 296 CK_X_FUNCTION_LIST *funcs; \ 297 bound = fixed_closures[fixed_index]; \ 298 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 299 wrapper = (Wrapper *) bound; \ 300 funcs = &wrapper->virt->funcs; \ 301 return funcs->C_Login (funcs, session, user_type, pin, pin_len); \ 302 } \ 303 \ 304 static CK_RV \ 305 fixed ## fixed_index ## _C_Logout (CK_SESSION_HANDLE session) \ 306 { \ 307 CK_FUNCTION_LIST *bound; \ 308 Wrapper *wrapper; \ 309 CK_X_FUNCTION_LIST *funcs; \ 310 bound = fixed_closures[fixed_index]; \ 311 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 312 wrapper = (Wrapper *) bound; \ 313 funcs = &wrapper->virt->funcs; \ 314 return funcs->C_Logout (funcs, session); \ 315 } \ 316 \ 317 static CK_RV \ 318 fixed ## fixed_index ## _C_CreateObject (CK_SESSION_HANDLE session, \ 319 CK_ATTRIBUTE_PTR templ, \ 320 CK_ULONG count, \ 321 CK_OBJECT_HANDLE_PTR object) \ 322 { \ 323 CK_FUNCTION_LIST *bound; \ 324 Wrapper *wrapper; \ 325 CK_X_FUNCTION_LIST *funcs; \ 326 bound = fixed_closures[fixed_index]; \ 327 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 328 wrapper = (Wrapper *) bound; \ 329 funcs = &wrapper->virt->funcs; \ 330 return funcs->C_CreateObject (funcs, session, templ, count, object); \ 331 } \ 332 \ 333 static CK_RV \ 334 fixed ## fixed_index ## _C_CopyObject (CK_SESSION_HANDLE session, \ 335 CK_OBJECT_HANDLE object, \ 336 CK_ATTRIBUTE_PTR templ, \ 337 CK_ULONG count, \ 338 CK_OBJECT_HANDLE_PTR new_object) \ 339 { \ 340 CK_FUNCTION_LIST *bound; \ 341 Wrapper *wrapper; \ 342 CK_X_FUNCTION_LIST *funcs; \ 343 bound = fixed_closures[fixed_index]; \ 344 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 345 wrapper = (Wrapper *) bound; \ 346 funcs = &wrapper->virt->funcs; \ 347 return funcs->C_CopyObject (funcs, session, object, templ, count, new_object); \ 348 } \ 349 \ 350 static CK_RV \ 351 fixed ## fixed_index ## _C_DestroyObject (CK_SESSION_HANDLE session, \ 352 CK_OBJECT_HANDLE object) \ 353 { \ 354 CK_FUNCTION_LIST *bound; \ 355 Wrapper *wrapper; \ 356 CK_X_FUNCTION_LIST *funcs; \ 357 bound = fixed_closures[fixed_index]; \ 358 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 359 wrapper = (Wrapper *) bound; \ 360 funcs = &wrapper->virt->funcs; \ 361 return funcs->C_DestroyObject (funcs, session, object); \ 362 } \ 363 \ 364 static CK_RV \ 365 fixed ## fixed_index ## _C_GetObjectSize (CK_SESSION_HANDLE session, \ 366 CK_OBJECT_HANDLE object, \ 367 CK_ULONG_PTR size) \ 368 { \ 369 CK_FUNCTION_LIST *bound; \ 370 Wrapper *wrapper; \ 371 CK_X_FUNCTION_LIST *funcs; \ 372 bound = fixed_closures[fixed_index]; \ 373 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 374 wrapper = (Wrapper *) bound; \ 375 funcs = &wrapper->virt->funcs; \ 376 return funcs->C_GetObjectSize (funcs, session, object, size); \ 377 } \ 378 \ 379 static CK_RV \ 380 fixed ## fixed_index ## _C_GetAttributeValue (CK_SESSION_HANDLE session, \ 381 CK_OBJECT_HANDLE object, \ 382 CK_ATTRIBUTE_PTR templ, \ 383 CK_ULONG count) \ 384 { \ 385 CK_FUNCTION_LIST *bound; \ 386 Wrapper *wrapper; \ 387 CK_X_FUNCTION_LIST *funcs; \ 388 bound = fixed_closures[fixed_index]; \ 389 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 390 wrapper = (Wrapper *) bound; \ 391 funcs = &wrapper->virt->funcs; \ 392 return funcs->C_GetAttributeValue (funcs, session, object, templ, count); \ 393 } \ 394 \ 395 static CK_RV \ 396 fixed ## fixed_index ## _C_SetAttributeValue (CK_SESSION_HANDLE session, \ 397 CK_OBJECT_HANDLE object, \ 398 CK_ATTRIBUTE_PTR templ, \ 399 CK_ULONG count) \ 400 { \ 401 CK_FUNCTION_LIST *bound; \ 402 Wrapper *wrapper; \ 403 CK_X_FUNCTION_LIST *funcs; \ 404 bound = fixed_closures[fixed_index]; \ 405 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 406 wrapper = (Wrapper *) bound; \ 407 funcs = &wrapper->virt->funcs; \ 408 return funcs->C_SetAttributeValue (funcs, session, object, templ, count); \ 409 } \ 410 \ 411 static CK_RV \ 412 fixed ## fixed_index ## _C_FindObjectsInit (CK_SESSION_HANDLE session, \ 413 CK_ATTRIBUTE_PTR templ, \ 414 CK_ULONG count) \ 415 { \ 416 CK_FUNCTION_LIST *bound; \ 417 Wrapper *wrapper; \ 418 CK_X_FUNCTION_LIST *funcs; \ 419 bound = fixed_closures[fixed_index]; \ 420 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 421 wrapper = (Wrapper *) bound; \ 422 funcs = &wrapper->virt->funcs; \ 423 return funcs->C_FindObjectsInit (funcs, session, templ, count); \ 424 } \ 425 \ 426 static CK_RV \ 427 fixed ## fixed_index ## _C_FindObjects (CK_SESSION_HANDLE session, \ 428 CK_OBJECT_HANDLE_PTR object, \ 429 CK_ULONG max_object_count, \ 430 CK_ULONG_PTR object_count) \ 431 { \ 432 CK_FUNCTION_LIST *bound; \ 433 Wrapper *wrapper; \ 434 CK_X_FUNCTION_LIST *funcs; \ 435 bound = fixed_closures[fixed_index]; \ 436 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 437 wrapper = (Wrapper *) bound; \ 438 funcs = &wrapper->virt->funcs; \ 439 return funcs->C_FindObjects (funcs, session, object, max_object_count, object_count); \ 440 } \ 441 \ 442 static CK_RV \ 443 fixed ## fixed_index ## _C_FindObjectsFinal (CK_SESSION_HANDLE session) \ 444 { \ 445 CK_FUNCTION_LIST *bound; \ 446 Wrapper *wrapper; \ 447 CK_X_FUNCTION_LIST *funcs; \ 448 bound = fixed_closures[fixed_index]; \ 449 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 450 wrapper = (Wrapper *) bound; \ 451 funcs = &wrapper->virt->funcs; \ 452 return funcs->C_FindObjectsFinal (funcs, session); \ 453 } \ 454 \ 455 static CK_RV \ 456 fixed ## fixed_index ## _C_EncryptInit (CK_SESSION_HANDLE session, \ 457 CK_MECHANISM_PTR mechanism, \ 458 CK_OBJECT_HANDLE key) \ 459 { \ 460 CK_FUNCTION_LIST *bound; \ 461 Wrapper *wrapper; \ 462 CK_X_FUNCTION_LIST *funcs; \ 463 bound = fixed_closures[fixed_index]; \ 464 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 465 wrapper = (Wrapper *) bound; \ 466 funcs = &wrapper->virt->funcs; \ 467 return funcs->C_EncryptInit (funcs, session, mechanism, key); \ 468 } \ 469 \ 470 static CK_RV \ 471 fixed ## fixed_index ## _C_Encrypt (CK_SESSION_HANDLE session, \ 472 CK_BYTE_PTR data, \ 473 CK_ULONG data_len, \ 474 CK_BYTE_PTR encrypted_data, \ 475 CK_ULONG_PTR encrypted_data_len) \ 476 { \ 477 CK_FUNCTION_LIST *bound; \ 478 Wrapper *wrapper; \ 479 CK_X_FUNCTION_LIST *funcs; \ 480 bound = fixed_closures[fixed_index]; \ 481 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 482 wrapper = (Wrapper *) bound; \ 483 funcs = &wrapper->virt->funcs; \ 484 return funcs->C_Encrypt (funcs, session, data, data_len, encrypted_data, encrypted_data_len); \ 485 } \ 486 \ 487 static CK_RV \ 488 fixed ## fixed_index ## _C_EncryptUpdate (CK_SESSION_HANDLE session, \ 489 CK_BYTE_PTR part, \ 490 CK_ULONG part_len, \ 491 CK_BYTE_PTR encrypted_part, \ 492 CK_ULONG_PTR encrypted_part_len) \ 493 { \ 494 CK_FUNCTION_LIST *bound; \ 495 Wrapper *wrapper; \ 496 CK_X_FUNCTION_LIST *funcs; \ 497 bound = fixed_closures[fixed_index]; \ 498 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 499 wrapper = (Wrapper *) bound; \ 500 funcs = &wrapper->virt->funcs; \ 501 return funcs->C_EncryptUpdate (funcs, session, part, part_len, encrypted_part, encrypted_part_len); \ 502 } \ 503 \ 504 static CK_RV \ 505 fixed ## fixed_index ## _C_EncryptFinal (CK_SESSION_HANDLE session, \ 506 CK_BYTE_PTR last_encrypted_part, \ 507 CK_ULONG_PTR last_encrypted_part_len) \ 508 { \ 509 CK_FUNCTION_LIST *bound; \ 510 Wrapper *wrapper; \ 511 CK_X_FUNCTION_LIST *funcs; \ 512 bound = fixed_closures[fixed_index]; \ 513 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 514 wrapper = (Wrapper *) bound; \ 515 funcs = &wrapper->virt->funcs; \ 516 return funcs->C_EncryptFinal (funcs, session, last_encrypted_part, last_encrypted_part_len); \ 517 } \ 518 \ 519 static CK_RV \ 520 fixed ## fixed_index ## _C_DecryptInit (CK_SESSION_HANDLE session, \ 521 CK_MECHANISM_PTR mechanism, \ 522 CK_OBJECT_HANDLE key) \ 523 { \ 524 CK_FUNCTION_LIST *bound; \ 525 Wrapper *wrapper; \ 526 CK_X_FUNCTION_LIST *funcs; \ 527 bound = fixed_closures[fixed_index]; \ 528 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 529 wrapper = (Wrapper *) bound; \ 530 funcs = &wrapper->virt->funcs; \ 531 return funcs->C_DecryptInit (funcs, session, mechanism, key); \ 532 } \ 533 \ 534 static CK_RV \ 535 fixed ## fixed_index ## _C_Decrypt (CK_SESSION_HANDLE session, \ 536 CK_BYTE_PTR encrypted_data, \ 537 CK_ULONG encrypted_data_len, \ 538 CK_BYTE_PTR data, \ 539 CK_ULONG_PTR data_len) \ 540 { \ 541 CK_FUNCTION_LIST *bound; \ 542 Wrapper *wrapper; \ 543 CK_X_FUNCTION_LIST *funcs; \ 544 bound = fixed_closures[fixed_index]; \ 545 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 546 wrapper = (Wrapper *) bound; \ 547 funcs = &wrapper->virt->funcs; \ 548 return funcs->C_Decrypt (funcs, session, encrypted_data, encrypted_data_len, data, data_len); \ 549 } \ 550 \ 551 static CK_RV \ 552 fixed ## fixed_index ## _C_DecryptUpdate (CK_SESSION_HANDLE session, \ 553 CK_BYTE_PTR encrypted_part, \ 554 CK_ULONG encrypted_part_len, \ 555 CK_BYTE_PTR part, \ 556 CK_ULONG_PTR part_len) \ 557 { \ 558 CK_FUNCTION_LIST *bound; \ 559 Wrapper *wrapper; \ 560 CK_X_FUNCTION_LIST *funcs; \ 561 bound = fixed_closures[fixed_index]; \ 562 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 563 wrapper = (Wrapper *) bound; \ 564 funcs = &wrapper->virt->funcs; \ 565 return funcs->C_DecryptUpdate (funcs, session, encrypted_part, encrypted_part_len, part, part_len); \ 566 } \ 567 \ 568 static CK_RV \ 569 fixed ## fixed_index ## _C_DecryptFinal (CK_SESSION_HANDLE session, \ 570 CK_BYTE_PTR last_part, \ 571 CK_ULONG_PTR last_part_len) \ 572 { \ 573 CK_FUNCTION_LIST *bound; \ 574 Wrapper *wrapper; \ 575 CK_X_FUNCTION_LIST *funcs; \ 576 bound = fixed_closures[fixed_index]; \ 577 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 578 wrapper = (Wrapper *) bound; \ 579 funcs = &wrapper->virt->funcs; \ 580 return funcs->C_DecryptFinal (funcs, session, last_part, last_part_len); \ 581 } \ 582 \ 583 static CK_RV \ 584 fixed ## fixed_index ## _C_DigestInit (CK_SESSION_HANDLE session, \ 585 CK_MECHANISM_PTR mechanism) \ 586 { \ 587 CK_FUNCTION_LIST *bound; \ 588 Wrapper *wrapper; \ 589 CK_X_FUNCTION_LIST *funcs; \ 590 bound = fixed_closures[fixed_index]; \ 591 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 592 wrapper = (Wrapper *) bound; \ 593 funcs = &wrapper->virt->funcs; \ 594 return funcs->C_DigestInit (funcs, session, mechanism); \ 595 } \ 596 \ 597 static CK_RV \ 598 fixed ## fixed_index ## _C_Digest (CK_SESSION_HANDLE session, \ 599 CK_BYTE_PTR data, \ 600 CK_ULONG data_len, \ 601 CK_BYTE_PTR digest, \ 602 CK_ULONG_PTR digest_len) \ 603 { \ 604 CK_FUNCTION_LIST *bound; \ 605 Wrapper *wrapper; \ 606 CK_X_FUNCTION_LIST *funcs; \ 607 bound = fixed_closures[fixed_index]; \ 608 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 609 wrapper = (Wrapper *) bound; \ 610 funcs = &wrapper->virt->funcs; \ 611 return funcs->C_Digest (funcs, session, data, data_len, digest, digest_len); \ 612 } \ 613 \ 614 static CK_RV \ 615 fixed ## fixed_index ## _C_DigestUpdate (CK_SESSION_HANDLE session, \ 616 CK_BYTE_PTR part, \ 617 CK_ULONG part_len) \ 618 { \ 619 CK_FUNCTION_LIST *bound; \ 620 Wrapper *wrapper; \ 621 CK_X_FUNCTION_LIST *funcs; \ 622 bound = fixed_closures[fixed_index]; \ 623 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 624 wrapper = (Wrapper *) bound; \ 625 funcs = &wrapper->virt->funcs; \ 626 return funcs->C_DigestUpdate (funcs, session, part, part_len); \ 627 } \ 628 \ 629 static CK_RV \ 630 fixed ## fixed_index ## _C_DigestKey (CK_SESSION_HANDLE session, \ 631 CK_OBJECT_HANDLE key) \ 632 { \ 633 CK_FUNCTION_LIST *bound; \ 634 Wrapper *wrapper; \ 635 CK_X_FUNCTION_LIST *funcs; \ 636 bound = fixed_closures[fixed_index]; \ 637 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 638 wrapper = (Wrapper *) bound; \ 639 funcs = &wrapper->virt->funcs; \ 640 return funcs->C_DigestKey (funcs, session, key); \ 641 } \ 642 \ 643 static CK_RV \ 644 fixed ## fixed_index ## _C_DigestFinal (CK_SESSION_HANDLE session, \ 645 CK_BYTE_PTR digest, \ 646 CK_ULONG_PTR digest_len) \ 647 { \ 648 CK_FUNCTION_LIST *bound; \ 649 Wrapper *wrapper; \ 650 CK_X_FUNCTION_LIST *funcs; \ 651 bound = fixed_closures[fixed_index]; \ 652 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 653 wrapper = (Wrapper *) bound; \ 654 funcs = &wrapper->virt->funcs; \ 655 return funcs->C_DigestFinal (funcs, session, digest, digest_len); \ 656 } \ 657 \ 658 static CK_RV \ 659 fixed ## fixed_index ## _C_SignInit (CK_SESSION_HANDLE session, \ 660 CK_MECHANISM_PTR mechanism, \ 661 CK_OBJECT_HANDLE key) \ 662 { \ 663 CK_FUNCTION_LIST *bound; \ 664 Wrapper *wrapper; \ 665 CK_X_FUNCTION_LIST *funcs; \ 666 bound = fixed_closures[fixed_index]; \ 667 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 668 wrapper = (Wrapper *) bound; \ 669 funcs = &wrapper->virt->funcs; \ 670 return funcs->C_SignInit (funcs, session, mechanism, key); \ 671 } \ 672 \ 673 static CK_RV \ 674 fixed ## fixed_index ## _C_Sign (CK_SESSION_HANDLE session, \ 675 CK_BYTE_PTR data, \ 676 CK_ULONG data_len, \ 677 CK_BYTE_PTR signature, \ 678 CK_ULONG_PTR signature_len) \ 679 { \ 680 CK_FUNCTION_LIST *bound; \ 681 Wrapper *wrapper; \ 682 CK_X_FUNCTION_LIST *funcs; \ 683 bound = fixed_closures[fixed_index]; \ 684 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 685 wrapper = (Wrapper *) bound; \ 686 funcs = &wrapper->virt->funcs; \ 687 return funcs->C_Sign (funcs, session, data, data_len, signature, signature_len); \ 688 } \ 689 \ 690 static CK_RV \ 691 fixed ## fixed_index ## _C_SignUpdate (CK_SESSION_HANDLE session, \ 692 CK_BYTE_PTR part, \ 693 CK_ULONG part_len) \ 694 { \ 695 CK_FUNCTION_LIST *bound; \ 696 Wrapper *wrapper; \ 697 CK_X_FUNCTION_LIST *funcs; \ 698 bound = fixed_closures[fixed_index]; \ 699 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 700 wrapper = (Wrapper *) bound; \ 701 funcs = &wrapper->virt->funcs; \ 702 return funcs->C_SignUpdate (funcs, session, part, part_len); \ 703 } \ 704 \ 705 static CK_RV \ 706 fixed ## fixed_index ## _C_SignFinal (CK_SESSION_HANDLE session, \ 707 CK_BYTE_PTR signature, \ 708 CK_ULONG_PTR signature_len) \ 709 { \ 710 CK_FUNCTION_LIST *bound; \ 711 Wrapper *wrapper; \ 712 CK_X_FUNCTION_LIST *funcs; \ 713 bound = fixed_closures[fixed_index]; \ 714 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 715 wrapper = (Wrapper *) bound; \ 716 funcs = &wrapper->virt->funcs; \ 717 return funcs->C_SignFinal (funcs, session, signature, signature_len); \ 718 } \ 719 \ 720 static CK_RV \ 721 fixed ## fixed_index ## _C_SignRecoverInit (CK_SESSION_HANDLE session, \ 722 CK_MECHANISM_PTR mechanism, \ 723 CK_OBJECT_HANDLE key) \ 724 { \ 725 CK_FUNCTION_LIST *bound; \ 726 Wrapper *wrapper; \ 727 CK_X_FUNCTION_LIST *funcs; \ 728 bound = fixed_closures[fixed_index]; \ 729 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 730 wrapper = (Wrapper *) bound; \ 731 funcs = &wrapper->virt->funcs; \ 732 return funcs->C_SignRecoverInit (funcs, session, mechanism, key); \ 733 } \ 734 \ 735 static CK_RV \ 736 fixed ## fixed_index ## _C_SignRecover (CK_SESSION_HANDLE session, \ 737 CK_BYTE_PTR data, \ 738 CK_ULONG data_len, \ 739 CK_BYTE_PTR signature, \ 740 CK_ULONG_PTR signature_len) \ 741 { \ 742 CK_FUNCTION_LIST *bound; \ 743 Wrapper *wrapper; \ 744 CK_X_FUNCTION_LIST *funcs; \ 745 bound = fixed_closures[fixed_index]; \ 746 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 747 wrapper = (Wrapper *) bound; \ 748 funcs = &wrapper->virt->funcs; \ 749 return funcs->C_SignRecover (funcs, session, data, data_len, signature, signature_len); \ 750 } \ 751 \ 752 static CK_RV \ 753 fixed ## fixed_index ## _C_VerifyInit (CK_SESSION_HANDLE session, \ 754 CK_MECHANISM_PTR mechanism, \ 755 CK_OBJECT_HANDLE key) \ 756 { \ 757 CK_FUNCTION_LIST *bound; \ 758 Wrapper *wrapper; \ 759 CK_X_FUNCTION_LIST *funcs; \ 760 bound = fixed_closures[fixed_index]; \ 761 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 762 wrapper = (Wrapper *) bound; \ 763 funcs = &wrapper->virt->funcs; \ 764 return funcs->C_VerifyInit (funcs, session, mechanism, key); \ 765 } \ 766 \ 767 static CK_RV \ 768 fixed ## fixed_index ## _C_Verify (CK_SESSION_HANDLE session, \ 769 CK_BYTE_PTR data, \ 770 CK_ULONG data_len, \ 771 CK_BYTE_PTR signature, \ 772 CK_ULONG signature_len) \ 773 { \ 774 CK_FUNCTION_LIST *bound; \ 775 Wrapper *wrapper; \ 776 CK_X_FUNCTION_LIST *funcs; \ 777 bound = fixed_closures[fixed_index]; \ 778 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 779 wrapper = (Wrapper *) bound; \ 780 funcs = &wrapper->virt->funcs; \ 781 return funcs->C_Verify (funcs, session, data, data_len, signature, signature_len); \ 782 } \ 783 \ 784 static CK_RV \ 785 fixed ## fixed_index ## _C_VerifyUpdate (CK_SESSION_HANDLE session, \ 786 CK_BYTE_PTR part, \ 787 CK_ULONG part_len) \ 788 { \ 789 CK_FUNCTION_LIST *bound; \ 790 Wrapper *wrapper; \ 791 CK_X_FUNCTION_LIST *funcs; \ 792 bound = fixed_closures[fixed_index]; \ 793 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 794 wrapper = (Wrapper *) bound; \ 795 funcs = &wrapper->virt->funcs; \ 796 return funcs->C_VerifyUpdate (funcs, session, part, part_len); \ 797 } \ 798 \ 799 static CK_RV \ 800 fixed ## fixed_index ## _C_VerifyFinal (CK_SESSION_HANDLE session, \ 801 CK_BYTE_PTR signature, \ 802 CK_ULONG signature_len) \ 803 { \ 804 CK_FUNCTION_LIST *bound; \ 805 Wrapper *wrapper; \ 806 CK_X_FUNCTION_LIST *funcs; \ 807 bound = fixed_closures[fixed_index]; \ 808 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 809 wrapper = (Wrapper *) bound; \ 810 funcs = &wrapper->virt->funcs; \ 811 return funcs->C_VerifyFinal (funcs, session, signature, signature_len); \ 812 } \ 813 \ 814 static CK_RV \ 815 fixed ## fixed_index ## _C_VerifyRecoverInit (CK_SESSION_HANDLE session, \ 816 CK_MECHANISM_PTR mechanism, \ 817 CK_OBJECT_HANDLE key) \ 818 { \ 819 CK_FUNCTION_LIST *bound; \ 820 Wrapper *wrapper; \ 821 CK_X_FUNCTION_LIST *funcs; \ 822 bound = fixed_closures[fixed_index]; \ 823 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 824 wrapper = (Wrapper *) bound; \ 825 funcs = &wrapper->virt->funcs; \ 826 return funcs->C_VerifyRecoverInit (funcs, session, mechanism, key); \ 827 } \ 828 \ 829 static CK_RV \ 830 fixed ## fixed_index ## _C_VerifyRecover (CK_SESSION_HANDLE session, \ 831 CK_BYTE_PTR signature, \ 832 CK_ULONG signature_len, \ 833 CK_BYTE_PTR data, \ 834 CK_ULONG_PTR data_len) \ 835 { \ 836 CK_FUNCTION_LIST *bound; \ 837 Wrapper *wrapper; \ 838 CK_X_FUNCTION_LIST *funcs; \ 839 bound = fixed_closures[fixed_index]; \ 840 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 841 wrapper = (Wrapper *) bound; \ 842 funcs = &wrapper->virt->funcs; \ 843 return funcs->C_VerifyRecover (funcs, session, signature, signature_len, data, data_len); \ 844 } \ 845 \ 846 static CK_RV \ 847 fixed ## fixed_index ## _C_DigestEncryptUpdate (CK_SESSION_HANDLE session, \ 848 CK_BYTE_PTR part, \ 849 CK_ULONG part_len, \ 850 CK_BYTE_PTR encrypted_part, \ 851 CK_ULONG_PTR encrypted_part_len) \ 852 { \ 853 CK_FUNCTION_LIST *bound; \ 854 Wrapper *wrapper; \ 855 CK_X_FUNCTION_LIST *funcs; \ 856 bound = fixed_closures[fixed_index]; \ 857 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 858 wrapper = (Wrapper *) bound; \ 859 funcs = &wrapper->virt->funcs; \ 860 return funcs->C_DigestEncryptUpdate (funcs, session, part, part_len, encrypted_part, encrypted_part_len); \ 861 } \ 862 \ 863 static CK_RV \ 864 fixed ## fixed_index ## _C_DecryptDigestUpdate (CK_SESSION_HANDLE session, \ 865 CK_BYTE_PTR encrypted_part, \ 866 CK_ULONG encrypted_part_len, \ 867 CK_BYTE_PTR part, \ 868 CK_ULONG_PTR part_len) \ 869 { \ 870 CK_FUNCTION_LIST *bound; \ 871 Wrapper *wrapper; \ 872 CK_X_FUNCTION_LIST *funcs; \ 873 bound = fixed_closures[fixed_index]; \ 874 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 875 wrapper = (Wrapper *) bound; \ 876 funcs = &wrapper->virt->funcs; \ 877 return funcs->C_DecryptDigestUpdate (funcs, session, encrypted_part, encrypted_part_len, part, part_len); \ 878 } \ 879 \ 880 static CK_RV \ 881 fixed ## fixed_index ## _C_SignEncryptUpdate (CK_SESSION_HANDLE session, \ 882 CK_BYTE_PTR part, \ 883 CK_ULONG part_len, \ 884 CK_BYTE_PTR encrypted_part, \ 885 CK_ULONG_PTR encrypted_part_len) \ 886 { \ 887 CK_FUNCTION_LIST *bound; \ 888 Wrapper *wrapper; \ 889 CK_X_FUNCTION_LIST *funcs; \ 890 bound = fixed_closures[fixed_index]; \ 891 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 892 wrapper = (Wrapper *) bound; \ 893 funcs = &wrapper->virt->funcs; \ 894 return funcs->C_SignEncryptUpdate (funcs, session, part, part_len, encrypted_part, encrypted_part_len); \ 895 } \ 896 \ 897 static CK_RV \ 898 fixed ## fixed_index ## _C_DecryptVerifyUpdate (CK_SESSION_HANDLE session, \ 899 CK_BYTE_PTR encrypted_part, \ 900 CK_ULONG encrypted_part_len, \ 901 CK_BYTE_PTR part, \ 902 CK_ULONG_PTR part_len) \ 903 { \ 904 CK_FUNCTION_LIST *bound; \ 905 Wrapper *wrapper; \ 906 CK_X_FUNCTION_LIST *funcs; \ 907 bound = fixed_closures[fixed_index]; \ 908 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 909 wrapper = (Wrapper *) bound; \ 910 funcs = &wrapper->virt->funcs; \ 911 return funcs->C_DecryptVerifyUpdate (funcs, session, encrypted_part, encrypted_part_len, part, part_len); \ 912 } \ 913 \ 914 static CK_RV \ 915 fixed ## fixed_index ## _C_GenerateKey (CK_SESSION_HANDLE session, \ 916 CK_MECHANISM_PTR mechanism, \ 917 CK_ATTRIBUTE_PTR templ, \ 918 CK_ULONG count, \ 919 CK_OBJECT_HANDLE_PTR key) \ 920 { \ 921 CK_FUNCTION_LIST *bound; \ 922 Wrapper *wrapper; \ 923 CK_X_FUNCTION_LIST *funcs; \ 924 bound = fixed_closures[fixed_index]; \ 925 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 926 wrapper = (Wrapper *) bound; \ 927 funcs = &wrapper->virt->funcs; \ 928 return funcs->C_GenerateKey (funcs, session, mechanism, templ, count, key); \ 929 } \ 930 \ 931 static CK_RV \ 932 fixed ## fixed_index ## _C_GenerateKeyPair (CK_SESSION_HANDLE session, \ 933 CK_MECHANISM_PTR mechanism, \ 934 CK_ATTRIBUTE_PTR public_key_template, \ 935 CK_ULONG public_key_attribute_count, \ 936 CK_ATTRIBUTE_PTR private_key_template, \ 937 CK_ULONG private_key_attribute_count, \ 938 CK_OBJECT_HANDLE_PTR public_key, \ 939 CK_OBJECT_HANDLE_PTR private_key) \ 940 { \ 941 CK_FUNCTION_LIST *bound; \ 942 Wrapper *wrapper; \ 943 CK_X_FUNCTION_LIST *funcs; \ 944 bound = fixed_closures[fixed_index]; \ 945 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 946 wrapper = (Wrapper *) bound; \ 947 funcs = &wrapper->virt->funcs; \ 948 return funcs->C_GenerateKeyPair (funcs, session, mechanism, public_key_template, public_key_attribute_count, private_key_template, private_key_attribute_count, public_key, private_key); \ 949 } \ 950 \ 951 static CK_RV \ 952 fixed ## fixed_index ## _C_WrapKey (CK_SESSION_HANDLE session, \ 953 CK_MECHANISM_PTR mechanism, \ 954 CK_OBJECT_HANDLE wrapping_key, \ 955 CK_OBJECT_HANDLE key, \ 956 CK_BYTE_PTR wrapped_key, \ 957 CK_ULONG_PTR wrapped_key_len) \ 958 { \ 959 CK_FUNCTION_LIST *bound; \ 960 Wrapper *wrapper; \ 961 CK_X_FUNCTION_LIST *funcs; \ 962 bound = fixed_closures[fixed_index]; \ 963 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 964 wrapper = (Wrapper *) bound; \ 965 funcs = &wrapper->virt->funcs; \ 966 return funcs->C_WrapKey (funcs, session, mechanism, wrapping_key, key, wrapped_key, wrapped_key_len); \ 967 } \ 968 \ 969 static CK_RV \ 970 fixed ## fixed_index ## _C_UnwrapKey (CK_SESSION_HANDLE session, \ 971 CK_MECHANISM_PTR mechanism, \ 972 CK_OBJECT_HANDLE unwrapping_key, \ 973 CK_BYTE_PTR wrapped_key, \ 974 CK_ULONG wrapped_key_len, \ 975 CK_ATTRIBUTE_PTR templ, \ 976 CK_ULONG attribute_count, \ 977 CK_OBJECT_HANDLE_PTR key) \ 978 { \ 979 CK_FUNCTION_LIST *bound; \ 980 Wrapper *wrapper; \ 981 CK_X_FUNCTION_LIST *funcs; \ 982 bound = fixed_closures[fixed_index]; \ 983 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 984 wrapper = (Wrapper *) bound; \ 985 funcs = &wrapper->virt->funcs; \ 986 return funcs->C_UnwrapKey (funcs, session, mechanism, unwrapping_key, wrapped_key, wrapped_key_len, templ, attribute_count, key); \ 987 } \ 988 \ 989 static CK_RV \ 990 fixed ## fixed_index ## _C_DeriveKey (CK_SESSION_HANDLE session, \ 991 CK_MECHANISM_PTR mechanism, \ 992 CK_OBJECT_HANDLE base_key, \ 993 CK_ATTRIBUTE_PTR templ, \ 994 CK_ULONG attribute_count, \ 995 CK_OBJECT_HANDLE_PTR key) \ 996 { \ 997 CK_FUNCTION_LIST *bound; \ 998 Wrapper *wrapper; \ 999 CK_X_FUNCTION_LIST *funcs; \ 1000 bound = fixed_closures[fixed_index]; \ 1001 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 1002 wrapper = (Wrapper *) bound; \ 1003 funcs = &wrapper->virt->funcs; \ 1004 return funcs->C_DeriveKey (funcs, session, mechanism, base_key, templ, attribute_count, key); \ 1005 } \ 1006 \ 1007 static CK_RV \ 1008 fixed ## fixed_index ## _C_SeedRandom (CK_SESSION_HANDLE session, \ 1009 CK_BYTE_PTR seed, \ 1010 CK_ULONG seed_len) \ 1011 { \ 1012 CK_FUNCTION_LIST *bound; \ 1013 Wrapper *wrapper; \ 1014 CK_X_FUNCTION_LIST *funcs; \ 1015 bound = fixed_closures[fixed_index]; \ 1016 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 1017 wrapper = (Wrapper *) bound; \ 1018 funcs = &wrapper->virt->funcs; \ 1019 return funcs->C_SeedRandom (funcs, session, seed, seed_len); \ 1020 } \ 1021 \ 1022 static CK_RV \ 1023 fixed ## fixed_index ## _C_GenerateRandom (CK_SESSION_HANDLE session, \ 1024 CK_BYTE_PTR random_data, \ 1025 CK_ULONG random_len) \ 1026 { \ 1027 CK_FUNCTION_LIST *bound; \ 1028 Wrapper *wrapper; \ 1029 CK_X_FUNCTION_LIST *funcs; \ 1030 bound = fixed_closures[fixed_index]; \ 1031 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 1032 wrapper = (Wrapper *) bound; \ 1033 funcs = &wrapper->virt->funcs; \ 1034 return funcs->C_GenerateRandom (funcs, session, random_data, random_len); \ 1035 } \ 1036 \ 1037 static CK_RV \ 1038 fixed ## fixed_index ## _C_WaitForSlotEvent (CK_FLAGS flags, \ 1039 CK_SLOT_ID_PTR slot, \ 1040 CK_VOID_PTR reserved) \ 1041 { \ 1042 CK_FUNCTION_LIST *bound; \ 1043 Wrapper *wrapper; \ 1044 CK_X_FUNCTION_LIST *funcs; \ 1045 bound = fixed_closures[fixed_index]; \ 1046 return_val_if_fail (bound != NULL, CKR_GENERAL_ERROR); \ 1047 wrapper = (Wrapper *) bound; \ 1048 funcs = &wrapper->virt->funcs; \ 1049 return funcs->C_WaitForSlotEvent (funcs, flags, slot, reserved); \ 1050 } \ 1051 \ 1052 static CK_RV \ 1053 fixed ## fixed_index ## _C_GetFunctionList (CK_FUNCTION_LIST_PTR_PTR list); 1054 1055 #define P11_VIRTUAL_FIXED_GET_FUNCTION_LIST(fixed_index) \ 1056 static CK_RV \ 1057 fixed ## fixed_index ## _C_GetFunctionList (CK_FUNCTION_LIST_PTR_PTR list) \ 1058 { \ 1059 if (!list) \ 1060 return CKR_ARGUMENTS_BAD; \ 1061 *list = fixed_closures[fixed_index]; \ 1062 return CKR_OK; \ 1063 } 1064 1065 #define P11_VIRTUAL_FIXED_INITIALIZER(fixed_index) \ 1066 { \ 1067 { CRYPTOKI_VERSION_MAJOR, CRYPTOKI_VERSION_MINOR }, /* version */ \ 1068 fixed ## fixed_index ## _C_Initialize, \ 1069 fixed ## fixed_index ## _C_Finalize, \ 1070 fixed ## fixed_index ## _C_GetInfo, \ 1071 fixed ## fixed_index ## _C_GetFunctionList, \ 1072 fixed ## fixed_index ## _C_GetSlotList, \ 1073 fixed ## fixed_index ## _C_GetSlotInfo, \ 1074 fixed ## fixed_index ## _C_GetTokenInfo, \ 1075 fixed ## fixed_index ## _C_GetMechanismList, \ 1076 fixed ## fixed_index ## _C_GetMechanismInfo, \ 1077 fixed ## fixed_index ## _C_InitToken, \ 1078 fixed ## fixed_index ## _C_InitPIN, \ 1079 fixed ## fixed_index ## _C_SetPIN, \ 1080 fixed ## fixed_index ## _C_OpenSession, \ 1081 fixed ## fixed_index ## _C_CloseSession, \ 1082 fixed ## fixed_index ## _C_CloseAllSessions, \ 1083 fixed ## fixed_index ## _C_GetSessionInfo, \ 1084 fixed ## fixed_index ## _C_GetOperationState, \ 1085 fixed ## fixed_index ## _C_SetOperationState, \ 1086 fixed ## fixed_index ## _C_Login, \ 1087 fixed ## fixed_index ## _C_Logout, \ 1088 fixed ## fixed_index ## _C_CreateObject, \ 1089 fixed ## fixed_index ## _C_CopyObject, \ 1090 fixed ## fixed_index ## _C_DestroyObject, \ 1091 fixed ## fixed_index ## _C_GetObjectSize, \ 1092 fixed ## fixed_index ## _C_GetAttributeValue, \ 1093 fixed ## fixed_index ## _C_SetAttributeValue, \ 1094 fixed ## fixed_index ## _C_FindObjectsInit, \ 1095 fixed ## fixed_index ## _C_FindObjects, \ 1096 fixed ## fixed_index ## _C_FindObjectsFinal, \ 1097 fixed ## fixed_index ## _C_EncryptInit, \ 1098 fixed ## fixed_index ## _C_Encrypt, \ 1099 fixed ## fixed_index ## _C_EncryptUpdate, \ 1100 fixed ## fixed_index ## _C_EncryptFinal, \ 1101 fixed ## fixed_index ## _C_DecryptInit, \ 1102 fixed ## fixed_index ## _C_Decrypt, \ 1103 fixed ## fixed_index ## _C_DecryptUpdate, \ 1104 fixed ## fixed_index ## _C_DecryptFinal, \ 1105 fixed ## fixed_index ## _C_DigestInit, \ 1106 fixed ## fixed_index ## _C_Digest, \ 1107 fixed ## fixed_index ## _C_DigestUpdate, \ 1108 fixed ## fixed_index ## _C_DigestKey, \ 1109 fixed ## fixed_index ## _C_DigestFinal, \ 1110 fixed ## fixed_index ## _C_SignInit, \ 1111 fixed ## fixed_index ## _C_Sign, \ 1112 fixed ## fixed_index ## _C_SignUpdate, \ 1113 fixed ## fixed_index ## _C_SignFinal, \ 1114 fixed ## fixed_index ## _C_SignRecoverInit, \ 1115 fixed ## fixed_index ## _C_SignRecover, \ 1116 fixed ## fixed_index ## _C_VerifyInit, \ 1117 fixed ## fixed_index ## _C_Verify, \ 1118 fixed ## fixed_index ## _C_VerifyUpdate, \ 1119 fixed ## fixed_index ## _C_VerifyFinal, \ 1120 fixed ## fixed_index ## _C_VerifyRecoverInit, \ 1121 fixed ## fixed_index ## _C_VerifyRecover, \ 1122 fixed ## fixed_index ## _C_DigestEncryptUpdate, \ 1123 fixed ## fixed_index ## _C_DecryptDigestUpdate, \ 1124 fixed ## fixed_index ## _C_SignEncryptUpdate, \ 1125 fixed ## fixed_index ## _C_DecryptVerifyUpdate, \ 1126 fixed ## fixed_index ## _C_GenerateKey, \ 1127 fixed ## fixed_index ## _C_GenerateKeyPair, \ 1128 fixed ## fixed_index ## _C_WrapKey, \ 1129 fixed ## fixed_index ## _C_UnwrapKey, \ 1130 fixed ## fixed_index ## _C_DeriveKey, \ 1131 fixed ## fixed_index ## _C_SeedRandom, \ 1132 fixed ## fixed_index ## _C_GenerateRandom, \ 1133 short_C_GetFunctionStatus, \ 1134 short_C_CancelFunction, \ 1135 fixed ## fixed_index ## _C_WaitForSlotEvent \ 1136 } 1137 1138 #endif /* __P11_VIRTUAL_FIXED_H__ */ 1139