1 /* 2 * The Initial Developer of the Original Code is International 3 * Business Machines Corporation. Portions created by IBM 4 * Corporation are Copyright(C) 2005 International Business 5 * Machines Corporation. All Rights Reserved. 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the Common Public License as published by 9 * IBM Corporation; either version 1 of the License, or(at your option) 10 * any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * Common Public License for more details. 16 * 17 * You should have received a copy of the Common Public License 18 * along with this program; if not, a copy can be viewed at 19 * http://www.opensource.org/licenses/cpl1.0.php. 20 */ 21 22 /* (C) COPYRIGHT International Business Machines Corp. 2001, 2002, 2005 */ 23 /* 24 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28 #ifndef _TPMTOK_INT_H 29 #define _TPMTOK_INT_H 30 31 #include <stdio.h> 32 #include <pthread.h> 33 #include <string.h> 34 #include <strings.h> 35 #include <md5.h> 36 #include <sha1.h> 37 #include <limits.h> 38 #include <syslog.h> 39 #include <errno.h> 40 #include <sys/types.h> 41 #include <sys/stat.h> 42 #include <sys/param.h> 43 #include <sys/byteorder.h> 44 #include <security/cryptoki.h> 45 46 #include <tss/platform.h> 47 #include <tss/tss_defines.h> 48 #include <tss/tss_typedef.h> 49 #include <tss/tss_structs.h> 50 #include <tss/tspi.h> 51 52 #define VERSION_MAJOR 2 53 #define VERSION_MINOR 1 54 55 #define MAX_SESSION_COUNT 64 56 #define MAX_PIN_LEN 256 57 #define MIN_PIN_LEN 1 58 59 #define MAX_SLOT_ID 10 60 61 #ifndef MIN 62 #define MIN(a, b) ((a) < (b) ? (a) : (b)) 63 #endif 64 65 #define MODE_COPY (1 << 0) 66 #define MODE_CREATE (1 << 1) 67 #define MODE_KEYGEN (1 << 2) 68 #define MODE_MODIFY (1 << 3) 69 #define MODE_DERIVE (1 << 4) 70 #define MODE_UNWRAP (1 << 5) 71 72 // RSA block formatting types 73 // 74 #define PKCS_BT_1 1 75 #define PKCS_BT_2 2 76 77 #define OP_ENCRYPT_INIT 1 78 #define OP_DECRYPT_INIT 2 79 #define OP_WRAP 3 80 #define OP_UNWRAP 4 81 #define OP_SIGN_INIT 5 82 #define OP_VERIFY_INIT 6 83 84 enum { 85 STATE_INVALID = 0, 86 STATE_ENCR, 87 STATE_DECR, 88 STATE_DIGEST, 89 STATE_SIGN, 90 STATE_VERIFY 91 }; 92 93 #define SHA1_BLOCK_SIZE 64 94 #define SHA1_BLOCK_SIZE_MASK (SHA1_BLOCK_SIZE - 1) 95 96 #define RSA_BLOCK_SIZE 256 97 98 #ifndef PATH_MAX 99 #define PATH_MAX MAXPATHLEN 100 #endif 101 102 #ifndef PACK_DATA 103 #define PACK_DATA 104 #endif 105 106 #define MD5_BLOCK_SIZE 64 107 108 #define DSA_SIGNATURE_SIZE 40 109 110 #define DEFAULT_SO_PIN "87654321" 111 112 typedef enum { 113 ALL = 1, 114 PRIVATE, 115 PUBLIC 116 } SESS_OBJ_TYPE; 117 118 typedef struct _DL_NODE 119 { 120 struct _DL_NODE *next; 121 struct _DL_NODE *prev; 122 void *data; 123 } DL_NODE; 124 125 #define TOKEN_DATA_FILE "token.dat" 126 #define TOKEN_OBJ_DIR "objects" 127 #define TOKEN_OBJ_INDEX_FILE "obj.idx" 128 129 #define TPMTOK_UUID_INDEX_FILENAME "uuids.idx" 130 131 /* 132 * Filenames used to store migration data. 133 */ 134 #define SO_MAKEY_FILENAME "so_makey.dat" 135 #define USER_MAKEY_FILENAME "user_makey.dat" 136 #define SO_KEYBLOB_FILENAME "so_blob.dat" 137 #define USER_KEYBLOB_FILENAME "user_blob.dat" 138 139 #define __FUNCTION__ __func__ 140 141 // 142 // Both of the strings below have a length of 32 chars and must be 143 // padded with spaces, and non - null terminated. 144 // 145 #define PKW_CRYPTOKI_VERSION_MAJOR 2 146 #define PKW_CRYPTOKI_VERSION_MINOR 1 147 #define PKW_CRYPTOKI_MANUFACTURER "Sun Microsystems, Inc. " 148 #define PKW_CRYPTOKI_LIBDESC "PKCS#11 Interface for TPM " 149 #define PKW_CRYPTOKI_LIB_VERSION_MAJOR 1 150 #define PKW_CRYPTOKI_LIB_VERSION_MINOR 0 151 #define PKW_MAX_DEVICES 10 152 153 #define MAX_TOK_OBJS 2048 154 #define NUMBER_SLOTS_MANAGED 1 155 #define TPM_SLOTID 1 156 157 /* 158 * CKA_HIDDEN will be used to filter return results on 159 * a C_FindObjects call. Used for objects internal to the 160 * TPM token for management 161 */ 162 /* custom attributes for the TPM token */ 163 #define CKA_HIDDEN CKA_VENDOR_DEFINED + 0x01 164 #define CKA_IBM_OPAQUE CKA_VENDOR_DEFINED + 0x02 165 /* 166 * CKA_ENC_AUTHDATA will be used to store the encrypted SHA-1 167 * hashes of auth data passed in for TPM keys. The authdata 168 * will be encrypted using either the public 169 * leaf key or the private leaf key 170 */ 171 #define CKA_ENC_AUTHDATA CKA_VENDOR_DEFINED + 0x03 172 173 /* custom return codes for the TPM token */ 174 #define CKR_KEY_NOT_FOUND CKR_VENDOR_DEFINED + 0x01 175 #define CKR_FILE_NOT_FOUND CKR_VENDOR_DEFINED + 0x02 176 177 typedef struct { 178 CK_SLOT_ID slotID; 179 CK_SESSION_HANDLE sessionh; 180 } ST_SESSION_T; 181 182 typedef ST_SESSION_T ST_SESSION_HANDLE; 183 184 typedef struct { 185 void *Previous; 186 void *Next; 187 CK_SLOT_ID SltId; 188 CK_SESSION_HANDLE RealHandle; 189 } Session_Struct_t; 190 191 typedef Session_Struct_t *SessStructP; 192 193 typedef struct { 194 pid_t Pid; 195 pthread_mutex_t ProcMutex; 196 Session_Struct_t *SessListBeg; 197 Session_Struct_t *SessListEnd; 198 pthread_mutex_t SessListMutex; 199 } API_Proc_Struct_t; 200 201 202 203 204 enum { 205 PRF_DUMMYFUNCTION = 1, 206 PRF_FCVFUNCTION, 207 PRF_INITIALIZE, 208 PRF_FINALIZE, 209 PRF_GETINFO, 210 PRF_GETFUNCTIONLIST, 211 PRF_GETSLOTLIST, 212 PRF_GETSLOTINFO, 213 PRF_GETTOKENINFO, 214 PRF_GETMECHLIST, 215 PRF_GETMECHINFO, 216 PRF_INITTOKEN, 217 PRF_INITPIN, 218 PRF_SETPIN, 219 PRF_OPENSESSION, 220 PRF_CLOSESESSION, 221 PRF_CLOSEALLSESSIONS, 222 PRF_GETSESSIONINFO, 223 PRF_GETOPERATIONSTATE, 224 PRF_SETOPERATIONSTATE, 225 PRF_LOGIN, 226 PRF_LOGOUT, 227 PRF_CREATEOBJECT, 228 PRF_COPYOBJECT, 229 PRF_DESTROYOBJECT, 230 PRF_GETOBJECTSIZE, 231 PRF_GETATTRIBUTEVALUE, 232 PRF_SETATTRIBUTEVALUE, 233 PRF_FINDOBJECTSINIT, 234 PRF_FINDOBJECTS, 235 PRF_FINDOBJECTSFINAL, 236 PRF_ENCRYPTINIT, 237 PRF_ENCRYPT, 238 PRF_ENCRYPTUPDATE, 239 PRF_ENCRYPTFINAL, 240 PRF_DECRYPTINIT, 241 PRF_DECRYPT, 242 PRF_DECRYPTUPDATE, 243 PRF_DECRYPTFINAL, 244 PRF_DIGESTINIT, 245 PRF_DIGEST, 246 PRF_DIGESTUPDATE, 247 PRF_DIGESTKEY, 248 PRF_DIGESTFINAL, 249 PRF_SIGNINIT, 250 PRF_SIGN, 251 PRF_SIGNUPDATE, 252 PRF_SIGNFINAL, 253 PRF_SIGNRECOVERINIT, 254 PRF_SIGNRECOVER, 255 PRF_VERIFYINIT, 256 PRF_VERIFY, 257 PRF_VERIFYUPDATE, 258 PRF_VERIFYFINAL, 259 PRF_VERIFYRECOVERINIT, 260 PRF_VERIFYRECOVER, 261 PRF_GENKEY, 262 PRF_GENKEYPAIR, 263 PRF_WRAPKEY, 264 PRF_UNWRAPKEY, 265 PRF_DERIVEKEY, 266 PRF_GENRND, 267 PRF_LASTENTRY 268 }; 269 270 typedef struct _ENCR_DECR_CONTEXT 271 { 272 CK_OBJECT_HANDLE key; 273 CK_MECHANISM mech; 274 CK_BYTE *context; 275 CK_ULONG context_len; 276 CK_BBOOL multi; 277 CK_BBOOL active; 278 } ENCR_DECR_CONTEXT; 279 280 typedef struct _DIGEST_CONTEXT 281 { 282 CK_MECHANISM mech; 283 union { 284 MD5_CTX *md5ctx; 285 SHA1_CTX *sha1ctx; 286 void *ref; /* reference ptr for the union */ 287 } context; 288 CK_ULONG context_len; 289 CK_BBOOL multi; 290 CK_BBOOL active; 291 } DIGEST_CONTEXT; 292 293 typedef struct _SIGN_VERIFY_CONTEXT 294 { 295 CK_OBJECT_HANDLE key; 296 CK_MECHANISM mech; // current sign mechanism 297 void *context; // temporary work area 298 CK_ULONG context_len; 299 CK_BBOOL multi; // is this a multi - part operation? 300 CK_BBOOL recover; // are we in recover mode? 301 CK_BBOOL active; 302 } SIGN_VERIFY_CONTEXT; 303 304 typedef struct _SESSION 305 { 306 CK_SESSION_HANDLE handle; 307 CK_SESSION_INFO session_info; 308 309 CK_OBJECT_HANDLE *find_list; // array of CK_OBJECT_HANDLE 310 CK_ULONG find_count; // # handles in the list 311 CK_ULONG find_len; // max # of handles in the list 312 CK_ULONG find_idx; // current position 313 CK_BBOOL find_active; 314 315 ENCR_DECR_CONTEXT encr_ctx; 316 ENCR_DECR_CONTEXT decr_ctx; 317 DIGEST_CONTEXT digest_ctx; 318 SIGN_VERIFY_CONTEXT sign_ctx; 319 SIGN_VERIFY_CONTEXT verify_ctx; 320 321 TSS_HCONTEXT hContext; 322 } SESSION; 323 324 typedef struct _TEMPLATE 325 { 326 DL_NODE *attribute_list; 327 } TEMPLATE; 328 329 typedef struct _OBJECT 330 { 331 CK_OBJECT_CLASS class; 332 CK_BYTE name[8]; // for token objects 333 334 SESSION *session; // creator; only for session objects 335 TEMPLATE *template; 336 CK_ULONG count_hi; // only significant for token objects 337 CK_ULONG count_lo; // only significant for token objects 338 CK_ULONG index; 339 } OBJECT; 340 341 typedef struct _OBJECT_MAP 342 { 343 CK_OBJECT_HANDLE handle; 344 CK_BBOOL is_private; 345 CK_BBOOL is_session_obj; 346 SESSION *session; 347 OBJECT *ptr; 348 } OBJECT_MAP; 349 350 typedef struct _ATTRIBUTE_PARSE_LIST 351 { 352 CK_ATTRIBUTE_TYPE type; 353 void *ptr; 354 CK_ULONG len; 355 CK_BBOOL found; 356 } ATTRIBUTE_PARSE_LIST; 357 358 typedef struct _OP_STATE_DATA 359 { 360 CK_STATE session_state; 361 CK_ULONG active_operation; 362 CK_ULONG data_len; 363 } OP_STATE_DATA; 364 365 typedef struct _TWEAK_VEC 366 { 367 int allow_key_mods; 368 } TWEAK_VEC; 369 370 typedef struct _TOKEN_DATA 371 { 372 CK_TOKEN_INFO token_info; 373 CK_BYTE user_pin_sha[SHA1_DIGEST_LENGTH]; 374 CK_BYTE so_pin_sha[SHA1_DIGEST_LENGTH]; 375 CK_BYTE next_token_object_name[8]; 376 TWEAK_VEC tweak_vector; 377 } TOKEN_DATA; 378 379 typedef struct _RSA_DIGEST_CONTEXT { 380 DIGEST_CONTEXT hash_context; 381 CK_BBOOL flag; 382 } RSA_DIGEST_CONTEXT; 383 384 typedef struct _MECH_LIST_ELEMENT 385 { 386 CK_MECHANISM_TYPE mech_type; 387 CK_MECHANISM_INFO mech_info; 388 } MECH_LIST_ELEMENT; 389 390 struct mech_list_item; 391 392 struct mech_list_item { 393 struct mech_list_item *next; 394 MECH_LIST_ELEMENT element; 395 }; 396 397 struct mech_list_item * 398 find_mech_list_item_for_type(CK_MECHANISM_TYPE type, 399 struct mech_list_item *head); 400 401 typedef struct _TOK_OBJ_ENTRY 402 { 403 CK_BBOOL deleted; 404 char name[8]; 405 CK_ULONG count_lo; 406 CK_ULONG count_hi; 407 } TOK_OBJ_ENTRY; 408 409 typedef struct _LW_SHM_TYPE 410 { 411 pthread_mutex_t mutex; 412 TOKEN_DATA nv_token_data; 413 CK_ULONG num_priv_tok_obj; 414 CK_ULONG num_publ_tok_obj; 415 CK_BBOOL priv_loaded; 416 CK_BBOOL publ_loaded; 417 CK_BBOOL token_available; 418 TOK_OBJ_ENTRY publ_tok_objs[ MAX_TOK_OBJS ]; 419 TOK_OBJ_ENTRY priv_tok_objs[ MAX_TOK_OBJS ]; 420 } LW_SHM_TYPE; 421 422 typedef unsigned int CK_ULONG_32; 423 typedef CK_ULONG_32 CK_OBJECT_CLASS_32; 424 typedef CK_ULONG_32 CK_ATTRIBUTE_TYPE_32; 425 426 typedef struct CK_ATTRIBUTE_32 { 427 CK_ATTRIBUTE_TYPE_32 type; 428 CK_ULONG_32 pValue; 429 CK_ULONG_32 ulValueLen; 430 } CK_ATTRIBUTE_32; 431 432 char *get_tpm_keystore_path(); 433 434 struct messages { 435 char *msg; 436 }; 437 438 struct token_specific_struct { 439 CK_BYTE token_debug_tag[MAXPATHLEN]; 440 441 CK_RV (*t_init)(char *, CK_SLOT_ID, TSS_HCONTEXT *); 442 int (*t_slot2local)(); 443 444 CK_RV (*t_rng)(TSS_HCONTEXT, CK_BYTE *, CK_ULONG); 445 CK_RV (*t_session)(CK_SLOT_ID); 446 CK_RV (*t_final)(TSS_HCONTEXT); 447 CK_RV (*t_rsa_decrypt)(TSS_HCONTEXT, CK_BYTE *, 448 CK_ULONG, CK_BYTE *, CK_ULONG *, OBJECT *); 449 450 CK_RV (*t_rsa_encrypt)( 451 TSS_HCONTEXT, 452 CK_BYTE *, CK_ULONG, CK_BYTE *, 453 CK_ULONG *, OBJECT *); 454 455 CK_RV (*t_rsa_sign)(TSS_HCONTEXT, 456 CK_BYTE *, 457 CK_ULONG, 458 CK_BYTE *, 459 CK_ULONG *, 460 OBJECT *); 461 462 CK_RV (*t_rsa_verify)(TSS_HCONTEXT, 463 CK_BYTE *, 464 CK_ULONG, 465 CK_BYTE *, 466 CK_ULONG, 467 OBJECT *); 468 469 CK_RV (*t_rsa_generate_keypair)(TSS_HCONTEXT, TEMPLATE *, TEMPLATE *); 470 471 CK_RV (*t_sha_init)(DIGEST_CONTEXT *); 472 473 CK_RV (*t_sha_update)( 474 DIGEST_CONTEXT *, 475 CK_BYTE *, 476 CK_ULONG); 477 478 CK_RV (*t_sha_final)( 479 DIGEST_CONTEXT *, 480 CK_BYTE *, 481 CK_ULONG *); 482 CK_RV (*t_login)(TSS_HCONTEXT, CK_USER_TYPE, CK_BYTE *, CK_ULONG); 483 CK_RV (*t_logout)(TSS_HCONTEXT); 484 CK_RV (*t_init_pin)(TSS_HCONTEXT, CK_BYTE *, CK_ULONG); 485 CK_RV (*t_set_pin)(ST_SESSION_HANDLE, CK_BYTE *, 486 CK_ULONG, CK_BYTE *, CK_ULONG); 487 CK_RV (*t_verify_so_pin)(TSS_HCONTEXT, CK_BYTE *, CK_ULONG); 488 }; 489 490 typedef struct token_specific_struct token_spec_t; 491 492 /* 493 * Global Variables 494 */ 495 extern void copy_slot_info(CK_SLOT_ID, CK_SLOT_INFO_PTR); 496 497 extern struct messages err_msg[]; 498 499 extern token_spec_t token_specific; 500 extern CK_BBOOL initialized; 501 extern char *card_function_names[]; 502 extern char *total_function_names[]; 503 504 extern MECH_LIST_ELEMENT mech_list[]; 505 extern CK_ULONG mech_list_len; 506 507 extern pthread_mutex_t native_mutex; 508 509 extern void *xproclock; 510 511 extern pthread_mutex_t pkcs_mutex, obj_list_mutex, 512 sess_list_mutex, login_mutex; 513 514 extern DL_NODE *sess_list; 515 extern DL_NODE *sess_obj_list; 516 extern DL_NODE *publ_token_obj_list; 517 extern DL_NODE *priv_token_obj_list; 518 extern DL_NODE *object_map; 519 520 extern CK_BYTE so_pin_md5[MD5_DIGEST_LENGTH]; 521 extern CK_BYTE user_pin_md5[MD5_DIGEST_LENGTH]; 522 523 extern CK_BYTE default_user_pin_sha[SHA1_DIGEST_LENGTH]; 524 extern CK_BYTE default_so_pin_sha[SHA1_DIGEST_LENGTH]; 525 extern CK_BYTE default_so_pin_md5[MD5_DIGEST_LENGTH]; 526 527 extern LW_SHM_TYPE *global_shm; 528 529 extern TOKEN_DATA *nv_token_data; 530 531 extern CK_ULONG next_object_handle; 532 extern CK_ULONG next_session_handle; 533 534 extern CK_STATE global_login_state; 535 536 extern CK_BYTE ber_AlgIdRSAEncryption[]; 537 extern CK_ULONG ber_AlgIdRSAEncryptionLen; 538 extern CK_BYTE ber_rsaEncryption[]; 539 extern CK_ULONG ber_rsaEncryptionLen; 540 extern CK_BYTE ber_idDSA[]; 541 extern CK_ULONG ber_idDSALen; 542 543 extern CK_BYTE ber_md5WithRSAEncryption[]; 544 extern CK_ULONG ber_md5WithRSAEncryptionLen; 545 extern CK_BYTE ber_sha1WithRSAEncryption[]; 546 extern CK_ULONG ber_sha1WithRSAEncryptionLen; 547 extern CK_BYTE ber_AlgMd5[]; 548 extern CK_ULONG ber_AlgMd5Len; 549 extern CK_BYTE ber_AlgSha1[]; 550 extern CK_ULONG ber_AlgSha1Len; 551 552 extern CK_C_INITIALIZE_ARGS cinit_args; 553 554 /* 555 * Function Prototypes 556 */ 557 void *attach_shared_memory(); 558 void detach_shared_memory(char *); 559 560 int API_Initialized(); 561 void Terminate_All_Process_Sessions(); 562 int API_Register(); 563 void API_UnRegister(); 564 565 void CreateXProcLock(void *); 566 int XProcLock(void *); 567 int XProcUnLock(void *); 568 569 void loginit(); 570 void logterm(); 571 void logit(int, char *, ...); 572 void AddToSessionList(Session_Struct_t *); 573 void RemoveFromSessionList(Session_Struct_t *); 574 575 int Valid_Session(Session_Struct_t *, ST_SESSION_T *); 576 577 CK_BBOOL pin_expired(CK_SESSION_INFO *, CK_FLAGS); 578 CK_BBOOL pin_locked(CK_SESSION_INFO *, CK_FLAGS); 579 void set_login_flags(CK_USER_TYPE, CK_FLAGS *); 580 581 extern void init_slot_info(TOKEN_DATA *); 582 583 CK_RV update_migration_data(TSS_HCONTEXT, 584 TSS_HKEY, TSS_HKEY, char *, char *, BYTE *, BYTE *); 585 CK_RV token_rng(TSS_HCONTEXT, CK_BYTE *, CK_ULONG); 586 587 TSS_RESULT set_public_modulus(TSS_HCONTEXT, TSS_HKEY, 588 unsigned long, unsigned char *); 589 TSS_RESULT open_tss_context(TSS_HCONTEXT *); 590 CK_RV token_get_tpm_info(TSS_HCONTEXT, TOKEN_DATA *); 591 592 CK_RV clock_set_default_attributes(TEMPLATE *); 593 CK_RV clock_check_required_attributes(TEMPLATE *, CK_ULONG); 594 CK_RV clock_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 595 596 CK_RV counter_set_default_attributes(TEMPLATE *); 597 CK_RV counter_check_required_attributes(TEMPLATE *, CK_ULONG); 598 CK_RV counter_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 599 600 CK_RV compute_next_token_obj_name(CK_BYTE *, CK_BYTE *); 601 602 CK_RV save_token_object(TSS_HCONTEXT, OBJECT *); 603 CK_RV save_public_token_object(OBJECT *); 604 CK_RV save_private_token_object(TSS_HCONTEXT, OBJECT *); 605 606 CK_RV load_public_token_objects(void); 607 CK_RV load_private_token_objects(TSS_HCONTEXT); 608 609 CK_RV reload_token_object(TSS_HCONTEXT, OBJECT *); 610 611 CK_RV delete_token_object(OBJECT *); 612 613 CK_RV init_token_data(TSS_HCONTEXT, TOKEN_DATA *); 614 CK_RV load_token_data(TSS_HCONTEXT, TOKEN_DATA *); 615 CK_RV save_token_data(TOKEN_DATA *); 616 void copy_slot_info(CK_SLOT_ID, CK_SLOT_INFO_PTR); 617 618 CK_RV compute_sha(CK_BYTE *, CK_ULONG_32, CK_BYTE *); 619 620 CK_RV parity_is_odd(CK_BYTE); 621 622 CK_RV build_attribute(CK_ATTRIBUTE_TYPE, 623 CK_BYTE *, CK_ULONG, CK_ATTRIBUTE **); 624 625 CK_RV add_pkcs_padding(CK_BYTE *, UINT32, UINT32, UINT32); 626 627 CK_RV strip_pkcs_padding(CK_BYTE *, UINT32, UINT32 *); 628 629 CK_RV remove_leading_zeros(CK_ATTRIBUTE *); 630 631 CK_RV rsa_pkcs_encrypt( 632 SESSION *, 633 CK_BBOOL, 634 ENCR_DECR_CONTEXT *, 635 CK_BYTE *, 636 CK_ULONG, 637 CK_BYTE *, 638 CK_ULONG *); 639 640 CK_RV rsa_pkcs_decrypt(SESSION *, 641 CK_BBOOL, 642 ENCR_DECR_CONTEXT *, 643 CK_BYTE *, 644 CK_ULONG, 645 CK_BYTE *, 646 CK_ULONG *); 647 648 CK_RV rsa_pkcs_sign(SESSION *, 649 CK_BBOOL, 650 SIGN_VERIFY_CONTEXT *, 651 CK_BYTE *, 652 CK_ULONG, 653 CK_BYTE *, 654 CK_ULONG *); 655 656 CK_RV rsa_pkcs_verify(SESSION *, 657 SIGN_VERIFY_CONTEXT *, 658 CK_BYTE *, 659 CK_ULONG, 660 CK_BYTE *, 661 CK_ULONG); 662 663 CK_RV rsa_pkcs_verify_recover(SESSION *, 664 CK_BBOOL, 665 SIGN_VERIFY_CONTEXT *, 666 CK_BYTE *, 667 CK_ULONG, 668 CK_BYTE *, 669 CK_ULONG *); 670 671 CK_RV rsa_hash_pkcs_sign(SESSION *, 672 CK_BBOOL, 673 SIGN_VERIFY_CONTEXT *, 674 CK_BYTE *, 675 CK_ULONG, 676 CK_BYTE *, 677 CK_ULONG *); 678 679 CK_RV rsa_hash_pkcs_verify(SESSION *, 680 SIGN_VERIFY_CONTEXT *, 681 CK_BYTE *, 682 CK_ULONG, 683 CK_BYTE *, 684 CK_ULONG); 685 686 CK_RV rsa_hash_pkcs_sign_update(SESSION *, 687 SIGN_VERIFY_CONTEXT *, 688 CK_BYTE *, 689 CK_ULONG); 690 691 CK_RV rsa_hash_pkcs_verify_update(SESSION *, 692 SIGN_VERIFY_CONTEXT *, 693 CK_BYTE *, 694 CK_ULONG); 695 696 CK_RV rsa_hash_pkcs_sign_final(SESSION *, 697 CK_BBOOL, 698 SIGN_VERIFY_CONTEXT *, 699 CK_BYTE *, 700 CK_ULONG *); 701 702 CK_RV rsa_hash_pkcs_verify_final(SESSION *, 703 SIGN_VERIFY_CONTEXT *, 704 CK_BYTE *, 705 CK_ULONG); 706 707 708 CK_RV ckm_rsa_key_pair_gen(TSS_HCONTEXT, TEMPLATE *, TEMPLATE *); 709 710 CK_RV sha1_hash(SESSION *, CK_BBOOL, 711 DIGEST_CONTEXT *, 712 CK_BYTE *, CK_ULONG, 713 CK_BYTE *, CK_ULONG *); 714 715 CK_RV sha1_hmac_sign(SESSION *, CK_BBOOL, 716 SIGN_VERIFY_CONTEXT *, 717 CK_BYTE *, 718 CK_ULONG, 719 CK_BYTE *, 720 CK_ULONG *); 721 722 CK_RV sha1_hmac_verify(SESSION *, 723 SIGN_VERIFY_CONTEXT *, 724 CK_BYTE *, 725 CK_ULONG, 726 CK_BYTE *, 727 CK_ULONG); 728 729 CK_RV md5_hash(SESSION *, CK_BBOOL, 730 DIGEST_CONTEXT *, 731 CK_BYTE *, CK_ULONG, 732 CK_BYTE *, CK_ULONG *); 733 734 CK_RV md5_hmac_sign(SESSION *, CK_BBOOL, 735 SIGN_VERIFY_CONTEXT *, 736 CK_BYTE *, 737 CK_ULONG, 738 CK_BYTE *, 739 CK_ULONG *); 740 741 CK_RV md5_hmac_verify(SESSION *, 742 SIGN_VERIFY_CONTEXT *, 743 CK_BYTE *, 744 CK_ULONG, 745 CK_BYTE *, 746 CK_ULONG); 747 748 DL_NODE *dlist_add_as_first(DL_NODE *, void *); 749 DL_NODE *dlist_add_as_last(DL_NODE *, void *); 750 DL_NODE *dlist_find(DL_NODE *, void *); 751 DL_NODE *dlist_get_first(DL_NODE *); 752 DL_NODE *dlist_get_last(DL_NODE *); 753 CK_ULONG dlist_length(DL_NODE *); 754 DL_NODE *dlist_next(DL_NODE *); 755 DL_NODE *dlist_prev(DL_NODE *); 756 void dlist_purge(DL_NODE *); 757 DL_NODE *dlist_remove_node(DL_NODE *, DL_NODE *); 758 759 CK_RV attach_shm(void); 760 CK_RV detach_shm(void); 761 762 // encryption manager routines 763 // 764 CK_RV encr_mgr_init(SESSION *, 765 ENCR_DECR_CONTEXT *, 766 CK_ULONG, 767 CK_MECHANISM *, 768 CK_OBJECT_HANDLE); 769 770 CK_RV encr_mgr_cleanup(ENCR_DECR_CONTEXT *); 771 772 CK_RV encr_mgr_encrypt(SESSION *, CK_BBOOL, 773 ENCR_DECR_CONTEXT *, 774 CK_BYTE *, CK_ULONG, 775 CK_BYTE *, CK_ULONG *); 776 777 CK_RV decr_mgr_init(SESSION *, 778 ENCR_DECR_CONTEXT *, 779 CK_ULONG, 780 CK_MECHANISM *, 781 CK_OBJECT_HANDLE); 782 783 CK_RV decr_mgr_cleanup(ENCR_DECR_CONTEXT *); 784 785 CK_RV decr_mgr_decrypt(SESSION *, CK_BBOOL, 786 ENCR_DECR_CONTEXT *, 787 CK_BYTE *, CK_ULONG, 788 CK_BYTE *, CK_ULONG *); 789 790 CK_RV digest_mgr_cleanup(DIGEST_CONTEXT *); 791 792 CK_RV digest_mgr_init(SESSION *, 793 DIGEST_CONTEXT *, 794 CK_MECHANISM *); 795 796 CK_RV digest_mgr_digest(SESSION *, CK_BBOOL, 797 DIGEST_CONTEXT *, 798 CK_BYTE *, CK_ULONG, 799 CK_BYTE *, CK_ULONG *); 800 801 CK_RV digest_mgr_digest_update(SESSION *, 802 DIGEST_CONTEXT *, 803 CK_BYTE *, CK_ULONG); 804 805 CK_RV digest_mgr_digest_key(SESSION *, 806 DIGEST_CONTEXT *, 807 CK_OBJECT_HANDLE); 808 809 CK_RV digest_mgr_digest_final(SESSION *, 810 DIGEST_CONTEXT *, 811 CK_BYTE *, CK_ULONG *); 812 813 CK_RV key_mgr_generate_key_pair(SESSION *, 814 CK_MECHANISM *, 815 CK_ATTRIBUTE *, CK_ULONG, 816 CK_ATTRIBUTE *, CK_ULONG, 817 CK_OBJECT_HANDLE *, 818 CK_OBJECT_HANDLE *); 819 820 CK_RV key_mgr_wrap_key(SESSION *, 821 CK_BBOOL, 822 CK_MECHANISM *, 823 CK_OBJECT_HANDLE, 824 CK_OBJECT_HANDLE, 825 CK_BYTE *, 826 CK_ULONG *); 827 828 CK_RV key_mgr_unwrap_key(SESSION *, 829 CK_MECHANISM *, 830 CK_ATTRIBUTE *, 831 CK_ULONG, 832 CK_BYTE *, 833 CK_ULONG, 834 CK_OBJECT_HANDLE, 835 CK_OBJECT_HANDLE *); 836 837 CK_RV sign_mgr_init(SESSION *, 838 SIGN_VERIFY_CONTEXT *, 839 CK_MECHANISM *, 840 CK_BBOOL, 841 CK_OBJECT_HANDLE); 842 843 CK_RV sign_mgr_cleanup(SIGN_VERIFY_CONTEXT *); 844 845 CK_RV sign_mgr_sign(SESSION *, 846 CK_BBOOL, 847 SIGN_VERIFY_CONTEXT *, 848 CK_BYTE *, 849 CK_ULONG, 850 CK_BYTE *, 851 CK_ULONG *); 852 853 CK_RV sign_mgr_sign_recover(SESSION *, 854 CK_BBOOL, 855 SIGN_VERIFY_CONTEXT *, 856 CK_BYTE *, 857 CK_ULONG, 858 CK_BYTE *, 859 CK_ULONG *); 860 861 CK_RV sign_mgr_sign_final(SESSION *, 862 CK_BBOOL, 863 SIGN_VERIFY_CONTEXT *, 864 CK_BYTE *, 865 CK_ULONG *); 866 867 CK_RV sign_mgr_sign_update(SESSION *, 868 SIGN_VERIFY_CONTEXT *, 869 CK_BYTE *, 870 CK_ULONG); 871 872 CK_RV verify_mgr_init(SESSION *, 873 SIGN_VERIFY_CONTEXT *, 874 CK_MECHANISM *, 875 CK_BBOOL, 876 CK_OBJECT_HANDLE); 877 878 CK_RV verify_mgr_cleanup(SIGN_VERIFY_CONTEXT *); 879 880 CK_RV verify_mgr_verify(SESSION *, 881 SIGN_VERIFY_CONTEXT *, 882 CK_BYTE *, 883 CK_ULONG, 884 CK_BYTE *, 885 CK_ULONG); 886 887 CK_RV verify_mgr_verify_recover(SESSION *, 888 CK_BBOOL, 889 SIGN_VERIFY_CONTEXT *, 890 CK_BYTE *, 891 CK_ULONG, 892 CK_BYTE *, 893 CK_ULONG *); 894 895 CK_RV verify_mgr_verify_update(SESSION *, 896 SIGN_VERIFY_CONTEXT *, 897 CK_BYTE *, 898 CK_ULONG); 899 900 CK_RV verify_mgr_verify_final(SESSION *, 901 SIGN_VERIFY_CONTEXT *, 902 CK_BYTE *, 903 CK_ULONG); 904 905 906 // session manager routines 907 // 908 CK_RV session_mgr_close_all_sessions(void); 909 CK_RV session_mgr_close_session(SESSION *); 910 SESSION *session_mgr_find(CK_SESSION_HANDLE); 911 CK_RV session_mgr_login_all(CK_USER_TYPE); 912 CK_RV session_mgr_logout_all(void); 913 CK_RV session_mgr_new(CK_ULONG, SESSION **); 914 915 CK_BBOOL session_mgr_readonly_exists(void); 916 CK_BBOOL session_mgr_so_session_exists(void); 917 CK_BBOOL session_mgr_user_session_exists(void); 918 CK_BBOOL session_mgr_public_session_exists(void); 919 920 CK_RV session_mgr_get_op_state(SESSION *, CK_BBOOL, 921 CK_BYTE *, CK_ULONG *); 922 923 CK_RV session_mgr_set_op_state(SESSION *, 924 CK_OBJECT_HANDLE, CK_OBJECT_HANDLE, CK_BYTE *); 925 926 CK_RV object_mgr_add(SESSION *, 927 CK_ATTRIBUTE *, CK_ULONG, CK_OBJECT_HANDLE *); 928 929 CK_RV object_mgr_add_to_map(SESSION *, OBJECT *, CK_OBJECT_HANDLE *); 930 931 CK_RV object_mgr_add_to_shm(OBJECT *); 932 CK_RV object_mgr_del_from_shm(OBJECT *); 933 934 CK_RV object_mgr_copy(SESSION *, 935 CK_ATTRIBUTE *, CK_ULONG, CK_OBJECT_HANDLE, 936 CK_OBJECT_HANDLE *); 937 938 CK_RV object_mgr_create_final(SESSION *, 939 OBJECT *, CK_OBJECT_HANDLE *); 940 941 CK_RV object_mgr_create_skel(SESSION *, 942 CK_ATTRIBUTE *, CK_ULONG, CK_ULONG, 943 CK_ULONG, CK_ULONG, OBJECT **); 944 945 CK_RV object_mgr_destroy_object(SESSION *, CK_OBJECT_HANDLE); 946 947 CK_RV object_mgr_destroy_token_objects(TSS_HCONTEXT); 948 949 CK_RV object_mgr_find_in_map1(TSS_HCONTEXT, CK_OBJECT_HANDLE, OBJECT **); 950 951 CK_RV object_mgr_find_in_map2(TSS_HCONTEXT, OBJECT *, CK_OBJECT_HANDLE *); 952 953 CK_RV object_mgr_find_init(SESSION *, CK_ATTRIBUTE *, CK_ULONG); 954 955 CK_RV object_mgr_find_build_list(SESSION *, 956 CK_ATTRIBUTE *, 957 CK_ULONG, 958 DL_NODE *, 959 CK_BBOOL public_only); 960 961 CK_RV object_mgr_find_final(SESSION *); 962 963 CK_RV object_mgr_get_attribute_values(SESSION *, 964 CK_OBJECT_HANDLE, 965 CK_ATTRIBUTE *, 966 CK_ULONG); 967 968 CK_RV object_mgr_get_object_size(TSS_HCONTEXT, CK_OBJECT_HANDLE, 969 CK_ULONG *); 970 971 CK_BBOOL object_mgr_invalidate_handle1(CK_OBJECT_HANDLE handle); 972 973 CK_BBOOL object_mgr_invalidate_handle2(OBJECT *); 974 975 CK_BBOOL object_mgr_purge_session_objects(SESSION *, SESS_OBJ_TYPE); 976 977 CK_BBOOL object_mgr_purge_token_objects(TSS_HCONTEXT); 978 979 CK_BBOOL object_mgr_purge_private_token_objects(TSS_HCONTEXT); 980 981 CK_RV object_mgr_remove_from_map(CK_OBJECT_HANDLE); 982 983 CK_RV object_mgr_restore_obj(CK_BYTE *, OBJECT *); 984 985 CK_RV object_mgr_set_attribute_values(SESSION *, 986 CK_OBJECT_HANDLE, 987 CK_ATTRIBUTE *, 988 CK_ULONG); 989 990 CK_BBOOL object_mgr_purge_map(SESSION *, SESS_OBJ_TYPE); 991 992 CK_RV object_create(CK_ATTRIBUTE *, CK_ULONG, OBJECT **); 993 994 CK_RV object_create_skel(CK_ATTRIBUTE *, 995 CK_ULONG, 996 CK_ULONG, 997 CK_ULONG, 998 CK_ULONG, 999 OBJECT **); 1000 1001 CK_RV object_copy(CK_ATTRIBUTE *, 1002 CK_ULONG, 1003 OBJECT *, 1004 OBJECT **); 1005 1006 CK_RV object_flatten(OBJECT *, 1007 CK_BYTE **, 1008 CK_ULONG_32 *); 1009 1010 CK_BBOOL object_free(OBJECT *); 1011 1012 CK_RV object_get_attribute_values(OBJECT *, 1013 CK_ATTRIBUTE *, 1014 CK_ULONG); 1015 1016 CK_ULONG object_get_size(OBJECT *); 1017 1018 CK_RV object_restore(CK_BYTE *, 1019 OBJECT **, 1020 CK_BBOOL replace); 1021 1022 CK_RV object_set_attribute_values(OBJECT *, 1023 CK_ATTRIBUTE *, 1024 CK_ULONG); 1025 1026 CK_BBOOL object_is_modifiable(OBJECT *); 1027 CK_BBOOL object_is_private(OBJECT *); 1028 CK_BBOOL object_is_public(OBJECT *); 1029 CK_BBOOL object_is_token_object(OBJECT *); 1030 CK_BBOOL object_is_session_object(OBJECT *); 1031 1032 CK_BBOOL is_attribute_defined(CK_ATTRIBUTE_TYPE); 1033 1034 CK_RV template_add_attributes(TEMPLATE *, 1035 CK_ATTRIBUTE *, CK_ULONG); 1036 1037 CK_RV template_add_default_attributes(TEMPLATE *, 1038 CK_ULONG, 1039 CK_ULONG, 1040 CK_ULONG); 1041 1042 CK_BBOOL template_attribute_find(TEMPLATE *, 1043 CK_ATTRIBUTE_TYPE, CK_ATTRIBUTE **); 1044 1045 void template_attribute_find_multiple(TEMPLATE *, 1046 ATTRIBUTE_PARSE_LIST *, 1047 CK_ULONG); 1048 1049 CK_BBOOL template_check_exportability(TEMPLATE *, CK_ATTRIBUTE_TYPE type); 1050 1051 CK_RV template_check_required_attributes(TEMPLATE *, 1052 CK_ULONG, CK_ULONG, CK_ULONG); 1053 1054 CK_RV template_check_required_base_attributes(TEMPLATE *, 1055 CK_ULONG); 1056 1057 CK_BBOOL template_compare(CK_ATTRIBUTE *, 1058 CK_ULONG, TEMPLATE *); 1059 1060 CK_RV template_copy(TEMPLATE *, TEMPLATE *); 1061 1062 CK_RV template_flatten(TEMPLATE *, CK_BYTE *); 1063 1064 CK_RV template_free(TEMPLATE *); 1065 1066 CK_BBOOL template_get_class(TEMPLATE *, CK_ULONG *, CK_ULONG *); 1067 1068 CK_ULONG template_get_count(TEMPLATE *); 1069 1070 CK_ULONG template_get_size(TEMPLATE *); 1071 CK_ULONG template_get_compressed_size(TEMPLATE *); 1072 1073 CK_RV template_set_default_common_attributes(TEMPLATE *); 1074 1075 CK_RV template_merge(TEMPLATE *, TEMPLATE **); 1076 1077 CK_RV template_update_attribute(TEMPLATE *, CK_ATTRIBUTE *); 1078 1079 CK_RV template_unflatten(TEMPLATE **, CK_BYTE *, CK_ULONG); 1080 1081 CK_RV template_validate_attribute(TEMPLATE *, 1082 CK_ATTRIBUTE *, CK_ULONG, CK_ULONG, CK_ULONG); 1083 1084 CK_RV template_validate_attributes(TEMPLATE *, 1085 CK_ULONG, CK_ULONG, CK_ULONG); 1086 1087 CK_RV template_validate_base_attribute(TEMPLATE *, 1088 CK_ATTRIBUTE *, CK_ULONG); 1089 1090 1091 // DATA OBJECT ROUTINES 1092 // 1093 CK_RV data_object_check_required_attributes(TEMPLATE *, CK_ULONG); 1094 CK_RV data_object_set_default_attributes(TEMPLATE *, CK_ULONG); 1095 CK_RV data_object_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 1096 1097 // CERTIFICATE ROUTINES 1098 CK_RV cert_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 1099 1100 CK_RV cert_x509_check_required_attributes(TEMPLATE *, CK_ULONG); 1101 CK_RV cert_x509_set_default_attributes(TEMPLATE *, CK_ULONG); 1102 CK_RV cert_x509_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 1103 CK_RV cert_vendor_check_required_attributes(TEMPLATE *, CK_ULONG); 1104 CK_RV cert_vendor_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 1105 1106 // 1107 // KEY ROUTINES 1108 // 1109 CK_RV key_object_check_required_attributes(TEMPLATE *, CK_ULONG); 1110 CK_RV key_object_set_default_attributes(TEMPLATE *, CK_ULONG); 1111 CK_RV key_object_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 1112 1113 CK_RV publ_key_check_required_attributes(TEMPLATE *, CK_ULONG); 1114 CK_RV publ_key_set_default_attributes(TEMPLATE *, CK_ULONG); 1115 CK_RV publ_key_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 1116 1117 CK_RV priv_key_check_required_attributes(TEMPLATE *, CK_ULONG); 1118 CK_RV priv_key_set_default_attributes(TEMPLATE *, CK_ULONG); 1119 CK_RV priv_key_unwrap(TEMPLATE *, CK_ULONG, CK_BYTE *, CK_ULONG); 1120 CK_RV priv_key_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 1121 1122 CK_BBOOL secret_key_check_exportability(CK_ATTRIBUTE_TYPE type); 1123 CK_RV secret_key_check_required_attributes(TEMPLATE *, CK_ULONG); 1124 CK_RV secret_key_set_default_attributes(TEMPLATE *, CK_ULONG); 1125 CK_RV secret_key_unwrap(TEMPLATE *, CK_ULONG, CK_BYTE *, CK_ULONG, 1126 CK_BBOOL fromend); 1127 CK_RV secret_key_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, 1128 CK_ULONG); 1129 1130 // rsa routines 1131 // 1132 CK_RV rsa_publ_check_required_attributes(TEMPLATE *, CK_ULONG); 1133 CK_RV rsa_publ_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 1134 CK_RV rsa_publ_set_default_attributes(TEMPLATE *, CK_ULONG); 1135 CK_BBOOL rsa_priv_check_exportability(CK_ATTRIBUTE_TYPE type); 1136 CK_RV rsa_priv_check_required_attributes(TEMPLATE *, CK_ULONG); 1137 CK_RV rsa_priv_set_default_attributes(TEMPLATE *, CK_ULONG); 1138 CK_RV rsa_priv_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 1139 CK_RV rsa_priv_wrap_get_data(TEMPLATE *, CK_BBOOL, CK_BYTE **, CK_ULONG *); 1140 CK_RV rsa_priv_unwrap(TEMPLATE *, CK_BYTE *, CK_ULONG); 1141 1142 // Generic secret key routines 1143 CK_RV generic_secret_check_required_attributes(TEMPLATE *, CK_ULONG); 1144 CK_RV generic_secret_set_default_attributes(TEMPLATE *, CK_ULONG); 1145 CK_RV generic_secret_validate_attribute(TEMPLATE *, CK_ATTRIBUTE *, CK_ULONG); 1146 CK_RV generic_secret_wrap_get_data(TEMPLATE *, CK_BBOOL, 1147 CK_BYTE **, CK_ULONG *); 1148 1149 CK_RV generic_secret_unwrap(TEMPLATE *, CK_BYTE *, CK_ULONG, CK_BBOOL fromend); 1150 1151 CK_RV tpm_encrypt_data(TSS_HCONTEXT, 1152 TSS_HKEY, CK_BYTE *, CK_ULONG, CK_BYTE *, CK_ULONG *); 1153 1154 CK_RV tpm_decrypt_data(TSS_HCONTEXT, 1155 TSS_HKEY, CK_BYTE *, CK_ULONG, CK_BYTE *, CK_ULONG *); 1156 1157 CK_ULONG ber_encode_INTEGER(CK_BBOOL, 1158 CK_BYTE **, CK_ULONG *, CK_BYTE *, CK_ULONG); 1159 1160 CK_RV ber_decode_INTEGER(CK_BYTE *, 1161 CK_BYTE **, CK_ULONG *, CK_ULONG *); 1162 1163 CK_RV ber_encode_OCTET_STRING(CK_BBOOL, 1164 CK_BYTE **, CK_ULONG *, CK_BYTE *, CK_ULONG); 1165 1166 CK_RV ber_decode_OCTET_STRING(CK_BYTE *, 1167 CK_BYTE **, CK_ULONG *, CK_ULONG *); 1168 1169 CK_RV ber_encode_SEQUENCE(CK_BBOOL, 1170 CK_BYTE **, CK_ULONG *, CK_BYTE *, CK_ULONG); 1171 1172 CK_RV ber_decode_SEQUENCE(CK_BYTE *, 1173 CK_BYTE **, CK_ULONG *, CK_ULONG *); 1174 1175 CK_RV ber_encode_PrivateKeyInfo(CK_BBOOL, 1176 CK_BYTE **, CK_ULONG *, CK_BYTE *, 1177 CK_ULONG, CK_BYTE *, CK_ULONG); 1178 1179 CK_RV ber_decode_PrivateKeyInfo(CK_BYTE *, 1180 CK_ULONG, CK_BYTE **, CK_ULONG *, CK_BYTE **); 1181 1182 CK_RV ber_encode_RSAPrivateKey(CK_BBOOL, 1183 CK_BYTE **, CK_ULONG *, CK_ATTRIBUTE *, 1184 CK_ATTRIBUTE *, CK_ATTRIBUTE *, CK_ATTRIBUTE *, 1185 CK_ATTRIBUTE *, CK_ATTRIBUTE *, CK_ATTRIBUTE *, 1186 CK_ATTRIBUTE *); 1187 1188 CK_RV ber_decode_RSAPrivateKey(CK_BYTE *, 1189 CK_ULONG, CK_ATTRIBUTE **, CK_ATTRIBUTE **, 1190 CK_ATTRIBUTE **, CK_ATTRIBUTE **, CK_ATTRIBUTE **, 1191 CK_ATTRIBUTE **, CK_ATTRIBUTE **, CK_ATTRIBUTE **); 1192 1193 1194 CK_RV ber_encode_DSAPrivateKey(CK_BBOOL, 1195 CK_BYTE **, CK_ULONG *, CK_ATTRIBUTE *, 1196 CK_ATTRIBUTE *, CK_ATTRIBUTE *, CK_ATTRIBUTE *); 1197 1198 CK_RV ber_decode_DSAPrivateKey(CK_BYTE *, 1199 CK_ULONG, CK_ATTRIBUTE **, CK_ATTRIBUTE **, 1200 CK_ATTRIBUTE **, CK_ATTRIBUTE **); 1201 1202 #define APPID "TPM_STDLL" 1203 1204 /* log to stdout */ 1205 #define LogMessage(dest, priority, layer, fmt, ...) \ 1206 (void) fprintf(dest, "%s %s %s:%d " fmt "\n", (char *)priority, \ 1207 (char *)layer, (char *)__FILE__,\ 1208 (int)__LINE__, __VA_ARGS__); 1209 1210 #define LogMessage1(dest, priority, layer, data) \ 1211 (void) fprintf(dest, "%s %s %s:%d %s\n", priority, layer, __FILE__, \ 1212 __LINE__, data); 1213 1214 /* Debug logging */ 1215 #ifdef DEBUG 1216 #define LogDebug(fmt, ...) LogMessage(stdout, "LOG_DEBUG", APPID, \ 1217 fmt, __VA_ARGS__) 1218 1219 #define LogDebug1(data) LogMessage1(stdout, "LOG_DEBUG", APPID, data) 1220 1221 /* Error logging */ 1222 #define LogError(fmt, ...) LogMessage(stderr, "LOG_ERR", APPID,\ 1223 "ERROR: " fmt, __VA_ARGS__) 1224 1225 #define LogError1(data) LogMessage1(stderr, "LOG_ERR", APPID,\ 1226 "ERROR: " data) 1227 1228 /* Warn logging */ 1229 #define LogWarn(fmt, ...) LogMessage(stdout, "LOG_WARNING", APPID,\ 1230 "WARNING: " fmt, __VA_ARGS__) 1231 1232 #define LogWarn1(data) LogMessage1(stdout, "LOG_WARNING", APPID,\ 1233 "WARNING: " data) 1234 1235 /* Info Logging */ 1236 #define LogInfo(fmt, ...) LogMessage(stdout, "LOG_INFO", APPID,\ 1237 fmt, __VA_ARGS__) 1238 1239 #define LogInfo1(data) LogMessage1(stdout, "LOG_INFO", APPID, data) 1240 1241 #define st_err_log(...) LogMessage(stderr, "ST MSG", APPID,\ 1242 "", __VA_ARGS__) 1243 #else 1244 #define LogDebug(...) 1245 #define LogDebug1(...) 1246 #define LogBlob(...) 1247 #define LogError(...) 1248 #define LogError1(...) 1249 #define LogWarn(...) 1250 #define LogWarn1(...) 1251 #define LogInfo(...) 1252 #define LogInfo1(...) 1253 #define st_err_log(...) 1254 #endif 1255 1256 /* 1257 * CK_FUNCTION_LIST is a structure holding a Cryptoki spec 1258 * version and pointers of appropriate types to all the 1259 * Cryptoki functions 1260 */ 1261 1262 /* CK_FUNCTION_LIST is new for v2.0 */ 1263 1264 typedef CK_RV 1265 (CK_PTR ST_C_Initialize) 1266 (void *ppFunctionList, CK_SLOT_ID slotID, CK_CHAR_PTR pCorrelator); 1267 typedef CK_RV 1268 (CK_PTR ST_C_Finalize) 1269 (CK_VOID_PTR pReserved); 1270 typedef CK_RV 1271 (CK_PTR ST_C_Terminate)(); 1272 typedef CK_RV 1273 (CK_PTR ST_C_GetInfo) 1274 (CK_INFO_PTR pInfo); 1275 typedef CK_RV 1276 (CK_PTR ST_C_GetFunctionList) 1277 (CK_FUNCTION_LIST_PTR_PTR ppFunctionList); 1278 typedef CK_RV 1279 (CK_PTR ST_C_GetSlotList) 1280 (CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList, 1281 CK_ULONG_PTR pusCount); 1282 typedef CK_RV 1283 (CK_PTR ST_C_GetSlotInfo) 1284 (CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo); 1285 typedef CK_RV 1286 (CK_PTR ST_C_GetTokenInfo) 1287 (CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo); 1288 typedef CK_RV 1289 (CK_PTR ST_C_GetMechanismList) 1290 (CK_SLOT_ID slotID, CK_MECHANISM_TYPE_PTR pMechanismList, 1291 CK_ULONG_PTR pusCount); 1292 typedef CK_RV 1293 (CK_PTR ST_C_GetMechanismInfo) 1294 (CK_SLOT_ID slotID, CK_MECHANISM_TYPE type, 1295 CK_MECHANISM_INFO_PTR pInfo); 1296 typedef CK_RV 1297 (CK_PTR ST_C_InitToken) 1298 (CK_SLOT_ID slotID, CK_CHAR_PTR pPin, CK_ULONG usPinLen, 1299 CK_CHAR_PTR pLabel); 1300 typedef CK_RV 1301 (CK_PTR ST_C_InitPIN) 1302 (ST_SESSION_T hSession, CK_CHAR_PTR pPin, 1303 CK_ULONG usPinLen); 1304 typedef CK_RV 1305 (CK_PTR ST_C_SetPIN) 1306 (ST_SESSION_T hSession, CK_CHAR_PTR pOldPin, 1307 CK_ULONG usOldLen, CK_CHAR_PTR pNewPin, 1308 CK_ULONG usNewLen); 1309 1310 typedef CK_RV 1311 (CK_PTR ST_C_OpenSession) 1312 (CK_SLOT_ID slotID, CK_FLAGS flags, 1313 CK_SESSION_HANDLE_PTR phSession); 1314 1315 typedef CK_RV 1316 (CK_PTR ST_C_CloseSession) 1317 (ST_SESSION_T hSession); 1318 typedef CK_RV 1319 (CK_PTR ST_C_CloseAllSessions) 1320 (CK_SLOT_ID slotID); 1321 typedef CK_RV 1322 (CK_PTR ST_C_GetSessionInfo) 1323 (ST_SESSION_T hSession, CK_SESSION_INFO_PTR pInfo); 1324 typedef CK_RV 1325 (CK_PTR ST_C_GetOperationState) 1326 (ST_SESSION_T hSession, CK_BYTE_PTR pOperationState, 1327 CK_ULONG_PTR pulOperationStateLen); 1328 typedef CK_RV 1329 (CK_PTR ST_C_SetOperationState) 1330 (ST_SESSION_T hSession, CK_BYTE_PTR pOperationState, 1331 CK_ULONG ulOperationStateLen, 1332 CK_OBJECT_HANDLE hEncryptionKey, 1333 CK_OBJECT_HANDLE hAuthenticationKey); 1334 typedef CK_RV 1335 (CK_PTR ST_C_Login)(ST_SESSION_T hSession, 1336 CK_USER_TYPE userType, CK_CHAR_PTR pPin, 1337 CK_ULONG usPinLen); 1338 typedef CK_RV 1339 (CK_PTR ST_C_Logout)(ST_SESSION_T hSession); 1340 typedef CK_RV 1341 (CK_PTR ST_C_CreateObject) 1342 (ST_SESSION_T hSession, CK_ATTRIBUTE_PTR pTemplate, 1343 CK_ULONG usCount, CK_OBJECT_HANDLE_PTR phObject); 1344 1345 typedef CK_RV 1346 (CK_PTR ST_C_CopyObject) 1347 (ST_SESSION_T hSession, CK_OBJECT_HANDLE hObject, 1348 CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount, 1349 CK_OBJECT_HANDLE_PTR phNewObject); 1350 typedef CK_RV 1351 (CK_PTR ST_C_DestroyObject) 1352 (ST_SESSION_T hSession, CK_OBJECT_HANDLE hObject); 1353 typedef CK_RV 1354 (CK_PTR ST_C_GetObjectSize) 1355 (ST_SESSION_T hSession, CK_OBJECT_HANDLE hObject, 1356 CK_ULONG_PTR pusSize); 1357 typedef CK_RV 1358 (CK_PTR ST_C_GetAttributeValue) 1359 (ST_SESSION_T hSession, CK_OBJECT_HANDLE hObject, 1360 CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount); 1361 typedef CK_RV 1362 (CK_PTR ST_C_SetAttributeValue) 1363 (ST_SESSION_T hSession, CK_OBJECT_HANDLE hObject, 1364 CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount); 1365 typedef CK_RV 1366 (CK_PTR ST_C_FindObjectsInit) 1367 (ST_SESSION_T hSession, CK_ATTRIBUTE_PTR pTemplate, 1368 CK_ULONG usCount); 1369 typedef CK_RV 1370 (CK_PTR ST_C_FindObjects) 1371 (ST_SESSION_T hSession, 1372 CK_OBJECT_HANDLE_PTR phObject, CK_ULONG usMaxObjectCount, 1373 CK_ULONG_PTR pusObjectCount); 1374 typedef CK_RV 1375 (CK_PTR ST_C_FindObjectsFinal) 1376 (ST_SESSION_T hSession); 1377 typedef CK_RV 1378 (CK_PTR ST_C_EncryptInit) 1379 (ST_SESSION_T hSession, CK_MECHANISM_PTR pMechanism, 1380 CK_OBJECT_HANDLE hKey); 1381 typedef CK_RV 1382 (CK_PTR ST_C_Encrypt) 1383 (ST_SESSION_T hSession, CK_BYTE_PTR pData, 1384 CK_ULONG usDataLen, CK_BYTE_PTR pEncryptedData, 1385 CK_ULONG_PTR pusEncryptedDataLen); 1386 typedef CK_RV 1387 (CK_PTR ST_C_EncryptUpdate) 1388 (ST_SESSION_T hSession, CK_BYTE_PTR pPart, 1389 CK_ULONG usPartLen, CK_BYTE_PTR pEncryptedPart, 1390 CK_ULONG_PTR pusEncryptedPartLen); 1391 typedef CK_RV 1392 (CK_PTR ST_C_EncryptFinal) 1393 (ST_SESSION_T hSession, 1394 CK_BYTE_PTR pLastEncryptedPart, 1395 CK_ULONG_PTR pusLastEncryptedPartLen); 1396 typedef CK_RV 1397 (CK_PTR ST_C_DecryptInit) 1398 (ST_SESSION_T hSession, CK_MECHANISM_PTR pMechanism, 1399 CK_OBJECT_HANDLE hKey); 1400 typedef CK_RV 1401 (CK_PTR ST_C_Decrypt) 1402 (ST_SESSION_T hSession, CK_BYTE_PTR pEncryptedData, 1403 CK_ULONG usEncryptedDataLen, CK_BYTE_PTR pData, 1404 CK_ULONG_PTR pusDataLen); 1405 typedef CK_RV 1406 (CK_PTR ST_C_DecryptUpdate) 1407 (ST_SESSION_T hSession, CK_BYTE_PTR pEncryptedPart, 1408 CK_ULONG usEncryptedPartLen, CK_BYTE_PTR pPart, 1409 CK_ULONG_PTR pusPartLen); 1410 typedef CK_RV 1411 (CK_PTR ST_C_DecryptFinal) 1412 (ST_SESSION_T hSession, CK_BYTE_PTR pLastPart, 1413 CK_ULONG_PTR pusLastPartLen); 1414 typedef CK_RV 1415 (CK_PTR ST_C_DigestInit) 1416 (ST_SESSION_T hSession, 1417 CK_MECHANISM_PTR pMechanism); 1418 typedef CK_RV 1419 (CK_PTR ST_C_Digest) 1420 (ST_SESSION_T hSession, CK_BYTE_PTR pData, 1421 CK_ULONG usDataLen, CK_BYTE_PTR pDigest, 1422 CK_ULONG_PTR pusDigestLen); 1423 typedef CK_RV 1424 (CK_PTR ST_C_DigestUpdate) 1425 (ST_SESSION_T hSession, CK_BYTE_PTR pPart, 1426 CK_ULONG usPartLen); 1427 typedef CK_RV 1428 (CK_PTR ST_C_DigestKey) 1429 (ST_SESSION_T hSession, CK_OBJECT_HANDLE hKey); 1430 typedef CK_RV 1431 (CK_PTR ST_C_DigestFinal) 1432 (ST_SESSION_T hSession, CK_BYTE_PTR pDigest, 1433 CK_ULONG_PTR pusDigestLen); 1434 typedef CK_RV 1435 (CK_PTR ST_C_SignInit) 1436 (ST_SESSION_T hSession, CK_MECHANISM_PTR pMechanism, 1437 CK_OBJECT_HANDLE hKey); 1438 typedef CK_RV 1439 (CK_PTR ST_C_Sign) 1440 (ST_SESSION_T hSession, CK_BYTE_PTR pData, 1441 CK_ULONG usDataLen, CK_BYTE_PTR pSignature, 1442 CK_ULONG_PTR pusSignatureLen); 1443 typedef CK_RV 1444 (CK_PTR ST_C_SignUpdate) 1445 (ST_SESSION_T hSession, CK_BYTE_PTR pPart, 1446 CK_ULONG usPartLen); 1447 typedef CK_RV 1448 (CK_PTR ST_C_SignFinal) 1449 (ST_SESSION_T hSession, CK_BYTE_PTR pSignature, 1450 CK_ULONG_PTR pusSignatureLen); 1451 typedef CK_RV 1452 (CK_PTR ST_C_SignRecoverInit) 1453 (ST_SESSION_T hSession, CK_MECHANISM_PTR pMechanism, 1454 CK_OBJECT_HANDLE hKey); 1455 typedef CK_RV 1456 (CK_PTR ST_C_SignRecover) 1457 (ST_SESSION_T hSession, CK_BYTE_PTR pData, 1458 CK_ULONG usDataLen, CK_BYTE_PTR pSignature, 1459 CK_ULONG_PTR pusSignatureLen); 1460 typedef CK_RV 1461 (CK_PTR ST_C_VerifyInit) 1462 (ST_SESSION_T hSession, CK_MECHANISM_PTR pMechanism, 1463 CK_OBJECT_HANDLE hKey); 1464 typedef CK_RV 1465 (CK_PTR ST_C_Verify) 1466 (ST_SESSION_T hSession, CK_BYTE_PTR pData, 1467 CK_ULONG usDataLen, CK_BYTE_PTR pSignature, 1468 CK_ULONG usSignatureLen); 1469 typedef CK_RV 1470 (CK_PTR ST_C_VerifyUpdate) 1471 (ST_SESSION_T hSession, CK_BYTE_PTR pPart, 1472 CK_ULONG usPartLen); 1473 typedef CK_RV 1474 (CK_PTR ST_C_VerifyFinal) 1475 (ST_SESSION_T hSession, CK_BYTE_PTR pSignature, 1476 CK_ULONG usSignatureLen); 1477 typedef CK_RV 1478 (CK_PTR ST_C_VerifyRecoverInit) 1479 (ST_SESSION_T hSession, CK_MECHANISM_PTR pMechanism, 1480 CK_OBJECT_HANDLE hKey); 1481 typedef CK_RV 1482 (CK_PTR ST_C_VerifyRecover) 1483 (ST_SESSION_T hSession, CK_BYTE_PTR pSignature, 1484 CK_ULONG usSignatureLen, CK_BYTE_PTR pData, 1485 CK_ULONG_PTR pusDataLen); 1486 typedef CK_RV 1487 (CK_PTR ST_C_DigestEncryptUpdate) 1488 (ST_SESSION_T hSession, CK_BYTE_PTR pPart, 1489 CK_ULONG ulPartLen, CK_BYTE_PTR pEncryptedPart, 1490 CK_ULONG_PTR pulEncryptedPartLen); 1491 typedef CK_RV 1492 (CK_PTR ST_C_DecryptDigestUpdate) 1493 (ST_SESSION_T hSession, CK_BYTE_PTR pEncryptedPart, 1494 CK_ULONG ulEncryptedPartLen, CK_BYTE_PTR pPart, 1495 CK_ULONG_PTR pulPartLen); 1496 typedef CK_RV 1497 (CK_PTR ST_C_SignEncryptUpdate) 1498 (ST_SESSION_T hSession, CK_BYTE_PTR pPart, 1499 CK_ULONG ulPartLen, CK_BYTE_PTR pEncryptedPart, 1500 CK_ULONG_PTR pulEncryptedPartLen); 1501 typedef CK_RV 1502 (CK_PTR ST_C_DecryptVerifyUpdate) 1503 (ST_SESSION_T hSession, CK_BYTE_PTR pEncryptedPart, 1504 CK_ULONG ulEncryptedPartLen, CK_BYTE_PTR pPart, 1505 CK_ULONG_PTR pulPartLen); 1506 typedef CK_RV 1507 (CK_PTR ST_C_GenerateKey) 1508 (ST_SESSION_T hSession, CK_MECHANISM_PTR pMechanism, 1509 CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount, 1510 CK_OBJECT_HANDLE_PTR phKey); 1511 typedef CK_RV 1512 (CK_PTR ST_C_GenerateKeyPair) 1513 (ST_SESSION_T hSession, CK_MECHANISM_PTR pMechanism, 1514 CK_ATTRIBUTE_PTR pPublicKeyTemplate, 1515 CK_ULONG usPublicKeyAttributeCount, 1516 CK_ATTRIBUTE_PTR pPrivateKeyTemplate, 1517 CK_ULONG usPrivateKeyAttributeCount, 1518 CK_OBJECT_HANDLE_PTR phPrivateKey, 1519 CK_OBJECT_HANDLE_PTR phPublicKey); 1520 typedef CK_RV 1521 (CK_PTR ST_C_WrapKey) 1522 (ST_SESSION_T hSession, CK_MECHANISM_PTR pMechanism, 1523 CK_OBJECT_HANDLE hWrappingKey, CK_OBJECT_HANDLE hKey, 1524 CK_BYTE_PTR pWrappedKey, CK_ULONG_PTR pusWrappedKeyLen); 1525 typedef CK_RV 1526 (CK_PTR ST_C_UnwrapKey) 1527 (ST_SESSION_T hSession, CK_MECHANISM_PTR pMechanism, 1528 CK_OBJECT_HANDLE hUnwrappingKey, CK_BYTE_PTR pWrappedKey, 1529 CK_ULONG usWrappedKeyLen, CK_ATTRIBUTE_PTR pTemplate, 1530 CK_ULONG usAttributeCount, CK_OBJECT_HANDLE_PTR phKey); 1531 typedef CK_RV 1532 (CK_PTR ST_C_DeriveKey) 1533 (ST_SESSION_T hSession, CK_MECHANISM_PTR pMechanism, 1534 CK_OBJECT_HANDLE hBaseKey, CK_ATTRIBUTE_PTR pTemplate, 1535 CK_ULONG usAttributeCount, CK_OBJECT_HANDLE_PTR phKey); 1536 typedef CK_RV 1537 (CK_PTR ST_C_SeedRandom) 1538 (ST_SESSION_T hSession, CK_BYTE_PTR pSeed, 1539 CK_ULONG usSeedLen); 1540 typedef CK_RV 1541 (CK_PTR ST_C_GenerateRandom) 1542 (ST_SESSION_T hSession, CK_BYTE_PTR pRandomData, 1543 CK_ULONG usRandomLen); 1544 typedef CK_RV 1545 (CK_PTR ST_C_GetFunctionStatus) 1546 (ST_SESSION_T hSession); 1547 typedef CK_RV 1548 (CK_PTR ST_C_CancelFunction) 1549 (ST_SESSION_T hSession); 1550 typedef CK_RV 1551 (CK_PTR ST_Notify) 1552 (ST_SESSION_T hSession, CK_NOTIFICATION event, 1553 CK_VOID_PTR pApplication); 1554 typedef CK_RV 1555 (CK_PTR ST_C_WaitForSlotEvent) 1556 (CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, 1557 CK_VOID_PTR pReserved); 1558 1559 1560 1561 struct ST_FCN_LIST { 1562 1563 ST_C_Initialize ST_Initialize; 1564 ST_C_Finalize ST_Finalize; 1565 1566 ST_C_GetTokenInfo ST_GetTokenInfo; 1567 ST_C_GetMechanismList ST_GetMechanismList; 1568 ST_C_GetMechanismInfo ST_GetMechanismInfo; 1569 ST_C_InitToken ST_InitToken; 1570 ST_C_InitPIN ST_InitPIN; 1571 ST_C_SetPIN ST_SetPIN; 1572 1573 ST_C_OpenSession ST_OpenSession; 1574 ST_C_CloseSession ST_CloseSession; 1575 ST_C_GetSessionInfo ST_GetSessionInfo; 1576 ST_C_GetOperationState ST_GetOperationState; 1577 ST_C_SetOperationState ST_SetOperationState; 1578 ST_C_Login ST_Login; 1579 ST_C_Logout ST_Logout; 1580 1581 ST_C_CreateObject ST_CreateObject; 1582 ST_C_CopyObject ST_CopyObject; 1583 ST_C_DestroyObject ST_DestroyObject; 1584 ST_C_GetObjectSize ST_GetObjectSize; 1585 ST_C_GetAttributeValue ST_GetAttributeValue; 1586 ST_C_SetAttributeValue ST_SetAttributeValue; 1587 ST_C_FindObjectsInit ST_FindObjectsInit; 1588 ST_C_FindObjects ST_FindObjects; 1589 ST_C_FindObjectsFinal ST_FindObjectsFinal; 1590 1591 1592 ST_C_EncryptInit ST_EncryptInit; 1593 ST_C_Encrypt ST_Encrypt; 1594 ST_C_EncryptUpdate ST_EncryptUpdate; 1595 ST_C_EncryptFinal ST_EncryptFinal; 1596 ST_C_DecryptInit ST_DecryptInit; 1597 ST_C_Decrypt ST_Decrypt; 1598 ST_C_DecryptUpdate ST_DecryptUpdate; 1599 ST_C_DecryptFinal ST_DecryptFinal; 1600 ST_C_DigestInit ST_DigestInit; 1601 ST_C_Digest ST_Digest; 1602 ST_C_DigestUpdate ST_DigestUpdate; 1603 ST_C_DigestKey ST_DigestKey; 1604 ST_C_DigestFinal ST_DigestFinal; 1605 ST_C_SignInit ST_SignInit; 1606 ST_C_Sign ST_Sign; 1607 ST_C_SignUpdate ST_SignUpdate; 1608 ST_C_SignFinal ST_SignFinal; 1609 ST_C_SignRecoverInit ST_SignRecoverInit; 1610 ST_C_SignRecover ST_SignRecover; 1611 ST_C_VerifyInit ST_VerifyInit; 1612 ST_C_Verify ST_Verify; 1613 ST_C_VerifyUpdate ST_VerifyUpdate; 1614 ST_C_VerifyFinal ST_VerifyFinal; 1615 ST_C_VerifyRecoverInit ST_VerifyRecoverInit; 1616 ST_C_VerifyRecover ST_VerifyRecover; 1617 ST_C_DigestEncryptUpdate ST_DigestEncryptUpdate; 1618 ST_C_DecryptDigestUpdate ST_DecryptDigestUpdate; 1619 ST_C_SignEncryptUpdate ST_SignEncryptUpdate; 1620 ST_C_DecryptVerifyUpdate ST_DecryptVerifyUpdate; 1621 ST_C_GenerateKey ST_GenerateKey; 1622 ST_C_GenerateKeyPair ST_GenerateKeyPair; 1623 ST_C_WrapKey ST_WrapKey; 1624 ST_C_UnwrapKey ST_UnwrapKey; 1625 ST_C_DeriveKey ST_DeriveKey; 1626 ST_C_SeedRandom ST_SeedRandom; 1627 ST_C_GenerateRandom ST_GenerateRandom; 1628 ST_C_GetFunctionStatus ST_GetFunctionStatus; 1629 ST_C_CancelFunction ST_CancelFunction; 1630 }; 1631 1632 typedef struct ST_FCN_LIST STDLL_FcnList_t; 1633 1634 #endif /* _TPMTOK_INT_H */