Search in sources :

Example 1 with WrapResult

use of com.azure.security.keyvault.keys.cryptography.models.WrapResult in project mssql-jdbc by Microsoft.

the class SQLServerColumnEncryptionAzureKeyVaultProvider method AzureKeyVaultWrap.

/**
 * Encrypts the text using specified Azure Key Vault key.
 *
 * @param masterKeyPath
 *        - Azure Key Vault key url.
 * @param encryptionAlgorithm
 *        - Encryption Algorithm.
 * @param columnEncryptionKey
 *        - Plain text Column Encryption Key.
 * @return Returns an encrypted blob or throws an exception if there are any errors.
 * @throws SQLServerException
 */
private byte[] AzureKeyVaultWrap(String masterKeyPath, KeyWrapAlgorithm encryptionAlgorithm, byte[] columnEncryptionKey) throws SQLServerException {
    if (null == columnEncryptionKey) {
        throw new SQLServerException(SQLServerException.getErrString("R_CEKNull"), null);
    }
    CryptographyClient cryptoClient = getCryptographyClient(masterKeyPath);
    WrapResult wrappedKey = cryptoClient.wrapKey(KeyWrapAlgorithm.RSA_OAEP, columnEncryptionKey);
    return wrappedKey.getEncryptedKey();
}
Also used : WrapResult(com.azure.security.keyvault.keys.cryptography.models.WrapResult) CryptographyClient(com.azure.security.keyvault.keys.cryptography.CryptographyClient)

Example 2 with WrapResult

use of com.azure.security.keyvault.keys.cryptography.models.WrapResult in project mssql-jdbc by microsoft.

the class SQLServerColumnEncryptionAzureKeyVaultProvider method AzureKeyVaultWrap.

/**
 * Encrypts the text using specified Azure Key Vault key.
 *
 * @param masterKeyPath
 *        - Azure Key Vault key url.
 * @param encryptionAlgorithm
 *        - Encryption Algorithm.
 * @param columnEncryptionKey
 *        - Plain text Column Encryption Key.
 * @return Returns an encrypted blob or throws an exception if there are any errors.
 * @throws SQLServerException
 */
private byte[] AzureKeyVaultWrap(String masterKeyPath, KeyWrapAlgorithm encryptionAlgorithm, byte[] columnEncryptionKey) throws SQLServerException {
    if (null == columnEncryptionKey) {
        throw new SQLServerException(SQLServerException.getErrString("R_CEKNull"), null);
    }
    CryptographyClient cryptoClient = getCryptographyClient(masterKeyPath);
    WrapResult wrappedKey = cryptoClient.wrapKey(KeyWrapAlgorithm.RSA_OAEP, columnEncryptionKey);
    return wrappedKey.getEncryptedKey();
}
Also used : WrapResult(com.azure.security.keyvault.keys.cryptography.models.WrapResult) CryptographyClient(com.azure.security.keyvault.keys.cryptography.CryptographyClient)

Aggregations

CryptographyClient (com.azure.security.keyvault.keys.cryptography.CryptographyClient)2 WrapResult (com.azure.security.keyvault.keys.cryptography.models.WrapResult)2