1# This file is dual licensed under the terms of the Apache License, Version 2# 2.0, and the BSD License. See the LICENSE file in the root of this repository 3# for complete details. 4 5from __future__ import absolute_import, division, print_function 6 7INCLUDES = """ 8#if CRYPTOGRAPHY_OPENSSL_110F_OR_GREATER && !defined(OPENSSL_NO_CT) 9#include <openssl/ct.h> 10 11typedef STACK_OF(SCT) Cryptography_STACK_OF_SCT; 12#endif 13""" 14 15TYPES = """ 16static const long Cryptography_HAS_SCT; 17 18typedef enum { 19 SCT_VERSION_NOT_SET, 20 SCT_VERSION_V1 21} sct_version_t; 22 23typedef enum { 24 CT_LOG_ENTRY_TYPE_NOT_SET, 25 CT_LOG_ENTRY_TYPE_X509, 26 CT_LOG_ENTRY_TYPE_PRECERT 27} ct_log_entry_type_t; 28 29typedef enum { 30 SCT_SOURCE_UNKNOWN, 31 SCT_SOURCE_TLS_EXTENSION, 32 SCT_SOURCE_X509V3_EXTENSION, 33 SCT_SOURCE_OCSP_STAPLED_RESPONSE 34} sct_source_t; 35 36typedef ... SCT; 37typedef ... Cryptography_STACK_OF_SCT; 38""" 39 40FUNCTIONS = """ 41sct_version_t SCT_get_version(const SCT *); 42 43ct_log_entry_type_t SCT_get_log_entry_type(const SCT *); 44 45size_t SCT_get0_log_id(const SCT *, unsigned char **); 46 47size_t SCT_get0_signature(const SCT *, unsigned char **); 48 49uint64_t SCT_get_timestamp(const SCT *); 50 51int SCT_set_source(SCT *, sct_source_t); 52 53Cryptography_STACK_OF_SCT *sk_SCT_new_null(void); 54void sk_SCT_free(Cryptography_STACK_OF_SCT *); 55int sk_SCT_num(const Cryptography_STACK_OF_SCT *); 56SCT *sk_SCT_value(const Cryptography_STACK_OF_SCT *, int); 57int sk_SCT_push(Cryptography_STACK_OF_SCT *, SCT *); 58 59void SCT_LIST_free(Cryptography_STACK_OF_SCT *); 60 61SCT *SCT_new(void); 62int SCT_set1_log_id(SCT *, unsigned char *, size_t); 63void SCT_set_timestamp(SCT *, uint64_t); 64int SCT_set_version(SCT *, sct_version_t); 65int SCT_set_log_entry_type(SCT *, ct_log_entry_type_t); 66""" 67 68CUSTOMIZATIONS = """ 69#if CRYPTOGRAPHY_OPENSSL_110F_OR_GREATER && !defined(OPENSSL_NO_CT) 70static const long Cryptography_HAS_SCT = 1; 71#else 72static const long Cryptography_HAS_SCT = 0; 73 74typedef enum { 75 SCT_VERSION_NOT_SET, 76 SCT_VERSION_V1 77} sct_version_t; 78typedef enum { 79 CT_LOG_ENTRY_TYPE_NOT_SET, 80 CT_LOG_ENTRY_TYPE_X509, 81 CT_LOG_ENTRY_TYPE_PRECERT 82} ct_log_entry_type_t; 83typedef enum { 84 SCT_SOURCE_UNKNOWN, 85 SCT_SOURCE_TLS_EXTENSION, 86 SCT_SOURCE_X509V3_EXTENSION, 87 SCT_SOURCE_OCSP_STAPLED_RESPONSE 88} sct_source_t; 89 90/* OpenSSL compiled with `no-ct` still defines the `SCT` struct. */ 91#if !defined(OPENSSL_NO_CT) 92typedef void SCT; 93#endif 94 95typedef void Cryptography_STACK_OF_SCT; 96 97sct_version_t (*SCT_get_version)(const SCT *) = NULL; 98ct_log_entry_type_t (*SCT_get_log_entry_type)(const SCT *) = NULL; 99size_t (*SCT_get0_log_id)(const SCT *, unsigned char **) = NULL; 100size_t (*SCT_get0_signature)(const SCT *, unsigned char **) = NULL; 101uint64_t (*SCT_get_timestamp)(const SCT *) = NULL; 102 103int (*SCT_set_source)(SCT *, sct_source_t) = NULL; 104 105Cryptography_STACK_OF_SCT *(*sk_SCT_new_null)(void) = NULL; 106void (*sk_SCT_free)(Cryptography_STACK_OF_SCT *) = NULL; 107int (*sk_SCT_num)(const Cryptography_STACK_OF_SCT *) = NULL; 108SCT *(*sk_SCT_value)(const Cryptography_STACK_OF_SCT *, int) = NULL; 109int (*sk_SCT_push)(Cryptography_STACK_OF_SCT *, SCT *) = NULL; 110 111void (*SCT_LIST_free)(Cryptography_STACK_OF_SCT *) = NULL; 112SCT *(*SCT_new)(void) = NULL; 113int (*SCT_set1_log_id)(SCT *, unsigned char *, size_t) = NULL; 114void (*SCT_set_timestamp)(SCT *, uint64_t) = NULL; 115int (*SCT_set_version)(SCT *, sct_version_t) = NULL; 116int (*SCT_set_log_entry_type)(SCT *, ct_log_entry_type_t) = NULL; 117#endif 118""" 119