3 个版本
0.1.2 | 2019年1月25日 |
---|---|
0.1.1 | 2019年1月25日 |
0.1.0 | 2019年1月24日 |
#2038 在 密码学
190KB
829 行
一个工具,用于向/从 WASM 二进制文件添加和验证数字签名。
WASM 签名
与典型的桌面和移动应用不同,WebAssembly 二进制文件没有嵌入任何数字签名来验证它们来自受信任的来源,且未被篡改。
Wasmsign 从现有的 wasm 二进制文件中读取,计算 EdDSA 签名,并构建一个新二进制文件,将签名嵌入为全局、导出符号。
生成的二进制文件仍然是独立的、有效的 wasm 二进制文件,但其签名可以在执行之前进行验证。
安装
wasmsign
需要 rust-nightly,可以使用 rustup
安装。
然后只需使用 cargo install
即可编译和安装命令行 wasmsign
工具。
使用方法
wasmsign [FLAGS] [OPTIONS] --symbol-name <symbol-name>
FLAGS:
-h, --help Prints help information
-G, --keygen Generate a key pair
-S, --sign Sign a file
--version Prints version information
-V, --verify Verify a file
OPTIONS:
-a, --ad <ad> Additional content to authenticate
-i, --input <input-path> Path to the wasm input file
-o, --output <output-path> Path to the wasm output file
-p, --pk-path <pk-path> Path to the public key file
-s, --sk-path <sk-path> Path to the secret key file
-n, --symbol-name <symbol-name> Name of the exported symbol containing the signature [default: ___SIGNATURE]
创建密钥对
wasmsign --keygen --pk-path key.public --sk-path key.secret
签名现有的 wasm 二进制文件
wasmsign --sign --pk-path key.public --sk-path key.secret \
--input unsigned.wasm --output signed.wasm
可以验证附加数据,以确保签名仅适用于给定的用户、组或机器
wasmsign --sign --pk-path key.public --sk-path key.secret \
--input unsigned.wasm --output signed.wasm --ad user19238
验证现有的 wasm 二进制文件
wasmsign --verify --pk-path key.public --input signed.wasm
或附加数据
wasmsign --verify --pk-path key.public --input signed.wasm --ad user19238
如果嵌入的签名对于给定的公钥、内容和附加数据有效,则命令退出时返回 0
,或者在出错时返回非 0
的值。
依赖关系
~4MB
~71K SLoC