开发者

Tiny asymmetric cipher implementation to validate download

开发者 https://www.devze.com 2023-01-08 20:08 出处:网络
To allow a small C++ application to update itself at clients connected over the internet, I am in need of a mechanism that validate开发者_StackOverflow社区s the download based on a public key. Algorit

To allow a small C++ application to update itself at clients connected over the internet, I am in need of a mechanism that validate开发者_StackOverflow社区s 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?


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.


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


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.


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.


I think you might find that the MIRACL library meets your needs.


checksums can easily handle validation jobs like these.

0

精彩评论

暂无评论...
验证码 换一张
取 消