Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into const-crypto-biguint
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Nov 6, 2024
2 parents 74d3197 + 8797ee2 commit ea2236d
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 58 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
rust:
- 1.73.0 # MSRV
- 1.81.0 # MSRV
- stable
target:
- thumbv7em-none-eabi
Expand All @@ -35,7 +35,7 @@ jobs:
strategy:
matrix:
rust:
- 1.73.0 # MSRV
- 1.81.0 # MSRV
- stable
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -65,6 +65,6 @@ jobs:
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2023-10-01
- run: cargo test --release
toolchain: nightly-2024-10-06
- run: cargo test --release --features nightly
- run: cargo build --benches
2 changes: 1 addition & 1 deletion .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.79.0
toolchain: 1.81.0
components: clippy
- run: cargo clippy --all -- -D warnings

Expand Down
70 changes: 34 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rsa"
version = "0.10.0-pre.2"
version = "0.10.0-pre.3"
authors = ["RustCrypto Developers", "dignifiedquire <[email protected]>"]
edition = "2021"
description = "Pure Rust RSA implementation"
Expand All @@ -10,17 +10,17 @@ repository = "https://github.com/RustCrypto/RSA"
keywords = ["rsa", "encryption", "security", "crypto"]
categories = ["cryptography"]
readme = "README.md"
rust-version = "1.73"
rust-version = "1.81"

[dependencies]
rand_core = { version = "0.6.4", default-features = false }
const-oid = { version = "=0.10.0-rc.0", default-features = false }
subtle = { version = "2.6.1", default-features = false }
digest = { version = "=0.11.0-pre.9", default-features = false, features = ["alloc", "oid"] }
pkcs1 = { version = "=0.8.0-rc.0", default-features = false, features = ["alloc", "pkcs8"] }
pkcs8 = { version = "=0.11.0-rc.0", default-features = false, features = ["alloc"] }
signature = { version = "=2.3.0-pre.4", default-features = false , features = ["alloc", "digest", "rand_core"] }
spki = { version = "=0.8.0-rc.0", default-features = false, features = ["alloc"] }
pkcs1 = { version = "0.8.0-rc.0", default-features = false, features = ["alloc", "pkcs8"] }
pkcs8 = { version = "0.11.0-rc.0", default-features = false, features = ["alloc"] }
signature = { version = "=2.3.0-pre.4", default-features = false, features = ["alloc", "digest", "rand_core"] }
spki = { version = "0.8.0-rc.1", default-features = false, features = ["alloc"] }
zeroize = { version = "1.5", features = ["alloc"] }
crypto-bigint = { version = "0.6.0-rc.2", default-features = false, features = ["zeroize", "alloc"] }
crypto-primes = { version = "0.6.0-pre.0" }
Expand Down Expand Up @@ -67,5 +67,8 @@ opt-level = 2
debug = true

[patch.crates-io]
pkcs1 = { git = "https://github.com/RustCrypto/formats.git" }
pkcs8 = { git = "https://github.com/RustCrypto/formats.git" }

# crypto-bigint = { git = "https://github.com/RustCrypto/crypto-bigint", branch = "master" }
# crypto-bigint = { path = "../rustcrypto/crypto-bigint" }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ dual licensed as above, without any additional terms or conditions.
[//]: # (badges)
[crate-image]: https://buildstats.info/crate/rsa
[crate-image]: https://img.shields.io/crates/v/rsa
[crate-link]: https://crates.io/crates/rsa
[doc-image]: https://docs.rs/rsa/badge.svg
[doc-link]: https://docs.rs/rsa
Expand Down
13 changes: 9 additions & 4 deletions src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use crate::{
use core::convert::{TryFrom, TryInto};
use crypto_bigint::{BoxedUint, NonZero, Odd};
use pkcs8::{
der::Encode, Document, EncodePrivateKey, EncodePublicKey, ObjectIdentifier, SecretDocument,
der::{asn1::OctetStringRef, Encode},
Document, EncodePrivateKey, EncodePublicKey, ObjectIdentifier, SecretDocument,
};
use zeroize::Zeroizing;

Expand Down Expand Up @@ -38,10 +39,10 @@ pub(crate) fn verify_algorithm_id(
Ok(())
}

impl TryFrom<pkcs8::PrivateKeyInfo<'_>> for RsaPrivateKey {
impl TryFrom<pkcs8::PrivateKeyInfoRef<'_>> for RsaPrivateKey {
type Error = pkcs8::Error;

fn try_from(private_key_info: pkcs8::PrivateKeyInfo<'_>) -> pkcs8::Result<Self> {
fn try_from(private_key_info: pkcs8::PrivateKeyInfoRef<'_>) -> pkcs8::Result<Self> {
verify_algorithm_id(&private_key_info.algorithm)?;

let pkcs1_key = pkcs1::RsaPrivateKey::try_from(private_key_info.private_key)?;
Expand Down Expand Up @@ -149,7 +150,11 @@ impl EncodePrivateKey for RsaPrivateKey {
}
.to_der()?;

pkcs8::PrivateKeyInfo::new(pkcs1::ALGORITHM_ID, private_key.as_ref()).try_into()
pkcs8::PrivateKeyInfoRef::new(
pkcs1::ALGORITHM_ID,
OctetStringRef::new(private_key.as_ref())?,
)
.try_into()
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/pkcs1v15/signing_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,13 @@ where
};
}

impl<D> TryFrom<pkcs8::PrivateKeyInfo<'_>> for SigningKey<D>
impl<D> TryFrom<pkcs8::PrivateKeyInfoRef<'_>> for SigningKey<D>
where
D: Digest + AssociatedOid,
{
type Error = pkcs8::Error;

fn try_from(private_key_info: pkcs8::PrivateKeyInfo<'_>) -> pkcs8::Result<Self> {
fn try_from(private_key_info: pkcs8::PrivateKeyInfoRef<'_>) -> pkcs8::Result<Self> {
private_key_info
.algorithm
.assert_algorithm_oid(pkcs1::ALGORITHM_OID)?;
Expand Down
4 changes: 2 additions & 2 deletions src/pss/blinded_signing_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ where
}
}

impl<D> TryFrom<pkcs8::PrivateKeyInfo<'_>> for BlindedSigningKey<D>
impl<D> TryFrom<pkcs8::PrivateKeyInfoRef<'_>> for BlindedSigningKey<D>
where
D: Digest + AssociatedOid,
{
type Error = pkcs8::Error;

fn try_from(private_key_info: pkcs8::PrivateKeyInfo<'_>) -> pkcs8::Result<Self> {
fn try_from(private_key_info: pkcs8::PrivateKeyInfoRef<'_>) -> pkcs8::Result<Self> {
RsaPrivateKey::try_from(private_key_info).map(Self::new)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/pss/signing_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ where
}
}

impl<D> TryFrom<pkcs8::PrivateKeyInfo<'_>> for SigningKey<D>
impl<D> TryFrom<pkcs8::PrivateKeyInfoRef<'_>> for SigningKey<D>
where
D: Digest + AssociatedOid,
{
type Error = pkcs8::Error;

fn try_from(private_key_info: pkcs8::PrivateKeyInfo<'_>) -> pkcs8::Result<Self> {
fn try_from(private_key_info: pkcs8::PrivateKeyInfoRef<'_>) -> pkcs8::Result<Self> {
verify_algorithm_id(&private_key_info.algorithm)?;
RsaPrivateKey::try_from(private_key_info).map(Self::new)
}
Expand Down
5 changes: 5 additions & 0 deletions src/pss/verifying_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ where
phantom: Default::default(),
}
}

/// Return specified salt length for this key
pub fn salt_len(&self) -> usize {
self.salt_len
}
}

//
Expand Down

0 comments on commit ea2236d

Please sign in to comment.