exaexa / codecrypt

Post-quantum cryptography tool (THIS REPOSITORY IS ONLY A MIRROR OF THE MAIN ONE, PLEASE DO NOT FILE BUGS HERE)
https://gitea.blesmrt.net/exa/codecrypt
GNU Lesser General Public License v3.0
308 stars 40 forks source link

Rewrite in Rust #28

Closed ghost closed 6 years ago

ghost commented 7 years ago

It's hard to write safe C/C++. For a cryptography library, safety is paramount; using a language that will happily leak memory without as much as blinking an eye in protest isn't a very good way to ensure safety. https://alexgaynor.net/2017/nov/20/a-vulnerability-by-any-other-name/

exaexa commented 7 years ago

This would be great (even greater rewrite would be in Haskell which would remove 95% of the logic-error-prone code), but it's not even remotely possible given my current time possibilities. I'll be happy to assist anyone who will want to do the reimplementation.

Anyway, memory leaks are not a significant problem for one-shot programs like codecrypt. Moreover, codecrypt uses c++-style guarded allocation almost everywhere except for the sencode parser, which is to be rewritten to C++11-style allocation in next release. I'd actually be more scared about out-of-bounds access and similar behavior (overflows etc.), is there a way Rust can prevent out-of-bounds array access?

So, if you have a reasonable answer to the question "what will Rust bring except the uniqueness-based allocation, which can also be implemented by a much simpler rewrite to c++11 style", AND you wish/have time to reimplement the project, please start a new repository and keep this issue open for tracking.

PS. the rewrite would certainly be a great research project/thesis, if you are a student this is probably waiting for you :]

exaexa commented 6 years ago

Closing this. If you're willing to carry out the reimplementation, please start a separate repository.

ghost commented 6 years ago

Oops, missed the notification for this somehow.

Thanks for the background and the suggestion. Rust does prevent out-of-bounds (both integer overflows and indexing), but not at compile time. Instead, it just crashes - an improvement, surely, over C/C++'s silent "may-or-may-not-fail".

Re a potential research project, I'm not really sure how research works in CS. Does rewriting things in Rust count as research?

exaexa commented 6 years ago

Not directly as research but I guess it would still make a good thesis (esp. for software-engineering-oriented courses). :]