Azure-RMSDocs icon indicating copy to clipboard operation
Azure-RMSDocs copied to clipboard

Unprotected content length for decryption ?

Open puthurr opened this issue 2 years ago • 0 comments

Hi All,

The DecryptBuffer method on the protection handler expects the following parameters

  • offsetFromStart: Relative position of inputBuffer from the very beginning of the encrypted content
  • inputBuffer: Buffer of encrypted content that will be decrypted
  • inputBufferSize: Size (in bytes) of input buffer
  • outputBuffer: Buffer into which decrypted content will be copied
  • outputBufferSize: Size (in bytes) of output buffer
  • isFinal: If input buffer contains the final encrypted bytes or not

=> Returns: Actual size (in bytes) of decrypted content

How could you estimate the size of the decrypted content buffer for the outputBufferSize/outputBufferSize ?

In your example, the variable bufferSize was known as per the encryption example (size of the string to encrypt)...In real cases, we wouldn't know that information upfront.

byte[] decryptedBuffer = new byte[bufferSize]; var bytesDecrypted = consumptionHandler.DecryptBuffer(0, encryptedTextBuffer, decryptedBuffer, true);

I see a GetProtectedContentLength but no correspondence for a GetUnProtectedContentLength.

Let me know.

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

puthurr avatar Mar 17 '23 09:03 puthurr