protected override void ProcessRecord() { if (!File.Exists(Path)) { throw new PSArgumentException("CPIX file not found: " + Path, "Path"); } var cpix = CpixDocument.Load(Path); if (!cpix.ContentKeysAreReadable) { throw new NotSupportedException("The content keys in the CPIX file are encrypted. This PowerShell command does not currently support decryption of encryted content keys."); } var communicationKey = Convert.FromBase64String(CommunicationKeyAsBase64); if (communicationKey.Length != 32) { throw new NotSupportedException("Communication key must be 256 bits long."); } foreach (var key in cpix.ContentKeys) { WriteVerbose("Adding key: " + key.Id); LicenseTokenLogic.AddKey(LicenseToken, key.Id, key.Value, communicationKey, KeyUsagePolicyName); } WriteObject(LicenseToken); }
protected override void ProcessRecord() { var communicationKey = Convert.FromBase64String(CommunicationKeyAsBase64); if (communicationKey.Length != 32) { throw new NotSupportedException("Communication key must be 256 bits long."); } var contentKey = Convert.FromBase64String(KeyAsBase64); if (contentKey.Length != 16) { throw new NotSupportedException("Content key must be 128 bits long."); } LicenseTokenLogic.AddKey(LicenseToken, KeyId, contentKey, communicationKey, KeyUsagePolicyName); WriteObject(LicenseToken); }