Examples of AlgorithmParameterSpec


Examples of java.security.spec.AlgorithmParameterSpec

        try
        {
            Cipher cipher = Cipher.getInstance( "DES/CBC/NoPadding" );
            SecretKey key = new SecretKeySpec( keyBytes, "DES" );

            AlgorithmParameterSpec paramSpec = new IvParameterSpec( iv );

            if ( isEncrypt )
            {
                cipher.init( Cipher.ENCRYPT_MODE, key, paramSpec );
            }
View Full Code Here

Examples of java.security.spec.AlgorithmParameterSpec

      KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), this.salt, this.iterationCount);
      SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec);
      this.ecipher = Cipher.getInstance(key.getAlgorithm());
      this.dcipher = Cipher.getInstance(key.getAlgorithm());
      // Prepare the parameter to the ciphers
      AlgorithmParameterSpec paramSpec = new PBEParameterSpec(this.salt, this.iterationCount);
      // Create the ciphers
      this.ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
      this.dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
    } catch (InvalidAlgorithmParameterException e) {
    } catch (InvalidKeySpecException e) {
View Full Code Here

Examples of java.security.spec.AlgorithmParameterSpec

    public void marshalParams(XMLStructure parent, XMLCryptoContext context)
        throws MarshalException {

  super.marshalParams(parent, context);
  AlgorithmParameterSpec spec = getParameterSpec();
  if (spec == null) {
      return;
  }

  String prefix =
View Full Code Here

Examples of java.security.spec.AlgorithmParameterSpec

    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

Examples of java.security.spec.AlgorithmParameterSpec

        macName = (String) it.next();
        // we dont provide OMAC based on NullCipher through the JCE. skip
        if (macName.equals("omac-null"))
          continue;

        AlgorithmParameterSpec params = null;
        if (macName.equalsIgnoreCase("UMAC32"))
          {
            byte[] nonce = new byte[16];
            for (int i = 0; i < nonce.length; i++)
              nonce[i] = (byte) i;
View Full Code Here

Examples of java.security.spec.AlgorithmParameterSpec

        if (macName.startsWith(Registry.OMAC_PREFIX))
          continue;

        try
          {
            AlgorithmParameterSpec params = null;
            if (macName.equalsIgnoreCase("UMAC32"))
              {
                byte[] nonce = new byte[16];
                for (int i = 0; i < nonce.length; i++)
                  nonce[i] = (byte) i;
View Full Code Here

Examples of java.security.spec.AlgorithmParameterSpec

        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

Examples of java.security.spec.AlgorithmParameterSpec

            final String CipherAlgorithmMode = "CBC";
            final String CipherAlgorithmPadding = "PKCS5Padding";
            final String CryptoTransformation = CipherAlgorithmName + "/" + CipherAlgorithmMode + "/" + CipherAlgorithmPadding;
            SecretKeySpec ky = new SecretKeySpec(key, CipherAlgorithmName);
            byte []iv=new byte[16];
            AlgorithmParameterSpec aps = new IvParameterSpec(iv);
            Cipher cf = Cipher.getInstance(CryptoTransformation);
            if(encrypt)
                cf.init(Cipher.ENCRYPT_MODE, ky, aps);
            else
                cf.init(Cipher.DECRYPT_MODE, ky, aps);
View Full Code Here

Examples of java.security.spec.AlgorithmParameterSpec

                    cf.init(Cipher.ENCRYPT_MODE, ky);
                else
                    cf.init(Cipher.DECRYPT_MODE, ky);
            }else{
                byte []iv=new byte[16];
                AlgorithmParameterSpec aps = new IvParameterSpec(iv);
                if(encrypt)
                    cf.init(Cipher.ENCRYPT_MODE, ky, aps);
                else
                    cf.init(Cipher.DECRYPT_MODE, ky, aps);
            }
View Full Code Here

Examples of java.security.spec.AlgorithmParameterSpec

    public void marshalParams(XMLStructure parent, XMLCryptoContext context)
        throws MarshalException {

  super.marshalParams(parent, context);
  AlgorithmParameterSpec spec = getParameterSpec();
  if (spec == null) {
      return;
  }

  String prefix =
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.