在java中有没有办法将ECDSA的签名格式设置为BER编码?
Is there a way to set signature format for ECDSA to BER encoding in java?
我正在尝试使用私钥签署消息。它运行良好,但签名编码为 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
DER 编码是有效的 BER 编码
来自 wikipedia
中的 X.690 摘要
DER (Distinguished Encoding Rules) is a restricted variant of BER for producing unequivocal transfer syntax for data structures described by ASN.1. Like CER, DER encodings are valid BER encodings. DER is the same thing as BER with all but one sender's options removed.
我正在尝试使用私钥签署消息。它运行良好,但签名编码为 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
DER 编码是有效的 BER 编码
来自 wikipedia
中的 X.690 摘要DER (Distinguished Encoding Rules) is a restricted variant of BER for producing unequivocal transfer syntax for data structures described by ASN.1. Like CER, DER encodings are valid BER encodings. DER is the same thing as BER with all but one sender's options removed.