liwugang / liwugang.github.io

blog
https://liwugang.github.io/
MIT License
1 stars 2 forks source link

openssl AES密钥和iv长度问题分析 - liwugang #4

Open liwugang opened 4 years ago

liwugang commented 4 years ago

https://liwugang.github.io/2019/04/21/openssl_decrypt_fail.html

在做filecrypt项目时花费时间最多的是AES256算法的调试上,出现的问题是:调用完加密函数然后直接调用解密函数,这样是可以正确解密的,但是调用完加密函数后将密文保存在文件后,然后重新使用程序进行解密却是无法正常解密,本文分析下该问题的原因。例子int aes_encrypt_common(uint8_t ...

jilongcui commented 4 years ago

第二次解密传递进去的another_key和another_iv,难道不是空值吗?

liwugang commented 4 years ago

@jilongcui 第二次解密传递进去的another_key和another_iv,难道不是空值吗?

遗漏了两句,有时间了更新上

    // 再次调用解密,密钥和iv是复制过来的
    char *another_key = (char *) calloc(1, strlen(key) + 1);
    char *another_iv = (char *) calloc(1, strlen(iv) + 1);
    strcpy(another_key, key);  // 遗漏
    strcpy(another_iv, iv); // 遗漏
   ... ...