I'm looking for a Linux/Unix command-line tool to create a DSA signature from a given file/data and a private key.
I know about the xmlsec1 tool. But I would like something simpler. It seems that OpenSSL provides this function as a developer library, but not as a tool.
It's done with "openssl dgst" - not the most obvious place to put it...
Found in:
http://www.myelin.co.nz/post/2005/5/23/
The following tentative set of commands seems to work with openssl 1.0.2g and 1.1.0g. Compared to that other answer, it aims to generate a signature of the file (including the standard-mandated hash step), rather than a signature (including a second hash step) of the lowercase hexadecimal ASCII representation of a first hash of the file. Also it uses more modern hash and modulus size.
Note: A former attempt made openssl 1.0.2g generate signatures with 160-bit q (perhaps using SHA-1). Per comment, I added
-sha256
toopenssl dgst
, but it made no difference. Experiments suggest it is necessary to use-pkeyopt dsa_paramgen_q_bits:256
, even though the man page explicitly states-pkeyopt dsa_paramgen_md:sha256
takes care of that:Have you looked at:
openssl gendsa
openssl dsa
openssl pkcs8
Do you want to create a signature for a file such that the integrity of that file can be verified? I think you're looking for Gnu Privacy Guard (GnuPG).
This creates a signature file, filename.sig, based on the original, filename, that can be verified with