1 /* |
1 /* |
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
25 * @test |
25 * @test |
26 * @bug 4942494 7146728 |
26 * @bug 4942494 7146728 |
27 * @summary KAT test for DH (normal and with secret that has leading a 0x00 byte) |
27 * @summary KAT test for DH (normal and with secret that has leading a 0x00 byte) |
28 * @author Andreas Sterbenz |
28 * @author Andreas Sterbenz |
29 * @library .. |
29 * @library .. |
|
30 * @run main/othervm TestShort |
|
31 * @run main/othervm TestShort sm |
30 */ |
32 */ |
31 |
33 |
32 import java.math.BigInteger; |
34 import java.math.BigInteger; |
33 import java.util.*; |
35 import java.security.KeyFactory; |
34 |
36 import java.security.PrivateKey; |
35 import java.security.*; |
37 import java.security.Provider; |
36 |
38 import java.security.PublicKey; |
37 import javax.crypto.*; |
39 import java.util.Arrays; |
38 import javax.crypto.spec.*; |
40 import javax.crypto.KeyAgreement; |
|
41 import javax.crypto.spec.DHPrivateKeySpec; |
|
42 import javax.crypto.spec.DHPublicKeySpec; |
39 |
43 |
40 public class TestShort extends PKCS11Test { |
44 public class TestShort extends PKCS11Test { |
41 |
45 |
42 private final static BigInteger p = new BigInteger |
46 private final static BigInteger p = new BigInteger |
43 ("132323768951986124075479307182674357577285270296234088722451560397577130" |
47 ("132323768951986124075479307182674357577285270296234088722451560397577130" |
81 private final static byte[] s3 = parse |
85 private final static byte[] s3 = parse |
82 ("98:62:f3:e4:ff:2b:8d:8a:5a:20:fe:52:35:56:73:09:8e:b3:e2:cb:e2:45:e5:b7:" |
86 ("98:62:f3:e4:ff:2b:8d:8a:5a:20:fe:52:35:56:73:09:8e:b3:e2:cb:e2:45:e5:b7:" |
83 + "1a:6a:15:d8:a4:8c:0a:ce:f0:15:03:0c:c2:56:82:a2:75:9b:49:fe:ed:60:c5:6e" |
87 + "1a:6a:15:d8:a4:8c:0a:ce:f0:15:03:0c:c2:56:82:a2:75:9b:49:fe:ed:60:c5:6e" |
84 + ":de:47:55:62:4f:16:20:6d:74:cc:7b:95:93:25:2c:ea"); |
88 + ":de:47:55:62:4f:16:20:6d:74:cc:7b:95:93:25:2c:ea"); |
85 |
89 |
|
90 @Override |
86 public void main(Provider provider) throws Exception { |
91 public void main(Provider provider) throws Exception { |
87 if (provider.getService("KeyAgreement", "DH") == null) { |
92 if (provider.getService("KeyAgreement", "DH") == null) { |
88 System.out.println("DH not supported, skipping"); |
93 System.out.println("DH not supported, skipping"); |
89 return; |
94 return; |
90 } |
95 } |