Allow kuznyechik-ctr-acpkm-omac PKCS12 integration#413
Allow kuznyechik-ctr-acpkm-omac PKCS12 integration#413yanovich wants to merge 4 commits intogost-engine:masterfrom
kuznyechik-ctr-acpkm-omac PKCS12 integration#413Conversation
|
When CMS files are created, IV (and, hence, these parameters) shouldn't be zeroes. |
|
Если прямо обязательно, чтобы была рандомная строка по умолчанию, то можно добавить в структуру контекста поле |
|
Просто оставить в инициализации не получается, потому что |
|
Да, это вариант |
|
Просто убрал своё удаление инициализации. Так тоже ключи шифруются и расшифровываются стандартной библиотекой. |
| gost_grasshopper_cipher_ctx_ctr *ctr = EVP_CIPHER_CTX_get_cipher_data(ctx); | ||
| if (init_zero_kdf_seed(ctr->kdf_seed) == 0) | ||
| return -1; | ||
| } |
There was a problem hiding this comment.
этот фрагмент дублирует инициализацию. заполнение kdf_seed рандомной строкой есть в init()
тут я оказался не прав |
|
Правильно было бы использовать |
| if (RAND_bytes(kdf_seed, 8) != 1) | ||
| return 0; | ||
| } | ||
|
|
There was a problem hiding this comment.
Так где сейчас берётся случайный IV?
There was a problem hiding this comment.
| unsigned char *tag = ptr; | ||
|
|
||
| gost_grasshopper_cipher_ctx *c = EVP_CIPHER_CTX_get_cipher_data(ctx); | ||
| if (c->c.type != GRASSHOPPER_CIPHER_MGM) |
There was a problem hiding this comment.
MGM тоже нужен. Или этого #define не сохранилось?
There was a problem hiding this comment.
этот код был под #if 0
OpenSSL PKCS12 module sets all-zeros initial vector on encryption and doesn't change it on decryption. This patch addresses `kuznyechik-ctr-acpkm-omac` behavior differences in two places: 1. in `gost2015_acpkm_omac_init()` IV is initialized with a random value on encryption, thus overwriting user-defined value 2. in `gost_grasshopper_cipher_init` IV is initialized with a random value, thus overwriting assumed default all-zeros value This patch also implements 3 ctrl operations required by PKCS12 module: - EVP_CTRL_AEAD_GET_TAG - EVP_CTRL_AEAD_SET_TAG - EVP_CTRL_AEAD_TLS1_AAD Signed-off-by: Sergei Ianovich <s@elektroplus.ru>
OpenSSL PKCS12 module sets all-zeros initial vector on encryption and doesn't change it on decryption.
This patch addresses
kuznyechik-ctr-acpkm-omacbehavior differences in two places:in
gost2015_acpkm_omac_init()IV is initialized with a random value on encryption, thus overwriting user-defined valuein
gost_grasshopper_cipher_initIV is initialized with a random value, thus overwriting assumed default all-zeros valueThis patch also implements 3 ctrl operations required by PKCS12 module:
Signed-off-by: Sergei Ianovich s@elektroplus.ru