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