Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Reynir Björnsson <reynir@reynir.dk>
  • Loading branch information
hannesm and reynir authored Mar 18, 2024
1 parent a9ebaa8 commit bec05fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/cipher_block.ml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ module Modes = struct

let decrypt ~key:(_, key) ~iv src =
bounds_check ~iv src ;
let msg = Bytes.of_string src
let msg = Bytes.create (String.length src)
and b = String.length src / block in
if b > 0 then begin
Core.decrypt ~key ~blocks:b src 0 msg 0 ;
Expand Down Expand Up @@ -329,8 +329,8 @@ module Modes = struct
let (key_sizes, block_size) = C.(key, block)

let cipher ~key src ~src_off dst ~dst_off =
if String.length src < block_size || Bytes.length dst < block_size then
invalid_arg "src len %u, dst len %u" (String.length src) (Bytes.length dst);
if String.length src - src_off < block_size || Bytes.length dst - dst_off < block_size then
invalid_arg "src len %u, dst len %u" (String.length src - src_off) (Bytes.length dst - dst_off);
C.encrypt ~key ~blocks:1 src src_off dst dst_off

let authenticate_encrypt_tag ~key ~nonce ?(adata = "") cs =
Expand Down
2 changes: 1 addition & 1 deletion src/cipher_stream.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module ARC4 = struct
let sj = s.(j) in
s.(i) <- sj ; s.(j) <- si ;
let k = s.((si + sj) land 0xff) in
Bytes.(set_uint8 res n (k lxor string_get_uint8 buf n));
Bytes.set_uint8 res n (k lxor string_get_uint8 buf n);
mix i j (succ n)
in
let key' = mix i j 0 in
Expand Down

0 comments on commit bec05fe

Please sign in to comment.