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
5 #ifndef DEV_H
6 #include "dev.h"
7 #endif /* DEV_H */
8
9 #ifndef PKIM_H
10 #include "pkim.h"
11 #endif /* PKIM_H */
12
13 #ifndef PKISTORE_H
14 #include "pkistore.h"
15 #endif /* PKISTORE_H */
16
17 extern const NSSError NSS_ERROR_NOT_FOUND;
18 extern const NSSError NSS_ERROR_INVALID_ARGUMENT;
19
20 NSS_IMPLEMENT NSSCryptoContext *
nssCryptoContext_Create(NSSTrustDomain * td,NSSCallback * uhhOpt)21 nssCryptoContext_Create(
22 NSSTrustDomain *td,
23 NSSCallback *uhhOpt)
24 {
25 NSSArena *arena;
26 NSSCryptoContext *rvCC;
27 arena = NSSArena_Create();
28 if (!arena) {
29 return NULL;
30 }
31 rvCC = nss_ZNEW(arena, NSSCryptoContext);
32 if (!rvCC) {
33 return NULL;
34 }
35 rvCC->td = td;
36 rvCC->arena = arena;
37 rvCC->certStore = nssCertificateStore_Create(rvCC->arena);
38 if (!rvCC->certStore) {
39 nssArena_Destroy(arena);
40 return NULL;
41 }
42
43 return rvCC;
44 }
45
46 NSS_IMPLEMENT PRStatus
NSSCryptoContext_Destroy(NSSCryptoContext * cc)47 NSSCryptoContext_Destroy(NSSCryptoContext *cc)
48 {
49 PRStatus status = PR_SUCCESS;
50 PORT_Assert(cc && cc->certStore);
51 if (!cc) {
52 return PR_FAILURE;
53 }
54 if (cc->certStore) {
55 status = nssCertificateStore_Destroy(cc->certStore);
56 if (status == PR_FAILURE) {
57 return status;
58 }
59 } else {
60 status = PR_FAILURE;
61 }
62 nssArena_Destroy(cc->arena);
63 return status;
64 }
65
66 NSS_IMPLEMENT PRStatus
NSSCryptoContext_SetDefaultCallback(NSSCryptoContext * td,NSSCallback * newCallback,NSSCallback ** oldCallbackOpt)67 NSSCryptoContext_SetDefaultCallback(
68 NSSCryptoContext *td,
69 NSSCallback *newCallback,
70 NSSCallback **oldCallbackOpt)
71 {
72 nss_SetError(NSS_ERROR_NOT_FOUND);
73 return PR_FAILURE;
74 }
75
76 NSS_IMPLEMENT NSSCallback *
NSSCryptoContext_GetDefaultCallback(NSSCryptoContext * td,PRStatus * statusOpt)77 NSSCryptoContext_GetDefaultCallback(
78 NSSCryptoContext *td,
79 PRStatus *statusOpt)
80 {
81 nss_SetError(NSS_ERROR_NOT_FOUND);
82 return NULL;
83 }
84
85 NSS_IMPLEMENT NSSTrustDomain *
NSSCryptoContext_GetTrustDomain(NSSCryptoContext * td)86 NSSCryptoContext_GetTrustDomain(NSSCryptoContext *td)
87 {
88 nss_SetError(NSS_ERROR_NOT_FOUND);
89 return NULL;
90 }
91
92 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindOrImportCertificate(NSSCryptoContext * cc,NSSCertificate * c)93 NSSCryptoContext_FindOrImportCertificate(
94 NSSCryptoContext *cc,
95 NSSCertificate *c)
96 {
97 NSSCertificate *rvCert = NULL;
98
99 PORT_Assert(cc && cc->certStore);
100 if (!cc || !cc->certStore) {
101 nss_SetError(NSS_ERROR_INVALID_ARGUMENT);
102 return rvCert;
103 }
104 rvCert = nssCertificateStore_FindOrAdd(cc->certStore, c);
105 if (rvCert == c && c->object.cryptoContext != cc) {
106 PORT_Assert(!c->object.cryptoContext);
107 c->object.cryptoContext = cc;
108 }
109 if (rvCert) {
110 /* an NSSCertificate cannot be part of two crypto contexts
111 ** simultaneously. If this assertion fails, then there is
112 ** a serious Stan design flaw.
113 */
114 PORT_Assert(cc == c->object.cryptoContext);
115 }
116 return rvCert;
117 }
118
119 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_ImportPKIXCertificate(NSSCryptoContext * cc,struct NSSPKIXCertificateStr * pc)120 NSSCryptoContext_ImportPKIXCertificate(
121 NSSCryptoContext *cc,
122 struct NSSPKIXCertificateStr *pc)
123 {
124 nss_SetError(NSS_ERROR_NOT_FOUND);
125 return NULL;
126 }
127
128 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_ImportEncodedCertificate(NSSCryptoContext * cc,NSSBER * ber)129 NSSCryptoContext_ImportEncodedCertificate(
130 NSSCryptoContext *cc,
131 NSSBER *ber)
132 {
133 nss_SetError(NSS_ERROR_NOT_FOUND);
134 return NULL;
135 }
136
137 NSS_IMPLEMENT PRStatus
NSSCryptoContext_ImportEncodedPKIXCertificateChain(NSSCryptoContext * cc,NSSBER * ber)138 NSSCryptoContext_ImportEncodedPKIXCertificateChain(
139 NSSCryptoContext *cc,
140 NSSBER *ber)
141 {
142 nss_SetError(NSS_ERROR_NOT_FOUND);
143 return PR_FAILURE;
144 }
145
146 NSS_IMPLEMENT PRStatus
nssCryptoContext_ImportTrust(NSSCryptoContext * cc,NSSTrust * trust)147 nssCryptoContext_ImportTrust(
148 NSSCryptoContext *cc,
149 NSSTrust *trust)
150 {
151 PRStatus nssrv;
152 PORT_Assert(cc && cc->certStore);
153 if (!cc || !cc->certStore) {
154 return PR_FAILURE;
155 }
156 nssrv = nssCertificateStore_AddTrust(cc->certStore, trust);
157 #if 0
158 if (nssrv == PR_SUCCESS) {
159 trust->object.cryptoContext = cc;
160 }
161 #endif
162 return nssrv;
163 }
164
165 NSS_IMPLEMENT PRStatus
nssCryptoContext_ImportSMIMEProfile(NSSCryptoContext * cc,nssSMIMEProfile * profile)166 nssCryptoContext_ImportSMIMEProfile(
167 NSSCryptoContext *cc,
168 nssSMIMEProfile *profile)
169 {
170 PRStatus nssrv;
171 PORT_Assert(cc && cc->certStore);
172 if (!cc || !cc->certStore) {
173 return PR_FAILURE;
174 }
175 nssrv = nssCertificateStore_AddSMIMEProfile(cc->certStore, profile);
176 #if 0
177 if (nssrv == PR_SUCCESS) {
178 profile->object.cryptoContext = cc;
179 }
180 #endif
181 return nssrv;
182 }
183
184 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindBestCertificateByNickname(NSSCryptoContext * cc,const NSSUTF8 * name,NSSTime * timeOpt,NSSUsage * usage,NSSPolicies * policiesOpt)185 NSSCryptoContext_FindBestCertificateByNickname(
186 NSSCryptoContext *cc,
187 const NSSUTF8 *name,
188 NSSTime *timeOpt, /* NULL for "now" */
189 NSSUsage *usage,
190 NSSPolicies *policiesOpt /* NULL for none */
191 )
192 {
193 NSSCertificate **certs;
194 NSSCertificate *rvCert = NULL;
195 PORT_Assert(cc && cc->certStore);
196 if (!cc || !cc->certStore) {
197 return NULL;
198 }
199 certs = nssCertificateStore_FindCertificatesByNickname(cc->certStore,
200 name,
201 NULL, 0, NULL);
202 if (certs) {
203 rvCert = nssCertificateArray_FindBestCertificate(certs,
204 timeOpt,
205 usage,
206 policiesOpt);
207 nssCertificateArray_Destroy(certs);
208 }
209 return rvCert;
210 }
211
212 NSS_IMPLEMENT NSSCertificate **
NSSCryptoContext_FindCertificatesByNickname(NSSCryptoContext * cc,NSSUTF8 * name,NSSCertificate * rvOpt[],PRUint32 maximumOpt,NSSArena * arenaOpt)213 NSSCryptoContext_FindCertificatesByNickname(
214 NSSCryptoContext *cc,
215 NSSUTF8 *name,
216 NSSCertificate *rvOpt[],
217 PRUint32 maximumOpt, /* 0 for no max */
218 NSSArena *arenaOpt)
219 {
220 NSSCertificate **rvCerts;
221 PORT_Assert(cc && cc->certStore);
222 if (!cc || !cc->certStore) {
223 return NULL;
224 }
225 rvCerts = nssCertificateStore_FindCertificatesByNickname(cc->certStore,
226 name,
227 rvOpt,
228 maximumOpt,
229 arenaOpt);
230 return rvCerts;
231 }
232
233 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindCertificateByIssuerAndSerialNumber(NSSCryptoContext * cc,NSSDER * issuer,NSSDER * serialNumber)234 NSSCryptoContext_FindCertificateByIssuerAndSerialNumber(
235 NSSCryptoContext *cc,
236 NSSDER *issuer,
237 NSSDER *serialNumber)
238 {
239 PORT_Assert(cc && cc->certStore);
240 if (!cc || !cc->certStore) {
241 return NULL;
242 }
243 return nssCertificateStore_FindCertificateByIssuerAndSerialNumber(
244 cc->certStore,
245 issuer,
246 serialNumber);
247 }
248
249 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindBestCertificateBySubject(NSSCryptoContext * cc,NSSDER * subject,NSSTime * timeOpt,NSSUsage * usage,NSSPolicies * policiesOpt)250 NSSCryptoContext_FindBestCertificateBySubject(
251 NSSCryptoContext *cc,
252 NSSDER *subject,
253 NSSTime *timeOpt,
254 NSSUsage *usage,
255 NSSPolicies *policiesOpt)
256 {
257 NSSCertificate **certs;
258 NSSCertificate *rvCert = NULL;
259 PORT_Assert(cc && cc->certStore);
260 if (!cc || !cc->certStore) {
261 return NULL;
262 }
263 certs = nssCertificateStore_FindCertificatesBySubject(cc->certStore,
264 subject,
265 NULL, 0, NULL);
266 if (certs) {
267 rvCert = nssCertificateArray_FindBestCertificate(certs,
268 timeOpt,
269 usage,
270 policiesOpt);
271 nssCertificateArray_Destroy(certs);
272 }
273 return rvCert;
274 }
275
276 NSS_IMPLEMENT NSSCertificate **
nssCryptoContext_FindCertificatesBySubject(NSSCryptoContext * cc,NSSDER * subject,NSSCertificate * rvOpt[],PRUint32 maximumOpt,NSSArena * arenaOpt)277 nssCryptoContext_FindCertificatesBySubject(
278 NSSCryptoContext *cc,
279 NSSDER *subject,
280 NSSCertificate *rvOpt[],
281 PRUint32 maximumOpt, /* 0 for no max */
282 NSSArena *arenaOpt)
283 {
284 NSSCertificate **rvCerts;
285 PORT_Assert(cc && cc->certStore);
286 if (!cc || !cc->certStore) {
287 return NULL;
288 }
289 rvCerts = nssCertificateStore_FindCertificatesBySubject(cc->certStore,
290 subject,
291 rvOpt,
292 maximumOpt,
293 arenaOpt);
294 return rvCerts;
295 }
296
297 NSS_IMPLEMENT NSSCertificate **
NSSCryptoContext_FindCertificatesBySubject(NSSCryptoContext * cc,NSSDER * subject,NSSCertificate * rvOpt[],PRUint32 maximumOpt,NSSArena * arenaOpt)298 NSSCryptoContext_FindCertificatesBySubject(
299 NSSCryptoContext *cc,
300 NSSDER *subject,
301 NSSCertificate *rvOpt[],
302 PRUint32 maximumOpt, /* 0 for no max */
303 NSSArena *arenaOpt)
304 {
305 return nssCryptoContext_FindCertificatesBySubject(cc, subject,
306 rvOpt, maximumOpt,
307 arenaOpt);
308 }
309
310 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindBestCertificateByNameComponents(NSSCryptoContext * cc,NSSUTF8 * nameComponents,NSSTime * timeOpt,NSSUsage * usage,NSSPolicies * policiesOpt)311 NSSCryptoContext_FindBestCertificateByNameComponents(
312 NSSCryptoContext *cc,
313 NSSUTF8 *nameComponents,
314 NSSTime *timeOpt,
315 NSSUsage *usage,
316 NSSPolicies *policiesOpt)
317 {
318 nss_SetError(NSS_ERROR_NOT_FOUND);
319 return NULL;
320 }
321
322 NSS_IMPLEMENT NSSCertificate **
NSSCryptoContext_FindCertificatesByNameComponents(NSSCryptoContext * cc,NSSUTF8 * nameComponents,NSSCertificate * rvOpt[],PRUint32 maximumOpt,NSSArena * arenaOpt)323 NSSCryptoContext_FindCertificatesByNameComponents(
324 NSSCryptoContext *cc,
325 NSSUTF8 *nameComponents,
326 NSSCertificate *rvOpt[],
327 PRUint32 maximumOpt, /* 0 for no max */
328 NSSArena *arenaOpt)
329 {
330 nss_SetError(NSS_ERROR_NOT_FOUND);
331 return NULL;
332 }
333
334 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindCertificateByEncodedCertificate(NSSCryptoContext * cc,NSSBER * encodedCertificate)335 NSSCryptoContext_FindCertificateByEncodedCertificate(
336 NSSCryptoContext *cc,
337 NSSBER *encodedCertificate)
338 {
339 PORT_Assert(cc && cc->certStore);
340 if (!cc || !cc->certStore) {
341 return NULL;
342 }
343 return nssCertificateStore_FindCertificateByEncodedCertificate(
344 cc->certStore,
345 encodedCertificate);
346 }
347
348 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindBestCertificateByEmail(NSSCryptoContext * cc,NSSASCII7 * email,NSSTime * timeOpt,NSSUsage * usage,NSSPolicies * policiesOpt)349 NSSCryptoContext_FindBestCertificateByEmail(
350 NSSCryptoContext *cc,
351 NSSASCII7 *email,
352 NSSTime *timeOpt,
353 NSSUsage *usage,
354 NSSPolicies *policiesOpt)
355 {
356 NSSCertificate **certs;
357 NSSCertificate *rvCert = NULL;
358
359 PORT_Assert(cc && cc->certStore);
360 if (!cc || !cc->certStore) {
361 return NULL;
362 }
363 certs = nssCertificateStore_FindCertificatesByEmail(cc->certStore,
364 email,
365 NULL, 0, NULL);
366 if (certs) {
367 rvCert = nssCertificateArray_FindBestCertificate(certs,
368 timeOpt,
369 usage,
370 policiesOpt);
371 nssCertificateArray_Destroy(certs);
372 }
373 return rvCert;
374 }
375
376 NSS_IMPLEMENT NSSCertificate **
NSSCryptoContext_FindCertificatesByEmail(NSSCryptoContext * cc,NSSASCII7 * email,NSSCertificate * rvOpt[],PRUint32 maximumOpt,NSSArena * arenaOpt)377 NSSCryptoContext_FindCertificatesByEmail(
378 NSSCryptoContext *cc,
379 NSSASCII7 *email,
380 NSSCertificate *rvOpt[],
381 PRUint32 maximumOpt, /* 0 for no max */
382 NSSArena *arenaOpt)
383 {
384 NSSCertificate **rvCerts;
385 PORT_Assert(cc && cc->certStore);
386 if (!cc || !cc->certStore) {
387 return NULL;
388 }
389 rvCerts = nssCertificateStore_FindCertificatesByEmail(cc->certStore,
390 email,
391 rvOpt,
392 maximumOpt,
393 arenaOpt);
394 return rvCerts;
395 }
396
397 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindCertificateByOCSPHash(NSSCryptoContext * cc,NSSItem * hash)398 NSSCryptoContext_FindCertificateByOCSPHash(
399 NSSCryptoContext *cc,
400 NSSItem *hash)
401 {
402 nss_SetError(NSS_ERROR_NOT_FOUND);
403 return NULL;
404 }
405
406 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindBestUserCertificate(NSSCryptoContext * cc,NSSTime * timeOpt,NSSUsage * usage,NSSPolicies * policiesOpt)407 NSSCryptoContext_FindBestUserCertificate(
408 NSSCryptoContext *cc,
409 NSSTime *timeOpt,
410 NSSUsage *usage,
411 NSSPolicies *policiesOpt)
412 {
413 nss_SetError(NSS_ERROR_NOT_FOUND);
414 return NULL;
415 }
416
417 NSS_IMPLEMENT NSSCertificate **
NSSCryptoContext_FindUserCertificates(NSSCryptoContext * cc,NSSTime * timeOpt,NSSUsage * usageOpt,NSSPolicies * policiesOpt,NSSCertificate ** rvOpt,PRUint32 rvLimit,NSSArena * arenaOpt)418 NSSCryptoContext_FindUserCertificates(
419 NSSCryptoContext *cc,
420 NSSTime *timeOpt,
421 NSSUsage *usageOpt,
422 NSSPolicies *policiesOpt,
423 NSSCertificate **rvOpt,
424 PRUint32 rvLimit, /* zero for no limit */
425 NSSArena *arenaOpt)
426 {
427 nss_SetError(NSS_ERROR_NOT_FOUND);
428 return NULL;
429 }
430
431 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindBestUserCertificateForSSLClientAuth(NSSCryptoContext * cc,NSSUTF8 * sslHostOpt,NSSDER * rootCAsOpt[],PRUint32 rootCAsMaxOpt,NSSAlgorithmAndParameters * apOpt,NSSPolicies * policiesOpt)432 NSSCryptoContext_FindBestUserCertificateForSSLClientAuth(
433 NSSCryptoContext *cc,
434 NSSUTF8 *sslHostOpt,
435 NSSDER *rootCAsOpt[], /* null pointer for none */
436 PRUint32 rootCAsMaxOpt, /* zero means list is null-terminated */
437 NSSAlgorithmAndParameters *apOpt,
438 NSSPolicies *policiesOpt)
439 {
440 nss_SetError(NSS_ERROR_NOT_FOUND);
441 return NULL;
442 }
443
444 NSS_IMPLEMENT NSSCertificate **
NSSCryptoContext_FindUserCertificatesForSSLClientAuth(NSSCryptoContext * cc,NSSUTF8 * sslHostOpt,NSSDER * rootCAsOpt[],PRUint32 rootCAsMaxOpt,NSSAlgorithmAndParameters * apOpt,NSSPolicies * policiesOpt,NSSCertificate ** rvOpt,PRUint32 rvLimit,NSSArena * arenaOpt)445 NSSCryptoContext_FindUserCertificatesForSSLClientAuth(
446 NSSCryptoContext *cc,
447 NSSUTF8 *sslHostOpt,
448 NSSDER *rootCAsOpt[], /* null pointer for none */
449 PRUint32 rootCAsMaxOpt, /* zero means list is null-terminated */
450 NSSAlgorithmAndParameters *apOpt,
451 NSSPolicies *policiesOpt,
452 NSSCertificate **rvOpt,
453 PRUint32 rvLimit, /* zero for no limit */
454 NSSArena *arenaOpt)
455 {
456 nss_SetError(NSS_ERROR_NOT_FOUND);
457 return NULL;
458 }
459
460 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindBestUserCertificateForEmailSigning(NSSCryptoContext * cc,NSSASCII7 * signerOpt,NSSASCII7 * recipientOpt,NSSAlgorithmAndParameters * apOpt,NSSPolicies * policiesOpt)461 NSSCryptoContext_FindBestUserCertificateForEmailSigning(
462 NSSCryptoContext *cc,
463 NSSASCII7 *signerOpt,
464 NSSASCII7 *recipientOpt,
465 /* anything more here? */
466 NSSAlgorithmAndParameters *apOpt,
467 NSSPolicies *policiesOpt)
468 {
469 nss_SetError(NSS_ERROR_NOT_FOUND);
470 return NULL;
471 }
472
473 NSS_IMPLEMENT NSSCertificate *
NSSCryptoContext_FindUserCertificatesForEmailSigning(NSSCryptoContext * cc,NSSASCII7 * signerOpt,NSSASCII7 * recipientOpt,NSSAlgorithmAndParameters * apOpt,NSSPolicies * policiesOpt,NSSCertificate ** rvOpt,PRUint32 rvLimit,NSSArena * arenaOpt)474 NSSCryptoContext_FindUserCertificatesForEmailSigning(
475 NSSCryptoContext *cc,
476 NSSASCII7 *signerOpt, /* fgmr or a more general name? */
477 NSSASCII7 *recipientOpt,
478 /* anything more here? */
479 NSSAlgorithmAndParameters *apOpt,
480 NSSPolicies *policiesOpt,
481 NSSCertificate **rvOpt,
482 PRUint32 rvLimit, /* zero for no limit */
483 NSSArena *arenaOpt)
484 {
485 nss_SetError(NSS_ERROR_NOT_FOUND);
486 return NULL;
487 }
488
489 NSS_IMPLEMENT NSSTrust *
nssCryptoContext_FindTrustForCertificate(NSSCryptoContext * cc,NSSCertificate * cert)490 nssCryptoContext_FindTrustForCertificate(
491 NSSCryptoContext *cc,
492 NSSCertificate *cert)
493 {
494 PORT_Assert(cc && cc->certStore);
495 if (!cc || !cc->certStore) {
496 return NULL;
497 }
498 return nssCertificateStore_FindTrustForCertificate(cc->certStore, cert);
499 }
500
501 NSS_IMPLEMENT nssSMIMEProfile *
nssCryptoContext_FindSMIMEProfileForCertificate(NSSCryptoContext * cc,NSSCertificate * cert)502 nssCryptoContext_FindSMIMEProfileForCertificate(
503 NSSCryptoContext *cc,
504 NSSCertificate *cert)
505 {
506 PORT_Assert(cc && cc->certStore);
507 if (!cc || !cc->certStore) {
508 return NULL;
509 }
510 return nssCertificateStore_FindSMIMEProfileForCertificate(cc->certStore,
511 cert);
512 }
513
514 NSS_IMPLEMENT PRStatus
NSSCryptoContext_GenerateKeyPair(NSSCryptoContext * cc,NSSAlgorithmAndParameters * ap,NSSPrivateKey ** pvkOpt,NSSPublicKey ** pbkOpt,PRBool privateKeyIsSensitive,NSSToken * destination,NSSCallback * uhhOpt)515 NSSCryptoContext_GenerateKeyPair(
516 NSSCryptoContext *cc,
517 NSSAlgorithmAndParameters *ap,
518 NSSPrivateKey **pvkOpt,
519 NSSPublicKey **pbkOpt,
520 PRBool privateKeyIsSensitive,
521 NSSToken *destination,
522 NSSCallback *uhhOpt)
523 {
524 nss_SetError(NSS_ERROR_NOT_FOUND);
525 return PR_FAILURE;
526 }
527
528 NSS_IMPLEMENT NSSSymmetricKey *
NSSCryptoContext_GenerateSymmetricKey(NSSCryptoContext * cc,NSSAlgorithmAndParameters * ap,PRUint32 keysize,NSSToken * destination,NSSCallback * uhhOpt)529 NSSCryptoContext_GenerateSymmetricKey(
530 NSSCryptoContext *cc,
531 NSSAlgorithmAndParameters *ap,
532 PRUint32 keysize,
533 NSSToken *destination,
534 NSSCallback *uhhOpt)
535 {
536 nss_SetError(NSS_ERROR_NOT_FOUND);
537 return NULL;
538 }
539
540 NSS_IMPLEMENT NSSSymmetricKey *
NSSCryptoContext_GenerateSymmetricKeyFromPassword(NSSCryptoContext * cc,NSSAlgorithmAndParameters * ap,NSSUTF8 * passwordOpt,NSSToken * destinationOpt,NSSCallback * uhhOpt)541 NSSCryptoContext_GenerateSymmetricKeyFromPassword(
542 NSSCryptoContext *cc,
543 NSSAlgorithmAndParameters *ap,
544 NSSUTF8 *passwordOpt, /* if null, prompt */
545 NSSToken *destinationOpt,
546 NSSCallback *uhhOpt)
547 {
548 nss_SetError(NSS_ERROR_NOT_FOUND);
549 return NULL;
550 }
551
552 NSS_IMPLEMENT NSSSymmetricKey *
NSSCryptoContext_FindSymmetricKeyByAlgorithmAndKeyID(NSSCryptoContext * cc,NSSOID * algorithm,NSSItem * keyID,NSSCallback * uhhOpt)553 NSSCryptoContext_FindSymmetricKeyByAlgorithmAndKeyID(
554 NSSCryptoContext *cc,
555 NSSOID *algorithm,
556 NSSItem *keyID,
557 NSSCallback *uhhOpt)
558 {
559 nss_SetError(NSS_ERROR_NOT_FOUND);
560 return NULL;
561 }
562
563 struct token_session_str {
564 NSSToken *token;
565 nssSession *session;
566 };
567
568 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_Decrypt(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSItem * encryptedData,NSSCallback * uhhOpt,NSSItem * rvOpt,NSSArena * arenaOpt)569 NSSCryptoContext_Decrypt(
570 NSSCryptoContext *cc,
571 NSSAlgorithmAndParameters *apOpt,
572 NSSItem *encryptedData,
573 NSSCallback *uhhOpt,
574 NSSItem *rvOpt,
575 NSSArena *arenaOpt)
576 {
577 nss_SetError(NSS_ERROR_NOT_FOUND);
578 return NULL;
579 }
580
581 NSS_IMPLEMENT PRStatus
NSSCryptoContext_BeginDecrypt(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSCallback * uhhOpt)582 NSSCryptoContext_BeginDecrypt(
583 NSSCryptoContext *cc,
584 NSSAlgorithmAndParameters *apOpt,
585 NSSCallback *uhhOpt)
586 {
587 nss_SetError(NSS_ERROR_NOT_FOUND);
588 return PR_FAILURE;
589 }
590
591 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_ContinueDecrypt(NSSCryptoContext * cc,NSSItem * data,NSSItem * rvOpt,NSSArena * arenaOpt)592 NSSCryptoContext_ContinueDecrypt(
593 NSSCryptoContext *cc,
594 NSSItem *data,
595 NSSItem *rvOpt,
596 NSSArena *arenaOpt)
597 {
598 nss_SetError(NSS_ERROR_NOT_FOUND);
599 return NULL;
600 }
601
602 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_FinishDecrypt(NSSCryptoContext * cc,NSSItem * rvOpt,NSSArena * arenaOpt)603 NSSCryptoContext_FinishDecrypt(
604 NSSCryptoContext *cc,
605 NSSItem *rvOpt,
606 NSSArena *arenaOpt)
607 {
608 nss_SetError(NSS_ERROR_NOT_FOUND);
609 return NULL;
610 }
611
612 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_Sign(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSItem * data,NSSCallback * uhhOpt,NSSItem * rvOpt,NSSArena * arenaOpt)613 NSSCryptoContext_Sign(
614 NSSCryptoContext *cc,
615 NSSAlgorithmAndParameters *apOpt,
616 NSSItem *data,
617 NSSCallback *uhhOpt,
618 NSSItem *rvOpt,
619 NSSArena *arenaOpt)
620 {
621 nss_SetError(NSS_ERROR_NOT_FOUND);
622 return NULL;
623 }
624
625 NSS_IMPLEMENT PRStatus
NSSCryptoContext_BeginSign(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSCallback * uhhOpt)626 NSSCryptoContext_BeginSign(
627 NSSCryptoContext *cc,
628 NSSAlgorithmAndParameters *apOpt,
629 NSSCallback *uhhOpt)
630 {
631 nss_SetError(NSS_ERROR_NOT_FOUND);
632 return PR_FAILURE;
633 }
634
635 NSS_IMPLEMENT PRStatus
NSSCryptoContext_ContinueSign(NSSCryptoContext * cc,NSSItem * data)636 NSSCryptoContext_ContinueSign(
637 NSSCryptoContext *cc,
638 NSSItem *data)
639 {
640 nss_SetError(NSS_ERROR_NOT_FOUND);
641 return PR_FAILURE;
642 }
643
644 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_FinishSign(NSSCryptoContext * cc,NSSItem * rvOpt,NSSArena * arenaOpt)645 NSSCryptoContext_FinishSign(
646 NSSCryptoContext *cc,
647 NSSItem *rvOpt,
648 NSSArena *arenaOpt)
649 {
650 nss_SetError(NSS_ERROR_NOT_FOUND);
651 return NULL;
652 }
653
654 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_SignRecover(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSItem * data,NSSCallback * uhhOpt,NSSItem * rvOpt,NSSArena * arenaOpt)655 NSSCryptoContext_SignRecover(
656 NSSCryptoContext *cc,
657 NSSAlgorithmAndParameters *apOpt,
658 NSSItem *data,
659 NSSCallback *uhhOpt,
660 NSSItem *rvOpt,
661 NSSArena *arenaOpt)
662 {
663 nss_SetError(NSS_ERROR_NOT_FOUND);
664 return NULL;
665 }
666
667 NSS_IMPLEMENT PRStatus
NSSCryptoContext_BeginSignRecover(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSCallback * uhhOpt)668 NSSCryptoContext_BeginSignRecover(
669 NSSCryptoContext *cc,
670 NSSAlgorithmAndParameters *apOpt,
671 NSSCallback *uhhOpt)
672 {
673 nss_SetError(NSS_ERROR_NOT_FOUND);
674 return PR_FAILURE;
675 }
676
677 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_ContinueSignRecover(NSSCryptoContext * cc,NSSItem * data,NSSItem * rvOpt,NSSArena * arenaOpt)678 NSSCryptoContext_ContinueSignRecover(
679 NSSCryptoContext *cc,
680 NSSItem *data,
681 NSSItem *rvOpt,
682 NSSArena *arenaOpt)
683 {
684 nss_SetError(NSS_ERROR_NOT_FOUND);
685 return NULL;
686 }
687
688 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_FinishSignRecover(NSSCryptoContext * cc,NSSItem * rvOpt,NSSArena * arenaOpt)689 NSSCryptoContext_FinishSignRecover(
690 NSSCryptoContext *cc,
691 NSSItem *rvOpt,
692 NSSArena *arenaOpt)
693 {
694 nss_SetError(NSS_ERROR_NOT_FOUND);
695 return NULL;
696 }
697
698 NSS_IMPLEMENT NSSSymmetricKey *
NSSCryptoContext_UnwrapSymmetricKey(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSItem * wrappedKey,NSSCallback * uhhOpt)699 NSSCryptoContext_UnwrapSymmetricKey(
700 NSSCryptoContext *cc,
701 NSSAlgorithmAndParameters *apOpt,
702 NSSItem *wrappedKey,
703 NSSCallback *uhhOpt)
704 {
705 nss_SetError(NSS_ERROR_NOT_FOUND);
706 return NULL;
707 }
708
709 NSS_IMPLEMENT NSSSymmetricKey *
NSSCryptoContext_DeriveSymmetricKey(NSSCryptoContext * cc,NSSPublicKey * bk,NSSAlgorithmAndParameters * apOpt,NSSOID * target,PRUint32 keySizeOpt,NSSOperations operations,NSSCallback * uhhOpt)710 NSSCryptoContext_DeriveSymmetricKey(
711 NSSCryptoContext *cc,
712 NSSPublicKey *bk,
713 NSSAlgorithmAndParameters *apOpt,
714 NSSOID *target,
715 PRUint32 keySizeOpt, /* zero for best allowed */
716 NSSOperations operations,
717 NSSCallback *uhhOpt)
718 {
719 nss_SetError(NSS_ERROR_NOT_FOUND);
720 return NULL;
721 }
722
723 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_Encrypt(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSItem * data,NSSCallback * uhhOpt,NSSItem * rvOpt,NSSArena * arenaOpt)724 NSSCryptoContext_Encrypt(
725 NSSCryptoContext *cc,
726 NSSAlgorithmAndParameters *apOpt,
727 NSSItem *data,
728 NSSCallback *uhhOpt,
729 NSSItem *rvOpt,
730 NSSArena *arenaOpt)
731 {
732 nss_SetError(NSS_ERROR_NOT_FOUND);
733 return NULL;
734 }
735
736 NSS_IMPLEMENT PRStatus
NSSCryptoContext_BeginEncrypt(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSCallback * uhhOpt)737 NSSCryptoContext_BeginEncrypt(
738 NSSCryptoContext *cc,
739 NSSAlgorithmAndParameters *apOpt,
740 NSSCallback *uhhOpt)
741 {
742 nss_SetError(NSS_ERROR_NOT_FOUND);
743 return PR_FAILURE;
744 }
745
746 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_ContinueEncrypt(NSSCryptoContext * cc,NSSItem * data,NSSItem * rvOpt,NSSArena * arenaOpt)747 NSSCryptoContext_ContinueEncrypt(
748 NSSCryptoContext *cc,
749 NSSItem *data,
750 NSSItem *rvOpt,
751 NSSArena *arenaOpt)
752 {
753 nss_SetError(NSS_ERROR_NOT_FOUND);
754 return NULL;
755 }
756
757 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_FinishEncrypt(NSSCryptoContext * cc,NSSItem * rvOpt,NSSArena * arenaOpt)758 NSSCryptoContext_FinishEncrypt(
759 NSSCryptoContext *cc,
760 NSSItem *rvOpt,
761 NSSArena *arenaOpt)
762 {
763 nss_SetError(NSS_ERROR_NOT_FOUND);
764 return NULL;
765 }
766
767 NSS_IMPLEMENT PRStatus
NSSCryptoContext_Verify(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSItem * data,NSSItem * signature,NSSCallback * uhhOpt)768 NSSCryptoContext_Verify(
769 NSSCryptoContext *cc,
770 NSSAlgorithmAndParameters *apOpt,
771 NSSItem *data,
772 NSSItem *signature,
773 NSSCallback *uhhOpt)
774 {
775 nss_SetError(NSS_ERROR_NOT_FOUND);
776 return PR_FAILURE;
777 }
778
779 NSS_IMPLEMENT PRStatus
NSSCryptoContext_BeginVerify(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSItem * signature,NSSCallback * uhhOpt)780 NSSCryptoContext_BeginVerify(
781 NSSCryptoContext *cc,
782 NSSAlgorithmAndParameters *apOpt,
783 NSSItem *signature,
784 NSSCallback *uhhOpt)
785 {
786 nss_SetError(NSS_ERROR_NOT_FOUND);
787 return PR_FAILURE;
788 }
789
790 NSS_IMPLEMENT PRStatus
NSSCryptoContext_ContinueVerify(NSSCryptoContext * cc,NSSItem * data)791 NSSCryptoContext_ContinueVerify(
792 NSSCryptoContext *cc,
793 NSSItem *data)
794 {
795 nss_SetError(NSS_ERROR_NOT_FOUND);
796 return PR_FAILURE;
797 }
798
799 NSS_IMPLEMENT PRStatus
NSSCryptoContext_FinishVerify(NSSCryptoContext * cc)800 NSSCryptoContext_FinishVerify(
801 NSSCryptoContext *cc)
802 {
803 nss_SetError(NSS_ERROR_NOT_FOUND);
804 return PR_FAILURE;
805 }
806
807 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_VerifyRecover(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSItem * signature,NSSCallback * uhhOpt,NSSItem * rvOpt,NSSArena * arenaOpt)808 NSSCryptoContext_VerifyRecover(
809 NSSCryptoContext *cc,
810 NSSAlgorithmAndParameters *apOpt,
811 NSSItem *signature,
812 NSSCallback *uhhOpt,
813 NSSItem *rvOpt,
814 NSSArena *arenaOpt)
815 {
816 nss_SetError(NSS_ERROR_NOT_FOUND);
817 return NULL;
818 }
819
820 NSS_IMPLEMENT PRStatus
NSSCryptoContext_BeginVerifyRecover(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSCallback * uhhOpt)821 NSSCryptoContext_BeginVerifyRecover(
822 NSSCryptoContext *cc,
823 NSSAlgorithmAndParameters *apOpt,
824 NSSCallback *uhhOpt)
825 {
826 nss_SetError(NSS_ERROR_NOT_FOUND);
827 return PR_FAILURE;
828 }
829
830 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_ContinueVerifyRecover(NSSCryptoContext * cc,NSSItem * data,NSSItem * rvOpt,NSSArena * arenaOpt)831 NSSCryptoContext_ContinueVerifyRecover(
832 NSSCryptoContext *cc,
833 NSSItem *data,
834 NSSItem *rvOpt,
835 NSSArena *arenaOpt)
836 {
837 nss_SetError(NSS_ERROR_NOT_FOUND);
838 return NULL;
839 }
840
841 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_FinishVerifyRecover(NSSCryptoContext * cc,NSSItem * rvOpt,NSSArena * arenaOpt)842 NSSCryptoContext_FinishVerifyRecover(
843 NSSCryptoContext *cc,
844 NSSItem *rvOpt,
845 NSSArena *arenaOpt)
846 {
847 nss_SetError(NSS_ERROR_NOT_FOUND);
848 return NULL;
849 }
850
851 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_WrapSymmetricKey(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSSymmetricKey * keyToWrap,NSSCallback * uhhOpt,NSSItem * rvOpt,NSSArena * arenaOpt)852 NSSCryptoContext_WrapSymmetricKey(
853 NSSCryptoContext *cc,
854 NSSAlgorithmAndParameters *apOpt,
855 NSSSymmetricKey *keyToWrap,
856 NSSCallback *uhhOpt,
857 NSSItem *rvOpt,
858 NSSArena *arenaOpt)
859 {
860 nss_SetError(NSS_ERROR_NOT_FOUND);
861 return NULL;
862 }
863
864 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_Digest(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSItem * data,NSSCallback * uhhOpt,NSSItem * rvOpt,NSSArena * arenaOpt)865 NSSCryptoContext_Digest(
866 NSSCryptoContext *cc,
867 NSSAlgorithmAndParameters *apOpt,
868 NSSItem *data,
869 NSSCallback *uhhOpt,
870 NSSItem *rvOpt,
871 NSSArena *arenaOpt)
872 {
873 return nssToken_Digest(cc->token, cc->session, apOpt,
874 data, rvOpt, arenaOpt);
875 }
876
877 NSS_IMPLEMENT PRStatus
NSSCryptoContext_BeginDigest(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSCallback * uhhOpt)878 NSSCryptoContext_BeginDigest(
879 NSSCryptoContext *cc,
880 NSSAlgorithmAndParameters *apOpt,
881 NSSCallback *uhhOpt)
882 {
883 return nssToken_BeginDigest(cc->token, cc->session, apOpt);
884 }
885
886 NSS_IMPLEMENT PRStatus
NSSCryptoContext_ContinueDigest(NSSCryptoContext * cc,NSSAlgorithmAndParameters * apOpt,NSSItem * item)887 NSSCryptoContext_ContinueDigest(
888 NSSCryptoContext *cc,
889 NSSAlgorithmAndParameters *apOpt,
890 NSSItem *item)
891 {
892 /*
893 NSSAlgorithmAndParameters *ap;
894 ap = (apOpt) ? apOpt : cc->ap;
895 */
896 /* why apOpt? can't change it at this point... */
897 return nssToken_ContinueDigest(cc->token, cc->session, item);
898 }
899
900 NSS_IMPLEMENT NSSItem *
NSSCryptoContext_FinishDigest(NSSCryptoContext * cc,NSSItem * rvOpt,NSSArena * arenaOpt)901 NSSCryptoContext_FinishDigest(
902 NSSCryptoContext *cc,
903 NSSItem *rvOpt,
904 NSSArena *arenaOpt)
905 {
906 return nssToken_FinishDigest(cc->token, cc->session, rvOpt, arenaOpt);
907 }
908
909 NSS_IMPLEMENT NSSCryptoContext *
NSSCryptoContext_Clone(NSSCryptoContext * cc)910 NSSCryptoContext_Clone(NSSCryptoContext *cc)
911 {
912 nss_SetError(NSS_ERROR_NOT_FOUND);
913 return NULL;
914 }
915