AuthenticateSignCommand Constructor
AuthenticateSignCommand(ReadOnlyMemory<Byte>, Byte)
Initializes a new instance of the AuthenticateSignCommand class. This command takes the slot number and the (possibly formatted) digest of the data to sign.
public AuthenticateSignCommand(ReadOnlyMemory<byte> digestData, byte slotNumber)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlyMemory<System.Byte> | digestData | The message digest of the data to sign, formatted, if RSA. |
System.Byte | slotNumber | The slot holding the private key to use. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The data to sign (formatted digest) is not the correct length. |
Remarks
The slot number must be for a slot that holds an asymmetric key and
can perform arbitrary signing, which is all asymmetric key slots other
than F9
. See the User's Manual
entry on PIV slots ,
entry on signing ,
and PivSlot.
The digest data is formatted if RSA. If the key that will be used to sign is RSA-1024, the the digest data must be 128 (1024 bits) bytes long. If the key is RSA-2048, then the digest data must be 256 bytes (2048 bits) long. See also the User's Manual entry on signing in the PIV commands page.
For ECC, the digest data is not formatted, it is simply the output of the message digest algorithm. If the key that will be used to sign is ECC-P256, then the digest data must be 32 bytes (256 bits) long. You will likely use SHA-256, which is the algorithm specified in the PIV standard. If the key is ECC-P384, then the digest data must be 48 bytes (384 bits) long. You will likely use SHA-384, which is the algorithm specified in the PIV standard.
Note that if the result of the digest has leading 00 bytes, you leave
those bytes in the digestData
. For example:
If the result of the SHA-256 digest is
00 00 87 A9 31 ... 7C
then you pass in 32 bytes:
00 00 87 A9 31 ... 7C
Do not strip the leading 00 bytes and pass in only 30 bytes (87 A9 ... 7C).
If you are signing with ECC and you use a digest algorithm that produces smaller output (not recommended, but if you do), prepend 00 bytes to make sure the length of data passed in is the correct length.