Skip to content

Commit b64a675

Browse files
authored
Merge pull request #180
docs: Documentation edits for SCP
2 parents 9a71a5e + a6db8a6 commit b64a675

File tree

8 files changed

+72
-125
lines changed

8 files changed

+72
-125
lines changed

Yubico.YubiKey/docs/users-manual/application-security-domain/security-domain-certificates.md

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@ var caIds = session.GetSupportedCaIdentifiers(
7171

7272
### Certificate allowlists
7373

74-
Use of the allowlist can provide the following benefits:
75-
- A strong binding to one (or multiple) OCE(s)
76-
- Protection against compromised OCEs
77-
It is recommended to use the allowlist also as a revocation mechanism for OCE certificates. However, if the
78-
allowlist is used in this way, special care shall be taken never to empty/remove the allowlist (i.e. if created, the
79-
allowlist shall always contain at least one certificate) because no restrictions apply (i.e. all certificates are
80-
accepted) once an allowlist is removed.
74+
Use of the allowlist will create strong binding to one or multiple OCE(s)
8175

8276
Control which certificates can be used for authentication by maintaining an allowlist of serial numbers:
8377

@@ -122,7 +116,7 @@ session.StoreCaIssuer(oceRef, skiBytes);
122116

123117
### SCP11b
124118

125-
- Simplest variant, no mutual authentication
119+
- No mutual authentication
126120
- Suitable when host authentication isn't required
127121

128122
Example setup:
@@ -139,37 +133,19 @@ session.StoreCertificates(keyRef, new[] { deviceCert });
139133
### SCP11c
140134

141135
- Mutual authentication
142-
- Similar to SCP11a but with additional features
143-
- such as offline scripting usage (See [GlobalPlatform SCP11 Specification Annex B](https://globalplatform.org/specs-library/secure-channel-protocol-11-amendment-f/))
136+
- Similar to SCP11a but with additional features such as offline scripting usage
137+
(See [GlobalPlatform SCP11 Specification Annex B](https://globalplatform.org/specs-library/secure-channel-protocol-11-amendment-f/))
144138

145139
## Security considerations
146140

147141
1. **Certificate Validation**
148142

149143
- Verify certificate chains completely
150-
- Check certificate revocation status
151-
- Validate certificate purposes and extensions
152-
- Ensure proper key usage constraints
153144

154145
2. **Access Control**
155146

156-
- Use allowlists in production environments
147+
- Consider using allowlists in production environments
157148
- Regularly review and update allowlists
158-
- Monitor for unauthorized certificate usage
159-
- Document certificate authorization policies
160-
161-
3. **Certificate Lifecycle**
162-
163-
- Plan for certificate renewal
164-
- Handle certificate revocation
165-
- Maintain certificate inventory
166-
- Test certificate rotation procedures
167-
168-
4. **Storage Limitations**
169-
- Be aware of YubiKey storage constraints
170-
- Optimize certificate chain length
171-
- Consider certificate compression if needed
172-
- Monitor available storage space
173149

174150
> [!IMPORTANT]
175151
> Most certificate operations require an authenticated session. Operations are typically only available when using SCP11a or SCP11c variants.
@@ -181,11 +157,11 @@ session.StoreCertificates(keyRef, new[] { deviceCert });
181157
1. Generate or obtain required certificates
182158
2. Store certificate chain on YubiKey
183159
3. Configure CA information if needed
184-
4. Set up allowlist for production use
160+
4. Optionally, set up an allowlist
185161

186162
```csharp
187163
// Example of complete setup
188-
using var session = new SecurityDomainSession(yubiKeyDevice, scp03Params);
164+
using var session = new SecurityDomainSession(yubiKeyDevice, Scp03KeyParameters.DefaultKey);
189165
var keyRef = KeyReference.Create(ScpKeyIds.Scp11A, kvn);
190166

191167
// Store full chain
@@ -214,17 +190,13 @@ session.StoreAllowlist(keyRef, newAllowedSerials);
214190
### Troubleshooting
215191

216192
1. **Certificate Loading Issues**
217-
218193
- Verify certificate format (X.509 v3)
219194
- Check certificate chain order
220-
- Ensure sufficient storage space
221195
- Validate key references
222196

223-
2. **Authentication Problems**
224-
- Verify certificate trust chain
197+
2. **Authentication Problems**
198+
- Verify certificates
225199
- Check allowlist configuration
226-
- Confirm proper SCP variant usage
227-
- Validate certificate dates
228200

229201
> [!NOTE]
230202
> For additional details on secure channel establishment and certificate usage, refer to the [Secure Channel Protocol (SCP)](xref:UsersManualScp) documentation.

Yubico.YubiKey/docs/users-manual/application-security-domain/security-domain-keys.md

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ limitations under the License. -->
1818

1919
# Security Domain key management
2020

21-
The Security Domain supports management of both symmetric (SCP03) and asymmetric (SCP11) keys. This document describes the key types, their usage, and management operations.
21+
The Security Domain supports management of both symmetric (SCP03) and asymmetric (SCP11) keys. This document describes
22+
the key types, their usage, and management operations.
2223

23-
For protocol details and secure channel implementation, see the [Secure Channel Protocol (SCP)](xref:UsersManualScp) documentation.
24+
For protocol details and secure channel implementation, see the [Secure Channel Protocol (SCP)](xref:UsersManualScp)
25+
documentation.
2426

2527
## Key types
2628

@@ -33,28 +35,30 @@ The Security Domain manages two main types of keys:
3335

3436
Each SCP03 key set consists of three AES-128 keys that work together to secure communications:
3537

36-
| Key Type | Purpose |
37-
|----------|---------|
38-
| Key-ENC | Channel encryption key for securing messages |
39-
| Key-MAC | Channel MAC key for message authentication |
40-
| Key-DEK | Data encryption key for sensitive data |
38+
| Key Type | Key ID (KID) | Purpose |
39+
|----------|--------------|----------------------------------------------|
40+
| Key-ENC | 0x1 | Channel encryption key for securing messages |
41+
| Key-MAC | 0x2 | Channel MAC key for message authentication |
42+
| Key-DEK | 0x3 | Data encryption key for sensitive data |
4143

4244
### Managing SCP03 keys
4345

4446
```csharp
4547
// Put a new SCP03 key set
46-
var keyRef = KeyReference.Create(ScpKeyIds.Scp03, 0x01); // KVN=1
48+
var kvn = 0x01;
49+
var keyRef = KeyReference.Create(ScpKeyIds.Scp03, kvn);
4750
var staticKeys = new StaticKeys(keyDataMac, keyDataEnc, keyDataDek);
48-
session.PutKey(keyRef, staticKeys); // 0 means new key
51+
session.PutKey(keyRef, staticKeys);
4952

5053
// Replace existing keys
5154
var newKeys = new StaticKeys(newMacKey, newEncKey, newDekKey);
52-
session.PutKey(keyRef, newKeys, currentKvn);
55+
session.PutKey(keyRef, newKeys, kvnToReplace);
5356
```
5457

5558
### Key Version Numbers (KVN)
5659

5760
SCP03 key sets are identified by Key Version Numbers:
61+
5862
- Default key set: KVN=0xFF (publicly known, no security)
5963
- Each YubiKey can store up to three custom SCP03 key sets
6064

@@ -64,7 +68,8 @@ SCP03 key sets are identified by Key Version Numbers:
6468
## SCP11 key management
6569

6670
SCP11 uses NIST P-256 elliptic curve cryptography. Keys can be:
67-
- Generated on the YubiKey (recommended)
71+
72+
- Generated on the YubiKey
6873
- Imported from external sources
6974

7075
### Generating keys
@@ -115,21 +120,22 @@ session.Reset();
115120
```
116121

117122
> [!WARNING]
118-
> Resetting removes all custom keys and restores factory defaults (within the Security Domain). Ensure you have backups before resetting.
123+
> Resetting removes all custom keys and restores factory defaults (within the Security Domain). Ensure you have backups
124+
> before resetting.
119125
120126
## Key rotation
121127

122-
Regular key rotation is recommended for security. Here are typical rotation procedures:
128+
Here are some simple key rotation procedures:
123129

124130
### SCP03 key rotation
125131

126132
```csharp
127133
// Authenticate with current keys
128-
using var session = new SecurityDomainSession(yubiKeyDevice, currentScp03Params);
134+
using var session = new SecurityDomainSession(yubiKeyDevice, scpParams);
129135

130136
// Replace with new keys
131137
var newKeyRef = KeyReference.Create(ScpKeyIds.Scp03, keyVersionNumber);
132-
session.PutKey(newKeyRef, newStaticKeys, currentKvn);
138+
session.PutKey(newKeyRef, newStaticKeys, kvnToReplace);
133139
```
134140

135141
### SCP11 key rotation
@@ -139,32 +145,24 @@ using var session = new SecurityDomainSession(yubiKeyDevice, scpParams);
139145

140146
// Generate new key pair
141147
var newKeyRef = KeyReference.Create(ScpKeyIds.Scp11B, keyVersionNumber);
142-
var newPublicKey = session.GenerateEcKey(newKeyRef, oldKvn); // Replaces oldKvn
148+
var newPublicKey = session.GenerateEcKey(newKeyRef, kvnToReplace);
143149
```
144150

145151
## Security considerations
146152

147153
1. **Key Protection**
148-
- Store keys securely
149-
- Use unique keys per device when possible
150-
- Consider using SCP11 for mutual authentication
151-
- Avoid storing sensitive keys in source code or configuration files
154+
- Use unique keys per device when possible
155+
- Consider using SCP11 for mutual authentication
152156

153157
2. **Key Version Management**
154-
- Track which keys are loaded on each YubiKey
155-
- Track KVNs in use
156-
157-
3. **Recovery Planning**
158-
- Maintain backup keys
159-
- Document key recovery procedures
160-
- Test recovery processes regularly
161-
- Keep track of key histories
158+
- Track which keys are loaded on each YubiKey
159+
- Track KVNs in use
162160

163-
4. **Default Keys**
164-
- Default SCP03 keys provide no security
165-
- Replace default keys in production environments
166-
- Cannot retain default keys alongside custom keys
167-
- Use proper key management in production
161+
3. **Default Keys**
162+
- Default SCP03 keys provide no security
163+
- Replace default keys in production environments
164+
- Cannot retain default keys alongside custom keys
168165

169166
> [!IMPORTANT]
170-
> The YubiKey provides no metadata about installed keys beyond what's available through `GetKeyInformation()`. Your application must track additional key management details.
167+
> The YubiKey provides no metadata about installed keys beyond what's available through `GetKeyInformation()`. Your
168+
> application must track additional key management details.

Yubico.YubiKey/docs/users-manual/application-security-domain/security-domain-tasks.md

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ var publicKey = session.GenerateEcKey(keyRef);
7373
session.StoreCertificates(keyRef, certificateChain);
7474

7575
// Configure CA for SCP11a/c
76+
var oceSubjectKeyIdentifier = GetSkiFromCertificate(oceCertCa);
7677
var caRef = KeyReference.Create(OceKid, kvn);
77-
session.StoreCaIssuer(caRef, skiBytes);
78+
session.StoreCaIssuer(caRef, oceSubjectKeyIdentifier);
7879
```
7980

80-
### 3. Set up access control
81+
### 3. Set up access control (Optional)
8182

8283
```csharp
8384
// Configure certificate allowlist
@@ -95,7 +96,7 @@ using var session = new SecurityDomainSession(yubiKeyDevice, currentScp03Params)
9596

9697
// Replace with new keys
9798
var newKeyRef = KeyReference.Create(ScpKeyIds.Scp03, newKvn);
98-
session.PutKey(newKeyRef, newStaticKeys, currentKvn);
99+
session.PutKey(newKeyRef, newStaticKeys, kvnToReplace);
99100
```
100101

101102
### Rotating SCP11 keys
@@ -105,7 +106,7 @@ using var session = new SecurityDomainSession(yubiKeyDevice, scpParams);
105106

106107
// Generate new key pair
107108
var newKeyRef = KeyReference.Create(ScpKeyIds.Scp11B, newKvn);
108-
var newPublicKey = session.GenerateEcKey(newKeyRef, oldKvn); // Will be replaced
109+
var newPublicKey = session.GenerateEcKey(newKeyRef, kvnToReplace); // Will be replaced
109110
```
110111

111112
## Recovery operations
@@ -210,7 +211,7 @@ var keyInfo = verifySession.GetKeyInformation();
210211

211212
1. **Monitor Key Status**
212213
```csharp
213-
// Check key information regularly
214+
// Check key information
214215
var keyInfo = session.GetKeyInformation();
215216
foreach (var key in keyInfo)
216217
{
@@ -231,34 +232,4 @@ foreach (var cert in certificates)
231232
PlanCertificateRenewal(cert);
232233
}
233234
}
234-
```
235-
236-
## Troubleshooting
237-
238-
### Key issues
239-
240-
1. **Unable to Authenticate**
241-
- Verify key version numbers
242-
- Check key reference values
243-
- Confirm key components
244-
245-
2. **Failed Key Import**
246-
- Validate key formats
247-
- Check authentication status
248-
- Verify available space
249-
- Confirm key compatibility
250-
251-
### Certificate issues
252-
253-
1. **Certificate Chain Problems**
254-
- Verify chain order
255-
- Check CA configuration
256-
- Validate certificate formats
257-
258-
2. **Access Control Issues**
259-
- Check allowlist configuration
260-
- Verify certificate serials
261-
- Validate certificate dates
262-
263-
> [!NOTE]
264-
> Always maintain detailed logs of key and certificate operations for troubleshooting.
235+
```

Yubico.YubiKey/docs/users-manual/sdk-programming-guide/secure-channel-protocol.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ Standard YubiKeys are manufactured with a default key set (KVN=0xFF):
283283
slot 3: --empty--
284284
```
285285

286-
The default keys are publicly known (0x40 41 42 ... 4F) and provide no security. You should replace them in production environments.
286+
> [!IMPORTANT]
287+
> The default keys are publicly known (0x40 41 42 ... 4F) and provide no security. You should replace them in production environments.
287288
288289
### Managing key sets
289290

@@ -324,27 +325,29 @@ session.Reset();
324325

325326
4. **Multiple Key Sets:**
326327
- After default keys are replaced, can have 1-3 custom key sets
327-
- Each must have unique KID
328+
- Each must have unique KVN
328329
- Can add/remove without affecting other sets
329330

330331
### Example: complete key management flow
331332

332333
```csharp
333334
// Start with default keys
334335
var defaultScp03Params = Scp03KeyParameters.DefaultKey;
336+
var firstKvn = 0x1;
337+
var keyRef1 = KeyReference.Create(ScpKeyIds.Scp03, firstKvn);
335338
using (var session = new SecurityDomainSession(yubiKeyDevice, defaultScp03Params))
336339
{
337340
// Add first custom key set (removes default)
338-
var keyRef1 = KeyReference.Create(ScpKeyIds.Scp03, 0x01);
339341
session.PutKey(keyRef1, newKeys);
340342
}
341343

342344
// Now authenticate with new keys
343-
var newScp03Params = new Scp03KeyParameters(ScpKeyIds.Scp03, 0x01, newKeys);
345+
var newScp03Params = new Scp03KeyParameters(keyRef1, newKeys);
344346
using (var session = new SecurityDomainSession(yubiKeyDevice, newScp03Params))
345347
{
346348
// Add second key set
347-
var keyRef2 = KeyReference.Create(ScpKeyIds.Scp03, 0x02);
349+
var secondKvn = 0x2;
350+
var keyRef2 = KeyReference.Create(ScpKeyIds.Scp03, secondKvn);
348351
session.PutKey(keyRef2, customKeys2);
349352

350353
// Check current key information
@@ -354,11 +357,10 @@ using (var session = new SecurityDomainSession(yubiKeyDevice, newScp03Params))
354357

355358
### Key management responsibilities
356359

357-
Your application must:
360+
You should:
358361
- Track which keys are loaded on each YubiKey
359-
- Know if a YubiKey has custom keys from manufacturing
360-
- Manage key distribution and storage
361362
- Track KVNs in use
363+
- Know if a YubiKey has custom keys from manufacturing
362364
- Handle key rotation
363365

364366
The YubiKey provides no metadata about installed keys beyond what's available through `GetKeyInformation()`.
@@ -375,7 +377,6 @@ SCP11 uses asymmetric cryptography based on elliptic curves (NIST P-256) for aut
375377

376378
Detailed information about SCP11 can be found in [GlobalPlatform Card Technology, Secure Channel Protocol '11' Card Specification v2.3 – Amendment F, Chapter 2](https://globalplatform.org/specs-library/secure-channel-protocol-11-amendment-f/)
377379

378-
379380
It comes in three variants, each offering different security properties:
380381

381382
### SCP11 variants
@@ -540,8 +541,7 @@ using var session = new SecurityDomainSession(yubiKeyDevice, scp11Params);
540541
4. **Certificate Allowlists:**
541542
- Restrict which certificates can authenticate
542543
- Update lists as certificates change
543-
- Clear allowlists when no longer needed
544-
- Can be used as a part of a certificate revocation stategy
544+
- Can be used as a part of a certificate revocation strategy
545545

546546
### Checking SCP support
547547

0 commit comments

Comments
 (0)