Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Unified Diff: firmware/lib/cryptolib/sha1.c

Issue 2851015: Fixes to compiler warnings in MSVC (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Also fix gpt numbering bug Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: firmware/lib/cryptolib/sha1.c
diff --git a/firmware/lib/cryptolib/sha1.c b/firmware/lib/cryptolib/sha1.c
index 70653ba78457e2ce9354b810d6e7f1d844b736b1..897742c5fd5529d7be8d1080f9895f3710f8d2af 100644
--- a/firmware/lib/cryptolib/sha1.c
+++ b/firmware/lib/cryptolib/sha1.c
@@ -224,7 +224,7 @@ static void SHA1_transform(SHA1_CTX *ctx) {
}
void SHA1_update(SHA1_CTX *ctx, const uint8_t *data, uint64_t len) {
- int i = ctx->count % sizeof(ctx->buf);
+ int i = (int)(ctx->count % sizeof(ctx->buf));
const uint8_t* p = (const uint8_t*) data;
ctx->count += len;
@@ -239,7 +239,7 @@ void SHA1_update(SHA1_CTX *ctx, const uint8_t *data, uint64_t len) {
}
uint8_t* SHA1_final(SHA1_CTX *ctx) {
uint8_t *p = ctx->buf;
- uint64_t cnt = ctx->count * 8;
+ uint64_t cnt = ctx->count << 3;
int i;
SHA1_update(ctx, (uint8_t*)"\x80", 1);
@@ -247,16 +247,16 @@ uint8_t* SHA1_final(SHA1_CTX *ctx) {
SHA1_update(ctx, (uint8_t*)"\0", 1);
}
for (i = 0; i < 8; ++i) {
- uint8_t tmp = cnt >> ((7 - i) * 8);
+ uint8_t tmp = (uint8_t)UINT64_RSHIFT(cnt, (7 - i) * 8);
SHA1_update(ctx, &tmp, 1);
}
for (i = 0; i < 5; i++) {
uint32_t tmp = ctx->state[i];
- *p++ = tmp >> 24;
- *p++ = tmp >> 16;
- *p++ = tmp >> 8;
- *p++ = tmp >> 0;
+ *p++ = (uint8_t)(tmp >> 24);
+ *p++ = (uint8_t)(tmp >> 16);
+ *p++ = (uint8_t)(tmp >> 8);
+ *p++ = (uint8_t)(tmp >> 0);
}
return ctx->buf;

Powered by Google App Engine
This is Rietveld 408576698