| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
from __future__ import absolute_import, division, print_function |
| 6 |
|
| 7 |
INCLUDES = """ |
| 8 |
#include <openssl/ec.h> |
| 9 |
#include <openssl/obj_mac.h> |
| 10 |
""" |
| 11 |
|
| 12 |
TYPES = """ |
| 13 |
static const int Cryptography_HAS_EC2M; |
| 14 |
static const int Cryptography_HAS_EC_1_0_2; |
| 15 |
|
| 16 |
static const int OPENSSL_EC_NAMED_CURVE; |
| 17 |
|
| 18 |
typedef ... EC_KEY; |
| 19 |
typedef ... EC_GROUP; |
| 20 |
typedef ... EC_POINT; |
| 21 |
typedef ... EC_METHOD; |
| 22 |
typedef struct { |
| 23 |
int nid; |
| 24 |
const char *comment; |
| 25 |
} EC_builtin_curve; |
| 26 |
typedef enum { |
| 27 |
POINT_CONVERSION_COMPRESSED, |
| 28 |
POINT_CONVERSION_UNCOMPRESSED, |
| 29 |
... |
| 30 |
} point_conversion_form_t; |
| 31 |
""" |
| 32 |
|
| 33 |
FUNCTIONS = """ |
| 34 |
void EC_GROUP_free(EC_GROUP *); |
| 35 |
|
| 36 |
EC_GROUP *EC_GROUP_new_by_curve_name(int); |
| 37 |
|
| 38 |
int EC_GROUP_get_degree(const EC_GROUP *); |
| 39 |
|
| 40 |
const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *); |
| 41 |
const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *); |
| 42 |
int EC_GROUP_get_curve_name(const EC_GROUP *); |
| 43 |
|
| 44 |
size_t EC_get_builtin_curves(EC_builtin_curve *, size_t); |
| 45 |
|
| 46 |
EC_KEY *EC_KEY_new(void); |
| 47 |
void EC_KEY_free(EC_KEY *); |
| 48 |
|
| 49 |
EC_KEY *EC_KEY_new_by_curve_name(int); |
| 50 |
const EC_GROUP *EC_KEY_get0_group(const EC_KEY *); |
| 51 |
int EC_GROUP_get_order(const EC_GROUP *, BIGNUM *, BN_CTX *); |
| 52 |
int EC_KEY_set_group(EC_KEY *, const EC_GROUP *); |
| 53 |
const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *); |
| 54 |
int EC_KEY_set_private_key(EC_KEY *, const BIGNUM *); |
| 55 |
const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *); |
| 56 |
int EC_KEY_set_public_key(EC_KEY *, const EC_POINT *); |
| 57 |
void EC_KEY_set_asn1_flag(EC_KEY *, int); |
| 58 |
int EC_KEY_generate_key(EC_KEY *); |
| 59 |
int EC_KEY_set_public_key_affine_coordinates(EC_KEY *, BIGNUM *, BIGNUM *); |
| 60 |
|
| 61 |
EC_POINT *EC_POINT_new(const EC_GROUP *); |
| 62 |
void EC_POINT_free(EC_POINT *); |
| 63 |
void EC_POINT_clear_free(EC_POINT *); |
| 64 |
EC_POINT *EC_POINT_dup(const EC_POINT *, const EC_GROUP *); |
| 65 |
|
| 66 |
int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *, EC_POINT *, |
| 67 |
const BIGNUM *, const BIGNUM *, BN_CTX *); |
| 68 |
|
| 69 |
int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *, |
| 70 |
const EC_POINT *, BIGNUM *, BIGNUM *, BN_CTX *); |
| 71 |
|
| 72 |
int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *, EC_POINT *, |
| 73 |
const BIGNUM *, int, BN_CTX *); |
| 74 |
|
| 75 |
int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *, EC_POINT *, |
| 76 |
const BIGNUM *, const BIGNUM *, BN_CTX *); |
| 77 |
|
| 78 |
int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *, |
| 79 |
const EC_POINT *, BIGNUM *, BIGNUM *, BN_CTX *); |
| 80 |
|
| 81 |
int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *, EC_POINT *, |
| 82 |
const BIGNUM *, int, BN_CTX *); |
| 83 |
|
| 84 |
size_t EC_POINT_point2oct(const EC_GROUP *, const EC_POINT *, |
| 85 |
point_conversion_form_t, |
| 86 |
unsigned char *, size_t, BN_CTX *); |
| 87 |
|
| 88 |
int EC_POINT_oct2point(const EC_GROUP *, EC_POINT *, |
| 89 |
const unsigned char *, size_t, BN_CTX *); |
| 90 |
|
| 91 |
int EC_POINT_add(const EC_GROUP *, EC_POINT *, const EC_POINT *, |
| 92 |
const EC_POINT *, BN_CTX *); |
| 93 |
|
| 94 |
int EC_POINT_dbl(const EC_GROUP *, EC_POINT *, const EC_POINT *, BN_CTX *); |
| 95 |
int EC_POINT_invert(const EC_GROUP *, EC_POINT *, BN_CTX *); |
| 96 |
int EC_POINT_is_at_infinity(const EC_GROUP *, const EC_POINT *); |
| 97 |
int EC_POINT_is_on_curve(const EC_GROUP *, const EC_POINT *, BN_CTX *); |
| 98 |
|
| 99 |
int EC_POINT_cmp( |
| 100 |
const EC_GROUP *, const EC_POINT *, const EC_POINT *, BN_CTX *); |
| 101 |
|
| 102 |
int EC_POINT_mul(const EC_GROUP *, EC_POINT *, const BIGNUM *, |
| 103 |
const EC_POINT *, const BIGNUM *, BN_CTX *); |
| 104 |
|
| 105 |
int EC_METHOD_get_field_type(const EC_METHOD *); |
| 106 |
|
| 107 |
const char *EC_curve_nid2nist(int); |
| 108 |
""" |
| 109 |
|
| 110 |
CUSTOMIZATIONS = """ |
| 111 |
#if defined(OPENSSL_NO_EC2M) |
| 112 |
static const long Cryptography_HAS_EC2M = 0; |
| 113 |
|
| 114 |
int (*EC_POINT_set_affine_coordinates_GF2m)(const EC_GROUP *, EC_POINT *, |
| 115 |
const BIGNUM *, const BIGNUM *, BN_CTX *) = NULL; |
| 116 |
|
| 117 |
int (*EC_POINT_get_affine_coordinates_GF2m)(const EC_GROUP *, |
| 118 |
const EC_POINT *, BIGNUM *, BIGNUM *, BN_CTX *) = NULL; |
| 119 |
|
| 120 |
int (*EC_POINT_set_compressed_coordinates_GF2m)(const EC_GROUP *, EC_POINT *, |
| 121 |
const BIGNUM *, int, BN_CTX *) = NULL; |
| 122 |
#else |
| 123 |
static const long Cryptography_HAS_EC2M = 1; |
| 124 |
#endif |
| 125 |
|
| 126 |
#if (!CRYPTOGRAPHY_IS_LIBRESSL && CRYPTOGRAPHY_OPENSSL_LESS_THAN_102) |
| 127 |
static const long Cryptography_HAS_EC_1_0_2 = 0; |
| 128 |
const char *(*EC_curve_nid2nist)(int) = NULL; |
| 129 |
#else |
| 130 |
static const long Cryptography_HAS_EC_1_0_2 = 1; |
| 131 |
#endif |
| 132 |
""" |