lib/sw_apps/rsa_auth_app/src/rsa_auth_app.c
static int RecreatePaddingAndCheck(const u8 *Signature, const u8 *Hash)
{
	int Status = XST_FAILURE;
	const u8 T_padding[] = {0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86,
							0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
							0x00, 0x04, 0x20 };
    const u8 * PadPtr = Signature + RSA_PARTITION_SIGNATURE_SIZE;
    u32 PadLen;
    u32 Idx;

	PadLen = RSA_PARTITION_SIGNATURE_SIZE - RSA_BYTE_PAD_LENGTH -
				RSA_T_PAD_LENGTH - HASHLEN;
    /*
    * Re-Create PKCS#1v1.5 Padding
    * MSB  ----------------------------------------------------LSB
    * 0x0 || 0x1 || 0xFF(for 202 bytes) || 0x0 || T_padding || SHA256 Hash
    */
    if (*--PadPtr != 0x00U) {
		goto END;
    }

	if (*--PadPtr != 0x01U) {
		goto END;
	}

    for (Idx = 0U; Idx < PadLen; Idx++) {
		if (*--PadPtr != 0xFFU) {
			goto END;
        }
    }

    if (*--PadPtr != 0x00U) {
		goto END;
    }

    for (Idx = 0U; Idx < sizeof(T_padding); Idx++) {
		if (*--PadPtr != T_padding[Idx]) {
			goto END;
        }
    }

    for (Idx = 0U; Idx < HASHLEN; Idx++) {
		if (*--PadPtr != Hash[Idx]) {
			goto END;
		}
    }
	Status = XST_SUCCESS;
END:
	return Status;
}
/*****************************************************************************/
/**
*
* This function recreates and checks the signature.
*
* @param	Signature Partition signature
* @param	Hash      Partition hash value which includes boot header,
*                     partition data
*
* @return   XST_SUCCESS signature verification passed
*		    XST_FAILURE signature verification failed
*
* @note		None
*
******************************************************************************/
This function recreates and checks the signature.
This function recreates and checks the signature .
static int RecreatePaddingAndCheck(const u8 *Signature, const u8 *Hash)
{
	int Status = XST_FAILURE;
	const u8 T_padding[] = {0x30, 0x31, 0x30, 0x0D, 0x06, 0x09, 0x60, 0x86,
							0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05,
							0x00, 0x04, 0x20 };
    const u8 * PadPtr = Signature + RSA_PARTITION_SIGNATURE_SIZE;
    u32 PadLen;
    u32 Idx;
	PadLen = RSA_PARTITION_SIGNATURE_SIZE - RSA_BYTE_PAD_LENGTH -
				RSA_T_PAD_LENGTH - HASHLEN;
    if (*--PadPtr != 0x00U) {
		goto END;
    }
	if (*--PadPtr != 0x01U) {
		goto END;
	}
    for (Idx = 0U; Idx < PadLen; Idx++) {
		if (*--PadPtr != 0xFFU) {
			goto END;
        }
    }
    if (*--PadPtr != 0x00U) {
		goto END;
    }
    for (Idx = 0U; Idx < sizeof(T_padding); Idx++) {
		if (*--PadPtr != T_padding[Idx]) {
			goto END;
        }
    }
    for (Idx = 0U; Idx < HASHLEN; Idx++) {
		if (*--PadPtr != Hash[Idx]) {
			goto END;
		}
    }
	Status = XST_SUCCESS;
END:
	return Status;
}
static int RecreatePaddingAndCheck ( const u8 * Signature , const u8 * Hash ) { int Status = XST_FAILURE ; const u8 T_padding [ ] = { 0x30 , 0x31 , 0x30 , 0x0D , 0x06 , 0x09 , 0x60 , 0x86 , 0x48 , 0x01 , 0x65 , 0x03 , 0x04 , 0x02 , 0x01 , 0x05 , 0x00 , 0x04 , 0x20 } ; const u8 * PadPtr = Signature + RSA_PARTITION_SIGNATURE_SIZE ; u32 PadLen ; u32 Idx ; PadLen = RSA_PARTITION_SIGNATURE_SIZE - RSA_BYTE_PAD_LENGTH - RSA_T_PAD_LENGTH - HASHLEN ; if ( * -- PadPtr != 0x00U ) { goto END ; } if ( * -- PadPtr != 0x01U ) { goto END ; } for ( Idx = 0U ; Idx < PadLen ; Idx ++ ) { if ( * -- PadPtr != 0xFFU ) { goto END ; } } if ( * -- PadPtr != 0x00U ) { goto END ; } for ( Idx = 0U ; Idx < sizeof ( T_padding ) ; Idx ++ ) { if ( * -- PadPtr != T_padding [ Idx ] ) { goto END ; } } for ( Idx = 0U ; Idx < HASHLEN ; Idx ++ ) { if ( * -- PadPtr != Hash [ Idx ] ) { goto END ; } } Status = XST_SUCCESS ; END : return Status ; }
This function recreates and checks the signature.
This function recreates and checks the signature .
/*
    * Re-Create PKCS#1v1.5 Padding
    * MSB  ----------------------------------------------------LSB
    * 0x0 || 0x1 || 0xFF(for 202 bytes) || 0x0 || T_padding || SHA256 Hash
    */