如何在 iPhone 上生成 openssl 3des 解密的密钥时间表
我需要解密一些在运行 mono (C#) 的系统上进行 3des 编码的数据,
我需要使用 openssl 并在 iPhone 上解密。
我找到了一个如下所示的示例,当我安装了 openssl 等时,它在 iphone 上运行没有错误,但为我在编码系统上验证过的测试用例生成了错误的结果。初始化向量是正确的,但是由于我拥有的唯一信息是输入,因此我应该将密钥计划设置为什么?
DES_cblock ivec[] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
DES_key_schedule ks1, ks2, ks3;
// What (and how) should I set ks1/2/3 to?
DES_ede3_cbc_encrypt(input,output, 24*8, &ks1, &ks2, &ks3,ivec, DES_DECRYPT);
单声道系统上的解码是通过以下代码完成的;
TripleDESCryptoServiceProvider m_des = new TripleDESCryptoServiceProvider();
byte[] IV ={0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
m_des.KeySize = 24*8;
MemoryStream memStream = new MemoryStream();
CryptoStream cryptStream = new CryptoStream(memStream,m_des.CreateDecryptor(key, IV), CryptoStreamMode.Write);
cryptStream.Write(input, 0, input.Length);
cryptStream.FlushFinalBlock();
据我所知,没有指定关键时间表,所以我不知道将其设置为什么?我猜它是从钥匙中衍生出来的……一分钱开始下降……但是如何呢?
有什么想法吗? (最好是具有 openssl 专业知识的人,使用该库是该项目的先决条件)
I need to decrypt some data that has been 3des encoded on system running mono (C#)
I need to use openssl and decrypt on the iPhone.
I found an example which looks like this, and it runs without error on the iphone when I have openssl etc installed, but generates the wrong result for my test case which I've verified on the encoding system. The initialisation vector is correct, but what should I set the key schedule to since the only information I have is the input?
DES_cblock ivec[] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
DES_key_schedule ks1, ks2, ks3;
// What (and how) should I set ks1/2/3 to?
DES_ede3_cbc_encrypt(input,output, 24*8, &ks1, &ks2, &ks3,ivec, DES_DECRYPT);
The decoding on the mono system is done with the following code;
TripleDESCryptoServiceProvider m_des = new TripleDESCryptoServiceProvider();
byte[] IV ={0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
m_des.KeySize = 24*8;
MemoryStream memStream = new MemoryStream();
CryptoStream cryptStream = new CryptoStream(memStream,m_des.CreateDecryptor(key, IV), CryptoStreamMode.Write);
cryptStream.Write(input, 0, input.Length);
cryptStream.FlushFinalBlock();
As far as I can tell, the key schedule isn't being specified, so I don't know what to set it to? I guess it gets derived from the key ... penny starting to drop ... but how?
Any ideas? (ideally from people with openssl expertise, use of this library is a pre-requisite for the project)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从
DES_cblock
的 typedef 开始:在注释中填写您自己的代码并使用类似以下内容的内容:
Starting with the typedef for a
DES_cblock
:Fill in you own code for the comments and use something like: