Skip to content

Commit f2791fe

Browse files
committed
Fix signature verification to use wasmsign2 "signature" section and upgrade rules_fuzzing for macOS support
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
1 parent 9a4ad18 commit f2791fe

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

bazel/repositories.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ def proxy_wasm_cpp_host_repositories():
121121
maybe(
122122
http_archive,
123123
name = "rules_fuzzing",
124-
sha256 = "3ec0eee05b243552cc4a784b30323d088bf73cb2177ddda02c827e68981933f1",
125-
strip_prefix = "rules_fuzzing-0.5.2",
126-
urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.5.2.tar.gz"],
124+
sha256 = "850897989ebc06567ea06c959eb4a6129fa509ed2dbbd0d147d62d2b986714a9",
125+
strip_prefix = "rules_fuzzing-0.6.0",
126+
urls = ["https://github.com/bazelbuild/rules_fuzzing/archive/v0.6.0.tar.gz"],
127127
)
128128

129129
maybe(

src/signature_util.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,18 @@ bool SignatureUtil::verifySignature(std::string_view bytecode, std::string &mess
6464
*/
6565

6666
std::string_view payload;
67-
if (!BytecodeUtil::getCustomSection(bytecode, "signature_wasmsign", payload)) {
67+
if (!BytecodeUtil::getCustomSection(bytecode, "signature", payload)) {
6868
message = "Failed to parse corrupted Wasm module";
6969
return false;
7070
}
7171

7272
if (payload.empty()) {
73-
message = "Custom Section \"signature_wasmsign\" not found";
73+
message = "Custom Section \"signature\" not found";
7474
return false;
7575
}
7676

7777
if (bytecode.data() + bytecode.size() != payload.data() + payload.size()) {
78-
message = "Custom Section \"signature_wasmsign\" not at the end of Wasm module";
78+
message = "Custom Section \"signature\" not at the end of Wasm module";
7979
return false;
8080
}
8181

@@ -100,7 +100,7 @@ bool SignatureUtil::verifySignature(std::string_view bytecode, std::string &mess
100100
SHA512_Update(&ctx, "WasmSignature", sizeof("WasmSignature") - 1);
101101
const uint32_t ad_len = 0;
102102
SHA512_Update(&ctx, &ad_len, sizeof(uint32_t));
103-
const size_t section_len = 3 + sizeof("signature_wasmsign") - 1 + 68;
103+
const size_t section_len = 3 + sizeof("signature") - 1 + 68;
104104
SHA512_Update(&ctx, bytecode.data(), bytecode.size() - section_len);
105105
uint8_t hash[SHA512_DIGEST_LENGTH];
106106
SHA512_Final(hash, &ctx);

test/signature_util_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ TEST(TestSignatureUtil, NoSignature) {
5454
const auto bytecode = readTestWasmFile("abi_export.wasm");
5555
std::string message;
5656
EXPECT_FALSE(SignatureUtil::verifySignature(bytecode, message));
57-
EXPECT_EQ(message, "Custom Section \"signature_wasmsign\" not found");
57+
EXPECT_EQ(message, "Custom Section \"signature\" not found");
5858
}
5959

6060
} // namespace proxy_wasm

0 commit comments

Comments
 (0)