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>
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>
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>
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>
- 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>
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`.
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>
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>
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
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
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.
- Fixes some broken links to the `pkcs1`/`pkcs8` crate traits
- Fixes other rustdoc warnings
- Adds rustdoc CI job to ensure docs build without warnings
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`
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.