diff mbox

[14/15,RESEND] uefirtauthvar: Set and delete authenticated variable created by different key test

Message ID 1414048780-25388-1-git-send-email-ivan.hu@canonical.com
State Rejected
Headers show

Commit Message

Ivan Hu Oct. 23, 2014, 7:19 a.m. UTC
Test with setting and deleting another authenticated variable which created by
different key, after previous test authenticated variable was deleted. It also
will check the existence of authenticated variable and the correctness of the
data.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/uefi/uefirtauthvar/authvardefs.h   |  121 ++++++++++++++++++++++++++++++++
 src/uefi/uefirtauthvar/uefirtauthvar.c |   96 +++++++++++++++++++++++++
 2 files changed, 217 insertions(+)

Comments

Colin Ian King Oct. 23, 2014, 4:51 p.m. UTC | #1
On 23/10/14 08:19, Ivan Hu wrote:
> Test with setting and deleting another authenticated variable which created by
> different key, after previous test authenticated variable was deleted. It also
> will check the existence of authenticated variable and the correctness of the
> data.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/uefi/uefirtauthvar/authvardefs.h   |  121 ++++++++++++++++++++++++++++++++
>  src/uefi/uefirtauthvar/uefirtauthvar.c |   96 +++++++++++++++++++++++++
>  2 files changed, 217 insertions(+)
> 
> diff --git a/src/uefi/uefirtauthvar/authvardefs.h b/src/uefi/uefirtauthvar/authvardefs.h
> index 6c5434c..a90223d 100644
> --- a/src/uefi/uefirtauthvar/authvardefs.h
> +++ b/src/uefi/uefirtauthvar/authvardefs.h
> @@ -874,4 +874,125 @@ static uint8_t AuthVarModTime[] = {
>  	0x64, 0x65, 0x66
>  };
>  
> +/*
> + * AuthVarDelDiff, using the same key as AuthVarCreateDiffer
> + * timestamp: 2014.09.08:05:52:44
> + * 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: empty
> + */
> +static uint8_t AuthVarDelDiff[] = {
> +	0xde, 0x07, 0x09, 0x08, 0x05, 0x34, 0x2c, 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, 0xe2, 0x7d, 0x10, 0xea,
> +	0xd8, 0x0d, 0x98, 0x77, 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, 0x31, 0x30,
> +	0x30, 0x38, 0x30, 0x35, 0x34, 0x39, 0x35, 0x38, 0x5a, 0x17, 0x0d, 0x31,
> +	0x34, 0x31, 0x31, 0x30, 0x37, 0x30, 0x35, 0x34, 0x39, 0x35, 0x38, 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, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01,
> +	0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb2, 0x11, 0xba, 0xfc, 0xb3, 0xb5,
> +	0xe9, 0xb4, 0xf4, 0x66, 0xc7, 0xe7, 0xa8, 0xed, 0xd1, 0xdb, 0xd9, 0xb2,
> +	0xb4, 0x72, 0x0e, 0x7a, 0xc2, 0x00, 0xd1, 0xa3, 0x3f, 0x24, 0xa7, 0xc9,
> +	0x9f, 0xef, 0x14, 0x07, 0x48, 0x2f, 0x6a, 0x54, 0xdb, 0xde, 0x72, 0xa8,
> +	0xdd, 0xba, 0x2c, 0x61, 0x14, 0xd4, 0x53, 0x54, 0xe7, 0x96, 0xfd, 0xa1,
> +	0x26, 0x05, 0x63, 0x1d, 0xd7, 0x1a, 0x70, 0xf8, 0xb5, 0x3d, 0x40, 0xc0,
> +	0x33, 0x35, 0x8a, 0xe9, 0x88, 0x8a, 0x8a, 0x7d, 0x56, 0x39, 0x9b, 0x70,
> +	0x4a, 0x07, 0xd9, 0xc2, 0x44, 0xe2, 0x12, 0x2e, 0x8b, 0x78, 0x9e, 0x14,
> +	0x99, 0x7a, 0x47, 0x92, 0x9e, 0x42, 0x0f, 0x76, 0xb7, 0x3d, 0x1f, 0xb4,
> +	0x20, 0xd2, 0x6d, 0x93, 0xdf, 0x2e, 0xb1, 0x00, 0xa9, 0x94, 0xe0, 0x0b,
> +	0xe6, 0x57, 0x25, 0x76, 0x99, 0x63, 0xa7, 0x4c, 0x0b, 0x44, 0x48, 0x59,
> +	0xbe, 0x52, 0xfb, 0x64, 0xca, 0xe0, 0x21, 0x8e, 0xaf, 0xdc, 0xa5, 0xb2,
> +	0x5b, 0x4a, 0x80, 0x7e, 0xe2, 0x95, 0xa5, 0x95, 0xb7, 0x75, 0x19, 0x44,
> +	0x77, 0x1b, 0x8f, 0xa0, 0x57, 0xc7, 0xb5, 0x33, 0x7f, 0xbb, 0x5b, 0x41,
> +	0x63, 0xde, 0xc8, 0xdd, 0x4a, 0x41, 0x98, 0x1a, 0xc0, 0x36, 0xed, 0x8d,
> +	0x4c, 0xc9, 0x2f, 0x19, 0x39, 0xf4, 0xf4, 0x31, 0xb4, 0x4e, 0x78, 0xff,
> +	0xab, 0x91, 0xe6, 0xf2, 0x23, 0xdc, 0x79, 0x24, 0x54, 0xba, 0x05, 0x60,
> +	0x2c, 0xad, 0x29, 0xeb, 0x8e, 0xa0, 0x2d, 0x73, 0x09, 0xbd, 0xdf, 0xe3,
> +	0x76, 0x98, 0x04, 0x4d, 0x29, 0x7d, 0xdd, 0xd2, 0xbd, 0xa8, 0x32, 0x66,
> +	0x45, 0x01, 0xff, 0xd7, 0xd0, 0x83, 0xfb, 0xec, 0xaa, 0xb7, 0x45, 0x34,
> +	0xf4, 0xd8, 0xf1, 0x23, 0x0e, 0x15, 0x84, 0xde, 0x59, 0xe5, 0x2e, 0x06,
> +	0xd6, 0xb8, 0x11, 0x1d, 0x59, 0xc9, 0x93, 0xea, 0x4e, 0x4b, 0x02, 0x03,
> +	0x01, 0x00, 0x01, 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55,
> +	0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xe5, 0x35, 0x8b, 0x82, 0xc5, 0xf0,
> +	0x10, 0x89, 0x6b, 0xe2, 0xdd, 0x60, 0x20, 0x5a, 0xd6, 0x17, 0x1e, 0x17,
> +	0x2a, 0xb8, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30,
> +	0x16, 0x80, 0x14, 0xe5, 0x35, 0x8b, 0x82, 0xc5, 0xf0, 0x10, 0x89, 0x6b,
> +	0xe2, 0xdd, 0x60, 0x20, 0x5a, 0xd6, 0x17, 0x1e, 0x17, 0x2a, 0xb8, 0x30,
> +	0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01,
> +	0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
> +	0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x8d, 0x9e, 0x39,
> +	0xf2, 0xf8, 0x1f, 0xb3, 0x71, 0x2b, 0x2d, 0xcb, 0x22, 0xf7, 0x23, 0x88,
> +	0xd4, 0x60, 0xee, 0xb1, 0xf7, 0xce, 0x39, 0x0d, 0xfd, 0xe5, 0x77, 0x5e,
> +	0x69, 0xf1, 0x39, 0xc6, 0x4b, 0x16, 0x30, 0xc4, 0x95, 0x70, 0x29, 0x3b,
> +	0x48, 0xe7, 0x6c, 0x33, 0x1d, 0x28, 0xa3, 0x87, 0x0e, 0xcf, 0xd3, 0x63,
> +	0x1b, 0x1a, 0x51, 0x61, 0xa7, 0x4a, 0x30, 0x47, 0xbc, 0xbc, 0x10, 0xe0,
> +	0x6e, 0x7b, 0x49, 0x2b, 0x77, 0xa8, 0x31, 0x0b, 0xfa, 0x64, 0xfe, 0x06,
> +	0x6f, 0xab, 0x59, 0x70, 0x31, 0xcc, 0x94, 0x63, 0x3a, 0x9b, 0xea, 0x8b,
> +	0xc2, 0xaa, 0x30, 0xed, 0xe0, 0x09, 0x7f, 0x16, 0x60, 0xf3, 0xc6, 0x5b,
> +	0xcb, 0x7e, 0xed, 0xab, 0x54, 0x8d, 0x46, 0x1f, 0x29, 0xa3, 0xa7, 0x8c,
> +	0xea, 0xb5, 0xed, 0xbe, 0x80, 0x00, 0x5f, 0x01, 0xbe, 0xa7, 0x92, 0x4f,
> +	0x3b, 0xe5, 0xc8, 0x3c, 0x93, 0x41, 0xbf, 0x51, 0x1e, 0x09, 0x99, 0xbe,
> +	0xb7, 0x65, 0x88, 0x93, 0x82, 0x26, 0x9b, 0x90, 0xc7, 0xb8, 0xea, 0x6b,
> +	0x79, 0x0f, 0xf4, 0x5e, 0x1a, 0x8f, 0x77, 0xdd, 0xa6, 0x7a, 0x53, 0xd4,
> +	0x9f, 0xb9, 0xab, 0x97, 0xdf, 0x40, 0xd8, 0x42, 0xfd, 0x1a, 0xa7, 0xa9,
> +	0x90, 0x0c, 0x98, 0x7e, 0xb1, 0x5e, 0xff, 0xeb, 0xd6, 0xec, 0x65, 0xce,
> +	0xd2, 0x4e, 0xd1, 0x71, 0x4b, 0xd5, 0xb8, 0x78, 0x64, 0xc2, 0x5f, 0xaf,
> +	0x50, 0x20, 0xa6, 0xf0, 0xba, 0x62, 0xa3, 0xe5, 0x38, 0xa2, 0x9f, 0x17,
> +	0xda, 0x65, 0xe6, 0x94, 0x1c, 0xa0, 0xc0, 0xf0, 0xf9, 0x5f, 0xeb, 0xdc,
> +	0x05, 0x70, 0x73, 0x60, 0xa5, 0x54, 0x89, 0x22, 0x84, 0x93, 0x79, 0x27,
> +	0xe6, 0xf6, 0x51, 0x72, 0x3e, 0x86, 0xd4, 0x7f, 0x0b, 0xb7, 0xed, 0xc4,
> +	0x09, 0x0f, 0xac, 0xf5, 0x58, 0x88, 0x10, 0xee, 0x8a, 0xc2, 0xeb, 0x12,
> +	0xe4, 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, 0xe2, 0x7d, 0x10, 0xea, 0xd8, 0x0d, 0x98, 0x77, 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, 0x35, 0x35, 0x32, 0x34, 0x34, 0x5a, 0x30,
> +	0x2f, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x04,
> +	0x31, 0x22, 0x04, 0x20, 0x03, 0x19, 0x7f, 0xab, 0x44, 0x42, 0xb8, 0x28,
> +	0x7f, 0x7d, 0x08, 0x1d, 0x7d, 0xe1, 0x79, 0x15, 0x72, 0x28, 0xa2, 0xd3,
> +	0x52, 0xe1, 0x47, 0xbf, 0x4d, 0x24, 0xaf, 0xca, 0x62, 0x23, 0xf4, 0x1c,
> +	0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
> +	0x01, 0x05, 0x00, 0x04, 0x82, 0x01, 0x00, 0x3d, 0x41, 0x71, 0xdb, 0x14,
> +	0x04, 0x4b, 0x69, 0x96, 0xb4, 0xf1, 0x50, 0xa3, 0x22, 0x85, 0xcc, 0x6c,
> +	0x0b, 0x6b, 0xe4, 0x12, 0x66, 0xd7, 0xd4, 0xd1, 0x03, 0x44, 0xf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d, 0x8e, 0x18, 0xc5, 0x19, 0x2b,
> +	0xaa, 0xc9, 0xf3, 0xf1, 0x0e, 0x5f, 0x55, 0x15, 0x16, 0xdf, 0x99, 0x1b,
> +	0xca, 0x18, 0xa5, 0x4e, 0xc8, 0x38, 0x05, 0xc1, 0xc9, 0x0b, 0xa7, 0xba,
> +	0x38, 0x94, 0x58, 0xa9, 0x2c, 0xf4, 0x94, 0x1a, 0x8c, 0x88, 0xb9, 0x9c,
> +	0xe6, 0x88, 0x13, 0x58, 0xd0, 0xcd, 0x2d, 0x84, 0x01, 0x63, 0xef
> +};
> +
>  #endif
> diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
> index 387cd93..6188396 100644
> --- a/src/uefi/uefirtauthvar/uefirtauthvar.c
> +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
> @@ -713,6 +713,101 @@ static int uefirtauthvar_test12(fwts_framework *fw)
>  	return FWTS_ERROR;
>  }
>  
> +/*
> + * Test with setting and deleting another authenticated variable,
> + * after previous test authenticated variable was deleted.
> + */
> +static int uefirtauthvar_test13(fwts_framework *fw)
> +{
> +	long ioret;
> +
> +	uint8_t data[getvar_buf_size];
> +	uint64_t getdatasize = sizeof(data);
> +	uint64_t status;
> +	int supcheck;
> +	uint32_t attributestest;
> +	size_t i;
> +
> +	ioret = setvar(&gtestguid, attributes, sizeof(AuthVarCreateDiff), AuthVarCreateDiff, &status);
> +
> +	if (ioret == -1) {
> +		supcheck = check_fw_support(fw, status);
> +		if (supcheck != FWTS_OK)
> +			return supcheck;
> +
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"UEFISetAuthVarDiff",
> +			"Failed to set authenticated variable with UEFI "
> +			"runtime service.");
> +
> +		fwts_uefi_print_status_info(fw, status);
> +		return FWTS_ERROR;
> +	}
> +
> +	ioret = getvar(&gtestguid, &attributestest, &getdatasize, data, &status);
> +	if (ioret == -1) {
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"UEFISetAuthVarDiff",
> +			"Failed to get authenticated variable with UEFI "
> +			"runtime service.");
> +		fwts_uefi_print_status_info(fw, status);
> +		return FWTS_ERROR;
> +	}
> +	if (getdatasize != sizeof(AuthVarCreateData)) {
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"UEFISetAuthVarDiff",
> +			"Get authenticated variable data size is not the "
> +			"same as it set.");
> +	}
> +	for (i = 0; i < sizeof(AuthVarCreateData); i++) {
> +		if (data[i] != AuthVarCreateData[i]) {
> +			fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"UEFISetAuthVarDiff",
> +			"Get authenticated variable data are not the "
> +			"same as it set.");
> +		return FWTS_ERROR;
> +		}
> +	}
> +
> +	fwts_passed(fw, "Set authenticated variable created by different key test passed.");
> +
> +	ioret = setvar(&gtestguid, attributes, sizeof(AuthVarDelDiff), AuthVarDelDiff, &status);
> +
> +	if (ioret == -1) {
> +		supcheck = check_fw_support(fw, status);
> +		if (supcheck != FWTS_OK)
> +			return supcheck;
> +
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"UEFIDelAuthVarDiff",
> +			"Failed to delete autheticated variable with UEFI "
> +			"runtime service.");
> +		fwts_uefi_print_status_info(fw, status);
> +		return FWTS_ERROR;
> +	}
> +
> +	ioret = getvar(&gtestguid, &attributestest, &getdatasize, data, &status);
> +	if (ioret == -1) {
> +		if (status == EFI_NOT_FOUND) {
> +			fwts_passed(fw, "Delete authenticated variable created by different key test passed.");
> +			return FWTS_OK;
> +		}
> +
> +		fwts_failed(fw, LOG_LEVEL_HIGH,
> +			"UEFIDelAuthVarDiff",
> +			"Failed to get authenticated variable with UEFI "
> +			"runtime service.");
> +		fwts_uefi_print_status_info(fw, status);
> +		return FWTS_ERROR;
> +	}
> +
> +	fwts_failed(fw, LOG_LEVEL_HIGH,
> +		"UEFIDelAuthVarDiff",
> +		"Failed to delete authenticated variable still get the test"
> +		"authenticated variable.");
> +
> +	return FWTS_ERROR;
> +}
>  
>  static fwts_framework_minor_test uefirtauthvar_tests[] = {
>  	{ uefirtauthvar_test1, "Create authenticated variable test." },
> @@ -727,6 +822,7 @@ static fwts_framework_minor_test uefirtauthvar_tests[] = {
>  	{ uefirtauthvar_test10, "Authenticated variable test with different guid." },
>  	{ uefirtauthvar_test11, "Authenticated variable test with invalid attributes." },
>  	{ uefirtauthvar_test12, "Test with both authenticated attributes are set." },
> +	{ uefirtauthvar_test13, "Set and delete authenticated variable created by different key test." },
>  	{ NULL, NULL }
>  };

Acked-by: Colin Ian King <colin.king@canonical.com>
>  
>
Ivan Hu Oct. 24, 2014, 10:26 a.m. UTC | #2
typos, will resend.

On 10/24/2014 12:51 AM, Colin Ian King wrote:
> On 23/10/14 08:19, Ivan Hu wrote:
>> Test with setting and deleting another authenticated variable which created by
>> different key, after previous test authenticated variable was deleted. It also
>> will check the existence of authenticated variable and the correctness of the
>> data.
>>
>> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
>> ---
>>   src/uefi/uefirtauthvar/authvardefs.h   |  121 ++++++++++++++++++++++++++++++++
>>   src/uefi/uefirtauthvar/uefirtauthvar.c |   96 +++++++++++++++++++++++++
>>   2 files changed, 217 insertions(+)
>>
>> diff --git a/src/uefi/uefirtauthvar/authvardefs.h b/src/uefi/uefirtauthvar/authvardefs.h
>> index 6c5434c..a90223d 100644
>> --- a/src/uefi/uefirtauthvar/authvardefs.h
>> +++ b/src/uefi/uefirtauthvar/authvardefs.h
>> @@ -874,4 +874,125 @@ static uint8_t AuthVarModTime[] = {
>>   	0x64, 0x65, 0x66
>>   };
>>
>> +/*
>> + * AuthVarDelDiff, using the same key as AuthVarCreateDiffer
>> + * timestamp: 2014.09.08:05:52:44
>> + * 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: empty
>> + */
>> +static uint8_t AuthVarDelDiff[] = {
>> +	0xde, 0x07, 0x09, 0x08, 0x05, 0x34, 0x2c, 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, 0xe2, 0x7d, 0x10, 0xea,
>> +	0xd8, 0x0d, 0x98, 0x77, 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, 0x31, 0x30,
>> +	0x30, 0x38, 0x30, 0x35, 0x34, 0x39, 0x35, 0x38, 0x5a, 0x17, 0x0d, 0x31,
>> +	0x34, 0x31, 0x31, 0x30, 0x37, 0x30, 0x35, 0x34, 0x39, 0x35, 0x38, 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, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01,
>> +	0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xb2, 0x11, 0xba, 0xfc, 0xb3, 0xb5,
>> +	0xe9, 0xb4, 0xf4, 0x66, 0xc7, 0xe7, 0xa8, 0xed, 0xd1, 0xdb, 0xd9, 0xb2,
>> +	0xb4, 0x72, 0x0e, 0x7a, 0xc2, 0x00, 0xd1, 0xa3, 0x3f, 0x24, 0xa7, 0xc9,
>> +	0x9f, 0xef, 0x14, 0x07, 0x48, 0x2f, 0x6a, 0x54, 0xdb, 0xde, 0x72, 0xa8,
>> +	0xdd, 0xba, 0x2c, 0x61, 0x14, 0xd4, 0x53, 0x54, 0xe7, 0x96, 0xfd, 0xa1,
>> +	0x26, 0x05, 0x63, 0x1d, 0xd7, 0x1a, 0x70, 0xf8, 0xb5, 0x3d, 0x40, 0xc0,
>> +	0x33, 0x35, 0x8a, 0xe9, 0x88, 0x8a, 0x8a, 0x7d, 0x56, 0x39, 0x9b, 0x70,
>> +	0x4a, 0x07, 0xd9, 0xc2, 0x44, 0xe2, 0x12, 0x2e, 0x8b, 0x78, 0x9e, 0x14,
>> +	0x99, 0x7a, 0x47, 0x92, 0x9e, 0x42, 0x0f, 0x76, 0xb7, 0x3d, 0x1f, 0xb4,
>> +	0x20, 0xd2, 0x6d, 0x93, 0xdf, 0x2e, 0xb1, 0x00, 0xa9, 0x94, 0xe0, 0x0b,
>> +	0xe6, 0x57, 0x25, 0x76, 0x99, 0x63, 0xa7, 0x4c, 0x0b, 0x44, 0x48, 0x59,
>> +	0xbe, 0x52, 0xfb, 0x64, 0xca, 0xe0, 0x21, 0x8e, 0xaf, 0xdc, 0xa5, 0xb2,
>> +	0x5b, 0x4a, 0x80, 0x7e, 0xe2, 0x95, 0xa5, 0x95, 0xb7, 0x75, 0x19, 0x44,
>> +	0x77, 0x1b, 0x8f, 0xa0, 0x57, 0xc7, 0xb5, 0x33, 0x7f, 0xbb, 0x5b, 0x41,
>> +	0x63, 0xde, 0xc8, 0xdd, 0x4a, 0x41, 0x98, 0x1a, 0xc0, 0x36, 0xed, 0x8d,
>> +	0x4c, 0xc9, 0x2f, 0x19, 0x39, 0xf4, 0xf4, 0x31, 0xb4, 0x4e, 0x78, 0xff,
>> +	0xab, 0x91, 0xe6, 0xf2, 0x23, 0xdc, 0x79, 0x24, 0x54, 0xba, 0x05, 0x60,
>> +	0x2c, 0xad, 0x29, 0xeb, 0x8e, 0xa0, 0x2d, 0x73, 0x09, 0xbd, 0xdf, 0xe3,
>> +	0x76, 0x98, 0x04, 0x4d, 0x29, 0x7d, 0xdd, 0xd2, 0xbd, 0xa8, 0x32, 0x66,
>> +	0x45, 0x01, 0xff, 0xd7, 0xd0, 0x83, 0xfb, 0xec, 0xaa, 0xb7, 0x45, 0x34,
>> +	0xf4, 0xd8, 0xf1, 0x23, 0x0e, 0x15, 0x84, 0xde, 0x59, 0xe5, 0x2e, 0x06,
>> +	0xd6, 0xb8, 0x11, 0x1d, 0x59, 0xc9, 0x93, 0xea, 0x4e, 0x4b, 0x02, 0x03,
>> +	0x01, 0x00, 0x01, 0xa3, 0x50, 0x30, 0x4e, 0x30, 0x1d, 0x06, 0x03, 0x55,
>> +	0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xe5, 0x35, 0x8b, 0x82, 0xc5, 0xf0,
>> +	0x10, 0x89, 0x6b, 0xe2, 0xdd, 0x60, 0x20, 0x5a, 0xd6, 0x17, 0x1e, 0x17,
>> +	0x2a, 0xb8, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30,
>> +	0x16, 0x80, 0x14, 0xe5, 0x35, 0x8b, 0x82, 0xc5, 0xf0, 0x10, 0x89, 0x6b,
>> +	0xe2, 0xdd, 0x60, 0x20, 0x5a, 0xd6, 0x17, 0x1e, 0x17, 0x2a, 0xb8, 0x30,
>> +	0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01,
>> +	0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
>> +	0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x8d, 0x9e, 0x39,
>> +	0xf2, 0xf8, 0x1f, 0xb3, 0x71, 0x2b, 0x2d, 0xcb, 0x22, 0xf7, 0x23, 0x88,
>> +	0xd4, 0x60, 0xee, 0xb1, 0xf7, 0xce, 0x39, 0x0d, 0xfd, 0xe5, 0x77, 0x5e,
>> +	0x69, 0xf1, 0x39, 0xc6, 0x4b, 0x16, 0x30, 0xc4, 0x95, 0x70, 0x29, 0x3b,
>> +	0x48, 0xe7, 0x6c, 0x33, 0x1d, 0x28, 0xa3, 0x87, 0x0e, 0xcf, 0xd3, 0x63,
>> +	0x1b, 0x1a, 0x51, 0x61, 0xa7, 0x4a, 0x30, 0x47, 0xbc, 0xbc, 0x10, 0xe0,
>> +	0x6e, 0x7b, 0x49, 0x2b, 0x77, 0xa8, 0x31, 0x0b, 0xfa, 0x64, 0xfe, 0x06,
>> +	0x6f, 0xab, 0x59, 0x70, 0x31, 0xcc, 0x94, 0x63, 0x3a, 0x9b, 0xea, 0x8b,
>> +	0xc2, 0xaa, 0x30, 0xed, 0x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x01,
>> +	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, 0xe2, 0x7d, 0x10, 0xea, 0xd8, 0x0d, 0x98, 0x77, 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, 0x35, 0x35, 0x32, 0x34, 0x34, 0x5a, 0x30,
>> +	0x2f, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x04,
>> +	0x31, 0x22, 0x04, 0x20, 0x03, 0x19, 0x7f, 0xab, 0x44, 0x42, 0xb8, 0x28,
>> +	0x7f, 0x7d, 0x08, 0x1d, 0x7d, 0xe1, 0x79, 0x15, 0x72, 0x28, 0xa2, 0xd3,
>> +	0x52, 0xe1, 0x47, 0xbf, 0x4d, 0x24, 0xaf, 0xca, 0x62, 0x23, 0xf4, 0x1c,
>> +	0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
>> +	0x01, 0x05, 0x00, 0x04, 0x82, 0x01, 0x00, 0x3d, 0x41, 0x71, 0xdb, 0x14,
>> +	0x04, 0x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b, 0x98, 0x96, 0x0b, 0x78,
>> +	0x0c, 0xf2, 0xfb, 0xa0, 0x9d, 0x19, 0x17, 0x4a, 0xb4, 0x3f, 0x39, 0x5a,
>> +	0x55, 0xd0, 0x5b, 0xd9, 0x61, 0x33, 0x8d, 0x8e, 0x18, 0xc5, 0x19, 0x2b,
>> +	0xaa, 0xc9, 0xf3, 0xf1, 0x0e, 0x5f, 0x55, 0x15, 0x16, 0xdf, 0x99, 0x1b,
>> +	0xca, 0x18, 0xa5, 0x4e, 0xc8, 0x38, 0x05, 0xc1, 0xc9, 0x0b, 0xa7, 0xba,
>> +	0x38, 0x94, 0x58, 0xa9, 0x2c, 0xf4, 0x94, 0x1a, 0x8c, 0x88, 0xb9, 0x9c,
>> +	0xe6, 0x88, 0x13, 0x58, 0xd0, 0xcd, 0x2d, 0x84, 0x01, 0x63, 0xef
>> +};
>> +
>>   #endif
>> diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
>> index 387cd93..6188396 100644
>> --- a/src/uefi/uefirtauthvar/uefirtauthvar.c
>> +++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
>> @@ -713,6 +713,101 @@ static int uefirtauthvar_test12(fwts_framework *fw)
>>   	return FWTS_ERROR;
>>   }
>>
>> +/*
>> + * Test with setting and deleting another authenticated variable,
>> + * after previous test authenticated variable was deleted.
>> + */
>> +static int uefirtauthvar_test13(fwts_framework *fw)
>> +{
>> +	long ioret;
>> +
>> +	uint8_t data[getvar_buf_size];
>> +	uint64_t getdatasize = sizeof(data);
>> +	uint64_t status;
>> +	int supcheck;
>> +	uint32_t attributestest;
>> +	size_t i;
>> +
>> +	ioret = setvar(&gtestguid, attributes, sizeof(AuthVarCreateDiff), AuthVarCreateDiff, &status);
>> +
>> +	if (ioret == -1) {
>> +		supcheck = check_fw_support(fw, status);
>> +		if (supcheck != FWTS_OK)
>> +			return supcheck;
>> +
>> +		fwts_failed(fw, LOG_LEVEL_HIGH,
>> +			"UEFISetAuthVarDiff",
>> +			"Failed to set authenticated variable with UEFI "
>> +			"runtime service.");
>> +
>> +		fwts_uefi_print_status_info(fw, status);
>> +		return FWTS_ERROR;
>> +	}
>> +
>> +	ioret = getvar(&gtestguid, &attributestest, &getdatasize, data, &status);
>> +	if (ioret == -1) {
>> +		fwts_failed(fw, LOG_LEVEL_HIGH,
>> +			"UEFISetAuthVarDiff",
>> +			"Failed to get authenticated variable with UEFI "
>> +			"runtime service.");
>> +		fwts_uefi_print_status_info(fw, status);
>> +		return FWTS_ERROR;
>> +	}
>> +	if (getdatasize != sizeof(AuthVarCreateData)) {
>> +		fwts_failed(fw, LOG_LEVEL_HIGH,
>> +			"UEFISetAuthVarDiff",
>> +			"Get authenticated variable data size is not the "
>> +			"same as it set.");
>> +	}
>> +	for (i = 0; i < sizeof(AuthVarCreateData); i++) {
>> +		if (data[i] != AuthVarCreateData[i]) {
>> +			fwts_failed(fw, LOG_LEVEL_HIGH,
>> +			"UEFISetAuthVarDiff",
>> +			"Get authenticated variable data are not the "
>> +			"same as it set.");
>> +		return FWTS_ERROR;
>> +		}
>> +	}
>> +
>> +	fwts_passed(fw, "Set authenticated variable created by different key test passed.");
>> +
>> +	ioret = setvar(&gtestguid, attributes, sizeof(AuthVarDelDiff), AuthVarDelDiff, &status);
>> +
>> +	if (ioret == -1) {
>> +		supcheck = check_fw_support(fw, status);
>> +		if (supcheck != FWTS_OK)
>> +			return supcheck;
>> +
>> +		fwts_failed(fw, LOG_LEVEL_HIGH,
>> +			"UEFIDelAuthVarDiff",
>> +			"Failed to delete autheticated variable with UEFI "
>> +			"runtime service.");
>> +		fwts_uefi_print_status_info(fw, status);
>> +		return FWTS_ERROR;
>> +	}
>> +
>> +	ioret = getvar(&gtestguid, &attributestest, &getdatasize, data, &status);
>> +	if (ioret == -1) {
>> +		if (status == EFI_NOT_FOUND) {
>> +			fwts_passed(fw, "Delete authenticated variable created by different key test passed.");
>> +			return FWTS_OK;
>> +		}
>> +
>> +		fwts_failed(fw, LOG_LEVEL_HIGH,
>> +			"UEFIDelAuthVarDiff",
>> +			"Failed to get authenticated variable with UEFI "
>> +			"runtime service.");
>> +		fwts_uefi_print_status_info(fw, status);
>> +		return FWTS_ERROR;
>> +	}
>> +
>> +	fwts_failed(fw, LOG_LEVEL_HIGH,
>> +		"UEFIDelAuthVarDiff",
>> +		"Failed to delete authenticated variable still get the test"
>> +		"authenticated variable.");
>> +
>> +	return FWTS_ERROR;
>> +}
>>
>>   static fwts_framework_minor_test uefirtauthvar_tests[] = {
>>   	{ uefirtauthvar_test1, "Create authenticated variable test." },
>> @@ -727,6 +822,7 @@ static fwts_framework_minor_test uefirtauthvar_tests[] = {
>>   	{ uefirtauthvar_test10, "Authenticated variable test with different guid." },
>>   	{ uefirtauthvar_test11, "Authenticated variable test with invalid attributes." },
>>   	{ uefirtauthvar_test12, "Test with both authenticated attributes are set." },
>> +	{ uefirtauthvar_test13, "Set and delete authenticated variable created by different key test." },
>>   	{ NULL, NULL }
>>   };
diff mbox

Patch

diff --git a/src/uefi/uefirtauthvar/authvardefs.h b/src/uefi/uefirtauthvar/authvardefs.h
index 6c5434c..a90223d 100644
--- a/src/uefi/uefirtauthvar/authvardefs.h
+++ b/src/uefi/uefirtauthvar/authvardefs.h
@@ -874,4 +874,125 @@  static uint8_t AuthVarModTime[] = {
 	0x64, 0x65, 0x66
 };
 
+/*
+ * AuthVarDelDiff, using the same key as AuthVarCreateDiffer
+ * timestamp: 2014.09.08:05:52:44
+ * 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: empty
+ */
+static uint8_t AuthVarDelDiff[] = {
+	0xde, 0x07, 0x09, 0x08, 0x05, 0x34, 0x2c, 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, 0xe2, 0x7d, 0x10, 0xea,
+	0xd8, 0x0d, 0x98, 0x77, 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, 0x31, 0x30,
+	0x30, 0x38, 0x30, 0x35, 0x34, 0x39, 0x35, 0x38, 0x5a, 0x17, 0x0d, 0x31,
+	0x34, 0x31, 0x31, 0x30, 0x37, 0x30, 0x35, 0x34, 0x39, 0x35, 0x38, 0x5a,
+	0x30, 0x13, 0x31, 0x11, 0x30, 0x0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x09, 0x99, 0xbe,
+	0xb7, 0x65, 0x88, 0x93, 0x82, 0x26, 0x9b, 0x90, 0xc7, 0xb8, 0xea, 0x6b,
+	0x79, 0x0f, 0xf4, 0x5e, 0x1a, 0x8f, 0x77, 0xdd, 0xa6, 0x7a, 0x53, 0xd4,
+	0x9f, 0xb9, 0xab, 0x97, 0xdf, 0x40, 0xd8, 0x42, 0xfd, 0x1a, 0xa7, 0xa9,
+	0x90, 0x0c, 0x98, 0x7e, 0xb1, 0x5e, 0xff, 0xeb, 0xd6, 0xec, 0x65, 0xce,
+	0xd2, 0x4e, 0xd1, 0x71, 0x4b, 0xd5, 0xb8, 0x78, 0x64, 0xc2, 0x5f, 0xaf,
+	0x50, 0x20, 0xa6, 0xf0, 0xba, 0x62, 0xa3, 0xe5, 0x38, 0xa2, 0x9f, 0x17,
+	0xda, 0x65, 0xe6, 0x94, 0x1c, 0xa0, 0xc0, 0xf0, 0xf9, 0x5f, 0xeb, 0xdc,
+	0x05, 0x70, 0x73, 0x60, 0xa5, 0x54, 0x89, 0x22, 0x84, 0x93, 0x79, 0x27,
+	0xe6, 0xf6, 0x51, 0x72, 0x3e, 0x86, 0xd4, 0x7f, 0x0b, 0xb7, 0xed, 0xc4,
+	0x09, 0x0f, 0xac, 0xf5, 0x58, 0x88, 0x10, 0xee, 0x8a, 0xc2, 0xeb, 0x12,
+	0xe4, 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, 0xe2, 0x7d, 0x10, 0xea, 0xd8, 0x0d, 0x98, 0x77, 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, 0x35, 0x35, 0x32, 0x34, 0x34, 0x5a, 0x30,
+	0x2f, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x04,
+	0x31, 0x22, 0x04, 0x20, 0x03, 0x19, 0x7f, 0xab, 0x44, 0x42, 0xb8, 0x28,
+	0x7f, 0x7d, 0x08, 0x1d, 0x7d, 0xe1, 0x79, 0x15, 0x72, 0x28, 0xa2, 0xd3,
+	0x52, 0xe1, 0x47, 0xbf, 0x4d, 0x24, 0xaf, 0xca, 0x62, 0x23, 0xf4, 0x1c,
+	0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
+	0x01, 0x05, 0x00, 0x04, 0x82, 0x01, 0x00, 0x3d, 0x41, 0x71, 0xdb, 0x14,
+	0x04, 0x4b, 0x69, 0x96, 0xb4, 0xf1, 0x50, 0xa3, 0x22, 0x85, 0xcc, 0x6c,
+	0x0b, 0x6b, 0xe4, 0x12, 0x66, 0xd7, 0xd4, 0xd1, 0x03, 0x44, 0xfd, 0xef,
+	0x19, 0xaf, 0xcf, 0xe3, 0x1d, 0x45, 0x57, 0x9a, 0x40, 0xa9, 0x20, 0x89,
+	0x23, 0xfa, 0x64, 0xc2, 0x7b, 0x2a, 0x75, 0x86, 0xf9, 0x25, 0xf7, 0x38,
+	0x33, 0x88, 0x45, 0x4b, 0x9c, 0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a9, 0x2c, 0xf4, 0x94, 0x1a, 0x8c, 0x88, 0xb9, 0x9c,
+	0xe6, 0x88, 0x13, 0x58, 0xd0, 0xcd, 0x2d, 0x84, 0x01, 0x63, 0xef
+};
+
 #endif
diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
index 387cd93..6188396 100644
--- a/src/uefi/uefirtauthvar/uefirtauthvar.c
+++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
@@ -713,6 +713,101 @@  static int uefirtauthvar_test12(fwts_framework *fw)
 	return FWTS_ERROR;
 }
 
+/*
+ * Test with setting and deleting another authenticated variable,
+ * after previous test authenticated variable was deleted.
+ */
+static int uefirtauthvar_test13(fwts_framework *fw)
+{
+	long ioret;
+
+	uint8_t data[getvar_buf_size];
+	uint64_t getdatasize = sizeof(data);
+	uint64_t status;
+	int supcheck;
+	uint32_t attributestest;
+	size_t i;
+
+	ioret = setvar(&gtestguid, attributes, sizeof(AuthVarCreateDiff), AuthVarCreateDiff, &status);
+
+	if (ioret == -1) {
+		supcheck = check_fw_support(fw, status);
+		if (supcheck != FWTS_OK)
+			return supcheck;
+
+		fwts_failed(fw, LOG_LEVEL_HIGH,
+			"UEFISetAuthVarDiff",
+			"Failed to set authenticated variable with UEFI "
+			"runtime service.");
+
+		fwts_uefi_print_status_info(fw, status);
+		return FWTS_ERROR;
+	}
+
+	ioret = getvar(&gtestguid, &attributestest, &getdatasize, data, &status);
+	if (ioret == -1) {
+		fwts_failed(fw, LOG_LEVEL_HIGH,
+			"UEFISetAuthVarDiff",
+			"Failed to get authenticated variable with UEFI "
+			"runtime service.");
+		fwts_uefi_print_status_info(fw, status);
+		return FWTS_ERROR;
+	}
+	if (getdatasize != sizeof(AuthVarCreateData)) {
+		fwts_failed(fw, LOG_LEVEL_HIGH,
+			"UEFISetAuthVarDiff",
+			"Get authenticated variable data size is not the "
+			"same as it set.");
+	}
+	for (i = 0; i < sizeof(AuthVarCreateData); i++) {
+		if (data[i] != AuthVarCreateData[i]) {
+			fwts_failed(fw, LOG_LEVEL_HIGH,
+			"UEFISetAuthVarDiff",
+			"Get authenticated variable data are not the "
+			"same as it set.");
+		return FWTS_ERROR;
+		}
+	}
+
+	fwts_passed(fw, "Set authenticated variable created by different key test passed.");
+
+	ioret = setvar(&gtestguid, attributes, sizeof(AuthVarDelDiff), AuthVarDelDiff, &status);
+
+	if (ioret == -1) {
+		supcheck = check_fw_support(fw, status);
+		if (supcheck != FWTS_OK)
+			return supcheck;
+
+		fwts_failed(fw, LOG_LEVEL_HIGH,
+			"UEFIDelAuthVarDiff",
+			"Failed to delete autheticated variable with UEFI "
+			"runtime service.");
+		fwts_uefi_print_status_info(fw, status);
+		return FWTS_ERROR;
+	}
+
+	ioret = getvar(&gtestguid, &attributestest, &getdatasize, data, &status);
+	if (ioret == -1) {
+		if (status == EFI_NOT_FOUND) {
+			fwts_passed(fw, "Delete authenticated variable created by different key test passed.");
+			return FWTS_OK;
+		}
+
+		fwts_failed(fw, LOG_LEVEL_HIGH,
+			"UEFIDelAuthVarDiff",
+			"Failed to get authenticated variable with UEFI "
+			"runtime service.");
+		fwts_uefi_print_status_info(fw, status);
+		return FWTS_ERROR;
+	}
+
+	fwts_failed(fw, LOG_LEVEL_HIGH,
+		"UEFIDelAuthVarDiff",
+		"Failed to delete authenticated variable still get the test"
+		"authenticated variable.");
+
+	return FWTS_ERROR;
+}
 
 static fwts_framework_minor_test uefirtauthvar_tests[] = {
 	{ uefirtauthvar_test1, "Create authenticated variable test." },
@@ -727,6 +822,7 @@  static fwts_framework_minor_test uefirtauthvar_tests[] = {
 	{ uefirtauthvar_test10, "Authenticated variable test with different guid." },
 	{ uefirtauthvar_test11, "Authenticated variable test with invalid attributes." },
 	{ uefirtauthvar_test12, "Test with both authenticated attributes are set." },
+	{ uefirtauthvar_test13, "Set and delete authenticated variable created by different key test." },
 	{ NULL, NULL }
 };