; domain_error(hkdf_algorithm, Algorithm, crypto_data_hkdf/4)
),
must_be(integer, L),
- L >= 0,
+ L #>= 0,
options_data_chars(Options, Data0, Data, Encoding),
option(salt(SaltBytes), Options, []),
must_be_bytes(SaltBytes, crypto_data_hkdf/4),
chars_bytes_(Password0, Password, crypto_password_hash/3),
must_be(list, Options),
option(cost(C), Options, 17),
- Iterations is 2^C,
+ Iterations #= 2^C,
Algorithm = 'pbkdf2-sha512', % current default and only option
option(algorithm(Algorithm), Options, Algorithm),
( member(salt(SaltBytes), Options) ->
curve25519_scalar_mult(Scalar, Point, Result) :-
( integer_si(Scalar) ->
- Scalar #>= 0,
- Scalar #< 2^256,
length(ScalarBytes, 32),
bytes_integer(ScalarBytes, Scalar)
; ScalarBytes = Scalar,
let result = scalarmult(&scalar, &point).unwrap();
- let mut string = String::new();
- for c in result[..].iter() {
- string.push(*c as char);
- }
+ let string = String::from_iter(result[..].iter().map(|b| *b as char));
let cstr = self.heap.put_complete_string(&string);
self.unify(self[temp_v!(3)], cstr);
}
env::remove_var(key);
}
&SystemClauseType::CharsBase64 => {
- let mut options = vec![];
-
- for i in 3..5 {
- match self.store(self.deref(self[temp_v!(i)])) {
- Addr::Con(h) if self.heap.atom_at(h) => {
- if let HeapCellValue::Atom(ref atom, _) = &self.heap[h] {
- options.push(atom.as_str());
- } else {
- unreachable!()
- }
- }
- _ => {
- unreachable!()
- }
- };
- }
+ let padding = self.atom_argument_to_string(3);
+ let charset = self.atom_argument_to_string(4);
let config =
- if options[0] == "true" {
- if options[1] == "standard" {
+ if padding == "true" {
+ if charset == "standard" {
base64::STANDARD
} else {
base64::URL_SAFE
}
} else {
- if options[1] == "standard" {
+ if charset == "standard" {
base64::STANDARD_NO_PAD
} else {
base64::URL_SAFE_NO_PAD
match bytes {
Ok(bs) => {
- let mut string = String::new();
- for c in bs {
- string.push(c as char);
- }
+ let string = String::from_iter(bs.iter().map(|b| *b as char));
let cstr = self.heap.put_complete_string(&string);
self.unify(self[temp_v!(1)], cstr);
}