Skip to content

Commit 18778ac

Browse files
committed
Add a way to load keys from data
1 parent aeaba74 commit 18778ac

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

LibXboxOne/Keys/DurangoKeys.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ public static bool LoadSignKey(string desiredKeyName, byte[] keyData, out bool i
205205
return true;
206206
}
207207

208+
public static bool LoadCikFromBytes(byte[] keyBytes)
209+
{
210+
var isNewKey = false;
211+
var keyCount = LoadCikKeys(keyBytes, out Guid[] loadedCiks);
212+
return keyCount > 0;
213+
}
214+
208215
public static bool LoadKey(KeyType keyType, string keyFilePath)
209216
{
210217
if (keyFilePath == String.Empty)

XVDTool/Program.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static void Main(string[] args)
4545
var signKeyFilepath = String.Empty;
4646
var odkFilepath = String.Empty;
4747
var cikFilepath = String.Empty;
48+
var cikData = String.Empty;
4849

4950
bool listKeys = false;
5051

@@ -85,6 +86,7 @@ static void Main(string[] args)
8586
{ "signfile=", v => signKeyFilepath = v },
8687
{ "odkfile=", v => odkFilepath = v },
8788
{ "cikfile=", v => cikFilepath = v },
89+
{ "cikdata=", v => cikData = v },
8890

8991
{ "sk|signkey=", v => signKeyToUse = v },
9092
{ "odk|odkid=", v =>
@@ -153,6 +155,7 @@ static void Main(string[] args)
153155
Console.WriteLine(fmt + "-signfile <path-to-file> - Path to xvd sign key (RSA)");
154156
Console.WriteLine(fmt + "-odkfile <path-to-file> - Path to Offline Distribution key");
155157
Console.WriteLine(fmt + "-cikfile <path-to-file> - Path to Content Instance key");
158+
Console.WriteLine(fmt + "-cikdata <data> - Byte data of the Content Instance key");
156159
Console.WriteLine();
157160
Console.WriteLine(fmt + "-sk (-signkey) <key-name> - Name of xvd sign key to use");
158161
Console.WriteLine(fmt + "-odk (-odkid) <id> - Id of Offline Distribution key to use (uint)");
@@ -224,7 +227,7 @@ static void Main(string[] args)
224227
}
225228
}
226229

227-
if (cikFilepath != String.Empty)
230+
if (cikFilepath != String.Empty && cikData == String.Empty)
228231
{
229232
if (!DurangoKeys.LoadKey(KeyType.Cik, cikFilepath))
230233
{
@@ -233,6 +236,15 @@ static void Main(string[] args)
233236
}
234237
}
235238

239+
if (cikFilepath == String.Empty && cikData != String.Empty)
240+
{
241+
if (!DurangoKeys.LoadCikFromBytes(Convert.FromBase64String(cikData)))
242+
{
243+
Console.WriteLine($"Failed to load CIK from hex string {cikData}");
244+
return;
245+
}
246+
}
247+
236248
if(signKeyToUse == String.Empty)
237249
{
238250
Console.WriteLine($"No desired signkey provided, falling back to {fallbackSignKey}");

0 commit comments

Comments
 (0)