Джим, спасибо за вашу помощь.
Кажется, мне пришлось поднять вопрос, чтобы найти ответ.После многих дней борьбы вот что я придумал:
unsigned char inbuf[1024]="Hello,world!";
unsigned char encbuf[1024];
unsigned char key32[] = {0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa};
unsigned char deckey32[] = {0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa}
;
unsigned char iv[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char deciv[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
AES_KEY aeskey;
AES_KEY aesdeckey;
//Now enrypt
memset(encbuf, 0, sizeof(encbuf));
AES_set_encrypt_key(key32, 32*8, &aeskey);
AES_cbc_encrypt(inbuf, encbuf, 16, &aeskey, iv, AES_ENCRYPT);
//Now decrypt
unsigned char decbuf[1024];
memset(decbuf, 0, sizeof(decbuf));
AES_set_decrypt_key(deckey32, 32*8, &aesdeckey);
AES_cbc_encrypt(encbuf, decbuf, 16, &aesdeckey, deciv, AES_DECRYPT);
//Display the results
NSLog(@"ORIGINAL: \"%s\"\n", inbuf);
NSLog(@"ENCRYPTED: \"%s\"\n", encbuf);
NSLog(@"DECRYPTED: \"%s\"\n", decbuf);
return;
Кредиты этим парням (после Джима): http://www.mail-archive.com/openssl-users@openssl.org/msg50142.html
Ключ должен был использовать AES_cbc_encrypt для расшифровки.