Open adamhewitt627 opened 6 years ago
For the record, this outputs the same checksum as the .NET SDK
<?php
$aesKey = array(/* 16 byte key */);
$encryptionKey = implode(array_map("chr", $aesKey));
$kid = array(/* the 16 bytes that the UUID represents, C#'s System.Guid.ToByteArray() */);
$kidStr = implode(array_map("chr", $kid));
$encrypted = openssl_encrypt($kidStr, "AES-128-ECB", $encryptionKey, 1/*OPENSSL_RAW_DATA*/);
$checksum = substr($encrypted, 0, 8);
echo base64_encode($checksum)."\n";
?>
I'm fairly certain my understanding of this is correct, but:
When creating a new content key with a generated KID,
$contentKey = new ContentKey()
we see here that$this->_id
is used for the checksum, except from the constructor,_id
includes "nb:kid:UUID:". The .NET and REST documentation show creating this checksum from the Guid, not the entire entity ID as it would be on Azure.Example
The end result of this is a 500 error when trying to retrieve a FairPlay license. Everything about the key looks right, but the checksum is different than if I calculate it with .NET. Correct the checksum and the 500 error goes away.