1NDCTL-LOAD-KEYS(1)               ndctl Manual               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
23           The '_' character is used to delimit the different components in
24           the file name. Within the hostname, the '_' character is allowed
25           since it is the last component of the 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>
89       [2] <https://www.kernel.org/doc/Documentation/security/keys/
90       trusted-encrypted.rst>
91
92       The following sub-sections describe specifics of each security feature.
93
94   UNLOCK
95       Unlock  is  performed  by  the  kernel, however a preparation step must
96       happen before the unlock DSM  can  be  issued  by  the  kernel.  It  is
97       expected  that from the initramfs, a setup command (ndctl load-keys) is
98       executed before the  libnvdimm  module  is  loaded  by  modprobe.  This
99       command  will  inject  the  kek  and the encrypted passphrases into the
100       kernel’s user keyring. During the probe of  the  libnvdimm  driver,  it
101       will:
102
103         1. Check  the  security  state  of  the device and see if the DIMM is
104           locked
105
106        2. Request the associated encrypted passphrase from the kernel’s  user
107           key ring
108
109        3. Use the kek to decrypt the passphrase
110
111        4. Create the unlock DSM, copy the decrypted payload into the DSM
112
113        5. Issue the DSM to unlock the DIMM
114
115       If  the DIMM is already unlocked, the kernel will attempt to revalidate
116       the passphrase. If we fail to revalidate  the  passphrase,  the  kernel
117       will   freeze   the   security   and   disallow  any  further  security
118       configuration changes.  A  kernel  module  parameter  is  available  to
119       override this behavior.
120
121   SETUP USER PASSPHRASE
122       To  setup  the passphrase for a DIMM, it is expected that the kek to be
123       used is present in the kernel’s user keyring. The kek encrypts the DIMM
124       passphrase  using  the  enc32  key  format. The plaintext passphrase is
125       never provided by or made visible to the user. It is  instead  randomly
126       generated  by the kernel and userspace does not have access to it. Upon
127       encryption,  a  binary  blob  of  the  passphrase  is  written  to  the
128       passphrase  blob  storage  directory  (/etc/ndctl/keys).  The  user  is
129       responsible for backing up the passphrase blobs to a secure location.
130
131   UPDATE USER PASSPHRASE
132       The update user passphrase operation  uses  the  same  DSM  command  as
133       enable  user passphrase. Most of the work is done on the key management
134       side. The user has the option of  providing  a  new  kek  for  the  new
135       passphrase,  but continuing to use the existing kek is also acceptable.
136       The following operations are performed for update-passphrase:
137
138        1. Remove the encrypted passphrase from the kernel’s user keyring.
139
140        2. Rename the passphrase blob to old.
141
142        3. Load this old passphrase blob into the keyring with an "old" name.
143
144        4. Create the new passphrase and encrypt with the  kek.
145
146        5. Send DSM with the old and new decrypted passphrases.
147
148        6. Remove old passphrase and the passphrase blob from the keyring.
149
150   REMOVE USER PASSPHRASE
151       The key-ID for the passphrase to be removed is written  to  sysfs.  The
152       kernel  then  sends  the DSM to disable security, and the passphrase is
153       then removed from the keyring, and the associated  passphrase  blob  is
154       deleted.
155
156   CRYPTO (SECURE) ERASE
157       This  operation  is  similar  to remove-passphrase. The kernel issues a
158       WBINVD instruction before and after the operation  to  ensure  no  data
159       corruption  from  a  stale CPU cache. Use ndctl’s sanitize-dimm command
160       with the --crypto-erase option to perform this operation.
161
162   OVERWRITE
163       This is invoked using --overwrite option for ndctl  sanitize-dimm.  The
164       overwrite  operation  wipes the entire NVDIMM. The operation can take a
165       significant  amount  of  time.   NOTE:   When   the   command   returns
166       successfully,  it  just  means overwrite has been successfully started,
167       and  not  that  the  overwrite  is   complete.   Subsequently,   'ndctl
168       wait-overwrite’can  be used to wait for the NVDIMMs that are performing
169       overwrite. Upon successful  completion  of  an  overwrite,  the  WBINVD
170       instruction  is  issued  by  the  kernel.  If  both  --crypto-erase and
171       --overwrite options are supplied, then crypto-erase is performed before
172       overwrite.
173
174   SECURITY FREEZE
175       This  operation  does  not  require  a  passphrase. This will cause any
176       security command other than a status query to be locked out  until  the
177       next boot.
178
179   MASTER PASSPHRASE SETUP, UPDATE, and CRYPTO ERASE
180       These  operations are similar to the user passphrase enable and update.
181       The only difference is that a different passphrase is used. The  master
182       passphrase  has  no  relation to the master key (kek) which is used for
183       encryption of either passphrase.
184
186       Copyright (c) 2016 - 2019, Intel Corporation. License  GPLv2:  GNU  GPL
187       version  2  <http://gnu.org/licenses/gpl.html>.  This is free software:
188       you are free to change and redistribute it. There is  NO  WARRANTY,  to
189       the extent permitted by law.
190
191
192
193ndctl                             2019-05-10                NDCTL-LOAD-KEYS(1)
Impressum