mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-21 06:03:12 +00:00
Added wrapper for safe supply of random bytes for use in Java side.
This commit is contained in:
parent
77757f550d
commit
4636cd6577
13
jni.c
13
jni.c
@ -8,6 +8,19 @@ JNIEXPORT jint JNICALL Java_to_yp_cr_NaCl_moose
|
||||
return 1;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_to_yp_cr_NaCl_nativeRandomBytes
|
||||
(JNIEnv *env, jobject obj, jbyteArray bytes)
|
||||
{
|
||||
int l=(*env)->GetArrayLength(env, bytes);
|
||||
if (l<1) return -1;
|
||||
jbyte *b = (*env)->GetPrimitiveArrayCritical(env, bytes, NULL);
|
||||
|
||||
randombytes(b,l);
|
||||
|
||||
if (b) (*env)->ReleasePrimitiveArrayCritical(env, bytes, b, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Lto/yp/cr/NaCl$CryptoBoxKeypair;.method ([B[B)I
|
||||
JNIEXPORT jint JNICALL Java_to_yp_cr_NaCl_nativeCryptoBoxKeypair
|
||||
(JNIEnv *env, jobject obj, jbyteArray jsk, jbyteArray jpk)
|
||||
|
Loading…
Reference in New Issue
Block a user