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