├── Android.mk ├── Application.mk ├── README.md ├── images ├── cryptopp-android-100.png ├── cryptopp-android-103.png ├── cryptopp-android-105.png └── cryptopp-android-107.png ├── test_shared.cxx └── test_shared.hxx /Android.mk: -------------------------------------------------------------------------------- 1 | ## Android.mk - Android build file for Crypto++. 2 | ## 3 | ## Written and placed in public domain by Jeffrey Walton. This 4 | ## Android.mk is based on Alex Afanasyev (GitHub @cawka) PR #3, 5 | ## https://github.com/weidai11/cryptopp/pull/3. 6 | ## 7 | ## The Android build system is a wrapper around GNU Make and is 8 | ## documented https://developer.android.com/ndk/guides/android_mk. 9 | ## The CPU Features library provides caps and is documented at 10 | ## https://developer.android.com/ndk/guides/cpu-features. 11 | ## 12 | ## At Crypto++ 8.5 we added test_shared.hxx and test_shared.cxx to 13 | ## produce libtest_shared.so. The test_shared recipe shows you how 14 | ## to build a simple shared object, if desired. A couple wiki pages 15 | ## refers to it for demonstration purposes. The test_shared recipe 16 | ## can be deleted at any time. 17 | ## 18 | ## At Crypto++ 8.6 we used architecture specific flags like in the 19 | ## makefile. The arch specific flags complicated Android.mk because 20 | ## we have to build a local library for each source file with an 21 | ## arch option. To see Android.mk before the changes checkout 22 | ## CRYPTOPP_8_5_0 tag. If you don't want to build like Android.mk 23 | ## does, then add -DCRYPTOPP_DISABLE_ANDROID_ADVANCED_ISA=1 to 24 | ## CPPFLAGS. The define disables the advanced ISA code paths used 25 | ## by Android. 26 | ## 27 | ## The library's makefile and the 'make distclean' recipe will 28 | ## clean the artifacts created by Android.mk, like obj/, 29 | ## neon_simd.cpp.neon and rijndael_simd.cpp.neon. 30 | 31 | ifeq ($(NDK_LOG),1) 32 | $(info Crypto++: TARGET_ARCH: $(TARGET_ARCH)) 33 | $(info Crypto++: TARGET_PLATFORM: $(TARGET_PLATFORM)) 34 | endif 35 | 36 | LOCAL_PATH := $(call my-dir) 37 | 38 | # Check for the test_shared source files. If present, 39 | # build the test shared object. 40 | ifneq ($(wildcard test_shared.hxx),) 41 | ifneq ($(wildcard test_shared.cxx),) 42 | $(info Crypto++: enabling test shared object) 43 | TEST_SHARED_PROJECT := 1 44 | endif 45 | endif 46 | 47 | ##################################################################### 48 | # Adjust CRYPTOPP_PATH to suit your taste, like ../cryptopp-7.1/. 49 | # If CRYPTOPP_PATH is empty then it means the library files and the 50 | # Android files are side-by-side in the same directory. If 51 | # CRYPTOPP_PATH is not empty then must include the trailing slash. 52 | # The trailing slash is needed because CRYPTOPP_PATH is prepended 53 | # to each source file listed in CRYPTOPP_LIB_FILES. 54 | 55 | # CRYPTOPP_PATH ?= ../cryptopp/ 56 | CRYPTOPP_PATH ?= 57 | 58 | ifeq ($(NDK_LOG),1) 59 | ifeq ($CRYPTOPP_PATH),) 60 | $(info Crypto++: CRYPTOPP_PATH is empty) 61 | else 62 | $(info Crypto++: CRYPTOPP_PATH is $(CRYPTOPP_PATH)) 63 | endif 64 | endif 65 | 66 | ##################################################################### 67 | # Test source files 68 | 69 | # Remove adhoc.cpp from this list 70 | 71 | CRYPTOPP_TEST_FILES := \ 72 | test.cpp bench1.cpp bench2.cpp bench3.cpp datatest.cpp \ 73 | dlltest.cpp fipsalgt.cpp validat0.cpp validat1.cpp validat2.cpp \ 74 | validat3.cpp validat4.cpp validat5.cpp validat6.cpp validat7.cpp \ 75 | validat8.cpp validat9.cpp validat10.cpp regtest1.cpp regtest2.cpp \ 76 | regtest3.cpp regtest4.cpp 77 | 78 | CRYPTOPP_TEST_FILES := $(filter-out adhoc.cpp,$(CRYPTOPP_TEST_FILES)) 79 | 80 | ##################################################################### 81 | # Library source files 82 | 83 | # The extra gyrations put cryptlib.cpp cpu.cpp integer.cpp at the head 84 | # of the list so their static initializers run first. Sort is used for 85 | # deterministic builds. 86 | 87 | CRYPTOPP_INIT_FILES := cryptlib.cpp cpu.cpp integer.cpp 88 | CRYPTOPP_ALL_FILES := $(sort $(filter-out adhoc.cpp,$(wildcard *.cpp))) 89 | CRYPTOPP_LIB_FILES := $(filter-out $(CRYPTOPP_TEST_FILES),$(CRYPTOPP_ALL_FILES)) 90 | CRYPTOPP_LIB_FILES := $(filter-out $(CRYPTOPP_INIT_FILES),$(CRYPTOPP_LIB_FILES)) 91 | CRYPTOPP_LIB_FILES := $(CRYPTOPP_INIT_FILES) $(CRYPTOPP_LIB_FILES) 92 | 93 | ##################################################################### 94 | # ARM A-32 source files 95 | 96 | ifeq ($(TARGET_ARCH),arm) 97 | CRYPTOPP_ARM_FILES := aes_armv4.S sha1_armv4.S sha256_armv4.S sha512_armv4.S 98 | CRYPTOPP_LIB_FILES := $(CRYPTOPP_LIB_FILES) $(CRYPTOPP_ARM_FILES) 99 | endif 100 | 101 | ##################################################################### 102 | # Remove unneeded arch specific source files 103 | 104 | CRYPTOPP_LIB_FILES := $(filter-out ppc_simd.cpp,$(CRYPTOPP_LIB_FILES)) 105 | CRYPTOPP_LIB_FILES := $(filter-out neon_simd.cpp,$(CRYPTOPP_LIB_FILES)) 106 | CRYPTOPP_LIB_FILES := $(filter-out sse_simd.cpp,$(CRYPTOPP_LIB_FILES)) 107 | 108 | ifeq ($(TARGET_ARCH),arm) 109 | CRYPTOPP_LIB_FILES := $(filter-out donna_64.cpp,$(CRYPTOPP_LIB_FILES)) 110 | CRYPTOPP_LIB_FILES := $(filter-out %_avx.cpp,$(CRYPTOPP_LIB_FILES)) 111 | endif 112 | 113 | ifeq ($(TARGET_ARCH),arm64) 114 | CRYPTOPP_LIB_FILES := $(filter-out donna_32.cpp,$(CRYPTOPP_LIB_FILES)) 115 | CRYPTOPP_LIB_FILES := $(filter-out %_avx.cpp,$(CRYPTOPP_LIB_FILES)) 116 | endif 117 | 118 | ifeq ($(TARGET_ARCH),x86) 119 | CRYPTOPP_LIB_FILES := $(filter-out donna_64.cpp,$(CRYPTOPP_LIB_FILES)) 120 | endif 121 | 122 | ifeq ($(TARGET_ARCH),x86_64) 123 | CRYPTOPP_LIB_FILES := $(filter-out donna_32.cpp,$(CRYPTOPP_LIB_FILES)) 124 | endif 125 | 126 | ##################################################################### 127 | # Hack because Android.mk does not allow us to specify arch options 128 | # during compile of a source file. Instead, we have to build a 129 | # local library with the arch options. 130 | # https://github.com/weidai11/cryptopp/issues/1015 131 | 132 | CRYPTOPP_LIB_FILES := $(filter-out aria_simd.cpp,$(CRYPTOPP_LIB_FILES)) 133 | CRYPTOPP_LIB_FILES := $(filter-out blake2b_simd.cpp,$(CRYPTOPP_LIB_FILES)) 134 | CRYPTOPP_LIB_FILES := $(filter-out blake2s_simd.cpp,$(CRYPTOPP_LIB_FILES)) 135 | CRYPTOPP_LIB_FILES := $(filter-out chacha_simd.cpp,$(CRYPTOPP_LIB_FILES)) 136 | CRYPTOPP_LIB_FILES := $(filter-out chacha_avx.cpp,$(CRYPTOPP_LIB_FILES)) 137 | CRYPTOPP_LIB_FILES := $(filter-out crc_simd.cpp,$(CRYPTOPP_LIB_FILES)) 138 | CRYPTOPP_LIB_FILES := $(filter-out gcm_simd.cpp,$(CRYPTOPP_LIB_FILES)) 139 | CRYPTOPP_LIB_FILES := $(filter-out gf2n_simd.cpp,$(CRYPTOPP_LIB_FILES)) 140 | CRYPTOPP_LIB_FILES := $(filter-out lea_simd.cpp,$(CRYPTOPP_LIB_FILES)) 141 | CRYPTOPP_LIB_FILES := $(filter-out lsh256_sse.cpp,$(CRYPTOPP_LIB_FILES)) 142 | CRYPTOPP_LIB_FILES := $(filter-out lsh512_sse.cpp,$(CRYPTOPP_LIB_FILES)) 143 | CRYPTOPP_LIB_FILES := $(filter-out lsh256_avx.cpp,$(CRYPTOPP_LIB_FILES)) 144 | CRYPTOPP_LIB_FILES := $(filter-out lsh512_avx.cpp,$(CRYPTOPP_LIB_FILES)) 145 | CRYPTOPP_LIB_FILES := $(filter-out rijndael_simd.cpp,$(CRYPTOPP_LIB_FILES)) 146 | CRYPTOPP_LIB_FILES := $(filter-out sm4_simd.cpp,$(CRYPTOPP_LIB_FILES)) 147 | CRYPTOPP_LIB_FILES := $(filter-out sha_simd.cpp,$(CRYPTOPP_LIB_FILES)) 148 | CRYPTOPP_LIB_FILES := $(filter-out shacal2_simd.cpp,$(CRYPTOPP_LIB_FILES)) 149 | CRYPTOPP_LIB_FILES := $(filter-out simon128_simd.cpp,$(CRYPTOPP_LIB_FILES)) 150 | CRYPTOPP_LIB_FILES := $(filter-out speck128_simd.cpp,$(CRYPTOPP_LIB_FILES)) 151 | 152 | ifeq ($(NDK_LOG),1) 153 | $(info CRYPTOPP_LIB_FILES ($(TARGET_ARCH)): $(CRYPTOPP_LIB_FILES)) 154 | endif 155 | 156 | ##################################################################### 157 | # ARIA using specific ISA. 158 | 159 | # Hack because Android.mk does not allow us to specify arch options 160 | # during compile of a source file. Instead, we have to build a 161 | # local library with the arch options. 162 | # https://github.com/weidai11/cryptopp/issues/1015 163 | 164 | # Check for the aria_simd.cpp source files. If present, 165 | # build the aria_simd object. 166 | ifneq ($(wildcard aria_simd.cpp),) 167 | 168 | include $(CLEAR_VARS) 169 | 170 | LOCAL_MODULE := cryptopp_aria 171 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),aria_simd.cpp) 172 | LOCAL_CPPFLAGS := -Wall 173 | LOCAL_CPP_FEATURES := rtti exceptions 174 | 175 | ifeq ($(TARGET_ARCH),arm) 176 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon 177 | endif 178 | 179 | CRYPTOPP_ARIA_SIMD := cryptopp_aria 180 | 181 | include $(BUILD_STATIC_LIBRARY) 182 | 183 | endif 184 | 185 | ##################################################################### 186 | # BLAKE2s using specific ISA. 187 | 188 | # Hack because Android.mk does not allow us to specify arch options 189 | # during compile of a source file. Instead, we have to build a 190 | # local library with the arch options. 191 | # https://github.com/weidai11/cryptopp/issues/1015 192 | 193 | include $(CLEAR_VARS) 194 | 195 | LOCAL_MODULE := cryptopp_blake2s 196 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),blake2s_simd.cpp) 197 | LOCAL_CPPFLAGS := -Wall 198 | LOCAL_CPP_FEATURES := rtti exceptions 199 | 200 | ifeq ($(TARGET_ARCH),arm) 201 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon 202 | else ifeq ($(TARGET_ARCH),x86) 203 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 204 | else ifeq ($(TARGET_ARCH),x86_64) 205 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 206 | endif 207 | 208 | include $(BUILD_STATIC_LIBRARY) 209 | 210 | ##################################################################### 211 | # BLAKE2b using specific ISA. 212 | 213 | # Hack because Android.mk does not allow us to specify arch options 214 | # during compile of a source file. Instead, we have to build a 215 | # local library with the arch options. 216 | # https://github.com/weidai11/cryptopp/issues/1015 217 | 218 | include $(CLEAR_VARS) 219 | 220 | LOCAL_MODULE := cryptopp_blake2b 221 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),blake2b_simd.cpp) 222 | LOCAL_CPPFLAGS := -Wall 223 | LOCAL_CPP_FEATURES := rtti exceptions 224 | 225 | ifeq ($(TARGET_ARCH),arm) 226 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon 227 | else ifeq ($(TARGET_ARCH),x86) 228 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 229 | else ifeq ($(TARGET_ARCH),x86_64) 230 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 231 | endif 232 | 233 | include $(BUILD_STATIC_LIBRARY) 234 | 235 | ##################################################################### 236 | # ChaCha using specific ISA. 237 | 238 | # Hack because Android.mk does not allow us to specify arch options 239 | # during compile of a source file. Instead, we have to build a 240 | # local library with the arch options. 241 | # https://github.com/weidai11/cryptopp/issues/1015 242 | 243 | include $(CLEAR_VARS) 244 | 245 | LOCAL_MODULE := cryptopp_chacha 246 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),chacha_simd.cpp) 247 | LOCAL_CPPFLAGS := -Wall 248 | LOCAL_CPP_FEATURES := rtti exceptions 249 | 250 | ifeq ($(TARGET_ARCH),arm) 251 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon 252 | else ifeq ($(TARGET_ARCH),x86) 253 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse2 254 | endif 255 | 256 | include $(BUILD_STATIC_LIBRARY) 257 | 258 | ##################################################################### 259 | # ChaCha using specific ISA. 260 | 261 | # Hack because Android.mk does not allow us to specify arch options 262 | # during compile of a source file. Instead, we have to build a 263 | # local library with the arch options. 264 | # https://github.com/weidai11/cryptopp/issues/1015 265 | 266 | ifneq ($(filter x86 x86_64,$(TARGET_ARCH)),) 267 | 268 | include $(CLEAR_VARS) 269 | 270 | LOCAL_MODULE := cryptopp_chacha_avx 271 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),chacha_avx.cpp) 272 | LOCAL_CPPFLAGS := -Wall 273 | LOCAL_CPP_FEATURES := rtti exceptions 274 | 275 | ifeq ($(TARGET_ARCH),x86) 276 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mavx2 277 | else ifeq ($(TARGET_ARCH),x86_64) 278 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mavx2 279 | endif 280 | 281 | CRYPTOPP_CHACHA_AVX := cryptopp_chacha_avx 282 | 283 | include $(BUILD_STATIC_LIBRARY) 284 | 285 | endif 286 | 287 | ##################################################################### 288 | # LEA using specific ISA. 289 | 290 | # Hack because Android.mk does not allow us to specify arch options 291 | # during compile of a source file. Instead, we have to build a 292 | # local library with the arch options. 293 | # https://github.com/weidai11/cryptopp/issues/1015 294 | 295 | include $(CLEAR_VARS) 296 | 297 | LOCAL_MODULE := cryptopp_lea 298 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),lea_simd.cpp) 299 | LOCAL_CPPFLAGS := -Wall 300 | LOCAL_CPP_FEATURES := rtti exceptions 301 | 302 | ifeq ($(TARGET_ARCH),arm) 303 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon 304 | endif 305 | 306 | include $(BUILD_STATIC_LIBRARY) 307 | 308 | ##################################################################### 309 | # LSH256 and LSH512 using specific ISA. 310 | 311 | # Hack because Android.mk does not allow us to specify arch options 312 | # during compile of a source file. Instead, we have to build a 313 | # local library with the arch options. 314 | # https://github.com/weidai11/cryptopp/issues/1015 315 | 316 | ifneq ($(filter x86 x86_64,$(TARGET_ARCH)),) 317 | 318 | include $(CLEAR_VARS) 319 | 320 | LOCAL_MODULE := cryptopp_lsh256_sse 321 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),lsh256_sse.cpp) 322 | LOCAL_CPPFLAGS := -Wall 323 | LOCAL_CPP_FEATURES := rtti exceptions 324 | 325 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mssse3 326 | 327 | CRYPTOPP_LSH256_SSE := cryptopp_lsh256_sse 328 | 329 | include $(BUILD_STATIC_LIBRARY) 330 | 331 | ##################################################################### 332 | 333 | include $(CLEAR_VARS) 334 | 335 | LOCAL_MODULE := cryptopp_lsh512_sse 336 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),lsh512_sse.cpp) 337 | LOCAL_CPPFLAGS := -Wall 338 | LOCAL_CPP_FEATURES := rtti exceptions 339 | 340 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mssse3 341 | 342 | CRYPTOPP_LSH512_SSE := cryptopp_lsh512_sse 343 | 344 | include $(BUILD_STATIC_LIBRARY) 345 | 346 | ##################################################################### 347 | 348 | include $(CLEAR_VARS) 349 | 350 | LOCAL_MODULE := cryptopp_lsh256_avx 351 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),lsh256_avx.cpp) 352 | LOCAL_CPPFLAGS := -Wall 353 | LOCAL_CPP_FEATURES := rtti exceptions 354 | 355 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mavx2 356 | 357 | CRYPTOPP_LSH256_AVX := cryptopp_lsh256_avx 358 | 359 | include $(BUILD_STATIC_LIBRARY) 360 | 361 | ##################################################################### 362 | 363 | include $(CLEAR_VARS) 364 | 365 | LOCAL_MODULE := cryptopp_lsh512_avx 366 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),lsh512_avx.cpp) 367 | LOCAL_CPPFLAGS := -Wall 368 | LOCAL_CPP_FEATURES := rtti exceptions 369 | 370 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mavx2 371 | 372 | CRYPTOPP_LSH512_AVX := cryptopp_lsh512_avx 373 | 374 | include $(BUILD_STATIC_LIBRARY) 375 | 376 | endif 377 | 378 | ##################################################################### 379 | # NEON using specific ISA. 380 | 381 | # Hack because Android.mk does not allow us to specify arch options 382 | # during compile of a source file. Instead, we have to build a 383 | # local library with the arch options. 384 | # https://github.com/weidai11/cryptopp/issues/1015 385 | 386 | ifneq ($(filter arm arm64,$(TARGET_ARCH)),) 387 | 388 | include $(CLEAR_VARS) 389 | 390 | LOCAL_MODULE := cryptopp_neon 391 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),neon_simd.cpp) 392 | LOCAL_CPPFLAGS := -Wall 393 | LOCAL_CPP_FEATURES := rtti exceptions 394 | 395 | ifeq ($(TARGET_ARCH),arm) 396 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon 397 | endif 398 | 399 | include $(BUILD_STATIC_LIBRARY) 400 | 401 | CRYPTOPP_NEON := cryptopp_neon 402 | 403 | endif 404 | 405 | ##################################################################### 406 | # CRC using specific ISA. 407 | 408 | # Hack because Android.mk does not allow us to specify arch options 409 | # during compile of a source file. Instead, we have to build a 410 | # local library with the arch options. 411 | # https://github.com/weidai11/cryptopp/issues/1015 412 | 413 | include $(CLEAR_VARS) 414 | 415 | LOCAL_MODULE := cryptopp_crc 416 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),crc_simd.cpp) 417 | LOCAL_CPPFLAGS := -Wall 418 | LOCAL_CPP_FEATURES := rtti exceptions 419 | 420 | ifeq ($(TARGET_ARCH),arm64) 421 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crc 422 | else ifeq ($(TARGET_ARCH),x86) 423 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.2 424 | else ifeq ($(TARGET_ARCH),x86_64) 425 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.2 426 | endif 427 | 428 | include $(BUILD_STATIC_LIBRARY) 429 | 430 | ##################################################################### 431 | # AES using specific ISA. 432 | 433 | # Hack because Android.mk does not allow us to specify arch options 434 | # during compile of a source file. Instead, we have to build a 435 | # local library with the arch options. 436 | # https://github.com/weidai11/cryptopp/issues/1015 437 | 438 | include $(CLEAR_VARS) 439 | 440 | LOCAL_MODULE := cryptopp_rijndael 441 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),rijndael_simd.cpp) 442 | LOCAL_CPPFLAGS := -Wall 443 | LOCAL_CPP_FEATURES := rtti exceptions 444 | 445 | ifeq ($(TARGET_ARCH),arm64) 446 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto 447 | else ifeq ($(TARGET_ARCH),x86) 448 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -maes 449 | else ifeq ($(TARGET_ARCH),x86_64) 450 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -maes 451 | endif 452 | 453 | include $(BUILD_STATIC_LIBRARY) 454 | 455 | ##################################################################### 456 | # SM4 using specific ISA. 457 | 458 | # Hack because Android.mk does not allow us to specify arch options 459 | # during compile of a source file. Instead, we have to build a 460 | # local library with the arch options 461 | # https://github.com/weidai11/cryptopp/issues/1015 462 | 463 | include $(CLEAR_VARS) 464 | 465 | LOCAL_MODULE := cryptopp_sm4 466 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),sm4_simd.cpp) 467 | LOCAL_CPPFLAGS := -Wall 468 | LOCAL_CPP_FEATURES := rtti exceptions 469 | 470 | ifeq ($(TARGET_ARCH),arm64) 471 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto 472 | else ifeq ($(TARGET_ARCH),x86) 473 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -maes 474 | else ifeq ($(TARGET_ARCH),x86_64) 475 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -maes 476 | endif 477 | 478 | include $(BUILD_STATIC_LIBRARY) 479 | 480 | ##################################################################### 481 | # GCM using specific ISA. 482 | 483 | # Hack because Android.mk does not allow us to specify arch options 484 | # during compile of a source file. Instead, we have to build a 485 | # local library with the arch options 486 | # https://github.com/weidai11/cryptopp/issues/1015 487 | 488 | include $(CLEAR_VARS) 489 | 490 | LOCAL_MODULE := cryptopp_gcm 491 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),gcm_simd.cpp) 492 | LOCAL_CPPFLAGS := -Wall 493 | LOCAL_CPP_FEATURES := rtti exceptions 494 | 495 | ifeq ($(TARGET_ARCH),arm) 496 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon 497 | else ifeq ($(TARGET_ARCH),arm64) 498 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto 499 | else ifeq ($(TARGET_ARCH),x86) 500 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mpclmul 501 | else ifeq ($(TARGET_ARCH),x86_64) 502 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mpclmul 503 | endif 504 | 505 | include $(BUILD_STATIC_LIBRARY) 506 | 507 | ##################################################################### 508 | # GF2N using specific ISA. 509 | 510 | # Hack because Android.mk does not allow us to specify arch options 511 | # during compile of a source file. Instead, we have to build a 512 | # local library with the arch options 513 | # https://github.com/weidai11/cryptopp/issues/1015 514 | 515 | include $(CLEAR_VARS) 516 | 517 | LOCAL_MODULE := cryptopp_gf2n 518 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),gf2n_simd.cpp) 519 | LOCAL_CPPFLAGS := -Wall 520 | LOCAL_CPP_FEATURES := rtti exceptions 521 | 522 | ifeq ($(TARGET_ARCH),arm64) 523 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto 524 | else ifeq ($(TARGET_ARCH),x86) 525 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mpclmul 526 | else ifeq ($(TARGET_ARCH),x86_64) 527 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -mpclmul 528 | endif 529 | 530 | include $(BUILD_STATIC_LIBRARY) 531 | 532 | ##################################################################### 533 | # SHA using specific ISA. 534 | 535 | # Hack because Android.mk does not allow us to specify arch options 536 | # during compile of a source file. Instead, we have to build a 537 | # local library with the arch options. 538 | # https://github.com/weidai11/cryptopp/issues/1015 539 | 540 | include $(CLEAR_VARS) 541 | 542 | LOCAL_MODULE := cryptopp_sha 543 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),sha_simd.cpp) 544 | LOCAL_CPPFLAGS := -Wall 545 | LOCAL_CPP_FEATURES := rtti exceptions 546 | 547 | ifeq ($(TARGET_ARCH),arm64) 548 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto 549 | else ifeq ($(TARGET_ARCH),x86) 550 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -msha 551 | else ifeq ($(TARGET_ARCH),x86_64) 552 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -msha 553 | endif 554 | 555 | include $(BUILD_STATIC_LIBRARY) 556 | 557 | ##################################################################### 558 | # SHACAL2 using specific ISA. 559 | 560 | # Hack because Android.mk does not allow us to specify arch options 561 | # during compile of a source file. Instead, we have to build a 562 | # local library with the arch options. 563 | # https://github.com/weidai11/cryptopp/issues/1015 564 | 565 | include $(CLEAR_VARS) 566 | 567 | LOCAL_MODULE := cryptopp_shacal2 568 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),shacal2_simd.cpp) 569 | LOCAL_CPPFLAGS := -Wall 570 | LOCAL_CPP_FEATURES := rtti exceptions 571 | 572 | ifeq ($(TARGET_ARCH),arm64) 573 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv8-a+crypto 574 | else ifeq ($(TARGET_ARCH),x86) 575 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -msha 576 | else ifeq ($(TARGET_ARCH),x86_64) 577 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 -msha 578 | endif 579 | 580 | include $(BUILD_STATIC_LIBRARY) 581 | 582 | ##################################################################### 583 | # SIMON using specific ISA. 584 | 585 | # Hack because Android.mk does not allow us to specify arch options 586 | # during compile of a source file. Instead, we have to build a 587 | # local library with the arch options. 588 | # https://github.com/weidai11/cryptopp/issues/1015 589 | 590 | include $(CLEAR_VARS) 591 | 592 | LOCAL_MODULE := cryptopp_simon 593 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),simon128_simd.cpp) 594 | LOCAL_CPPFLAGS := -Wall 595 | LOCAL_CPP_FEATURES := rtti exceptions 596 | 597 | ifeq ($(TARGET_ARCH),arm) 598 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon 599 | else ifeq ($(TARGET_ARCH),x86) 600 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 601 | else ifeq ($(TARGET_ARCH),x86_64) 602 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 603 | endif 604 | 605 | include $(BUILD_STATIC_LIBRARY) 606 | 607 | ##################################################################### 608 | # SPECK using specific ISA. 609 | 610 | # Hack because Android.mk does not allow us to specify arch options 611 | # during compile of a source file. Instead, we have to build a 612 | # local library with the arch options. 613 | # https://github.com/weidai11/cryptopp/issues/1015 614 | 615 | include $(CLEAR_VARS) 616 | 617 | LOCAL_MODULE := cryptopp_speck 618 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),speck128_simd.cpp) 619 | LOCAL_CPPFLAGS := -Wall 620 | LOCAL_CPP_FEATURES := rtti exceptions 621 | 622 | ifeq ($(TARGET_ARCH),arm) 623 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -march=armv7-a -mfpu=neon 624 | else ifeq ($(TARGET_ARCH),x86) 625 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 626 | else ifeq ($(TARGET_ARCH),x86_64) 627 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse4.1 628 | endif 629 | 630 | include $(BUILD_STATIC_LIBRARY) 631 | 632 | ##################################################################### 633 | # SSE using specific ISA. 634 | 635 | # Hack because Android.mk does not allow us to specify arch options 636 | # during compile of a source file. Instead, we have to build a 637 | # local library with the arch options. 638 | # https://github.com/weidai11/cryptopp/issues/1015 639 | 640 | ifneq ($(filter x86 x86_64,$(TARGET_ARCH)),) 641 | 642 | include $(CLEAR_VARS) 643 | 644 | LOCAL_MODULE := cryptopp_sse 645 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),sse_simd.cpp) 646 | LOCAL_CPPFLAGS := -Wall 647 | LOCAL_CPP_FEATURES := rtti exceptions 648 | 649 | ifeq ($(TARGET_ARCH),x86) 650 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -msse2 651 | endif 652 | 653 | include $(BUILD_STATIC_LIBRARY) 654 | 655 | CRYPTOPP_SSE := cryptopp_sse 656 | 657 | endif 658 | 659 | ##################################################################### 660 | # Static library 661 | 662 | include $(CLEAR_VARS) 663 | 664 | LOCAL_MODULE := cryptopp_static 665 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),$(CRYPTOPP_LIB_FILES)) 666 | LOCAL_CPPFLAGS := -Wall 667 | LOCAL_CPP_FEATURES := rtti exceptions 668 | 669 | ifeq ($(TARGET_ARCH),arm) 670 | LOCAL_ARM_MODE := arm 671 | LOCAL_FILTER_ASM := 672 | endif 673 | 674 | # Configure for release unless NDK_DEBUG=1 675 | ifeq ($(NDK_DEBUG),1) 676 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DDEBUG 677 | else 678 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DNDEBUG 679 | endif 680 | 681 | # Include all the local libraries for arch specific compiles. 682 | # https://github.com/weidai11/cryptopp/issues/1015 683 | LOCAL_STATIC_LIBRARIES := cpufeatures \ 684 | $(CRYPTOPP_ARIA_SIMD) \ 685 | cryptopp_blake2s cryptopp_blake2b \ 686 | cryptopp_chacha $(CRYPTOPP_CHACHA_AVX) \ 687 | cryptopp_crc \ 688 | cryptopp_gcm cryptopp_gf2n \ 689 | cryptopp_lea $(CRYPTOPP_NEON) \ 690 | cryptopp_rijndael cryptopp_sm4 \ 691 | $(CRYPTOPP_LSH256_SSE) $(CRYPTOPP_LSH256_AVX) \ 692 | $(CRYPTOPP_LSH512_SSE) $(CRYPTOPP_LSH512_AVX) \ 693 | cryptopp_sha cryptopp_shacal2 \ 694 | cryptopp_simon cryptopp_speck \ 695 | $(CRYPTOPP_SSE) 696 | 697 | include $(BUILD_STATIC_LIBRARY) 698 | 699 | ##################################################################### 700 | # Shared object 701 | 702 | include $(CLEAR_VARS) 703 | 704 | LOCAL_MODULE := cryptopp_shared 705 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),$(CRYPTOPP_LIB_FILES)) 706 | LOCAL_CPPFLAGS := -Wall 707 | LOCAL_CPP_FEATURES := rtti exceptions 708 | LOCAL_LDFLAGS := -Wl,--gc-sections -Wl,--exclude-libs,ALL -Wl,--as-needed 709 | 710 | ifeq ($(TARGET_ARCH),arm) 711 | LOCAL_ARM_MODE := arm 712 | LOCAL_FILTER_ASM := 713 | endif 714 | 715 | # Configure for release unless NDK_DEBUG=1 716 | ifeq ($(NDK_DEBUG),1) 717 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DDEBUG 718 | else 719 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DNDEBUG 720 | endif 721 | 722 | # Include all the local libraries for arch specific compiles. 723 | # https://github.com/weidai11/cryptopp/issues/1015 724 | LOCAL_STATIC_LIBRARIES := cpufeatures \ 725 | $(CRYPTOPP_ARIA_SIMD) \ 726 | cryptopp_blake2s cryptopp_blake2b \ 727 | cryptopp_chacha $(CRYPTOPP_CHACHA_AVX) \ 728 | cryptopp_crc \ 729 | cryptopp_gcm cryptopp_gf2n \ 730 | cryptopp_lea $(CRYPTOPP_NEON) \ 731 | $(CRYPTOPP_LSH256_SSE) $(CRYPTOPP_LSH256_AVX) \ 732 | $(CRYPTOPP_LSH512_SSE) $(CRYPTOPP_LSH512_AVX) \ 733 | cryptopp_rijndael cryptopp_sm4 \ 734 | cryptopp_sha cryptopp_shacal2 \ 735 | cryptopp_simon cryptopp_speck \ 736 | $(CRYPTOPP_SSE) 737 | 738 | include $(BUILD_SHARED_LIBRARY) 739 | 740 | ##################################################################### 741 | # Test shared object 742 | 743 | # This recipe is for demonstration purposes. It shows you how to 744 | # build your own shared object. It is OK to delete this recipe and 745 | # the source files test_shared.hxx and test_shared.cxx. 746 | 747 | ifeq ($(TEST_SHARED_PROJECT),1) 748 | 749 | include $(CLEAR_VARS) 750 | 751 | LOCAL_MODULE := test_shared 752 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),test_shared.cxx) 753 | LOCAL_CPPFLAGS := -Wall -fvisibility=hidden 754 | LOCAL_CPP_FEATURES := rtti exceptions 755 | LOCAL_LDFLAGS := -Wl,--gc-sections -Wl,--exclude-libs,ALL -Wl,--as-needed 756 | 757 | ifeq ($(TARGET_ARCH),arm) 758 | LOCAL_ARM_MODE := arm 759 | LOCAL_FILTER_ASM := 760 | endif 761 | 762 | # Configure for release unless NDK_DEBUG=1 763 | ifeq ($(NDK_DEBUG),1) 764 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DDEBUG 765 | else 766 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DNDEBUG 767 | endif 768 | 769 | LOCAL_STATIC_LIBRARIES := cryptopp_static 770 | 771 | include $(BUILD_SHARED_LIBRARY) 772 | 773 | endif 774 | 775 | ##################################################################### 776 | # Test program 777 | 778 | include $(CLEAR_VARS) 779 | 780 | LOCAL_MODULE := cryptest.exe 781 | LOCAL_SRC_FILES := $(addprefix $(CRYPTOPP_PATH),$(CRYPTOPP_TEST_FILES)) 782 | LOCAL_CPPFLAGS := -Wall 783 | LOCAL_CPP_FEATURES := rtti exceptions 784 | LOCAL_LDFLAGS := -Wl,--gc-sections -Wl,--as-needed 785 | 786 | ifeq ($(TARGET_ARCH),arm) 787 | LOCAL_ARM_MODE := arm 788 | LOCAL_FILTER_ASM := 789 | endif 790 | 791 | # Configure for release unless NDK_DEBUG=1 792 | ifeq ($(NDK_DEBUG),1) 793 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DDEBUG 794 | else 795 | LOCAL_CPPFLAGS := $(LOCAL_CPPFLAGS) -DNDEBUG 796 | endif 797 | 798 | LOCAL_STATIC_LIBRARIES := cryptopp_static 799 | 800 | include $(BUILD_EXECUTABLE) 801 | 802 | ##################################################################### 803 | # Android cpuFeatures library 804 | 805 | $(call import-module,android/cpufeatures) 806 | -------------------------------------------------------------------------------- /Application.mk: -------------------------------------------------------------------------------- 1 | ## Application.mk - Android build file for Crypto++. 2 | 3 | ## Written and placed in public domain by Jeffrey Walton. This 4 | ## Android.mk is based on Alex Afanasyev (GitHub @cawka) PR #3, 5 | ## https://github.com/weidai11/cryptopp/pull/3. 6 | ## 7 | ## The Android build system is a wrapper around GNU Make and is 8 | ## documented https://developer.android.com/ndk/guides/android_mk. 9 | ## The CPU Features library provides caps and is documented at 10 | ## https://developer.android.com/ndk/guides/cpu-features. 11 | ## 12 | ## For a list of Android Platforms and API levels see 13 | ## https://developer.android.com/ndk/guides/stable_apis. 14 | ## Android 4.3 is android-18, Android 5 is android-21, 15 | ## and Android 6.0 is android-23. 16 | ## 17 | ## Android recommends c++_shared for NDK version 16.0 and 18 | ## above. Android will be removing other runtime libraries 19 | ## as early as NDK version 18. Also see 20 | ## https://developer.android.com/ndk/guides/cpp-support. 21 | 22 | APP_ABI := all 23 | APP_PLATFORM := android-21 24 | 25 | # APP_STL := gnustl_shared 26 | APP_STL := c++_shared 27 | 28 | CRYPTOPP_ROOT := $(call my-dir) 29 | NDK_PROJECT_PATH := $(CRYPTOPP_ROOT) 30 | APP_BUILD_SCRIPT := $(CRYPTOPP_ROOT)/Android.mk 31 | 32 | GREP ?= grep 33 | NDK_r16_OR_LATER := $(shell $(GREP) -i -c -E "Pkg.Revision = (1[6-9]|[2-9][0-9]\.)" "$$ANDROID_NDK_ROOT/source.properties") 34 | ifneq ($(NDK_r16_OR_LATER),0) 35 | ifneq ($(APP_STL),c++_shared) 36 | $(info Crypto++: NDK r16 or later. Use c++_shared instead of $(APP_STL)) 37 | endif 38 | endif 39 | 40 | ifeq ($(NDK_LOG),1) 41 | $(info Crypto++: ANDROID_NDK_ROOT is $(ANDROID_NDK_ROOT)) 42 | $(info Crypto++: NDK_PROJECT_PATH is $(NDK_PROJECT_PATH)) 43 | $(info Crypto++: APP_BUILD_SCRIPT is $(APP_BUILD_SCRIPT)) 44 | endif 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Crypto++ Android.mk 2 | 3 | This repository contains Android build files for Wei Dai's [Crypto++](http://github.com/weidai11/cryptopp). It supplies `Android.mk` and `Application.mk` for Crypto++ for those who want to use Android build tools. 4 | 5 | The purpose of Crypto++ Android build is two-fold: 6 | 7 | 1. better support Android distributions 8 | 2. supplement the GNUmakefile which is reaching its limits with repsect to GNUmake-based configuration 9 | 10 | The initial `Android.mk` and `Application.mk` based on Alex Afanasyev's pull request at http://github.com/weidai11/cryptopp/pull/3. The pull request went unmerged because we did not want to add the directory structure to accommodate Android builds. Though we did not merge Afanasyev's pull request, Afanasyev should get the credit for this work. 11 | 12 | There is a wiki page available that discusses the Android build system and the Crypto++ project files in more detail at [Android.mk (Command Line)](https://www.cryptopp.com/wiki/Android.mk_(Command_Line)). 13 | 14 | ## Testing 15 | 16 | The Android build files are a work in progress, so use them at your own risk. With that said cryptest-ndk.sh is used to test the build system. 17 | 18 | In September 2016 the library added cryptest-ndk.sh to help test the Android.mk gear. The script is located in Crypto++'s TestScripts directory. The script downloads the Android.mk project files and builds the library. 19 | 20 | If you want to use cryptest-ndk.sh to drive things then perform the following steps. 21 | 22 | ``` 23 | cd cryptopp 24 | cp -p TestScripts/cryptest-ndk.sh . 25 | bash cryptest-ndk.sh 26 | ``` 27 | 28 | ## Workflow 29 | The general workflow is clone Wei Dai's crypto++, fetch the Android files, and then build using `ndk-build`: 30 | 31 | git clone http://github.com/weidai11/cryptopp.git 32 | cd cryptopp 33 | 34 | wget -O Android.mk https://raw.githubusercontent.com/noloader/cryptopp-android/master/Android.mk 35 | wget -O Application.mk https://raw.githubusercontent.com/noloader/cryptopp-android/master/Application.mk 36 | wget -O make_neon.sh https://raw.githubusercontent.com/noloader/cryptopp-android/master/make_neon.sh 37 | 38 | # Create *.neon source files for armeabi-v7a 39 | bash make_neon.sh 40 | 41 | ndk-build NDK_PROJECT_PATH=... NDK_APPLICATION_MK=... 42 | 43 | ## ZIP Files 44 | 45 | If you are working from a Crypto++ release zip file, then you should download the same cryptopp-android release zip file. Both Crypto++ and this project use the same release tags, such as CRYPTOPP_8_0_0. 46 | 47 | If you mix and match Master with a release zip file then things may not work as expected. You may find the build project files reference a source file that is not present in the Crypto++ release. 48 | 49 | ## Prerequisites 50 | 51 | Before running the Android project please ensure you have the following installed: 52 | 53 | 1. Android NDK 54 | 2. Android SDK 55 | 3. `ANDROID_NDK_ROOT` envar set 56 | 4. `ANDROID_SDK_ROOT` envar set 57 | 58 | `ANDROID_NDK_ROOT` and `ANDROID_SDK_ROOT` are NDK and SDK environmental variables used by the Android tools. They should be set whenever you use Android's command line tools. The project does not use environmental variables from Eclipse or Android Studio like `ANDROID_HOME` or `ANDROID_SDK_HOME`. Also see [Recommended NDK Directory?](http://groups.google.com/group/android-ndk/browse_thread/thread/a998e139aca71d77) on the Android NDK mailing list. 59 | 60 | ## Integration 61 | The Android build files require an unusal filesystem layout. Your Crypto++ source files will be located in a folder like `/cryptopp-7.1`. `Android.mk` and `Application.mk` will be located in a folder like `/jni`. You must set `CRYPTOPP_ROOT` in `Android.mk` to a value like `../cryptopp-7.1/`. The trailing slash is important because the build system uses GNU Make's `addprefix` which is a simple concatenation. 62 | 63 | To run the script issue `ndk-build` with several NDK build variables set. `NDK_PROJECT_PATH` and `NDK_APPLICATION_MK` are required when not using Android default paths like `jni/`. 64 | 65 | cd cryptopp 66 | ndk-build V=1 NDK_PROJECT_PATH="$PWD" NDK_APPLICATION_MK="$PWD/Application.mk" 67 | 68 | According to [NDK Build](http://developer.android.com/ndk/guides/ndk-build) you should set `NDK_DEBUG=1` for debug builds and `NDK_DEBUG=0` for release builds. You can also set `NDK_LOG=1` and `V=1` for verbose NDK builds which should help with diagnostics. 69 | 70 | ## Collaboration 71 | We would like all maintainers to be collaborators on this repo. If you are a maintainer then please contact us so we can send you an invite. 72 | 73 | If you are a collaborator then make changes as you see fit. You don't need to ask for permission to make a change. Noloader is not an Android expert so there are probably lots of opportunities for improvement. 74 | 75 | Keep in mind other folks may be using the files, so try not to break things for the other guy. We have to be mindful of different versions of the NDK and API versions. 76 | 77 | Everything in this repo is release under Public Domain code. If the license or terms is unpalatable for you, then don't feel obligated to commit. 78 | -------------------------------------------------------------------------------- /images/cryptopp-android-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noloader/cryptopp-android-mk/7b91b7cb921cc6625df56b07cf3176e6141206bb/images/cryptopp-android-100.png -------------------------------------------------------------------------------- /images/cryptopp-android-103.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noloader/cryptopp-android-mk/7b91b7cb921cc6625df56b07cf3176e6141206bb/images/cryptopp-android-103.png -------------------------------------------------------------------------------- /images/cryptopp-android-105.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noloader/cryptopp-android-mk/7b91b7cb921cc6625df56b07cf3176e6141206bb/images/cryptopp-android-105.png -------------------------------------------------------------------------------- /images/cryptopp-android-107.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noloader/cryptopp-android-mk/7b91b7cb921cc6625df56b07cf3176e6141206bb/images/cryptopp-android-107.png -------------------------------------------------------------------------------- /test_shared.cxx: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | extern "C" DLL_PUBLIC 7 | int sha1_hash(uint8_t* digest, size_t dsize, const uint8_t* message, size_t msize) 8 | { 9 | using CryptoPP::SHA1; 10 | using CryptoPP::Exception; 11 | 12 | try 13 | { 14 | SHA1().CalculateTruncatedDigest(digest, dsize, message, msize); 15 | return 0; // success 16 | } 17 | catch(const Exception&) 18 | { 19 | return 1; // failure 20 | } 21 | } 22 | 23 | extern "C" DLL_PUBLIC 24 | int sha256_hash(uint8_t* digest, size_t dsize, const uint8_t* message, size_t msize) 25 | { 26 | using CryptoPP::SHA256; 27 | using CryptoPP::Exception; 28 | 29 | try 30 | { 31 | SHA256().CalculateTruncatedDigest(digest, dsize, message, msize); 32 | return 0; // success 33 | } 34 | catch(const Exception&) 35 | { 36 | return 1; // failure 37 | } 38 | } 39 | 40 | extern "C" DLL_PUBLIC 41 | int sha512_hash(uint8_t* digest, size_t dsize, const uint8_t* message, size_t msize) 42 | { 43 | using CryptoPP::SHA512; 44 | using CryptoPP::Exception; 45 | 46 | try 47 | { 48 | SHA512().CalculateTruncatedDigest(digest, dsize, message, msize); 49 | return 0; // success 50 | } 51 | catch(const Exception&) 52 | { 53 | return 1; // failure 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /test_shared.hxx: -------------------------------------------------------------------------------- 1 | #ifndef CRYPTOPP_TEST_SHARED 2 | #define CRYPTOPP_TEST_SHARED 3 | 4 | #include 5 | 6 | #if __GNUC__ >= 4 7 | #define DLL_PUBLIC __attribute__ ((visibility ("default"))) 8 | #define DLL_LOCAL __attribute__ ((visibility ("hidden"))) 9 | #else 10 | #define DLL_PUBLIC 11 | #define DLL_LOCAL 12 | #endif 13 | 14 | extern "C" DLL_PUBLIC 15 | int sha1_hash(uint8_t* digest, size_t dsize, const uint8_t* message, size_t msize); 16 | 17 | extern "C" DLL_PUBLIC 18 | int sha256_hash(uint8_t* digest, size_t dsize, const uint8_t* message, size_t msize); 19 | 20 | extern "C" DLL_PUBLIC 21 | int sha512_hash(uint8_t* digest, size_t dsize, const uint8_t* message, size_t msize); 22 | 23 | #endif // CRYPTOPP_TEST_SHARED --------------------------------------------------------------------------------