-
Notifications
You must be signed in to change notification settings - Fork 186
Allow kuznyechik-ctr-acpkm-omac PKCS12 integration
#413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
этот фрагмент дублирует инициализацию. заполнение kdf_seed рандомной строкой есть в init()
тут я оказался не прав |
|
Правильно было бы использовать |
| if (RAND_bytes(kdf_seed, 8) != 1) | ||
| return 0; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Так где сейчас берётся случайный IV?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MGM тоже нужен. Или этого #define не сохранилось?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
этот код был под #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 <[email protected]>
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 [email protected]