来自openssl的CMS加密/解密已损坏 [英] CMS encryption/decryption from openssl broken
问题描述
所以我导航到
/ usr / share / doc / libssl-doc / demo / cms
我在那里编译了测试文件
gcc cms_enc.c -o enc -lssl -lcrypto
gcc cms_dec.c -o dec -lssl -lcrypto
然后我们先启动它们./enc then./dec。不幸的是,发生以下错误
140502142240416:错误:0200B009:系统库:fread:错误的文件描述符:bss_file.c:245:
140502142240416:错误:20082002:BIO例程:FILE_READ:系统lib:bss_file.c:246:
140502142240416:错误:0606506D:数字信封例程:EVP_DecryptFinal_ex:错误的最终块长度:evp_enc.c:532 :
这意味着openSSL中的CMS实现已经破了?我想为我自己的c ++程序使用这个功能,但是它失败了,所以我想尝试,甚至这个例子都可以工作。
我在那里编译了测试文件:
pre>
gcc cms_enc.c -o enc -lssl -lcrypto
gcc cms_dec.c -o dec -lssl - lcrypto
...
140502142240416:错误:0200B009:系统库:fread:错误的文件描述符:bss_file.c:245:
cms_dec.c
中有一个打字错误。滚动到第50行,并交换out
和NULL
。在交换后,应该看起来像:/ *解密S / MIME消息* /
if(!CMS_decrypt (cms,rkey,rcert,NULL,out,0))
goto err;
然后重新编译
cms_dec.c
。在下一次运行后,应该没有错误,而decout.txt
应该是按预期的(与encr.txt
)。So i navigated to the demos folder of openssl in
/usr/share/doc/libssl-doc/demos/cms
I compiled the test files there
gcc cms_enc.c -o enc -lssl -lcrypto gcc cms_dec.c -o dec -lssl -lcrypto
Then i started both of them first ./enc then ./dec. Unfortunately the following error occured
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:
So that means that the CMS implementation in openSSL is broken already? i wanted to use that functionality for my own c++ program but it failed so i wanted to try if even the examples work..
解决方案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:
There's a typo in
cms_dec.c
. Scroll on down to line 50, and swap theout
and theNULL
. After the swap, it should look like:/* Decrypt S/MIME message */ if (!CMS_decrypt(cms, rkey, rcert, NULL, out, 0)) goto err;
Then recompile
cms_dec.c
. After the next run, there should be no error, anddecout.txt
should be as expected (the same asencr.txt
).这篇关于来自openssl的CMS加密/解密已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!