diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2014-06-21 22:57:16 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2014-06-21 22:57:16 +0000 |
commit | 173a913f33c770d023f5ebaca8b198b1f2f471e3 (patch) | |
tree | 97406709dc4a664669bb90ea96a335a0c785b694 /regress/lib | |
parent | ded62ddfecc7e4e5328d8cddb4c529cb1666c52d (diff) |
matthew reminds me to update regress to reflect current spec
Diffstat (limited to 'regress/lib')
-rw-r--r-- | regress/lib/libc/timingsafe/timingsafe.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/regress/lib/libc/timingsafe/timingsafe.c b/regress/lib/libc/timingsafe/timingsafe.c index e7807db2586..f6605f8696a 100644 --- a/regress/lib/libc/timingsafe/timingsafe.c +++ b/regress/lib/libc/timingsafe/timingsafe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timingsafe.c,v 1.2 2014/06/13 02:12:17 matthew Exp $ */ +/* $OpenBSD: timingsafe.c,v 1.3 2014/06/21 22:57:15 tedu Exp $ */ /* * Copyright (c) 2014 Google Inc. * @@ -32,13 +32,6 @@ check() { int cmp = memcmp(bufone, buftwo, N); - /* - * timingsafe_memcmp is specified to return -1, 0, or 1, - * but memcmp only specifies <0, 0, or >0. - */ - if (cmp < 0) cmp = -1; - if (cmp > 0) cmp = 1; - /* Check for reflexivity. */ ASSERT_EQ(0, timingsafe_bcmp(bufone, bufone, N)); ASSERT_EQ(0, timingsafe_bcmp(buftwo, buftwo, N)); @@ -49,10 +42,10 @@ check() ASSERT_EQ(cmp == 0, timingsafe_bcmp(bufone, buftwo, N) == 0); /* Check that timingsafe_memcmp returns cmp... */ - ASSERT_EQ(cmp, timingsafe_memcmp(bufone, buftwo, N)); + ASSERT_EQ(cmp < 0, timingsafe_memcmp(bufone, buftwo, N) < 0); /* ... or -cmp if the argument order is swapped. */ - ASSERT_EQ(-cmp, timingsafe_memcmp(buftwo, bufone, N)); + ASSERT_EQ(-cmp < 0, timingsafe_memcmp(buftwo, bufone, N) < 0); } int |