changeset 13122:f1bb1d3fcbf1

8176183: sun/security/mscapi/SignedObjectChain.java fails on Windows Reviewed-by: weijun
author igerasim
date Wed, 14 Feb 2018 10:04:46 -0800
parents 2edaf51db818
children e3f69c0c7764
files test/java/security/SignedObject/Chain.java
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/security/SignedObject/Chain.java	Fri Feb 09 08:24:05 2018 +0000
+++ b/test/java/security/SignedObject/Chain.java	Wed Feb 14 10:04:46 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -142,8 +142,17 @@
             PrivateKey[] privKeys = new PrivateKey[N];
             PublicKey[] pubKeys = new PublicKey[N];
             PublicKey[] anotherPubKeys = new PublicKey[N];
-            KeyPairGenerator kpg = KeyPairGenerator.getInstance(
-                    test.keyAlg.name);
+            Signature signature;
+            KeyPairGenerator kpg;
+            if (test.provider != Provider.Default) {
+                signature = Signature.getInstance(test.sigAlg.name,
+                        test.provider.name);
+                kpg = KeyPairGenerator.getInstance(
+                    test.keyAlg.name, test.provider.name);
+            } else {
+                signature = Signature.getInstance(test.sigAlg.name);
+                kpg = KeyPairGenerator.getInstance(test.keyAlg.name);
+            }
             for (int j=0; j < N; j++) {
                 if (test.keySize != -1) {
                     kpg.initialize(test.keySize);
@@ -162,14 +171,6 @@
                 }
             }
 
-            Signature signature;
-            if (test.provider != Provider.Default) {
-                signature = Signature.getInstance(test.sigAlg.name,
-                        test.provider.name);
-            } else {
-                signature = Signature.getInstance(test.sigAlg.name);
-            }
-
             // Create a chain of signed objects
             SignedObject[] objects = new SignedObject[N];
             objects[0] = new SignedObject(str, privKeys[0], signature);