diff --git a/src/cipher_block.ml b/src/cipher_block.ml index 474b42df..6919fdff 100644 --- a/src/cipher_block.ml +++ b/src/cipher_block.ml @@ -243,12 +243,12 @@ module Modes = struct let derive cs = assert (String.length cs >= tagsize); let k = Bytes.create keysize in - Native.GHASH.keyinit cs 0 k; + Native.GHASH.keyinit cs k; Bytes.unsafe_to_string k let hash0 = Bytes.make tagsize '\x00' let digesti ~key i = let res = Bytes.copy hash0 in - i (fun cs -> Native.GHASH.ghash key res cs 0 (String.length cs)); + i (fun cs -> Native.GHASH.ghash key res cs (String.length cs)); Bytes.unsafe_to_string res end diff --git a/src/native.ml b/src/native.ml index fcc6592e..2dd72f46 100644 --- a/src/native.ml +++ b/src/native.ml @@ -30,8 +30,8 @@ end module GHASH = struct external keysize : unit -> int = "mc_ghash_key_size" [@@noalloc] - external keyinit : string -> int -> bytes -> unit = "mc_ghash_init_key" [@@noalloc] - external ghash : string -> bytes -> string -> int -> int -> unit = "mc_ghash" [@@noalloc] + external keyinit : string -> bytes -> unit = "mc_ghash_init_key" [@@noalloc] + external ghash : string -> bytes -> string -> int -> unit = "mc_ghash" [@@noalloc] external mode : unit -> int = "mc_ghash_mode" [@@noalloc] end diff --git a/src/native/ghash_ctmul.c b/src/native/ghash_ctmul.c index 8d517586..7788fd05 100644 --- a/src/native/ghash_ctmul.c +++ b/src/native/ghash_ctmul.c @@ -284,14 +284,14 @@ static inline void __copy (uint64_t key[2], uint32_t m[4]) { m[3] = key[1] >> 32; } -CAMLprim value mc_ghash_init_key_generic (value key, value off, value m) { +CAMLprim value mc_ghash_init_key_generic (value key, value m) { //push key at off into m - __copy ((uint64_t *) _st_uint8_off(key, off), (uint32_t *) m); + __copy ((uint64_t *) _st_uint8(key), (uint32_t *) m); return Val_unit; } -CAMLprim value mc_ghash_generic (value m, value hash, value src, value off, value len) { - br_ghash_ctmul(Bp_val(hash), Bp_val(m), _st_uint8_off(src, off), Int_val(len)); +CAMLprim value mc_ghash_generic (value m, value hash, value src, value len) { + br_ghash_ctmul(Bp_val(hash), Bp_val(m), _st_uint8(src), Int_val(len)); return Val_unit; } diff --git a/src/native/ghash_generic.c b/src/native/ghash_generic.c index 5bf5f2bf..2cc49532 100644 --- a/src/native/ghash_generic.c +++ b/src/native/ghash_generic.c @@ -95,15 +95,15 @@ CAMLprim value mc_ghash_key_size_generic (__unit ()) { return Val_int (sizeof (__uint128_t) * __t_size); } -CAMLprim value mc_ghash_init_key_generic (value key, value off, value m) { - __derive ((uint64_t *) _st_uint8_off (key, off), (__uint128_t *) Bp_val (m)); +CAMLprim value mc_ghash_init_key_generic (value key, value m) { + __derive ((uint64_t *) _st_uint8 (key), (__uint128_t *) Bp_val (m)); return Val_unit; } CAMLprim value -mc_ghash_generic (value m, value hash, value src, value off, value len) { +mc_ghash_generic (value m, value hash, value src, value len) { __ghash ((__uint128_t *) Bp_val (m), (uint64_t *) Bp_val (hash), - _st_uint8_off (src, off), Int_val (len) ); + _st_uint8 (src), Int_val (len) ); return Val_unit; } diff --git a/src/native/ghash_pclmul.c b/src/native/ghash_pclmul.c index 069c2b3b..58ca02ea 100644 --- a/src/native/ghash_pclmul.c +++ b/src/native/ghash_pclmul.c @@ -196,19 +196,19 @@ CAMLprim value mc_ghash_key_size (__unit ()) { return s; } -CAMLprim value mc_ghash_init_key (value key, value off, value m) { +CAMLprim value mc_ghash_init_key (value key, value m) { _mc_switch_accel(pclmul, - mc_ghash_init_key_generic(key, off, m), - __derive ((__m128i *) _st_uint8_off (key, off), (__m128i *) Bp_val (m))) + mc_ghash_init_key_generic(key, m), + __derive ((__m128i *) _st_uint8 (key), (__m128i *) Bp_val (m))) return Val_unit; } CAMLprim value -mc_ghash (value k, value hash, value src, value off, value len) { +mc_ghash (value k, value hash, value src, value len) { _mc_switch_accel(pclmul, - mc_ghash_generic(k, hash, src, off, len), + mc_ghash_generic(k, hash, src, len), __ghash ( (__m128i *) Bp_val (k), (__m128i *) Bp_val (hash), - (__m128i *) _st_uint8_off (src, off), Int_val (len) )) + (__m128i *) _st_uint8 (src), Int_val (len) )) return Val_unit; } diff --git a/src/native/mirage_crypto.h b/src/native/mirage_crypto.h index 11536e24..31b9d77a 100644 --- a/src/native/mirage_crypto.h +++ b/src/native/mirage_crypto.h @@ -102,10 +102,10 @@ mc_aes_dec_generic (value src, value off1, value dst, value off2, value rk, valu CAMLprim value mc_ghash_key_size_generic (__unit ()); -CAMLprim value mc_ghash_init_key_generic (value key, value off, value m); +CAMLprim value mc_ghash_init_key_generic (value key, value m); CAMLprim value -mc_ghash_generic (value m, value hash, value src, value off, value len); +mc_ghash_generic (value m, value hash, value src, value len); CAMLprim value mc_xor_into_generic (value b1, value off1, value b2, value off2, value n);