- algorithm(+A)
where A is one of ripemd160, sha256, sha384, sha512,
- sha512_256, or a variable. If A is a variable, then it is
- unified with the default algorithm, which is an algorithm that
- is considered cryptographically secure at the time of this
- writing.
+ sha512_256, sha3_224, sha3_256, sha3_384, sha3_512, or a
+ variable. If A is a variable, then it is unified with the
+ default algorithm, which is an algorithm that is considered
+ cryptographically secure at the time of this writing.
- encoding(+Encoding)
The default encoding is utf8. The alternative is octet,
to treat the input as a list of raw bytes.
hash_algorithm(sha512).
hash_algorithm(sha384).
hash_algorithm(sha512_256).
+hash_algorithm(sha3_224).
+hash_algorithm(sha3_256).
+hash_algorithm(sha3_384).
+hash_algorithm(sha3_512).
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Admissible options are:
- algorithm(+Algorithm)
- A hashing algorithm as specified to crypto_data_hash/3. The
- default is a cryptographically secure algorithm. If you
- specify a variable, then it is unified with the algorithm
- that was used, which is a cryptographically secure algorithm.
+ One of sha256, sha384 or sha512. If you specify a variable,
+ then it is unified with the algorithm that was used, which is a
+ cryptographically secure algorithm by default.
- info(+Info)
Optional context and application specific information,
specified as a list of bytes or characters. The default is [].
use ring::rand::{SecureRandom, SystemRandom};
use ring::{digest,hkdf,pbkdf2,aead,error};
use ripemd160::{Ripemd160, Digest};
+use sha3::{Sha3_224, Sha3_256, Sha3_384, Sha3_512};
pub fn get_key() -> KeyEvent {
let key;
};
let ints_list =
- if algorithm_str == "ripemd160" {
+ if algorithm_str == "sha3_224" {
+ let mut context = Sha3_224::new();
+ context.input(&bytes);
+ Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b))))))
+ } else if algorithm_str == "sha3_256" {
+ let mut context = Sha3_256::new();
+ context.input(&bytes);
+ Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b))))))
+ } else if algorithm_str == "sha3_384" {
+ let mut context = Sha3_384::new();
+ context.input(&bytes);
+ Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b))))))
+ } else if algorithm_str == "sha3_512" {
+ let mut context = Sha3_512::new();
+ context.input(&bytes);
+ Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b))))))
+ } else if algorithm_str == "ripemd160" {
let mut context = Ripemd160::new();
context.input(&bytes);
Addr::HeapCell(self.heap.to_list(context.result().as_ref().iter().map(|b| HeapCellValue::Integer(Rc::new(Integer::from(*b))))))
"sha256" => { hkdf::HKDF_SHA256 }
"sha384" => { hkdf::HKDF_SHA384 }
"sha512" => { hkdf::HKDF_SHA512 }
- _ => { unreachable!() }
+ _ => { self.fail = true; return Ok(()); }
};
let salt = hkdf::Salt::new(digest_alg, &salt);
let mut bytes : Vec<u8> = Vec::new();