< prev index next >

test/java/security/Signature/Offsets.java

Print this page
rev 12543 : 8181048: Refactor existing providers to refer to the same constants for default values for key length
Reviewed-by: mullan, ahgross

*** 1,7 **** /* ! * Copyright (c) 2015, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 32,42 **** import java.security.SignatureException; import jdk.testlibrary.RandomFactory; /* * @test ! * @bug 8050374 * @key randomness * @summary This test validates signature verification * Signature.verify(byte[], int, int). The test uses RandomFactory to * get random set of clear text data to sign. After the signature * generation, the test tries to verify signature with the above API --- 32,42 ---- import java.security.SignatureException; import jdk.testlibrary.RandomFactory; /* * @test ! * @bug 8050374 8181048 * @key randomness * @summary This test validates signature verification * Signature.verify(byte[], int, int). The test uses RandomFactory to * get random set of clear text data to sign. After the signature * generation, the test tries to verify signature with the above API
*** 103,124 **** --- 103,131 ---- // create signature instance Signature signature = Signature.getInstance(algorithm, provider); String keyAlgo; + int keySize = 2048; if (algorithm.contains("RSA")) { keyAlgo = "RSA"; } else if (algorithm.contains("ECDSA")) { keyAlgo = "EC"; + keySize = 256; } else if (algorithm.contains("DSA")) { keyAlgo = "DSA"; + if (algorithm.startsWith("SHAwith") || + algorithm.startsWith("SHA1with")) { + keySize = 1024; + } } else { throw new RuntimeException("Test doesn't support this signature " + "algorithm: " + algorithm); } KeyPairGenerator kpg = KeyPairGenerator.getInstance(keyAlgo, provider); + kpg.initialize(keySize); KeyPair kp = kpg.generateKeyPair(); PublicKey pubkey = kp.getPublic(); PrivateKey privkey = kp.getPrivate(); return new Offsets(signature, pubkey, privkey, size, cleartext);
< prev index next >