Mercurial > dropbear
view libtomcrypt/testprof/katja_test.c @ 466:f11544d96354
fix up after merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sun, 13 Jan 2008 04:02:08 +0000 |
parents | 0cbe8f6dbf9e |
children | f849a5ca2efc |
line wrap: on
line source
#include <tomcrypt_test.h> #ifdef MKAT int katja_test(void) { unsigned char in[1024], out[1024], tmp[1024]; katja_key key, privKey, pubKey; int hash_idx, prng_idx, stat, stat2, size; unsigned long kat_msgsize, len, len2, cnt; static unsigned char lparam[] = { 0x01, 0x02, 0x03, 0x04 }; hash_idx = find_hash("sha1"); prng_idx = find_prng("yarrow"); if (hash_idx == -1 || prng_idx == -1) { fprintf(stderr, "katja_test requires SHA1 and yarrow"); return 1; } for (size = 1024; size <= 2048; size += 256) { /* make 10 random key */ for (cnt = 0; cnt < 10; cnt++) { DO(katja_make_key(&yarrow_prng, prng_idx, size/8, &key)); if (mp_count_bits(key.N) < size - 7) { fprintf(stderr, "katja_%d key modulus has %d bits\n", size, mp_count_bits(key.N)); len = mp_unsigned_bin_size(key.N); mp_to_unsigned_bin(key.N, tmp); fprintf(stderr, "N == \n"); for (cnt = 0; cnt < len; ) { fprintf(stderr, "%02x ", tmp[cnt]); if (!(++cnt & 15)) fprintf(stderr, "\n"); } len = mp_unsigned_bin_size(key.p); mp_to_unsigned_bin(key.p, tmp); fprintf(stderr, "p == \n"); for (cnt = 0; cnt < len; ) { fprintf(stderr, "%02x ", tmp[cnt]); if (!(++cnt & 15)) fprintf(stderr, "\n"); } len = mp_unsigned_bin_size(key.q); mp_to_unsigned_bin(key.q, tmp); fprintf(stderr, "\nq == \n"); for (cnt = 0; cnt < len; ) { fprintf(stderr, "%02x ", tmp[cnt]); if (!(++cnt & 15)) fprintf(stderr, "\n"); }