ACK: [PATCH 06/15] uefirtauthvar: add test update the authenticated variable
Colin Ian King
colin.king at canonical.com
Wed Oct 22 16:04:00 UTC 2014
On 22/10/14 10:38, Ivan Hu wrote:
> This test update the new authenticated variable by using the same key but
> a new timestame and data. It also checks the updated data and size.
>
> Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
> ---
> src/uefi/uefirtauthvar/authvardefs.h | 124 ++++++++++++++++++++++++++++++++
> src/uefi/uefirtauthvar/uefirtauthvar.c | 64 +++++++++++++++++
> 2 files changed, 188 insertions(+)
>
> diff --git a/src/uefi/uefirtauthvar/authvardefs.h b/src/uefi/uefirtauthvar/authvardefs.h
> index 703a8c8..1707dd3 100644
> --- a/src/uefi/uefirtauthvar/authvardefs.h
> +++ b/src/uefi/uefirtauthvar/authvardefs.h
> @@ -514,4 +514,128 @@ static uint8_t AuthVarAppend[] = {
>
> static uint8_t AuthVarAppendData[] = {0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x30};
>
> +/*
> + * AuthVarUpdate,
> + * timestamp: 2014.09.08:06:08:33
> + * GUID: 7f5c5d52-2f14-4f12-967cdb60db05a0fd
> + * attributes = UEFI_VAR_NON_VOLATILE, UEFI_VAR_BOOTSERVICE_ACCESS,
> + * UEFI_VAR_RUNTIME_ACCESS, UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
> + * Variable name: AuthVarTest
> + * data content: 0123456789
> + */
> +static uint8_t AuthVarUpdate[] = {
> + 0xde, 0x07, 0x09, 0x08, 0x06, 0x08, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00,
> + 0x00, 0x00, 0x00, 0x00, 0x0b, 0x05, 0x00, 0x00, 0x00, 0x02, 0xf1, 0x0e,
> + 0x9d, 0xd2, 0xaf, 0x4a, 0xdf, 0x68, 0xee, 0x49, 0x8a, 0xa9, 0x34, 0x7d,
> + 0x37, 0x56, 0x65, 0xa7, 0x30, 0x82, 0x04, 0xef, 0x06, 0x09, 0x2a, 0x86,
> + 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x82, 0x04, 0xe0, 0x30,
> + 0x82, 0x04, 0xdc, 0x02, 0x01, 0x01, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x09,
> + 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x30,
> + 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01,
> + 0xa0, 0x82, 0x02, 0xfd, 0x30, 0x82, 0x02, 0xf9, 0x30, 0x82, 0x01, 0xe1,
> + 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xbb, 0x94, 0x92, 0x5f,
> + 0x3b, 0x5e, 0xd3, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
> + 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x13, 0x31, 0x11, 0x30,
> + 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x08, 0x74, 0x65, 0x73, 0x74,
> + 0x2d, 0x6b, 0x65, 0x79, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x34, 0x30, 0x38,
> + 0x31, 0x32, 0x31, 0x30, 0x32, 0x31, 0x33, 0x30, 0x5a, 0x17, 0x0d, 0x31,
> + 0x34, 0x30, 0x39, 0x31, 0x31, 0x31, 0x30, 0x32, 0x31, 0x33, 0x30, 0x5a,
> + 0x30, 0x13, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
> + 0x08, 0x74, 0x65, 0x73, 0x74, 0x2d, 0x6b, 0x65, 0x79, 0x30, 0x82, 0x01,
> + 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
> + 0x01, 0x01, 0x05, 0x00, 0x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
> + 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
> + 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0xb2, 0x28, 0xe3,
> + 0x94, 0x02, 0x6f, 0xe5, 0x2a, 0xdc, 0x29, 0x7d, 0xcf, 0x2b, 0x88, 0x09,
> + 0x4f, 0x73, 0x8a, 0xc3, 0x54, 0xfc, 0xa3, 0x40, 0x84, 0x82, 0xce, 0x32,
> + 0x8d, 0x75, 0x51, 0xa2, 0xc3, 0x3f, 0x01, 0x0f, 0xde, 0x1b, 0x1f, 0x48,
> + 0xdb, 0x8f, 0xf9, 0xe0, 0xf3, 0x23, 0x78, 0x17, 0x4a, 0x84, 0xbc, 0xf4,
> + 0x84, 0xb5, 0xe5, 0x8c, 0x17, 0x36, 0x7f, 0x4f, 0x6f, 0x54, 0x47, 0xbd,
> + 0xe6, 0x40, 0xb0, 0x8a, 0x73, 0x74, 0x65, 0x57, 0x98, 0xf6, 0x77, 0x58,
> + 0x0e, 0x5f, 0x82, 0x77, 0xb3, 0xd9, 0x87, 0xf8, 0xe9, 0x21, 0x11, 0x37,
> + 0x4c, 0x6e, 0x5f, 0xda, 0x1e, 0x81, 0xa6, 0xa3, 0x45, 0x09, 0x81, 0x26,
> + 0xd0, 0xb6, 0xe1, 0x27, 0xa5, 0xc3, 0x6e, 0xed, 0x86, 0xb7, 0x4f, 0xf3,
> + 0x7e, 0x34, 0xa5, 0x0b, 0x8a, 0xd1, 0x56, 0x65, 0x04, 0xe2, 0x16, 0x71,
> + 0x11, 0xdc, 0xa8, 0xa6, 0xe0, 0x57, 0x91, 0x63, 0xe2, 0x9d, 0xe7, 0x86,
> + 0x00, 0xa6, 0xb4, 0x75, 0xf3, 0x37, 0x63, 0x48, 0x41, 0xcd, 0x97, 0x12,
> + 0x2e, 0x5c, 0xc0, 0xf0, 0x13, 0x62, 0x71, 0xc1, 0x8e, 0x65, 0x28, 0x52,
> + 0x09, 0x71, 0x87, 0x33, 0x27, 0x77, 0x84, 0x2f, 0xb4, 0x9a, 0x0a, 0x62,
> + 0xe6, 0x69, 0x05, 0xd7, 0x94, 0x70, 0x8a, 0xb9, 0x61, 0x68, 0xdb, 0xbd,
> + 0x4b, 0x58, 0xd3, 0x74, 0x0e, 0x3e, 0x00, 0x6c, 0x64, 0x02, 0x22, 0x4f,
> + 0x62, 0xbe, 0xe1, 0x53, 0x96, 0xa5, 0x6a, 0x7d, 0xf7, 0x8c, 0x77, 0x42,
> + 0x49, 0xb3, 0xb0, 0x44, 0xf1, 0xa9, 0xd5, 0x64, 0xdf, 0xcc, 0x8b, 0x90,
> + 0x03, 0x05, 0xb8, 0x07, 0x5f, 0x6e, 0x88, 0x11, 0x7e, 0x93, 0x85, 0xe6,
> + 0x3c, 0x87, 0x92, 0x74, 0xbb, 0xfe, 0x01, 0x32, 0xe8, 0x0b, 0xa9, 0xab,
> + 0x15, 0xd4, 0x8a, 0x4f, 0xd7, 0x40, 0x12, 0xe1, 0xde, 0x8a, 0xa8, 0x7c,
> + 0xf5, 0x31, 0x82, 0x01, 0xb6, 0x30, 0x82, 0x01, 0xb2, 0x02, 0x01, 0x01,
> + 0x30, 0x20, 0x30, 0x13, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04,
> + 0x03, 0x0c, 0x08, 0x74, 0x65, 0x73, 0x74, 0x2d, 0x6b, 0x65, 0x79, 0x02,
> + 0x09, 0x00, 0xbb, 0x94, 0x92, 0x5f, 0x3b, 0x5e, 0xd3, 0x2d, 0x30, 0x0d,
> + 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
> + 0x00, 0xa0, 0x69, 0x30, 0x18, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
> + 0x0d, 0x01, 0x09, 0x03, 0x31, 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
> + 0xf7, 0x0d, 0x01, 0x07, 0x01, 0x30, 0x1c, 0x06, 0x09, 0x2a, 0x86, 0x48,
> + 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x05, 0x31, 0x0f, 0x17, 0x0d, 0x31, 0x34,
> + 0x31, 0x30, 0x30, 0x38, 0x30, 0x36, 0x30, 0x38, 0x33, 0x33, 0x5a, 0x30,
> + 0x2f, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x04,
> + 0x31, 0x22, 0x04, 0x20, 0x87, 0xad, 0x32, 0xf8, 0x72, 0xff, 0x46, 0xe9,
> + 0xfc, 0x57, 0xca, 0xf2, 0x2e, 0x44, 0xf9, 0xcb, 0x91, 0x2d, 0x97, 0x76,
> + 0x6d, 0xc9, 0x5e, 0x31, 0x80, 0x5d, 0x76, 0xbd, 0xbc, 0xbd, 0x89, 0xb7,
> + 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
> + 0x01, 0x05, 0x00, 0x04, 0x82, 0x01, 0x00, 0x32, 0x3a, 0x9c, 0x07, 0x60,
> + 0xf4, 0x5a, 0x6d, 0x30, 0xd3, 0x45, 0x4d, 0xb8, 0x68, 0x59, 0x1b, 0x26,
> + 0xd5, 0xb0, 0x9b, 0x8e, 0x1b, 0x1b, 0x1e, 0x30, 0x0c, 0x61, 0x53, 0x43,
> + 0xa6, 0xde, 0x56, 0x49, 0x49, 0xfb, 0xf7, 0x5d, 0x73, 0xe9, 0xec, 0x49,
> + 0x97, 0x19, 0x5f, 0x0e, 0x03, 0x49, 0xbc, 0x1d, 0x62, 0x4c, 0xf5, 0xea,
> + 0x47, 0x5a, 0x6a, 0x32, 0x3e, 0x6d, 0x08, 0x19, 0x39, 0x6f, 0x0a, 0xf8,
> + 0x57, 0xdc, 0xbb, 0xe8, 0x34, 0x69, 0x7f, 0x43, 0x3e, 0x40, 0x6d, 0x49,
> + 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0xf5, 0x30,
> + 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39
> +};
> +
> +static uint8_t AuthVarUpdateData[] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39};
> +
> #endif
> diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
> index a64b4e4..0af2714 100644
> --- a/src/uefi/uefirtauthvar/uefirtauthvar.c
> +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
> @@ -366,11 +366,75 @@ static int uefirtauthvar_test4(fwts_framework *fw)
> return FWTS_OK;
> }
>
> +/*
> + * Update the new authenticated variable by using the same key but a new
> + * timestamp and data.
> + */
> +static int uefirtauthvar_test5(fwts_framework *fw)
> +{
> + long ioret;
> + int supcheck;
> +
> + uint8_t data[getvar_buf_size];
> + uint64_t getdatasize = sizeof(data);
> + uint64_t status;
> + uint32_t attributestest;
> + size_t i;
> +
> + ioret = setvar(>estguid, attributes, sizeof(AuthVarUpdate), AuthVarUpdate, &status);
> +
> + if (ioret == -1) {
> + supcheck = check_fw_support(fw, status);
> + if (supcheck != FWTS_OK)
> + return supcheck;
> +
> + fwts_failed(fw, LOG_LEVEL_HIGH,
> + "UEFIUpdateAuthVar",
> + "Failed to update authenticated variable with UEFI "
> + "runtime service.");
> +
> + fwts_uefi_print_status_info(fw, status);
> + return FWTS_ERROR;
> + }
> +
> + ioret = getvar(>estguid, &attributestest, &getdatasize, data, &status);
> + if (ioret == -1) {
> + fwts_failed(fw, LOG_LEVEL_HIGH,
> + "UEFIUpdateAuthVar",
> + "Failed to get authenticated variable with UEFI "
> + "runtime service.");
> + fwts_uefi_print_status_info(fw, status);
> + return FWTS_ERROR;
> + }
> +
> + if (getdatasize != sizeof(AuthVarUpdateData)) {
> + fwts_failed(fw, LOG_LEVEL_HIGH,
> + "UEFIUpdateAuthVar",
> + "Get authenticated variable data size is not the "
> + "same as it set.");
> + }
> +
> + for (i = 0; i < getdatasize; i++) {
> + if (data[i] != AuthVarUpdateData[i]) {
> + fwts_failed(fw, LOG_LEVEL_HIGH,
> + "UEFIUpdateAuthVar",
> + "Get authenticated variable data are not the "
> + "same as it set.");
> + return FWTS_ERROR;
> + }
> + }
> +
> + fwts_passed(fw, "Update authenticated variable tests passed.");
> +
> + return FWTS_OK;
> +}
> +
> static fwts_framework_minor_test uefirtauthvar_tests[] = {
> { uefirtauthvar_test1, "Create authenticated variable test." },
> { uefirtauthvar_test2, "Authenticated variable test with the same authenticated variable." },
> { uefirtauthvar_test3, "Authenticated variable test with another valid authenticated variable." },
> { uefirtauthvar_test4, "Append authenticated variable test." },
> + { uefirtauthvar_test5, "Update authenticated variable test." },
> { NULL, NULL }
> };
>
>
Acked-by: Colin Ian King <colin.king at canonical.com>
More information about the fwts-devel
mailing list