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

Error with r a n d o m b y t e s / r a n d o m b y t e s . c #733

Closed
Serasar opened this issue Jul 14, 2018 · 4 comments
Closed

Error with r a n d o m b y t e s / r a n d o m b y t e s . c #733

Serasar opened this issue Jul 14, 2018 · 4 comments

Comments

@Serasar
Copy link

Serasar commented Jul 14, 2018

Have this program written in Nim(I use this binding https://github.com/FedericoCeratto/nim-libsodium):

var key = randombytes(crypto_secretbox_KEYBYTES())
let c = crypto_secretbox_easy(key, "test")
let d = crypto_secretbox_easy(key, c)
echo(d)

Get this error:
A s s e r t i o n f a i l e d !

P r o g r a m : C : \ D e v \ n i m _ e n c \ c r y p t o . e x e
F i l e : r a n d o m b y t e s / r a n d o m b y t e s . c , L i n e 2 0
4

E x p r e s s i o n : b u f _ l e n < = S I Z E _ M A X

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
SIGABRT: Abnormal termination.
It seems that this error only happens on 32 bit install for some reason. Everything works fine on 64 bits.

Also this issue is here FedericoCeratto/nim-libsodium#8

@jedisct1
Copy link
Owner

I'm not familiar with Nim, but an error on Line 20 for a source code that is only 4 lines long doesn't seem right :) Neither seems to be the double call to secretbox().

Can you post the actual test case?

@ektrah
Copy link
Contributor

ektrah commented Jul 14, 2018

The assertion seems to be this one:

assert(buf_len <= SIZE_MAX);

@ektrah
Copy link
Contributor

ektrah commented Jul 14, 2018

buf_len is an unsigned long long in the C code but a csize (=size_t) in the Nim wrapper.

@jedisct1
Copy link
Owner

Glad that we have these assertions :)

So this is a bug in the Nim wrapper that you should report to the author!

Repository owner locked and limited conversation to collaborators Aug 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants