Skip to content

Commit

Permalink
Merge pull request adegtyarev#5 from KirillSmirnov/master
Browse files Browse the repository at this point in the history
Fix overflow check in add512(). Improve compatibility.
  • Loading branch information
adegtyarev authored Nov 30, 2017
2 parents e8b8020 + f0754e9 commit 8a4e74f
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion auto/header/endianness
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# $Id$

TMPFILE=`mktemp -t gost3411-end-autotest-XXX` || exit 1
TMPFILE=`mktemp -t gost3411-end-autotest-XXXXXX` || exit 1
trap "rm -f ${TMPFILE} ${TMPFILE}.c 2>/dev/null" INT TERM EXIT

cat <<EOF > ${TMPFILE}.c
Expand Down
2 changes: 1 addition & 1 deletion auto/header/mmx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# $Id$

TMPFILE=`mktemp -t gost3411-autotest.XXX` || exit 1
TMPFILE=`mktemp -t gost3411-autotest.XXXXXX` || exit 1
trap "rm -f ${TMPFILE} ${TMPFILE}.c 2>/dev/null" INT TERM EXIT

cat <<EOF > ${TMPFILE}.c
Expand Down
2 changes: 1 addition & 1 deletion auto/header/sse2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# $Id$

TMPFILE=`mktemp -t gost3411-autotest.XXX` || exit 1
TMPFILE=`mktemp -t gost3411-autotest.XXXXXX` || exit 1
trap "rm -f ${TMPFILE} ${TMPFILE}.c 2>/dev/null" INT TERM EXIT

cat <<EOF > ${TMPFILE}.c
Expand Down
2 changes: 1 addition & 1 deletion auto/header/sse41
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# $Id$

TMPFILE=`mktemp -t gost3411-autotest.XXX` || exit 1
TMPFILE=`mktemp -t gost3411-autotest.XXXXXX` || exit 1
trap "rm -f ${TMPFILE} ${TMPFILE}.c 2>/dev/null" INT TERM EXIT

cat <<EOF > ${TMPFILE}.c
Expand Down
2 changes: 1 addition & 1 deletion auto/mk/mmx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# $Id$

TMPFILE=`mktemp -t gost3411-autotest.XXX` || exit 1
TMPFILE=`mktemp -t gost3411-autotest.XXXXXX` || exit 1
trap "rm -f ${TMPFILE} ${TMPFILE}.c 2>/dev/null" INT TERM EXIT

cat <<EOF > ${TMPFILE}.c
Expand Down
2 changes: 1 addition & 1 deletion auto/mk/sse2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# $Id$

TMPFILE=`mktemp -t gost3411-autotest.XXX` || exit 1
TMPFILE=`mktemp -t gost3411-autotest.XXXXXX` || exit 1
trap "rm -f ${TMPFILE} ${TMPFILE}.c 2>/dev/null" INT TERM EXIT

cat <<EOF > ${TMPFILE}.c
Expand Down
2 changes: 1 addition & 1 deletion auto/mk/sse41
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# $Id$

TMPFILE=`mktemp -t gost3411-autotest.XXX` || exit 1
TMPFILE=`mktemp -t gost3411-autotest.XXXXXX` || exit 1
trap "rm -f ${TMPFILE} ${TMPFILE}.c 2>/dev/null" INT TERM EXIT

cat <<EOF > ${TMPFILE}.c
Expand Down
10 changes: 6 additions & 4 deletions gost3411-2012-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,22 @@ add512(const union uint512_u *x, const union uint512_u *y, union uint512_u *r)
{
#ifndef __GOST3411_BIG_ENDIAN__
unsigned int CF, OF;
unsigned long long tmp;
unsigned int i;

CF = 0;
for (i = 0; i < 8; i++)
{
r->QWORD[i] = x->QWORD[i] + y->QWORD[i];
if ( (r->QWORD[i] < y->QWORD[i]) ||
(r->QWORD[i] < x->QWORD[i]) )
tmp = x->QWORD[i] + y->QWORD[i];
if ( (tmp < y->QWORD[i]) ||
(tmp < x->QWORD[i]) )
OF = 1;
else
OF = 0;

r->QWORD[i] += CF;
tmp += CF;
CF = OF;
r->QWORD[i] = tmp;
}
#else
const unsigned char *xp, *yp;
Expand Down

0 comments on commit 8a4e74f

Please sign in to comment.