Custom crypto library in C 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 &amp; 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 &amp; .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) ...
It's generally strongly recommended you use an existing library for your crypto, instead of trying to reimplement it.  One big advantage of a widely used existing library is that it's been improved over time to deal with new threats.  You may be aware of timing attacks as a current weakness, but these libraries have already solved those problems and many others, and fixed them.

OpenSSL is written in C, widely used and trusted, and could meet your needs.  Cryptlib is distributed under the Sleepycat license (sort of compatible with the GPL) and is also written in C, and has a paid support team.  GnuTLS is LGPL, if you really want GPL compatibility.