EVP_PKEY_get_attr.3ossl 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "EVP_PKEY_GET_ATTR 3ossl"
  58. .TH EVP_PKEY_GET_ATTR 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. EVP_PKEY_get_attr,
  65. EVP_PKEY_get_attr_count,
  66. EVP_PKEY_get_attr_by_NID, EVP_PKEY_get_attr_by_OBJ,
  67. EVP_PKEY_delete_attr,
  68. EVP_PKEY_add1_attr,
  69. EVP_PKEY_add1_attr_by_OBJ, EVP_PKEY_add1_attr_by_NID, EVP_PKEY_add1_attr_by_txt
  70. \&\- EVP_PKEY X509_ATTRIBUTE functions
  71. .SH SYNOPSIS
  72. .IX Header "SYNOPSIS"
  73. .Vb 1
  74. \& #include <openssl/x509.h>
  75. \&
  76. \& int EVP_PKEY_get_attr_count(const EVP_PKEY *key);
  77. \& int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos);
  78. \& int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj,
  79. \& int lastpos);
  80. \& X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc);
  81. \& X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc);
  82. \& int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr);
  83. \& int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key,
  84. \& const ASN1_OBJECT *obj, int type,
  85. \& const unsigned char *bytes, int len);
  86. \& int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key,
  87. \& int nid, int type,
  88. \& const unsigned char *bytes, int len);
  89. \& int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key,
  90. \& const char *attrname, int type,
  91. \& const unsigned char *bytes, int len);
  92. .Ve
  93. .SH DESCRIPTION
  94. .IX Header "DESCRIPTION"
  95. These functions are used by \fBPKCS12\fR.
  96. .PP
  97. \&\fBEVP_PKEY_get_attr_by_OBJ()\fR finds the location of the first matching object \fIobj\fR
  98. in the \fIkey\fR attribute list. The search starts at the position after \fIlastpos\fR.
  99. If the returned value is positive then it can be used on the next call to
  100. \&\fBEVP_PKEY_get_attr_by_OBJ()\fR as the value of \fIlastpos\fR in order to iterate through
  101. the remaining attributes. \fIlastpos\fR can be set to any negative value on the
  102. first call, in order to start searching from the start of the attribute list.
  103. .PP
  104. \&\fBEVP_PKEY_get_attr_by_NID()\fR is similar to \fBEVP_PKEY_get_attr_by_OBJ()\fR except that
  105. it passes the numerical identifier (NID) \fInid\fR associated with the object.
  106. See <openssl/obj_mac.h> for a list of NID_*.
  107. .PP
  108. \&\fBEVP_PKEY_get_attr()\fR returns the \fBX509_ATTRIBUTE\fR object at index \fIloc\fR in the
  109. \&\fIkey\fR attribute list. \fIloc\fR should be in the range from 0 to
  110. \&\fBEVP_PKEY_get_attr_count()\fR \- 1.
  111. .PP
  112. \&\fBEVP_PKEY_delete_attr()\fR removes the \fBX509_ATTRIBUTE\fR object at index \fIloc\fR in
  113. the \fIkey\fR attribute list.
  114. .PP
  115. \&\fBEVP_PKEY_add1_attr()\fR pushes a copy of the passed in \fBX509_ATTRIBUTE\fR object
  116. to the \fIkey\fR attribute list. A new \fIkey\fR attribute list is created if required.
  117. An error occurs if either \fIattr\fR is NULL, or the attribute already exists.
  118. .PP
  119. \&\fBEVP_PKEY_add1_attr_by_OBJ()\fR creates a new \fBX509_ATTRIBUTE\fR using
  120. \&\fBX509_ATTRIBUTE_set1_object()\fR and \fBX509_ATTRIBUTE_set1_data()\fR to assign a new
  121. \&\fIobj\fR with type \fItype\fR and data \fIbytes\fR of length \fIlen\fR and then pushes it
  122. to the \fIkey\fR object's attribute list. If \fIobj\fR already exists in the attribute
  123. list then an error occurs.
  124. .PP
  125. \&\fBEVP_PKEY_add1_attr_by_NID()\fR is similar to \fBEVP_PKEY_add1_attr_by_OBJ()\fR except
  126. that it passes the numerical identifier (NID) \fInid\fR associated with the object.
  127. See <openssl/obj_mac.h> for a list of NID_*.
  128. .PP
  129. \&\fBEVP_PKEY_add1_attr_by_txt()\fR is similar to \fBEVP_PKEY_add1_attr_by_OBJ()\fR except
  130. that it passes a name \fIattrname\fR associated with the object.
  131. See <openssl/obj_mac.h> for a list of SN_* names.
  132. .SH "RETURN VALUES"
  133. .IX Header "RETURN VALUES"
  134. \&\fBEVP_PKEY_get_attr_count()\fR returns the number of attributes in the \fIkey\fR object
  135. attribute list or \-1 if the attribute list is NULL.
  136. .PP
  137. \&\fBEVP_PKEY_get_attr_by_OBJ()\fR returns \-1 if either the list is empty OR the object
  138. is not found, otherwise it returns the location of the object in the list.
  139. .PP
  140. \&\fBEVP_PKEY_get_attr_by_NID()\fR is similar to \fBEVP_PKEY_get_attr_by_OBJ()\fR, except that
  141. it returns \-2 if the \fInid\fR is not known by OpenSSL.
  142. .PP
  143. \&\fBEVP_PKEY_get_attr()\fR returns either a \fBX509_ATTRIBUTE\fR or NULL if there is a
  144. error.
  145. .PP
  146. \&\fBEVP_PKEY_delete_attr()\fR returns either the removed \fBX509_ATTRIBUTE\fR or NULL if
  147. there is a error.
  148. .PP
  149. \&\fBEVP_PKEY_add1_attr()\fR, \fBEVP_PKEY_add1_attr_by_OBJ()\fR, \fBEVP_PKEY_add1_attr_by_NID()\fR
  150. and \fBEVP_PKEY_add1_attr_by_txt()\fR return 1 on success or 0 otherwise.
  151. .SH NOTES
  152. .IX Header "NOTES"
  153. A \fBEVP_PKEY\fR object's attribute list is initially NULL. All the above functions
  154. listed will return an error unless \fBEVP_PKEY_add1_attr()\fR is called.
  155. All functions listed assume that the \fIkey\fR is not NULL.
  156. .SH "SEE ALSO"
  157. .IX Header "SEE ALSO"
  158. \&\fBX509_ATTRIBUTE\fR\|(3)
  159. .SH COPYRIGHT
  160. .IX Header "COPYRIGHT"
  161. Copyright 2023\-2024 The OpenSSL Project Authors. All Rights Reserved.
  162. .PP
  163. Licensed under the Apache License 2.0 (the "License"). You may not use
  164. this file except in compliance with the License. You can obtain a copy
  165. in the file LICENSE in the source distribution or at
  166. <https://www.openssl.org/source/license.html>.