comparison nss/lib/pk11wrap/debug_module.c @ 0:1e5118fa0cb1

This is NSS with a Cmake Buildsyste To compile a static NSS library for Windows we've used the Chromium-NSS fork and added a Cmake buildsystem to compile it statically for Windows. See README.chromium for chromium changes and README.trustbridge for our modifications.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 28 Jul 2014 10:47:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e5118fa0cb1
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #include "prlog.h"
5 #include <stdio.h>
6 #include "cert.h" /* for CERT_DerNameToAscii & CERT_Hexify */
7
8 static PRLogModuleInfo *modlog = NULL;
9
10 static CK_FUNCTION_LIST_PTR module_functions;
11
12 static CK_FUNCTION_LIST debug_functions;
13
14 static void print_final_statistics(void);
15
16 #define STRING static const char
17
18 STRING fmt_flags[] = " flags = 0x%x";
19 STRING fmt_hKey[] = " hKey = 0x%x";
20 STRING fmt_hObject[] = " hObject = 0x%x";
21 STRING fmt_hSession[] = " hSession = 0x%x";
22 STRING fmt_manufacturerID[] = " manufacturerID = \"%.32s\"";
23 STRING fmt_pData[] = " pData = 0x%p";
24 STRING fmt_pDigest[] = " pDigest = 0x%p";
25 STRING fmt_pEncryptedData[] = " pEncryptedData = 0x%p";
26 STRING fmt_pEncryptedPart[] = " pEncryptedPart = 0x%p";
27 STRING fmt_pInfo[] = " pInfo = 0x%p";
28 STRING fmt_pMechanism[] = " pMechanism = 0x%p";
29 STRING fmt_pOperationState[] = " pOperationState = 0x%p";
30 STRING fmt_pPart[] = " pPart = 0x%p";
31 STRING fmt_pPin[] = " pPin = 0x%p";
32 STRING fmt_pSignature[] = " pSignature = 0x%p";
33 STRING fmt_pTemplate[] = " pTemplate = 0x%p";
34 STRING fmt_pWrappedKey[] = " pWrappedKey = 0x%p";
35 STRING fmt_phKey[] = " phKey = 0x%p";
36 STRING fmt_phObject[] = " phObject = 0x%p";
37 STRING fmt_pulCount[] = " pulCount = 0x%p";
38 STRING fmt_pulDataLen[] = " pulDataLen = 0x%p";
39 STRING fmt_pulDigestLen[] = " pulDigestLen = 0x%p";
40 STRING fmt_pulEncryptedPartLen[] = " pulEncryptedPartLen = 0x%p";
41 STRING fmt_pulPartLen[] = " pulPartLen = 0x%p";
42 STRING fmt_pulSignatureLen[] = " pulSignatureLen = 0x%p";
43 STRING fmt_slotID[] = " slotID = 0x%x";
44 STRING fmt_sphKey[] = " *phKey = 0x%x";
45 STRING fmt_spulCount[] = " *pulCount = 0x%x";
46 STRING fmt_spulDataLen[] = " *pulDataLen = 0x%x";
47 STRING fmt_spulDigestLen[] = " *pulDigestLen = 0x%x";
48 STRING fmt_spulEncryptedPartLen[] = " *pulEncryptedPartLen = 0x%x";
49 STRING fmt_spulPartLen[] = " *pulPartLen = 0x%x";
50 STRING fmt_spulSignatureLen[] = " *pulSignatureLen = 0x%x";
51 STRING fmt_ulAttributeCount[] = " ulAttributeCount = %d";
52 STRING fmt_ulCount[] = " ulCount = %d";
53 STRING fmt_ulDataLen[] = " ulDataLen = %d";
54 STRING fmt_ulEncryptedPartLen[] = " ulEncryptedPartLen = %d";
55 STRING fmt_ulPartLen[] = " ulPartLen = %d";
56 STRING fmt_ulPinLen[] = " ulPinLen = %d";
57 STRING fmt_ulSignatureLen[] = " ulSignatureLen = %d";
58
59 STRING fmt_fwVersion[] = " firmware version: %d.%d";
60 STRING fmt_hwVersion[] = " hardware version: %d.%d";
61 STRING fmt_s_qsq_d[] = " %s = \"%s\" [%d]";
62 STRING fmt_s_s_d[] = " %s = %s [%d]";
63 STRING fmt_s_lu[] = " %s = %lu";
64 STRING fmt_invalid_handle[] = " (CK_INVALID_HANDLE)";
65
66
67 static void get_attr_type_str(CK_ATTRIBUTE_TYPE atype, char *str, int len)
68 {
69 #define CASE(attr) case attr: a = #attr ; break
70
71 const char * a = NULL;
72
73 switch (atype) {
74 CASE(CKA_CLASS);
75 CASE(CKA_TOKEN);
76 CASE(CKA_PRIVATE);
77 CASE(CKA_LABEL);
78 CASE(CKA_APPLICATION);
79 CASE(CKA_VALUE);
80 CASE(CKA_OBJECT_ID);
81 CASE(CKA_CERTIFICATE_TYPE);
82 CASE(CKA_CERTIFICATE_CATEGORY);
83 CASE(CKA_ISSUER);
84 CASE(CKA_SERIAL_NUMBER);
85 CASE(CKA_AC_ISSUER);
86 CASE(CKA_OWNER);
87 CASE(CKA_ATTR_TYPES);
88 CASE(CKA_TRUSTED);
89 CASE(CKA_KEY_TYPE);
90 CASE(CKA_SUBJECT);
91 CASE(CKA_ID);
92 CASE(CKA_SENSITIVE);
93 CASE(CKA_ENCRYPT);
94 CASE(CKA_DECRYPT);
95 CASE(CKA_WRAP);
96 CASE(CKA_UNWRAP);
97 CASE(CKA_SIGN);
98 CASE(CKA_SIGN_RECOVER);
99 CASE(CKA_VERIFY);
100 CASE(CKA_VERIFY_RECOVER);
101 CASE(CKA_DERIVE);
102 CASE(CKA_START_DATE);
103 CASE(CKA_END_DATE);
104 CASE(CKA_MODULUS);
105 CASE(CKA_MODULUS_BITS);
106 CASE(CKA_PUBLIC_EXPONENT);
107 CASE(CKA_PRIVATE_EXPONENT);
108 CASE(CKA_PRIME_1);
109 CASE(CKA_PRIME_2);
110 CASE(CKA_EXPONENT_1);
111 CASE(CKA_EXPONENT_2);
112 CASE(CKA_COEFFICIENT);
113 CASE(CKA_PRIME);
114 CASE(CKA_SUBPRIME);
115 CASE(CKA_BASE);
116 CASE(CKA_PRIME_BITS);
117 CASE(CKA_SUBPRIME_BITS);
118 CASE(CKA_VALUE_BITS);
119 CASE(CKA_VALUE_LEN);
120 CASE(CKA_EXTRACTABLE);
121 CASE(CKA_LOCAL);
122 CASE(CKA_NEVER_EXTRACTABLE);
123 CASE(CKA_ALWAYS_SENSITIVE);
124 CASE(CKA_KEY_GEN_MECHANISM);
125 CASE(CKA_MODIFIABLE);
126 CASE(CKA_ECDSA_PARAMS);
127 CASE(CKA_EC_POINT);
128 CASE(CKA_SECONDARY_AUTH);
129 CASE(CKA_AUTH_PIN_FLAGS);
130 CASE(CKA_HW_FEATURE_TYPE);
131 CASE(CKA_RESET_ON_INIT);
132 CASE(CKA_HAS_RESET);
133 CASE(CKA_VENDOR_DEFINED);
134 CASE(CKA_NSS_URL);
135 CASE(CKA_NSS_EMAIL);
136 CASE(CKA_NSS_SMIME_INFO);
137 CASE(CKA_NSS_SMIME_TIMESTAMP);
138 CASE(CKA_NSS_PKCS8_SALT);
139 CASE(CKA_NSS_PASSWORD_CHECK);
140 CASE(CKA_NSS_EXPIRES);
141 CASE(CKA_NSS_KRL);
142 CASE(CKA_NSS_PQG_COUNTER);
143 CASE(CKA_NSS_PQG_SEED);
144 CASE(CKA_NSS_PQG_H);
145 CASE(CKA_NSS_PQG_SEED_BITS);
146 CASE(CKA_TRUST);
147 CASE(CKA_TRUST_DIGITAL_SIGNATURE);
148 CASE(CKA_TRUST_NON_REPUDIATION);
149 CASE(CKA_TRUST_KEY_ENCIPHERMENT);
150 CASE(CKA_TRUST_DATA_ENCIPHERMENT);
151 CASE(CKA_TRUST_KEY_AGREEMENT);
152 CASE(CKA_TRUST_KEY_CERT_SIGN);
153 CASE(CKA_TRUST_CRL_SIGN);
154 CASE(CKA_TRUST_SERVER_AUTH);
155 CASE(CKA_TRUST_CLIENT_AUTH);
156 CASE(CKA_TRUST_CODE_SIGNING);
157 CASE(CKA_TRUST_EMAIL_PROTECTION);
158 CASE(CKA_TRUST_IPSEC_END_SYSTEM);
159 CASE(CKA_TRUST_IPSEC_TUNNEL);
160 CASE(CKA_TRUST_IPSEC_USER);
161 CASE(CKA_TRUST_TIME_STAMPING);
162 CASE(CKA_CERT_SHA1_HASH);
163 CASE(CKA_CERT_MD5_HASH);
164 CASE(CKA_NETSCAPE_DB);
165 CASE(CKA_NETSCAPE_TRUST);
166 default: break;
167 }
168 if (a)
169 PR_snprintf(str, len, "%s", a);
170 else
171 PR_snprintf(str, len, "0x%p", atype);
172 }
173
174 static void get_obj_class(CK_OBJECT_CLASS objClass, char *str, int len)
175 {
176
177 const char * a = NULL;
178
179 switch (objClass) {
180 CASE(CKO_DATA);
181 CASE(CKO_CERTIFICATE);
182 CASE(CKO_PUBLIC_KEY);
183 CASE(CKO_PRIVATE_KEY);
184 CASE(CKO_SECRET_KEY);
185 CASE(CKO_HW_FEATURE);
186 CASE(CKO_DOMAIN_PARAMETERS);
187 CASE(CKO_NSS_CRL);
188 CASE(CKO_NSS_SMIME);
189 CASE(CKO_NSS_TRUST);
190 CASE(CKO_NSS_BUILTIN_ROOT_LIST);
191 default: break;
192 }
193 if (a)
194 PR_snprintf(str, len, "%s", a);
195 else
196 PR_snprintf(str, len, "0x%p", objClass);
197 }
198
199 static void get_trust_val(CK_TRUST trust, char *str, int len)
200 {
201 const char * a = NULL;
202
203 switch (trust) {
204 CASE(CKT_NSS_TRUSTED);
205 CASE(CKT_NSS_TRUSTED_DELEGATOR);
206 CASE(CKT_NSS_NOT_TRUSTED);
207 CASE(CKT_NSS_MUST_VERIFY_TRUST);
208 CASE(CKT_NSS_TRUST_UNKNOWN);
209 CASE(CKT_NSS_VALID_DELEGATOR);
210 default: break;
211 }
212 if (a)
213 PR_snprintf(str, len, "%s", a);
214 else
215 PR_snprintf(str, len, "0x%p", trust);
216 }
217
218 static void log_rv(CK_RV rv)
219 {
220 const char * a = NULL;
221
222 switch (rv) {
223 CASE(CKR_OK);
224 CASE(CKR_CANCEL);
225 CASE(CKR_HOST_MEMORY);
226 CASE(CKR_SLOT_ID_INVALID);
227 CASE(CKR_GENERAL_ERROR);
228 CASE(CKR_FUNCTION_FAILED);
229 CASE(CKR_ARGUMENTS_BAD);
230 CASE(CKR_NO_EVENT);
231 CASE(CKR_NEED_TO_CREATE_THREADS);
232 CASE(CKR_CANT_LOCK);
233 CASE(CKR_ATTRIBUTE_READ_ONLY);
234 CASE(CKR_ATTRIBUTE_SENSITIVE);
235 CASE(CKR_ATTRIBUTE_TYPE_INVALID);
236 CASE(CKR_ATTRIBUTE_VALUE_INVALID);
237 CASE(CKR_DATA_INVALID);
238 CASE(CKR_DATA_LEN_RANGE);
239 CASE(CKR_DEVICE_ERROR);
240 CASE(CKR_DEVICE_MEMORY);
241 CASE(CKR_DEVICE_REMOVED);
242 CASE(CKR_ENCRYPTED_DATA_INVALID);
243 CASE(CKR_ENCRYPTED_DATA_LEN_RANGE);
244 CASE(CKR_FUNCTION_CANCELED);
245 CASE(CKR_FUNCTION_NOT_PARALLEL);
246 CASE(CKR_FUNCTION_NOT_SUPPORTED);
247 CASE(CKR_KEY_HANDLE_INVALID);
248 CASE(CKR_KEY_SIZE_RANGE);
249 CASE(CKR_KEY_TYPE_INCONSISTENT);
250 CASE(CKR_KEY_NOT_NEEDED);
251 CASE(CKR_KEY_CHANGED);
252 CASE(CKR_KEY_NEEDED);
253 CASE(CKR_KEY_INDIGESTIBLE);
254 CASE(CKR_KEY_FUNCTION_NOT_PERMITTED);
255 CASE(CKR_KEY_NOT_WRAPPABLE);
256 CASE(CKR_KEY_UNEXTRACTABLE);
257 CASE(CKR_MECHANISM_INVALID);
258 CASE(CKR_MECHANISM_PARAM_INVALID);
259 CASE(CKR_OBJECT_HANDLE_INVALID);
260 CASE(CKR_OPERATION_ACTIVE);
261 CASE(CKR_OPERATION_NOT_INITIALIZED);
262 CASE(CKR_PIN_INCORRECT);
263 CASE(CKR_PIN_INVALID);
264 CASE(CKR_PIN_LEN_RANGE);
265 CASE(CKR_PIN_EXPIRED);
266 CASE(CKR_PIN_LOCKED);
267 CASE(CKR_SESSION_CLOSED);
268 CASE(CKR_SESSION_COUNT);
269 CASE(CKR_SESSION_HANDLE_INVALID);
270 CASE(CKR_SESSION_PARALLEL_NOT_SUPPORTED);
271 CASE(CKR_SESSION_READ_ONLY);
272 CASE(CKR_SESSION_EXISTS);
273 CASE(CKR_SESSION_READ_ONLY_EXISTS);
274 CASE(CKR_SESSION_READ_WRITE_SO_EXISTS);
275 CASE(CKR_SIGNATURE_INVALID);
276 CASE(CKR_SIGNATURE_LEN_RANGE);
277 CASE(CKR_TEMPLATE_INCOMPLETE);
278 CASE(CKR_TEMPLATE_INCONSISTENT);
279 CASE(CKR_TOKEN_NOT_PRESENT);
280 CASE(CKR_TOKEN_NOT_RECOGNIZED);
281 CASE(CKR_TOKEN_WRITE_PROTECTED);
282 CASE(CKR_UNWRAPPING_KEY_HANDLE_INVALID);
283 CASE(CKR_UNWRAPPING_KEY_SIZE_RANGE);
284 CASE(CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT);
285 CASE(CKR_USER_ALREADY_LOGGED_IN);
286 CASE(CKR_USER_NOT_LOGGED_IN);
287 CASE(CKR_USER_PIN_NOT_INITIALIZED);
288 CASE(CKR_USER_TYPE_INVALID);
289 CASE(CKR_USER_ANOTHER_ALREADY_LOGGED_IN);
290 CASE(CKR_USER_TOO_MANY_TYPES);
291 CASE(CKR_WRAPPED_KEY_INVALID);
292 CASE(CKR_WRAPPED_KEY_LEN_RANGE);
293 CASE(CKR_WRAPPING_KEY_HANDLE_INVALID);
294 CASE(CKR_WRAPPING_KEY_SIZE_RANGE);
295 CASE(CKR_WRAPPING_KEY_TYPE_INCONSISTENT);
296 CASE(CKR_RANDOM_SEED_NOT_SUPPORTED);
297 CASE(CKR_RANDOM_NO_RNG);
298 CASE(CKR_DOMAIN_PARAMS_INVALID);
299 CASE(CKR_BUFFER_TOO_SMALL);
300 CASE(CKR_SAVED_STATE_INVALID);
301 CASE(CKR_INFORMATION_SENSITIVE);
302 CASE(CKR_STATE_UNSAVEABLE);
303 CASE(CKR_CRYPTOKI_NOT_INITIALIZED);
304 CASE(CKR_CRYPTOKI_ALREADY_INITIALIZED);
305 CASE(CKR_MUTEX_BAD);
306 CASE(CKR_MUTEX_NOT_LOCKED);
307 CASE(CKR_FUNCTION_REJECTED);
308 CASE(CKR_KEY_PARAMS_INVALID);
309 default: break;
310 }
311 if (a)
312 PR_LOG(modlog, 1, (" rv = %s\n", a));
313 else
314 PR_LOG(modlog, 1, (" rv = 0x%x\n", rv));
315 }
316
317 static void log_state(CK_STATE state)
318 {
319 const char * a = NULL;
320
321 switch (state) {
322 CASE(CKS_RO_PUBLIC_SESSION);
323 CASE(CKS_RO_USER_FUNCTIONS);
324 CASE(CKS_RW_PUBLIC_SESSION);
325 CASE(CKS_RW_USER_FUNCTIONS);
326 CASE(CKS_RW_SO_FUNCTIONS);
327 default: break;
328 }
329 if (a)
330 PR_LOG(modlog, 1, (" state = %s\n", a));
331 else
332 PR_LOG(modlog, 1, (" state = 0x%x\n", state));
333 }
334
335 static void log_handle(int level, const char * format, CK_ULONG handle)
336 {
337 char fmtBuf[80];
338 if (handle)
339 PR_LOG(modlog, level, (format, handle));
340 else {
341 PL_strncpyz(fmtBuf, format, sizeof fmtBuf);
342 PL_strcatn(fmtBuf, sizeof fmtBuf, fmt_invalid_handle);
343 PR_LOG(modlog, level, (fmtBuf, handle));
344 }
345 }
346
347 static void print_mechanism(CK_MECHANISM_PTR m)
348 {
349
350 const char * a = NULL;
351
352 switch (m->mechanism) {
353 CASE(CKM_AES_CBC);
354 CASE(CKM_AES_CBC_ENCRYPT_DATA);
355 CASE(CKM_AES_CBC_PAD);
356 CASE(CKM_AES_CCM);
357 CASE(CKM_AES_CTR);
358 CASE(CKM_AES_CTS);
359 CASE(CKM_AES_GCM);
360 CASE(CKM_AES_ECB);
361 CASE(CKM_AES_ECB_ENCRYPT_DATA);
362 CASE(CKM_AES_KEY_GEN);
363 CASE(CKM_AES_MAC);
364 CASE(CKM_AES_MAC_GENERAL);
365 CASE(CKM_CAMELLIA_CBC);
366 CASE(CKM_CAMELLIA_CBC_ENCRYPT_DATA);
367 CASE(CKM_CAMELLIA_CBC_PAD);
368 CASE(CKM_CAMELLIA_ECB);
369 CASE(CKM_CAMELLIA_ECB_ENCRYPT_DATA);
370 CASE(CKM_CAMELLIA_KEY_GEN);
371 CASE(CKM_CAMELLIA_MAC);
372 CASE(CKM_CAMELLIA_MAC_GENERAL);
373 CASE(CKM_CDMF_CBC);
374 CASE(CKM_CDMF_CBC_PAD);
375 CASE(CKM_CDMF_ECB);
376 CASE(CKM_CDMF_KEY_GEN);
377 CASE(CKM_CDMF_MAC);
378 CASE(CKM_CDMF_MAC_GENERAL);
379 CASE(CKM_CMS_SIG);
380 CASE(CKM_CONCATENATE_BASE_AND_DATA);
381 CASE(CKM_CONCATENATE_BASE_AND_KEY);
382 CASE(CKM_CONCATENATE_DATA_AND_BASE);
383 CASE(CKM_DES2_KEY_GEN);
384 CASE(CKM_DES3_CBC);
385 CASE(CKM_DES3_CBC_ENCRYPT_DATA);
386 CASE(CKM_DES3_CBC_PAD);
387 CASE(CKM_DES3_ECB);
388 CASE(CKM_DES3_ECB_ENCRYPT_DATA);
389 CASE(CKM_DES3_KEY_GEN);
390 CASE(CKM_DES3_MAC);
391 CASE(CKM_DES3_MAC_GENERAL);
392 CASE(CKM_DES_CBC);
393 CASE(CKM_DES_CBC_ENCRYPT_DATA);
394 CASE(CKM_DES_CBC_PAD);
395 CASE(CKM_DES_CFB64);
396 CASE(CKM_DES_CFB8);
397 CASE(CKM_DES_ECB);
398 CASE(CKM_DES_ECB_ENCRYPT_DATA);
399 CASE(CKM_DES_KEY_GEN);
400 CASE(CKM_DES_MAC);
401 CASE(CKM_DES_MAC_GENERAL);
402 CASE(CKM_DES_OFB64);
403 CASE(CKM_DES_OFB8);
404 CASE(CKM_DH_PKCS_DERIVE);
405 CASE(CKM_DH_PKCS_KEY_PAIR_GEN);
406 CASE(CKM_DH_PKCS_PARAMETER_GEN);
407 CASE(CKM_DSA);
408 CASE(CKM_DSA_KEY_PAIR_GEN);
409 CASE(CKM_DSA_PARAMETER_GEN);
410 CASE(CKM_DSA_SHA1);
411 CASE(CKM_ECDH1_COFACTOR_DERIVE);
412 CASE(CKM_ECDH1_DERIVE);
413 CASE(CKM_ECDSA);
414 CASE(CKM_ECDSA_SHA1);
415 CASE(CKM_ECMQV_DERIVE);
416 CASE(CKM_EC_KEY_PAIR_GEN); /* also CASE(CKM_ECDSA_KEY_PAIR_GEN); */
417 CASE(CKM_EXTRACT_KEY_FROM_KEY);
418 CASE(CKM_FASTHASH);
419 CASE(CKM_FORTEZZA_TIMESTAMP);
420 CASE(CKM_GENERIC_SECRET_KEY_GEN);
421 CASE(CKM_IDEA_CBC);
422 CASE(CKM_IDEA_CBC_PAD);
423 CASE(CKM_IDEA_ECB);
424 CASE(CKM_IDEA_KEY_GEN);
425 CASE(CKM_IDEA_MAC);
426 CASE(CKM_IDEA_MAC_GENERAL);
427 CASE(CKM_KEA_KEY_DERIVE);
428 CASE(CKM_KEA_KEY_PAIR_GEN);
429 CASE(CKM_KEY_WRAP_LYNKS);
430 CASE(CKM_KEY_WRAP_SET_OAEP);
431 CASE(CKM_MD2);
432 CASE(CKM_MD2_HMAC);
433 CASE(CKM_MD2_HMAC_GENERAL);
434 CASE(CKM_MD2_KEY_DERIVATION);
435 CASE(CKM_MD2_RSA_PKCS);
436 CASE(CKM_MD5);
437 CASE(CKM_MD5_HMAC);
438 CASE(CKM_MD5_HMAC_GENERAL);
439 CASE(CKM_MD5_KEY_DERIVATION);
440 CASE(CKM_MD5_RSA_PKCS);
441 CASE(CKM_PBA_SHA1_WITH_SHA1_HMAC);
442 CASE(CKM_PBE_MD2_DES_CBC);
443 CASE(CKM_PBE_MD5_DES_CBC);
444 CASE(CKM_PBE_SHA1_DES2_EDE_CBC);
445 CASE(CKM_PBE_SHA1_DES3_EDE_CBC);
446 CASE(CKM_PBE_SHA1_RC2_128_CBC);
447 CASE(CKM_PBE_SHA1_RC2_40_CBC);
448 CASE(CKM_PBE_SHA1_RC4_128);
449 CASE(CKM_PBE_SHA1_RC4_40);
450 CASE(CKM_PKCS5_PBKD2);
451 CASE(CKM_RC2_CBC);
452 CASE(CKM_RC2_CBC_PAD);
453 CASE(CKM_RC2_ECB);
454 CASE(CKM_RC2_KEY_GEN);
455 CASE(CKM_RC2_MAC);
456 CASE(CKM_RC2_MAC_GENERAL);
457 CASE(CKM_RC4);
458 CASE(CKM_RC4_KEY_GEN);
459 CASE(CKM_RC5_CBC);
460 CASE(CKM_RC5_CBC_PAD);
461 CASE(CKM_RC5_ECB);
462 CASE(CKM_RC5_KEY_GEN);
463 CASE(CKM_RC5_MAC);
464 CASE(CKM_RC5_MAC_GENERAL);
465 CASE(CKM_RIPEMD128);
466 CASE(CKM_RIPEMD128_HMAC);
467 CASE(CKM_RIPEMD128_HMAC_GENERAL);
468 CASE(CKM_RIPEMD128_RSA_PKCS);
469 CASE(CKM_RIPEMD160);
470 CASE(CKM_RIPEMD160_HMAC);
471 CASE(CKM_RIPEMD160_HMAC_GENERAL);
472 CASE(CKM_RIPEMD160_RSA_PKCS);
473 CASE(CKM_RSA_9796);
474 CASE(CKM_RSA_PKCS);
475 CASE(CKM_RSA_PKCS_KEY_PAIR_GEN);
476 CASE(CKM_RSA_PKCS_OAEP);
477 CASE(CKM_RSA_PKCS_PSS);
478 CASE(CKM_RSA_X9_31);
479 CASE(CKM_RSA_X9_31_KEY_PAIR_GEN);
480 CASE(CKM_RSA_X_509);
481 CASE(CKM_SHA1_KEY_DERIVATION);
482 CASE(CKM_SHA1_RSA_PKCS);
483 CASE(CKM_SHA1_RSA_PKCS_PSS);
484 CASE(CKM_SHA1_RSA_X9_31);
485 CASE(CKM_SHA224);
486 CASE(CKM_SHA224_HMAC);
487 CASE(CKM_SHA224_HMAC_GENERAL);
488 CASE(CKM_SHA224_KEY_DERIVATION);
489 CASE(CKM_SHA224_RSA_PKCS);
490 CASE(CKM_SHA224_RSA_PKCS_PSS);
491 CASE(CKM_SHA256);
492 CASE(CKM_SHA256_HMAC);
493 CASE(CKM_SHA256_HMAC_GENERAL);
494 CASE(CKM_SHA256_KEY_DERIVATION);
495 CASE(CKM_SHA256_RSA_PKCS);
496 CASE(CKM_SHA256_RSA_PKCS_PSS);
497 CASE(CKM_SHA384);
498 CASE(CKM_SHA384_HMAC);
499 CASE(CKM_SHA384_HMAC_GENERAL);
500 CASE(CKM_SHA384_KEY_DERIVATION);
501 CASE(CKM_SHA384_RSA_PKCS);
502 CASE(CKM_SHA384_RSA_PKCS_PSS);
503 CASE(CKM_SHA512);
504 CASE(CKM_SHA512_HMAC);
505 CASE(CKM_SHA512_HMAC_GENERAL);
506 CASE(CKM_SHA512_KEY_DERIVATION);
507 CASE(CKM_SHA512_RSA_PKCS);
508 CASE(CKM_SHA512_RSA_PKCS_PSS);
509 CASE(CKM_SHA_1);
510 CASE(CKM_SHA_1_HMAC);
511 CASE(CKM_SHA_1_HMAC_GENERAL);
512 CASE(CKM_SKIPJACK_CBC64);
513 CASE(CKM_SKIPJACK_CFB16);
514 CASE(CKM_SKIPJACK_CFB32);
515 CASE(CKM_SKIPJACK_CFB64);
516 CASE(CKM_SKIPJACK_CFB8);
517 CASE(CKM_SKIPJACK_ECB64);
518 CASE(CKM_SKIPJACK_KEY_GEN);
519 CASE(CKM_SKIPJACK_OFB64);
520 CASE(CKM_SKIPJACK_PRIVATE_WRAP);
521 CASE(CKM_SKIPJACK_RELAYX);
522 CASE(CKM_SKIPJACK_WRAP);
523 CASE(CKM_SSL3_KEY_AND_MAC_DERIVE);
524 CASE(CKM_SSL3_MASTER_KEY_DERIVE);
525 CASE(CKM_SSL3_MASTER_KEY_DERIVE_DH);
526 CASE(CKM_SSL3_MD5_MAC);
527 CASE(CKM_SSL3_PRE_MASTER_KEY_GEN);
528 CASE(CKM_SSL3_SHA1_MAC);
529 CASE(CKM_TLS_KEY_AND_MAC_DERIVE);
530 CASE(CKM_TLS_MASTER_KEY_DERIVE);
531 CASE(CKM_TLS_MASTER_KEY_DERIVE_DH);
532 CASE(CKM_TLS_PRE_MASTER_KEY_GEN);
533 CASE(CKM_TLS_PRF);
534 CASE(CKM_TWOFISH_CBC);
535 CASE(CKM_TWOFISH_KEY_GEN);
536 CASE(CKM_X9_42_DH_DERIVE);
537 CASE(CKM_X9_42_DH_HYBRID_DERIVE);
538 CASE(CKM_X9_42_DH_KEY_PAIR_GEN);
539 CASE(CKM_X9_42_DH_PARAMETER_GEN);
540 CASE(CKM_X9_42_MQV_DERIVE);
541 CASE(CKM_XOR_BASE_AND_DATA);
542 default: break;
543 }
544 if (a)
545 PR_LOG(modlog, 4, (" mechanism = %s", a));
546 else
547 PR_LOG(modlog, 4, (" mechanism = 0x%p", m->mechanism));
548 }
549
550 static void get_key_type(CK_KEY_TYPE keyType, char *str, int len)
551 {
552
553 const char * a = NULL;
554
555 switch (keyType) {
556 CASE(CKK_AES);
557 CASE(CKK_CAMELLIA);
558 CASE(CKK_CDMF);
559 CASE(CKK_DES);
560 CASE(CKK_DES2);
561 CASE(CKK_DES3);
562 CASE(CKK_DH);
563 CASE(CKK_DSA);
564 CASE(CKK_EC); /* also CASE(CKK_ECDSA); */
565 CASE(CKK_GENERIC_SECRET);
566 CASE(CKK_IDEA);
567 CASE(CKK_INVALID_KEY_TYPE);
568 CASE(CKK_KEA);
569 CASE(CKK_RC2);
570 CASE(CKK_RC4);
571 CASE(CKK_RC5);
572 CASE(CKK_RSA);
573 CASE(CKK_SKIPJACK);
574 CASE(CKK_TWOFISH);
575 CASE(CKK_X9_42_DH);
576 default: break;
577 }
578 if (a)
579 PR_snprintf(str, len, "%s", a);
580 else
581 PR_snprintf(str, len, "0x%p", keyType);
582 }
583
584 static void print_attr_value(CK_ATTRIBUTE_PTR attr)
585 {
586 char atype[48];
587 char valstr[49];
588 int len;
589
590 get_attr_type_str(attr->type, atype, sizeof atype);
591 switch (attr->type) {
592 case CKA_ALWAYS_SENSITIVE:
593 case CKA_DECRYPT:
594 case CKA_DERIVE:
595 case CKA_ENCRYPT:
596 case CKA_EXTRACTABLE:
597 case CKA_LOCAL:
598 case CKA_MODIFIABLE:
599 case CKA_NEVER_EXTRACTABLE:
600 case CKA_PRIVATE:
601 case CKA_SENSITIVE:
602 case CKA_SIGN:
603 case CKA_SIGN_RECOVER:
604 case CKA_TOKEN:
605 case CKA_UNWRAP:
606 case CKA_VERIFY:
607 case CKA_VERIFY_RECOVER:
608 case CKA_WRAP:
609 if (attr->ulValueLen > 0 && attr->pValue) {
610 CK_BBOOL tf = *((CK_BBOOL *)attr->pValue);
611 PR_LOG(modlog, 4, (fmt_s_s_d,
612 atype, tf ? "CK_TRUE" : "CK_FALSE", attr->ulValueLen));
613 break;
614 }
615 case CKA_CLASS:
616 if (attr->ulValueLen > 0 && attr->pValue) {
617 CK_OBJECT_CLASS objClass = *((CK_OBJECT_CLASS *)attr->pValue);
618 get_obj_class(objClass, valstr, sizeof valstr);
619 PR_LOG(modlog, 4, (fmt_s_s_d,
620 atype, valstr, attr->ulValueLen));
621 break;
622 }
623 case CKA_TRUST_CLIENT_AUTH:
624 case CKA_TRUST_CODE_SIGNING:
625 case CKA_TRUST_EMAIL_PROTECTION:
626 case CKA_TRUST_SERVER_AUTH:
627 if (attr->ulValueLen > 0 && attr->pValue) {
628 CK_TRUST trust = *((CK_TRUST *)attr->pValue);
629 get_trust_val(trust, valstr, sizeof valstr);
630 PR_LOG(modlog, 4, (fmt_s_s_d,
631 atype, valstr, attr->ulValueLen));
632 break;
633 }
634 case CKA_KEY_TYPE:
635 if (attr->ulValueLen > 0 && attr->pValue) {
636 CK_KEY_TYPE keyType = *((CK_KEY_TYPE *)attr->pValue);
637 get_key_type(keyType, valstr, sizeof valstr);
638 PR_LOG(modlog, 4, (fmt_s_s_d,
639 atype, valstr, attr->ulValueLen));
640 break;
641 }
642 case CKA_PIXEL_X:
643 case CKA_PIXEL_Y:
644 case CKA_RESOLUTION:
645 case CKA_CHAR_ROWS:
646 case CKA_CHAR_COLUMNS:
647 case CKA_BITS_PER_PIXEL:
648 case CKA_CERTIFICATE_CATEGORY: /* should print as enum/string */
649 case CKA_JAVA_MIDP_SECURITY_DOMAIN: /* should print as enum/string */
650 case CKA_MODULUS_BITS:
651 case CKA_PRIME_BITS:
652 case CKA_SUBPRIME_BITS:
653 case CKA_VALUE_BITS:
654 case CKA_VALUE_LEN:
655 if (attr->ulValueLen > 0 && attr->pValue) {
656 CK_ULONG valueLen = *((CK_ULONG *)attr->pValue);
657 /* XXX check for the special value CK_UNAVAILABLE_INFORMATION */
658 PR_LOG(modlog, 4, (fmt_s_lu, atype, (PRUint32)valueLen));
659 break;
660 }
661 case CKA_LABEL:
662 case CKA_NSS_EMAIL:
663 case CKA_NSS_URL:
664 if (attr->ulValueLen > 0 && attr->pValue) {
665 len = PR_MIN(attr->ulValueLen + 1, sizeof valstr);
666 PR_snprintf(valstr, len, "%s", attr->pValue);
667 PR_LOG(modlog, 4, (fmt_s_qsq_d,
668 atype, valstr, attr->ulValueLen));
669 break;
670 }
671 case CKA_ISSUER:
672 case CKA_SUBJECT:
673 if (attr->ulValueLen > 0 && attr->pValue) {
674 char * asciiName;
675 SECItem derName;
676 derName.type = siDERNameBuffer;
677 derName.data = attr->pValue;
678 derName.len = attr->ulValueLen;
679 asciiName = CERT_DerNameToAscii(&derName);
680 if (asciiName) {
681 PR_LOG(modlog, 4, (fmt_s_s_d,
682 atype, asciiName, attr->ulValueLen));
683 PORT_Free(asciiName);
684 break;
685 }
686 /* else treat like a binary buffer */
687 goto binary_buffer;
688 }
689 case CKA_ID:
690 if (attr->ulValueLen > 0 && attr->pValue) {
691 unsigned char * pV = attr->pValue;
692 for (len = (int)attr->ulValueLen; len > 0; --len) {
693 unsigned int ch = *pV++;
694 if (ch >= 0x20 && ch < 0x7f)
695 continue;
696 if (!ch && len == 1) /* will ignore NUL if last character */
697 continue;
698 break;
699 }
700 if (!len) { /* entire string is printable */
701 len = PR_MIN(attr->ulValueLen + 1, sizeof valstr);
702 PR_snprintf(valstr, len, "%s", attr->pValue);
703 PR_LOG(modlog, 4, (fmt_s_qsq_d,
704 atype, valstr, attr->ulValueLen));
705 break;
706 }
707 /* else fall through and treat like a binary buffer */
708 }
709 binary_buffer:
710 case CKA_SERIAL_NUMBER:
711 default:
712 if (attr->ulValueLen > 0 && attr->pValue) {
713 char * hexBuf;
714 SECItem attrBuf;
715 attrBuf.type = siDERNameBuffer;
716 attrBuf.data = attr->pValue;
717 attrBuf.len = PR_MIN(attr->ulValueLen, (sizeof valstr)/2);
718
719 hexBuf = CERT_Hexify(&attrBuf, PR_FALSE);
720 if (hexBuf) {
721 PR_LOG(modlog, 4, (fmt_s_s_d,
722 atype, hexBuf, attr->ulValueLen));
723 PORT_Free(hexBuf);
724 break;
725 }
726 /* else fall through and show only the address. :( */
727 }
728 PR_LOG(modlog, 4, (" %s = [0x%p] [%d]",
729 atype, attr->pValue, attr->ulValueLen));
730 break;
731 }
732 }
733
734 static void print_template(CK_ATTRIBUTE_PTR templ, CK_ULONG tlen)
735 {
736 CK_ULONG i;
737 for (i=0; i<tlen; i++) {
738 print_attr_value(&templ[i]);
739 }
740 }
741
742 struct nssdbg_prof_str {
743 PRUint32 time;
744 PRUint32 calls;
745 char *function;
746 };
747
748 #define NSSDBG_DEFINE(func) { 0, 0, #func }
749
750 struct nssdbg_prof_str nssdbg_prof_data[] = {
751 #define FUNC_C_INITIALIZE 0
752 NSSDBG_DEFINE(C_Initialize),
753 #define FUNC_C_FINALIZE 1
754 NSSDBG_DEFINE(C_Finalize),
755 #define FUNC_C_GETINFO 2
756 NSSDBG_DEFINE(C_GetInfo),
757 #define FUNC_C_GETFUNCITONLIST 3
758 NSSDBG_DEFINE(C_GetFunctionList),
759 #define FUNC_C_GETSLOTLIST 4
760 NSSDBG_DEFINE(C_GetSlotList),
761 #define FUNC_C_GETSLOTINFO 5
762 NSSDBG_DEFINE(C_GetSlotInfo),
763 #define FUNC_C_GETTOKENINFO 6
764 NSSDBG_DEFINE(C_GetTokenInfo),
765 #define FUNC_C_GETMECHANISMLIST 7
766 NSSDBG_DEFINE(C_GetMechanismList),
767 #define FUNC_C_GETMECHANISMINFO 8
768 NSSDBG_DEFINE(C_GetMechanismInfo),
769 #define FUNC_C_INITTOKEN 9
770 NSSDBG_DEFINE(C_InitToken),
771 #define FUNC_C_INITPIN 10
772 NSSDBG_DEFINE(C_InitPIN),
773 #define FUNC_C_SETPIN 11
774 NSSDBG_DEFINE(C_SetPIN),
775 #define FUNC_C_OPENSESSION 12
776 NSSDBG_DEFINE(C_OpenSession),
777 #define FUNC_C_CLOSESESSION 13
778 NSSDBG_DEFINE(C_CloseSession),
779 #define FUNC_C_CLOSEALLSESSIONS 14
780 NSSDBG_DEFINE(C_CloseAllSessions),
781 #define FUNC_C_GETSESSIONINFO 15
782 NSSDBG_DEFINE(C_GetSessionInfo),
783 #define FUNC_C_GETOPERATIONSTATE 16
784 NSSDBG_DEFINE(C_GetOperationState),
785 #define FUNC_C_SETOPERATIONSTATE 17
786 NSSDBG_DEFINE(C_SetOperationState),
787 #define FUNC_C_LOGIN 18
788 NSSDBG_DEFINE(C_Login),
789 #define FUNC_C_LOGOUT 19
790 NSSDBG_DEFINE(C_Logout),
791 #define FUNC_C_CREATEOBJECT 20
792 NSSDBG_DEFINE(C_CreateObject),
793 #define FUNC_C_COPYOBJECT 21
794 NSSDBG_DEFINE(C_CopyObject),
795 #define FUNC_C_DESTROYOBJECT 22
796 NSSDBG_DEFINE(C_DestroyObject),
797 #define FUNC_C_GETOBJECTSIZE 23
798 NSSDBG_DEFINE(C_GetObjectSize),
799 #define FUNC_C_GETATTRIBUTEVALUE 24
800 NSSDBG_DEFINE(C_GetAttributeValue),
801 #define FUNC_C_SETATTRIBUTEVALUE 25
802 NSSDBG_DEFINE(C_SetAttributeValue),
803 #define FUNC_C_FINDOBJECTSINIT 26
804 NSSDBG_DEFINE(C_FindObjectsInit),
805 #define FUNC_C_FINDOBJECTS 27
806 NSSDBG_DEFINE(C_FindObjects),
807 #define FUNC_C_FINDOBJECTSFINAL 28
808 NSSDBG_DEFINE(C_FindObjectsFinal),
809 #define FUNC_C_ENCRYPTINIT 29
810 NSSDBG_DEFINE(C_EncryptInit),
811 #define FUNC_C_ENCRYPT 30
812 NSSDBG_DEFINE(C_Encrypt),
813 #define FUNC_C_ENCRYPTUPDATE 31
814 NSSDBG_DEFINE(C_EncryptUpdate),
815 #define FUNC_C_ENCRYPTFINAL 32
816 NSSDBG_DEFINE(C_EncryptFinal),
817 #define FUNC_C_DECRYPTINIT 33
818 NSSDBG_DEFINE(C_DecryptInit),
819 #define FUNC_C_DECRYPT 34
820 NSSDBG_DEFINE(C_Decrypt),
821 #define FUNC_C_DECRYPTUPDATE 35
822 NSSDBG_DEFINE(C_DecryptUpdate),
823 #define FUNC_C_DECRYPTFINAL 36
824 NSSDBG_DEFINE(C_DecryptFinal),
825 #define FUNC_C_DIGESTINIT 37
826 NSSDBG_DEFINE(C_DigestInit),
827 #define FUNC_C_DIGEST 38
828 NSSDBG_DEFINE(C_Digest),
829 #define FUNC_C_DIGESTUPDATE 39
830 NSSDBG_DEFINE(C_DigestUpdate),
831 #define FUNC_C_DIGESTKEY 40
832 NSSDBG_DEFINE(C_DigestKey),
833 #define FUNC_C_DIGESTFINAL 41
834 NSSDBG_DEFINE(C_DigestFinal),
835 #define FUNC_C_SIGNINIT 42
836 NSSDBG_DEFINE(C_SignInit),
837 #define FUNC_C_SIGN 43
838 NSSDBG_DEFINE(C_Sign),
839 #define FUNC_C_SIGNUPDATE 44
840 NSSDBG_DEFINE(C_SignUpdate),
841 #define FUNC_C_SIGNFINAL 45
842 NSSDBG_DEFINE(C_SignFinal),
843 #define FUNC_C_SIGNRECOVERINIT 46
844 NSSDBG_DEFINE(C_SignRecoverInit),
845 #define FUNC_C_SIGNRECOVER 47
846 NSSDBG_DEFINE(C_SignRecover),
847 #define FUNC_C_VERIFYINIT 48
848 NSSDBG_DEFINE(C_VerifyInit),
849 #define FUNC_C_VERIFY 49
850 NSSDBG_DEFINE(C_Verify),
851 #define FUNC_C_VERIFYUPDATE 50
852 NSSDBG_DEFINE(C_VerifyUpdate),
853 #define FUNC_C_VERIFYFINAL 51
854 NSSDBG_DEFINE(C_VerifyFinal),
855 #define FUNC_C_VERIFYRECOVERINIT 52
856 NSSDBG_DEFINE(C_VerifyRecoverInit),
857 #define FUNC_C_VERIFYRECOVER 53
858 NSSDBG_DEFINE(C_VerifyRecover),
859 #define FUNC_C_DIGESTENCRYPTUPDATE 54
860 NSSDBG_DEFINE(C_DigestEncryptUpdate),
861 #define FUNC_C_DECRYPTDIGESTUPDATE 55
862 NSSDBG_DEFINE(C_DecryptDigestUpdate),
863 #define FUNC_C_SIGNENCRYPTUPDATE 56
864 NSSDBG_DEFINE(C_SignEncryptUpdate),
865 #define FUNC_C_DECRYPTVERIFYUPDATE 57
866 NSSDBG_DEFINE(C_DecryptVerifyUpdate),
867 #define FUNC_C_GENERATEKEY 58
868 NSSDBG_DEFINE(C_GenerateKey),
869 #define FUNC_C_GENERATEKEYPAIR 59
870 NSSDBG_DEFINE(C_GenerateKeyPair),
871 #define FUNC_C_WRAPKEY 60
872 NSSDBG_DEFINE(C_WrapKey),
873 #define FUNC_C_UNWRAPKEY 61
874 NSSDBG_DEFINE(C_UnWrapKey),
875 #define FUNC_C_DERIVEKEY 62
876 NSSDBG_DEFINE(C_DeriveKey),
877 #define FUNC_C_SEEDRANDOM 63
878 NSSDBG_DEFINE(C_SeedRandom),
879 #define FUNC_C_GENERATERANDOM 64
880 NSSDBG_DEFINE(C_GenerateRandom),
881 #define FUNC_C_GETFUNCTIONSTATUS 65
882 NSSDBG_DEFINE(C_GetFunctionStatus),
883 #define FUNC_C_CANCELFUNCTION 66
884 NSSDBG_DEFINE(C_CancelFunction),
885 #define FUNC_C_WAITFORSLOTEVENT 67
886 NSSDBG_DEFINE(C_WaitForSlotEvent)
887 };
888
889 int nssdbg_prof_size = sizeof(nssdbg_prof_data)/sizeof(nssdbg_prof_data[0]);
890
891
892 static void nssdbg_finish_time(PRInt32 fun_number, PRIntervalTime start)
893 {
894 PRIntervalTime ival;
895 PRIntervalTime end = PR_IntervalNow();
896
897 ival = end-start;
898 /* sigh, lie to PRAtomic add and say we are using signed values */
899 PR_ATOMIC_ADD((PRInt32 *)&nssdbg_prof_data[fun_number].time, (PRInt32)ival);
900 }
901
902 static void nssdbg_start_time(PRInt32 fun_number, PRIntervalTime *start)
903 {
904 PR_ATOMIC_INCREMENT((PRInt32 *)&nssdbg_prof_data[fun_number].calls);
905 *start = PR_IntervalNow();
906 }
907
908 #define COMMON_DEFINITIONS \
909 CK_RV rv; \
910 PRIntervalTime start
911
912 CK_RV NSSDBGC_Initialize(
913 CK_VOID_PTR pInitArgs
914 )
915 {
916 COMMON_DEFINITIONS;
917
918 PR_LOG(modlog, 1, ("C_Initialize"));
919 PR_LOG(modlog, 3, (" pInitArgs = 0x%p", pInitArgs));
920 nssdbg_start_time(FUNC_C_INITIALIZE,&start);
921 rv = module_functions->C_Initialize(pInitArgs);
922 nssdbg_finish_time(FUNC_C_INITIALIZE,start);
923 log_rv(rv);
924 return rv;
925 }
926
927 CK_RV NSSDBGC_Finalize(
928 CK_VOID_PTR pReserved
929 )
930 {
931 COMMON_DEFINITIONS;
932
933 PR_LOG(modlog, 1, ("C_Finalize"));
934 PR_LOG(modlog, 3, (" pReserved = 0x%p", pReserved));
935 nssdbg_start_time(FUNC_C_FINALIZE,&start);
936 rv = module_functions->C_Finalize(pReserved);
937 nssdbg_finish_time(FUNC_C_FINALIZE,start);
938 log_rv(rv);
939 return rv;
940 }
941
942 CK_RV NSSDBGC_GetInfo(
943 CK_INFO_PTR pInfo
944 )
945 {
946 COMMON_DEFINITIONS;
947
948 PR_LOG(modlog, 1, ("C_GetInfo"));
949 PR_LOG(modlog, 3, (fmt_pInfo, pInfo));
950 nssdbg_start_time(FUNC_C_GETINFO,&start);
951 rv = module_functions->C_GetInfo(pInfo);
952 nssdbg_finish_time(FUNC_C_GETINFO,start);
953 if (rv == CKR_OK) {
954 PR_LOG(modlog, 4, (" cryptoki version: %d.%d",
955 pInfo->cryptokiVersion.major,
956 pInfo->cryptokiVersion.minor));
957 PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID));
958 PR_LOG(modlog, 4, (" library description = \"%.32s\"",
959 pInfo->libraryDescription));
960 PR_LOG(modlog, 4, (" library version: %d.%d",
961 pInfo->libraryVersion.major,
962 pInfo->libraryVersion.minor));
963 }
964 log_rv(rv);
965 return rv;
966 }
967
968 CK_RV NSSDBGC_GetFunctionList(
969 CK_FUNCTION_LIST_PTR_PTR ppFunctionList
970 )
971 {
972 COMMON_DEFINITIONS;
973
974 PR_LOG(modlog, 1, ("C_GetFunctionList"));
975 PR_LOG(modlog, 3, (" ppFunctionList = 0x%p", ppFunctionList));
976 nssdbg_start_time(FUNC_C_GETFUNCITONLIST,&start);
977 rv = module_functions->C_GetFunctionList(ppFunctionList);
978 nssdbg_finish_time(FUNC_C_GETFUNCITONLIST,start);
979 log_rv(rv);
980 return rv;
981 }
982
983 CK_RV NSSDBGC_GetSlotList(
984 CK_BBOOL tokenPresent,
985 CK_SLOT_ID_PTR pSlotList,
986 CK_ULONG_PTR pulCount
987 )
988 {
989 COMMON_DEFINITIONS;
990
991 CK_ULONG i;
992 PR_LOG(modlog, 1, ("C_GetSlotList"));
993 PR_LOG(modlog, 3, (" tokenPresent = 0x%x", tokenPresent));
994 PR_LOG(modlog, 3, (" pSlotList = 0x%p", pSlotList));
995 PR_LOG(modlog, 3, (fmt_pulCount, pulCount));
996 nssdbg_start_time(FUNC_C_GETSLOTLIST,&start);
997 rv = module_functions->C_GetSlotList(tokenPresent, pSlotList, pulCount);
998 nssdbg_finish_time(FUNC_C_GETSLOTLIST,start);
999 PR_LOG(modlog, 4, (fmt_spulCount, *pulCount));
1000 if (pSlotList) {
1001 for (i=0; i<*pulCount; i++) {
1002 PR_LOG(modlog, 4, (" slotID[%d] = %x", i, pSlotList[i]));
1003 }
1004 }
1005 log_rv(rv);
1006 return rv;
1007 }
1008
1009 CK_RV NSSDBGC_GetSlotInfo(
1010 CK_SLOT_ID slotID,
1011 CK_SLOT_INFO_PTR pInfo
1012 )
1013 {
1014 COMMON_DEFINITIONS;
1015
1016 PR_LOG(modlog, 1, ("C_GetSlotInfo"));
1017 PR_LOG(modlog, 3, (fmt_slotID, slotID));
1018 PR_LOG(modlog, 3, (fmt_pInfo, pInfo));
1019 nssdbg_start_time(FUNC_C_GETSLOTINFO,&start);
1020 rv = module_functions->C_GetSlotInfo(slotID, pInfo);
1021 nssdbg_finish_time(FUNC_C_GETSLOTINFO,start);
1022 if (rv == CKR_OK) {
1023 PR_LOG(modlog, 4, (" slotDescription = \"%.64s\"",
1024 pInfo->slotDescription));
1025 PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID));
1026 PR_LOG(modlog, 4, (" flags = %s %s %s",
1027 pInfo->flags & CKF_HW_SLOT ? "CKF_HW_SLOT" : "",
1028 pInfo->flags & CKF_REMOVABLE_DEVICE ? "CKF_REMOVABLE_DEVICE" : "",
1029 pInfo->flags & CKF_TOKEN_PRESENT ? "CKF_TOKEN_PRESENT" : ""));
1030 PR_LOG(modlog, 4, (fmt_hwVersion,
1031 pInfo->hardwareVersion.major,
1032 pInfo->hardwareVersion.minor));
1033 PR_LOG(modlog, 4, (fmt_fwVersion,
1034 pInfo->firmwareVersion.major,
1035 pInfo->firmwareVersion.minor));
1036 }
1037 log_rv(rv);
1038 return rv;
1039 }
1040
1041 CK_RV NSSDBGC_GetTokenInfo(
1042 CK_SLOT_ID slotID,
1043 CK_TOKEN_INFO_PTR pInfo
1044 )
1045 {
1046 COMMON_DEFINITIONS;
1047
1048 PR_LOG(modlog, 1, ("C_GetTokenInfo"));
1049 PR_LOG(modlog, 3, (fmt_slotID, slotID));
1050 PR_LOG(modlog, 3, (fmt_pInfo, pInfo));
1051 nssdbg_start_time(FUNC_C_GETTOKENINFO,&start);
1052 rv = module_functions->C_GetTokenInfo(slotID, pInfo);
1053 nssdbg_finish_time(FUNC_C_GETTOKENINFO,start);
1054 if (rv == CKR_OK) {
1055 PR_LOG(modlog, 4, (" label = \"%.32s\"", pInfo->label));
1056 PR_LOG(modlog, 4, (fmt_manufacturerID, pInfo->manufacturerID));
1057 PR_LOG(modlog, 4, (" model = \"%.16s\"", pInfo->model));
1058 PR_LOG(modlog, 4, (" serial = \"%.16s\"", pInfo->serialNumber));
1059 PR_LOG(modlog, 4, (" flags = %s %s %s %s",
1060 pInfo->flags & CKF_RNG ? "CKF_RNG" : "",
1061 pInfo->flags & CKF_WRITE_PROTECTED ? "CKF_WRITE_PROTECTED" : "",
1062 pInfo->flags & CKF_LOGIN_REQUIRED ? "CKF_LOGIN_REQUIRED" : "",
1063 pInfo->flags & CKF_USER_PIN_INITIALIZED ? "CKF_USER_PIN_INIT" : ""));
1064 PR_LOG(modlog, 4, (" maxSessions = %u, Sessions = %u",
1065 pInfo->ulMaxSessionCount, pInfo->ulSessionCount));
1066 PR_LOG(modlog, 4, (" maxRwSessions = %u, RwSessions = %u",
1067 pInfo->ulMaxRwSessionCount,
1068 pInfo->ulRwSessionCount));
1069 /* ignore Max & Min Pin Len, Public and Private Memory */
1070 PR_LOG(modlog, 4, (fmt_hwVersion,
1071 pInfo->hardwareVersion.major,
1072 pInfo->hardwareVersion.minor));
1073 PR_LOG(modlog, 4, (fmt_fwVersion,
1074 pInfo->firmwareVersion.major,
1075 pInfo->firmwareVersion.minor));
1076 }
1077 log_rv(rv);
1078 return rv;
1079 }
1080
1081 CK_RV NSSDBGC_GetMechanismList(
1082 CK_SLOT_ID slotID,
1083 CK_MECHANISM_TYPE_PTR pMechanismList,
1084 CK_ULONG_PTR pulCount
1085 )
1086 {
1087 COMMON_DEFINITIONS;
1088
1089 PR_LOG(modlog, 1, ("C_GetMechanismList"));
1090 PR_LOG(modlog, 3, (fmt_slotID, slotID));
1091 PR_LOG(modlog, 3, (" pMechanismList = 0x%p", pMechanismList));
1092 PR_LOG(modlog, 3, (fmt_pulCount, pulCount));
1093 nssdbg_start_time(FUNC_C_GETMECHANISMLIST,&start);
1094 rv = module_functions->C_GetMechanismList(slotID,
1095 pMechanismList,
1096 pulCount);
1097 nssdbg_finish_time(FUNC_C_GETMECHANISMLIST,start);
1098 PR_LOG(modlog, 4, (fmt_spulCount, *pulCount));
1099 log_rv(rv);
1100 return rv;
1101 }
1102
1103 CK_RV NSSDBGC_GetMechanismInfo(
1104 CK_SLOT_ID slotID,
1105 CK_MECHANISM_TYPE type,
1106 CK_MECHANISM_INFO_PTR pInfo
1107 )
1108 {
1109 COMMON_DEFINITIONS;
1110
1111 PR_LOG(modlog, 1, ("C_GetMechanismInfo"));
1112 PR_LOG(modlog, 3, (fmt_slotID, slotID));
1113 PR_LOG(modlog, 3, (" type = 0x%x", type));
1114 PR_LOG(modlog, 3, (fmt_pInfo, pInfo));
1115 nssdbg_start_time(FUNC_C_GETMECHANISMINFO,&start);
1116 rv = module_functions->C_GetMechanismInfo(slotID,
1117 type,
1118 pInfo);
1119 nssdbg_finish_time(FUNC_C_GETMECHANISMINFO,start);
1120 log_rv(rv);
1121 return rv;
1122 }
1123
1124 CK_RV NSSDBGC_InitToken(
1125 CK_SLOT_ID slotID,
1126 CK_CHAR_PTR pPin,
1127 CK_ULONG ulPinLen,
1128 CK_CHAR_PTR pLabel
1129 )
1130 {
1131 COMMON_DEFINITIONS;
1132
1133 PR_LOG(modlog, 1, ("C_InitToken"));
1134 PR_LOG(modlog, 3, (fmt_slotID, slotID));
1135 PR_LOG(modlog, 3, (fmt_pPin, pPin));
1136 PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen));
1137 PR_LOG(modlog, 3, (" pLabel = 0x%p", pLabel));
1138 nssdbg_start_time(FUNC_C_INITTOKEN,&start);
1139 rv = module_functions->C_InitToken(slotID,
1140 pPin,
1141 ulPinLen,
1142 pLabel);
1143 nssdbg_finish_time(FUNC_C_INITTOKEN,start);
1144 log_rv(rv);
1145 return rv;
1146 }
1147
1148 CK_RV NSSDBGC_InitPIN(
1149 CK_SESSION_HANDLE hSession,
1150 CK_CHAR_PTR pPin,
1151 CK_ULONG ulPinLen
1152 )
1153 {
1154 COMMON_DEFINITIONS;
1155
1156 PR_LOG(modlog, 1, ("C_InitPIN"));
1157 log_handle(3, fmt_hSession, hSession);
1158 PR_LOG(modlog, 3, (fmt_pPin, pPin));
1159 PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen));
1160 nssdbg_start_time(FUNC_C_INITPIN,&start);
1161 rv = module_functions->C_InitPIN(hSession,
1162 pPin,
1163 ulPinLen);
1164 nssdbg_finish_time(FUNC_C_INITPIN,start);
1165 log_rv(rv);
1166 return rv;
1167 }
1168
1169 CK_RV NSSDBGC_SetPIN(
1170 CK_SESSION_HANDLE hSession,
1171 CK_CHAR_PTR pOldPin,
1172 CK_ULONG ulOldLen,
1173 CK_CHAR_PTR pNewPin,
1174 CK_ULONG ulNewLen
1175 )
1176 {
1177 COMMON_DEFINITIONS;
1178
1179 PR_LOG(modlog, 1, ("C_SetPIN"));
1180 log_handle(3, fmt_hSession, hSession);
1181 PR_LOG(modlog, 3, (" pOldPin = 0x%p", pOldPin));
1182 PR_LOG(modlog, 3, (" ulOldLen = %d", ulOldLen));
1183 PR_LOG(modlog, 3, (" pNewPin = 0x%p", pNewPin));
1184 PR_LOG(modlog, 3, (" ulNewLen = %d", ulNewLen));
1185 nssdbg_start_time(FUNC_C_SETPIN,&start);
1186 rv = module_functions->C_SetPIN(hSession,
1187 pOldPin,
1188 ulOldLen,
1189 pNewPin,
1190 ulNewLen);
1191 nssdbg_finish_time(FUNC_C_SETPIN,start);
1192 log_rv(rv);
1193 return rv;
1194 }
1195
1196 static PRUint32 numOpenSessions = 0;
1197 static PRUint32 maxOpenSessions = 0;
1198
1199 CK_RV NSSDBGC_OpenSession(
1200 CK_SLOT_ID slotID,
1201 CK_FLAGS flags,
1202 CK_VOID_PTR pApplication,
1203 CK_NOTIFY Notify,
1204 CK_SESSION_HANDLE_PTR phSession
1205 )
1206 {
1207 COMMON_DEFINITIONS;
1208
1209 PR_ATOMIC_INCREMENT((PRInt32 *)&numOpenSessions);
1210 maxOpenSessions = PR_MAX(numOpenSessions, maxOpenSessions);
1211 PR_LOG(modlog, 1, ("C_OpenSession"));
1212 PR_LOG(modlog, 3, (fmt_slotID, slotID));
1213 PR_LOG(modlog, 3, (fmt_flags, flags));
1214 PR_LOG(modlog, 3, (" pApplication = 0x%p", pApplication));
1215 PR_LOG(modlog, 3, (" Notify = 0x%x", Notify));
1216 PR_LOG(modlog, 3, (" phSession = 0x%p", phSession));
1217 nssdbg_start_time(FUNC_C_OPENSESSION,&start);
1218 rv = module_functions->C_OpenSession(slotID,
1219 flags,
1220 pApplication,
1221 Notify,
1222 phSession);
1223 nssdbg_finish_time(FUNC_C_OPENSESSION,start);
1224 log_handle(4, " *phSession = 0x%x", *phSession);
1225 log_rv(rv);
1226 return rv;
1227 }
1228
1229 CK_RV NSSDBGC_CloseSession(
1230 CK_SESSION_HANDLE hSession
1231 )
1232 {
1233 COMMON_DEFINITIONS;
1234
1235 PR_ATOMIC_DECREMENT((PRInt32 *)&numOpenSessions);
1236 PR_LOG(modlog, 1, ("C_CloseSession"));
1237 log_handle(3, fmt_hSession, hSession);
1238 nssdbg_start_time(FUNC_C_CLOSESESSION,&start);
1239 rv = module_functions->C_CloseSession(hSession);
1240 nssdbg_finish_time(FUNC_C_CLOSESESSION,start);
1241 log_rv(rv);
1242 return rv;
1243 }
1244
1245 CK_RV NSSDBGC_CloseAllSessions(
1246 CK_SLOT_ID slotID
1247 )
1248 {
1249 COMMON_DEFINITIONS;
1250
1251 PR_LOG(modlog, 1, ("C_CloseAllSessions"));
1252 PR_LOG(modlog, 3, (fmt_slotID, slotID));
1253 nssdbg_start_time(FUNC_C_CLOSEALLSESSIONS,&start);
1254 rv = module_functions->C_CloseAllSessions(slotID);
1255 nssdbg_finish_time(FUNC_C_CLOSEALLSESSIONS,start);
1256 log_rv(rv);
1257 return rv;
1258 }
1259
1260 CK_RV NSSDBGC_GetSessionInfo(
1261 CK_SESSION_HANDLE hSession,
1262 CK_SESSION_INFO_PTR pInfo
1263 )
1264 {
1265 COMMON_DEFINITIONS;
1266
1267 PR_LOG(modlog, 1, ("C_GetSessionInfo"));
1268 log_handle(3, fmt_hSession, hSession);
1269 PR_LOG(modlog, 3, (fmt_pInfo, pInfo));
1270 nssdbg_start_time(FUNC_C_GETSESSIONINFO,&start);
1271 rv = module_functions->C_GetSessionInfo(hSession,
1272 pInfo);
1273 nssdbg_finish_time(FUNC_C_GETSESSIONINFO,start);
1274 if (rv == CKR_OK) {
1275 PR_LOG(modlog, 4, (fmt_slotID, pInfo->slotID));
1276 log_state(pInfo->state);
1277 PR_LOG(modlog, 4, (" flags = %s %s",
1278 pInfo->flags & CKF_RW_SESSION ? "CKF_RW_SESSION" : "",
1279 pInfo->flags & CKF_SERIAL_SESSION ? "CKF_SERIAL_SESSION" : ""));
1280 PR_LOG(modlog, 4, (" deviceError = 0x%x", pInfo->ulDeviceError));
1281 }
1282 log_rv(rv);
1283 return rv;
1284 }
1285
1286 CK_RV NSSDBGC_GetOperationState(
1287 CK_SESSION_HANDLE hSession,
1288 CK_BYTE_PTR pOperationState,
1289 CK_ULONG_PTR pulOperationStateLen
1290 )
1291 {
1292 COMMON_DEFINITIONS;
1293
1294 PR_LOG(modlog, 1, ("C_GetOperationState"));
1295 log_handle(3, fmt_hSession, hSession);
1296 PR_LOG(modlog, 3, (fmt_pOperationState, pOperationState));
1297 PR_LOG(modlog, 3, (" pulOperationStateLen = 0x%p", pulOperationStateLen));
1298 nssdbg_start_time(FUNC_C_GETOPERATIONSTATE,&start);
1299 rv = module_functions->C_GetOperationState(hSession,
1300 pOperationState,
1301 pulOperationStateLen);
1302 nssdbg_finish_time(FUNC_C_GETOPERATIONSTATE,start);
1303 PR_LOG(modlog, 4, (" *pulOperationStateLen = 0x%x", *pulOperationStateLen));
1304 log_rv(rv);
1305 return rv;
1306 }
1307
1308 CK_RV NSSDBGC_SetOperationState(
1309 CK_SESSION_HANDLE hSession,
1310 CK_BYTE_PTR pOperationState,
1311 CK_ULONG ulOperationStateLen,
1312 CK_OBJECT_HANDLE hEncryptionKey,
1313 CK_OBJECT_HANDLE hAuthenticationKey
1314 )
1315 {
1316 COMMON_DEFINITIONS;
1317
1318 PR_LOG(modlog, 1, ("C_SetOperationState"));
1319 log_handle(3, fmt_hSession, hSession);
1320 PR_LOG(modlog, 3, (fmt_pOperationState, pOperationState));
1321 PR_LOG(modlog, 3, (" ulOperationStateLen = %d", ulOperationStateLen));
1322 log_handle(3, " hEncryptionKey = 0x%x", hEncryptionKey);
1323 log_handle(3, " hAuthenticationKey = 0x%x", hAuthenticationKey);
1324 nssdbg_start_time(FUNC_C_SETOPERATIONSTATE,&start);
1325 rv = module_functions->C_SetOperationState(hSession,
1326 pOperationState,
1327 ulOperationStateLen,
1328 hEncryptionKey,
1329 hAuthenticationKey);
1330 nssdbg_finish_time(FUNC_C_SETOPERATIONSTATE,start);
1331 log_rv(rv);
1332 return rv;
1333 }
1334
1335 CK_RV NSSDBGC_Login(
1336 CK_SESSION_HANDLE hSession,
1337 CK_USER_TYPE userType,
1338 CK_CHAR_PTR pPin,
1339 CK_ULONG ulPinLen
1340 )
1341 {
1342 COMMON_DEFINITIONS;
1343
1344 PR_LOG(modlog, 1, ("C_Login"));
1345 log_handle(3, fmt_hSession, hSession);
1346 PR_LOG(modlog, 3, (" userType = 0x%x", userType));
1347 PR_LOG(modlog, 3, (fmt_pPin, pPin));
1348 PR_LOG(modlog, 3, (fmt_ulPinLen, ulPinLen));
1349 nssdbg_start_time(FUNC_C_LOGIN,&start);
1350 rv = module_functions->C_Login(hSession,
1351 userType,
1352 pPin,
1353 ulPinLen);
1354 nssdbg_finish_time(FUNC_C_LOGIN,start);
1355 log_rv(rv);
1356 return rv;
1357 }
1358
1359 CK_RV NSSDBGC_Logout(
1360 CK_SESSION_HANDLE hSession
1361 )
1362 {
1363 COMMON_DEFINITIONS;
1364
1365 PR_LOG(modlog, 1, ("C_Logout"));
1366 log_handle(3, fmt_hSession, hSession);
1367 nssdbg_start_time(FUNC_C_LOGOUT,&start);
1368 rv = module_functions->C_Logout(hSession);
1369 nssdbg_finish_time(FUNC_C_LOGOUT,start);
1370 log_rv(rv);
1371 return rv;
1372 }
1373
1374 CK_RV NSSDBGC_CreateObject(
1375 CK_SESSION_HANDLE hSession,
1376 CK_ATTRIBUTE_PTR pTemplate,
1377 CK_ULONG ulCount,
1378 CK_OBJECT_HANDLE_PTR phObject
1379 )
1380 {
1381 COMMON_DEFINITIONS;
1382
1383 PR_LOG(modlog, 1, ("C_CreateObject"));
1384 log_handle(3, fmt_hSession, hSession);
1385 PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate));
1386 PR_LOG(modlog, 3, (fmt_ulCount, ulCount));
1387 PR_LOG(modlog, 3, (fmt_phObject, phObject));
1388 print_template(pTemplate, ulCount);
1389 nssdbg_start_time(FUNC_C_CREATEOBJECT,&start);
1390 rv = module_functions->C_CreateObject(hSession,
1391 pTemplate,
1392 ulCount,
1393 phObject);
1394 nssdbg_finish_time(FUNC_C_CREATEOBJECT,start);
1395 log_handle(4, " *phObject = 0x%x", *phObject);
1396 log_rv(rv);
1397 return rv;
1398 }
1399
1400 CK_RV NSSDBGC_CopyObject(
1401 CK_SESSION_HANDLE hSession,
1402 CK_OBJECT_HANDLE hObject,
1403 CK_ATTRIBUTE_PTR pTemplate,
1404 CK_ULONG ulCount,
1405 CK_OBJECT_HANDLE_PTR phNewObject
1406 )
1407 {
1408 COMMON_DEFINITIONS;
1409
1410 PR_LOG(modlog, 1, ("C_CopyObject"));
1411 log_handle(3, fmt_hSession, hSession);
1412 log_handle(3, fmt_hObject, hObject);
1413 PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate));
1414 PR_LOG(modlog, 3, (fmt_ulCount, ulCount));
1415 PR_LOG(modlog, 3, (" phNewObject = 0x%p", phNewObject));
1416 print_template(pTemplate, ulCount);
1417 nssdbg_start_time(FUNC_C_COPYOBJECT,&start);
1418 rv = module_functions->C_CopyObject(hSession,
1419 hObject,
1420 pTemplate,
1421 ulCount,
1422 phNewObject);
1423 nssdbg_finish_time(FUNC_C_COPYOBJECT,start);
1424 log_handle(4, " *phNewObject = 0x%x", *phNewObject);
1425 log_rv(rv);
1426 return rv;
1427 }
1428
1429 CK_RV NSSDBGC_DestroyObject(
1430 CK_SESSION_HANDLE hSession,
1431 CK_OBJECT_HANDLE hObject
1432 )
1433 {
1434 COMMON_DEFINITIONS;
1435
1436 PR_LOG(modlog, 1, ("C_DestroyObject"));
1437 log_handle(3, fmt_hSession, hSession);
1438 log_handle(3, fmt_hObject, hObject);
1439 nssdbg_start_time(FUNC_C_DESTROYOBJECT,&start);
1440 rv = module_functions->C_DestroyObject(hSession,
1441 hObject);
1442 nssdbg_finish_time(FUNC_C_DESTROYOBJECT,start);
1443 log_rv(rv);
1444 return rv;
1445 }
1446
1447 CK_RV NSSDBGC_GetObjectSize(
1448 CK_SESSION_HANDLE hSession,
1449 CK_OBJECT_HANDLE hObject,
1450 CK_ULONG_PTR pulSize
1451 )
1452 {
1453 COMMON_DEFINITIONS;
1454
1455 PR_LOG(modlog, 1, ("C_GetObjectSize"));
1456 log_handle(3, fmt_hSession, hSession);
1457 log_handle(3, fmt_hObject, hObject);
1458 PR_LOG(modlog, 3, (" pulSize = 0x%p", pulSize));
1459 nssdbg_start_time(FUNC_C_GETOBJECTSIZE,&start);
1460 rv = module_functions->C_GetObjectSize(hSession,
1461 hObject,
1462 pulSize);
1463 nssdbg_finish_time(FUNC_C_GETOBJECTSIZE,start);
1464 PR_LOG(modlog, 4, (" *pulSize = 0x%x", *pulSize));
1465 log_rv(rv);
1466 return rv;
1467 }
1468
1469 CK_RV NSSDBGC_GetAttributeValue(
1470 CK_SESSION_HANDLE hSession,
1471 CK_OBJECT_HANDLE hObject,
1472 CK_ATTRIBUTE_PTR pTemplate,
1473 CK_ULONG ulCount
1474 )
1475 {
1476 COMMON_DEFINITIONS;
1477
1478 PR_LOG(modlog, 1, ("C_GetAttributeValue"));
1479 log_handle(3, fmt_hSession, hSession);
1480 log_handle(3, fmt_hObject, hObject);
1481 PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate));
1482 PR_LOG(modlog, 3, (fmt_ulCount, ulCount));
1483 nssdbg_start_time(FUNC_C_GETATTRIBUTEVALUE,&start);
1484 rv = module_functions->C_GetAttributeValue(hSession,
1485 hObject,
1486 pTemplate,
1487 ulCount);
1488 nssdbg_finish_time(FUNC_C_GETATTRIBUTEVALUE,start);
1489 print_template(pTemplate, ulCount);
1490 log_rv(rv);
1491 return rv;
1492 }
1493
1494 CK_RV NSSDBGC_SetAttributeValue(
1495 CK_SESSION_HANDLE hSession,
1496 CK_OBJECT_HANDLE hObject,
1497 CK_ATTRIBUTE_PTR pTemplate,
1498 CK_ULONG ulCount
1499 )
1500 {
1501 COMMON_DEFINITIONS;
1502
1503 PR_LOG(modlog, 1, ("C_SetAttributeValue"));
1504 log_handle(3, fmt_hSession, hSession);
1505 log_handle(3, fmt_hObject, hObject);
1506 PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate));
1507 PR_LOG(modlog, 3, (fmt_ulCount, ulCount));
1508 print_template(pTemplate, ulCount);
1509 nssdbg_start_time(FUNC_C_SETATTRIBUTEVALUE,&start);
1510 rv = module_functions->C_SetAttributeValue(hSession,
1511 hObject,
1512 pTemplate,
1513 ulCount);
1514 nssdbg_finish_time(FUNC_C_SETATTRIBUTEVALUE,start);
1515 log_rv(rv);
1516 return rv;
1517 }
1518
1519 CK_RV NSSDBGC_FindObjectsInit(
1520 CK_SESSION_HANDLE hSession,
1521 CK_ATTRIBUTE_PTR pTemplate,
1522 CK_ULONG ulCount
1523 )
1524 {
1525 COMMON_DEFINITIONS;
1526
1527 PR_LOG(modlog, 1, ("C_FindObjectsInit"));
1528 log_handle(3, fmt_hSession, hSession);
1529 PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate));
1530 PR_LOG(modlog, 3, (fmt_ulCount, ulCount));
1531 print_template(pTemplate, ulCount);
1532 nssdbg_start_time(FUNC_C_FINDOBJECTSINIT,&start);
1533 rv = module_functions->C_FindObjectsInit(hSession,
1534 pTemplate,
1535 ulCount);
1536 nssdbg_finish_time(FUNC_C_FINDOBJECTSINIT,start);
1537 log_rv(rv);
1538 return rv;
1539 }
1540
1541 CK_RV NSSDBGC_FindObjects(
1542 CK_SESSION_HANDLE hSession,
1543 CK_OBJECT_HANDLE_PTR phObject,
1544 CK_ULONG ulMaxObjectCount,
1545 CK_ULONG_PTR pulObjectCount
1546 )
1547 {
1548 COMMON_DEFINITIONS;
1549 CK_ULONG i;
1550
1551 PR_LOG(modlog, 1, ("C_FindObjects"));
1552 log_handle(3, fmt_hSession, hSession);
1553 PR_LOG(modlog, 3, (fmt_phObject, phObject));
1554 PR_LOG(modlog, 3, (" ulMaxObjectCount = %d", ulMaxObjectCount));
1555 PR_LOG(modlog, 3, (" pulObjectCount = 0x%p", pulObjectCount));
1556 nssdbg_start_time(FUNC_C_FINDOBJECTS,&start);
1557 rv = module_functions->C_FindObjects(hSession,
1558 phObject,
1559 ulMaxObjectCount,
1560 pulObjectCount);
1561 nssdbg_finish_time(FUNC_C_FINDOBJECTS,start);
1562 PR_LOG(modlog, 4, (" *pulObjectCount = 0x%x", *pulObjectCount));
1563 for (i=0; i<*pulObjectCount; i++) {
1564 PR_LOG(modlog, 4, (" phObject[%d] = 0x%x%s", i, phObject[i],
1565 phObject[i] ? "" : fmt_invalid_handle));
1566 }
1567 log_rv(rv);
1568 return rv;
1569 }
1570
1571 CK_RV NSSDBGC_FindObjectsFinal(
1572 CK_SESSION_HANDLE hSession
1573 )
1574 {
1575 COMMON_DEFINITIONS;
1576
1577 PR_LOG(modlog, 1, ("C_FindObjectsFinal"));
1578 log_handle(3, fmt_hSession, hSession);
1579 nssdbg_start_time(FUNC_C_FINDOBJECTSFINAL,&start);
1580 rv = module_functions->C_FindObjectsFinal(hSession);
1581 nssdbg_finish_time(FUNC_C_FINDOBJECTSFINAL,start);
1582 log_rv(rv);
1583 return rv;
1584 }
1585
1586 CK_RV NSSDBGC_EncryptInit(
1587 CK_SESSION_HANDLE hSession,
1588 CK_MECHANISM_PTR pMechanism,
1589 CK_OBJECT_HANDLE hKey
1590 )
1591 {
1592 COMMON_DEFINITIONS;
1593
1594 PR_LOG(modlog, 1, ("C_EncryptInit"));
1595 log_handle(3, fmt_hSession, hSession);
1596 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
1597 log_handle(3, fmt_hKey, hKey);
1598 print_mechanism(pMechanism);
1599 nssdbg_start_time(FUNC_C_ENCRYPTINIT,&start);
1600 rv = module_functions->C_EncryptInit(hSession,
1601 pMechanism,
1602 hKey);
1603 nssdbg_finish_time(FUNC_C_ENCRYPTINIT,start);
1604 log_rv(rv);
1605 return rv;
1606 }
1607
1608 CK_RV NSSDBGC_Encrypt(
1609 CK_SESSION_HANDLE hSession,
1610 CK_BYTE_PTR pData,
1611 CK_ULONG ulDataLen,
1612 CK_BYTE_PTR pEncryptedData,
1613 CK_ULONG_PTR pulEncryptedDataLen
1614 )
1615 {
1616 COMMON_DEFINITIONS;
1617
1618 PR_LOG(modlog, 1, ("C_Encrypt"));
1619 log_handle(3, fmt_hSession, hSession);
1620 PR_LOG(modlog, 3, (fmt_pData, pData));
1621 PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen));
1622 PR_LOG(modlog, 3, (fmt_pEncryptedData, pEncryptedData));
1623 PR_LOG(modlog, 3, (" pulEncryptedDataLen = 0x%p", pulEncryptedDataLen));
1624 nssdbg_start_time(FUNC_C_ENCRYPT,&start);
1625 rv = module_functions->C_Encrypt(hSession,
1626 pData,
1627 ulDataLen,
1628 pEncryptedData,
1629 pulEncryptedDataLen);
1630 nssdbg_finish_time(FUNC_C_ENCRYPT,start);
1631 PR_LOG(modlog, 4, (" *pulEncryptedDataLen = 0x%x", *pulEncryptedDataLen));
1632 log_rv(rv);
1633 return rv;
1634 }
1635
1636 CK_RV NSSDBGC_EncryptUpdate(
1637 CK_SESSION_HANDLE hSession,
1638 CK_BYTE_PTR pPart,
1639 CK_ULONG ulPartLen,
1640 CK_BYTE_PTR pEncryptedPart,
1641 CK_ULONG_PTR pulEncryptedPartLen
1642 )
1643 {
1644 COMMON_DEFINITIONS;
1645
1646 PR_LOG(modlog, 1, ("C_EncryptUpdate"));
1647 log_handle(3, fmt_hSession, hSession);
1648 PR_LOG(modlog, 3, (fmt_pPart, pPart));
1649 PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen));
1650 PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart));
1651 PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen));
1652 nssdbg_start_time(FUNC_C_ENCRYPTUPDATE,&start);
1653 rv = module_functions->C_EncryptUpdate(hSession,
1654 pPart,
1655 ulPartLen,
1656 pEncryptedPart,
1657 pulEncryptedPartLen);
1658 nssdbg_finish_time(FUNC_C_ENCRYPTUPDATE,start);
1659 PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen));
1660 log_rv(rv);
1661 return rv;
1662 }
1663
1664 CK_RV NSSDBGC_EncryptFinal(
1665 CK_SESSION_HANDLE hSession,
1666 CK_BYTE_PTR pLastEncryptedPart,
1667 CK_ULONG_PTR pulLastEncryptedPartLen
1668 )
1669 {
1670 COMMON_DEFINITIONS;
1671
1672 PR_LOG(modlog, 1, ("C_EncryptFinal"));
1673 log_handle(3, fmt_hSession, hSession);
1674 PR_LOG(modlog, 3, (" pLastEncryptedPart = 0x%p", pLastEncryptedPart));
1675 PR_LOG(modlog, 3, (" pulLastEncryptedPartLen = 0x%p", pulLastEncryptedPartLen));
1676 nssdbg_start_time(FUNC_C_ENCRYPTFINAL,&start);
1677 rv = module_functions->C_EncryptFinal(hSession,
1678 pLastEncryptedPart,
1679 pulLastEncryptedPartLen);
1680 nssdbg_finish_time(FUNC_C_ENCRYPTFINAL,start);
1681 PR_LOG(modlog, 4, (" *pulLastEncryptedPartLen = 0x%x", *pulLastEncryptedPartLen));
1682 log_rv(rv);
1683 return rv;
1684 }
1685
1686 CK_RV NSSDBGC_DecryptInit(
1687 CK_SESSION_HANDLE hSession,
1688 CK_MECHANISM_PTR pMechanism,
1689 CK_OBJECT_HANDLE hKey
1690 )
1691 {
1692 COMMON_DEFINITIONS;
1693
1694 PR_LOG(modlog, 1, ("C_DecryptInit"));
1695 log_handle(3, fmt_hSession, hSession);
1696 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
1697 log_handle(3, fmt_hKey, hKey);
1698 print_mechanism(pMechanism);
1699 nssdbg_start_time(FUNC_C_DECRYPTINIT,&start);
1700 rv = module_functions->C_DecryptInit(hSession,
1701 pMechanism,
1702 hKey);
1703 nssdbg_finish_time(FUNC_C_DECRYPTINIT,start);
1704 log_rv(rv);
1705 return rv;
1706 }
1707
1708 CK_RV NSSDBGC_Decrypt(
1709 CK_SESSION_HANDLE hSession,
1710 CK_BYTE_PTR pEncryptedData,
1711 CK_ULONG ulEncryptedDataLen,
1712 CK_BYTE_PTR pData,
1713 CK_ULONG_PTR pulDataLen
1714 )
1715 {
1716 COMMON_DEFINITIONS;
1717
1718 PR_LOG(modlog, 1, ("C_Decrypt"));
1719 log_handle(3, fmt_hSession, hSession);
1720 PR_LOG(modlog, 3, (fmt_pEncryptedData, pEncryptedData));
1721 PR_LOG(modlog, 3, (" ulEncryptedDataLen = %d", ulEncryptedDataLen));
1722 PR_LOG(modlog, 3, (fmt_pData, pData));
1723 PR_LOG(modlog, 3, (fmt_pulDataLen, pulDataLen));
1724 nssdbg_start_time(FUNC_C_DECRYPT,&start);
1725 rv = module_functions->C_Decrypt(hSession,
1726 pEncryptedData,
1727 ulEncryptedDataLen,
1728 pData,
1729 pulDataLen);
1730 nssdbg_finish_time(FUNC_C_DECRYPT,start);
1731 PR_LOG(modlog, 4, (fmt_spulDataLen, *pulDataLen));
1732 log_rv(rv);
1733 return rv;
1734 }
1735
1736 CK_RV NSSDBGC_DecryptUpdate(
1737 CK_SESSION_HANDLE hSession,
1738 CK_BYTE_PTR pEncryptedPart,
1739 CK_ULONG ulEncryptedPartLen,
1740 CK_BYTE_PTR pPart,
1741 CK_ULONG_PTR pulPartLen
1742 )
1743 {
1744 COMMON_DEFINITIONS;
1745
1746 PR_LOG(modlog, 1, ("C_DecryptUpdate"));
1747 log_handle(3, fmt_hSession, hSession);
1748 PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart));
1749 PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen));
1750 PR_LOG(modlog, 3, (fmt_pPart, pPart));
1751 PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen));
1752 nssdbg_start_time(FUNC_C_DECRYPTUPDATE,&start);
1753 rv = module_functions->C_DecryptUpdate(hSession,
1754 pEncryptedPart,
1755 ulEncryptedPartLen,
1756 pPart,
1757 pulPartLen);
1758 nssdbg_finish_time(FUNC_C_DECRYPTUPDATE,start);
1759 PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen));
1760 log_rv(rv);
1761 return rv;
1762 }
1763
1764 CK_RV NSSDBGC_DecryptFinal(
1765 CK_SESSION_HANDLE hSession,
1766 CK_BYTE_PTR pLastPart,
1767 CK_ULONG_PTR pulLastPartLen
1768 )
1769 {
1770 COMMON_DEFINITIONS;
1771
1772 PR_LOG(modlog, 1, ("C_DecryptFinal"));
1773 log_handle(3, fmt_hSession, hSession);
1774 PR_LOG(modlog, 3, (" pLastPart = 0x%p", pLastPart));
1775 PR_LOG(modlog, 3, (" pulLastPartLen = 0x%p", pulLastPartLen));
1776 nssdbg_start_time(FUNC_C_DECRYPTFINAL,&start);
1777 rv = module_functions->C_DecryptFinal(hSession,
1778 pLastPart,
1779 pulLastPartLen);
1780 nssdbg_finish_time(FUNC_C_DECRYPTFINAL,start);
1781 PR_LOG(modlog, 4, (" *pulLastPartLen = 0x%x", *pulLastPartLen));
1782 log_rv(rv);
1783 return rv;
1784 }
1785
1786 CK_RV NSSDBGC_DigestInit(
1787 CK_SESSION_HANDLE hSession,
1788 CK_MECHANISM_PTR pMechanism
1789 )
1790 {
1791 COMMON_DEFINITIONS;
1792
1793 PR_LOG(modlog, 1, ("C_DigestInit"));
1794 log_handle(3, fmt_hSession, hSession);
1795 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
1796 print_mechanism(pMechanism);
1797 nssdbg_start_time(FUNC_C_DIGESTINIT,&start);
1798 rv = module_functions->C_DigestInit(hSession,
1799 pMechanism);
1800 nssdbg_finish_time(FUNC_C_DIGESTINIT,start);
1801 log_rv(rv);
1802 return rv;
1803 }
1804
1805 CK_RV NSSDBGC_Digest(
1806 CK_SESSION_HANDLE hSession,
1807 CK_BYTE_PTR pData,
1808 CK_ULONG ulDataLen,
1809 CK_BYTE_PTR pDigest,
1810 CK_ULONG_PTR pulDigestLen
1811 )
1812 {
1813 COMMON_DEFINITIONS;
1814
1815 PR_LOG(modlog, 1, ("C_Digest"));
1816 log_handle(3, fmt_hSession, hSession);
1817 PR_LOG(modlog, 3, (fmt_pData, pData));
1818 PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen));
1819 PR_LOG(modlog, 3, (fmt_pDigest, pDigest));
1820 PR_LOG(modlog, 3, (fmt_pulDigestLen, pulDigestLen));
1821 nssdbg_start_time(FUNC_C_DIGEST,&start);
1822 rv = module_functions->C_Digest(hSession,
1823 pData,
1824 ulDataLen,
1825 pDigest,
1826 pulDigestLen);
1827 nssdbg_finish_time(FUNC_C_DIGEST,start);
1828 PR_LOG(modlog, 4, (fmt_spulDigestLen, *pulDigestLen));
1829 log_rv(rv);
1830 return rv;
1831 }
1832
1833 CK_RV NSSDBGC_DigestUpdate(
1834 CK_SESSION_HANDLE hSession,
1835 CK_BYTE_PTR pPart,
1836 CK_ULONG ulPartLen
1837 )
1838 {
1839 COMMON_DEFINITIONS;
1840
1841 PR_LOG(modlog, 1, ("C_DigestUpdate"));
1842 log_handle(3, fmt_hSession, hSession);
1843 PR_LOG(modlog, 3, (fmt_pPart, pPart));
1844 PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen));
1845 nssdbg_start_time(FUNC_C_DIGESTUPDATE,&start);
1846 rv = module_functions->C_DigestUpdate(hSession,
1847 pPart,
1848 ulPartLen);
1849 nssdbg_finish_time(FUNC_C_DIGESTUPDATE,start);
1850 log_rv(rv);
1851 return rv;
1852 }
1853
1854 CK_RV NSSDBGC_DigestKey(
1855 CK_SESSION_HANDLE hSession,
1856 CK_OBJECT_HANDLE hKey
1857 )
1858 {
1859 COMMON_DEFINITIONS;
1860
1861 PR_LOG(modlog, 1, ("C_DigestKey"));
1862 log_handle(3, fmt_hSession, hSession);
1863 nssdbg_start_time(FUNC_C_DIGESTKEY,&start);
1864 rv = module_functions->C_DigestKey(hSession,
1865 hKey);
1866 nssdbg_finish_time(FUNC_C_DIGESTKEY,start);
1867 log_rv(rv);
1868 return rv;
1869 }
1870
1871 CK_RV NSSDBGC_DigestFinal(
1872 CK_SESSION_HANDLE hSession,
1873 CK_BYTE_PTR pDigest,
1874 CK_ULONG_PTR pulDigestLen
1875 )
1876 {
1877 COMMON_DEFINITIONS;
1878
1879 PR_LOG(modlog, 1, ("C_DigestFinal"));
1880 log_handle(3, fmt_hSession, hSession);
1881 PR_LOG(modlog, 3, (fmt_pDigest, pDigest));
1882 PR_LOG(modlog, 3, (fmt_pulDigestLen, pulDigestLen));
1883 nssdbg_start_time(FUNC_C_DIGESTFINAL,&start);
1884 rv = module_functions->C_DigestFinal(hSession,
1885 pDigest,
1886 pulDigestLen);
1887 nssdbg_finish_time(FUNC_C_DIGESTFINAL,start);
1888 PR_LOG(modlog, 4, (fmt_spulDigestLen, *pulDigestLen));
1889 log_rv(rv);
1890 return rv;
1891 }
1892
1893 CK_RV NSSDBGC_SignInit(
1894 CK_SESSION_HANDLE hSession,
1895 CK_MECHANISM_PTR pMechanism,
1896 CK_OBJECT_HANDLE hKey
1897 )
1898 {
1899 COMMON_DEFINITIONS;
1900
1901 PR_LOG(modlog, 1, ("C_SignInit"));
1902 log_handle(3, fmt_hSession, hSession);
1903 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
1904 log_handle(3, fmt_hKey, hKey);
1905 print_mechanism(pMechanism);
1906 nssdbg_start_time(FUNC_C_SIGNINIT,&start);
1907 rv = module_functions->C_SignInit(hSession,
1908 pMechanism,
1909 hKey);
1910 nssdbg_finish_time(FUNC_C_SIGNINIT,start);
1911 log_rv(rv);
1912 return rv;
1913 }
1914
1915 CK_RV NSSDBGC_Sign(
1916 CK_SESSION_HANDLE hSession,
1917 CK_BYTE_PTR pData,
1918 CK_ULONG ulDataLen,
1919 CK_BYTE_PTR pSignature,
1920 CK_ULONG_PTR pulSignatureLen
1921 )
1922 {
1923 COMMON_DEFINITIONS;
1924
1925 PR_LOG(modlog, 1, ("C_Sign"));
1926 log_handle(3, fmt_hSession, hSession);
1927 PR_LOG(modlog, 3, (fmt_pData, pData));
1928 PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen));
1929 PR_LOG(modlog, 3, (fmt_pSignature, pSignature));
1930 PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen));
1931 nssdbg_start_time(FUNC_C_SIGN,&start);
1932 rv = module_functions->C_Sign(hSession,
1933 pData,
1934 ulDataLen,
1935 pSignature,
1936 pulSignatureLen);
1937 nssdbg_finish_time(FUNC_C_SIGN,start);
1938 PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen));
1939 log_rv(rv);
1940 return rv;
1941 }
1942
1943 CK_RV NSSDBGC_SignUpdate(
1944 CK_SESSION_HANDLE hSession,
1945 CK_BYTE_PTR pPart,
1946 CK_ULONG ulPartLen
1947 )
1948 {
1949 COMMON_DEFINITIONS;
1950
1951 PR_LOG(modlog, 1, ("C_SignUpdate"));
1952 log_handle(3, fmt_hSession, hSession);
1953 PR_LOG(modlog, 3, (fmt_pPart, pPart));
1954 PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen));
1955 nssdbg_start_time(FUNC_C_SIGNUPDATE,&start);
1956 rv = module_functions->C_SignUpdate(hSession,
1957 pPart,
1958 ulPartLen);
1959 nssdbg_finish_time(FUNC_C_SIGNUPDATE,start);
1960 log_rv(rv);
1961 return rv;
1962 }
1963
1964 CK_RV NSSDBGC_SignFinal(
1965 CK_SESSION_HANDLE hSession,
1966 CK_BYTE_PTR pSignature,
1967 CK_ULONG_PTR pulSignatureLen
1968 )
1969 {
1970 COMMON_DEFINITIONS;
1971
1972 PR_LOG(modlog, 1, ("C_SignFinal"));
1973 log_handle(3, fmt_hSession, hSession);
1974 PR_LOG(modlog, 3, (fmt_pSignature, pSignature));
1975 PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen));
1976 nssdbg_start_time(FUNC_C_SIGNFINAL,&start);
1977 rv = module_functions->C_SignFinal(hSession,
1978 pSignature,
1979 pulSignatureLen);
1980 nssdbg_finish_time(FUNC_C_SIGNFINAL,start);
1981 PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen));
1982 log_rv(rv);
1983 return rv;
1984 }
1985
1986 CK_RV NSSDBGC_SignRecoverInit(
1987 CK_SESSION_HANDLE hSession,
1988 CK_MECHANISM_PTR pMechanism,
1989 CK_OBJECT_HANDLE hKey
1990 )
1991 {
1992 COMMON_DEFINITIONS;
1993
1994 PR_LOG(modlog, 1, ("C_SignRecoverInit"));
1995 log_handle(3, fmt_hSession, hSession);
1996 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
1997 log_handle(3, fmt_hKey, hKey);
1998 print_mechanism(pMechanism);
1999 nssdbg_start_time(FUNC_C_SIGNRECOVERINIT,&start);
2000 rv = module_functions->C_SignRecoverInit(hSession,
2001 pMechanism,
2002 hKey);
2003 nssdbg_finish_time(FUNC_C_SIGNRECOVERINIT,start);
2004 log_rv(rv);
2005 return rv;
2006 }
2007
2008 CK_RV NSSDBGC_SignRecover(
2009 CK_SESSION_HANDLE hSession,
2010 CK_BYTE_PTR pData,
2011 CK_ULONG ulDataLen,
2012 CK_BYTE_PTR pSignature,
2013 CK_ULONG_PTR pulSignatureLen
2014 )
2015 {
2016 COMMON_DEFINITIONS;
2017
2018 PR_LOG(modlog, 1, ("C_SignRecover"));
2019 log_handle(3, fmt_hSession, hSession);
2020 PR_LOG(modlog, 3, (fmt_pData, pData));
2021 PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen));
2022 PR_LOG(modlog, 3, (fmt_pSignature, pSignature));
2023 PR_LOG(modlog, 3, (fmt_pulSignatureLen, pulSignatureLen));
2024 nssdbg_start_time(FUNC_C_SIGNRECOVER,&start);
2025 rv = module_functions->C_SignRecover(hSession,
2026 pData,
2027 ulDataLen,
2028 pSignature,
2029 pulSignatureLen);
2030 nssdbg_finish_time(FUNC_C_SIGNRECOVER,start);
2031 PR_LOG(modlog, 4, (fmt_spulSignatureLen, *pulSignatureLen));
2032 log_rv(rv);
2033 return rv;
2034 }
2035
2036 CK_RV NSSDBGC_VerifyInit(
2037 CK_SESSION_HANDLE hSession,
2038 CK_MECHANISM_PTR pMechanism,
2039 CK_OBJECT_HANDLE hKey
2040 )
2041 {
2042 COMMON_DEFINITIONS;
2043
2044 PR_LOG(modlog, 1, ("C_VerifyInit"));
2045 log_handle(3, fmt_hSession, hSession);
2046 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
2047 log_handle(3, fmt_hKey, hKey);
2048 print_mechanism(pMechanism);
2049 nssdbg_start_time(FUNC_C_VERIFYINIT,&start);
2050 rv = module_functions->C_VerifyInit(hSession,
2051 pMechanism,
2052 hKey);
2053 nssdbg_finish_time(FUNC_C_VERIFYINIT,start);
2054 log_rv(rv);
2055 return rv;
2056 }
2057
2058 CK_RV NSSDBGC_Verify(
2059 CK_SESSION_HANDLE hSession,
2060 CK_BYTE_PTR pData,
2061 CK_ULONG ulDataLen,
2062 CK_BYTE_PTR pSignature,
2063 CK_ULONG ulSignatureLen
2064 )
2065 {
2066 COMMON_DEFINITIONS;
2067
2068 PR_LOG(modlog, 1, ("C_Verify"));
2069 log_handle(3, fmt_hSession, hSession);
2070 PR_LOG(modlog, 3, (fmt_pData, pData));
2071 PR_LOG(modlog, 3, (fmt_ulDataLen, ulDataLen));
2072 PR_LOG(modlog, 3, (fmt_pSignature, pSignature));
2073 PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen));
2074 nssdbg_start_time(FUNC_C_VERIFY,&start);
2075 rv = module_functions->C_Verify(hSession,
2076 pData,
2077 ulDataLen,
2078 pSignature,
2079 ulSignatureLen);
2080 nssdbg_finish_time(FUNC_C_VERIFY,start);
2081 log_rv(rv);
2082 return rv;
2083 }
2084
2085 CK_RV NSSDBGC_VerifyUpdate(
2086 CK_SESSION_HANDLE hSession,
2087 CK_BYTE_PTR pPart,
2088 CK_ULONG ulPartLen
2089 )
2090 {
2091 COMMON_DEFINITIONS;
2092
2093 PR_LOG(modlog, 1, ("C_VerifyUpdate"));
2094 log_handle(3, fmt_hSession, hSession);
2095 PR_LOG(modlog, 3, (fmt_pPart, pPart));
2096 PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen));
2097 nssdbg_start_time(FUNC_C_VERIFYUPDATE,&start);
2098 rv = module_functions->C_VerifyUpdate(hSession,
2099 pPart,
2100 ulPartLen);
2101 nssdbg_finish_time(FUNC_C_VERIFYUPDATE,start);
2102 log_rv(rv);
2103 return rv;
2104 }
2105
2106 CK_RV NSSDBGC_VerifyFinal(
2107 CK_SESSION_HANDLE hSession,
2108 CK_BYTE_PTR pSignature,
2109 CK_ULONG ulSignatureLen
2110 )
2111 {
2112 COMMON_DEFINITIONS;
2113
2114 PR_LOG(modlog, 1, ("C_VerifyFinal"));
2115 log_handle(3, fmt_hSession, hSession);
2116 PR_LOG(modlog, 3, (fmt_pSignature, pSignature));
2117 PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen));
2118 nssdbg_start_time(FUNC_C_VERIFYFINAL,&start);
2119 rv = module_functions->C_VerifyFinal(hSession,
2120 pSignature,
2121 ulSignatureLen);
2122 nssdbg_finish_time(FUNC_C_VERIFYFINAL,start);
2123 log_rv(rv);
2124 return rv;
2125 }
2126
2127 CK_RV NSSDBGC_VerifyRecoverInit(
2128 CK_SESSION_HANDLE hSession,
2129 CK_MECHANISM_PTR pMechanism,
2130 CK_OBJECT_HANDLE hKey
2131 )
2132 {
2133 COMMON_DEFINITIONS;
2134
2135 PR_LOG(modlog, 1, ("C_VerifyRecoverInit"));
2136 log_handle(3, fmt_hSession, hSession);
2137 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
2138 log_handle(3, fmt_hKey, hKey);
2139 print_mechanism(pMechanism);
2140 nssdbg_start_time(FUNC_C_VERIFYRECOVERINIT,&start);
2141 rv = module_functions->C_VerifyRecoverInit(hSession,
2142 pMechanism,
2143 hKey);
2144 nssdbg_finish_time(FUNC_C_VERIFYRECOVERINIT,start);
2145 log_rv(rv);
2146 return rv;
2147 }
2148
2149 CK_RV NSSDBGC_VerifyRecover(
2150 CK_SESSION_HANDLE hSession,
2151 CK_BYTE_PTR pSignature,
2152 CK_ULONG ulSignatureLen,
2153 CK_BYTE_PTR pData,
2154 CK_ULONG_PTR pulDataLen
2155 )
2156 {
2157 COMMON_DEFINITIONS;
2158
2159 PR_LOG(modlog, 1, ("C_VerifyRecover"));
2160 log_handle(3, fmt_hSession, hSession);
2161 PR_LOG(modlog, 3, (fmt_pSignature, pSignature));
2162 PR_LOG(modlog, 3, (fmt_ulSignatureLen, ulSignatureLen));
2163 PR_LOG(modlog, 3, (fmt_pData, pData));
2164 PR_LOG(modlog, 3, (fmt_pulDataLen, pulDataLen));
2165 nssdbg_start_time(FUNC_C_VERIFYRECOVER,&start);
2166 rv = module_functions->C_VerifyRecover(hSession,
2167 pSignature,
2168 ulSignatureLen,
2169 pData,
2170 pulDataLen);
2171 nssdbg_finish_time(FUNC_C_VERIFYRECOVER,start);
2172 PR_LOG(modlog, 4, (fmt_spulDataLen, *pulDataLen));
2173 log_rv(rv);
2174 return rv;
2175 }
2176
2177 CK_RV NSSDBGC_DigestEncryptUpdate(
2178 CK_SESSION_HANDLE hSession,
2179 CK_BYTE_PTR pPart,
2180 CK_ULONG ulPartLen,
2181 CK_BYTE_PTR pEncryptedPart,
2182 CK_ULONG_PTR pulEncryptedPartLen
2183 )
2184 {
2185 COMMON_DEFINITIONS;
2186
2187 PR_LOG(modlog, 1, ("C_DigestEncryptUpdate"));
2188 log_handle(3, fmt_hSession, hSession);
2189 PR_LOG(modlog, 3, (fmt_pPart, pPart));
2190 PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen));
2191 PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart));
2192 PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen));
2193 nssdbg_start_time(FUNC_C_DIGESTENCRYPTUPDATE,&start);
2194 rv = module_functions->C_DigestEncryptUpdate(hSession,
2195 pPart,
2196 ulPartLen,
2197 pEncryptedPart,
2198 pulEncryptedPartLen);
2199 nssdbg_finish_time(FUNC_C_DIGESTENCRYPTUPDATE,start);
2200 PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen));
2201 log_rv(rv);
2202 return rv;
2203 }
2204
2205 CK_RV NSSDBGC_DecryptDigestUpdate(
2206 CK_SESSION_HANDLE hSession,
2207 CK_BYTE_PTR pEncryptedPart,
2208 CK_ULONG ulEncryptedPartLen,
2209 CK_BYTE_PTR pPart,
2210 CK_ULONG_PTR pulPartLen
2211 )
2212 {
2213 COMMON_DEFINITIONS;
2214
2215 PR_LOG(modlog, 1, ("C_DecryptDigestUpdate"));
2216 log_handle(3, fmt_hSession, hSession);
2217 PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart));
2218 PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen));
2219 PR_LOG(modlog, 3, (fmt_pPart, pPart));
2220 PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen));
2221 nssdbg_start_time(FUNC_C_DECRYPTDIGESTUPDATE,&start);
2222 rv = module_functions->C_DecryptDigestUpdate(hSession,
2223 pEncryptedPart,
2224 ulEncryptedPartLen,
2225 pPart,
2226 pulPartLen);
2227 nssdbg_finish_time(FUNC_C_DECRYPTDIGESTUPDATE,start);
2228 PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen));
2229 log_rv(rv);
2230 return rv;
2231 }
2232
2233 CK_RV NSSDBGC_SignEncryptUpdate(
2234 CK_SESSION_HANDLE hSession,
2235 CK_BYTE_PTR pPart,
2236 CK_ULONG ulPartLen,
2237 CK_BYTE_PTR pEncryptedPart,
2238 CK_ULONG_PTR pulEncryptedPartLen
2239 )
2240 {
2241 COMMON_DEFINITIONS;
2242
2243 PR_LOG(modlog, 1, ("C_SignEncryptUpdate"));
2244 log_handle(3, fmt_hSession, hSession);
2245 PR_LOG(modlog, 3, (fmt_pPart, pPart));
2246 PR_LOG(modlog, 3, (fmt_ulPartLen, ulPartLen));
2247 PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart));
2248 PR_LOG(modlog, 3, (fmt_pulEncryptedPartLen, pulEncryptedPartLen));
2249 nssdbg_start_time(FUNC_C_SIGNENCRYPTUPDATE,&start);
2250 rv = module_functions->C_SignEncryptUpdate(hSession,
2251 pPart,
2252 ulPartLen,
2253 pEncryptedPart,
2254 pulEncryptedPartLen);
2255 nssdbg_finish_time(FUNC_C_SIGNENCRYPTUPDATE,start);
2256 PR_LOG(modlog, 4, (fmt_spulEncryptedPartLen, *pulEncryptedPartLen));
2257 log_rv(rv);
2258 return rv;
2259 }
2260
2261 CK_RV NSSDBGC_DecryptVerifyUpdate(
2262 CK_SESSION_HANDLE hSession,
2263 CK_BYTE_PTR pEncryptedPart,
2264 CK_ULONG ulEncryptedPartLen,
2265 CK_BYTE_PTR pPart,
2266 CK_ULONG_PTR pulPartLen
2267 )
2268 {
2269 COMMON_DEFINITIONS;
2270
2271 PR_LOG(modlog, 1, ("C_DecryptVerifyUpdate"));
2272 log_handle(3, fmt_hSession, hSession);
2273 PR_LOG(modlog, 3, (fmt_pEncryptedPart, pEncryptedPart));
2274 PR_LOG(modlog, 3, (fmt_ulEncryptedPartLen, ulEncryptedPartLen));
2275 PR_LOG(modlog, 3, (fmt_pPart, pPart));
2276 PR_LOG(modlog, 3, (fmt_pulPartLen, pulPartLen));
2277 nssdbg_start_time(FUNC_C_DECRYPTVERIFYUPDATE,&start);
2278 rv = module_functions->C_DecryptVerifyUpdate(hSession,
2279 pEncryptedPart,
2280 ulEncryptedPartLen,
2281 pPart,
2282 pulPartLen);
2283 nssdbg_finish_time(FUNC_C_DECRYPTVERIFYUPDATE,start);
2284 PR_LOG(modlog, 4, (fmt_spulPartLen, *pulPartLen));
2285 log_rv(rv);
2286 return rv;
2287 }
2288
2289 CK_RV NSSDBGC_GenerateKey(
2290 CK_SESSION_HANDLE hSession,
2291 CK_MECHANISM_PTR pMechanism,
2292 CK_ATTRIBUTE_PTR pTemplate,
2293 CK_ULONG ulCount,
2294 CK_OBJECT_HANDLE_PTR phKey
2295 )
2296 {
2297 COMMON_DEFINITIONS;
2298
2299 PR_LOG(modlog, 1, ("C_GenerateKey"));
2300 log_handle(3, fmt_hSession, hSession);
2301 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
2302 PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate));
2303 PR_LOG(modlog, 3, (fmt_ulCount, ulCount));
2304 PR_LOG(modlog, 3, (fmt_phKey, phKey));
2305 print_template(pTemplate, ulCount);
2306 print_mechanism(pMechanism);
2307 nssdbg_start_time(FUNC_C_GENERATEKEY,&start);
2308 rv = module_functions->C_GenerateKey(hSession,
2309 pMechanism,
2310 pTemplate,
2311 ulCount,
2312 phKey);
2313 nssdbg_finish_time(FUNC_C_GENERATEKEY,start);
2314 log_handle(4, fmt_sphKey, *phKey);
2315 log_rv(rv);
2316 return rv;
2317 }
2318
2319 CK_RV NSSDBGC_GenerateKeyPair(
2320 CK_SESSION_HANDLE hSession,
2321 CK_MECHANISM_PTR pMechanism,
2322 CK_ATTRIBUTE_PTR pPublicKeyTemplate,
2323 CK_ULONG ulPublicKeyAttributeCount,
2324 CK_ATTRIBUTE_PTR pPrivateKeyTemplate,
2325 CK_ULONG ulPrivateKeyAttributeCount,
2326 CK_OBJECT_HANDLE_PTR phPublicKey,
2327 CK_OBJECT_HANDLE_PTR phPrivateKey
2328 )
2329 {
2330 COMMON_DEFINITIONS;
2331
2332 PR_LOG(modlog, 1, ("C_GenerateKeyPair"));
2333 log_handle(3, fmt_hSession, hSession);
2334 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
2335 PR_LOG(modlog, 3, (" pPublicKeyTemplate = 0x%p", pPublicKeyTemplate));
2336 PR_LOG(modlog, 3, (" ulPublicKeyAttributeCount = %d", ulPublicKeyAttributeCount));
2337 PR_LOG(modlog, 3, (" pPrivateKeyTemplate = 0x%p", pPrivateKeyTemplate));
2338 PR_LOG(modlog, 3, (" ulPrivateKeyAttributeCount = %d", ulPrivateKeyAttributeCount));
2339 PR_LOG(modlog, 3, (" phPublicKey = 0x%p", phPublicKey));
2340 print_template(pPublicKeyTemplate, ulPublicKeyAttributeCount);
2341 PR_LOG(modlog, 3, (" phPrivateKey = 0x%p", phPrivateKey));
2342 print_template(pPrivateKeyTemplate, ulPrivateKeyAttributeCount);
2343 print_mechanism(pMechanism);
2344 nssdbg_start_time(FUNC_C_GENERATEKEYPAIR,&start);
2345 rv = module_functions->C_GenerateKeyPair(hSession,
2346 pMechanism,
2347 pPublicKeyTemplate,
2348 ulPublicKeyAttributeCount,
2349 pPrivateKeyTemplate,
2350 ulPrivateKeyAttributeCount,
2351 phPublicKey,
2352 phPrivateKey);
2353 nssdbg_finish_time(FUNC_C_GENERATEKEYPAIR,start);
2354 log_handle(4, " *phPublicKey = 0x%x", *phPublicKey);
2355 log_handle(4, " *phPrivateKey = 0x%x", *phPrivateKey);
2356 log_rv(rv);
2357 return rv;
2358 }
2359
2360 CK_RV NSSDBGC_WrapKey(
2361 CK_SESSION_HANDLE hSession,
2362 CK_MECHANISM_PTR pMechanism,
2363 CK_OBJECT_HANDLE hWrappingKey,
2364 CK_OBJECT_HANDLE hKey,
2365 CK_BYTE_PTR pWrappedKey,
2366 CK_ULONG_PTR pulWrappedKeyLen
2367 )
2368 {
2369 COMMON_DEFINITIONS;
2370
2371 PR_LOG(modlog, 1, ("C_WrapKey"));
2372 log_handle(3, fmt_hSession, hSession);
2373 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
2374 log_handle(3, " hWrappingKey = 0x%x", hWrappingKey);
2375 log_handle(3, fmt_hKey, hKey);
2376 PR_LOG(modlog, 3, (fmt_pWrappedKey, pWrappedKey));
2377 PR_LOG(modlog, 3, (" pulWrappedKeyLen = 0x%p", pulWrappedKeyLen));
2378 print_mechanism(pMechanism);
2379 nssdbg_start_time(FUNC_C_WRAPKEY,&start);
2380 rv = module_functions->C_WrapKey(hSession,
2381 pMechanism,
2382 hWrappingKey,
2383 hKey,
2384 pWrappedKey,
2385 pulWrappedKeyLen);
2386 nssdbg_finish_time(FUNC_C_WRAPKEY,start);
2387 PR_LOG(modlog, 4, (" *pulWrappedKeyLen = 0x%x", *pulWrappedKeyLen));
2388 log_rv(rv);
2389 return rv;
2390 }
2391
2392 CK_RV NSSDBGC_UnwrapKey(
2393 CK_SESSION_HANDLE hSession,
2394 CK_MECHANISM_PTR pMechanism,
2395 CK_OBJECT_HANDLE hUnwrappingKey,
2396 CK_BYTE_PTR pWrappedKey,
2397 CK_ULONG ulWrappedKeyLen,
2398 CK_ATTRIBUTE_PTR pTemplate,
2399 CK_ULONG ulAttributeCount,
2400 CK_OBJECT_HANDLE_PTR phKey
2401 )
2402 {
2403 COMMON_DEFINITIONS;
2404
2405 PR_LOG(modlog, 1, ("C_UnwrapKey"));
2406 log_handle(3, fmt_hSession, hSession);
2407 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
2408 log_handle(3, " hUnwrappingKey = 0x%x", hUnwrappingKey);
2409 PR_LOG(modlog, 3, (fmt_pWrappedKey, pWrappedKey));
2410 PR_LOG(modlog, 3, (" ulWrappedKeyLen = %d", ulWrappedKeyLen));
2411 PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate));
2412 PR_LOG(modlog, 3, (fmt_ulAttributeCount, ulAttributeCount));
2413 PR_LOG(modlog, 3, (fmt_phKey, phKey));
2414 print_template(pTemplate, ulAttributeCount);
2415 print_mechanism(pMechanism);
2416 nssdbg_start_time(FUNC_C_UNWRAPKEY,&start);
2417 rv = module_functions->C_UnwrapKey(hSession,
2418 pMechanism,
2419 hUnwrappingKey,
2420 pWrappedKey,
2421 ulWrappedKeyLen,
2422 pTemplate,
2423 ulAttributeCount,
2424 phKey);
2425 nssdbg_finish_time(FUNC_C_UNWRAPKEY,start);
2426 log_handle(4, fmt_sphKey, *phKey);
2427 log_rv(rv);
2428 return rv;
2429 }
2430
2431 CK_RV NSSDBGC_DeriveKey(
2432 CK_SESSION_HANDLE hSession,
2433 CK_MECHANISM_PTR pMechanism,
2434 CK_OBJECT_HANDLE hBaseKey,
2435 CK_ATTRIBUTE_PTR pTemplate,
2436 CK_ULONG ulAttributeCount,
2437 CK_OBJECT_HANDLE_PTR phKey
2438 )
2439 {
2440 COMMON_DEFINITIONS;
2441
2442 PR_LOG(modlog, 1, ("C_DeriveKey"));
2443 log_handle(3, fmt_hSession, hSession);
2444 PR_LOG(modlog, 3, (fmt_pMechanism, pMechanism));
2445 log_handle(3, " hBaseKey = 0x%x", hBaseKey);
2446 PR_LOG(modlog, 3, (fmt_pTemplate, pTemplate));
2447 PR_LOG(modlog, 3, (fmt_ulAttributeCount, ulAttributeCount));
2448 PR_LOG(modlog, 3, (fmt_phKey, phKey));
2449 print_template(pTemplate, ulAttributeCount);
2450 print_mechanism(pMechanism);
2451 nssdbg_start_time(FUNC_C_DERIVEKEY,&start);
2452 rv = module_functions->C_DeriveKey(hSession,
2453 pMechanism,
2454 hBaseKey,
2455 pTemplate,
2456 ulAttributeCount,
2457 phKey);
2458 nssdbg_finish_time(FUNC_C_DERIVEKEY,start);
2459 log_handle(4, fmt_sphKey, *phKey);
2460 log_rv(rv);
2461 return rv;
2462 }
2463
2464 CK_RV NSSDBGC_SeedRandom(
2465 CK_SESSION_HANDLE hSession,
2466 CK_BYTE_PTR pSeed,
2467 CK_ULONG ulSeedLen
2468 )
2469 {
2470 COMMON_DEFINITIONS;
2471
2472 PR_LOG(modlog, 1, ("C_SeedRandom"));
2473 log_handle(3, fmt_hSession, hSession);
2474 PR_LOG(modlog, 3, (" pSeed = 0x%p", pSeed));
2475 PR_LOG(modlog, 3, (" ulSeedLen = %d", ulSeedLen));
2476 nssdbg_start_time(FUNC_C_SEEDRANDOM,&start);
2477 rv = module_functions->C_SeedRandom(hSession,
2478 pSeed,
2479 ulSeedLen);
2480 nssdbg_finish_time(FUNC_C_SEEDRANDOM,start);
2481 log_rv(rv);
2482 return rv;
2483 }
2484
2485 CK_RV NSSDBGC_GenerateRandom(
2486 CK_SESSION_HANDLE hSession,
2487 CK_BYTE_PTR RandomData,
2488 CK_ULONG ulRandomLen
2489 )
2490 {
2491 COMMON_DEFINITIONS;
2492
2493 PR_LOG(modlog, 1, ("C_GenerateRandom"));
2494 log_handle(3, fmt_hSession, hSession);
2495 PR_LOG(modlog, 3, (" RandomData = 0x%p", RandomData));
2496 PR_LOG(modlog, 3, (" ulRandomLen = %d", ulRandomLen));
2497 nssdbg_start_time(FUNC_C_GENERATERANDOM,&start);
2498 rv = module_functions->C_GenerateRandom(hSession,
2499 RandomData,
2500 ulRandomLen);
2501 nssdbg_finish_time(FUNC_C_GENERATERANDOM,start);
2502 log_rv(rv);
2503 return rv;
2504 }
2505
2506 CK_RV NSSDBGC_GetFunctionStatus(
2507 CK_SESSION_HANDLE hSession
2508 )
2509 {
2510 COMMON_DEFINITIONS;
2511
2512 PR_LOG(modlog, 1, ("C_GetFunctionStatus"));
2513 log_handle(3, fmt_hSession, hSession);
2514 nssdbg_start_time(FUNC_C_GETFUNCTIONSTATUS,&start);
2515 rv = module_functions->C_GetFunctionStatus(hSession);
2516 nssdbg_finish_time(FUNC_C_GETFUNCTIONSTATUS,start);
2517 log_rv(rv);
2518 return rv;
2519 }
2520
2521 CK_RV NSSDBGC_CancelFunction(
2522 CK_SESSION_HANDLE hSession
2523 )
2524 {
2525 COMMON_DEFINITIONS;
2526
2527 PR_LOG(modlog, 1, ("C_CancelFunction"));
2528 log_handle(3, fmt_hSession, hSession);
2529 nssdbg_start_time(FUNC_C_CANCELFUNCTION,&start);
2530 rv = module_functions->C_CancelFunction(hSession);
2531 nssdbg_finish_time(FUNC_C_CANCELFUNCTION,start);
2532 log_rv(rv);
2533 return rv;
2534 }
2535
2536 CK_RV NSSDBGC_WaitForSlotEvent(
2537 CK_FLAGS flags,
2538 CK_SLOT_ID_PTR pSlot,
2539 CK_VOID_PTR pRserved
2540 )
2541 {
2542 COMMON_DEFINITIONS;
2543
2544 PR_LOG(modlog, 1, ("C_WaitForSlotEvent"));
2545 PR_LOG(modlog, 3, (fmt_flags, flags));
2546 PR_LOG(modlog, 3, (" pSlot = 0x%p", pSlot));
2547 PR_LOG(modlog, 3, (" pRserved = 0x%p", pRserved));
2548 nssdbg_start_time(FUNC_C_WAITFORSLOTEVENT,&start);
2549 rv = module_functions->C_WaitForSlotEvent(flags,
2550 pSlot,
2551 pRserved);
2552 nssdbg_finish_time(FUNC_C_WAITFORSLOTEVENT,start);
2553 log_rv(rv);
2554 return rv;
2555 }
2556
2557 CK_FUNCTION_LIST_PTR nss_InsertDeviceLog(
2558 CK_FUNCTION_LIST_PTR devEPV
2559 )
2560 {
2561 module_functions = devEPV;
2562 modlog = PR_NewLogModule("nss_mod_log");
2563 debug_functions.C_Initialize = NSSDBGC_Initialize;
2564 debug_functions.C_Finalize = NSSDBGC_Finalize;
2565 debug_functions.C_GetInfo = NSSDBGC_GetInfo;
2566 debug_functions.C_GetFunctionList = NSSDBGC_GetFunctionList;
2567 debug_functions.C_GetSlotList = NSSDBGC_GetSlotList;
2568 debug_functions.C_GetSlotInfo = NSSDBGC_GetSlotInfo;
2569 debug_functions.C_GetTokenInfo = NSSDBGC_GetTokenInfo;
2570 debug_functions.C_GetMechanismList = NSSDBGC_GetMechanismList;
2571 debug_functions.C_GetMechanismInfo = NSSDBGC_GetMechanismInfo;
2572 debug_functions.C_InitToken = NSSDBGC_InitToken;
2573 debug_functions.C_InitPIN = NSSDBGC_InitPIN;
2574 debug_functions.C_SetPIN = NSSDBGC_SetPIN;
2575 debug_functions.C_OpenSession = NSSDBGC_OpenSession;
2576 debug_functions.C_CloseSession = NSSDBGC_CloseSession;
2577 debug_functions.C_CloseAllSessions = NSSDBGC_CloseAllSessions;
2578 debug_functions.C_GetSessionInfo = NSSDBGC_GetSessionInfo;
2579 debug_functions.C_GetOperationState = NSSDBGC_GetOperationState;
2580 debug_functions.C_SetOperationState = NSSDBGC_SetOperationState;
2581 debug_functions.C_Login = NSSDBGC_Login;
2582 debug_functions.C_Logout = NSSDBGC_Logout;
2583 debug_functions.C_CreateObject = NSSDBGC_CreateObject;
2584 debug_functions.C_CopyObject = NSSDBGC_CopyObject;
2585 debug_functions.C_DestroyObject = NSSDBGC_DestroyObject;
2586 debug_functions.C_GetObjectSize = NSSDBGC_GetObjectSize;
2587 debug_functions.C_GetAttributeValue = NSSDBGC_GetAttributeValue;
2588 debug_functions.C_SetAttributeValue = NSSDBGC_SetAttributeValue;
2589 debug_functions.C_FindObjectsInit = NSSDBGC_FindObjectsInit;
2590 debug_functions.C_FindObjects = NSSDBGC_FindObjects;
2591 debug_functions.C_FindObjectsFinal = NSSDBGC_FindObjectsFinal;
2592 debug_functions.C_EncryptInit = NSSDBGC_EncryptInit;
2593 debug_functions.C_Encrypt = NSSDBGC_Encrypt;
2594 debug_functions.C_EncryptUpdate = NSSDBGC_EncryptUpdate;
2595 debug_functions.C_EncryptFinal = NSSDBGC_EncryptFinal;
2596 debug_functions.C_DecryptInit = NSSDBGC_DecryptInit;
2597 debug_functions.C_Decrypt = NSSDBGC_Decrypt;
2598 debug_functions.C_DecryptUpdate = NSSDBGC_DecryptUpdate;
2599 debug_functions.C_DecryptFinal = NSSDBGC_DecryptFinal;
2600 debug_functions.C_DigestInit = NSSDBGC_DigestInit;
2601 debug_functions.C_Digest = NSSDBGC_Digest;
2602 debug_functions.C_DigestUpdate = NSSDBGC_DigestUpdate;
2603 debug_functions.C_DigestKey = NSSDBGC_DigestKey;
2604 debug_functions.C_DigestFinal = NSSDBGC_DigestFinal;
2605 debug_functions.C_SignInit = NSSDBGC_SignInit;
2606 debug_functions.C_Sign = NSSDBGC_Sign;
2607 debug_functions.C_SignUpdate = NSSDBGC_SignUpdate;
2608 debug_functions.C_SignFinal = NSSDBGC_SignFinal;
2609 debug_functions.C_SignRecoverInit = NSSDBGC_SignRecoverInit;
2610 debug_functions.C_SignRecover = NSSDBGC_SignRecover;
2611 debug_functions.C_VerifyInit = NSSDBGC_VerifyInit;
2612 debug_functions.C_Verify = NSSDBGC_Verify;
2613 debug_functions.C_VerifyUpdate = NSSDBGC_VerifyUpdate;
2614 debug_functions.C_VerifyFinal = NSSDBGC_VerifyFinal;
2615 debug_functions.C_VerifyRecoverInit = NSSDBGC_VerifyRecoverInit;
2616 debug_functions.C_VerifyRecover = NSSDBGC_VerifyRecover;
2617 debug_functions.C_DigestEncryptUpdate = NSSDBGC_DigestEncryptUpdate;
2618 debug_functions.C_DecryptDigestUpdate = NSSDBGC_DecryptDigestUpdate;
2619 debug_functions.C_SignEncryptUpdate = NSSDBGC_SignEncryptUpdate;
2620 debug_functions.C_DecryptVerifyUpdate = NSSDBGC_DecryptVerifyUpdate;
2621 debug_functions.C_GenerateKey = NSSDBGC_GenerateKey;
2622 debug_functions.C_GenerateKeyPair = NSSDBGC_GenerateKeyPair;
2623 debug_functions.C_WrapKey = NSSDBGC_WrapKey;
2624 debug_functions.C_UnwrapKey = NSSDBGC_UnwrapKey;
2625 debug_functions.C_DeriveKey = NSSDBGC_DeriveKey;
2626 debug_functions.C_SeedRandom = NSSDBGC_SeedRandom;
2627 debug_functions.C_GenerateRandom = NSSDBGC_GenerateRandom;
2628 debug_functions.C_GetFunctionStatus = NSSDBGC_GetFunctionStatus;
2629 debug_functions.C_CancelFunction = NSSDBGC_CancelFunction;
2630 debug_functions.C_WaitForSlotEvent = NSSDBGC_WaitForSlotEvent;
2631 return &debug_functions;
2632 }
2633
2634 /*
2635 * scale the time factor up accordingly.
2636 * This routine tries to keep at least 2 significant figures on output.
2637 * If the time is 0, then indicate that with a 'z' for units.
2638 * If the time is greater than 10 minutes, output the time in minutes.
2639 * If the time is less than 10 minutes but greater than 10 seconds output
2640 * the time in second.
2641 * If the time is less than 10 seconds but greater than 10 milliseconds
2642 * output * the time in millisecond.
2643 * If the time is less than 10 milliseconds but greater than 0 ticks output
2644 * the time in microsecond.
2645 *
2646 */
2647 static PRUint32 getPrintTime(PRIntervalTime time ,char **type)
2648 {
2649 PRUint32 prTime;
2650
2651 /* detect a programming error by outputting 'bu' to the output stream
2652 * rather than crashing */
2653 *type = "bug";
2654 if (time == 0) {
2655 *type = "z";
2656 return 0;
2657 }
2658
2659 prTime = PR_IntervalToSeconds(time);
2660
2661 if (prTime >= 600) {
2662 *type="m";
2663 return prTime/60;
2664 }
2665 if (prTime >= 10) {
2666 *type="s";
2667 return prTime;
2668 }
2669 prTime = PR_IntervalToMilliseconds(time);
2670 if (prTime >= 10) {
2671 *type="ms";
2672 return prTime;
2673 }
2674 *type = "us";
2675 return PR_IntervalToMicroseconds(time);
2676 }
2677
2678 static void print_final_statistics(void)
2679 {
2680 int total_calls = 0;
2681 PRIntervalTime total_time = 0;
2682 PRUint32 pr_total_time;
2683 char *type;
2684 char *fname;
2685 FILE *outfile = NULL;
2686 int i;
2687
2688 fname = PR_GetEnv("NSS_OUTPUT_FILE");
2689 if (fname) {
2690 /* need to add an optional process id to the filename */
2691 outfile = fopen(fname,"w+");
2692 }
2693 if (!outfile) {
2694 outfile = stdout;
2695 }
2696
2697
2698 fprintf(outfile,"%-25s %10s %12s %12s %10s\n", "Function", "# Calls",
2699 "Time", "Avg.", "% Time");
2700 fprintf(outfile,"\n");
2701 for (i=0; i < nssdbg_prof_size; i++) {
2702 total_calls += nssdbg_prof_data[i].calls;
2703 total_time += nssdbg_prof_data[i].time;
2704 }
2705 for (i=0; i < nssdbg_prof_size; i++) {
2706 PRIntervalTime time = nssdbg_prof_data[i].time;
2707 PRUint32 usTime = PR_IntervalToMicroseconds(time);
2708 PRUint32 prTime = 0;
2709 PRUint32 calls = nssdbg_prof_data[i].calls;
2710 /* don't print out functions that weren't even called */
2711 if (calls == 0) {
2712 continue;
2713 }
2714
2715 prTime = getPrintTime(time,&type);
2716
2717 fprintf(outfile,"%-25s %10d %10d%2s ", nssdbg_prof_data[i].function,
2718 calls, prTime, type);
2719 /* for now always output the average in microseconds */
2720 fprintf(outfile,"%10.2f%2s", (float)usTime / (float)calls, "us" );
2721 fprintf(outfile,"%10.2f%%", ((float)time / (float)total_time) * 100);
2722 fprintf(outfile,"\n");
2723 }
2724 fprintf(outfile,"\n");
2725
2726 pr_total_time = getPrintTime(total_time,&type);
2727
2728 fprintf(outfile,"%25s %10d %10d%2s\n", "Totals", total_calls,
2729 pr_total_time, type);
2730 fprintf(outfile,"\n\nMaximum number of concurrent open sessions: %d\n\n",
2731 maxOpenSessions);
2732 fflush (outfile);
2733 if (outfile != stdout) {
2734 fclose(outfile);
2735 }
2736 }
2737
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)