I am trying to sign an existing digest with openssl.
Let's say I already have a digest 'mydigest'. With that said I dont want to use:
echo -n "mydigest" | openssl dgst -sha256 -sign key.pem | openssl enc -A -base64
I have ECDSA not rsa so I assume I should not use rsautl which is using the input as-is.
So my assumption is that I would need something which takes input as-is (mydigest) and sign it with my ECDSA private key.
I tried following in order to see if the size of hash created with different hash algorithm has any affect on sign result:
echo -n "mydigest" | openssl pkeyutl -sign -inkey key.pem | openssl enc -A -base64
and
echo -n "my-very-very-very-long-digest" | openssl pkeyutl -sign -inkey key.pem | openssl enc -A -base64
but the size of the outputs is same for both commands in terms of output length. I would assume for the large my-very..-long-digest it should return larger output (because it should take the input as-is without shortening (hashing).
========================================
EDIT.
Maybe the example below will help to understand what I am asking. This is an example with bouncycastle.
// sign something
String messageToSign = "something_to_sign";
ECDomainParameters domain = new ECDomainParameters(spec.getCurve(), spec.getG(), spec.getN());
ECDSASigner signer = new ECDSASigner();
signer.init(true, new ECPrivateKeyParameters(privateKey, domain));
MessageDigest digest = MessageDigest.getInstance("Keccak-256");
byte[] hash = digest.digest(messageToSign.getBytes(StandardCharsets.UTF_8));
BigInteger[] signature = signer.generateSignature(hash);
Let's assume I have following:
- hash.
- keys.
And now I want to create signature with openssl which should take the hash and keys as an input without creating the hash. Basically I want to replace
BigInteger[] signature = signer.generateSignature(hash);
in the example with openssl.
openssl * ????? *
I assumed the size of the results should indicate if the hash (with different digest size) algorithm I use for hash has any affect on results.