]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Build with -Werror
authorDmitry Belyavskiy <beldmit@gmail.com>
Sat, 19 Nov 2016 18:54:18 +0000 (21:54 +0300)
committerDmitry Belyavskiy <beldmit@gmail.com>
Sat, 19 Nov 2016 18:54:18 +0000 (21:54 +0300)
gost_ameth.c
gost_ec_sign.c
gost_grasshopper_cipher.c
gost_grasshopper_cipher.h
gost_grasshopper_precompiled.c
gost_grasshopper_precompiled.h
gost_lcl.h
gost_pmeth.c

index 8dc47f141c5f9e3ad5b1576014b0ad7fc5d8de1a..8c2645061fa3fd6b195600447314305297265204 100644 (file)
@@ -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);
index 2c04ed756e2600b86fa197dbc97b5afe21e8d207..904b80c6b22512b185280757e1cb5dcfd9d31b80 100644 (file)
@@ -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)) {
index b3aa4b9aa9009184dae6b9cc20b30f9ba9b4deba..b33fe53dca4ba3f7a2fdf24e3ebf5f84f80965b7 100644 (file)
@@ -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;
 
index c406614c6d45241a2db4891f4781d6124bece05b..7f775a24b8ff2f7576c4d1317f79e70566d581e0 100644 (file)
@@ -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();
index af4cc6ba138f85dbc5bb1ca668ca35beef5fe588..a9fcd9c6a304bbbf7f5f0be932ba830cb7d02b70 100644 (file)
@@ -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,
index cadf442c0ac764abea97e42f9259452377a9d872..eb1d7f8b5d1aba95c95805a9e88d22309c73aaf9 100644 (file)
@@ -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
index 9dac7d4a486d208e01eef95ee2bc0764dcde652c..faa454bb380e0b41dbf21ef989f9cadc4df61015 100644 (file)
@@ -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 */
index d84c7ef933d4cfa246c4c05887cdb2e48d9ee6af..2ef949d2da79b3d1da1c6be2f42c44166fc76cfd 100644 (file)
@@ -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;