diff options
-rw-r--r-- | lib/nettle/cipher.c | 10 | ||||
-rw-r--r-- | lib/nettle/gost/gost28147.c | 19 | ||||
-rw-r--r-- | lib/nettle/mac.c | 2 |
3 files changed, 11 insertions, 20 deletions
diff --git a/lib/nettle/cipher.c b/lib/nettle/cipher.c index 28f676a480..5e9f25b2ec 100644 --- a/lib/nettle/cipher.c +++ b/lib/nettle/cipher.c @@ -166,36 +166,36 @@ _cfb_decrypt(struct nettle_cipher_ctx *ctx, size_t length, uint8_t * dst, static void _gost28147_set_key_tc26z(void *ctx, const uint8_t *key) { - gost28147_set_key(ctx, key); gost28147_set_param(ctx, &gost28147_param_TC26_Z); + gost28147_set_key(ctx, key); } static void _gost28147_set_key_cpa(void *ctx, const uint8_t *key) { - gost28147_set_key(ctx, key); gost28147_set_param(ctx, &gost28147_param_CryptoPro_A); + gost28147_set_key(ctx, key); } static void _gost28147_set_key_cpb(void *ctx, const uint8_t *key) { - gost28147_set_key(ctx, key); gost28147_set_param(ctx, &gost28147_param_CryptoPro_B); + gost28147_set_key(ctx, key); } static void _gost28147_set_key_cpc(void *ctx, const uint8_t *key) { - gost28147_set_key(ctx, key); gost28147_set_param(ctx, &gost28147_param_CryptoPro_C); + gost28147_set_key(ctx, key); } static void _gost28147_set_key_cpd(void *ctx, const uint8_t *key) { - gost28147_set_key(ctx, key); gost28147_set_param(ctx, &gost28147_param_CryptoPro_D); + gost28147_set_key(ctx, key); } static void diff --git a/lib/nettle/gost/gost28147.c b/lib/nettle/gost/gost28147.c index d6a278ab09..8d648c1045 100644 --- a/lib/nettle/gost/gost28147.c +++ b/lib/nettle/gost/gost28147.c @@ -2292,25 +2292,18 @@ static void gost28147_key_mesh_cryptopro(struct gost28147_ctx *ctx) ctx->key_count = 0; } -static void -_gost28147_set_key(struct gost28147_ctx *ctx, const uint8_t *key) +void +gost28147_set_key(struct gost28147_ctx *ctx, const uint8_t *key) { unsigned i; + assert(key); for (i = 0; i < 8; i++, key += 4) ctx->key[i] = LE_READ_UINT32(key); ctx->key_count = 0; } void -gost28147_set_key(struct gost28147_ctx *ctx, const uint8_t *key) -{ - assert(key); - _gost28147_set_key(ctx, key); - gost28147_set_param(ctx, &gost28147_param_TC26_Z); -} - -void gost28147_set_param(struct gost28147_ctx *ctx, const struct gost28147_param *param) { assert(param); @@ -2419,8 +2412,8 @@ gost28147_cnt_init(struct gost28147_cnt_ctx *ctx, const uint8_t *key, const struct gost28147_param *param) { - gost28147_set_key(&ctx->ctx, key); gost28147_set_param(&ctx->ctx, param); + gost28147_set_key(&ctx->ctx, key); ctx->bytes = 0; } @@ -2487,10 +2480,8 @@ gost28147_imit_set_key(struct gost28147_imit_ctx *ctx, assert(length == GOST28147_IMIT_KEY_SIZE); assert(key); - _gost28147_set_key(&ctx->cctx, key); _gost28147_imit_reinit(ctx); - if (!ctx->cctx.sbox) - gost28147_set_param(&ctx->cctx, &gost28147_param_TC26_Z); + gost28147_set_key(&ctx->cctx, key); } void diff --git a/lib/nettle/mac.c b/lib/nettle/mac.c index f997cf3d46..4e14a9475b 100644 --- a/lib/nettle/mac.c +++ b/lib/nettle/mac.c @@ -140,8 +140,8 @@ struct nettle_mac_ctx { static void _wrap_gost28147_imit_set_key_tc26z(void *ctx, size_t len, const uint8_t * key) { - gost28147_imit_set_key(ctx, len, key); gost28147_imit_set_param(ctx, &gost28147_param_TC26_Z); + gost28147_imit_set_key(ctx, len, key); } #endif |