-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feed_string #30
Comments
|
An interface like this should be better: type 'a iter = ('a -> unit) -> unit
module type S = sig
val digest_size : int
type ctx
type t = string
val init: unit -> ctx
val feed_bytes: ctx -> Bytes.t -> ctx
val feed_string: ctx -> String.t -> ctx
val feed_bigstring: ctx -> Bigstring.t -> ctx
val feedi_bytes: ctx -> Bytes.t iter -> ctx
val feedi_string: ctx -> String.t iter -> ctx
val feedi_bigstring: ctx -> Bigstring.t iter -> ctx
val get: ctx -> t
val digest_bytes: Bytes.t -> t
val digest_string: String.t -> t
val digest_bigstring: Bigstring.t -> t
val digesti_bytes: Bytes.t iter -> t
val digesti_string: String.t iter -> t
val digesti_bigstring: Bigstring.t iter -> t
val digestv_bytes: Bytes.t list -> t
val digestv_string: String.t list -> t
val digestv_bigstring: Bigstring.t list -> t
val hmac_bytes: key:Bytes.t -> Bytes.t -> a
val hmac_string: key:String.t -> String.t -> t
val hmac_bigstring: key:Bigstring.t -> Bigstring.t -> t
val hmaci_bytes: key:Bytes.t -> Bytes.t iter -> t
val hmaci_string: key:String.t -> String.t iter -> t
val hmaci_bigstring: key:Bigstring.t -> Bigstring.t iter -> t
val hmacv_bytes: key:Bytes.t -> Bytes.t list -> t
val hmacv_string: key:String.t -> String.t list -> t
val hmacv_bigstring: key:Bigstring.t -> Bigstring.t list -> t
val compare: t -> t -> int
val eq: t -> t -> bool
val neq: t -> t -> bool
val pp: Format.formatter -> t -> unit
val of_hex: string -> t
val to_hex: t -> string
end Isn't it ? |
Arf, I forget |
@dinosaure what does this mean (the other hmac_ functions return val hmac_bytes: key:Bytes.t -> Bytes.t -> a |
I think I would make the |
did you intentionally leave out |
@hannesm do you have any comments on this API? |
I'm not sure that Speaking of interface, it would be useful if EDIT: A naive implementation could look something like let eq a b =
if (len a) <> (len b) then false else
let rec comp acc idx =
if idx = ~-1 then (acc = 0) else
let c_eq = (get a idx) lxor (get b idx) in (* 0 if equal *)
comp (acc lor c_eq) (pred idx)
in comp 0 (len a -1) |
Yeah, if you have any issue about security, it could be the best time to explain it now. The next release will break the API and I'm not aware about security but I can spend my time on it. Then, from what I did, About Optional argument about |
@dinosaure apart from timing attacks I can't think of any security problems as long as the implementations are correct. Timing attacks work by learning information about the value being hashed by observing the time required to perform an operation. If the implementations take different amount of times depending on the nature of the data, the attacker can sometimes extrapolate the data from these timings (which is bad).
|
Close by #31 |
Would be nice to have a
feed_string
function in addition tofeed_bytes
so we don't have to allocate aBytes.t
to hash a string.The text was updated successfully, but these errors were encountered: