Allow downloading of encrypted content.

pull/8/head
Scott Ehlert 14 years ago
parent 96236acb0e
commit 1c181a351b

@ -25,8 +25,23 @@ namespace DepotDownloader
[BlobField( FieldKey = CDRAppRecordFields.eFieldCurrentVersionId, Depth = 1 )]
public int CurrentVersion { get; set; }
[BlobField( FieldKey = CDRAppRecordFields.eFieldVersionsRecord, Complex = true, Depth = 1 )]
public List<AppVersion> Versions { get; private set; }
[BlobField( FieldKey = CDRAppRecordFields.eFieldFilesystemsRecord, Complex = true, Depth = 1 )]
public List<FileSystem> FileSystems { get; set; }
public List<FileSystem> FileSystems { get; private set; }
}
class AppVersion
{
[BlobField( FieldKey = CDRAppVersionFields.eFieldVersionId )]
public uint VersionID { get; set; }
[BlobField( FieldKey = CDRAppVersionFields.eFieldDepotEncryptionKey )]
public string DepotEncryptionKey { get; set; }
[BlobField( FieldKey = CDRAppVersionFields.eFieldIsEncryptionKeyAvailable )]
public bool IsEncryptionKeyAvailable { get; set; }
}
class FileSystem
@ -124,6 +139,28 @@ namespace DepotDownloader
return app.CurrentVersion;
}
public static byte[] GetDepotEncryptionKey( int depotId, int version )
{
App app = GetAppBlob( depotId );
if ( app == null )
{
return null;
}
foreach ( AppVersion ver in app.Versions )
{
if ( ver.VersionID == version )
{
if ( ver.IsEncryptionKeyAvailable )
return DecodeHexString( ver.DepotEncryptionKey );
break;
}
}
return null;
}
public static List<int> GetDepotIDsForGameserver( string gameName )
{
List<int> appIDs = new List<int>();
@ -171,5 +208,18 @@ namespace DepotDownloader
return null;
}
}
static byte[] DecodeHexString( string hex )
{
if ( hex == null )
return null;
int chars = hex.Length;
byte[] bytes = new byte [ chars / 2 ];
for ( int i = 0 ; i < chars ; i += 2 )
bytes[ i / 2 ] = Convert.ToByte( hex.Substring( i, 2 ), 16 );
return bytes;
}
}
}

@ -122,6 +122,8 @@ namespace DepotDownloader
}
}
byte[] cryptKey = CDRManager.GetDepotEncryptionKey( depotId, depotVersion );
for ( int x = 0 ; x < manifest.Nodes.Count ; ++x )
{
var dirEntry = manifest.Nodes[ x ];
@ -192,7 +194,7 @@ namespace DepotDownloader
if ( fi.Exists && fi.Length == dirEntry.SizeOrCount )
continue;
var file = session.DownloadFile( dirEntry, ContentServerClient.StorageSession.DownloadPriority.High );
var file = session.DownloadFile( dirEntry, ContentServerClient.StorageSession.DownloadPriority.High, cryptKey );
File.WriteAllBytes( downloadPath, file );
}

Loading…
Cancel
Save