OpenBSD manual page server

Manual Page Search Parameters

PKCS8_PKEY_SET0(3) Library Functions Manual PKCS8_PKEY_SET0(3)

PKCS8_pkey_set0, PKCS8_pkey_get0, PKCS8_pkey_add1_attr_by_NID, PKCS8_pkey_get0_attrschange and inspect PKCS#8 PrivateKeyInfo objects

#include <openssl/x509.h>

PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *keyinfo, ASN1_OBJECT *aobj, int version, int ptype, void *pval, unsigned char *data, int len);

PKCS8_pkey_get0(const ASN1_OBJECT **paobj, const unsigned char **pdata, int *plen, const X509_ALGOR **palgor, const PKCS8_PRIV_KEY_INFO *keyinfo);

PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *keyinfo, int nid, int type, const unsigned char *data, int len);

PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *keyinfo);

() initializes the keyinfo object. The algorithm is set to aobj with the associated parameter type ptype and parameter value pval using X509_ALGOR_set0(3), replacing any previous information about the algorithm. Unless data is NULL, the encoded private key is set to the len bytes starting at data using ASN1_STRING_set0(3), not performing any validation. If data is NULL, the key data remains unchanged. If the version argument is greater than or equal to 0, it replaces any existing version; otherwise, the version remains unchanged. If keyinfo contains any attributes, they remain unchanged.

() retrieves some information from the keyinfo object. Internal pointers to the algorithm OID, the AlgorithmIdentifier, and the encoded private key are stored in *paobj, *palgor, and *pdata, respectively. NULL pointers can be passed for any of these three arguments if the respective information is not needed. Unless pdata is NULL, *plen is set to the number of bytes in *pdata.

() creates a new X.501 Attribute object using X509_ATTRIBUTE_create_by_NID(3) and appends it to the attributes of keyinfo using X509at_add1_attr(3).

PKCS8_pkey_set0() and PKCS8_pkey_add1_attr_by_NID() return 1 for success or 0 for failure.

PKCS8_pkey_get0() always returns 1.

PKCS8_pkey_get0_attrs() returns an internal pointer to the array of attributes associated with keyinfo or NULL if no attributes are set.

ASN1_STRING_set0(3), EVP_PKCS82PKEY(3), OBJ_nid2obj(3), PKCS8_PRIV_KEY_INFO_new(3), STACK_OF(3), X509_ALGOR_new(3), X509_ATTRIBUTE_create_by_NID(3), X509_ATTRIBUTE_new(3), X509at_add1_attr(3), X509at_get_attr(3)

PKCS8_pkey_set0() and PKCS8_pkey_get0() first appeared in OpenSSL 1.0.0 and have been available since OpenBSD 4.9.

PKCS8_pkey_add1_attr_by_NID() and PKCS8_pkey_get0_attrs() first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 6.4.

October 25, 2021 OpenBSD-7.1