Show / Hide Table of Contents

Scp03Session Class

Namespace: Yubico.YubiKey.Scp03 Assembly: Yubico.YubiKey.dll

Create a session for managing the SCP03 configuration of a YubiKey.

C#
[Obsolete("Use new SecurityDomainSession")]
public sealed class Scp03Session
Inheritance object Scp03Session

Remarks

See the User's Manual entry on SCP03.

Usually, you use SCP03 "in the background" to secure the communication with another application. For example, when you want to perform PIV operations, but need to send the commands to and get the responses from the YubiKey securely (such as sending commands remotely where authenticity and confidentiality are required), you use SCP03.

if (YubiKeyDevice.TryGetYubiKey(serialNumber, out IYubiKeyDevice yubiKeyDevice))
{
    using (var pivSession = new PivSession(scp03Device, scp03Keys))
    {
      . . .
    }
}

However, there are times you need to manage the configuration of SCP03 directly, not as simply the security layer for a PIV or other applications. The most common operations are loading and deleting SCP03 key sets on the YubiKey.

For the SCP03 configuration management operations, use the Scp03Session class.

Once you have the YubiKey to use, you will build an instance of this Scp03Session class to represent the SCP03 on the hardware. Because this class implements IDisposable, use the using keyword. For example,

if (YubiKeyDevice.TryGetYubiKey(serialNumber, out IYubiKeyDevice yubiKeyDevice))
{
    var scp03Keys = new StaticKeys();
    using (var scp03 = new Scp03Session(yubiKeyDevice, scp03Keys))
    {
        // Perform SCP03 operations.
    }
}

If the YubiKey does not support SCP03, the constructor will throw an exception.

If the StaticKeys provided are not correct, the constructor will throw an exception.

Constructors

Name Description
Scp03Session(IYubiKeyDevice, StaticKeys)

Create an instance of Scp03Session, the object that represents SCP03 on the YubiKey.

Properties

Name Description
Connection

The object that represents the connection to the YubiKey. Most applications will ignore this, but it can be used to call Commands directly.

Methods

Name Description
DeleteKeySet(byte, bool)

Delete the key set with the given keyVersionNumber. If the key set to delete is the last SCP03 key set on the YubiKey, pass true as the isLastKey arg.

Dispose()

When the Scp03Session object goes out of scope, this method is called. It will close the session. The most important function of closing a session is to close the connection.

PutKeySet(StaticKeys)

Put the given key set onto the YubiKey.

In this article
Back to top Generated by DocFX