It depends on what algorithm (determined by key type) and padding you use.
If the key is a DSA key, or an ECC key used for ECDSA, those algorithms normally use randomized signatures to remain secure, and OpenSSL does so. (There is a variant scheme that makes k unique and unpredictable without making it truly random, but it is not widely used and not implemented in OpenSSL.)
If the key is an RSA key, OpenSSL supports 3 RSA paddings other than none
: pkcs1
(more exactly the type-1 scheme of PKCS#1 through v1.5, now retronymed RSASSA-PKCS1-v1_5), pss
, and x931
. dgst -sign
for RSA defaults to pkcs
, which is deterministic and should not produce varying results; if it does please edit your question with details (preferably using a test key). Only if you specify -sigopt rsa_padding_mode:pss
should you get a randomized result.
Note RSA encryption is different, and OpenSSL supports two paddings other than none
: pkcs1
(this time meaning RSAES-PKCS1-v1_5) and oaep
, both of which are randomized; the newer OAEP is randomized in a way that is provably secure which the older v1_5 scheme does not.