ImportAsymmetricKeyCommand Constructor
ImportAsymmetricKeyCommand(PivPrivateKey, Byte, PivPinPolicy, PivTouchPolicy)
Initializes a new instance of the ImportAsymmetricKeyCommand
class.
This command takes the slot number, PIN and touch policies, and the
private key as input.
public ImportAsymmetricKeyCommand(PivPrivateKey privateKey, byte slotNumber, PivPinPolicy pinPolicy, PivTouchPolicy touchPolicy)
Parameters
Type | Name | Description |
---|---|---|
PivPrivateKey | privateKey | The private key to import. |
System.Byte | slotNumber | The slot which will hold the private key. |
PivPinPolicy | pinPolicy | The PIN policy the key will have. |
PivTouchPolicy | touchPolicy | The touch policy the key will have. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentException | The |
Remarks
The only possible private keys this command will accept are RSA-1024, RSA-2048, RSA-3072, RSA-4096, ECC-P256, and ECC-P384. If you supply any other private key, the constructor will throw an exception.
The slot number must be for a slot that holds an asymmetric key. See the User's Manual entry on PIV slots and PivSlot.
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
.
The key data must be supplied as an instance of PivPrivateKey
ImportAsymmetricKeyCommand(PivPrivateKey)
Initializes a new instance of the ImportAsymmetricKeyCommand
class.
This command takes the private key as input, it will set the
PinPolicy
and TouchPolicy
to the defaults.
public ImportAsymmetricKeyCommand(PivPrivateKey privateKey)
Parameters
Type | Name | Description |
---|---|---|
PivPrivateKey | privateKey | The private key to import. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentException | The |
Remarks
This constructor is provided for those developers who want to use the object initializer pattern. For example:
var command = new ImportAsymmetricKeyCommand(privateKey)
{
SlotNumber = PivSlots.Authentication,
PinPolicy = PivPinPolicy.Once,
};
There is no default slot number, hence, for this command to be valid, the slot number must be specified. So if you create an object using this constructor, you must set the SlotNumber property at some time before using it. Otherwise you will get an exception when you do use it.