summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ct/ct.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ct/ct.h')
-rw-r--r--src/lib/libcrypto/ct/ct.h60
1 files changed, 28 insertions, 32 deletions
diff --git a/src/lib/libcrypto/ct/ct.h b/src/lib/libcrypto/ct/ct.h
index ac981fa0b5..9665880464 100644
--- a/src/lib/libcrypto/ct/ct.h
+++ b/src/lib/libcrypto/ct/ct.h
@@ -17,11 +17,10 @@
17#include <openssl/safestack.h> 17#include <openssl/safestack.h>
18#include <openssl/x509.h> 18#include <openssl/x509.h>
19#include <openssl/cterr.h> 19#include <openssl/cterr.h>
20#ifdef __cplusplus 20#ifdef __cplusplus
21extern "C" { 21extern "C" {
22#endif 22#endif
23 23
24
25/* Minimum RSA key size, from RFC6962 */ 24/* Minimum RSA key size, from RFC6962 */
26#define SCT_MIN_RSA_BITS 2048 25#define SCT_MIN_RSA_BITS 2048
27 26
@@ -55,8 +54,8 @@ typedef enum {
55 SCT_VALIDATION_STATUS_UNKNOWN_VERSION 54 SCT_VALIDATION_STATUS_UNKNOWN_VERSION
56} sct_validation_status_t; 55} sct_validation_status_t;
57 56
58DEFINE_STACK_OF(SCT) 57DECLARE_STACK_OF(SCT)
59DEFINE_STACK_OF(CTLOG) 58DECLARE_STACK_OF(CTLOG)
60 59
61/****************************************** 60/******************************************
62 * CT policy evaluation context functions * 61 * CT policy evaluation context functions *
@@ -128,12 +127,9 @@ SCT *SCT_new(void);
128 * Creates a new SCT from some base64-encoded strings. 127 * Creates a new SCT from some base64-encoded strings.
129 * The caller is responsible for calling SCT_free when finished with the SCT. 128 * The caller is responsible for calling SCT_free when finished with the SCT.
130 */ 129 */
131SCT *SCT_new_from_base64(unsigned char version, 130SCT *SCT_new_from_base64(unsigned char version, const char *logid_base64,
132 const char *logid_base64, 131 ct_log_entry_type_t entry_type, uint64_t timestamp,
133 ct_log_entry_type_t entry_type, 132 const char *extensions_base64, const char *signature_base64);
134 uint64_t timestamp,
135 const char *extensions_base64,
136 const char *signature_base64);
137 133
138/* 134/*
139 * Frees the SCT and the underlying data structures. 135 * Frees the SCT and the underlying data structures.
@@ -155,7 +151,7 @@ sct_version_t SCT_get_version(const SCT *sct);
155 * Set the version of an SCT. 151 * Set the version of an SCT.
156 * Returns 1 on success, 0 if the version is unrecognized. 152 * Returns 1 on success, 0 if the version is unrecognized.
157 */ 153 */
158__owur int SCT_set_version(SCT *sct, sct_version_t version); 154int SCT_set_version(SCT *sct, sct_version_t version);
159 155
160/* 156/*
161 * Returns the log entry type of the SCT. 157 * Returns the log entry type of the SCT.
@@ -166,7 +162,7 @@ ct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct);
166 * Set the log entry type of an SCT. 162 * Set the log entry type of an SCT.
167 * Returns 1 on success, 0 otherwise. 163 * Returns 1 on success, 0 otherwise.
168 */ 164 */
169__owur int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type); 165int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type);
170 166
171/* 167/*
172 * Gets the ID of the log that an SCT came from. 168 * Gets the ID of the log that an SCT came from.
@@ -180,14 +176,14 @@ size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id);
180 * The SCT takes ownership of the specified pointer. 176 * The SCT takes ownership of the specified pointer.
181 * Returns 1 on success, 0 otherwise. 177 * Returns 1 on success, 0 otherwise.
182 */ 178 */
183__owur int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len); 179int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len);
184 180
185/* 181/*
186 * Set the log ID of an SCT. 182 * Set the log ID of an SCT.
187 * This makes a copy of the log_id. 183 * This makes a copy of the log_id.
188 * Returns 1 on success, 0 otherwise. 184 * Returns 1 on success, 0 otherwise.
189 */ 185 */
190__owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id, 186int SCT_set1_log_id(SCT *sct, const unsigned char *log_id,
191 size_t log_id_len); 187 size_t log_id_len);
192 188
193/* 189/*
@@ -213,7 +209,7 @@ int SCT_get_signature_nid(const SCT *sct);
213 * NID_ecdsa_with_SHA256. 209 * NID_ecdsa_with_SHA256.
214 * Returns 1 on success, 0 otherwise. 210 * Returns 1 on success, 0 otherwise.
215 */ 211 */
216__owur int SCT_set_signature_nid(SCT *sct, int nid); 212int SCT_set_signature_nid(SCT *sct, int nid);
217 213
218/* 214/*
219 * Set *ext to point to the extension data for the SCT. ext must not be NULL. 215 * Set *ext to point to the extension data for the SCT. ext must not be NULL.
@@ -233,7 +229,7 @@ void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len);
233 * This takes a copy of the ext. 229 * This takes a copy of the ext.
234 * Returns 1 on success, 0 otherwise. 230 * Returns 1 on success, 0 otherwise.
235 */ 231 */
236__owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext, 232int SCT_set1_extensions(SCT *sct, const unsigned char *ext,
237 size_t ext_len); 233 size_t ext_len);
238 234
239/* 235/*
@@ -253,8 +249,8 @@ void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len);
253 * Set the signature of an SCT to be a copy of the *sig specified. 249 * Set the signature of an SCT to be a copy of the *sig specified.
254 * Returns 1 on success, 0 otherwise. 250 * Returns 1 on success, 0 otherwise.
255 */ 251 */
256__owur int SCT_set1_signature(SCT *sct, const unsigned char *sig, 252int SCT_set1_signature(SCT *sct, const unsigned char *sig,
257 size_t sig_len); 253 size_t sig_len);
258 254
259/* 255/*
260 * The origin of this SCT, e.g. TLS extension, OCSP response, etc. 256 * The origin of this SCT, e.g. TLS extension, OCSP response, etc.
@@ -265,7 +261,7 @@ sct_source_t SCT_get_source(const SCT *sct);
265 * Set the origin of this SCT, e.g. TLS extension, OCSP response, etc. 261 * Set the origin of this SCT, e.g. TLS extension, OCSP response, etc.
266 * Returns 1 on success, 0 otherwise. 262 * Returns 1 on success, 0 otherwise.
267 */ 263 */
268__owur int SCT_set_source(SCT *sct, sct_source_t source); 264int SCT_set_source(SCT *sct, sct_source_t source);
269 265
270/* 266/*
271 * Returns a text string describing the validation status of |sct|. 267 * Returns a text string describing the validation status of |sct|.
@@ -303,7 +299,7 @@ sct_validation_status_t SCT_get_validation_status(const SCT *sct);
303 * Returns 0 if the SCT is invalid or could not be verified. 299 * Returns 0 if the SCT is invalid or could not be verified.
304 * Returns -1 if an error occurs. 300 * Returns -1 if an error occurs.
305 */ 301 */
306__owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx); 302int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx);
307 303
308/* 304/*
309 * Validates the given list of SCTs with the provided context. 305 * Validates the given list of SCTs with the provided context.
@@ -312,7 +308,7 @@ __owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx);
312 * Returns 0 if at least one SCT is invalid or could not be verified. 308 * Returns 0 if at least one SCT is invalid or could not be verified.
313 * Returns a negative integer if an error occurs. 309 * Returns a negative integer if an error occurs.
314 */ 310 */
315__owur int SCT_LIST_validate(const STACK_OF(SCT) *scts, 311int SCT_LIST_validate(const STACK_OF(SCT) *scts,
316 CT_POLICY_EVAL_CTX *ctx); 312 CT_POLICY_EVAL_CTX *ctx);
317 313
318 314
@@ -332,7 +328,7 @@ __owur int SCT_LIST_validate(const STACK_OF(SCT) *scts,
332 * Returns < 0 on error, >= 0 indicating bytes written (or would have been) 328 * Returns < 0 on error, >= 0 indicating bytes written (or would have been)
333 * on success. 329 * on success.
334 */ 330 */
335__owur int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp); 331int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);
336 332
337/* 333/*
338 * Convert TLS format SCT list to a stack of SCTs. 334 * Convert TLS format SCT list to a stack of SCTs.
@@ -359,7 +355,7 @@ STACK_OF(SCT) *o2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,
359 * Returns < 0 on error, >= 0 indicating bytes written (or would have been) 355 * Returns < 0 on error, >= 0 indicating bytes written (or would have been)
360 * on success. 356 * on success.
361 */ 357 */
362__owur int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp); 358int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);
363 359
364/* 360/*
365 * Parses an SCT list in DER format and returns it. 361 * Parses an SCT list in DER format and returns it.
@@ -383,7 +379,7 @@ STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,
383 * to it. 379 * to it.
384 * The length of the SCT in TLS format will be returned. 380 * The length of the SCT in TLS format will be returned.
385 */ 381 */
386__owur int i2o_SCT(const SCT *sct, unsigned char **out); 382int i2o_SCT(const SCT *sct, unsigned char **out);
387 383
388/* 384/*
389 * Parses an SCT in TLS format and returns it. 385 * Parses an SCT in TLS format and returns it.
@@ -416,8 +412,8 @@ CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name);
416 * Returns 1 on success, 0 on failure. 412 * Returns 1 on success, 0 on failure.
417 * Should be deleted by the caller using CTLOG_free when no longer needed. 413 * Should be deleted by the caller using CTLOG_free when no longer needed.
418 */ 414 */
419int CTLOG_new_from_base64(CTLOG ** ct_log, 415int CTLOG_new_from_base64(CTLOG **ct_log, const char *pkey_base64,
420 const char *pkey_base64, const char *name); 416 const char *name);
421 417
422/* 418/*
423 * Deletes a CT log instance and its fields. 419 * Deletes a CT log instance and its fields.
@@ -428,7 +424,7 @@ void CTLOG_free(CTLOG *log);
428const char *CTLOG_get0_name(const CTLOG *log); 424const char *CTLOG_get0_name(const CTLOG *log);
429/* Gets the ID of the CT log */ 425/* Gets the ID of the CT log */
430void CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id, 426void CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id,
431 size_t *log_id_len); 427 size_t *log_id_len);
432/* Gets the public key of the CT log */ 428/* Gets the public key of the CT log */
433EVP_PKEY *CTLOG_get0_public_key(const CTLOG *log); 429EVP_PKEY *CTLOG_get0_public_key(const CTLOG *log);
434 430
@@ -458,16 +454,16 @@ const CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store,
458 * Loads a CT log list into a |store| from a |file|. 454 * Loads a CT log list into a |store| from a |file|.
459 * Returns 1 if loading is successful, or 0 otherwise. 455 * Returns 1 if loading is successful, or 0 otherwise.
460 */ 456 */
461__owur int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file); 457int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file);
462 458
463/* 459/*
464 * Loads the default CT log list into a |store|. 460 * Loads the default CT log list into a |store|.
465 * Returns 1 if loading is successful, or 0 otherwise. 461 * Returns 1 if loading is successful, or 0 otherwise.
466 */ 462 */
467__owur int CTLOG_STORE_load_default_file(CTLOG_STORE *store); 463int CTLOG_STORE_load_default_file(CTLOG_STORE *store);
468 464
469# ifdef __cplusplus 465#ifdef __cplusplus
470} 466}
471# endif 467#endif
472# endif 468#endif
473#endif 469#endif