mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-07 00:01:49 -04:00
android: Add utility JNI function to validate proposal strings
This commit is contained in:
parent
2307bffe56
commit
836a943804
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2014 Tobias Brunner
|
* Copyright (C) 2014-2017 Tobias Brunner
|
||||||
* Hochschule fuer Technik Rapperswil
|
* HSR Hochschule fuer Technik Rapperswil
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the
|
* under the terms of the GNU General Public License as published by the
|
||||||
@ -37,4 +37,13 @@ public class Utils
|
|||||||
}
|
}
|
||||||
return new String(hex);
|
return new String(hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the given proposal string
|
||||||
|
*
|
||||||
|
* @param ike true for IKE, false for ESP
|
||||||
|
* @param proposal proposal string
|
||||||
|
* @return true if valid
|
||||||
|
*/
|
||||||
|
public native static boolean isProposalValid(boolean ike, String proposal);
|
||||||
}
|
}
|
||||||
|
@ -716,3 +716,29 @@ JNI_METHOD(CharonVpnService, initiate, void,
|
|||||||
|
|
||||||
initiate(settings);
|
initiate(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility function to verify proposal strings (static, so `this` is the class)
|
||||||
|
*/
|
||||||
|
JNI_METHOD_P(org_strongswan_android_utils, Utils, isProposalValid, jboolean,
|
||||||
|
jboolean ike, jstring proposal)
|
||||||
|
{
|
||||||
|
proposal_t *prop;
|
||||||
|
char *str;
|
||||||
|
bool valid;
|
||||||
|
|
||||||
|
dbg = dbg_android;
|
||||||
|
|
||||||
|
if (!library_init(NULL, "charon"))
|
||||||
|
{
|
||||||
|
library_deinit();
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
str = androidjni_convert_jstring(env, proposal);
|
||||||
|
prop = proposal_create_from_string(ike ? PROTO_IKE : PROTO_ESP, str);
|
||||||
|
valid = prop != NULL;
|
||||||
|
DESTROY_IF(prop);
|
||||||
|
free(str);
|
||||||
|
library_deinit();
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user