-
Notifications
You must be signed in to change notification settings - Fork 143
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
Update header parser in Secure Cell master key API #592
Commits on Feb 12, 2020
-
Describe master key header format
Just like with passphrase API, introduce structures, serializers and parsers for header used by master key API. It's mostly identical but lacks KDF context.
Configuration menu - View commit details
-
Copy full SHA for ce85e2e - Browse repository at this point
Copy the full SHA ce85e2eView commit details -
Update SCell master key decryption code path
Make it read like the current passphrase API using the same parsing techniques. This resolves a bunch of possible vulnerabilities found by AFL fuzzer which could be triggered by specific corruptions in the header. We reuse some utilities from passphrase API files so move them into common internal header. Note how we treat the compatibility path. Themis 0.9.6 used to use incompatble format for one of the context fields used for Soter KDF which resulted in encrypted data that cannot be decrypted by modern implementation. We still support decryption of these 'broken' cells by trying compatibility KDF if the initial decryption fails.
Configuration menu - View commit details
-
Copy full SHA for 5203090 - Browse repository at this point
Copy the full SHA 5203090View commit details -
Update SCell master key encryption code path
Similarly to decryption, unify the code with passphrase implementation.
Configuration menu - View commit details
-
Copy full SHA for 2abee99 - Browse repository at this point
Copy the full SHA 2abee99View commit details -
Since we use new definitions now, those are no longer necessary.
Configuration menu - View commit details
-
Copy full SHA for 1557f4b - Browse repository at this point
Copy the full SHA 1557f4bView commit details -
Use new accessors in passphrase API
We have added a new accessor to KDF in Soter algorithm ID, use it.
Configuration menu - View commit details
-
Copy full SHA for b37c2c0 - Browse repository at this point
Copy the full SHA b37c2c0View commit details -
Validate key length on decryption
Just like with passphrase API, we need to pay close attention to the key length field which we use to determine the length of the derived key. Accept only formats currently produced by Themis. It's unlikely that we update them, and Soter cannot handle other formats anyway right now.
Configuration menu - View commit details
-
Copy full SHA for 420087c - Browse repository at this point
Copy the full SHA 420087cView commit details -
Avoid unsigned overflow in length computations
Similar to passphrase API, master key header can encode messages with total length exceeding UINT32_MAX which can cause overflows on 32-bit platforms (with 32-bit size_t). Avoid overflows in computations by judiciously using uint64_t and breaking up intermediate computations to ensure uint64_t is used.
Configuration menu - View commit details
-
Copy full SHA for bb82e06 - Browse repository at this point
Copy the full SHA bb82e06View commit details -
Update expected error codes in tests
Changes in master key implementations unify error reporting with passphrase API as well. In particular, we consistently report detected data corruption with THEMIS_FAIL error code now. THEMIS_INVALID_PARAMETER is used to indicate programming errors which could have been prevented by a better type system. Attempting to decrypt corrupted data is not such an issue. Some tests that verify corrupted data processing expect particular error codes to be reported. Update them to expect THEMIS_FAIL now.
Configuration menu - View commit details
-
Copy full SHA for ce7a003 - Browse repository at this point
Copy the full SHA ce7a003View commit details
Commits on Mar 2, 2020
-
Reduce code duplication in decryption path
We still need to maintain compatibility KDF implementation in order to be able to decrypt data encrypted by Themis 0.9.6 which used incorrect Soter KDF context computation, incompatible with 32-bit platforms. Refactor the compatibility shim code to extact the context computation and avoid duplicating the entire KDF processing, with all its length and algorithm verification.
Configuration menu - View commit details
-
Copy full SHA for 583df40 - Browse repository at this point
Copy the full SHA 583df40View commit details