316 Commits

Author SHA1 Message Date
Tony Arcieri
d0a755a354
Re-export signature crate (#223)
It's needed to use the `SigningKey`/`VerifyingKey` types in the
`pkcs1v15` and `pss` modules.

Also updates the code examples to use the re-export.
2022-11-13 20:25:44 -07:00
Tony Arcieri
6800df5b37
Linkify code examples in rustdoc (#222)
Makes each code example a linkable section of the rustdoc.

Uses these links to link from individual modules to code examples in the
toplevel rustdoc.
2022-11-12 18:43:30 -07:00
BrettMayson
b06a5ce300
Add public accessor methods for PrecomputedValues (#221) 2022-11-11 07:46:06 -07:00
Tony Arcieri
4f1d413845
v0.7.1 (#218) 2022-10-31 15:03:26 -06:00
Tony Arcieri
eeb18ee88d
Add missing rustdoc comments; enable missing_docs lint (#216)
Several types and methods were missing documentation.

This commit adds document and enables warnings for `missing_docs`.

Additionally it updates all references to PKCS#1 RFCs to use RFC8017,
which documents the latest version of PKCS#1.
2022-10-31 14:15:52 -06:00
Guillaume Desmottes
a857c8f785
padding: ensure PaddingScheme is Send and Sync (#215)
It's more convenient for users.

Fix #214
2022-10-24 13:27:35 -06:00
Tony Arcieri
942571f544
v0.7.0 (#211) 2022-10-10 12:15:14 -06:00
Dmitry Baryshkov
ece83cbdad
feat: add support for EncodePrivateKey (#208)
Implement encoding Signing keys to PKCS#8 DER format.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-10-08 14:38:43 -06:00
Tony Arcieri
8a1026b379
Add RsaPublicKey::new_unchecked (#206)
Constructor for `RsaPublicKey` which bypasses all checks around the
modulus and public exponent size.
2022-10-08 13:02:14 -06:00
Dmitry Baryshkov
9066931701
RSA: implement EncodePublicKey for VerifyingKeys (#207)
Implement key -> der conversion for public keys.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2022-10-08 13:01:19 -06:00
Dmitry Baryshkov
2cac57a360
feat: implement hazmat signature traits for PSS keys (#202)
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
Dirk Stolle
43127dc119
chore: extend Dependabot configuration for GitHub Actions updates (#198) 2022-10-05 17:53:17 -06:00
Dirk Stolle
7caba62e9b
chore: fix some typos (#196) 2022-10-05 17:52:57 -06:00
Dirk Stolle
ba0539e223
chore: update actions used in GitHub Actions workflows (#197) 2022-10-05 17:52:34 -06:00
Tony Arcieri
bfd17e2ec6
v0.7.0-rc.1 (#204) 2022-10-05 17:18:05 -06:00
Tony Arcieri
cfc27dc85c
Fix signature version requirement (#203)
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
Nathaniel McCallum
c880e5fed8
feat: enable extracting the inner key type (#201)
Signed-off-by: Nathaniel McCallum <nathaniel@profian.com>

Signed-off-by: Nathaniel McCallum <nathaniel@profian.com>
2022-09-27 15:42:36 -06:00
Nathaniel McCallum
6083c913f7
feat: derive(Debug, Copy) for pss::BlindedSigningKey (#200)
Signed-off-by: Nathaniel McCallum <nathaniel@profian.com>
2022-09-27 08:29:46 -06:00
Dmitry Baryshkov
165f06f9cd
feat: iplement hazmat signature traits for PKCS1v15 keys (#195)
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
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