?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include "aes256.h"
  5. #include <stdio.h>
  6. #include <oscalls.h>
  7.  
  8. #define DUMP(s, i, buf, sz)          \
  9.     {                                \
  10.         printf(s);                   \
  11.         for (i = 0; i < (sz); i++)   \
  12.             printf("%02x ", buf[i]); \
  13.         printf("\r\n");                \
  14.     }
  15.  
  16. int main(int argc, char *argv[])
  17. {
  18.     aesctx ctx;
  19.     aesctx ctx1;
  20.  
  21.     unsigned char key[32] = {060, 061, 062, 063, 064, 065, 066, 067, 070, 071, 060, 061, 062, 063, 064, 065, 060, 061, 062, 063, 064, 065, 066, 067, 070, 071, 060, 061, 062, 063, 064, 065};
  22.     unsigned char buf[16] = {060, 061, 062, 063, 064, 065, 066, 067, 070, 071, 060, 061, 062, 063, 064, 065};
  23.  
  24.     int i;
  25.  
  26.     os_initstdio();
  27.  
  28.     DUMP("txt: ", i, buf, sizeof(buf));
  29.     DUMP("key: ", i, key, sizeof(key));
  30.     printf("---\r\n");
  31.  
  32.     aesini(&ctx, key);
  33.     aesenc(&ctx, buf);
  34.  
  35.     DUMP("enc: ", i, buf, sizeof(buf));
  36.     printf("tst: 06 b2 d7 c9 fe f2 45 4c 76 7f 3f 1c 7c b2 a6 77\r\n");
  37.  
  38.     aesini(&ctx1, key);
  39.     aesdec(&ctx1, buf);
  40.     DUMP("dec: ", i, buf, sizeof(buf));
  41.  
  42.     aesdon(&ctx);
  43.     aesdon(&ctx1);
  44.  
  45.     return 0;
  46. }
  47.