Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(identity): allow importing and exporting ECDSA keys #3863

Merged
merged 40 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7d5e606
feat: make mdns::Event clone-able
drHuangMHT Mar 13, 2023
05ce438
Merge branch 'libp2p:master' into master
Mar 13, 2023
a72e5e2
docs: filling CHANGELOG for PR 3606
drHuangMHT Mar 13, 2023
09bef20
Merge branch 'master' of https://github.com/drHuangMHT/rust-libp2p
drHuangMHT Mar 13, 2023
926c7ca
Update protocols/mdns/CHANGELOG.md
thomaseizinger Mar 13, 2023
49d26c4
Update protocols/mdns/CHANGELOG.md
thomaseizinger Mar 13, 2023
4a35406
Merge branch 'master' into master
mergify[bot] Mar 13, 2023
a8ff1eb
feat: change 'mdns::Event' to hold 'SmallVec'
drHuangMHT Mar 16, 2023
4cec5fa
test: adapting test to 'mdns::Event' change
drHuangMHT Mar 16, 2023
a876f2f
Merge branch 'master' of https://github.com/drHuangMHT/rust-libp2p
drHuangMHT Mar 16, 2023
18811d2
feat(mdns): change 'mdns::Event' to hold 'Vec'
drHuangMHT Mar 16, 2023
abdce7e
doc: add entry for #3621
drHuangMHT Mar 16, 2023
d5c246c
Update protocols/mdns/CHANGELOG.md
Mar 16, 2023
ed128a7
Merge branch 'master' of https://github.com/drHuangMHT/rust-libp2p
drHuangMHT Mar 26, 2023
0d06f4c
Merge branch 'master' of https://github.com/drHuangMHT/rust-libp2p
drHuangMHT Mar 26, 2023
9d45cf3
Remove conflict marker to resolve conflicts
drHuangMHT Mar 26, 2023
752002b
Merge branch 'master' of https://github.com/drHuangMHT/rust-libp2p
drHuangMHT Apr 11, 2023
05ed0ef
Merge branch 'master' of https://github.com/libp2p/rust-libp2p
drHuangMHT Apr 14, 2023
7cf5556
Update protocols/mdns/CHANGELOG.md
thomaseizinger Apr 14, 2023
3602c76
Merge remote-tracking branch 'upstream/master'
drHuangMHT May 2, 2023
cc9eb65
Merge branch 'master' into master
drHuangMHT May 2, 2023
7b6c9dc
implement 'encode_pkcs8_der' for 'ecdsa::SecretKey'
drHuangMHT May 2, 2023
ad42397
Merge branch 'libp2p:master' into ecdsa-impl
May 2, 2023
8ec8263
bump 'p256' from 0.12 to 0.13
drHuangMHT May 2, 2023
cc32b12
implement 'try_decode_pkcs8_der' for 'ecdsa::SecretKey'
drHuangMHT May 2, 2023
4329dc0
changelog entry for #3863
drHuangMHT May 2, 2023
a788cbb
Merge branch 'ecdsa-impl' of https://github.com/drHuangMHT/rust-libp2…
drHuangMHT May 2, 2023
412d31f
Merge branch 'master' into ecdsa-impl
drHuangMHT May 2, 2023
37e663f
encode/decode roundtrip test
drHuangMHT May 2, 2023
8af2ca5
change visibility of en/decode method to crate-level only
drHuangMHT May 3, 2023
7828552
implement protobuf en/decode for ecdsa keys
drHuangMHT May 3, 2023
5efbcb0
correct feature configuration
drHuangMHT May 3, 2023
af8c068
fix: buffer not zeroized upon successful secret key decoding
drHuangMHT May 3, 2023
26bc0f6
Update identity/CHANGELOG.md
May 3, 2023
1c8d282
protobuf roundtrip test for ecdsa keys
drHuangMHT May 3, 2023
0c5c08d
Fix feature gates in test
thomaseizinger May 3, 2023
6c92bb3
Replace with correct test vector
thomaseizinger May 3, 2023
3d850d0
drop pkcs8 and provide der support
drHuangMHT May 4, 2023
11b26fa
update test vector for ecdsa
drHuangMHT May 4, 2023
d08e965
Merge branch 'master' into ecdsa-impl
mergify[bot] May 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion identity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ libsecp256k1 = { version = "0.7.0", optional = true }
log = "0.4"
multiaddr = { version = "0.17.1", optional = true }
multihash = { version = "0.17.0", default-features = false, features = ["std"], optional = true }
p256 = { version = "0.12", default-features = false, features = ["ecdsa", "std"], optional = true }
p256 = { version = "0.12", default-features = false, features = ["ecdsa", "std", "pem"], optional = true }
quick-protobuf = { version = "0.8.1", optional = true }
rand = { version = "0.8", optional = true }
sec1 = { version = "0.3.0", features = ["std"], optional = true } # Activate `std` feature until https://github.com/RustCrypto/traits/pull/1131 is released.
Expand Down
18 changes: 18 additions & 0 deletions identity/src/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use super::error::DecodingError;
use core::cmp;
use core::fmt;
use core::hash;
use p256::pkcs8::EncodePrivateKey;
use p256::{
ecdsa::{
signature::{Signer, Verifier},
Expand Down Expand Up @@ -122,6 +123,23 @@ impl SecretKey {
.map_err(|err| DecodingError::failed_to_parse("ecdsa p256 secret key", err))
.map(SecretKey)
}

/// Encode the secret key into DER-encoded PKCS#8 format.
pub fn encode_pkcs8_der(&self) -> Vec<u8> {
self.0
.to_pkcs8_der()
.expect("Encoding to pkcs#8 format to succeed")
.to_bytes()
.to_vec()
}

// Cannot implement this because error type does not implement `std::error::Error`
// pub fn try_decode_pkcs8_der(buf:&[u8])->Result<Self,DecodingError>{
// match SigningKey::from_pkcs8_der(buf){
// Ok(key) => Ok(SecretKey(key)),
// Err(e) => Err(DecodingError::failed_to_parse("ECDSA", e)),
// }
// }
}

impl fmt::Debug for SecretKey {
Expand Down