diff --git a/gost_gost2015.c b/gost_gost2015.c index 1ffa4281..3fcde339 100644 --- a/gost_gost2015.c +++ b/gost_gost2015.c @@ -163,11 +163,6 @@ int gost2015_acpkm_omac_init(int nid, int enc, const unsigned char *inkey, if (md == NULL) return 0; - if (enc) { - if (RAND_bytes(kdf_seed, 8) != 1) - return 0; - } - if (gost_kdftree2012_256(keys, 64, inkey, 32, (const unsigned char *)"kdf tree", 8, kdf_seed, 8, 1) <= 0) return 0; diff --git a/gost_grasshopper_cipher.c b/gost_grasshopper_cipher.c index 001746bc..7805f4b8 100644 --- a/gost_grasshopper_cipher.c +++ b/gost_grasshopper_cipher.c @@ -871,31 +871,44 @@ static int gost_grasshopper_cipher_ctl(EVP_CIPHER_CTX *ctx, int type, int arg, v } } return -1; -#if 0 case EVP_CTRL_AEAD_GET_TAG: case EVP_CTRL_AEAD_SET_TAG: { int taglen = arg; unsigned char *tag = ptr; - gost_grasshopper_cipher_ctx *c = EVP_CIPHER_CTX_get_cipher_data(ctx); - if (c->c.type != GRASSHOPPER_CIPHER_MGM) + gost_grasshopper_cipher_ctx_ctr *c = EVP_CIPHER_CTX_get_cipher_data(ctx); + if (c->c.type != GRASSHOPPER_CIPHER_CTRACPKMOMAC) return -1; if (taglen > KUZNYECHIK_MAC_MAX_SIZE) { - CRYPTOCOMerr(CRYPTOCOM_F_GOST_GRASSHOPPER_CIPHER_CTL, - CRYPTOCOM_R_INVALID_TAG_LENGTH); + GOSTerr(GOST_F_GOST_GRASSHOPPER_CIPHER_CTL, GOST_R_BAD_MAC); return -1; } if (type == EVP_CTRL_AEAD_GET_TAG) - memcpy(tag, c->final_tag, taglen); + memcpy(tag, c->tag, taglen); else - memcpy(c->final_tag, tag, taglen); + memcpy(c->tag, tag, taglen); return 1; } -#endif + case EVP_CTRL_AEAD_TLS1_AAD: { + gost_grasshopper_cipher_ctx_ctr *c = EVP_CIPHER_CTX_get_cipher_data(ctx); + if (!ptr || c->c.type != GRASSHOPPER_CIPHER_CTRACPKMOMAC) + return -1; + if (arg != 0) + return 0; + *(int *) ptr = KUZNYECHIK_MAC_MAX_SIZE; + return 1; + } + case EVP_CTRL_PBE_PRF_NID: { + if (ptr) { + *((int *)ptr) = NID_id_tc26_hmac_gost_3411_2012_512; + return 1; + } + return 0; + } case EVP_CTRL_PROCESS_UNPROTECTED: { STACK_OF(X509_ATTRIBUTE) *x = ptr;