GenerateKeyPairCommand Constructor
GenerateKeyPairCommand(Byte, PivAlgorithm, PivPinPolicy, PivTouchPolicy)
Initializes a new instance of the GenerateKeyPairCommand class. This command takes the slot number, algorithm, and PIN and touch policies as input.
public GenerateKeyPairCommand(byte slotNumber, PivAlgorithm algorithm, PivPinPolicy pinPolicy, PivTouchPolicy touchPolicy)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | slotNumber | The slot which will hold the private key. |
PivAlgorithm | algorithm | The algorithm (and size) of the key to generate. |
PivPinPolicy | pinPolicy | The PIN policy the key will have. |
PivTouchPolicy | touchPolicy | The touch policy the key will have. |
Remarks
The slot number must be for a slot that holds an asymmetric key. See the User's Manual entry on PIV slots and PivSlot.
Note that the algorithm
argument is of type
PivAlgorithm,
which includes None
, TripleDes
, and Pin
.
However, the only allowed values for this command are Rsa1024
,
Rsa2048
, EccP256
, and EccP384
.
Both the touch policy and pin policy enum
arguments have
None
as a possible value. This command, will treat a policy of
None
the same as Default
.
GenerateKeyPairCommand()
Initializes a new instance of the GenerateKeyPairCommand
class.
This command will set the PinPolicy
and TouchPolicy
to the defaults.
public GenerateKeyPairCommand()
Remarks
This constructor is provided for those developers who want to use the object initializer pattern. For example:
var command = new GenerateKeyPairCommand()
{
SlotNumber = PivSlot.Authentication,
Algorithm = PivAlgorithm.Rsa2048,
PinPolicy = PivPinPolicy.Once,
};
There is no default slot number or algorithm, hence, for this command to be valid, the slot number and algorithm must be specified. So if you create an object using this constructor, you must set the SlotNumber and Algorithm properties at some time before using it. Otherwise you will get an exception when you do use it.