用于验证下载的小型非对称密码实现
为了允许小型 C++ 应用程序在通过互联网连接的客户端上进行自我更新,我需要一种基于公钥验证下载的机制。 DSA 或 RSA 等算法似乎能够很好地做到这一点。
然而,查看著名的可用库(Crypto++、LibTomCrypt),它们最终都会使我的二进制文件 > 500k 更大,而在我看来,这样的逻辑可以在几 k 内实现。是否有任何库可以在小于 20k 的空间内实现 RSA/DSA 哈希验证?
To allow a small C++ application to update itself at clients connected over the internet, I am in need of a mechanism that validates the download based on a public key. Algorithms such as DSA or RSA seem to be able to do this nicely.
However, looking at well-known available libraries for this (Crypto++, LibTomCrypt) they all end up making my binary > 500k larger, while it seems to me such logic can be implemented in a couple of k. Are there any libraries that implement RSA/DSA hash verification in a, say, <20k footprint?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
由于我没有找到适合我的特定需求的库,因此我为此创建了自己的库:http://github。 com/paiq/dsa_verify。当前的实现占用了约 50k 的程序内存,主要是由于包含了 bignum 数学库,但未来的版本可能会减少更多。
Since I found no libraries that fitted my specific need, I whipped up my own library for this: http://github.com/paiq/dsa_verify. The current implementation has a ~50k footprint of program memory, mainly due to the included bignum math lib, but future versions may be stripped even more.
在 http://citeseerx .ist.psu.edu/viewdoc/download?doi=10.1.1.143.3049&rep=rep1&type=pdf 描述了一个椭圆曲线库,根据作者的说法,可以将其配置为仅需要大约 7k ROM微控制器上的 RAM 低于 200 字节
In http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.143.3049&rep=rep1&type=pdf an elliptic curve library is described which according to the authors can be configured to need only about 7k ROM and below 200 bytes of RAM on a microcontroller
你真的需要密码吗?
通常,要验证下载,您可以使用 MD5 或 SHA 等哈希函数。也许你可以找到一个使用这些的小型图书馆。
无论哪种方式,您都可以尝试 openssl 库。然而,我机器上的 .a 大约被剥离了 400K 和 250K。
Do you really need ciphers ?
Generally, to validate a download, you can use a hash function like MD5 or SHA. Maybe you can find a small library using these.
Either way, you can try the openssl library. However the .a on my machine is about 400K and 250K stripped.
如果您仅使用 Windows,只要您的应用程序部署在 win2k 或更高版本上,您就可以链接到 Windows Crypto API。 Windows 加密 MSDN 文章。
编辑:
另一种可能的解决方案,如果您只需要验证下载没有损坏,快速搜索一下即可找到 MD5 的这个小实现。根据编译的目标代码顶部 3k 处的自述文件。
If you are windows only you may be able to link against the windows Crypto API as long as your apps are deployed on win2k or greater. Windows Crypto MSDN article.
EDIT:
Another possible solution, if you just need to verify the the download did not get corrupted a quick bit of googleing found the source to this small implementation of MD5. according to the read-me at the top 3k of object code compiled.
我想您可能会发现 MIRACL 库满足您的需求。
I think you might find that the MIRACL library meets your needs.
校验和可以轻松处理此类验证工作。
checksums can easily handle validation jobs like these.