mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-23 22:14:54 +00:00
sha1: Remove sha1 non-watchdog API
We don't need an API specially for non-watchdog since sha1_csum_wd supports it by disabling CONFIG_HW_WATCHDOG and CONFIG_WATCHDOG. Set 0x10000 as default chunk size for SHA1. Signed-off-by: Raymond Mao <raymond.mao@linaro.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
parent
2b6f572958
commit
988e749d97
4 changed files with 4 additions and 25 deletions
|
@ -166,7 +166,7 @@ static int find_key(struct udevice *tpm, const uint8_t auth[20],
|
||||||
return -1;
|
return -1;
|
||||||
if (err)
|
if (err)
|
||||||
continue;
|
continue;
|
||||||
sha1_csum(buf, buf_len, digest);
|
sha1_csum_wd(buf, buf_len, digest, SHA1_DEF_CHUNK_SZ);
|
||||||
if (!memcmp(digest, pubkey_digest, 20)) {
|
if (!memcmp(digest, pubkey_digest, 20)) {
|
||||||
*handle = key_handles[i];
|
*handle = key_handles[i];
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -39,6 +39,8 @@ extern "C" {
|
||||||
#define SHA1_SUM_LEN 20
|
#define SHA1_SUM_LEN 20
|
||||||
#define SHA1_DER_LEN 15
|
#define SHA1_DER_LEN 15
|
||||||
|
|
||||||
|
#define SHA1_DEF_CHUNK_SZ 0x10000
|
||||||
|
|
||||||
extern const uint8_t sha1_der_prefix[];
|
extern const uint8_t sha1_der_prefix[];
|
||||||
|
|
||||||
#if defined(CONFIG_MBEDTLS_LIB_CRYPTO)
|
#if defined(CONFIG_MBEDTLS_LIB_CRYPTO)
|
||||||
|
@ -81,16 +83,6 @@ void sha1_update(sha1_context *ctx, const unsigned char *input,
|
||||||
*/
|
*/
|
||||||
void sha1_finish( sha1_context *ctx, unsigned char output[20] );
|
void sha1_finish( sha1_context *ctx, unsigned char output[20] );
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Output = SHA-1( input buffer )
|
|
||||||
*
|
|
||||||
* \param input buffer holding the data
|
|
||||||
* \param ilen length of the input data
|
|
||||||
* \param output SHA-1 checksum result
|
|
||||||
*/
|
|
||||||
void sha1_csum(const unsigned char *input, unsigned int ilen,
|
|
||||||
unsigned char *output);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Output = SHA-1( input buffer ), with watchdog triggering
|
* \brief Output = SHA-1( input buffer ), with watchdog triggering
|
||||||
*
|
*
|
||||||
|
|
13
lib/sha1.c
13
lib/sha1.c
|
@ -304,19 +304,6 @@ void sha1_finish (sha1_context * ctx, unsigned char output[20])
|
||||||
PUT_UINT32_BE (ctx->state[4], output, 16);
|
PUT_UINT32_BE (ctx->state[4], output, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Output = SHA-1( input buffer )
|
|
||||||
*/
|
|
||||||
void sha1_csum(const unsigned char *input, unsigned int ilen,
|
|
||||||
unsigned char *output)
|
|
||||||
{
|
|
||||||
sha1_context ctx;
|
|
||||||
|
|
||||||
sha1_starts (&ctx);
|
|
||||||
sha1_update (&ctx, input, ilen);
|
|
||||||
sha1_finish (&ctx, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output = SHA-1( input buffer ). Trigger the watchdog every 'chunk_sz'
|
* Output = SHA-1( input buffer ). Trigger the watchdog every 'chunk_sz'
|
||||||
* bytes of input processed.
|
* bytes of input processed.
|
||||||
|
|
|
@ -871,7 +871,7 @@ u32 tpm1_find_key_sha1(struct udevice *dev, const u8 auth[20],
|
||||||
return -1;
|
return -1;
|
||||||
if (err)
|
if (err)
|
||||||
continue;
|
continue;
|
||||||
sha1_csum(buf, buf_len, digest);
|
sha1_csum_wd(buf, buf_len, digest, SHA1_DEF_CHUNK_SZ);
|
||||||
if (!memcmp(digest, pubkey_digest, 20)) {
|
if (!memcmp(digest, pubkey_digest, 20)) {
|
||||||
*handle = key_handles[i];
|
*handle = key_handles[i];
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue