# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import absolute_import, division, print_function import binascii import os import textwrap import pretend import pytest import cryptography from cryptography.exceptions import UnsupportedAlgorithm, _Reasons import cryptography_vectors from .utils import ( check_backend_support, check_for_iface, der_encode_dsa_signature, load_cryptrec_vectors, load_fips_dsa_key_pair_vectors, load_fips_dsa_sig_vectors, load_fips_ecdsa_key_pair_vectors, load_fips_ecdsa_signing_vectors, load_hash_vectors, load_nist_vectors, load_pkcs1_vectors, load_rsa_nist_vectors, load_vectors_from_file, raises_unsupported_algorithm, select_backends ) class FakeInterface(object): pass def test_select_one_backend(): b1 = pretend.stub(name="b1") b2 = pretend.stub(name="b2") b3 = pretend.stub(name="b3") backends = [b1, b2, b3] name = "b2" selected_backends = select_backends(name, backends) assert len(selected_backends) == 1 assert selected_backends[0] == b2 def test_select_no_backend(): b1 = pretend.stub(name="b1") b2 = pretend.stub(name="b2") b3 = pretend.stub(name="b3") backends = [b1, b2, b3] name = "back!" with pytest.raises(ValueError): select_backends(name, backends) def test_select_backends_none(): b1 = pretend.stub(name="b1") b2 = pretend.stub(name="b2") b3 = pretend.stub(name="b3") backends = [b1, b2, b3] name = None selected_backends = select_backends(name, backends) assert len(selected_backends) == 3 def test_select_two_backends(): b1 = pretend.stub(name="b1") b2 = pretend.stub(name="b2") b3 = pretend.stub(name="b3") backends = [b1, b2, b3] name = "b2 ,b1 " selected_backends = select_backends(name, backends) assert len(selected_backends) == 2 assert selected_backends == [b1, b2] def test_check_for_iface(): item = pretend.stub(keywords=["fake_name"], funcargs={"backend": True}) with pytest.raises(pytest.skip.Exception) as exc_info: check_for_iface("fake_name", FakeInterface, item) assert exc_info.value.args[0] == "True backend does not support fake_name" item = pretend.stub( keywords=["fake_name"], funcargs={"backend": FakeInterface()} ) check_for_iface("fake_name", FakeInterface, item) def test_check_backend_support_skip(): supported = pretend.stub( kwargs={"only_if": lambda backend: False, "skip_message": "Nope"} ) item = pretend.stub(keywords={"supported": supported}, funcargs={"backend": True}) with pytest.raises(pytest.skip.Exception) as exc_info: check_backend_support(item) assert exc_info.value.args[0] == "Nope (True)" def test_check_backend_support_no_skip(): supported = pretend.stub( kwargs={"only_if": lambda backend: True, "skip_message": "Nope"} ) item = pretend.stub(keywords={"supported": supported}, funcargs={"backend": True}) assert check_backend_support(item) is None def test_check_backend_support_no_backend(): supported = pretend.stub( kwargs={"only_if": "notalambda", "skip_message": "Nope"} ) item = pretend.stub(keywords={"supported": supported}, funcargs={}) with pytest.raises(ValueError): check_backend_support(item) def test_der_encode_dsa_signature_values(): sig = der_encode_dsa_signature(1, 1) assert sig == b"0\x06\x02\x01\x01\x02\x01\x01" sig2 = der_encode_dsa_signature( 1037234182290683143945502320610861668562885151617, 559776156650501990899426031439030258256861634312 ) assert sig2 == ( b'0-\x02\x15\x00\xb5\xaf0xg\xfb\x8bT9\x00\x13\xccg\x02\r\xdf\x1f,\x0b' b'\x81\x02\x14b\r;"\xabP1D\x0c>5\xea\xb6\xf4\x81)\x8f\x9e\x9f\x08' ) sig3 = der_encode_dsa_signature(0, 0) assert sig3 == b"0\x06\x02\x01\x00\x02\x01\x00" sig4 = der_encode_dsa_signature(-1, 0) assert sig4 == b"0\x06\x02\x01\xFF\x02\x01\x00" def test_load_nist_vectors(): vector_data = textwrap.dedent(""" # CAVS 11.1 # Config info for aes_values # AESVS GFSbox test data for CBC # State : Encrypt and Decrypt # Key Length : 128 # Generated on Fri Apr 22 15:11:33 2011 [ENCRYPT] COUNT = 0 KEY = 00000000000000000000000000000000 IV = 00000000000000000000000000000000 PLAINTEXT = f34481ec3cc627bacd5dc3fb08f273e6 CIPHERTEXT = 0336763e966d92595a567cc9ce537f5e COUNT = 1 KEY = 00000000000000000000000000000000 IV = 00000000000000000000000000000000 PLAINTEXT = 9798c4640bad75c7c3227db910174e72 CIPHERTEXT = a9a1631bf4996954ebc093957b234589 [DECRYPT] COUNT = 0 KEY = 00000000000000000000000000000000 IV = 00000000000000000000000000000000 CIPHERTEXT = 0336763e966d92595a567cc9ce537f5e PLAINTEXT = f34481ec3cc627bacd5dc3fb08f273e6 COUNT = 1 KEY = 00000000000000000000000000000000 IV = 00000000000000000000000000000000 CIPHERTEXT = a9a1631bf4996954ebc093957b234589 PLAINTEXT = 9798c4640bad75c7c3227db910174e72 """).splitlines() assert load_nist_vectors(vector_data) == [ { "key": b"00000000000000000000000000000000", "iv": b"00000000000000000000000000000000", "plaintext": b"f34481ec3cc627bacd5dc3fb08f273e6", "ciphertext": b"0336763e966d92595a567cc9ce537f5e", }, { "key": b"00000000000000000000000000000000", "iv": b"00000000000000000000000000000000", "plaintext": b"9798c4640bad75c7c3227db910174e72", "ciphertext": b"a9a1631bf4996954ebc093957b234589", }, { "key": b"00000000000000000000000000000000", "iv": b"00000000000000000000000000000000", "plaintext": b"f34481ec3cc627bacd5dc3fb08f273e6", "ciphertext": b"0336763e966d92595a567cc9ce537f5e", }, { "key": b"00000000000000000000000000000000", "iv": b"00000000000000000000000000000000", "plaintext": b"9798c4640bad75c7c3227db910174e72", "ciphertext": b"a9a1631bf4996954ebc093957b234589", }, ] def test_load_nist_vectors_with_null_chars(): vector_data = textwrap.dedent(""" COUNT = 0 KEY = thing\\0withnulls COUNT = 1 KEY = 00000000000000000000000000000000 """).splitlines() assert load_nist_vectors(vector_data) == [ { "key": b"thing\x00withnulls", }, { "key": b"00000000000000000000000000000000", }, ] def test_load_cryptrec_vectors(): vector_data = textwrap.dedent(""" # Vectors taken from http://info.isl.ntt.co.jp/crypt/eng/camellia/ # Download is t_camelia.txt # Camellia with 128-bit key K No.001 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 P No.001 : 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C No.001 : 07 92 3A 39 EB 0A 81 7D 1C 4D 87 BD B8 2D 1F 1C P No.002 : 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C No.002 : 48 CD 64 19 80 96 72 D2 34 92 60 D8 9A 08 D3 D3 K No.002 : 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 P No.001 : 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C No.001 : 07 92 3A 39 EB 0A 81 7D 1C 4D 87 BD B8 2D 1F 1C """).splitlines() assert load_cryptrec_vectors(vector_data) == [ { "key": b"00000000000000000000000000000000", "plaintext": b"80000000000000000000000000000000", "ciphertext": b"07923A39EB0A817D1C4D87BDB82D1F1C", }, { "key": b"00000000000000000000000000000000", "plaintext": b"40000000000000000000000000000000", "ciphertext": b"48CD6419809672D2349260D89A08D3D3", }, { "key": b"10000000000000000000000000000000", "plaintext": b"80000000000000000000000000000000", "ciphertext": b"07923A39EB0A817D1C4D87BDB82D1F1C", }, ] def test_load_cryptrec_vectors_invalid(): vector_data = textwrap.dedent(""" # Vectors taken from http://info.isl.ntt.co.jp/crypt/eng/camellia/ # Download is t_camelia.txt # Camellia with 128-bit key E No.001 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 """).splitlines() with pytest.raises(ValueError): load_cryptrec_vectors(vector_data) def test_load_hash_vectors(): vector_data = textwrap.dedent(""" # http://tools.ietf.org/html/rfc1321 [irrelevant] Len = 0 Msg = 00 MD = d41d8cd98f00b204e9800998ecf8427e Len = 8 Msg = 61 MD = 0cc175b9c0f1b6a831c399e269772661 Len = 24 Msg = 616263 MD = 900150983cd24fb0d6963f7d28e17f72 Len = 112 Msg = 6d65737361676520646967657374 MD = f96b697d7cb7938d525a2f31aaf161d0 """).splitlines() assert load_hash_vectors(vector_data) == [ (b"", "d41d8cd98f00b204e9800998ecf8427e"), (b"61", "0cc175b9c0f1b6a831c399e269772661"), (b"616263", "900150983cd24fb0d6963f7d28e17f72"), (b"6d65737361676520646967657374", "f96b697d7cb7938d525a2f31aaf161d0"), ] def test_load_hmac_vectors(): vector_data = textwrap.dedent(""" Len = 224 # "Jefe" Key = 4a656665 # "what do ya want for nothing?" Msg = 7768617420646f2079612077616e7420666f72206e6f7468696e673f MD = 750c783e6ab0b503eaa86e310a5db738 """).splitlines() assert load_hash_vectors(vector_data) == [ (b"7768617420646f2079612077616e7420666f72206e6f7468696e673f", "750c783e6ab0b503eaa86e310a5db738", b"4a656665"), ] def test_load_hash_vectors_bad_data(): vector_data = textwrap.dedent(""" # http://tools.ietf.org/html/rfc1321 Len = 0 Msg = 00 UNKNOWN=Hello World """).splitlines() with pytest.raises(ValueError): load_hash_vectors(vector_data) def test_load_vectors_from_file(): vectors = load_vectors_from_file( os.path.join("ciphers", "Blowfish", "bf-cfb.txt"), load_nist_vectors, ) assert vectors == [ { "key": b"0123456789ABCDEFF0E1D2C3B4A59687", "iv": b"FEDCBA9876543210", "plaintext": ( b"37363534333231204E6F77206973207468652074696D6520666F722000" ), "ciphertext": ( b"E73214A2822139CAF26ECF6D2EB9E76E3DA3DE04D1517200519D57A6C3" ), } ] def test_load_nist_gcm_vectors(): vector_data = textwrap.dedent(""" [Keylen = 128] [IVlen = 96] [PTlen = 0] [AADlen = 0] [Taglen = 128] Count = 0 Key = 11754cd72aec309bf52f7687212e8957 IV = 3c819d9a9bed087615030b65 PT = AAD = CT = Tag = 250327c674aaf477aef2675748cf6971 Count = 1 Key = 272f16edb81a7abbea887357a58c1917 IV = 794ec588176c703d3d2a7a07 PT = AAD = CT = Tag = b6e6f197168f5049aeda32dafbdaeb Count = 2 Key = a49a5e26a2f8cb63d05546c2a62f5343 IV = 907763b19b9b4ab6bd4f0281 CT = AAD = Tag = a2be08210d8c470a8df6e8fbd79ec5cf FAIL Count = 3 Key = 5c1155084cc0ede76b3bc22e9f7574ef IV = 9549e4ba69a61cad7856efc1 PT = d1448fa852b84408e2dad8381f363de7 AAD = e98e9d9c618e46fef32660976f854ee3 CT = f78b60ca125218493bea1c50a2e12ef4 Tag = d72da7f5c6cf0bca7242c71835809449 [Keylen = 128] [IVlen = 96] [PTlen = 0] [AADlen = 0] [Taglen = 120] Count = 0 Key = eac258e99c55e6ae8ef1da26640613d7 IV = 4e8df20faaf2c8eebe922902 CT = AAD = Tag = e39aeaebe86aa309a4d062d6274339 PT = Count = 1 Key = 3726cf02fcc6b8639a5497652c94350d IV = 55fef82cde693ce76efcc193 CT = AAD = Tag = 3d68111a81ed22d2ef5bccac4fc27f FAIL Count = 2 K
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import absolute_import, division, print_function
INCLUDES = """
#include <openssl/err.h>
"""
TYPES = """
static const int Cryptography_HAS_EC_CODES;
static const int Cryptography_HAS_RSA_R_PKCS_DECODING_ERROR;
struct ERR_string_data_st {
unsigned long error;
const char *string;
};
typedef struct ERR_string_data_st ERR_STRING_DATA;
typedef ... ERR_STATE;
static const int ERR_LIB_DH;
static const int ERR_LIB_EVP;
static const int ERR_LIB_EC;
static const int ERR_LIB_PEM;
static const int ERR_LIB_ASN1;
static const int ERR_LIB_RSA;
static const int ERR_LIB_PKCS12;
static const int ERR_LIB_SSL;
static const int ERR_LIB_X509;
static const int ASN1_F_ASN1_EX_C2I;
static const int ASN1_F_ASN1_FIND_END;
static const int ASN1_F_ASN1_GENERATE_V3;
static const int ASN1_F_ASN1_GET_OBJECT;
static const int ASN1_F_ASN1_ITEM_I2D_FP;
static const int ASN1_F_ASN1_ITEM_PACK;
static const int ASN1_F_ASN1_ITEM_SIGN;
static const int ASN1_F_ASN1_ITEM_UNPACK;
static const int ASN1_F_ASN1_ITEM_VERIFY;
static const int ASN1_F_ASN1_MBSTRING_NCOPY;
static const int ASN1_F_ASN1_TEMPLATE_EX_D2I;
static const int ASN1_F_ASN1_TEMPLATE_NEW;
static const int ASN1_F_ASN1_TEMPLATE_NOEXP_D2I;
static const int ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING;
static const int ASN1_F_ASN1_TYPE_GET_OCTETSTRING;
static const int ASN1_F_ASN1_VERIFY;
static const int ASN1_F_BITSTR_CB;
static const int ASN1_F_D2I_ASN1_UINTEGER;
static const int ASN1_F_D2I_PRIVATEKEY;
static const int ASN1_F_I2D_DSA_PUBKEY;
static const int ASN1_F_LONG_C2I;
static const int ASN1_F_OID_MODULE_INIT;
static const int ASN1_F_PARSE_TAGGING;
static const int ASN1_F_PKCS5_PBE_SET;
static const int ASN1_F_B64_READ_ASN1;
static const int ASN1_F_B64_WRITE_ASN1;
static const int ASN1_F_SMIME_READ_ASN1;
static const int ASN1_F_SMIME_TEXT;
static const int ASN1_F_ASN1_CHECK_TLEN;
static const int ASN1_R_BOOLEAN_IS_WRONG_LENGTH;
static const int ASN1_R_BUFFER_TOO_SMALL;
static const int ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER;
static const int ASN1_R_DATA_IS_WRONG;
static const int ASN1_R_DECODE_ERROR;
static const int ASN1_R_DEPTH_EXCEEDED;
static const int ASN1_R_ENCODE_ERROR;
static const int ASN1_R_ERROR_GETTING_TIME;
static const int ASN1_R_ERROR_LOADING_SECTION;
static const int ASN1_R_MSTRING_WRONG_TAG;
static const int ASN1_R_NESTED_ASN1_STRING;
static const int ASN1_R_NO_MATCHING_CHOICE_TYPE;
static const int ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM;
static const int ASN1_R_UNKNOWN_OBJECT_TYPE;
static const int ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE;
static const int ASN1_R_UNKNOWN_TAG;
static const int ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE;
static const int ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE;
static const int ASN1_R_UNSUPPORTED_TYPE;
static const int ASN1_R_WRONG_TAG;
static const int ASN1_R_NO_CONTENT_TYPE;
static const int ASN1_R_NO_MULTIPART_BODY_FAILURE;
static const int ASN1_R_NO_MULTIPART_BOUNDARY;
static const int ASN1_R_HEADER_TOO_LONG;
static const int DH_F_COMPUTE_KEY;
static const int DH_R_INVALID_PUBKEY;
static const int EVP_F_AES_INIT_KEY;
static const int EVP_F_EVP_CIPHER_CTX_CTRL;
static const int EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH;
static const int EVP_F_EVP_CIPHERINIT_EX;
static const int EVP_F_EVP_DECRYPTFINAL_EX;
static const int EVP_F_EVP_DIGESTINIT_EX;
static const int EVP_F_EVP_ENCRYPTFINAL_EX;
static const int EVP_F_EVP_MD_CTX_COPY_EX;
static const int EVP_F_EVP_OPENINIT;
static const int EVP_F_EVP_PBE_ALG_ADD;
static const int EVP_F_EVP_PBE_CIPHERINIT;
static const int EVP_F_EVP_PKCS82PKEY;
static const int EVP_F_EVP_PKEY_COPY_PARAMETERS;
static const int EVP_F_EVP_PKEY_DECRYPT;
static const int EVP_F_EVP_PKEY_ENCRYPT;
static const int EVP_F_EVP_PKEY_NEW;
static const int EVP_F_EVP_SIGNFINAL;
static const int EVP_F_EVP_VERIFYFINAL;
static const int EVP_F_PKCS5_PBE_KEYIVGEN;
static const int EVP_F_PKCS5_V2_PBE_KEYIVGEN;
static const int EVP_F_RC2_MAGIC_TO_METH;
static const int EVP_F_RC5_CTRL;
static const int EVP_F_CAMELLIA_INIT_KEY;
static const int EVP_R_AES_KEY_SETUP_FAILED;
static const int EVP_R_BAD_DECRYPT;
static const int EVP_R_CIPHER_PARAMETER_ERROR;
static const int EVP_R_CTRL_NOT_IMPLEMENTED;
static const int EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED;
static const int EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH;
static const int EVP_R_DECODE_ERROR;
static const int EVP_R_DIFFERENT_KEY_TYPES;
static const int EVP_R_INITIALIZATION_ERROR;
static const int EVP_R_INPUT_NOT_INITIALIZED;
static const int EVP_R_INVALID_KEY_LENGTH;
static const int EVP_R_KEYGEN_FAILURE;
static const int EVP_R_MISSING_PARAMETERS;
static const int EVP_R_NO_CIPHER_SET;
static const int EVP_R_NO_DIGEST_SET;
static const int EVP_R_PUBLIC_KEY_NOT_RSA;
static const int EVP_R_UNKNOWN_PBE_ALGORITHM;
static const int EVP_R_UNSUPPORTED_CIPHER;
static const int EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION;
static const int EVP_R_UNSUPPORTED_KEYLENGTH;
static const int EVP_R_UNSUPPORTED_SALT_TYPE;
static const int EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM;
static const int EVP_R_WRONG_FINAL_BLOCK_LENGTH;
static const int EVP_R_CAMELLIA_KEY_SETUP_FAILED;
static const int EC_F_EC_GROUP_NEW_BY_CURVE_NAME;
static const int EC_R_UNKNOWN_GROUP;
static const int PEM_F_D2I_PKCS8PRIVATEKEY_BIO;
static const int PEM_F_D2I_PKCS8PRIVATEKEY_FP;
static const int PEM_F_DO_PK8PKEY;
static const int PEM_F_DO_PK8PKEY_FP;
static const int PEM_F_LOAD_IV;
static const int PEM_F_PEM_ASN1_READ;
static const int PEM_F_PEM_ASN1_READ_BIO;
static const int PEM_F_PEM_ASN1_WRITE;
static const int PEM_F_PEM_ASN1_WRITE_BIO;
static const int PEM_F_PEM_DEF_CALLBACK;
static const int PEM_F_PEM_DO_HEADER;
static const int PEM_F_PEM_GET_EVP_CIPHER_INFO;
static const int PEM_F_PEM_READ;
static const int PEM_F_PEM_READ_BIO;
static const int PEM_F_PEM_READ_BIO_PRIVATEKEY;
static const int PEM_F_PEM_READ_PRIVATEKEY;
static const int PEM_F_PEM_SIGNFINAL;
static const int PEM_F_PEM_WRITE;
static const int PEM_F_PEM_WRITE_BIO;
static const int PEM_F_PEM_X509_INFO_READ;
static const int PEM_F_PEM_X509_INFO_READ_BIO;
static const int PEM_F_PEM_X509_INFO_WRITE_BIO;
static const int PEM_R_BAD_BASE64_DECODE;
static const int PEM_R_BAD_DECRYPT;
static const int PEM_R_BAD_END_LINE;
static const int PEM_R_BAD_IV_CHARS;
static const int PEM_R_BAD_PASSWORD_READ;
static const int PEM_R_ERROR_CONVERTING_PRIVATE_KEY;
static const int PEM_R_NO_START_LINE;
static const int PEM_R_NOT_DEK_INFO;
static const int PEM_R_NOT_ENCRYPTED;
static const int PEM_R_NOT_PROC_TYPE;
static const int PEM_R_PROBLEMS_GETTING_PASSWORD;
static const int PEM_R_READ_KEY;
static const int PEM_R_SHORT_HEADER;
static const int PEM_R_UNSUPPORTED_CIPHER;
static const int PEM_R_UNSUPPORTED_ENCRYPTION;
static const int PKCS12_F_PKCS12_PBE_CRYPT;
static const int PKCS12_R_PKCS12_CIPHERFINAL_ERROR;
static const int RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE;
static const int RSA_R_DATA_TOO_LARGE_FOR_MODULUS;
static const int RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY;
static const int RSA_R_BLOCK_TYPE_IS_NOT_01;
static const int RSA_R_BLOCK_TYPE_IS_NOT_02;
static const int RSA_R_PKCS_DECODING_ERROR;
static const int RSA_R_OAEP_DECODING_ERROR;
static const int RSA_F_RSA_SIGN;
static const int SSL_TLSEXT_ERR_OK;
static const int SSL_TLSEXT_ERR_ALERT_WARNING;
static const int SSL_TLSEXT_ERR_ALERT_FATAL;
static const int SSL_TLSEXT_ERR_NOACK;
static const int SSL_AD_CLOSE_NOTIFY;
static const int SSL_AD_UNEXPECTED_MESSAGE;
static const int SSL_AD_BAD_RECORD_MAC;
static const int SSL_AD_RECORD_OVERFLOW;
static const int SSL_AD_DECOMPRESSION_FAILURE;
static const int SSL_AD_HANDSHAKE_FAILURE;
static const int SSL_AD_BAD_CERTIFICATE;
static const int SSL_AD_UNSUPPORTED_CERTIFICATE;
static const int SSL_AD_CERTIFICATE_REVOKED;
static const int SSL_AD_CERTIFICATE_EXPIRED;
static const int SSL_AD_CERTIFICATE_UNKNOWN;
static const int SSL_AD_ILLEGAL_PARAMETER;
static const int SSL_AD_UNKNOWN_CA;
static const int SSL_AD_ACCESS_DENIED;
static const int SSL_AD_DECODE_ERROR;
static const int SSL_AD_DECRYPT_ERROR;
static const int SSL_AD_PROTOCOL_VERSION;
static const int SSL_AD_INSUFFICIENT_SECURITY;
static const int SSL_AD_INTERNAL_ERROR;
static const int SSL_AD_USER_CANCELLED;
static const int SSL_AD_NO_RENEGOTIATION;
static const int SSL_AD_UNSUPPORTED_EXTENSION;
static const int SSL_AD_CERTIFICATE_UNOBTAINABLE;
static const int SSL_AD_UNRECOGNIZED_NAME;
static const int SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE;
static const int SSL_AD_BAD_CERTIFICATE_HASH_VALUE;
static const int SSL_AD_UNKNOWN_PSK_IDENTITY;
static const int X509_R_CERT_ALREADY_IN_HASH_TABLE;
"""
FUNCTIONS = """
char *ERR_error_string(unsigned long, char *);
void ERR_error_string_n(unsigned long, char *, size_t);
const char *ERR_lib_error_string(unsigned long);
const char *ERR_func_error_string(unsigned long);
const char *ERR_reason_error_string(unsigned long);
void ERR_print_errors(BIO *);
void ERR_print_errors_fp(FILE *);
unsigned long ERR_get_error(void);
unsigned long ERR_peek_error(void);
unsigned long ERR_peek_last_error(void);
unsigned long ERR_get_error_line(const char **, int *);
unsigned long ERR_peek_error_line(const char **, int *);
unsigned long ERR_peek_last_error_line(const char **, int *);
unsigned long ERR_get_error_line_data(const char **, int *,
const char **, int *);
void ERR_clear_error(void);
unsigned long ERR_peek_error_line_data(const char **,
int *, const char **, int *);
unsigned long ERR_peek_last_error_line_data(const char **,
int *, const char **, int *);
void ERR_put_error(int, int, int, const char *, int);
void ERR_add_error_data(int, ...);
int ERR_get_next_error_library(void);
ERR_STATE *ERR_get_state(void);
/* ERR_free_strings became a macro in 1.1.0 */
void ERR_free_strings(void);
unsigned long ERR_PACK(int, int, int);
int ERR_GET_LIB(unsigned long);
int ERR_GET_FUNC(unsigned long);
int ERR_GET_REASON(unsigned long);
"""
CUSTOMIZATIONS = """
static const long Cryptography_HAS_EC_CODES = 1;
#ifdef RSA_R_PKCS_DECODING_ERROR
static const long Cryptography_HAS_RSA_R_PKCS_DECODING_ERROR = 1;
#else
static const long Cryptography_HAS_RSA_R_PKCS_DECODING_ERROR = 0;
static const long RSA_R_PKCS_DECODING_ERROR = 0;
#endif
"""