Skip to content

Commit 3e4d35a

Browse files
author
George Tavares
committed
Unsigned arithmetic in vn function
1 parent 481c05b commit 3e4d35a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/com/iwebpp/crypto/TweetNacl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ private static int vn(
826826
int n)
827827
{
828828
int i,d = 0;
829-
for (i = 0; i < n; i ++) d |= x[i+xoff]^y[i+yoff];
829+
for (i = 0; i < n; i ++) d |= (x[i+xoff]&0xff) ^ (y[i+yoff]&0xff);
830830
return (1 & ((d - 1) >>> 8)) - 1;
831831
}
832832

src/com/iwebpp/crypto/TweetNaclFast.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ private static int vn(
840840
int n)
841841
{
842842
int i,d = 0;
843-
for (i = 0; i < n; i ++) d |= x[i+xoff]^y[i+yoff];
843+
for (i = 0; i < n; i ++) d |= (x[i+xoff]&0xff) ^ (y[i+yoff]&0xff);
844844
return (1 & ((d - 1) >>> 8)) - 1;
845845
}
846846

0 commit comments

Comments
 (0)