security/nss/lib/smime/smime.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/smime/smime.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,138 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +/*
     1.9 + * Header file for routines specific to S/MIME.  Keep things that are pure
    1.10 + * pkcs7 out of here; this is for S/MIME policy, S/MIME interoperability, etc.
    1.11 + */
    1.12 +
    1.13 +#ifndef _SMIME_H_
    1.14 +#define _SMIME_H_ 1
    1.15 +
    1.16 +#include "cms.h"
    1.17 +
    1.18 +
    1.19 +/************************************************************************/
    1.20 +SEC_BEGIN_PROTOS
    1.21 +
    1.22 +/*
    1.23 + * Initialize the local recording of the user S/MIME cipher preferences.
    1.24 + * This function is called once for each cipher, the order being
    1.25 + * important (first call records greatest preference, and so on).
    1.26 + * When finished, it is called with a "which" of CIPHER_FAMILID_MASK.
    1.27 + * If the function is called again after that, it is assumed that
    1.28 + * the preferences are being reset, and the old preferences are
    1.29 + * discarded.
    1.30 + *
    1.31 + * XXX This is for a particular user, and right now the storage is
    1.32 + * XXX local, static.  The preference should be stored elsewhere to allow
    1.33 + * XXX for multiple uses of one library?  How does SSL handle this;
    1.34 + * XXX it has something similar?
    1.35 + *
    1.36 + *  - The "which" values are defined in ciferfam.h (the SMIME_* values,
    1.37 + *    for example SMIME_DES_CBC_56).
    1.38 + *  - If "on" is non-zero then the named cipher is enabled, otherwise
    1.39 + *    it is disabled.  (It is not necessary to call the function for
    1.40 + *    ciphers that are disabled, however, as that is the default.)
    1.41 + *
    1.42 + * If the cipher preference is successfully recorded, SECSuccess
    1.43 + * is returned.  Otherwise SECFailure is returned.  The only errors
    1.44 + * are due to failure allocating memory or bad parameters/calls:
    1.45 + *	SEC_ERROR_XXX ("which" is not in the S/MIME cipher family)
    1.46 + *	SEC_ERROR_XXX (function is being called more times than there
    1.47 + *		are known/expected ciphers)
    1.48 + */
    1.49 +extern SECStatus NSS_SMIMEUtil_EnableCipher(long which, int on);
    1.50 +
    1.51 +/*
    1.52 + * Initialize the local recording of the S/MIME policy.
    1.53 + * This function is called to allow/disallow a particular cipher.
    1.54 + *
    1.55 + * XXX This is for the current module, I think, so local, static storage
    1.56 + * XXX is okay.  Is that correct, or could multiple uses of the same
    1.57 + * XXX library expect to operate under different policies?
    1.58 + *
    1.59 + *  - The "which" values are defined in ciferfam.h (the SMIME_* values,
    1.60 + *    for example SMIME_DES_CBC_56).
    1.61 + *  - If "on" is non-zero then the named cipher is enabled, otherwise
    1.62 + *    it is disabled.
    1.63 + */
    1.64 +extern SECStatus NSS_SMIMEUtils_AllowCipher(long which, int on);
    1.65 +
    1.66 +/*
    1.67 + * Does the current policy allow S/MIME decryption of this particular
    1.68 + * algorithm and keysize?
    1.69 + */
    1.70 +extern PRBool NSS_SMIMEUtil_DecryptionAllowed(SECAlgorithmID *algid, PK11SymKey *key);
    1.71 +
    1.72 +/*
    1.73 + * Does the current policy allow *any* S/MIME encryption (or decryption)?
    1.74 + *
    1.75 + * This tells whether or not *any* S/MIME encryption can be done,
    1.76 + * according to policy.  Callers may use this to do nicer user interface
    1.77 + * (say, greying out a checkbox so a user does not even try to encrypt
    1.78 + * a message when they are not allowed to) or for any reason they want
    1.79 + * to check whether S/MIME encryption (or decryption, for that matter)
    1.80 + * may be done.
    1.81 + *
    1.82 + * It takes no arguments.  The return value is a simple boolean:
    1.83 + *   PR_TRUE means encryption (or decryption) is *possible*
    1.84 + *	(but may still fail due to other reasons, like because we cannot
    1.85 + *	find all the necessary certs, etc.; PR_TRUE is *not* a guarantee)
    1.86 + *   PR_FALSE means encryption (or decryption) is not permitted
    1.87 + *
    1.88 + * There are no errors from this routine.
    1.89 + */
    1.90 +extern PRBool NSS_SMIMEUtil_EncryptionPossible(void);
    1.91 +
    1.92 +/*
    1.93 + * NSS_SMIMEUtil_CreateSMIMECapabilities - get S/MIME capabilities attr value
    1.94 + *
    1.95 + * scans the list of allowed and enabled ciphers and construct a PKCS9-compliant
    1.96 + * S/MIME capabilities attribute value.
    1.97 + */
    1.98 +extern SECStatus NSS_SMIMEUtil_CreateSMIMECapabilities(PLArenaPool *poolp, SECItem *dest);
    1.99 +
   1.100 +/*
   1.101 + * NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value
   1.102 + */
   1.103 +extern SECStatus NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs(PLArenaPool *poolp, SECItem *dest, CERTCertificate *cert);
   1.104 +
   1.105 +/*
   1.106 + * NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value using MS oid
   1.107 + */
   1.108 +extern SECStatus NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs(PLArenaPool *poolp, SECItem *dest, CERTCertificate *cert);
   1.109 +
   1.110 +/*
   1.111 + * NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference - find cert marked by EncryptionKeyPreference
   1.112 + *          attribute
   1.113 + */
   1.114 +extern CERTCertificate *NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference(CERTCertDBHandle *certdb, SECItem *DERekp);
   1.115 +
   1.116 +/*
   1.117 + * NSS_SMIMEUtil_FindBulkAlgForRecipients - find bulk algorithm suitable for all recipients
   1.118 + */
   1.119 +extern SECStatus
   1.120 +NSS_SMIMEUtil_FindBulkAlgForRecipients(CERTCertificate **rcerts, SECOidTag *bulkalgtag, int *keysize);
   1.121 +
   1.122 +/*
   1.123 + * Return a boolean that indicates whether the underlying library
   1.124 + * will perform as the caller expects.
   1.125 + *
   1.126 + * The only argument is a string, which should be the version
   1.127 + * identifier of the NSS library. That string will be compared
   1.128 + * against a string that represents the actual build version of
   1.129 + * the S/MIME library.
   1.130 + */
   1.131 +extern PRBool NSSSMIME_VersionCheck(const char *importedVersion);
   1.132 +
   1.133 +/*
   1.134 + * Returns a const string of the S/MIME library version.
   1.135 + */
   1.136 +extern const char *NSSSMIME_GetVersion(void);
   1.137 +
   1.138 +/************************************************************************/
   1.139 +SEC_END_PROTOS
   1.140 +
   1.141 +#endif /* _SECMIME_H_ */

mercurial