static void tiger_drv_output(ErlDrvData handle, char *buff, int bufflen) { tiger_data* d = (tiger_data*)handle; uint64_t tiger_res[3]; tiger((uint64_t*) buff, bufflen, (uint64_t*) tiger_res); driver_output(d->port, tiger_res, 24); }
static PyObject* tiger_digest(tiger_TigerObject* self, PyObject* args) { word64 result[3]; char* message = self->message; unsigned long long int msize = self->msize; tiger((word64*)message, msize, &result); return PyString_FromStringAndSize((char*)result, 24); }
// Tiger static dword func4(dword aKey) { dword res[6] = { 0 }; dword str[16] = { 0 }; str[1] = aKey; tiger(str, 64, res); return res[2]; }
static void tt_internal_hash(const struct tth *a, const struct tth *b, struct tth *dst) { union { guint64 u64; /* Better alignment */ char bytes[TIGERSIZE * 2 + 1]; } buf; buf.bytes[0] = 0x01; memcpy(&buf.bytes[1 + 0 * TIGERSIZE], a, TIGERSIZE); memcpy(&buf.bytes[1 + 1 * TIGERSIZE], b, TIGERSIZE); tiger(buf.bytes, sizeof buf.bytes, dst->data); }
/* * This will generate the same challenge to the same user, always. * The challenge is made up of the time of the user connected * seconds since the unix epoch (modulus 1 million) * and the SID of the user (0-1 million). */ const char* acl_password_generate_challenge(struct hub_info* hub, struct hub_user* user) { char buf[64]; uint64_t tiger_res[3]; static char tiger_buf[MAX_CID_LEN+1]; // FIXME: Generate a better nonce scheme. snprintf(buf, 64, "%p%d%d", user, (int) user->id.sid, (int) net_con_get_sd(user->connection)); tiger((uint64_t*) buf, strlen(buf), (uint64_t*) tiger_res); base32_encode((unsigned char*) tiger_res, TIGERSIZE, tiger_buf); tiger_buf[MAX_CID_LEN] = 0; return (const char*) tiger_buf; }
static void adc_cid_pid(struct ADC_client* client) { ADC_TRACE; char seed[64]; char pid[64]; char cid[64]; uint64_t tiger_res1[3]; uint64_t tiger_res2[3]; /* create cid+pid pair */ memset(seed, 0, 64); snprintf(seed, 64, VERSION "%p", client); tiger((uint64_t*) seed, strlen(seed), tiger_res1); base32_encode((unsigned char*) tiger_res1, TIGERSIZE, pid); tiger((uint64_t*) tiger_res1, TIGERSIZE, tiger_res2); base32_encode((unsigned char*) tiger_res2, TIGERSIZE, cid); cid[ADC_CID_SIZE] = 0; pid[ADC_CID_SIZE] = 0; adc_msg_add_named_argument(client->info, ADC_INF_FLAG_PRIVATE_ID, pid); adc_msg_add_named_argument(client->info, ADC_INF_FLAG_CLIENT_ID, cid); }
static int check_hash_tiger(const char* cid, const char* pid) { char x_pid[64]; char raw_pid[64]; uint64_t tiger_res[3]; memset(x_pid, 0, MAX_CID_LEN+1); base32_decode(pid, (unsigned char*) raw_pid, MAX_CID_LEN); tiger((uint64_t*) raw_pid, TIGERSIZE, (uint64_t*) tiger_res); base32_encode((unsigned char*) tiger_res, TIGERSIZE, x_pid); x_pid[MAX_CID_LEN] = 0; if (strncasecmp(x_pid, cid, MAX_CID_LEN) == 0) return 1; return 0; }
int acl_password_verify(struct hub_info* hub, struct hub_user* user, const char* password) { char buf[1024]; struct auth_info* access; const char* challenge; char raw_challenge[64]; char password_calc[64]; uint64_t tiger_res[3]; size_t password_len; if (!password || !user || strlen(password) != MAX_CID_LEN) return 0; access = acl_get_access_info(hub, user->id.nick); if (!access) return 0; challenge = acl_password_generate_challenge(hub, user); base32_decode(challenge, (unsigned char*) raw_challenge, MAX_CID_LEN); password_len = strlen(access->password); memcpy(&buf[0], access->password, password_len); memcpy(&buf[password_len], raw_challenge, TIGERSIZE); tiger((uint64_t*) buf, TIGERSIZE+password_len, (uint64_t*) tiger_res); base32_encode((unsigned char*) tiger_res, TIGERSIZE, password_calc); password_calc[MAX_CID_LEN] = 0; #ifdef PLUGIN_SUPPORT hub_free(access); #endif if (strcasecmp(password, password_calc) == 0) { return 1; } return 0; }
static void tt_block(TTH_CONTEXT *ctx) { g_assert(ctx); tiger(ctx->block.bytes, ctx->block_fill, ctx->stack[ctx->si].data); if (ctx->bpl == 1) { ctx->leaves[ctx->li] = ctx->stack[ctx->si]; ctx->li++; } ctx->block_fill = 1; ctx->si++; ctx->n++; if (ctx->n > (1U << ctx->depth)) { ctx->depth++; } tt_collapse(ctx); }
/** * Runs some test cases to check whether the implementation of the tiger * hash algorithm is alright. */ G_GNUC_COLD void tiger_check(void) { static const char zeros[1025]; static const struct { const char *r; const char *s; size_t len; } tests[] = { { "QMLU34VTTAIWJQM5RVN4RIQKRM2JWIFZQFDYY3Y", "\0" "1", 2 }, { "LWPNACQDBZRYXW3VHJVCJ64QBZNGHOHHHZWCLNQ", zeros, 1 }, { "VK54ZIEEVTWNAUI5D5RDFIL37LX2IQNSTAXFKSA", zeros, 2 }, { "KIU5YUNESS4RH6HAJRGHFHETZOFSMDFE52HKTVY", zeros, 8 }, { "Z5PUAX6MEZB6EWYXFCSLMMUMZEFIQPOEWX3BA6Q", zeros, 255 }, { "D6UXHPOSAGHITCD4VVRHJQ4PCKIWY2WEHPJOUWY", zeros, 1024 }, { "CMKDYROZKSC6VTM4I7LSMMHPAE4UG3FXPXZGGKY", zeros, sizeof zeros }, }; guint i; for (i = 0; i < G_N_ELEMENTS(tests); i++) { char hash[24]; char buf[40]; gboolean ok; ZERO(&buf); tiger(tests[i].s, tests[i].len, hash); base32_encode(buf, sizeof buf, hash, sizeof hash); buf[G_N_ELEMENTS(buf) - 1] = '\0'; ok = 0 == strcmp(tests[i].r, buf); if (!ok) { g_warning("i=%u, buf=\"%s\"", i, buf); g_assert_not_reached(); } } }
void _tiger(const void * data, unsigned dlen, unsigned char * hval) { tiger((word64*)data, dlen, (void*)hval); }