Search in sources :

Example 1 with VerifyResult

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

the class SQLServerColumnEncryptionAzureKeyVaultProvider method AzureKeyVaultVerifySignature.

/**
 * Verifies the given RSA PKCSv1.5 signature.
 *
 * @param dataToVerify
 * @param signature
 * @param masterKeyPath
 *        - Azure Key Vault key url.
 * @return true if signature is valid, false if it is not valid
 * @throws SQLServerException
 */
private boolean AzureKeyVaultVerifySignature(byte[] dataToVerify, byte[] signature, String masterKeyPath) throws SQLServerException {
    assert ((null != dataToVerify) && (0 != dataToVerify.length));
    assert ((null != signature) && (0 != signature.length));
    CryptographyClient cryptoClient = getCryptographyClient(masterKeyPath);
    VerifyResult valid = cryptoClient.verify(SignatureAlgorithm.RS256, dataToVerify, signature);
    return valid.isValid();
}
Also used : CryptographyClient(com.azure.security.keyvault.keys.cryptography.CryptographyClient) VerifyResult(com.azure.security.keyvault.keys.cryptography.models.VerifyResult)

Example 2 with VerifyResult

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

the class SQLServerColumnEncryptionAzureKeyVaultProvider method AzureKeyVaultVerifySignature.

/**
 * Verifies the given RSA PKCSv1.5 signature.
 *
 * @param dataToVerify
 * @param signature
 * @param masterKeyPath
 *        - Azure Key Vault key url.
 * @return true if signature is valid, false if it is not valid
 * @throws SQLServerException
 */
private boolean AzureKeyVaultVerifySignature(byte[] dataToVerify, byte[] signature, String masterKeyPath) throws SQLServerException {
    assert ((null != dataToVerify) && (0 != dataToVerify.length));
    assert ((null != signature) && (0 != signature.length));
    CryptographyClient cryptoClient = getCryptographyClient(masterKeyPath);
    VerifyResult valid = cryptoClient.verify(SignatureAlgorithm.RS256, dataToVerify, signature);
    return valid.isValid();
}
Also used : CryptographyClient(com.azure.security.keyvault.keys.cryptography.CryptographyClient) VerifyResult(com.azure.security.keyvault.keys.cryptography.models.VerifyResult)

Aggregations

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