michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Header file for routines specific to S/MIME. Keep things that are pure michael@0: * pkcs7 out of here; this is for S/MIME policy, S/MIME interoperability, etc. michael@0: */ michael@0: michael@0: #ifndef _SMIME_H_ michael@0: #define _SMIME_H_ 1 michael@0: michael@0: #include "cms.h" michael@0: michael@0: michael@0: /************************************************************************/ michael@0: SEC_BEGIN_PROTOS michael@0: michael@0: /* michael@0: * Initialize the local recording of the user S/MIME cipher preferences. michael@0: * This function is called once for each cipher, the order being michael@0: * important (first call records greatest preference, and so on). michael@0: * When finished, it is called with a "which" of CIPHER_FAMILID_MASK. michael@0: * If the function is called again after that, it is assumed that michael@0: * the preferences are being reset, and the old preferences are michael@0: * discarded. michael@0: * michael@0: * XXX This is for a particular user, and right now the storage is michael@0: * XXX local, static. The preference should be stored elsewhere to allow michael@0: * XXX for multiple uses of one library? How does SSL handle this; michael@0: * XXX it has something similar? michael@0: * michael@0: * - The "which" values are defined in ciferfam.h (the SMIME_* values, michael@0: * for example SMIME_DES_CBC_56). michael@0: * - If "on" is non-zero then the named cipher is enabled, otherwise michael@0: * it is disabled. (It is not necessary to call the function for michael@0: * ciphers that are disabled, however, as that is the default.) michael@0: * michael@0: * If the cipher preference is successfully recorded, SECSuccess michael@0: * is returned. Otherwise SECFailure is returned. The only errors michael@0: * are due to failure allocating memory or bad parameters/calls: michael@0: * SEC_ERROR_XXX ("which" is not in the S/MIME cipher family) michael@0: * SEC_ERROR_XXX (function is being called more times than there michael@0: * are known/expected ciphers) michael@0: */ michael@0: extern SECStatus NSS_SMIMEUtil_EnableCipher(long which, int on); michael@0: michael@0: /* michael@0: * Initialize the local recording of the S/MIME policy. michael@0: * This function is called to allow/disallow a particular cipher. michael@0: * michael@0: * XXX This is for the current module, I think, so local, static storage michael@0: * XXX is okay. Is that correct, or could multiple uses of the same michael@0: * XXX library expect to operate under different policies? michael@0: * michael@0: * - The "which" values are defined in ciferfam.h (the SMIME_* values, michael@0: * for example SMIME_DES_CBC_56). michael@0: * - If "on" is non-zero then the named cipher is enabled, otherwise michael@0: * it is disabled. michael@0: */ michael@0: extern SECStatus NSS_SMIMEUtils_AllowCipher(long which, int on); michael@0: michael@0: /* michael@0: * Does the current policy allow S/MIME decryption of this particular michael@0: * algorithm and keysize? michael@0: */ michael@0: extern PRBool NSS_SMIMEUtil_DecryptionAllowed(SECAlgorithmID *algid, PK11SymKey *key); michael@0: michael@0: /* michael@0: * Does the current policy allow *any* S/MIME encryption (or decryption)? michael@0: * michael@0: * This tells whether or not *any* S/MIME encryption can be done, michael@0: * according to policy. Callers may use this to do nicer user interface michael@0: * (say, greying out a checkbox so a user does not even try to encrypt michael@0: * a message when they are not allowed to) or for any reason they want michael@0: * to check whether S/MIME encryption (or decryption, for that matter) michael@0: * may be done. michael@0: * michael@0: * It takes no arguments. The return value is a simple boolean: michael@0: * PR_TRUE means encryption (or decryption) is *possible* michael@0: * (but may still fail due to other reasons, like because we cannot michael@0: * find all the necessary certs, etc.; PR_TRUE is *not* a guarantee) michael@0: * PR_FALSE means encryption (or decryption) is not permitted michael@0: * michael@0: * There are no errors from this routine. michael@0: */ michael@0: extern PRBool NSS_SMIMEUtil_EncryptionPossible(void); michael@0: michael@0: /* michael@0: * NSS_SMIMEUtil_CreateSMIMECapabilities - get S/MIME capabilities attr value michael@0: * michael@0: * scans the list of allowed and enabled ciphers and construct a PKCS9-compliant michael@0: * S/MIME capabilities attribute value. michael@0: */ michael@0: extern SECStatus NSS_SMIMEUtil_CreateSMIMECapabilities(PLArenaPool *poolp, SECItem *dest); michael@0: michael@0: /* michael@0: * NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value michael@0: */ michael@0: extern SECStatus NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs(PLArenaPool *poolp, SECItem *dest, CERTCertificate *cert); michael@0: michael@0: /* michael@0: * NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value using MS oid michael@0: */ michael@0: extern SECStatus NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs(PLArenaPool *poolp, SECItem *dest, CERTCertificate *cert); michael@0: michael@0: /* michael@0: * NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference - find cert marked by EncryptionKeyPreference michael@0: * attribute michael@0: */ michael@0: extern CERTCertificate *NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference(CERTCertDBHandle *certdb, SECItem *DERekp); michael@0: michael@0: /* michael@0: * NSS_SMIMEUtil_FindBulkAlgForRecipients - find bulk algorithm suitable for all recipients michael@0: */ michael@0: extern SECStatus michael@0: NSS_SMIMEUtil_FindBulkAlgForRecipients(CERTCertificate **rcerts, SECOidTag *bulkalgtag, int *keysize); michael@0: michael@0: /* michael@0: * Return a boolean that indicates whether the underlying library michael@0: * will perform as the caller expects. michael@0: * michael@0: * The only argument is a string, which should be the version michael@0: * identifier of the NSS library. That string will be compared michael@0: * against a string that represents the actual build version of michael@0: * the S/MIME library. michael@0: */ michael@0: extern PRBool NSSSMIME_VersionCheck(const char *importedVersion); michael@0: michael@0: /* michael@0: * Returns a const string of the S/MIME library version. michael@0: */ michael@0: extern const char *NSSSMIME_GetVersion(void); michael@0: michael@0: /************************************************************************/ michael@0: SEC_END_PROTOS michael@0: michael@0: #endif /* _SECMIME_H_ */