I'm trying to sign a message with a private key. It works well, but the signature is encoded in DER encoding
. What I want is to get the signature in BER encoding
. Here is the method used to sign :
public static byte[] sign(String plainText, String privateKeyPath) throws
Exception {
PrivateKey privateKey = getPrivate(privateKeyPath);
System.out.println(privateKey.getAlgorithm());
Signature ecdsaSign = Signature.getInstance("SHA256withECDSA", "BC");
ecdsaSign.initSign(privateKey);
ecdsaSign.update(plainText.getBytes("UTF-8"));
byte[] signature = ecdsaSign.sign();
return signature;
}
I'm using BouncyCastle library
DER encoding is valid BER encoding
From X.690 summary in wikipedia