-
Notifications
You must be signed in to change notification settings - Fork 2
/
host.rs
47 lines (41 loc) · 1.47 KB
/
host.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Hash host implementation for WASM runtime.
use super::blake2b;
use crate::{
runtime_context::HermesRuntimeContext,
runtime_extensions::bindings::hermes::{
binary::api::Bstr,
hash::api::{Errno, Host},
},
};
impl Host for HermesRuntimeContext {
/// Hash a binary buffer with BLAKE2s
fn blake2s(
&mut self, _buf: Bstr, _outlen: Option<u8>,
) -> wasmtime::Result<Result<Bstr, Errno>> {
todo!()
}
/// Hash a binary buffer with `BLAKE2s` with `MAC` (Message Authentication Code) mode
fn blake2smac(
&mut self, _buf: Bstr, _outlen: Option<u8>, _key: Bstr, _salt: Option<Bstr>,
_persona: Option<Bstr>,
) -> wasmtime::Result<Result<Bstr, Errno>> {
todo!()
}
/// Hash a binary buffer with `BLAKE2b`
fn blake2b(&mut self, buf: Bstr, outlen: Option<u8>) -> wasmtime::Result<Result<Bstr, Errno>> {
Ok(blake2b::blake2b_impl(&buf, outlen))
}
/// Hash a binary buffer with `BLAKE2b` with `MAC` (Message Authentication Code) mode
fn blake2bmac(
&mut self, buf: Bstr, outlen: Option<u8>, key: Bstr, salt: Option<Bstr>,
personal: Option<Bstr>,
) -> wasmtime::Result<Result<Bstr, Errno>> {
Ok(blake2b::blake2bmac_impl(&buf, outlen, &key, salt, personal))
}
/// Hash a binary buffer with BLAKE3
fn blake3(
&mut self, _buf: Bstr, _outlen: Option<u8>, _key: Option<Bstr>,
) -> wasmtime::Result<Result<Bstr, Errno>> {
todo!()
}
}