• boringssl EVP_aes_128_ecb实现


    最近学习boringssl,发现没找到EVP_aes_128_ecb在哪里实现的

    饶了一大圈,发现它的定义很无语

    1. #define EVP_CIPHER_FUNCTION(keybits, mode)             \
    2.   const EVP_CIPHER *EVP_aes_##keybits##_##mode(void) { \
    3.     return aes_##keybits##_##mode##_generic();         \
    4.   }
    5. EVP_CIPHER_FUNCTION(128, cbc)
    6. EVP_CIPHER_FUNCTION(128, ctr)
    7. EVP_CIPHER_FUNCTION(128, ofb)
    8. EVP_CIPHER_FUNCTION(128, gcm)
    9. EVP_CIPHER_FUNCTION(192, cbc)
    10. EVP_CIPHER_FUNCTION(192, ctr)
    11. EVP_CIPHER_FUNCTION(192, ofb)
    12. EVP_CIPHER_FUNCTION(192, gcm)
    13. EVP_CIPHER_FUNCTION(256, cbc)
    14. EVP_CIPHER_FUNCTION(256, ctr)
    15. EVP_CIPHER_FUNCTION(256, ofb)
    16. EVP_CIPHER_FUNCTION(256, gcm)
    17. EVP_ECB_CIPHER_FUNCTION(128)
    18. EVP_ECB_CIPHER_FUNCTION(192)
    19. EVP_ECB_CIPHER_FUNCTION(256)

    随便拿EVP_CIPHER_FUNCTION(128, cbc)展开

    1. EVP_CIPHER_FUNCTION(128, cbc) = const EVP_CIPHER *EVP_aes_128_cbc(void) { \
    2. return aes_128_cbc_generic(); \
    3. }

    这里的 aes_128_cbc_generic 参考boringssl DEFINE_LOCAL_DATA

    其实有方向的情况下可以用gcc -E ./src/crypto/fipsmodule/cipher/e_aes.c -o test.i -I include/

    -E,只执行到预编译,直接输出预编译结果【有目标的情况下】

    可以看看如下的预编译结果

    1. # 855 "./src/crypto/fipsmodule/cipher/e_aes.c"
    2. const EVP_CIPHER *EVP_aes_128_cbc(void) { return aes_128_cbc_generic(); }
    3. const EVP_CIPHER *EVP_aes_128_ctr(void) { return aes_128_ctr_generic(); }
    4. const EVP_CIPHER *EVP_aes_128_ofb(void) { return aes_128_ofb_generic(); }
    5. const EVP_CIPHER *EVP_aes_128_gcm(void) { return aes_128_gcm_generic(); }
    6. const EVP_CIPHER *EVP_aes_192_cbc(void) { return aes_192_cbc_generic(); }
    7. const EVP_CIPHER *EVP_aes_192_ctr(void) { return aes_192_ctr_generic(); }
    8. const EVP_CIPHER *EVP_aes_192_ofb(void) { return aes_192_ofb_generic(); }
    9. const EVP_CIPHER *EVP_aes_192_gcm(void) { return aes_192_gcm_generic(); }
    10. const EVP_CIPHER *EVP_aes_256_cbc(void) { return aes_256_cbc_generic(); }
    11. const EVP_CIPHER *EVP_aes_256_ctr(void) { return aes_256_ctr_generic(); }
    12. const EVP_CIPHER *EVP_aes_256_ofb(void) { return aes_256_ofb_generic(); }
    13. const EVP_CIPHER *EVP_aes_256_gcm(void) { return aes_256_gcm_generic(); }
    14. const EVP_CIPHER *EVP_aes_128_ecb(void) { if (hwaes_capable()) { return aes_hw_128_ecb(); } return aes_128_ecb_generic(); }
    15. const EVP_CIPHER *EVP_aes_192_ecb(void) { if (hwaes_capable()) { return aes_hw_192_ecb(); } return aes_192_ecb_generic(); }
    16. const EVP_CIPHER *EVP_aes_256_ecb(void) { if (hwaes_capable()) { return aes_hw_256_ecb(); } return aes_256_ecb_generic(); }

    文件 "./src/crypto/fipsmodule/cipher/e_aes.c + 行号;855

  • 相关阅读:
    机试打卡 -05 接雨水(动态规划&栈)
    vue中v-model应用于表单元素
    【深入理解设计模式】模板方法模式
    AI 技术创意图像编辑器:Luminar Neo Mac
    线性代数的本质(七)——特征值和特征向量
    Nuxt - 超详细环境搭建及创建项目整体流程(create-nuxt-app)
    微信小程序 23 播放音乐页
    Windows下MySQL的安装和删除
    pycharm集成通义灵码
    springboot+APP基于Android的洗衣店预约系统毕业设计源码260839
  • 原文地址:https://blog.csdn.net/gang542725/article/details/132569857