Page MenuHomeFreeBSD

crypto: Add an API supporting curve25519.
ClosedPublic

Authored by jhb on Jan 18 2022, 10:51 PM.

Details

Summary

This adds a wrapper around libsodium's curve25519 support matching
Linux's curve25519 API. The intended use case for this is WireGuard.

Note that this is not integrated with OCF as it is not related to
symmetric operations on data.

Sponsored by: The FreeBSD Foundation

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jhb requested review of this revision.Jan 18 2022, 10:51 PM
sys/crypto/curve25519.h
18

"REGENTS"?

sys/crypto/libsodium/utils.c
1–20

I wonder if we shouldn't use just the ISC license, with perhaps a special comment on sodium_memzero - I imagine that if we needed to extend what we support over time we'd just bring in more of libsodium's utils.c?

markj added inline comments.
sys/crypto/curve25519.c
45

I noticed that the Linux implementations check for an all-zeros secret, presumably as a seatbelt against programming errors? A clamped secret can't be all-zeros...

sys/crypto/curve25519.h
48

libsodium handles clamping for you, but I guess it doesn't hurt to be sure.

This revision is now accepted and ready to land.Jan 19 2022, 5:05 PM
sys/crypto/curve25519.c
18

Similarly.

sys/crypto/curve25519.h
18

Sigh, I must have copied this from the wrong file, I will fix.

48

WireGuard expects to use this function directly, but yes, I noticed libsodium already does this.

sys/crypto/libsodium/utils.c
1–20

Mmm, yeah.

jhb marked 3 inline comments as done.Jan 20 2022, 10:33 PM
sys/crypto/curve25519.c
45

It also checks the computed value, perhaps as a seatbelt against broken backends (since they support MD backends)? I could add the check against all zeroes if you think it's warranted.

sys/crypto/curve25519.c
45

I think the change is fine as-is.

This revision now requires review to proceed.Jan 21 2022, 1:01 AM
This revision was not accepted when it landed; it landed in state Needs Review.Jan 24 2022, 11:29 PM
This revision was automatically updated to reflect the committed changes.