-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroutines.typ
824 lines (664 loc) · 20.9 KB
/
routines.typ
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
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
// This module contains a bunch of reusable steps for `ceremony.typ`.
#import "debug.typ": debug_level, debug_text
#import "model.typ": /*
*/ assert_card, /*
*/ assert_card_reader, /*
*/ assert_component_loaded, /*
*/ assert_dvd_drive, /*
*/ assert_hsm_mode, /*
*/ boot_dvd, /*
*/ dvd_drive, /*
*/ realm_dvd, /*
*/ set_card_reader, /*
*/ set_card_reader_connected, /*
*/ set_component_loaded, /*
*/ set_computer_on, /*
*/ set_computer_plugged_in, /*
*/ set_dvd_drive, /*
*/ set_hsm_installed, /*
*/ set_hsm_mode /*
*/
#import "presentation.typ": /*
*/ blank, /*
*/ blank_entrust_esn, /*
*/ blank_entrust_serial_long, /*
*/ blanks, /*
*/ checkbox, /*
*/ keys, /*
*/ labeled_blank_bag_id, /*
*/ morse_code, /*
*/ outpath, /*
*/ radio, /*
*/ ref_step, /*
*/ step, /*
*/ todo /*
*/
#let boot_into_windows() = step(time: "1m50s", [
Boot into Windows:
- Plug the power cord into the back of the computer.
- Press the "power button" on the front of the computer.
- Boot the computer into the pre-installed Windows OS.
#set_computer_plugged_in(true)
#set_computer_on(true)
#assert_dvd_drive(
none,
message: boot_dvd + " can't be in the drive",
)
])
#let boot_into_dvd(uefi_setup: false) = {
let start = (
[
Plug the power cord into the back of the computer.
#set_computer_plugged_in(true)
],
[
Press the "power button" on the front of the computer.
#set_computer_on(true)
],
)
let end = (
[
The computer should boot into the bootloader on the #boot_dvd.
],
[
Press #keys("Enter") at the GRUB menu to boot into Linux.
#assert_dvd_drive(boot_dvd)
],
)
if uefi_setup {(
step(time: "30s", [
Determine the current date and 24-hour time in UTC. This will be used to
set the system time.
#radio(
[Pacific Standard Time (UTC−08:00)],
[Pacific Daylight Time (UTC−07:00)],
)
#blanks(
[Local Date (`MM/DD/YYYY`)],
[Local Time (`HH:MM`, from analog clock)],
[UTC Date (`MM/DD/YYYY`)],
[UTC Time (`HH:MM`)]
)
]),
step(time: "3m40s", [
Configure UEFI and boot into the #boot_dvd:
#enum(
..start,
[
Tap #keys("F1") repeatedly during boot to enter the UEFI setup.
],
[
Press #keys("Enter") to dismiss the help dialog.
],
// Time & Date
[
Press #keys("Right") to enter the #outpath[`Main`] settings.
],
[
Press #keys("Down"), then #keys("Enter") to enter the
#outpath[`Main`][`System Time & Date`] settings.
],
[
Set the time and date to UTC. Use the arrows and #keys("Enter") to
navigate, and #keys("+") and #keys("-") to adjust the time. Use the
time and date calculated in the previous step, adjusted for the
minutes that have since passed.
],
[
Press #keys("Up") repeatedly until highlighting the back arrow, then
#keys("Enter"), then #keys("Left") to return to the main menu.
],
// Secure Boot
[
Press #keys("Down") several times, then #keys("Right") to enter the
#outpath[`Security`] settings.
],
[
Press #keys("Down") several times, then #keys("Enter") to enter the
#outpath[`Security`][`Secure Boot`] settings.
],
[
Press #keys("Enter"), then #keys("Up"), then #keys("Enter") to
disable Secure Boot. (The Linux kernel would refuse to load the
vendor's HSM driver with Secure Boot enabled.)
],
[
Press #keys("Up"), then #keys("Enter"), then #keys("Left") to return
to the main menu.
],
// Boot Priority
[
Press #keys("Down"), then #keys("Right") to enter #outpath[`Startup`]
settings.
],
[
Press #keys("Enter") to enter the
#outpath[`Startup`][`Boot Priority Order`] settings.
],
[
Except for the SATA DVD-RW drive, press #keys("x") on each device to
exclude it from the boot order. (Skip the DVD-RW drive with
#keys("Down"). You can also un-exclude something with #keys("x").)
],
[
Press #keys("F10"), then #keys("Enter") to save the changes and
reboot.
],
..end
)
]),
)} else {
step(time: "40s", [
Boot into the #boot_dvd:
#list(
..start,
..end,
)
])
}
}
#let power_off(os: "linux") = step(time: "20s", [
Power off the computer:
#if os == "linux" [
- ```sh
ceremony computer shutdown
```
] else if os == "windows" [
- Press and release the "power button" on the front of the computer.
] else {
panic("unrecognized os")
}
- Wait for the computer to turn off.
- Unplug the power cord from the back of the computer.
- Wait a few seconds.
#set_computer_on(false)
#set_computer_plugged_in(false)
])
#let eject_dvd() = step(time: "10s", [
#dvd_drive.display(previous => [
Eject the #previous by pressing the button and remove it from the DVD
drive.
#set_dvd_drive(from: previous, to: none)
])
])
#let load_dvd(next) = step(time: "10s", [
#assert(next != none)
#dvd_drive.display(previous => [
#if previous == none [
Insert the #next into the DVD drive.
] else [
Eject the #previous by pressing the button and insert the #next into the
DVD drive.
]
#set_dvd_drive(from: previous, to: next)
])
])
#let unpack_hsm(first: false) = {
// HSM factory packaging notes (based on loaner):
// - Outermost box was brown cardboard. (For the newer HSMs, they've shipped
// multiple in one outer box.)
// - Inside that, packing list included "Item: NC4035E-B" and "Serial Numbers:
// 46-X19142".
// - Then there's a clear plastic bag with a sticker that says the date,
// customer, PO and order numbers and a second "WIP Completion / Picking
// Label" with "Serial Nbr: 46X19142".
// - Inside that, there's a white NCipher-branded plastic bag that's somewhat
// tamper-evident.
// - Inside that, there's a white box with an Entrust nShield-branded sleeve.
// On the end is a label that includes a checkbox for "nC4035E-000", a
// checkbox for "Base" (vs "Mid" or "High"), a serial number "46-X19142 A".
// - Inside that is an Installation Guide, the module (which came with the
// half-height plate attached) in an antistatic bag, and a white box.
// - Inside the white box is a card reader, wrapped in clear plastic.
// - On the side of the module there's a white sticker that says "S/N:
// 46-X19142 A" and "Model: nC4035E-000"
// - On the end of the module there's a "REV" label with "06" written in
// marker.
let smoosh = v(-0.4em) // layout hack
let open_shipping_box = [
Inspect the outer shipping box:
#smoosh
#checkbox[The box does not appear tampered with.]
#smoosh
Open the outer shipping box, remove its contents, and put away the box
and any extra padding.
]
let factory_checks = [
Inspect the white plastic bag containing this HSM:
#checkbox[
The text says "NCIPHER: AN ENTRUST DATACARD COMPANY", with the first "N"
enclosed in a circle.
]
#smoosh
#checkbox[The bag is sealed and does not appear tampered with.]
Use scissors to open the end of the bag at the dashed line. Remove the bag
and put it away. Inspect the box sleeve:
#checkbox[
The text says "ENTRUST: SECURING A WORLD IN MOTION" with the hexagonal
"E" logo and "nShield: Hardware Security Modules".
]
#smoosh
#checkbox[The box sleeve does not appear tampered with.]
Remove the box sleeve and put it away. Inspect the box:
#checkbox[The box does not appear tampered with.]
Inspect the sticker at the end of the box:
#checkbox[The top text says "ENTRUST: nShield Solo XC".]
#smoosh
#checkbox[Only the `nC4035E-000 nShield Solo XC F3` model is checked.]
#smoosh
#checkbox[Only the `Base` speed is checked.]
#smoosh
#checkbox[The serial number matches an unused HSM listed in @materials.]
]
(
if first {(
step(time: "2m", [
This step will process the HSM packaging.
#checkbox[The HSM is in factory packaging.]
#open_shipping_box
#factory_checks
Serial number: #blank_entrust_serial_long
]),
)} else {(
step(time: "1m", [
#radio(
[
*The HSM is in factory packaging.*
#radio(
[The outer shipping box was opened earlier in the ceremony.],
[
The outer shipping box was not opened earlier in the ceremony.
#open_shipping_box
],
)
#factory_checks
],
[
*The HSM is in an antistatic bag within a tamper-evident bag.*
#checkbox[The tamper-evident bag does not appear tampered with.]
#smoosh
#checkbox[
The serial number and bag ID match an unused HSM listed in
@materials.
]
]
)
Serial number: #blank_entrust_serial_long
]),
)},
step(time: "1m", [
Unpack and inspect the HSM. Retain the antistatic bag and put away the
other packaging.
#checkbox[The HSM does not appear tampered with.]
Inspect the sticker on the side of the HSM:
#checkbox[
The serial number (#outpath[`S/N`]) matches that of the previous step.
]
#checkbox[The model is `nC4035E-000`.]
]),
step(time: "10s", [
Set the mode switch and jumpers on the HSM:
#checkbox[
Set the outside-facing physical switch to `O` (the middle position).
]
#checkbox[
Ensure both override jumper switches are set to off.
]
]),
step(time: "1m30s", [
#if first [
Note: To fit different computer cases, the HSM may have a low-profile
PCI bracket or a full-height PCI bracket attached. Due to a
misalignment, the HSM is physically unable to fit into this particular
computer when it has either bracket attached, so it will be used
without a bracket.
]
#radio(
[
The HSM currently has no PCI bracket.
],
[
The HSM currently has a low-profile or full-height PCI bracket.
Remove the two screws holding the bracket from the HSM, then remove
the bracket. Put away the bracket and the screws.
]
)
]),
step(time: "1m", [
Insert the HSM (without an attached bracket) into the PCIe x16 slot in
the computer.
#set_hsm_installed(true)
]),
if first {
step(time: "1m", [
Unpack the card reader. Put away the packaging.
#checkbox[
The card reader is etched with "ENTRUST" text and the hexagonal "E"
logo.
]
#checkbox[
The card reader does not appear tampered with.
]
])
} else {
step(time: "1m", [
#radio(
[
This HSM did not come with a card reader.
],
[
This HSM came with a card reader.
Place the new card reader in a tamper-evident bag for storage.
#labeled_blank_bag_id
]
)
])
},
step(time: "15s", [
#if first [
While bracing the HSM, plug the card reader into the HSM's external
port.
] else [
While bracing the HSM, plug the existing card reader into the HSM's
external port.
]
#assert_card_reader(none)
#set_card_reader_connected(true)
]),
)
}
// The body of the `restart_hsm()` step. This is also used as a bullet point
// when activating the codesafe feature.
#let _restart_hsm_inner(mode) = [
Restart the HSM in #mode mode:
#if mode == "initialization" [
```sh
ceremony hsm restart --mode initialization
```
] else if mode == "maintenance" [
```sh
ceremony hsm restart --mode maintenance
```
] else if mode == "operational" [
```sh
ceremony hsm restart
```
] else [
#panic("unsupported HSM mode")
]
This command should take about 55 seconds.
#set_hsm_mode(mode)
]
#let restart_hsm(mode) = step(time: "55s", _restart_hsm_inner(mode))
#let erase_hsm() = (
restart_hsm("initialization"),
step(time: "30s", [
Initialize the HSM with a new module key:
```sh
ceremony hsm erase
```
#checkbox[
The output includes the line `Initialising Unit 1 (SetNSOPerms)`.
]
#checkbox[
#outpath[`Module Key Info`][`HKM[0] is`] shows 20 random-looking bytes in
hex.
]
This command should take less than 1 second. This key is temporary, as
creating or joining a Security World later will generate a new module key.
#assert_hsm_mode("initialization")
#assert_component_loaded("secworld", true)
])
)
#let install_secworld() = step(time: "1m20s", [
Install Entrust's tools, daemons, and driver:
```sh
ceremony vendor install secworld
```
This command takes about 80 seconds.
#set_component_loaded("secworld", true)
])
#let install_codesafe() = step(time: "10s", [
Install Entrust's compiler, libraries, and header files:
```sh
ceremony vendor install codesafe
```
This command should take about 10 seconds.
#set_component_loaded("codesafe", true)
])
#let restore_realm_dvd_files() = step(time: "30s", [
Copy the files from the #realm_dvd:
```sh
ceremony realm-dvd restore
```
#assert_dvd_drive(realm_dvd)
#set_component_loaded("entrust_init", true)
#set_component_loaded("sar_files", true)
#set_component_loaded("simple_keys", true)
])
#let initialize_hsm(i) = {
let esn_step = label("hsm_" + str(i) + "_esn")
let activate_codesafe() = [
Activate the SEE (CodeSafe) feature on the HSM:
- ```sh
ceremony feature activate features/SEEUE_❰ESN❱.txt
```
// Note: This command doesn't work immediately after a firmware flash,
// until a KNSO is generated.
This command takes about 55 seconds. It has a side effect of leaving the
HSM in operational mode.
// Features can probably be enabled from other modes, but we happen to
// always run it in initialization mode.
#assert_hsm_mode("initialization")
#assert_component_loaded("secworld", true)
#set_hsm_mode("operational")
- #_restart_hsm_inner("initialization")
- ```sh
ceremony feature info
```
#checkbox[`SEE Activation (EU+10)` is activated (shows `Y`).]
#assert_component_loaded("secworld", true)
]
(
install_secworld(),
step(time: "1m40s", label: esn_step, [
Print HSM info:
```sh
ceremony hsm info
```
ESN (#outpath[`Module #1`][`serial number`]):
#blank_entrust_esn
#checkbox[The ESN matches the HSM listed in @materials.]
#blank[Firmware version (#outpath[`Module #1`][`version`])]
#checkbox[
#outpath[`Module #1`][`product name`] shows all of
`nC3025E/nC4035E/nC4335N`.
]
#assert_component_loaded("secworld", true)
]),
restart_hsm("maintenance"),
step(time: "3m", [
Update/overwrite the HSM firmware to version 13.3.1:
```sh
ceremony vendor mount firmware
ceremony firmware write
ceremony vendor unmount firmware
```
These commands should take about 3 minutes if starting from the same
version and may take several more minutes if starting from an earlier
version.
#assert_hsm_mode("maintenance")
#assert_component_loaded("secworld", true)
]),
step(time: "30s", [
Wait until the HSM is done:
```sh
ceremony hsm info
```
#checkbox[
#outpath[`Module #1`][`enquiry reply flags`] shows `none` (not
`Offline`).
]
#checkbox[
#outpath[`Module #1`][`hardware status`] shows `OK`.
]
#checkbox[
The HSM LED is blinking in the repeated #morse_code("--") pattern.
]
Wait and re-run the command until these conditions are satisfied.
#assert_component_loaded("secworld", true)
]),
power_off(),
boot_into_dvd(),
install_secworld(),
step(time: "30s", [
Wait until the HSM is ready:
```sh
ceremony hsm info
```
#checkbox[
#outpath[`Module #1`][`enquiry reply flags`] shows `none` (not
`Offline`).
]
#checkbox[
#outpath[`Module #1`][`mode`] shows `uninitialized`.
]
#checkbox[
#outpath[`Module #1`][`serial number`] matches #ref_step(esn_step).
]
#checkbox[
#outpath[`Module #1`][`version`] shows `13.3.1`.
]
#checkbox[
#outpath[`Module #1`][`hardware status`] shows `OK`.
]
#checkbox[
The HSM LED is blinking in the repeated #morse_code("-.-") pattern.
]
Wait and re-run the command until these conditions are satisfied.
If the module does not appear at all, check `dmesg` for the error
`nfp_open: device ❰...❱ failed to open with error: -5`. Powering the
computer off and on should resolve this. While this problem is somewhat
anticipated, use an _exception sheet_ the first time it occurs.
#assert_component_loaded("secworld", true)
]),
erase_hsm(),
step(time: "2m", [
#assert_component_loaded("secworld", true)
Check which features have been activated on the HSM:
```sh
ceremony feature info
```
#blank[Active features (excluding SEE)]
#if i == 0 [
#checkbox[`SEE Activation (EU+10)` is not activated (shows `N`).]
] else [
#radio(
[
`SEE Activation (EU+10)` is already activated (shows `Y`).
],
[
`SEE Activation (EU+10)` is not activated (shows `N`).
#activate_codesafe()
],
)
]
]),
if i == 0 {
step(time: "0s", activate_codesafe())
} else {
()
}
)
}
#let destroy(card) = (
step(time: "30s", [
Erase the #card smartcard:
```sh
ceremony smartcard erase
```
This command takes about 30 seconds.
#assert_card(card)
#assert_component_loaded("secworld", true)
]),
step(time: "2m", [
Remove the #card smartcard from the card reader and physically destroy it.
Use a rotary tool to grind the smartcard electronics into a powder. Use
scissors to shred the remaining plastic.
#set_card_reader(from: card, to: none)
]),
)
#let enroll_hsm_and_init_nvram(leave_acs_in_reader: false) = (
step(time: "0s", [
Place the ACS smartcard in the card reader.
#set_card_reader(from: none, to: "ACS")
]),
step(time: "50s", [
Enroll the HSM in the Security World:
```sh
ceremony hsm join-world
```
This command takes about 22 seconds and reads from the ACS smartcard.
#checkbox[
The output `hknso` matches the one recorded in
#ref_step(<create_world>).
]
#assert_card("ACS")
#assert_hsm_mode("initialization")
#assert_component_loaded("secworld", true)
#assert_component_loaded("simple_keys", true)
]),
restart_hsm("operational"),
step(time: "40s", [
Print the signing key hash from the ACL of a key:
```sh
ceremony realm print-acl noise
```
#checkbox[
#outpath[`key simple,jbox-noise exists`...][`Permission Group 2`][`Requires Cert`][`hash`]
matches the signing key hash in #ref_step(<signing_key_hash>).
]
#assert_component_loaded("entrust_init", true)
#assert_component_loaded("simple_keys", true)
#assert_component_loaded("secworld", true) // probably
]),
step(time: "50s", [
Initialize this HSM's NVRAM file, providing the same signing key hash as
the previous step for its ACL:
```sh
ceremony realm create-nvram-file --signing-key-hash ❰HASH❱
```
#checkbox[
#outpath[`Permission Group 2`][`Requires Cert`][`hash`]
matches the signing key hash in #ref_step(<signing_key_hash>).
]
This command takes about 1 second and reads from the ACS smartcard.
#assert_card("ACS")
#assert_hsm_mode("operational")
#assert_component_loaded("entrust_init", true)
#assert_component_loaded("secworld", true)
]),
if leave_acs_in_reader {
()
} else {
step(time: "30s", [
Remove the ACS smartcard from the card reader and place it visibly in the
stand.
#set_card_reader(from: "ACS", to: none)
])
}
)
#let store_hsm() = (
step(time: "0s", [
Unplug the card reader from the HSM.
#assert_card_reader(none)
#set_card_reader_connected(false)
]),
step(time: "2m", [
Remove the HSM from the computer. Insert it into an antistatic bag and
then insert that into a tamper-evident bag (for transport to the production
environment).
#labeled_blank_bag_id
#set_hsm_installed(false)
]),
)