提交 a3a2e3a4 编写于 作者: D Dr. Stephen Henson

add cofactor ECDH support from fips branch

上级 67ef4f63
...@@ -85,6 +85,8 @@ ...@@ -85,6 +85,8 @@
extern "C" { extern "C" {
#endif #endif
#define EC_FLAG_COFACTOR_ECDH 0x1000
const ECDH_METHOD *ECDH_OpenSSL(void); const ECDH_METHOD *ECDH_OpenSSL(void);
void ECDH_set_default_method(const ECDH_METHOD *); void ECDH_set_default_method(const ECDH_METHOD *);
......
...@@ -146,6 +146,18 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, ...@@ -146,6 +146,18 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
} }
group = EC_KEY_get0_group(ecdh); group = EC_KEY_get0_group(ecdh);
if (EC_KEY_get_flags(ecdh) & EC_FLAG_COFACTOR_ECDH)
{
if (!EC_GROUP_get_cofactor(group, x, ctx) ||
!BN_mul(x, x, priv_key, ctx))
{
ECDHerr(ECDH_F_ECDH_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);
goto err;
}
priv_key = x;
}
if ((tmp=EC_POINT_new(group)) == NULL) if ((tmp=EC_POINT_new(group)) == NULL)
{ {
ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE); ECDHerr(ECDH_F_ECDH_COMPUTE_KEY,ERR_R_MALLOC_FAILURE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册