File: pkcs11_test.go

package info (click to toggle)
cosign 2.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,184 kB
  • sloc: sh: 229; makefile: 170
file content (604 lines) | stat: -rw-r--r-- 17,383 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
// Copyright 2021 The Sigstore Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !pkcs11keydisabled && softhsm
// +build !pkcs11keydisabled,softhsm

// DANGER
// This test requires SoftHSMv2 to be installed. An initialized token should already exist.
// This test will import an RSA key pair, using the specified token label.
// By default, the test assumes the following :
//	- The SoftHSMv2 library is located at "/usr/local/lib/softhsm/libsofthsm2.so"
//	- The initialized token has the label "My Token"
//	- The initialized token has the pin "1234"
//	- The test will import the key pair using the key label "My Key"
// These values can be overriden using the following environment variable :
//	- SOFTHSM_LIB
// 	- SOFTHSM_TOKENLABEL
// 	- SOFTHSM_PIN
// 	- SOFTHSM_KEYLABEL
// By default, the test makes use of the following SoftHSMv2 configuration files :
//	- /etc/softhsm2.conf
// 	- /etc/softhsm.conf
// These values can be overriden using the following environment variable :
//	- SOFTHSM2_CONF
// 	- SOFTHSM_CONF

package test

import (
	"bytes"
	"context"
	"crypto/rsa"
	"crypto/x509"
	"encoding/hex"
	"encoding/pem"
	"fmt"
	"io"
	"math/big"
	"os"
	"strings"
	"testing"

	// Import the functions directly for testing.

	"github.com/miekg/pkcs11"
	. "github.com/sigstore/cosign/v2/cmd/cosign/cli/pkcs11cli"
	"github.com/sigstore/cosign/v2/pkg/cosign/pkcs11key"
	"github.com/stretchr/testify/require"
)

var (
	modulePath = "/usr/local/lib/softhsm/libsofthsm2.so"
	tokenLabel = "My Token"
	pin        = "1234"
	keyLabel   = "My Key"

	keyID = "355d2d0b569a2a0169e46b82e172cf99aca41400"
	uri   = ""
)

func init() {
	if x := os.Getenv("SOFTHSM_LIB"); x != "" {
		modulePath = x
	}
	if x := os.Getenv("SOFTHSM_TOKENLABEL"); x != "" {
		tokenLabel = x
	}
	if x := os.Getenv("SOFTHSM_PIN"); x != "" {
		pin = x
	}
	if x := os.Getenv("SOFTHSM_KEYLABEL"); x != "" {
		keyLabel = x
	}
	if x := os.Getenv("SOFTHSM_CONF"); x == "" {
		os.Setenv("SOFTHSM_CONF", "/etc/softhsm.conf")
	}
	if x := os.Getenv("SOFTHSM2_CONF"); x == "" {
		os.Setenv("SOFTHSM2_CONF", "/etc/softhsm2.conf")
	}

	keyIDBytes, _ := hex.DecodeString(keyID)
	pkcs11UriConfig := pkcs11key.NewPkcs11UriConfigFromInput(modulePath, nil, tokenLabel, []byte(keyLabel), keyIDBytes, pin)
	uri, _ = pkcs11UriConfig.Construct()
}

func TestParsePKCS11URI(t *testing.T) {
	_ = context.Background()

	uriString := "pkcs11:"
	uriString += "library-manufacturer=manufacturer;library-description=description;library-version=1;"
	uriString += "slot-manufacturer=manufacturer;slot-description=description;slot-id=1;"
	uriString += "manufacturer=manufacturer;model=model;serial=12345678;token=token%20label;"
	uriString += "type=private;object=key%20label;id=%6b%65%79%5f%69%64"
	uriString += "?"
	uriString += "module-path=/path/to/some%20folder/libmodule.so&module-name=libmodule.so&"
	uriString += "pin-value=1234&pin-source=/path/to/pinfile"

	pkcs11UriConfig := pkcs11key.NewPkcs11UriConfig()
	must(pkcs11UriConfig.Parse(uriString), t)
	require.Equal(t, pkcs11UriConfig.KeyID, []byte("key_id"))
	require.Equal(t, pkcs11UriConfig.KeyLabel, []byte("key label"))
	require.Equal(t, pkcs11UriConfig.ModulePath, "/path/to/some folder/libmodule.so")
	require.Equal(t, pkcs11UriConfig.Pin, "1234")
	require.Equal(t, *pkcs11UriConfig.SlotID, 1)
	require.Equal(t, pkcs11UriConfig.TokenLabel, "token label")
}

func TestConstructPKCS11URI(t *testing.T) {
	_ = context.Background()

	uri := "pkcs11:token=token%20label;slot-id=1;id=%6b%65%79%5f%69%64;object=key%20label"
	uri += "?"
	uri += "module-path=/path/to/some%20folder/libmodule.so&pin-value=1234"

	slotID := 1
	pkcs11UriConfig := pkcs11key.NewPkcs11UriConfigFromInput("/path/to/some folder/libmodule.so", &slotID, "token label", []byte("key label"), []byte("key_id"), "1234")
	uriString, err := pkcs11UriConfig.Construct()
	require.NoError(t, err)
	require.Equal(t, uri, uriString)
}

func TestListTokensCmd(t *testing.T) {
	ctx := context.Background()

	tokens, err := GetTokens(ctx, modulePath)
	if err != nil {
		t.Fatal(err)
	}

	bTokenFound := false
	for _, token := range tokens {
		if token.TokenInfo.Label == tokenLabel {
			bTokenFound = true
			break
		}
	}

	if !bTokenFound {
		t.Fatalf("token with label '%s' not found", tokenLabel)
	}
}

func TestListKeysUrisCmd(t *testing.T) {
	ctx := context.Background()

	tokens, err := GetTokens(ctx, modulePath)
	if err != nil {
		t.Fatal(err)
	}

	bTokenFound := false
	var slotID uint
	for _, token := range tokens {
		if token.TokenInfo.Label == tokenLabel {
			bTokenFound = true
			slotID = token.Slot
			break
		}
	}
	if !bTokenFound {
		t.Fatalf("token with label '%s' not found", tokenLabel)
	}

	err = importKey(slotID)
	if err != nil {
		t.Fatal(err)
	}
	defer deleteKey(slotID)

	keysInfo, err := GetKeysInfo(ctx, modulePath, slotID, pin)
	if err != nil {
		t.Fatal(err)
	}

	bKeyFound := false
	for _, keyInfo := range keysInfo {
		if hex.EncodeToString(keyInfo.KeyID) == keyID && string(keyInfo.KeyLabel) == keyLabel {
			foundUriConfig := pkcs11key.NewPkcs11UriConfig()
			err = foundUriConfig.Parse(keyInfo.KeyURI)
			if err != nil {
				t.Fatal(err)
			}

			uriConfig := pkcs11key.NewPkcs11UriConfig()
			err = uriConfig.Parse(uri)
			if err != nil {
				t.Fatal(err)
			}

			if foundUriConfig.TokenLabel == uriConfig.TokenLabel &&
				bytes.Compare(foundUriConfig.KeyID, uriConfig.KeyID) == 0 &&
				bytes.Compare(foundUriConfig.KeyLabel, uriConfig.KeyLabel) == 0 &&
				foundUriConfig.ModulePath == uriConfig.ModulePath &&
				foundUriConfig.Pin == uriConfig.Pin {
				bKeyFound = true
			}

			break
		}
	}

	if !bKeyFound {
		t.Fatalf("key not found")
	}
}

func TestCertificateIgnored(t *testing.T) {
	ctx := context.Background()

	tokens, err := GetTokens(ctx, modulePath)
	if err != nil {
		t.Fatal(err)
	}

	bTokenFound := false
	var slotID uint
	for _, token := range tokens {
		if token.TokenInfo.Label == tokenLabel {
			bTokenFound = true
			slotID = token.Slot
			break
		}
	}
	if !bTokenFound {
		t.Fatalf("token with label '%s' not found", tokenLabel)
	}

	err = importKey(slotID)
	if err != nil {
		t.Fatal(err)
	}
	defer deleteKey(slotID)

	pkcs11UriConfig := pkcs11key.NewPkcs11UriConfig()
	err = pkcs11UriConfig.Parse(uri)
	if err != nil {
		t.Fatal(err)
	}

	const envvar = "COSIGN_PKCS11_IGNORE_CERTIFICATE"

	if err := os.Setenv(envvar, "1"); err != nil {
		t.Fatal(err)
	}

	defer os.Setenv(envvar, "")

	sk, err := pkcs11key.GetKeyWithURIConfig(pkcs11UriConfig, true)
	if err != nil {
		t.Fatal(err)
	}

	defer sk.Close()

	cert, err := sk.Certificate()
	if err != nil {
		t.Fatal(err)
	}

	if cert != nil {
		t.Fatalf("expected certificate to be ignored while loading")
	}
}

func TestSignAndVerify(t *testing.T) {
	ctx := context.Background()

	tokens, err := GetTokens(ctx, modulePath)
	if err != nil {
		t.Fatal(err)
	}

	bTokenFound := false
	var slotID uint
	for _, token := range tokens {
		if token.TokenInfo.Label == tokenLabel {
			bTokenFound = true
			slotID = token.Slot
			break
		}
	}
	if !bTokenFound {
		t.Fatalf("token with label '%s' not found", tokenLabel)
	}

	err = importKey(slotID)
	if err != nil {
		t.Fatal(err)
	}
	defer deleteKey(slotID)

	pkcs11UriConfig := pkcs11key.NewPkcs11UriConfig()
	err = pkcs11UriConfig.Parse(uri)
	if err != nil {
		t.Fatal(err)
	}

	sk, err := pkcs11key.GetKeyWithURIConfig(pkcs11UriConfig, true)
	if err != nil {
		t.Fatal(err)
	}
	defer sk.Close()

	sv, err := sk.SignerVerifier()
	if err != nil {
		t.Fatal(err)
	}

	v, err := sk.Verifier()
	if err != nil {
		t.Fatal(err)
	}

	sig, err := sv.SignMessage(bytes.NewReader([]byte("hello, world!")))
	if err != nil {
		t.Fatal(err)
	}

	err = v.VerifySignature(bytes.NewReader(sig), bytes.NewReader([]byte("hello, world!")))
	if err != nil {
		t.Fatal(err)
	}
}

var newPublicKeyAttrs = []*pkcs11.Attribute{
	pkcs11.NewAttribute(pkcs11.CKA_CLASS, pkcs11.CKO_PUBLIC_KEY),
	pkcs11.NewAttribute(pkcs11.CKA_TOKEN, true),
	pkcs11.NewAttribute(pkcs11.CKA_PRIVATE, false),
	pkcs11.NewAttribute(pkcs11.CKA_VERIFY, true),
}

var newPrivateKeyAttrs = []*pkcs11.Attribute{
	pkcs11.NewAttribute(pkcs11.CKA_CLASS, pkcs11.CKO_PRIVATE_KEY),
	pkcs11.NewAttribute(pkcs11.CKA_TOKEN, true),
	pkcs11.NewAttribute(pkcs11.CKA_PRIVATE, true),
	pkcs11.NewAttribute(pkcs11.CKA_SENSITIVE, true),
	pkcs11.NewAttribute(pkcs11.CKA_EXTRACTABLE, false),
	pkcs11.NewAttribute(pkcs11.CKA_SIGN, true),
}

func rsaImportAttrs(priv *rsa.PrivateKey) (pubAttrs, privAttrs []*pkcs11.Attribute) {
	pubAttrs = []*pkcs11.Attribute{
		pkcs11.NewAttribute(pkcs11.CKA_PUBLIC_EXPONENT, big.NewInt(int64(priv.E)).Bytes()),
		pkcs11.NewAttribute(pkcs11.CKA_MODULUS, priv.N.Bytes()),
	}
	privAttrs = []*pkcs11.Attribute{
		pkcs11.NewAttribute(pkcs11.CKA_PUBLIC_EXPONENT, big.NewInt(int64(priv.E)).Bytes()),
		pkcs11.NewAttribute(pkcs11.CKA_MODULUS, priv.N.Bytes()),
		pkcs11.NewAttribute(pkcs11.CKA_PRIVATE_EXPONENT, priv.D.Bytes()),
		pkcs11.NewAttribute(pkcs11.CKA_PRIME_1, priv.Primes[0].Bytes()),
		pkcs11.NewAttribute(pkcs11.CKA_PRIME_2, priv.Primes[1].Bytes()),
		pkcs11.NewAttribute(pkcs11.CKA_EXPONENT_1, priv.Precomputed.Dp.Bytes()),
		pkcs11.NewAttribute(pkcs11.CKA_EXPONENT_2, priv.Precomputed.Dq.Bytes()),
		pkcs11.NewAttribute(pkcs11.CKA_COEFFICIENT, priv.Precomputed.Qinv.Bytes()),
	}
	return
}

func attrConcat(attrSets ...[]*pkcs11.Attribute) []*pkcs11.Attribute {
	ret := make([]*pkcs11.Attribute, 0)
	for _, attrs := range attrSets {
		ret = append(ret, attrs...)
	}
	return ret
}

func initPKCS11(modulePath string) (*pkcs11.Ctx, error) {
	ctx := pkcs11.New(modulePath)
	if ctx == nil {
		return nil, fmt.Errorf("unable to load PKCS#11 module")
	}

	err := ctx.Initialize()
	if err != nil {
		return nil, fmt.Errorf("unable to initialize PKCS#11 module")
	}

	return ctx, nil
}

func importKey(slotID uint) error {
	var pemBytes []byte
	var priv interface{}

	ctx, err := initPKCS11(modulePath)
	if err != nil {
		return err
	}
	defer func() {
		ctx.Finalize()
		ctx.Destroy()
	}()

	keyIDBytes, err := hex.DecodeString(keyID)
	if err != nil {
		return err
	}
	keyLabelBytes := []byte(keyLabel)

	r := strings.NewReader(rsaPrivKey)
	pemBytes, err = io.ReadAll(r)
	if err != nil {
		return fmt.Errorf("unable to read pem")
	}
	block, _ := pem.Decode(pemBytes)
	if block == nil {
		return fmt.Errorf("unable to decode pem")
	}
	priv, err = x509.ParsePKCS8PrivateKey(block.Bytes)
	if err != nil {
		return fmt.Errorf("unable to parse pem")
	}
	privKey, ok := priv.(*rsa.PrivateKey)
	if !ok {
		return fmt.Errorf("unable to load key")
	}

	session, err := ctx.OpenSession(slotID, pkcs11.CKF_SERIAL_SESSION|pkcs11.CKF_RW_SESSION)
	if err != nil {
		return fmt.Errorf("unable to open session")
	}
	defer ctx.CloseSession(session)
	err = ctx.Login(session, pkcs11.CKU_USER, pin)
	if err != nil {
		return fmt.Errorf("unable to login")
	}
	defer ctx.Logout(session)

	keyType := pkcs11.CKK_RSA
	pubTypeAttrs, privTypeAttrs := rsaImportAttrs(privKey)
	commonAttrs := []*pkcs11.Attribute{
		pkcs11.NewAttribute(pkcs11.CKA_KEY_TYPE, keyType),
		pkcs11.NewAttribute(pkcs11.CKA_ID, keyIDBytes),
		pkcs11.NewAttribute(pkcs11.CKA_LABEL, keyLabelBytes),
	}
	pubAttrs := attrConcat(commonAttrs, newPublicKeyAttrs, pubTypeAttrs)
	privAttrs := attrConcat(commonAttrs, newPrivateKeyAttrs, privTypeAttrs)
	pubHandle, err := ctx.CreateObject(session, pubAttrs)
	if err != nil {
		return fmt.Errorf("unable to create public key")
	}
	_, err = ctx.CreateObject(session, privAttrs)
	if err != nil {
		ctx.DestroyObject(session, pubHandle)
		return fmt.Errorf("unable to create private key")
	}

	return nil
}

func deleteKey(slotID uint) error {
	var handles []pkcs11.ObjectHandle

	ctx, err := initPKCS11(modulePath)
	if err != nil {
		return err
	}
	defer func() {
		ctx.Finalize()
		ctx.Destroy()
	}()

	keyIDBytes, err := hex.DecodeString(keyID)
	if err != nil {
		return err
	}
	keyLabelBytes := []byte(keyLabel)

	session, err := ctx.OpenSession(slotID, pkcs11.CKF_SERIAL_SESSION|pkcs11.CKF_RW_SESSION)
	if err != nil {
		return fmt.Errorf("unable to open session")
	}
	defer ctx.CloseSession(session)
	err = ctx.Login(session, pkcs11.CKU_USER, pin)
	if err != nil {
		return fmt.Errorf("unable to login")
	}
	defer ctx.Logout(session)

	maxHandlePerFind := 20
	publicAttrs := []*pkcs11.Attribute{
		pkcs11.NewAttribute(pkcs11.CKA_CLASS, pkcs11.CKO_PUBLIC_KEY),
		pkcs11.NewAttribute(pkcs11.CKA_ID, keyIDBytes),
		pkcs11.NewAttribute(pkcs11.CKA_LABEL, keyLabelBytes),
	}
	if err = ctx.FindObjectsInit(session, publicAttrs); err != nil {
		return fmt.Errorf("unable to initialize find objects")
	}
	handles, _, err = ctx.FindObjects(session, maxHandlePerFind)
	if err != nil {
		return fmt.Errorf("unable to find objects")
	}
	err = ctx.FindObjectsFinal(session)
	if err != nil {
		return fmt.Errorf("unable to finalize find objects")
	}
	if len(handles) == 1 {
		ctx.DestroyObject(session, handles[0])
		if err != nil {
			return fmt.Errorf("unable to destroy public key")
		}
	}

	privAttrs := []*pkcs11.Attribute{
		pkcs11.NewAttribute(pkcs11.CKA_CLASS, pkcs11.CKO_PRIVATE_KEY),
		pkcs11.NewAttribute(pkcs11.CKA_ID, keyIDBytes),
		pkcs11.NewAttribute(pkcs11.CKA_LABEL, keyLabelBytes),
	}
	if err = ctx.FindObjectsInit(session, privAttrs); err != nil {
		return fmt.Errorf("unable to initialize find objects")
	}
	handles, _, err = ctx.FindObjects(session, maxHandlePerFind)
	if err != nil {
		return fmt.Errorf("unable to find objects")
	}
	err = ctx.FindObjectsFinal(session)
	if err != nil {
		return fmt.Errorf("unable to finalize find objects")
	}
	if len(handles) == 1 {
		ctx.DestroyObject(session, handles[0])
		if err != nil {
			return fmt.Errorf("unable to destroy private key")
		}
	}

	return nil
}

func must(err error, t *testing.T) {
	t.Helper()
	if err != nil {
		t.Fatal(err)
	}
}

func mustErr(err error, t *testing.T) {
	t.Helper()
	if err == nil {
		t.Fatal("expected error")
	}
}

const rsaPrivKey = `-----BEGIN PRIVATE KEY-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