⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modes_test.c

📁 最新版本的加密解密算法库
💻 C
字号:
/* test CFB/OFB/CBC modes */#include "test.h"int modes_test(void){   unsigned char pt[64], ct[64], tmp[64], key[16], iv[16];   int x, cipher_idx;   symmetric_CBC cbc;      /* make a random pt, key and iv */   yarrow_read(pt, 64,  &test_yarrow);   yarrow_read(key, 16, &test_yarrow);   yarrow_read(iv, 16,  &test_yarrow);   /* test CBC mode */   cipher_idx = find_cipher("aes");   if (cipher_idx == -1) {      printf("test requires AES");      return 1;   }         /* encode the block */   DO(cbc_start(cipher_idx, iv, key, 16, 0, &cbc));   for (x = 0; x < 4; x++) {      DO(cbc_encrypt(pt+x*16, ct+x*16, &cbc));   }      /* decode the block */   DO(cbc_start(cipher_idx, iv, key, 16, 0, &cbc));   for (x = 0; x < 4; x++) {      DO(cbc_decrypt(ct+x*16, tmp+x*16, &cbc));   }   if (memcmp(tmp, pt, 64) != 0) {      printf("CBC failed");      return 1;   }   /*      extern int cbc_start(int cipher, const unsigned char *IV, const unsigned char *key,                     int keylen, int num_rounds, symmetric_CBC *cbc);extern int cbc_encrypt(const unsigned char *pt, unsigned char *ct, symmetric_CBC *cbc);extern int cbc_decrypt(const unsigned char *ct, unsigned char *pt, symmetric_CBC *cbc);*/}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -