< prev index next >

test/java/security/Signature/Offsets.java

Print this page
rev 17325 : 8181761: add explicit @build actions for jdk.test.lib classes in all :tier2 tests
Reviewed-by: duke


  25 import java.security.KeyPair;
  26 import java.security.KeyPairGenerator;
  27 import java.security.NoSuchAlgorithmException;
  28 import java.security.NoSuchProviderException;
  29 import java.security.PrivateKey;
  30 import java.security.PublicKey;
  31 import java.security.Signature;
  32 import java.security.SignatureException;
  33 import jdk.test.lib.RandomFactory;
  34 
  35 /*
  36  * @test
  37  * @bug 8050374
  38  * @key randomness
  39  * @summary This test validates signature verification
  40  *          Signature.verify(byte[], int, int). The test uses RandomFactory to
  41  *          get random set of clear text data to sign. After the signature
  42  *          generation, the test tries to verify signature with the above API
  43  *          and passing in different signature offset (0, 33, 66, 99).
  44  * @library /test/lib

  45  * @run main Offsets SUN NONEwithDSA
  46  * @run main Offsets SUN SHA1withDSA
  47  * @run main Offsets SUN SHA224withDSA
  48  * @run main Offsets SUN SHA256withDSA
  49  */
  50 public class Offsets {
  51 
  52     private final int size;
  53     private final byte[] cleartext;
  54     private final PublicKey pubkey;
  55     private final Signature signature;
  56     private final byte[] signed;
  57 
  58     private Offsets(Signature signature, PublicKey pubkey, PrivateKey privkey,
  59             int size, byte[] cleartext) throws InvalidKeyException,
  60                 SignatureException {
  61         this.pubkey = pubkey;
  62         this.signature = signature;
  63         this.size = size;
  64         this.cleartext = cleartext;




  25 import java.security.KeyPair;
  26 import java.security.KeyPairGenerator;
  27 import java.security.NoSuchAlgorithmException;
  28 import java.security.NoSuchProviderException;
  29 import java.security.PrivateKey;
  30 import java.security.PublicKey;
  31 import java.security.Signature;
  32 import java.security.SignatureException;
  33 import jdk.test.lib.RandomFactory;
  34 
  35 /*
  36  * @test
  37  * @bug 8050374
  38  * @key randomness
  39  * @summary This test validates signature verification
  40  *          Signature.verify(byte[], int, int). The test uses RandomFactory to
  41  *          get random set of clear text data to sign. After the signature
  42  *          generation, the test tries to verify signature with the above API
  43  *          and passing in different signature offset (0, 33, 66, 99).
  44  * @library /test/lib
  45  * @build jdk.test.lib.RandomFactory
  46  * @run main Offsets SUN NONEwithDSA
  47  * @run main Offsets SUN SHA1withDSA
  48  * @run main Offsets SUN SHA224withDSA
  49  * @run main Offsets SUN SHA256withDSA
  50  */
  51 public class Offsets {
  52 
  53     private final int size;
  54     private final byte[] cleartext;
  55     private final PublicKey pubkey;
  56     private final Signature signature;
  57     private final byte[] signed;
  58 
  59     private Offsets(Signature signature, PublicKey pubkey, PrivateKey privkey,
  60             int size, byte[] cleartext) throws InvalidKeyException,
  61                 SignatureException {
  62         this.pubkey = pubkey;
  63         this.signature = signature;
  64         this.size = size;
  65         this.cleartext = cleartext;


< prev index next >