Package javax.crypto

Examples of javax.crypto.Cipher.unwrap()


      throw new RuntimeException(e);
    }     
   
    if (Cipher.UNWRAP_MODE == encryptionMode) {
      try {
        Key plaintextKey = cipher.unwrap(params.getEncryptedKey(), params.getAlgorithmName(), Cipher.SECRET_KEY);
        params.setPlaintextKey(plaintextKey.getEncoded());
      } catch (InvalidKeyException e) {
        log.error(e);
        throw new RuntimeException(e);
      } catch (NoSuchAlgorithmException e) {
View Full Code Here


        throw new RuntimeException(e);
      }     
     
      if (Cipher.UNWRAP_MODE == encryptionMode) {
        try {
          Key plaintextKey = cipher.unwrap(params.getEncryptedKey(), params.getAlgorithmName(), Cipher.SECRET_KEY);
          params.setPlaintextKey(plaintextKey.getEncoded());
        } catch (InvalidKeyException e) {
          log.error(e);
          throw new RuntimeException(e);
        } catch (NoSuchAlgorithmException e) {
View Full Code Here

    Key ret;

    try {   
      c.init(Cipher.UNWRAP_MODE, _key);
      ret = c.unwrap(encryptedBytes, jceKeyAlgorithm, Cipher.SECRET_KEY);
     
    } catch (InvalidKeyException ike) {
      throw new XMLEncryptionException("empty", ike);
    } catch (NoSuchAlgorithmException nsae) {
      throw new XMLEncryptionException("empty", nsae);
View Full Code Here

            if (oaepParameters == null) {
                c.init(Cipher.UNWRAP_MODE, key);
            } else {
                c.init(Cipher.UNWRAP_MODE, key, oaepParameters);
            }
            ret = c.unwrap(encryptedBytes, jceKeyAlgorithm, Cipher.SECRET_KEY);
        } catch (InvalidKeyException ike) {
            throw new XMLEncryptionException("empty", ike);
        } catch (NoSuchAlgorithmException nsae) {
            throw new XMLEncryptionException("empty", nsae);
        } catch (InvalidAlgorithmParameterException e) {
View Full Code Here

            IvParameterSpec ivSpec = new IvParameterSpec(ASN1OctetString.getInstance(kekAlgParams.getObjectAt(1)).getOctets());
            keyCipher.init(Cipher.UNWRAP_MODE, new SecretKeySpec(((CMSPBEKey)key).getEncoded(kekAlgName), kekAlgName), ivSpec);

            AlgorithmIdentifier aid = _encAlg;
            String              alg = aid.getObjectId().getId();
            Key                 sKey = keyCipher.unwrap(
                                        encryptedKey, alg, Cipher.SECRET_KEY);

            return getContentFromSessionKey(sKey, prov);
        }
        catch (NoSuchAlgorithmException e)
View Full Code Here

           
            try
            {
                keyCipher.init(Cipher.UNWRAP_MODE, key);

                sKey = keyCipher.unwrap(encryptedKey, alg, Cipher.SECRET_KEY);
            }
            catch (GeneralSecurityException e)   // some providers do not support UNWRAP
            {
                keyCipher.init(Cipher.DECRYPT_MODE, key);
View Full Code Here

            AlgorithmIdentifier aid = _encAlg;
            String              alg = aid.getObjectId().getId();

            byte[]              encryptedKey = _encryptedKey.getOctets();
            Key                 sKey = keyCipher.unwrap(
                                        encryptedKey, alg, Cipher.SECRET_KEY);

            return getContentFromSessionKey(sKey, prov);
        }
        catch (NoSuchAlgorithmException e)
View Full Code Here

            keyCipher.init(Cipher.UNWRAP_MODE, key);

            AlgorithmIdentifier aid = _encAlg;
            String              alg = aid.getObjectId().getId();
            Key                 sKey = keyCipher.unwrap(
                                        encryptedKey, alg, Cipher.SECRET_KEY);

            return getContentFromSessionKey(sKey, prov);
        }
        catch (NoSuchAlgorithmException e)
View Full Code Here

                // Key wrapping specified
                Cipher cipher = securityProvider == null ? Cipher
                        .getInstance(keyWrapAlgo) : Cipher.getInstance(
                        keyWrapAlgo, securityProvider);
                cipher.init(Cipher.UNWRAP_MODE, kek);
                return (SecretKey) cipher.unwrap(cekSecured, keyWrapAlgo,
                        Cipher.SECRET_KEY);
            }
            // fall back to the Encryption Only (EO) key decrypting method
            Cipher cipher;
            if (securityProvider != null) {
View Full Code Here

            Row row = null;
       
            try {
                Cipher cipher = Cipher.getInstance("RSA");
                cipher.init(Cipher.UNWRAP_MODE, publicKey);
                Key key = cipher.unwrap(getCixKey().wrappedKey, "DES", Cipher.SECRET_KEY);
                row = (Row)getEncryedData().getObject(key);
            } catch (Exception e) {
                e.printStackTrace();
            }
       
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.