Compare commits
2 commits
a0052b50e2
...
a871b0ae82
Author | SHA1 | Date | |
---|---|---|---|
asonix | a871b0ae82 | ||
asonix | 6c43f9533c |
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "rsa-magic-public-key"
|
||||
description = "Converting between the Magic Public Key format and a RustCrypto RSA type"
|
||||
version = "0.6.0"
|
||||
version = "0.7.0"
|
||||
license-file = "LICENSE"
|
||||
authors = ["asonix <asonix@asonix.dog>"]
|
||||
edition = "2018"
|
||||
|
@ -11,9 +11,9 @@ readme = "README.md"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.13"
|
||||
base64 = "0.21"
|
||||
num-bigint-dig = "0.8"
|
||||
rsa = "0.7.0"
|
||||
rsa = "0.8.1"
|
||||
thiserror = "1.0.9"
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -30,7 +30,7 @@
|
|||
//! use rsa_magic_public_key::FromMagicPublicKey;
|
||||
//! let public_key = RsaPublicKey::from_magic_public_key(&magic_public_key).unwrap();
|
||||
//! ```
|
||||
use base64::{decode_config, encode_config, URL_SAFE};
|
||||
use base64::{engine::general_purpose::URL_SAFE, Engine};
|
||||
use num_bigint_dig::BigUint;
|
||||
use rsa::{PublicKey, RsaPublicKey};
|
||||
use thiserror::Error;
|
||||
|
@ -66,8 +66,8 @@ where
|
|||
T: PublicKey,
|
||||
{
|
||||
fn as_magic_public_key(&self) -> String {
|
||||
let n = encode_config(&self.n().to_bytes_be(), URL_SAFE);
|
||||
let e = encode_config(&self.e().to_bytes_be(), URL_SAFE);
|
||||
let n = URL_SAFE.encode(&self.n().to_bytes_be());
|
||||
let e = URL_SAFE.encode(&self.e().to_bytes_be());
|
||||
|
||||
format!("Rsa.{}.{}", n, e)
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ impl FromMagicPublicKey for RsaPublicKey {
|
|||
let n = iter.next().ok_or(KeyError::Malformed)?;
|
||||
let e = iter.next().ok_or(KeyError::Malformed)?;
|
||||
|
||||
let n = decode_config(n, URL_SAFE)?;
|
||||
let e = decode_config(e, URL_SAFE)?;
|
||||
let n = URL_SAFE.decode(n)?;
|
||||
let e = URL_SAFE.decode(e)?;
|
||||
|
||||
let n = BigUint::from_bytes_be(&n);
|
||||
let e = BigUint::from_bytes_be(&e);
|
||||
|
|
Loading…
Reference in a new issue