Example #1
0
int main(int argc, char **argv)
{
    printf("Config: bits: %d, optimize mult: %d, use mul table: %d, use tables: %d\n",
           get_bits(), use_galois(), use_mul_table(), use_tables());

    kuz_key_t key;
    w128_t x;
    uint32_t buf[0x100];
    clock_t tim;

    kuz_init();

    self_test();

    // == Speed Test ==

    for (int i = 0; i < 0x100; i++)
        buf[i] = i;
    kuz_set_encrypt_key(&key, testvec_key);

    for (int n = 4000, tim = 0; tim < 2 * CLOCKS_PER_SEC; n <<= 1) {
        tim = clock();
        for (int j = 0; j < n; j++) {
            for (int i = 0; i < 0x100; i += 4)
                kuz_encrypt_block(&key, &buf[i]);
        }
        tim = clock() - tim;
        printf("kuz_encrypt_block(): %.3f kB/s (n=%dkB,t=%.3fs)\r",
               ((double) CLOCKS_PER_SEC * n) / ((double) tim),
               n, ((double) tim) / ((double) CLOCKS_PER_SEC));
        fflush(stdout);
    }
    printf("\n");


    for (int i = 0; i < 0x100; i++)
        buf[i] = i;
    kuz_set_decrypt_key(&key, testvec_key);

    for (int n = 4000, tim = 0; tim < 2 * CLOCKS_PER_SEC; n <<= 1) {
        tim = clock();
        for (int j = 0; j < n; j++) {
            for (int i = 0; i < 0x100; i += 4)
                kuz_decrypt_block(&key, &buf[i]);
        }
        tim = clock() - tim;
        printf("kuz_decrypt_block(): %.3f kB/s (n=%dkB,t=%.3fs)\r",
               ((double) CLOCKS_PER_SEC * n) / ((double) tim),
               n, ((double) tim) / ((double) CLOCKS_PER_SEC));
        fflush(stdout);
    }
    printf("\n");

    printf("Tables: %.1fK (encrypt: %.1fK, decrypt: %.1fK)\n", (float)get_used_memory_count() / 1024, (float)get_encrypt_used_memory_count() / 1024, (float)get_decrypt_used_memory_count() / 1024);


    return 0;
}
Example #2
0
 virtual void do_prepare(const TaskData &) override
 {
     kuz_init_tables();
     kuz_set_encrypt_key(&m_ctx, m_key.data());
 }
Example #3
0
void key_init() {
    kuz_set_encrypt_key(&encrypt_key, testvec_key);
    kuz_set_decrypt_key(&decrypt_key, testvec_key);
}