OSSL_CMP_MSG_get0_header.pod 5.7 KB

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