/gecko_api/include/smime.h
C++ Header | 156 lines | 16 code | 16 blank | 124 comment | 0 complexity | 9f38d10b14475c92fd210da6168f0ad5 MD5 | raw file
1/* ***** BEGIN LICENSE BLOCK ***** 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 * 4 * The contents of this file are subject to the Mozilla Public License Version 5 * 1.1 (the "License"); you may not use this file except in compliance with 6 * the License. You may obtain a copy of the License at 7 * http://www.mozilla.org/MPL/ 8 * 9 * Software distributed under the License is distributed on an "AS IS" basis, 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 * for the specific language governing rights and limitations under the 12 * License. 13 * 14 * The Original Code is the Netscape security libraries. 15 * 16 * The Initial Developer of the Original Code is 17 * Netscape Communications Corporation. 18 * Portions created by the Initial Developer are Copyright (C) 1994-2000 19 * the Initial Developer. All Rights Reserved. 20 * 21 * Contributor(s): 22 * 23 * Alternatively, the contents of this file may be used under the terms of 24 * either the GNU General Public License Version 2 or later (the "GPL"), or 25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 26 * in which case the provisions of the GPL or the LGPL are applicable instead 27 * of those above. If you wish to allow use of your version of this file only 28 * under the terms of either the GPL or the LGPL, and not to allow others to 29 * use your version of this file under the terms of the MPL, indicate your 30 * decision by deleting the provisions above and replace them with the notice 31 * and other provisions required by the GPL or the LGPL. If you do not delete 32 * the provisions above, a recipient may use your version of this file under 33 * the terms of any one of the MPL, the GPL or the LGPL. 34 * 35 * ***** END LICENSE BLOCK ***** */ 36 37/* 38 * Header file for routines specific to S/MIME. Keep things that are pure 39 * pkcs7 out of here; this is for S/MIME policy, S/MIME interoperability, etc. 40 * 41 * $Id: smime.h,v 1.8 2004/04/25 15:03:16 gerv%gerv.net Exp $ 42 */ 43 44#ifndef _SECMIME_H_ 45#define _SECMIME_H_ 1 46 47#include "cms.h" 48 49 50/************************************************************************/ 51SEC_BEGIN_PROTOS 52 53/* 54 * Initialize the local recording of the user S/MIME cipher preferences. 55 * This function is called once for each cipher, the order being 56 * important (first call records greatest preference, and so on). 57 * When finished, it is called with a "which" of CIPHER_FAMILID_MASK. 58 * If the function is called again after that, it is assumed that 59 * the preferences are being reset, and the old preferences are 60 * discarded. 61 * 62 * XXX This is for a particular user, and right now the storage is 63 * XXX local, static. The preference should be stored elsewhere to allow 64 * XXX for multiple uses of one library? How does SSL handle this; 65 * XXX it has something similar? 66 * 67 * - The "which" values are defined in ciferfam.h (the SMIME_* values, 68 * for example SMIME_DES_CBC_56). 69 * - If "on" is non-zero then the named cipher is enabled, otherwise 70 * it is disabled. (It is not necessary to call the function for 71 * ciphers that are disabled, however, as that is the default.) 72 * 73 * If the cipher preference is successfully recorded, SECSuccess 74 * is returned. Otherwise SECFailure is returned. The only errors 75 * are due to failure allocating memory or bad parameters/calls: 76 * SEC_ERROR_XXX ("which" is not in the S/MIME cipher family) 77 * SEC_ERROR_XXX (function is being called more times than there 78 * are known/expected ciphers) 79 */ 80extern SECStatus NSS_SMIMEUtil_EnableCipher(long which, int on); 81 82/* 83 * Initialize the local recording of the S/MIME policy. 84 * This function is called to allow/disallow a particular cipher. 85 * 86 * XXX This is for a the current module, I think, so local, static storage 87 * XXX is okay. Is that correct, or could multiple uses of the same 88 * XXX library expect to operate under different policies? 89 * 90 * - The "which" values are defined in ciferfam.h (the SMIME_* values, 91 * for example SMIME_DES_CBC_56). 92 * - If "on" is non-zero then the named cipher is enabled, otherwise 93 * it is disabled. 94 */ 95extern SECStatus NSS_SMIMEUtils_AllowCipher(long which, int on); 96 97/* 98 * Does the current policy allow S/MIME decryption of this particular 99 * algorithm and keysize? 100 */ 101extern PRBool NSS_SMIMEUtil_DecryptionAllowed(SECAlgorithmID *algid, PK11SymKey *key); 102 103/* 104 * Does the current policy allow *any* S/MIME encryption (or decryption)? 105 * 106 * This tells whether or not *any* S/MIME encryption can be done, 107 * according to policy. Callers may use this to do nicer user interface 108 * (say, greying out a checkbox so a user does not even try to encrypt 109 * a message when they are not allowed to) or for any reason they want 110 * to check whether S/MIME encryption (or decryption, for that matter) 111 * may be done. 112 * 113 * It takes no arguments. The return value is a simple boolean: 114 * PR_TRUE means encryption (or decryption) is *possible* 115 * (but may still fail due to other reasons, like because we cannot 116 * find all the necessary certs, etc.; PR_TRUE is *not* a guarantee) 117 * PR_FALSE means encryption (or decryption) is not permitted 118 * 119 * There are no errors from this routine. 120 */ 121extern PRBool NSS_SMIMEUtil_EncryptionPossible(void); 122 123/* 124 * NSS_SMIMEUtil_CreateSMIMECapabilities - get S/MIME capabilities attr value 125 * 126 * scans the list of allowed and enabled ciphers and construct a PKCS9-compliant 127 * S/MIME capabilities attribute value. 128 */ 129extern SECStatus NSS_SMIMEUtil_CreateSMIMECapabilities(PLArenaPool *poolp, SECItem *dest, PRBool includeFortezzaCiphers); 130 131/* 132 * NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value 133 */ 134extern SECStatus NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs(PLArenaPool *poolp, SECItem *dest, CERTCertificate *cert); 135 136/* 137 * NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value using MS oid 138 */ 139extern SECStatus NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs(PLArenaPool *poolp, SECItem *dest, CERTCertificate *cert); 140 141/* 142 * NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference - find cert marked by EncryptionKeyPreference 143 * attribute 144 */ 145extern CERTCertificate *NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference(CERTCertDBHandle *certdb, SECItem *DERekp); 146 147/* 148 * NSS_SMIMEUtil_FindBulkAlgForRecipients - find bulk algorithm suitable for all recipients 149 */ 150extern SECStatus 151NSS_SMIMEUtil_FindBulkAlgForRecipients(CERTCertificate **rcerts, SECOidTag *bulkalgtag, int *keysize); 152 153/************************************************************************/ 154SEC_END_PROTOS 155 156#endif /* _SECMIME_H_ */