int (*field_set_to_one) (const EC_GROUP *, BIGNUM *r, BN_CTX *);
/* private key operations */
size_t (*priv2oct)(const EC_KEY *eckey, unsigned char *buf, size_t len);
- int (*oct2priv)(EC_KEY *eckey, unsigned char *buf, size_t len);
+ int (*oct2priv)(EC_KEY *eckey, const unsigned char *buf, size_t len);
int (*set_private)(EC_KEY *eckey, const BIGNUM *priv_key);
int (*keygen)(EC_KEY *eckey);
int (*keycheck)(const EC_KEY *eckey);
/* custom ECDH operation */
int (*ecdh_compute_key)(unsigned char **pout, size_t *poutlen,
const EC_POINT *pub_key, const EC_KEY *ecdh);
-} /* EC_METHOD */ ;
+};
/*
* Types and functions to manipulate pre-computed values.
/* data for ECDSA inverse */
BN_MONT_CTX *mont_data;
- /* precomputed values for speed. */
+ /*
+ * Precomputed values for speed. The PCT_xxx names match the
+ * pre_comp.xxx union names; see the SETPRECOMP and HAVEPRECOMP
+ * macros, below.
+ */
enum {
- pct_none,
- pct_nistp224, pct_nistp256, pct_nistp521, pct_nistz256,
- pct_ec } pre_comp_type;
+ PCT_none,
+ PCT_nistp224, PCT_nistp256, PCT_nistp521, PCT_nistz256,
+ PCT_ec
+ } pre_comp_type;
union {
NISTP224_PRE_COMP *nistp224;
NISTP256_PRE_COMP *nistp256;
NISTZ256_PRE_COMP *nistz256;
EC_PRE_COMP *ec;
} pre_comp;
-} /* EC_GROUP */ ;
+};
#define SETPRECOMP(g, type, pre) \
- g->pre_comp_type = pct_##type, g->pre_comp.type = pre
+ g->pre_comp_type = PCT_##type, g->pre_comp.type = pre
#define HAVEPRECOMP(g, type) \
- g->pre_comp_type == pct_##type && g->pre_comp.type != NULL
+ g->pre_comp_type == PCT_##type && g->pre_comp.type != NULL
struct ec_key_st {
const EC_KEY_METHOD *meth;
EC_GROUP *group;
EC_POINT *pub_key;
BIGNUM *priv_key;
- /*
- * Arbitrary extra data.
- * For example in X25519 this contains the raw private key in a 32 byte
- * buffer.
- */
- void *custom_data;
unsigned int enc_flag;
point_conversion_form_t conv_form;
int references;
int flags;
CRYPTO_EX_DATA ex_data;
CRYPTO_RWLOCK *lock;
-} /* EC_KEY */ ;
+};
struct ec_point_st {
const EC_METHOD *meth;
* Z) represents (X/Z^2, Y/Z^3) if Z != 0 */
int Z_is_one; /* enable optimized point arithmetics for
* special case */
- /*
- * Arbitrary extra data.
- * For example in X25519 this contains the public key in a 32 byte buffer.
- */
- void *custom_data;
-} /* EC_POINT */ ;
+};
NISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *);
NISTP256_PRE_COMP *EC_nistp256_pre_comp_dup(NISTP256_PRE_COMP *);
size_t ec_key_simple_priv2oct(const EC_KEY *eckey,
unsigned char *buf, size_t len);
-int ec_key_simple_oct2priv(EC_KEY *eckey, unsigned char *buf, size_t len);
+int ec_key_simple_oct2priv(EC_KEY *eckey, const unsigned char *buf, size_t len);
int ec_key_simple_generate_key(EC_KEY *eckey);
int ec_key_simple_generate_public_key(EC_KEY *eckey);
int ec_key_simple_check_key(const EC_KEY *eckey);
const unsigned char *sigbuf, int sig_len, EC_KEY *eckey);
int (*verify_sig)(const unsigned char *dgst, int dgst_len,
const ECDSA_SIG *sig, EC_KEY *eckey);
-} /* EC_KEY_METHOD */ ;
+};
#define EC_KEY_METHOD_DYNAMIC 1
int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len,
const ECDSA_SIG *sig, EC_KEY *eckey);
-const EC_METHOD *ec_x25519_meth(void);
-
int X25519(uint8_t out_shared_key[32], const uint8_t private_key[32],
const uint8_t peer_public_value[32]);
void X25519_public_from_private(uint8_t out_public_value[32],