utelle / SQLite3MultipleCiphers

SQLite3 encryption extension with support for multiple ciphers
https://utelle.github.io/SQLite3MultipleCiphers/
MIT License
390 stars 73 forks source link

Wasm target #88

Closed nullrocket closed 2 years ago

nullrocket commented 2 years ago

Added conditional WASM so that the entropy can be properly defined for wasm targets.

nullrocket commented 2 years ago

Sorry about all the noise! Something was wrong with my local git repo, every time i commited changes, it would be a strange merge of an old commit with the new. Fixed now. I thought I was losing my mind!

I do remember why I had the full braces and return here. https://github.com/utelle/SQLite3MultipleCiphers/blob/cc7033eb6f88c68b5322e6fac3c1369aec554974/src/chacha20poly1305.c#L393

I was seeing this warning and thought I would clear it up.

warning: non-void function does not return a value in all control paths

utelle commented 2 years ago

I do remember why I had the full braces and return here.

https://github.com/utelle/SQLite3MultipleCiphers/blob/cc7033eb6f88c68b5322e6fac3c1369aec554974/src/chacha20poly1305.c#L393

I was seeing this warning and thought I would clear it up.

warning: non-void function does not return a value in all control paths

I already commented on the latter, but additionally the keyword static should be dropped. That is, the final code for function entropy should look like this:

extern size_t entropy(void* buf, size_t n);
size_t entropy(void* buf, size_t n)
{
  return (getentropy(buf, n) == 0) ? n : 0;
}
nullrocket commented 2 years ago

Ok, I removed the static keyword, just curious why? There is another definition further up where I believe I got the signature from when I was making the change that is static.

Also just to be sure, your code above is not what I have.

extern size_t entropy(void* buf, size_t n);
size_t entropy(void* buf, size_t n)
{
  return (getentropy(buf, n) == 0) ? n : 0;
}

This is what I have. the extern decl is for getentropy.

extern size_t getentropy(void* buf, size_t n);
size_t entropy(void* buf, size_t n)
{
  return (getentropy(buf, n) == 0) ? n : 0;
}
utelle commented 2 years ago

Ok, I removed the static keyword, just curious why? There is another definition further up where I believe I got the signature from when I was making the change that is static.

Ouch, please revert this change. That is, the static keyword should actually be used. Otherwise the symbol will be exported. Sorry for the confusion (it's late in the evening here in Germany 😉 ).

Also just to be sure, your code above is not what I have. [...] This is what I have. the extern decl is for getentropy.

extern size_t getentropy(void* buf, size_t n);
size_t entropy(void* buf, size_t n)
{
  return (getentropy(buf, n) == 0) ? n : 0;
}

Yes, your version is correct. Sorry for my lack of concentration.