Package net.snowflake.client.jdbc.cloud.storage

## Class EncryptionProvider

- java.lang.Object
- - net.snowflake.client.jdbc.cloud.storage.EncryptionProvider

    public class EncryptionProvider
    extends Object

Handles encryption and decryption using AES CBC (for files) and ECB (for keys).

### Constructor Summary

Constructors
`EncryptionProvider()`

### Method Summary

All Methods Static Methods Concrete Methods
`static void` `decrypt​(File file, String keyBase64, String ivBase64, net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat)`
`static InputStream` `decryptStream​(InputStream inputStream, String keyBase64, String ivBase64, net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat)` Decrypt a InputStream
`static CipherInputStream` `encrypt​(StorageObjectMetadata meta, long originalContentLength, InputStream src, net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat, SnowflakeStorageClient client)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### EncryptionProvider

    public EncryptionProvider()

### Method Detail

#### decryptStream

    public static InputStream decryptStream​(InputStream inputStream,
                                            String keyBase64,
                                            String ivBase64,
                                            net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat)
                                     throws NoSuchPaddingException,
                                            NoSuchAlgorithmException,
                                            InvalidKeyException,
                                            BadPaddingException,
                                            IllegalBlockSizeException,
                                            InvalidAlgorithmParameterException

Decrypt a InputStream

Parameters:
  `inputStream` - input stream
  `keyBase64` - keyBase64
  `ivBase64` - ivBase64
  `encMat` - RemoteStoreFileEncryptionMaterial
Returns:
  InputStream
Throws:
  `NoSuchPaddingException` - when padding mechanism is not available for this environment
  `NoSuchAlgorithmException` - when the requested algorithm is not available for this environment
  `InvalidKeyException` - when there is an issue with the key value
  `BadPaddingException` - when the data is not padded as expected
  `IllegalBlockSizeException` - when the length of data is incorrect
  `InvalidAlgorithmParameterException` - when the provided KeyStore has no trustAnchors

#### decrypt

    public static void decrypt​(File file,
                               String keyBase64,
                               String ivBase64,
                               net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat)
                        throws NoSuchAlgorithmException,
                               NoSuchPaddingException,
                               InvalidKeyException,
                               IllegalBlockSizeException,
                               BadPaddingException,
                               InvalidAlgorithmParameterException,
                               IOException

Throws:
  `NoSuchAlgorithmException`
  `NoSuchPaddingException`
  `InvalidKeyException`
  `IllegalBlockSizeException`
  `BadPaddingException`
  `InvalidAlgorithmParameterException`
  `IOException`

#### encrypt

    public static CipherInputStream encrypt​(StorageObjectMetadata meta,
                                            long originalContentLength,
                                            InputStream src,
                                            net.snowflake.common.core.RemoteStoreFileEncryptionMaterial encMat,
                                            SnowflakeStorageClient client)
                                     throws InvalidKeyException,
                                            InvalidAlgorithmParameterException,
                                            NoSuchAlgorithmException,
                                            NoSuchProviderException,
                                            NoSuchPaddingException,
                                            FileNotFoundException,
                                            IllegalBlockSizeException,
                                            BadPaddingException

Throws:
  `InvalidKeyException`
  `InvalidAlgorithmParameterException`
  `NoSuchAlgorithmException`
  `NoSuchProviderException`
  `NoSuchPaddingException`
  `FileNotFoundException`
  `IllegalBlockSizeException`
  `BadPaddingException`