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