Show / Hide Table of Contents

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.

C#
[Obsolete("Usage of PivEccPublic/PivEccPrivateKey is deprecated. Use IPublicKey, IPrivateKey instead", false)]
public ImportAsymmetricKeyCommand(PivPrivateKey privateKey, byte slotNumber, PivPinPolicy pinPolicy, PivTouchPolicy touchPolicy)

Parameters

Type Name Description
PivPrivateKey privateKey

The private key to import.

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
ArgumentNullException

The privateKey argument is null.

ArgumentException

The privateKey argument does not contain a key.

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.

C#
[Obsolete("Usage of PivEccPublic/PivEccPrivateKey is deprecated. Use IPublicKey, IPrivateKey instead", false)]
public ImportAsymmetricKeyCommand(PivPrivateKey privateKey)

Parameters

Type Name Description
PivPrivateKey privateKey

The private key to import.

Exceptions

Type Condition
ArgumentNullException

The privateKey argument is null.

ArgumentException

The privateKey argument does not contain a key.

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.

ImportAsymmetricKeyCommand(ReadOnlyMemory<byte>, KeyType, byte, PivPinPolicy, PivTouchPolicy)

C#
public ImportAsymmetricKeyCommand(ReadOnlyMemory<byte> encodedKey, KeyType keyType, byte slotNumber, PivPinPolicy pinPolicy = PivPinPolicy.Default, PivTouchPolicy touchPolicy = PivTouchPolicy.Default)

Parameters

Type Name Description
ReadOnlyMemory<byte> encodedKey
KeyType keyType
byte slotNumber
PivPinPolicy pinPolicy
PivTouchPolicy touchPolicy
In this article
Back to top Generated by DocFX