2
0

SCT_new.pod 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. =pod
  2. =head1 NAME
  3. SCT_new, SCT_new_from_base64, SCT_free, SCT_LIST_free,
  4. SCT_get_version, SCT_set_version,
  5. SCT_get_log_entry_type, SCT_set_log_entry_type,
  6. SCT_get0_log_id, SCT_set0_log_id, SCT_set1_log_id,
  7. SCT_get_timestamp, SCT_set_timestamp,
  8. SCT_get_signature_nid, SCT_set_signature_nid,
  9. SCT_get0_signature, SCT_set0_signature, SCT_set1_signature,
  10. SCT_get0_extensions, SCT_set0_extensions, SCT_set1_extensions,
  11. SCT_get_source, SCT_set_source
  12. - A Certificate Transparency Signed Certificate Timestamp
  13. =head1 SYNOPSIS
  14. #include <openssl/ct.h>
  15. typedef enum {
  16. CT_LOG_ENTRY_TYPE_NOT_SET = -1,
  17. CT_LOG_ENTRY_TYPE_X509 = 0,
  18. CT_LOG_ENTRY_TYPE_PRECERT = 1
  19. } ct_log_entry_type_t;
  20. typedef enum {
  21. SCT_VERSION_NOT_SET = -1,
  22. SCT_VERSION_V1 = 0
  23. } sct_version_t;
  24. typedef enum {
  25. SCT_SOURCE_UNKNOWN,
  26. SCT_SOURCE_TLS_EXTENSION,
  27. SCT_SOURCE_X509V3_EXTENSION,
  28. SCT_SOURCE_OCSP_STAPLED_RESPONSE
  29. } sct_source_t;
  30. SCT *SCT_new(void);
  31. SCT *SCT_new_from_base64(unsigned char version,
  32. const char *logid_base64,
  33. ct_log_entry_type_t entry_type,
  34. uint64_t timestamp,
  35. const char *extensions_base64,
  36. const char *signature_base64);
  37. void SCT_free(SCT *sct);
  38. void SCT_LIST_free(STACK_OF(SCT) *a);
  39. sct_version_t SCT_get_version(const SCT *sct);
  40. int SCT_set_version(SCT *sct, sct_version_t version);
  41. ct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct);
  42. int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type);
  43. size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id);
  44. int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len);
  45. int SCT_set1_log_id(SCT *sct, const unsigned char *log_id, size_t log_id_len);
  46. uint64_t SCT_get_timestamp(const SCT *sct);
  47. void SCT_set_timestamp(SCT *sct, uint64_t timestamp);
  48. int SCT_get_signature_nid(const SCT *sct);
  49. int SCT_set_signature_nid(SCT *sct, int nid);
  50. size_t SCT_get0_signature(const SCT *sct, unsigned char **sig);
  51. void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len);
  52. int SCT_set1_signature(SCT *sct, const unsigned char *sig, size_t sig_len);
  53. size_t SCT_get0_extensions(const SCT *sct, unsigned char **ext);
  54. void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len);
  55. int SCT_set1_extensions(SCT *sct, const unsigned char *ext, size_t ext_len);
  56. sct_source_t SCT_get_source(const SCT *sct);
  57. int SCT_set_source(SCT *sct, sct_source_t source);
  58. =head1 DESCRIPTION
  59. Signed Certificate Timestamps (SCTs) are defined by RFC 6962, Section 3.2.
  60. They constitute a promise by a Certificate Transparency (CT) log to publicly
  61. record a certificate. By cryptographically verifying that a log did indeed issue
  62. an SCT, some confidence can be gained that the certificate is publicly known.
  63. An internal representation of an SCT can be created in one of two ways.
  64. The first option is to create a blank SCT, using SCT_new(), and then populate
  65. it using:
  66. =over 2
  67. =item *
  68. SCT_set_version() to set the SCT version.
  69. Only SCT_VERSION_V1 is currently supported.
  70. =item *
  71. SCT_set_log_entry_type() to set the type of certificate the SCT was issued for:
  72. B<CT_LOG_ENTRY_TYPE_X509> for a normal certificate.
  73. B<CT_LOG_ENTRY_TYPE_PRECERT> for a pre-certificate.
  74. =item *
  75. SCT_set0_log_id() or SCT_set1_log_id() to set the LogID of the CT log that the SCT came from.
  76. The former takes ownership, whereas the latter makes a copy.
  77. See RFC 6962, Section 3.2 for the definition of LogID.
  78. =item *
  79. SCT_set_timestamp() to set the time the SCT was issued (time in milliseconds
  80. since the Unix Epoch).
  81. =item *
  82. SCT_set_signature_nid() to set the NID of the signature.
  83. =item *
  84. SCT_set0_signature() or SCT_set1_signature() to set the raw signature value.
  85. The former takes ownership, whereas the latter makes a copy.
  86. =item *
  87. SCT_set0_extensions() or B<SCT_set1_extensions> to provide SCT extensions.
  88. The former takes ownership, whereas the latter makes a copy.
  89. =back
  90. Alternatively, the SCT can be pre-populated from the following data using
  91. SCT_new_from_base64():
  92. =over 2
  93. =item *
  94. The SCT version (only SCT_VERSION_V1 is currently supported).
  95. =item *
  96. The LogID (see RFC 6962, Section 3.2), base64 encoded.
  97. =item *
  98. The type of certificate the SCT was issued for:
  99. B<CT_LOG_ENTRY_TYPE_X509> for a normal certificate.
  100. B<CT_LOG_ENTRY_TYPE_PRECERT> for a pre-certificate.
  101. =item *
  102. The time that the SCT was issued (time in milliseconds since the Unix Epoch).
  103. =item *
  104. The SCT extensions, base64 encoded.
  105. =item *
  106. The SCT signature, base64 encoded.
  107. =back
  108. SCT_set_source() can be used to record where the SCT was found
  109. (TLS extension, X.509 certificate extension or OCSP response). This is not
  110. required for verifying the SCT.
  111. =head1 NOTES
  112. Some of the setters return int, instead of void. These will all return 1 on
  113. success, 0 on failure. They will not make changes on failure.
  114. All of the setters will reset the validation status of the SCT to
  115. SCT_VALIDATION_STATUS_NOT_SET (see L<SCT_validate(3)>).
  116. SCT_set_source() will call SCT_set_log_entry_type() if the type of
  117. certificate the SCT was issued for can be inferred from where the SCT was found.
  118. For example, an SCT found in an X.509 extension must have been issued for a pre-
  119. certificate.
  120. SCT_set_source() will not refuse unknown values.
  121. =head1 RETURN VALUES
  122. SCT_set_version() returns 1 if the specified version is supported, 0 otherwise.
  123. SCT_set_log_entry_type() returns 1 if the specified log entry type is supported, 0 otherwise.
  124. SCT_set0_log_id() and B<SCT_set1_log_id> return 1 if the specified LogID is a
  125. valid SHA-256 hash, 0 otherwise. Additionally, B<SCT_set1_log_id> returns 0 if
  126. malloc fails.
  127. B<SCT_set_signature_nid> returns 1 if the specified NID is supported, 0 otherwise.
  128. B<SCT_set1_extensions> and B<SCT_set1_signature> return 1 if the supplied buffer
  129. is copied successfully, 0 otherwise (i.e. if malloc fails).
  130. B<SCT_set_source> returns 1 on success, 0 otherwise.
  131. =head1 SEE ALSO
  132. L<ct(7)>,
  133. L<SCT_validate(3)>,
  134. L<OBJ_nid2obj(3)>
  135. =head1 HISTORY
  136. These functions were added in OpenSSL 1.1.0.
  137. =head1 COPYRIGHT
  138. Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
  139. Licensed under the Apache License 2.0 (the "License"). You may not use
  140. this file except in compliance with the License. You can obtain a copy
  141. in the file LICENSE in the source distribution or at
  142. L<https://www.openssl.org/source/license.html>.
  143. =cut