I am sending a encrypted mail using OpenSSL in an android app. While sending the mail this is the relevant native code -
我在Android应用程序中使用OpenSSL发送加密邮件。发送邮件时,这是相关的本机代码 -
cipher = EVP_rc2_40_cbc();
int flags = PKCS7_STREAM;
PKCS7* p7 = PKCS7_encrypt(certs, bio, cipher, flags);
int r = SMIME_write_PKCS7(out, p7, bio, flags);
The mail is successfully sent to the server and I get a sent mail notification.
邮件已成功发送到服务器,我收到已发送邮件通知。
Now when I am trying to open the mail using the another android app which has bouncycastle I am unable to open it. It says "Unable to decrypt message."
现在,当我尝试使用另一个具有bouncycastle的Android应用程序打开邮件时,我无法打开它。它说“无法解密消息”。
Also I tried openning the app using the webmail - interface on desktop. Here also I was unable to open the mail.
此外,我尝试使用桌面上的webmail接口打开应用程序。在这里我也无法打开邮件。
Any Idea what could be the problem?
任何想法可能是什么问题?
I tried using a different cipher also ( 3des ). But that too did not work.
我也试过使用不同的密码(3des)。但这也行不通。
Update -> If I change my encryption code to bouncy castle then everything works fine. I am able to decrypt in both android app and web-browser. So is there a possibilty that this might be a OpenSSL Issue?
更新 - >如果我将加密代码更改为bouncy castle,那么一切正常。我能够在Android应用程序和Web浏览器中解密。那么这可能是一个OpenSSL问题吗?
Update 2 -> I tried decrypting the encrypted text using openssl command prompt and it worked. So I guess it is surely some compatibilty problem? But is this a problem with bouncycastle or with openssl ?
更新2 - >我尝试使用openssl命令提示解密加密文本,它工作正常。所以我猜这肯定是一些兼容性的问题?但这是bouncycastle还是openssl的问题?
1 个解决方案
#1
0
It turns out I was missing a flag.
事实证明我错过了一面旗帜。
int flags = PKCS7_STREAM | PKCS7_BINARY;
This did the charm.
这样做的魅力。
#1
0
It turns out I was missing a flag.
事实证明我错过了一面旗帜。
int flags = PKCS7_STREAM | PKCS7_BINARY;
This did the charm.
这样做的魅力。