void encrypt(char *input, char *key) { initial_permutation(input); fk(output, k1); switch_halves(output); fk(output, k2); initial_permutation_inverse(output); }
void test_initial_permutation() { des_block_t mblock; mblock.c = 0x01234567; mblock.d = 0x89ABCDEF; des_block_t ip = initial_permutation(mblock); assert(ip.c == 0xCC00CCFF); assert(ip.d == 0xF0AAF0AA); }
int ora_hash_password(char *pass) { // secret hash function comes here, and written to char *hash int siz = 0; unsigned char *desresult; unsigned char *result; char buff[strlen(pass) + 5]; memset(buff, 0, sizeof(buff)); //concatenate Arb string and convert the resulting string to uppercase snprintf(buff, sizeof(buff), "Arb%s", pass); strupper(buff); if (initial_permutation(&result, buff, &siz)) { hydra_report(stderr, "[ERROR] ora_hash_password: in initial_permutation\n"); return 1; } if (convert_byteorder(&result, siz)) { hydra_report(stderr, "[ERROR] ora_hash_password: in convert_byteorder\n"); return 1; } if (ora_descrypt(&desresult, result, siz)) { hydra_report(stderr, "[ERROR] ora_hash_password: in DES crypt\n"); return 1; } free(result); if (ora_hash(&result, desresult, siz)) { hydra_report(stderr, "[ERROR] ora_hash_password: in extracting Oracle hash\n"); return 1; } memcpy(hash, result, HASHSIZE); free(desresult); free(result); return 0; }