Back to index

lightning-sunbird  0.9+nobinonly
smime.h
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the Netscape security libraries.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 1994-2000
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 /*
00038  * Header file for routines specific to S/MIME.  Keep things that are pure
00039  * pkcs7 out of here; this is for S/MIME policy, S/MIME interoperability, etc.
00040  *
00041  * $Id: smime.h,v 1.8 2004/04/25 15:03:16 gerv%gerv.net Exp $
00042  */
00043 
00044 #ifndef _SECMIME_H_
00045 #define _SECMIME_H_ 1
00046 
00047 #include "cms.h"
00048 
00049 
00050 /************************************************************************/
00051 SEC_BEGIN_PROTOS
00052 
00053 /*
00054  * Initialize the local recording of the user S/MIME cipher preferences.
00055  * This function is called once for each cipher, the order being
00056  * important (first call records greatest preference, and so on).
00057  * When finished, it is called with a "which" of CIPHER_FAMILID_MASK.
00058  * If the function is called again after that, it is assumed that
00059  * the preferences are being reset, and the old preferences are
00060  * discarded.
00061  *
00062  * XXX This is for a particular user, and right now the storage is
00063  * XXX local, static.  The preference should be stored elsewhere to allow
00064  * XXX for multiple uses of one library?  How does SSL handle this;
00065  * XXX it has something similar?
00066  *
00067  *  - The "which" values are defined in ciferfam.h (the SMIME_* values,
00068  *    for example SMIME_DES_CBC_56).
00069  *  - If "on" is non-zero then the named cipher is enabled, otherwise
00070  *    it is disabled.  (It is not necessary to call the function for
00071  *    ciphers that are disabled, however, as that is the default.)
00072  *
00073  * If the cipher preference is successfully recorded, SECSuccess
00074  * is returned.  Otherwise SECFailure is returned.  The only errors
00075  * are due to failure allocating memory or bad parameters/calls:
00076  *     SEC_ERROR_XXX ("which" is not in the S/MIME cipher family)
00077  *     SEC_ERROR_XXX (function is being called more times than there
00078  *            are known/expected ciphers)
00079  */
00080 extern SECStatus NSS_SMIMEUtil_EnableCipher(long which, int on);
00081 
00082 /*
00083  * Initialize the local recording of the S/MIME policy.
00084  * This function is called to allow/disallow a particular cipher.
00085  *
00086  * XXX This is for a the current module, I think, so local, static storage
00087  * XXX is okay.  Is that correct, or could multiple uses of the same
00088  * XXX library expect to operate under different policies?
00089  *
00090  *  - The "which" values are defined in ciferfam.h (the SMIME_* values,
00091  *    for example SMIME_DES_CBC_56).
00092  *  - If "on" is non-zero then the named cipher is enabled, otherwise
00093  *    it is disabled.
00094  */
00095 extern SECStatus NSS_SMIMEUtils_AllowCipher(long which, int on);
00096 
00097 /*
00098  * Does the current policy allow S/MIME decryption of this particular
00099  * algorithm and keysize?
00100  */
00101 extern PRBool NSS_SMIMEUtil_DecryptionAllowed(SECAlgorithmID *algid, PK11SymKey *key);
00102 
00103 /*
00104  * Does the current policy allow *any* S/MIME encryption (or decryption)?
00105  *
00106  * This tells whether or not *any* S/MIME encryption can be done,
00107  * according to policy.  Callers may use this to do nicer user interface
00108  * (say, greying out a checkbox so a user does not even try to encrypt
00109  * a message when they are not allowed to) or for any reason they want
00110  * to check whether S/MIME encryption (or decryption, for that matter)
00111  * may be done.
00112  *
00113  * It takes no arguments.  The return value is a simple boolean:
00114  *   PR_TRUE means encryption (or decryption) is *possible*
00115  *     (but may still fail due to other reasons, like because we cannot
00116  *     find all the necessary certs, etc.; PR_TRUE is *not* a guarantee)
00117  *   PR_FALSE means encryption (or decryption) is not permitted
00118  *
00119  * There are no errors from this routine.
00120  */
00121 extern PRBool NSS_SMIMEUtil_EncryptionPossible(void);
00122 
00123 /*
00124  * NSS_SMIMEUtil_CreateSMIMECapabilities - get S/MIME capabilities attr value
00125  *
00126  * scans the list of allowed and enabled ciphers and construct a PKCS9-compliant
00127  * S/MIME capabilities attribute value.
00128  */
00129 extern SECStatus NSS_SMIMEUtil_CreateSMIMECapabilities(PLArenaPool *poolp, SECItem *dest, PRBool includeFortezzaCiphers);
00130 
00131 /*
00132  * NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value
00133  */
00134 extern SECStatus NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs(PLArenaPool *poolp, SECItem *dest, CERTCertificate *cert);
00135 
00136 /*
00137  * NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value using MS oid
00138  */
00139 extern SECStatus NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs(PLArenaPool *poolp, SECItem *dest, CERTCertificate *cert);
00140 
00141 /*
00142  * NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference - find cert marked by EncryptionKeyPreference
00143  *          attribute
00144  */
00145 extern CERTCertificate *NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference(CERTCertDBHandle *certdb, SECItem *DERekp);
00146 
00147 /*
00148  * NSS_SMIMEUtil_FindBulkAlgForRecipients - find bulk algorithm suitable for all recipients
00149  */
00150 extern SECStatus
00151 NSS_SMIMEUtil_FindBulkAlgForRecipients(CERTCertificate **rcerts, SECOidTag *bulkalgtag, int *keysize);
00152 
00153 /************************************************************************/
00154 SEC_END_PROTOS
00155 
00156 #endif /* _SECMIME_H_ */