PEM_read_bio_PrivateKey.pod 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. =pod
  2. =head1 NAME
  3. pem_password_cb,
  4. PEM_read_bio_PrivateKey, PEM_read_PrivateKey, PEM_write_bio_PrivateKey,
  5. PEM_write_bio_PrivateKey_traditional, PEM_write_PrivateKey,
  6. PEM_write_bio_PKCS8PrivateKey, PEM_write_PKCS8PrivateKey,
  7. PEM_write_bio_PKCS8PrivateKey_nid, PEM_write_PKCS8PrivateKey_nid,
  8. PEM_read_bio_PUBKEY, PEM_read_PUBKEY, PEM_write_bio_PUBKEY, PEM_write_PUBKEY,
  9. PEM_read_bio_RSAPrivateKey, PEM_read_RSAPrivateKey,
  10. PEM_write_bio_RSAPrivateKey, PEM_write_RSAPrivateKey,
  11. PEM_read_bio_RSAPublicKey, PEM_read_RSAPublicKey, PEM_write_bio_RSAPublicKey,
  12. PEM_write_RSAPublicKey, PEM_read_bio_RSA_PUBKEY, PEM_read_RSA_PUBKEY,
  13. PEM_write_bio_RSA_PUBKEY, PEM_write_RSA_PUBKEY, PEM_read_bio_DSAPrivateKey,
  14. PEM_read_DSAPrivateKey, PEM_write_bio_DSAPrivateKey, PEM_write_DSAPrivateKey,
  15. PEM_read_bio_DSA_PUBKEY, PEM_read_DSA_PUBKEY, PEM_write_bio_DSA_PUBKEY,
  16. PEM_write_DSA_PUBKEY, PEM_read_bio_DSAparams, PEM_read_DSAparams,
  17. PEM_write_bio_DSAparams, PEM_write_DSAparams, PEM_read_bio_DHparams,
  18. PEM_read_DHparams, PEM_write_bio_DHparams, PEM_write_DHparams,
  19. PEM_read_bio_X509, PEM_read_X509, PEM_write_bio_X509, PEM_write_X509,
  20. PEM_read_bio_X509_AUX, PEM_read_X509_AUX, PEM_write_bio_X509_AUX,
  21. PEM_write_X509_AUX, PEM_read_bio_X509_REQ, PEM_read_X509_REQ,
  22. PEM_write_bio_X509_REQ, PEM_write_X509_REQ, PEM_write_bio_X509_REQ_NEW,
  23. PEM_write_X509_REQ_NEW, PEM_read_bio_X509_CRL, PEM_read_X509_CRL,
  24. PEM_write_bio_X509_CRL, PEM_write_X509_CRL, PEM_read_bio_PKCS7, PEM_read_PKCS7,
  25. PEM_write_bio_PKCS7, PEM_write_PKCS7 - PEM routines
  26. =head1 SYNOPSIS
  27. #include <openssl/pem.h>
  28. typedef int pem_password_cb(char *buf, int size, int rwflag, void *u);
  29. EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x,
  30. pem_password_cb *cb, void *u);
  31. EVP_PKEY *PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x,
  32. pem_password_cb *cb, void *u);
  33. int PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
  34. unsigned char *kstr, int klen,
  35. pem_password_cb *cb, void *u);
  36. int PEM_write_bio_PrivateKey_traditional(BIO *bp, EVP_PKEY *x,
  37. const EVP_CIPHER *enc,
  38. unsigned char *kstr, int klen,
  39. pem_password_cb *cb, void *u);
  40. int PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
  41. unsigned char *kstr, int klen,
  42. pem_password_cb *cb, void *u);
  43. int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc,
  44. char *kstr, int klen,
  45. pem_password_cb *cb, void *u);
  46. int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc,
  47. char *kstr, int klen,
  48. pem_password_cb *cb, void *u);
  49. int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid,
  50. char *kstr, int klen,
  51. pem_password_cb *cb, void *u);
  52. int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid,
  53. char *kstr, int klen,
  54. pem_password_cb *cb, void *u);
  55. EVP_PKEY *PEM_read_bio_PUBKEY(BIO *bp, EVP_PKEY **x,
  56. pem_password_cb *cb, void *u);
  57. EVP_PKEY *PEM_read_PUBKEY(FILE *fp, EVP_PKEY **x,
  58. pem_password_cb *cb, void *u);
  59. int PEM_write_bio_PUBKEY(BIO *bp, EVP_PKEY *x);
  60. int PEM_write_PUBKEY(FILE *fp, EVP_PKEY *x);
  61. RSA *PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **x,
  62. pem_password_cb *cb, void *u);
  63. RSA *PEM_read_RSAPrivateKey(FILE *fp, RSA **x,
  64. pem_password_cb *cb, void *u);
  65. int PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc,
  66. unsigned char *kstr, int klen,
  67. pem_password_cb *cb, void *u);
  68. int PEM_write_RSAPrivateKey(FILE *fp, RSA *x, const EVP_CIPHER *enc,
  69. unsigned char *kstr, int klen,
  70. pem_password_cb *cb, void *u);
  71. RSA *PEM_read_bio_RSAPublicKey(BIO *bp, RSA **x,
  72. pem_password_cb *cb, void *u);
  73. RSA *PEM_read_RSAPublicKey(FILE *fp, RSA **x,
  74. pem_password_cb *cb, void *u);
  75. int PEM_write_bio_RSAPublicKey(BIO *bp, RSA *x);
  76. int PEM_write_RSAPublicKey(FILE *fp, RSA *x);
  77. RSA *PEM_read_bio_RSA_PUBKEY(BIO *bp, RSA **x,
  78. pem_password_cb *cb, void *u);
  79. RSA *PEM_read_RSA_PUBKEY(FILE *fp, RSA **x,
  80. pem_password_cb *cb, void *u);
  81. int PEM_write_bio_RSA_PUBKEY(BIO *bp, RSA *x);
  82. int PEM_write_RSA_PUBKEY(FILE *fp, RSA *x);
  83. DSA *PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **x,
  84. pem_password_cb *cb, void *u);
  85. DSA *PEM_read_DSAPrivateKey(FILE *fp, DSA **x,
  86. pem_password_cb *cb, void *u);
  87. int PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x, const EVP_CIPHER *enc,
  88. unsigned char *kstr, int klen,
  89. pem_password_cb *cb, void *u);
  90. int PEM_write_DSAPrivateKey(FILE *fp, DSA *x, const EVP_CIPHER *enc,
  91. unsigned char *kstr, int klen,
  92. pem_password_cb *cb, void *u);
  93. DSA *PEM_read_bio_DSA_PUBKEY(BIO *bp, DSA **x,
  94. pem_password_cb *cb, void *u);
  95. DSA *PEM_read_DSA_PUBKEY(FILE *fp, DSA **x,
  96. pem_password_cb *cb, void *u);
  97. int PEM_write_bio_DSA_PUBKEY(BIO *bp, DSA *x);
  98. int PEM_write_DSA_PUBKEY(FILE *fp, DSA *x);
  99. DSA *PEM_read_bio_DSAparams(BIO *bp, DSA **x, pem_password_cb *cb, void *u);
  100. DSA *PEM_read_DSAparams(FILE *fp, DSA **x, pem_password_cb *cb, void *u);
  101. int PEM_write_bio_DSAparams(BIO *bp, DSA *x);
  102. int PEM_write_DSAparams(FILE *fp, DSA *x);
  103. DH *PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u);
  104. DH *PEM_read_DHparams(FILE *fp, DH **x, pem_password_cb *cb, void *u);
  105. int PEM_write_bio_DHparams(BIO *bp, DH *x);
  106. int PEM_write_DHparams(FILE *fp, DH *x);
  107. X509 *PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb *cb, void *u);
  108. X509 *PEM_read_X509(FILE *fp, X509 **x, pem_password_cb *cb, void *u);
  109. int PEM_write_bio_X509(BIO *bp, X509 *x);
  110. int PEM_write_X509(FILE *fp, X509 *x);
  111. X509 *PEM_read_bio_X509_AUX(BIO *bp, X509 **x, pem_password_cb *cb, void *u);
  112. X509 *PEM_read_X509_AUX(FILE *fp, X509 **x, pem_password_cb *cb, void *u);
  113. int PEM_write_bio_X509_AUX(BIO *bp, X509 *x);
  114. int PEM_write_X509_AUX(FILE *fp, X509 *x);
  115. X509_REQ *PEM_read_bio_X509_REQ(BIO *bp, X509_REQ **x,
  116. pem_password_cb *cb, void *u);
  117. X509_REQ *PEM_read_X509_REQ(FILE *fp, X509_REQ **x,
  118. pem_password_cb *cb, void *u);
  119. int PEM_write_bio_X509_REQ(BIO *bp, X509_REQ *x);
  120. int PEM_write_X509_REQ(FILE *fp, X509_REQ *x);
  121. int PEM_write_bio_X509_REQ_NEW(BIO *bp, X509_REQ *x);
  122. int PEM_write_X509_REQ_NEW(FILE *fp, X509_REQ *x);
  123. X509_CRL *PEM_read_bio_X509_CRL(BIO *bp, X509_CRL **x,
  124. pem_password_cb *cb, void *u);
  125. X509_CRL *PEM_read_X509_CRL(FILE *fp, X509_CRL **x,
  126. pem_password_cb *cb, void *u);
  127. int PEM_write_bio_X509_CRL(BIO *bp, X509_CRL *x);
  128. int PEM_write_X509_CRL(FILE *fp, X509_CRL *x);
  129. PKCS7 *PEM_read_bio_PKCS7(BIO *bp, PKCS7 **x, pem_password_cb *cb, void *u);
  130. PKCS7 *PEM_read_PKCS7(FILE *fp, PKCS7 **x, pem_password_cb *cb, void *u);
  131. int PEM_write_bio_PKCS7(BIO *bp, PKCS7 *x);
  132. int PEM_write_PKCS7(FILE *fp, PKCS7 *x);
  133. =head1 DESCRIPTION
  134. The PEM functions read or write structures in PEM format. In
  135. this sense PEM format is simply base64 encoded data surrounded
  136. by header lines.
  137. For more details about the meaning of arguments see the
  138. B<PEM FUNCTION ARGUMENTS> section.
  139. Each operation has four functions associated with it. For
  140. brevity the term "B<TYPE> functions" will be used below to collectively
  141. refer to the PEM_read_bio_TYPE(), PEM_read_TYPE(),
  142. PEM_write_bio_TYPE(), and PEM_write_TYPE() functions.
  143. The B<PrivateKey> functions read or write a private key in PEM format using an
  144. EVP_PKEY structure. The write routines use PKCS#8 private key format and are
  145. equivalent to PEM_write_bio_PKCS8PrivateKey().The read functions transparently
  146. handle traditional and PKCS#8 format encrypted and unencrypted keys.
  147. PEM_write_bio_PrivateKey_traditional() writes out a private key in the
  148. "traditional" format with a simple private key marker and should only
  149. be used for compatibility with legacy programs.
  150. PEM_write_bio_PKCS8PrivateKey() and PEM_write_PKCS8PrivateKey() write a private
  151. key in an EVP_PKEY structure in PKCS#8 EncryptedPrivateKeyInfo format using
  152. PKCS#5 v2.0 password based encryption algorithms. The B<cipher> argument
  153. specifies the encryption algorithm to use: unlike some other PEM routines the
  154. encryption is applied at the PKCS#8 level and not in the PEM headers. If
  155. B<cipher> is NULL then no encryption is used and a PKCS#8 PrivateKeyInfo
  156. structure is used instead.
  157. PEM_write_bio_PKCS8PrivateKey_nid() and PEM_write_PKCS8PrivateKey_nid()
  158. also write out a private key as a PKCS#8 EncryptedPrivateKeyInfo however
  159. it uses PKCS#5 v1.5 or PKCS#12 encryption algorithms instead. The algorithm
  160. to use is specified in the B<nid> parameter and should be the NID of the
  161. corresponding OBJECT IDENTIFIER (see NOTES section).
  162. The B<PUBKEY> functions process a public key using an EVP_PKEY
  163. structure. The public key is encoded as a SubjectPublicKeyInfo
  164. structure.
  165. The B<RSAPrivateKey> functions process an RSA private key using an
  166. RSA structure. The write routines uses traditional format. The read
  167. routines handles the same formats as the B<PrivateKey>
  168. functions but an error occurs if the private key is not RSA.
  169. The B<RSAPublicKey> functions process an RSA public key using an
  170. RSA structure. The public key is encoded using a PKCS#1 RSAPublicKey
  171. structure.
  172. The B<RSA_PUBKEY> functions also process an RSA public key using
  173. an RSA structure. However the public key is encoded using a
  174. SubjectPublicKeyInfo structure and an error occurs if the public
  175. key is not RSA.
  176. The B<DSAPrivateKey> functions process a DSA private key using a
  177. DSA structure. The write routines uses traditional format. The read
  178. routines handles the same formats as the B<PrivateKey>
  179. functions but an error occurs if the private key is not DSA.
  180. The B<DSA_PUBKEY> functions process a DSA public key using
  181. a DSA structure. The public key is encoded using a
  182. SubjectPublicKeyInfo structure and an error occurs if the public
  183. key is not DSA.
  184. The B<DSAparams> functions process DSA parameters using a DSA
  185. structure. The parameters are encoded using a Dss-Parms structure
  186. as defined in RFC2459.
  187. The B<DHparams> functions process DH parameters using a DH
  188. structure. The parameters are encoded using a PKCS#3 DHparameter
  189. structure.
  190. The B<X509> functions process an X509 certificate using an X509
  191. structure. They will also process a trusted X509 certificate but
  192. any trust settings are discarded.
  193. The B<X509_AUX> functions process a trusted X509 certificate using
  194. an X509 structure.
  195. The B<X509_REQ> and B<X509_REQ_NEW> functions process a PKCS#10
  196. certificate request using an X509_REQ structure. The B<X509_REQ>
  197. write functions use B<CERTIFICATE REQUEST> in the header whereas
  198. the B<X509_REQ_NEW> functions use B<NEW CERTIFICATE REQUEST>
  199. (as required by some CAs). The B<X509_REQ> read functions will
  200. handle either form so there are no B<X509_REQ_NEW> read functions.
  201. The B<X509_CRL> functions process an X509 CRL using an X509_CRL
  202. structure.
  203. The B<PKCS7> functions process a PKCS#7 ContentInfo using a PKCS7
  204. structure.
  205. =head1 PEM FUNCTION ARGUMENTS
  206. The PEM functions have many common arguments.
  207. The B<bp> BIO parameter (if present) specifies the BIO to read from
  208. or write to.
  209. The B<fp> FILE parameter (if present) specifies the FILE pointer to
  210. read from or write to.
  211. The PEM read functions all take an argument B<TYPE **x> and return
  212. a B<TYPE *> pointer. Where B<TYPE> is whatever structure the function
  213. uses. If B<x> is NULL then the parameter is ignored. If B<x> is not
  214. NULL but B<*x> is NULL then the structure returned will be written
  215. to B<*x>. If neither B<x> nor B<*x> is NULL then an attempt is made
  216. to reuse the structure at B<*x> (but see BUGS and EXAMPLES sections).
  217. Irrespective of the value of B<x> a pointer to the structure is always
  218. returned (or NULL if an error occurred).
  219. The PEM functions which write private keys take an B<enc> parameter
  220. which specifies the encryption algorithm to use, encryption is done
  221. at the PEM level. If this parameter is set to NULL then the private
  222. key is written in unencrypted form.
  223. The B<cb> argument is the callback to use when querying for the pass
  224. phrase used for encrypted PEM structures (normally only private keys).
  225. For the PEM write routines if the B<kstr> parameter is not NULL then
  226. B<klen> bytes at B<kstr> are used as the passphrase and B<cb> is
  227. ignored.
  228. If the B<cb> parameters is set to NULL and the B<u> parameter is not
  229. NULL then the B<u> parameter is interpreted as a null terminated string
  230. to use as the passphrase. If both B<cb> and B<u> are NULL then the
  231. default callback routine is used which will typically prompt for the
  232. passphrase on the current terminal with echoing turned off.
  233. The default passphrase callback is sometimes inappropriate (for example
  234. in a GUI application) so an alternative can be supplied. The callback
  235. routine has the following form:
  236. int cb(char *buf, int size, int rwflag, void *u);
  237. B<buf> is the buffer to write the passphrase to. B<size> is the maximum
  238. length of the passphrase (i.e. the size of buf). B<rwflag> is a flag
  239. which is set to 0 when reading and 1 when writing. A typical routine
  240. will ask the user to verify the passphrase (for example by prompting
  241. for it twice) if B<rwflag> is 1. The B<u> parameter has the same
  242. value as the B<u> parameter passed to the PEM routine. It allows
  243. arbitrary data to be passed to the callback by the application
  244. (for example a window handle in a GUI application). The callback
  245. B<must> return the number of characters in the passphrase or -1 if
  246. an error occurred.
  247. =head1 EXAMPLES
  248. Although the PEM routines take several arguments in almost all applications
  249. most of them are set to 0 or NULL.
  250. Read a certificate in PEM format from a BIO:
  251. X509 *x;
  252. x = PEM_read_bio_X509(bp, NULL, 0, NULL);
  253. if (x == NULL)
  254. /* Error */
  255. Alternative method:
  256. X509 *x = NULL;
  257. if (!PEM_read_bio_X509(bp, &x, 0, NULL))
  258. /* Error */
  259. Write a certificate to a BIO:
  260. if (!PEM_write_bio_X509(bp, x))
  261. /* Error */
  262. Write a private key (using traditional format) to a BIO using
  263. triple DES encryption, the pass phrase is prompted for:
  264. if (!PEM_write_bio_PrivateKey(bp, key, EVP_des_ede3_cbc(), NULL, 0, 0, NULL))
  265. /* Error */
  266. Write a private key (using PKCS#8 format) to a BIO using triple
  267. DES encryption, using the pass phrase "hello":
  268. if (!PEM_write_bio_PKCS8PrivateKey(bp, key, EVP_des_ede3_cbc(),
  269. NULL, 0, 0, "hello"))
  270. /* Error */
  271. Read a private key from a BIO using a pass phrase callback:
  272. key = PEM_read_bio_PrivateKey(bp, NULL, pass_cb, "My Private Key");
  273. if (key == NULL)
  274. /* Error */
  275. Skeleton pass phrase callback:
  276. int pass_cb(char *buf, int size, int rwflag, void *u)
  277. {
  278. /* We'd probably do something else if 'rwflag' is 1 */
  279. printf("Enter pass phrase for \"%s\"\n", (char *)u);
  280. /* get pass phrase, length 'len' into 'tmp' */
  281. char *tmp = "hello";
  282. if (tmp == NULL) /* An error occurred */
  283. return -1;
  284. size_t len = strlen(tmp);
  285. if (len > size)
  286. len = size;
  287. memcpy(buf, tmp, len);
  288. return len;
  289. }
  290. =head1 NOTES
  291. The old B<PrivateKey> write routines are retained for compatibility.
  292. New applications should write private keys using the
  293. PEM_write_bio_PKCS8PrivateKey() or PEM_write_PKCS8PrivateKey() routines
  294. because they are more secure (they use an iteration count of 2048 whereas
  295. the traditional routines use a count of 1) unless compatibility with older
  296. versions of OpenSSL is important.
  297. The B<PrivateKey> read routines can be used in all applications because
  298. they handle all formats transparently.
  299. A frequent cause of problems is attempting to use the PEM routines like
  300. this:
  301. X509 *x;
  302. PEM_read_bio_X509(bp, &x, 0, NULL);
  303. this is a bug because an attempt will be made to reuse the data at B<x>
  304. which is an uninitialised pointer.
  305. These functions make no assumption regarding the pass phrase received from the
  306. password callback.
  307. It will simply be treated as a byte sequence.
  308. =head1 PEM ENCRYPTION FORMAT
  309. These old B<PrivateKey> routines use a non standard technique for encryption.
  310. The private key (or other data) takes the following form:
  311. -----BEGIN RSA PRIVATE KEY-----
  312. Proc-Type: 4,ENCRYPTED
  313. DEK-Info: DES-EDE3-CBC,3F17F5316E2BAC89
  314. ...base64 encoded data...
  315. -----END RSA PRIVATE KEY-----
  316. The line beginning with I<Proc-Type> contains the version and the
  317. protection on the encapsulated data. The line beginning I<DEK-Info>
  318. contains two comma separated values: the encryption algorithm name as
  319. used by EVP_get_cipherbyname() and an initialization vector used by the
  320. cipher encoded as a set of hexadecimal digits. After those two lines is
  321. the base64-encoded encrypted data.
  322. The encryption key is derived using EVP_BytesToKey(). The cipher's
  323. initialization vector is passed to EVP_BytesToKey() as the B<salt>
  324. parameter. Internally, B<PKCS5_SALT_LEN> bytes of the salt are used
  325. (regardless of the size of the initialization vector). The user's
  326. password is passed to EVP_BytesToKey() using the B<data> and B<datal>
  327. parameters. Finally, the library uses an iteration count of 1 for
  328. EVP_BytesToKey().
  329. The B<key> derived by EVP_BytesToKey() along with the original initialization
  330. vector is then used to decrypt the encrypted data. The B<iv> produced by
  331. EVP_BytesToKey() is not utilized or needed, and NULL should be passed to
  332. the function.
  333. The pseudo code to derive the key would look similar to:
  334. EVP_CIPHER* cipher = EVP_des_ede3_cbc();
  335. EVP_MD* md = EVP_md5();
  336. unsigned int nkey = EVP_CIPHER_key_length(cipher);
  337. unsigned int niv = EVP_CIPHER_iv_length(cipher);
  338. unsigned char key[nkey];
  339. unsigned char iv[niv];
  340. memcpy(iv, HexToBin("3F17F5316E2BAC89"), niv);
  341. rc = EVP_BytesToKey(cipher, md, iv /*salt*/, pword, plen, 1, key, NULL /*iv*/);
  342. if (rc != nkey)
  343. /* Error */
  344. /* On success, use key and iv to initialize the cipher */
  345. =head1 BUGS
  346. The PEM read routines in some versions of OpenSSL will not correctly reuse
  347. an existing structure. Therefore the following:
  348. PEM_read_bio_X509(bp, &x, 0, NULL);
  349. where B<x> already contains a valid certificate, may not work, whereas:
  350. X509_free(x);
  351. x = PEM_read_bio_X509(bp, NULL, 0, NULL);
  352. is guaranteed to work.
  353. =head1 RETURN VALUES
  354. The read routines return either a pointer to the structure read or NULL
  355. if an error occurred.
  356. The write routines return 1 for success or 0 for failure.
  357. =head1 HISTORY
  358. The old Netscape certificate sequences were no longer documented
  359. in OpenSSL 1.1.0; applications should use the PKCS7 standard instead
  360. as they will be formally deprecated in a future releases.
  361. =head1 SEE ALSO
  362. L<EVP_EncryptInit(3)>, L<EVP_BytesToKey(3)>,
  363. L<passphrase-encoding(7)>
  364. =head1 COPYRIGHT
  365. Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
  366. Licensed under the OpenSSL license (the "License"). You may not use
  367. this file except in compliance with the License. You can obtain a copy
  368. in the file LICENSE in the source distribution or at
  369. L<https://www.openssl.org/source/license.html>.
  370. =cut