如何为iphone上的openssl 3des解密生成密钥计划
我需要解密一些在运行mono(C#)的系统上经过3des编码的数据 我需要在iPhone上使用openssl和解密 我发现了一个类似这样的例子,当我安装了openssl etc时,它在iphone上运行没有错误,但是为我的测试用例生成了错误的结果,我已经在编码系统上验证了这个结果。初始化向量是正确的,但我应该将密钥计划设置为什么,因为我仅有的信息是输入如何为iphone上的openssl 3des解密生成密钥计划,iphone,cryptography,openssl,encryption,3des,Iphone,Cryptography,Openssl,Encryption,3des,我需要解密一些在运行mono(C#)的系统上经过3des编码的数据 我需要在iPhone上使用openssl和解密 我发现了一个类似这样的例子,当我安装了openssl etc时,它在iphone上运行没有错误,但是为我的测试用例生成了错误的结果,我已经在编码系统上验证了这个结果。初始化向量是正确的,但我应该将密钥计划设置为什么,因为我仅有的信息是输入 DES_cblock ivec[] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}; DES_key_
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专业知识的人员,使用此库是项目的先决条件)首先是
DES_cblock的typedef
:
typedef unsigned char DES_cblock[8];
为注释填写您自己的代码,并使用以下内容:
DES_key_schedule ks1, ks2, ks3;
DES_cblock key_8bytes;
/* ... copy the first 64 bits of the 192 bits into key_8bytes....*/
DES_set_key_unchecked(&key_8bytes, &ks1);
/* ... copy the second 64 bits of the 192 bits into key_8bytes....*/
DES_set_key_unchecked(&key_8bytes, &ks2);
/* ... copy the final 64 bits of the 192 bits into key_8bytes....*/
DES_set_key_unchecked(&key_8bytes, &ks3);
谢谢Greg,我昨晚也很晚才发现这个。。。谢谢你的确认。