zig/lib/std/crypto
Frank Denis 27610b0a0f
std/crypto: add support for ECDSA signatures (#11855)
ECDSA is the most commonly used signature scheme today, mainly for
historical and conformance reasons. It is a necessary evil for
many standard protocols such as TLS and JWT.

It is tricky to implement securely and has been the root cause of
multiple security disasters, from the Playstation 3 hack to multiple
critical issues in OpenSSL and Java.

This implementation combines lessons learned from the past with
recent recommendations.

In Zig, the NIST curves that ECDSA is almost always instantied with
use formally verified field arithmetic, giving us peace of mind
even on edge cases. And the API rejects neutral elements where it
matters, and unconditionally checks for non-canonical encoding for
scalars and group elements. This automatically eliminates common
vulnerabilities such as https://sk.tl/2LpS695v .

ECDSA's security heavily relies on the security of the random number
generator, which is a concern in some environments.

This implementation mitigates this by computing deterministic
nonces using the conservative scheme from Pornin et al. with the
optional addition of randomness as proposed in Ericsson's
"Deterministic ECDSA and EdDSA Signatures with Additional Randomness"
document. This approach mitigates both the implications of a weak RNG
and the practical implications of fault attacks.

Project Wycheproof is a Google project to test crypto libraries against
known attacks by triggering edge cases. It discovered vulnerabilities
in virtually all major ECDSA implementations.

The entire set of ECDSA-P256-SHA256 test vectors from Project Wycheproof
is included here. Zero defects were found in this implementation.

The public API differs from the Ed25519 one. Instead of raw byte strings
for keys and signatures, we introduce Signature, PublicKey and SecretKey
structures.

The reason is that a raw byte representation would not be optimal.
There are multiple standard representations for keys and signatures,
and decoding/encoding them may not be cheap (field elements have to be
converted from/to the montgomery domain).

So, the intent is to eventually move ed25519 to the same API, which
is not going to introduce any performance regression, but will bring
us a consistent API, that we can also reuse for RSA.
2022-06-15 08:55:39 +02:00
..
25519 std: update tests to stage2 semantics 2022-06-03 20:21:20 +03:00
aes std.crypto: cosmetic improvement to AES multiplication algorithm (#11616) 2022-05-25 19:23:49 +02:00
pcurves crypto/pcurves: compute constants for inversion at comptime (#11780) 2022-06-13 08:13:52 +02:00
aegis.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
aes.zig std: break up some long lines 2022-01-28 16:23:47 -07:00
aes_gcm.zig migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
aes_ocb.zig migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
argon2.zig std: disable failing tests, add zig2 build test-std to CI 2022-06-12 10:43:28 +03:00
bcrypt.zig std: disable failing tests, add zig2 build test-std to CI 2022-06-12 10:43:28 +03:00
benchmark.zig std: fix crypto and hash benchmark 2022-04-24 23:01:06 -04:00
blake2.zig std: add writer methods on all crypto.hash types (#10168) 2021-11-20 01:37:17 -08:00
blake3.zig std: update tests to stage2 semantics 2022-06-03 20:21:20 +03:00
chacha20.zig replace other uses of std.meta.Vector with @Vector (#11346) 2022-03-30 14:12:14 -04:00
ecdsa.zig std/crypto: add support for ECDSA signatures (#11855) 2022-06-15 08:55:39 +02:00
errors.zig
ghash.zig replace other uses of std.meta.Vector with @Vector (#11346) 2022-03-30 14:12:14 -04:00
gimli.zig replace other uses of std.meta.Vector with @Vector (#11346) 2022-03-30 14:12:14 -04:00
hkdf.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
hmac.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
isap.zig
md5.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
modes.zig migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
pbkdf2.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
phc_encoding.zig std: disable failing tests, add zig2 build test-std to CI 2022-06-12 10:43:28 +03:00
poly1305.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
salsa20.zig replace other uses of std.meta.Vector with @Vector (#11346) 2022-03-30 14:12:14 -04:00
scrypt.zig std: disable failing tests, add zig2 build test-std to CI 2022-06-12 10:43:28 +03:00
sha1.zig std: add writer methods on all crypto.hash types (#10168) 2021-11-20 01:37:17 -08:00
sha2.zig std: add writer methods on all crypto.hash types (#10168) 2021-11-20 01:37:17 -08:00
sha3.zig std: update tests to stage2 semantics 2022-06-03 20:21:20 +03:00
siphash.zig Fixes comptime 'error: cannot assign to constant' error in siphash. 2022-05-16 22:31:09 -04:00
test.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
tlcsprng.zig stage1, stage2: rename c_void to anyopaque (#10316) 2021-12-19 00:24:45 -05:00
utils.zig replace other uses of std.meta.Vector with @Vector (#11346) 2022-03-30 14:12:14 -04:00