OSSL_CMP_MSG_get0_header.pod 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. =pod
  2. =head1 NAME
  3. OSSL_CMP_MSG_get0_header,
  4. OSSL_CMP_MSG_get_bodytype,
  5. OSSL_CMP_MSG_update_transactionID,
  6. OSSL_CMP_CTX_setup_CRM,
  7. OSSL_CMP_MSG_read,
  8. OSSL_CMP_MSG_write,
  9. d2i_OSSL_CMP_MSG_bio,
  10. i2d_OSSL_CMP_MSG_bio
  11. - function(s) manipulating CMP messages
  12. =head1 SYNOPSIS
  13. #include <openssl/cmp.h>
  14. OSSL_CMP_PKIHEADER *OSSL_CMP_MSG_get0_header(const OSSL_CMP_MSG *msg);
  15. int OSSL_CMP_MSG_get_bodytype(const OSSL_CMP_MSG *msg);
  16. int OSSL_CMP_MSG_update_transactionID(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg);
  17. OSSL_CRMF_MSG *OSSL_CMP_CTX_setup_CRM(OSSL_CMP_CTX *ctx, int for_KUR, int rid);
  18. OSSL_CMP_MSG *OSSL_CMP_MSG_read(const char *file, OSSL_LIB_CTX *libctx, const char *propq);
  19. int OSSL_CMP_MSG_write(const char *file, const OSSL_CMP_MSG *msg);
  20. OSSL_CMP_MSG *d2i_OSSL_CMP_MSG_bio(BIO *bio, OSSL_CMP_MSG **msg);
  21. int i2d_OSSL_CMP_MSG_bio(BIO *bio, const OSSL_CMP_MSG *msg);
  22. =head1 DESCRIPTION
  23. OSSL_CMP_MSG_get0_header() returns the header of the given CMP message.
  24. OSSL_CMP_MSG_get_bodytype() returns the body type of the given CMP message.
  25. OSSL_CMP_MSG_update_transactionID() updates the transactionID field
  26. in the header of the given message according to the CMP_CTX.
  27. This requires re-protecting the message (if it was protected).
  28. OSSL_CMP_CTX_setup_CRM() creates a CRMF certificate request message
  29. from various information provided in the CMP context argument I<ctx>
  30. for inclusion in a CMP request message based on details contained in I<ctx>.
  31. The I<rid> argument defines the request identifier to use, which typically is 0.
  32. The subject DN included in the certificate template is
  33. the first available value of these:
  34. =over 4
  35. =item any subject name in I<ctx> set via L<OSSL_CMP_CTX_set1_subjectName(3)> -
  36. if it is the NULL-DN (i.e., any empty sequence of RDNs), no subject is included,
  37. =item the subject field of any PKCS#10 CSR set in I<ctx>
  38. via L<OSSL_CMP_CTX_set1_p10CSR(3)>,
  39. =item the subject field of any reference certificate given in I<ctx>
  40. (see L<OSSL_CMP_CTX_set1_oldCert(3)>), but only if I<for_KUR> is nonzero
  41. or the I<ctx> does not include a Subject Alternative Name.
  42. =back
  43. The public key included is the first available value of these:
  44. =over 4
  45. =item the public key derived from any key set via L<OSSL_CMP_CTX_set0_newPkey(3)>,
  46. =item the public key of any PKCS#10 CSR given in I<ctx>,
  47. =item the public key of any reference certificate given in I<ctx>,
  48. =item the public key derived from any client's private key
  49. set via L<OSSL_CMP_CTX_set1_pkey(3)>.
  50. =back
  51. The set of X.509 extensions to include is computed as follows.
  52. If a PKCS#10 CSR is present in I<ctx>, default extensions are taken from there,
  53. otherwise the empty set is taken as the initial value.
  54. If there is a reference certificate in I<ctx> and contains Subject Alternative
  55. Names (SANs) and B<OSSL_CMP_OPT_SUBJECTALTNAME_NODEFAULT> is not set,
  56. these override any SANs from the PKCS#10 CSR.
  57. The extensions are further augmented or overridden by any extensions with the
  58. same OIDs included in the I<ctx> via L<OSSL_CMP_CTX_set0_reqExtensions(3)>.
  59. The SANs are further overridden by any SANs included in I<ctx> via
  60. L<OSSL_CMP_CTX_push1_subjectAltName(3)>.
  61. Finally, policies are overridden by any policies included in I<ctx> via
  62. L<OSSL_CMP_CTX_push0_policy(3)>.
  63. OSSL_CMP_CTX_setup_CRM() also sets the sets the regToken control B<oldCertID>
  64. for KUR messages using the issuer name and serial number of the reference
  65. certificate, if present.
  66. OSSL_CMP_MSG_read() loads a DER-encoded OSSL_CMP_MSG from I<file>.
  67. OSSL_CMP_MSG_write() stores the given OSSL_CMP_MSG to I<file> in DER encoding.
  68. d2i_OSSL_CMP_MSG_bio() parses an ASN.1-encoded OSSL_CMP_MSG from the BIO I<bio>.
  69. It assigns a pointer to the new structure to I<*msg> if I<msg> is not NULL.
  70. i2d_OSSL_CMP_MSG_bio() writes the OSSL_CMP_MSG I<msg> in ASN.1 encoding
  71. to BIO I<bio>.
  72. =head1 NOTES
  73. CMP is defined in RFC 4210.
  74. =head1 RETURN VALUES
  75. OSSL_CMP_MSG_get0_header() returns the intended pointer value as described above
  76. or NULL if the respective entry does not exist and on error.
  77. OSSL_CMP_MSG_get_bodytype() returns the body type or -1 on error.
  78. OSSL_CMP_CTX_setup_CRM() returns a pointer to a B<OSSL_CRMF_MSG> on success,
  79. NULL on error.
  80. d2i_OSSL_CMP_MSG_bio() returns the parsed message or NULL on error.
  81. OSSL_CMP_MSG_read() and d2i_OSSL_CMP_MSG_bio()
  82. return the parsed CMP message or NULL on error.
  83. OSSL_CMP_MSG_write() and i2d_OSSL_CMP_MSG_bio() return
  84. the number of bytes successfully encoded or a negative value if an error occurs.
  85. OSSL_CMP_MSG_update_transactionID() returns 1 on success, 0 on error.
  86. =head1 SEE ALSO
  87. L<OSSL_CMP_CTX_set1_subjectName(3)>, L<OSSL_CMP_CTX_set1_p10CSR(3)>,
  88. L<OSSL_CMP_CTX_set1_oldCert(3)>, L<OSSL_CMP_CTX_set0_newPkey(3)>,
  89. L<OSSL_CMP_CTX_set1_pkey(3)>, L<OSSL_CMP_CTX_set0_reqExtensions(3)>,
  90. L<OSSL_CMP_CTX_push1_subjectAltName(3)>, L<OSSL_CMP_CTX_push0_policy(3)>
  91. =head1 HISTORY
  92. The OpenSSL CMP support was added in OpenSSL 3.0.
  93. =head1 COPYRIGHT
  94. Copyright 2007-2022 The OpenSSL Project Authors. All Rights Reserved.
  95. Licensed under the Apache License 2.0 (the "License"). You may not use
  96. this file except in compliance with the License. You can obtain a copy
  97. in the file LICENSE in the source distribution or at
  98. L<https://www.openssl.org/source/license.html>.
  99. =cut