From: Dmitry Belyavskiy Date: Sat, 19 Nov 2016 18:54:18 +0000 (+0300) Subject: Build with -Werror X-Git-Tag: v1.1.0.2~22^2 X-Git-Url: http://www.wagner.pp.ru/gitweb/?p=openssl-gost%2Fengine.git;a=commitdiff_plain;h=a72a02c4dd5778eea83db6e9e17d89f0d2b278dd Build with -Werror --- diff --git a/gost_ameth.c b/gost_ameth.c index 8dc47f1..8c26450 100644 --- a/gost_ameth.c +++ b/gost_ameth.c @@ -23,7 +23,7 @@ * Pack bignum into byte buffer of given size, filling all leading bytes by * zeros */ -int store_bignum(BIGNUM *bn, unsigned char *buf, int len) +int store_bignum(const BIGNUM *bn, unsigned char *buf, int len) { int bytes = BN_num_bytes(bn); @@ -129,9 +129,9 @@ static int gost_decode_nid_params(EVP_PKEY *pkey, int pkey_nid, int param_nid) * Parses GOST algorithm parameters from X509_ALGOR and modifies pkey setting * NID and parameters */ -static int decode_gost_algor_params(EVP_PKEY *pkey, X509_ALGOR *palg) +static int decode_gost_algor_params(EVP_PKEY *pkey, const X509_ALGOR *palg) { - ASN1_OBJECT *palg_obj = NULL; + const ASN1_OBJECT *palg_obj = NULL; int ptype = V_ASN1_UNDEF; int pkey_nid = NID_undef, param_nid = NID_undef; ASN1_STRING *pval = NULL; @@ -140,7 +140,7 @@ static int decode_gost_algor_params(EVP_PKEY *pkey, X509_ALGOR *palg) if (!pkey || !palg) return 0; - X509_ALGOR_get0(&palg_obj, &ptype, (void **)&pval, palg); + X509_ALGOR_get0(&palg_obj, &ptype, (const void **)&pval, palg); if (ptype != V_ASN1_SEQUENCE) { GOSTerr(GOST_F_DECODE_GOST_ALGOR_PARAMS, GOST_R_BAD_KEY_PARAMETERS_FORMAT); @@ -329,14 +329,14 @@ static BIGNUM *unmask_priv_key(EVP_PKEY *pk, return pknum_masked; } -static int priv_decode_gost(EVP_PKEY *pk, PKCS8_PRIV_KEY_INFO *p8inf) +static int priv_decode_gost(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf) { const unsigned char *pkey_buf = NULL, *p = NULL; int priv_len = 0; BIGNUM *pk_num = NULL; int ret = 0; - X509_ALGOR *palg = NULL; - ASN1_OBJECT *palg_obj = NULL; + const X509_ALGOR *palg = NULL; + const ASN1_OBJECT *palg_obj = NULL; ASN1_INTEGER *priv_key = NULL; int expected_key_len = 32; @@ -742,15 +742,17 @@ static int pub_encode_gost_ec(X509_PUBKEY *pub, const EVP_PKEY *pk) store_bignum(X, databuf + data_len / 2, data_len / 2); store_bignum(Y, databuf, data_len / 2); + BUF_reverse(NULL, databuf, data_len); + octet = ASN1_OCTET_STRING_new(); if (octet == NULL) { GOSTerr(GOST_F_PUB_ENCODE_GOST_EC, ERR_R_MALLOC_FAILURE); goto err; } - ASN1_STRING_set(octet, NULL, data_len); - sptr = ASN1_STRING_data(octet); - for (i = 0, j = data_len - 1; i < data_len; i++, j--) { - sptr[i] = databuf[j]; + + if (0 == ASN1_STRING_set(octet, databuf, data_len)) { + GOSTerr(GOST_F_PUB_ENCODE_GOST_EC, ERR_R_MALLOC_FAILURE); + goto err; } ret = i2d_ASN1_OCTET_STRING(octet, &buf); diff --git a/gost_ec_sign.c b/gost_ec_sign.c index 2c04ed7..904b80c 100644 --- a/gost_ec_sign.c +++ b/gost_ec_sign.c @@ -161,7 +161,7 @@ DSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) BIGNUM *r = NULL, *s = NULL, *X = NULL, *tmp = NULL, *tmp2 = NULL, *k = NULL, *e = NULL; - BIGNUM *new_r = NULL, *new_s = NULL; + const BIGNUM *new_r = NULL, *new_s = NULL; EC_POINT *C = NULL; BN_CTX *ctx; @@ -276,7 +276,7 @@ DSA_SIG *gost_ec_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) } while (BN_is_zero(s)); - DSA_SIG_get0(&new_r, &new_s, newsig); + DSA_SIG_get0(newsig, &new_r, &new_s); new_s = BN_dup(s); new_r = BN_dup(r); if (!new_s || !new_r) { @@ -310,7 +310,7 @@ int gost_ec_verify(const unsigned char *dgst, int dgst_len, BIGNUM *order; BIGNUM *md = NULL, *e = NULL, *R = NULL, *v = NULL, *z1 = NULL, *z2 = NULL; - BIGNUM *sig_s = NULL, *sig_r = NULL; + const BIGNUM *sig_s = NULL, *sig_r = NULL; BIGNUM *X = NULL, *tmp = NULL; EC_POINT *C = NULL; const EC_POINT *pub_key = NULL; @@ -343,7 +343,7 @@ int gost_ec_verify(const unsigned char *dgst, int dgst_len, goto err; } - DSA_SIG_get0(&sig_r, &sig_s, sig); + DSA_SIG_get0(sig, &sig_r, &sig_s); if (BN_is_zero(sig_s) || BN_is_zero(sig_r) || (BN_cmp(sig_s, order) >= 1) || (BN_cmp(sig_r, order) >= 1)) { diff --git a/gost_grasshopper_cipher.c b/gost_grasshopper_cipher.c index b3aa4b9..b33fe53 100644 --- a/gost_grasshopper_cipher.c +++ b/gost_grasshopper_cipher.c @@ -103,7 +103,7 @@ static struct GRASSHOPPER_CIPHER_PARAMS gost_cipher_params[5] = { }; /* Set 256 bit key into context */ -static GRASSHOPPER_INLINE void gost_grasshopper_cipher_key(gost_grasshopper_cipher_ctx* c, const uint8_t* k) { +GRASSHOPPER_INLINE void gost_grasshopper_cipher_key(gost_grasshopper_cipher_ctx* c, const uint8_t* k) { int i; for (i = 0; i < 2; i++) { grasshopper_copy128(&c->key.k.k[i], (const grasshopper_w128_t*) (k + i * 16)); @@ -113,7 +113,7 @@ static GRASSHOPPER_INLINE void gost_grasshopper_cipher_key(gost_grasshopper_ciph } /* Cleans up key from context */ -static GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy(gost_grasshopper_cipher_ctx* c) { +GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy(gost_grasshopper_cipher_ctx* c) { int i; for (i = 0; i < 2; i++) { grasshopper_zero128(&c->key.k.k[i]); @@ -142,7 +142,7 @@ static GRASSHOPPER_INLINE void gost_grasshopper_cipher_destroy_ctr(gost_grasshop ctx->counter = 0; } -static int gost_grasshopper_cipher_init(EVP_CIPHER_CTX* ctx, const unsigned char* key, +int gost_grasshopper_cipher_init(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc) { gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx); @@ -168,7 +168,7 @@ static int gost_grasshopper_cipher_init(EVP_CIPHER_CTX* ctx, const unsigned char return 1; } -static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ecb(EVP_CIPHER_CTX* ctx, const unsigned char* key, +GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ecb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc) { gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx); @@ -176,7 +176,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ecb(EVP_CIPHER_CTX* c return gost_grasshopper_cipher_init(ctx, key, iv, enc); } -static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cbc(EVP_CIPHER_CTX* ctx, const unsigned char* key, +GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cbc(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc) { gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx); @@ -184,7 +184,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cbc(EVP_CIPHER_CTX* c return gost_grasshopper_cipher_init(ctx, key, iv, enc); } -static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ofb(EVP_CIPHER_CTX* ctx, const unsigned char* key, +GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ofb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc) { gost_grasshopper_cipher_ctx_ofb* c = EVP_CIPHER_CTX_get_cipher_data(ctx); @@ -196,7 +196,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ofb(EVP_CIPHER_CTX* c return gost_grasshopper_cipher_init(ctx, key, iv, enc); } -static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cfb(EVP_CIPHER_CTX* ctx, const unsigned char* key, +GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cfb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc) { gost_grasshopper_cipher_ctx* c = EVP_CIPHER_CTX_get_cipher_data(ctx); @@ -204,7 +204,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_cfb(EVP_CIPHER_CTX* c return gost_grasshopper_cipher_init(ctx, key, iv, enc); } -static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ctr(EVP_CIPHER_CTX* ctx, const unsigned char* key, +GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ctr(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc) { gost_grasshopper_cipher_ctx_ctr* c = EVP_CIPHER_CTX_get_cipher_data(ctx); @@ -219,7 +219,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_init_ctr(EVP_CIPHER_CTX* c return gost_grasshopper_cipher_init(ctx, key, iv, enc); } -static GRASSHOPPER_INLINE int gost_grasshopper_cipher_do(EVP_CIPHER_CTX* ctx, unsigned char* out, +GRASSHOPPER_INLINE int gost_grasshopper_cipher_do(EVP_CIPHER_CTX* ctx, unsigned char* out, const unsigned char* in, size_t inl) { gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx); struct GRASSHOPPER_CIPHER_PARAMS* params = &gost_cipher_params[c->type]; @@ -227,7 +227,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_cipher_do(EVP_CIPHER_CTX* ctx, un return params->do_cipher(ctx, out, in, inl); } -static int gost_grasshopper_cipher_do_ecb(EVP_CIPHER_CTX* ctx, unsigned char* out, +int gost_grasshopper_cipher_do_ecb(EVP_CIPHER_CTX* ctx, unsigned char* out, const unsigned char* in, size_t inl) { gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx); bool encrypting = (bool) EVP_CIPHER_CTX_encrypting(ctx); @@ -251,7 +251,7 @@ static int gost_grasshopper_cipher_do_ecb(EVP_CIPHER_CTX* ctx, unsigned char* ou return 1; } -static int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* out, +int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* out, const unsigned char* in, size_t inl) { gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx); unsigned char* iv = EVP_CIPHER_CTX_iv_noconst(ctx); @@ -283,7 +283,7 @@ static int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* ou return 1; } -static int gost_grasshopper_cipher_do_ctr(EVP_CIPHER_CTX* ctx, unsigned char* out, +int gost_grasshopper_cipher_do_ctr(EVP_CIPHER_CTX* ctx, unsigned char* out, const unsigned char* in, size_t inl) { gost_grasshopper_cipher_ctx_ctr* c = (gost_grasshopper_cipher_ctx_ctr*) EVP_CIPHER_CTX_get_cipher_data(ctx); unsigned char* iv = EVP_CIPHER_CTX_iv_noconst(ctx); @@ -372,7 +372,7 @@ static void gost_grasshopper_cnt_next(gost_grasshopper_cipher_ctx_ofb* ctx, gras grasshopper_encrypt_block(&ctx->c.encrypt_round_keys, &ctx->buffer1, buf, &ctx->c.buffer); } -static int gost_grasshopper_cipher_do_ofb(EVP_CIPHER_CTX* ctx, unsigned char* out, +int gost_grasshopper_cipher_do_ofb(EVP_CIPHER_CTX* ctx, unsigned char* out, const unsigned char* in, size_t inl) { gost_grasshopper_cipher_ctx_ofb* c = (gost_grasshopper_cipher_ctx_ofb*) EVP_CIPHER_CTX_get_cipher_data(ctx); const unsigned char* in_ptr = in; @@ -430,7 +430,7 @@ static int gost_grasshopper_cipher_do_ofb(EVP_CIPHER_CTX* ctx, unsigned char* ou return 1; } -static int gost_grasshopper_cipher_do_cfb(EVP_CIPHER_CTX* ctx, unsigned char* out, +int gost_grasshopper_cipher_do_cfb(EVP_CIPHER_CTX* ctx, unsigned char* out, const unsigned char* in, size_t inl) { gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx); const unsigned char* in_ptr = in; @@ -509,7 +509,7 @@ static int gost_grasshopper_cipher_do_cfb(EVP_CIPHER_CTX* ctx, unsigned char* ou return 1; } -static int gost_grasshopper_cipher_cleanup(EVP_CIPHER_CTX* ctx) { +int gost_grasshopper_cipher_cleanup(EVP_CIPHER_CTX* ctx) { gost_grasshopper_cipher_ctx* c = (gost_grasshopper_cipher_ctx*) EVP_CIPHER_CTX_get_cipher_data(ctx); struct GRASSHOPPER_CIPHER_PARAMS* params = &gost_cipher_params[c->type]; @@ -523,7 +523,7 @@ static int gost_grasshopper_cipher_cleanup(EVP_CIPHER_CTX* ctx) { return 1; } -static int gost_grasshopper_set_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params) { +int gost_grasshopper_set_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params) { int len = 0; unsigned char* buf = NULL; unsigned char* p = NULL; @@ -542,7 +542,7 @@ static int gost_grasshopper_set_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* return 1; } -static GRASSHOPPER_INLINE int gost_grasshopper_get_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params) { +GRASSHOPPER_INLINE int gost_grasshopper_get_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params) { int ret = -1; if (ASN1_TYPE_get(params) != V_ASN1_SEQUENCE) { @@ -552,7 +552,7 @@ static GRASSHOPPER_INLINE int gost_grasshopper_get_asn1_parameters(EVP_CIPHER_CT return 1; } -static int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX* ctx, int type, int arg, void* ptr) { +int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX* ctx, int type, int arg, void* ptr) { switch (type) { case EVP_CTRL_RAND_KEY: { if (RAND_bytes((unsigned char*) ptr, EVP_CIPHER_CTX_key_length(ctx)) <= 0) { @@ -568,7 +568,7 @@ static int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX* ctx, int type, int arg, v return 1; } -static GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper_create(int cipher_type, int block_size) { +GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper_create(int cipher_type, int block_size) { return EVP_CIPHER_meth_new(cipher_type, block_size /* block_size */, GRASSHOPPER_KEY_SIZE /* key_size */); @@ -590,7 +590,7 @@ const int cipher_gost_grasshopper_setup(EVP_CIPHER* cipher, uint8_t mode, int iv EVP_CIPHER_meth_set_do_cipher(cipher, gost_grasshopper_cipher_do); } -static const GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper(uint8_t mode, uint8_t num) { +const GRASSHOPPER_INLINE EVP_CIPHER* cipher_gost_grasshopper(uint8_t mode, uint8_t num) { EVP_CIPHER** cipher; struct GRASSHOPPER_CIPHER_PARAMS* params; diff --git a/gost_grasshopper_cipher.h b/gost_grasshopper_cipher.h index c406614..7f775a2 100644 --- a/gost_grasshopper_cipher.h +++ b/gost_grasshopper_cipher.h @@ -46,54 +46,54 @@ typedef int (* grasshopper_do_cipher_func)(EVP_CIPHER_CTX* ctx, unsigned char* o typedef void (* grasshopper_destroy_cipher_func)(gost_grasshopper_cipher_ctx* c); -static void gost_grasshopper_cipher_key(gost_grasshopper_cipher_ctx* c, const uint8_t* k); +void gost_grasshopper_cipher_key(gost_grasshopper_cipher_ctx* c, const uint8_t* k); -static void gost_grasshopper_cipher_destroy(gost_grasshopper_cipher_ctx* c); +void gost_grasshopper_cipher_destroy(gost_grasshopper_cipher_ctx* c); -static int gost_grasshopper_cipher_init_ecb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc); +int gost_grasshopper_cipher_init_ecb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc); -static int gost_grasshopper_cipher_init_cbc(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc); +int gost_grasshopper_cipher_init_cbc(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc); -static int gost_grasshopper_cipher_init_ofb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc); +int gost_grasshopper_cipher_init_ofb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc); -static int gost_grasshopper_cipher_init_cfb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc); +int gost_grasshopper_cipher_init_cfb(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc); -static int gost_grasshopper_cipher_init_ctr(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc); +int gost_grasshopper_cipher_init_ctr(EVP_CIPHER_CTX* ctx, const unsigned char* key, const unsigned char* iv, int enc); -static int gost_grasshopper_cipher_init(EVP_CIPHER_CTX* ctx, const unsigned char* key, - const unsigned char* iv, int enc); +int gost_grasshopper_cipher_init(EVP_CIPHER_CTX* ctx, const unsigned char* key, + const unsigned char* iv, int enc); -static int gost_grasshopper_cipher_do(EVP_CIPHER_CTX* ctx, unsigned char* out, - const unsigned char* in, size_t inl); +int gost_grasshopper_cipher_do(EVP_CIPHER_CTX* ctx, unsigned char* out, + const unsigned char* in, size_t inl); -static int gost_grasshopper_cipher_do_ecb(EVP_CIPHER_CTX* ctx, unsigned char* out, - const unsigned char* in, size_t inl); +int gost_grasshopper_cipher_do_ecb(EVP_CIPHER_CTX* ctx, unsigned char* out, + const unsigned char* in, size_t inl); -static int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* out, - const unsigned char* in, size_t inl); +int gost_grasshopper_cipher_do_cbc(EVP_CIPHER_CTX* ctx, unsigned char* out, + const unsigned char* in, size_t inl); -static int gost_grasshopper_cipher_do_ofb(EVP_CIPHER_CTX* ctx, unsigned char* out, - const unsigned char* in, size_t inl); +int gost_grasshopper_cipher_do_ofb(EVP_CIPHER_CTX* ctx, unsigned char* out, + const unsigned char* in, size_t inl); -static int gost_grasshopper_cipher_do_cfb(EVP_CIPHER_CTX* ctx, unsigned char* out, - const unsigned char* in, size_t inl); +int gost_grasshopper_cipher_do_cfb(EVP_CIPHER_CTX* ctx, unsigned char* out, + const unsigned char* in, size_t inl); -static int gost_grasshopper_cipher_do_ctr(EVP_CIPHER_CTX* ctx, unsigned char* out, - const unsigned char* in, size_t inl); +int gost_grasshopper_cipher_do_ctr(EVP_CIPHER_CTX* ctx, unsigned char* out, + const unsigned char* in, size_t inl); -static int gost_grasshopper_cipher_cleanup(EVP_CIPHER_CTX* ctx); +int gost_grasshopper_cipher_cleanup(EVP_CIPHER_CTX* ctx); -static int gost_grasshopper_set_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params); +int gost_grasshopper_set_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params); -static int gost_grasshopper_get_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params); +int gost_grasshopper_get_asn1_parameters(EVP_CIPHER_CTX* ctx, ASN1_TYPE* params); -static int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX* ctx, int type, int arg, void* ptr); +int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX* ctx, int type, int arg, void* ptr); -static EVP_CIPHER* cipher_gost_grasshopper_create(int cipher_type, int block_size); +EVP_CIPHER* cipher_gost_grasshopper_create(int cipher_type, int block_size); -static const int cipher_gost_grasshopper_setup(EVP_CIPHER* cipher, uint8_t mode, int iv_size, bool padding); +const int cipher_gost_grasshopper_setup(EVP_CIPHER* cipher, uint8_t mode, int iv_size, bool padding); -static const EVP_CIPHER* cipher_gost_grasshopper(uint8_t mode, uint8_t num); +const EVP_CIPHER* cipher_gost_grasshopper(uint8_t mode, uint8_t num); extern const EVP_CIPHER* cipher_gost_grasshopper_ecb(); extern const EVP_CIPHER* cipher_gost_grasshopper_cbc(); diff --git a/gost_grasshopper_precompiled.c b/gost_grasshopper_precompiled.c index af4cc6b..a9fcd9c 100644 --- a/gost_grasshopper_precompiled.c +++ b/gost_grasshopper_precompiled.c @@ -7,7 +7,7 @@ #include "gost_grasshopper_defines.h" #include "gost_grasshopper_math.h" -grasshopper_w128_t grasshopper_pil_enc128[GRASSHOPPER_MAX_BIT_PARTS][256] = { +const grasshopper_w128_t grasshopper_pil_enc128[GRASSHOPPER_MAX_BIT_PARTS][256] = { { { 233, 251, 213, 12, 122, 192, 128, 150, 25, 17, 135, 147, 27, 201, 174, 181, @@ -12329,7 +12329,7 @@ grasshopper_w128_t grasshopper_pil_enc128[GRASSHOPPER_MAX_BIT_PARTS][256] = { }, }, }; -grasshopper_w128_t grasshopper_pil_dec128[GRASSHOPPER_MAX_BIT_PARTS][256] = { +const grasshopper_w128_t grasshopper_pil_dec128[GRASSHOPPER_MAX_BIT_PARTS][256] = { { { 165, 204, 14, 134, 194, 79, 186, 89, 59, 227, 239, 121, 130, 83, 17, 240, @@ -24651,7 +24651,7 @@ grasshopper_w128_t grasshopper_pil_dec128[GRASSHOPPER_MAX_BIT_PARTS][256] = { }, }, }; -grasshopper_w128_t grasshopper_l_dec128[GRASSHOPPER_MAX_BIT_PARTS][256] = { +const grasshopper_w128_t grasshopper_l_dec128[GRASSHOPPER_MAX_BIT_PARTS][256] = { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/gost_grasshopper_precompiled.h b/gost_grasshopper_precompiled.h index cadf442..eb1d7f8 100644 --- a/gost_grasshopper_precompiled.h +++ b/gost_grasshopper_precompiled.h @@ -9,10 +9,10 @@ #include "gost_grasshopper_defines.h" #include "gost_grasshopper_math.h" -extern grasshopper_w128_t grasshopper_pil_enc128[GRASSHOPPER_MAX_BIT_PARTS][256]; +extern const grasshopper_w128_t grasshopper_pil_enc128[GRASSHOPPER_MAX_BIT_PARTS][256]; -extern grasshopper_w128_t grasshopper_l_dec128[GRASSHOPPER_MAX_BIT_PARTS][256]; +extern const grasshopper_w128_t grasshopper_l_dec128[GRASSHOPPER_MAX_BIT_PARTS][256]; -extern grasshopper_w128_t grasshopper_pil_dec128[GRASSHOPPER_MAX_BIT_PARTS][256]; +extern const grasshopper_w128_t grasshopper_pil_dec128[GRASSHOPPER_MAX_BIT_PARTS][256]; #endif diff --git a/gost_lcl.h b/gost_lcl.h index 9dac7d4..faa454b 100644 --- a/gost_lcl.h +++ b/gost_lcl.h @@ -245,7 +245,7 @@ BIGNUM *hashsum2bn(const unsigned char *dgst, int len); * Store bignum in byte array of given length, prepending by zeros if * nesseccary */ -int store_bignum(BIGNUM *bn, unsigned char *buf, int len); +int store_bignum(const BIGNUM *bn, unsigned char *buf, int len); /* Pack GOST R 34.10 signature according to CryptoPro rules */ int pack_sign_cp(DSA_SIG *s, int order, unsigned char *sig, size_t *siglen); /* from ameth.c */ diff --git a/gost_pmeth.c b/gost_pmeth.c index d84c7ef..2ef949d 100644 --- a/gost_pmeth.c +++ b/gost_pmeth.c @@ -369,8 +369,8 @@ static int pkey_gost2012cp_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) */ int pack_sign_cp(DSA_SIG *s, int order, unsigned char *sig, size_t *siglen) { - BIGNUM *sig_r = NULL, *sig_s = NULL; - DSA_SIG_get0(&sig_r, &sig_s, s); + const BIGNUM *sig_r = NULL, *sig_s = NULL; + DSA_SIG_get0(s, &sig_r, &sig_s); *siglen = 2 * order; memset(sig, 0, *siglen); store_bignum(sig_s, sig, order); @@ -420,14 +420,14 @@ static int pkey_gost_ec_cp_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, DSA_SIG *unpack_cp_signature(const unsigned char *sig, size_t siglen) { DSA_SIG *s; - BIGNUM *sig_r = NULL, *sig_s = NULL; + const BIGNUM *sig_r = NULL, *sig_s = NULL; s = DSA_SIG_new(); if (s == NULL) { GOSTerr(GOST_F_UNPACK_CP_SIGNATURE, ERR_R_MALLOC_FAILURE); return NULL; } - DSA_SIG_get0(&sig_r, &sig_s, s); + DSA_SIG_get0(s, &sig_r, &sig_s); sig_s = BN_bin2bn(sig, siglen / 2, NULL); sig_r = BN_bin2bn(sig + siglen / 2, siglen / 2, NULL); return s;