mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-24 06:24:17 +00:00
tpm: refactor tcg2_get_pcr_info()
Rename the arguments of tcg2_get_pcr_info() to clarify they are bank masks, not PCR mask. Remove the unused local variable. Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
parent
0698f1331f
commit
9f9797aaa8
2 changed files with 14 additions and 17 deletions
|
@ -94,17 +94,17 @@ struct tcg_pcr_event {
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tcg2_get_pcr_info() - get the supported, active PCRs and number of banks
|
* tcg2_get_pcr_info() - get the supported, active banks and number of banks
|
||||||
*
|
*
|
||||||
* @dev: TPM device
|
* @dev: TPM device
|
||||||
* @supported_pcr: bitmask with the algorithms supported
|
* @supported_bank: bitmask with the algorithms supported
|
||||||
* @active_pcr: bitmask with the active algorithms
|
* @active_bank: bitmask with the active algorithms
|
||||||
* @pcr_banks: number of PCR banks
|
* @bank_num: number of PCR banks
|
||||||
*
|
*
|
||||||
* @return 0 on success, code of operation or negative errno on failure
|
* @return 0 on success, code of operation or negative errno on failure
|
||||||
*/
|
*/
|
||||||
int tcg2_get_pcr_info(struct udevice *dev, u32 *supported_pcr, u32 *active_pcr,
|
int tcg2_get_pcr_info(struct udevice *dev, u32 *supported_bank, u32 *active_bank,
|
||||||
u32 *pcr_banks);
|
u32 *bank_num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crypto Agile Log Entry Format
|
* Crypto Agile Log Entry Format
|
||||||
|
|
|
@ -20,19 +20,16 @@
|
||||||
#include <linux/unaligned/le_byteshift.h>
|
#include <linux/unaligned/le_byteshift.h>
|
||||||
#include "tpm-utils.h"
|
#include "tpm-utils.h"
|
||||||
|
|
||||||
int tcg2_get_pcr_info(struct udevice *dev, u32 *supported_pcr, u32 *active_pcr,
|
int tcg2_get_pcr_info(struct udevice *dev, u32 *supported_bank, u32 *active_bank,
|
||||||
u32 *pcr_banks)
|
u32 *bank_num)
|
||||||
{
|
{
|
||||||
u8 response[(sizeof(struct tpms_capability_data) -
|
|
||||||
offsetof(struct tpms_capability_data, data))];
|
|
||||||
struct tpml_pcr_selection pcrs;
|
struct tpml_pcr_selection pcrs;
|
||||||
size_t i;
|
size_t i;
|
||||||
u32 ret;
|
u32 ret;
|
||||||
|
|
||||||
*supported_pcr = 0;
|
*supported_bank = 0;
|
||||||
*active_pcr = 0;
|
*active_bank = 0;
|
||||||
*pcr_banks = 0;
|
*bank_num = 0;
|
||||||
memset(response, 0, sizeof(response));
|
|
||||||
|
|
||||||
ret = tpm2_get_pcr_info(dev, &pcrs);
|
ret = tpm2_get_pcr_info(dev, &pcrs);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -42,16 +39,16 @@ int tcg2_get_pcr_info(struct udevice *dev, u32 *supported_pcr, u32 *active_pcr,
|
||||||
u32 hash_mask = tcg2_algorithm_to_mask(pcrs.selection[i].hash);
|
u32 hash_mask = tcg2_algorithm_to_mask(pcrs.selection[i].hash);
|
||||||
|
|
||||||
if (hash_mask) {
|
if (hash_mask) {
|
||||||
*supported_pcr |= hash_mask;
|
*supported_bank |= hash_mask;
|
||||||
if (tpm2_is_active_bank(&pcrs.selection[i]))
|
if (tpm2_is_active_bank(&pcrs.selection[i]))
|
||||||
*active_pcr |= hash_mask;
|
*active_bank |= hash_mask;
|
||||||
} else {
|
} else {
|
||||||
printf("%s: unknown algorithm %x\n", __func__,
|
printf("%s: unknown algorithm %x\n", __func__,
|
||||||
pcrs.selection[i].hash);
|
pcrs.selection[i].hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*pcr_banks = pcrs.count;
|
*bank_num = pcrs.count;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue