static int skipjack_setkey(u_int8_t **sched, const u_int8_t *key, int len) { /* NB: allocate all the memory that's needed at once */ /* XXX assumes bytes are aligned on sizeof(u_char) == 1 boundaries. * Will this break a pdp-10, Cray-1, or GE-645 port? */ *sched = malloc(10 * (sizeof(u_int8_t *) + 0x100), M_CRYPTO_DATA, M_NOWAIT|M_ZERO); if (*sched == NULL) return ENOMEM; u_int8_t** key_tables = (u_int8_t**) *sched; u_int8_t* table = (u_int8_t*) &key_tables[10]; int k; for (k = 0; k < 10; k++) { key_tables[k] = table; table += 0x100; } subkey_table_gen(key, (u_int8_t **) *sched); return 0; }
static int skipjack_setkey(u_int8_t **sched, u_int8_t *key, int len) { int err; /* NB: allocate all the memory that's needed at once */ *sched = malloc(10 * (sizeof(u_int8_t *) + 0x100), M_CRYPTO_DATA, M_NOWAIT|M_ZERO); if (*sched != NULL) { u_int8_t** key_tables = (u_int8_t**) *sched; u_int8_t* table = (u_int8_t*) &key_tables[10]; int k; for (k = 0; k < 10; k++) { key_tables[k] = table; table += 0x100; } subkey_table_gen(key, (u_int8_t **) *sched); err = 0; } else err = ENOMEM; return err; }