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