authenticvision / libpaseto

C implementation of Platform-Agnostic Security Tokens (PASETO)
https://paseto.io
BSD 3-Clause "New" or "Revised" License
22 stars 2 forks source link

Will paseto_v2_encrypt always terminate with a nul \0 byte? #2

Closed jackturnbull closed 6 years ago

jackturnbull commented 6 years ago

Apologies for the incorrect use of an issue but it feels like the best place to ask. I need a little guidance since I'm not very proficient at reading C and don't want to take something for granted that could potentially be unsafe.

I've written some Crystal C bindings for this library and the largest area of concern is that I'm allowing the Crystal string initialiser to step over the returned pointer from paseto_v2_encrypt which appears to terminate whenever reaches a zero byte.

The libsodium docs suggest that the returned char* will be terminated with a \0 character so I'm assuming that would be enough in this instance?

Thanks for the lib!

minus7 commented 6 years ago

Hi, The string returned from paseto_v2_encrypt is standard C string and thus is null-terminated. The docs in the header file also mention this.

Nice that you're building Crystal bindings for paseto :+1:

jackturnbull commented 6 years ago

Ah that's a little embarassing - totally missed that. Thanks :smile:

minus7 commented 6 years ago

FYI I just changed the API and added v2.public. You might want to update :)

jackturnbull commented 6 years ago

Oh wow good update! I'll get onto that this weekend, thanks :)