PageRenderTime 52ms CodeModel.GetById 45ms RepoModel.GetById 0ms app.codeStats 0ms

/gecko_api/include/smime.h

http://firefox-mac-pdf.googlecode.com/
C Header | 156 lines | 16 code | 16 blank | 124 comment | 0 complexity | 9f38d10b14475c92fd210da6168f0ad5 MD5 | raw file
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is the Netscape security libraries.
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Netscape Communications Corporation.
  18. * Portions created by the Initial Developer are Copyright (C) 1994-2000
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. *
  23. * Alternatively, the contents of this file may be used under the terms of
  24. * either the GNU General Public License Version 2 or later (the "GPL"), or
  25. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  26. * in which case the provisions of the GPL or the LGPL are applicable instead
  27. * of those above. If you wish to allow use of your version of this file only
  28. * under the terms of either the GPL or the LGPL, and not to allow others to
  29. * use your version of this file under the terms of the MPL, indicate your
  30. * decision by deleting the provisions above and replace them with the notice
  31. * and other provisions required by the GPL or the LGPL. If you do not delete
  32. * the provisions above, a recipient may use your version of this file under
  33. * the terms of any one of the MPL, the GPL or the LGPL.
  34. *
  35. * ***** END LICENSE BLOCK ***** */
  36. /*
  37. * Header file for routines specific to S/MIME. Keep things that are pure
  38. * pkcs7 out of here; this is for S/MIME policy, S/MIME interoperability, etc.
  39. *
  40. * $Id: smime.h,v 1.8 2004/04/25 15:03:16 gerv%gerv.net Exp $
  41. */
  42. #ifndef _SECMIME_H_
  43. #define _SECMIME_H_ 1
  44. #include "cms.h"
  45. /************************************************************************/
  46. SEC_BEGIN_PROTOS
  47. /*
  48. * Initialize the local recording of the user S/MIME cipher preferences.
  49. * This function is called once for each cipher, the order being
  50. * important (first call records greatest preference, and so on).
  51. * When finished, it is called with a "which" of CIPHER_FAMILID_MASK.
  52. * If the function is called again after that, it is assumed that
  53. * the preferences are being reset, and the old preferences are
  54. * discarded.
  55. *
  56. * XXX This is for a particular user, and right now the storage is
  57. * XXX local, static. The preference should be stored elsewhere to allow
  58. * XXX for multiple uses of one library? How does SSL handle this;
  59. * XXX it has something similar?
  60. *
  61. * - The "which" values are defined in ciferfam.h (the SMIME_* values,
  62. * for example SMIME_DES_CBC_56).
  63. * - If "on" is non-zero then the named cipher is enabled, otherwise
  64. * it is disabled. (It is not necessary to call the function for
  65. * ciphers that are disabled, however, as that is the default.)
  66. *
  67. * If the cipher preference is successfully recorded, SECSuccess
  68. * is returned. Otherwise SECFailure is returned. The only errors
  69. * are due to failure allocating memory or bad parameters/calls:
  70. * SEC_ERROR_XXX ("which" is not in the S/MIME cipher family)
  71. * SEC_ERROR_XXX (function is being called more times than there
  72. * are known/expected ciphers)
  73. */
  74. extern SECStatus NSS_SMIMEUtil_EnableCipher(long which, int on);
  75. /*
  76. * Initialize the local recording of the S/MIME policy.
  77. * This function is called to allow/disallow a particular cipher.
  78. *
  79. * XXX This is for a the current module, I think, so local, static storage
  80. * XXX is okay. Is that correct, or could multiple uses of the same
  81. * XXX library expect to operate under different policies?
  82. *
  83. * - The "which" values are defined in ciferfam.h (the SMIME_* values,
  84. * for example SMIME_DES_CBC_56).
  85. * - If "on" is non-zero then the named cipher is enabled, otherwise
  86. * it is disabled.
  87. */
  88. extern SECStatus NSS_SMIMEUtils_AllowCipher(long which, int on);
  89. /*
  90. * Does the current policy allow S/MIME decryption of this particular
  91. * algorithm and keysize?
  92. */
  93. extern PRBool NSS_SMIMEUtil_DecryptionAllowed(SECAlgorithmID *algid, PK11SymKey *key);
  94. /*
  95. * Does the current policy allow *any* S/MIME encryption (or decryption)?
  96. *
  97. * This tells whether or not *any* S/MIME encryption can be done,
  98. * according to policy. Callers may use this to do nicer user interface
  99. * (say, greying out a checkbox so a user does not even try to encrypt
  100. * a message when they are not allowed to) or for any reason they want
  101. * to check whether S/MIME encryption (or decryption, for that matter)
  102. * may be done.
  103. *
  104. * It takes no arguments. The return value is a simple boolean:
  105. * PR_TRUE means encryption (or decryption) is *possible*
  106. * (but may still fail due to other reasons, like because we cannot
  107. * find all the necessary certs, etc.; PR_TRUE is *not* a guarantee)
  108. * PR_FALSE means encryption (or decryption) is not permitted
  109. *
  110. * There are no errors from this routine.
  111. */
  112. extern PRBool NSS_SMIMEUtil_EncryptionPossible(void);
  113. /*
  114. * NSS_SMIMEUtil_CreateSMIMECapabilities - get S/MIME capabilities attr value
  115. *
  116. * scans the list of allowed and enabled ciphers and construct a PKCS9-compliant
  117. * S/MIME capabilities attribute value.
  118. */
  119. extern SECStatus NSS_SMIMEUtil_CreateSMIMECapabilities(PLArenaPool *poolp, SECItem *dest, PRBool includeFortezzaCiphers);
  120. /*
  121. * NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value
  122. */
  123. extern SECStatus NSS_SMIMEUtil_CreateSMIMEEncKeyPrefs(PLArenaPool *poolp, SECItem *dest, CERTCertificate *cert);
  124. /*
  125. * NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs - create S/MIME encryption key preferences attr value using MS oid
  126. */
  127. extern SECStatus NSS_SMIMEUtil_CreateMSSMIMEEncKeyPrefs(PLArenaPool *poolp, SECItem *dest, CERTCertificate *cert);
  128. /*
  129. * NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference - find cert marked by EncryptionKeyPreference
  130. * attribute
  131. */
  132. extern CERTCertificate *NSS_SMIMEUtil_GetCertFromEncryptionKeyPreference(CERTCertDBHandle *certdb, SECItem *DERekp);
  133. /*
  134. * NSS_SMIMEUtil_FindBulkAlgForRecipients - find bulk algorithm suitable for all recipients
  135. */
  136. extern SECStatus
  137. NSS_SMIMEUtil_FindBulkAlgForRecipients(CERTCertificate **rcerts, SECOidTag *bulkalgtag, int *keysize);
  138. /************************************************************************/
  139. SEC_END_PROTOS
  140. #endif /* _SECMIME_H_ */