libressl-PKCS8_pkey_set03
Change and inspect pkcs#8 privatekeyinfo objects
Usage
Crypto Library
(libcrypto,
-lcrypto)
int
int
int
const STACK_OF(X509_ATTRIBUTE)
*
Overview
PKCS8_pkey_set0() 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.
PKCS8_pkey_get0() 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.
PKCS8_pkey_add1_attr_by_NID() creates a new X.501 Attribute object using X509_ATTRIBUTE_create_by_NID(3) and appends it to the attributes of keyinfo.
Return values
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.