PandA-2024.02
aes_test.c
Go to the documentation of this file.
1 /*
2 * Byte-oriented AES-256 implementation.
3 * All lookup tables replaced with 'on the fly' calculations.
4 *
5 * Copyright (c) 2007 Ilya O. Levin, http://www.literatecode.com
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19 #include <stdlib.h>
20 #include <stdio.h>
21 #include "aes.h"
22 
23 #define DUMP(s, i, buf, sz) {printf(s); \
24  for (i = 0; i < (sz);i++) \
25  printf("%02x ", buf[i]); \
26  printf("\n");}
27 
28 int main (int argc, char *argv[])
29 {
30  aes256_context ctx;
31  uint8_t key[32];
32  uint8_t buf[16], i;
33 
34  /* put a test vector */
35  for (i = 0; i < sizeof(buf);i++){
36  buf[i] = i * 16 + i;
37  }
38 
39  for (i = 0; i < sizeof(key);i++){
40  key[i] = i;
41  }
42 
43  DUMP("txt: ", i, buf, sizeof(buf));
44  DUMP("key: ", i, key, sizeof(key));
45 
46  printf("---\n");
47 
48  //aes256_init(&ctx, key);
49  aes256_encrypt_ecb(&ctx,key, buf);
50 
51  DUMP("enc: ", i, buf, sizeof(buf));
52  printf("tst: 8e a2 b7 ca 51 67 45 bf ea fc 49 90 4b 49 60 89\n");
53 
54  //aes256_init(&ctx, key);
55  //aes256_decrypt_ecb(&ctx, buf);
56  //DUMP("dec: ", i, buf, sizeof(buf));
57 
58  //aes256_done(&ctx);
59 
60  return 0;
61 } /* main */
62 
#define DUMP(s, i, buf, sz)
Definition: aes_test.c:23
int key[32]
Definition: aes.h:67
void aes256_encrypt_ecb(aes256_context *ctx, uint8_t k[32], uint8_t buf[16])
Definition: aes.c:176
int main(int argc, char *argv[])
Definition: aes_test.c:28

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13