Skip to content

Commit eda06c9

Browse files
committed
Match hashing scheme on server side
Refer to LIT-Protocol/lit-assets#2116
1 parent b722ecc commit eda06c9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/wasm/rust/src/sev_snp.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,27 @@ fn get_expected_report_data(
130130
) -> JsResult<[u8; 64]> {
131131
let mut hasher = Sha512::new();
132132
hasher.update("noonce");
133+
hasher.update(&(challenge.len() as u64).to_be_bytes());
133134
hasher.update(challenge);
134135

135136
hasher.update("data");
137+
hasher.update(&(data.len() as u64).to_be_bytes());
136138
for (key, value) in data {
139+
hasher.update(&(key.len() as u64).to_be_bytes());
137140
hasher.update(key);
141+
hasher.update(&(value.len() as u64).to_be_bytes());
138142
hasher.update(value);
139143
}
140144

141145
if !signatures.is_empty() {
142146
hasher.update("signatures");
147+
hasher.update(&(signatures.len() as u64).to_be_bytes());
143148

144-
for idx in 0..((signatures.len() - 1) as usize) {
149+
for idx in 0..=((signatures.len() - 1) as usize) {
145150
let sig = signatures.get(idx);
146151
match sig {
147152
Some(s) => {
153+
hasher.update(&(s.len() as u64).to_be_bytes());
148154
hasher.update(s.clone());
149155
}
150156
None => {

0 commit comments

Comments
 (0)