Search code examples
caes

AES algorithm implementation in C


Can anyone share me AES algorithm code with Input and Key details in C, i have checked this link https://github.com/kokke/tiny-AES-c/blob/master/aes.c, but couldn't conclude as it not has the main() function.

Thanks in advance


Solution

  • Here's the proper way to call it:

    struct AES_ctx ctx;
    AES_init_ctx(&ctx, key);
    
    for (i = 0; i < 4; ++i)
    {
      AES_ECB_encrypt(&ctx, plain_text + (i * 16));
      phex(plain_text + (i * 16));
    }
    

    You may check other details in the following file from the same repository: https://github.com/kokke/tiny-AES-c/blob/master/test.c