diff options
3 files changed, 24 insertions, 3 deletions
diff --git a/nix/cryptoppshim.nix b/nix/cryptoppshim.nix index f526275..2989066 100644 --- a/nix/cryptoppshim.nix +++ b/nix/cryptoppshim.nix @@ -1,5 +1,8 @@ { pkgs, cryptopp }: with pkgs; +let + dotVersion = builtins.replaceStrings ["_"] ["."] cryptopp.version; +in stdenv.mkDerivation { name = "Crypto++ Shim"; src = ../standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni; @@ -14,7 +17,12 @@ stdenv.mkDerivation { make cryptopp ''; - CRYPTOPP_CXXFLAGS = "-DECTESTER_CRYPTOPP_${cryptopp.version}=1"; + CRYPTOPP_CXXFLAGS = '' + -DECTESTER_CRYPTOPP_${cryptopp.version}=1 \ + -DECTESTER_CRYPTOPP_MAJOR=${pkgs.lib.versions.major dotVersion} \ + -DECTESTER_CRYPTOPP_MINOR=${pkgs.lib.versions.minor dotVersion} \ + -DECTESTER_CRYPTOPP_PATCH=${pkgs.lib.versions.patch dotVersion} \ + ''; installPhase = '' mkdir --parents $out/lib diff --git a/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/cpp_utils.hpp b/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/cpp_utils.hpp index ed26c01..0e74ee0 100644 --- a/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/cpp_utils.hpp +++ b/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/cpp_utils.hpp @@ -47,4 +47,13 @@ void add_ka(JNIEnv *env, const std::string &type, const std::string &klass, jobj /** * Add a SignatureSpi class to this provider. */ -void add_sig(JNIEnv *env, const std::string &type, const std::string &klass, jobject provider, jmethodID put_method);
\ No newline at end of file +void add_sig(JNIEnv *env, const std::string &type, const std::string &klass, jobject provider, jmethodID put_method); + +/** + * Version handling. + */ +#define VERSION_GT(lib,a,b,c) ((ECTESTER_##lib##_MAJOR == a && ECTESTER_##lib##_MINOR == b && ECTESTER_##lib##_PATCH > c) || (ECTESTER_##lib##_MAJOR == a && ECTESTER_##lib##_MINOR > b) || (ECTESTER_##lib##_MAJOR > a)) +#define VERSION_EQ(lib,a,b,c) (ECTESTER_##lib##_MAJOR == a && ECTESTER_##lib##_MINOR == b && ECTESTER_##lib##_PATCH == c) +#define VERSION_GE(lib,a,b,c) (VERSION_GT(lib,a,b,c) || VERSION_EQ(lib,a,b,c)) +#define VERSION_LT(lib,a,b,c) !(VERSION_GE(lib,a,b,c)) +#define VERSION_LE(lib,a,b,c) !(VERSION_GT(lib,a,b,c)) diff --git a/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/cryptopp.cpp b/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/cryptopp.cpp index 2cff58c..c194bf6 100644 --- a/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/cryptopp.cpp +++ b/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/cryptopp.cpp @@ -163,7 +163,11 @@ static std::vector<OID> get_all_curve_oids() { } static std::string oid_to_str(const OID &oid) { +#if VERSION_LT(CRYPTOPP, 8, 0, 0) + const std::vector<CryptoPP::word32>& oid_values = oid.m_values; +#else const std::vector<CryptoPP::word32>& oid_values = oid.GetValues(); +#endif std::stringstream ss; for (size_t i = 0; i < oid_values.size(); ++i) { if(i != 0) @@ -839,4 +843,4 @@ JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSigna } // unreachable return JNI_FALSE; -}
\ No newline at end of file +} |
