expose the private key length in the Android sdk

This commit is contained in:
Hubert Chathi 2018-10-23 12:15:14 -04:00
parent b79590e490
commit 9acfd1791e
4 changed files with 10 additions and 0 deletions

View file

@ -116,6 +116,8 @@ public class OlmPkTest {
(byte)0x1D, (byte)0xB9, (byte)0x2C, (byte)0x2A
};
assertTrue(privateKey.length == OlmPkDecryption.privateKeyLength());
try {
mOlmPkDecryption.setPrivateKey(privateKey);
} catch (OlmException e) {

View file

@ -51,6 +51,8 @@ public class OlmPkDecryption {
return (0 == mNativeId);
}
public static native int privateKeyLength();
public String setPrivateKey(byte[] privateKey) throws OlmException {
try {
byte[] key = setPrivateKeyJni(privateKey);

View file

@ -364,6 +364,11 @@ JNIEXPORT void OLM_PK_DECRYPTION_FUNC_DEF(releasePkDecryptionJni)(JNIEnv *env, j
}
}
JNIEXPORT jint OLM_PK_DECRYPTION_FUNC_DEF(privateKeyLength)(JNIEnv *env, jobject thiz)
{
return (jint) olm_pk_private_key_length();
}
JNIEXPORT jbyteArray OLM_PK_DECRYPTION_FUNC_DEF(setPrivateKeyJni)(JNIEnv *env, jobject thiz, jbyteArray key)
{
jbyteArray publicKeyRet = 0;

View file

@ -35,6 +35,7 @@ JNIEXPORT jbyteArray OLM_PK_ENCRYPTION_FUNC_DEF(encryptJni)(JNIEnv *env, jobject
JNIEXPORT jlong OLM_PK_DECRYPTION_FUNC_DEF(createNewPkDecryptionJni)(JNIEnv *env, jobject thiz);
JNIEXPORT void OLM_PK_DECRYPTION_FUNC_DEF(releasePkDecryptionJni)(JNIEnv *env, jobject thiz);
JNIEXPORT jint OLM_PK_DECRYPTION_FUNC_DEF(privateKeyLength)(JNIEnv *env, jobject thiz);
JNIEXPORT jbyteArray OLM_PK_DECRYPTION_FUNC_DEF(setPrivateKeyJni)(JNIEnv *env, jobject thiz, jbyteArray key);
JNIEXPORT jbyteArray OLM_PK_DECRYPTION_FUNC_DEF(generateKeyJni)(JNIEnv *env, jobject thiz);
JNIEXPORT jbyteArray OLM_PK_DECRYPTION_FUNC_DEF(privateKeyJni)(JNIEnv *env, jobject thiz);