OLD | NEW |
| (Empty) |
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 /* | |
6 * Header file for routines specific to S/MIME. Keep things that are pure | |
7 * pkcs7 out of here; this is for S/MIME policy, S/MIME interoperability, etc. | |
8 * | |
9 * $Id: smime.h,v 1.13 2012/09/21 21:58:44 wtc%google.com Exp $ | |
10 */ | |
11 | |
12 #ifndef _SECMIME_H_ | |
13 #define _SECMIME_H_ 1 | |
14 | |
15 #include "cms.h" | |
16 | |
17 | |
18 /************************************************************************/ | |
19 SEC_BEGIN_PROTOS | |
20 | |
21 /* | |
22 * Initialize the local recording of the user S/MIME cipher preferences. | |
23 * This function is called once for each cipher, the order being | |
24 * important (first call records greatest preference, and so on). | |
25 * When finished, it is called with a "which" of CIPHER_FAMILID_MASK. | |
26 * If the function is called again after that, it is assumed that | |
27 * the preferences are being reset, and the old preferences are | |
28 * discarded. | |
29 * | |
30 * XXX This is for a particular user, and right now the storage is | |
31 * XXX local, static. The preference should be stored elsewhere to allow | |
32 * XXX for multiple uses of one library? How does SSL handle this; | |
33 * XXX it has something similar? | |
34 * | |
35 * - The "which" values are defined in ciferfam.h (the SMIME_* values, | |
36 * for example SMIME_DES_CBC_56). | |
37 * - If "on" is non-zero then the named cipher is enabled, otherwise | |
38 * it is disabled. (It is not necessary to call the function for | |
39 * ciphers that are disabled, however, as that is the default.) | |
40 * | |
41 * If the cipher preference is successfully recorded, SECSuccess | |
42 * is returned. Otherwise SECFailure is returned. The only errors | |
43 * are due to failure allocating memory or bad parameters/calls: | |
44 * SEC_ERROR_XXX ("which" is not in the S/MIME cipher family) | |
45 * SEC_ERROR_XXX (function is being called more times than there | |
46 * are known/expected ciphers) | |
47 */ | |
48 extern SECStatus NSS_SMIMEUtil_EnableCipher(long which, int on); | |
49 | |
50 /* | |
51 * Initialize the local recording of the S/MIME policy. | |
52 * This function is called to allow/disallow a particular cipher. | |
53 * | |
54 * XXX This is for the current module, I think, so local, static storage | |
55 * XXX is okay. Is that correct, or could multiple uses of the same | |
56 * XXX library expect to operate under different policies? | |
57 * | |
58 * - The "which" values are defined in ciferfam.h (the SMIME_* values, | |
59 * for example SMIME_DES_CBC_56). | |
60 * - If "on" is non-zero then the named cipher is enabled, otherwise | |
61 * it is disabled. | |
62 */ | |
63 extern SECStatus NSS_SMIMEUtils_AllowCipher(long which, int on); | |
64 | |
65 /* | |
66 * Does the current policy allow S/MIME decryption of this particular | |
67 * algorithm and keysize? | |
68 */ | |
69 extern PRBool NSS_SMIMEUtil_DecryptionAllowed(SECAlgorithmID *algid, PK11SymKey
*key); | |
70 | |
71 /* | |
72 * Does the current policy allow *any* S/MIME encryption (or decryption)? | |
73 * | |
74 * This tells whether or not *any* S/MIME encryption can be done, | |
75 * according to policy. Callers may use this to do nicer user interface | |
76 * (say, greying out a checkbox so a user does not even try to encrypt | |
77 * a message when they are not allowed to) or for any reason they want | |
78 * to check whether S/MIME encryption (or decryption, for that matter) | |
79 * may be done. | |
80 * | |
81 * It takes no arguments. The return value is a simple boolean: | |
82 * PR_TRUE means encryption (or decryption) is *possible* | |
83 * (but may still fail due to other reasons, like because we cannot | |
84 * find all the necessary certs, etc.; PR_TRUE is *not* a guarantee) | |
85 * PR_FALSE means encryption (or decryption) is not permitted | |
86 * | |
87 * There are no errors from this routine. | |
88 */ | |
89 extern PRBool NSS_SMIMEUtil_EncryptionPossible(void); | |
90 | |
91 /* | |
92 * NSS_SMIMEUtil_CreateSMIMECapabilities - get S/MIME capabilities attr value | |
93 * | |
94 * scans the list of allowed and enabled ciphers and construct a PKCS9-compliant | |
95 * S/MIME capabilities attribute value. | |
96 */ | |
97 extern SECStatus NSS_SMIMEUtil_CreateSMIMECapabilities(PLArenaPool *poolp, SECIt
em *dest); | |
98 | |
99 /* | |
100 * NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs - create S/MIME encryption key preferenc
es attr value | |
101 */ | |
102 extern SECStatus NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs(PLArenaPool *poolp, SECIte
m *dest, CERTCertificate *cert); | |
103 | |
104 /* | |
105 * NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs - create S/MIME encryption key prefere
nces attr value using MS oid | |
106 */ | |
107 extern SECStatus NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs(PLArenaPool *poolp, SECI
tem *dest, CERTCertificate *cert); | |
108 | |
109 /* | |
110 * NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference - find cert marked by Encryp
tionKeyPreference | |
111 * attribute | |
112 */ | |
113 extern CERTCertificate *NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference(CERTCer
tDBHandle *certdb, SECItem *DERekp); | |
114 | |
115 /* | |
116 * NSS_SMIMEUtil_FindBulkAlgForRecipients - find bulk algorithm suitable for all
recipients | |
117 */ | |
118 extern SECStatus | |
119 NSS_SMIMEUtil_FindBulkAlgForRecipients(CERTCertificate **rcerts, SECOidTag *bulk
algtag, int *keysize); | |
120 | |
121 /* | |
122 * Return a boolean that indicates whether the underlying library | |
123 * will perform as the caller expects. | |
124 * | |
125 * The only argument is a string, which should be the version | |
126 * identifier of the NSS library. That string will be compared | |
127 * against a string that represents the actual build version of | |
128 * the S/MIME library. | |
129 */ | |
130 extern PRBool NSSSMIME_VersionCheck(const char *importedVersion); | |
131 | |
132 /* | |
133 * Returns a const string of the S/MIME library version. | |
134 */ | |
135 extern const char *NSSSMIME_GetVersion(void); | |
136 | |
137 /************************************************************************/ | |
138 SEC_END_PROTOS | |
139 | |
140 #endif /* _SECMIME_H_ */ | |
OLD | NEW |