-
Notifications
You must be signed in to change notification settings - Fork 34
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
Switch from cryptonite library to crypton and fix cbits #95
Conversation
@@ -253,9 +253,9 @@ static void serialize_index32(uint8_t *out, uint32_t index, derivation_scheme_mo | |||
|
|||
static void add_left(ed25519_secret_key res_key, uint8_t *z, ed25519_secret_key priv_key, derivation_scheme_mode mode) | |||
{ | |||
uint8_t zl8[32]; | |||
ed25519_secret_key zl8; |
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.
The unit8_t
array had 32
elements (which is what caused the error message) and is replace with ed25519_secret_key
which is 64 elements.
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.
Before the fix, the error was:
cbits/encrypted_sign.c:304:9: error:
warning: ‘cardano_crypto_ed25519_publickey’ reading 64 bytes from a region of size 32 [-Wstringop-overread]
304 | cardano_crypto_ed25519_publickey(zl8, pub_zl8);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
304 | cardano_crypto_ed25519_publickey(zl8, pub_zl8);
|
|
||
memset(zl8, 0, 32); | ||
memset(zl8, 0, 64); |
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.
Because the size of the z18
array has increased to 64
we set all 64
elements to zero.
69286e4
to
e85789b
Compare
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.
This looks great to me. But we should sometimes new else have a lot to o as well!
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.
LGTM,
I am a bit puzzled why this compiler did not catch this buffer mismatch, as this was always trying to read 64 bytes.
Darwin 8.10.7 is missing llvm 🤦 |
The cryptonite library is deprecated and has been replaced by crypton which is a drop in replacement. For the `cbits` code, replace all instances of `cryptonite` with `crypton`.
Pretty sure this warning is only generated with GCC versions >= 14.2. A type and a function were defined as follows: typedef unsigned char ed25519_secret_key[64]; void cardano_crypto_ed25519_publickey(const ed25519_secret_key sk, ed25519_public_key pk); and then the code had: uint8_t zl8[32]; cardano_crypto_ed25519_publickey(zl8, pub_zl8); The compiler error was squashed by changing the type of `uint8_t [32]` to `ed25519_secret_key` which is 64 bytes in size and then updating the `memset` call to zero the whole array.
8746e56
to
2607d9f
Compare
- Use haskell-actions/setup instead of haskell/actions/setup - Bump from v1 to v2 - Don't pin the cabal-version. Haskell-actions already bring in a newer version.
The cryptonite library is deprecated and has been replaced by crypton which is a drop in replacement.
cbits: Squash a Wstringop-overread error (This needs very careful review).