Lines Matching refs:state
326 static void shift_rows(u8 *state) in shift_rows() argument
331 state[0] = sbox[state[0]]; in shift_rows()
332 state[4] = sbox[state[4]]; in shift_rows()
333 state[8] = sbox[state[8]]; in shift_rows()
334 state[12] = sbox[state[12]]; in shift_rows()
337 tmp = sbox[state[1]]; in shift_rows()
338 state[1] = sbox[state[5]]; in shift_rows()
339 state[5] = sbox[state[9]]; in shift_rows()
340 state[9] = sbox[state[13]]; in shift_rows()
341 state[13] = tmp; in shift_rows()
344 tmp = sbox[state[2]]; in shift_rows()
345 state[2] = sbox[state[10]]; in shift_rows()
346 state[10] = tmp; in shift_rows()
347 tmp = sbox[state[6]]; in shift_rows()
348 state[6] = sbox[state[14]]; in shift_rows()
349 state[14] = tmp; in shift_rows()
352 tmp = sbox[state[15]]; in shift_rows()
353 state[15] = sbox[state[11]]; in shift_rows()
354 state[11] = sbox[state[7]]; in shift_rows()
355 state[7] = sbox[state[3]]; in shift_rows()
356 state[3] = tmp; in shift_rows()
364 static void inv_shift_rows(u8 *state) in inv_shift_rows() argument
369 state[0] = inv_sbox[state[0]]; in inv_shift_rows()
370 state[4] = inv_sbox[state[4]]; in inv_shift_rows()
371 state[8] = inv_sbox[state[8]]; in inv_shift_rows()
372 state[12] = inv_sbox[state[12]]; in inv_shift_rows()
375 tmp = inv_sbox[state[13]]; in inv_shift_rows()
376 state[13] = inv_sbox[state[9]]; in inv_shift_rows()
377 state[9] = inv_sbox[state[5]]; in inv_shift_rows()
378 state[5] = inv_sbox[state[1]]; in inv_shift_rows()
379 state[1] = tmp; in inv_shift_rows()
382 tmp = inv_sbox[state[2]]; in inv_shift_rows()
383 state[2] = inv_sbox[state[10]]; in inv_shift_rows()
384 state[10] = tmp; in inv_shift_rows()
385 tmp = inv_sbox[state[6]]; in inv_shift_rows()
386 state[6] = inv_sbox[state[14]]; in inv_shift_rows()
387 state[14] = tmp; in inv_shift_rows()
390 tmp = inv_sbox[state[3]]; in inv_shift_rows()
391 state[3] = inv_sbox[state[7]]; in inv_shift_rows()
392 state[7] = inv_sbox[state[11]]; in inv_shift_rows()
393 state[11] = inv_sbox[state[15]]; in inv_shift_rows()
394 state[15] = tmp; in inv_shift_rows()
398 static void mix_sub_columns(u8 *state) in mix_sub_columns() argument
403 tmp[0] = x2_sbox[state[0]] ^ x3_sbox[state[5]] ^ in mix_sub_columns()
404 sbox[state[10]] ^ sbox[state[15]]; in mix_sub_columns()
405 tmp[1] = sbox[state[0]] ^ x2_sbox[state[5]] ^ in mix_sub_columns()
406 x3_sbox[state[10]] ^ sbox[state[15]]; in mix_sub_columns()
407 tmp[2] = sbox[state[0]] ^ sbox[state[5]] ^ in mix_sub_columns()
408 x2_sbox[state[10]] ^ x3_sbox[state[15]]; in mix_sub_columns()
409 tmp[3] = x3_sbox[state[0]] ^ sbox[state[5]] ^ in mix_sub_columns()
410 sbox[state[10]] ^ x2_sbox[state[15]]; in mix_sub_columns()
413 tmp[4] = x2_sbox[state[4]] ^ x3_sbox[state[9]] ^ in mix_sub_columns()
414 sbox[state[14]] ^ sbox[state[3]]; in mix_sub_columns()
415 tmp[5] = sbox[state[4]] ^ x2_sbox[state[9]] ^ in mix_sub_columns()
416 x3_sbox[state[14]] ^ sbox[state[3]]; in mix_sub_columns()
417 tmp[6] = sbox[state[4]] ^ sbox[state[9]] ^ in mix_sub_columns()
418 x2_sbox[state[14]] ^ x3_sbox[state[3]]; in mix_sub_columns()
419 tmp[7] = x3_sbox[state[4]] ^ sbox[state[9]] ^ in mix_sub_columns()
420 sbox[state[14]] ^ x2_sbox[state[3]]; in mix_sub_columns()
423 tmp[8] = x2_sbox[state[8]] ^ x3_sbox[state[13]] ^ in mix_sub_columns()
424 sbox[state[2]] ^ sbox[state[7]]; in mix_sub_columns()
425 tmp[9] = sbox[state[8]] ^ x2_sbox[state[13]] ^ in mix_sub_columns()
426 x3_sbox[state[2]] ^ sbox[state[7]]; in mix_sub_columns()
427 tmp[10] = sbox[state[8]] ^ sbox[state[13]] ^ in mix_sub_columns()
428 x2_sbox[state[2]] ^ x3_sbox[state[7]]; in mix_sub_columns()
429 tmp[11] = x3_sbox[state[8]] ^ sbox[state[13]] ^ in mix_sub_columns()
430 sbox[state[2]] ^ x2_sbox[state[7]]; in mix_sub_columns()
433 tmp[12] = x2_sbox[state[12]] ^ x3_sbox[state[1]] ^ in mix_sub_columns()
434 sbox[state[6]] ^ sbox[state[11]]; in mix_sub_columns()
435 tmp[13] = sbox[state[12]] ^ x2_sbox[state[1]] ^ in mix_sub_columns()
436 x3_sbox[state[6]] ^ sbox[state[11]]; in mix_sub_columns()
437 tmp[14] = sbox[state[12]] ^ sbox[state[1]] ^ in mix_sub_columns()
438 x2_sbox[state[6]] ^ x3_sbox[state[11]]; in mix_sub_columns()
439 tmp[15] = x3_sbox[state[12]] ^ sbox[state[1]] ^ in mix_sub_columns()
440 sbox[state[6]] ^ x2_sbox[state[11]]; in mix_sub_columns()
442 memcpy(state, tmp, sizeof(tmp)); in mix_sub_columns()
446 static void inv_mix_sub_columns(u8 *state) in inv_mix_sub_columns() argument
452 tmp[0] = x_time_e[state[0]] ^ x_time_b[state[1]] ^ in inv_mix_sub_columns()
453 x_time_d[state[2]] ^ x_time_9[state[3]]; in inv_mix_sub_columns()
454 tmp[5] = x_time_9[state[0]] ^ x_time_e[state[1]] ^ in inv_mix_sub_columns()
455 x_time_b[state[2]] ^ x_time_d[state[3]]; in inv_mix_sub_columns()
456 tmp[10] = x_time_d[state[0]] ^ x_time_9[state[1]] ^ in inv_mix_sub_columns()
457 x_time_e[state[2]] ^ x_time_b[state[3]]; in inv_mix_sub_columns()
458 tmp[15] = x_time_b[state[0]] ^ x_time_d[state[1]] ^ in inv_mix_sub_columns()
459 x_time_9[state[2]] ^ x_time_e[state[3]]; in inv_mix_sub_columns()
462 tmp[4] = x_time_e[state[4]] ^ x_time_b[state[5]] ^ in inv_mix_sub_columns()
463 x_time_d[state[6]] ^ x_time_9[state[7]]; in inv_mix_sub_columns()
464 tmp[9] = x_time_9[state[4]] ^ x_time_e[state[5]] ^ in inv_mix_sub_columns()
465 x_time_b[state[6]] ^ x_time_d[state[7]]; in inv_mix_sub_columns()
466 tmp[14] = x_time_d[state[4]] ^ x_time_9[state[5]] ^ in inv_mix_sub_columns()
467 x_time_e[state[6]] ^ x_time_b[state[7]]; in inv_mix_sub_columns()
468 tmp[3] = x_time_b[state[4]] ^ x_time_d[state[5]] ^ in inv_mix_sub_columns()
469 x_time_9[state[6]] ^ x_time_e[state[7]]; in inv_mix_sub_columns()
472 tmp[8] = x_time_e[state[8]] ^ x_time_b[state[9]] ^ in inv_mix_sub_columns()
473 x_time_d[state[10]] ^ x_time_9[state[11]]; in inv_mix_sub_columns()
474 tmp[13] = x_time_9[state[8]] ^ x_time_e[state[9]] ^ in inv_mix_sub_columns()
475 x_time_b[state[10]] ^ x_time_d[state[11]]; in inv_mix_sub_columns()
476 tmp[2] = x_time_d[state[8]] ^ x_time_9[state[9]] ^ in inv_mix_sub_columns()
477 x_time_e[state[10]] ^ x_time_b[state[11]]; in inv_mix_sub_columns()
478 tmp[7] = x_time_b[state[8]] ^ x_time_d[state[9]] ^ in inv_mix_sub_columns()
479 x_time_9[state[10]] ^ x_time_e[state[11]]; in inv_mix_sub_columns()
482 tmp[12] = x_time_e[state[12]] ^ x_time_b[state[13]] ^ in inv_mix_sub_columns()
483 x_time_d[state[14]] ^ x_time_9[state[15]]; in inv_mix_sub_columns()
484 tmp[1] = x_time_9[state[12]] ^ x_time_e[state[13]] ^ in inv_mix_sub_columns()
485 x_time_b[state[14]] ^ x_time_d[state[15]]; in inv_mix_sub_columns()
486 tmp[6] = x_time_d[state[12]] ^ x_time_9[state[13]] ^ in inv_mix_sub_columns()
487 x_time_e[state[14]] ^ x_time_b[state[15]]; in inv_mix_sub_columns()
488 tmp[11] = x_time_b[state[12]] ^ x_time_d[state[13]] ^ in inv_mix_sub_columns()
489 x_time_9[state[14]] ^ x_time_e[state[15]]; in inv_mix_sub_columns()
492 state[i] = inv_sbox[tmp[i]]; in inv_mix_sub_columns()
499 static void add_round_key(u32 *state, u32 *key) in add_round_key() argument
504 state[idx] ^= key[idx]; in add_round_key()
547 u8 state[AES_STATECOLS * 4]; in aes_encrypt() local
550 memcpy(state, in, AES_STATECOLS * 4); in aes_encrypt()
551 add_round_key((u32 *)state, (u32 *)expkey); in aes_encrypt()
555 mix_sub_columns(state); in aes_encrypt()
557 shift_rows(state); in aes_encrypt()
559 add_round_key((u32 *)state, in aes_encrypt()
563 memcpy(out, state, sizeof(state)); in aes_encrypt()
568 u8 state[AES_STATECOLS * 4]; in aes_decrypt() local
571 memcpy(state, in, sizeof(state)); in aes_decrypt()
573 add_round_key((u32 *)state, in aes_decrypt()
575 inv_shift_rows(state); in aes_decrypt()
578 add_round_key((u32 *)state, in aes_decrypt()
581 inv_mix_sub_columns(state); in aes_decrypt()
584 memcpy(out, state, sizeof(state)); in aes_decrypt()