Code Monkey home page Code Monkey logo

Comments (4)

hynek avatar hynek commented on June 20, 2024

By tricky you mean inconvenient I presume? :)

The situation is as following:

  • The library works (as virtually any C library) on bytes. I can’t know what encoding your secrets are in (because it can be any byte, not just readable/printable ones). Trying to guess that in a security context like this, is a road to security vulnerabilities.
  • hash_password_raw() also has to return bytes because it does. There’s no applicable encoding.

On the other hand, the encoded hash is always ASCII bytes, therefore I could easily encode/decode it.

But I’ve decided for the sake of:

  1. simplicity/symmetry (any string is bytes, you don’t have to think about it),
  2. performance (I still have to pass in bytes and I still get back bytes. if the user doesn't want unicode, there's an extra encoding/decoding round which puts you at a disadvantage to the attacker).

to keep it as bytes too.

As you can see, supporting Unicode would force me to make decisions for the users. In my other libraries I’m usually happy to do so (opinionated software tends to be better software), but this one is a) security-related and b) rather low-level since it’s the direct C-wrapper.


So, at this point we can decide to build higher-level helpers that presume that you always want your Unicode secrets interpreted as UTF-8 when going in and decoded when coming out. Maybe I’ll add something like that at some point, but for know I’d encourage you to build your own simple helpers (which also may contain your parameters?) until clearer usage patterns emerge.

I think I’ll start an FAQ with this. :)

from argon2-cffi.

rismalrv avatar rismalrv commented on June 20, 2024

Thanks for the explanation hynek! I really appreciate it.

from argon2-cffi.

hynek avatar hynek commented on June 20, 2024

Does http://argon2-cffi.readthedocs.org/en/latest/api.html#module-argon2 do what you need?

from argon2-cffi.

rismalrv avatar rismalrv commented on June 20, 2024

Yes!!! LOL
Thanks a lot!!

from argon2-cffi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.