Is there any way to encrypt a string which is more than 255 characters using azure keyvault

Viewed 195

We are using key from key vault to encrypt a token. The token includes user id. For some of the users, the length is big. so encryption is failing as it supports only 255 characters. Is there any way we can handle it?

'kty': 'RSA',
  'key_size': 2048,
  'key_ops': [
    'encrypt',
    'decrypt'
  ],
  'key_attributes': { expires: date },
  'attributes': {
    'recoveryLevel': 'Recoverable',
    'enabled': true
  }
2 Answers

AFAIK, according to the MsDoc it is not possible to encrypt a string which is more than 255 characters using azure keyvault.

  • Key Vault stores and manages secrets with a maximum size of 25k bytes each .
  • You can try encrypting it via Key encrypted/decrypted blobs using Azure Key vault.
  • You can make use of symmetric class because a secret is essentially a symmetric key.
  • The key in a SymmetricKey has to be a fixed length 128, 192, 256, 384, or 512 bits and it should be Base64 encoded.
  • Key Vault secret used as a SymmetricKey
  • It needs to have a Content Type of "application/octet-stream" in Key Vault.

For more information in detail, please refer below links:

https://docs.microsoft.com/en-us/azure/storage/blobs/storage-encrypt-decrypt-blobs-key-vault?tabs=dotnet#encrypt-blob-and-upload

Azure Key Vault service limits

You could break the string value into 255-character segments.

Related