109 Commits

Author SHA1 Message Date
Tony Arcieri
c611408a2e
v0.9.0 () 2023-04-27 12:57:20 -06:00
Tony Arcieri
a8bddc2f6b
Add u64_digit feature ()
Adds an on-by-default feature which enables `num-bigint-dig/u64_digit`.

Disabling this on 32-bit platforms (e.g. WASM) should improve
performance.

Closes 
2023-04-27 07:39:25 -06:00
Tony Arcieri
78ea9cb7da
Impl ZeroizeOnDrop for RsaPrivateKey+newtypes ()
`RsaPrivateKey` self-zeroizes on drop, so add the `ZeroizeOnDrop` marker
trait to `RsaPrivateKey` and all newtypes thereof, i.e. `DecryptingKey`
and `SigningKey` for the various padding modes.

This also removes the `Zeroize` impl on `RsaPrivateKey`, since it
self-zeroizes on `Drop`, and allowing `Zeroize` might accidentally
permit use-after-zeroize vulnerabilities.
2023-04-26 10:39:18 -06:00
Tony Arcieri
b1151dfb0e
v0.9.0-rc.0 () 2023-04-25 08:48:24 -06:00
Tony Arcieri
bd14ee90b6
Bump pkcs1 dependency to v0.7.5 ()
Workaround for 
2023-04-24 13:43:49 -06:00
Dmitry Baryshkov
574664808d
Internals refactoring ()
* feat: decouple key generation and random generation

Make generate_multi_prime_key_with_exp() generic enough to generate
abstract key structure. Rewrite RsaPrivateKey constructors to use
RsaPrivateKey::from_components().

* feat: move key-related traits to separate module

Move PublicKeyParts to the separate module.

* feat: stop using RsaPrivateKey in internals.rs

Make internals.rs generic enough to be moved to the algorithms module.

* feat: move soft RSA implementation to crate::algorithms::rsa.rs

Separate software RSA implementation to separate module under
crate::algorithms.

* key: drop raw_int_*_primitive wrappers

Now as raw_int_encryption_primitive() and raw_int_decryption_primitive()
became simple wrappers around properly defined functions we can inline
them and always use software RSA algorithm from src::algorithms::rsa.rs.

* feat: move internals.rs to src/algortihms/pad.rs

internals.rs now contains only small functions related to BigUint to
Vec<u8> conversion. Move them to src/algorithms/pad.rs and get rid of
internals.rs

* algorithms: protect all functions with pub(crate)

While it is expected that the functions inside algorithms crates might
be useful (and used) by other parties, they are low level functions and
as such impose a high risk of being misused. Protect all of them with
pub(crate) to prevent them from being exposed by mistake.

Also add big fat warnings to raw RSA functions, which should never be
used unless authors knows exactly what they are using.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-04-23 16:53:21 -06:00
Tony Arcieri
3292db138d
v0.9.0-pre.2 () 2023-04-19 09:06:51 -06:00
Dmitry Baryshkov
a6fd36d5c5
feat: switch to RsaPssParams::new() ()
Switch to using RsaPssParams::new() from pkcs1 crate. This fixes the
issue reported by zlint for x509-cert, where SHA* digest algorithms had
empty parameters instead of NULL parameters (as required by Mozilla
policy and permitted by RFC4055).

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-04-18 11:13:52 -06:00
Tony Arcieri
d3a25cd2b2
Cargo.toml: alphabetize feature names () 2023-04-17 14:57:00 -06:00
Tony Arcieri
534eca6ae8
v0.9.0-pre.1 () 2023-04-04 21:10:12 -06:00
Dmitry Baryshkov
cf90255057
AssociatedAlgorithmIdentifier implementation ()
Implement associated AlgorithmIdentifier traits for PKCS1v15 and PSS keys

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-04-04 20:12:08 -06:00
Tony Arcieri
31f25dacee
v0.9.0-pre.0 () 2023-03-06 13:51:13 -07:00
Tony Arcieri
54ddb2802f
Bump pkcs1 to v0.7, pkcs8 to v0.10; MSRV 1.65 () 2023-03-06 13:31:16 -07:00
Tony Arcieri
99397db9ca
Use namespaced features for serde; MSRV 1.60 ()
Reverts-the-revert from , reinstating 

This reverts commit 26f38ad66a09fc42ed6d73e3b1864f0251db4e2d.

Since we need to upgrade `pkcs1` and `pkcs8`, which are MSRV 1.65, now
is a good time to start making brekaing changes again.
2023-03-05 18:34:51 -07:00
Tony Arcieri
c2a16aac47
v0.8.2 () 2023-03-01 21:54:18 -07:00
Tony Arcieri
d10fcd9081
rsa v0.8.1 () 2023-01-21 09:25:00 -07:00
Tony Arcieri
134a061237
Add sha2 feature with oid subfeature enabled ()
We seem to be running into a lot of people who are having trouble with
PKCS#1 v1.5 signatures because the failure mode for the `oid` feature of
the `sha2` crate being disabled is fairly unscrutable.

See , , and the semi-related tracking issue for .

If `rsa` has a `sha2` feature, we can always ensure `oid` is enabled,
and this can be used in code examples. It also means users don't need
two crates to create/verify PKCS#1 v1.5 signatures.

RSA is used commonly enough with the SHA2 family that this integration
probably makes sense.
2023-01-20 16:46:27 -07:00
Tony Arcieri
26f38ad66a
Revert "Use namespaced features for serde; MSRV 1.60 ()" ()
This reverts commit da1997d0b786181f3e3375e3eef09899486a3833.

I was probably over-eager on this: it's a breaking change.

There are probably some non-breaking changes we can make first, and when
we're ready to make breaking changes again, we can revert the revert.
2023-01-19 16:26:52 -07:00
Tony Arcieri
da1997d0b7
Use namespaced features for serde; MSRV 1.60 ()
Gets rid of the `serde_crate` hacks.

Weak/namespaced features should also make it possible to make more of
the functionality in this crate optional.
2023-01-17 09:20:29 -07:00
Tony Arcieri
3c2a3f8ee6
v0.8.0 () 2023-01-17 09:04:52 -07:00
Tony Arcieri
b10b924c5d
Bump signature crate dependency to v2 ()
Release notes: https://github.com/RustCrypto/traits/pull/1211
2023-01-16 13:25:29 -07:00
Tony Arcieri
37c1e14069
rsa v0.8.0-rc.0 () 2023-01-10 21:29:34 -07:00
Tony Arcieri
35a32093f0
Bump signature to v2.0.0-rc.1 () 2023-01-07 21:26:52 -07:00
Tony Arcieri
47b8aaae69
Bump signature to v2.0.0-rc.0 () 2023-01-05 13:37:02 -07:00
Dmitry Baryshkov
8c96243f9f
v0.8.0-pre.0 ()
Also uses the new `CryptoRngCore` where possible instead of separate
`CryptoRng + RngCore`, and switches to `signature` v2.0.0-pre.3

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-12-17 08:26:59 -07:00
Dmitry Baryshkov
b39752d4d8
feat: switch to version 2.0 (pre) of the signature crate ()
Rework the crate to implement traits from the preview of the signature
crate. Use `Vec<u8>` as `Self::Repr` type.

Drop the hand-crafted `From` traits, replacing them with the
implementation of the `Keypair` trait.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-12-04 19:03:38 -07:00
Tony Arcieri
35f7ae2d97
Remove minimal-versions workaround ()
Now that https://github.com/dignifiedquire/num-bigint/pull/42 has landed
it is no longer needed.
2022-11-21 08:28:25 -07:00
Tony Arcieri
0c7feac620
v0.7.2 () 2022-11-14 19:47:48 -07:00
Tony Arcieri
4f1d413845
v0.7.1 () 2022-10-31 15:03:26 -06:00
Tony Arcieri
942571f544
v0.7.0 () 2022-10-10 12:15:14 -06:00
Dmitry Baryshkov
2cac57a360
feat: implement hazmat signature traits for PSS keys ()
Implement PrehashSigner and PrehashVerifier traits for PSS
key structures.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-10-06 11:31:12 -06:00
Tony Arcieri
bfd17e2ec6
v0.7.0-rc.1 () 2022-10-05 17:18:05 -06:00
Tony Arcieri
cfc27dc85c
Fix signature version requirement ()
The crate is now using the `PrehashSigner`/`PrehashVerifier` traits,
which were added in `signature` v1.6.1.

However, that release was also yanked, so this commit pins to 1.6.2.
2022-10-05 16:57:59 -06:00
Dmitry Baryshkov
165f06f9cd
feat: iplement hazmat signature traits for PKCS1v15 keys ()
Implement PrehashSigner and PrehashVerifier traits for PKCS1v15
structures.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-09-22 10:03:46 -06:00
Tony Arcieri
18da70ae57
v0.7.0-rc.0 () 2022-09-16 11:46:43 -06:00
Dmitry Baryshkov
92ef4c823b
pkcs1v15: use AssociatedOid for getting the RSA prefix ()
Drop internal implementation of `AssociatedHash` and use `AssociatedOid`
trait from `const_oid` to get the OID corresponding to the `Digest` and to
format the ASN.1 prefix.

Also removes the previous `Hash` enum as it was used for looking up OIDs.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-09-16 11:25:05 -06:00
Dmitry Baryshkov
d68e2731dc
Update RSA signature traits implementations ()
- Change the `SigningKey` and `VerifiyingKey` implementations accept raw
message rather than pre-hashed message.

- Implement the experimental (preview) `DigestSigner` and `DigestVerifier`
traits for the PKCS1v15 structs.

- Implement the experimental (preview) `RandomizedDigestSigner` and
`DigestVerifier` traits for the PSS structs.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-09-07 11:47:03 -06:00
Dmitry Baryshkov
40242fbbb0
Implement Signer/Verifier/Signature interfaces for the RSA signatures ()
Refactor the `rsa` crate to use the API defined by the signature crate.

This adds `pss` and `pkcs1v15` modules, each of them providing
`Signature`, `Verifier` and `Signer`/`RandomizedSigner` implementations.

Add tests for pkcs1v15 and pss signature verification functions to check
that verifying invalid signatures returns an error.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-08-19 11:46:40 -06:00
Tony Arcieri
4ccdcf92a9
Make RsaPrivateKey::from_components fallible ()
Adds an error case in the event the number of `primes` provides is fewer
than 2, which prevents panics when invoking methods which expect primes
to always be present at indices 0 and 1 (i.e. `p` and `q`)

Fixes 
2022-07-25 06:35:47 -06:00
Tony Arcieri
b626d48a4f
v0.7.0-pre () 2022-05-23 21:29:10 -06:00
Quentin Gliech
2b8b7dd4bb
Bump pkcs1 => 0.4, pkcs8 => 0.9 ()
Also bumps MSRV to 1.57
2022-05-23 20:44:33 -06:00
Tony Arcieri
4b8fa4fb67 chore(rsa): release 0.6.1 2022-04-11 07:43:19 -06:00
dignifiedquire
cc3c9e0040 chore(rsa): release 0.6.0 2022-04-08 16:24:49 +02:00
Artyom Pavlov
bc44abf96e
Address RUSTSEC-2021-0003 by bumping smallvec to 1.6.1 () 2022-03-22 14:38:12 +00:00
Artyom Pavlov
bbfd911207
Remove nondeterministic tests () 2022-03-14 14:22:48 +00:00
Artyom Pavlov
0844aeb88d
Fix min versions build () 2022-03-13 21:07:40 +00:00
Artyom Pavlov
cf27569687
Replace rand dependency with rand_core () 2022-03-13 19:50:05 +00:00
Tony Arcieri
56c02cfd24
v0.6.0-pre () 2022-03-10 13:27:39 -07:00
Friedel Ziegelmayer
190a8ec856
feat: update to rust edition 2021 ()
bumps MSRV to 1.56.0

Co-authored-by: Tony Arcieri <bascule@gmail.com>
2022-03-10 11:25:50 -07:00
Tony Arcieri
7395997c40
Impl zeroize without using zeroize_derive ()
The `zeroize_derive` crate has quite a few dependencies, and in
particular `syn` is a fairly large one with not-insignificant compile
times.

Together with , this will remove the
following dependencies from the dependency tree:

- `proc-macro2`
- `quote`
- `syn`
- `synstructure`
- `zeroize_derive`
2022-02-02 05:49:01 -07:00