Skip to content
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

segfault when doing decode_secret #17

Closed
jcdutton opened this issue Mar 30, 2019 · 3 comments
Closed

segfault when doing decode_secret #17

jcdutton opened this issue Mar 30, 2019 · 3 comments

Comments

@jcdutton
Copy link
Contributor

The decoder seg faults when doing decode_secret
Program received signal SIGSEGV, Segmentation fault.
0x000000000041625f in _nettle_aes_set_key (nr=14, nk=8, subkeys=0x0, key=0x6efc50 "\235\262\207\260\204W\274rX\331%\254\304\312", <incomplete sequence \332>) at aes-set-key-internal.c:60 60 subkeys[i] = LE_READ_UINT32(key + i*4); (gdb) bt #0 0x000000000041625f in _nettle_aes_set_key (nr=14, nk=8, subkeys=0x0, key=0x6efc50 "\235\262\207\260\204W\274rX\331%\254\304\312", <incomplete sequence \332>)
at aes-set-key-internal.c:60
#1 0x0000000000416179 in nettle_aes256_set_encrypt_key (ctx=0x0, key=0x6efc50 "\235\262\207\260\204W\274rX\331%\254\304\312", <incomplete sequence \332>) at aes256-set-encrypt-key.c:43 #2 0x0000000000414a8e in nettle_aes256_set_decrypt_key (ctx=0x0, key=0x6efc50 "\235\262\207\260\204W\274rX\331%\254\304\312", <incomplete sequence \332>)
at aes256-set-decrypt-key.c:50
#3 0x0000000000405189 in CipherInit (ctx=0x0, mode=CipherTypeValue, key=0x6efc50 "\235\262\207\260\204W\274rX\331%\254\304\312", <incomplete sequence \332>, iv=0x6efb90 "\370\230ϲP\352\255#\264\070\070)V\354hi\311\350\223o\221\070\rZ\206\253\231\061\220X\352'\032\n\177\017\224\030XqC5Va\aɃJI\247Ȁ#\b\245\252\025\003\203X\253\222p", padding=false) at crypto_nettle.c:89
#4 0x000000000040c830 in decsngl_entry (argc=5, argv=0x7fffffffdd58, argo=1, entry=0x6e8ce0 <__decsngl_command>) at decsngl.c:218
#5 0x000000000041471d in main (argc=5, argv=0x7fffffffdd58) at decoder.c:140

@jcdutton
Copy link
Contributor Author

patch.txt

See attached patch to fix the seg fault.

@jcdutton jcdutton reopened this Mar 30, 2019
@jcdutton
Copy link
Contributor Author

Leave it open until the patch is committed.

@PeterPawn
Copy link
Owner

Yes, there's only one call of CipherInit with a NULL pointer for ctx and a value for key and iv.

grep -r "CipherInit(NULL"
src/memory.c:   CipherContext           *ctx = CipherInit(NULL, CipherTypeValue, NULL, NULL, false);
src/decsngl.c:  CipherContext           *ctx = CipherInit(NULL, CipherTypeValue, keyBuffer, secretBuffer, false);

and the OpenSSL version contains the correct code.

Stupid mistake, I've made - thanks for pointing it out.

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

No branches or pull requests

2 participants