WIP: Add note about memory safety
This commit is contained in:
@@ -30,7 +30,16 @@ import swiss.qpq.gajumaru.core.tools.CryptoUtils;
|
||||
// Pure Java implementation of Ed25519 curve arithmetic.
|
||||
// Uses exquisitely annoying Radix-2^25.5 field arithmetic. Never do this if you can avoid it.
|
||||
// Verified against the canonical Erlang ec_utils (see test/README.md for how).
|
||||
|
||||
//
|
||||
// SAFETY NOTE:
|
||||
// It turns out that many JVM environments completely lack a way to allocate pinned memory
|
||||
// that lives outside the domain of the garbage collector. While the techniques used in this
|
||||
// code are pretty darn safe, the underlying byte arrays can still get copied on GC before
|
||||
// being zeroed if they are allocated in memory that isn't pinned. It turns out Android is
|
||||
// one such platform, and the solution there is to vendor out a C implementation of Ed25519
|
||||
// and interact with it over a JNI boundary with off-heap memory via java.nio.ByteBuffer.
|
||||
// In cases where this code can run in a fully isolated memory environment it is sufficient.
|
||||
//
|
||||
// References:
|
||||
// I don't even know where to start with references, but the tink-java library and pretty much
|
||||
// everything (and everyone!) referenced on the lib25519 page deserves a mention.
|
||||
|
||||
Reference in New Issue
Block a user