So I am trying to generate an ECDSAwithHA256 signature in Java, and for that, I am using the BouncyCastle provider. The curve is a secp521r1.
To initalize the signer I am using:
public static final String SIGNATURE_ALGORITHEM = "SHA256withECDSA";
public void init() {
signer = Signature.getInstance(SIGNATURE_ALGORITHEM, BouncyCastleProvider.PROVIDER_NAME);
signer.initSign(privKey);
}
And to sign I am using
public byte[] sign(byte[] bytes) throws SignatureException {
signer.update(bytes);
byte[] signature = signer.sign();
System.out.println("Signature lenght is " + signature.length);
return signature;
}
The only problem now is, that when I am running the code, I get signatures with a length between 137 and 139 byte. But I expected to get always the same amount of bytes. Does somebody know what I have to change, that I have always the same signature length, but still a standardized signature format?