refactor: use once_cell instead of lazy_static (#13135)

This commit is contained in:
Divy Srivastava 2021-12-19 02:44:42 +05:30 committed by GitHub
parent 3db18bf9e6
commit 6de53b631f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 434 additions and 313 deletions

View file

@ -1,11 +1,13 @@
use std::cell::RefCell;
use std::rc::Rc;
use crate::shared::*;
use deno_core::error::AnyError;
use deno_core::OpState;
use deno_core::ZeroCopyBuf;
use elliptic_curve::rand_core::OsRng;
use num_traits::FromPrimitive;
use once_cell::sync::Lazy;
use ring::rand::SecureRandom;
use ring::signature::EcdsaKeyPair;
use rsa::pkcs1::ToRsaPrivateKey;
@ -13,13 +15,11 @@ use rsa::BigUint;
use rsa::RsaPrivateKey;
use serde::Deserialize;
use crate::shared::*;
// Allowlist for RSA public exponents.
lazy_static::lazy_static! {
static ref PUB_EXPONENT_1: BigUint = BigUint::from_u64(3).unwrap();
static ref PUB_EXPONENT_2: BigUint = BigUint::from_u64(65537).unwrap();
}
static PUB_EXPONENT_1: Lazy<BigUint> =
Lazy::new(|| BigUint::from_u64(3).unwrap());
static PUB_EXPONENT_2: Lazy<BigUint> =
Lazy::new(|| BigUint::from_u64(65537).unwrap());
#[derive(Deserialize)]
#[serde(rename_all = "camelCase", tag = "algorithm")]