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

◆ TryEncryptOrDecrypt() [2/2]

unsafe bool System.Security.Cryptography.RSAImplementation.RSACng.TryEncryptOrDecrypt ( SafeNCryptKeyHandle key,
ReadOnlySpan< byte > input,
Span< byte > output,
global::Interop::NCrypt::AsymmetricPaddingMode paddingMode,
void * paddingInfo,
bool encrypt,
out int bytesWritten )
inlineprivate

Definition at line 341 of file RSAImplementation.cs.

342 {
343 for (int i = 0; i <= 1; i++)
344 {
345 int bytesNeeded;
346 global::Interop.NCrypt.ErrorCode errorCode = EncryptOrDecrypt(key, input, output, paddingMode, paddingInfo, encrypt, out bytesNeeded);
347 switch (errorCode)
348 {
349 case global::Interop.NCrypt.ErrorCode.ERROR_SUCCESS:
351 return true;
352 case global::Interop.NCrypt.ErrorCode.NTE_BUFFER_TOO_SMALL:
353 bytesWritten = 0;
354 return false;
355 default:
356 throw errorCode.ToCryptographicException();
357 case global::Interop.NCrypt.ErrorCode.STATUS_UNSUCCESSFUL:
358 break;
359 }
360 }
361 throw global::Interop.NCrypt.ErrorCode.STATUS_UNSUCCESSFUL.ToCryptographicException();
362 }
unsafe byte[] EncryptOrDecrypt(byte[] data, RSAEncryptionPadding padding, bool encrypt)

References System.Security.Cryptography.RSAImplementation.RSACng.EncryptOrDecrypt(), System.input, and System.key.