Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ RewriteEncryptedPkcs8PrivateKey() [2/4]

static AsnWriter System.Security.Cryptography.CngPkcs8.RewriteEncryptedPkcs8PrivateKey ( AsymmetricAlgorithm key,
ReadOnlySpan< byte > passwordBytes,
PbeParameters pbeParameters )
inlinestaticprivate

Definition at line 234 of file CngPkcs8.cs.

235 {
237 int bytesWritten = 0;
238 Span<char> span = stackalloc char[22];
239 try
240 {
242 while (!key.TryExportEncryptedPkcs8PrivateKey(span, s_platformParameters, array, out bytesWritten))
243 {
244 int num = array.Length;
245 byte[] array2 = array;
246 array = System.Security.Cryptography.CryptoPool.Rent(checked(num * 2));
247 System.Security.Cryptography.CryptoPool.Return(array2, bytesWritten);
248 }
249 return System.Security.Cryptography.KeyFormatHelper.ReencryptPkcs8(span, array.AsMemory(0, bytesWritten), passwordBytes, pbeParameters);
250 }
251 finally
252 {
253 span.Clear();
255 }
256 }
static readonly PbeParameters s_platformParameters
Definition CngPkcs8.cs:26
static void FillRandomAsciiString(Span< char > destination)
Definition CngPkcs8.cs:312
static void Return(byte[] array, int clearSize=-1)
Definition CryptoPool.cs:12
static byte[] Rent(int minimumLength)
Definition CryptoPool.cs:7
static AsnWriter ReencryptPkcs8(ReadOnlySpan< char > inputPassword, ReadOnlyMemory< byte > current, ReadOnlySpan< char > newPassword, PbeParameters pbeParameters)

References System.array, System.Span< T >.Clear(), System.Security.Cryptography.CngPkcs8.FillRandomAsciiString(), System.key, System.Security.Cryptography.KeyFormatHelper.ReencryptPkcs8(), System.Security.Cryptography.CryptoPool.Rent(), System.Security.Cryptography.CryptoPool.Return(), and System.Security.Cryptography.CngPkcs8.s_platformParameters.