aboutsummaryrefslogtreecommitdiff
path: root/gost_ec_keyx.c
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2015-10-03 21:21:57 +0300
committerDmitry Belyavskiy <beldmit@gmail.com>2015-10-03 21:21:57 +0300
commit671a6236ffa2e92bc635db1429ed0d7ae8d3a959 (patch)
treea9223f48d1190a46e3daae139331a47c12b4604a /gost_ec_keyx.c
parentfd4e5958709dea5b6a88abcc2612525869153e29 (diff)
downloadgost-engine-671a6236ffa2e92bc635db1429ed0d7ae8d3a959.zip
gost-engine-671a6236ffa2e92bc635db1429ed0d7ae8d3a959.tar.gz
gost-engine-671a6236ffa2e92bc635db1429ed0d7ae8d3a959.tar.bz2
Fixes of error codes. Check result of EC_POINT_mul
Diffstat (limited to 'gost_ec_keyx.c')
-rw-r--r--gost_ec_keyx.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/gost_ec_keyx.c b/gost_ec_keyx.c
index 929c786..c2a465b 100644
--- a/gost_ec_keyx.c
+++ b/gost_ec_keyx.c
@@ -35,7 +35,7 @@ static int VKO_compute_key(unsigned char *shared_key, size_t shared_key_size,
half_len = buf_len >> 1;
if (!ctx) {
- GOSTerr(GOST_F_VKO_COMPUTE_KEY, GOST_R_NO_MEMORY);
+ GOSTerr(GOST_F_VKO_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);
return 0;
}
BN_CTX_start(ctx);
@@ -43,7 +43,7 @@ static int VKO_compute_key(unsigned char *shared_key, size_t shared_key_size,
databuf = OPENSSL_malloc(buf_len);
hashbuf = OPENSSL_malloc(buf_len);
if (!databuf || !hashbuf) {
- GOSTerr(GOST_F_VKO_COMPUTE_KEY, GOST_R_MALLOC_FAILURE);
+ GOSTerr(GOST_F_VKO_COMPUTE_KEY, ERR_R_MALLOC_FAILURE);
goto err;
}
@@ -60,7 +60,10 @@ static int VKO_compute_key(unsigned char *shared_key, size_t shared_key_size,
Y = BN_CTX_get(ctx);
EC_GROUP_get_order(EC_KEY_get0_group(priv_key), order, ctx);
BN_mod_mul(p, key, UKM, order, ctx);
- EC_POINT_mul(EC_KEY_get0_group(priv_key), pnt, NULL, pub_key, p, ctx);
+ if(!EC_POINT_mul(EC_KEY_get0_group(priv_key), pnt, NULL, pub_key, p, ctx)) {
+ GOSTerr(GOST_F_VKO_COMPUTE_KEY, GOST_R_ERROR_POINT_MUL);
+ goto err;
+ }
EC_POINT_get_affine_coordinates_GFp(EC_KEY_get0_group(priv_key),
pnt, X, Y, ctx);
/*
@@ -163,8 +166,7 @@ int pkey_GOST_ECcp_encrypt(EVP_PKEY_CTX *pctx, unsigned char *out,
} else if (out) {
if (RAND_bytes(ukm, 8) <= 0) {
- GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT,
- GOST_R_RANDOM_GENERATOR_FAILURE);
+ GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT, GOST_R_RNG_ERROR);
return 0;
}
}