Skip to content

Commit

Permalink
chore!: rsa dep changes (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeeshan Lakhani authored and zeeshanlakhani committed Nov 29, 2022
1 parent bf55a3f commit ef3bdf3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ updates:
- package-ecosystem: "cargo"
directory: "/ucan"
commit-message:
prefix: "chore(deps)"
prefix: "chore"
include: "scope"
target-branch: "main"
schedule:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions ucan-key-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
17 changes: 5 additions & 12 deletions ucan-key-support/src/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -35,7 +32,7 @@ impl KeyMaterial for RsaKeyMaterial {

async fn get_did(&self) -> Result<String> {
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);
Expand All @@ -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::<Sha256>(),
hashed.as_ref(),
)?;
info!("SIGNED!");
Expand All @@ -72,9 +67,7 @@ impl KeyMaterial for RsaKeyMaterial {

self.0
.verify(
PaddingScheme::PKCS1v15Sign {
hash: Some(Hash::SHA2_256),
},
PaddingScheme::new_pkcs1v15_sign::<Sha256>(),
hashed.as_ref(),
signature,
)
Expand Down
2 changes: 1 addition & 1 deletion ucan-key-support/src/web_crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit ef3bdf3

Please sign in to comment.