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

Proposal: KeyPair should not use byte[] for the private key #3

Open
danielcrenna opened this issue Oct 26, 2020 · 3 comments
Open

Proposal: KeyPair should not use byte[] for the private key #3

danielcrenna opened this issue Oct 26, 2020 · 3 comments

Comments

@danielcrenna
Copy link

danielcrenna commented Oct 26, 2020

In order to facilitate secure memory solutions, KeyPair:

  • should not copy a given private key into a byte array to make it suitable for KeyPair storage (i.e. in factory methods ala Curve25519.GenerateKeyPair
  • should not use managed buffer.Clear() to zero out memory on disposal, rather deferring to something like libsodium_free

This is a pre-requisite for enabling secure memory scenarios in this library, and could work for PSKs in the Protocol API methods.

@Zetanova
Copy link

danielcrenna's commit 6c5fdb6

@Zetanova
Copy link

The nsec.net lib uses libsodium too and has the reverse problem.
See ektrah/nsec#31

@ektrah
Copy link

ektrah commented Apr 10, 2021

Fwiw, I think it's totally the right way to do (passing keys around as KeyPair instances rather than byte arrays & storing private keys in sodium_malloc'd memory). The "problem" I'm facing with NSec is that API users are consistently undermining this by recreating the KeyPair instances from byte arrays on every single library invocation. I guess this might be less of a problem in a Noise implementation, which will probably more likely expose a "HandshakeState"- or "Connection"-oriented API rather than an "Algorithm"- and "KeyPair"-API.

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

3 participants