n00b problem with deimos.openssl AES_cbc_encrypt

moechofe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 30 08:05:12 PDT 2014


Hi,

I'm try to encrypt a string with AES_cbc_encrypt using the 
openssl bindings from 
https://github.com/D-Programming-Deimos/openssl

And the result I got is wrong.

---
ubyte[32] key
// ...fill key

ubyte[16] iv;
// ...fill iv;

AES_KEY aes_key;
AES_set_encrypt_key(cast(const(ubyte)*)key.ptr,256,&aes_key);

ubyte[] test_in = cast(ubyte[])"foo";

ubyte[] test_out = new ubyte[](test_in.length + AES_BLOCK_SIZE - 
(test_in.length % AES_BLOCK_SIZE));

AES_cbc_encrypt(
     cast(const(ubyte)*) test_in.ptr,
     test_out.ptr,
     test_in.length,
     &aes_key,
     iv.ptr,
     AES_ENCRYPT);
---

What I'm doing wrong?


More information about the Digitalmars-d-learn mailing list