* Requires OpenSSL 1.0.0+ for compilation *
**********************************************************************/
#include "gost_lcl.h"
-#include "gost_params.h"
#include <string.h>
#include <openssl/rand.h>
#include <openssl/ecdsa.h>
# define dump_dsa_sig(a,b)
#endif
+/* Convert little-endian byte array into bignum */
+BIGNUM *hashsum2bn(const unsigned char *dgst, int len)
+{
+ unsigned char buf[64];
+ int i;
+
+ if (len > sizeof(buf))
+ return NULL;
+
+ for (i = 0; i < len; i++) {
+ buf[len - i - 1] = dgst[i];
+ }
+ return getbnfrombuf(buf, len);
+}
+
static R3410_ec_params *gost_nid2params(int nid)
{
R3410_ec_params *params;
md = hashsum2bn(dgst, dlen);
newsig = DSA_SIG_new();
if (!newsig || !md) {
- GOSTerr(GOST_F_GOST_EC_SIGN, GOST_R_NO_MEMORY);
+ GOSTerr(GOST_F_GOST_EC_SIGN, ERR_R_MALLOC_FAILURE);
goto err;
}
group = EC_KEY_get0_group(eckey);
do {
do {
if (!BN_rand_range(k, order)) {
- GOSTerr(GOST_F_GOST_EC_SIGN,
- GOST_R_RANDOM_NUMBER_GENERATOR_FAILED);
+ GOSTerr(GOST_F_GOST_EC_SIGN, GOST_R_RNG_ERROR);
goto err;
}
/*
OPENSSL_assert(dgst != NULL && sig != NULL && group != NULL);
if (!(ctx = BN_CTX_new())) {
- GOSTerr(GOST_F_GOST_EC_VERIFY, GOST_R_NO_MEMORY);
+ GOSTerr(GOST_F_GOST_EC_VERIFY, ERR_R_MALLOC_FAILURE);
return 0;
}
do {
if (!BN_rand_range(d, order)) {
- GOSTerr(GOST_F_GOST_EC_KEYGEN,
- GOST_R_RANDOM_NUMBER_GENERATOR_FAILED);
+ GOSTerr(GOST_F_GOST_EC_KEYGEN, GOST_R_RNG_ERROR);
goto end;
}
}