1 #include <tomcrypt_test.h>
3 /* Test store/load macros with offsets */
6 unsigned char buf
[256];
14 for (y
= 0; y
< 4; y
++) {
20 fprintf(stderr
, "\n32L failed at offset %d\n", y
);
26 fprintf(stderr
, "\n32H failed at offset %d\n", y
);
31 for (y
= 0; y
< 8; y
++) {
32 LL
= CONST64 (0x01020304050607);
34 STORE64L(LL
, buf
+ y
);
35 LOAD64L(LL1
, buf
+ y
);
37 fprintf(stderr
, "\n64L failed at offset %d\n", y
);
40 STORE64H(LL
, buf
+ y
);
41 LOAD64H(LL1
, buf
+ y
);
43 fprintf(stderr
, "\n64H failed at offset %d\n", y
);
52 for (z
= 0; z
< y
; z
++) {
53 /* fill y bytes with random */
54 yarrow_read(buf
+z
, y
, &yarrow_prng
);
55 yarrow_read(buf
+z
+y
, y
, &yarrow_prng
);
57 /* now XOR it byte for byte */
58 for (x
= 0; x
< y
; x
++) {
59 buf
[2*y
+z
+x
] = buf
[z
+x
] ^ buf
[z
+y
+x
];
62 /* now XOR it word for word */
63 for (x
= 0; x
< y
; x
+= sizeof(LTC_FAST_TYPE
)) {
64 *((LTC_FAST_TYPE
*)(&buf
[3*y
+z
+x
])) = *((LTC_FAST_TYPE
*)(&buf
[z
+x
])) ^ *((LTC_FAST_TYPE
*)(&buf
[z
+y
+x
]));
67 if (memcmp(&buf
[2*y
+z
], &buf
[3*y
+z
], y
)) {
68 fprintf(stderr
, "\nLTC_FAST failed at offset %d\n", z
);
76 /* $Source: /cvs/libtom/libtomcrypt/testprof/store_test.c,v $ */
77 /* $Revision: 1.6 $ */
78 /* $Date: 2005/05/05 14:35:59 $ */