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

◆ TryCreateSignatureCore()

unsafe override bool System.Security.Cryptography.DSAImplementation.DSACng.TryCreateSignatureCore ( ReadOnlySpan< byte > hash,
Span< byte > destination,
DSASignatureFormat signatureFormat,
out int bytesWritten )
inlineprotectedvirtual

Reimplemented from System.Security.Cryptography.DSA.

Definition at line 397 of file DSAImplementation.cs.

398 {
399 Span<byte> stackBuf = stackalloc byte[32];
400 ReadOnlySpan<byte> hash2 = AdjustHashSizeIfNecessary(hash, stackBuf);
401 using (SafeNCryptKeyHandle keyHandle = GetDuplicatedKeyHandle())
402 {
403 if (!keyHandle.TrySignHash(hash2, destination, global::Interop.NCrypt.AsymmetricPaddingMode.None, null, out bytesWritten))
404 {
405 bytesWritten = 0;
406 return false;
407 }
408 }
409 return signatureFormat switch
410 {
411 DSASignatureFormat.IeeeP1363FixedFieldConcatenation => true,
412 DSASignatureFormat.Rfc3279DerSequence => AsymmetricAlgorithmHelpers.TryConvertIeee1363ToDer(destination.Slice(0, bytesWritten), destination, out bytesWritten),
413 _ => throw new CryptographicException(System.SR.Cryptography_UnknownSignatureFormat, signatureFormat.ToString()),
414 };
415 }
static bool TryConvertIeee1363ToDer(ReadOnlySpan< byte > input, Span< byte > destination, out int bytesWritten)
static string Cryptography_UnknownSignatureFormat
Definition SR.cs:156
Definition SR.cs:7
ReadOnlySpan< byte > AdjustHashSizeIfNecessary(ReadOnlySpan< byte > hash, Span< byte > stackBuf)

References System.Security.Cryptography.DSAImplementation.DSACng.AdjustHashSizeIfNecessary(), System.SR.Cryptography_UnknownSignatureFormat, System.destination, System.Security.Cryptography.DSAImplementation.DSACng.GetDuplicatedKeyHandle(), and Internal.Cryptography.AsymmetricAlgorithmHelpers.TryConvertIeee1363ToDer().