Skip to content

Commit

Permalink
fix pkcs8 api break
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo committed Sep 7, 2024
1 parent 4781762 commit 30925d9
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 32 deletions.
37 changes: 21 additions & 16 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ members = [

[profile.dev]
opt-level = 2

[patch.crates-io]
ecdsa = { git = "https://github.com/RustCrypto/signatures.git" }
rfc6979 = { git = "https://github.com/RustCrypto/signatures.git" }
2 changes: 1 addition & 1 deletion bign256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.6", features = ["sec1"] }
elliptic-curve = { version = "0.14.0-rc.0", features = ["sec1"] }

# optional dependencies
belt-hash = { version = "=0.2.0-pre.4", optional = true, default-features = false }
Expand Down
14 changes: 9 additions & 5 deletions bign256/src/secret_key.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Bign256 secret key.

use core::str::FromStr;
use der::SecretDocument;
use der::{asn1::OctetStringRef, SecretDocument};

use elliptic_curve::{array::typenum::Unsigned, zeroize::Zeroizing, Error};
use pkcs8::{
Expand Down Expand Up @@ -129,14 +129,15 @@ impl AssociatedAlgorithmIdentifier for SecretKey {
};
}

impl TryFrom<pkcs8::PrivateKeyInfo<'_>> for SecretKey {
impl TryFrom<pkcs8::PrivateKeyInfoRef<'_>> for SecretKey {
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_oids(ALGORITHM_OID, BignP256::OID)?;
Self::from_slice(private_key_info.private_key).map_err(|_| pkcs8::Error::KeyMalformed)
Self::from_slice(private_key_info.private_key.as_bytes())
.map_err(|_| pkcs8::Error::KeyMalformed)
}
}

Expand All @@ -156,7 +157,10 @@ impl EncodePrivateKey for SecretKey {
};

let ec_private_key = self.to_bytes();
let pkcs8_key = pkcs8::PrivateKeyInfo::new(algorithm_identifier, &ec_private_key);
let pkcs8_key = pkcs8::PrivateKeyInfoRef::new(
algorithm_identifier,
OctetStringRef::new(&ec_private_key)?,
);
Ok(SecretDocument::encode_msg(&pkcs8_key)?)
}
}
2 changes: 1 addition & 1 deletion bp256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.6", default-features = false, features = ["sec1"] }
elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] }

# optional dependencies
ecdsa = { version = "=0.17.0-pre.7", optional = true, default-features = false, features = ["der"] }
Expand Down
2 changes: 1 addition & 1 deletion bp384/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.6", default-features = false, features = ["sec1"] }
elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] }

# optional dependencies
ecdsa = { version = "=0.17.0-pre.7", optional = true, default-features = false, features = ["der"] }
Expand Down
2 changes: 1 addition & 1 deletion k256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ rust-version = "1.73"

[dependencies]
cfg-if = "1.0"
elliptic-curve = { version = "=0.14.0-pre.6", default-features = false, features = ["sec1"] }
elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] }

# optional dependencies
once_cell = { version = "1.19", optional = true, default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion p192/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.6", default-features = false, features = ["sec1"] }
elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] }
sec1 = { version = "0.8.0-rc.0", default-features = false }

# optional dependencies
Expand Down
2 changes: 1 addition & 1 deletion p224/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.6", default-features = false, features = ["sec1"] }
elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] }

# optional dependencies
ecdsa-core = { version = "=0.17.0-pre.7", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
Expand Down
2 changes: 1 addition & 1 deletion p256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.6", default-features = false, features = ["sec1"] }
elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] }

# optional dependencies
ecdsa-core = { version = "=0.17.0-pre.7", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
Expand Down
2 changes: 1 addition & 1 deletion p384/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.6", default-features = false, features = ["sec1"] }
elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] }

# optional dependencies
ecdsa-core = { version = "=0.17.0-pre.7", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
Expand Down
2 changes: 1 addition & 1 deletion p521/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rust-version = "1.73"

[dependencies]
base16ct = "0.2"
elliptic-curve = { version = "=0.14.0-pre.6", default-features = false, features = ["sec1"] }
elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] }

# optional dependencies
ecdsa-core = { version = "=0.17.0-pre.7", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
Expand Down
2 changes: 1 addition & 1 deletion primeorder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.6", default-features = false, features = ["arithmetic", "sec1"] }
elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["arithmetic", "sec1"] }

# optional dependencies
serdect = { version = "0.2", optional = true, default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion sm2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.6", default-features = false, features = ["sec1"] }
elliptic-curve = { version = "0.14.0-rc.0", default-features = false, features = ["sec1"] }

# optional dependencies
primeorder = { version = "=0.14.0-pre.1", optional = true, path = "../primeorder" }
Expand Down

0 comments on commit 30925d9

Please sign in to comment.