# currently does not include
# ffi due to libffi
# tls, http due to openssl
-# crypto-impure due to ring
+# crypto-full due to ring
all-pure = ["repl", "hostname"]
# enables all features that are simple to get working for cross-compliation
# currently all but tls, http as those depend on openssl
tls = ["dep:native-tls"]
http = ["dep:warp", "dep:reqwest"]
# crypto function that require non pure-rust dependencies
-crypto-impure = ["dep:ring"]
-crypto-full = ["crypto-impure"]
+crypto-full = ["dep:ring"]
[lints.clippy]
collapsible_match = "allow"
use blake2::{Blake2b512, Blake2s256};
#[cfg(feature = "crypto-full")]
-use ring::aead;
-#[cfg(feature = "crypto-impure")]
use ring::{
- digest, hkdf, hmac, pbkdf2,
+ aead, digest, hkdf, hmac, pbkdf2,
rand::{SecureRandom, SystemRandom},
};
#[inline(always)]
pub(crate) fn crypto_random_byte(&mut self) {
- #[cfg(feature = "crypto-impure")]
+ #[cfg(feature = "crypto-full")]
{
let arg = self.machine_st.registers[1];
let mut bytes: [u8; 1] = [0];
self.machine_st.unify_fixnum(byte, arg);
}
- #[cfg(not(feature = "crypto-impure"))]
+ #[cfg(not(feature = "crypto-full"))]
{
let stub_gen = || functor_stub(atom!("crypto_random_byte"), 1);
let err = self.machine_st.missing_feature_error(atom!("crypto"));
)
}
_ => {
- #[cfg(feature = "crypto-impure")]
+ #[cfg(feature = "crypto-full")]
{
let ints = digest::digest(
match algorithm {
)
)
}
- #[cfg(not(feature = "crypto-impure"))]
+ #[cfg(not(feature = "crypto-full"))]
{
let stub_gen = || functor_stub(atom!("crypto_data_hash"), 1);
let err = self.machine_st.missing_feature_error(atom!("crypto"));
pub(crate) fn crypto_hmac(&mut self) {
let stub_gen = || functor_stub(atom!("crypto_data_hash"), 3);
- #[cfg(feature = "crypto-impure")]
+ #[cfg(feature = "crypto-full")]
{
let encoding = cell_as_atom!(self.deref_register(2));
let data = self.string_encoding_bytes(self.machine_st.registers[1], encoding);
unify!(self.machine_st, self.machine_st.registers[4], ints_list);
}
- #[cfg(not(feature = "crypto-impure"))]
+ #[cfg(not(feature = "crypto-full"))]
{
let err = self.machine_st.missing_feature_error(atom!("crypto"));
let exception = self.machine_st.error_form(err, stub_gen());
pub(crate) fn crypto_data_hkdf(&mut self) {
let stub1_gen = || functor_stub(atom!("crypto_data_hkdf"), 4);
- #[cfg(feature = "crypto-impure")]
+ #[cfg(feature = "crypto-full")]
{
let encoding = cell_as_atom!(self.deref_register(2));
let data = self.string_encoding_bytes(self.machine_st.registers[1], encoding);
unify!(self.machine_st, self.machine_st.registers[7], ints_list);
}
- #[cfg(not(feature = "crypto-impure"))]
+ #[cfg(not(feature = "crypto-full"))]
{
let err = self.machine_st.missing_feature_error(atom!("crypto"));
let exception = self.machine_st.error_form(err, stub1_gen());
pub(crate) fn crypto_password_hash(&mut self) {
let stub1_gen = || functor_stub(atom!("crypto_password_hash"), 3);
- #[cfg(feature = "crypto-impure")]
+ #[cfg(feature = "crypto-full")]
{
use std::num::NonZeroU32;
let data = self
unify!(self.machine_st, self.machine_st.registers[4], ints_list);
}
- #[cfg(not(feature = "crypto-impure"))]
+ #[cfg(not(feature = "crypto-full"))]
{
let err = self.machine_st.missing_feature_error(atom!("crypto"));
let exception = self.machine_st.error_form(err, stub1_gen());
}
}
-#[cfg(feature = "crypto-impure")]
+#[cfg(feature = "crypto-full")]
fn rng() -> &'static dyn SecureRandom {
use std::ops::Deref;
RANDOM.deref()
}
-#[cfg(feature = "crypto-impure")]
+#[cfg(feature = "crypto-full")]
struct MyKey<T: core::fmt::Debug + PartialEq>(T);
-#[cfg(feature = "crypto-impure")]
+#[cfg(feature = "crypto-full")]
impl hkdf::KeyType for MyKey<usize> {
fn len(&self) -> usize {
self.0