Unclear how to decrypt exported files when using provided storage
When using ProvisionMigrationContainers and CreateSPAsyncReadJob, all output files are encrypted. It is not clear from the documentation how to obtain the IVs to decrypt the output files.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 1654a603-da1f-b11b-fd2f-9aa20e9fac02
- Version Independent ID: e8453081-caea-ee38-137d-3cfe2c145f45
- Content: Sharepoint Migration Export (Asynchronous Metadata Read) API
- Content Source: docs/apis/export-amr-api.md
- Product: sharepoint-server-itpro
- GitHub Login: @JoanneHendrickson
- Microsoft Alias: jhendr
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
When using the encryption option, the messages in the queue will also get encrypted.
It is important to remember the Job ID. Without the specific key used for the job, you won’t be able to read the message back.
Here is the JSON content in the queue message
{"Label", "Encrypted"},
{"JobId", "[JobId value]"},
{"IV", "[IV value in base64format]"},
{"Content", "[encrypted message in base64string]"}
Once the messages are decrypted, they will be the same as the API without encryption.
More information is here: migration-api-encryption.md
I have no problem decrypting queue messages when I use the storage provided by ProvisionMigrationContainers and ProvisionMigrationQueue. I use the encryption key returned by ProvisionMigrationContainers and the IV present in each queue message.
It’s the files written to the metadata and data blob containers that I can’t decrypt. I have the encryption key returned by ProvisionMigrationContainers, but I don’t know where to find the IV to decrypt each file. For example, where are the IVs to decrypt SystemData.xml? Manifest.xml?
It is also frustrating not to have List access to the metadata and data blob containers. It would be convenient to be able to browse the files produced by CreateSPAsyncReadJob.
Thanks, Jim Jim Osborne | Senior Developer | 202-754-8067 www.BinaryTree.comhttp://www.binarytree.com/ | [Facebook]https://www.facebook.com/BinaryTreeInc/[LinkedIn]https://www.linkedin.com/company/binary-tree[Twitter]https://twitter.com/binarytreeinc[YouTube]http://www.youtube.com/user/BinaryTreeSoftware[News and Events]https://www.binarytree.com/news-events/[Blog]https://www.binarytree.com/blog/[NeedToMeet.com]http://www.needtomeet.com/[Google+]https://plus.google.com/+BinaryTreeMigration/posts
From: Dennis-LZ [email protected] Sent: Tuesday, October 1, 2019 4:03 AM To: SharePoint/sp-dev-docs [email protected] Cc: Jim Osborne [email protected]; Author [email protected] Subject: Re: [SharePoint/sp-dev-docs] Unclear how to decrypt exported files when using provided storage (#4699)
When using the encryption option, the messages in the queue will also get encrypted.
It is important to remember the Job ID. Without the specific key used for the job, you won’t be able to read the message back.
Here is the JSON content in the queue message
{"Label", "Encrypted"},
{"JobId", "[JobId value]"},
{"IV", "[IV value in base64format]"},
{"Content", "[encrypted message in base64string]"}
Once the messages are decrypted, they will be the same as the API without encryption.
More information is here: migration-api-encryption.mdhttps://github.com/SharePoint/sp-dev-docs/blob/master/docs/apis/migration-api-encryption.md
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/SharePoint/sp-dev-docs/issues/4699?email_source=notifications&email_token=ALZ4YDTVGYUNQ5UNRMBDBNLQMMG4LA5CNFSM4I4BQ22KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAARJ6Y#issuecomment-536941819, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALZ4YDU3F6E5GE724TYIF43QMMG4LANCNFSM4I4BQ22A.
Ugh. I now know that signatures are not stripped when replying to a thread via email.
Try to use the method below to decrypt the data.
/// <summary>
/// AES256CBC Decrypt
/// </summary>
/// <param name="cipherData"></param>
/// <param name="keyString"></param>
/// <param name="ivString"></param>
/// <returns></returns>
public static string Decrypt(string cipherData, string keyString, string ivString)
{
byte[] key = Encoding.UTF8.GetBytes(keyString);
byte[] iv = Encoding.UTF8.GetBytes(ivString);
try
{
using (var rijndaelManaged =
new RijndaelManaged { Key = key, IV = iv, Mode = CipherMode.CBC })
using (var memoryStream =
new MemoryStream(Convert.FromBase64String(cipherData)))
using (var cryptoStream =
new CryptoStream(memoryStream,
rijndaelManaged.CreateDecryptor(key, iv),
CryptoStreamMode.Read))
{
return new StreamReader(cryptoStream).ReadToEnd();
}
}
catch (CryptographicException e)
{
Console.WriteLine("A Cryptographic error occurred: {0}", e.Message);
return null;
}
// You may want to catch more exceptions here...
}
I know how to decrypt data once I have the data, key, and IV. The problem is that, for output files like SystemData.xml, I only know how to obtain the data and key, not the IV.
Closing issue as "answered". If you encounter similar issue(s), please open up a NEW issue. Thank you.
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues