Blame nss/lib/smime/smime.h

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