1

(3 replies, posted in wolfCrypt)

I was simply being lazy with the 1024 for the prototype and provide a buffer that's plenty big for the expected string. The encrypted pw is sent to me from another application that used AES 256 to encrypt (probably OpenSLL but I'm not sure) and I'm using the same key and iv values.

2

(3 replies, posted in wolfCrypt)

I'm sure I'm overlooking something fundamental in the docs. I'm prototyping a method to decrypt a short password that was encrypted using AES 256. I suspect this is defaulting to AES 128 but I can't find how to change it. Can someone please point me in the right direction?

std::string WolfDec(std::string sPw)
{
    Aes enc;
    Aes dec;

    const byte key[] = "Some32ByteKeyForTestingTheDecode";
    const byte iv[] = "A16BitIVisNeeded";

    byte plain[1024];
    byte cipher[1024];

    memset(plain, 0, 1024);
    memset(cipher, 0, 1024);
   
    // Decrypt cipher to plain
    memmove(cipher, sPw.data(), sPw.length());
    wc_AesSetKey(&dec, key, sizeof(key), iv, AES_DECRYPTION);
    wc_AesCbcDecrypt(&dec, plain, cipher, sizeof(cipher));

    std::string sRet;
    sRet.append((const char*)plain);

    return sRet;
}