n_policy_hash,
srk,
ret_decrypted_key);
+ if (r == -EREMOTE)
+ return log_error_errno(r, "TPM key integrity check failed. Key enrolled in superblock most likely does not belong to this TPM.");
if (r < 0)
return log_error_errno(r, "Failed to unseal secret using TPM2: %m");
/* n_policy_hash= */ 1,
/* srk= */ NULL,
&tpm2_key);
+ if (r == -EREMOTE)
+ return log_error_errno(r, "TPM key integrity check failed. Key enrolled in superblock most likely does not belong to this TPM.");
if (r < 0)
return log_error_errno(r, "Failed to unseal secret using TPM2: %m");
#else
n_policy_hash,
srk,
ret_decrypted_key);
+ if (r == -EREMOTE)
+ return log_error_errno(r, "TPM key integrity check failed. Key enrolled in superblock most likely does not belong to this TPM.");
if (r < 0)
return log_error_errno(r, "Failed to unseal secret using TPM2: %m");
n_policy_hash,
srk,
ret_decrypted_key);
+ if (r == -EREMOTE)
+ return log_error_errno(r, "TPM key integrity check failed. Key enrolled in superblock most likely does not belong to this TPM.");
if (r < 0) {
log_error_errno(r, "Failed to unseal secret using TPM2: %m");
if (rc == TPM2_RC_LOCKOUT)
return log_debug_errno(SYNTHETIC_ERRNO(ENOLCK),
"TPM2 device is in dictionary attack lockout mode.");
+ if ((rc & ~(TPM2_RC_N_MASK|TPM2_RC_P)) == TPM2_RC_INTEGRITY) /* Return a recognizable error if this key does not belong to the local TPM */
+ return log_debug_errno(SYNTHETIC_ERRNO(EREMOTE),
+ "Key invalid or does not belong to current TPM.");
if (rc != TSS2_RC_SUCCESS)
return log_debug_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE),
"Failed to load key into TPM: %s", sym_Tss2_RC_Decode(rc));