Skip to content

Fix CMS CTR-ACPKM decrypt after ASN.1 parameter reinit#528

Open
rostislaved wants to merge 2 commits into
gost-engine:masterfrom
rostislaved:master
Open

Fix CMS CTR-ACPKM decrypt after ASN.1 parameter reinit#528
rostislaved wants to merge 2 commits into
gost-engine:masterfrom
rostislaved:master

Conversation

@rostislaved
Copy link
Copy Markdown

I ran into an issue with Kuznyechik where, after decrypting files, bytes after offset 4096 were corrupted.

I do not understand the C code or these algorithms well enough, so I asked Codex to investigate it. It produced this pull request.

Codex found that CMS kuznyechik-ctr-acpkm parameters set the ACPKM section size from ASN.1, but a later cipher reinit overwrote that value with the default section size. As a result, decryption switched keys at the wrong boundary.

This PR preserves the ACPKM section size when it was explicitly set from ASN.1 or via ctrl. It also adds a regression test that reproduces the ASN.1 parameter + reinit flow.

Please take a look if this makes sense.

@rostislaved
Copy link
Copy Markdown
Author

The issue looked like this. It is a file after decryption: bytes after 4096 were incorrect
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant