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_110_OR_GREATER
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
53int sk_SCT_num(const Cryptography_STACK_OF_SCT *);
54SCT *sk_SCT_value(const Cryptography_STACK_OF_SCT *, int);
55
56void SCT_LIST_free(Cryptography_STACK_OF_SCT *);
57
58int sk_SCT_push(Cryptography_STACK_OF_SCT *, SCT *);
59Cryptography_STACK_OF_SCT *sk_SCT_new_null(void);
60SCT *SCT_new(void);
61int SCT_set1_log_id(SCT *, unsigned char *, size_t);
62void SCT_set_timestamp(SCT *, uint64_t);
63int SCT_set_version(SCT *, sct_version_t);
64int SCT_set_log_entry_type(SCT *, ct_log_entry_type_t);
65"""
66
67CUSTOMIZATIONS = """
68#if CRYPTOGRAPHY_OPENSSL_110_OR_GREATER
69static const long Cryptography_HAS_SCT = 1;
70#else
71static const long Cryptography_HAS_SCT = 0;
72
73typedef enum {
74    SCT_VERSION_NOT_SET,
75    SCT_VERSION_V1
76} sct_version_t;
77typedef enum {
78    CT_LOG_ENTRY_TYPE_NOT_SET,
79    CT_LOG_ENTRY_TYPE_X509,
80    CT_LOG_ENTRY_TYPE_PRECERT
81} ct_log_entry_type_t;
82typedef enum {
83    SCT_SOURCE_UNKNOWN,
84    SCT_SOURCE_TLS_EXTENSION,
85    SCT_SOURCE_X509V3_EXTENSION,
86    SCT_SOURCE_OCSP_STAPLED_RESPONSE
87} sct_source_t;
88typedef void SCT;
89typedef void Cryptography_STACK_OF_SCT;
90
91sct_version_t (*SCT_get_version)(const SCT *) = NULL;
92ct_log_entry_type_t (*SCT_get_log_entry_type)(const SCT *) = NULL;
93size_t (*SCT_get0_log_id)(const SCT *, unsigned char **) = NULL;
94size_t (*SCT_get0_signature)(const SCT *, unsigned char **) = NULL;
95uint64_t (*SCT_get_timestamp)(const SCT *) = NULL;
96
97int (*SCT_set_source)(SCT *, sct_source_t) = NULL;
98
99int (*sk_SCT_num)(const Cryptography_STACK_OF_SCT *) = NULL;
100SCT *(*sk_SCT_value)(const Cryptography_STACK_OF_SCT *, int) = NULL;
101
102void (*SCT_LIST_free)(Cryptography_STACK_OF_SCT *) = NULL;
103int (*sk_SCT_push)(Cryptography_STACK_OF_SCT *, SCT *) = NULL;
104Cryptography_STACK_OF_SCT *(*sk_SCT_new_null)(void) = NULL;
105SCT *(*SCT_new)(void) = NULL;
106int (*SCT_set1_log_id)(SCT *, unsigned char *, size_t) = NULL;
107void (*SCT_set_timestamp)(SCT *, uint64_t) = NULL;
108int (*SCT_set_version)(SCT *, sct_version_t) = NULL;
109int (*SCT_set_log_entry_type)(SCT *, ct_log_entry_type_t) = NULL;
110#endif
111"""
112