#ifndef ROUND_H_ #define ROUND_H_ #include "ascon.h" #include "printstate.h" forceinline void ROUND_LOOP(state_t* s, uint32_t C) { uint32_t tmp0, tmp1; __asm__ __volatile__( "@.syntax_unified\n\t" "rbegin_%=:;\n\t" "eor %[x2_l], %[x2_l], %[tmp1]\n\t" "push {%[tmp1]}\n\t" "eor %[x0_l], %[x0_l], %[x4_l]\n\t" "eor %[x4_l], %[x4_l], %[x3_l]\n\t" "eor %[x2_l], %[x2_l], %[x1_l]\n\t" "mvn %[tmp0], %[x0_l]\n\t" "orr %[tmp0], %[tmp0], %[x4_l]\n\t" "movs %[tmp1], %[x2_l]\n\t" "bic %[tmp1], %[tmp1], %[x1_l]\n\t" "eor %[x0_l], %[x0_l], %[tmp1]\n\t" "mvn %[tmp1], %[x4_l]\n\t" "orr %[tmp1], %[tmp1], %[x3_l]\n\t" "eor %[x2_l], %[x2_l], %[tmp1]\n\t" "movs %[tmp1], %[x1_l]\n\t" "bic %[tmp1], %[tmp1], %[x0_l]\n\t" "eor %[x4_l], %[x4_l], %[tmp1]\n\t" "movs %[tmp1], %[x3_l]\n\t" "and %[tmp1], %[tmp1], %[x2_l]\n\t" "eor %[tmp1], %[x1_l], %[tmp1]\n\t" "eor %[tmp0], %[x3_l], %[tmp0]\n\t" "eor %[tmp0], %[tmp0], %[x2_l]\n\t" "eor %[tmp1], %[tmp1], %[x0_l]\n\t" "eor %[x0_l], %[x0_l], %[x4_l]\n\t" "movs %[x1_l], %[x0_h]\n\t" "movs %[x3_l], %[x1_h]\n\t" "movs %[x0_h], %[x2_l]\n\t" "movs %[x1_h], %[x0_l]\n\t" "movs %[x0_l], %[x2_h]\n\t" "movs %[x2_l], %[x3_h]\n\t" "movs %[tmp2], %[x4_h]\n\t" "movs %[x2_h], %[tmp0]\n\t" "movs %[x3_h], %[x4_l]\n\t" "eor %[x1_l], %[x1_l], %[tmp2]\n\t" "eor %[tmp2], %[tmp2], %[x2_l]\n\t" "eor %[x0_l], %[x0_l], %[x3_l]\n\t" "mvn %[tmp0], %[x1_l]\n\t" "orr %[tmp0], %[tmp0], %[tmp2]\n\t" "movs %[x4_l], %[x0_l]\n\t" "bic %[x4_l], %[x4_l], %[x3_l]\n\t" "eor %[x1_l], %[x1_l], %[x4_l]\n\t" "mvn %[x4_l], %[tmp2]\n\t" "orr %[x4_l], %[x4_l], %[x2_l]\n\t" "eor %[x0_l], %[x0_l], %[x4_l]\n\t" "movs %[x4_l], %[x3_l]\n\t" "bic %[x4_l], %[x4_l], %[x1_l]\n\t" "eor %[tmp2], %[tmp2], %[x4_l]\n\t" "movs %[x4_l], %[x2_l]\n\t" "and %[x4_l], %[x4_l], %[x0_l]\n\t" "eor %[x3_l], %[x3_l], %[x4_l]\n\t" "eor %[x2_l], %[x2_l], %[tmp0]\n\t" "eor %[x2_l], %[x2_l], %[x0_l]\n\t" "eor %[x3_l], %[x3_l], %[x1_l]\n\t" "eor %[x1_l], %[x1_l], %[tmp2]\n\t" "movs %[x4_h], %[x2_l]\n\t" "movs %[x2_l], %[x0_h]\n\t" "movs %[x0_h], %[x1_l]\n\t" "lsr %[x4_l], %[x0_l], #6\n\t" "lsl %[x1_l], %[x2_l], #26\n\t" "lsr %[tmp0], %[x2_l], #6\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsl %[x1_l], %[x0_l], #26\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsr %[x1_l], %[x0_l], #1\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsl %[x1_l], %[x2_l], #31\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsr %[x1_l], %[x2_l], #1\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsl %[x1_l], %[x0_l], #31\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "eor %[x0_l], %[x0_l], %[x4_l]\n\t" "eor %[x2_l], %[x2_l], %[tmp0]\n\t" "lsl %[x4_l], %[x3_l], #3\n\t" "lsr %[x1_l], %[tmp1], #29\n\t" "lsl %[tmp0], %[tmp1], #3\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsr %[x1_l], %[x3_l], #29\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsl %[x1_l], %[x3_l], #25\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsr %[x1_l], %[tmp1], #7\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsl %[x1_l], %[tmp1], #25\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsr %[x1_l], %[x3_l], #7\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "eor %[x3_l], %[x3_l], %[x4_l]\n\t" "eor %[tmp1], %[tmp1], %[tmp0]\n\t" "movs %[x4_l], %[x3_h]\n\t" "movs %[x3_h], %[tmp1]\n\t" "lsl %[tmp1], %[tmp2], #23\n\t" "lsr %[x1_l], %[x4_l], #9\n\t" "lsl %[tmp0], %[x4_l], #23\n\t" "eor %[tmp1], %[tmp1], %[x1_l]\n\t" "lsr %[x1_l], %[tmp2], #9\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsr %[x1_l], %[tmp2], #7\n\t" "eor %[tmp1], %[tmp1], %[x1_l]\n\t" "lsl %[x1_l], %[x4_l], #25\n\t" "eor %[tmp1], %[tmp1], %[x1_l]\n\t" "lsr %[x1_l], %[x4_l], #7\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsl %[x1_l], %[tmp2], #25\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "eor %[tmp2], %[tmp2], %[tmp1]\n\t" "eor %[x4_l], %[x4_l], %[tmp0]\n\t" "movs %[x1_l], %[x3_h]\n\t" "movs %[tmp1], %[x4_h]\n\t" "movs %[x4_h], %[tmp2]\n\t" "movs %[x3_h], %[x3_l]\n\t" "movs %[x3_l], %[x2_h]\n\t" "movs %[x2_h], %[x0_l]\n\t" "lsr %[tmp2], %[tmp1], #17\n\t" "lsl %[x0_l], %[x3_l], #15\n\t" "lsr %[tmp0], %[x3_l], #17\n\t" "eor %[tmp2], %[tmp2], %[x0_l]\n\t" "lsl %[x0_l], %[tmp1], #15\n\t" "eor %[tmp0], %[tmp0], %[x0_l]\n\t" "lsr %[x0_l], %[tmp1], #10\n\t" "eor %[tmp2], %[tmp2], %[x0_l]\n\t" "lsl %[x0_l], %[x3_l], #22\n\t" "eor %[tmp2], %[tmp2], %[x0_l]\n\t" "lsr %[x0_l], %[x3_l], #10\n\t" "eor %[tmp0], %[tmp0], %[x0_l]\n\t" "lsl %[x0_l], %[tmp1], #22\n\t" "eor %[tmp0], %[tmp0], %[x0_l]\n\t" "eor %[tmp1], %[tmp1], %[tmp2]\n\t" "eor %[x3_l], %[x3_l], %[tmp0]\n\t" "movs %[tmp0], %[x0_h]\n\t" "movs %[x0_l], %[x1_h]\n\t" "movs %[x0_h], %[x4_l]\n\t" "movs %[x1_h], %[x3_h]\n\t" "movs %[x3_h], %[tmp1]\n\t" "lsr %[x4_l], %[tmp0], #28\n\t" "lsl %[tmp1], %[x0_l], #4\n\t" "lsr %[tmp2], %[x0_l], #28\n\t" "eor %[x4_l], %[x4_l], %[tmp1]\n\t" "lsl %[tmp1], %[tmp0], #4\n\t" "eor %[tmp2], %[tmp2], %[tmp1]\n\t" "lsr %[tmp1], %[tmp0], #19\n\t" "eor %[x4_l], %[x4_l], %[tmp1]\n\t" "lsl %[tmp1], %[x0_l], #13\n\t" "eor %[x4_l], %[x4_l], %[tmp1]\n\t" "lsr %[tmp1], %[x0_l], #19\n\t" "eor %[tmp2], %[tmp2], %[tmp1]\n\t" "lsl %[tmp1], %[tmp0], #13\n\t" "eor %[tmp2], %[tmp2], %[tmp1]\n\t" "pop {%[tmp1]}\n\t" "eor %[tmp0], %[tmp0], %[x4_l]\n\t" "eor %[x0_l], %[x0_l], %[tmp2]\n\t" "movs %[x4_l], %[x0_h]\n\t" "movs %[x0_h], %[tmp0]\n\t" "sub %[tmp1], %[tmp1], #15\n\t" "cmp %[tmp1], #60\n\t" "beq rend_%=\n\t" "b rbegin_%=\n\t" "rend_%=:;\n\t" : [ x0_l ] "+l"(s->w[0][0]), [ x0_h ] "+r"(s->w[0][1]), [ x1_l ] "+l"(s->w[1][0]), [ x1_h ] "+r"(s->w[1][1]), [ x2_l ] "+l"(s->w[2][0]), [ x2_h ] "+r"(s->w[2][1]), [ x3_l ] "+l"(s->w[3][0]), [ x3_h ] "+r"(s->w[3][1]), [ x4_l ] "+l"(s->w[4][0]), [ x4_h ] "+r"(s->w[4][1]), [ tmp1 ] "+l"(C), [ tmp0 ] "=l"(tmp0), [ tmp2 ] "=l"(tmp1) : :); } forceinline void ROUND(state_t* s, uint32_t C) { uint32_t tmp0, tmp1, tmp2; __asm__ __volatile__( "@.syntax_unified\n\t" "movs %[tmp0], %[C]\n\t" "eor %[x2_l], %[x2_l], %[tmp0]\n\t" "eor %[x0_l], %[x0_l], %[x4_l]\n\t" "eor %[x4_l], %[x4_l], %[x3_l]\n\t" "eor %[x2_l], %[x2_l], %[x1_l]\n\t" "mvn %[tmp0], %[x0_l]\n\t" "orr %[tmp0], %[tmp0], %[x4_l]\n\t" "movs %[tmp1], %[x2_l]\n\t" "bic %[tmp1], %[tmp1], %[x1_l]\n\t" "eor %[x0_l], %[x0_l], %[tmp1]\n\t" "mvn %[tmp1], %[x4_l]\n\t" "orr %[tmp1], %[tmp1], %[x3_l]\n\t" "eor %[x2_l], %[x2_l], %[tmp1]\n\t" "movs %[tmp1], %[x1_l]\n\t" "bic %[tmp1], %[tmp1], %[x0_l]\n\t" "eor %[x4_l], %[x4_l], %[tmp1]\n\t" "movs %[tmp1], %[x3_l]\n\t" "and %[tmp1], %[tmp1], %[x2_l]\n\t" "eor %[tmp1], %[x1_l], %[tmp1]\n\t" "eor %[tmp0], %[x3_l], %[tmp0]\n\t" "eor %[tmp0], %[tmp0], %[x2_l]\n\t" "eor %[tmp1], %[tmp1], %[x0_l]\n\t" "eor %[x0_l], %[x0_l], %[x4_l]\n\t" "movs %[x1_l], %[x0_h]\n\t" "movs %[x3_l], %[x1_h]\n\t" "movs %[x0_h], %[x2_l]\n\t" "movs %[x1_h], %[x0_l]\n\t" "movs %[x0_l], %[x2_h]\n\t" "movs %[x2_l], %[x3_h]\n\t" "movs %[tmp2], %[x4_h]\n\t" "movs %[x2_h], %[tmp0]\n\t" "movs %[x3_h], %[x4_l]\n\t" "eor %[x1_l], %[x1_l], %[tmp2]\n\t" "eor %[tmp2], %[tmp2], %[x2_l]\n\t" "eor %[x0_l], %[x0_l], %[x3_l]\n\t" "mvn %[tmp0], %[x1_l]\n\t" "orr %[tmp0], %[tmp0], %[tmp2]\n\t" "movs %[x4_l], %[x0_l]\n\t" "bic %[x4_l], %[x4_l], %[x3_l]\n\t" "eor %[x1_l], %[x1_l], %[x4_l]\n\t" "mvn %[x4_l], %[tmp2]\n\t" "orr %[x4_l], %[x4_l], %[x2_l]\n\t" "eor %[x0_l], %[x0_l], %[x4_l]\n\t" "movs %[x4_l], %[x3_l]\n\t" "bic %[x4_l], %[x4_l], %[x1_l]\n\t" "eor %[tmp2], %[tmp2], %[x4_l]\n\t" "movs %[x4_l], %[x2_l]\n\t" "and %[x4_l], %[x4_l], %[x0_l]\n\t" "eor %[x3_l], %[x3_l], %[x4_l]\n\t" "eor %[x2_l], %[x2_l], %[tmp0]\n\t" "eor %[x2_l], %[x2_l], %[x0_l]\n\t" "eor %[x3_l], %[x3_l], %[x1_l]\n\t" "eor %[x1_l], %[x1_l], %[tmp2]\n\t" "movs %[x4_h], %[x2_l]\n\t" "movs %[x2_l], %[x0_h]\n\t" "movs %[x0_h], %[x1_l]\n\t" "lsr %[x4_l], %[x0_l], #6\n\t" "lsl %[x1_l], %[x2_l], #26\n\t" "lsr %[tmp0], %[x2_l], #6\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsl %[x1_l], %[x0_l], #26\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsr %[x1_l], %[x0_l], #1\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsl %[x1_l], %[x2_l], #31\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsr %[x1_l], %[x2_l], #1\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsl %[x1_l], %[x0_l], #31\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "eor %[x0_l], %[x0_l], %[x4_l]\n\t" "eor %[x2_l], %[x2_l], %[tmp0]\n\t" "lsl %[x4_l], %[x3_l], #3\n\t" "lsr %[x1_l], %[tmp1], #29\n\t" "lsl %[tmp0], %[tmp1], #3\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsr %[x1_l], %[x3_l], #29\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsl %[x1_l], %[x3_l], #25\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsr %[x1_l], %[tmp1], #7\n\t" "eor %[x4_l], %[x4_l], %[x1_l]\n\t" "lsl %[x1_l], %[tmp1], #25\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsr %[x1_l], %[x3_l], #7\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "eor %[x3_l], %[x3_l], %[x4_l]\n\t" "eor %[tmp1], %[tmp1], %[tmp0]\n\t" "movs %[x4_l], %[x3_h]\n\t" "movs %[x3_h], %[tmp1]\n\t" "lsl %[tmp1], %[tmp2], #23\n\t" "lsr %[x1_l], %[x4_l], #9\n\t" "lsl %[tmp0], %[x4_l], #23\n\t" "eor %[tmp1], %[tmp1], %[x1_l]\n\t" "lsr %[x1_l], %[tmp2], #9\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsr %[x1_l], %[tmp2], #7\n\t" "eor %[tmp1], %[tmp1], %[x1_l]\n\t" "lsl %[x1_l], %[x4_l], #25\n\t" "eor %[tmp1], %[tmp1], %[x1_l]\n\t" "lsr %[x1_l], %[x4_l], #7\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "lsl %[x1_l], %[tmp2], #25\n\t" "eor %[tmp0], %[tmp0], %[x1_l]\n\t" "eor %[tmp2], %[tmp2], %[tmp1]\n\t" "eor %[x4_l], %[x4_l], %[tmp0]\n\t" "movs %[x1_l], %[x3_h]\n\t" "movs %[tmp1], %[x4_h]\n\t" "movs %[x4_h], %[tmp2]\n\t" "movs %[x3_h], %[x3_l]\n\t" "movs %[x3_l], %[x2_h]\n\t" "movs %[x2_h], %[x0_l]\n\t" "lsr %[tmp2], %[tmp1], #17\n\t" "lsl %[x0_l], %[x3_l], #15\n\t" "lsr %[tmp0], %[x3_l], #17\n\t" "eor %[tmp2], %[tmp2], %[x0_l]\n\t" "lsl %[x0_l], %[tmp1], #15\n\t" "eor %[tmp0], %[tmp0], %[x0_l]\n\t" "lsr %[x0_l], %[tmp1], #10\n\t" "eor %[tmp2], %[tmp2], %[x0_l]\n\t" "lsl %[x0_l], %[x3_l], #22\n\t" "eor %[tmp2], %[tmp2], %[x0_l]\n\t" "lsr %[x0_l], %[x3_l], #10\n\t" "eor %[tmp0], %[tmp0], %[x0_l]\n\t" "lsl %[x0_l], %[tmp1], #22\n\t" "eor %[tmp0], %[tmp0], %[x0_l]\n\t" "eor %[tmp1], %[tmp1], %[tmp2]\n\t" "eor %[x3_l], %[x3_l], %[tmp0]\n\t" "movs %[tmp0], %[x0_h]\n\t" "movs %[x0_l], %[x1_h]\n\t" "movs %[x0_h], %[x4_l]\n\t" "movs %[x1_h], %[x3_h]\n\t" "movs %[x3_h], %[tmp1]\n\t" "lsr %[x4_l], %[tmp0], #28\n\t" "lsl %[tmp1], %[x0_l], #4\n\t" "lsr %[tmp2], %[x0_l], #28\n\t" "eor %[x4_l], %[x4_l], %[tmp1]\n\t" "lsl %[tmp1], %[tmp0], #4\n\t" "eor %[tmp2], %[tmp2], %[tmp1]\n\t" "lsr %[tmp1], %[tmp0], #19\n\t" "eor %[x4_l], %[x4_l], %[tmp1]\n\t" "lsl %[tmp1], %[x0_l], #13\n\t" "eor %[x4_l], %[x4_l], %[tmp1]\n\t" "lsr %[tmp1], %[x0_l], #19\n\t" "eor %[tmp2], %[tmp2], %[tmp1]\n\t" "lsl %[tmp1], %[tmp0], #13\n\t" "eor %[tmp2], %[tmp2], %[tmp1]\n\t" "eor %[tmp0], %[tmp0], %[x4_l]\n\t" "eor %[x0_l], %[x0_l], %[tmp2]\n\t" "movs %[x4_l], %[x0_h]\n\t" "movs %[x0_h], %[tmp0]\n\t" : [ x0_l ] "+l"(s->w[0][0]), [ x0_h ] "+r"(s->w[0][1]), [ x1_l ] "+l"(s->w[1][0]), [ x1_h ] "+r"(s->w[1][1]), [ x2_l ] "+l"(s->w[2][0]), [ x2_h ] "+r"(s->w[2][1]), [ x3_l ] "+l"(s->w[3][0]), [ x3_h ] "+r"(s->w[3][1]), [ x4_l ] "+l"(s->w[4][0]), [ x4_h ] "+r"(s->w[4][1]), [ tmp0 ] "=l"(tmp0), [ tmp1 ] "=l"(tmp1), [ tmp2 ] "=l"(tmp2) : [ C ] "ri"(C) :); printstate(" round output", s); } forceinline void PROUNDS(state_t* s, int nr) { ROUND_LOOP(s, START(nr)); } #endif /* ROUND_H_ */