提交 20c17c10 编写于 作者: A apetcher

8221172: SunEC specific test is not limited to SunEC

Summary: Fixing a minor test bug in the SignatureDigestTruncate regression test
Reviewed-by: mullan
上级 e754cced
...@@ -91,22 +91,25 @@ public class SignatureDigestTruncate { ...@@ -91,22 +91,25 @@ public class SignatureDigestTruncate {
String privateKeyStr, String msgStr, String kStr, String sigStr) String privateKeyStr, String msgStr, String kStr, String sigStr)
throws Exception { throws Exception {
System.out.println("Testing " + alg + " with " + curveName);
byte[] privateKey = Convert.hexStringToByteArray(privateKeyStr); byte[] privateKey = Convert.hexStringToByteArray(privateKeyStr);
byte[] msg = Convert.hexStringToByteArray(msgStr); byte[] msg = Convert.hexStringToByteArray(msgStr);
byte[] k = Convert.hexStringToByteArray(kStr); byte[] k = Convert.hexStringToByteArray(kStr);
byte[] expectedSig = Convert.hexStringToByteArray(sigStr); byte[] expectedSig = Convert.hexStringToByteArray(sigStr);
AlgorithmParameters params = AlgorithmParameters.getInstance("EC"); AlgorithmParameters params =
AlgorithmParameters.getInstance("EC", "SunEC");
params.init(new ECGenParameterSpec(curveName)); params.init(new ECGenParameterSpec(curveName));
ECParameterSpec ecParams = ECParameterSpec ecParams =
params.getParameterSpec(ECParameterSpec.class); params.getParameterSpec(ECParameterSpec.class);
KeyFactory kf = KeyFactory.getInstance("EC"); KeyFactory kf = KeyFactory.getInstance("EC", "SunEC");
BigInteger s = new BigInteger(1, privateKey); BigInteger s = new BigInteger(1, privateKey);
ECPrivateKeySpec privKeySpec = new ECPrivateKeySpec(s, ecParams); ECPrivateKeySpec privKeySpec = new ECPrivateKeySpec(s, ecParams);
PrivateKey privKey = kf.generatePrivate(privKeySpec); PrivateKey privKey = kf.generatePrivate(privKeySpec);
Signature sig = Signature.getInstance(alg); Signature sig = Signature.getInstance(alg, "SunEC");
sig.initSign(privKey, new FixedRandom(k)); sig.initSign(privKey, new FixedRandom(k));
sig.update(msg); sig.update(msg);
byte[] computedSig = sig.sign(); byte[] computedSig = sig.sign();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册