aboutsummaryrefslogtreecommitdiff
path: root/aes_keywrap.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2017-10-23 18:05:31 -0400
committerPaul Selkirk <paul@psgd.org>2017-10-23 18:05:31 -0400
commitca84af553cbaae45b17cce04d457b2e61cc4277c (patch)
tree90f2bc5e96d2f1ae3fece3dfb9075edda08c4ace /aes_keywrap.c
parent12a3c63b75044b207dd7982ce3ed170231bd4467 (diff)
Cleanup signed/unsigned mismatches, mostly in loop counters
Diffstat (limited to 'aes_keywrap.c')
-rw-r--r--aes_keywrap.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/aes_keywrap.c b/aes_keywrap.c
index d7701f0..355cb0b 100644
--- a/aes_keywrap.c
+++ b/aes_keywrap.c
@@ -165,8 +165,7 @@ hal_error_t hal_aes_keywrap(hal_core_t *core,
{
const size_t calculated_C_len = hal_aes_keywrap_ciphertext_length(m);
hal_error_t err;
- uint32_t n;
- long i, j;
+ size_t n;
assert(calculated_C_len % 8 == 0);
@@ -202,8 +201,8 @@ hal_error_t hal_aes_keywrap(hal_core_t *core,
}
else {
- for (j = 0; j <= 5; j++) {
- for (i = 1; i <= n; i++) {
+ for (size_t j = 0; j <= 5; j++) {
+ for (size_t i = 1; i <= n; i++) {
uint32_t t = n * j + i;
if ((err = do_block(core, C, C + i * 8)) != HAL_OK)
goto out;
@@ -235,8 +234,7 @@ hal_error_t hal_aes_keyunwrap(hal_core_t * core,
size_t *Q_len)
{
hal_error_t err;
- uint32_t n;
- long i, j;
+ size_t n;
size_t m;
if (C == NULL || Q == NULL || C_len % 8 != 0 || C_len < 16 || Q_len == NULL || *Q_len < C_len)
@@ -259,8 +257,8 @@ hal_error_t hal_aes_keyunwrap(hal_core_t * core,
}
else {
- for (j = 5; j >= 0; j--) {
- for (i = n; i >= 1; i--) {
+ for (long j = 5; j >= 0; j--) {
+ for (size_t i = n; i >= 1; i--) {
uint32_t t = n * j + i;
Q[7] ^= t & 0xFF; t >>= 8;
Q[6] ^= t & 0xFF; t >>= 8;
@@ -285,7 +283,7 @@ hal_error_t hal_aes_keyunwrap(hal_core_t * core,
}
if (m % 8 != 0)
- for (i = m + 8; i < 8 * (n + 1); i++)
+ for (size_t i = m + 8; i < 8 * (n + 1); i++)
if (Q[i] != 0x00) {
err = HAL_ERROR_KEYWRAP_BAD_PADDING;
goto out;