mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
chore: Upgrade RSA to 0.5.0 (#11589)
This commit is contained in:
parent
728d205d9d
commit
b6b71c3d59
3 changed files with 86 additions and 61 deletions
116
Cargo.lock
generated
116
Cargo.lock
generated
|
@ -377,6 +377,12 @@ dependencies = [
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "const-oid"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "44c32f031ea41b4291d695026c023b95d59db2d8a2c7640800ed56bc8f510f22"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "convert_case"
|
name = "convert_case"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
@ -464,6 +470,17 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crypto-bigint"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b32a398eb1ccfbe7e4f452bc749c44d38dd732e9a253f19da224c416f00ee7f4"
|
||||||
|
dependencies = [
|
||||||
|
"generic-array",
|
||||||
|
"rand_core 0.6.3",
|
||||||
|
"subtle",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "d3d12"
|
name = "d3d12"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
@ -884,6 +901,16 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "der"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "49f215f706081a44cb702c71c39a52c05da637822e9c1645a50b7202689e982d"
|
||||||
|
dependencies = [
|
||||||
|
"const-oid",
|
||||||
|
"crypto-bigint",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive_more"
|
name = "derive_more"
|
||||||
version = "0.99.16"
|
version = "0.99.16"
|
||||||
|
@ -991,7 +1018,7 @@ checksum = "9a9591846b69e7c62879e3f9dc02d5ebd0fcc2868a96ba9bbb9b6bc304e02dee"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"fnv",
|
"fnv",
|
||||||
"num-bigint 0.2.6",
|
"num-bigint",
|
||||||
"swc_atoms",
|
"swc_atoms",
|
||||||
"swc_common",
|
"swc_common",
|
||||||
"swc_ecmascript",
|
"swc_ecmascript",
|
||||||
|
@ -2241,17 +2268,6 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-bigint"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4e0d047c1062aa51e256408c560894e5251f08925980e53cf1aa5bd00eec6512"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg 1.0.1",
|
|
||||||
"num-integer",
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-bigint-dig"
|
name = "num-bigint-dig"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
|
@ -2386,17 +2402,6 @@ dependencies = [
|
||||||
"winapi 0.3.9",
|
"winapi 0.3.9",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pem"
|
|
||||||
version = "0.8.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fd56cbd21fea48d0c440b41cd69c589faacade08c992d9a54e471b79d0fd13eb"
|
|
||||||
dependencies = [
|
|
||||||
"base64 0.13.0",
|
|
||||||
"once_cell",
|
|
||||||
"regex",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
|
@ -2498,6 +2503,28 @@ version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pkcs1"
|
||||||
|
version = "0.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "359e7852310174a810f078124edb73c66e88a1a731b2fd586dba34ee32dbe416"
|
||||||
|
dependencies = [
|
||||||
|
"der",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pkcs8"
|
||||||
|
version = "0.7.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fbee84ed13e44dd82689fa18348a49934fa79cc774a344c42fc9b301c71b140a"
|
||||||
|
dependencies = [
|
||||||
|
"der",
|
||||||
|
"pkcs1",
|
||||||
|
"spki",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkg-config"
|
name = "pkg-config"
|
||||||
version = "0.3.19"
|
version = "0.3.19"
|
||||||
|
@ -2892,9 +2919,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rsa"
|
name = "rsa"
|
||||||
version = "0.4.0"
|
version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "68ef841a26fc5d040ced0417c6c6a64ee851f42489df11cdf0218e545b6f8d28"
|
checksum = "e05c2603e2823634ab331437001b411b9ed11660fbc4066f3908c84a9439260d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"digest",
|
"digest",
|
||||||
|
@ -2903,9 +2930,9 @@ dependencies = [
|
||||||
"num-integer",
|
"num-integer",
|
||||||
"num-iter",
|
"num-iter",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"pem",
|
"pkcs1",
|
||||||
|
"pkcs8",
|
||||||
"rand 0.8.4",
|
"rand 0.8.4",
|
||||||
"simple_asn1",
|
|
||||||
"subtle",
|
"subtle",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
@ -3139,9 +3166,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha-1"
|
name = "sha-1"
|
||||||
version = "0.9.6"
|
version = "0.9.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8c4cfa741c5832d0ef7fab46cabed29c2aae926db0b11bb2069edd8db5e64e16"
|
checksum = "1a0c8611594e2ab4ebbf06ec7cbbf0a99450b8570e96cbf5188b5d5f6ef18d81"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"block-buffer",
|
"block-buffer",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
|
@ -3178,18 +3205,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "simple_asn1"
|
|
||||||
version = "0.5.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8eb4ea60fb301dc81dfc113df680571045d375ab7345d171c5dc7d7e13107a80"
|
|
||||||
dependencies = [
|
|
||||||
"chrono",
|
|
||||||
"num-bigint 0.4.0",
|
|
||||||
"num-traits",
|
|
||||||
"thiserror",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "siphasher"
|
name = "siphasher"
|
||||||
version = "0.3.5"
|
version = "0.3.5"
|
||||||
|
@ -3278,6 +3293,15 @@ dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "spki"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "987637c5ae6b3121aba9d513f869bd2bff11c4cc086c22473befd6649c0bd521"
|
||||||
|
dependencies = [
|
||||||
|
"der",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stable_deref_trait"
|
name = "stable_deref_trait"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
|
@ -3412,7 +3436,7 @@ dependencies = [
|
||||||
"from_variant",
|
"from_variant",
|
||||||
"fxhash",
|
"fxhash",
|
||||||
"log",
|
"log",
|
||||||
"num-bigint 0.2.6",
|
"num-bigint",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"owning_ref",
|
"owning_ref",
|
||||||
"scoped-tls",
|
"scoped-tls",
|
||||||
|
@ -3431,7 +3455,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "033da686d95b9663e6732c4021e002bc23173bef251db87857e1c3c8bfbfe8cb"
|
checksum = "033da686d95b9663e6732c4021e002bc23173bef251db87857e1c3c8bfbfe8cb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"is-macro",
|
"is-macro",
|
||||||
"num-bigint 0.2.6",
|
"num-bigint",
|
||||||
"serde",
|
"serde",
|
||||||
"string_enum",
|
"string_enum",
|
||||||
"swc_atoms",
|
"swc_atoms",
|
||||||
|
@ -3445,7 +3469,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4f377629e04d7e4c6b17167421072a51015ced9e8cb4d0022a90470d4779c637"
|
checksum = "4f377629e04d7e4c6b17167421072a51015ced9e8cb4d0022a90470d4779c637"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"num-bigint 0.2.6",
|
"num-bigint",
|
||||||
"sourcemap",
|
"sourcemap",
|
||||||
"swc_atoms",
|
"swc_atoms",
|
||||||
"swc_common",
|
"swc_common",
|
||||||
|
@ -3503,7 +3527,7 @@ dependencies = [
|
||||||
"fxhash",
|
"fxhash",
|
||||||
"lexical",
|
"lexical",
|
||||||
"log",
|
"log",
|
||||||
"num-bigint 0.2.6",
|
"num-bigint",
|
||||||
"serde",
|
"serde",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"swc_atoms",
|
"swc_atoms",
|
||||||
|
@ -3669,7 +3693,7 @@ version = "0.35.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b06818a3a50e6de46a81d3d9f51a46d08624ff0f9eb2b3f30de717b15133858d"
|
checksum = "b06818a3a50e6de46a81d3d9f51a46d08624ff0f9eb2b3f30de717b15133858d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-bigint 0.2.6",
|
"num-bigint",
|
||||||
"swc_atoms",
|
"swc_atoms",
|
||||||
"swc_common",
|
"swc_common",
|
||||||
"swc_ecma_ast",
|
"swc_ecma_ast",
|
||||||
|
|
|
@ -20,9 +20,9 @@ lazy_static = "1.4.0"
|
||||||
num-traits = "0.2.14"
|
num-traits = "0.2.14"
|
||||||
rand = "0.8.4"
|
rand = "0.8.4"
|
||||||
ring = { version = "0.16.20", features = ["std"] }
|
ring = { version = "0.16.20", features = ["std"] }
|
||||||
rsa = "0.4.0" # TODO: remove "pem" feature when next release is on crates.io
|
rsa = { version = "0.5.0", default-features = false, features = ["std"] }
|
||||||
serde = { version = "1.0.126", features = ["derive"] }
|
serde = { version = "1.0.126", features = ["derive"] }
|
||||||
sha-1 = "0.9.6"
|
sha-1 = "0.9.7"
|
||||||
sha2 = "0.9.5"
|
sha2 = "0.9.5"
|
||||||
tokio = { version = "1.8.1", features = ["full"] }
|
tokio = { version = "1.8.1", features = ["full"] }
|
||||||
uuid = { version = "0.8.2", features = ["v4"] }
|
uuid = { version = "0.8.2", features = ["v4"] }
|
||||||
|
|
|
@ -32,11 +32,12 @@ use ring::rand::SecureRandom;
|
||||||
use ring::signature::EcdsaKeyPair;
|
use ring::signature::EcdsaKeyPair;
|
||||||
use ring::signature::EcdsaSigningAlgorithm;
|
use ring::signature::EcdsaSigningAlgorithm;
|
||||||
use rsa::padding::PaddingScheme;
|
use rsa::padding::PaddingScheme;
|
||||||
|
use rsa::pkcs8::FromPrivateKey;
|
||||||
|
use rsa::pkcs8::ToPrivateKey;
|
||||||
use rsa::BigUint;
|
use rsa::BigUint;
|
||||||
use rsa::PrivateKeyEncoding;
|
|
||||||
use rsa::PublicKey;
|
use rsa::PublicKey;
|
||||||
use rsa::RSAPrivateKey;
|
use rsa::RsaPrivateKey;
|
||||||
use rsa::RSAPublicKey;
|
use rsa::RsaPublicKey;
|
||||||
use sha1::Sha1;
|
use sha1::Sha1;
|
||||||
use sha2::Digest;
|
use sha2::Digest;
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
|
@ -141,9 +142,9 @@ pub async fn op_crypto_generate_key(
|
||||||
|
|
||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
|
|
||||||
let private_key: RSAPrivateKey = tokio::task::spawn_blocking(
|
let private_key: RsaPrivateKey = tokio::task::spawn_blocking(
|
||||||
move || -> Result<RSAPrivateKey, rsa::errors::Error> {
|
move || -> Result<RsaPrivateKey, rsa::errors::Error> {
|
||||||
RSAPrivateKey::new_with_exp(
|
RsaPrivateKey::new_with_exp(
|
||||||
&mut rng,
|
&mut rng,
|
||||||
modulus_length as usize,
|
modulus_length as usize,
|
||||||
&exponent,
|
&exponent,
|
||||||
|
@ -154,7 +155,7 @@ pub async fn op_crypto_generate_key(
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.map_err(|e| custom_error("DOMExceptionOperationError", e.to_string()))?;
|
.map_err(|e| custom_error("DOMExceptionOperationError", e.to_string()))?;
|
||||||
|
|
||||||
private_key.to_pkcs8()?
|
private_key.to_pkcs8_der()?.as_ref().to_vec()
|
||||||
}
|
}
|
||||||
Algorithm::Ecdsa => {
|
Algorithm::Ecdsa => {
|
||||||
let curve: &EcdsaSigningAlgorithm =
|
let curve: &EcdsaSigningAlgorithm =
|
||||||
|
@ -248,7 +249,7 @@ pub async fn op_crypto_sign_key(
|
||||||
|
|
||||||
let signature = match algorithm {
|
let signature = match algorithm {
|
||||||
Algorithm::RsassaPkcs1v15 => {
|
Algorithm::RsassaPkcs1v15 => {
|
||||||
let private_key = RSAPrivateKey::from_pkcs8(&*args.key.data)?;
|
let private_key = RsaPrivateKey::from_pkcs8_der(&*args.key.data)?;
|
||||||
let (padding, hashed) = match args
|
let (padding, hashed) = match args
|
||||||
.hash
|
.hash
|
||||||
.ok_or_else(|| type_error("Missing argument hash".to_string()))?
|
.ok_or_else(|| type_error("Missing argument hash".to_string()))?
|
||||||
|
@ -298,7 +299,7 @@ pub async fn op_crypto_sign_key(
|
||||||
private_key.sign(padding, &hashed)?
|
private_key.sign(padding, &hashed)?
|
||||||
}
|
}
|
||||||
Algorithm::RsaPss => {
|
Algorithm::RsaPss => {
|
||||||
let private_key = RSAPrivateKey::from_pkcs8(&*args.key.data)?;
|
let private_key = RsaPrivateKey::from_pkcs8_der(&*args.key.data)?;
|
||||||
|
|
||||||
let salt_len = args
|
let salt_len = args
|
||||||
.salt_length
|
.salt_length
|
||||||
|
@ -402,8 +403,8 @@ pub async fn op_crypto_verify_key(
|
||||||
|
|
||||||
let verification = match algorithm {
|
let verification = match algorithm {
|
||||||
Algorithm::RsassaPkcs1v15 => {
|
Algorithm::RsassaPkcs1v15 => {
|
||||||
let public_key: RSAPublicKey =
|
let public_key: RsaPublicKey =
|
||||||
RSAPrivateKey::from_pkcs8(&*args.key.data)?.to_public_key();
|
RsaPrivateKey::from_pkcs8_der(&*args.key.data)?.to_public_key();
|
||||||
let (padding, hashed) = match args
|
let (padding, hashed) = match args
|
||||||
.hash
|
.hash
|
||||||
.ok_or_else(|| type_error("Missing argument hash".to_string()))?
|
.ok_or_else(|| type_error("Missing argument hash".to_string()))?
|
||||||
|
@ -459,8 +460,8 @@ pub async fn op_crypto_verify_key(
|
||||||
.salt_length
|
.salt_length
|
||||||
.ok_or_else(|| type_error("Missing argument saltLength".to_string()))?
|
.ok_or_else(|| type_error("Missing argument saltLength".to_string()))?
|
||||||
as usize;
|
as usize;
|
||||||
let public_key: RSAPublicKey =
|
let public_key: RsaPublicKey =
|
||||||
RSAPrivateKey::from_pkcs8(&*args.key.data)?.to_public_key();
|
RsaPrivateKey::from_pkcs8_der(&*args.key.data)?.to_public_key();
|
||||||
|
|
||||||
let rng = OsRng;
|
let rng = OsRng;
|
||||||
let (padding, hashed) = match args
|
let (padding, hashed) = match args
|
||||||
|
|
Loading…
Reference in a new issue