Sortix volatile manual
This manual documents Sortix volatile, a development build that has not been officially released. You can instead view this document in the latest official manual.
NAME
PEM_read_bio_PrivateKey, PEM_read_PrivateKey, PEM_write_bio_PrivateKey, PEM_write_PrivateKey, PEM_write_bio_PKCS8PrivateKey, PEM_write_PKCS8PrivateKey, PEM_write_bio_PKCS8PrivateKey_nid, PEM_write_PKCS8PrivateKey_nid, PEM_read_bio_PKCS8, PEM_read_PKCS8, PEM_write_bio_PKCS8, PEM_write_PKCS8, PEM_read_bio_PKCS8_PRIV_KEY_INFO, PEM_read_PKCS8_PRIV_KEY_INFO, PEM_write_bio_PKCS8_PRIV_KEY_INFO, PEM_write_PKCS8_PRIV_KEY_INFO, PEM_read_bio_PUBKEY, PEM_read_PUBKEY, PEM_write_bio_PUBKEY, PEM_write_PUBKEY, PEM_read_bio_RSAPrivateKey, PEM_read_RSAPrivateKey, PEM_write_bio_RSAPrivateKey, PEM_write_RSAPrivateKey, PEM_read_bio_RSAPublicKey, PEM_read_RSAPublicKey, PEM_write_bio_RSAPublicKey, PEM_write_RSAPublicKey, PEM_read_bio_RSA_PUBKEY, PEM_read_RSA_PUBKEY, PEM_write_bio_RSA_PUBKEY, PEM_write_RSA_PUBKEY, PEM_read_bio_DSAPrivateKey, PEM_read_DSAPrivateKey, PEM_write_bio_DSAPrivateKey, PEM_write_DSAPrivateKey, PEM_read_bio_DSA_PUBKEY, PEM_read_DSA_PUBKEY, PEM_write_bio_DSA_PUBKEY, PEM_write_DSA_PUBKEY, PEM_read_bio_DSAparams, PEM_read_DSAparams, PEM_write_bio_DSAparams, PEM_write_DSAparams, PEM_read_bio_DHparams, PEM_read_DHparams, PEM_write_bio_DHparams, PEM_write_DHparams, PEM_read_bio_ECPKParameters, PEM_read_ECPKParameters, PEM_write_bio_ECPKParameters, PEM_write_ECPKParameters, PEM_read_bio_ECPrivateKey, PEM_read_ECPrivateKey, PEM_write_bio_ECPrivateKey, PEM_write_ECPrivateKey, PEM_read_bio_EC_PUBKEY, PEM_read_EC_PUBKEY, PEM_write_bio_EC_PUBKEY, PEM_write_EC_PUBKEY, PEM_read_bio_X509, PEM_read_X509, PEM_write_bio_X509, PEM_write_X509, PEM_read_bio_X509_AUX, PEM_read_X509_AUX, PEM_write_bio_X509_AUX, PEM_write_X509_AUX, PEM_read_bio_X509_REQ, PEM_read_X509_REQ, PEM_write_bio_X509_REQ, PEM_write_X509_REQ, PEM_write_bio_X509_REQ_NEW, PEM_write_X509_REQ_NEW, PEM_read_bio_X509_CRL, PEM_read_X509_CRL, PEM_write_bio_X509_CRL, PEM_write_X509_CRL, PEM_read_bio_PKCS7, PEM_read_PKCS7, PEM_write_bio_PKCS7, PEM_write_PKCS7, PEM_read_CMS, PEM_read_bio_CMS, PEM_write_CMS, PEM_write_bio_CMS — PEM routinesSYNOPSIS
#include <openssl/pem.h>PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
PEM_read_PrivateKey(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
PEM_write_bio_PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_write_PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_read_bio_PKCS8(BIO *bp, X509_SIG **x, pem_password_cb *cb, void *u);
PEM_read_PKCS8(FILE *fp, X509_SIG **x, pem_password_cb *cb, void *u);
PEM_write_bio_PKCS8(BIO *bp, X509_SIG *x);
PEM_write_PKCS8(FILE *fp, X509_SIG *x);
PEM_read_bio_PKCS8_PRIV_KEY_INFO(BIO *bp, PKCS8_PRIV_KEY_INFO **x, pem_password_cb *cb, void *u);
PEM_read_PKCS8_PRIV_KEY_INFO(FILE *fp, PKCS8_PRIV_KEY_INFO **x, pem_password_cb *cb, void *u);
PEM_write_bio_PKCS8_PRIV_KEY_INFO(BIO *bp, PKCS8_PRIV_KEY_INFO *x);
PEM_write_PKCS8_PRIV_KEY_INFO(FILE *fp, PKCS8_PRIV_KEY_INFO *x);
PEM_read_bio_PUBKEY(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, void *u);
PEM_read_PUBKEY(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u);
PEM_write_bio_PUBKEY(BIO *bp, EVP_PKEY *x);
PEM_write_PUBKEY(FILE *fp, EVP_PKEY *x);
PEM_read_bio_RSAPrivateKey(BIO *bp, RSA **x, pem_password_cb *cb, void *u);
PEM_read_RSAPrivateKey(FILE *fp, RSA **x, pem_password_cb *cb, void *u);
PEM_write_bio_RSAPrivateKey(BIO *bp, RSA *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_write_RSAPrivateKey(FILE *fp, RSA *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_read_bio_RSAPublicKey(BIO *bp, RSA **x, pem_password_cb *cb, void *u);
PEM_read_RSAPublicKey(FILE *fp, RSA **x, pem_password_cb *cb, void *u);
PEM_write_bio_RSAPublicKey(BIO *bp, RSA *x);
PEM_write_RSAPublicKey(FILE *fp, RSA *x);
PEM_read_bio_RSA_PUBKEY(BIO *bp, RSA **x, pem_password_cb *cb, void *u);
PEM_read_RSA_PUBKEY(FILE *fp, RSA **x, pem_password_cb *cb, void *u);
PEM_write_bio_RSA_PUBKEY(BIO *bp, RSA *x);
PEM_write_RSA_PUBKEY(FILE *fp, RSA *x);
PEM_read_bio_DSAPrivateKey(BIO *bp, DSA **x, pem_password_cb *cb, void *u);
PEM_read_DSAPrivateKey(FILE *fp, DSA **x, pem_password_cb *cb, void *u);
PEM_write_bio_DSAPrivateKey(BIO *bp, DSA *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_write_DSAPrivateKey(FILE *fp, DSA *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_read_bio_DSA_PUBKEY(BIO *bp, DSA **x, pem_password_cb *cb, void *u);
PEM_read_DSA_PUBKEY(FILE *fp, DSA **x, pem_password_cb *cb, void *u);
PEM_write_bio_DSA_PUBKEY(BIO *bp, DSA *x);
PEM_write_DSA_PUBKEY(FILE *fp, DSA *x);
PEM_read_bio_DSAparams(BIO *bp, DSA **x, pem_password_cb *cb, void *u);
PEM_read_DSAparams(FILE *fp, DSA **x, pem_password_cb *cb, void *u);
PEM_write_bio_DSAparams(BIO *bp, DSA *x);
PEM_write_DSAparams(FILE *fp, DSA *x);
PEM_read_bio_DHparams(BIO *bp, DH **x, pem_password_cb *cb, void *u);
PEM_read_DHparams(FILE *fp, DH **x, pem_password_cb *cb, void *u);
PEM_write_bio_DHparams(BIO *bp, DH *x);
PEM_write_DHparams(FILE *fp, DH *x);
PEM_read_bio_ECPKParameters(BIO *bp, EC_GROUP **x, pem_password_cb *cb, void *u);
PEM_read_ECPKParameters(FILE *fp, EC_GROUP **x, pem_password_cb *cb, void *u);
PEM_write_bio_ECPKParameters(BIO *bp, const EC_GROUP *x);
PEM_write_ECPKParameters(FILE *fp, const EC_GROUP *x);
PEM_read_bio_ECPrivateKey(BIO *bp, EC_KEY **key, pem_password_cb *cb, void *u);
PEM_read_ECPrivateKey(FILE *fp, EC_KEY **eckey, pem_password_cb *cb, void *u);
PEM_write_bio_ECPrivateKey(BIO *bp, EC_KEY *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_write_ECPrivateKey(FILE *fp, EC_KEY *x, const EVP_CIPHER *enc, unsigned char *kstr, int klen, pem_password_cb *cb, void *u);
PEM_read_bio_EC_PUBKEY(BIO *bp, EC_KEY **x, pem_password_cb *cb, void *u);
PEM_read_EC_PUBKEY(FILE *fp, EC_KEY **x, pem_password_cb *cb, void *u);
PEM_write_bio_EC_PUBKEY(BIO *bp, EC_KEY *x);
PEM_write_EC_PUBKEY(FILE *fp, EC_KEY *x);
PEM_read_bio_X509(BIO *bp, X509 **x, pem_password_cb *cb, void *u);
PEM_read_X509(FILE *fp, X509 **x, pem_password_cb *cb, void *u);
PEM_write_bio_X509(BIO *bp, X509 *x);
PEM_write_X509(FILE *fp, X509 *x);
PEM_read_bio_X509_AUX(BIO *bp, X509 **x, pem_password_cb *cb, void *u);
PEM_read_X509_AUX(FILE *fp, X509 **x, pem_password_cb *cb, void *u);
PEM_write_bio_X509_AUX(BIO *bp, X509 *x);
PEM_write_X509_AUX(FILE *fp, X509 *x);
PEM_read_bio_X509_REQ(BIO *bp, X509_REQ **x, pem_password_cb *cb, void *u);
PEM_read_X509_REQ(FILE *fp, X509_REQ **x, pem_password_cb *cb, void *u);
PEM_write_bio_X509_REQ(BIO *bp, X509_REQ *x);
PEM_write_X509_REQ(FILE *fp, X509_REQ *x);
PEM_write_bio_X509_REQ_NEW(BIO *bp, X509_REQ *x);
PEM_write_X509_REQ_NEW(FILE *fp, X509_REQ *x);
PEM_read_bio_X509_CRL(BIO *bp, X509_CRL **x, pem_password_cb *cb, void *u);
PEM_read_X509_CRL(FILE *fp, X509_CRL **x, pem_password_cb *cb, void *u);
PEM_write_bio_X509_CRL(BIO *bp, X509_CRL *x);
PEM_write_X509_CRL(FILE *fp, X509_CRL *x);
PEM_read_bio_PKCS7(BIO *bp, PKCS7 **x, pem_password_cb *cb, void *u);
PEM_read_PKCS7(FILE *fp, PKCS7 **x, pem_password_cb *cb, void *u);
PEM_write_bio_PKCS7(BIO *bp, PKCS7 *x);
PEM_write_PKCS7(FILE *fp, PKCS7 *x);
PEM_read_CMS(FILE *fp, CMS_ContentInfo **x, pem_password_cb *cb, void *u);
PEM_read_bio_CMS(BIO *bp, CMS_ContentInfo **x, pem_password_cb *cb, void *u);
PEM_write_CMS(FILE *fp, const CMS_ContentInfo *x);
PEM_write_bio_CMS(BIO *bp, const CMS_ContentInfo *x);
DESCRIPTION
The PEM functions read or write structures in PEM format. In this sense PEM format is simply base64-encoded data surrounded by header lines; see PEM_read(3) for more details.functions
” will be used to collectively refer to the PEM_read_bio_TYPE(), PEM_read_TYPE(), PEM_write_bio_TYPE(), and PEM_write_TYPE() functions. If no set of specific functions exists for a given type, PEM_ASN1_read(3) can be used instead.PEM function arguments
The PEM functions have many common arguments.PEM encryption format
These old PrivateKey routines use a non-standard technique for encryption.-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,3F17F5316E2BAC89 ...base64 encoded data... -----END RSA PRIVATE KEY-----
RETURN VALUES
The read routines return either a pointer to the structure read or NULL if an error occurred.EXAMPLES
Although the PEM routines take several arguments, in almost all applications most of them are set to 0 or NULL.X509 *x; x = PEM_read_bio_X509(bp, NULL, 0, NULL); if (x == NULL) { /* Error */ }
X509 *x = NULL; if (!PEM_read_bio_X509(bp, &x, 0, NULL)) { /* Error */ }
if (!PEM_write_bio_X509(bp, x)) { /* Error */ }
if (!PEM_write_PrivateKey(fp, key, NULL, NULL, 0, 0, NULL)) { /* Error */ }
if (!PEM_write_bio_PrivateKey(bp, key, EVP_des_ede3_cbc(), NULL, 0, 0, NULL)) { /* Error */ }
if (!PEM_write_bio_PKCS8PrivateKey(bp, key, EVP_des_ede3_cbc(), NULL, 0, 0, "hello")) { /* Error */ }
key = PEM_read_bio_PrivateKey(bp, NULL, 0, "hello"); if (key == NULL) { /* Error */ }
key = PEM_read_bio_PrivateKey(bp, NULL, pass_cb, "My Private Key"); if (key == NULL) { /* Error */ }
int pass_cb(char *buf, int size, int rwflag, void *u) { char *tmp; size_t len; /* We'd probably do something else if 'rwflag' is 1 */ printf("Enter pass phrase for \"%s\"\n", u); /* * Instead of the following line, get the passphrase * from the user in some way. */ tmp = "hello"; if (tmp == NULL) /* An error occurred. */ return -1; len = strlen(tmp); if (len == 0) /* Treat an empty passphrase as an error, too. */ return -1; /* if too long, truncate */ if (len > size) len = size; memcpy(buf, tmp, len); return len; }
SEE ALSO
BIO_new(3), DSA_new(3), PEM_ASN1_read(3), PEM_bytes_read_bio(3), PEM_read(3), PEM_read_SSL_SESSION(3), PEM_write_bio_CMS_stream(3), PEM_write_bio_PKCS7_stream(3), PEM_X509_INFO_read(3), RSA_new(3), X509_CRL_new(3), X509_REQ_new(3), X509_SIG_new(3)HISTORY
PEM_read_X509() and PEM_write_X509() appeared in SSLeay 0.4 or earlier. PEM_read_X509_REQ(), PEM_write_X509_REQ(), PEM_read_X509_CRL(), and PEM_write_X509_CRL() first appeared in SSLeay 0.4.4. PEM_read_RSAPrivateKey(), PEM_write_RSAPrivateKey(), PEM_read_DHparams(), PEM_write_DHparams(), PEM_read_PKCS7(), and PEM_write_PKCS7() first appeared in SSLeay 0.5.1. PEM_read_bio_PrivateKey(), PEM_read_PrivateKey(), PEM_read_bio_RSAPrivateKey(), PEM_write_bio_RSAPrivateKey(), PEM_read_bio_DSAPrivateKey(), PEM_read_DSAPrivateKey(), PEM_write_bio_DSAPrivateKey(), PEM_write_DSAPrivateKey(), PEM_read_bio_DHparams(), PEM_write_bio_DHparams(), PEM_read_bio_X509(), PEM_write_bio_X509(), PEM_read_bio_X509_REQ(), PEM_write_bio_X509_REQ(), PEM_read_bio_X509_CRL(), PEM_write_bio_X509_CRL(), PEM_read_bio_PKCS7(), and PEM_write_bio_PKCS7() first appeared in SSLeay 0.6.0. PEM_write_bio_PrivateKey(), PEM_write_PrivateKey(), PEM_read_bio_DSAparams(), PEM_read_DSAparams(), PEM_write_bio_DSAparams(), and PEM_write_DSAparams() first appeared in SSLeay 0.8.0. PEM_read_bio_RSAPublicKey(), PEM_read_RSAPublicKey(), PEM_write_bio_RSAPublicKey(), and PEM_write_RSAPublicKey() first appeared in SSLeay 0.8.1. All these functions have been available since OpenBSD 2.4.CAVEATS
A frequent cause of problems is attempting to use the PEM routines like this:X509 *x; PEM_read_bio_X509(bp, &x, 0, NULL);
BUGS
The PEM read routines in some versions of OpenSSL will not correctly reuse an existing structure. ThereforePEM_read_bio_X509(bp, &x, 0, NULL);
X509_free(x); x = PEM_read_bio_X509(bp, NULL, 0, NULL);