Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unprotected content length for decryption ? #1515

Open
puthurr opened this issue Mar 17, 2023 · 0 comments
Open

Unprotected content length for decryption ? #1515

puthurr opened this issue Mar 17, 2023 · 0 comments

Comments

@puthurr
Copy link

puthurr commented Mar 17, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant