throw new NoSuchAlgorithmException(e.getMessage()); } catch (InvalidAlgorithmParameterException e) { throw new NoSuchAlgorithmException(e.getMessage());
throw new NoSuchAlgorithmException(e.getMessage()); } catch (InvalidAlgorithmParameterException e) { throw new NoSuchAlgorithmException(e.getMessage());
throw new NoSuchAlgorithmException(e.getMessage()); } catch (InvalidAlgorithmParameterException e) { throw new NoSuchAlgorithmException(e.getMessage());
} catch (NoSuchPaddingException npex) { throw new NoSuchAlgorithmException(npex.getMessage(), npex);
public CipherSpi( OAEPParameterSpec pSpec) { try { initFromSpec(pSpec); } catch (NoSuchPaddingException e) { throw new IllegalArgumentException(e.getMessage()); } }
public CipherSpi( OAEPParameterSpec pSpec) { try { initFromSpec(pSpec); } catch (NoSuchPaddingException e) { throw new IllegalArgumentException(e.getMessage()); } }
public CipherSpi( OAEPParameterSpec pSpec) { try { initFromSpec(pSpec); } catch (NoSuchPaddingException e) { throw new IllegalArgumentException(e.getMessage()); } }
public CipherSpi( OAEPParameterSpec pSpec) { try { initFromSpec(pSpec); } catch (NoSuchPaddingException e) { throw new IllegalArgumentException(e.getMessage()); } }
public CipherSpi( OAEPParameterSpec pSpec) { try { initFromSpec(pSpec); } catch (NoSuchPaddingException e) { throw new IllegalArgumentException(e.getMessage()); } }
public CipherSpi( OAEPParameterSpec pSpec) { try { initFromSpec(pSpec); } catch (NoSuchPaddingException e) { throw new IllegalArgumentException(e.getMessage()); } }
private static Cipher aesCipher() throws BraintreeEncryptionException { try { return Cipher.getInstance(TRANSFORMATION); } catch (NoSuchAlgorithmException e) { throw new BraintreeEncryptionException("No Such Algorithm: " + e.getMessage()); } catch (NoSuchPaddingException e) { throw new BraintreeEncryptionException("No Such Padding: " + e.getMessage()); } } }
/** * Returns an inputstream that will decrypt the bytes coming in through the specified input using the given key * @param theStream the stream to read encrypted data from * @param theKey the key to use for decryption * @return an input stream that will decrypt the data * @throws IOException if the stream cannot be read from, or if there is an error while decrypting */ public static InputStream decrypt(InputStream theStream, SecretKey theKey) throws IOException { try { return new CipherInputStream(theStream, createDecryptCipher(theKey)); } catch (InvalidAlgorithmParameterException e) { throw new IOException(e.getMessage()); } catch (InvalidKeyException e) { throw new IOException(e.getMessage()); } catch (NoSuchAlgorithmException e) { throw new IOException(e.getMessage()); } catch (NoSuchPaddingException e) { throw new IOException(e.getMessage()); } }
/** * Return an encrypted output stream using the given secret key * @param theStream the stream to encrypt * @param theKey the key to use for encryption * @return an encrypted streawm * @throws IOException thrown if there is an error while encrypting the stream */ public static OutputStream encrypt(OutputStream theStream, SecretKey theKey) throws IOException { try { return new CipherOutputStream(theStream, createEncryptCipher(theKey)); } catch (InvalidAlgorithmParameterException e) { throw new IOException(e.getMessage()); } catch (InvalidKeyException e) { throw new IOException(e.getMessage()); } catch (NoSuchAlgorithmException e) { throw new IOException(e.getMessage()); } catch (NoSuchPaddingException e) { throw new IOException(e.getMessage()); } }
throw e; } catch (NoSuchPaddingException e) { log.error("Error occurred during key initialization. Requested padding not available. "+e.getMessage()); throw e; } catch (InvalidKeyException e) {
return false; } catch (final NoSuchPaddingException nspex) { LOGGER.warn("no such padding: " + nspex.getMessage(), nspex); return false; } catch (final BadPaddingException bpex) {
/** * Initialize the ciphers used for encryption and decryption. The ciphers * define the algorithms to be used. They are initialized with the * appropriate key to be used in the encryption or decryption operation. */ protected void initDecryptCipher() throws CryptoException { // Create and initialize decryption cipher try { decryptCipher = Cipher.getInstance( cipherAlgorithm); decryptCipher.init( Cipher.DECRYPT_MODE, decryptKey, iv ); } catch ( NoSuchAlgorithmException e ) { throw new CryptoException(CorePlugin.Event.TEIID10009, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10009, cipherAlgorithm )); } catch ( NoSuchPaddingException e ) { throw new CryptoException(CorePlugin.Event.TEIID10010, CorePlugin.Util.gs(CorePlugin.Event.TEIID10010, cipherAlgorithm, e.getClass().getName(), e.getMessage() )); } catch ( InvalidKeyException e ) { throw new CryptoException(CorePlugin.Event.TEIID10011, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10011, e.getClass().getName(), e.getMessage()) ); } catch (InvalidAlgorithmParameterException e) { throw new CryptoException(CorePlugin.Event.TEIID10009, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10009, cipherAlgorithm )); } }
/** * Initialize the ciphers used for encryption and decryption. The ciphers * define the algorithms to be used. They are initialized with the * appropriate key to be used in the encryption or decryption operation. */ protected void initDecryptCipher() throws CryptoException { // Create and initialize decryption cipher try { decryptCipher = Cipher.getInstance( cipherAlgorithm); decryptCipher.init( Cipher.DECRYPT_MODE, decryptKey, iv ); } catch ( NoSuchAlgorithmException e ) { throw new CryptoException(CorePlugin.Event.TEIID10009, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10009, cipherAlgorithm )); } catch ( NoSuchPaddingException e ) { throw new CryptoException(CorePlugin.Event.TEIID10010, CorePlugin.Util.gs(CorePlugin.Event.TEIID10010, cipherAlgorithm, e.getClass().getName(), e.getMessage() )); } catch ( InvalidKeyException e ) { throw new CryptoException(CorePlugin.Event.TEIID10011, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10011, e.getClass().getName(), e.getMessage()) ); } catch (InvalidAlgorithmParameterException e) { throw new CryptoException(CorePlugin.Event.TEIID10009, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10009, cipherAlgorithm )); } }
public static String encrypt(byte[] data, String publicKeyString) throws BraintreeEncryptionException { Cipher rsa; try { rsa = Cipher.getInstance(TRANSFORMATION); PublicKey publicKey = publicKey(publicKeyString); rsa.init(Cipher.ENCRYPT_MODE, publicKey); byte[] encodedData = Base64.encode(data); byte[] encryptedData = rsa.doFinal(encodedData); return new String(Base64.encode(encryptedData)); } catch (NoSuchAlgorithmException e) { throw new BraintreeEncryptionException("No Such Algorithm: " + e.getMessage()); } catch (NoSuchPaddingException e) { throw new BraintreeEncryptionException("No Such Padding: " + e.getMessage()); } catch (InvalidKeyException e) { throw new BraintreeEncryptionException("Invalid Key: " + e.getMessage()); } catch (IllegalBlockSizeException e) { throw new BraintreeEncryptionException("Illegal Block Size: " + e.getMessage()); } catch (BadPaddingException e) { throw new BraintreeEncryptionException("Bad Padding: " + e.getMessage()); } }
/** * Initialize the cipher used for encryption. The cipher defines the * algorithm to be used. It is initialized with the appropriate key to * be used in the encryption operation. */ protected void initEncryptCipher() throws CryptoException { // Create and initialize encryption cipher try { encryptCipher = Cipher.getInstance( cipherAlgorithm ); encryptCipher.init( Cipher.ENCRYPT_MODE, encryptKey, iv ); } catch ( NoSuchAlgorithmException e ) { throw new CryptoException(CorePlugin.Event.TEIID10016, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10016, cipherAlgorithm )); } catch ( NoSuchPaddingException e ) { throw new CryptoException(CorePlugin.Event.TEIID10017, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10017, cipherAlgorithm , e.getMessage() )); } catch ( InvalidKeyException e ) { throw new CryptoException(CorePlugin.Event.TEIID10018, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10018, e.getMessage() )); } catch (InvalidAlgorithmParameterException e) { throw new CryptoException(CorePlugin.Event.TEIID10016, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10016, cipherAlgorithm )); } }
/** * Initialize the cipher used for encryption. The cipher defines the * algorithm to be used. It is initialized with the appropriate key to * be used in the encryption operation. */ protected void initEncryptCipher() throws CryptoException { // Create and initialize encryption cipher try { encryptCipher = Cipher.getInstance( cipherAlgorithm ); encryptCipher.init( Cipher.ENCRYPT_MODE, encryptKey, iv ); } catch ( NoSuchAlgorithmException e ) { throw new CryptoException(CorePlugin.Event.TEIID10016, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10016, cipherAlgorithm )); } catch ( NoSuchPaddingException e ) { throw new CryptoException(CorePlugin.Event.TEIID10017, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10017, cipherAlgorithm , e.getMessage() )); } catch ( InvalidKeyException e ) { throw new CryptoException(CorePlugin.Event.TEIID10018, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10018, e.getMessage() )); } catch (InvalidAlgorithmParameterException e) { throw new CryptoException(CorePlugin.Event.TEIID10016, e, CorePlugin.Util.gs(CorePlugin.Event.TEIID10016, cipherAlgorithm )); } }