diff --git a/halfsiphash.c b/halfsiphash.c index 74d7517..877f62f 100644 --- a/halfsiphash.c +++ b/halfsiphash.c @@ -124,7 +124,7 @@ int halfsiphash(const uint8_t *in, const size_t inlen, const uint8_t *k, uint8_t v0 ^= b; - if (outlen == 16) v2 ^= 0xee; + if (outlen == 8) v2 ^= 0xee; else v2 ^= 0xff; TRACE; diff --git a/test.c b/test.c index 0991320..f11200e 100644 --- a/test.c +++ b/test.c @@ -237,70 +237,70 @@ const uint8_t vectors_halfsip32[MAXLEN][4] = const uint8_t vectors_halfsip64[MAXLEN][8] = { - { 0xb8, 0x62, 0x84, 0x3a, 0x86, 0x64, 0x73, 0xae }, - { 0xe0, 0xe2, 0xb6, 0xd2, 0x21, 0x57, 0xd5, 0x75 }, - { 0x67, 0xde, 0x38, 0xbf, 0xc4, 0xb2, 0x44, 0xd4 }, - { 0x3c, 0xe0, 0x26, 0x24, 0x27, 0xf9, 0xcc, 0x24 }, - { 0x33, 0xb2, 0xf3, 0x0a, 0xce, 0x59, 0xa2, 0xf5 }, - { 0xca, 0x79, 0x45, 0x60, 0x6d, 0x15, 0xa6, 0xd0 }, - { 0xa7, 0xdf, 0x19, 0x39, 0x12, 0xdc, 0xc5, 0xf9 }, - { 0xa7, 0xfd, 0x3d, 0xe1, 0x27, 0x7b, 0xf6, 0xe3 }, - { 0x70, 0xc9, 0x51, 0x15, 0xc6, 0x00, 0x15, 0x03 }, - { 0x65, 0x4b, 0x0c, 0x2d, 0x10, 0xa0, 0x3d, 0x45 }, - { 0x31, 0x76, 0x92, 0x4f, 0x01, 0xdd, 0x29, 0x99 }, - { 0x27, 0x96, 0x5d, 0x92, 0xd1, 0x33, 0x59, 0x30 }, - { 0xd2, 0x8b, 0xcf, 0xc9, 0x31, 0x42, 0x51, 0xe8 }, - { 0xd8, 0x82, 0x3e, 0x37, 0xb4, 0x15, 0xfa, 0x43 }, - { 0x46, 0xe5, 0x13, 0xd6, 0x86, 0xa8, 0xde, 0x4e }, - { 0x04, 0x26, 0x89, 0x09, 0xcb, 0x1f, 0x7f, 0xf4 }, - { 0xc7, 0x8e, 0xab, 0x4f, 0x6c, 0x9a, 0x2b, 0xad }, - { 0xf0, 0x42, 0xd8, 0xf5, 0xf9, 0x8e, 0x43, 0xa4 }, - { 0x13, 0x7b, 0x2c, 0x31, 0xc9, 0x77, 0x7f, 0x31 }, - { 0x4c, 0x5b, 0x8d, 0xb5, 0xcc, 0x8b, 0x3f, 0x1e }, - { 0x56, 0xaa, 0xcf, 0xb6, 0x97, 0x85, 0xd3, 0xa6 }, - { 0xb7, 0x22, 0x8d, 0x6f, 0x7a, 0x40, 0x6e, 0x5b }, - { 0xcc, 0x84, 0x85, 0x75, 0x2d, 0x5a, 0x22, 0xcf }, - { 0xed, 0xec, 0x84, 0x7d, 0xc5, 0xad, 0x2a, 0x92 }, - { 0xd8, 0xfa, 0xba, 0x0b, 0xdc, 0x46, 0x36, 0xc1 }, - { 0x52, 0x88, 0x3f, 0x23, 0x2b, 0x74, 0xd7, 0x7f }, - { 0x8f, 0xb5, 0xe1, 0xd6, 0xc6, 0x5d, 0xf4, 0x06 }, - { 0xbe, 0x18, 0xd7, 0xb0, 0xa1, 0xec, 0xcd, 0xba }, - { 0x4f, 0xd7, 0x0f, 0xdf, 0x14, 0x85, 0x20, 0x44 }, - { 0xf1, 0xce, 0x14, 0x1b, 0x30, 0x1d, 0xd1, 0x2a }, - { 0x98, 0x32, 0x38, 0xda, 0x09, 0xb0, 0x0b, 0xef }, - { 0x25, 0xa4, 0x5e, 0xf9, 0xc5, 0xc7, 0x13, 0x24 }, - { 0x76, 0xb1, 0xdf, 0xec, 0xcd, 0x56, 0x37, 0xd4 }, - { 0xe0, 0xca, 0xfc, 0x7b, 0x89, 0xba, 0x55, 0x21 }, - { 0xc3, 0x61, 0xbe, 0xa1, 0x78, 0x53, 0x14, 0x04 }, - { 0x1f, 0xb3, 0x6e, 0x12, 0x77, 0x06, 0x12, 0x1f }, - { 0xb2, 0xc5, 0x0e, 0x7a, 0x24, 0x35, 0xfc, 0x05 }, - { 0x87, 0xa2, 0x2b, 0xc6, 0xec, 0x73, 0x69, 0x29 }, - { 0xee, 0x92, 0x71, 0x74, 0xfe, 0x9d, 0x67, 0x61 }, - { 0xa3, 0x8e, 0xc9, 0xdd, 0xf4, 0x4b, 0xec, 0xc0 }, - { 0x37, 0x17, 0x99, 0x3c, 0xbc, 0xa1, 0x29, 0x09 }, - { 0x63, 0x94, 0xed, 0xf0, 0x15, 0x7e, 0xa7, 0xae }, - { 0x25, 0xe8, 0x93, 0x60, 0xef, 0x3d, 0xae, 0x45 }, - { 0x62, 0x1f, 0xf6, 0xd8, 0x56, 0x46, 0x9b, 0x21 }, - { 0x6b, 0xf2, 0xf9, 0x8b, 0x8f, 0x85, 0xee, 0x7a }, - { 0xb4, 0x62, 0x03, 0xe7, 0xdf, 0x69, 0x2b, 0xea }, - { 0x77, 0xf1, 0x25, 0xfb, 0x38, 0x89, 0xa2, 0xe2 }, - { 0x72, 0xb7, 0x0d, 0xa6, 0xc9, 0x1a, 0x0c, 0x1c }, - { 0x47, 0x2c, 0xe2, 0xa9, 0xa1, 0x7d, 0x3f, 0x8a }, - { 0x47, 0x1d, 0x2f, 0x9a, 0x3b, 0xaa, 0x0e, 0x3e }, - { 0xfc, 0x95, 0x2a, 0xa5, 0x4a, 0xd8, 0xb3, 0x99 }, - { 0x28, 0xf5, 0x7f, 0xcd, 0x2f, 0xc1, 0x83, 0x56 }, - { 0x24, 0xd2, 0xe6, 0x15, 0x9f, 0xae, 0xf6, 0x94 }, - { 0xd9, 0xb5, 0x0d, 0x34, 0x88, 0xdd, 0xd8, 0x58 }, - { 0xa7, 0xc6, 0xbf, 0x4e, 0x05, 0xb5, 0x5c, 0x54 }, - { 0x60, 0x33, 0xe4, 0xcf, 0xe1, 0xcf, 0xdf, 0x71 }, - { 0xc1, 0x7e, 0x6d, 0x72, 0xda, 0xd1, 0xd0, 0x3a }, - { 0x14, 0xd7, 0xd5, 0xe2, 0x06, 0xc8, 0x93, 0x0e }, - { 0x65, 0xb8, 0x91, 0xe4, 0x0a, 0x52, 0xb8, 0x94 }, - { 0x4b, 0x72, 0x77, 0xc0, 0x5d, 0x84, 0x92, 0x50 }, - { 0x03, 0xb9, 0x51, 0x4a, 0x9f, 0xd6, 0xba, 0xd2 }, - { 0x2e, 0xc7, 0x23, 0x2f, 0xbe, 0xe1, 0xcd, 0x29 }, - { 0xb3, 0xa7, 0xb7, 0x4a, 0x40, 0x0d, 0xf9, 0xdc }, - { 0xec, 0x37, 0x76, 0xe7, 0x27, 0xc2, 0x0b, 0x93 }, + { 0xf5, 0x70, 0x92, 0x8e, 0x16, 0x88, 0x96, 0x26 }, + { 0xd8, 0x52, 0x14, 0x35, 0x00, 0x67, 0xa3, 0xbc }, + { 0xed, 0x69, 0xfc, 0xed, 0xc0, 0x27, 0x8a, 0xe1 }, + { 0x82, 0x17, 0x5a, 0x64, 0x06, 0x40, 0xec, 0xfa }, + { 0xd8, 0xaa, 0x10, 0x07, 0x76, 0xdc, 0xb3, 0x29 }, + { 0x5f, 0x16, 0x6c, 0x90, 0x16, 0x14, 0x74, 0x95 }, + { 0xb9, 0xf3, 0x10, 0x35, 0xae, 0xd2, 0x13, 0x46 }, + { 0x2a, 0x10, 0xc4, 0x8a, 0xb7, 0xb8, 0x75, 0x65 }, + { 0x6a, 0x49, 0xab, 0xce, 0x02, 0xb7, 0x48, 0x1f }, + { 0xfd, 0xc8, 0xd1, 0x5b, 0xea, 0x5f, 0x14, 0x96 }, + { 0x52, 0x80, 0xe0, 0xfb, 0x95, 0xf3, 0x04, 0x03 }, + { 0x08, 0x05, 0x2a, 0xea, 0x38, 0xcf, 0xc0, 0x0d }, + { 0xca, 0x6c, 0x72, 0x51, 0xbb, 0x08, 0x03, 0x5d }, + { 0xda, 0x4a, 0xe2, 0xce, 0xb9, 0x62, 0xc7, 0xc9 }, + { 0x26, 0x0d, 0x47, 0xb2, 0x3d, 0x0b, 0x43, 0xe9 }, + { 0x2e, 0xb0, 0x82, 0xb2, 0x4d, 0x82, 0xcb, 0xa0 }, + { 0x19, 0xfd, 0x76, 0xf8, 0x8d, 0xa4, 0xee, 0x7f }, + { 0xc1, 0x33, 0x6b, 0x32, 0x73, 0xda, 0x0e, 0x10 }, + { 0xe4, 0xb1, 0xac, 0x3b, 0x56, 0xd3, 0x9f, 0xb9 }, + { 0x67, 0xf6, 0x2f, 0x55, 0x57, 0xe8, 0xbe, 0x7a }, + { 0x4e, 0x05, 0x52, 0xef, 0x0f, 0x8a, 0x01, 0xaf }, + { 0x32, 0x33, 0x6a, 0xc5, 0x6f, 0x2e, 0x53, 0xaa }, + { 0x5f, 0xd3, 0xc6, 0x3b, 0x8c, 0x8b, 0xce, 0x1a }, + { 0xec, 0xae, 0xbb, 0x16, 0x8d, 0xa9, 0xdc, 0x97 }, + { 0x0e, 0xf2, 0xd1, 0x8e, 0x2b, 0xa8, 0x4a, 0x86 }, + { 0x4a, 0x30, 0xee, 0x7c, 0x62, 0xc6, 0xa2, 0xe8 }, + { 0x40, 0x38, 0xab, 0xe5, 0x9e, 0x38, 0x51, 0xc4 }, + { 0xd8, 0xf8, 0x5e, 0x30, 0x95, 0x15, 0x70, 0x7e }, + { 0x34, 0xa0, 0xef, 0x84, 0x27, 0x34, 0x36, 0x87 }, + { 0x49, 0xed, 0x6d, 0xae, 0x01, 0xb9, 0x72, 0xf2 }, + { 0xf7, 0x4b, 0x97, 0xe0, 0x36, 0xab, 0xe0, 0x76 }, + { 0x3a, 0x3e, 0x0c, 0xd8, 0xa9, 0x0a, 0xed, 0x96 }, + { 0x59, 0x37, 0xc9, 0xda, 0x44, 0x02, 0xe5, 0x96 }, + { 0xda, 0x49, 0x67, 0x2a, 0xb1, 0x8c, 0x4c, 0xd5 }, + { 0x7c, 0x1c, 0x21, 0x96, 0x32, 0x36, 0x5d, 0xdf }, + { 0x10, 0xef, 0x25, 0x89, 0x75, 0x2d, 0xf6, 0x5f }, + { 0xd5, 0xab, 0x6d, 0x0c, 0x31, 0xe2, 0xd9, 0xbb }, + { 0x4d, 0xc8, 0xf0, 0xae, 0x90, 0x62, 0x57, 0xac }, + { 0x59, 0x8e, 0x7a, 0x58, 0xb3, 0xb8, 0x89, 0xe4 }, + { 0x4a, 0x6b, 0xa4, 0x84, 0x13, 0xfd, 0xcc, 0x09 }, + { 0x2e, 0x4f, 0xd1, 0xfc, 0x0b, 0x75, 0xc8, 0x82 }, + { 0x35, 0xcb, 0x75, 0x33, 0x89, 0xd8, 0x32, 0xf8 }, + { 0x99, 0x02, 0xd7, 0xdc, 0xf5, 0xd8, 0xe3, 0x1f }, + { 0x47, 0xf3, 0x25, 0x67, 0x49, 0x4c, 0xfa, 0x29 }, + { 0x27, 0x1f, 0x40, 0xae, 0x2b, 0x61, 0xcf, 0x77 }, + { 0x2f, 0x6a, 0x2d, 0x22, 0x97, 0x8b, 0x29, 0x94 }, + { 0x67, 0x03, 0xd8, 0xcc, 0xb9, 0xc5, 0x52, 0xd9 }, + { 0x48, 0x9b, 0xdd, 0x66, 0x33, 0xd0, 0xb7, 0x29 }, + { 0xb7, 0xb2, 0x77, 0xef, 0xd1, 0xdb, 0x6b, 0x40 }, + { 0xbd, 0x59, 0xfc, 0x3c, 0xf4, 0x48, 0xa9, 0x8a }, + { 0xee, 0x2e, 0x7c, 0x77, 0x82, 0xd1, 0x0c, 0xd9 }, + { 0xbb, 0xff, 0xe2, 0x09, 0x3a, 0x20, 0x08, 0xc8 }, + { 0x3e, 0x4b, 0x07, 0xeb, 0x18, 0xfd, 0x32, 0xfb }, + { 0xcb, 0xf9, 0xa1, 0xdb, 0x55, 0x00, 0xaa, 0x1c }, + { 0x9e, 0x96, 0x20, 0x0a, 0xfc, 0x60, 0xc3, 0x11 }, + { 0x1a, 0x77, 0xdd, 0x85, 0x7f, 0xbb, 0x70, 0x92 }, + { 0xff, 0x22, 0x22, 0xa3, 0xc4, 0x27, 0x2c, 0x3e }, + { 0x90, 0xa1, 0xfc, 0x3b, 0xd3, 0x5a, 0xf1, 0x8a }, + { 0x10, 0x97, 0x29, 0xae, 0x74, 0x62, 0x62, 0x64 }, + { 0xf4, 0x5e, 0xa6, 0xeb, 0x49, 0x02, 0xe0, 0x30 }, + { 0x0b, 0x03, 0x87, 0xeb, 0xcb, 0x25, 0x8f, 0x83 }, + { 0x55, 0x17, 0x07, 0x1b, 0x32, 0x0f, 0x5c, 0xf6 }, + { 0x03, 0xa2, 0x08, 0x8e, 0x70, 0xd7, 0x65, 0x91 }, + { 0x89, 0x9d, 0x50, 0x42, 0x17, 0xdb, 0x52, 0xd3 } }; int main()