This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.microsoft.azure.AzureEnvironment; | |
import com.microsoft.azure.credentials.ApplicationTokenCredentials; | |
import com.microsoft.azure.keyvault.KeyVaultClient; | |
import com.microsoft.azure.keyvault.models.KeyOperationResult; | |
import com.microsoft.azure.keyvault.webkey.JsonWebKeyEncryptionAlgorithm; | |
public class MyKeyVaultTest { | |
public static String CLIENT_ID = "<<your application id>>"; | |
public static String DOMAIN_ID = "<<your orgnization id>>"; | |
public static String SECRET = "<<your secret>>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Name | Supported key type(s) | Cost | Programming Interface | |
---|---|---|---|---|
AWS HSM | AES, RSA, EC | at least $1044 per month | C/C++/Java | |
AWS KMS | AES/GCM | $1/key/month + $0.03 per 10k request | AWS SDK | |
Azure Key Vault | RSA, EC | $1/key/month + $0.03 per 10k request | Azure SDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA"); | |
kpGen.initialize(2048); | |
KeyPair keyPair = kpGen.generateKeyPair(); | |
Random random = new SecureRandom(); | |
byte[] data = new byte[256]; | |
random.nextBytes(data); | |
Cipher cipher = Cipher.getInstance(__RSA_ENCRYPTION__); | |
cipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+---------------------------------------+-----------+ | |
| Encryption | Max bytes | | |
+---------------------------------------+-----------+ | |
| RSA/ECB/NoPadding | 256 | | |
| RSA/ECB/PKCS1Padding | 245 | | |
| RSA/ECB/OAEPPadding | 214 | | |
| RSA/ECB/OAEPWithSHA-1AndMGF1Padding | 214 | | |
| RSA/ECB/OAEPWithSHA-224AndMGF1Padding | 198 | | |
| RSA/ECB/OAEPWithSHA-256AndMGF1Padding | 190 | | |
| RSA/ECB/OAEPWithSHA-384AndMGF1Padding | 158 | |