Unprotected content length for decryption ?
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.
- ID: 625e09a4-3fcf-57c9-c62c-5aea6c8e9d86
- Version Independent ID: 7151e733-3b59-a817-8cef-a5dfc3a2ddd2
- Content: Quickstart - Encrypt/Decrypt text using the C# MIP Protection SDK
- Content Source: mip/develop/quick-protection-encrypt-decrypt-text-csharp.md
- Service: information-protection
- GitHub Login: @msmbaldwin
- Microsoft Alias: mbaldwin