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

◆ EncryptOrDecrypt() [2/3]

unsafe byte[] System.Security.Cryptography.RSACng.EncryptOrDecrypt ( SafeNCryptKeyHandle key,
ReadOnlySpan< byte > input,
global::Interop::NCrypt::AsymmetricPaddingMode paddingMode,
void * paddingInfo,
bool encrypt )
inlineprivate

Definition at line 302 of file RSACng.cs.

303 {
304 int num = KeySize / 8;
305 byte[] array = new byte[num];
306 int bytesNeeded = 0;
307 global::Interop.NCrypt.ErrorCode errorCode = global::Interop.NCrypt.ErrorCode.ERROR_SUCCESS;
308 for (int i = 0; i <= 1; i++)
309 {
311 if (errorCode != global::Interop.NCrypt.ErrorCode.STATUS_UNSUCCESSFUL)
312 {
313 break;
314 }
315 }
316 if (errorCode == global::Interop.NCrypt.ErrorCode.NTE_BUFFER_TOO_SMALL)
317 {
318 CryptographicOperations.ZeroMemory(array);
319 array = new byte[bytesNeeded];
320 for (int j = 0; j <= 1; j++)
321 {
323 if (errorCode != global::Interop.NCrypt.ErrorCode.STATUS_UNSUCCESSFUL)
324 {
325 break;
326 }
327 }
328 }
329 if (errorCode != 0)
330 {
331 throw errorCode.ToCryptographicException();
332 }
333 if (bytesNeeded != array.Length)
334 {
335 byte[] array2 = array.AsSpan(0, bytesNeeded).ToArray();
336 CryptographicOperations.ZeroMemory(array);
337 array = array2;
338 }
339 return array;
340 }
unsafe byte[] EncryptOrDecrypt(byte[] data, RSAEncryptionPadding padding, bool encrypt)
Definition RSACng.cs:160

References System.array, System.Security.Cryptography.RSACng.EncryptOrDecrypt(), System.input, System.key, System.Security.Cryptography.AsymmetricAlgorithm.KeySize, and System.Security.Cryptography.CryptographicOperations.ZeroMemory().