Skip to content

Commit

Permalink
Merge pull request #198 from bas-d/master
Browse files Browse the repository at this point in the history
Use UTF8String instead of Pointer_stringify
  • Loading branch information
jedisct1 authored May 21, 2019
2 parents 943ff95 + 5090bbc commit b9213d1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion wrapper/build-wrappers.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function exportConstants(constSymbols) {
exportsCode += "var constants_str = [" + keys.sort().join(", ") + "];\n";
exportsCode += "for (var i = 0; i < constants_str.length; i++) {\n";
exportsCode += ' var raw = libsodium["_" + constants_str[i].toLowerCase()];\n';
exportsCode += ' if (typeof raw === "function") exports[constants_str[i]] = libsodium.Pointer_stringify(raw());\n';
exportsCode += ' if (typeof raw === "function") exports[constants_str[i]] = libsodium.UTF8ToString(raw());\n';
exportsCode += "}\n";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
],
"target": "libsodium._crypto_pwhash_scryptsalsa208sha256_str(hashed_password_address, password_address, password_length, 0, opsLimit, 0, memLimit) | 0",
"assert_retval": [{"condition": "=== 0", "or_else_throw": "invalid usage"}],
"return": "libsodium.Pointer_stringify(hashed_password_address)"
"return": "libsodium.UTF8ToString(hashed_password_address)"
}
2 changes: 1 addition & 1 deletion wrapper/symbols/crypto_pwhash_str.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
],
"target": "libsodium._crypto_pwhash_str(hashed_password_address, password_address, password_length, 0, opsLimit, 0, memLimit) | 0",
"assert_retval": [{"condition": "=== 0", "or_else_throw": "invalid usage"}],
"return": "libsodium.Pointer_stringify(hashed_password_address)"
"return": "libsodium.UTF8ToString(hashed_password_address)"
}
2 changes: 1 addition & 1 deletion wrapper/symbols/sodium_version_string.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"inputs": [],
"outputs": [],
"target": "var version = libsodium._sodium_version_string()",
"return": "libsodium.Pointer_stringify(version)"
"return": "libsodium.UTF8ToString(version)"
}
6 changes: 5 additions & 1 deletion wrapper/wrap-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
return;
}
}
catch (_) {}
catch (err) {
if (libsodium.useBackupModule == null) {
throw new Error("Both wasm and asm failed to load" + err)
}
}

libsodium.useBackupModule();
libsodiumInit();
Expand Down

0 comments on commit b9213d1

Please sign in to comment.