static analysis: make __write static to avoid confusion

This commit is contained in:
Joey Castillo 2022-04-10 14:51:13 -04:00
parent 5cb68923b9
commit 7b06d7d6fd
2 changed files with 6 additions and 7 deletions

View file

@ -84,7 +84,7 @@ static void addUncounted(uint8_t data) {
}
}
void write(uint8_t data) {
static void __write(uint8_t data) {
++byteCount;
addUncounted(data);
@ -93,7 +93,7 @@ void write(uint8_t data) {
void writeArray(uint8_t *buffer, uint8_t size){
while (size--) {
write(*buffer++);
__write(*buffer++);
}
}
@ -144,7 +144,7 @@ void initHmac(const uint8_t* key, uint8_t keyLength) {
if (keyLength > BLOCK_LENGTH) {
// Hash long keys
init();
for (;keyLength--;) write(*key++);
for (;keyLength--;) __write(*key++);
memcpy(keyBuffer,result(),HASH_LENGTH);
} else {
// Block length keys are used as is
@ -153,7 +153,7 @@ void initHmac(const uint8_t* key, uint8_t keyLength) {
// Start inner hash
init();
for (i=0; i<BLOCK_LENGTH; i++) {
write(keyBuffer[i] ^ HMAC_IPAD);
__write(keyBuffer[i] ^ HMAC_IPAD);
}
}
@ -163,7 +163,7 @@ uint8_t* resultHmac(void) {
memcpy(innerHash,result(),HASH_LENGTH);
// Calculate outer hash
init();
for (i=0; i<BLOCK_LENGTH; i++) write(keyBuffer[i] ^ HMAC_OPAD);
for (i=0; i<HASH_LENGTH; i++) write(innerHash[i]);
for (i=0; i<BLOCK_LENGTH; i++) __write(keyBuffer[i] ^ HMAC_OPAD);
for (i=0; i<HASH_LENGTH; i++) __write(innerHash[i]);
return result();
}

View file

@ -10,7 +10,6 @@ void init(void);
void initHmac(const uint8_t* secret, uint8_t secretLength);
uint8_t* result(void);
uint8_t* resultHmac(void);
void write(uint8_t);
void writeArray(uint8_t *buffer, uint8_t size);
#endif // SHA1_H