ct.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. from __future__ import absolute_import, division, print_function
  5. INCLUDES = """
  6. #if CRYPTOGRAPHY_OPENSSL_110F_OR_GREATER && !defined(OPENSSL_NO_CT)
  7. #include <openssl/ct.h>
  8. typedef STACK_OF(SCT) Cryptography_STACK_OF_SCT;
  9. #endif
  10. """
  11. TYPES = """
  12. static const long Cryptography_HAS_SCT;
  13. typedef enum {
  14. SCT_VERSION_NOT_SET,
  15. SCT_VERSION_V1
  16. } sct_version_t;
  17. typedef enum {
  18. CT_LOG_ENTRY_TYPE_NOT_SET,
  19. CT_LOG_ENTRY_TYPE_X509,
  20. CT_LOG_ENTRY_TYPE_PRECERT
  21. } ct_log_entry_type_t;
  22. typedef enum {
  23. SCT_SOURCE_UNKNOWN,
  24. SCT_SOURCE_TLS_EXTENSION,
  25. SCT_SOURCE_X509V3_EXTENSION,
  26. SCT_SOURCE_OCSP_STAPLED_RESPONSE
  27. } sct_source_t;
  28. typedef ... SCT;
  29. typedef ... Cryptography_STACK_OF_SCT;
  30. """
  31. FUNCTIONS = """
  32. sct_version_t SCT_get_version(const SCT *);
  33. ct_log_entry_type_t SCT_get_log_entry_type(const SCT *);
  34. size_t SCT_get0_log_id(const SCT *, unsigned char **);
  35. size_t SCT_get0_signature(const SCT *, unsigned char **);
  36. uint64_t SCT_get_timestamp(const SCT *);
  37. int SCT_set_source(SCT *, sct_source_t);
  38. Cryptography_STACK_OF_SCT *sk_SCT_new_null(void);
  39. void sk_SCT_free(Cryptography_STACK_OF_SCT *);
  40. int sk_SCT_num(const Cryptography_STACK_OF_SCT *);
  41. SCT *sk_SCT_value(const Cryptography_STACK_OF_SCT *, int);
  42. int sk_SCT_push(Cryptography_STACK_OF_SCT *, SCT *);
  43. void SCT_LIST_free(Cryptography_STACK_OF_SCT *);
  44. SCT *SCT_new(void);
  45. int SCT_set1_log_id(SCT *, unsigned char *, size_t);
  46. void SCT_set_timestamp(SCT *, uint64_t);
  47. int SCT_set_version(SCT *, sct_version_t);
  48. int SCT_set_log_entry_type(SCT *, ct_log_entry_type_t);
  49. """
  50. CUSTOMIZATIONS = """
  51. #if CRYPTOGRAPHY_OPENSSL_110F_OR_GREATER && !defined(OPENSSL_NO_CT)
  52. static const long Cryptography_HAS_SCT = 1;
  53. #else
  54. static const long Cryptography_HAS_SCT = 0;
  55. typedef enum {
  56. SCT_VERSION_NOT_SET,
  57. SCT_VERSION_V1
  58. } sct_version_t;
  59. typedef enum {
  60. CT_LOG_ENTRY_TYPE_NOT_SET,
  61. CT_LOG_ENTRY_TYPE_X509,
  62. CT_LOG_ENTRY_TYPE_PRECERT
  63. } ct_log_entry_type_t;
  64. typedef enum {
  65. SCT_SOURCE_UNKNOWN,
  66. SCT_SOURCE_TLS_EXTENSION,
  67. SCT_SOURCE_X509V3_EXTENSION,
  68. SCT_SOURCE_OCSP_STAPLED_RESPONSE
  69. } sct_source_t;
  70. /* OpenSSL compiled with `no-ct` still defines the `SCT` struct. */
  71. #if !defined(OPENSSL_NO_CT)
  72. typedef void SCT;
  73. #endif
  74. typedef void Cryptography_STACK_OF_SCT;
  75. sct_version_t (*SCT_get_version)(const SCT *) = NULL;
  76. ct_log_entry_type_t (*SCT_get_log_entry_type)(const SCT *) = NULL;
  77. size_t (*SCT_get0_log_id)(const SCT *, unsigned char **) = NULL;
  78. size_t (*SCT_get0_signature)(const SCT *, unsigned char **) = NULL;
  79. uint64_t (*SCT_get_timestamp)(const SCT *) = NULL;
  80. int (*SCT_set_source)(SCT *, sct_source_t) = NULL;
  81. Cryptography_STACK_OF_SCT *(*sk_SCT_new_null)(void) = NULL;
  82. void (*sk_SCT_free)(Cryptography_STACK_OF_SCT *) = NULL;
  83. int (*sk_SCT_num)(const Cryptography_STACK_OF_SCT *) = NULL;
  84. SCT *(*sk_SCT_value)(const Cryptography_STACK_OF_SCT *, int) = NULL;
  85. int (*sk_SCT_push)(Cryptography_STACK_OF_SCT *, SCT *) = NULL;
  86. void (*SCT_LIST_free)(Cryptography_STACK_OF_SCT *) = NULL;
  87. SCT *(*SCT_new)(void) = NULL;
  88. int (*SCT_set1_log_id)(SCT *, unsigned char *, size_t) = NULL;
  89. void (*SCT_set_timestamp)(SCT *, uint64_t) = NULL;
  90. int (*SCT_set_version)(SCT *, sct_version_t) = NULL;
  91. int (*SCT_set_log_entry_type)(SCT *, ct_log_entry_type_t) = NULL;
  92. #endif
  93. """