Skip to content

Commit

Permalink
Use sequoia-openpgp with crypto-rust
Browse files Browse the repository at this point in the history
Fix use with didkit-wasm
  • Loading branch information
clehner committed Feb 16, 2022
1 parent b7d8969 commit 311183f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ clang
openssl-devel
```

If using feature `did-webkey/sequoia-openpgp` for PGP support, the following
If using feature `did-webkey/crypto-nettle` for PGP support with the nettle library, the following
dependencies are also needed:

```
Expand Down
18 changes: 4 additions & 14 deletions did-webkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ homepage = "https://github.com/spruceid/ssi/tree/main/did-webkey/"
documentation = "https://docs.rs/did-webkey/"

[features]
default = ["ssi/ring", "crypto-nettle"]
default = ["crypto-rust"]
crypto-cng = ["sequoia-openpgp/crypto-cng"]
crypto-rust = ["sequoia-openpgp/crypto-rust", "sequoia-openpgp/allow-experimental-crypto", "sequoia-openpgp/allow-variable-time-crypto"]
crypto-nettle = ["sequoia-openpgp/crypto-nettle"]
p256 = ["ssi/p256"]

[dependencies]
ssi = { version = "0.3", path = "../", default-features = false, features = [
"secp256r1",
] }
ssi = { version = "0.3", path = "../", default-features = false }
anyhow = "1.0.52"
async-trait = "0.1.52"
reqwest = { version = "0.11.9", features = ["json"] }
Expand All @@ -30,18 +29,9 @@ serde_json = "1.0.75"
serde = { version = "1.0.134", features = ["derive"] }
sshkeys = "0.3.1"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
sequoia-openpgp = { version = "1.7.0", features = [
"compression-deflate",
], default-features = false, optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
sequoia-openpgp = { version = "1.7.0", default-features = false, features = [
"crypto-rust",
"allow-experimental-crypto",
"allow-variable-time-crypto",
] }

], default-features = false }

[target.'cfg(target_os = "android")'.dependencies.reqwest]
version = "0.11.9"
Expand Down
8 changes: 1 addition & 7 deletions did-webkey/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ use async_trait::async_trait;
use serde::{Deserialize, Serialize};

use anyhow::{anyhow, Context, Result};
#[cfg(feature = "sequoia-openpgp")]
use openpgp::{
use sequoia_openpgp::{
cert::prelude::*,
parse::{PacketParser, Parse},
serialize::SerializeInto,
};
#[cfg(feature = "sequoia-openpgp")]
use sequoia_openpgp as openpgp;
use sshkeys::PublicKeyKind;
use ssi::did::{DIDMethod, Document, VerificationMethod, VerificationMethodMap, DIDURL};
use ssi::did_resolve::{
Expand Down Expand Up @@ -47,7 +44,6 @@ impl FromStr for DIDWebKeyType {
}
}

#[cfg(feature = "sequoia-openpgp")]
fn parse_pubkeys_gpg(
did: &str,
bytes: Vec<u8>,
Expand All @@ -66,7 +62,6 @@ fn parse_pubkeys_gpg(
Ok((vm_maps, did_urls))
}

#[cfg(feature = "sequoia-openpgp")]
fn gpg_pk_to_vm(did: &str, cert: Cert) -> Result<(VerificationMethodMap, DIDURL)> {
let vm_url = DIDURL {
did: did.to_string(),
Expand Down Expand Up @@ -473,7 +468,6 @@ mod tests {
}

#[tokio::test]
#[cfg(feature = "sequoia-openpgp")]
async fn from_did_webkey_gpg() {
let did_url: &str = "https://localhost/user.gpg";
let pubkeys: &str = include_str!("../tests/user.gpg");
Expand Down

0 comments on commit 311183f

Please sign in to comment.