+static
+void shift_columns(uint8_t* a, const uint8_t *shifts){
+ uint8_t tmp[8];
+ uint8_t i,j,s;
+ for(i=0; i<8; ++i){
+ s = *shifts++;
+ if(s==0){
+ continue;
+ }
+ for(j=0;j<8;++j){
+ tmp[j] = a[i+j*8];
+ }
+ for(j=0;j<8;++j){
+ a[i+((j-s+8)%8)*8] = tmp[j];
+ }
+ }
+}
+
+static const uint8_t p_shifts[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+static const uint8_t q_shifts[8] = { 1, 3, 5, 7, 0, 2, 4, 6 };
+
+static