我正在尝试使用私钥签署消息。它运作良好,但签名以DER encoding
. 我想要的是在BER encoding
. 这是用于签名的方法:
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;
}
我在用着BouncyCastle library