检查Gnutls中荨麻的解密部分的代码

时间:2019-01-17 17:43:34

标签: c openssl gnutls nettle

在解密时要求下面的代码类似加密。
下面的代码是为了测试加密,类似地,我只能获取代码 测试荨麻的解密部分。

/* aes encryption example */
/* LICENSE: LGPL */
/* Compile in nettle (http://www.lysator.liu.se/~nisse/nettle/) source 
directory with gcc -E */
/* Must use gcc on Linux b/c on Mac OS X you will encounter CIL errors */



#define OUTPUT

#include <stdio.h>
#include </home/nettle-3.1/include/nettle/aes.h>
unsigned char plaintext[AES_BLOCK_SIZE] = "0123456789abcdef";
unsigned char ciphertext[AES_BLOCK_SIZE];

struct aes_ctx ctx;
/*unsigned char key[AES_BLOCK_SIZE]="0011223344556677";*/
unsigned char key[AES_BLOCK_SIZE];

int main() {

int i;

aes_set_encrypt_key(&ctx, AES_BLOCK_SIZE, key);/* sets the key for 
expansion*/
aes_encrypt(&ctx, AES_BLOCK_SIZE, ciphertext, plaintext);
printf("AES_BLOCK_SIZE=%d", AES_BLOCK_SIZE);

printf("\nExpected: 14f5fe746966f292651c2288bbff4609\n");
printf("\nActual:   ");

for (i = 0; i < 16; i++) {
printf("%02x", ciphertext[i]);
}
printf("\n");
return 0;
}

0 个答案:

没有答案