File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -245,13 +245,25 @@ def decrypt_config(key):
245
245
246
246
if not is_opened ():
247
247
if tpm_exists :
248
+ existing_key = None
249
+
250
+ try :
251
+ existing_key = read_tpm_key ()
252
+ except : pass
253
+
248
254
if args .enable :
249
- key = Fernet .generate_key ()
255
+ if existing_key :
256
+ print ('WARNING: An encryption key already exists in the TPM.' )
257
+ print ('If you choose not to use the existing key, any system image' )
258
+ print ('using the old key will need the recovery key.' )
259
+ if existing_key and ask_yes_no ('Do you want to use the existing TPM key?' ):
260
+ key = existing_key
261
+ else :
262
+ key = Fernet .generate_key ()
250
263
elif args .disable or args .load :
251
- try :
252
- key = read_tpm_key ()
264
+ if existing_key :
253
265
need_recovery = False
254
- except :
266
+ else :
255
267
print ('Failed to read key from TPM, recovery key required' )
256
268
need_recovery = True
257
269
else :
You can’t perform that action at this time.
0 commit comments