X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fcrypto%2Fxtea%2Ftest%2Frun.c;fp=ccan%2Fcrypto%2Fxtea%2Ftest%2Frun.c;h=35231f282c63baa952a7813e78e8cf466b6bd61b;hb=e5fb923ba3735c758ef795eb69d5ee1c6f0a94e9;hp=0000000000000000000000000000000000000000;hpb=c36444e062622d97e4368670f5c50f0c482a3a95;p=ccan diff --git a/ccan/crypto/xtea/test/run.c b/ccan/crypto/xtea/test/run.c new file mode 100644 index 00000000..35231f28 --- /dev/null +++ b/ccan/crypto/xtea/test/run.c @@ -0,0 +1,37 @@ +#include +/* Include the C files directly. */ +#include +#include +#include + +int main(void) +{ + uint64_t v, e; + struct xtea_secret s; + + /* This is how many tests you plan to run */ + plan_tests(66); + + memset(&s, 1, sizeof(s)); + + for (v = 1; v; v <<= 1) { + e = xtea_encipher(&s, v); + ok1(xtea_decipher(&s, e) == v); + } + + /* The only 32-iteration from the "test vectors" at + * http://www.cix.co.uk/~klockstone/teavect.htm: + * in=af20a390547571aa, N=32, k=27f917b1c1da899360e2acaaa6eb923d, out=d26428af0a202283 + */ + v = 0xaf20a390547571aaULL; + s.u.u32[0] = 0x27f917b1; + s.u.u32[1] = 0xc1da8993; + s.u.u32[2] = 0x60e2acaa; + s.u.u32[3] = 0xa6eb923d; + e = xtea_encipher(&s, v); + ok1(e == 0xd26428af0a202283ULL); + ok1(xtea_decipher(&s, e) == v); + + /* This exits depending on whether all tests passed */ + return exit_status(); +}