@@ -348,42 +348,10 @@ private static string GetSalt(string Salt)
348
348
349
349
private static bool GetKeyMaterial ( string KeyName , out byte [ ] KeyMaterial )
350
350
{
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 ) )
356
352
{
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 ) ) ;
387
355
return true ;
388
356
}
389
357
else if ( File . Exists ( GetPath ( $ "{ KeyName } .key") ) )
@@ -397,5 +365,57 @@ private static bool GetKeyMaterial(string KeyName, out byte[] KeyMaterial)
397
365
return false ;
398
366
}
399
367
}
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
+ //}
400
420
}
401
421
}
0 commit comments