Skip to content

Commit a5fb3bd

Browse files
committed
Update Verify.cs
1 parent cec7798 commit a5fb3bd

File tree

1 file changed

+55
-35
lines changed

1 file changed

+55
-35
lines changed

tools/CustomBuildTool/Verify.cs

+55-35
Original file line numberDiff line numberDiff line change
@@ -348,42 +348,10 @@ private static string GetSalt(string Salt)
348348

349349
private static bool GetKeyMaterial(string KeyName, out byte[] KeyMaterial)
350350
{
351-
if (
352-
Win32.GetEnvironmentVariable(KeyName_Vars[KeyName].Key, out string key) &&
353-
Win32.GetEnvironmentVariable(KeyName_Vars[KeyName].Value, out string value) &&
354-
Win32.GetEnvironmentVariable("KPH_BUILD_SALT", out string salt)
355-
)
351+
if (Win32.GetEnvironmentVariable(KeyName_Vars[KeyName].Key, out string secret))
356352
{
357-
if (Uri.TryCreate(value, UriKind.Absolute, out Uri result) && result.IsFile)
358-
{
359-
using (var fileStream = File.OpenRead(value))
360-
{
361-
KeyMaterial = Decrypt(fileStream, key, salt);
362-
}
363-
}
364-
else
365-
{
366-
byte[] bytes = Utils.ReadAllBytes(value);
367-
KeyMaterial = Decrypt(bytes, key, salt);
368-
}
369-
370-
return true;
371-
}
372-
else if (Win32.GetEnvironmentVariable(KeyName_Vars[KeyName].Key, out string secret))
373-
{
374-
if (Uri.TryCreate(secret, UriKind.Absolute, out Uri result) && result.IsFile)
375-
{
376-
using (var fileStream = File.OpenRead(secret))
377-
{
378-
KeyMaterial = Decrypt(fileStream, secret, GetSalt(null));
379-
}
380-
}
381-
else
382-
{
383-
byte[] bytes = Utils.ReadAllBytes(GetPath($"{KeyName}.s"));
384-
KeyMaterial = Decrypt(bytes, secret, GetSalt(null));
385-
}
386-
353+
byte[] bytes = Utils.ReadAllBytes(GetPath($"{KeyName}.s"));
354+
KeyMaterial = Decrypt(bytes, secret, GetSalt(null));
387355
return true;
388356
}
389357
else if (File.Exists(GetPath($"{KeyName}.key")))
@@ -397,5 +365,57 @@ private static bool GetKeyMaterial(string KeyName, out byte[] KeyMaterial)
397365
return false;
398366
}
399367
}
368+
369+
//private static bool GetKeyMaterial(string KeyName, out byte[] KeyMaterial)
370+
//{
371+
// if (
372+
// Win32.GetEnvironmentVariable(KeyName_Vars[KeyName].Key, out string key) &&
373+
// Win32.GetEnvironmentVariable(KeyName_Vars[KeyName].Value, out string value) &&
374+
// Win32.GetEnvironmentVariable("KPH_BUILD_SALT", out string salt)
375+
// )
376+
// {
377+
// if (Uri.TryCreate(value, UriKind.Absolute, out Uri result) && result.IsFile)
378+
// {
379+
// using (var fileStream = File.OpenRead(value))
380+
// {
381+
// KeyMaterial = Decrypt(fileStream, key, salt);
382+
// }
383+
// }
384+
// else
385+
// {
386+
// byte[] bytes = Utils.ReadAllBytes(value);
387+
// KeyMaterial = Decrypt(bytes, key, salt);
388+
// }
389+
//
390+
// return true;
391+
// }
392+
// else if (Win32.GetEnvironmentVariable(KeyName_Vars[KeyName].Key, out string secret))
393+
// {
394+
// if (Uri.TryCreate(secret, UriKind.Absolute, out Uri result) && result.IsFile)
395+
// {
396+
// using (var fileStream = File.OpenRead(secret))
397+
// {
398+
// KeyMaterial = Decrypt(fileStream, secret, GetSalt(null));
399+
// }
400+
// }
401+
// else
402+
// {
403+
// byte[] bytes = Utils.ReadAllBytes(GetPath($"{KeyName}.s"));
404+
// KeyMaterial = Decrypt(bytes, secret, GetSalt(null));
405+
// }
406+
//
407+
// return true;
408+
// }
409+
// else if (File.Exists(GetPath($"{KeyName}.key")))
410+
// {
411+
// KeyMaterial = Utils.ReadAllBytes(GetPath($"{KeyName}.key"));
412+
// return true;
413+
// }
414+
// else
415+
// {
416+
// KeyMaterial = null;
417+
// return false;
418+
// }
419+
//}
400420
}
401421
}

0 commit comments

Comments
 (0)