/* * Copyright (c) 2008 Sebastiaan Indesteege * * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * Example collision pair for EnRUPT-256, using the defaults for the other * tunable parameters. This file should be linked with the reference * implementation of EnRUPT. * * 2008-11-06, Sebastiaan Indesteege, COSIC, Katholieke Universiteit Leuven */ #include "EnRUPT_ref.h" #include #include #include #define HASHBITLEN 256 #define LEN 48*8 static const uint8_t m1[] = { 0x13, 0xc8, 0x4b, 0x45, 0x62, 0x70, 0x17, 0x6e, 0x04, 0xf9, 0x31, 0x7e, 0xc3, 0x6c, 0xe7, 0xd3, 0xe1, 0x21, 0x78, 0x6a, 0x34, 0x74, 0x11, 0x19, 0x7f, 0x64, 0xa3, 0xc9, 0x40, 0x07, 0x75, 0x76, 0xa1, 0x4f, 0x90, 0x86, 0xfd, 0xc7, 0x33, 0x4a, 0x41, 0x3a, 0x76, 0x91, 0x96, 0x06, 0x2c, 0xa1 }; static const uint8_t m2[] = { 0x13, 0xc8, 0x4b, 0x45, 0x6a, 0x70, 0x17, 0x6e, 0x04, 0xf9, 0x31, 0x5c, 0x43, 0x6c, 0xe7, 0xd3, 0xe1, 0x21, 0x78, 0x48, 0xbc, 0x74, 0x11, 0x19, 0x7f, 0x64, 0xa3, 0xcb, 0x48, 0x07, 0x75, 0x76, 0xa1, 0x4f, 0x90, 0x84, 0xfd, 0xc7, 0x33, 0x4a, 0x41, 0x3a, 0x76, 0x93, 0x96, 0x06, 0x2c, 0xa1 }; uint8_t h1[HASHBITLEN/8]; uint8_t h2[HASHBITLEN/8]; void printbytes(uint8_t const *p, int n) { int i; for (i=0; i!=n; ++i) printf("%02x", p[i]); printf("\n"); } int main() { int i; printf("Example collision pair for EnRUPT-256\n"); printf("2008-11-06, Sebastiaan Indesteege, COSIC, Katholieke Universiteit Leuven\n\n"); /* Hash first mesage */ if (Hash(HASHBITLEN, m1, LEN, h1) != SUCCESS) errx(1, "Hashing failed!"); printf("m1 = "); printbytes(m1, LEN/8); printf("EnRUPT-256(m1) = "); printbytes(h1, HASHBITLEN/8); printf("\n"); /* Hash second mesage */ if (Hash(HASHBITLEN, m2, LEN, h2) != SUCCESS) errx(1, "Hashing failed!"); printf("m2 = "); printbytes(m2, LEN/8); printf("EnRUPT-256(m2) = "); printbytes(h2, HASHBITLEN/8); printf("\n"); /* Verify collision */ for (i=0; i!=32; ++i) { if (h1[i] != h2[i]) { printf("ERROR: m1 and m2 do NOT collide\n"); return 1; } } printf("m1 and m2 collide!\n\n"); return 0; }