// this code is just sample. not function form.
// just a reference!

const unsigned char pKey[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

const unsigned char pIn[] = {0,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc,0xd,0xe,0xf};
unsigned char pCipher[16] = {0,};
unsigned char pPlain[16] = {0,};

{
    /**
    * AES ECB Encryption
    *
    * @param pKey 128bit key
    * @param pIn 128bit plain input
    * @param pCipher (output) 128bit cipher output
    * @return true/false
    */
    AES_KEY stKey;
    memset(&stKey, 0, sizeof(AES_KEY));
    if(AES_set_encrypt_key(pKey, 128, &stKey)<0)
        return false;
    AES_ecb_encrypt(pIn, pCipher, &stKey, AES_ENCRYPT);
    //return true;
}

{
    /**
    * AES ECB Decryption
    *
    * @param pKey 128bit key
    * @param pCipher 128bit cipher input
    * @param pPlain (output) 128bit plain output
    * @return true/false
    */
    AES_KEY stKey;
    memset(&stKey, 0, sizeof(AES_KEY));
    if(AES_set_decrypt_key(pKey, 128, &stKey)<0)
        return false;
    AES_ecb_encrypt(pCipher, pPlain, &stKey, AES_DECRYPT);
    //return true;
}
Posted by 배트
,