来自openssl的CMS加密/解密损坏

时间:2014-01-05 19:20:37

标签: c encryption openssl

所以我导航到

中的openssl的demos文件夹
/usr/share/doc/libssl-doc/demos/cms

我在那里编译了测试文件

gcc cms_enc.c -o enc -lssl -lcrypto
gcc cms_dec.c -o dec -lssl -lcrypto

然后我首先开始他们两个./enc然后./dec。不幸的是发生了以下错误

140502142240416:error:0200B009:system library:fread:Bad file descriptor:bss_file.c:245:
140502142240416:error:20082002:BIO routines:FILE_READ:system lib:bss_file.c:246:
140502142240416:error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length:evp_enc.c:532:

那么这意味着openSSL中的CMS实现已经破了吗?我想将这个功能用于我自己的c ++程序,但它失败了所以我想试试即使这些例子都有效..

1 个答案:

答案 0 :(得分:1)

I compiled the test files there:

gcc cms_enc.c -o enc -lssl -lcrypto
gcc cms_dec.c -o dec -lssl -lcrypto
...

140502142240416:error:0200B009:system library:fread:Bad file descriptor:bss_file.c:245:

cms_dec.c中有一个拼写错误。向下滚动到第50行,然后交换outNULL。交换后,它应该看起来像:

/* Decrypt S/MIME message */
if (!CMS_decrypt(cms, rkey, rcert, NULL, out, 0))
    goto err;

然后重新编译cms_dec.c。下次运行后,应该没有错误,decout.txt应该符合预期(与encr.txt相同)。