File indexing completed on 2025-01-18 10:05:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef OPENSSL_CT_H
0016 # define OPENSSL_CT_H
0017 # pragma once
0018
0019 # include <openssl/macros.h>
0020 # ifndef OPENSSL_NO_DEPRECATED_3_0
0021 # define HEADER_CT_H
0022 # endif
0023
0024 # include <openssl/opensslconf.h>
0025
0026 # ifndef OPENSSL_NO_CT
0027 # include <openssl/types.h>
0028 # include <openssl/safestack.h>
0029 # include <openssl/x509.h>
0030 # include <openssl/cterr.h>
0031 # ifdef __cplusplus
0032 extern "C" {
0033 # endif
0034
0035
0036
0037 # define SCT_MIN_RSA_BITS 2048
0038
0039
0040 # define CT_V1_HASHLEN SHA256_DIGEST_LENGTH
0041
0042 SKM_DEFINE_STACK_OF_INTERNAL(SCT, SCT, SCT)
0043 #define sk_SCT_num(sk) OPENSSL_sk_num(ossl_check_const_SCT_sk_type(sk))
0044 #define sk_SCT_value(sk, idx) ((SCT *)OPENSSL_sk_value(ossl_check_const_SCT_sk_type(sk), (idx)))
0045 #define sk_SCT_new(cmp) ((STACK_OF(SCT) *)OPENSSL_sk_new(ossl_check_SCT_compfunc_type(cmp)))
0046 #define sk_SCT_new_null() ((STACK_OF(SCT) *)OPENSSL_sk_new_null())
0047 #define sk_SCT_new_reserve(cmp, n) ((STACK_OF(SCT) *)OPENSSL_sk_new_reserve(ossl_check_SCT_compfunc_type(cmp), (n)))
0048 #define sk_SCT_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SCT_sk_type(sk), (n))
0049 #define sk_SCT_free(sk) OPENSSL_sk_free(ossl_check_SCT_sk_type(sk))
0050 #define sk_SCT_zero(sk) OPENSSL_sk_zero(ossl_check_SCT_sk_type(sk))
0051 #define sk_SCT_delete(sk, i) ((SCT *)OPENSSL_sk_delete(ossl_check_SCT_sk_type(sk), (i)))
0052 #define sk_SCT_delete_ptr(sk, ptr) ((SCT *)OPENSSL_sk_delete_ptr(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr)))
0053 #define sk_SCT_push(sk, ptr) OPENSSL_sk_push(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr))
0054 #define sk_SCT_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr))
0055 #define sk_SCT_pop(sk) ((SCT *)OPENSSL_sk_pop(ossl_check_SCT_sk_type(sk)))
0056 #define sk_SCT_shift(sk) ((SCT *)OPENSSL_sk_shift(ossl_check_SCT_sk_type(sk)))
0057 #define sk_SCT_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_SCT_sk_type(sk),ossl_check_SCT_freefunc_type(freefunc))
0058 #define sk_SCT_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr), (idx))
0059 #define sk_SCT_set(sk, idx, ptr) ((SCT *)OPENSSL_sk_set(ossl_check_SCT_sk_type(sk), (idx), ossl_check_SCT_type(ptr)))
0060 #define sk_SCT_find(sk, ptr) OPENSSL_sk_find(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr))
0061 #define sk_SCT_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr))
0062 #define sk_SCT_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_SCT_sk_type(sk), ossl_check_SCT_type(ptr), pnum)
0063 #define sk_SCT_sort(sk) OPENSSL_sk_sort(ossl_check_SCT_sk_type(sk))
0064 #define sk_SCT_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SCT_sk_type(sk))
0065 #define sk_SCT_dup(sk) ((STACK_OF(SCT) *)OPENSSL_sk_dup(ossl_check_const_SCT_sk_type(sk)))
0066 #define sk_SCT_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(SCT) *)OPENSSL_sk_deep_copy(ossl_check_const_SCT_sk_type(sk), ossl_check_SCT_copyfunc_type(copyfunc), ossl_check_SCT_freefunc_type(freefunc)))
0067 #define sk_SCT_set_cmp_func(sk, cmp) ((sk_SCT_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SCT_sk_type(sk), ossl_check_SCT_compfunc_type(cmp)))
0068 SKM_DEFINE_STACK_OF_INTERNAL(CTLOG, CTLOG, CTLOG)
0069 #define sk_CTLOG_num(sk) OPENSSL_sk_num(ossl_check_const_CTLOG_sk_type(sk))
0070 #define sk_CTLOG_value(sk, idx) ((CTLOG *)OPENSSL_sk_value(ossl_check_const_CTLOG_sk_type(sk), (idx)))
0071 #define sk_CTLOG_new(cmp) ((STACK_OF(CTLOG) *)OPENSSL_sk_new(ossl_check_CTLOG_compfunc_type(cmp)))
0072 #define sk_CTLOG_new_null() ((STACK_OF(CTLOG) *)OPENSSL_sk_new_null())
0073 #define sk_CTLOG_new_reserve(cmp, n) ((STACK_OF(CTLOG) *)OPENSSL_sk_new_reserve(ossl_check_CTLOG_compfunc_type(cmp), (n)))
0074 #define sk_CTLOG_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_CTLOG_sk_type(sk), (n))
0075 #define sk_CTLOG_free(sk) OPENSSL_sk_free(ossl_check_CTLOG_sk_type(sk))
0076 #define sk_CTLOG_zero(sk) OPENSSL_sk_zero(ossl_check_CTLOG_sk_type(sk))
0077 #define sk_CTLOG_delete(sk, i) ((CTLOG *)OPENSSL_sk_delete(ossl_check_CTLOG_sk_type(sk), (i)))
0078 #define sk_CTLOG_delete_ptr(sk, ptr) ((CTLOG *)OPENSSL_sk_delete_ptr(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr)))
0079 #define sk_CTLOG_push(sk, ptr) OPENSSL_sk_push(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr))
0080 #define sk_CTLOG_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr))
0081 #define sk_CTLOG_pop(sk) ((CTLOG *)OPENSSL_sk_pop(ossl_check_CTLOG_sk_type(sk)))
0082 #define sk_CTLOG_shift(sk) ((CTLOG *)OPENSSL_sk_shift(ossl_check_CTLOG_sk_type(sk)))
0083 #define sk_CTLOG_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_CTLOG_sk_type(sk),ossl_check_CTLOG_freefunc_type(freefunc))
0084 #define sk_CTLOG_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr), (idx))
0085 #define sk_CTLOG_set(sk, idx, ptr) ((CTLOG *)OPENSSL_sk_set(ossl_check_CTLOG_sk_type(sk), (idx), ossl_check_CTLOG_type(ptr)))
0086 #define sk_CTLOG_find(sk, ptr) OPENSSL_sk_find(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr))
0087 #define sk_CTLOG_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr))
0088 #define sk_CTLOG_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_type(ptr), pnum)
0089 #define sk_CTLOG_sort(sk) OPENSSL_sk_sort(ossl_check_CTLOG_sk_type(sk))
0090 #define sk_CTLOG_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_CTLOG_sk_type(sk))
0091 #define sk_CTLOG_dup(sk) ((STACK_OF(CTLOG) *)OPENSSL_sk_dup(ossl_check_const_CTLOG_sk_type(sk)))
0092 #define sk_CTLOG_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(CTLOG) *)OPENSSL_sk_deep_copy(ossl_check_const_CTLOG_sk_type(sk), ossl_check_CTLOG_copyfunc_type(copyfunc), ossl_check_CTLOG_freefunc_type(freefunc)))
0093 #define sk_CTLOG_set_cmp_func(sk, cmp) ((sk_CTLOG_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_CTLOG_sk_type(sk), ossl_check_CTLOG_compfunc_type(cmp)))
0094
0095
0096
0097 typedef enum {
0098 CT_LOG_ENTRY_TYPE_NOT_SET = -1,
0099 CT_LOG_ENTRY_TYPE_X509 = 0,
0100 CT_LOG_ENTRY_TYPE_PRECERT = 1
0101 } ct_log_entry_type_t;
0102
0103 typedef enum {
0104 SCT_VERSION_NOT_SET = -1,
0105 SCT_VERSION_V1 = 0
0106 } sct_version_t;
0107
0108 typedef enum {
0109 SCT_SOURCE_UNKNOWN,
0110 SCT_SOURCE_TLS_EXTENSION,
0111 SCT_SOURCE_X509V3_EXTENSION,
0112 SCT_SOURCE_OCSP_STAPLED_RESPONSE
0113 } sct_source_t;
0114
0115 typedef enum {
0116 SCT_VALIDATION_STATUS_NOT_SET,
0117 SCT_VALIDATION_STATUS_UNKNOWN_LOG,
0118 SCT_VALIDATION_STATUS_VALID,
0119 SCT_VALIDATION_STATUS_INVALID,
0120 SCT_VALIDATION_STATUS_UNVERIFIED,
0121 SCT_VALIDATION_STATUS_UNKNOWN_VERSION
0122 } sct_validation_status_t;
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134 CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new_ex(OSSL_LIB_CTX *libctx,
0135 const char *propq);
0136
0137
0138
0139
0140
0141 CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void);
0142
0143
0144 void CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx);
0145
0146
0147 X509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx);
0148
0149
0150
0151
0152
0153
0154 int CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert);
0155
0156
0157 X509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx);
0158
0159
0160
0161
0162
0163
0164 int CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer);
0165
0166
0167 const CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx);
0168
0169
0170 void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx,
0171 CTLOG_STORE *log_store);
0172
0173
0174
0175
0176
0177
0178 uint64_t CT_POLICY_EVAL_CTX_get_time(const CT_POLICY_EVAL_CTX *ctx);
0179
0180
0181
0182
0183
0184
0185
0186 void CT_POLICY_EVAL_CTX_set_time(CT_POLICY_EVAL_CTX *ctx, uint64_t time_in_ms);
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196 SCT *SCT_new(void);
0197
0198
0199
0200
0201
0202 SCT *SCT_new_from_base64(unsigned char version,
0203 const char *logid_base64,
0204 ct_log_entry_type_t entry_type,
0205 uint64_t timestamp,
0206 const char *extensions_base64,
0207 const char *signature_base64);
0208
0209
0210
0211
0212 void SCT_free(SCT *sct);
0213
0214
0215
0216
0217
0218 void SCT_LIST_free(STACK_OF(SCT) *a);
0219
0220
0221
0222
0223 sct_version_t SCT_get_version(const SCT *sct);
0224
0225
0226
0227
0228
0229 __owur int SCT_set_version(SCT *sct, sct_version_t version);
0230
0231
0232
0233
0234 ct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct);
0235
0236
0237
0238
0239
0240 __owur int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type);
0241
0242
0243
0244
0245
0246
0247 size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id);
0248
0249
0250
0251
0252
0253
0254 __owur int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len);
0255
0256
0257
0258
0259
0260
0261 __owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id,
0262 size_t log_id_len);
0263
0264
0265
0266
0267 uint64_t SCT_get_timestamp(const SCT *sct);
0268
0269
0270
0271
0272 void SCT_set_timestamp(SCT *sct, uint64_t timestamp);
0273
0274
0275
0276
0277
0278
0279 int SCT_get_signature_nid(const SCT *sct);
0280
0281
0282
0283
0284
0285
0286
0287 __owur int SCT_set_signature_nid(SCT *sct, int nid);
0288
0289
0290
0291
0292
0293
0294 size_t SCT_get0_extensions(const SCT *sct, unsigned char **ext);
0295
0296
0297
0298
0299
0300 void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len);
0301
0302
0303
0304
0305
0306
0307 __owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext,
0308 size_t ext_len);
0309
0310
0311
0312
0313
0314
0315 size_t SCT_get0_signature(const SCT *sct, unsigned char **sig);
0316
0317
0318
0319
0320
0321 void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len);
0322
0323
0324
0325
0326
0327 __owur int SCT_set1_signature(SCT *sct, const unsigned char *sig,
0328 size_t sig_len);
0329
0330
0331
0332
0333 sct_source_t SCT_get_source(const SCT *sct);
0334
0335
0336
0337
0338
0339 __owur int SCT_set_source(SCT *sct, sct_source_t source);
0340
0341
0342
0343
0344 const char *SCT_validation_status_string(const SCT *sct);
0345
0346
0347
0348
0349
0350
0351
0352 void SCT_print(const SCT *sct, BIO *out, int indent, const CTLOG_STORE *logs);
0353
0354
0355
0356
0357
0358
0359
0360
0361 void SCT_LIST_print(const STACK_OF(SCT) *sct_list, BIO *out, int indent,
0362 const char *separator, const CTLOG_STORE *logs);
0363
0364
0365
0366
0367
0368 sct_validation_status_t SCT_get_validation_status(const SCT *sct);
0369
0370
0371
0372
0373
0374
0375
0376
0377 __owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx);
0378
0379
0380
0381
0382
0383
0384
0385
0386 __owur int SCT_LIST_validate(const STACK_OF(SCT) *scts,
0387 CT_POLICY_EVAL_CTX *ctx);
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406 __owur int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418 STACK_OF(SCT) *o2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,
0419 size_t len);
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433 __owur int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp);
0434
0435
0436
0437
0438
0439
0440
0441
0442
0443
0444
0445 STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp,
0446 long len);
0447
0448
0449
0450
0451
0452
0453
0454
0455
0456
0457 __owur int i2o_SCT(const SCT *sct, unsigned char **out);
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470 SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len);
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484 CTLOG *CTLOG_new_ex(EVP_PKEY *public_key, const char *name, OSSL_LIB_CTX *libctx,
0485 const char *propq);
0486
0487
0488
0489
0490
0491 CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name);
0492
0493
0494
0495
0496
0497
0498
0499
0500
0501 int CTLOG_new_from_base64_ex(CTLOG **ct_log, const char *pkey_base64,
0502 const char *name, OSSL_LIB_CTX *libctx,
0503 const char *propq);
0504
0505
0506
0507
0508
0509
0510 int CTLOG_new_from_base64(CTLOG ** ct_log,
0511 const char *pkey_base64, const char *name);
0512
0513
0514
0515
0516 void CTLOG_free(CTLOG *log);
0517
0518
0519 const char *CTLOG_get0_name(const CTLOG *log);
0520
0521 void CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id,
0522 size_t *log_id_len);
0523
0524 EVP_PKEY *CTLOG_get0_public_key(const CTLOG *log);
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535 CTLOG_STORE *CTLOG_STORE_new_ex(OSSL_LIB_CTX *libctx, const char *propq);
0536
0537
0538
0539
0540
0541
0542 CTLOG_STORE *CTLOG_STORE_new(void);
0543
0544
0545
0546
0547 void CTLOG_STORE_free(CTLOG_STORE *store);
0548
0549
0550
0551
0552
0553 const CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store,
0554 const uint8_t *log_id,
0555 size_t log_id_len);
0556
0557
0558
0559
0560
0561 __owur int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file);
0562
0563
0564
0565
0566
0567 __owur int CTLOG_STORE_load_default_file(CTLOG_STORE *store);
0568
0569 # ifdef __cplusplus
0570 }
0571 # endif
0572 # endif
0573 #endif