adds ecc_import_x963() to Java API

pull/2/merge
Moisés Guimarães 2015-10-26 21:10:29 -03:00
parent bf456ebc89
commit f95cd413be
3 changed files with 48 additions and 0 deletions

View File

@ -463,6 +463,14 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_Fips_ecc_1make_1key
JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_Fips_ecc_1shared_1secret
(JNIEnv *, jclass, jobject, jobject, jobject, jlongArray);
/*
* Class: com_wolfssl_wolfcrypt_Fips
* Method: ecc_import_x963
* Signature: (Ljava/nio/ByteBuffer;JLcom/wolfssl/wolfcrypt/Ecc;)I
*/
JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_Fips_ecc_1import_1x963
(JNIEnv *, jclass, jobject, jlong, jobject);
/*
* Class: com_wolfssl_wolfcrypt_Fips
* Method: ecc_export_x963

View File

@ -1530,6 +1530,31 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_Fips_ecc_1shared_1secret(
return ret;
}
JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_Fips_ecc_1import_1x963(
JNIEnv* env, jclass class, jobject in_buffer, jlong inLen,
jobject key_object)
{
jint ret = NOT_COMPILED_IN;
#if defined(HAVE_FIPS) && defined(HAVE_ECC)
ecc_key* key = (ecc_key*) getNativeStruct(env, key_object);
byte* in = getDirectBufferAddress(env, in_buffer);
if (!key || !in)
return BAD_FUNC_ARG;
ret = ecc_import_x963(in, inLen, key);
LogStr("ecc_import_x963(in, inLen, key=%p) = %d\n", key, ret);
LogStr("in:\n");
LogHex(in, inLen);
#endif
return ret;
}
JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_Fips_ecc_1export_1x963(
JNIEnv* env, jclass class, jobject key_object, jobject out_buffer,
jlongArray outLen)

View File

@ -950,6 +950,21 @@ public class Fips extends WolfObject {
public static native int ecc_shared_secret(Ecc private_key, Ecc public_key,
ByteBuffer out, long[] outlen);
/**
* Imports the public ecc key from in of length inLen in x963 format.
*
* @param in
* the input buffer.
* @param inLen
* the input length.
* @param key
* the Ecc object.
*
* @return 0 on success, {@literal <} 0 on error.
*/
public static native int ecc_import_x963(ByteBuffer in, long inLen,
Ecc key);
/**
* Exports the public ecc key into out of length outLen in x963 format.
*