ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/spritz/spritz.c
(Generate patch)

Comparing spritz/spritz.c (file contents):
Revision 1.5 by root, Sat Jan 10 08:29:03 2015 UTC vs.
Revision 1.6 by root, Sat Jan 10 09:13:51 2015 UTC

267spritz_aead_encrypt (spritz_state *s, const void *I, void *O, size_t len) 267spritz_aead_encrypt (spritz_state *s, const void *I, void *O, size_t len)
268{ 268{
269 const uint8_t *i = (const uint8_t *)I; 269 const uint8_t *i = (const uint8_t *)I;
270 uint8_t *o = ( uint8_t *)O; 270 uint8_t *o = ( uint8_t *)O;
271 271
272 uint8_t x[spritz_N >> 2];
273
274 while (len) 272 while (len)
275 { 273 {
276 uint_fast8_t j; 274 uint_fast8_t j;
275 uint8_t x[spritz_N >> 2];
277 uint8_t l = len > sizeof (x) ? sizeof (x) : len; 276 uint8_t l = len > sizeof (x) ? sizeof (x) : len;
278 len -= l; 277 len -= l;
279 278
280 spritz_squeeze (s, x, l); 279 spritz_squeeze (s, x, l);
281 280
282 for (j = 0; j < l; ++j) 281 for (j = 0; j < l; ++j)
282 {
283 *o = *i++ + x[j];
283 spritz_absorb_byte (s, *o++ = *i++ + x[j]); 284 spritz_absorb_byte (s, *o);
285 ++o;
286 }
284 } 287 }
285} 288}
286 289
287void 290void
288spritz_aead_decrypt (spritz_state *s, const void *I, void *O, size_t len) 291spritz_aead_decrypt (spritz_state *s, const void *I, void *O, size_t len)
289{ 292{
290 const uint8_t *i = (const uint8_t *)I; 293 const uint8_t *i = (const uint8_t *)I;
291 uint8_t *o = ( uint8_t *)O; 294 uint8_t *o = ( uint8_t *)O;
292
293 uint8_t x[spritz_N >> 2];
294 295
295 while (len) 296 while (len)
296 { 297 {
297 uint_fast8_t j; 298 uint_fast8_t j;
299 uint8_t x[spritz_N >> 2];
298 uint8_t l = len > sizeof (x) ? sizeof (x) : len; 300 uint8_t l = len > sizeof (x) ? sizeof (x) : len;
299 len -= l; 301 len -= l;
300 302
301 spritz_squeeze (s, x, l); 303 spritz_squeeze (s, x, l);
302 304
303 for (j = 0; j < l; ++j) 305 for (j = 0; j < l; ++j)
306 {
304 spritz_absorb_byte (s, *o++ = *i++ - x[j]); 307 spritz_absorb_byte (s, *i);
308 *o = *i++ - x[j];
309 ++o;
310 }
305 } 311 }
306} 312}
307 313
308/*****************************************************************************/ 314/*****************************************************************************/
309 315
310void 316void
311spritz_aead_xor_crypt (spritz_state *s, const void *I, void *O, size_t len) 317spritz_aead_xor_crypt (spritz_state *s, const void *I, void *O, size_t len)
312{ 318{
313 const uint8_t *i = (const uint8_t *)I; 319 const uint8_t *i = (const uint8_t *)I;
314 uint8_t *o = ( uint8_t *)O; 320 uint8_t *o = ( uint8_t *)O;
315
316 uint8_t x[spritz_N >> 2];
317 321
318 while (len) 322 while (len)
319 { 323 {
320 uint_fast8_t j; 324 uint_fast8_t j;
325 uint8_t x[spritz_N >> 2];
321 uint8_t l = len > sizeof (x) ? sizeof (x) : len; 326 uint8_t l = len > sizeof (x) ? sizeof (x) : len;
322 len -= l; 327 len -= l;
323 328
324 spritz_squeeze (s, x, l); 329 spritz_squeeze (s, x, l);
325 330

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines