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

Side by Side Diff: nss/lib/freebl/poly1305/poly1305.c

Issue 515383002: Avoids MSVC warnings about possible value truncation. (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Also add a PRUint32 cast to counter >> 32. Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « nss/lib/freebl/chacha20/chacha20.c ('k') | patches/nss-chacha20-poly1305.patch » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* This Source Code Form is subject to the terms of the Mozilla Public 1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 4
5 /* This implementation of poly1305 is by Andrew Moon 5 /* This implementation of poly1305 is by Andrew Moon
6 * (https://github.com/floodyberry/poly1305-donna) and released as public 6 * (https://github.com/floodyberry/poly1305-donna) and released as public
7 * domain. */ 7 * domain. */
8 8
9 #include <string.h> 9 #include <string.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 state->h1 = (state->h1 & nb) | (g1 & b); 240 state->h1 = (state->h1 & nb) | (g1 & b);
241 state->h2 = (state->h2 & nb) | (g2 & b); 241 state->h2 = (state->h2 & nb) | (g2 & b);
242 state->h3 = (state->h3 & nb) | (g3 & b); 242 state->h3 = (state->h3 & nb) | (g3 & b);
243 state->h4 = (state->h4 & nb) | (g4 & b); 243 state->h4 = (state->h4 & nb) | (g4 & b);
244 244
245 f0 = ((state->h0 ) | (state->h1 << 26)) + (uint64_t)U8TO32_LE(&stat e->key[0]); 245 f0 = ((state->h0 ) | (state->h1 << 26)) + (uint64_t)U8TO32_LE(&stat e->key[0]);
246 f1 = ((state->h1 >> 6) | (state->h2 << 20)) + (uint64_t)U8TO32_LE(&stat e->key[4]); 246 f1 = ((state->h1 >> 6) | (state->h2 << 20)) + (uint64_t)U8TO32_LE(&stat e->key[4]);
247 f2 = ((state->h2 >> 12) | (state->h3 << 14)) + (uint64_t)U8TO32_LE(&stat e->key[8]); 247 f2 = ((state->h2 >> 12) | (state->h3 << 14)) + (uint64_t)U8TO32_LE(&stat e->key[8]);
248 f3 = ((state->h3 >> 18) | (state->h4 << 8)) + (uint64_t)U8TO32_LE(&stat e->key[12]); 248 f3 = ((state->h3 >> 18) | (state->h4 << 8)) + (uint64_t)U8TO32_LE(&stat e->key[12]);
249 249
250 » U32TO8_LE(&mac[ 0], f0); f1 += (f0 >> 32); 250 » U32TO8_LE(&mac[ 0], (uint32_t)f0); f1 += (f0 >> 32);
251 » U32TO8_LE(&mac[ 4], f1); f2 += (f1 >> 32); 251 » U32TO8_LE(&mac[ 4], (uint32_t)f1); f2 += (f1 >> 32);
252 » U32TO8_LE(&mac[ 8], f2); f3 += (f2 >> 32); 252 » U32TO8_LE(&mac[ 8], (uint32_t)f2); f3 += (f2 >> 32);
253 » U32TO8_LE(&mac[12], f3); 253 » U32TO8_LE(&mac[12], (uint32_t)f3);
254 } 254 }
OLDNEW
« no previous file with comments | « nss/lib/freebl/chacha20/chacha20.c ('k') | patches/nss-chacha20-poly1305.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698