react-native-nitro-bsx 0.0.0-stage → 0.2.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +7 -2
- package/android/CMakeLists.txt +28 -0
- package/android/build.gradle +99 -0
- package/android/src/main/AndroidManifest.xml +35 -0
- package/android/src/main/cpp/cpp-adapter.cpp +12 -0
- package/android/src/main/java/com/nitrobsx/BSXAlarmReceiver.kt +29 -0
- package/android/src/main/java/com/nitrobsx/BSXAlarmScheduler.kt +112 -0
- package/android/src/main/java/com/nitrobsx/BSXForegroundService.kt +78 -0
- package/android/src/main/java/com/nitrobsx/BSXNotifications.kt +47 -0
- package/android/src/main/java/com/nitrobsx/BSXServiceController.kt +90 -0
- package/android/src/main/java/com/nitrobsx/BSXWakeWorker.kt +136 -0
- package/android/src/main/java/com/nitrobsx/HeadlessJsTaskSupportShim.kt +41 -0
- package/android/src/main/java/com/nitrobsx/NitroBSXPackage.kt +28 -0
- package/android/src/main/res/drawable/bsx_ic_stat_swap.xml +9 -0
- package/cpp/BSXContext.cpp +263 -0
- package/cpp/BSXContext.h +49 -0
- package/cpp/BSXModule.cpp +21191 -0
- package/cpp/BSXModule.h +1523 -0
- package/cpp/CMakeLists.txt +463 -0
- package/cpp/HybridNitroBSX.cpp +1483 -0
- package/cpp/HybridNitroBSX.hpp +173 -0
- package/cpp/arith_uint256.cpp +232 -0
- package/cpp/arith_uint256.h +277 -0
- package/cpp/bsx/event.cpp +48 -0
- package/cpp/bsx/event.h +29 -0
- package/cpp/bsx/swap.h +293 -0
- package/cpp/bsx/types.cpp +486 -0
- package/cpp/bsx/types.h +308 -0
- package/cpp/bsx_db.cpp +4951 -0
- package/cpp/bsx_db.h +465 -0
- package/cpp/chain_client.h +143 -0
- package/cpp/cmake/GenVersion.cmake +52 -0
- package/cpp/coin_config.h.in +12 -0
- package/cpp/coins/block_index.cpp +33 -0
- package/cpp/coins/block_index.h +35 -0
- package/cpp/coins/btc/chainparams.cpp +70 -0
- package/cpp/coins/btc/chainparams.h +23 -0
- package/cpp/coins/btc/interface.h +30 -0
- package/cpp/coins/btc_base/interface.cpp +2200 -0
- package/cpp/coins/btc_base/interface.h +225 -0
- package/cpp/coins/btc_base/primitives.cpp +560 -0
- package/cpp/coins/btc_base/primitives.h +157 -0
- package/cpp/coins/btc_base/psbt.cpp +150 -0
- package/cpp/coins/btc_base/psbt.h +52 -0
- package/cpp/coins/btc_base/script.cpp +304 -0
- package/cpp/coins/btc_base/script.h +181 -0
- package/cpp/coins/chainparams.cpp +47 -0
- package/cpp/coins/chainparams.h +58 -0
- package/cpp/coins/firo/chainparams.cpp +52 -0
- package/cpp/coins/firo/chainparams.h +24 -0
- package/cpp/coins/firo/firo.cpp +118 -0
- package/cpp/coins/firo/firo.h +79 -0
- package/cpp/coins/firo/primitives.cpp +109 -0
- package/cpp/coins/firo/primitives.h +47 -0
- package/cpp/coins/interface.cpp +1815 -0
- package/cpp/coins/interface.h +554 -0
- package/cpp/coins/ltc/chainparams.cpp +70 -0
- package/cpp/coins/ltc/chainparams.h +22 -0
- package/cpp/coins/ltc/ltc.cpp +69 -0
- package/cpp/coins/ltc/ltc.h +82 -0
- package/cpp/coins/ltc/primitives.cpp +20 -0
- package/cpp/coins/ltc/primitives.h +18 -0
- package/cpp/coins/part/chainparams.cpp +89 -0
- package/cpp/coins/part/chainparams.h +47 -0
- package/cpp/coins/part/part.cpp +905 -0
- package/cpp/coins/part/part.h +164 -0
- package/cpp/coins/part/primitives.cpp +548 -0
- package/cpp/coins/part/primitives.h +187 -0
- package/cpp/coins/part/stake.cpp +330 -0
- package/cpp/coins/part/stake.h +92 -0
- package/cpp/coins/primitives.h +125 -0
- package/cpp/coins/registry.cpp +99 -0
- package/cpp/coins/registry.h +32 -0
- package/cpp/coins/script.h +18 -0
- package/cpp/coins/types.cpp +60 -0
- package/cpp/coins/types.h +41 -0
- package/cpp/coins/xmr/chainparams.cpp +28 -0
- package/cpp/coins/xmr/chainparams.h +24 -0
- package/cpp/coins/xmr/tx.cpp +670 -0
- package/cpp/coins/xmr/tx.h +77 -0
- package/cpp/coins/xmr/xmr.cpp +639 -0
- package/cpp/coins/xmr/xmr.h +223 -0
- package/cpp/compat/byteswap.h +74 -0
- package/cpp/compat/endian.h +98 -0
- package/cpp/compat/mbedtls/threading_alt.h +20 -0
- package/cpp/compat/sockets.h +160 -0
- package/cpp/contrib/mbedtls/CMakeLists.txt +566 -0
- package/cpp/contrib/mbedtls/LICENSE +553 -0
- package/cpp/contrib/mbedtls/cmake/MbedTLSConfig.cmake.in +3 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_encdec.h +52 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_hashing.h +30 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_mainpage.h +52 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_rng.h +27 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_ssltls.h +37 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_tcpip.h +32 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_x509.h +31 -0
- package/cpp/contrib/mbedtls/doxygen/mbedtls.doxyfile +56 -0
- package/cpp/contrib/mbedtls/framework/CMakeLists.txt +1 -0
- package/cpp/contrib/mbedtls/framework/LICENSE +553 -0
- package/cpp/contrib/mbedtls/include/CMakeLists.txt +21 -0
- package/cpp/contrib/mbedtls/include/mbedtls/build_info.h +93 -0
- package/cpp/contrib/mbedtls/include/mbedtls/debug.h +120 -0
- package/cpp/contrib/mbedtls/include/mbedtls/error.h +39 -0
- package/cpp/contrib/mbedtls/include/mbedtls/mbedtls_config.h +1189 -0
- package/cpp/contrib/mbedtls/include/mbedtls/net_sockets.h +299 -0
- package/cpp/contrib/mbedtls/include/mbedtls/oid.h +304 -0
- package/cpp/contrib/mbedtls/include/mbedtls/pkcs7.h +250 -0
- package/cpp/contrib/mbedtls/include/mbedtls/private/config_adjust_ssl.h +84 -0
- package/cpp/contrib/mbedtls/include/mbedtls/private/config_adjust_x509.h +35 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl.h +5622 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_cache.h +187 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_ciphersuites.h +303 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_cookie.h +90 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_ticket.h +186 -0
- package/cpp/contrib/mbedtls/include/mbedtls/timing.h +105 -0
- package/cpp/contrib/mbedtls/include/mbedtls/version.h +69 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509.h +503 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509_crl.h +180 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509_crt.h +1174 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509_csr.h +368 -0
- package/cpp/contrib/mbedtls/library/CMakeLists.txt +375 -0
- package/cpp/contrib/mbedtls/library/Makefile +334 -0
- package/cpp/contrib/mbedtls/library/debug.c +285 -0
- package/cpp/contrib/mbedtls/library/debug_internal.h +108 -0
- package/cpp/contrib/mbedtls/library/error.c +505 -0
- package/cpp/contrib/mbedtls/library/mbedtls_check_config.h +376 -0
- package/cpp/contrib/mbedtls/library/mbedtls_common.h +51 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config.c +40 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config_check_before.h +1769 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config_check_final.h +12 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config_check_user.h +2436 -0
- package/cpp/contrib/mbedtls/library/mbedtls_platform_requirements.h +55 -0
- package/cpp/contrib/mbedtls/library/mbedtls_utils.h +23 -0
- package/cpp/contrib/mbedtls/library/mps_common.h +181 -0
- package/cpp/contrib/mbedtls/library/mps_error.h +89 -0
- package/cpp/contrib/mbedtls/library/mps_reader.c +538 -0
- package/cpp/contrib/mbedtls/library/mps_reader.h +366 -0
- package/cpp/contrib/mbedtls/library/mps_trace.c +112 -0
- package/cpp/contrib/mbedtls/library/mps_trace.h +154 -0
- package/cpp/contrib/mbedtls/library/net_sockets.c +684 -0
- package/cpp/contrib/mbedtls/library/pkcs7.c +784 -0
- package/cpp/contrib/mbedtls/library/ssl_cache.c +409 -0
- package/cpp/contrib/mbedtls/library/ssl_ciphersuites.c +996 -0
- package/cpp/contrib/mbedtls/library/ssl_ciphersuites_internal.h +108 -0
- package/cpp/contrib/mbedtls/library/ssl_client.c +1019 -0
- package/cpp/contrib/mbedtls/library/ssl_client.h +18 -0
- package/cpp/contrib/mbedtls/library/ssl_cookie.c +251 -0
- package/cpp/contrib/mbedtls/library/ssl_debug_helpers.h +83 -0
- package/cpp/contrib/mbedtls/library/ssl_debug_helpers_generated.c +243 -0
- package/cpp/contrib/mbedtls/library/ssl_misc.h +2851 -0
- package/cpp/contrib/mbedtls/library/ssl_msg.c +6275 -0
- package/cpp/contrib/mbedtls/library/ssl_ticket.c +453 -0
- package/cpp/contrib/mbedtls/library/ssl_tls.c +9048 -0
- package/cpp/contrib/mbedtls/library/ssl_tls12_client.c +3054 -0
- package/cpp/contrib/mbedtls/library/ssl_tls12_server.c +3546 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_client.c +3202 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_generic.c +1773 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_invasive.h +23 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_keys.c +1860 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_keys.h +668 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_server.c +3602 -0
- package/cpp/contrib/mbedtls/library/timing.c +76 -0
- package/cpp/contrib/mbedtls/library/version.c +30 -0
- package/cpp/contrib/mbedtls/library/version_features.c +244 -0
- package/cpp/contrib/mbedtls/library/x509.c +1848 -0
- package/cpp/contrib/mbedtls/library/x509_create.c +747 -0
- package/cpp/contrib/mbedtls/library/x509_crl.c +701 -0
- package/cpp/contrib/mbedtls/library/x509_crt.c +3278 -0
- package/cpp/contrib/mbedtls/library/x509_csr.c +642 -0
- package/cpp/contrib/mbedtls/library/x509_internal.h +97 -0
- package/cpp/contrib/mbedtls/library/x509_oid.c +603 -0
- package/cpp/contrib/mbedtls/library/x509_oid.h +150 -0
- package/cpp/contrib/mbedtls/library/x509write.c +171 -0
- package/cpp/contrib/mbedtls/library/x509write_crt.c +637 -0
- package/cpp/contrib/mbedtls/library/x509write_csr.c +317 -0
- package/cpp/contrib/mbedtls/pkgconfig/CMakeLists.txt +25 -0
- package/cpp/contrib/mbedtls/pkgconfig/JoinPaths.cmake +27 -0
- package/cpp/contrib/mbedtls/pkgconfig/mbedcrypto.pc.in +10 -0
- package/cpp/contrib/mbedtls/pkgconfig/mbedtls.pc.in +11 -0
- package/cpp/contrib/mbedtls/pkgconfig/mbedx509.pc.in +11 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/CMakeLists.txt +584 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/LICENSE +552 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/cmake/TF-PSA-CryptoConfig.cmake.in +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/CMakeLists.txt +193 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/alignment.h +700 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/check_crypto_config.h +111 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/crypto-library.make +57 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto.c +9820 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_client.c +22 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_core.h +972 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_core_common.h +52 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_driver_wrappers.h +3395 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_driver_wrappers_no_static.c +247 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_invasive.h +85 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_its.h +131 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random.c +168 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random.h +72 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random_impl.h +215 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_slot_management.c +998 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_slot_management.h +330 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_storage.c +400 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_storage.h +201 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_its_file.c +254 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_util.c +295 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_check_config.h +598 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_common.h +628 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config.c +72 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_before.h +12 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_final.h +12 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_user.h +1220 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_platform_requirements.h +62 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_version.c +28 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/dispatch/psa_crypto_driver_wrappers_no_static.h +31 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/doxygen/input/doc_mainpage.h.in +51 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/doxygen/tfpsacrypto.doxyfile.in +54 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/CMakeLists.txt +142 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/aes.h +607 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/aria.h +342 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/bignum.h +1137 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/block_cipher.h +76 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/camellia.h +302 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ccm.h +523 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/chacha20.h +230 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/chachapoly.h +339 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/cipher.h +1173 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/cmac.h +209 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/config_adjust_test_accelerators.h +111 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_adjust_config_enable_builtins.h +820 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_adjust_config_tweak_builtins.h +203 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_composites.h +278 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_key_derivation.h +120 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_primitives.h +136 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ctr_drbg.h +554 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecdsa.h +667 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecjpake.h +296 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecp.h +1452 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/entropy.h +253 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/error_common.h +79 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/gcm.h +382 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/hmac_drbg.h +426 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/md5.h +169 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/pkcs5.h +123 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/poly1305.h +165 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ripemd160.h +120 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/rsa.h +821 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha1.h +196 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha256.h +180 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha3.h +189 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha512.h +188 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private_access.h +53 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aes.c +2236 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesce.c +624 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesce.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesni.c +846 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesni.h +162 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aria.c +966 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum.c +2635 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c +1242 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.h +885 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core_invasive.h +38 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_internal.h +164 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod.c +394 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod.h +452 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.c +276 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.h +416 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw_invasive.h +34 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/block_cipher.c +207 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/block_cipher_internal.h +99 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bn_mul.h +1094 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/camellia.c +1055 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ccm.c +773 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20.c +576 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20_neon.c +294 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20_neon.h +62 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chachapoly.c +479 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher.c +1126 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_invasive.h +28 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_wrap.c +1937 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_wrap.h +173 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cmac.c +911 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ctr.h +35 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ctr_drbg.c +1017 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecdsa.c +826 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecjpake.c +1206 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp.c +3478 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp_curves.c +4798 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp_invasive.h +220 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy.c +677 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy_poll.c +89 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy_poll.h +44 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/gcm.c +1314 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/hmac_drbg.c +639 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/md5.c +419 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/md_psa.h +26 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/poly1305.c +488 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_aead.c +648 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_aead.h +499 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_cipher.c +752 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_cipher.h +314 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.c +921 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.h +516 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ffdh.c +781 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ffdh.h +131 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_hash.c +458 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_hash.h +211 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_mac.c +495 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_mac.h +264 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_pake.c +568 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_pake.h +159 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_rsa.c +698 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_rsa.h +321 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_xof.c +149 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_xof.h +155 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_util_internal.c +282 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_util_internal.h +132 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ripemd160.c +482 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa.c +2720 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.c +294 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.h +185 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_internal.h +172 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_invasive.h +57 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha1.c +473 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha256.c +956 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha3.c +951 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha512.c +1089 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/driver.cmake +54 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/CMakeLists.txt +45 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/Makefile.inc +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/README.md +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/Hacl_Curve25519.h +25 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib/FStar_UInt128.h +124 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.h +280 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib.h +29 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/c_endianness.h +206 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/builtin.h +16 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/callconv.h +48 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/compat.h +34 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/debug.h +57 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/target.h +102 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/types.h +61 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/wasmsupport.h +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/vs2013/Hacl_Curve25519.h +21 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/x25519.h +48 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/Hacl_Curve25519.c +760 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/Hacl_Curve25519_joined.c +50 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/kremlib/FStar_UInt128_extracted.c +413 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.c +100 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/legacy/Hacl_Curve25519.c +805 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/x25519.c +52 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/CMakeLists.txt +36 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/Makefile.inc +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/README.md +4 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/README.md +544 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/p256-m.c +1514 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/p256-m.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m_driver_entrypoints.c +312 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m_driver_entrypoints.h +219 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/CMakeLists.txt +14 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/Makefile.inc +6 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/include/tf-psa-crypto/private/crypto_struct_pqcp.h +52 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/fips202_psa.h +117 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/pqcp-config.h +68 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/psa_crypto_mldsa.c +528 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/psa_crypto_mldsa.h +301 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/wrap_mldsa_native.c +66 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/wrap_mldsa_native.h +37 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lmots.c +768 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lmots.h +272 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lms.c +772 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/md.c +1182 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/md_wrap.h +46 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/nist_kw.c +458 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk.c +1464 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_ecc.c +175 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_internal.h +188 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_rsa.c +106 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_wrap.c +667 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_wrap.h +101 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkparse.c +1351 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkwrite.c +574 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkwrite.h +101 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/framework/CMakeLists.txt +1 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/framework/LICENSE +553 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/CMakeLists.txt +41 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/asn1.h +623 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/asn1write.h +397 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/base64.h +81 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/compat-3-crypto.h +43 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/constant_time.h +36 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/lms.h +431 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/md.h +538 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/memory_buffer_alloc.h +142 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/nist_kw.h +106 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/pem.h +157 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/pk.h +888 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform.h +513 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform_time.h +79 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform_util.h +197 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/private/pk_private.h +150 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/psa_util.h +199 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/threading.h +412 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto.h +6082 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_compat.h +74 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_config.h +2073 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_common.h +42 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_composites.h +182 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_key_derivation.h +54 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_primitives.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_random.h +49 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_extra.h +2115 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_platform.h +94 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_sizes.h +1301 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_struct.h +682 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_types.h +466 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_values.h +2827 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/build_info.h +193 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_auto_enabled.h +23 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_dependencies.h +58 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_derived.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_key_pair_types.h +93 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_support.h +211 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_synonyms.h +41 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/version.h +44 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/objlib.cmake +71 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/CMakeLists.txt +15 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/JoinPaths.cmake +27 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/tfpsacrypto.pc.in +10 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/memory_buffer_alloc.c +751 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/platform.c +362 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/platform_util.c +428 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/threading.c +311 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/threading_internal.h +75 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/asn1parse.c +483 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/asn1write.c +465 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/base64.c +322 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/base64_internal.h +45 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time.c +247 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time_impl.h +514 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time_internal.h +540 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/crypto_oid.h +354 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/oid.c +469 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/pem.c +458 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/pkcs5.c +475 -0
- package/cpp/contrib/monero/LICENSE +41 -0
- package/cpp/contrib/monero/bsx/common/perf_timer.h +15 -0
- package/cpp/contrib/monero/bsx/common/threadpool.h +43 -0
- package/cpp/contrib/monero/bsx/hex.h +25 -0
- package/cpp/contrib/monero/bsx/misc_log_ex.h +61 -0
- package/cpp/contrib/monero/bsx/random.cpp +20 -0
- package/cpp/contrib/monero/contrib/epee/include/int-util.h +320 -0
- package/cpp/contrib/monero/contrib/epee/include/memwipe.h +81 -0
- package/cpp/contrib/monero/contrib/epee/include/misc_language.h +109 -0
- package/cpp/contrib/monero/contrib/epee/include/mlocker.h +89 -0
- package/cpp/contrib/monero/contrib/epee/include/span.h +189 -0
- package/cpp/contrib/monero/contrib/epee/include/warnings.h +31 -0
- package/cpp/contrib/monero/contrib/epee/src/memwipe.c +115 -0
- package/cpp/contrib/monero/contrib/epee/src/mlocker.cpp +197 -0
- package/cpp/contrib/monero/src/common/aligned.c +139 -0
- package/cpp/contrib/monero/src/common/aligned.h +42 -0
- package/cpp/contrib/monero/src/common/base58.cpp +259 -0
- package/cpp/contrib/monero/src/common/base58.h +46 -0
- package/cpp/contrib/monero/src/common/pod-class.h +43 -0
- package/cpp/contrib/monero/src/common/varint.h +138 -0
- package/cpp/contrib/monero/src/crypto/chacha.h +96 -0
- package/cpp/contrib/monero/src/crypto/crypto-ops-data.c +881 -0
- package/cpp/contrib/monero/src/crypto/crypto-ops.c +3891 -0
- package/cpp/contrib/monero/src/crypto/crypto-ops.h +167 -0
- package/cpp/contrib/monero/src/crypto/crypto.cpp +792 -0
- package/cpp/contrib/monero/src/crypto/crypto.h +359 -0
- package/cpp/contrib/monero/src/crypto/generic-ops.h +103 -0
- package/cpp/contrib/monero/src/crypto/hash-ops.h +105 -0
- package/cpp/contrib/monero/src/crypto/hash.c +57 -0
- package/cpp/contrib/monero/src/crypto/hash.h +110 -0
- package/cpp/contrib/monero/src/crypto/keccak.c +239 -0
- package/cpp/contrib/monero/src/crypto/keccak.h +40 -0
- package/cpp/contrib/monero/src/crypto/random.h +46 -0
- package/cpp/contrib/monero/src/crypto/tree-hash.c +257 -0
- package/cpp/contrib/monero/src/crypto/wallet/crypto.h +57 -0
- package/cpp/contrib/monero/src/crypto/wallet/ops.h +32 -0
- package/cpp/contrib/monero/src/cryptonote_config.h +365 -0
- package/cpp/contrib/monero/src/device/device.cpp +105 -0
- package/cpp/contrib/monero/src/device/device.hpp +274 -0
- package/cpp/contrib/monero/src/device/device_default.cpp +343 -0
- package/cpp/contrib/monero/src/device/device_default.hpp +156 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs.cc +1097 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs.h +51 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs_plus.cc +1120 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs_plus.h +49 -0
- package/cpp/contrib/monero/src/ringct/multiexp.cc +708 -0
- package/cpp/contrib/monero/src/ringct/multiexp.h +72 -0
- package/cpp/contrib/monero/src/ringct/rctCryptoOps.c +221 -0
- package/cpp/contrib/monero/src/ringct/rctCryptoOps.h +37 -0
- package/cpp/contrib/monero/src/ringct/rctOps.cpp +727 -0
- package/cpp/contrib/monero/src/ringct/rctOps.h +191 -0
- package/cpp/contrib/monero/src/ringct/rctSigs.cpp +1652 -0
- package/cpp/contrib/monero/src/ringct/rctSigs.h +143 -0
- package/cpp/contrib/monero/src/ringct/rctTypes.cpp +338 -0
- package/cpp/contrib/monero/src/ringct/rctTypes.h +842 -0
- package/cpp/contrib/monero/src/serialization/binary_archive.h +243 -0
- package/cpp/contrib/monero/src/serialization/container.h +146 -0
- package/cpp/contrib/monero/src/serialization/containers.h +127 -0
- package/cpp/contrib/monero/src/serialization/crypto.h +97 -0
- package/cpp/contrib/monero/src/serialization/debug_archive.h +53 -0
- package/cpp/contrib/monero/src/serialization/json_archive.h +193 -0
- package/cpp/contrib/monero/src/serialization/serialization.h +328 -0
- package/cpp/contrib/monero/src/serialization/variant.h +50 -0
- package/cpp/contrib/nlohmann/LICENSE.MIT +21 -0
- package/cpp/contrib/nlohmann/json.hpp +25526 -0
- package/cpp/contrib/nlohmann/json_fwd.hpp +187 -0
- package/cpp/contrib/notes.txt +96 -0
- package/cpp/contrib/secp256k1/CHANGELOG.md +214 -0
- package/cpp/contrib/secp256k1/CMakeLists.txt +392 -0
- package/cpp/contrib/secp256k1/CMakePresets.json +18 -0
- package/cpp/contrib/secp256k1/CONTRIBUTING.md +111 -0
- package/cpp/contrib/secp256k1/COPYING +19 -0
- package/cpp/contrib/secp256k1/Makefile.am +332 -0
- package/cpp/contrib/secp256k1/README.md +176 -0
- package/cpp/contrib/secp256k1/SECURITY.md +15 -0
- package/cpp/contrib/secp256k1/autogen.sh +3 -0
- package/cpp/contrib/secp256k1/ci/ci.sh +147 -0
- package/cpp/contrib/secp256k1/ci/linux-debian.Dockerfile +84 -0
- package/cpp/contrib/secp256k1/ci/travis.sh +68 -0
- package/cpp/contrib/secp256k1/cmake/CheckArm32Assembly.cmake +6 -0
- package/cpp/contrib/secp256k1/cmake/CheckMemorySanitizer.cmake +18 -0
- package/cpp/contrib/secp256k1/cmake/CheckStringOptionValue.cmake +10 -0
- package/cpp/contrib/secp256k1/cmake/CheckX86_64Assembly.cmake +15 -0
- package/cpp/contrib/secp256k1/cmake/DiscoverTests.cmake +71 -0
- package/cpp/contrib/secp256k1/cmake/FindValgrind.cmake +41 -0
- package/cpp/contrib/secp256k1/cmake/GeneratePkgConfigFile.cmake +8 -0
- package/cpp/contrib/secp256k1/cmake/TryAppendCFlags.cmake +24 -0
- package/cpp/contrib/secp256k1/cmake/arm-linux-gnueabihf.toolchain.cmake +3 -0
- package/cpp/contrib/secp256k1/cmake/config.cmake.in +5 -0
- package/cpp/contrib/secp256k1/cmake/source_arm32.s +9 -0
- package/cpp/contrib/secp256k1/cmake/x86_64-w64-mingw32.toolchain.cmake +3 -0
- package/cpp/contrib/secp256k1/configure.ac +590 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_parsing.c +148 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_parsing.h +97 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_privatekey_parsing.c +112 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_privatekey_parsing.h +95 -0
- package/cpp/contrib/secp256k1/doc/ellswift.md +483 -0
- package/cpp/contrib/secp256k1/doc/musig.md +54 -0
- package/cpp/contrib/secp256k1/doc/release-process.md +94 -0
- package/cpp/contrib/secp256k1/doc/safegcd_implementation.md +819 -0
- package/cpp/contrib/secp256k1/examples/CMakeLists.txt +33 -0
- package/cpp/contrib/secp256k1/examples/EXAMPLES_COPYING +121 -0
- package/cpp/contrib/secp256k1/examples/ecdh.c +121 -0
- package/cpp/contrib/secp256k1/examples/ecdsa.c +138 -0
- package/cpp/contrib/secp256k1/examples/ellswift.c +122 -0
- package/cpp/contrib/secp256k1/examples/examples_util.h +108 -0
- package/cpp/contrib/secp256k1/examples/musig.c +261 -0
- package/cpp/contrib/secp256k1/examples/schnorr.c +154 -0
- package/cpp/contrib/secp256k1/include/secp256k1.h +877 -0
- package/cpp/contrib/secp256k1/include/secp256k1_dleag.h +150 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ecdh.h +63 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ecdsaotves.h +55 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ed25519.h +239 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ellswift.h +200 -0
- package/cpp/contrib/secp256k1/include/secp256k1_extrakeys.h +250 -0
- package/cpp/contrib/secp256k1/include/secp256k1_generator.h +106 -0
- package/cpp/contrib/secp256k1/include/secp256k1_hash.h +45 -0
- package/cpp/contrib/secp256k1/include/secp256k1_musig.h +588 -0
- package/cpp/contrib/secp256k1/include/secp256k1_preallocated.h +134 -0
- package/cpp/contrib/secp256k1/include/secp256k1_recovery.h +123 -0
- package/cpp/contrib/secp256k1/include/secp256k1_schnorrsig.h +190 -0
- package/cpp/contrib/secp256k1/include/visibility.h +58 -0
- package/cpp/contrib/secp256k1/libsecp256k1.pc.in +12 -0
- package/cpp/contrib/secp256k1/sage/gen_exhaustive_groups.sage +156 -0
- package/cpp/contrib/secp256k1/sage/gen_split_lambda_constants.sage +123 -0
- package/cpp/contrib/secp256k1/sage/group_prover.sage +353 -0
- package/cpp/contrib/secp256k1/sage/prove_group_implementations.sage +285 -0
- package/cpp/contrib/secp256k1/sage/secp256k1_params.sage +39 -0
- package/cpp/contrib/secp256k1/sage/weierstrass_prover.sage +275 -0
- package/cpp/contrib/secp256k1/src/CMakeLists.txt +253 -0
- package/cpp/contrib/secp256k1/src/asm/field_10x26_arm.s +916 -0
- package/cpp/contrib/secp256k1/src/assumptions.h +87 -0
- package/cpp/contrib/secp256k1/src/checkmem.h +117 -0
- package/cpp/contrib/secp256k1/src/ecdsa.h +21 -0
- package/cpp/contrib/secp256k1/src/ecdsa_impl.h +312 -0
- package/cpp/contrib/secp256k1/src/eckey.h +28 -0
- package/cpp/contrib/secp256k1/src/eckey_impl.h +94 -0
- package/cpp/contrib/secp256k1/src/ecmult.h +64 -0
- package/cpp/contrib/secp256k1/src/ecmult_compute_table.h +16 -0
- package/cpp/contrib/secp256k1/src/ecmult_compute_table_impl.h +49 -0
- package/cpp/contrib/secp256k1/src/ecmult_const.h +38 -0
- package/cpp/contrib/secp256k1/src/ecmult_const_impl.h +402 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen.h +144 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen_compute_table.h +14 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen_compute_table_impl.h +108 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen_impl.h +341 -0
- package/cpp/contrib/secp256k1/src/ecmult_impl.h +869 -0
- package/cpp/contrib/secp256k1/src/field.h +354 -0
- package/cpp/contrib/secp256k1/src/field_10x26.h +57 -0
- package/cpp/contrib/secp256k1/src/field_10x26_impl.h +1234 -0
- package/cpp/contrib/secp256k1/src/field_5x52.h +62 -0
- package/cpp/contrib/secp256k1/src/field_5x52_impl.h +524 -0
- package/cpp/contrib/secp256k1/src/field_5x52_int128_impl.h +274 -0
- package/cpp/contrib/secp256k1/src/field_impl.h +462 -0
- package/cpp/contrib/secp256k1/src/group.h +224 -0
- package/cpp/contrib/secp256k1/src/group_impl.h +1024 -0
- package/cpp/contrib/secp256k1/src/hash.h +54 -0
- package/cpp/contrib/secp256k1/src/hash_impl.h +360 -0
- package/cpp/contrib/secp256k1/src/hsort.h +33 -0
- package/cpp/contrib/secp256k1/src/hsort_impl.h +125 -0
- package/cpp/contrib/secp256k1/src/int128.h +90 -0
- package/cpp/contrib/secp256k1/src/int128_impl.h +18 -0
- package/cpp/contrib/secp256k1/src/int128_native.h +19 -0
- package/cpp/contrib/secp256k1/src/int128_native_impl.h +94 -0
- package/cpp/contrib/secp256k1/src/int128_struct.h +14 -0
- package/cpp/contrib/secp256k1/src/int128_struct_impl.h +205 -0
- package/cpp/contrib/secp256k1/src/modinv32.h +43 -0
- package/cpp/contrib/secp256k1/src/modinv32_impl.h +725 -0
- package/cpp/contrib/secp256k1/src/modinv64.h +47 -0
- package/cpp/contrib/secp256k1/src/modinv64_impl.h +780 -0
- package/cpp/contrib/secp256k1/src/modules/dleag/Makefile.am.include +3 -0
- package/cpp/contrib/secp256k1/src/modules/dleag/main_impl.h +1073 -0
- package/cpp/contrib/secp256k1/src/modules/dleag/tests_impl.h +68 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/bench_impl.h +54 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/main_impl.h +79 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/tests_impl.h +218 -0
- package/cpp/contrib/secp256k1/src/modules/ecdsaotves/Makefile.am.include +3 -0
- package/cpp/contrib/secp256k1/src/modules/ecdsaotves/main_impl.h +365 -0
- package/cpp/contrib/secp256k1/src/modules/ecdsaotves/tests_impl.h +49 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/Makefile.am.include +16 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/common.h +68 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/core_ed25519.h +229 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/main_impl.h +98 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/common.h +21 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10.h +2698 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10_fe_25_5.h +1056 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10_fe_51.h +518 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/base.h +1344 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/base2.h +40 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/constants.h +40 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/fe.h +220 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/scalarmult_ed25519_ref10.h +417 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/sha512/hash_sha512.h +14 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/sha512/hash_sha512_cp.h +287 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/tests_impl.h +109 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/utils.h +97 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/bench_impl.h +106 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/main_impl.h +581 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/tests_exhaustive_impl.h +39 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/tests_impl.h +544 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/Makefile.am.include +4 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/main_impl.h +285 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/tests_exhaustive_impl.h +68 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/tests_impl.h +484 -0
- package/cpp/contrib/secp256k1/src/modules/generator/Makefile.am.include +9 -0
- package/cpp/contrib/secp256k1/src/modules/generator/main_impl.h +271 -0
- package/cpp/contrib/secp256k1/src/modules/generator/tests_impl.h +227 -0
- package/cpp/contrib/secp256k1/src/modules/musig/Makefile.am.include +8 -0
- package/cpp/contrib/secp256k1/src/modules/musig/keyagg.h +32 -0
- package/cpp/contrib/secp256k1/src/modules/musig/keyagg_impl.h +275 -0
- package/cpp/contrib/secp256k1/src/modules/musig/main_impl.h +12 -0
- package/cpp/contrib/secp256k1/src/modules/musig/session.h +24 -0
- package/cpp/contrib/secp256k1/src/modules/musig/session_impl.h +795 -0
- package/cpp/contrib/secp256k1/src/modules/musig/tests_impl.h +1161 -0
- package/cpp/contrib/secp256k1/src/modules/musig/vectors.h +346 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/bench_impl.h +62 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/main_impl.h +159 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/tests_exhaustive_impl.h +148 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/tests_impl.h +339 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/bench_impl.h +104 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/main_impl.h +263 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/tests_exhaustive_impl.h +214 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/tests_impl.h +1010 -0
- package/cpp/contrib/secp256k1/src/precompute_ecmult.c +91 -0
- package/cpp/contrib/secp256k1/src/precompute_ecmult_gen.c +101 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult.c +16456 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult.h +40 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult_gen.c +1779 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult_gen.h +28 -0
- package/cpp/contrib/secp256k1/src/scalar.h +108 -0
- package/cpp/contrib/secp256k1/src/scalar_4x64.h +19 -0
- package/cpp/contrib/secp256k1/src/scalar_4x64_impl.h +1010 -0
- package/cpp/contrib/secp256k1/src/scalar_8x32.h +19 -0
- package/cpp/contrib/secp256k1/src/scalar_8x32_impl.h +830 -0
- package/cpp/contrib/secp256k1/src/scalar_impl.h +321 -0
- package/cpp/contrib/secp256k1/src/scalar_low.h +24 -0
- package/cpp/contrib/secp256k1/src/scalar_low_impl.h +215 -0
- package/cpp/contrib/secp256k1/src/scratch.h +44 -0
- package/cpp/contrib/secp256k1/src/scratch_impl.h +99 -0
- package/cpp/contrib/secp256k1/src/secp256k1.c +896 -0
- package/cpp/contrib/secp256k1/src/selftest.h +35 -0
- package/cpp/contrib/secp256k1/src/testrand.h +45 -0
- package/cpp/contrib/secp256k1/src/testrand_impl.h +162 -0
- package/cpp/contrib/secp256k1/src/testutil.h +161 -0
- package/cpp/contrib/secp256k1/src/unit_test.c +479 -0
- package/cpp/contrib/secp256k1/src/unit_test.h +147 -0
- package/cpp/contrib/secp256k1/src/util.h +469 -0
- package/cpp/contrib/secp256k1/src/util_local_visibility.h +12 -0
- package/cpp/contrib/secp256k1/tools/check-abi.sh +67 -0
- package/cpp/contrib/secp256k1/tools/symbol-check.py +72 -0
- package/cpp/contrib/secp256k1/tools/test_vectors_musig2_generate.py +656 -0
- package/cpp/contrib/secp256k1/tools/tests_wycheproof_generate_ecdh.py +166 -0
- package/cpp/contrib/secp256k1/tools/tests_wycheproof_generate_ecdsa.py +111 -0
- package/cpp/contrib/secp256k1/tools/wycheproof_utils.py +12 -0
- package/cpp/contrib/secp256k1/wasm/test_module.html +320 -0
- package/cpp/contrib/secp256k1/wasm/wrap.cpp +331 -0
- package/cpp/contrib/sqlite3.h +14349 -0
- package/cpp/contrib/sqlite3mc_amalgamation.c +369890 -0
- package/cpp/contrib/sqlite3mc_amalgamation.h +15548 -0
- package/cpp/contrib/unilib/uninorms.cpp +393 -0
- package/cpp/contrib/unilib/uninorms.h +56 -0
- package/cpp/contrib/unilib/utf8.cpp +78 -0
- package/cpp/contrib/unilib/utf8.h +260 -0
- package/cpp/contrib/update_mbedtls.sh +85 -0
- package/cpp/crypto/aes.cpp +141 -0
- package/cpp/crypto/aes.h +67 -0
- package/cpp/crypto/chacha20.cpp +342 -0
- package/cpp/crypto/chacha20.h +82 -0
- package/cpp/crypto/chacha20poly1305.cpp +91 -0
- package/cpp/crypto/chacha20poly1305.h +46 -0
- package/cpp/crypto/common.h +85 -0
- package/cpp/crypto/ctaes/COPYING +21 -0
- package/cpp/crypto/ctaes/README.md +41 -0
- package/cpp/crypto/ctaes/bench.c +170 -0
- package/cpp/crypto/ctaes/ctaes.c +556 -0
- package/cpp/crypto/ctaes/ctaes.h +41 -0
- package/cpp/crypto/ctaes/test.c +110 -0
- package/cpp/crypto/extkey.cpp +257 -0
- package/cpp/crypto/extkey.h +66 -0
- package/cpp/crypto/hmac_sha512.cpp +37 -0
- package/cpp/crypto/hmac_sha512.h +32 -0
- package/cpp/crypto/merkle.cpp +47 -0
- package/cpp/crypto/merkle.h +20 -0
- package/cpp/crypto/poly1305.cpp +223 -0
- package/cpp/crypto/poly1305.h +59 -0
- package/cpp/crypto/ripemd160.cpp +292 -0
- package/cpp/crypto/ripemd160.h +28 -0
- package/cpp/crypto/scrypt-sse2.cpp +141 -0
- package/cpp/crypto/scrypt.cpp +336 -0
- package/cpp/crypto/scrypt.h +49 -0
- package/cpp/crypto/sealed_key.cpp +62 -0
- package/cpp/crypto/sealed_key.h +34 -0
- package/cpp/crypto/secure_bytes.h +16 -0
- package/cpp/crypto/sha512.cpp +206 -0
- package/cpp/crypto/sha512.h +29 -0
- package/cpp/crypto/util.cpp +77 -0
- package/cpp/crypto/util.h +32 -0
- package/cpp/debug_rpc.cpp +703 -0
- package/cpp/debug_rpc.h +63 -0
- package/cpp/electrum.cpp +931 -0
- package/cpp/electrum.h +169 -0
- package/cpp/engine/xmr_engine.cpp +463 -0
- package/cpp/engine/xmr_engine.h +84 -0
- package/cpp/engine/xmr_engine_c.cpp +141 -0
- package/cpp/engine/xmr_engine_c.h +35 -0
- package/cpp/fees.cpp +270 -0
- package/cpp/fees.h +60 -0
- package/cpp/height_search.cpp +64 -0
- package/cpp/height_search.h +27 -0
- package/cpp/main.cpp +146 -0
- package/cpp/messages_npb.cpp +701 -0
- package/cpp/messages_npb.h +667 -0
- package/cpp/mnemonic/mnemonic.cpp +715 -0
- package/cpp/mnemonic/mnemonic.h +52 -0
- package/cpp/mnemonic/wordlists/english.h +1103 -0
- package/cpp/mnemonic/wordlists/japanese.h +2212 -0
- package/cpp/network/bridge.cpp +232 -0
- package/cpp/network/bridge.h +115 -0
- package/cpp/network/ca_roots.cpp +114 -0
- package/cpp/network/ca_roots.h +12 -0
- package/cpp/network/http_client.cpp +261 -0
- package/cpp/network/http_client.h +33 -0
- package/cpp/network/pem.cpp +84 -0
- package/cpp/network/pem.h +22 -0
- package/cpp/network/psa_user_config.h +15 -0
- package/cpp/network/socks5.cpp +180 -0
- package/cpp/network/socks5.h +26 -0
- package/cpp/network/tls_transport.cpp +502 -0
- package/cpp/network/tls_transport.h +62 -0
- package/cpp/network/transport.cpp +169 -0
- package/cpp/network/transport.h +115 -0
- package/cpp/network/url.cpp +88 -0
- package/cpp/network/url.h +25 -0
- package/cpp/network/websocket.cpp +253 -0
- package/cpp/network/websocket.h +68 -0
- package/cpp/network/ws_transport.cpp +361 -0
- package/cpp/network/ws_transport.h +72 -0
- package/cpp/node_client.cpp +1196 -0
- package/cpp/node_client.h +209 -0
- package/cpp/node_scan.h +35 -0
- package/cpp/schema.cpp +1249 -0
- package/cpp/schema.h +132 -0
- package/cpp/smsg.cpp +453 -0
- package/cpp/smsg.h +43 -0
- package/cpp/support/allocators/secure.h +85 -0
- package/cpp/support/cleanse.cpp +35 -0
- package/cpp/support/cleanse.h +15 -0
- package/cpp/support/coop.cpp +319 -0
- package/cpp/support/coop.h +157 -0
- package/cpp/support/lockedpool.cpp +406 -0
- package/cpp/support/lockedpool.h +240 -0
- package/cpp/uint256.cpp +62 -0
- package/cpp/uint256.h +121 -0
- package/cpp/util/base58.cpp +181 -0
- package/cpp/util/base58.h +45 -0
- package/cpp/util/bech32.cpp +578 -0
- package/cpp/util/bech32.h +96 -0
- package/cpp/util/debug.cpp +23 -0
- package/cpp/util/debug.h +12 -0
- package/cpp/util/int.cpp +118 -0
- package/cpp/util/int.h +18 -0
- package/cpp/util/json.h +26 -0
- package/cpp/util/log.cpp +137 -0
- package/cpp/util/log.h +37 -0
- package/cpp/util/mutex.h +89 -0
- package/cpp/util/platform.cpp +90 -0
- package/cpp/util/platform.h +17 -0
- package/cpp/util/random.cpp +136 -0
- package/cpp/util/random.h +28 -0
- package/cpp/util/rpc.cpp +192 -0
- package/cpp/util/rpc.h +454 -0
- package/cpp/util/str.cpp +254 -0
- package/cpp/util/str.h +54 -0
- package/cpp/util/thread.cpp +17 -0
- package/cpp/util/thread.h +12 -0
- package/cpp/util/time.cpp +30 -0
- package/cpp/util/time.h +30 -0
- package/cpp/util/tinyformat.h +1163 -0
- package/cpp/util/vector.h +83 -0
- package/cpp/version.h.in +12 -0
- package/cpp/view_key_chain.h +283 -0
- package/cpp/wallet/account_wallet.cpp +668 -0
- package/cpp/wallet/account_wallet.h +136 -0
- package/cpp/wallet/base_wallet.cpp +302 -0
- package/cpp/wallet/base_wallet.h +129 -0
- package/cpp/wallet/debug_wallet.cpp +40 -0
- package/cpp/wallet/debug_wallet.h +36 -0
- package/cpp/wallet/encrypted_seed.cpp +96 -0
- package/cpp/wallet/encrypted_seed.h +41 -0
- package/cpp/wallet/host_wallet.cpp +85 -0
- package/cpp/wallet/host_wallet.h +51 -0
- package/cpp/wallet/native_wallet.cpp +34 -0
- package/cpp/wallet/native_wallet.h +28 -0
- package/cpp/wallet/xmr/account_wallet.cpp +803 -0
- package/cpp/wallet/xmr/account_wallet.h +139 -0
- package/cpp/wallet/xmr/builder.cpp +568 -0
- package/cpp/wallet/xmr/builder.h +65 -0
- package/cpp/wallet/xmr/chain.cpp +1437 -0
- package/cpp/wallet/xmr/chain.h +213 -0
- package/cpp/wallet/xmr/daemon.cpp +583 -0
- package/cpp/wallet/xmr/daemon.h +153 -0
- package/cpp/wallet/xmr/decoys.cpp +197 -0
- package/cpp/wallet/xmr/decoys.h +64 -0
- package/cpp/wallet/xmr/epee.cpp +448 -0
- package/cpp/wallet/xmr/epee.h +25 -0
- package/cpp/wallet/xmr/fee.cpp +169 -0
- package/cpp/wallet/xmr/fee.h +61 -0
- package/cpp/wallet/xmr/reserve_proof.cpp +169 -0
- package/cpp/wallet/xmr/reserve_proof.h +24 -0
- package/cpp/wallet/xmr/scanner.cpp +860 -0
- package/cpp/wallet/xmr/scanner.h +239 -0
- package/lib/commonjs/NativeNitroBSX.js +128 -0
- package/lib/commonjs/NativeNitroBSX.js.map +1 -0
- package/lib/commonjs/format.js +21 -0
- package/lib/commonjs/format.js.map +1 -0
- package/lib/commonjs/index.js +50 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/service.js +75 -0
- package/lib/commonjs/service.js.map +1 -0
- package/lib/commonjs/specs/NitroBSX.nitro.js +6 -0
- package/lib/commonjs/specs/NitroBSX.nitro.js.map +1 -0
- package/lib/module/NativeNitroBSX.js +124 -0
- package/lib/module/NativeNitroBSX.js.map +1 -0
- package/lib/module/format.js +15 -0
- package/lib/module/format.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/service.js +66 -0
- package/lib/module/service.js.map +1 -0
- package/lib/module/specs/NitroBSX.nitro.js +4 -0
- package/lib/module/specs/NitroBSX.nitro.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeNitroBSX.d.ts +94 -0
- package/lib/typescript/commonjs/src/NativeNitroBSX.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/format.d.ts +3 -0
- package/lib/typescript/commonjs/src/format.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +5 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/service.d.ts +28 -0
- package/lib/typescript/commonjs/src/service.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NitroBSX.nitro.d.ts +251 -0
- package/lib/typescript/commonjs/src/specs/NitroBSX.nitro.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeNitroBSX.d.ts +94 -0
- package/lib/typescript/module/src/NativeNitroBSX.d.ts.map +1 -0
- package/lib/typescript/module/src/format.d.ts +3 -0
- package/lib/typescript/module/src/format.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +5 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/service.d.ts +28 -0
- package/lib/typescript/module/src/service.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NitroBSX.nitro.d.ts +251 -0
- package/lib/typescript/module/src/specs/NitroBSX.nitro.d.ts.map +1 -0
- package/nitro.json +19 -0
- package/nitrogen/generated/android/NitroBSX+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroBSX+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroBSXOnLoad.cpp +49 -0
- package/nitrogen/generated/android/NitroBSXOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobsx/NitroBSXOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroBSX+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/NitroBSXAutolinking.mm +35 -0
- package/nitrogen/generated/ios/NitroBSXAutolinking.swift +16 -0
- package/nitrogen/generated/shared/c++/HybridNitroBSXSpec.cpp +91 -0
- package/nitrogen/generated/shared/c++/HybridNitroBSXSpec.hpp +142 -0
- package/nitrogen/generated/shared/c++/NotificationPair.hpp +87 -0
- package/nitrogen/generated/shared/c++/SignOutcome.hpp +80 -0
- package/nitrogen/generated/shared/c++/SignTxResult.hpp +89 -0
- package/package.json +172 -4
- package/react-native-nitro-bsx.podspec +33 -0
- package/react-native.config.js +26 -0
- package/scripts/build-ios.sh +49 -0
- package/src/NativeNitroBSX.ts +203 -0
- package/src/format.ts +14 -0
- package/src/index.ts +4 -0
- package/src/service.ts +77 -0
- package/src/specs/NitroBSX.nitro.ts +300 -0
|
@@ -0,0 +1,1017 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* CTR_DRBG implementation based on AES-256 (NIST SP 800-90)
|
|
3
|
+
*
|
|
4
|
+
* Copyright The Mbed TLS Contributors
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
|
6
|
+
*/
|
|
7
|
+
/*
|
|
8
|
+
* The NIST SP 800-90 DRBGs are described in the following publication.
|
|
9
|
+
*
|
|
10
|
+
* https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-90r.pdf
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
#include "tf_psa_crypto_common.h"
|
|
14
|
+
|
|
15
|
+
#if defined(MBEDTLS_CTR_DRBG_C)
|
|
16
|
+
|
|
17
|
+
#include "ctr.h"
|
|
18
|
+
#include "mbedtls/private/ctr_drbg.h"
|
|
19
|
+
#include "mbedtls/platform_util.h"
|
|
20
|
+
#include "mbedtls/private/error_common.h"
|
|
21
|
+
|
|
22
|
+
#include <limits.h>
|
|
23
|
+
#include <string.h>
|
|
24
|
+
|
|
25
|
+
#if defined(MBEDTLS_FS_IO)
|
|
26
|
+
#include <stdio.h>
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
/* Using error translation functions from PSA to MbedTLS */
|
|
30
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
31
|
+
#include "psa_util_internal.h"
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
#include "mbedtls/platform.h"
|
|
35
|
+
|
|
36
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
37
|
+
static psa_status_t ctr_drbg_setup_psa_context(mbedtls_ctr_drbg_psa_context *psa_ctx,
|
|
38
|
+
unsigned char *key, size_t key_len)
|
|
39
|
+
{
|
|
40
|
+
psa_key_attributes_t key_attr = PSA_KEY_ATTRIBUTES_INIT;
|
|
41
|
+
psa_status_t status;
|
|
42
|
+
|
|
43
|
+
psa_set_key_usage_flags(&key_attr, PSA_KEY_USAGE_ENCRYPT);
|
|
44
|
+
psa_set_key_algorithm(&key_attr, PSA_ALG_ECB_NO_PADDING);
|
|
45
|
+
psa_set_key_type(&key_attr, PSA_KEY_TYPE_AES);
|
|
46
|
+
status = psa_import_key(&key_attr, key, key_len, &psa_ctx->key_id);
|
|
47
|
+
if (status != PSA_SUCCESS) {
|
|
48
|
+
goto exit;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
status = psa_cipher_encrypt_setup(&psa_ctx->operation, psa_ctx->key_id, PSA_ALG_ECB_NO_PADDING);
|
|
52
|
+
if (status != PSA_SUCCESS) {
|
|
53
|
+
goto exit;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
exit:
|
|
57
|
+
psa_reset_key_attributes(&key_attr);
|
|
58
|
+
return status;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static void ctr_drbg_destroy_psa_contex(mbedtls_ctr_drbg_psa_context *psa_ctx)
|
|
62
|
+
{
|
|
63
|
+
psa_cipher_abort(&psa_ctx->operation);
|
|
64
|
+
psa_destroy_key(psa_ctx->key_id);
|
|
65
|
+
|
|
66
|
+
psa_ctx->operation = psa_cipher_operation_init();
|
|
67
|
+
psa_ctx->key_id = MBEDTLS_SVC_KEY_ID_INIT;
|
|
68
|
+
}
|
|
69
|
+
#endif
|
|
70
|
+
|
|
71
|
+
/*
|
|
72
|
+
* CTR_DRBG context initialization
|
|
73
|
+
*/
|
|
74
|
+
void mbedtls_ctr_drbg_init(mbedtls_ctr_drbg_context *ctx)
|
|
75
|
+
{
|
|
76
|
+
memset(ctx, 0, sizeof(mbedtls_ctr_drbg_context));
|
|
77
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
78
|
+
ctx->psa_ctx.key_id = MBEDTLS_SVC_KEY_ID_INIT;
|
|
79
|
+
ctx->psa_ctx.operation = psa_cipher_operation_init();
|
|
80
|
+
#else
|
|
81
|
+
mbedtls_aes_init(&ctx->aes_ctx);
|
|
82
|
+
#endif
|
|
83
|
+
/* Indicate that the entropy nonce length is not set explicitly.
|
|
84
|
+
* See mbedtls_ctr_drbg_set_nonce_len(). */
|
|
85
|
+
ctx->reseed_counter = -1;
|
|
86
|
+
|
|
87
|
+
ctx->reseed_interval = MBEDTLS_PSA_RNG_RESEED_INTERVAL;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* This function resets CTR_DRBG context to the state immediately
|
|
92
|
+
* after initial call of mbedtls_ctr_drbg_init().
|
|
93
|
+
*/
|
|
94
|
+
void mbedtls_ctr_drbg_free(mbedtls_ctr_drbg_context *ctx)
|
|
95
|
+
{
|
|
96
|
+
if (ctx == NULL) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
#if defined(MBEDTLS_THREADING_C)
|
|
101
|
+
/* The mutex is initialized iff f_entropy is set. */
|
|
102
|
+
if (ctx->f_entropy != NULL) {
|
|
103
|
+
mbedtls_mutex_free(&ctx->mutex);
|
|
104
|
+
}
|
|
105
|
+
#endif
|
|
106
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
107
|
+
ctr_drbg_destroy_psa_contex(&ctx->psa_ctx);
|
|
108
|
+
#else
|
|
109
|
+
mbedtls_aes_free(&ctx->aes_ctx);
|
|
110
|
+
#endif
|
|
111
|
+
mbedtls_platform_zeroize(ctx, sizeof(mbedtls_ctr_drbg_context));
|
|
112
|
+
ctx->reseed_interval = MBEDTLS_PSA_RNG_RESEED_INTERVAL;
|
|
113
|
+
ctx->reseed_counter = -1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void mbedtls_ctr_drbg_set_prediction_resistance(mbedtls_ctr_drbg_context *ctx,
|
|
117
|
+
int resistance)
|
|
118
|
+
{
|
|
119
|
+
ctx->prediction_resistance = resistance;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
void mbedtls_ctr_drbg_set_entropy_len(mbedtls_ctr_drbg_context *ctx,
|
|
123
|
+
size_t len)
|
|
124
|
+
{
|
|
125
|
+
ctx->entropy_len = len;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
int mbedtls_ctr_drbg_set_nonce_len(mbedtls_ctr_drbg_context *ctx,
|
|
129
|
+
size_t len)
|
|
130
|
+
{
|
|
131
|
+
/* If mbedtls_ctr_drbg_seed() has already been called, it's
|
|
132
|
+
* too late. Return the error code that's closest to making sense. */
|
|
133
|
+
if (ctx->f_entropy != NULL) {
|
|
134
|
+
return MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT) {
|
|
138
|
+
return MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* This shouldn't be an issue because
|
|
142
|
+
* MBEDTLS_CTR_DRBG_MAX_SEED_INPUT < INT_MAX in any sensible
|
|
143
|
+
* configuration, but make sure anyway. */
|
|
144
|
+
if (len > INT_MAX) {
|
|
145
|
+
return MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* For backward compatibility with Mbed TLS <= 2.19, store the
|
|
149
|
+
* entropy nonce length in a field that already exists, but isn't
|
|
150
|
+
* used until after the initial seeding. */
|
|
151
|
+
/* Due to the capping of len above, the value fits in an int. */
|
|
152
|
+
ctx->reseed_counter = (int) len;
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
void mbedtls_ctr_drbg_set_reseed_interval(mbedtls_ctr_drbg_context *ctx,
|
|
157
|
+
int interval)
|
|
158
|
+
{
|
|
159
|
+
ctx->reseed_interval = interval;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static int block_cipher_df(unsigned char *output,
|
|
163
|
+
const unsigned char *data, size_t data_len)
|
|
164
|
+
{
|
|
165
|
+
unsigned char buf[MBEDTLS_CTR_DRBG_MAX_SEED_INPUT +
|
|
166
|
+
MBEDTLS_CTR_DRBG_BLOCKSIZE + 16];
|
|
167
|
+
unsigned char tmp[MBEDTLS_CTR_DRBG_SEEDLEN];
|
|
168
|
+
unsigned char key[MBEDTLS_CTR_DRBG_KEYSIZE];
|
|
169
|
+
unsigned char chain[MBEDTLS_CTR_DRBG_BLOCKSIZE];
|
|
170
|
+
unsigned char *p, *iv;
|
|
171
|
+
int ret = 0;
|
|
172
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
173
|
+
psa_status_t status;
|
|
174
|
+
size_t tmp_len;
|
|
175
|
+
mbedtls_ctr_drbg_psa_context psa_ctx;
|
|
176
|
+
|
|
177
|
+
psa_ctx.key_id = MBEDTLS_SVC_KEY_ID_INIT;
|
|
178
|
+
psa_ctx.operation = psa_cipher_operation_init();
|
|
179
|
+
#else
|
|
180
|
+
mbedtls_aes_context aes_ctx;
|
|
181
|
+
#endif
|
|
182
|
+
|
|
183
|
+
int i, j;
|
|
184
|
+
size_t buf_len, use_len;
|
|
185
|
+
|
|
186
|
+
if (data_len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT) {
|
|
187
|
+
return MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
memset(buf, 0, MBEDTLS_CTR_DRBG_MAX_SEED_INPUT +
|
|
191
|
+
MBEDTLS_CTR_DRBG_BLOCKSIZE + 16);
|
|
192
|
+
|
|
193
|
+
/*
|
|
194
|
+
* Construct IV (16 bytes) and S in buffer
|
|
195
|
+
* IV = Counter (in 32-bits) padded to 16 with zeroes
|
|
196
|
+
* S = Length input string (in 32-bits) || Length of output (in 32-bits) ||
|
|
197
|
+
* data || 0x80
|
|
198
|
+
* (Total is padded to a multiple of 16-bytes with zeroes)
|
|
199
|
+
*/
|
|
200
|
+
p = buf + MBEDTLS_CTR_DRBG_BLOCKSIZE;
|
|
201
|
+
MBEDTLS_PUT_UINT32_BE(data_len, p, 0);
|
|
202
|
+
p += 4 + 3;
|
|
203
|
+
*p++ = MBEDTLS_CTR_DRBG_SEEDLEN;
|
|
204
|
+
memcpy(p, data, data_len);
|
|
205
|
+
p[data_len] = 0x80;
|
|
206
|
+
|
|
207
|
+
buf_len = MBEDTLS_CTR_DRBG_BLOCKSIZE + 8 + data_len + 1;
|
|
208
|
+
|
|
209
|
+
for (i = 0; i < MBEDTLS_CTR_DRBG_KEYSIZE; i++) {
|
|
210
|
+
key[i] = i;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
214
|
+
status = ctr_drbg_setup_psa_context(&psa_ctx, key, sizeof(key));
|
|
215
|
+
if (status != PSA_SUCCESS) {
|
|
216
|
+
ret = psa_generic_status_to_mbedtls(status);
|
|
217
|
+
goto exit;
|
|
218
|
+
}
|
|
219
|
+
#else
|
|
220
|
+
mbedtls_aes_init(&aes_ctx);
|
|
221
|
+
|
|
222
|
+
if ((ret = mbedtls_aes_setkey_enc(&aes_ctx, key,
|
|
223
|
+
MBEDTLS_CTR_DRBG_KEYBITS)) != 0) {
|
|
224
|
+
goto exit;
|
|
225
|
+
}
|
|
226
|
+
#endif
|
|
227
|
+
|
|
228
|
+
/*
|
|
229
|
+
* Reduce data to MBEDTLS_CTR_DRBG_SEEDLEN bytes of data
|
|
230
|
+
*/
|
|
231
|
+
for (j = 0; j < MBEDTLS_CTR_DRBG_SEEDLEN; j += MBEDTLS_CTR_DRBG_BLOCKSIZE) {
|
|
232
|
+
p = buf;
|
|
233
|
+
memset(chain, 0, MBEDTLS_CTR_DRBG_BLOCKSIZE);
|
|
234
|
+
use_len = buf_len;
|
|
235
|
+
|
|
236
|
+
while (use_len > 0) {
|
|
237
|
+
mbedtls_xor(chain, chain, p, MBEDTLS_CTR_DRBG_BLOCKSIZE);
|
|
238
|
+
p += MBEDTLS_CTR_DRBG_BLOCKSIZE;
|
|
239
|
+
use_len -= (use_len >= MBEDTLS_CTR_DRBG_BLOCKSIZE) ?
|
|
240
|
+
MBEDTLS_CTR_DRBG_BLOCKSIZE : use_len;
|
|
241
|
+
|
|
242
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
243
|
+
status = psa_cipher_update(&psa_ctx.operation, chain, MBEDTLS_CTR_DRBG_BLOCKSIZE,
|
|
244
|
+
chain, MBEDTLS_CTR_DRBG_BLOCKSIZE, &tmp_len);
|
|
245
|
+
if (status != PSA_SUCCESS) {
|
|
246
|
+
ret = psa_generic_status_to_mbedtls(status);
|
|
247
|
+
goto exit;
|
|
248
|
+
}
|
|
249
|
+
#else
|
|
250
|
+
if ((ret = mbedtls_aes_crypt_ecb(&aes_ctx, MBEDTLS_AES_ENCRYPT,
|
|
251
|
+
chain, chain)) != 0) {
|
|
252
|
+
goto exit;
|
|
253
|
+
}
|
|
254
|
+
#endif
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
memcpy(tmp + j, chain, MBEDTLS_CTR_DRBG_BLOCKSIZE);
|
|
258
|
+
|
|
259
|
+
/*
|
|
260
|
+
* Update IV
|
|
261
|
+
*/
|
|
262
|
+
buf[3]++;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/*
|
|
266
|
+
* Do final encryption with reduced data
|
|
267
|
+
*/
|
|
268
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
269
|
+
ctr_drbg_destroy_psa_contex(&psa_ctx);
|
|
270
|
+
|
|
271
|
+
status = ctr_drbg_setup_psa_context(&psa_ctx, tmp, MBEDTLS_CTR_DRBG_KEYSIZE);
|
|
272
|
+
if (status != PSA_SUCCESS) {
|
|
273
|
+
ret = psa_generic_status_to_mbedtls(status);
|
|
274
|
+
goto exit;
|
|
275
|
+
}
|
|
276
|
+
#else
|
|
277
|
+
if ((ret = mbedtls_aes_setkey_enc(&aes_ctx, tmp,
|
|
278
|
+
MBEDTLS_CTR_DRBG_KEYBITS)) != 0) {
|
|
279
|
+
goto exit;
|
|
280
|
+
}
|
|
281
|
+
#endif
|
|
282
|
+
iv = tmp + MBEDTLS_CTR_DRBG_KEYSIZE;
|
|
283
|
+
p = output;
|
|
284
|
+
|
|
285
|
+
for (j = 0; j < MBEDTLS_CTR_DRBG_SEEDLEN; j += MBEDTLS_CTR_DRBG_BLOCKSIZE) {
|
|
286
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
287
|
+
status = psa_cipher_update(&psa_ctx.operation, iv, MBEDTLS_CTR_DRBG_BLOCKSIZE,
|
|
288
|
+
iv, MBEDTLS_CTR_DRBG_BLOCKSIZE, &tmp_len);
|
|
289
|
+
if (status != PSA_SUCCESS) {
|
|
290
|
+
ret = psa_generic_status_to_mbedtls(status);
|
|
291
|
+
goto exit;
|
|
292
|
+
}
|
|
293
|
+
#else
|
|
294
|
+
if ((ret = mbedtls_aes_crypt_ecb(&aes_ctx, MBEDTLS_AES_ENCRYPT,
|
|
295
|
+
iv, iv)) != 0) {
|
|
296
|
+
goto exit;
|
|
297
|
+
}
|
|
298
|
+
#endif
|
|
299
|
+
memcpy(p, iv, MBEDTLS_CTR_DRBG_BLOCKSIZE);
|
|
300
|
+
p += MBEDTLS_CTR_DRBG_BLOCKSIZE;
|
|
301
|
+
}
|
|
302
|
+
exit:
|
|
303
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
304
|
+
ctr_drbg_destroy_psa_contex(&psa_ctx);
|
|
305
|
+
#else
|
|
306
|
+
mbedtls_aes_free(&aes_ctx);
|
|
307
|
+
#endif
|
|
308
|
+
/*
|
|
309
|
+
* tidy up the stack
|
|
310
|
+
*/
|
|
311
|
+
mbedtls_platform_zeroize(buf, sizeof(buf));
|
|
312
|
+
mbedtls_platform_zeroize(tmp, sizeof(tmp));
|
|
313
|
+
mbedtls_platform_zeroize(key, sizeof(key));
|
|
314
|
+
mbedtls_platform_zeroize(chain, sizeof(chain));
|
|
315
|
+
if (0 != ret) {
|
|
316
|
+
/*
|
|
317
|
+
* wipe partial seed from memory
|
|
318
|
+
*/
|
|
319
|
+
mbedtls_platform_zeroize(output, MBEDTLS_CTR_DRBG_SEEDLEN);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return ret;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/* CTR_DRBG_Update (SP 800-90A §10.2.1.2)
|
|
326
|
+
* ctr_drbg_update_internal(ctx, provided_data)
|
|
327
|
+
* implements
|
|
328
|
+
* CTR_DRBG_Update(provided_data, Key, V)
|
|
329
|
+
* with inputs and outputs
|
|
330
|
+
* ctx->aes_ctx = Key
|
|
331
|
+
* ctx->counter = V
|
|
332
|
+
*/
|
|
333
|
+
static int ctr_drbg_update_internal(mbedtls_ctr_drbg_context *ctx,
|
|
334
|
+
const unsigned char data[MBEDTLS_CTR_DRBG_SEEDLEN])
|
|
335
|
+
{
|
|
336
|
+
unsigned char tmp[MBEDTLS_CTR_DRBG_SEEDLEN];
|
|
337
|
+
unsigned char *p = tmp;
|
|
338
|
+
int j;
|
|
339
|
+
int ret = 0;
|
|
340
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
341
|
+
psa_status_t status;
|
|
342
|
+
size_t tmp_len;
|
|
343
|
+
#endif
|
|
344
|
+
|
|
345
|
+
memset(tmp, 0, MBEDTLS_CTR_DRBG_SEEDLEN);
|
|
346
|
+
|
|
347
|
+
for (j = 0; j < MBEDTLS_CTR_DRBG_SEEDLEN; j += MBEDTLS_CTR_DRBG_BLOCKSIZE) {
|
|
348
|
+
/*
|
|
349
|
+
* Increase counter
|
|
350
|
+
*/
|
|
351
|
+
mbedtls_ctr_increment_counter(ctx->counter);
|
|
352
|
+
|
|
353
|
+
/*
|
|
354
|
+
* Crypt counter block
|
|
355
|
+
*/
|
|
356
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
357
|
+
status = psa_cipher_update(&ctx->psa_ctx.operation, ctx->counter, sizeof(ctx->counter),
|
|
358
|
+
p, MBEDTLS_CTR_DRBG_BLOCKSIZE, &tmp_len);
|
|
359
|
+
if (status != PSA_SUCCESS) {
|
|
360
|
+
ret = psa_generic_status_to_mbedtls(status);
|
|
361
|
+
goto exit;
|
|
362
|
+
}
|
|
363
|
+
#else
|
|
364
|
+
if ((ret = mbedtls_aes_crypt_ecb(&ctx->aes_ctx, MBEDTLS_AES_ENCRYPT,
|
|
365
|
+
ctx->counter, p)) != 0) {
|
|
366
|
+
goto exit;
|
|
367
|
+
}
|
|
368
|
+
#endif
|
|
369
|
+
|
|
370
|
+
p += MBEDTLS_CTR_DRBG_BLOCKSIZE;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
mbedtls_xor(tmp, tmp, data, MBEDTLS_CTR_DRBG_SEEDLEN);
|
|
374
|
+
|
|
375
|
+
/*
|
|
376
|
+
* Update key and counter
|
|
377
|
+
*/
|
|
378
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
379
|
+
ctr_drbg_destroy_psa_contex(&ctx->psa_ctx);
|
|
380
|
+
|
|
381
|
+
status = ctr_drbg_setup_psa_context(&ctx->psa_ctx, tmp, MBEDTLS_CTR_DRBG_KEYSIZE);
|
|
382
|
+
if (status != PSA_SUCCESS) {
|
|
383
|
+
ret = psa_generic_status_to_mbedtls(status);
|
|
384
|
+
goto exit;
|
|
385
|
+
}
|
|
386
|
+
#else
|
|
387
|
+
if ((ret = mbedtls_aes_setkey_enc(&ctx->aes_ctx, tmp,
|
|
388
|
+
MBEDTLS_CTR_DRBG_KEYBITS)) != 0) {
|
|
389
|
+
goto exit;
|
|
390
|
+
}
|
|
391
|
+
#endif
|
|
392
|
+
memcpy(ctx->counter, tmp + MBEDTLS_CTR_DRBG_KEYSIZE,
|
|
393
|
+
MBEDTLS_CTR_DRBG_BLOCKSIZE);
|
|
394
|
+
|
|
395
|
+
exit:
|
|
396
|
+
mbedtls_platform_zeroize(tmp, sizeof(tmp));
|
|
397
|
+
return ret;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/* CTR_DRBG_Instantiate with derivation function (SP 800-90A §10.2.1.3.2)
|
|
401
|
+
* mbedtls_ctr_drbg_update(ctx, additional, add_len)
|
|
402
|
+
* implements
|
|
403
|
+
* CTR_DRBG_Instantiate(entropy_input, nonce, personalization_string,
|
|
404
|
+
* security_strength) -> initial_working_state
|
|
405
|
+
* with inputs
|
|
406
|
+
* ctx->counter = all-bits-0
|
|
407
|
+
* ctx->aes_ctx = context from all-bits-0 key
|
|
408
|
+
* additional[:add_len] = entropy_input || nonce || personalization_string
|
|
409
|
+
* and with outputs
|
|
410
|
+
* ctx = initial_working_state
|
|
411
|
+
*/
|
|
412
|
+
int mbedtls_ctr_drbg_update(mbedtls_ctr_drbg_context *ctx,
|
|
413
|
+
const unsigned char *additional,
|
|
414
|
+
size_t add_len)
|
|
415
|
+
{
|
|
416
|
+
unsigned char add_input[MBEDTLS_CTR_DRBG_SEEDLEN];
|
|
417
|
+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
|
418
|
+
|
|
419
|
+
if (add_len == 0) {
|
|
420
|
+
return 0;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if ((ret = block_cipher_df(add_input, additional, add_len)) != 0) {
|
|
424
|
+
goto exit;
|
|
425
|
+
}
|
|
426
|
+
if ((ret = ctr_drbg_update_internal(ctx, add_input)) != 0) {
|
|
427
|
+
goto exit;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
exit:
|
|
431
|
+
mbedtls_platform_zeroize(add_input, sizeof(add_input));
|
|
432
|
+
return ret;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/* CTR_DRBG_Reseed with derivation function (SP 800-90A §10.2.1.4.2)
|
|
436
|
+
* mbedtls_ctr_drbg_reseed(ctx, additional, len, nonce_len)
|
|
437
|
+
* implements
|
|
438
|
+
* CTR_DRBG_Reseed(working_state, entropy_input, additional_input)
|
|
439
|
+
* -> new_working_state
|
|
440
|
+
* with inputs
|
|
441
|
+
* ctx contains working_state
|
|
442
|
+
* additional[:len] = additional_input
|
|
443
|
+
* and entropy_input comes from calling ctx->f_entropy
|
|
444
|
+
* for (ctx->entropy_len + nonce_len) bytes
|
|
445
|
+
* and with output
|
|
446
|
+
* ctx contains new_working_state
|
|
447
|
+
*/
|
|
448
|
+
static int mbedtls_ctr_drbg_reseed_internal(mbedtls_ctr_drbg_context *ctx,
|
|
449
|
+
const unsigned char *additional,
|
|
450
|
+
size_t len,
|
|
451
|
+
size_t nonce_len)
|
|
452
|
+
{
|
|
453
|
+
unsigned char seed[MBEDTLS_CTR_DRBG_MAX_SEED_INPUT];
|
|
454
|
+
size_t seedlen = 0;
|
|
455
|
+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
|
456
|
+
|
|
457
|
+
if (ctx->entropy_len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT) {
|
|
458
|
+
return MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG;
|
|
459
|
+
}
|
|
460
|
+
if (nonce_len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT - ctx->entropy_len) {
|
|
461
|
+
return MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG;
|
|
462
|
+
}
|
|
463
|
+
if (len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT - ctx->entropy_len - nonce_len) {
|
|
464
|
+
return MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
memset(seed, 0, MBEDTLS_CTR_DRBG_MAX_SEED_INPUT);
|
|
468
|
+
|
|
469
|
+
/* Gather entropy_len bytes of entropy to seed state. */
|
|
470
|
+
if (0 != ctx->f_entropy(ctx->p_entropy, seed, ctx->entropy_len)) {
|
|
471
|
+
return MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED;
|
|
472
|
+
}
|
|
473
|
+
seedlen += ctx->entropy_len;
|
|
474
|
+
|
|
475
|
+
/* Gather entropy for a nonce if requested. */
|
|
476
|
+
if (nonce_len != 0) {
|
|
477
|
+
if (0 != ctx->f_entropy(ctx->p_entropy, seed + seedlen, nonce_len)) {
|
|
478
|
+
return MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED;
|
|
479
|
+
}
|
|
480
|
+
seedlen += nonce_len;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/* Add additional data if provided. */
|
|
484
|
+
if (additional != NULL && len != 0) {
|
|
485
|
+
memcpy(seed + seedlen, additional, len);
|
|
486
|
+
seedlen += len;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/* Reduce to 384 bits. */
|
|
490
|
+
if ((ret = block_cipher_df(seed, seed, seedlen)) != 0) {
|
|
491
|
+
goto exit;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/* Update state. */
|
|
495
|
+
if ((ret = ctr_drbg_update_internal(ctx, seed)) != 0) {
|
|
496
|
+
goto exit;
|
|
497
|
+
}
|
|
498
|
+
ctx->reseed_counter = 0;
|
|
499
|
+
|
|
500
|
+
exit:
|
|
501
|
+
mbedtls_platform_zeroize(seed, sizeof(seed));
|
|
502
|
+
return ret;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
int mbedtls_ctr_drbg_reseed(mbedtls_ctr_drbg_context *ctx,
|
|
506
|
+
const unsigned char *additional, size_t len)
|
|
507
|
+
{
|
|
508
|
+
return mbedtls_ctr_drbg_reseed_internal(ctx, additional, len, 0);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/* Return a "good" nonce length for CTR_DRBG. The chosen nonce length
|
|
512
|
+
* is sufficient to achieve the maximum security strength given the key
|
|
513
|
+
* size and entropy length. If there is enough entropy in the initial
|
|
514
|
+
* call to the entropy function to serve as both the entropy input and
|
|
515
|
+
* the nonce, don't make a second call to get a nonce. */
|
|
516
|
+
static size_t good_nonce_len(size_t entropy_len)
|
|
517
|
+
{
|
|
518
|
+
if (entropy_len >= MBEDTLS_CTR_DRBG_KEYSIZE * 3 / 2) {
|
|
519
|
+
return 0;
|
|
520
|
+
} else {
|
|
521
|
+
return (entropy_len + 1) / 2;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/* CTR_DRBG_Instantiate with derivation function (SP 800-90A §10.2.1.3.2)
|
|
526
|
+
* mbedtls_ctr_drbg_seed(ctx, f_entropy, p_entropy, custom, len)
|
|
527
|
+
* implements
|
|
528
|
+
* CTR_DRBG_Instantiate(entropy_input, nonce, personalization_string,
|
|
529
|
+
* security_strength) -> initial_working_state
|
|
530
|
+
* with inputs
|
|
531
|
+
* custom[:len] = nonce || personalization_string
|
|
532
|
+
* where entropy_input comes from f_entropy for ctx->entropy_len bytes
|
|
533
|
+
* and with outputs
|
|
534
|
+
* ctx = initial_working_state
|
|
535
|
+
*/
|
|
536
|
+
int mbedtls_ctr_drbg_seed(mbedtls_ctr_drbg_context *ctx,
|
|
537
|
+
int (*f_entropy)(void *, unsigned char *, size_t),
|
|
538
|
+
void *p_entropy,
|
|
539
|
+
const unsigned char *custom,
|
|
540
|
+
size_t len)
|
|
541
|
+
{
|
|
542
|
+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
|
543
|
+
unsigned char key[MBEDTLS_CTR_DRBG_KEYSIZE];
|
|
544
|
+
size_t nonce_len;
|
|
545
|
+
|
|
546
|
+
memset(key, 0, MBEDTLS_CTR_DRBG_KEYSIZE);
|
|
547
|
+
|
|
548
|
+
/* The mutex is initialized iff f_entropy is set. */
|
|
549
|
+
#if defined(MBEDTLS_THREADING_C)
|
|
550
|
+
mbedtls_mutex_init(&ctx->mutex);
|
|
551
|
+
#endif
|
|
552
|
+
|
|
553
|
+
ctx->f_entropy = f_entropy;
|
|
554
|
+
ctx->p_entropy = p_entropy;
|
|
555
|
+
|
|
556
|
+
if (ctx->entropy_len == 0) {
|
|
557
|
+
ctx->entropy_len = MBEDTLS_CTR_DRBG_ENTROPY_LEN;
|
|
558
|
+
}
|
|
559
|
+
/* ctx->reseed_counter contains the desired amount of entropy to
|
|
560
|
+
* grab for a nonce (see mbedtls_ctr_drbg_set_nonce_len()).
|
|
561
|
+
* If it's -1, indicating that the entropy nonce length was not set
|
|
562
|
+
* explicitly, use a sufficiently large nonce for security. */
|
|
563
|
+
nonce_len = (ctx->reseed_counter >= 0 ?
|
|
564
|
+
(size_t) ctx->reseed_counter :
|
|
565
|
+
good_nonce_len(ctx->entropy_len));
|
|
566
|
+
|
|
567
|
+
/* Initialize with an empty key. */
|
|
568
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
569
|
+
psa_status_t status;
|
|
570
|
+
|
|
571
|
+
status = ctr_drbg_setup_psa_context(&ctx->psa_ctx, key, MBEDTLS_CTR_DRBG_KEYSIZE);
|
|
572
|
+
if (status != PSA_SUCCESS) {
|
|
573
|
+
ret = psa_generic_status_to_mbedtls(status);
|
|
574
|
+
return status;
|
|
575
|
+
}
|
|
576
|
+
#else
|
|
577
|
+
if ((ret = mbedtls_aes_setkey_enc(&ctx->aes_ctx, key,
|
|
578
|
+
MBEDTLS_CTR_DRBG_KEYBITS)) != 0) {
|
|
579
|
+
return ret;
|
|
580
|
+
}
|
|
581
|
+
#endif
|
|
582
|
+
|
|
583
|
+
/* Do the initial seeding. */
|
|
584
|
+
if ((ret = mbedtls_ctr_drbg_reseed_internal(ctx, custom, len,
|
|
585
|
+
nonce_len)) != 0) {
|
|
586
|
+
return ret;
|
|
587
|
+
}
|
|
588
|
+
return 0;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/* CTR_DRBG_Generate with derivation function (SP 800-90A §10.2.1.5.2)
|
|
592
|
+
* mbedtls_ctr_drbg_random_with_add(ctx, output, output_len, additional, add_len)
|
|
593
|
+
* implements
|
|
594
|
+
* CTR_DRBG_Reseed(working_state, entropy_input, additional[:add_len])
|
|
595
|
+
* -> working_state_after_reseed
|
|
596
|
+
* if required, then
|
|
597
|
+
* CTR_DRBG_Generate(working_state_after_reseed,
|
|
598
|
+
* requested_number_of_bits, additional_input)
|
|
599
|
+
* -> status, returned_bits, new_working_state
|
|
600
|
+
* with inputs
|
|
601
|
+
* ctx contains working_state
|
|
602
|
+
* requested_number_of_bits = 8 * output_len
|
|
603
|
+
* additional[:add_len] = additional_input
|
|
604
|
+
* and entropy_input comes from calling ctx->f_entropy
|
|
605
|
+
* and with outputs
|
|
606
|
+
* status = SUCCESS (this function does the reseed internally)
|
|
607
|
+
* returned_bits = output[:output_len]
|
|
608
|
+
* ctx contains new_working_state
|
|
609
|
+
*/
|
|
610
|
+
int mbedtls_ctr_drbg_random_with_add(void *p_rng,
|
|
611
|
+
unsigned char *output, size_t output_len,
|
|
612
|
+
const unsigned char *additional, size_t add_len)
|
|
613
|
+
{
|
|
614
|
+
int ret = 0;
|
|
615
|
+
mbedtls_ctr_drbg_context *ctx = (mbedtls_ctr_drbg_context *) p_rng;
|
|
616
|
+
unsigned char *p = output;
|
|
617
|
+
struct {
|
|
618
|
+
unsigned char add_input[MBEDTLS_CTR_DRBG_SEEDLEN];
|
|
619
|
+
unsigned char tmp[MBEDTLS_CTR_DRBG_BLOCKSIZE];
|
|
620
|
+
} locals;
|
|
621
|
+
size_t use_len;
|
|
622
|
+
|
|
623
|
+
if (output_len > MBEDTLS_CTR_DRBG_MAX_REQUEST) {
|
|
624
|
+
return MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
if (add_len > MBEDTLS_CTR_DRBG_MAX_INPUT) {
|
|
628
|
+
return MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
memset(locals.add_input, 0, MBEDTLS_CTR_DRBG_SEEDLEN);
|
|
632
|
+
|
|
633
|
+
if (ctx->reseed_counter >= ctx->reseed_interval ||
|
|
634
|
+
ctx->prediction_resistance) {
|
|
635
|
+
if ((ret = mbedtls_ctr_drbg_reseed(ctx, additional, add_len)) != 0) {
|
|
636
|
+
return ret;
|
|
637
|
+
}
|
|
638
|
+
add_len = 0;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
if (add_len > 0) {
|
|
642
|
+
if ((ret = block_cipher_df(locals.add_input, additional, add_len)) != 0) {
|
|
643
|
+
goto exit;
|
|
644
|
+
}
|
|
645
|
+
if ((ret = ctr_drbg_update_internal(ctx, locals.add_input)) != 0) {
|
|
646
|
+
goto exit;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
while (output_len > 0) {
|
|
651
|
+
/*
|
|
652
|
+
* Increase counter (treat it as a 128-bit big-endian integer).
|
|
653
|
+
*/
|
|
654
|
+
mbedtls_ctr_increment_counter(ctx->counter);
|
|
655
|
+
|
|
656
|
+
/*
|
|
657
|
+
* Crypt counter block
|
|
658
|
+
*/
|
|
659
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_PSA_CRYPTO)
|
|
660
|
+
psa_status_t status;
|
|
661
|
+
size_t tmp_len;
|
|
662
|
+
|
|
663
|
+
status = psa_cipher_update(&ctx->psa_ctx.operation, ctx->counter, sizeof(ctx->counter),
|
|
664
|
+
locals.tmp, MBEDTLS_CTR_DRBG_BLOCKSIZE, &tmp_len);
|
|
665
|
+
if (status != PSA_SUCCESS) {
|
|
666
|
+
ret = psa_generic_status_to_mbedtls(status);
|
|
667
|
+
goto exit;
|
|
668
|
+
}
|
|
669
|
+
#else
|
|
670
|
+
if ((ret = mbedtls_aes_crypt_ecb(&ctx->aes_ctx, MBEDTLS_AES_ENCRYPT,
|
|
671
|
+
ctx->counter, locals.tmp)) != 0) {
|
|
672
|
+
goto exit;
|
|
673
|
+
}
|
|
674
|
+
#endif
|
|
675
|
+
|
|
676
|
+
use_len = (output_len > MBEDTLS_CTR_DRBG_BLOCKSIZE)
|
|
677
|
+
? MBEDTLS_CTR_DRBG_BLOCKSIZE : output_len;
|
|
678
|
+
/*
|
|
679
|
+
* Copy random block to destination
|
|
680
|
+
*/
|
|
681
|
+
memcpy(p, locals.tmp, use_len);
|
|
682
|
+
p += use_len;
|
|
683
|
+
output_len -= use_len;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
if ((ret = ctr_drbg_update_internal(ctx, locals.add_input)) != 0) {
|
|
687
|
+
goto exit;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
ctx->reseed_counter++;
|
|
691
|
+
|
|
692
|
+
exit:
|
|
693
|
+
mbedtls_platform_zeroize(&locals, sizeof(locals));
|
|
694
|
+
return ret;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
int mbedtls_ctr_drbg_random(void *p_rng, unsigned char *output,
|
|
698
|
+
size_t output_len)
|
|
699
|
+
{
|
|
700
|
+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
|
701
|
+
mbedtls_ctr_drbg_context *ctx = (mbedtls_ctr_drbg_context *) p_rng;
|
|
702
|
+
|
|
703
|
+
#if defined(MBEDTLS_THREADING_C)
|
|
704
|
+
if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) {
|
|
705
|
+
return ret;
|
|
706
|
+
}
|
|
707
|
+
#endif
|
|
708
|
+
|
|
709
|
+
ret = mbedtls_ctr_drbg_random_with_add(ctx, output, output_len, NULL, 0);
|
|
710
|
+
|
|
711
|
+
#if defined(MBEDTLS_THREADING_C)
|
|
712
|
+
if (mbedtls_mutex_unlock(&ctx->mutex) != 0) {
|
|
713
|
+
return MBEDTLS_ERR_THREADING_MUTEX_ERROR;
|
|
714
|
+
}
|
|
715
|
+
#endif
|
|
716
|
+
|
|
717
|
+
return ret;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
#if defined(MBEDTLS_FS_IO)
|
|
721
|
+
int mbedtls_ctr_drbg_write_seed_file(mbedtls_ctr_drbg_context *ctx,
|
|
722
|
+
const char *path)
|
|
723
|
+
{
|
|
724
|
+
int ret = MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR;
|
|
725
|
+
FILE *f;
|
|
726
|
+
unsigned char buf[MBEDTLS_CTR_DRBG_MAX_INPUT];
|
|
727
|
+
|
|
728
|
+
if ((f = fopen(path, "wb")) == NULL) {
|
|
729
|
+
return MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
|
733
|
+
mbedtls_setbuf(f, NULL);
|
|
734
|
+
|
|
735
|
+
if ((ret = mbedtls_ctr_drbg_random(ctx, buf,
|
|
736
|
+
MBEDTLS_CTR_DRBG_MAX_INPUT)) != 0) {
|
|
737
|
+
goto exit;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
if (fwrite(buf, 1, MBEDTLS_CTR_DRBG_MAX_INPUT, f) !=
|
|
741
|
+
MBEDTLS_CTR_DRBG_MAX_INPUT) {
|
|
742
|
+
ret = MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR;
|
|
743
|
+
} else {
|
|
744
|
+
ret = 0;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
exit:
|
|
748
|
+
mbedtls_platform_zeroize(buf, sizeof(buf));
|
|
749
|
+
|
|
750
|
+
fclose(f);
|
|
751
|
+
return ret;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
int mbedtls_ctr_drbg_update_seed_file(mbedtls_ctr_drbg_context *ctx,
|
|
755
|
+
const char *path)
|
|
756
|
+
{
|
|
757
|
+
int ret = 0;
|
|
758
|
+
FILE *f = NULL;
|
|
759
|
+
size_t n;
|
|
760
|
+
unsigned char buf[MBEDTLS_CTR_DRBG_MAX_INPUT];
|
|
761
|
+
unsigned char c;
|
|
762
|
+
|
|
763
|
+
if ((f = fopen(path, "rb")) == NULL) {
|
|
764
|
+
return MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/* Ensure no stdio buffering of secrets, as such buffers cannot be wiped. */
|
|
768
|
+
mbedtls_setbuf(f, NULL);
|
|
769
|
+
|
|
770
|
+
n = fread(buf, 1, sizeof(buf), f);
|
|
771
|
+
if (fread(&c, 1, 1, f) != 0) {
|
|
772
|
+
ret = MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG;
|
|
773
|
+
goto exit;
|
|
774
|
+
}
|
|
775
|
+
if (n == 0 || ferror(f)) {
|
|
776
|
+
ret = MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR;
|
|
777
|
+
goto exit;
|
|
778
|
+
}
|
|
779
|
+
fclose(f);
|
|
780
|
+
f = NULL;
|
|
781
|
+
|
|
782
|
+
ret = mbedtls_ctr_drbg_update(ctx, buf, n);
|
|
783
|
+
|
|
784
|
+
exit:
|
|
785
|
+
mbedtls_platform_zeroize(buf, sizeof(buf));
|
|
786
|
+
if (f != NULL) {
|
|
787
|
+
fclose(f);
|
|
788
|
+
}
|
|
789
|
+
if (ret != 0) {
|
|
790
|
+
return ret;
|
|
791
|
+
}
|
|
792
|
+
return mbedtls_ctr_drbg_write_seed_file(ctx, path);
|
|
793
|
+
}
|
|
794
|
+
#endif /* MBEDTLS_FS_IO */
|
|
795
|
+
|
|
796
|
+
#if defined(MBEDTLS_SELF_TEST)
|
|
797
|
+
|
|
798
|
+
/* The CTR_DRBG NIST test vectors used here are available at
|
|
799
|
+
* https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-Validation-Program/documents/drbg/drbgtestvectors.zip
|
|
800
|
+
*
|
|
801
|
+
* The parameters used to derive the test data are:
|
|
802
|
+
*
|
|
803
|
+
* [AES-128 use df]
|
|
804
|
+
* [PredictionResistance = True/False]
|
|
805
|
+
* [EntropyInputLen = 128]
|
|
806
|
+
* [NonceLen = 64]
|
|
807
|
+
* [PersonalizationStringLen = 128]
|
|
808
|
+
* [AdditionalInputLen = 0]
|
|
809
|
+
* [ReturnedBitsLen = 512]
|
|
810
|
+
*
|
|
811
|
+
* [AES-256 use df]
|
|
812
|
+
* [PredictionResistance = True/False]
|
|
813
|
+
* [EntropyInputLen = 256]
|
|
814
|
+
* [NonceLen = 128]
|
|
815
|
+
* [PersonalizationStringLen = 256]
|
|
816
|
+
* [AdditionalInputLen = 0]
|
|
817
|
+
* [ReturnedBitsLen = 512]
|
|
818
|
+
*
|
|
819
|
+
*/
|
|
820
|
+
|
|
821
|
+
#if defined(MBEDTLS_CTR_DRBG_USE_128_BIT_KEY)
|
|
822
|
+
static const unsigned char entropy_source_pr[] =
|
|
823
|
+
{ 0x04, 0xd9, 0x49, 0xa6, 0xdc, 0xe8, 0x6e, 0xbb,
|
|
824
|
+
0xf1, 0x08, 0x77, 0x2b, 0x9e, 0x08, 0xca, 0x92,
|
|
825
|
+
0x65, 0x16, 0xda, 0x99, 0xa2, 0x59, 0xf3, 0xe8,
|
|
826
|
+
0x38, 0x7e, 0x3f, 0x6b, 0x51, 0x70, 0x7b, 0x20,
|
|
827
|
+
0xec, 0x53, 0xd0, 0x66, 0xc3, 0x0f, 0xe3, 0xb0,
|
|
828
|
+
0xe0, 0x86, 0xa6, 0xaa, 0x5f, 0x72, 0x2f, 0xad,
|
|
829
|
+
0xf7, 0xef, 0x06, 0xb8, 0xd6, 0x9c, 0x9d, 0xe8 };
|
|
830
|
+
|
|
831
|
+
static const unsigned char entropy_source_nopr[] =
|
|
832
|
+
{ 0x07, 0x0d, 0x59, 0x63, 0x98, 0x73, 0xa5, 0x45,
|
|
833
|
+
0x27, 0x38, 0x22, 0x7b, 0x76, 0x85, 0xd1, 0xa9,
|
|
834
|
+
0x74, 0x18, 0x1f, 0x3c, 0x22, 0xf6, 0x49, 0x20,
|
|
835
|
+
0x4a, 0x47, 0xc2, 0xf3, 0x85, 0x16, 0xb4, 0x6f,
|
|
836
|
+
0x00, 0x2e, 0x71, 0xda, 0xed, 0x16, 0x9b, 0x5c };
|
|
837
|
+
|
|
838
|
+
static const unsigned char pers_pr[] =
|
|
839
|
+
{ 0xbf, 0xa4, 0x9a, 0x8f, 0x7b, 0xd8, 0xb1, 0x7a,
|
|
840
|
+
0x9d, 0xfa, 0x45, 0xed, 0x21, 0x52, 0xb3, 0xad };
|
|
841
|
+
|
|
842
|
+
static const unsigned char pers_nopr[] =
|
|
843
|
+
{ 0x4e, 0x61, 0x79, 0xd4, 0xc2, 0x72, 0xa1, 0x4c,
|
|
844
|
+
0xf1, 0x3d, 0xf6, 0x5e, 0xa3, 0xa6, 0xe5, 0x0f };
|
|
845
|
+
|
|
846
|
+
static const unsigned char result_pr[] =
|
|
847
|
+
{ 0xc9, 0x0a, 0xaf, 0x85, 0x89, 0x71, 0x44, 0x66,
|
|
848
|
+
0x4f, 0x25, 0x0b, 0x2b, 0xde, 0xd8, 0xfa, 0xff,
|
|
849
|
+
0x52, 0x5a, 0x1b, 0x32, 0x5e, 0x41, 0x7a, 0x10,
|
|
850
|
+
0x1f, 0xef, 0x1e, 0x62, 0x23, 0xe9, 0x20, 0x30,
|
|
851
|
+
0xc9, 0x0d, 0xad, 0x69, 0xb4, 0x9c, 0x5b, 0xf4,
|
|
852
|
+
0x87, 0x42, 0xd5, 0xae, 0x5e, 0x5e, 0x43, 0xcc,
|
|
853
|
+
0xd9, 0xfd, 0x0b, 0x93, 0x4a, 0xe3, 0xd4, 0x06,
|
|
854
|
+
0x37, 0x36, 0x0f, 0x3f, 0x72, 0x82, 0x0c, 0xcf };
|
|
855
|
+
|
|
856
|
+
static const unsigned char result_nopr[] =
|
|
857
|
+
{ 0x31, 0xc9, 0x91, 0x09, 0xf8, 0xc5, 0x10, 0x13,
|
|
858
|
+
0x3c, 0xd3, 0x96, 0xf9, 0xbc, 0x2c, 0x12, 0xc0,
|
|
859
|
+
0x7c, 0xc1, 0x61, 0x5f, 0xa3, 0x09, 0x99, 0xaf,
|
|
860
|
+
0xd7, 0xf2, 0x36, 0xfd, 0x40, 0x1a, 0x8b, 0xf2,
|
|
861
|
+
0x33, 0x38, 0xee, 0x1d, 0x03, 0x5f, 0x83, 0xb7,
|
|
862
|
+
0xa2, 0x53, 0xdc, 0xee, 0x18, 0xfc, 0xa7, 0xf2,
|
|
863
|
+
0xee, 0x96, 0xc6, 0xc2, 0xcd, 0x0c, 0xff, 0x02,
|
|
864
|
+
0x76, 0x70, 0x69, 0xaa, 0x69, 0xd1, 0x3b, 0xe8 };
|
|
865
|
+
#else /* MBEDTLS_CTR_DRBG_USE_128_BIT_KEY */
|
|
866
|
+
|
|
867
|
+
static const unsigned char entropy_source_pr[] =
|
|
868
|
+
{ 0xca, 0x58, 0xfd, 0xf2, 0xb9, 0x77, 0xcb, 0x49,
|
|
869
|
+
0xd4, 0xe0, 0x5b, 0xe2, 0x39, 0x50, 0xd9, 0x8a,
|
|
870
|
+
0x6a, 0xb3, 0xc5, 0x2f, 0xdf, 0x74, 0xd5, 0x85,
|
|
871
|
+
0x8f, 0xd1, 0xba, 0x64, 0x54, 0x7b, 0xdb, 0x1e,
|
|
872
|
+
0xc5, 0xea, 0x24, 0xc0, 0xfa, 0x0c, 0x90, 0x15,
|
|
873
|
+
0x09, 0x20, 0x92, 0x42, 0x32, 0x36, 0x45, 0x45,
|
|
874
|
+
0x7d, 0x20, 0x76, 0x6b, 0xcf, 0xa2, 0x15, 0xc8,
|
|
875
|
+
0x2f, 0x9f, 0xbc, 0x88, 0x3f, 0x80, 0xd1, 0x2c,
|
|
876
|
+
0xb7, 0x16, 0xd1, 0x80, 0x9e, 0xe1, 0xc9, 0xb3,
|
|
877
|
+
0x88, 0x1b, 0x21, 0x45, 0xef, 0xa1, 0x7f, 0xce,
|
|
878
|
+
0xc8, 0x92, 0x35, 0x55, 0x2a, 0xd9, 0x1d, 0x8e,
|
|
879
|
+
0x12, 0x38, 0xac, 0x01, 0x4e, 0x38, 0x18, 0x76,
|
|
880
|
+
0x9c, 0xf2, 0xb6, 0xd4, 0x13, 0xb6, 0x2c, 0x77,
|
|
881
|
+
0xc0, 0xe7, 0xe6, 0x0c, 0x47, 0x44, 0x95, 0xbe };
|
|
882
|
+
|
|
883
|
+
static const unsigned char entropy_source_nopr[] =
|
|
884
|
+
{ 0x4c, 0xfb, 0x21, 0x86, 0x73, 0x34, 0x6d, 0x9d,
|
|
885
|
+
0x50, 0xc9, 0x22, 0xe4, 0x9b, 0x0d, 0xfc, 0xd0,
|
|
886
|
+
0x90, 0xad, 0xf0, 0x4f, 0x5c, 0x3b, 0xa4, 0x73,
|
|
887
|
+
0x27, 0xdf, 0xcd, 0x6f, 0xa6, 0x3a, 0x78, 0x5c,
|
|
888
|
+
0x01, 0x69, 0x62, 0xa7, 0xfd, 0x27, 0x87, 0xa2,
|
|
889
|
+
0x4b, 0xf6, 0xbe, 0x47, 0xef, 0x37, 0x83, 0xf1,
|
|
890
|
+
0xb7, 0xec, 0x46, 0x07, 0x23, 0x63, 0x83, 0x4a,
|
|
891
|
+
0x1b, 0x01, 0x33, 0xf2, 0xc2, 0x38, 0x91, 0xdb,
|
|
892
|
+
0x4f, 0x11, 0xa6, 0x86, 0x51, 0xf2, 0x3e, 0x3a,
|
|
893
|
+
0x8b, 0x1f, 0xdc, 0x03, 0xb1, 0x92, 0xc7, 0xe7 };
|
|
894
|
+
|
|
895
|
+
static const unsigned char pers_pr[] =
|
|
896
|
+
{ 0x5a, 0x70, 0x95, 0xe9, 0x81, 0x40, 0x52, 0x33,
|
|
897
|
+
0x91, 0x53, 0x7e, 0x75, 0xd6, 0x19, 0x9d, 0x1e,
|
|
898
|
+
0xad, 0x0d, 0xc6, 0xa7, 0xde, 0x6c, 0x1f, 0xe0,
|
|
899
|
+
0xea, 0x18, 0x33, 0xa8, 0x7e, 0x06, 0x20, 0xe9 };
|
|
900
|
+
|
|
901
|
+
static const unsigned char pers_nopr[] =
|
|
902
|
+
{ 0x88, 0xee, 0xb8, 0xe0, 0xe8, 0x3b, 0xf3, 0x29,
|
|
903
|
+
0x4b, 0xda, 0xcd, 0x60, 0x99, 0xeb, 0xe4, 0xbf,
|
|
904
|
+
0x55, 0xec, 0xd9, 0x11, 0x3f, 0x71, 0xe5, 0xeb,
|
|
905
|
+
0xcb, 0x45, 0x75, 0xf3, 0xd6, 0xa6, 0x8a, 0x6b };
|
|
906
|
+
|
|
907
|
+
static const unsigned char result_pr[] =
|
|
908
|
+
{ 0xce, 0x2f, 0xdb, 0xb6, 0xd9, 0xb7, 0x39, 0x85,
|
|
909
|
+
0x04, 0xc5, 0xc0, 0x42, 0xc2, 0x31, 0xc6, 0x1d,
|
|
910
|
+
0x9b, 0x5a, 0x59, 0xf8, 0x7e, 0x0d, 0xcc, 0x62,
|
|
911
|
+
0x7b, 0x65, 0x11, 0x55, 0x10, 0xeb, 0x9e, 0x3d,
|
|
912
|
+
0xa4, 0xfb, 0x1c, 0x6a, 0x18, 0xc0, 0x74, 0xdb,
|
|
913
|
+
0xdd, 0xe7, 0x02, 0x23, 0x63, 0x21, 0xd0, 0x39,
|
|
914
|
+
0xf9, 0xa7, 0xc4, 0x52, 0x84, 0x3b, 0x49, 0x40,
|
|
915
|
+
0x72, 0x2b, 0xb0, 0x6c, 0x9c, 0xdb, 0xc3, 0x43 };
|
|
916
|
+
|
|
917
|
+
static const unsigned char result_nopr[] =
|
|
918
|
+
{ 0xa5, 0x51, 0x80, 0xa1, 0x90, 0xbe, 0xf3, 0xad,
|
|
919
|
+
0xaf, 0x28, 0xf6, 0xb7, 0x95, 0xe9, 0xf1, 0xf3,
|
|
920
|
+
0xd6, 0xdf, 0xa1, 0xb2, 0x7d, 0xd0, 0x46, 0x7b,
|
|
921
|
+
0x0c, 0x75, 0xf5, 0xfa, 0x93, 0x1e, 0x97, 0x14,
|
|
922
|
+
0x75, 0xb2, 0x7c, 0xae, 0x03, 0xa2, 0x96, 0x54,
|
|
923
|
+
0xe2, 0xf4, 0x09, 0x66, 0xea, 0x33, 0x64, 0x30,
|
|
924
|
+
0x40, 0xd1, 0x40, 0x0f, 0xe6, 0x77, 0x87, 0x3a,
|
|
925
|
+
0xf8, 0x09, 0x7c, 0x1f, 0xe9, 0xf0, 0x02, 0x98 };
|
|
926
|
+
#endif /* MBEDTLS_CTR_DRBG_USE_128_BIT_KEY */
|
|
927
|
+
|
|
928
|
+
static size_t test_offset;
|
|
929
|
+
static int ctr_drbg_self_test_entropy(void *data, unsigned char *buf,
|
|
930
|
+
size_t len)
|
|
931
|
+
{
|
|
932
|
+
const unsigned char *p = data;
|
|
933
|
+
memcpy(buf, p + test_offset, len);
|
|
934
|
+
test_offset += len;
|
|
935
|
+
return 0;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
#define CHK(c) if ((c) != 0) \
|
|
939
|
+
{ \
|
|
940
|
+
if (verbose != 0) \
|
|
941
|
+
mbedtls_printf("failed\n"); \
|
|
942
|
+
return 1; \
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
#define SELF_TEST_OUTPUT_DISCARD_LENGTH 64
|
|
946
|
+
|
|
947
|
+
/*
|
|
948
|
+
* Checkup routine
|
|
949
|
+
*/
|
|
950
|
+
int mbedtls_ctr_drbg_self_test(int verbose)
|
|
951
|
+
{
|
|
952
|
+
mbedtls_ctr_drbg_context ctx;
|
|
953
|
+
unsigned char buf[sizeof(result_pr)];
|
|
954
|
+
|
|
955
|
+
mbedtls_ctr_drbg_init(&ctx);
|
|
956
|
+
|
|
957
|
+
/*
|
|
958
|
+
* Based on a NIST CTR_DRBG test vector (PR = True)
|
|
959
|
+
*/
|
|
960
|
+
if (verbose != 0) {
|
|
961
|
+
mbedtls_printf(" CTR_DRBG (PR = TRUE) : ");
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
test_offset = 0;
|
|
965
|
+
mbedtls_ctr_drbg_set_entropy_len(&ctx, MBEDTLS_CTR_DRBG_KEYSIZE);
|
|
966
|
+
mbedtls_ctr_drbg_set_nonce_len(&ctx, MBEDTLS_CTR_DRBG_KEYSIZE / 2);
|
|
967
|
+
CHK(mbedtls_ctr_drbg_seed(&ctx,
|
|
968
|
+
ctr_drbg_self_test_entropy,
|
|
969
|
+
(void *) entropy_source_pr,
|
|
970
|
+
pers_pr, MBEDTLS_CTR_DRBG_KEYSIZE));
|
|
971
|
+
mbedtls_ctr_drbg_set_prediction_resistance(&ctx, MBEDTLS_CTR_DRBG_PR_ON);
|
|
972
|
+
CHK(mbedtls_ctr_drbg_random(&ctx, buf, SELF_TEST_OUTPUT_DISCARD_LENGTH));
|
|
973
|
+
CHK(mbedtls_ctr_drbg_random(&ctx, buf, sizeof(result_pr)));
|
|
974
|
+
CHK(memcmp(buf, result_pr, sizeof(result_pr)));
|
|
975
|
+
|
|
976
|
+
mbedtls_ctr_drbg_free(&ctx);
|
|
977
|
+
|
|
978
|
+
if (verbose != 0) {
|
|
979
|
+
mbedtls_printf("passed\n");
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/*
|
|
983
|
+
* Based on a NIST CTR_DRBG test vector (PR = FALSE)
|
|
984
|
+
*/
|
|
985
|
+
if (verbose != 0) {
|
|
986
|
+
mbedtls_printf(" CTR_DRBG (PR = FALSE): ");
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
mbedtls_ctr_drbg_init(&ctx);
|
|
990
|
+
|
|
991
|
+
test_offset = 0;
|
|
992
|
+
mbedtls_ctr_drbg_set_entropy_len(&ctx, MBEDTLS_CTR_DRBG_KEYSIZE);
|
|
993
|
+
mbedtls_ctr_drbg_set_nonce_len(&ctx, MBEDTLS_CTR_DRBG_KEYSIZE / 2);
|
|
994
|
+
CHK(mbedtls_ctr_drbg_seed(&ctx,
|
|
995
|
+
ctr_drbg_self_test_entropy,
|
|
996
|
+
(void *) entropy_source_nopr,
|
|
997
|
+
pers_nopr, MBEDTLS_CTR_DRBG_KEYSIZE));
|
|
998
|
+
CHK(mbedtls_ctr_drbg_reseed(&ctx, NULL, 0));
|
|
999
|
+
CHK(mbedtls_ctr_drbg_random(&ctx, buf, SELF_TEST_OUTPUT_DISCARD_LENGTH));
|
|
1000
|
+
CHK(mbedtls_ctr_drbg_random(&ctx, buf, sizeof(result_nopr)));
|
|
1001
|
+
CHK(memcmp(buf, result_nopr, sizeof(result_nopr)));
|
|
1002
|
+
|
|
1003
|
+
mbedtls_ctr_drbg_free(&ctx);
|
|
1004
|
+
|
|
1005
|
+
if (verbose != 0) {
|
|
1006
|
+
mbedtls_printf("passed\n");
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
if (verbose != 0) {
|
|
1010
|
+
mbedtls_printf("\n");
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
return 0;
|
|
1014
|
+
}
|
|
1015
|
+
#endif /* MBEDTLS_SELF_TEST */
|
|
1016
|
+
|
|
1017
|
+
#endif /* MBEDTLS_CTR_DRBG_C */
|