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 @@ -242,13 +242,25 @@ def decrypt_config(key):
242
242
243
243
if not is_opened ():
244
244
if tpm_exists :
245
+ existing_key = None
246
+
247
+ try :
248
+ existing_key = read_tpm_key ()
249
+ except : pass
250
+
245
251
if args .enable :
246
- key = Fernet .generate_key ()
252
+ if existing_key :
253
+ print ('WARNING: An encryption key already exists in the TPM.' )
254
+ print ('If you choose not to use the existing key, any system image' )
255
+ print ('using the old key will need the recovery key.' )
256
+ if existing_key and ask_yes_no ('Do you want to use the existing TPM key?' ):
257
+ key = existing_key
258
+ else :
259
+ key = Fernet .generate_key ()
247
260
elif args .disable or args .load :
248
- try :
249
- key = read_tpm_key ()
261
+ if existing_key :
250
262
need_recovery = False
251
- except :
263
+ else :
252
264
print ('Failed to read key from TPM, recovery key required' )
253
265
need_recovery = True
254
266
else :
You can’t perform that action at this time.
0 commit comments