Update RSA

This commit is contained in:
asonix 2023-04-27 19:02:04 -05:00
parent a871b0ae82
commit 0df2cc3c1a
5 changed files with 92 additions and 4 deletions

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
/target
**/*.rs.bk
Cargo.lock
/.direnv
/.envrc

View file

@ -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.7.0"
version = "0.8.0"
license-file = "LICENSE"
authors = ["asonix <asonix@asonix.dog>"]
edition = "2018"
@ -13,7 +13,7 @@ readme = "README.md"
[dependencies]
base64 = "0.21"
num-bigint-dig = "0.8"
rsa = "0.8.1"
rsa = "0.9.0"
thiserror = "1.0.9"
[dev-dependencies]

61
flake.lock Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1682526928,
"narHash": "sha256-2cKh4O6t1rQ8Ok+v16URynmb0rV7oZPEbXkU0owNLQs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d6b863fd9b7bb962e6f9fdf292419a775e772891",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

25
flake.nix Normal file
View file

@ -0,0 +1,25 @@
{
description = "rsa-magic-public-key";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
packages.default = pkgs.hello;
devShell = with pkgs; mkShell {
nativeBuildInputs = [ cargo cargo-outdated cargo-zigbuild clippy gcc protobuf rust-analyzer rustc rustfmt ];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
});
}

View file

@ -32,7 +32,7 @@
//! ```
use base64::{engine::general_purpose::URL_SAFE, Engine};
use num_bigint_dig::BigUint;
use rsa::{PublicKey, RsaPublicKey};
use rsa::{traits::PublicKeyParts, RsaPublicKey};
use thiserror::Error;
/// Helper trait to add functionality to Rsa types
@ -63,7 +63,7 @@ pub enum KeyError {
impl<T> AsMagicPublicKey for T
where
T: PublicKey,
T: PublicKeyParts,
{
fn as_magic_public_key(&self) -> String {
let n = URL_SAFE.encode(&self.n().to_bytes_be());