From ecde6ffce6ad07c1ccb1c9d2257a3f7650189afc Mon Sep 17 00:00:00 2001 From: Zeeshan Lakhani Date: Mon, 28 Nov 2022 23:39:11 -0500 Subject: [PATCH] chore: rsa dep changes (#58) BREAKING CHANGE: New version requirements include rsa@0.7 --- .github/dependabot.yml | 6 +++--- ucan-key-support/Cargo.toml | 4 ++-- ucan-key-support/src/rsa.rs | 17 +++++------------ ucan-key-support/src/web_crypto.rs | 2 +- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2bee4199..e8a829d4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,7 @@ updates: - package-ecosystem: "cargo" directory: "/ucan" commit-message: - prefix: "chore(deps)" + prefix: "chore" include: "scope" target-branch: "main" schedule: @@ -20,7 +20,7 @@ updates: - package-ecosystem: "cargo" directory: "/ucan-key-support" commit-message: - prefix: "chore(deps)" + prefix: "chore" include: "scope" target-branch: "main" schedule: @@ -31,7 +31,7 @@ updates: - package-ecosystem: "github-actions" directory: "/" commit-message: - prefix: "chore(ci-deps)" + prefix: "chore(ci)" include: "scope" target-branch: "main" schedule: diff --git a/ucan-key-support/Cargo.toml b/ucan-key-support/Cargo.toml index 864d27b8..41b9e64c 100644 --- a/ucan-key-support/Cargo.toml +++ b/ucan-key-support/Cargo.toml @@ -25,8 +25,8 @@ async-trait = "0.1" bs58 = "0.4" ed25519-zebra = "3.1" log = "0.4" -rsa = "0.6" -sha2 = "0.10" +rsa = "0.7" +sha2 = { version = "0.10", features = ["oid"] } ucan = { path = "../ucan", version = "0.7.0-alpha.1" } [build-dependencies] diff --git a/ucan-key-support/src/rsa.rs b/ucan-key-support/src/rsa.rs index bccfc6af..16a5523e 100644 --- a/ucan-key-support/src/rsa.rs +++ b/ucan-key-support/src/rsa.rs @@ -2,11 +2,8 @@ use anyhow::{anyhow, Result}; use async_trait::async_trait; use rsa::{ - pkcs1::{ - der::{Document, Encodable}, - DecodeRsaPublicKey, EncodeRsaPublicKey, - }, - Hash, PaddingScheme, PublicKey, RsaPrivateKey, RsaPublicKey, + pkcs1::{der::Encode, DecodeRsaPublicKey, EncodeRsaPublicKey}, + PaddingScheme, PublicKey, RsaPrivateKey, RsaPublicKey, }; use sha2::{Digest, Sha256}; @@ -35,7 +32,7 @@ impl KeyMaterial for RsaKeyMaterial { async fn get_did(&self) -> Result { let bytes = match self.0.to_pkcs1_der() { - Ok(document) => [RSA_MAGIC_BYTES, document.as_der()].concat(), + Ok(document) => [RSA_MAGIC_BYTES, document.as_bytes()].concat(), Err(error) => { // TODO: Probably shouldn't swallow this error... warn!("Could not get RSA public key bytes for DID: {:?}", error); @@ -53,9 +50,7 @@ impl KeyMaterial for RsaKeyMaterial { match &self.1 { Some(private_key) => { let signature = private_key.sign( - PaddingScheme::PKCS1v15Sign { - hash: Some(Hash::SHA2_256), - }, + PaddingScheme::new_pkcs1v15_sign::(), hashed.as_ref(), )?; info!("SIGNED!"); @@ -72,9 +67,7 @@ impl KeyMaterial for RsaKeyMaterial { self.0 .verify( - PaddingScheme::PKCS1v15Sign { - hash: Some(Hash::SHA2_256), - }, + PaddingScheme::new_pkcs1v15_sign::(), hashed.as_ref(), signature, ) diff --git a/ucan-key-support/src/web_crypto.rs b/ucan-key-support/src/web_crypto.rs index f41d88d6..c9d54ba3 100644 --- a/ucan-key-support/src/web_crypto.rs +++ b/ucan-key-support/src/web_crypto.rs @@ -3,7 +3,7 @@ use anyhow::{anyhow, Result}; use async_trait::async_trait; use js_sys::{Array, ArrayBuffer, Boolean, Object, Reflect, Uint8Array}; use rsa::{ - pkcs1::{der::Encodable, DecodeRsaPublicKey}, + pkcs1::{der::Encode, DecodeRsaPublicKey}, RsaPublicKey, }; use ucan::crypto::{JwtSignatureAlgorithm, KeyMaterial};