将 Symbian 描述符形式的非常大的整数转换为无符号字符*
我们正在尝试使用 Open C/C++ 库 (rsa.h) 和“RSA_public_encrypt”方法在 Symbian 中实现 RSA 加密:
buffSize = RSA_public_encrypt(maxSize, (unsigned char *) plainkey, (unsigned char * ) cipherkey, rsa, RSA_NO_PADDING);
我们使用自己的指数和模数创建了一个公钥,并将其放入“rsa”对象中。 我们要加密的纯文本是一个以字符串形式接收的非常大的整数(作为 Symbian 描述符)。
但是,纯文本应作为“unsigned char*”提供给加密方法。 如何将描述符(纯文本)转换为“unsigned char*”,以便加密方法将我们的纯文本解释为一个非常大的整数。 或者对于那些不熟悉 Symbian 描述符的人:如何将纯文本从常规字符串 (char *) 转换为加密解释为非常大的整数的值。
我们已经尝试通过多种方式提供纯文本,但加密文本并不是应有的样子 (我们将此与我们验证正确的其他平台上的结果进行比较)。
非常感谢任何帮助。
We're trying to implement RSA encryption in Symbian using the Open C/C++ library (rsa.h), and the 'RSA_public_encrypt' method:
buffSize = RSA_public_encrypt(maxSize, (unsigned char *) plainkey, (unsigned char *) cipherkey, rsa, RSA_NO_PADDING);
We created a public key with our own exponent and modulus and put that in the 'rsa'-object.
Our plain text to be encrypted is a very large integer received in string form (so as a Symbian descriptor).
However, the plain text should be provided as an 'unsigned char*' to the encryption method.
How can I transform the descriptor (plain text) to an 'unsigned char*' so that the encryption method interprets our plain text as a very large integer.
Or for those not familiar with Symbian descriptors: how can I transform the plain text from a regular string (char *) to a value that the encryption interprets as a very large integer.
We already tried to provide the plain text in several ways, but the encryption text wasn't what it should have been
(we compared this with results on other platforms which we verified was correct).
Any help is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须分配(malloc)plainkey 和cipherkey 变量,并使用lstrcpy 或类似的东西将未加密的纯文本字符串复制到cipherkey,以便使该函数正常工作。
您还可以使用无符号字符数组:
You have to allocate (malloc) the plainkey and cipherkey variables and copy the unencrypted plain text string to cipherkey using lstrcpy or something similar in order to make this function work.
you can also use unsigned char arrays:
RSA_public_encrypt
的第一个参数是flen
,第二个参数是from
,即它将加密flen
字节中的来自
。假设您有一个要加密的
TDesC8
描述符source
,请像这样调用该函数:The first argument to
RSA_public_encrypt
isflen
and the second isfrom
i.e. it will encryptflen
bytess fromfrom
.Assuming you have a
TDesC8
descriptorsource
you want to encrypt, call the function like this: