void keys_generation(char *key) { // generating k1 p10_key_permutation(key); circular_left_shift(key_tmp); p8_key_permutation(key_tmp, 1); // generating k2 circular_left_shift(key_tmp); circular_left_shift(key_tmp); // repeated p8_key_permutation(key_tmp, 2); }
void MoveGenerator::add_pawn_attacks(class MoveList &list, const class Board &board, const int side){ const int diffs[2][2] = {{7, 64-9}, {9, 64-7}}; const U64 promotions_mask[2] = {ROW_8, ROW_1}; const U64 file_mask[2] = {~FILE_H, ~FILE_A}; U64 attacks, ep_attacks, promotions, targets, pawns, enemy; pawns = board.bitboards[side | PAWN]; enemy = board.bitboards[!side]; // CALCULATE ATTACKS FOR LEFT, RIGHT for (int dir = 0; dir < 2; dir++){ int diff = diffs[dir][side]; targets = circular_left_shift(pawns, diff) & file_mask[dir]; // ADD ATTACKS attacks = enemy & targets; add_moves_with_diff(diff, attacks & (~promotions_mask[side]), list, board, NO_FLAGS); // ADD EP ATTACKS ep_attacks = targets & (1ULL << board.irrev.ep_square); add_moves_with_diff(diff, ep_attacks, list, board, EP_CAPTURE | ((PAWN|(!side)) << 24)); // ADD PROMOTION ATTACKS promotions = attacks & promotions_mask[side]; add_promotions_with_diff(diff, promotions, list, board, side); } }
void MoveGenerator::add_pawn_pushes(class MoveList &list, const class Board &board, const int side){ const int diffs[2] = {8, 64-8}; const U64 promotions_mask[2] = {ROW_8, ROW_1}; const U64 start_row_plus_one_mask[2] = {ROW_3, ROW_6}; U64 pushes, double_pushes, promotions, pawns, free_squares; int diff = diffs[side]; pawns = board.bitboards[side | PAWN]; free_squares = ~(board.bitboards[WHITE] | board.bitboards[BLACK]); // ADD SINGLE PUSHES pushes = circular_left_shift(pawns, diff) & free_squares; add_moves_with_diff(diff, pushes & (~promotions_mask[side]), list, board, NO_FLAGS); // ADD PROMOTIONS promotions = pushes & promotions_mask[side]; add_promotions_with_diff(diff, promotions, list, board, side); // ADD DOUBLE PUSHES double_pushes = circular_left_shift(pushes & start_row_plus_one_mask[side], diff) & free_squares; add_moves_with_diff(diff+diff, double_pushes, list, board, PAWN_DOUBLE_PUSH); }
void calc_SHA(int *abcdef, int *words, SHAContext *con){ int i,inhash[5]; unsigned f = 0x00000000; unsigned k = 0x00000000; unsigned temp = 0x00000000; for(i = 0; i < 5; i++) inhash[i] = abcdef[i]; for( i = 0; i < 80; i++){ if(i < 20){ f = (inhash[3] ^ (inhash[1] & (inhash[2] ^ inhash[3]))); k = 0x5A827999; } else{ if(i >= 20 && i < 40){ f = inhash[1] ^ inhash[2] ^ inhash[3]; k = 0x6ED9EBA1; } else{ if(i >= 40 && i < 60){ f = (inhash[1] & inhash[2]) | (inhash[1] & inhash[3]) | (inhash[2] & inhash[3]); k = 0x8F1BBCDC; } else{ if(i >= 60 && i<80){ f = inhash[1] ^ inhash[2] ^ inhash[3]; k = 0xCA62C1D6; } } } } temp = circular_left_shift(inhash[0],5) + f + inhash[4] + k + words[i]; inhash[4] = inhash[3]; inhash[3] = inhash[2]; inhash[2] = circular_left_shift(inhash[1],30); inhash[1] = inhash[0]; inhash[0] = temp; } for( i = 0; i < 5; i++) con->Message_Digest[i] += inhash[i]; }
void init_words_remain(unsigned int *w){ int t; unsigned int temp; for( t = 16; t < 80; t++){ w[t] = (unsigned int)(w[t-3] ^ w[t-8] ^ w[t-14] ^ w[t-16]); if(t ==16) printf("spl: %d",w[t]); temp = (unsigned int)circular_left_shift(w[t],1); w[t] = (unsigned int) temp; if(t == 16) printf("spl1: %d",w[t]); } }