Package java.security

Examples of java.security.AlgorithmParameters


           InvalidAlgorithmParameterException,
           InvalidParameterSpecException,
           InvalidKeySpecException  {
    AlgorithmParameterGenerator pgen = AlgorithmParameterGenerator.getInstance("DH");
    pgen.init(512);
    AlgorithmParameters params = pgen.generateParameters();
    DHParameterSpec dhspec = (DHParameterSpec)params.getParameterSpec(DHParameterSpec.class);
    KeyPairGenerator keypairgen = KeyPairGenerator.getInstance("DH");
    keypairgen.initialize(dhspec);  
    keyPair = keypairgen.generateKeyPair();
    p = dhspec.getP();
    g = dhspec.getG();
View Full Code Here


    Provider fp = new Gnu();

    msg = "initialize(AlgorithmParameterSpec) MUST succeed";
    try
      {
        AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA", fp);
        AlgorithmParameterSpec spec =
            ap.getParameterSpec(DSAParameterSpec.class);
        kpg.initialize(spec);
        harness.check(true, msg);
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail(msg);
      }

    msg = "initialize(AlgorithmParameterSpec, SecureRandom) MUST succeed";
    try
      {
        AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA", fp);
        AlgorithmParameterSpec spec =
            ap.getParameterSpec(DSAParameterSpec.class);
        kpg.initialize(spec, rnd);
        harness.check(true, msg);
      }
    catch (Exception x)
      {
View Full Code Here

  public void test (TestHarness harness)
  {
    harness.checkPoint ("AlgorithmParameters");

    AlgorithmParameters spi;
    Provider provider = this;
    Security.addProvider(provider);
    String signature;

    spi = null;
View Full Code Here

        ciphertext = bobCipher.doFinal(cleartext);
        // Retrieve the parameter that was used, and transfer it to Alice
        byte[] encodedParams = bobCipher.getParameters().getEncoded();

        // Alice decrypts, using DES in CBC mode
        AlgorithmParameters params = AlgorithmParameters.getInstance("DES");
        params.init(encodedParams);
        aliceCipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
        aliceCipher.init(Cipher.DECRYPT_MODE, aliceSK, params);
        recovered = aliceCipher.doFinal(ciphertext);

        harness.check(Arrays.equals(cleartext, recovered),
View Full Code Here

        byte[] plaintext = input.getBytes();
        byte[] ciphertext = cipher.doFinal(plaintext);

        iv = null;

        AlgorithmParameters ap = cipher.getParameters();
        AlgorithmParameterSpec backupAlg = ap.getParameterSpec(IvParameterSpec.class);
        String msg = "(CBC Decrypt + null AlgorithmParameterSpec) init(3) MUST throw InvalidAlgorithmParameterException";
        try
          {
            // Should not be able to init a CBC cipher in DECRYPT opmode without
            // params
View Full Code Here

    {

        String s = "1.2.840.113549.3.2";

        AlgorithmParameterGenerator algorithmparametergenerator = AlgorithmParameterGenerator.getInstance(s);
        AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
        ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1"));
        ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream);
        ASN1Primitive derobject = asn1inputstream.readObject();
        KeyGenerator keygenerator = KeyGenerator.getInstance(s);
        keygenerator.init(128);
        SecretKey secretkey = keygenerator.generateKey();
View Full Code Here

    {
       
        String s = "1.2.840.113549.3.2";
       
        AlgorithmParameterGenerator algorithmparametergenerator = AlgorithmParameterGenerator.getInstance(s);
        AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
        ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1"));
        ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream);
        DERObject derobject = asn1inputstream.readObject();
        KeyGenerator keygenerator = KeyGenerator.getInstance(s);
        keygenerator.init(128);
        SecretKey secretkey = keygenerator.generateKey();
View Full Code Here

    {

        String s = "1.2.840.113549.3.2";

        AlgorithmParameterGenerator algorithmparametergenerator = AlgorithmParameterGenerator.getInstance(s);
        AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
        ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1"));
        ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream);
        DERObject derobject = asn1inputstream.readObject();
        KeyGenerator keygenerator = KeyGenerator.getInstance(s);
        keygenerator.init(128);
        SecretKey secretkey = keygenerator.generateKey();
View Full Code Here

    {

        String s = "1.2.840.113549.3.2";

        AlgorithmParameterGenerator algorithmparametergenerator = AlgorithmParameterGenerator.getInstance(s);
        AlgorithmParameters algorithmparameters = algorithmparametergenerator.generateParameters();
        ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(algorithmparameters.getEncoded("ASN.1"));
        ASN1InputStream asn1inputstream = new ASN1InputStream(bytearrayinputstream);
        DERObject derobject = asn1inputstream.readObject();
        KeyGenerator keygenerator = KeyGenerator.getInstance(s);
        keygenerator.init(128);
        SecretKey secretkey = keygenerator.generateKey();
View Full Code Here

        // algName == oid now
        boolean mappingExists = mapAlgName();
        // algName == name from map oid->name if mapping exists, or
        // algName == oid if mapping does not exist

        AlgorithmParameters aParams = null;
        byte[] params = aId.getParameters();
        if (params != null && !isNullValue(params)) {
            try {
                aParams = AlgorithmParameters.getInstance(algName);
                aParams.init(aId.getParameters());
                if (!mappingExists) {
                    algName = aParams.getAlgorithm();
                }
            } catch (NoSuchAlgorithmException e) {
            }
        }
        algParameters = aParams;
View Full Code Here

TOP

Related Classes of java.security.AlgorithmParameters

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.