kopia lustrzana
https://github.com/henrydcase/pqc.git
synced 2024-11-22 07:35:38 +00:00
ct_expect/require_umr -> ct_expect/require_uum
This commit is contained in:
rodzic
5f5b48891c
commit
e96e7aaea8
@ -82,7 +82,7 @@ static inline void ct_purify(const volatile void *p, size_t sz) {
|
||||
}
|
||||
|
||||
// Function instructs memory sanitizer that code expects to do operation on unintialized memory.
|
||||
static inline void ct_expect_umr() {
|
||||
static inline void ct_expect_uum() {
|
||||
#if defined(PQC_USE_CTSANITIZER) && defined(__clang__) && defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
__msan_set_expect_umr(1);
|
||||
@ -94,7 +94,7 @@ static inline void ct_expect_umr() {
|
||||
// then error is reported. It works in tandem with ct_expect_umr(). In current version of
|
||||
// MSan, the code needs to be compiled with `-mllvm -msan-keep-going=1` flags in order to work
|
||||
// correctly.
|
||||
static inline void ct_require_umr() {
|
||||
static inline void ct_require_uum() {
|
||||
#if defined(PQC_USE_CTSANITIZER) && defined(__clang__) && defined(__has_feature)
|
||||
#if __has_feature(memory_sanitizer)
|
||||
__msan_set_expect_umr(0);
|
||||
|
24
test/ct.cpp
24
test/ct.cpp
@ -12,11 +12,11 @@ TEST(ConstantTime, CtCheck_Negative) {
|
||||
|
||||
ct_poison(a, 16);
|
||||
for (i = 0; i < 16; i++) {
|
||||
ct_expect_umr();
|
||||
ct_expect_uum();
|
||||
if (a[i] != b[i]) {
|
||||
break;
|
||||
}
|
||||
ct_require_umr();
|
||||
ct_require_uum();
|
||||
}
|
||||
|
||||
ct_purify(a, 16);
|
||||
@ -53,9 +53,9 @@ TEST(ConstantTime, CtCheck_Negative_UseSecretAsIndex) {
|
||||
|
||||
ct_poison(a, 16);
|
||||
|
||||
ct_expect_umr();
|
||||
ct_expect_uum();
|
||||
result = tab[a[0] & 1];
|
||||
ct_require_umr();
|
||||
ct_require_uum();
|
||||
|
||||
ct_purify(a, 16);
|
||||
|
||||
@ -72,18 +72,18 @@ TEST(ConstantTime, CtCheck_memcmp) {
|
||||
|
||||
ct_poison(a, 16);
|
||||
ret = ct_memcmp(a,b,16);
|
||||
ct_expect_umr();
|
||||
ct_expect_uum();
|
||||
// Doesn't matter what we check. It's just to
|
||||
// enusre UMR is triggered.
|
||||
if (!ret) ASSERT_EQ(ret, 0);
|
||||
ct_require_umr();
|
||||
ct_require_uum();
|
||||
ct_purify(&ret, 1);
|
||||
|
||||
b[1] = 0;
|
||||
ct_expect_umr();
|
||||
ct_expect_uum();
|
||||
ret = ct_memcmp(a,b,16);
|
||||
if (ret) ASSERT_EQ(ret,1);
|
||||
ct_require_umr();
|
||||
ct_require_uum();
|
||||
ct_purify(&ret, 1);
|
||||
}
|
||||
|
||||
@ -97,18 +97,18 @@ TEST(ConstantTime, CtCheck_memcmp_chained) {
|
||||
|
||||
ct_poison(a, 16);
|
||||
|
||||
ct_expect_umr();
|
||||
ct_expect_uum();
|
||||
// obviously must generate UMR if first check fails
|
||||
// and second is not done
|
||||
ret = (ct_memcmp(a,c,16)==0) && (ct_memcmp(a,b,16)==0);
|
||||
ct_require_umr();
|
||||
ct_require_uum();
|
||||
ct_purify(&ret, 1);
|
||||
ASSERT_EQ(ret,0);
|
||||
|
||||
ct_expect_umr();
|
||||
ct_expect_uum();
|
||||
// it's still UMR even if both checks are OK
|
||||
ret = (ct_memcmp(a,d,16)==0) && (ct_memcmp(a,b,16)==0);
|
||||
ct_require_umr();
|
||||
ct_require_uum();
|
||||
|
||||
ct_purify(&ret, 1);
|
||||
ASSERT_EQ(ret,1);
|
||||
|
Ładowanie…
Reference in New Issue
Block a user