1NDCTL-LOAD-KEYS(1)                                          NDCTL-LOAD-KEYS(1)
2
3
4

NAME

6       ndctl-load-keys - load the kek and encrypted passphrases into the
7       keyring
8

SYNOPSIS

10       ndctl load-keys [<options>]
11

DESCRIPTION

13       The load-keys command loads the master key (kek) and the encrypted
14       passphrases for all NVDIMMs into the user keyring maintained by the
15       kernel. The command is expected to be called during initialization and
16       before the libnvdimm kernel module is loaded, typically from an initrd.
17       This is typically set up using a modprobe config that calls the command
18       before module load.
19
20           Note
21           All key files are expected to be in the format:
22           nvdimm_<id>_hostname The ‘'_’ character is used to delimit the
23           different components in the file name. Within the hostname, the
24           ‘'_’ character is allowed since it is the last component of the
25           file name.
26
27           Note
28           This command is typically never called directly by a user.
29

OPTIONS

31       -p, --key-path=
32           Path to where key related files reside. This parameter is optional
33           and the default location is /etc/ndctl/keys.
34
35       -t, --tpm-handle=
36           Provide a TPM handle (should be a string such as 0x81000001). If
37           the key path (/etc/ndctl/keys) contains a file called tpm.handle
38           which contains the handle string, then this option may be left out,
39           and the tpm handle will be obtained from the file. If both are
40           present, then this option will override (but not overwrite)
41           anything that is in the file.
42

THEORY OF OPERATION

44       The Intel Device Specific Methods (DSM) specification v1.7 and v1.8 [1]
45       introduced the following security management operations: enable
46       passhprase, update passphrase, unlock DIMM, disable security, freeze
47       security, secure (crypto) erase, overwrite, master passphrase enable,
48       master passphrase update, and master passphrase secure erase.
49
50       The security management for NVDIMMs is comprised of two parts. The
51       front end uses the Linux key management framework (trusted and
52       encrypted keys [2]) to store the encrypted passphrases in the
53       kernel-managed keyring. The interface for this is the keyutils utility
54       which uses the key management APIs in the Linux kernel. The back end
55       takes the decrypted payload (which is the DIMM passphrase) and passes
56       it to the DIMM.
57
58       Unlike other DSMs which are composed by libndctl and sent to the kernel
59       via an ioctl, the security DSMs are managed through the security sysfs
60       attribute under the dimm device. A key-ID is written to the security
61       attribute and the kernel pulls the associated key material from the
62       user keyring that is maintained by the kernel.
63
64       The security process begins with the generation of a master key that is
65       used to seal (encrypt) the passphrase for the DIMM. There can either be
66       one common master key that is used to encrypt every DIMM’s passphrase,
67       or a separate key can be generated for each DIMM. The master key is
68       also referred to as the key-encryption-key (kek). The kek can either be
69       generated by the TPM (Trusted Platform Module) on the system, or
70       alternatively, the System Master Key can also be used as the kek
71
72       For testing purposes a user key with randomized payload can also be
73       used as a kek. See [2] for details. To perform any security operations,
74       it is expected that the kek has been added to the kernel’s user keyring
75       as shown in example below:
76
77           # keyctl show
78           Session Keyring
79            736023423 --alswrv      0     0  keyring: _ses
80            675104189 --alswrv      0 65534   \_ keyring: _uid.0
81            680187394 --alswrv      0     0       \_ trusted: nvdimm-master
82
83       Before performing any of the security operations, all the regions
84       associated with the DIMM in question need to be disabled. For the
85       overwrite operation, in addition to the regions, the dimm also needs to
86       be disabled.
87
88       [1] http://pmem.io/documents/NVDIMM_DSM_Interface-V1.8.pdf [2]
89       https://www.kernel.org/doc/Documentation/security/keys/trusted-encrypted.rst
90
91       The following sub-sections describe specifics of each security feature.
92
93   UNLOCK
94       Unlock is performed by the kernel, however a preparation step must
95       happen before the unlock DSM can be issued by the kernel. It is
96       expected that from the initramfs, a setup command (ndctl load-keys) is
97       executed before the libnvdimm module is loaded by modprobe. This
98       command will inject the kek and the encrypted passphrases into the
99       kernel’s user keyring. During the probe of the libnvdimm driver, it
100       will:
101
102        1. Check the security state of the device and see if the DIMM is
103           locked
104
105        2. Request the associated encrypted passphrase from the kernel’s user
106           key ring
107
108        3. Use the kek to decrypt the passphrase
109
110        4. Create the unlock DSM, copy the decrypted payload into the DSM
111
112        5. Issue the DSM to unlock the DIMM
113
114       If the DIMM is already unlocked, the kernel will attempt to revalidate
115       the passphrase. If we fail to revalidate the passphrase, the kernel
116       will freeze the security and disallow any further security
117       configuration changes. A kernel module parameter is available to
118       override this behavior.
119
120   SETUP USER PASSPHRASE
121       To setup the passphrase for a DIMM, it is expected that the kek to be
122       used is present in the kernel’s user keyring. The kek encrypts the DIMM
123       passphrase using the enc32 key format. The plaintext passphrase is
124       never provided by or made visible to the user. It is instead randomly
125       generated by the kernel and userspace does not have access to it. Upon
126       encryption, a binary blob of the passphrase is written to the
127       passphrase blob storage directory (/etc/ndctl/keys). The user is
128       responsible for backing up the passphrase blobs to a secure location.
129
130   UPDATE USER PASSPHRASE
131       The update user passphrase operation uses the same DSM command as
132       enable user passphrase. Most of the work is done on the key management
133       side. The user has the option of providing a new kek for the new
134       passphrase, but continuing to use the existing kek is also acceptable.
135       The following operations are performed for update-passphrase:
136
137        1. Remove the encrypted passphrase from the kernel’s user keyring.
138
139        2. Rename the passphrase blob to old.
140
141        3. Load this old passphrase blob into the keyring with an "old" name.
142
143        4. Create the new passphrase and encrypt with the kek.
144
145        5. Send DSM with the old and new decrypted passphrases.
146
147        6. Remove old passphrase and the passphrase blob from the keyring.
148
149   REMOVE USER PASSPHRASE
150       The key-ID for the passphrase to be removed is written to sysfs. The
151       kernel then sends the DSM to disable security, and the passphrase is
152       then removed from the keyring, and the associated passphrase blob is
153       deleted.
154
155   CRYPTO (SECURE) ERASE
156       This operation is similar to remove-passphrase. The kernel issues a
157       WBINVD instruction before and after the operation to ensure no data
158       corruption from a stale CPU cache. Use ndctl’s sanitize-dimm command
159       with the --crypto-erase option to perform this operation.
160
161   OVERWRITE
162       This is invoked using --overwrite option for ndctl sanitize-dimm. The
163       overwrite operation wipes the entire NVDIMM. The operation can take a
164       significant amount of time. NOTE: When the command returns
165       successfully, it just means overwrite has been successfully started,
166       and not that the overwrite is complete. Subsequently, 'ndctl
167       wait-overwrite’can be used to wait for the NVDIMMs that are performing
168       overwrite. Upon successful completion of an overwrite, the WBINVD
169       instruction is issued by the kernel. If both --crypto-erase and
170       --overwrite options are supplied, then crypto-erase is performed before
171       overwrite.
172
173   SECURITY FREEZE
174       This operation does not require a passphrase. This will cause any
175       security command other than a status query to be locked out until the
176       next boot.
177
178   MASTER PASSPHRASE SETUP, UPDATE, and CRYPTO ERASE
179       These operations are similar to the user passphrase enable and update.
180       The only difference is that a different passphrase is used. The master
181       passphrase has no relation to the master key (kek) which is used for
182       encryption of either passphrase.
183
185       Copyright © 2016 - 2022, Intel Corporation. License GPLv2: GNU GPL
186       version 2 http://gnu.org/licenses/gpl.html. This is free software: you
187       are free to change and redistribute it. There is NO WARRANTY, to the
188       extent permitted by law.
189
190
191
192                                  03/08/2022                NDCTL-LOAD-KEYS(1)
Impressum