DSA.TryCreateSignature Method

Definition

Overloads

TryCreateSignature(ReadOnlySpan<Byte>, Span<Byte>, Int32)

Attempts to create the DSA signature for the specified hash into the provided buffer.

TryCreateSignature(ReadOnlySpan<Byte>, Span<Byte>, DSASignatureFormat, Int32)

Attempts to create the DSA signature for the specified hash value in the indicated format and place it into the provided buffer.

TryCreateSignature(ReadOnlySpan<Byte>, Span<Byte>, Int32)

Source:
DSA.cs
Source:
DSA.cs
Source:
DSA.cs

Attempts to create the DSA signature for the specified hash into the provided buffer.

C#
public virtual bool TryCreateSignature(ReadOnlySpan<byte> hash, Span<byte> destination, out int bytesWritten);

Parameters

hash
ReadOnlySpan<Byte>

The hash to sign.

destination
Span<Byte>

The byte span to receive the signature.

bytesWritten
Int32

When this method returns, contains a value that indicates the number of bytes written to destination.

Returns

true if destination is large enough to receive the result; otherwise, false.

Exceptions

This instance represents only a public key.

-or-

The implementation type only supports legacy DSA (FIPS 186-2), and hash is not a 20-byte value.

-or-

Creating the signature otherwise failed.

Remarks

The default implementation of this method is to call CreateSignature(Byte[]) and copy the result to destination. Derived types should override this method to avoid the intermediate array creation.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1

TryCreateSignature(ReadOnlySpan<Byte>, Span<Byte>, DSASignatureFormat, Int32)

Source:
DSA.cs
Source:
DSA.cs
Source:
DSA.cs

Attempts to create the DSA signature for the specified hash value in the indicated format and place it into the provided buffer.

C#
public bool TryCreateSignature(ReadOnlySpan<byte> hash, Span<byte> destination, System.Security.Cryptography.DSASignatureFormat signatureFormat, out int bytesWritten);

Parameters

hash
ReadOnlySpan<Byte>

The hash value to sign.

destination
Span<Byte>

The buffer to receive the signature.

signatureFormat
DSASignatureFormat

The encoding format to use for the signature.

bytesWritten
Int32

When this method returns, contains a value that indicates the number of bytes written to destination. This parameter is treated as uninitialized.

Returns

true if destination is large enough to receive the signature; otherwise, false.

Exceptions

signatureFormat is not a known format.

An error occurred in the signing operation.

Applies to

.NET 10 and other versions
Product Versions
.NET 5, 6, 7, 8, 9, 10