197 Commits

Author SHA1 Message Date
Nathaniel McCallum
a760b51b1e
feat: impl From for Signing/Verifying keys (#193)
Signed-off-by: Nathaniel McCallum <nathaniel@profian.com>
2022-09-21 16:43:04 -06:00
Nathaniel McCallum
0332c659df
feat: impl AsRef for Signing/Verifying keys (#194)
Signed-off-by: Nathaniel McCallum <nathaniel@profian.com>
2022-09-21 16:42:29 -06:00
Nathaniel McCallum
c2a57c640d
chore: resolve numerous clippy lints
Signed-off-by: Nathaniel McCallum <nathaniel@profian.com>
2022-09-21 23:06:18 +02:00
Xynnn_
29ff287752
feat: derive Clone and Debug for SigningKey/VerifyingKey (#191)
- added Clone and Debug for SigningKey & VerifyingKey
of pss and pkcs1v15

Signed-off-by: Xynnn007 <mading.ma@alibaba-inc.com>
2022-09-19 09:17:56 -06:00
Tony Arcieri
8e712770d5
Add CHANGELOG.md (#189)
Includes stubs for all current non-prerelease releases (except v0.0.0)
which we can eventually fill out, or just add new versions going
forward.
2022-09-16 16:30:12 -06:00
Tony Arcieri
18da70ae57
v0.7.0-rc.0 (#188) 2022-09-16 11:46:43 -06:00
Dmitry Baryshkov
88be36bef4
Drop reference boilerplate code (#185)
Drop boilerplate code which implements traits for references to key
types. The code can use references directly.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-09-16 11:25:33 -06:00
Dmitry Baryshkov
92ef4c823b
pkcs1v15: use AssociatedOid for getting the RSA prefix (#183)
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
36df97aded
Allow dereferencing Signature types (#182)
Implement Deref<Target = [u8]> for the Signature types to allow
automatically dereferencing Signature as byte slices.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-09-12 10:43:13 -06:00
Dmitry Baryshkov
98f50fd6a1
Drop unused Hash usage from doc-tests (#184)
Remove a leftover use rsa::Hash part from the crate's doc-tests.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-09-10 13:56:06 -06:00
Dmitry Baryshkov
d68e2731dc
Update RSA signature traits implementations (#179)
- 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
Tony Arcieri
eb8bc2211f
Fix PKCS#1/PKCS#8 line endings on Windows (#181)
The checked-in files use Unix-style line endings, so use
`LineEnding::LF` in tests, rather than `Default::default` (which uses
OS-specific line endings.

Also adds a `.gitattributes` file which specifies these files should
always be checked out with `eol=lf`.
2022-09-06 10:38:54 -06:00
Dmitry Baryshkov
2ffd3aef61
PaddingScheme: remove rng from PSS padding scheme (#172) (#173)
The passed rng is not necessary for PSS signature verification. Instead
of passing artificial unused RNG through the PaddingScheme, add new
sign_with_rng() API and pass rng directly. In the sign_blinded() use the
passed rng both for salt generation and for the blinding process.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-08-29 12:57:29 -06:00
Dmitry Baryshkov
40242fbbb0
Implement Signer/Verifier/Signature interfaces for the RSA signatures (#174)
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
e7f48101a4
Add RsaPublicKey::new_with_max_size; 4096-bit default max (#176)
This constructor accepts a configurable maximum key size which can be
used in applications that need to deal with unusually large RSA public
keys, such as OpenPGP.

With the ability to configure an upper limit, this makes it possible to
lower the default maximum key size to 4096-bits, which is a reasonable
upper limit for most applications.

Fixes #166
2022-08-09 08:24:01 -06:00
Tony Arcieri
8d3fe53711
check_public improvements (#170)
- Ensure modulus is 16384-bits or fewer. See #166
- Increase maximum public exponent. Closes #155
2022-08-07 15:47:12 -06:00
Tony Arcieri
4ccdcf92a9
Make RsaPrivateKey::from_components fallible (#167)
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 #163
2022-07-25 06:35:47 -06:00
Tony Arcieri
b626d48a4f
v0.7.0-pre (#164) 2022-05-23 21:29:10 -06:00
Quentin Gliech
2b8b7dd4bb
Bump pkcs1 => 0.4, pkcs8 => 0.9 (#162)
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
Tony Arcieri
c6dbce6634
Add RsaPrivateKey::crt_coefficient (#158)
This method is useful for key serialization formats and is internally
useful within the context of the PKCS#1/PKCS#8 implementations.

Externally I'm working on adding support to the `ssh-key` crate. I could
implement this same thing by pulling in `num_bigint_dig::ModInverse`,
it'd be a lot easier if this purpose-dedicated method were available.
2022-04-11 08:20:37 +02:00
Tony Arcieri
82b0dbcfb2
Fix rustdoc warnings and add rustdoc CI (#157)
- Fixes some broken links to the `pkcs1`/`pkcs8` crate traits
- Fixes other rustdoc warnings
- Adds rustdoc CI job to ensure docs build without warnings
2022-04-11 08:19:13 +02:00
dignifiedquire
cc3c9e0040 chore(rsa): release 0.6.0 2022-04-08 16:24:49 +02:00
dignifiedquire
43dd9e537d chore: update release.toml to work with latest cargo-release 2022-04-08 16:24:15 +02:00
Artyom Pavlov
bc44abf96e
Address RUSTSEC-2021-0003 by bumping smallvec to 1.6.1 (#156) 2022-03-22 14:38:12 +00:00
Addison Crump
fb6016575a
zeroize plaintexts which are about to be encrypted (#154) 2022-03-15 15:20:20 -06:00
Artyom Pavlov
bbfd911207
Remove nondeterministic tests (#152) 2022-03-14 14:22:48 +00:00
Artyom Pavlov
0844aeb88d
Fix min versions build (#150) 2022-03-13 21:07:40 +00:00
Artyom Pavlov
cf27569687
Replace rand dependency with rand_core (#148) 2022-03-13 19:50:05 +00:00
Tony Arcieri
56c02cfd24
v0.6.0-pre (#147) 2022-03-10 13:27:39 -07:00
Friedel Ziegelmayer
190a8ec856
feat: update to rust edition 2021 (#135)
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 (#143)
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 dignifiedquire/num-bigint#35, 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
Friedel Ziegelmayer
6717592cc8
Merge pull request #139 from RustCrypto/pkcs1-v0.3+pkcs8-v0.8 2022-01-17 14:55:23 +01:00
Tony Arcieri
e4366a7e8f Bump pkcs1 => v0.3, pkcs8 => v0.8; MSRV 1.56
Updates the `pkcs1` and `pkcs8` crates to their latest versions.

These releases reversed the blanket impl relationship between the traits
in the two respective crates.

The names of the traits have changed:
- `From*Key` => `Decode*Key` (e.g. `DecodePrivateKey`)
- `To*Key` => `Encode*Key` (e.g. `EncodePrivateKey`).

Previously there was a blanket impl of `pkcs8` traits for the `pkcs1`
crates, e.g. `DecodePrivateKey` was impl'd for `DecodeRsaPrivateKey`.

This relationship has been reversed in the latest releases, and as such
this commit now implements the `pkcs8` traits instead of the `pkcs1`
traits (even though this internally involves decoding a PKCS#1 document
as part of PKCS#8 decoding).

The reasoning is this was necessary to make it possible for traits for
multiple formats to have blanket impls for the PKCS#8 traits. Concretely
this was needed to allow blanket impls of the traits in the `sec1` crate
for types which impl traits from the `pkcs8` crate.

Both of these crates are MSRV 1.56 and hard dependencies, so the MSRV of
the `rsa` crate is accordingly bumped to 1.56.
2022-01-16 10:57:11 -07:00
Trevor Arjeski
2d68db2e0f
feat(key): add fn to clear precomputed values on RsaPrivateKey 2022-01-05 23:00:23 +01:00
Poliorcetics
024a61b6ed
chore(deps): Update crypto crates
Co-authored-by: Alexis Bourget <alexis@harfanglab.fr>
2022-01-05 22:59:20 +01:00
Expyron
1ad5f1c4df
refactor: remove lazy_static dependency 2021-12-07 01:08:36 +01:00
Marcin
3b7ee867a7
docs(readme): update to match the documentation example 2021-12-06 12:35:16 +01:00
william
9d8e8e5ffa
Add missing RsaPublicKey import (#119) 2021-12-03 08:05:07 -07:00
Luca Cominardi
fd1961dfe2
feat: derive Hash for RsaPublicKey 2021-09-30 14:26:22 +02:00
Friedel Ziegelmayer
d4376e089f
Merge pull request #111 from RustCrypto/readme/use-unicode-emoji
README.md: use Unicode emoji
2021-07-27 18:23:33 +02:00
Tony Arcieri
fc9c69b988 README.md: use Unicode emoji
The `:emoji:` tags are part of GitHub Flavored Markdown and don't render
correctly on https://crates.io
2021-07-27 08:54:10 -07:00
dignifiedquire
a1c1f2b8f0 chore(rsa): release 0.5.0 2021-07-27 08:47:48 +02:00
Friedel Ziegelmayer
cd257a74aa
Merge pull request #110 from RustCrypto/fix-type-names
refactor: rename  `RSA*` to `Rsa`
2021-07-26 23:57:46 +02:00
dignifiedquire
7a1eaa0329 refactor: rename RSA* to Rsa
This matches the rust naming convention better.

Closes #24
2021-07-26 23:25:13 +02:00
Tony Arcieri
f251dee5a9
Use pkcs1 and pkcs8 crates; MSRV 1.51+ (#104)
This is an initial attempt to switch the `rsa` crate to use the `pkcs1`
and `pkcs8` crates from https://github.com/rustcrypto/utils
2021-07-26 13:57:23 -07:00
dignifiedquire
dc103e1453 chore(rsa): release 0.4.1 2021-07-26 22:45:43 +02:00
est31
12336e2467
docs(readme): only optimizing num-bigint-dig is enough to unlock most speedups 2021-07-26 22:44:31 +02:00
Zicklag
9559d99fa8
docs(readme): add Note About Key Generation Speed 2021-07-26 10:58:58 +02:00
Tony Arcieri
e4027b1b2b
rustfmt (#107)
Applies `rustfmt` (again) with the following version:

    rustfmt 1.4.37-stable (2a3635d5 2021-05-04)
2021-07-25 17:31:48 -07:00