EVP_PKEY_GET_ATTR(3ossl)
π NAME π
okay so this is the EVP_PKEY_GET_ATTR(3ossl) manual page, and it's all about the EVP_PKEY X509_ATTRIBUTE functions β the little crew that PKCS12 uses. slay π
The whole squad:
EVP_PKEY_get_attrEVP_PKEY_get_attr_countEVP_PKEY_get_attr_by_NIDEVP_PKEY_get_attr_by_OBJEVP_PKEY_delete_attrEVP_PKEY_add1_attrEVP_PKEY_add1_attr_by_OBJEVP_PKEY_add1_attr_by_NIDEVP_PKEY_add1_attr_by_txt
β¨ SYNOPSIS β¨
#include <openssl/x509.h>
int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);
int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj,
int lastpos);
X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
const ASN1_OBJECT *obj, int type,
const unsigned char *bytes, int len);
int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
int nid, int type,
const unsigned char *bytes, int len);
int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
const char *attrname, int type,
const unsigned char *bytes, int len);
πΈ DESCRIPTION πΈ
These functions are used by PKCS12. That's the vibe. π«Ά
EVP_PKEY_get_attr_by_OBJ()β finds the location of the first matching objectobjin the key attribute list. The search starts at the position afterlastpos. If the returned value is positive, you can use it on the next call toEVP_PKEY_get_attr_by_OBJ()as the value oflastposso you can iterate through the remaining attributes. On the first call,lastposcan be set to any negative value so the search starts from the beginning of the attribute list. iykyk β¨EVP_PKEY_get_attr_by_NID()β same energy asEVP_PKEY_get_attr_by_OBJ(), except it passes the numerical identifier (NID)nidassociated with the object. See<openssl/obj_mac.h>for a list ofNID_*. π¦EVP_PKEY_get_attr()β returns theX509_ATTRIBUTEobject at indexlocin the key attribute list.locshould be in the range from0toEVP_PKEY_get_attr_count() - 1. literally stay in bounds, bestie.EVP_PKEY_delete_attr()β removes theX509_ATTRIBUTEobject at indexlocin the key attribute list. πEVP_PKEY_add1_attr()β pushes a copy of the passed-inX509_ATTRIBUTEobject to the key attribute list. A new key attribute list is created if required. An error occurs if eitherattrisNULL, or the attribute already exists. no duplicates allowed, periodt. πEVP_PKEY_add1_attr_by_OBJ()β creates a newX509_ATTRIBUTEusingX509_ATTRIBUTE_set1_object()andX509_ATTRIBUTE_set1_data()to assign a newobjwith typetypeand databytesof lengthlen, and then pushes it to the key object's attribute list. Ifobjalready exists in the attribute list, then an error occurs. πEVP_PKEY_add1_attr_by_NID()β similar toEVP_PKEY_add1_attr_by_OBJ(), except it passes the numerical identifier (NID)nidassociated with the object. See<openssl/obj_mac.h>for a list ofNID_*. πEVP_PKEY_add1_attr_by_txt()β similar toEVP_PKEY_add1_attr_by_OBJ(), except it passes a nameattrnameassociated with the object. See<openssl/obj_mac.h>for a list ofSN_*names. β
π RETURN VALUES π
EVP_PKEY_get_attr_count()β returns the number of attributes in the key object attribute list, or-1if the attribute list isNULL. πEVP_PKEY_get_attr_by_OBJ()β returns-1if either the list is empty OR the object is not found; otherwise it returns the location of the object in the list. π₯EVP_PKEY_get_attr_by_NID()β similar toEVP_PKEY_get_attr_by_OBJ(), except that it returns-2if thenidis not known by OpenSSL. extra special error code, bestie. πEVP_PKEY_get_attr()β returns either anX509_ATTRIBUTEorNULLif there is an error. π¦EVP_PKEY_delete_attr()β returns either the removedX509_ATTRIBUTEorNULLif there is an error. πEVP_PKEY_add1_attr(),EVP_PKEY_add1_attr_by_OBJ(),EVP_PKEY_add1_attr_by_NID()andEVP_PKEY_add1_attr_by_txt()β return1on success or0otherwise. slay. β
π¦ NOTES π¦
A EVP_PKEY object's attribute list is initially NULL.
β οΈ Important vibe check: all the functions listed above will return an error unless EVP_PKEY_add1_attr() is called. fr fr, do not skip that step. π
All functions listed assume that the key is not NULL. no cap. πΈ
π₯ SEE ALSO π₯
X509_ATTRIBUTE(3)β the related manual page, go read it next bestie. β¨
π COPYRIGHT π
Copyright 2023-2024 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
mwah π β this cutie is from OpenSSL 3.5.6, dated 2026-04-07. πβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms