diff options
author | Jake Edge <jake@lwn.net> | 2014-05-20 10:02:28 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-05-20 22:17:42 -0400 |
commit | 007dfe5ad6d039df784b44285bae89654eab3258 (patch) | |
tree | 13e0b3da44a372318ab9759df70aea898d6b0bb3 | |
parent | a82100e78cdf099f6c36fc4b0e2dc1b7d558f1db (diff) |
staging/skein: variable/member name cleanup
Rename a few more variables and structure member names to lower case.
Signed-off-by: Jake Edge <jake@lwn.net>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/skein/skein.c | 148 | ||||
-rw-r--r-- | drivers/staging/skein/skein.h | 34 | ||||
-rw-r--r-- | drivers/staging/skein/skein_api.c | 32 | ||||
-rw-r--r-- | drivers/staging/skein/skein_api.h | 2 | ||||
-rw-r--r-- | drivers/staging/skein/skein_block.c | 155 |
5 files changed, 186 insertions, 185 deletions
diff --git a/drivers/staging/skein/skein.c b/drivers/staging/skein/skein.c index f76d5850c7dd..8cc83587b1f1 100644 --- a/drivers/staging/skein/skein.c +++ b/drivers/staging/skein/skein.c | |||
@@ -33,16 +33,16 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) | |||
33 | 33 | ||
34 | switch (hash_bit_len) { /* use pre-computed values, where available */ | 34 | switch (hash_bit_len) { /* use pre-computed values, where available */ |
35 | case 256: | 35 | case 256: |
36 | memcpy(ctx->X, SKEIN_256_IV_256, sizeof(ctx->X)); | 36 | memcpy(ctx->x, SKEIN_256_IV_256, sizeof(ctx->x)); |
37 | break; | 37 | break; |
38 | case 224: | 38 | case 224: |
39 | memcpy(ctx->X, SKEIN_256_IV_224, sizeof(ctx->X)); | 39 | memcpy(ctx->x, SKEIN_256_IV_224, sizeof(ctx->x)); |
40 | break; | 40 | break; |
41 | case 160: | 41 | case 160: |
42 | memcpy(ctx->X, SKEIN_256_IV_160, sizeof(ctx->X)); | 42 | memcpy(ctx->x, SKEIN_256_IV_160, sizeof(ctx->x)); |
43 | break; | 43 | break; |
44 | case 128: | 44 | case 128: |
45 | memcpy(ctx->X, SKEIN_256_IV_128, sizeof(ctx->X)); | 45 | memcpy(ctx->x, SKEIN_256_IV_128, sizeof(ctx->x)); |
46 | break; | 46 | break; |
47 | default: | 47 | default: |
48 | /* here if there is no precomputed IV value available */ | 48 | /* here if there is no precomputed IV value available */ |
@@ -63,11 +63,11 @@ int skein_256_init(struct skein_256_ctx *ctx, size_t hash_bit_len) | |||
63 | 63 | ||
64 | /* compute the initial chaining values from config block */ | 64 | /* compute the initial chaining values from config block */ |
65 | /* zero the chaining variables */ | 65 | /* zero the chaining variables */ |
66 | memset(ctx->X, 0, sizeof(ctx->X)); | 66 | memset(ctx->x, 0, sizeof(ctx->x)); |
67 | skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); | 67 | skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); |
68 | break; | 68 | break; |
69 | } | 69 | } |
70 | /* The chaining vars ctx->X are now initialized for hash_bit_len. */ | 70 | /* The chaining vars ctx->x are now initialized for hash_bit_len. */ |
71 | /* Set up to process the data message portion of the hash (default) */ | 71 | /* Set up to process the data message portion of the hash (default) */ |
72 | skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ | 72 | skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ |
73 | 73 | ||
@@ -89,25 +89,25 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, | |||
89 | skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); | 89 | skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); |
90 | skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); | 90 | skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); |
91 | 91 | ||
92 | /* compute the initial chaining values ctx->X[], based on key */ | 92 | /* compute the initial chaining values ctx->x[], based on key */ |
93 | if (key_bytes == 0) { /* is there a key? */ | 93 | if (key_bytes == 0) { /* is there a key? */ |
94 | /* no key: use all zeroes as key for config block */ | 94 | /* no key: use all zeroes as key for config block */ |
95 | memset(ctx->X, 0, sizeof(ctx->X)); | 95 | memset(ctx->x, 0, sizeof(ctx->x)); |
96 | } else { /* here to pre-process a key */ | 96 | } else { /* here to pre-process a key */ |
97 | skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); | 97 | skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); |
98 | /* do a mini-Init right here */ | 98 | /* do a mini-Init right here */ |
99 | /* set output hash bit count = state size */ | 99 | /* set output hash bit count = state size */ |
100 | ctx->h.hash_bit_len = 8*sizeof(ctx->X); | 100 | ctx->h.hash_bit_len = 8*sizeof(ctx->x); |
101 | /* set tweaks: T0 = 0; T1 = KEY type */ | 101 | /* set tweaks: T0 = 0; T1 = KEY type */ |
102 | skein_start_new_type(ctx, KEY); | 102 | skein_start_new_type(ctx, KEY); |
103 | /* zero the initial chaining variables */ | 103 | /* zero the initial chaining variables */ |
104 | memset(ctx->X, 0, sizeof(ctx->X)); | 104 | memset(ctx->x, 0, sizeof(ctx->x)); |
105 | /* hash the key */ | 105 | /* hash the key */ |
106 | skein_256_update(ctx, key, key_bytes); | 106 | skein_256_update(ctx, key, key_bytes); |
107 | /* put result into cfg.b[] */ | 107 | /* put result into cfg.b[] */ |
108 | skein_256_final_pad(ctx, cfg.b); | 108 | skein_256_final_pad(ctx, cfg.b); |
109 | /* copy over into ctx->X[] */ | 109 | /* copy over into ctx->x[] */ |
110 | memcpy(ctx->X, cfg.b, sizeof(cfg.b)); | 110 | memcpy(ctx->x, cfg.b, sizeof(cfg.b)); |
111 | } | 111 | } |
112 | /* | 112 | /* |
113 | * build/process the config block, type == CONFIG (could be | 113 | * build/process the config block, type == CONFIG (could be |
@@ -130,7 +130,7 @@ int skein_256_init_ext(struct skein_256_ctx *ctx, size_t hash_bit_len, | |||
130 | /* compute the initial chaining values from config block */ | 130 | /* compute the initial chaining values from config block */ |
131 | skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); | 131 | skein_256_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); |
132 | 132 | ||
133 | /* The chaining vars ctx->X are now initialized */ | 133 | /* The chaining vars ctx->x are now initialized */ |
134 | /* Set up to process the data message portion of the hash (default) */ | 134 | /* Set up to process the data message portion of the hash (default) */ |
135 | skein_start_new_type(ctx, MSG); | 135 | skein_start_new_type(ctx, MSG); |
136 | 136 | ||
@@ -197,12 +197,12 @@ int skein_256_update(struct skein_256_ctx *ctx, const u8 *msg, | |||
197 | int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) | 197 | int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) |
198 | { | 198 | { |
199 | size_t i, n, byte_cnt; | 199 | size_t i, n, byte_cnt; |
200 | u64 X[SKEIN_256_STATE_WORDS]; | 200 | u64 x[SKEIN_256_STATE_WORDS]; |
201 | /* catch uninitialized context */ | 201 | /* catch uninitialized context */ |
202 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); | 202 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); |
203 | 203 | ||
204 | /* tag as the final block */ | 204 | /* tag as the final block */ |
205 | ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; | 205 | ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; |
206 | /* zero pad b[] if necessary */ | 206 | /* zero pad b[] if necessary */ |
207 | if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) | 207 | if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) |
208 | memset(&ctx->b[ctx->h.b_cnt], 0, | 208 | memset(&ctx->b[ctx->h.b_cnt], 0, |
@@ -219,7 +219,7 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) | |||
219 | /* zero out b[], so it can hold the counter */ | 219 | /* zero out b[], so it can hold the counter */ |
220 | memset(ctx->b, 0, sizeof(ctx->b)); | 220 | memset(ctx->b, 0, sizeof(ctx->b)); |
221 | /* keep a local copy of counter mode "key" */ | 221 | /* keep a local copy of counter mode "key" */ |
222 | memcpy(X, ctx->X, sizeof(X)); | 222 | memcpy(x, ctx->x, sizeof(x)); |
223 | for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { | 223 | for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { |
224 | /* build the counter block */ | 224 | /* build the counter block */ |
225 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); | 225 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); |
@@ -231,12 +231,12 @@ int skein_256_final(struct skein_256_ctx *ctx, u8 *hash_val) | |||
231 | if (n >= SKEIN_256_BLOCK_BYTES) | 231 | if (n >= SKEIN_256_BLOCK_BYTES) |
232 | n = SKEIN_256_BLOCK_BYTES; | 232 | n = SKEIN_256_BLOCK_BYTES; |
233 | /* "output" the ctr mode bytes */ | 233 | /* "output" the ctr mode bytes */ |
234 | skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X, | 234 | skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, |
235 | n); | 235 | n); |
236 | skein_show_final(256, &ctx->h, n, | 236 | skein_show_final(256, &ctx->h, n, |
237 | hash_val+i*SKEIN_256_BLOCK_BYTES); | 237 | hash_val+i*SKEIN_256_BLOCK_BYTES); |
238 | /* restore the counter mode key for next time */ | 238 | /* restore the counter mode key for next time */ |
239 | memcpy(ctx->X, X, sizeof(X)); | 239 | memcpy(ctx->x, x, sizeof(x)); |
240 | } | 240 | } |
241 | return SKEIN_SUCCESS; | 241 | return SKEIN_SUCCESS; |
242 | } | 242 | } |
@@ -259,16 +259,16 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) | |||
259 | 259 | ||
260 | switch (hash_bit_len) { /* use pre-computed values, where available */ | 260 | switch (hash_bit_len) { /* use pre-computed values, where available */ |
261 | case 512: | 261 | case 512: |
262 | memcpy(ctx->X, SKEIN_512_IV_512, sizeof(ctx->X)); | 262 | memcpy(ctx->x, SKEIN_512_IV_512, sizeof(ctx->x)); |
263 | break; | 263 | break; |
264 | case 384: | 264 | case 384: |
265 | memcpy(ctx->X, SKEIN_512_IV_384, sizeof(ctx->X)); | 265 | memcpy(ctx->x, SKEIN_512_IV_384, sizeof(ctx->x)); |
266 | break; | 266 | break; |
267 | case 256: | 267 | case 256: |
268 | memcpy(ctx->X, SKEIN_512_IV_256, sizeof(ctx->X)); | 268 | memcpy(ctx->x, SKEIN_512_IV_256, sizeof(ctx->x)); |
269 | break; | 269 | break; |
270 | case 224: | 270 | case 224: |
271 | memcpy(ctx->X, SKEIN_512_IV_224, sizeof(ctx->X)); | 271 | memcpy(ctx->x, SKEIN_512_IV_224, sizeof(ctx->x)); |
272 | break; | 272 | break; |
273 | default: | 273 | default: |
274 | /* here if there is no precomputed IV value available */ | 274 | /* here if there is no precomputed IV value available */ |
@@ -289,13 +289,13 @@ int skein_512_init(struct skein_512_ctx *ctx, size_t hash_bit_len) | |||
289 | 289 | ||
290 | /* compute the initial chaining values from config block */ | 290 | /* compute the initial chaining values from config block */ |
291 | /* zero the chaining variables */ | 291 | /* zero the chaining variables */ |
292 | memset(ctx->X, 0, sizeof(ctx->X)); | 292 | memset(ctx->x, 0, sizeof(ctx->x)); |
293 | skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); | 293 | skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); |
294 | break; | 294 | break; |
295 | } | 295 | } |
296 | 296 | ||
297 | /* | 297 | /* |
298 | * The chaining vars ctx->X are now initialized for the given | 298 | * The chaining vars ctx->x are now initialized for the given |
299 | * hash_bit_len. | 299 | * hash_bit_len. |
300 | */ | 300 | */ |
301 | /* Set up to process the data message portion of the hash (default) */ | 301 | /* Set up to process the data message portion of the hash (default) */ |
@@ -319,25 +319,25 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, | |||
319 | skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); | 319 | skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); |
320 | skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); | 320 | skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); |
321 | 321 | ||
322 | /* compute the initial chaining values ctx->X[], based on key */ | 322 | /* compute the initial chaining values ctx->x[], based on key */ |
323 | if (key_bytes == 0) { /* is there a key? */ | 323 | if (key_bytes == 0) { /* is there a key? */ |
324 | /* no key: use all zeroes as key for config block */ | 324 | /* no key: use all zeroes as key for config block */ |
325 | memset(ctx->X, 0, sizeof(ctx->X)); | 325 | memset(ctx->x, 0, sizeof(ctx->x)); |
326 | } else { /* here to pre-process a key */ | 326 | } else { /* here to pre-process a key */ |
327 | skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); | 327 | skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); |
328 | /* do a mini-Init right here */ | 328 | /* do a mini-Init right here */ |
329 | /* set output hash bit count = state size */ | 329 | /* set output hash bit count = state size */ |
330 | ctx->h.hash_bit_len = 8*sizeof(ctx->X); | 330 | ctx->h.hash_bit_len = 8*sizeof(ctx->x); |
331 | /* set tweaks: T0 = 0; T1 = KEY type */ | 331 | /* set tweaks: T0 = 0; T1 = KEY type */ |
332 | skein_start_new_type(ctx, KEY); | 332 | skein_start_new_type(ctx, KEY); |
333 | /* zero the initial chaining variables */ | 333 | /* zero the initial chaining variables */ |
334 | memset(ctx->X, 0, sizeof(ctx->X)); | 334 | memset(ctx->x, 0, sizeof(ctx->x)); |
335 | /* hash the key */ | 335 | /* hash the key */ |
336 | skein_512_update(ctx, key, key_bytes); | 336 | skein_512_update(ctx, key, key_bytes); |
337 | /* put result into cfg.b[] */ | 337 | /* put result into cfg.b[] */ |
338 | skein_512_final_pad(ctx, cfg.b); | 338 | skein_512_final_pad(ctx, cfg.b); |
339 | /* copy over into ctx->X[] */ | 339 | /* copy over into ctx->x[] */ |
340 | memcpy(ctx->X, cfg.b, sizeof(cfg.b)); | 340 | memcpy(ctx->x, cfg.b, sizeof(cfg.b)); |
341 | } | 341 | } |
342 | /* | 342 | /* |
343 | * build/process the config block, type == CONFIG (could be | 343 | * build/process the config block, type == CONFIG (could be |
@@ -359,7 +359,7 @@ int skein_512_init_ext(struct skein_512_ctx *ctx, size_t hash_bit_len, | |||
359 | /* compute the initial chaining values from config block */ | 359 | /* compute the initial chaining values from config block */ |
360 | skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); | 360 | skein_512_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); |
361 | 361 | ||
362 | /* The chaining vars ctx->X are now initialized */ | 362 | /* The chaining vars ctx->x are now initialized */ |
363 | /* Set up to process the data message portion of the hash (default) */ | 363 | /* Set up to process the data message portion of the hash (default) */ |
364 | skein_start_new_type(ctx, MSG); | 364 | skein_start_new_type(ctx, MSG); |
365 | 365 | ||
@@ -426,12 +426,12 @@ int skein_512_update(struct skein_512_ctx *ctx, const u8 *msg, | |||
426 | int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) | 426 | int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) |
427 | { | 427 | { |
428 | size_t i, n, byte_cnt; | 428 | size_t i, n, byte_cnt; |
429 | u64 X[SKEIN_512_STATE_WORDS]; | 429 | u64 x[SKEIN_512_STATE_WORDS]; |
430 | /* catch uninitialized context */ | 430 | /* catch uninitialized context */ |
431 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); | 431 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); |
432 | 432 | ||
433 | /* tag as the final block */ | 433 | /* tag as the final block */ |
434 | ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; | 434 | ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; |
435 | /* zero pad b[] if necessary */ | 435 | /* zero pad b[] if necessary */ |
436 | if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) | 436 | if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) |
437 | memset(&ctx->b[ctx->h.b_cnt], 0, | 437 | memset(&ctx->b[ctx->h.b_cnt], 0, |
@@ -448,7 +448,7 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) | |||
448 | /* zero out b[], so it can hold the counter */ | 448 | /* zero out b[], so it can hold the counter */ |
449 | memset(ctx->b, 0, sizeof(ctx->b)); | 449 | memset(ctx->b, 0, sizeof(ctx->b)); |
450 | /* keep a local copy of counter mode "key" */ | 450 | /* keep a local copy of counter mode "key" */ |
451 | memcpy(X, ctx->X, sizeof(X)); | 451 | memcpy(x, ctx->x, sizeof(x)); |
452 | for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { | 452 | for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { |
453 | /* build the counter block */ | 453 | /* build the counter block */ |
454 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); | 454 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); |
@@ -460,12 +460,12 @@ int skein_512_final(struct skein_512_ctx *ctx, u8 *hash_val) | |||
460 | if (n >= SKEIN_512_BLOCK_BYTES) | 460 | if (n >= SKEIN_512_BLOCK_BYTES) |
461 | n = SKEIN_512_BLOCK_BYTES; | 461 | n = SKEIN_512_BLOCK_BYTES; |
462 | /* "output" the ctr mode bytes */ | 462 | /* "output" the ctr mode bytes */ |
463 | skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X, | 463 | skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, |
464 | n); | 464 | n); |
465 | skein_show_final(512, &ctx->h, n, | 465 | skein_show_final(512, &ctx->h, n, |
466 | hash_val+i*SKEIN_512_BLOCK_BYTES); | 466 | hash_val+i*SKEIN_512_BLOCK_BYTES); |
467 | /* restore the counter mode key for next time */ | 467 | /* restore the counter mode key for next time */ |
468 | memcpy(ctx->X, X, sizeof(X)); | 468 | memcpy(ctx->x, x, sizeof(x)); |
469 | } | 469 | } |
470 | return SKEIN_SUCCESS; | 470 | return SKEIN_SUCCESS; |
471 | } | 471 | } |
@@ -488,13 +488,13 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) | |||
488 | 488 | ||
489 | switch (hash_bit_len) { /* use pre-computed values, where available */ | 489 | switch (hash_bit_len) { /* use pre-computed values, where available */ |
490 | case 512: | 490 | case 512: |
491 | memcpy(ctx->X, SKEIN_1024_IV_512, sizeof(ctx->X)); | 491 | memcpy(ctx->x, SKEIN_1024_IV_512, sizeof(ctx->x)); |
492 | break; | 492 | break; |
493 | case 384: | 493 | case 384: |
494 | memcpy(ctx->X, SKEIN_1024_IV_384, sizeof(ctx->X)); | 494 | memcpy(ctx->x, SKEIN_1024_IV_384, sizeof(ctx->x)); |
495 | break; | 495 | break; |
496 | case 1024: | 496 | case 1024: |
497 | memcpy(ctx->X, SKEIN_1024_IV_1024, sizeof(ctx->X)); | 497 | memcpy(ctx->x, SKEIN_1024_IV_1024, sizeof(ctx->x)); |
498 | break; | 498 | break; |
499 | default: | 499 | default: |
500 | /* here if there is no precomputed IV value available */ | 500 | /* here if there is no precomputed IV value available */ |
@@ -515,12 +515,12 @@ int skein_1024_init(struct skein_1024_ctx *ctx, size_t hash_bit_len) | |||
515 | 515 | ||
516 | /* compute the initial chaining values from config block */ | 516 | /* compute the initial chaining values from config block */ |
517 | /* zero the chaining variables */ | 517 | /* zero the chaining variables */ |
518 | memset(ctx->X, 0, sizeof(ctx->X)); | 518 | memset(ctx->x, 0, sizeof(ctx->x)); |
519 | skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); | 519 | skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); |
520 | break; | 520 | break; |
521 | } | 521 | } |
522 | 522 | ||
523 | /* The chaining vars ctx->X are now initialized for the hash_bit_len. */ | 523 | /* The chaining vars ctx->x are now initialized for the hash_bit_len. */ |
524 | /* Set up to process the data message portion of the hash (default) */ | 524 | /* Set up to process the data message portion of the hash (default) */ |
525 | skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ | 525 | skein_start_new_type(ctx, MSG); /* T0=0, T1= MSG type */ |
526 | 526 | ||
@@ -542,25 +542,25 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, | |||
542 | skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); | 542 | skein_assert_ret(hash_bit_len > 0, SKEIN_BAD_HASHLEN); |
543 | skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); | 543 | skein_assert_ret(key_bytes == 0 || key != NULL, SKEIN_FAIL); |
544 | 544 | ||
545 | /* compute the initial chaining values ctx->X[], based on key */ | 545 | /* compute the initial chaining values ctx->x[], based on key */ |
546 | if (key_bytes == 0) { /* is there a key? */ | 546 | if (key_bytes == 0) { /* is there a key? */ |
547 | /* no key: use all zeroes as key for config block */ | 547 | /* no key: use all zeroes as key for config block */ |
548 | memset(ctx->X, 0, sizeof(ctx->X)); | 548 | memset(ctx->x, 0, sizeof(ctx->x)); |
549 | } else { /* here to pre-process a key */ | 549 | } else { /* here to pre-process a key */ |
550 | skein_assert(sizeof(cfg.b) >= sizeof(ctx->X)); | 550 | skein_assert(sizeof(cfg.b) >= sizeof(ctx->x)); |
551 | /* do a mini-Init right here */ | 551 | /* do a mini-Init right here */ |
552 | /* set output hash bit count = state size */ | 552 | /* set output hash bit count = state size */ |
553 | ctx->h.hash_bit_len = 8*sizeof(ctx->X); | 553 | ctx->h.hash_bit_len = 8*sizeof(ctx->x); |
554 | /* set tweaks: T0 = 0; T1 = KEY type */ | 554 | /* set tweaks: T0 = 0; T1 = KEY type */ |
555 | skein_start_new_type(ctx, KEY); | 555 | skein_start_new_type(ctx, KEY); |
556 | /* zero the initial chaining variables */ | 556 | /* zero the initial chaining variables */ |
557 | memset(ctx->X, 0, sizeof(ctx->X)); | 557 | memset(ctx->x, 0, sizeof(ctx->x)); |
558 | /* hash the key */ | 558 | /* hash the key */ |
559 | skein_1024_update(ctx, key, key_bytes); | 559 | skein_1024_update(ctx, key, key_bytes); |
560 | /* put result into cfg.b[] */ | 560 | /* put result into cfg.b[] */ |
561 | skein_1024_final_pad(ctx, cfg.b); | 561 | skein_1024_final_pad(ctx, cfg.b); |
562 | /* copy over into ctx->X[] */ | 562 | /* copy over into ctx->x[] */ |
563 | memcpy(ctx->X, cfg.b, sizeof(cfg.b)); | 563 | memcpy(ctx->x, cfg.b, sizeof(cfg.b)); |
564 | } | 564 | } |
565 | /* | 565 | /* |
566 | * build/process the config block, type == CONFIG (could be | 566 | * build/process the config block, type == CONFIG (could be |
@@ -583,7 +583,7 @@ int skein_1024_init_ext(struct skein_1024_ctx *ctx, size_t hash_bit_len, | |||
583 | /* compute the initial chaining values from config block */ | 583 | /* compute the initial chaining values from config block */ |
584 | skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); | 584 | skein_1024_process_block(ctx, cfg.b, 1, SKEIN_CFG_STR_LEN); |
585 | 585 | ||
586 | /* The chaining vars ctx->X are now initialized */ | 586 | /* The chaining vars ctx->x are now initialized */ |
587 | /* Set up to process the data message portion of the hash (default) */ | 587 | /* Set up to process the data message portion of the hash (default) */ |
588 | skein_start_new_type(ctx, MSG); | 588 | skein_start_new_type(ctx, MSG); |
589 | 589 | ||
@@ -650,12 +650,12 @@ int skein_1024_update(struct skein_1024_ctx *ctx, const u8 *msg, | |||
650 | int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) | 650 | int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) |
651 | { | 651 | { |
652 | size_t i, n, byte_cnt; | 652 | size_t i, n, byte_cnt; |
653 | u64 X[SKEIN_1024_STATE_WORDS]; | 653 | u64 x[SKEIN_1024_STATE_WORDS]; |
654 | /* catch uninitialized context */ | 654 | /* catch uninitialized context */ |
655 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); | 655 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); |
656 | 656 | ||
657 | /* tag as the final block */ | 657 | /* tag as the final block */ |
658 | ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; | 658 | ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; |
659 | /* zero pad b[] if necessary */ | 659 | /* zero pad b[] if necessary */ |
660 | if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) | 660 | if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) |
661 | memset(&ctx->b[ctx->h.b_cnt], 0, | 661 | memset(&ctx->b[ctx->h.b_cnt], 0, |
@@ -672,7 +672,7 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) | |||
672 | /* zero out b[], so it can hold the counter */ | 672 | /* zero out b[], so it can hold the counter */ |
673 | memset(ctx->b, 0, sizeof(ctx->b)); | 673 | memset(ctx->b, 0, sizeof(ctx->b)); |
674 | /* keep a local copy of counter mode "key" */ | 674 | /* keep a local copy of counter mode "key" */ |
675 | memcpy(X, ctx->X, sizeof(X)); | 675 | memcpy(x, ctx->x, sizeof(x)); |
676 | for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { | 676 | for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { |
677 | /* build the counter block */ | 677 | /* build the counter block */ |
678 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); | 678 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); |
@@ -684,12 +684,12 @@ int skein_1024_final(struct skein_1024_ctx *ctx, u8 *hash_val) | |||
684 | if (n >= SKEIN_1024_BLOCK_BYTES) | 684 | if (n >= SKEIN_1024_BLOCK_BYTES) |
685 | n = SKEIN_1024_BLOCK_BYTES; | 685 | n = SKEIN_1024_BLOCK_BYTES; |
686 | /* "output" the ctr mode bytes */ | 686 | /* "output" the ctr mode bytes */ |
687 | skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->X, | 687 | skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, |
688 | n); | 688 | n); |
689 | skein_show_final(1024, &ctx->h, n, | 689 | skein_show_final(1024, &ctx->h, n, |
690 | hash_val+i*SKEIN_1024_BLOCK_BYTES); | 690 | hash_val+i*SKEIN_1024_BLOCK_BYTES); |
691 | /* restore the counter mode key for next time */ | 691 | /* restore the counter mode key for next time */ |
692 | memcpy(ctx->X, X, sizeof(X)); | 692 | memcpy(ctx->x, x, sizeof(x)); |
693 | } | 693 | } |
694 | return SKEIN_SUCCESS; | 694 | return SKEIN_SUCCESS; |
695 | } | 695 | } |
@@ -705,7 +705,7 @@ int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val) | |||
705 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); | 705 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); |
706 | 706 | ||
707 | /* tag as the final block */ | 707 | /* tag as the final block */ |
708 | ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; | 708 | ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; |
709 | /* zero pad b[] if necessary */ | 709 | /* zero pad b[] if necessary */ |
710 | if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) | 710 | if (ctx->h.b_cnt < SKEIN_256_BLOCK_BYTES) |
711 | memset(&ctx->b[ctx->h.b_cnt], 0, | 711 | memset(&ctx->b[ctx->h.b_cnt], 0, |
@@ -714,7 +714,7 @@ int skein_256_final_pad(struct skein_256_ctx *ctx, u8 *hash_val) | |||
714 | skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); | 714 | skein_256_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); |
715 | 715 | ||
716 | /* "output" the state bytes */ | 716 | /* "output" the state bytes */ |
717 | skein_put64_lsb_first(hash_val, ctx->X, SKEIN_256_BLOCK_BYTES); | 717 | skein_put64_lsb_first(hash_val, ctx->x, SKEIN_256_BLOCK_BYTES); |
718 | 718 | ||
719 | return SKEIN_SUCCESS; | 719 | return SKEIN_SUCCESS; |
720 | } | 720 | } |
@@ -727,7 +727,7 @@ int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) | |||
727 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); | 727 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); |
728 | 728 | ||
729 | /* tag as the final block */ | 729 | /* tag as the final block */ |
730 | ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; | 730 | ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; |
731 | /* zero pad b[] if necessary */ | 731 | /* zero pad b[] if necessary */ |
732 | if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) | 732 | if (ctx->h.b_cnt < SKEIN_512_BLOCK_BYTES) |
733 | memset(&ctx->b[ctx->h.b_cnt], 0, | 733 | memset(&ctx->b[ctx->h.b_cnt], 0, |
@@ -736,7 +736,7 @@ int skein_512_final_pad(struct skein_512_ctx *ctx, u8 *hash_val) | |||
736 | skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); | 736 | skein_512_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); |
737 | 737 | ||
738 | /* "output" the state bytes */ | 738 | /* "output" the state bytes */ |
739 | skein_put64_lsb_first(hash_val, ctx->X, SKEIN_512_BLOCK_BYTES); | 739 | skein_put64_lsb_first(hash_val, ctx->x, SKEIN_512_BLOCK_BYTES); |
740 | 740 | ||
741 | return SKEIN_SUCCESS; | 741 | return SKEIN_SUCCESS; |
742 | } | 742 | } |
@@ -749,7 +749,7 @@ int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val) | |||
749 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); | 749 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); |
750 | 750 | ||
751 | /* tag as the final block */ | 751 | /* tag as the final block */ |
752 | ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; | 752 | ctx->h.tweak[1] |= SKEIN_T1_FLAG_FINAL; |
753 | /* zero pad b[] if necessary */ | 753 | /* zero pad b[] if necessary */ |
754 | if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) | 754 | if (ctx->h.b_cnt < SKEIN_1024_BLOCK_BYTES) |
755 | memset(&ctx->b[ctx->h.b_cnt], 0, | 755 | memset(&ctx->b[ctx->h.b_cnt], 0, |
@@ -758,7 +758,7 @@ int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val) | |||
758 | skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); | 758 | skein_1024_process_block(ctx, ctx->b, 1, ctx->h.b_cnt); |
759 | 759 | ||
760 | /* "output" the state bytes */ | 760 | /* "output" the state bytes */ |
761 | skein_put64_lsb_first(hash_val, ctx->X, SKEIN_1024_BLOCK_BYTES); | 761 | skein_put64_lsb_first(hash_val, ctx->x, SKEIN_1024_BLOCK_BYTES); |
762 | 762 | ||
763 | return SKEIN_SUCCESS; | 763 | return SKEIN_SUCCESS; |
764 | } | 764 | } |
@@ -769,7 +769,7 @@ int skein_1024_final_pad(struct skein_1024_ctx *ctx, u8 *hash_val) | |||
769 | int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) | 769 | int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) |
770 | { | 770 | { |
771 | size_t i, n, byte_cnt; | 771 | size_t i, n, byte_cnt; |
772 | u64 X[SKEIN_256_STATE_WORDS]; | 772 | u64 x[SKEIN_256_STATE_WORDS]; |
773 | /* catch uninitialized context */ | 773 | /* catch uninitialized context */ |
774 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); | 774 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_256_BLOCK_BYTES, SKEIN_FAIL); |
775 | 775 | ||
@@ -781,7 +781,7 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) | |||
781 | /* zero out b[], so it can hold the counter */ | 781 | /* zero out b[], so it can hold the counter */ |
782 | memset(ctx->b, 0, sizeof(ctx->b)); | 782 | memset(ctx->b, 0, sizeof(ctx->b)); |
783 | /* keep a local copy of counter mode "key" */ | 783 | /* keep a local copy of counter mode "key" */ |
784 | memcpy(X, ctx->X, sizeof(X)); | 784 | memcpy(x, ctx->x, sizeof(x)); |
785 | for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { | 785 | for (i = 0; i*SKEIN_256_BLOCK_BYTES < byte_cnt; i++) { |
786 | /* build the counter block */ | 786 | /* build the counter block */ |
787 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); | 787 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); |
@@ -793,12 +793,12 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) | |||
793 | if (n >= SKEIN_256_BLOCK_BYTES) | 793 | if (n >= SKEIN_256_BLOCK_BYTES) |
794 | n = SKEIN_256_BLOCK_BYTES; | 794 | n = SKEIN_256_BLOCK_BYTES; |
795 | /* "output" the ctr mode bytes */ | 795 | /* "output" the ctr mode bytes */ |
796 | skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->X, | 796 | skein_put64_lsb_first(hash_val+i*SKEIN_256_BLOCK_BYTES, ctx->x, |
797 | n); | 797 | n); |
798 | skein_show_final(256, &ctx->h, n, | 798 | skein_show_final(256, &ctx->h, n, |
799 | hash_val+i*SKEIN_256_BLOCK_BYTES); | 799 | hash_val+i*SKEIN_256_BLOCK_BYTES); |
800 | /* restore the counter mode key for next time */ | 800 | /* restore the counter mode key for next time */ |
801 | memcpy(ctx->X, X, sizeof(X)); | 801 | memcpy(ctx->x, x, sizeof(x)); |
802 | } | 802 | } |
803 | return SKEIN_SUCCESS; | 803 | return SKEIN_SUCCESS; |
804 | } | 804 | } |
@@ -808,7 +808,7 @@ int skein_256_output(struct skein_256_ctx *ctx, u8 *hash_val) | |||
808 | int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) | 808 | int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) |
809 | { | 809 | { |
810 | size_t i, n, byte_cnt; | 810 | size_t i, n, byte_cnt; |
811 | u64 X[SKEIN_512_STATE_WORDS]; | 811 | u64 x[SKEIN_512_STATE_WORDS]; |
812 | /* catch uninitialized context */ | 812 | /* catch uninitialized context */ |
813 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); | 813 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_512_BLOCK_BYTES, SKEIN_FAIL); |
814 | 814 | ||
@@ -820,7 +820,7 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) | |||
820 | /* zero out b[], so it can hold the counter */ | 820 | /* zero out b[], so it can hold the counter */ |
821 | memset(ctx->b, 0, sizeof(ctx->b)); | 821 | memset(ctx->b, 0, sizeof(ctx->b)); |
822 | /* keep a local copy of counter mode "key" */ | 822 | /* keep a local copy of counter mode "key" */ |
823 | memcpy(X, ctx->X, sizeof(X)); | 823 | memcpy(x, ctx->x, sizeof(x)); |
824 | for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { | 824 | for (i = 0; i*SKEIN_512_BLOCK_BYTES < byte_cnt; i++) { |
825 | /* build the counter block */ | 825 | /* build the counter block */ |
826 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); | 826 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); |
@@ -832,12 +832,12 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) | |||
832 | if (n >= SKEIN_512_BLOCK_BYTES) | 832 | if (n >= SKEIN_512_BLOCK_BYTES) |
833 | n = SKEIN_512_BLOCK_BYTES; | 833 | n = SKEIN_512_BLOCK_BYTES; |
834 | /* "output" the ctr mode bytes */ | 834 | /* "output" the ctr mode bytes */ |
835 | skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->X, | 835 | skein_put64_lsb_first(hash_val+i*SKEIN_512_BLOCK_BYTES, ctx->x, |
836 | n); | 836 | n); |
837 | skein_show_final(256, &ctx->h, n, | 837 | skein_show_final(256, &ctx->h, n, |
838 | hash_val+i*SKEIN_512_BLOCK_BYTES); | 838 | hash_val+i*SKEIN_512_BLOCK_BYTES); |
839 | /* restore the counter mode key for next time */ | 839 | /* restore the counter mode key for next time */ |
840 | memcpy(ctx->X, X, sizeof(X)); | 840 | memcpy(ctx->x, x, sizeof(x)); |
841 | } | 841 | } |
842 | return SKEIN_SUCCESS; | 842 | return SKEIN_SUCCESS; |
843 | } | 843 | } |
@@ -847,7 +847,7 @@ int skein_512_output(struct skein_512_ctx *ctx, u8 *hash_val) | |||
847 | int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) | 847 | int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) |
848 | { | 848 | { |
849 | size_t i, n, byte_cnt; | 849 | size_t i, n, byte_cnt; |
850 | u64 X[SKEIN_1024_STATE_WORDS]; | 850 | u64 x[SKEIN_1024_STATE_WORDS]; |
851 | /* catch uninitialized context */ | 851 | /* catch uninitialized context */ |
852 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); | 852 | skein_assert_ret(ctx->h.b_cnt <= SKEIN_1024_BLOCK_BYTES, SKEIN_FAIL); |
853 | 853 | ||
@@ -859,7 +859,7 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) | |||
859 | /* zero out b[], so it can hold the counter */ | 859 | /* zero out b[], so it can hold the counter */ |
860 | memset(ctx->b, 0, sizeof(ctx->b)); | 860 | memset(ctx->b, 0, sizeof(ctx->b)); |
861 | /* keep a local copy of counter mode "key" */ | 861 | /* keep a local copy of counter mode "key" */ |
862 | memcpy(X, ctx->X, sizeof(X)); | 862 | memcpy(x, ctx->x, sizeof(x)); |
863 | for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { | 863 | for (i = 0; i*SKEIN_1024_BLOCK_BYTES < byte_cnt; i++) { |
864 | /* build the counter block */ | 864 | /* build the counter block */ |
865 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); | 865 | ((u64 *)ctx->b)[0] = skein_swap64((u64) i); |
@@ -871,12 +871,12 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val) | |||
871 | if (n >= SKEIN_1024_BLOCK_BYTES) | 871 | if (n >= SKEIN_1024_BLOCK_BYTES) |
872 | n = SKEIN_1024_BLOCK_BYTES; | 872 | n = SKEIN_1024_BLOCK_BYTES; |
873 | /* "output" the ctr mode bytes */ | 873 | /* "output" the ctr mode bytes */ |
874 | skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->X, | 874 | skein_put64_lsb_first(hash_val+i*SKEIN_1024_BLOCK_BYTES, ctx->x, |
875 | n); | 875 | n); |
876 | skein_show_final(256, &ctx->h, n, | 876 | skein_show_final(256, &ctx->h, n, |
877 | hash_val+i*SKEIN_1024_BLOCK_BYTES); | 877 | hash_val+i*SKEIN_1024_BLOCK_BYTES); |
878 | /* restore the counter mode key for next time */ | 878 | /* restore the counter mode key for next time */ |
879 | memcpy(ctx->X, X, sizeof(X)); | 879 | memcpy(ctx->x, x, sizeof(x)); |
880 | } | 880 | } |
881 | return SKEIN_SUCCESS; | 881 | return SKEIN_SUCCESS; |
882 | } | 882 | } |
diff --git a/drivers/staging/skein/skein.h b/drivers/staging/skein/skein.h index 2c87ff74aaea..e6669f196e5d 100644 --- a/drivers/staging/skein/skein.h +++ b/drivers/staging/skein/skein.h | |||
@@ -66,24 +66,24 @@ enum { | |||
66 | struct skein_ctx_hdr { | 66 | struct skein_ctx_hdr { |
67 | size_t hash_bit_len; /* size of hash result, in bits */ | 67 | size_t hash_bit_len; /* size of hash result, in bits */ |
68 | size_t b_cnt; /* current byte count in buffer b[] */ | 68 | size_t b_cnt; /* current byte count in buffer b[] */ |
69 | u64 T[SKEIN_MODIFIER_WORDS]; /* tweak: T[0]=byte cnt, T[1]=flags */ | 69 | u64 tweak[SKEIN_MODIFIER_WORDS]; /* tweak[0]=byte cnt, tweak[1]=flags */ |
70 | }; | 70 | }; |
71 | 71 | ||
72 | struct skein_256_ctx { /* 256-bit Skein hash context structure */ | 72 | struct skein_256_ctx { /* 256-bit Skein hash context structure */ |
73 | struct skein_ctx_hdr h; /* common header context variables */ | 73 | struct skein_ctx_hdr h; /* common header context variables */ |
74 | u64 X[SKEIN_256_STATE_WORDS]; /* chaining variables */ | 74 | u64 x[SKEIN_256_STATE_WORDS]; /* chaining variables */ |
75 | u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ | 75 | u8 b[SKEIN_256_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ |
76 | }; | 76 | }; |
77 | 77 | ||
78 | struct skein_512_ctx { /* 512-bit Skein hash context structure */ | 78 | struct skein_512_ctx { /* 512-bit Skein hash context structure */ |
79 | struct skein_ctx_hdr h; /* common header context variables */ | 79 | struct skein_ctx_hdr h; /* common header context variables */ |
80 | u64 X[SKEIN_512_STATE_WORDS]; /* chaining variables */ | 80 | u64 x[SKEIN_512_STATE_WORDS]; /* chaining variables */ |
81 | u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ | 81 | u8 b[SKEIN_512_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ |
82 | }; | 82 | }; |
83 | 83 | ||
84 | struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ | 84 | struct skein_1024_ctx { /* 1024-bit Skein hash context structure */ |
85 | struct skein_ctx_hdr h; /* common header context variables */ | 85 | struct skein_ctx_hdr h; /* common header context variables */ |
86 | u64 X[SKEIN_1024_STATE_WORDS]; /* chaining variables */ | 86 | u64 x[SKEIN_1024_STATE_WORDS]; /* chaining variables */ |
87 | u8 b[SKEIN_1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ | 87 | u8 b[SKEIN_1024_BLOCK_BYTES]; /* partial block buf (8-byte aligned) */ |
88 | }; | 88 | }; |
89 | 89 | ||
@@ -150,7 +150,7 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); | |||
150 | ** reference and optimized code. | 150 | ** reference and optimized code. |
151 | ******************************************************************/ | 151 | ******************************************************************/ |
152 | 152 | ||
153 | /* tweak word T[1]: bit field starting positions */ | 153 | /* tweak word tweak[1]: bit field starting positions */ |
154 | #define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* second word */ | 154 | #define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* second word */ |
155 | 155 | ||
156 | #define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* 112..118 hash tree level */ | 156 | #define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* 112..118 hash tree level */ |
@@ -159,16 +159,16 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); | |||
159 | #define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* 126 first blk flag */ | 159 | #define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* 126 first blk flag */ |
160 | #define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* 127 final blk flag */ | 160 | #define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* 127 final blk flag */ |
161 | 161 | ||
162 | /* tweak word T[1]: flag bit definition(s) */ | 162 | /* tweak word tweak[1]: flag bit definition(s) */ |
163 | #define SKEIN_T1_FLAG_FIRST (((u64) 1) << SKEIN_T1_POS_FIRST) | 163 | #define SKEIN_T1_FLAG_FIRST (((u64) 1) << SKEIN_T1_POS_FIRST) |
164 | #define SKEIN_T1_FLAG_FINAL (((u64) 1) << SKEIN_T1_POS_FINAL) | 164 | #define SKEIN_T1_FLAG_FINAL (((u64) 1) << SKEIN_T1_POS_FINAL) |
165 | #define SKEIN_T1_FLAG_BIT_PAD (((u64) 1) << SKEIN_T1_POS_BIT_PAD) | 165 | #define SKEIN_T1_FLAG_BIT_PAD (((u64) 1) << SKEIN_T1_POS_BIT_PAD) |
166 | 166 | ||
167 | /* tweak word T[1]: tree level bit field mask */ | 167 | /* tweak word tweak[1]: tree level bit field mask */ |
168 | #define SKEIN_T1_TREE_LVL_MASK (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL) | 168 | #define SKEIN_T1_TREE_LVL_MASK (((u64)0x7F) << SKEIN_T1_POS_TREE_LVL) |
169 | #define SKEIN_T1_TREE_LEVEL(n) (((u64) (n)) << SKEIN_T1_POS_TREE_LVL) | 169 | #define SKEIN_T1_TREE_LEVEL(n) (((u64) (n)) << SKEIN_T1_POS_TREE_LVL) |
170 | 170 | ||
171 | /* tweak word T[1]: block type field */ | 171 | /* tweak word tweak[1]: block type field */ |
172 | #define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */ | 172 | #define SKEIN_BLK_TYPE_KEY (0) /* key, for MAC and KDF */ |
173 | #define SKEIN_BLK_TYPE_CFG (4) /* configuration block */ | 173 | #define SKEIN_BLK_TYPE_CFG (4) /* configuration block */ |
174 | #define SKEIN_BLK_TYPE_PERS (8) /* personalization string */ | 174 | #define SKEIN_BLK_TYPE_PERS (8) /* personalization string */ |
@@ -232,9 +232,9 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); | |||
232 | ** Skein macros for getting/setting tweak words, etc. | 232 | ** Skein macros for getting/setting tweak words, etc. |
233 | ** These are useful for partial input bytes, hash tree init/update, etc. | 233 | ** These are useful for partial input bytes, hash tree init/update, etc. |
234 | **/ | 234 | **/ |
235 | #define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.T[TWK_NUM]) | 235 | #define skein_get_tweak(ctx_ptr, TWK_NUM) ((ctx_ptr)->h.tweak[TWK_NUM]) |
236 | #define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \ | 236 | #define skein_set_tweak(ctx_ptr, TWK_NUM, t_val) { \ |
237 | (ctx_ptr)->h.T[TWK_NUM] = (t_val); \ | 237 | (ctx_ptr)->h.tweak[TWK_NUM] = (t_val); \ |
238 | } | 238 | } |
239 | 239 | ||
240 | #define skein_get_T0(ctx_ptr) skein_get_tweak(ctx_ptr, 0) | 240 | #define skein_get_T0(ctx_ptr) skein_get_tweak(ctx_ptr, 0) |
@@ -254,7 +254,7 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); | |||
254 | 254 | ||
255 | /* | 255 | /* |
256 | * setup for starting with a new type: | 256 | * setup for starting with a new type: |
257 | * h.T[0]=0; h.T[1] = NEW_TYPE; h.b_cnt=0; | 257 | * h.tweak[0]=0; h.tweak[1] = NEW_TYPE; h.b_cnt=0; |
258 | */ | 258 | */ |
259 | #define skein_start_new_type(ctx_ptr, BLK_TYPE) { \ | 259 | #define skein_start_new_type(ctx_ptr, BLK_TYPE) { \ |
260 | skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ | 260 | skein_set_T0_T1(ctx_ptr, 0, SKEIN_T1_FLAG_FIRST | \ |
@@ -263,14 +263,14 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); | |||
263 | } | 263 | } |
264 | 264 | ||
265 | #define skein_clear_first_flag(hdr) { \ | 265 | #define skein_clear_first_flag(hdr) { \ |
266 | (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; \ | 266 | (hdr).tweak[1] &= ~SKEIN_T1_FLAG_FIRST; \ |
267 | } | 267 | } |
268 | #define skein_set_bit_pad_flag(hdr) { \ | 268 | #define skein_set_bit_pad_flag(hdr) { \ |
269 | (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; \ | 269 | (hdr).tweak[1] |= SKEIN_T1_FLAG_BIT_PAD; \ |
270 | } | 270 | } |
271 | 271 | ||
272 | #define skein_set_tree_level(hdr, height) { \ | 272 | #define skein_set_tree_level(hdr, height) { \ |
273 | (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height); \ | 273 | (hdr).tweak[1] |= SKEIN_T1_TREE_LEVEL(height); \ |
274 | } | 274 | } |
275 | 275 | ||
276 | /***************************************************************** | 276 | /***************************************************************** |
@@ -279,9 +279,9 @@ int skein_1024_output(struct skein_1024_ctx *ctx, u8 *hash_val); | |||
279 | #ifdef SKEIN_DEBUG /* examine/display intermediate values? */ | 279 | #ifdef SKEIN_DEBUG /* examine/display intermediate values? */ |
280 | #include "skein_debug.h" | 280 | #include "skein_debug.h" |
281 | #else /* default is no callouts */ | 281 | #else /* default is no callouts */ |
282 | #define skein_show_block(bits, ctx, X, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) | 282 | #define skein_show_block(bits, ctx, x, blk_ptr, w_ptr, ks_event_ptr, ks_odd_ptr) |
283 | #define skein_show_round(bits, ctx, r, X) | 283 | #define skein_show_round(bits, ctx, r, x) |
284 | #define skein_show_r_ptr(bits, ctx, r, X_ptr) | 284 | #define skein_show_r_ptr(bits, ctx, r, x_ptr) |
285 | #define skein_show_final(bits, ctx, cnt, out_ptr) | 285 | #define skein_show_final(bits, ctx, cnt, out_ptr) |
286 | #define skein_show_key(bits, ctx, key, key_bytes) | 286 | #define skein_show_key(bits, ctx, key, key_bytes) |
287 | #endif | 287 | #endif |
diff --git a/drivers/staging/skein/skein_api.c b/drivers/staging/skein/skein_api.c index eaf7af4c8007..6e700eefc00c 100644 --- a/drivers/staging/skein/skein_api.c +++ b/drivers/staging/skein/skein_api.c | |||
@@ -40,8 +40,8 @@ int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size) | |||
40 | int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) | 40 | int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) |
41 | { | 41 | { |
42 | int ret = SKEIN_FAIL; | 42 | int ret = SKEIN_FAIL; |
43 | size_t X_len = 0; | 43 | size_t x_len = 0; |
44 | u64 *X = NULL; | 44 | u64 *x = NULL; |
45 | u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; | 45 | u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; |
46 | 46 | ||
47 | skein_assert_ret(ctx, SKEIN_FAIL); | 47 | skein_assert_ret(ctx, SKEIN_FAIL); |
@@ -50,8 +50,8 @@ int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) | |||
50 | * contexts are a union in out context and thus have tha maximum | 50 | * contexts are a union in out context and thus have tha maximum |
51 | * memory available. The beauty of C :-) . | 51 | * memory available. The beauty of C :-) . |
52 | */ | 52 | */ |
53 | X = ctx->m.s256.X; | 53 | x = ctx->m.s256.x; |
54 | X_len = ctx->skein_size/8; | 54 | x_len = ctx->skein_size/8; |
55 | /* | 55 | /* |
56 | * If size is the same and hash bit length is zero then reuse | 56 | * If size is the same and hash bit length is zero then reuse |
57 | * the save chaining variables. | 57 | * the save chaining variables. |
@@ -76,7 +76,7 @@ int skein_init(struct skein_ctx *ctx, size_t hash_bit_len) | |||
76 | * Save chaining variables for this combination of size and | 76 | * Save chaining variables for this combination of size and |
77 | * hash_bit_len | 77 | * hash_bit_len |
78 | */ | 78 | */ |
79 | memcpy(ctx->X_save, X, X_len); | 79 | memcpy(ctx->x_save, x, x_len); |
80 | } | 80 | } |
81 | return ret; | 81 | return ret; |
82 | } | 82 | } |
@@ -85,14 +85,14 @@ int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, | |||
85 | size_t hash_bit_len) | 85 | size_t hash_bit_len) |
86 | { | 86 | { |
87 | int ret = SKEIN_FAIL; | 87 | int ret = SKEIN_FAIL; |
88 | u64 *X = NULL; | 88 | u64 *x = NULL; |
89 | size_t X_len = 0; | 89 | size_t x_len = 0; |
90 | u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; | 90 | u64 tree_info = SKEIN_CFG_TREE_INFO_SEQUENTIAL; |
91 | 91 | ||
92 | skein_assert_ret(ctx, SKEIN_FAIL); | 92 | skein_assert_ret(ctx, SKEIN_FAIL); |
93 | 93 | ||
94 | X = ctx->m.s256.X; | 94 | x = ctx->m.s256.x; |
95 | X_len = ctx->skein_size/8; | 95 | x_len = ctx->skein_size/8; |
96 | 96 | ||
97 | skein_assert_ret(hash_bit_len, SKEIN_BAD_HASHLEN); | 97 | skein_assert_ret(hash_bit_len, SKEIN_BAD_HASHLEN); |
98 | 98 | ||
@@ -120,25 +120,25 @@ int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len, | |||
120 | * Save chaining variables for this combination of key, | 120 | * Save chaining variables for this combination of key, |
121 | * key_len, hash_bit_len | 121 | * key_len, hash_bit_len |
122 | */ | 122 | */ |
123 | memcpy(ctx->X_save, X, X_len); | 123 | memcpy(ctx->x_save, x, x_len); |
124 | } | 124 | } |
125 | return ret; | 125 | return ret; |
126 | } | 126 | } |
127 | 127 | ||
128 | void skein_reset(struct skein_ctx *ctx) | 128 | void skein_reset(struct skein_ctx *ctx) |
129 | { | 129 | { |
130 | size_t X_len = 0; | 130 | size_t x_len = 0; |
131 | u64 *X = NULL; | 131 | u64 *x = NULL; |
132 | 132 | ||
133 | /* | 133 | /* |
134 | * The following two lines rely of the fact that the real Skein | 134 | * The following two lines rely of the fact that the real Skein |
135 | * contexts are a union in out context and thus have tha maximum | 135 | * contexts are a union in out context and thus have tha maximum |
136 | * memory available. The beautiy of C :-) . | 136 | * memory available. The beautiy of C :-) . |
137 | */ | 137 | */ |
138 | X = ctx->m.s256.X; | 138 | x = ctx->m.s256.x; |
139 | X_len = ctx->skein_size/8; | 139 | x_len = ctx->skein_size/8; |
140 | /* Restore the chaing variable, reset byte counter */ | 140 | /* Restore the chaing variable, reset byte counter */ |
141 | memcpy(X, ctx->X_save, X_len); | 141 | memcpy(x, ctx->x_save, x_len); |
142 | 142 | ||
143 | /* Setup context to process the message */ | 143 | /* Setup context to process the message */ |
144 | skein_start_new_type(&ctx->m, MSG); | 144 | skein_start_new_type(&ctx->m, MSG); |
@@ -200,7 +200,7 @@ int skein_update_bits(struct skein_ctx *ctx, const u8 *msg, | |||
200 | * Skein's real partial block buffer. | 200 | * Skein's real partial block buffer. |
201 | * If this layout ever changes we have to adapt this as well. | 201 | * If this layout ever changes we have to adapt this as well. |
202 | */ | 202 | */ |
203 | up = (u8 *)ctx->m.s256.X + ctx->skein_size / 8; | 203 | up = (u8 *)ctx->m.s256.x + ctx->skein_size / 8; |
204 | 204 | ||
205 | /* set tweak flag for the skein_final call */ | 205 | /* set tweak flag for the skein_final call */ |
206 | skein_set_bit_pad_flag(ctx->m.h); | 206 | skein_set_bit_pad_flag(ctx->m.h); |
diff --git a/drivers/staging/skein/skein_api.h b/drivers/staging/skein/skein_api.h index db808ae434ff..e02fa19d9458 100644 --- a/drivers/staging/skein/skein_api.h +++ b/drivers/staging/skein/skein_api.h | |||
@@ -100,7 +100,7 @@ enum skein_size { | |||
100 | */ | 100 | */ |
101 | struct skein_ctx { | 101 | struct skein_ctx { |
102 | u64 skein_size; | 102 | u64 skein_size; |
103 | u64 X_save[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ | 103 | u64 x_save[SKEIN_MAX_STATE_WORDS]; /* save area for state variables */ |
104 | union { | 104 | union { |
105 | struct skein_ctx_hdr h; | 105 | struct skein_ctx_hdr h; |
106 | struct skein_256_ctx s256; | 106 | struct skein_256_ctx s256; |
diff --git a/drivers/staging/skein/skein_block.c b/drivers/staging/skein/skein_block.c index 76c4113ea5c8..f49eb2e9e5af 100644 --- a/drivers/staging/skein/skein_block.c +++ b/drivers/staging/skein/skein_block.c | |||
@@ -32,7 +32,8 @@ | |||
32 | #define ts (kw + KW_TWK_BASE) | 32 | #define ts (kw + KW_TWK_BASE) |
33 | 33 | ||
34 | #ifdef SKEIN_DEBUG | 34 | #ifdef SKEIN_DEBUG |
35 | #define debug_save_tweak(ctx) { ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } | 35 | #define debug_save_tweak(ctx) { \ |
36 | ctx->h.tweak[0] = ts[0]; ctx->h.tweak[1] = ts[1]; } | ||
36 | #else | 37 | #else |
37 | #define debug_save_tweak(ctx) | 38 | #define debug_save_tweak(ctx) |
38 | #endif | 39 | #endif |
@@ -71,8 +72,8 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, | |||
71 | X_ptr[0] = &X0; X_ptr[1] = &X1; X_ptr[2] = &X2; X_ptr[3] = &X3; | 72 | X_ptr[0] = &X0; X_ptr[1] = &X1; X_ptr[2] = &X2; X_ptr[3] = &X3; |
72 | #endif | 73 | #endif |
73 | skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ | 74 | skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ |
74 | ts[0] = ctx->h.T[0]; | 75 | ts[0] = ctx->h.tweak[0]; |
75 | ts[1] = ctx->h.T[1]; | 76 | ts[1] = ctx->h.tweak[1]; |
76 | do { | 77 | do { |
77 | /* | 78 | /* |
78 | * this implementation only supports 2**64 input bytes | 79 | * this implementation only supports 2**64 input bytes |
@@ -81,10 +82,10 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, | |||
81 | ts[0] += byte_cnt_add; /* update processed length */ | 82 | ts[0] += byte_cnt_add; /* update processed length */ |
82 | 83 | ||
83 | /* precompute the key schedule for this block */ | 84 | /* precompute the key schedule for this block */ |
84 | ks[0] = ctx->X[0]; | 85 | ks[0] = ctx->x[0]; |
85 | ks[1] = ctx->X[1]; | 86 | ks[1] = ctx->x[1]; |
86 | ks[2] = ctx->X[2]; | 87 | ks[2] = ctx->x[2]; |
87 | ks[3] = ctx->X[3]; | 88 | ks[3] = ctx->x[3]; |
88 | ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY; | 89 | ks[4] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ SKEIN_KS_PARITY; |
89 | 90 | ||
90 | ts[2] = ts[0] ^ ts[1]; | 91 | ts[2] = ts[0] ^ ts[1]; |
@@ -92,7 +93,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, | |||
92 | /* get input block in little-endian format */ | 93 | /* get input block in little-endian format */ |
93 | skein_get64_lsb_first(w, blk_ptr, WCNT); | 94 | skein_get64_lsb_first(w, blk_ptr, WCNT); |
94 | debug_save_tweak(ctx); | 95 | debug_save_tweak(ctx); |
95 | skein_show_block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); | 96 | skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); |
96 | 97 | ||
97 | X0 = w[0] + ks[0]; /* do the first full key injection */ | 98 | X0 = w[0] + ks[0]; /* do the first full key injection */ |
98 | X1 = w[1] + ks[1] + ts[0]; | 99 | X1 = w[1] + ks[1] + ts[0]; |
@@ -101,7 +102,7 @@ void skein_256_process_block(struct skein_256_ctx *ctx, const u8 *blk_ptr, | |||
101 | 102 | ||
102 | /* show starting state values */ | 103 | /* show starting state values */ |
103 | skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, | 104 | skein_show_r_ptr(BLK_BITS, &ctx->h, SKEIN_RND_KEY_INITIAL, |
104 | X_ptr); | 105 | x_ptr); |
105 | 106 | ||
106 | blk_ptr += SKEIN_256_BLOCK_BYTES; | 107 | blk_ptr += SKEIN_256_BLOCK_BYTES; |
107 | 108 | ||
@@ -220,17 +221,17 @@ do { \ | |||
220 | #endif | 221 | #endif |
221 | } | 222 | } |
222 | /* do the final "feedforward" xor, update context chaining */ | 223 | /* do the final "feedforward" xor, update context chaining */ |
223 | ctx->X[0] = X0 ^ w[0]; | 224 | ctx->x[0] = X0 ^ w[0]; |
224 | ctx->X[1] = X1 ^ w[1]; | 225 | ctx->x[1] = X1 ^ w[1]; |
225 | ctx->X[2] = X2 ^ w[2]; | 226 | ctx->x[2] = X2 ^ w[2]; |
226 | ctx->X[3] = X3 ^ w[3]; | 227 | ctx->x[3] = X3 ^ w[3]; |
227 | 228 | ||
228 | skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); | 229 | skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->x); |
229 | 230 | ||
230 | ts[1] &= ~SKEIN_T1_FLAG_FIRST; | 231 | ts[1] &= ~SKEIN_T1_FLAG_FIRST; |
231 | } while (--blk_cnt); | 232 | } while (--blk_cnt); |
232 | ctx->h.T[0] = ts[0]; | 233 | ctx->h.tweak[0] = ts[0]; |
233 | ctx->h.T[1] = ts[1]; | 234 | ctx->h.tweak[1] = ts[1]; |
234 | } | 235 | } |
235 | 236 | ||
236 | #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) | 237 | #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) |
@@ -282,8 +283,8 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, | |||
282 | #endif | 283 | #endif |
283 | 284 | ||
284 | skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ | 285 | skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ |
285 | ts[0] = ctx->h.T[0]; | 286 | ts[0] = ctx->h.tweak[0]; |
286 | ts[1] = ctx->h.T[1]; | 287 | ts[1] = ctx->h.tweak[1]; |
287 | do { | 288 | do { |
288 | /* | 289 | /* |
289 | * this implementation only supports 2**64 input bytes | 290 | * this implementation only supports 2**64 input bytes |
@@ -292,14 +293,14 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, | |||
292 | ts[0] += byte_cnt_add; /* update processed length */ | 293 | ts[0] += byte_cnt_add; /* update processed length */ |
293 | 294 | ||
294 | /* precompute the key schedule for this block */ | 295 | /* precompute the key schedule for this block */ |
295 | ks[0] = ctx->X[0]; | 296 | ks[0] = ctx->x[0]; |
296 | ks[1] = ctx->X[1]; | 297 | ks[1] = ctx->x[1]; |
297 | ks[2] = ctx->X[2]; | 298 | ks[2] = ctx->x[2]; |
298 | ks[3] = ctx->X[3]; | 299 | ks[3] = ctx->x[3]; |
299 | ks[4] = ctx->X[4]; | 300 | ks[4] = ctx->x[4]; |
300 | ks[5] = ctx->X[5]; | 301 | ks[5] = ctx->x[5]; |
301 | ks[6] = ctx->X[6]; | 302 | ks[6] = ctx->x[6]; |
302 | ks[7] = ctx->X[7]; | 303 | ks[7] = ctx->x[7]; |
303 | ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ | 304 | ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ |
304 | ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ SKEIN_KS_PARITY; | 305 | ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ SKEIN_KS_PARITY; |
305 | 306 | ||
@@ -308,7 +309,7 @@ void skein_512_process_block(struct skein_512_ctx *ctx, const u8 *blk_ptr, | |||
308 | /* get input block in little-endian format */ | 309 | /* get input block in little-endian format */ |
309 | skein_get64_lsb_first(w, blk_ptr, WCNT); | 310 | skein_get64_lsb_first(w, blk_ptr, WCNT); |
310 | debug_save_tweak(ctx); | 311 | debug_save_tweak(ctx); |
311 | skein_show_block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); | 312 | skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); |
312 | 313 | ||
313 | X0 = w[0] + ks[0]; /* do the first full key injection */ | 314 | X0 = w[0] + ks[0]; /* do the first full key injection */ |
314 | X1 = w[1] + ks[1]; | 315 | X1 = w[1] + ks[1]; |
@@ -448,20 +449,20 @@ do { \ | |||
448 | } | 449 | } |
449 | 450 | ||
450 | /* do the final "feedforward" xor, update context chaining */ | 451 | /* do the final "feedforward" xor, update context chaining */ |
451 | ctx->X[0] = X0 ^ w[0]; | 452 | ctx->x[0] = X0 ^ w[0]; |
452 | ctx->X[1] = X1 ^ w[1]; | 453 | ctx->x[1] = X1 ^ w[1]; |
453 | ctx->X[2] = X2 ^ w[2]; | 454 | ctx->x[2] = X2 ^ w[2]; |
454 | ctx->X[3] = X3 ^ w[3]; | 455 | ctx->x[3] = X3 ^ w[3]; |
455 | ctx->X[4] = X4 ^ w[4]; | 456 | ctx->x[4] = X4 ^ w[4]; |
456 | ctx->X[5] = X5 ^ w[5]; | 457 | ctx->x[5] = X5 ^ w[5]; |
457 | ctx->X[6] = X6 ^ w[6]; | 458 | ctx->x[6] = X6 ^ w[6]; |
458 | ctx->X[7] = X7 ^ w[7]; | 459 | ctx->x[7] = X7 ^ w[7]; |
459 | skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); | 460 | skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->x); |
460 | 461 | ||
461 | ts[1] &= ~SKEIN_T1_FLAG_FIRST; | 462 | ts[1] &= ~SKEIN_T1_FLAG_FIRST; |
462 | } while (--blk_cnt); | 463 | } while (--blk_cnt); |
463 | ctx->h.T[0] = ts[0]; | 464 | ctx->h.tweak[0] = ts[0]; |
464 | ctx->h.T[1] = ts[1]; | 465 | ctx->h.tweak[1] = ts[1]; |
465 | } | 466 | } |
466 | 467 | ||
467 | #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) | 468 | #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) |
@@ -520,8 +521,8 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, | |||
520 | #endif | 521 | #endif |
521 | 522 | ||
522 | skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ | 523 | skein_assert(blk_cnt != 0); /* never call with blk_cnt == 0! */ |
523 | ts[0] = ctx->h.T[0]; | 524 | ts[0] = ctx->h.tweak[0]; |
524 | ts[1] = ctx->h.T[1]; | 525 | ts[1] = ctx->h.tweak[1]; |
525 | do { | 526 | do { |
526 | /* | 527 | /* |
527 | * this implementation only supports 2**64 input bytes | 528 | * this implementation only supports 2**64 input bytes |
@@ -530,22 +531,22 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, | |||
530 | ts[0] += byte_cnt_add; /* update processed length */ | 531 | ts[0] += byte_cnt_add; /* update processed length */ |
531 | 532 | ||
532 | /* precompute the key schedule for this block */ | 533 | /* precompute the key schedule for this block */ |
533 | ks[0] = ctx->X[0]; | 534 | ks[0] = ctx->x[0]; |
534 | ks[1] = ctx->X[1]; | 535 | ks[1] = ctx->x[1]; |
535 | ks[2] = ctx->X[2]; | 536 | ks[2] = ctx->x[2]; |
536 | ks[3] = ctx->X[3]; | 537 | ks[3] = ctx->x[3]; |
537 | ks[4] = ctx->X[4]; | 538 | ks[4] = ctx->x[4]; |
538 | ks[5] = ctx->X[5]; | 539 | ks[5] = ctx->x[5]; |
539 | ks[6] = ctx->X[6]; | 540 | ks[6] = ctx->x[6]; |
540 | ks[7] = ctx->X[7]; | 541 | ks[7] = ctx->x[7]; |
541 | ks[8] = ctx->X[8]; | 542 | ks[8] = ctx->x[8]; |
542 | ks[9] = ctx->X[9]; | 543 | ks[9] = ctx->x[9]; |
543 | ks[10] = ctx->X[10]; | 544 | ks[10] = ctx->x[10]; |
544 | ks[11] = ctx->X[11]; | 545 | ks[11] = ctx->x[11]; |
545 | ks[12] = ctx->X[12]; | 546 | ks[12] = ctx->x[12]; |
546 | ks[13] = ctx->X[13]; | 547 | ks[13] = ctx->x[13]; |
547 | ks[14] = ctx->X[14]; | 548 | ks[14] = ctx->x[14]; |
548 | ks[15] = ctx->X[15]; | 549 | ks[15] = ctx->x[15]; |
549 | ks[16] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ | 550 | ks[16] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ |
550 | ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ | 551 | ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ |
551 | ks[8] ^ ks[9] ^ ks[10] ^ ks[11] ^ | 552 | ks[8] ^ ks[9] ^ ks[10] ^ ks[11] ^ |
@@ -556,7 +557,7 @@ void skein_1024_process_block(struct skein_1024_ctx *ctx, const u8 *blk_ptr, | |||
556 | /* get input block in little-endian format */ | 557 | /* get input block in little-endian format */ |
557 | skein_get64_lsb_first(w, blk_ptr, WCNT); | 558 | skein_get64_lsb_first(w, blk_ptr, WCNT); |
558 | debug_save_tweak(ctx); | 559 | debug_save_tweak(ctx); |
559 | skein_show_block(BLK_BITS, &ctx->h, ctx->X, blk_ptr, w, ks, ts); | 560 | skein_show_block(BLK_BITS, &ctx->h, ctx->x, blk_ptr, w, ks, ts); |
560 | 561 | ||
561 | X00 = w[0] + ks[0]; /* do the first full key injection */ | 562 | X00 = w[0] + ks[0]; /* do the first full key injection */ |
562 | X01 = w[1] + ks[1]; | 563 | X01 = w[1] + ks[1]; |
@@ -735,30 +736,30 @@ do { \ | |||
735 | } | 736 | } |
736 | /* do the final "feedforward" xor, update context chaining */ | 737 | /* do the final "feedforward" xor, update context chaining */ |
737 | 738 | ||
738 | ctx->X[0] = X00 ^ w[0]; | 739 | ctx->x[0] = X00 ^ w[0]; |
739 | ctx->X[1] = X01 ^ w[1]; | 740 | ctx->x[1] = X01 ^ w[1]; |
740 | ctx->X[2] = X02 ^ w[2]; | 741 | ctx->x[2] = X02 ^ w[2]; |
741 | ctx->X[3] = X03 ^ w[3]; | 742 | ctx->x[3] = X03 ^ w[3]; |
742 | ctx->X[4] = X04 ^ w[4]; | 743 | ctx->x[4] = X04 ^ w[4]; |
743 | ctx->X[5] = X05 ^ w[5]; | 744 | ctx->x[5] = X05 ^ w[5]; |
744 | ctx->X[6] = X06 ^ w[6]; | 745 | ctx->x[6] = X06 ^ w[6]; |
745 | ctx->X[7] = X07 ^ w[7]; | 746 | ctx->x[7] = X07 ^ w[7]; |
746 | ctx->X[8] = X08 ^ w[8]; | 747 | ctx->x[8] = X08 ^ w[8]; |
747 | ctx->X[9] = X09 ^ w[9]; | 748 | ctx->x[9] = X09 ^ w[9]; |
748 | ctx->X[10] = X10 ^ w[10]; | 749 | ctx->x[10] = X10 ^ w[10]; |
749 | ctx->X[11] = X11 ^ w[11]; | 750 | ctx->x[11] = X11 ^ w[11]; |
750 | ctx->X[12] = X12 ^ w[12]; | 751 | ctx->x[12] = X12 ^ w[12]; |
751 | ctx->X[13] = X13 ^ w[13]; | 752 | ctx->x[13] = X13 ^ w[13]; |
752 | ctx->X[14] = X14 ^ w[14]; | 753 | ctx->x[14] = X14 ^ w[14]; |
753 | ctx->X[15] = X15 ^ w[15]; | 754 | ctx->x[15] = X15 ^ w[15]; |
754 | 755 | ||
755 | skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->X); | 756 | skein_show_round(BLK_BITS, &ctx->h, SKEIN_RND_FEED_FWD, ctx->x); |
756 | 757 | ||
757 | ts[1] &= ~SKEIN_T1_FLAG_FIRST; | 758 | ts[1] &= ~SKEIN_T1_FLAG_FIRST; |
758 | blk_ptr += SKEIN_1024_BLOCK_BYTES; | 759 | blk_ptr += SKEIN_1024_BLOCK_BYTES; |
759 | } while (--blk_cnt); | 760 | } while (--blk_cnt); |
760 | ctx->h.T[0] = ts[0]; | 761 | ctx->h.tweak[0] = ts[0]; |
761 | ctx->h.T[1] = ts[1]; | 762 | ctx->h.tweak[1] = ts[1]; |
762 | } | 763 | } |
763 | 764 | ||
764 | #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) | 765 | #if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) |