38 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
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
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
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
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
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
cf27569687
Replace rand dependency with rand_core (#148) 2022-03-13 19:50:05 +00: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
89a527c05f
rustfmt (#105)
Applies `rustfmt` with the following version:

    rustfmt 1.4.37-stable (2a3635d5 2021-05-04)
2021-07-25 14:14:18 -07:00
Robin Lambertz
e8152949f9
feat: nostd, core+alloc support
* No-std support

* Fix tests

* Cleanly error out when building without the alloc feature

* Run no-std tests on arm-linux-gnu target

* Fix nostd tests

* Attempt 2 at fixing nostd tests

* Fix warnings when running tests in nostd mode

* fixup! No-std support
2020-08-07 22:39:36 +02:00
dignifiedquire
668e9ddfe4 apply CR 2020-04-10 14:34:25 +02:00
dignifiedquire
11500ed5e9 make oaep and pss generic over keys 2020-03-06 23:10:55 +01:00
dignifiedquire
167080e2a4 Merge remote-tracking branch 'origin/master' into oaep-dig 2020-03-06 22:49:57 +01:00
Jack Grigg
ff584d1bb8 pkcs1v15: Make decrypt() and sign() generic over PrivateKey 2020-03-07 09:46:48 +13:00
dignifiedquire
476f642075 Merge branch 'pss' into oaep-dig 2020-03-06 21:10:13 +01:00
Jack Grigg
ea2a3bfeb8 Introduce key::{PrivateKey, PublicKeyParts}
RSAPrivateKey no longer implements PublicKey. Instead,
RSAPublicKey::from(RSAPrivateKey) should be used to obtain a public key.
2020-03-06 18:05:57 +01:00
Jack Grigg
826ea30004 Introduce raw::{DecryptionPrimitive, EncryptionPrimitive} 2020-03-06 18:05:57 +01:00
roblabla
610c4cc95f Move copy_with_left_pad to algorithms 2019-09-26 14:49:59 +00:00
roblabla
30220cfd44 Fix the tests 2019-09-26 14:49:59 +00:00
roblabla
071f07f6c8 Avoid using vectors to store the asn1 prefixes 2019-09-26 14:49:59 +00:00
roblabla
2462f1dd56 Remove PublicKey trait, use deref.
Removes the PublicKey trait, using Deref to provide the RSAPublicKey
methods to RSAPrivateKey.
2019-09-26 14:49:59 +00:00
roblabla
5d28baf32a Implement PSS 2019-09-26 14:49:59 +00:00
dignifiedquire
021ae799da feat: implement zeroing using the zeroize crate 2019-03-26 14:53:53 +01:00
phayes
bbd63fbba4
Switch to using for all crate level uses 2019-03-18 09:29:05 -07:00
Patrick D Hayes
1703482ba9 feat: split (un)blind into their own functions, exposing raw RSA functions via internals module
* Splitting blind and unblind into their own functions
* Adding public functions to private-key for blinding and unblinding
* Re-exporting raw RSA functions into a 'danger' module
* Better documentation
* Typos and grammar
* Updating as per suggestions, moving things into an 'internals' module which is optionally made public
* We blind and unblind using n and e, so public key is sufficient
2019-03-16 10:30:32 +01:00
dignifiedquire
f99d2160c1 chore: update dependencies 2019-02-20 18:50:46 +01:00
dignifiedquire
fe7c5105fb feat: use BigUint to represent the exponent 2018-11-08 18:17:59 +01:00
dignifiedquire
4d046fa70e chore: some code cleanup from clippy 2018-11-07 14:28:16 +01:00
dignifiedquire
73cbdd7c0d fix: proper error handling 2018-07-24 23:46:58 +02:00
dignifiedquire
f6f909d344 feat: implement pkcs1v15 signature verification 2018-07-24 22:04:41 +02:00
dignifiedquire
79bb8fa9b3 test(bench): add decrypt and sign benchmarks 2018-07-24 15:09:03 +02:00
dignifiedquire
3943cd44fb feat: implemen pkcs1v15 signing 2018-07-24 14:31:06 +02:00
dignifiedquire
6d2b756864 feat: implement pkcs1v15 encryption and decryption 2018-07-24 01:01:44 +02:00