Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ name = 'routing'

[package]
name = 'didcomm'
version = '0.3.2'
version = '0.3.3'
authors = ['Vyacheslav Gudkov <vyacheslav.gudkov@dsr-corporation.com>']
edition = '2018'
description = 'DIDComm for Rust'
Expand Down
23 changes: 23 additions & 0 deletions Specs/DidcommSDK/0.3.3/DidcommSDK.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Pod::Spec.new do |spec|

spec.name = "DidcommSDK"
spec.version = "0.3.3"
spec.summary = "Didcomm v2 created from rust."

spec.description = "Didcomm v2 created from rust. UNIFFI was used to convert from rust to Swift."
spec.homepage = "https://github.com/sicpa-dlab/didcomm-rust"

spec.license = { :type => 'Apache License 2.0', :file => 'LICENSE.txt' }

spec.authors = { "Sicpa-Dlab" => "dlab@sicpa.com" }
spec.platforms = { :ios => "10.0" }
spec.source = { :http => 'https://github.com/sicpa-dlab/didcomm-rust/releases/download/v0.3.3/didcomm-swift-0.3.3.tar.gz'}
spec.swift_version = '4.0'

spec.ios.vendored_library = '*.a'
spec.source_files = ['didcomm.swift', 'didcommFFI.h']

spec.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64 i386' }
spec.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64 i386' }

end
3 changes: 2 additions & 1 deletion src/jwe/encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use askar_crypto::{
random,
repr::{KeyGen, ToSecretBytes},
};
use std::borrow::Cow;

use sha2::{Digest, Sha256};

Expand Down Expand Up @@ -50,7 +51,7 @@ where
let apv = base64::encode_config(apv, base64::URL_SAFE_NO_PAD);

let p = ProtectedHeader {
typ: Some("application/didcomm-encrypted+json"),
typ: Some(Cow::Borrowed("application/didcomm-encrypted+json")),
alg: alg.clone(),
enc,
skid,
Expand Down
3 changes: 2 additions & 1 deletion src/jwe/envelope.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use serde_enum_str::{Deserialize_enum_str, Serialize_enum_str};
use serde_json::Value;
use std::borrow::Cow;

/// Subset of JWE in generic json serialization form used for authcrypt
/// and anoncrypt message types.
Expand Down Expand Up @@ -29,7 +30,7 @@ pub(crate) struct ProtectedHeader<'a> {
/// Must be `application/didcomm-encrypted+json` or `didcomm-encrypted+json` for now.
/// Something like `application/didcomm-encrypted+cbor` can be introduced in the
/// future.
pub typ: Option<&'a str>,
pub typ: Option<Cow<'a, str>>,

/// Cryptographic algorithm used to encrypt or determine the value of the CEK.
pub alg: Algorithm,
Expand Down
17 changes: 9 additions & 8 deletions src/jwe/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ impl<'a, 'b> ParsedJWE<'a, 'b> {
#[cfg(test)]
mod tests {
use serde_json::json;
use std::borrow::Cow;

use crate::{
error::ErrorKind,
Expand Down Expand Up @@ -158,7 +159,7 @@ mod tests {
tag: "6ylC_iAs4JvDQzXeY6MuYQ",
},
protected: ProtectedHeader {
typ: Some("application/didcomm-encrypted+json"),
typ: Some(Cow::Borrowed("application/didcomm-encrypted+json")),
alg: jwe::envelope::Algorithm::EcdhEsA256kw,
enc: EncAlgorithm::Xc20P,
skid: None,
Expand Down Expand Up @@ -235,7 +236,7 @@ mod tests {
tag: "6ylC_iAs4JvDQzXeY6MuYQ",
},
protected: ProtectedHeader {
typ: Some("application/didcomm-encrypted+json"),
typ: Some(Cow::Borrowed("application/didcomm-encrypted+json")),
alg: jwe::envelope::Algorithm::EcdhEsA256kw,
enc: EncAlgorithm::Xc20P,
skid: None,
Expand Down Expand Up @@ -311,7 +312,7 @@ mod tests {
tag: "6ylC_iAs4JvDQzXeY6MuYQ",
},
protected: ProtectedHeader {
typ: Some("application/didcomm-encrypted+json"),
typ: Some(Cow::Borrowed("application/didcomm-encrypted+json")),
alg: jwe::envelope::Algorithm::EcdhEsA256kw,
enc: EncAlgorithm::Xc20P,
skid: None,
Expand Down Expand Up @@ -387,7 +388,7 @@ mod tests {
tag: "uYeo7IsZjN7AnvBjUZE5lNryNENbf6_zew_VC-d4b3U",
},
protected: ProtectedHeader {
typ: Some("application/didcomm-encrypted+json"),
typ: Some(Cow::Borrowed("application/didcomm-encrypted+json")),
alg: jwe::envelope::Algorithm::Ecdh1puA256kw,
enc: EncAlgorithm::A256cbcHs512,
skid: Some("did:example:alice#key-x25519-1"),
Expand Down Expand Up @@ -464,7 +465,7 @@ mod tests {
tag: "uYeo7IsZjN7AnvBjUZE5lNryNENbf6_zew_VC-d4b3U",
},
protected: ProtectedHeader {
typ: Some("application/didcomm-encrypted+json"),
typ: Some(Cow::Borrowed("application/didcomm-encrypted+json")),
alg: jwe::envelope::Algorithm::Ecdh1puA256kw,
enc: EncAlgorithm::A256cbcHs512,
skid: Some("did:example:alice#key-x25519-1"),
Expand Down Expand Up @@ -540,7 +541,7 @@ mod tests {
tag: "uYeo7IsZjN7AnvBjUZE5lNryNENbf6_zew_VC-d4b3U",
},
protected: ProtectedHeader {
typ: Some("application/didcomm-encrypted+json"),
typ: Some(Cow::Borrowed("application/didcomm-encrypted+json")),
alg: jwe::envelope::Algorithm::Ecdh1puA256kw,
enc: EncAlgorithm::A256cbcHs512,
skid: Some("did:example:alice#key-x25519-1"),
Expand Down Expand Up @@ -965,7 +966,7 @@ mod tests {
tag: "6ylC_iAs4JvDQzXeY6MuYQ",
},
protected: ProtectedHeader {
typ: Some("application/didcomm-encrypted+json"),
typ: Some(Cow::Borrowed("application/didcomm-encrypted+json")),
alg: jwe::envelope::Algorithm::EcdhEsA256kw,
enc: EncAlgorithm::Xc20P,
skid: None,
Expand Down Expand Up @@ -1044,7 +1045,7 @@ mod tests {
tag: "uYeo7IsZjN7AnvBjUZE5lNryNENbf6_zew_VC-d4b3U",
},
protected: ProtectedHeader {
typ: Some("application/didcomm-encrypted+json"),
typ: Some(Cow::Borrowed("application/didcomm-encrypted+json")),
alg: jwe::envelope::Algorithm::Ecdh1puA256kw,
enc: EncAlgorithm::A256cbcHs512,
skid: Some("did:example:alice#key-x25519-1"),
Expand Down
3 changes: 2 additions & 1 deletion src/jws/envelope.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use askar_crypto::sign::SignatureType;
use serde::{Deserialize, Serialize};
use serde_enum_str::{Deserialize_enum_str, Serialize_enum_str};
use std::borrow::Cow;

use crate::error::{err_msg, ErrorKind, Result};

Expand Down Expand Up @@ -37,7 +38,7 @@ pub(crate) struct ProtectedHeader<'a> {
/// Must be `application/didcomm-signed+json` or `didcomm-signed+json` for now.
/// Something like `application/didcomm-signed+cbor` can be introduced in the
/// future.
pub typ: &'a str,
pub typ: Cow<'a, str>,

/// Cryptographic algorithm used to produce signature.
pub alg: Algorithm,
Expand Down
11 changes: 6 additions & 5 deletions src/jws/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ mod tests {
ParsedJWS,
},
};
use std::borrow::Cow;

#[test]
fn parse_works() {
Expand Down Expand Up @@ -131,7 +132,7 @@ mod tests {
payload: "eyJpZCI6IjEyMzQ1Njc4OTAiLCJ0eXAiOiJhcHBsaWNhdGlvbi9kaWRjb21tLXBsYWluK2pzb24iLCJ0eXBlIjoiaHR0cDovL2V4YW1wbGUuY29tL3Byb3RvY29scy9sZXRzX2RvX2x1bmNoLzEuMC9wcm9wb3NhbCIsImZyb20iOiJkaWQ6ZXhhbXBsZTphbGljZSIsInRvIjpbImRpZDpleGFtcGxlOmJvYiJdLCJjcmVhdGVkX3RpbWUiOjE1MTYyNjkwMjIsImV4cGlyZXNfdGltZSI6MTUxNjM4NTkzMSwiYm9keSI6eyJtZXNzYWdlc3BlY2lmaWNhdHRyaWJ1dGUiOiJhbmQgaXRzIHZhbHVlIn19",
},
protected: vec![ProtectedHeader {
typ: "application/didcomm-signed+json",
typ: Cow::Borrowed("application/didcomm-signed+json"),
alg: Algorithm::EdDSA,
}],
};
Expand Down Expand Up @@ -171,7 +172,7 @@ mod tests {
payload: "eyJpZCI6IjEyMzQ1Njc4OTAiLCJ0eXAiOiJhcHBsaWNhdGlvbi9kaWRjb21tLXBsYWluK2pzb24iLCJ0eXBlIjoiaHR0cDovL2V4YW1wbGUuY29tL3Byb3RvY29scy9sZXRzX2RvX2x1bmNoLzEuMC9wcm9wb3NhbCIsImZyb20iOiJkaWQ6ZXhhbXBsZTphbGljZSIsInRvIjpbImRpZDpleGFtcGxlOmJvYiJdLCJjcmVhdGVkX3RpbWUiOjE1MTYyNjkwMjIsImV4cGlyZXNfdGltZSI6MTUxNjM4NTkzMSwiYm9keSI6eyJtZXNzYWdlc3BlY2lmaWNhdHRyaWJ1dGUiOiJhbmQgaXRzIHZhbHVlIn19",
},
protected: vec![ProtectedHeader {
typ: "application/didcomm-signed+json",
typ: Cow::Borrowed("application/didcomm-signed+json"),
alg: Algorithm::EdDSA,
}],
};
Expand Down Expand Up @@ -210,7 +211,7 @@ mod tests {
payload: "eyJpZCI6IjEyMzQ1Njc4OTAiLCJ0eXAiOiJhcHBsaWNhdGlvbi9kaWRjb21tLXBsYWluK2pzb24iLCJ0eXBlIjoiaHR0cDovL2V4YW1wbGUuY29tL3Byb3RvY29scy9sZXRzX2RvX2x1bmNoLzEuMC9wcm9wb3NhbCIsImZyb20iOiJkaWQ6ZXhhbXBsZTphbGljZSIsInRvIjpbImRpZDpleGFtcGxlOmJvYiJdLCJjcmVhdGVkX3RpbWUiOjE1MTYyNjkwMjIsImV4cGlyZXNfdGltZSI6MTUxNjM4NTkzMSwiYm9keSI6eyJtZXNzYWdlc3BlY2lmaWNhdHRyaWJ1dGUiOiJhbmQgaXRzIHZhbHVlIn19",
},
protected: vec![ProtectedHeader {
typ: "application/didcomm-signed+json",
typ: Cow::Borrowed("application/didcomm-signed+json"),
alg: Algorithm::EdDSA,
}],
};
Expand Down Expand Up @@ -264,11 +265,11 @@ mod tests {
},
protected: vec![
ProtectedHeader {
typ: "application/didcomm-signed+json",
typ: Cow::Borrowed("application/didcomm-signed+json"),
alg: Algorithm::EdDSA,
},
ProtectedHeader {
typ: "application/didcomm-signed+json",
typ: Cow::Borrowed("application/didcomm-signed+json"),
alg: Algorithm::EdDSA,
}
],
Expand Down
3 changes: 2 additions & 1 deletion src/jws/sign.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use askar_crypto::sign::KeySign;
use std::borrow::Cow;

use crate::{
error::{ErrorKind, Result, ResultExt},
Expand All @@ -16,7 +17,7 @@ pub(crate) fn sign<Key: KeySign>(

let protected = {
let protected = ProtectedHeader {
typ: "application/didcomm-signed+json",
typ: Cow::Borrowed("application/didcomm-signed+json"),
alg,
};

Expand Down
7 changes: 4 additions & 3 deletions src/message/pack_encrypted/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ pub struct MessagingServiceMetadata {

#[cfg(test)]
mod tests {
use std::borrow::Cow;
use std::{collections::HashMap, iter::FromIterator};

use askar_crypto::{
Expand Down Expand Up @@ -2854,7 +2855,7 @@ mod tests {

assert_eq!(
msg.protected.typ,
Some("application/didcomm-encrypted+json")
Some(Cow::Borrowed("application/didcomm-encrypted+json"))
);

assert_eq!(msg.protected.alg, jwe::Algorithm::Ecdh1puA256kw);
Expand Down Expand Up @@ -2922,7 +2923,7 @@ mod tests {

assert_eq!(
msg.protected.typ,
Some("application/didcomm-encrypted+json")
Some(Cow::Borrowed("application/didcomm-encrypted+json"))
);

assert_eq!(msg.protected.alg, jwe::Algorithm::EcdhEsA256kw);
Expand Down Expand Up @@ -2968,7 +2969,7 @@ mod tests {
assert_eq!(
msg.protected,
vec![jws::ProtectedHeader {
typ: "application/didcomm-signed+json",
typ: Cow::Borrowed("application/didcomm-signed+json"),
alg,
}]
);
Expand Down
3 changes: 2 additions & 1 deletion src/message/pack_signed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ mod tests {
alg::{ed25519::Ed25519KeyPair, k256::K256KeyPair, p256::P256KeyPair},
sign::KeySigVerify,
};
use std::borrow::Cow;

use serde_json::Value;

Expand Down Expand Up @@ -245,7 +246,7 @@ mod tests {
assert_eq!(
msg.protected,
vec![ProtectedHeader {
typ: "application/didcomm-signed+json",
typ: Cow::Borrowed("application/didcomm-signed+json"),
alg,
}]
);
Expand Down
2 changes: 1 addition & 1 deletion uniffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'didcomm-uniffi'
version = '0.3.2'
version = '0.3.3'
authors = ['Vyacheslav Gudkov <vyacheslav.gudkov@dsr-corporation.com>']
edition = '2018'
description = 'FFI wrapper for DIDComm'
Expand Down
2 changes: 1 addition & 1 deletion wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'didcomm-js'
version = '0.3.2'
version = '0.3.3'
authors = ['Vyacheslav Gudkov <vyacheslav.gudkov@dsr-corporation.com>']
edition = '2018'
description = 'WASM based javascript wrapper for DIDComm'
Expand Down
2 changes: 1 addition & 1 deletion wasm/demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "didcomm-demo",
"version": "0.3.2",
"version": "0.3.3",
"description": "JS demo for didcomm",
"scripts": {
"start": "ts-node src/main.ts",
Expand Down
2 changes: 1 addition & 1 deletion wasm/tests-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "didcomm-tests",
"version": "0.3.2",
"version": "0.3.3",
"description": "JS tests for didcomm",
"scripts": {
"test": "jest",
Expand Down