Skip to content

Commit

Permalink
fix: handle wasm compiliaton
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Dec 1, 2024
1 parent b8312e9 commit ffdc5c2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ signature = { version = "=2.3.0-pre.4", default-features = false, features = ["a
spki = { version = "0.8.0-rc.1", default-features = false, features = ["alloc"] }
zeroize = { version = "1.5", features = ["alloc"] }
crypto-bigint = { version = "0.6.0-rc.6", default-features = false, features = ["zeroize", "alloc"] }
crypto-primes = { version = "0.6.0-pre.2" }
crypto-primes = { version = "0.6.0-pre.2", default-features = false }
libm = "0.2"

# optional dependencies
sha1 = { version = "=0.11.0-pre.4", optional = true, default-features = false, features = ["oid"] }
serdect = { version = "0.2.0", optional = true }
sha2 = { version = "=0.11.0-pre.4", optional = true, default-features = false, features = ["oid"] }
serde = { version = "1.0.184", optional = true, default-features = false, features = ["derive"] }


[dev-dependencies]
base64ct = { version = "1", features = ["alloc"] }
hex-literal = "0.4.1"
Expand All @@ -56,6 +58,7 @@ pem = ["pkcs1/pem", "pkcs8/pem"]
pkcs5 = ["pkcs8/encryption"]
std = ["digest/std", "pkcs1/std", "pkcs8/std", "rand_core/std", "signature/std", "crypto-bigint/rand"]


[package.metadata.docs.rs]
features = ["std", "pem", "serde", "hazmat", "sha2"]
rustdoc-args = ["--cfg", "docsrs"]
Expand Down
3 changes: 3 additions & 0 deletions src/algorithms/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ pub(crate) fn generate_multi_prime_key_with_exp<R: CryptoRngCore>(
let prime_limit = (1u64 << (bit_size / nprimes) as u64) as f64;

// pi aproximates the number of primes less than prime_limit
#[cfg(feature = "std")]
let mut pi = prime_limit / (prime_limit.ln() - 1f64);
#[cfg(not(feature = "std"))]
let mut pi = prime_limit / (libm::logf(prime_limit as f32) as f64 - 1f64);
// Generated primes start with 0b11, so we can only use a quarter of them.
pi /= 4f64;
// Use a factor of two to ensure that key generation terminates in a
Expand Down

0 comments on commit ffdc5c2

Please sign in to comment.