mirror of https://github.com/ARMmbed/mbed-os.git
[NUC472/M487] Guard against SHA internal state size is not word-aligned in SHA alter.
parent
8ba07815ed
commit
980cb6b9c8
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "nu_bitutil.h"
|
||||
#include "mbed_assert.h"
|
||||
#include "mbed_error.h"
|
||||
#include "crypto-misc.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@ -416,6 +417,10 @@ void crypto_sha_update_nobuf(crypto_sha_context *ctx, const unsigned char *input
|
|||
|
||||
void crypto_sha_getinternstate(unsigned char output[], size_t olen)
|
||||
{
|
||||
if (olen & 0x3) {
|
||||
error("Internal error in SHA alter. SHA internal state size requires to be a multiple of 4 bytes.");
|
||||
}
|
||||
|
||||
uint32_t *in_pos = (uint32_t *) &CRPT->HMAC_DGST[0];
|
||||
unsigned char *out_pos = output;
|
||||
uint32_t rmn = olen;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "nu_bitutil.h"
|
||||
#include "mbed_assert.h"
|
||||
#include "mbed_error.h"
|
||||
#include "crypto-misc.h"
|
||||
|
||||
#include <string.h>
|
||||
|
@ -312,6 +313,10 @@ void crypto_sha_update_nobuf(crypto_sha_context *ctx, const unsigned char *input
|
|||
|
||||
void crypto_sha_getinternstate(unsigned char output[], size_t olen)
|
||||
{
|
||||
if (olen & 0x3) {
|
||||
error("Internal error in SHA alter. SHA internal state size requires to be a multiple of 4 bytes.");
|
||||
}
|
||||
|
||||
uint32_t *in_pos = (uint32_t *) &CRPT->SHA_DGST0;
|
||||
unsigned char *out_pos = output;
|
||||
uint32_t rmn = olen;
|
||||
|
|
Loading…
Reference in New Issue