示例#1
0
/**
 * @buf - [in] msg input
 * @outbuf - [out] hash output
 */
static void get_hash(u08b_t *inbuf, u08b_t *outbuf)
{
        Skein1024_Ctxt_t ctx;

        Skein1024_Init(&ctx, 1024);
        Skein1024_Update(&ctx, inbuf, strlen((char *)inbuf));
        Skein1024_Final(&ctx, outbuf);
}
示例#2
0
int main(int argc, char *argv[]) {
    struct timeval tv;
    gettimeofday(&tv, NULL);

    srand(tv.tv_sec ^ tv.tv_usec + getpid() + (getppid() << 12));

    Skein1024_Ctxt_t ctx;
    uint8_t hash[128];
    int best = 1024;
    int current;
    time_t time_ref = time(NULL);
    int nhash = 0;

    int input_length = 0;
    char input[101];

    while (1) {

        // Only refresh the input with a new random value every so often
        if (nhash % INC_BEFORE_NEW == 0) {
            input_length = new_input(input);
        } else {
            inc_input(input, input_length);
        }
            

        Skein1024_Init(&ctx, 1024);
        Skein1024_Update(&ctx, (uint8_t *) input, input_length);
        Skein1024_Final(&ctx, hash);
        ++nhash;

        // Rate reporting
        // Overflow, stay accurate
        if (nhash == 0)
            time_ref = time(NULL);
        else if (nhash % HASH_BEFORE_REPORT == 0) {
            double khash = nhash / 1000.0;
            fprintf(stderr, "%f khash/s\n", khash / (double)(time(NULL) - time_ref));
        }

        current = bitdiff(hash, oracle);

        if (current < best) {
            best = current;
            printf("%d %s\n", best, input);
            fflush(stdout);
        }
    } 


    return 0;
}
示例#3
0
文件: bruteforce.c 项目: Gerst20051/C
static inline void checkHash() {
	assert(Skein1024_Init(&ctx, 1024) == SKEIN_SUCCESS);
	assert(Skein1024_Update(&ctx, plaintext, DEPTH) == SKEIN_SUCCESS);
	assert(Skein1024_Final(&ctx, hash) == SKEIN_SUCCESS);
	unsigned int bits_one = 0;
	for (unsigned int i = 0; i < 1024/8; i++) {
		u08b_t bits = hash[i] ^ XOR[i];
		for (unsigned char j = 0; j < 8; j++)
			bits_one += (bits >> j) & 1;
	}
	if (bits_one < low_bits) {
		low_bits = bits_one;
		fprintf(stdout, "New best: \"%s\" %d\n", plaintext, bits_one);
		fflush(stdout);
	}
//	count++; if (count > 10000000) exit(0);
}
示例#4
0
/* select the context size and init the context */
int Skein::Init(int hashbitlen)
    {
#if SKEIN_256_NIST_MAX_HASH_BITS
    if (hashbitlen <= SKEIN_256_NIST_MAX_HASHBITS)
        {
        Skein_Assert(hashbitlen > 0,BAD_HASHLEN);
        skeinState.statebits = 64*SKEIN_256_STATE_WORDS;
        return Skein_256_Init(&skeinState.u.ctx_256,(size_t) hashbitlen);
        }
#endif
    if (hashbitlen <= SKEIN_512_NIST_MAX_HASHBITS)
        {
        skeinState.statebits = 64*SKEIN_512_STATE_WORDS;
        return Skein_512_Init(&skeinState.u.ctx_512,(size_t) hashbitlen);
        }
    else
        {
        skeinState.statebits = 64*SKEIN1024_STATE_WORDS;
        return Skein1024_Init(&skeinState.u.ctx1024,(size_t) hashbitlen);
        }
    }
示例#5
0
文件: skein.c 项目: 2asoft/freebsd
void
SKEIN1024_Init(SKEIN1024_CTX * ctx)
{

	Skein1024_Init(ctx, 1024);
}