2020-09-29 21:33:14 +02:00
|
|
|
|
|
|
|
|
|
2020-11-02 22:40:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-26 08:44:40 +01:00
|
|
|
|
2020-11-02 22:40:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-26 08:44:40 +01:00
|
|
|
|
2021-02-28 08:29:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-26 08:44:40 +01:00
|
|
|
|
|
|
|
|
|
2020-11-02 22:40:13 +01:00
|
|
|
|
2021-03-14 22:30:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-02 22:40:13 +01:00
|
|
|
|
2020-10-26 08:44:40 +01:00
|
|
|
|
2020-11-11 01:22:21 +01:00
|
|
|
|
|
|
|
|
|
2020-11-02 22:40:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-29 21:33:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
crypto: add the Xoodoo permutation, prepare for Gimli deprecation (#11866)
Gimli was a game changer. A permutation that is large enough to be
used in sponge-like constructions, yet small enough to be compact
to implement and fast on a wide range of platforms.
And Gimli being part of the Zig standard library was awesome.
But since then, Gimli entered the NIST Lightweight Cryptography
Competition, competing againt other candidates sharing a similar set
of properties.
Unfortunately, Gimli didn't pass the 3rd round.
There are no practical attacks against Gimli when used correctly, but
NIST's decision means that Gimli is unlikely to ever get any traction.
So, maybe the time has come to move Gimli from the standard library
to another repository.
We shouldn't do it without providing an alternative, though.
And the best candidate for this is probably Xoodoo.
Xoodoo is the core function of Xoodyak, one of the finalists of the
NIST LWC competition, and the most direct competitor to Gimli. It is
also a 384-bit permutation, so it can easily be used everywhere Gimli
was used with no parameter changes.
It is the building block of Xoodyak (for actual encryption and hashing)
as well as Charm, that some Zig applications are already using.
Like Gimli that it was heavily inspired from, it is compact and
suitable for constrained environments.
This change adds the Xoodoo permutation to std.crypto.core.
The set of public functions includes everything required to later
implement existing Xoodoo-based constructions.
In order to prepare for the Gimli deprecation, the default
CSPRNG was changed to a Xoodoo-based that works exactly the same way.
2022-07-01 13:18:08 +02:00
|
|
|
|
2020-09-29 21:33:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-01 08:14:32 +02:00
|
|
|
|
2022-05-31 17:29:38 +02:00
|
|
|
|
2020-09-29 21:33:14 +02:00
|
|
|
|
2022-06-29 15:11:33 +02:00
|
|
|
|
2020-09-29 21:33:14 +02:00
|
|
|
|
|
|
|
|
|
2020-08-19 16:21:05 +02:00
|
|
|
|
|
|
|
|
|
2020-10-26 08:44:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-19 16:21:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-01 11:37:41 +02:00
|
|
|
|
2020-08-19 16:21:05 +02:00
|
|
|
|
2019-03-02 16:46:04 -05:00
|
|
|
|
2020-09-29 21:33:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-16 23:37:42 +02:00
|
|
|
|
|
|
|
|
|
2020-08-19 16:21:05 +02:00
|
|
|
|
|
|
|
|
|
2020-09-30 01:12:37 +02:00
|
|
|
|
2020-10-26 08:44:40 +01:00
|
|
|
|
2020-08-19 16:21:05 +02:00
|
|
|
|
|
|
|
|
|
2020-09-23 21:37:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-08-24 14:58:09 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-11-15 06:47:57 +03:00
|
|
|
|
2021-08-24 14:58:09 +03:00
|
|
|
|
2021-11-15 06:47:57 +03:00
|
|
|
|
|
|
|
|
|
2021-08-24 14:58:09 +03:00
|
|
|
|
2021-11-15 06:47:57 +03:00
|
|
|
|
2020-10-24 22:40:20 +02:00
|
|
|
|
2021-08-24 14:58:09 +03:00
|
|
|
|
2020-09-13 23:00:33 +03:00
|
|
|
|
2021-11-15 06:47:57 +03:00
|
|
|
|
|
|
|
|
|
2020-09-13 23:00:33 +03:00
|
|
|
|
2020-09-11 17:10:27 -04:00
|
|
|
|
2020-08-19 16:21:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2020-08-19 16:21:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-11-02 22:40:13 +01:00
|
|
|
|
|
|
|
|
|
2021-03-14 22:30:25 +01:00
|
|
|
|
|
|
|
|
|
2020-11-02 22:40:13 +01:00
|
|
|
|
2021-03-14 22:30:25 +01:00
|
|
|
|
|
|
|
|
|
2020-11-02 22:40:13 +01:00
|
|
|
|
2021-03-14 22:30:25 +01:00
|
|
|
|
|
|
|
|
|
2020-11-02 22:40:13 +01:00
|
|
|
|
2020-10-26 08:44:40 +01:00
|
|
|
|
2020-11-02 22:40:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-25 17:02:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-26 08:44:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-19 16:21:05 +02:00
|
|
|
|
|
|
|
|
|
2020-08-23 01:36:37 +02:00
|
|
|
|
|
|
|
|
|
2020-12-17 20:03:41 -07:00
|
|
|
|
2022-01-24 23:28:45 -08:00
|
|
|
|
2020-12-17 20:03:41 -07:00
|
|
|
|
2019-05-24 18:27:18 -04:00
|
|
|
|
|
|
|
|
|
2021-04-20 19:57:27 +02:00
|
|
|
|
2021-03-13 15:11:35 +01:00
|
|
|
|
2022-01-31 22:25:49 -07:00
|
|
|
|
2021-10-04 23:47:27 -07:00
|
|
|
|
2021-01-04 15:57:54 -07:00
|
|
|
|
|
|
|
|
|
2022-01-31 22:25:49 -07:00
|
|
|
|
|
|
|
|
|
2020-09-13 23:00:33 +03:00
|
|
|
|
2022-01-31 22:25:49 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 17:29:38 +02:00
|
|
|
|
2022-01-31 22:25:49 -07:00
|
|
|
|
2022-06-29 15:11:33 +02:00
|
|
|
|
2022-01-31 22:25:49 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-01 11:37:41 +02:00
|
|
|
|
2022-01-31 22:25:49 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2022-01-31 22:25:49 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-02 16:46:04 -05:00
|
|
|
|
2020-02-24 01:45:37 +08:00
|
|
|
|
2020-12-17 20:03:41 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-04 20:47:26 +03:00
|
|
|
|
2020-12-17 20:03:41 -07:00
|
|
|
|
|
|
|
|
|
2020-02-24 01:45:37 +08:00
|
|
|
|
|
|
|
|
|
2020-08-19 16:21:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-16 19:10:20 +02:00
|
|
|
|
2020-08-19 16:21:05 +02:00
|
|
|
|
|
|
|
|
|
2020-10-16 19:10:20 +02:00
|
|
|
|
|
|
|
|
|
2020-08-19 16:21:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-24 01:45:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-08-21 00:51:14 +02:00
|
|
|
|
2020-08-20 22:36:57 +02:00
|
|
|
|
2020-02-24 01:45:37 +08:00
|
|
|
|
2020-10-16 19:10:20 +02:00
|
|
|
|
2020-08-20 22:36:57 +02:00
|
|
|
|
2020-02-24 01:45:37 +08:00
|
|
|
|
|
|
|
|
|
2020-10-16 19:10:20 +02:00
|
|
|
|
2020-02-24 01:45:37 +08:00
|
|
|
|
2021-05-04 20:47:26 +03:00
|
|
|
|
2020-02-24 01:45:37 +08:00
|
|
|
|
|
|
|
|
|