Skip to content

Commit 4e1da74

Browse files
fix secure_zero odr
1 parent bfb1a30 commit 4e1da74

5 files changed

Lines changed: 21 additions & 90 deletions

File tree

.github/workflows/secure_zero_odr.yml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,15 @@ jobs:
1313
run: |
1414
sudo apt-get update
1515
sudo apt-get install -y build-essential
16-
17-
- name: Build secure_zero conflict sample
16+
17+
- name: Build secure_zero ODR sample
1818
run: |
1919
g++ -std=c++11 -Wall -Wextra -pedantic -DHMAC_CPP_STATIC -Iinclude \
2020
tests/odr/main.cpp \
21-
tests/odr/tu_memsets.cpp \
22-
tests/odr/tu_manual.cpp \
23-
tests/odr/stubs.cpp \
24-
-o secure_zero_conflict
25-
26-
- name: Expect secure_zero mismatch
27-
run: |
28-
if ./secure_zero_conflict; then
29-
echo "secure_zero conflict binary unexpectedly succeeded"
30-
exit 1
31-
fi
32-
echo "secure_zero conflict binary correctly reported mismatch"
21+
tests/odr/tu_memset.cpp \
22+
tests/odr/tu_explicit.cpp \
23+
tests/odr/platform_stubs.cpp \
24+
-o secure_zero_odr
25+
26+
- name: Run secure_zero ODR sample
27+
run: ./secure_zero_odr

tests/odr/main.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#include <iostream>
22

3-
extern "C" int secure_zero_branch_memsets();
4-
extern "C" int secure_zero_branch_manual();
3+
extern "C" bool secure_zero_memset_s_branch();
4+
extern "C" bool secure_zero_explicit_bzero_branch();
55

66
int main() {
7-
const auto a = secure_zero_branch_memsets();
8-
const auto b = secure_zero_branch_manual();
9-
if (a == b) {
10-
std::cout << "secure_zero branch matches across TUs: " << a << "\n";
11-
return 0;
12-
}
7+
const bool memset_ok = secure_zero_memset_s_branch();
8+
const bool explicit_ok = secure_zero_explicit_bzero_branch();
139

14-
std::cout << "secure_zero branch mismatch across TUs: " << a << " vs " << b << "\n";
15-
return 1;
10+
if (!memset_ok || !explicit_ok) {
11+
std::cout << "secure_zero failed: memset_s=" << memset_ok
12+
<< ", explicit_bzero=" << explicit_ok << "\n";
13+
return 1;
14+
}
15+
16+
std::cout << "secure_zero zeroed buffers across translation units\n";
17+
return 0;
1618
}

tests/odr/stubs.cpp

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/odr/tu_manual.cpp

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/odr/tu_memsets.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)