Total Pageviews

Friday 25 February 2022

Minisign, 替文件签名和核实数码签名的工具


A dead simple tool to sign files and verify digital signatures.

https://jedisct1.github.io/minisign/

Minisign is a dead simple tool to sign files and verify signatures.

For more information, please refer to the Minisign documentation

Tarballs and pre-compiled binaries can be verified with the following public key:

RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3

Compilation / installation

Using Zig:

Dependencies:

Compilation:

$ zig build -Drelease-safe

Using cmake and gcc or clang:

Compilation:

$ mkdir build
$ cd build
$ cmake ..
$ make
# make install

Alternative configuration for static binaries:

$ cmake -D STATIC_LIBSODIUM=1 ..

or:

$ cmake -D BUILD_STATIC_EXECUTABLES=1 ..

Minisign is also available in Homebrew:

$ brew install minisign

Minisign is also available in Scoop on Windows:

$ scoop install minisign

Minisign is also available in chocolatey on Windows:

$ choco install minisign

Minisign is also available with docker:

$ docker run -i --rm jedisct1/minisign

Additional tools, libraries and implementations

  • minizign is a compact implementation in Zig, that can also use ssh-encoded keys.
  • minisign-misc is a very nice set of workflows and scripts for macOS to verify and sign files with minisign.
  • go-minisign is a small module in Go to verify Minisign signatures.
  • rust-minisign is a Minisign library written in pure Rust, that can be embedded in other applications.
  • rsign2 is a reimplementation of the command-line tool in Rust.
  • minisign (go) is a rewrite of Minisign in the Go language. It reimplements the CLI but can also be used as a library.
  • minisign-verify is a small Rust crate to verify Minisign signatures.
  • minisign-net is a .NET library to handle and create Minisign signatures.
  • minisign a Javascript implementation.
  • WebAssembly implementations of rsign2 and minisign-cli are available on WAPM.
  • minisign-php is a PHP implementation.
  • py-minisign is a Python implementation.

Signature determinism

This implementation uses deterministic signatures, unless libsodium was compiled with the ED25519_NONDETERMINISTIC macro defined. This adds random noise to the computation of EdDSA nonces.

Other implementations can choose to use non-deterministic signatures by default. They will remain fully interoperable with implementations using deterministic signatures.


from https://github.com/jedisct1/minisign

------


Minisign

Minisign is a dead simple tool to sign files and verify signatures.

It is portable, lightweight, and uses the highly secure Ed25519 public-key signature system.

Creating a key pair

$ minisign -G

The public key is printed and put into the minisign.pub file. The secret key is encrypted and saved as a file named ~/.minisign/minisign.key.

Signing a file

$ minisign -Sm myfile.txt

Or to include a comment in the signature, that will be verified and displayed when verifying the file:

$ minisign -Sm myfile.txt -t 'This comment will be signed as well'

The signature is put into myfile.txt.minisig.

Starting with version 0.8, multiple files can also be signed at once:

$ minisign -Sm file1.txt file2.txt *.jpg

Verifying a file

$ minisign -Vm myfile.txt -P RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3

or

$ minisign -Vm myfile.txt -p signature.pub

This requires the signature myfile.txt.minisig to be present in the same directory.

The public key can either reside in a file (./minisign.pub by default) or be directly specified on the command line.

Usage


Usage:
minisign -G [-p pubkey] [-s seckey]
minisign -S [-l] [-x sigfile] [-s seckey] [-c untrusted_comment] [-t trusted_comment] -m file [file ...]
minisign -V [-H] [-x sigfile] [-p pubkeyfile | -P pubkey] [-o] [-q] -m file
minisign -R -s seckey -p pubkeyfile

-G generate a new key pair
-H require input to be prehashed
-S sign files
-V verify that a signature is valid for a given file
-l sign using the legacy format
-m <file> file to sign/verify
-o combined with -V, output the file content after verification
-p <pubkeyfile> public key file (default: ./minisign.pub)
-P <pubkey> public key, as a base64 string
-s <seckey> secret key file (default: ~/.minisign/minisign.key)
-x <sigfile> signature file (default: <file>.minisig)
-c <comment> add a one-line untrusted comment
-t <comment> add a one-line trusted comment
-q quiet mode, suppress output
-Q pretty quiet mode, only print the trusted comment
-R recreate a public key file from a secret key file
-f force. Combined with -G, overwrite a previous key pair
-v display version number

Trusted comments

Signature files include an untrusted comment line that can be freely modified, even after signature creation.

They also include a second comment line, that cannot be modified without the secret key.

Trusted comments can be used to add instructions or application-specific metadata (intended file name, timestamps, resource identifiers, version numbers to prevent downgrade attacks).

Compilation / installation

Using Zig

Dependencies:

Compilation:

$ zig build -Drelease-safe

Using Cmake

Dependencies

  • libsodium
  • cmake
  • make
  • pkg-config
  • a C compilation toolchain

Compilation:

$ mkdir build
$ cd build
$ cmake ..
$ make
# make install

Pre-hashing

By default, files are signed and verified with very low memory requirements, by pre-hashing the content.

Signatures that are not pre-hashed can be rejected with the -H switch. Support for these legacy signatures will eventually be removed.

Signature format

untrusted comment: <arbitrary text>
base64(<signature_algorithm> || <key_id> || <signature>)
trusted_comment: <arbitrary text>
base64(<global_signature>)
  • signature_algorithmEd (legacy) or ED (hashed)
  • key_id: 8 random bytes, matching the public key
  • signature (legacy): ed25519(<file data>)
  • signature (prehashed): ed25519(Blake2b-512(<file data>))
  • global_signatureed25519(<signature> || <trusted_comment>)

New implementations must use the hashed signature format; support for the legacy one is optional and should not be done by default.

Public key format

untrusted comment: <arbitrary text>
base64(<signature_algorithm> || <key_id> || <public_key>)
  • signature_algorithmEd
  • key_id: 8 random bytes
  • public_key: Ed25519 public key

Secret key format

untrusted comment: <arbitrary text>
base64(<signature_algorithm> || <kdf_algorithm> || <cksum_algorithm> ||
       <kdf_salt> || <kdf_opslimit> || <kdf_memlimit> || <keynum_sk>)
  • signature_algorithmEd
  • kdf_algorithmSc
  • cksum_algorithmB2
  • kdf_salt: 32 random bytes
  • kdf_opslimitcrypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE
  • kdf_memlimitcrypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE
  • keynum_sk<kdf_output> ^ (<key_id> || <secret_key> || <public_key> || <checksum>), 104 bytes
  • key_id: 8 random bytes
  • secret_key: Ed25519 secret key
  • public_key: Ed25519 public key
  • checksumBlake2b-256(<signature_algorithm> || <key_id> || <secret_key> || <public_key>), 32 bytes

Encryption

Looking for an equally simple tool for file and stream encryption? Check out Encpipe and Age.
from  https://jedisct1.github.io/minisign/
------

C# port of Ed25519 an elliptic-curve digital signature algorithm.

Ed25519 is an Elliptic Curve Digital Signature Algortithm based on Curve25519 developed by Dan BernsteinNiels DuifTanja LangePeter Schwabe, and Bo-Yin Yang.

This project is a C# port of the Java version that was a port of the Python implementation. Beware that this is a simple but very slow implementation and should be used for testing only.

If you need a faster implementation of Ed25519, have a look at:
https://github.com/CodesInChaos/Chaos.NaCl

Usage Example

byte[] signingKey = new byte[32];
RNGCryptoServiceProvider.Create().GetBytes(signingKey);

byte[] publicKey = Ed25519.PublicKey(signingKey);

byte[] message = Encoding.UTF8.GetBytes("This is a secret message");
byte[] signature = Ed25519.Signature(message, signingKey, publicKey);

bool signatureValid = Ed25519.CheckValid(signature, message, publicKey);
from  https://github.com/hanswolff/ed25519

No comments:

Post a Comment