This repository was archived by the owner on Jun 22, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathUtils.cs
More file actions
4213 lines (3630 loc) · 129 KB
/
Copy pathUtils.cs
File metadata and controls
4213 lines (3630 loc) · 129 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using Microsoft.PowerShell.SecretManagement;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Management.Automation;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.AccessControl;
using System.Security.Cryptography;
using System.Security.Principal;
using System.Text;
using System.Threading;
using Dbg = System.Diagnostics.Debug;
namespace Microsoft.PowerShell.SecretStore
{
#region Utils
internal static class Utils
{
#region Members
internal const string PasswordRequiredMessage = "A valid password is required to access the Microsoft.PowerShell.SecretStore vault.\nUse the Unlock-SecretStore cmdlet to provide the required password to access the store.";
#endregion
#region Separators
internal static class Separators
{
public static readonly char[] Backslash = new char[] { '\\' };
}
#endregion
#region Constructor
static Utils()
{
IsWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(
System.Runtime.InteropServices.OSPlatform.Windows);
}
#endregion
#region Properties
public static bool IsWindows { get; }
#endregion
#region Methods
/// <summary>
/// Return current logged in user name in all upper case.
/// WindowsIdentity.GetCurrent().Name does not always return account user
/// name with correct casing (e.g., AD domain account with RunAs), and name
/// casing needs to be consistent for encryption.
/// </summary>
/// <param name="origCharCasing">
/// When true, user name is returned with char casing from system.
/// This is needed for backward compatibility when reading from older stores
/// encrypted with original character casing.
/// </param>
public static string GetCurrentUserName(
bool origCharCasing = false)
{
if (IsWindows)
{
try
{
var nameParts = WindowsIdentity.GetCurrent().Name.Split(Separators.Backslash);
switch (nameParts.Length)
{
case 1:
return origCharCasing ? nameParts[0] : nameParts[0].ToUpper();
case 2:
// 'DOMAIN\UserName'
return origCharCasing ? nameParts[1] : nameParts[1].ToUpper();
}
}
catch (SecurityException) { }
}
return origCharCasing ? Environment.UserName : Environment.UserName.ToUpper();
}
public static PSObject ConvertJsonToPSObject(string json)
{
var results = PowerShellInvoker.InvokeScriptCommon<PSObject>(
script: @"param ([string] $json) Microsoft.PowerShell.Utility\ConvertFrom-Json -InputObject $json",
args: new object[] { json },
error: out ErrorRecord _);
return (results.Count > 0) ? results[0] : null;
}
public static string ConvertHashtableToJson(Hashtable hashtable)
{
var results = PowerShellInvoker.InvokeScriptCommon<string>(
script: @"param ([hashtable] $hashtable) Microsoft.PowerShell.Utility\ConvertTo-Json -InputObject $hashtable -Depth 5",
args: new object[] { hashtable },
error: out ErrorRecord _);
return (results.Count > 0) ? results[0] : null;
}
public static bool GetSecureStringFromData(
byte[] data,
out SecureString outSecureString)
{
if ((data.Length % 2) != 0)
{
Dbg.Assert(false, "Blob length for SecureString secure must be even.");
outSecureString = null;
return false;
}
outSecureString = new SecureString();
var strLen = data.Length / 2;
for (int i=0; i < strLen; i++)
{
int index = (2 * i);
var ch = (char)(data[index + 1] * 256 + data[index]);
outSecureString.AppendChar(ch);
}
return true;
}
public static bool GetDataFromSecureString(
SecureString secureString,
out byte[] data)
{
IntPtr ptr = Marshal.SecureStringToCoTaskMemUnicode(secureString);
if (ptr != IntPtr.Zero)
{
try
{
data = new byte[secureString.Length * 2];
Marshal.Copy(ptr, data, 0, data.Length);
return true;
}
finally
{
Marshal.ZeroFreeCoTaskMemUnicode(ptr);
}
}
data = null;
return false;
}
private static bool ComparePasswords(
SecureString password1,
SecureString password2)
{
if (password1.Length != password2.Length)
{
return false;
}
IntPtr ptrPassword1 = IntPtr.Zero;
IntPtr ptrPassword2 = IntPtr.Zero;
try
{
ptrPassword1 = Marshal.SecureStringToCoTaskMemUnicode(password1);
ptrPassword2 = Marshal.SecureStringToCoTaskMemUnicode(password2);
if (ptrPassword1 != IntPtr.Zero && ptrPassword2 != IntPtr.Zero)
{
for (int i=0; i<(password1.Length * 2); i++)
{
if (Marshal.ReadByte(ptrPassword1, i) != Marshal.ReadByte(ptrPassword2, i))
{
return false;
}
}
return true;
}
}
finally
{
if (ptrPassword1 != IntPtr.Zero)
{
Marshal.ZeroFreeCoTaskMemUnicode(ptrPassword1);
}
if (ptrPassword2 != IntPtr.Zero)
{
Marshal.ZeroFreeCoTaskMemUnicode(ptrPassword2);
}
}
return false;
}
public static SecureString PromptForPassword(
PSCmdlet cmdlet,
bool verifyPassword = false,
string message = null)
{
if (cmdlet.Host is null || cmdlet.Host.UI is null)
{
throw new PSInvalidOperationException(
"Cannot prompt for password. No host available.");
}
SecureString password = null;
cmdlet.Host.UI.WriteLine(
string.IsNullOrEmpty(message) ?
"A password is required for Microsoft.PowerShell.SecretStore vault."
: message);
var isVerified = false;
do
{
// Initial prompt
cmdlet.Host.UI.WriteLine("Enter password:");
password = cmdlet.Host.UI.ReadLineAsSecureString();
if (password.Length == 0)
{
cmdlet.Host.UI.WriteLine("\nThe entered password cannot be empty. Please re-enter the password.\n");
continue;
}
if (verifyPassword)
{
// Verification prompt
cmdlet.Host.UI.WriteLine("Enter password again for verification:");
var passwordVerified = cmdlet.Host.UI.ReadLineAsSecureString();
isVerified = ComparePasswords(password, passwordVerified);
if (!isVerified)
{
cmdlet.Host.UI.WriteLine("\nThe two entered passwords do not match. Please re-enter the passwords.\n");
}
}
else
{
isVerified = true;
}
} while (!isVerified);
return password;
}
public static SecureString CheckPassword(SecureString password)
{
if (password != null && password.Length == 0)
{
throw new PSInvalidOperationException("A password cannot be empty.");
}
return password?.Copy() ?? null;
}
#endregion
}
#endregion
#region SecureStore
#region CryptoUtils
internal static class CryptoUtils
{
#region Private members
private static byte[] salt = new byte[32]
{
154, 146, 58, 204, 7, 124, 237, 132,
248, 95, 158, 243, 108, 235, 163, 103,
148, 95, 205, 190, 109, 184, 116, 92,
155, 12, 6, 99, 0, 91, 54, 250
};
#endregion
#region Public methods
public static AesKey GenerateKey()
{
// By default this creates a 256 AES key with 128 block size.
// IV size then, is 16.
byte[] key;
byte[] iv;
using (var aes = Aes.Create())
{
key = aes.Key;
iv = new byte[aes.BlockSize / 8];
}
using (var rng = RandomNumberGenerator.Create())
{
rng.GetBytes(iv);
}
return new AesKey(key, iv);
}
public static AesKey GenerateKeyFromUserName(
bool useOrigUserNameCasing = false)
{
var key = DeriveKeyFromPassword(
passwordData: Encoding.UTF8.GetBytes(Utils.GetCurrentUserName(useOrigUserNameCasing)),
keyLength: 32);
var iv = new byte[16]; // Zero IV.
return new AesKey(key, iv);
}
public static byte[] EncryptWithKey(
SecureString passWord,
AesKey key,
byte[] data)
{
var keyToUse = DeriveKeyFromKeyAndPasswordOrUser(passWord, key);
try
{
using (var aes = Aes.Create())
{
aes.Key = keyToUse.Key;
aes.IV = keyToUse.IV;
using (var encryptor = aes.CreateEncryptor())
using (var sourceStream = new MemoryStream(data))
using (var targetStream = new MemoryStream())
{
using (var cryptoStream = new CryptoStream(targetStream, encryptor, CryptoStreamMode.Write))
{
sourceStream.CopyTo(cryptoStream);
}
return targetStream.ToArray();
}
}
}
finally
{
keyToUse.Clear();
}
}
/// <summary>
/// Decrypts data with provided key and password value.
/// If no password, current user name is used to derive final key.
/// If decryption fails, it is retried with older version of username with
/// original character casing.
/// </summary>
public static byte[] DecryptWithKeyWithRetry(
SecureString passWord,
AesKey key,
byte[] data)
{
try
{
return DecryptWithKey(
passWord,
key,
data,
useOrigUserNameCasing: false);
}
catch (CryptographicException)
{
if (!(passWord is null))
{
throw new PasswordRequiredException(Utils.PasswordRequiredMessage);
}
}
// Retry but with original user name casing.
// This only applies when passWord is null, and username is substituted for key derivation.
try
{
return DecryptWithKey(
passWord,
key,
data,
useOrigUserNameCasing: true);
}
catch (CryptographicException)
{
throw new PasswordRequiredException(Utils.PasswordRequiredMessage);
}
}
/// <summary>
/// Decrypts data with no provided key, and uses current UserName to derive
/// the key.
/// UserName is converted to all upper case to ensure it is consistent.
/// (Workaround for bug: Windows AD account user name char casing).
/// If decryption fails, it is retried with older version of UserName with
/// original character casing.
/// </summary>
public static byte[] DecryptWithNoKeyWithRetry(
byte[] data)
{
var encryptKey = GenerateKeyFromUserName(useOrigUserNameCasing: false);
try
{
return DecryptWithKey(
passWord: null,
key: encryptKey,
data: data,
useOrigUserNameCasing: false);
}
catch (CryptographicException) { }
finally
{
encryptKey.Clear();
}
// Retry but with original user name casing.
encryptKey = GenerateKeyFromUserName(useOrigUserNameCasing: true);
try
{
return DecryptWithKey(
passWord: null,
key: encryptKey,
data: data,
useOrigUserNameCasing: true);
}
finally
{
encryptKey.Clear();
}
}
/// <summary>
/// Decrypt data key and password value.
/// If no password, then current user name is used to derive final key.
/// </summary>
private static byte[] DecryptWithKey(
SecureString passWord,
AesKey key,
byte[] data,
bool useOrigUserNameCasing = false)
{
var keyToUse = DeriveKeyFromKeyAndPasswordOrUser(passWord, key, useOrigUserNameCasing);
try
{
using (var aes = Aes.Create())
{
aes.Key = keyToUse.Key;
aes.IV = keyToUse.IV;
using (var decryptor = aes.CreateDecryptor())
using (var sourceStream = new MemoryStream(data))
using (var targetStream = new MemoryStream())
{
using (var cryptoStream = new CryptoStream(sourceStream, decryptor, CryptoStreamMode.Read))
{
cryptoStream.CopyTo(targetStream);
}
return targetStream.ToArray();
}
}
}
finally
{
keyToUse.Clear();
}
}
public static byte[] ComputeHashWithPasswordOrUser(
SecureString passWord,
byte[] dataToHash)
{
byte[] keyToUse = DeriveKeyFromPasswordOrUser(passWord);
try
{
return ComputeHash(keyToUse, dataToHash);
}
finally
{
ZeroOutData(keyToUse);
}
}
/// <summary>
/// Validates provided data blob with the provide hash value.
/// Hash is computed with a key derived from the provided password, or
/// the current UserName if no password.
/// UserName is returned in all upper case to ensure consistency.
/// (Workaround for bug: Windows AD account user name char casing).
/// If validation fails, it is retried with older version of UserName with
/// original character casing.
/// </summary>
public static bool ValidateHashWithPasswordOrUser(
SecureString passWord,
byte[] hash,
byte[] dataToValidate)
{
var keyToUse = DeriveKeyFromPasswordOrUser(passWord, useOrigUserNameCasing: false);
try
{
bool isValid = ValidateHash(
key: keyToUse,
hashToCompare: hash,
dataToValidate: dataToValidate);
if (!isValid && passWord is null)
{
// Try again but with original user name character casing,
// in case this is older encrypted data.
ZeroOutData(keyToUse);
keyToUse = DeriveKeyFromPasswordOrUser(passWord, useOrigUserNameCasing: true);
isValid = ValidateHash(
key: keyToUse,
hashToCompare: hash,
dataToValidate: dataToValidate);
}
return isValid;
}
finally
{
ZeroOutData(keyToUse);
}
}
public static void ZeroOutData(byte[] data)
{
if (data is null) { return; }
for (int i = 0; i < data.Length; i++)
{
data[i] = 0;
}
}
#endregion
#region Private methods
private static byte[] GetPasswordOrUserData(
SecureString passWord,
bool useOrigUserNameCasing = false)
{
if (passWord is null)
{
return Encoding.UTF8.GetBytes(
Utils.GetCurrentUserName(useOrigUserNameCasing));
}
if (Utils.GetDataFromSecureString(
secureString: passWord,
data: out byte[] passWordData))
{
return passWordData;
}
throw new PSInvalidOperationException("Unable to read password data from SecureString.");
}
private static AesKey DeriveKeyFromKeyAndPasswordOrUser(
SecureString passWord,
AesKey key,
bool useOrigUserNameCasing = false)
{
var passWordData = GetPasswordOrUserData(passWord, useOrigUserNameCasing);
try
{
byte[] newKey;
using (var derivedBytes = new Rfc2898DeriveBytes(
password: passWordData,
salt: key.Key,
iterations: 1000))
{
newKey = derivedBytes.GetBytes(key.Key.Length);
}
byte[] newIV;
using (var derivedBytes = new Rfc2898DeriveBytes(
password: passWordData,
salt: key.IV,
iterations: 1000))
{
newIV = derivedBytes.GetBytes(key.IV.Length);
}
return new AesKey(
key: newKey,
iv: newIV);
}
finally
{
ZeroOutData(passWordData);
}
}
private static byte[] DeriveKeyFromPasswordOrUser(
SecureString passWord,
bool useOrigUserNameCasing = false)
{
// Create hash key with either provided password or current user name.
var passWordData = GetPasswordOrUserData(passWord, useOrigUserNameCasing);
return DeriveKeyFromPassword(
passwordData: passWordData,
keyLength: 64);
}
private static byte[] DeriveKeyFromPassword(
byte[] passwordData,
int keyLength)
{
try
{
using (var derivedBytes = new Rfc2898DeriveBytes(
password: passwordData,
salt: salt,
iterations: 1000))
{
return derivedBytes.GetBytes(keyLength);
}
}
finally
{
ZeroOutData(passwordData);
}
}
private static byte[] ComputeHash(
byte[] key,
byte[] dataToHash)
{
using (var hMac = new HMACSHA256(key))
{
return hMac.ComputeHash(dataToHash);
}
}
private static bool ValidateHash(
byte[] key,
byte[] hashToCompare,
byte[] dataToValidate)
{
var computedHash = ComputeHash(
key: key,
dataToHash: dataToValidate);
if (hashToCompare.Length != computedHash.Length)
{
return false;
}
for (int i=0; i<hashToCompare.Length; i++)
{
if (hashToCompare[i] != computedHash[i])
{
return false;
}
}
return true;
}
#endregion
}
#endregion
#region Public Enums
public enum SecureStoreScope
{
CurrentUser = 1,
AllUsers
}
public enum Authenticate
{
None = 0,
Password = 1
}
public enum Interaction
{
None = 0,
Prompt = 1
}
#endregion
#region SecureStoreConfig
internal sealed class SecureStoreConfig
{
#region Public Properties
public SecureStoreScope Scope
{
get;
private set;
}
public Authenticate Authentication
{
get;
private set;
}
/// <Summary>
/// Password timeout time in seconds
/// </Summary>
public int PasswordTimeout
{
get;
private set;
}
public Interaction Interaction
{
get;
private set;
}
#endregion
#region Internal Properties
internal bool PasswordRequired
{
get;
private set;
}
#endregion
#region Constructor
private SecureStoreConfig()
{
}
public SecureStoreConfig(
SecureStoreScope scope,
Authenticate authentication,
int passwordTimeout,
Interaction interaction)
{
Scope = scope;
PasswordTimeout = passwordTimeout;
Authentication = authentication;
Interaction = interaction;
PasswordRequired = authentication == Authenticate.Password;
}
public SecureStoreConfig(
string json)
{
ConvertFromJson(json);
}
#endregion
#region Public methods
public string ConvertToJson()
{
// Config data
var configHashtable = new Hashtable();
configHashtable.Add(
key: "StoreScope",
value: Scope);
configHashtable.Add(
key: "Authentication",
value: Authentication);
configHashtable.Add(
key: "PasswordTimeout",
value: PasswordTimeout);
configHashtable.Add(
key: "Interaction",
value: Interaction);
var dataDictionary = new Hashtable();
dataDictionary.Add(
key: "ConfigData",
value: configHashtable);
return Utils.ConvertHashtableToJson(dataDictionary);
}
#endregion
#region Private methods
private void ConvertFromJson(string json)
{
dynamic configDataObj = (Utils.ConvertJsonToPSObject(json));
if (configDataObj is null)
{
throw new InvalidDataException("Unable to read store configuration json data.");
}
Scope = (SecureStoreScope) configDataObj.ConfigData.StoreScope;
Authentication = (Authenticate) configDataObj.ConfigData.Authentication;
PasswordTimeout = (int) configDataObj.ConfigData.PasswordTimeout;
Interaction = (Interaction) configDataObj.ConfigData.Interaction;
PasswordRequired = Authentication == Authenticate.Password;
}
#endregion
#region Static methods
public static SecureStoreConfig GetDefault()
{
return new SecureStoreConfig(
scope: SecureStoreScope.CurrentUser,
authentication: Authenticate.Password,
passwordTimeout: 900,
interaction: Interaction.Prompt);
}
#endregion
}
#endregion
#region SecureStoreMetada
internal sealed class SecureStoreMetadata
{
#region Properties
public string Name
{
get;
}
public string TypeName
{
get;
}
public int Offset
{
get;
set;
}
public int Size
{
get;
}
public ReadOnlyDictionary<string, object> Attributes
{
get;
}
public ReadOnlyDictionary<string, object> AdditionalData
{
get;
}
public Hashtable AttributesAsHashtable
{
get
{
return ConvertToHashtable(Attributes);
}
}
public Hashtable AdditionalDataAsHashtable
{
get
{
return ConvertToHashtable(AdditionalData);
}
}
#endregion
#region Constructor
private SecureStoreMetadata()
{
}
public SecureStoreMetadata(
string name,
string typeName,
int offset,
int size,
ReadOnlyDictionary<string, object> attributes,
ReadOnlyDictionary<string, object> additionalData)
{
Name = name;
TypeName = typeName;
Offset = offset;
Size = size;
Attributes = attributes;
AdditionalData = additionalData;
}
public SecureStoreMetadata(
SecureStoreMetadata metadata)
{
Name = metadata.Name;
TypeName = metadata.TypeName;
Offset = metadata.Offset;
Size = metadata.Size;
Attributes = metadata.Attributes;
AdditionalData = metadata.AdditionalData;
}
#endregion
#region Private methods
private Hashtable ConvertToHashtable(
ReadOnlyDictionary<string, object> dictionary)
{
var returnHashtable = new Hashtable();
if (dictionary != null)
{
foreach (var key in dictionary.Keys)
{
returnHashtable.Add(
key: key,
value: dictionary[key]);
}
}
return returnHashtable;
}
#endregion
}
#endregion
#region AesKey
internal sealed class AesKey
{
#region Properties
public byte[] Key { get; }
public byte[] IV { get; }
#endregion
#region Constructor
private AesKey() { }
public AesKey(
byte[] key,
byte[] iv)
{
Key = key;
IV = iv;
}
#endregion
#region Public methods
public void Clear()
{
CryptoUtils.ZeroOutData(Key);
CryptoUtils.ZeroOutData(IV);
}
#endregion
}
#endregion
#region SecureStoreData
internal sealed class SecureStoreData
{
#region Properties
public AesKey Key { get; set; }
public byte[] Blob { get; set; }
public Dictionary<string, SecureStoreMetadata> MetaData { get; set; }
#endregion
#region Constructor
public SecureStoreData()