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