PageRenderTime 37ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_api/include/p12.h

http://firefox-mac-pdf.googlecode.com/
C Header | 209 lines | 136 code | 38 blank | 35 comment | 0 complexity | 2c2dc8cebcf1dd80bd3f4d41e20b0bae 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. #ifndef _P12_H_
  37. #define _P12_H_
  38. #include "secoid.h"
  39. #include "key.h"
  40. #include "secpkcs7.h"
  41. #include "p12t.h"
  42. typedef int (PR_CALLBACK * PKCS12OpenFunction)(void *arg);
  43. typedef int (PR_CALLBACK * PKCS12ReadFunction)(void *arg,
  44. unsigned char *buffer,
  45. unsigned int *lenRead,
  46. unsigned int maxLen);
  47. typedef int (PR_CALLBACK * PKCS12WriteFunction)(void *arg,
  48. unsigned char *buffer,
  49. unsigned int *bufLen,
  50. unsigned int *lenWritten);
  51. typedef int (PR_CALLBACK * PKCS12CloseFunction)(void *arg);
  52. typedef SECStatus (PR_CALLBACK * PKCS12UnicodeConvertFunction)(
  53. PRArenaPool *arena,
  54. SECItem *dest, SECItem *src,
  55. PRBool toUnicode,
  56. PRBool swapBytes);
  57. typedef void (PR_CALLBACK * SEC_PKCS12EncoderOutputCallback)(
  58. void *arg, const char *buf,
  59. unsigned long len);
  60. typedef void (PR_CALLBACK * SEC_PKCS12DecoderOutputCallback)(
  61. void *arg, const char *buf,
  62. unsigned long len);
  63. typedef SECItem * (PR_CALLBACK * SEC_PKCS12NicknameCollisionCallback)(
  64. SECItem *old_nickname,
  65. PRBool *cancel,
  66. void *arg);
  67. typedef SECStatus (PR_CALLBACK *digestOpenFn)(void *arg, PRBool readData);
  68. typedef SECStatus (PR_CALLBACK *digestCloseFn)(void *arg, PRBool removeFile);
  69. typedef int (PR_CALLBACK *digestIOFn)(void *arg, unsigned char *buf,
  70. unsigned long len);
  71. typedef struct SEC_PKCS12ExportContextStr SEC_PKCS12ExportContext;
  72. typedef struct SEC_PKCS12SafeInfoStr SEC_PKCS12SafeInfo;
  73. typedef struct SEC_PKCS12DecoderContextStr SEC_PKCS12DecoderContext;
  74. typedef struct SEC_PKCS12DecoderItemStr SEC_PKCS12DecoderItem;
  75. struct sec_PKCS12PasswordModeInfo {
  76. SECItem *password;
  77. SECOidTag algorithm;
  78. };
  79. struct sec_PKCS12PublicKeyModeInfo {
  80. CERTCertificate *cert;
  81. CERTCertDBHandle *certDb;
  82. SECOidTag algorithm;
  83. int keySize;
  84. };
  85. struct SEC_PKCS12DecoderItemStr {
  86. SECItem *der;
  87. SECOidTag type;
  88. PRBool hasKey;
  89. SECItem *friendlyName; /* UTF-8 string */
  90. SECAlgorithmID *shroudAlg;
  91. };
  92. SEC_BEGIN_PROTOS
  93. SEC_PKCS12SafeInfo *
  94. SEC_PKCS12CreatePubKeyEncryptedSafe(SEC_PKCS12ExportContext *p12ctxt,
  95. CERTCertDBHandle *certDb,
  96. CERTCertificate *signer,
  97. CERTCertificate **recipients,
  98. SECOidTag algorithm, int keysize);
  99. extern SEC_PKCS12SafeInfo *
  100. SEC_PKCS12CreatePasswordPrivSafe(SEC_PKCS12ExportContext *p12ctxt,
  101. SECItem *pwitem, SECOidTag privAlg);
  102. extern SEC_PKCS12SafeInfo *
  103. SEC_PKCS12CreateUnencryptedSafe(SEC_PKCS12ExportContext *p12ctxt);
  104. extern SECStatus
  105. SEC_PKCS12AddPasswordIntegrity(SEC_PKCS12ExportContext *p12ctxt,
  106. SECItem *pwitem, SECOidTag integAlg);
  107. extern SECStatus
  108. SEC_PKCS12AddPublicKeyIntegrity(SEC_PKCS12ExportContext *p12ctxt,
  109. CERTCertificate *cert, CERTCertDBHandle *certDb,
  110. SECOidTag algorithm, int keySize);
  111. extern SEC_PKCS12ExportContext *
  112. SEC_PKCS12CreateExportContext(SECKEYGetPasswordKey pwfn, void *pwfnarg,
  113. PK11SlotInfo *slot, void *wincx);
  114. extern SECStatus
  115. SEC_PKCS12AddCert(SEC_PKCS12ExportContext *p12ctxt,
  116. SEC_PKCS12SafeInfo *safe, void *nestedDest,
  117. CERTCertificate *cert, CERTCertDBHandle *certDb,
  118. SECItem *keyId, PRBool includeCertChain);
  119. extern SECStatus
  120. SEC_PKCS12AddKeyForCert(SEC_PKCS12ExportContext *p12ctxt,
  121. SEC_PKCS12SafeInfo *safe,
  122. void *nestedDest, CERTCertificate *cert,
  123. PRBool shroudKey, SECOidTag algorithm, SECItem *pwitem,
  124. SECItem *keyId, SECItem *nickName);
  125. extern SECStatus
  126. SEC_PKCS12AddCertAndKey(SEC_PKCS12ExportContext *p12ctxt,
  127. void *certSafe, void *certNestedDest,
  128. CERTCertificate *cert, CERTCertDBHandle *certDb,
  129. void *keySafe, void *keyNestedDest,
  130. PRBool shroudKey, SECItem *pwitem, SECOidTag algorithm);
  131. extern SECStatus
  132. SEC_PKCS12AddDERCertAndEncryptedKey(SEC_PKCS12ExportContext *p12ctxt,
  133. void *certSafe, void *certNestedDest, SECItem *derCert,
  134. void *keySafe, void *keyNestedDest,
  135. SECKEYEncryptedPrivateKeyInfo *epki, char *nickname);
  136. extern void *
  137. SEC_PKCS12CreateNestedSafeContents(SEC_PKCS12ExportContext *p12ctxt,
  138. void *baseSafe, void *nestedDest);
  139. extern SECStatus
  140. SEC_PKCS12Encode(SEC_PKCS12ExportContext *p12exp,
  141. SEC_PKCS12EncoderOutputCallback output, void *outputarg);
  142. extern void
  143. SEC_PKCS12DestroyExportContext(SEC_PKCS12ExportContext *p12exp);
  144. extern SEC_PKCS12DecoderContext *
  145. SEC_PKCS12DecoderStart(SECItem *pwitem, PK11SlotInfo *slot, void *wincx,
  146. digestOpenFn dOpen, digestCloseFn dClose,
  147. digestIOFn dRead, digestIOFn dWrite, void *dArg);
  148. extern SECStatus
  149. SEC_PKCS12DecoderSetTargetTokenCAs(SEC_PKCS12DecoderContext *p12dcx,
  150. SECPKCS12TargetTokenCAs tokenCAs);
  151. extern SECStatus
  152. SEC_PKCS12DecoderUpdate(SEC_PKCS12DecoderContext *p12dcx, unsigned char *data,
  153. unsigned long len);
  154. extern void
  155. SEC_PKCS12DecoderFinish(SEC_PKCS12DecoderContext *p12dcx);
  156. extern SECStatus
  157. SEC_PKCS12DecoderVerify(SEC_PKCS12DecoderContext *p12dcx);
  158. extern SECStatus
  159. SEC_PKCS12DecoderValidateBags(SEC_PKCS12DecoderContext *p12dcx,
  160. SEC_PKCS12NicknameCollisionCallback nicknameCb);
  161. extern SECStatus
  162. SEC_PKCS12DecoderImportBags(SEC_PKCS12DecoderContext *p12dcx);
  163. CERTCertList *
  164. SEC_PKCS12DecoderGetCerts(SEC_PKCS12DecoderContext *p12dcx);
  165. SECStatus
  166. SEC_PKCS12DecoderIterateInit(SEC_PKCS12DecoderContext *p12dcx);
  167. SECStatus
  168. SEC_PKCS12DecoderIterateNext(SEC_PKCS12DecoderContext *p12dcx,
  169. const SEC_PKCS12DecoderItem **ipp);
  170. SEC_END_PROTOS
  171. #endif