I will be making (in the near future) an app that will contain some pretty heavy crypto. As it is possible that my app will be ported to different devices (initially it will be iOs only, but Mac, Android & maybe even Windows ports will eventually exist). The question is how to make the crypto library as portable as possible. I'm thinking about writing it as a C11 header & .c implementation. That way it would be easy to integrate on every platform ( I may use Androids NDK to access the C code from Java). As I understand, Visual C++ can use C headers and functions. Then I will just write a wrapper class in the platforms default language (Objective-C 2.0 for iOs) that will access the cryptographic primitives from the C library...
Is this an ok design?
I will be using sleep() to make all operations last the same time (anti-timing attacks); does this work the same on all platforms? Should this be done in the wrapper rather than the C library?
Should I use open source implementations of the algorithms, or just write my own? (I would like all the code in the crypto library to be 100% C11)
BTW: I'm going to use some non-standard algorithms that most public libraries don't have (Serpent, TwoFish, ThreeFish, as a key derivation function I'm thinking about scrypt) ...
sleep
is a good way of preventing timing attacks against a C library, you have absolutely no business implementing your own crypto. $\endgroup$