~ubuntu-branches/ubuntu/utopic/dropbear/utopic-proposed

« back to all changes in this revision

Viewing changes to libtomcrypt/demos/test/store_test.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Johnston
  • Date: 2005-12-08 19:20:21 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051208192021-nyp9rwnt77nsg6ty
Tags: 0.47-1
* New upstream release.
* SECURITY: Fix incorrect buffer sizing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "test.h"
2
 
 
3
 
/* Test store/load macros with offsets */
4
 
int store_test(void)
5
 
{
6
 
  unsigned char buf[24];
7
 
  unsigned long L, L1;
8
 
  int y;
9
 
  ulong64 LL, LL1;
10
 
 
11
 
  L = 0x12345678UL;
12
 
  for (y = 0; y < 4; y++) {
13
 
      STORE32L(L, buf + y);
14
 
      LOAD32L(L1, buf + y);
15
 
      if (L1 != L) {
16
 
         fprintf(stderr, "\n32L failed at offset %d\n", y);
17
 
         return 1;
18
 
      }
19
 
      STORE32H(L, buf + y);
20
 
      LOAD32H(L1, buf + y);
21
 
      if (L1 != L) {
22
 
         fprintf(stderr, "\n32H failed at offset %d\n", y);
23
 
         return 1;
24
 
      }
25
 
  }
26
 
 
27
 
  LL = CONST64 (0x01020304050607);
28
 
  for (y = 0; y < 8; y++) {
29
 
      STORE64L(LL, buf + y);
30
 
      LOAD64L(LL1, buf + y);
31
 
      if (LL1 != LL) {
32
 
         fprintf(stderr, "\n64L failed at offset %d\n", y);
33
 
         return 1;
34
 
      }
35
 
      STORE64H(LL, buf + y);
36
 
      LOAD64H(LL1, buf + y);
37
 
      if (LL1 != LL) {
38
 
         fprintf(stderr, "\n64H failed at offset %d\n", y);
39
 
         return 1;
40
 
      }
41
 
  }
42
 
 
43
 
  return 0;
44
 
}