-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Secure Cell: reuse WasmThemis tests Update Secure Cell test suite with the tests used in WasmThemis. There are some minor tweaks here and there to make them compatible, but it's all the same tests otherwise. * Secure Cell: report TypeError correctly Instead of throwing a generic error with INVALID_PARAMETER status code, throw a proper TypeError when we notice an issue with input types. This commit updates all cryptosystems, not only Secure Cell. * Secure Cell: allow "null" for context values In addition to allowing empty buffers and omitted arguments, accept explicit "null" values when the context is not used. This improves API compatibility with WasmThemis. * Secure Message: reuse WasmThemis tests In JsThemis there is no SecureMessageSign and SecureMessageVerify objects, empty keys should be used instead. * Secure Message: allow "null" keys for sign/verify Allow omitted keys to be specified with "null" values in addition to empty buffers. This improves compatibility with WasmThemis API and is consistent with other places where we allow optional values. * Secure Message: disallow both empty keys Check that the user has provided either public or private key, do not allow both keys to be omitted. * Secure Comparator: reuse WasmThemis tests Note that JsThemis uses a bit different naming and does not have a "destroy()" method. The Secure Comparator object is freed when Node.js runtime collects the garbage. * Secure Session: reuse WasmThemis tests API is slightly different in JsThemis and WasmThemis, the names are not the same and JsThemis does not have a dedicated negotiation method, using just unwrap() for that. * Secure Session: check private key validity WasmThemis verifies the private key during Secure Session construction. Don't defer this to usage in JsThemis either. * Secure Session: handle exceptions in callback We should check the call result as it may be empty if the callback throws an exception. Failure to check for this leads to process abort: FATAL ERROR: v8::ToLocalChecked Empty MaybeLocal. 1: 0x8fa090 node::Abort() [node] 2: 0x8fa0dc [node] 3: 0xb0030a v8::Utils::ReportApiFailure(char const*, char const*) [node] 4: 0x7ff9182b1785 jsthemis::SecureSession::get_public_key_for_id_callback(void const*, unsigned long, void*, unsigned long, void*) [...] 9: 0xb8e96f [node] 10: 0xb8f4d9 v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [node] 11: 0x1762fd45be1d Aborted (core dumped) We don't want this to happen. * Retroactively apply copyright to tests Since we're publishing test code on npm now, we should properly attribute this file. The tests were added in 944b9e0 ("Add JSTHEMIS test", 2016-01-17). * Simplify sign/verify test case We know that JsThemis returns results as instances of Node.js Buffer so we can verify that signed message includes the plaintext by using the "includes" method. We don't need to write it ourselves. * Reformat code with "make fmt"
- Loading branch information
Showing
11 changed files
with
849 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.