├── .gitignore ├── README.md └── whatsappcpp ├── 3rd ├── curve25519 │ ├── CMakeLists.txt │ ├── ed25519 │ │ ├── additions │ │ │ ├── compare.c │ │ │ ├── compare.h │ │ │ ├── crypto_additions.h │ │ │ ├── crypto_hash_sha512.h │ │ │ ├── curve_sigs.c │ │ │ ├── curve_sigs.h │ │ │ ├── elligator.c │ │ │ ├── fe_isequal.c │ │ │ ├── fe_isreduced.c │ │ │ ├── fe_mont_rhs.c │ │ │ ├── fe_montx_to_edy.c │ │ │ ├── fe_sqrt.c │ │ │ ├── ge_isneutral.c │ │ │ ├── ge_montx_to_p3.c │ │ │ ├── ge_neg.c │ │ │ ├── ge_p3_to_montx.c │ │ │ ├── ge_scalarmult.c │ │ │ ├── ge_scalarmult_cofactor.c │ │ │ ├── generalized │ │ │ │ ├── ge_p3_add.c │ │ │ │ ├── gen_constants.h │ │ │ │ ├── gen_crypto_additions.h │ │ │ │ ├── gen_eddsa.c │ │ │ │ ├── gen_eddsa.h │ │ │ │ ├── gen_labelset.c │ │ │ │ ├── gen_labelset.h │ │ │ │ ├── gen_veddsa.c │ │ │ │ ├── gen_veddsa.h │ │ │ │ ├── gen_x.c │ │ │ │ ├── gen_x.h │ │ │ │ ├── point_isreduced.c │ │ │ │ └── sc_isreduced.c │ │ │ ├── keygen.c │ │ │ ├── keygen.h │ │ │ ├── open_modified.c │ │ │ ├── sc_clamp.c │ │ │ ├── sc_cmov.c │ │ │ ├── sc_neg.c │ │ │ ├── sign_modified.c │ │ │ ├── utility.c │ │ │ ├── utility.h │ │ │ ├── xeddsa.c │ │ │ ├── xeddsa.h │ │ │ ├── zeroize.c │ │ │ └── zeroize.h │ │ ├── base.h │ │ ├── base2.h │ │ ├── d.h │ │ ├── d2.h │ │ ├── fe.h │ │ ├── fe_0.c │ │ ├── fe_1.c │ │ ├── fe_add.c │ │ ├── fe_cmov.c │ │ ├── fe_copy.c │ │ ├── fe_frombytes.c │ │ ├── fe_invert.c │ │ ├── fe_isnegative.c │ │ ├── fe_isnonzero.c │ │ ├── fe_mul.c │ │ ├── fe_neg.c │ │ ├── fe_pow22523.c │ │ ├── fe_sq.c │ │ ├── fe_sq2.c │ │ ├── fe_sub.c │ │ ├── fe_tobytes.c │ │ ├── ge.h │ │ ├── ge_add.c │ │ ├── ge_add.h │ │ ├── ge_double_scalarmult.c │ │ ├── ge_frombytes.c │ │ ├── ge_madd.c │ │ ├── ge_madd.h │ │ ├── ge_msub.c │ │ ├── ge_msub.h │ │ ├── ge_p1p1_to_p2.c │ │ ├── ge_p1p1_to_p3.c │ │ ├── ge_p2_0.c │ │ ├── ge_p2_dbl.c │ │ ├── ge_p2_dbl.h │ │ ├── ge_p3_0.c │ │ ├── ge_p3_dbl.c │ │ ├── ge_p3_to_cached.c │ │ ├── ge_p3_to_p2.c │ │ ├── ge_p3_tobytes.c │ │ ├── ge_precomp_0.c │ │ ├── ge_scalarmult_base.c │ │ ├── ge_sub.c │ │ ├── ge_sub.h │ │ ├── ge_tobytes.c │ │ ├── nacl_includes │ │ │ ├── crypto_int32.h │ │ │ ├── crypto_int64.h │ │ │ ├── crypto_sign.h │ │ │ ├── crypto_sign_edwards25519sha512batch.h │ │ │ ├── crypto_uint32.h │ │ │ ├── crypto_uint64.h │ │ │ └── crypto_verify_32.h │ │ ├── nacl_sha512 │ │ │ ├── blocks.c │ │ │ └── hash.c │ │ ├── open.c │ │ ├── pow22523.h │ │ ├── pow225521.h │ │ ├── sc.h │ │ ├── sc_muladd.c │ │ ├── sc_reduce.c │ │ ├── sign.c │ │ ├── sqrtm1.h │ │ └── tests │ │ │ ├── internal_fast_tests.c │ │ │ ├── internal_fast_tests.h │ │ │ ├── internal_slow_tests.c │ │ │ └── internal_slow_tests.h │ └── lib │ │ └── curve25519.lib ├── mbedtls │ ├── include │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── mbedtls │ │ │ ├── aes.h │ │ │ ├── aesni.h │ │ │ ├── arc4.h │ │ │ ├── aria.h │ │ │ ├── asn1.h │ │ │ ├── asn1write.h │ │ │ ├── base64.h │ │ │ ├── bignum.h │ │ │ ├── blowfish.h │ │ │ ├── bn_mul.h │ │ │ ├── camellia.h │ │ │ ├── ccm.h │ │ │ ├── certs.h │ │ │ ├── chacha20.h │ │ │ ├── chachapoly.h │ │ │ ├── check_config.h │ │ │ ├── cipher.h │ │ │ ├── cipher_internal.h │ │ │ ├── cmac.h │ │ │ ├── compat-1.3.h │ │ │ ├── config.h │ │ │ ├── config_psa.h │ │ │ ├── ctr_drbg.h │ │ │ ├── debug.h │ │ │ ├── des.h │ │ │ ├── dhm.h │ │ │ ├── ecdh.h │ │ │ ├── ecdsa.h │ │ │ ├── ecjpake.h │ │ │ ├── ecp.h │ │ │ ├── ecp_internal.h │ │ │ ├── entropy.h │ │ │ ├── entropy_poll.h │ │ │ ├── error.h │ │ │ ├── gcm.h │ │ │ ├── havege.h │ │ │ ├── hkdf.h │ │ │ ├── hmac_drbg.h │ │ │ ├── md.h │ │ │ ├── md2.h │ │ │ ├── md4.h │ │ │ ├── md5.h │ │ │ ├── md_internal.h │ │ │ ├── memory_buffer_alloc.h │ │ │ ├── net.h │ │ │ ├── net_sockets.h │ │ │ ├── nist_kw.h │ │ │ ├── oid.h │ │ │ ├── padlock.h │ │ │ ├── pem.h │ │ │ ├── pk.h │ │ │ ├── pk_internal.h │ │ │ ├── pkcs11.h │ │ │ ├── pkcs12.h │ │ │ ├── pkcs5.h │ │ │ ├── platform.h │ │ │ ├── platform_time.h │ │ │ ├── platform_util.h │ │ │ ├── poly1305.h │ │ │ ├── psa_util.h │ │ │ ├── ripemd160.h │ │ │ ├── rsa.h │ │ │ ├── rsa_internal.h │ │ │ ├── sha1.h │ │ │ ├── sha256.h │ │ │ ├── sha512.h │ │ │ ├── ssl.h │ │ │ ├── ssl_cache.h │ │ │ ├── ssl_ciphersuites.h │ │ │ ├── ssl_cookie.h │ │ │ ├── ssl_internal.h │ │ │ ├── ssl_ticket.h │ │ │ ├── threading.h │ │ │ ├── timing.h │ │ │ ├── version.h │ │ │ ├── x509.h │ │ │ ├── x509_crl.h │ │ │ ├── x509_crt.h │ │ │ ├── x509_csr.h │ │ │ └── xtea.h │ │ └── psa │ │ │ ├── crypto.h │ │ │ ├── crypto_accel_driver.h │ │ │ ├── crypto_compat.h │ │ │ ├── crypto_config.h │ │ │ ├── crypto_driver_common.h │ │ │ ├── crypto_entropy_driver.h │ │ │ ├── crypto_extra.h │ │ │ ├── crypto_platform.h │ │ │ ├── crypto_se_driver.h │ │ │ ├── crypto_sizes.h │ │ │ ├── crypto_struct.h │ │ │ ├── crypto_types.h │ │ │ └── crypto_values.h │ └── lib │ │ ├── mbedcrypto.lib │ │ ├── mbedtls.lib │ │ └── mbedx509.lib └── openssl │ ├── bin │ └── openssl.exe │ ├── include │ └── openssl │ │ ├── aes.h │ │ ├── asn1.h │ │ ├── asn1_mac.h │ │ ├── asn1t.h │ │ ├── bio.h │ │ ├── blowfish.h │ │ ├── bn.h │ │ ├── buffer.h │ │ ├── camellia.h │ │ ├── cast.h │ │ ├── cmac.h │ │ ├── cms.h │ │ ├── comp.h │ │ ├── conf.h │ │ ├── conf_api.h │ │ ├── crypto.h │ │ ├── des.h │ │ ├── des_old.h │ │ ├── dh.h │ │ ├── dsa.h │ │ ├── dso.h │ │ ├── dtls1.h │ │ ├── e_os2.h │ │ ├── ebcdic.h │ │ ├── ec.h │ │ ├── ecdh.h │ │ ├── ecdsa.h │ │ ├── engine.h │ │ ├── err.h │ │ ├── evp.h │ │ ├── hmac.h │ │ ├── idea.h │ │ ├── krb5_asn.h │ │ ├── kssl.h │ │ ├── lhash.h │ │ ├── md4.h │ │ ├── md5.h │ │ ├── mdc2.h │ │ ├── modes.h │ │ ├── obj_mac.h │ │ ├── objects.h │ │ ├── ocsp.h │ │ ├── opensslconf.h │ │ ├── opensslv.h │ │ ├── ossl_typ.h │ │ ├── pem.h │ │ ├── pem2.h │ │ ├── pkcs12.h │ │ ├── pkcs7.h │ │ ├── pqueue.h │ │ ├── rand.h │ │ ├── rc2.h │ │ ├── rc4.h │ │ ├── ripemd.h │ │ ├── rsa.h │ │ ├── safestack.h │ │ ├── seed.h │ │ ├── sha.h │ │ ├── srp.h │ │ ├── srtp.h │ │ ├── ssl.h │ │ ├── ssl2.h │ │ ├── ssl23.h │ │ ├── ssl3.h │ │ ├── stack.h │ │ ├── symhacks.h │ │ ├── tls1.h │ │ ├── ts.h │ │ ├── txt_db.h │ │ ├── ui.h │ │ ├── ui_compat.h │ │ ├── whrlpool.h │ │ ├── x509.h │ │ ├── x509_vfy.h │ │ └── x509v3.h │ ├── lib │ ├── libeay32.lib │ └── ssleay32.lib │ └── openssl.cnf ├── whatsappcpp.sln └── whatsappcpp ├── curve ├── curve.cpp ├── curve.h ├── curve25519-donna.cpp └── curve25519-donna.h ├── main.cpp ├── whatsapp ├── whatsapp.cpp └── whatsapp.h ├── whatsappcpp.vcxproj ├── whatsappcpp.vcxproj.filters └── whatsappcpp.vcxproj.user /.gitignore: -------------------------------------------------------------------------------- 1 | whatsappcpp/.vs/ 2 | whatsappcpp/whatsappcpp/x64/ 3 | whatsappcpp/x64/Debug/ 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # whatsapp_protocol 2 | whatsapp android protocol 3 | 4 | whatsapp 安卓协议分析 5 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") 2 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable -Wno-unused-function -Wno-shadow") 3 | ENDIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") 4 | 5 | IF(CMAKE_COMPILER_IS_GNUCC) 6 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-sign-compare") 7 | IF(GCC_WARN_SIGN_CONVERSION) 8 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-sign-conversion") 9 | ENDIF(GCC_WARN_SIGN_CONVERSION) 10 | ENDIF(CMAKE_COMPILER_IS_GNUCC) 11 | 12 | IF(CMAKE_C_COMPILER_ID MATCHES "Clang") 13 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-shorten-64-to-32") 14 | ENDIF(CMAKE_C_COMPILER_ID MATCHES "Clang") 15 | 16 | include_directories( 17 | ed25519/nacl_includes 18 | ed25519/additions 19 | ed25519/additions/generalized 20 | ed25519/sha512 21 | ed25519/tests 22 | ed25519 23 | ) 24 | 25 | set(curve25519_SRCS 26 | curve25519-donna.c 27 | ) 28 | 29 | set(ed25519_SRCS 30 | ed25519/fe_0.c 31 | ed25519/fe_1.c 32 | ed25519/fe_add.c 33 | ed25519/fe_cmov.c 34 | ed25519/fe_copy.c 35 | ed25519/fe_frombytes.c 36 | ed25519/fe_invert.c 37 | ed25519/fe_isnegative.c 38 | ed25519/fe_isnonzero.c 39 | ed25519/fe_mul.c 40 | ed25519/fe_neg.c 41 | ed25519/fe_pow22523.c 42 | ed25519/fe_sq.c 43 | ed25519/fe_sq2.c 44 | ed25519/fe_sub.c 45 | ed25519/fe_tobytes.c 46 | ed25519/ge_add.c 47 | ed25519/ge_double_scalarmult.c 48 | ed25519/ge_frombytes.c 49 | ed25519/ge_madd.c 50 | ed25519/ge_msub.c 51 | ed25519/ge_p1p1_to_p2.c 52 | ed25519/ge_p1p1_to_p3.c 53 | ed25519/ge_p2_0.c 54 | ed25519/ge_p2_dbl.c 55 | ed25519/ge_p3_0.c 56 | ed25519/ge_p3_dbl.c 57 | ed25519/ge_p3_to_cached.c 58 | ed25519/ge_p3_to_p2.c 59 | ed25519/ge_p3_tobytes.c 60 | ed25519/ge_precomp_0.c 61 | ed25519/ge_scalarmult_base.c 62 | ed25519/ge_sub.c 63 | ed25519/ge_tobytes.c 64 | ed25519/open.c 65 | ed25519/sc_muladd.c 66 | ed25519/sc_reduce.c 67 | ed25519/sign.c 68 | ed25519/additions/compare.c 69 | ed25519/additions/curve_sigs.c 70 | ed25519/additions/elligator.c 71 | ed25519/additions/fe_isequal.c 72 | ed25519/additions/fe_isreduced.c 73 | ed25519/additions/fe_mont_rhs.c 74 | ed25519/additions/fe_montx_to_edy.c 75 | ed25519/additions/fe_sqrt.c 76 | ed25519/additions/ge_isneutral.c 77 | ed25519/additions/ge_montx_to_p3.c 78 | ed25519/additions/ge_neg.c 79 | ed25519/additions/ge_p3_to_montx.c 80 | ed25519/additions/ge_scalarmult.c 81 | ed25519/additions/ge_scalarmult_cofactor.c 82 | ed25519/additions/keygen.c 83 | ed25519/additions/open_modified.c 84 | ed25519/additions/sc_clamp.c 85 | ed25519/additions/sc_cmov.c 86 | ed25519/additions/sc_neg.c 87 | ed25519/additions/sign_modified.c 88 | ed25519/additions/utility.c 89 | ed25519/additions/generalized/ge_p3_add.c 90 | ed25519/additions/generalized/gen_eddsa.c 91 | ed25519/additions/generalized/gen_labelset.c 92 | ed25519/additions/generalized/gen_veddsa.c 93 | ed25519/additions/generalized/gen_x.c 94 | ed25519/additions/generalized/point_isreduced.c 95 | ed25519/additions/generalized/sc_isreduced.c 96 | ed25519/additions/xeddsa.c 97 | ed25519/additions/zeroize.c 98 | ed25519/nacl_sha512/blocks.c 99 | ed25519/nacl_sha512/hash.c 100 | ed25519/tests/internal_fast_tests.c 101 | ) 102 | 103 | add_library(curve25519 OBJECT ${curve25519_SRCS} ${ed25519_SRCS}) 104 | 105 | # Add -fPIC flag 106 | if(BUILD_SHARED_LIBS) 107 | set_property(TARGET curve25519 PROPERTY POSITION_INDEPENDENT_CODE ON) 108 | endif() 109 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/compare.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "compare.h" 3 | 4 | /* Const-time comparison from SUPERCOP, but here it's only used for 5 | signature verification, so doesn't need to be const-time. But 6 | copied the nacl version anyways. */ 7 | int crypto_verify_32_ref(const unsigned char *x, const unsigned char *y) 8 | { 9 | unsigned int differentbits = 0; 10 | #define F(i) differentbits |= x[i] ^ y[i]; 11 | F(0) 12 | F(1) 13 | F(2) 14 | F(3) 15 | F(4) 16 | F(5) 17 | F(6) 18 | F(7) 19 | F(8) 20 | F(9) 21 | F(10) 22 | F(11) 23 | F(12) 24 | F(13) 25 | F(14) 26 | F(15) 27 | F(16) 28 | F(17) 29 | F(18) 30 | F(19) 31 | F(20) 32 | F(21) 33 | F(22) 34 | F(23) 35 | F(24) 36 | F(25) 37 | F(26) 38 | F(27) 39 | F(28) 40 | F(29) 41 | F(30) 42 | F(31) 43 | return (1 & ((differentbits - 1) >> 8)) - 1; 44 | } 45 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/compare.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMPARE_H__ 2 | #define __COMPARE_H__ 3 | 4 | int crypto_verify_32_ref(const unsigned char *b1, const unsigned char *b2); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/crypto_additions.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CRYPTO_ADDITIONS__ 3 | #define __CRYPTO_ADDITIONS__ 4 | 5 | #include "crypto_uint32.h" 6 | #include "fe.h" 7 | #include "ge.h" 8 | 9 | #define MAX_MSG_LEN 256 10 | 11 | void sc_neg(unsigned char *b, const unsigned char *a); 12 | void sc_cmov(unsigned char* f, const unsigned char* g, unsigned char b); 13 | 14 | int fe_isequal(const fe f, const fe g); 15 | int fe_isreduced(const unsigned char* s); 16 | void fe_mont_rhs(fe v2, const fe u); 17 | void fe_montx_to_edy(fe y, const fe u); 18 | void fe_sqrt(fe b, const fe a); 19 | 20 | int ge_isneutral(const ge_p3* q); 21 | void ge_neg(ge_p3* r, const ge_p3 *p); 22 | void ge_montx_to_p3(ge_p3* p, const fe u, const unsigned char ed_sign_bit); 23 | void ge_p3_to_montx(fe u, const ge_p3 *p); 24 | void ge_scalarmult(ge_p3 *h, const unsigned char *a, const ge_p3 *A); 25 | void ge_scalarmult_cofactor(ge_p3 *q, const ge_p3 *p); 26 | 27 | void elligator(fe u, const fe r); 28 | void hash_to_point(ge_p3* p, const unsigned char* msg, const unsigned long in_len); 29 | 30 | int crypto_sign_modified( 31 | unsigned char *sm, 32 | const unsigned char *m,unsigned long long mlen, 33 | const unsigned char *sk, /* Curve/Ed25519 private key */ 34 | const unsigned char *pk, /* Ed25519 public key */ 35 | const unsigned char *random /* 64 bytes random to hash into nonce */ 36 | ); 37 | 38 | int crypto_sign_open_modified( 39 | unsigned char *m, 40 | const unsigned char *sm,unsigned long long smlen, 41 | const unsigned char *pk 42 | ); 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/crypto_hash_sha512.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_hash_sha512_H 2 | #define crypto_hash_sha512_H 3 | 4 | extern int crypto_hash_sha512(unsigned char *,const unsigned char *,unsigned long long); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/curve_sigs.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "ge.h" 4 | #include "curve_sigs.h" 5 | #include "crypto_sign.h" 6 | #include "crypto_additions.h" 7 | 8 | int curve25519_sign(unsigned char* signature_out, 9 | const unsigned char* curve25519_privkey, 10 | const unsigned char* msg, const unsigned long msg_len, 11 | const unsigned char* random) 12 | { 13 | ge_p3 ed_pubkey_point; /* Ed25519 pubkey point */ 14 | unsigned char ed_pubkey[32]; /* Ed25519 encoded pubkey */ 15 | unsigned char *sigbuf; /* working buffer */ 16 | unsigned char sign_bit = 0; 17 | 18 | if ((sigbuf = malloc(msg_len + 128)) == 0) { 19 | memset(signature_out, 0, 64); 20 | return -1; 21 | } 22 | 23 | /* Convert the Curve25519 privkey to an Ed25519 public key */ 24 | ge_scalarmult_base(&ed_pubkey_point, curve25519_privkey); 25 | ge_p3_tobytes(ed_pubkey, &ed_pubkey_point); 26 | sign_bit = ed_pubkey[31] & 0x80; 27 | 28 | /* Perform an Ed25519 signature with explicit private key */ 29 | crypto_sign_modified(sigbuf, msg, msg_len, curve25519_privkey, 30 | ed_pubkey, random); 31 | memmove(signature_out, sigbuf, 64); 32 | 33 | /* Encode the sign bit into signature (in unused high bit of S) */ 34 | signature_out[63] &= 0x7F; /* bit should be zero already, but just in case */ 35 | signature_out[63] |= sign_bit; 36 | 37 | free(sigbuf); 38 | return 0; 39 | } 40 | 41 | int curve25519_verify(const unsigned char* signature, 42 | const unsigned char* curve25519_pubkey, 43 | const unsigned char* msg, const unsigned long msg_len) 44 | { 45 | fe u; 46 | fe y; 47 | unsigned char ed_pubkey[32]; 48 | unsigned char *verifybuf = NULL; /* working buffer */ 49 | unsigned char *verifybuf2 = NULL; /* working buffer #2 */ 50 | int result; 51 | 52 | if ((verifybuf = malloc(msg_len + 64)) == 0) { 53 | result = -1; 54 | goto err; 55 | } 56 | 57 | if ((verifybuf2 = malloc(msg_len + 64)) == 0) { 58 | result = -1; 59 | goto err; 60 | } 61 | 62 | /* Convert the Curve25519 public key into an Ed25519 public key. In 63 | particular, convert Curve25519's "montgomery" x-coordinate (u) into an 64 | Ed25519 "edwards" y-coordinate: 65 | 66 | y = (u - 1) / (u + 1) 67 | 68 | NOTE: u=-1 is converted to y=0 since fe_invert is mod-exp 69 | 70 | Then move the sign bit into the pubkey from the signature. 71 | */ 72 | fe_frombytes(u, curve25519_pubkey); 73 | fe_montx_to_edy(y, u); 74 | fe_tobytes(ed_pubkey, y); 75 | 76 | /* Copy the sign bit, and remove it from signature */ 77 | ed_pubkey[31] &= 0x7F; /* bit should be zero already, but just in case */ 78 | ed_pubkey[31] |= (signature[63] & 0x80); 79 | memmove(verifybuf, signature, 64); 80 | verifybuf[63] &= 0x7F; 81 | 82 | memmove(verifybuf+64, msg, msg_len); 83 | 84 | /* Then perform a normal Ed25519 verification, return 0 on success */ 85 | /* The below call has a strange API: */ 86 | /* verifybuf = R || S || message */ 87 | /* verifybuf2 = internal to next call gets a copy of verifybuf, S gets 88 | replaced with pubkey for hashing */ 89 | result = crypto_sign_open_modified(verifybuf2, verifybuf, 64 + msg_len, ed_pubkey); 90 | 91 | err: 92 | 93 | if (verifybuf != NULL) { 94 | free(verifybuf); 95 | } 96 | 97 | if (verifybuf2 != NULL) { 98 | free(verifybuf2); 99 | } 100 | 101 | return result; 102 | } 103 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/curve_sigs.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CURVE_SIGS_H__ 3 | #define __CURVE_SIGS_H__ 4 | 5 | /* returns 0 on success */ 6 | int curve25519_sign(unsigned char* signature_out, /* 64 bytes */ 7 | const unsigned char* curve25519_privkey, /* 32 bytes */ 8 | const unsigned char* msg, const unsigned long msg_len, /* <= 256 bytes */ 9 | const unsigned char* random); /* 64 bytes */ 10 | 11 | /* returns 0 on success */ 12 | int curve25519_verify(const unsigned char* signature, /* 64 bytes */ 13 | const unsigned char* curve25519_pubkey, /* 32 bytes */ 14 | const unsigned char* msg, const unsigned long msg_len); /* <= 256 bytes */ 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/elligator.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "fe.h" 3 | #include "ge.h" 4 | #include "crypto_uint32.h" 5 | #include "crypto_hash_sha512.h" 6 | #include "crypto_additions.h" 7 | 8 | unsigned int legendre_is_nonsquare(fe in) 9 | { 10 | fe temp; 11 | unsigned char bytes[32]; 12 | fe_pow22523(temp, in); /* temp = in^((q-5)/8) */ 13 | fe_sq(temp, temp); /* in^((q-5)/4) */ 14 | fe_sq(temp, temp); /* in^((q-5)/2) */ 15 | fe_mul(temp, temp, in); /* in^((q-3)/2) */ 16 | fe_mul(temp, temp, in); /* in^((q-1)/2) */ 17 | 18 | /* temp is now the Legendre symbol: 19 | * 1 = square 20 | * 0 = input is zero 21 | * -1 = nonsquare 22 | */ 23 | fe_tobytes(bytes, temp); 24 | return 1 & bytes[31]; 25 | } 26 | 27 | void elligator(fe u, const fe r) 28 | { 29 | /* r = input 30 | * x = -A/(1+2r^2) # 2 is nonsquare 31 | * e = (x^3 + Ax^2 + x)^((q-1)/2) # legendre symbol 32 | * if e == 1 (square) or e == 0 (because x == 0 and 2r^2 + 1 == 0) 33 | * u = x 34 | * if e == -1 (nonsquare) 35 | * u = -x - A 36 | */ 37 | fe A, one, twor2, twor2plus1, twor2plus1inv; 38 | fe x, e, Atemp, uneg; 39 | unsigned int nonsquare; 40 | 41 | fe_1(one); 42 | fe_0(A); 43 | A[0] = 486662; /* A = 486662 */ 44 | 45 | fe_sq2(twor2, r); /* 2r^2 */ 46 | fe_add(twor2plus1, twor2, one); /* 1+2r^2 */ 47 | fe_invert(twor2plus1inv, twor2plus1); /* 1/(1+2r^2) */ 48 | fe_mul(x, twor2plus1inv, A); /* A/(1+2r^2) */ 49 | fe_neg(x, x); /* x = -A/(1+2r^2) */ 50 | 51 | fe_mont_rhs(e, x); /* e = x^3 + Ax^2 + x */ 52 | nonsquare = legendre_is_nonsquare(e); 53 | 54 | fe_0(Atemp); 55 | fe_cmov(Atemp, A, nonsquare); /* 0, or A if nonsquare */ 56 | fe_add(u, x, Atemp); /* x, or x+A if nonsquare */ 57 | fe_neg(uneg, u); /* -x, or -x-A if nonsquare */ 58 | fe_cmov(u, uneg, nonsquare); /* x, or -x-A if nonsquare */ 59 | } 60 | 61 | void hash_to_point(ge_p3* p, const unsigned char* in, const unsigned long in_len) 62 | { 63 | unsigned char hash[64]; 64 | fe h, u; 65 | unsigned char sign_bit; 66 | ge_p3 p3; 67 | 68 | crypto_hash_sha512(hash, in, in_len); 69 | 70 | /* take the high bit as Edwards sign bit */ 71 | sign_bit = (hash[31] & 0x80) >> 7; 72 | hash[31] &= 0x7F; 73 | fe_frombytes(h, hash); 74 | elligator(u, h); 75 | 76 | ge_montx_to_p3(&p3, u, sign_bit); 77 | ge_scalarmult_cofactor(p, &p3); 78 | } 79 | 80 | 81 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/fe_isequal.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | #include "crypto_verify_32.h" 3 | 4 | /* 5 | return 1 if f == g 6 | return 0 if f != g 7 | */ 8 | 9 | int fe_isequal(const fe f, const fe g) 10 | { 11 | fe h; 12 | fe_sub(h, f, g); 13 | return 1 ^ (1 & (fe_isnonzero(h) >> 8)); 14 | } 15 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/fe_isreduced.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | #include "crypto_verify_32.h" 3 | 4 | int fe_isreduced(const unsigned char* s) 5 | { 6 | fe f; 7 | unsigned char strict[32]; 8 | 9 | fe_frombytes(f, s); 10 | fe_tobytes(strict, f); 11 | if (crypto_verify_32(strict, s) != 0) 12 | return 0; 13 | return 1; 14 | } 15 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/fe_mont_rhs.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | void fe_mont_rhs(fe v2, fe u) { 4 | fe A, one; 5 | fe u2, Au, inner; 6 | 7 | fe_1(one); 8 | fe_0(A); 9 | A[0] = 486662; /* A = 486662 */ 10 | 11 | fe_sq(u2, u); /* u^2 */ 12 | fe_mul(Au, A, u); /* Au */ 13 | fe_add(inner, u2, Au); /* u^2 + Au */ 14 | fe_add(inner, inner, one); /* u^2 + Au + 1 */ 15 | fe_mul(v2, u, inner); /* u(u^2 + Au + 1) */ 16 | } 17 | 18 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/fe_montx_to_edy.c: -------------------------------------------------------------------------------- 1 | 2 | #include "fe.h" 3 | #include "crypto_additions.h" 4 | 5 | void fe_montx_to_edy(fe y, const fe u) 6 | { 7 | /* 8 | y = (u - 1) / (u + 1) 9 | 10 | NOTE: u=-1 is converted to y=0 since fe_invert is mod-exp 11 | */ 12 | fe one, um1, up1; 13 | 14 | fe_1(one); 15 | fe_sub(um1, u, one); 16 | fe_add(up1, u, one); 17 | fe_invert(up1, up1); 18 | fe_mul(y, um1, up1); 19 | } 20 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/fe_sqrt.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "fe.h" 3 | #include "crypto_additions.h" 4 | 5 | /* sqrt(-1) */ 6 | static unsigned char i_bytes[32] = { 7 | 0xb0, 0xa0, 0x0e, 0x4a, 0x27, 0x1b, 0xee, 0xc4, 8 | 0x78, 0xe4, 0x2f, 0xad, 0x06, 0x18, 0x43, 0x2f, 9 | 0xa7, 0xd7, 0xfb, 0x3d, 0x99, 0x00, 0x4d, 0x2b, 10 | 0x0b, 0xdf, 0xc1, 0x4f, 0x80, 0x24, 0x83, 0x2b 11 | }; 12 | 13 | /* Preconditions: a is square or zero */ 14 | 15 | void fe_sqrt(fe out, const fe a) 16 | { 17 | fe exp, b, b2, bi, i; 18 | #ifndef NDEBUG 19 | fe legendre, zero, one; 20 | #endif 21 | 22 | fe_frombytes(i, i_bytes); 23 | fe_pow22523(exp, a); /* b = a^(q-5)/8 */ 24 | 25 | /* PRECONDITION: legendre symbol == 1 (square) or 0 (a == zero) */ 26 | #ifndef NDEBUG 27 | fe_sq(legendre, exp); /* in^((q-5)/4) */ 28 | fe_sq(legendre, legendre); /* in^((q-5)/2) */ 29 | fe_mul(legendre, legendre, a); /* in^((q-3)/2) */ 30 | fe_mul(legendre, legendre, a); /* in^((q-1)/2) */ 31 | 32 | fe_0(zero); 33 | fe_1(one); 34 | assert(fe_isequal(legendre, zero) || fe_isequal(legendre, one)); 35 | #endif 36 | 37 | fe_mul(b, a, exp); /* b = a * a^(q-5)/8 */ 38 | fe_sq(b2, b); /* b^2 = a * a^(q-1)/4 */ 39 | 40 | /* note b^4 == a^2, so b^2 == a or -a 41 | * if b^2 != a, multiply it by sqrt(-1) */ 42 | fe_mul(bi, b, i); 43 | fe_cmov(b, bi, 1 ^ fe_isequal(b2, a)); 44 | fe_copy(out, b); 45 | 46 | /* PRECONDITION: out^2 == a */ 47 | #ifndef NDEBUG 48 | fe_sq(b2, out); 49 | assert(fe_isequal(a, b2)); 50 | #endif 51 | } 52 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/ge_isneutral.c: -------------------------------------------------------------------------------- 1 | #include "crypto_additions.h" 2 | #include "ge.h" 3 | 4 | /* 5 | return 1 if p is the neutral point 6 | return 0 otherwise 7 | */ 8 | 9 | int ge_isneutral(const ge_p3 *p) 10 | { 11 | fe zero; 12 | fe_0(zero); 13 | 14 | /* Check if p == neutral element == (0, 1) */ 15 | return (fe_isequal(p->X, zero) & fe_isequal(p->Y, p->Z)); 16 | } 17 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/ge_montx_to_p3.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | #include "ge.h" 3 | #include "assert.h" 4 | #include "crypto_additions.h" 5 | #include "utility.h" 6 | 7 | /* sqrt(-(A+2)) */ 8 | static unsigned char A_bytes[32] = { 9 | 0x06, 0x7e, 0x45, 0xff, 0xaa, 0x04, 0x6e, 0xcc, 10 | 0x82, 0x1a, 0x7d, 0x4b, 0xd1, 0xd3, 0xa1, 0xc5, 11 | 0x7e, 0x4f, 0xfc, 0x03, 0xdc, 0x08, 0x7b, 0xd2, 12 | 0xbb, 0x06, 0xa0, 0x60, 0xf4, 0xed, 0x26, 0x0f 13 | }; 14 | 15 | void ge_montx_to_p3(ge_p3* p, const fe u, const unsigned char ed_sign_bit) 16 | { 17 | fe x, y, A, v, v2, iv, nx; 18 | 19 | fe_frombytes(A, A_bytes); 20 | 21 | /* given u, recover edwards y */ 22 | /* given u, recover v */ 23 | /* given u and v, recover edwards x */ 24 | 25 | fe_montx_to_edy(y, u); /* y = (u - 1) / (u + 1) */ 26 | 27 | fe_mont_rhs(v2, u); /* v^2 = u(u^2 + Au + 1) */ 28 | fe_sqrt(v, v2); /* v = sqrt(v^2) */ 29 | 30 | fe_mul(x, u, A); /* x = u * sqrt(-(A+2)) */ 31 | fe_invert(iv, v); /* 1/v */ 32 | fe_mul(x, x, iv); /* x = (u/v) * sqrt(-(A+2)) */ 33 | 34 | fe_neg(nx, x); /* negate x to match sign bit */ 35 | fe_cmov(x, nx, fe_isnegative(x) ^ ed_sign_bit); 36 | 37 | fe_copy(p->X, x); 38 | fe_copy(p->Y, y); 39 | fe_1(p->Z); 40 | fe_mul(p->T, p->X, p->Y); 41 | 42 | /* POSTCONDITION: check that p->X and p->Y satisfy the Ed curve equation */ 43 | /* -x^2 + y^2 = 1 + dx^2y^2 */ 44 | #ifndef NDEBUG 45 | { 46 | fe one, d, x2, y2, x2y2, dx2y2; 47 | 48 | unsigned char dbytes[32] = { 49 | 0xa3, 0x78, 0x59, 0x13, 0xca, 0x4d, 0xeb, 0x75, 50 | 0xab, 0xd8, 0x41, 0x41, 0x4d, 0x0a, 0x70, 0x00, 51 | 0x98, 0xe8, 0x79, 0x77, 0x79, 0x40, 0xc7, 0x8c, 52 | 0x73, 0xfe, 0x6f, 0x2b, 0xee, 0x6c, 0x03, 0x52 53 | }; 54 | 55 | fe_frombytes(d, dbytes); 56 | fe_1(one); 57 | fe_sq(x2, p->X); /* x^2 */ 58 | fe_sq(y2, p->Y); /* y^2 */ 59 | 60 | fe_mul(dx2y2, x2, y2); /* x^2y^2 */ 61 | fe_mul(dx2y2, dx2y2, d); /* dx^2y^2 */ 62 | fe_add(dx2y2, dx2y2, one); /* dx^2y^2 + 1 */ 63 | 64 | fe_neg(x2y2, x2); /* -x^2 */ 65 | fe_add(x2y2, x2y2, y2); /* -x^2 + y^2 */ 66 | 67 | assert(fe_isequal(x2y2, dx2y2)); 68 | } 69 | #endif 70 | } 71 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/ge_neg.c: -------------------------------------------------------------------------------- 1 | #include "crypto_additions.h" 2 | #include "ge.h" 3 | 4 | /* 5 | return r = -p 6 | */ 7 | 8 | 9 | void ge_neg(ge_p3* r, const ge_p3 *p) 10 | { 11 | fe_neg(r->X, p->X); 12 | fe_copy(r->Y, p->Y); 13 | fe_copy(r->Z, p->Z); 14 | fe_neg(r->T, p->T); 15 | } 16 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/ge_p3_to_montx.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | #include "crypto_additions.h" 3 | 4 | void ge_p3_to_montx(fe u, const ge_p3 *ed) 5 | { 6 | /* 7 | u = (y + 1) / (1 - y) 8 | or 9 | u = (y + z) / (z - y) 10 | 11 | NOTE: y=1 is converted to u=0 since fe_invert is mod-exp 12 | */ 13 | 14 | fe y_plus_one, one_minus_y, inv_one_minus_y; 15 | 16 | fe_add(y_plus_one, ed->Y, ed->Z); 17 | fe_sub(one_minus_y, ed->Z, ed->Y); 18 | fe_invert(inv_one_minus_y, one_minus_y); 19 | fe_mul(u, y_plus_one, inv_one_minus_y); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/ge_scalarmult.c: -------------------------------------------------------------------------------- 1 | #include "crypto_uint32.h" 2 | #include "ge.h" 3 | #include "crypto_additions.h" 4 | 5 | static unsigned char equal(signed char b,signed char c) 6 | { 7 | unsigned char ub = b; 8 | unsigned char uc = c; 9 | unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */ 10 | crypto_uint32 y = x; /* 0: yes; 1..255: no */ 11 | y -= 1; /* 4294967295: yes; 0..254: no */ 12 | y >>= 31; /* 1: yes; 0: no */ 13 | return y; 14 | } 15 | 16 | static unsigned char negative(signed char b) 17 | { 18 | unsigned long long x = b; /* 18446744073709551361..18446744073709551615: yes; 0..255: no */ 19 | x >>= 63; /* 1: yes; 0: no */ 20 | return x; 21 | } 22 | 23 | static void cmov(ge_cached *t,const ge_cached *u,unsigned char b) 24 | { 25 | fe_cmov(t->YplusX,u->YplusX,b); 26 | fe_cmov(t->YminusX,u->YminusX,b); 27 | fe_cmov(t->Z,u->Z,b); 28 | fe_cmov(t->T2d,u->T2d,b); 29 | } 30 | 31 | static void select(ge_cached *t,const ge_cached *pre, signed char b) 32 | { 33 | ge_cached minust; 34 | unsigned char bnegative = negative(b); 35 | unsigned char babs = b - (((-bnegative) & b) << 1); 36 | 37 | fe_1(t->YplusX); 38 | fe_1(t->YminusX); 39 | fe_1(t->Z); 40 | fe_0(t->T2d); 41 | 42 | cmov(t,pre+0,equal(babs,1)); 43 | cmov(t,pre+1,equal(babs,2)); 44 | cmov(t,pre+2,equal(babs,3)); 45 | cmov(t,pre+3,equal(babs,4)); 46 | cmov(t,pre+4,equal(babs,5)); 47 | cmov(t,pre+5,equal(babs,6)); 48 | cmov(t,pre+6,equal(babs,7)); 49 | cmov(t,pre+7,equal(babs,8)); 50 | fe_copy(minust.YplusX,t->YminusX); 51 | fe_copy(minust.YminusX,t->YplusX); 52 | fe_copy(minust.Z,t->Z); 53 | fe_neg(minust.T2d,t->T2d); 54 | cmov(t,&minust,bnegative); 55 | } 56 | 57 | /* 58 | h = a * B 59 | where a = a[0]+256*a[1]+...+256^31 a[31] 60 | B is the Ed25519 base point (x,4/5) with x positive. 61 | 62 | Preconditions: 63 | a[31] <= 127 64 | */ 65 | 66 | void ge_scalarmult(ge_p3 *h, const unsigned char *a, const ge_p3 *A) 67 | { 68 | signed char e[64]; 69 | signed char carry; 70 | ge_p1p1 r; 71 | ge_p2 s; 72 | ge_p3 t0, t1, t2; 73 | ge_cached t, pre[8]; 74 | int i; 75 | 76 | for (i = 0;i < 32;++i) { 77 | e[2 * i + 0] = (a[i] >> 0) & 15; 78 | e[2 * i + 1] = (a[i] >> 4) & 15; 79 | } 80 | /* each e[i] is between 0 and 15 */ 81 | /* e[63] is between 0 and 7 */ 82 | 83 | carry = 0; 84 | for (i = 0;i < 63;++i) { 85 | e[i] += carry; 86 | carry = e[i] + 8; 87 | carry >>= 4; 88 | e[i] -= carry << 4; 89 | } 90 | e[63] += carry; 91 | /* each e[i] is between -8 and 8 */ 92 | 93 | // Precomputation: 94 | ge_p3_to_cached(pre+0, A); // A 95 | 96 | ge_p3_dbl(&r, A); 97 | ge_p1p1_to_p3(&t0, &r); 98 | ge_p3_to_cached(pre+1, &t0); // 2A 99 | 100 | ge_add(&r, A, pre+1); 101 | ge_p1p1_to_p3(&t1, &r); 102 | ge_p3_to_cached(pre+2, &t1); // 3A 103 | 104 | ge_p3_dbl(&r, &t0); 105 | ge_p1p1_to_p3(&t0, &r); 106 | ge_p3_to_cached(pre+3, &t0); // 4A 107 | 108 | ge_add(&r, A, pre+3); 109 | ge_p1p1_to_p3(&t2, &r); 110 | ge_p3_to_cached(pre+4, &t2); // 5A 111 | 112 | ge_p3_dbl(&r, &t1); 113 | ge_p1p1_to_p3(&t1, &r); 114 | ge_p3_to_cached(pre+5, &t1); // 6A 115 | 116 | ge_add(&r, A, pre+5); 117 | ge_p1p1_to_p3(&t1, &r); 118 | ge_p3_to_cached(pre+6, &t1); // 7A 119 | 120 | ge_p3_dbl(&r, &t0); 121 | ge_p1p1_to_p3(&t0, &r); 122 | ge_p3_to_cached(pre+7, &t0); // 8A 123 | 124 | ge_p3_0(h); 125 | 126 | for (i = 63;i > 0; i--) { 127 | select(&t,pre,e[i]); 128 | ge_add(&r, h, &t); 129 | ge_p1p1_to_p2(&s,&r); 130 | 131 | ge_p2_dbl(&r,&s); ge_p1p1_to_p2(&s,&r); 132 | ge_p2_dbl(&r,&s); ge_p1p1_to_p2(&s,&r); 133 | ge_p2_dbl(&r,&s); ge_p1p1_to_p2(&s,&r); 134 | ge_p2_dbl(&r,&s); ge_p1p1_to_p3(h,&r); 135 | 136 | } 137 | select(&t,pre,e[0]); 138 | ge_add(&r, h, &t); 139 | ge_p1p1_to_p3(h,&r); 140 | } 141 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/ge_scalarmult_cofactor.c: -------------------------------------------------------------------------------- 1 | #include "crypto_additions.h" 2 | #include "ge.h" 3 | 4 | /* 5 | return 8 * p 6 | */ 7 | 8 | void ge_scalarmult_cofactor(ge_p3 *q, const ge_p3 *p) 9 | { 10 | ge_p1p1 p1p1; 11 | ge_p2 p2; 12 | 13 | ge_p3_dbl(&p1p1, p); 14 | ge_p1p1_to_p2(&p2, &p1p1); 15 | 16 | ge_p2_dbl(&p1p1, &p2); 17 | ge_p1p1_to_p2(&p2, &p1p1); 18 | 19 | ge_p2_dbl(&p1p1, &p2); 20 | ge_p1p1_to_p3(q, &p1p1); 21 | } 22 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/generalized/ge_p3_add.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p + q 5 | */ 6 | 7 | void ge_p3_add(ge_p3 *r, const ge_p3 *p, const ge_p3 *q) 8 | { 9 | ge_cached p_cached; 10 | ge_p1p1 r_p1p1; 11 | 12 | ge_p3_to_cached(&p_cached, p); 13 | ge_add(&r_p1p1, q, &p_cached); 14 | ge_p1p1_to_p3(r, &r_p1p1); 15 | } 16 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/generalized/gen_constants.h: -------------------------------------------------------------------------------- 1 | #ifndef _GEN_CONSTANTS_H__ 2 | #define _GEN_CONSTANTS_H__ 3 | 4 | #define LABELSETMAXLEN 512 5 | #define LABELMAXLEN 128 6 | #define BUFLEN 1024 7 | #define BLOCKLEN 128 /* SHA512 */ 8 | #define HASHLEN 64 /* SHA512 */ 9 | #define POINTLEN 32 10 | #define SCALARLEN 32 11 | #define RANDLEN 32 12 | #define SIGNATURELEN 64 13 | #define VRFSIGNATURELEN 96 14 | #define VRFOUTPUTLEN 32 15 | #define MSTART 2048 16 | #define MSGMAXLEN 1048576 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/generalized/gen_crypto_additions.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __GEN_CRYPTO_ADDITIONS__ 3 | #define __GEN_CRYPTO_ADDITIONS__ 4 | 5 | #include "crypto_uint32.h" 6 | #include "fe.h" 7 | #include "ge.h" 8 | 9 | int sc_isreduced(const unsigned char* s); 10 | 11 | int point_isreduced(const unsigned char* p); 12 | 13 | void ge_p3_add(ge_p3 *r, const ge_p3 *p, const ge_p3 *q); 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/generalized/gen_eddsa.h: -------------------------------------------------------------------------------- 1 | #ifndef __GEN_EDDSA_H__ 2 | #define __GEN_EDDSA_H__ 3 | 4 | #include "ge.h" 5 | 6 | /* B: base point 7 | R: commitment (point), 8 | r: private nonce (scalar) 9 | K: encoded public key 10 | k: private key (scalar) 11 | Z: 32-bytes random 12 | M: buffer containing message, message starts at M_start, continues for M_len 13 | 14 | r = hash(B || labelset || Z || pad1 || k || pad2 || labelset || K || extra || M) (mod q) 15 | */ 16 | int generalized_commit(unsigned char* R_bytes, unsigned char* r_scalar, 17 | const unsigned char* labelset, const unsigned long labelset_len, 18 | const unsigned char* extra, const unsigned long extra_len, 19 | const unsigned char* K_bytes, const unsigned char* k_scalar, 20 | const unsigned char* Z, 21 | unsigned char* M_buf, const unsigned long M_start, const unsigned long M_len); 22 | 23 | /* if is_labelset_empty(labelset): 24 | return hash(R || K || M) (mod q) 25 | else: 26 | return hash(B || labelset || R || labelset || K || extra || M) (mod q) 27 | */ 28 | int generalized_challenge(unsigned char* h_scalar, 29 | const unsigned char* labelset, const unsigned long labelset_len, 30 | const unsigned char* extra, const unsigned long extra_len, 31 | const unsigned char* R_bytes, 32 | const unsigned char* K_bytes, 33 | unsigned char* M_buf, const unsigned long M_start, const unsigned long M_len); 34 | 35 | /* return r + kh (mod q) */ 36 | int generalized_prove(unsigned char* out_scalar, 37 | const unsigned char* r_scalar, 38 | const unsigned char* k_scalar, 39 | const unsigned char* h_scalar); 40 | 41 | /* R = B^s / K^h */ 42 | int generalized_solve_commitment(unsigned char* R_bytes_out, ge_p3* K_point_out, 43 | const ge_p3* B_point, const unsigned char* s_scalar, 44 | const unsigned char* K_bytes, const unsigned char* h_scalar); 45 | 46 | 47 | int generalized_eddsa_25519_sign( 48 | unsigned char* signature_out, 49 | const unsigned char* eddsa_25519_pubkey_bytes, 50 | const unsigned char* eddsa_25519_privkey_scalar, 51 | const unsigned char* msg, 52 | const unsigned long msg_len, 53 | const unsigned char* random, 54 | const unsigned char* customization_label, 55 | const unsigned long customization_label_len); 56 | 57 | int generalized_eddsa_25519_verify( 58 | const unsigned char* signature, 59 | const unsigned char* eddsa_25519_pubkey, 60 | const unsigned char* msg, 61 | const unsigned long msg_len, 62 | const unsigned char* customization_label, 63 | const unsigned long customization_label_len); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/generalized/gen_labelset.h: -------------------------------------------------------------------------------- 1 | #ifndef __GEN_LABELSET_H__ 2 | #define __GEN_LABELSET_H__ 3 | 4 | extern const unsigned char B_bytes[]; 5 | 6 | unsigned char* buffer_add(unsigned char* bufptr, const unsigned char* bufend, 7 | const unsigned char* in, const unsigned long in_len); 8 | 9 | unsigned char* buffer_pad(const unsigned char* buf, unsigned char* bufptr, const unsigned char* bufend); 10 | 11 | 12 | int labelset_new(unsigned char* labelset, unsigned long* labelset_len, const unsigned long labelset_maxlen, 13 | const unsigned char* protocol_name, const unsigned char protocol_name_len, 14 | const unsigned char* customization_label, const unsigned char customization_label_len); 15 | 16 | int labelset_add(unsigned char* labelset, unsigned long* labelset_len, const unsigned long labelset_maxlen, 17 | const unsigned char* label, const unsigned char label_len); 18 | 19 | int labelset_validate(const unsigned char* labelset, const unsigned long labelset_len); 20 | 21 | int labelset_is_empty(const unsigned char* labelset, const unsigned long labelset_len); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/generalized/gen_veddsa.h: -------------------------------------------------------------------------------- 1 | #ifndef __GEN_VEDDSA_H__ 2 | #define __GEN_VEDDSA_H__ 3 | 4 | int generalized_veddsa_25519_sign( 5 | unsigned char* signature_out, 6 | const unsigned char* eddsa_25519_pubkey_bytes, 7 | const unsigned char* eddsa_25519_privkey_scalar, 8 | const unsigned char* msg, 9 | const unsigned long msg_len, 10 | const unsigned char* random, 11 | const unsigned char* customization_label, 12 | const unsigned long customization_label_len); 13 | 14 | int generalized_veddsa_25519_verify( 15 | unsigned char* vrf_out, 16 | const unsigned char* signature, 17 | const unsigned char* eddsa_25519_pubkey_bytes, 18 | const unsigned char* msg, 19 | const unsigned long msg_len, 20 | const unsigned char* customization_label, 21 | const unsigned long customization_label_len); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/generalized/gen_x.h: -------------------------------------------------------------------------------- 1 | #ifndef __GEN_X_H 2 | #define __GEN_X_H 3 | 4 | int generalized_xeddsa_25519_sign(unsigned char* signature_out, /* 64 bytes */ 5 | const unsigned char* x25519_privkey_scalar, /* 32 bytes */ 6 | const unsigned char* msg, const unsigned long msg_len, 7 | const unsigned char* random, /* 32 bytes */ 8 | const unsigned char* customization_label, 9 | const unsigned long customization_label_len); 10 | 11 | int generalized_xeddsa_25519_verify( 12 | const unsigned char* signature, /* 64 bytes */ 13 | const unsigned char* x25519_pubkey_bytes, /* 32 bytes */ 14 | const unsigned char* msg, 15 | const unsigned long msg_len, 16 | const unsigned char* customization_label, 17 | const unsigned long customization_label_len); 18 | 19 | int generalized_xveddsa_25519_sign( 20 | unsigned char* signature_out, /* 96 bytes */ 21 | const unsigned char* x25519_privkey_scalar, /* 32 bytes */ 22 | const unsigned char* msg, 23 | const unsigned long msg_len, 24 | const unsigned char* random, /* 32 bytes */ 25 | const unsigned char* customization_label, 26 | const unsigned long customization_label_len); 27 | 28 | int generalized_xveddsa_25519_verify( 29 | unsigned char* vrf_out, /* 32 bytes */ 30 | const unsigned char* signature, /* 96 bytes */ 31 | const unsigned char* x25519_pubkey_bytes, /* 32 bytes */ 32 | const unsigned char* msg, 33 | const unsigned long msg_len, 34 | const unsigned char* customization_label, 35 | const unsigned long customization_label_len); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/generalized/point_isreduced.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "fe.h" 3 | #include "crypto_additions.h" 4 | 5 | int point_isreduced(const unsigned char* p) 6 | { 7 | unsigned char strict[32]; 8 | 9 | memmove(strict, p, 32); 10 | strict[31] &= 0x7F; /* mask off sign bit */ 11 | return fe_isreduced(strict); 12 | } 13 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/generalized/sc_isreduced.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "fe.h" 3 | #include "sc.h" 4 | #include "crypto_additions.h" 5 | #include "crypto_verify_32.h" 6 | 7 | int sc_isreduced(const unsigned char* s) 8 | { 9 | unsigned char strict[64]; 10 | 11 | memset(strict, 0, 64); 12 | memmove(strict, s, 32); 13 | sc_reduce(strict); 14 | if (crypto_verify_32(strict, s) != 0) 15 | return 0; 16 | return 1; 17 | } 18 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/keygen.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | #include "keygen.h" 3 | #include "crypto_additions.h" 4 | 5 | void curve25519_keygen(unsigned char* curve25519_pubkey_out, 6 | const unsigned char* curve25519_privkey_in) 7 | { 8 | /* Perform a fixed-base multiplication of the Edwards base point, 9 | (which is efficient due to precalculated tables), then convert 10 | to the Curve25519 montgomery-format public key. 11 | 12 | NOTE: y=1 is converted to u=0 since fe_invert is mod-exp 13 | */ 14 | 15 | ge_p3 ed; /* Ed25519 pubkey point */ 16 | fe u; 17 | 18 | ge_scalarmult_base(&ed, curve25519_privkey_in); 19 | ge_p3_to_montx(u, &ed); 20 | fe_tobytes(curve25519_pubkey_out, u); 21 | } 22 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/keygen.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __KEYGEN_H__ 3 | #define __KEYGEN_H__ 4 | 5 | /* Sets and clears bits to make a random 32 bytes into a private key */ 6 | void sc_clamp(unsigned char* a); 7 | 8 | /* The private key should be 32 random bytes "clamped" by sc_clamp() */ 9 | void curve25519_keygen(unsigned char* curve25519_pubkey_out, /* 32 bytes */ 10 | const unsigned char* curve25519_privkey_in); /* 32 bytes */ 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/open_modified.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_sign.h" 3 | #include "crypto_hash_sha512.h" 4 | #include "crypto_verify_32.h" 5 | #include "ge.h" 6 | #include "sc.h" 7 | #include "crypto_additions.h" 8 | 9 | int crypto_sign_open_modified( 10 | unsigned char *m, 11 | const unsigned char *sm,unsigned long long smlen, 12 | const unsigned char *pk 13 | ) 14 | { 15 | unsigned char pkcopy[32]; 16 | unsigned char rcopy[32]; 17 | unsigned char scopy[32]; 18 | unsigned char h[64]; 19 | unsigned char rcheck[32]; 20 | ge_p3 A; 21 | ge_p2 R; 22 | 23 | if (smlen < 64) goto badsig; 24 | if (sm[63] & 224) goto badsig; /* strict parsing of s */ 25 | if (ge_frombytes_negate_vartime(&A,pk) != 0) goto badsig; 26 | 27 | memmove(pkcopy,pk,32); 28 | memmove(rcopy,sm,32); 29 | memmove(scopy,sm + 32,32); 30 | 31 | memmove(m,sm,smlen); 32 | memmove(m + 32,pkcopy,32); 33 | crypto_hash_sha512(h,m,smlen); 34 | sc_reduce(h); 35 | 36 | ge_double_scalarmult_vartime(&R,h,&A,scopy); 37 | ge_tobytes(rcheck,&R); 38 | 39 | if (crypto_verify_32(rcheck,rcopy) == 0) { 40 | return 0; 41 | } 42 | 43 | badsig: 44 | return -1; 45 | } 46 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/sc_clamp.c: -------------------------------------------------------------------------------- 1 | #include "crypto_additions.h" 2 | 3 | void sc_clamp(unsigned char* a) 4 | { 5 | a[0] &= 248; 6 | a[31] &= 127; 7 | a[31] |= 64; 8 | } 9 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/sc_cmov.c: -------------------------------------------------------------------------------- 1 | #include "crypto_additions.h" 2 | 3 | /* 4 | Replace (f,g) with (g,g) if b == 1; 5 | replace (f,g) with (f,g) if b == 0. 6 | 7 | Preconditions: b in {0,1}. 8 | */ 9 | 10 | void sc_cmov(unsigned char* f, const unsigned char* g, unsigned char b) 11 | { 12 | int count=32; 13 | unsigned char x[32]; 14 | for (count=0; count < 32; count++) 15 | x[count] = f[count] ^ g[count]; 16 | b = -b; 17 | for (count=0; count < 32; count++) 18 | x[count] &= b; 19 | for (count=0; count < 32; count++) 20 | f[count] = f[count] ^ x[count]; 21 | } 22 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/sc_neg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_additions.h" 3 | #include "sc.h" 4 | 5 | /* l = order of base point = 2^252 + 27742317777372353535851937790883648493 */ 6 | 7 | /* 8 | static unsigned char l[32] = {0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 9 | 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 10 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 11 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0, 0x10}; 12 | */ 13 | 14 | static unsigned char lminus1[32] = {0xec, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 15 | 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 16 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}; 18 | 19 | /* b = -a (mod l) */ 20 | void sc_neg(unsigned char *b, const unsigned char *a) 21 | { 22 | unsigned char zero[32]; 23 | memset(zero, 0, 32); 24 | sc_muladd(b, lminus1, a, zero); /* b = (-1)a + 0 (mod l) */ 25 | } 26 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/sign_modified.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_sign.h" 3 | #include "crypto_hash_sha512.h" 4 | #include "ge.h" 5 | #include "sc.h" 6 | #include "zeroize.h" 7 | #include "crypto_additions.h" 8 | 9 | /* NEW: Compare to pristine crypto_sign() 10 | Uses explicit private key for nonce derivation and as scalar, 11 | instead of deriving both from a master key. 12 | */ 13 | int crypto_sign_modified( 14 | unsigned char *sm, 15 | const unsigned char *m,unsigned long long mlen, 16 | const unsigned char *sk, const unsigned char* pk, 17 | const unsigned char* random 18 | ) 19 | { 20 | unsigned char nonce[64]; 21 | unsigned char hram[64]; 22 | ge_p3 R; 23 | int count=0; 24 | 25 | memmove(sm + 64,m,mlen); 26 | memmove(sm + 32,sk,32); /* NEW: Use privkey directly for nonce derivation */ 27 | 28 | /* NEW : add prefix to separate hash uses - see .h */ 29 | sm[0] = 0xFE; 30 | for (count = 1; count < 32; count++) 31 | sm[count] = 0xFF; 32 | 33 | /* NEW: add suffix of random data */ 34 | memmove(sm + mlen + 64, random, 64); 35 | 36 | crypto_hash_sha512(nonce,sm,mlen + 128); 37 | memmove(sm + 32,pk,32); 38 | 39 | sc_reduce(nonce); 40 | 41 | ge_scalarmult_base(&R,nonce); 42 | ge_p3_tobytes(sm,&R); 43 | 44 | crypto_hash_sha512(hram,sm,mlen + 64); 45 | sc_reduce(hram); 46 | sc_muladd(sm + 32,hram,sk,nonce); /* NEW: Use privkey directly */ 47 | 48 | /* Erase any traces of private scalar or 49 | nonce left in the stack from sc_muladd */ 50 | zeroize_stack(); 51 | zeroize(nonce, 64); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/utility.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "utility.h" 4 | 5 | void print_vector(const char* name, const unsigned char* v) 6 | { 7 | int count; 8 | printf("%s = \n", name); 9 | for (count = 0; count < 32; count++) 10 | printf("%02x ", v[count]); 11 | printf("\n"); 12 | } 13 | 14 | void print_bytes(const char* name, const unsigned char* v, int numbytes) 15 | { 16 | int count; 17 | printf("%s = \n", name); 18 | for (count = 0; count < numbytes; count++) 19 | printf("%02x ", v[count]); 20 | printf("\n"); 21 | } 22 | 23 | void print_fe(const char* name, const fe in) 24 | { 25 | unsigned char bytes[32]; 26 | fe_tobytes(bytes, in); 27 | print_vector(name, bytes); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/utility.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __UTILITY_H__ 3 | #define __UTILITY_H__ 4 | 5 | #include "fe.h" 6 | 7 | void print_vector(const char* name, const unsigned char* v); 8 | void print_bytes(const char* name, const unsigned char* v, int numbytes); 9 | void print_fe(const char* name, const fe in); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/xeddsa.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "ge.h" 3 | #include "crypto_additions.h" 4 | #include "zeroize.h" 5 | #include "xeddsa.h" 6 | #include "crypto_verify_32.h" 7 | 8 | int xed25519_sign(unsigned char* signature_out, 9 | const unsigned char* curve25519_privkey, 10 | const unsigned char* msg, const unsigned long msg_len, 11 | const unsigned char* random) 12 | { 13 | unsigned char a[32], aneg[32]; 14 | unsigned char A[32]; 15 | ge_p3 ed_pubkey_point; 16 | unsigned char *sigbuf; /* working buffer */ 17 | unsigned char sign_bit = 0; 18 | 19 | if ((sigbuf = malloc(msg_len + 128)) == 0) { 20 | memset(signature_out, 0, 64); 21 | return -1; 22 | } 23 | 24 | /* Convert the Curve25519 privkey to an Ed25519 public key */ 25 | ge_scalarmult_base(&ed_pubkey_point, curve25519_privkey); 26 | ge_p3_tobytes(A, &ed_pubkey_point); 27 | 28 | /* Force Edwards sign bit to zero */ 29 | sign_bit = (A[31] & 0x80) >> 7; 30 | memcpy(a, curve25519_privkey, 32); 31 | sc_neg(aneg, a); 32 | sc_cmov(a, aneg, sign_bit); 33 | A[31] &= 0x7F; 34 | 35 | /* Perform an Ed25519 signature with explicit private key */ 36 | crypto_sign_modified(sigbuf, msg, msg_len, a, A, random); 37 | memmove(signature_out, sigbuf, 64); 38 | 39 | zeroize(a, 32); 40 | zeroize(aneg, 32); 41 | free(sigbuf); 42 | return 0; 43 | } 44 | 45 | int xed25519_verify(const unsigned char* signature, 46 | const unsigned char* curve25519_pubkey, 47 | const unsigned char* msg, const unsigned long msg_len) 48 | { 49 | fe u; 50 | fe y; 51 | unsigned char ed_pubkey[32]; 52 | unsigned char verifybuf[MAX_MSG_LEN + 64]; /* working buffer */ 53 | unsigned char verifybuf2[MAX_MSG_LEN + 64]; /* working buffer #2 */ 54 | 55 | if (msg_len > MAX_MSG_LEN) { 56 | return -1; 57 | } 58 | 59 | /* Convert the Curve25519 public key into an Ed25519 public key. 60 | 61 | y = (u - 1) / (u + 1) 62 | 63 | NOTE: u=-1 is converted to y=0 since fe_invert is mod-exp 64 | */ 65 | if (!fe_isreduced(curve25519_pubkey)) 66 | return -1; 67 | fe_frombytes(u, curve25519_pubkey); 68 | fe_montx_to_edy(y, u); 69 | fe_tobytes(ed_pubkey, y); 70 | 71 | memmove(verifybuf, signature, 64); 72 | memmove(verifybuf+64, msg, msg_len); 73 | 74 | /* Then perform a normal Ed25519 verification, return 0 on success */ 75 | /* The below call has a strange API: */ 76 | /* verifybuf = R || S || message */ 77 | /* verifybuf2 = internal to next call gets a copy of verifybuf, S gets 78 | replaced with pubkey for hashing */ 79 | return crypto_sign_open_modified(verifybuf2, verifybuf, 64 + msg_len, ed_pubkey); 80 | } 81 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/xeddsa.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __XEDDSA_H__ 3 | #define __XEDDSA_H__ 4 | 5 | /* returns 0 on success */ 6 | int xed25519_sign(unsigned char* signature_out, /* 64 bytes */ 7 | const unsigned char* curve25519_privkey, /* 32 bytes */ 8 | const unsigned char* msg, const unsigned long msg_len, /* <= 256 bytes */ 9 | const unsigned char* random); /* 64 bytes */ 10 | 11 | /* returns 0 on success */ 12 | int xed25519_verify(const unsigned char* signature, /* 64 bytes */ 13 | const unsigned char* curve25519_pubkey, /* 32 bytes */ 14 | const unsigned char* msg, const unsigned long msg_len); /* <= 256 bytes */ 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/zeroize.c: -------------------------------------------------------------------------------- 1 | #include "zeroize.h" 2 | 3 | void zeroize(unsigned char* b, size_t len) 4 | { 5 | size_t count = 0; 6 | volatile unsigned char *p = b; 7 | 8 | for (count = 0; count < len; count++) 9 | p[count] = 0; 10 | } 11 | 12 | void zeroize_stack() 13 | { 14 | unsigned char m[ZEROIZE_STACK_SIZE]; 15 | zeroize(m, ZEROIZE_STACK_SIZE); 16 | } 17 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/additions/zeroize.h: -------------------------------------------------------------------------------- 1 | #ifndef __ZEROIZE_H__ 2 | #define __ZEROIZE_H__ 3 | 4 | #include 5 | 6 | #define ZEROIZE_STACK_SIZE 1024 7 | 8 | void zeroize(unsigned char* b, size_t len); 9 | 10 | void zeroize_stack(); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/base2.h: -------------------------------------------------------------------------------- 1 | { 2 | { 25967493,-14356035,29566456,3660896,-12694345,4014787,27544626,-11754271,-6079156,2047605 }, 3 | { -12545711,934262,-2722910,3049990,-727428,9406986,12720692,5043384,19500929,-15469378 }, 4 | { -8738181,4489570,9688441,-14785194,10184609,-12363380,29287919,11864899,-24514362,-4438546 }, 5 | }, 6 | { 7 | { 15636291,-9688557,24204773,-7912398,616977,-16685262,27787600,-14772189,28944400,-1550024 }, 8 | { 16568933,4717097,-11556148,-1102322,15682896,-11807043,16354577,-11775962,7689662,11199574 }, 9 | { 30464156,-5976125,-11779434,-15670865,23220365,15915852,7512774,10017326,-17749093,-9920357 }, 10 | }, 11 | { 12 | { 10861363,11473154,27284546,1981175,-30064349,12577861,32867885,14515107,-15438304,10819380 }, 13 | { 4708026,6336745,20377586,9066809,-11272109,6594696,-25653668,12483688,-12668491,5581306 }, 14 | { 19563160,16186464,-29386857,4097519,10237984,-4348115,28542350,13850243,-23678021,-15815942 }, 15 | }, 16 | { 17 | { 5153746,9909285,1723747,-2777874,30523605,5516873,19480852,5230134,-23952439,-15175766 }, 18 | { -30269007,-3463509,7665486,10083793,28475525,1649722,20654025,16520125,30598449,7715701 }, 19 | { 28881845,14381568,9657904,3680757,-20181635,7843316,-31400660,1370708,29794553,-1409300 }, 20 | }, 21 | { 22 | { -22518993,-6692182,14201702,-8745502,-23510406,8844726,18474211,-1361450,-13062696,13821877 }, 23 | { -6455177,-7839871,3374702,-4740862,-27098617,-10571707,31655028,-7212327,18853322,-14220951 }, 24 | { 4566830,-12963868,-28974889,-12240689,-7602672,-2830569,-8514358,-10431137,2207753,-3209784 }, 25 | }, 26 | { 27 | { -25154831,-4185821,29681144,7868801,-6854661,-9423865,-12437364,-663000,-31111463,-16132436 }, 28 | { 25576264,-2703214,7349804,-11814844,16472782,9300885,3844789,15725684,171356,6466918 }, 29 | { 23103977,13316479,9739013,-16149481,817875,-15038942,8965339,-14088058,-30714912,16193877 }, 30 | }, 31 | { 32 | { -33521811,3180713,-2394130,14003687,-16903474,-16270840,17238398,4729455,-18074513,9256800 }, 33 | { -25182317,-4174131,32336398,5036987,-21236817,11360617,22616405,9761698,-19827198,630305 }, 34 | { -13720693,2639453,-24237460,-7406481,9494427,-5774029,-6554551,-15960994,-2449256,-14291300 }, 35 | }, 36 | { 37 | { -3151181,-5046075,9282714,6866145,-31907062,-863023,-18940575,15033784,25105118,-7894876 }, 38 | { -24326370,15950226,-31801215,-14592823,-11662737,-5090925,1573892,-2625887,2198790,-15804619 }, 39 | { -3099351,10324967,-2241613,7453183,-5446979,-2735503,-13812022,-16236442,-32461234,-12290683 }, 40 | }, 41 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/d.h: -------------------------------------------------------------------------------- 1 | -10913610,13857413,-15372611,6949391,114729,-8787816,-6275908,-3247719,-18696448,-12055116 2 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/d2.h: -------------------------------------------------------------------------------- 1 | -21827239,-5839606,-30745221,13898782,229458,15978800,-12551817,-6495438,29715968,9444199 2 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe.h: -------------------------------------------------------------------------------- 1 | #ifndef FE_H 2 | #define FE_H 3 | 4 | #include "crypto_int32.h" 5 | 6 | typedef crypto_int32 fe[10]; 7 | 8 | /* 9 | fe means field element. 10 | Here the field is \Z/(2^255-19). 11 | An element t, entries t[0]...t[9], represents the integer 12 | t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9]. 13 | Bounds on each t[i] vary depending on context. 14 | */ 15 | 16 | #define fe_frombytes crypto_sign_ed25519_ref10_fe_frombytes 17 | #define fe_tobytes crypto_sign_ed25519_ref10_fe_tobytes 18 | #define fe_copy crypto_sign_ed25519_ref10_fe_copy 19 | #define fe_isnonzero crypto_sign_ed25519_ref10_fe_isnonzero 20 | #define fe_isnegative crypto_sign_ed25519_ref10_fe_isnegative 21 | #define fe_0 crypto_sign_ed25519_ref10_fe_0 22 | #define fe_1 crypto_sign_ed25519_ref10_fe_1 23 | #define fe_cswap crypto_sign_ed25519_ref10_fe_cswap 24 | #define fe_cmov crypto_sign_ed25519_ref10_fe_cmov 25 | #define fe_add crypto_sign_ed25519_ref10_fe_add 26 | #define fe_sub crypto_sign_ed25519_ref10_fe_sub 27 | #define fe_neg crypto_sign_ed25519_ref10_fe_neg 28 | #define fe_mul crypto_sign_ed25519_ref10_fe_mul 29 | #define fe_sq crypto_sign_ed25519_ref10_fe_sq 30 | #define fe_sq2 crypto_sign_ed25519_ref10_fe_sq2 31 | #define fe_mul121666 crypto_sign_ed25519_ref10_fe_mul121666 32 | #define fe_invert crypto_sign_ed25519_ref10_fe_invert 33 | #define fe_pow22523 crypto_sign_ed25519_ref10_fe_pow22523 34 | 35 | extern void fe_frombytes(fe,const unsigned char *); 36 | extern void fe_tobytes(unsigned char *,const fe); 37 | 38 | extern void fe_copy(fe,const fe); 39 | extern int fe_isnonzero(const fe); 40 | extern int fe_isnegative(const fe); 41 | extern void fe_0(fe); 42 | extern void fe_1(fe); 43 | extern void fe_cswap(fe,fe,unsigned int); 44 | extern void fe_cmov(fe,const fe,unsigned int); 45 | 46 | extern void fe_add(fe,const fe,const fe); 47 | extern void fe_sub(fe,const fe,const fe); 48 | extern void fe_neg(fe,const fe); 49 | extern void fe_mul(fe,const fe,const fe); 50 | extern void fe_sq(fe,const fe); 51 | extern void fe_sq2(fe,const fe); 52 | extern void fe_mul121666(fe,const fe); 53 | extern void fe_invert(fe,const fe); 54 | extern void fe_pow22523(fe,const fe); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_0.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = 0 5 | */ 6 | 7 | void fe_0(fe h) 8 | { 9 | h[0] = 0; 10 | h[1] = 0; 11 | h[2] = 0; 12 | h[3] = 0; 13 | h[4] = 0; 14 | h[5] = 0; 15 | h[6] = 0; 16 | h[7] = 0; 17 | h[8] = 0; 18 | h[9] = 0; 19 | } 20 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_1.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = 1 5 | */ 6 | 7 | void fe_1(fe h) 8 | { 9 | h[0] = 1; 10 | h[1] = 0; 11 | h[2] = 0; 12 | h[3] = 0; 13 | h[4] = 0; 14 | h[5] = 0; 15 | h[6] = 0; 16 | h[7] = 0; 17 | h[8] = 0; 18 | h[9] = 0; 19 | } 20 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_add.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = f + g 5 | Can overlap h with f or g. 6 | 7 | Preconditions: 8 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 9 | |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 10 | 11 | Postconditions: 12 | |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. 13 | */ 14 | 15 | void fe_add(fe h,const fe f,const fe g) 16 | { 17 | crypto_int32 f0 = f[0]; 18 | crypto_int32 f1 = f[1]; 19 | crypto_int32 f2 = f[2]; 20 | crypto_int32 f3 = f[3]; 21 | crypto_int32 f4 = f[4]; 22 | crypto_int32 f5 = f[5]; 23 | crypto_int32 f6 = f[6]; 24 | crypto_int32 f7 = f[7]; 25 | crypto_int32 f8 = f[8]; 26 | crypto_int32 f9 = f[9]; 27 | crypto_int32 g0 = g[0]; 28 | crypto_int32 g1 = g[1]; 29 | crypto_int32 g2 = g[2]; 30 | crypto_int32 g3 = g[3]; 31 | crypto_int32 g4 = g[4]; 32 | crypto_int32 g5 = g[5]; 33 | crypto_int32 g6 = g[6]; 34 | crypto_int32 g7 = g[7]; 35 | crypto_int32 g8 = g[8]; 36 | crypto_int32 g9 = g[9]; 37 | crypto_int32 h0 = f0 + g0; 38 | crypto_int32 h1 = f1 + g1; 39 | crypto_int32 h2 = f2 + g2; 40 | crypto_int32 h3 = f3 + g3; 41 | crypto_int32 h4 = f4 + g4; 42 | crypto_int32 h5 = f5 + g5; 43 | crypto_int32 h6 = f6 + g6; 44 | crypto_int32 h7 = f7 + g7; 45 | crypto_int32 h8 = f8 + g8; 46 | crypto_int32 h9 = f9 + g9; 47 | h[0] = h0; 48 | h[1] = h1; 49 | h[2] = h2; 50 | h[3] = h3; 51 | h[4] = h4; 52 | h[5] = h5; 53 | h[6] = h6; 54 | h[7] = h7; 55 | h[8] = h8; 56 | h[9] = h9; 57 | } 58 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_cmov.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | Replace (f,g) with (g,g) if b == 1; 5 | replace (f,g) with (f,g) if b == 0. 6 | 7 | Preconditions: b in {0,1}. 8 | */ 9 | 10 | void fe_cmov(fe f,const fe g,unsigned int b) 11 | { 12 | crypto_int32 f0 = f[0]; 13 | crypto_int32 f1 = f[1]; 14 | crypto_int32 f2 = f[2]; 15 | crypto_int32 f3 = f[3]; 16 | crypto_int32 f4 = f[4]; 17 | crypto_int32 f5 = f[5]; 18 | crypto_int32 f6 = f[6]; 19 | crypto_int32 f7 = f[7]; 20 | crypto_int32 f8 = f[8]; 21 | crypto_int32 f9 = f[9]; 22 | crypto_int32 g0 = g[0]; 23 | crypto_int32 g1 = g[1]; 24 | crypto_int32 g2 = g[2]; 25 | crypto_int32 g3 = g[3]; 26 | crypto_int32 g4 = g[4]; 27 | crypto_int32 g5 = g[5]; 28 | crypto_int32 g6 = g[6]; 29 | crypto_int32 g7 = g[7]; 30 | crypto_int32 g8 = g[8]; 31 | crypto_int32 g9 = g[9]; 32 | crypto_int32 x0 = f0 ^ g0; 33 | crypto_int32 x1 = f1 ^ g1; 34 | crypto_int32 x2 = f2 ^ g2; 35 | crypto_int32 x3 = f3 ^ g3; 36 | crypto_int32 x4 = f4 ^ g4; 37 | crypto_int32 x5 = f5 ^ g5; 38 | crypto_int32 x6 = f6 ^ g6; 39 | crypto_int32 x7 = f7 ^ g7; 40 | crypto_int32 x8 = f8 ^ g8; 41 | crypto_int32 x9 = f9 ^ g9; 42 | b = -b; 43 | x0 &= b; 44 | x1 &= b; 45 | x2 &= b; 46 | x3 &= b; 47 | x4 &= b; 48 | x5 &= b; 49 | x6 &= b; 50 | x7 &= b; 51 | x8 &= b; 52 | x9 &= b; 53 | f[0] = f0 ^ x0; 54 | f[1] = f1 ^ x1; 55 | f[2] = f2 ^ x2; 56 | f[3] = f3 ^ x3; 57 | f[4] = f4 ^ x4; 58 | f[5] = f5 ^ x5; 59 | f[6] = f6 ^ x6; 60 | f[7] = f7 ^ x7; 61 | f[8] = f8 ^ x8; 62 | f[9] = f9 ^ x9; 63 | } 64 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_copy.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = f 5 | */ 6 | 7 | void fe_copy(fe h,const fe f) 8 | { 9 | crypto_int32 f0 = f[0]; 10 | crypto_int32 f1 = f[1]; 11 | crypto_int32 f2 = f[2]; 12 | crypto_int32 f3 = f[3]; 13 | crypto_int32 f4 = f[4]; 14 | crypto_int32 f5 = f[5]; 15 | crypto_int32 f6 = f[6]; 16 | crypto_int32 f7 = f[7]; 17 | crypto_int32 f8 = f[8]; 18 | crypto_int32 f9 = f[9]; 19 | h[0] = f0; 20 | h[1] = f1; 21 | h[2] = f2; 22 | h[3] = f3; 23 | h[4] = f4; 24 | h[5] = f5; 25 | h[6] = f6; 26 | h[7] = f7; 27 | h[8] = f8; 28 | h[9] = f9; 29 | } 30 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_frombytes.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | #include "crypto_int64.h" 3 | #include "crypto_uint64.h" 4 | 5 | static crypto_uint64 load_3(const unsigned char *in) 6 | { 7 | crypto_uint64 result; 8 | result = (crypto_uint64) in[0]; 9 | result |= ((crypto_uint64) in[1]) << 8; 10 | result |= ((crypto_uint64) in[2]) << 16; 11 | return result; 12 | } 13 | 14 | static crypto_uint64 load_4(const unsigned char *in) 15 | { 16 | crypto_uint64 result; 17 | result = (crypto_uint64) in[0]; 18 | result |= ((crypto_uint64) in[1]) << 8; 19 | result |= ((crypto_uint64) in[2]) << 16; 20 | result |= ((crypto_uint64) in[3]) << 24; 21 | return result; 22 | } 23 | 24 | /* 25 | Ignores top bit of h. 26 | */ 27 | 28 | void fe_frombytes(fe h,const unsigned char *s) 29 | { 30 | crypto_int64 h0 = load_4(s); 31 | crypto_int64 h1 = load_3(s + 4) << 6; 32 | crypto_int64 h2 = load_3(s + 7) << 5; 33 | crypto_int64 h3 = load_3(s + 10) << 3; 34 | crypto_int64 h4 = load_3(s + 13) << 2; 35 | crypto_int64 h5 = load_4(s + 16); 36 | crypto_int64 h6 = load_3(s + 20) << 7; 37 | crypto_int64 h7 = load_3(s + 23) << 5; 38 | crypto_int64 h8 = load_3(s + 26) << 4; 39 | crypto_int64 h9 = (load_3(s + 29) & 8388607) << 2; 40 | crypto_int64 carry0; 41 | crypto_int64 carry1; 42 | crypto_int64 carry2; 43 | crypto_int64 carry3; 44 | crypto_int64 carry4; 45 | crypto_int64 carry5; 46 | crypto_int64 carry6; 47 | crypto_int64 carry7; 48 | crypto_int64 carry8; 49 | crypto_int64 carry9; 50 | 51 | carry9 = (h9 + (crypto_int64) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= carry9 << 25; 52 | carry1 = (h1 + (crypto_int64) (1<<24)) >> 25; h2 += carry1; h1 -= carry1 << 25; 53 | carry3 = (h3 + (crypto_int64) (1<<24)) >> 25; h4 += carry3; h3 -= carry3 << 25; 54 | carry5 = (h5 + (crypto_int64) (1<<24)) >> 25; h6 += carry5; h5 -= carry5 << 25; 55 | carry7 = (h7 + (crypto_int64) (1<<24)) >> 25; h8 += carry7; h7 -= carry7 << 25; 56 | 57 | carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= carry0 << 26; 58 | carry2 = (h2 + (crypto_int64) (1<<25)) >> 26; h3 += carry2; h2 -= carry2 << 26; 59 | carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= carry4 << 26; 60 | carry6 = (h6 + (crypto_int64) (1<<25)) >> 26; h7 += carry6; h6 -= carry6 << 26; 61 | carry8 = (h8 + (crypto_int64) (1<<25)) >> 26; h9 += carry8; h8 -= carry8 << 26; 62 | 63 | h[0] = h0; 64 | h[1] = h1; 65 | h[2] = h2; 66 | h[3] = h3; 67 | h[4] = h4; 68 | h[5] = h5; 69 | h[6] = h6; 70 | h[7] = h7; 71 | h[8] = h8; 72 | h[9] = h9; 73 | } 74 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_invert.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | void fe_invert(fe out,const fe z) 4 | { 5 | fe t0; 6 | fe t1; 7 | fe t2; 8 | fe t3; 9 | int i; 10 | 11 | #include "pow225521.h" 12 | 13 | return; 14 | } 15 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_isnegative.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | return 1 if f is in {1,3,5,...,q-2} 5 | return 0 if f is in {0,2,4,...,q-1} 6 | 7 | Preconditions: 8 | |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. 9 | */ 10 | 11 | int fe_isnegative(const fe f) 12 | { 13 | unsigned char s[32]; 14 | fe_tobytes(s,f); 15 | return s[0] & 1; 16 | } 17 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_isnonzero.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | #include "crypto_verify_32.h" 3 | 4 | /* 5 | return nonzero if f == 0 6 | return 0 if f != 0 7 | 8 | Preconditions: 9 | |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. 10 | */ 11 | 12 | /* TREVOR'S COMMENT 13 | * 14 | * I think the above comment is wrong. Instead: 15 | * 16 | * return 0 if f == 0 17 | * return -1 if f != 0 18 | * 19 | * */ 20 | 21 | static const unsigned char zero[32]; 22 | 23 | int fe_isnonzero(const fe f) 24 | { 25 | unsigned char s[32]; 26 | fe_tobytes(s,f); 27 | return crypto_verify_32(s,zero); 28 | } 29 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_neg.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = -f 5 | 6 | Preconditions: 7 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 8 | 9 | Postconditions: 10 | |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 11 | */ 12 | 13 | void fe_neg(fe h,const fe f) 14 | { 15 | crypto_int32 f0 = f[0]; 16 | crypto_int32 f1 = f[1]; 17 | crypto_int32 f2 = f[2]; 18 | crypto_int32 f3 = f[3]; 19 | crypto_int32 f4 = f[4]; 20 | crypto_int32 f5 = f[5]; 21 | crypto_int32 f6 = f[6]; 22 | crypto_int32 f7 = f[7]; 23 | crypto_int32 f8 = f[8]; 24 | crypto_int32 f9 = f[9]; 25 | crypto_int32 h0 = -f0; 26 | crypto_int32 h1 = -f1; 27 | crypto_int32 h2 = -f2; 28 | crypto_int32 h3 = -f3; 29 | crypto_int32 h4 = -f4; 30 | crypto_int32 h5 = -f5; 31 | crypto_int32 h6 = -f6; 32 | crypto_int32 h7 = -f7; 33 | crypto_int32 h8 = -f8; 34 | crypto_int32 h9 = -f9; 35 | h[0] = h0; 36 | h[1] = h1; 37 | h[2] = h2; 38 | h[3] = h3; 39 | h[4] = h4; 40 | h[5] = h5; 41 | h[6] = h6; 42 | h[7] = h7; 43 | h[8] = h8; 44 | h[9] = h9; 45 | } 46 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_pow22523.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | void fe_pow22523(fe out,const fe z) 4 | { 5 | fe t0; 6 | fe t1; 7 | fe t2; 8 | int i; 9 | 10 | #include "pow22523.h" 11 | 12 | return; 13 | } 14 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_sub.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | h = f - g 5 | Can overlap h with f or g. 6 | 7 | Preconditions: 8 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 9 | |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. 10 | 11 | Postconditions: 12 | |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. 13 | */ 14 | 15 | void fe_sub(fe h,const fe f,const fe g) 16 | { 17 | crypto_int32 f0 = f[0]; 18 | crypto_int32 f1 = f[1]; 19 | crypto_int32 f2 = f[2]; 20 | crypto_int32 f3 = f[3]; 21 | crypto_int32 f4 = f[4]; 22 | crypto_int32 f5 = f[5]; 23 | crypto_int32 f6 = f[6]; 24 | crypto_int32 f7 = f[7]; 25 | crypto_int32 f8 = f[8]; 26 | crypto_int32 f9 = f[9]; 27 | crypto_int32 g0 = g[0]; 28 | crypto_int32 g1 = g[1]; 29 | crypto_int32 g2 = g[2]; 30 | crypto_int32 g3 = g[3]; 31 | crypto_int32 g4 = g[4]; 32 | crypto_int32 g5 = g[5]; 33 | crypto_int32 g6 = g[6]; 34 | crypto_int32 g7 = g[7]; 35 | crypto_int32 g8 = g[8]; 36 | crypto_int32 g9 = g[9]; 37 | crypto_int32 h0 = f0 - g0; 38 | crypto_int32 h1 = f1 - g1; 39 | crypto_int32 h2 = f2 - g2; 40 | crypto_int32 h3 = f3 - g3; 41 | crypto_int32 h4 = f4 - g4; 42 | crypto_int32 h5 = f5 - g5; 43 | crypto_int32 h6 = f6 - g6; 44 | crypto_int32 h7 = f7 - g7; 45 | crypto_int32 h8 = f8 - g8; 46 | crypto_int32 h9 = f9 - g9; 47 | h[0] = h0; 48 | h[1] = h1; 49 | h[2] = h2; 50 | h[3] = h3; 51 | h[4] = h4; 52 | h[5] = h5; 53 | h[6] = h6; 54 | h[7] = h7; 55 | h[8] = h8; 56 | h[9] = h9; 57 | } 58 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/fe_tobytes.c: -------------------------------------------------------------------------------- 1 | #include "fe.h" 2 | 3 | /* 4 | Preconditions: 5 | |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. 6 | 7 | Write p=2^255-19; q=floor(h/p). 8 | Basic claim: q = floor(2^(-255)(h + 19 2^(-25)h9 + 2^(-1))). 9 | 10 | Proof: 11 | Have |h|<=p so |q|<=1 so |19^2 2^(-255) q|<1/4. 12 | Also have |h-2^230 h9|<2^231 so |19 2^(-255)(h-2^230 h9)|<1/4. 13 | 14 | Write y=2^(-1)-19^2 2^(-255)q-19 2^(-255)(h-2^230 h9). 15 | Then 0> 25; 53 | q = (h0 + q) >> 26; 54 | q = (h1 + q) >> 25; 55 | q = (h2 + q) >> 26; 56 | q = (h3 + q) >> 25; 57 | q = (h4 + q) >> 26; 58 | q = (h5 + q) >> 25; 59 | q = (h6 + q) >> 26; 60 | q = (h7 + q) >> 25; 61 | q = (h8 + q) >> 26; 62 | q = (h9 + q) >> 25; 63 | 64 | /* Goal: Output h-(2^255-19)q, which is between 0 and 2^255-20. */ 65 | h0 += 19 * q; 66 | /* Goal: Output h-2^255 q, which is between 0 and 2^255-20. */ 67 | 68 | carry0 = h0 >> 26; h1 += carry0; h0 -= carry0 << 26; 69 | carry1 = h1 >> 25; h2 += carry1; h1 -= carry1 << 25; 70 | carry2 = h2 >> 26; h3 += carry2; h2 -= carry2 << 26; 71 | carry3 = h3 >> 25; h4 += carry3; h3 -= carry3 << 25; 72 | carry4 = h4 >> 26; h5 += carry4; h4 -= carry4 << 26; 73 | carry5 = h5 >> 25; h6 += carry5; h5 -= carry5 << 25; 74 | carry6 = h6 >> 26; h7 += carry6; h6 -= carry6 << 26; 75 | carry7 = h7 >> 25; h8 += carry7; h7 -= carry7 << 25; 76 | carry8 = h8 >> 26; h9 += carry8; h8 -= carry8 << 26; 77 | carry9 = h9 >> 25; h9 -= carry9 << 25; 78 | /* h10 = carry9 */ 79 | 80 | /* 81 | Goal: Output h0+...+2^255 h10-2^255 q, which is between 0 and 2^255-20. 82 | Have h0+...+2^230 h9 between 0 and 2^255-1; 83 | evidently 2^255 h10-2^255 q = 0. 84 | Goal: Output h0+...+2^230 h9. 85 | */ 86 | 87 | s[0] = h0 >> 0; 88 | s[1] = h0 >> 8; 89 | s[2] = h0 >> 16; 90 | s[3] = (h0 >> 24) | (h1 << 2); 91 | s[4] = h1 >> 6; 92 | s[5] = h1 >> 14; 93 | s[6] = (h1 >> 22) | (h2 << 3); 94 | s[7] = h2 >> 5; 95 | s[8] = h2 >> 13; 96 | s[9] = (h2 >> 21) | (h3 << 5); 97 | s[10] = h3 >> 3; 98 | s[11] = h3 >> 11; 99 | s[12] = (h3 >> 19) | (h4 << 6); 100 | s[13] = h4 >> 2; 101 | s[14] = h4 >> 10; 102 | s[15] = h4 >> 18; 103 | s[16] = h5 >> 0; 104 | s[17] = h5 >> 8; 105 | s[18] = h5 >> 16; 106 | s[19] = (h5 >> 24) | (h6 << 1); 107 | s[20] = h6 >> 7; 108 | s[21] = h6 >> 15; 109 | s[22] = (h6 >> 23) | (h7 << 3); 110 | s[23] = h7 >> 5; 111 | s[24] = h7 >> 13; 112 | s[25] = (h7 >> 21) | (h8 << 4); 113 | s[26] = h8 >> 4; 114 | s[27] = h8 >> 12; 115 | s[28] = (h8 >> 20) | (h9 << 6); 116 | s[29] = h9 >> 2; 117 | s[30] = h9 >> 10; 118 | s[31] = h9 >> 18; 119 | } 120 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge.h: -------------------------------------------------------------------------------- 1 | #ifndef GE_H 2 | #define GE_H 3 | 4 | /* 5 | ge means group element. 6 | 7 | Here the group is the set of pairs (x,y) of field elements (see fe.h) 8 | satisfying -x^2 + y^2 = 1 + d x^2y^2 9 | where d = -121665/121666. 10 | 11 | Representations: 12 | ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z 13 | ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT 14 | ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T 15 | ge_precomp (Duif): (y+x,y-x,2dxy) 16 | */ 17 | 18 | #include "fe.h" 19 | 20 | typedef struct { 21 | fe X; 22 | fe Y; 23 | fe Z; 24 | } ge_p2; 25 | 26 | typedef struct { 27 | fe X; 28 | fe Y; 29 | fe Z; 30 | fe T; 31 | } ge_p3; 32 | 33 | typedef struct { 34 | fe X; 35 | fe Y; 36 | fe Z; 37 | fe T; 38 | } ge_p1p1; 39 | 40 | typedef struct { 41 | fe yplusx; 42 | fe yminusx; 43 | fe xy2d; 44 | } ge_precomp; 45 | 46 | typedef struct { 47 | fe YplusX; 48 | fe YminusX; 49 | fe Z; 50 | fe T2d; 51 | } ge_cached; 52 | 53 | #define ge_frombytes_negate_vartime crypto_sign_ed25519_ref10_ge_frombytes_negate_vartime 54 | #define ge_tobytes crypto_sign_ed25519_ref10_ge_tobytes 55 | #define ge_p3_tobytes crypto_sign_ed25519_ref10_ge_p3_tobytes 56 | 57 | #define ge_p2_0 crypto_sign_ed25519_ref10_ge_p2_0 58 | #define ge_p3_0 crypto_sign_ed25519_ref10_ge_p3_0 59 | #define ge_precomp_0 crypto_sign_ed25519_ref10_ge_precomp_0 60 | #define ge_p3_to_p2 crypto_sign_ed25519_ref10_ge_p3_to_p2 61 | #define ge_p3_to_cached crypto_sign_ed25519_ref10_ge_p3_to_cached 62 | #define ge_p1p1_to_p2 crypto_sign_ed25519_ref10_ge_p1p1_to_p2 63 | #define ge_p1p1_to_p3 crypto_sign_ed25519_ref10_ge_p1p1_to_p3 64 | #define ge_p2_dbl crypto_sign_ed25519_ref10_ge_p2_dbl 65 | #define ge_p3_dbl crypto_sign_ed25519_ref10_ge_p3_dbl 66 | 67 | #define ge_madd crypto_sign_ed25519_ref10_ge_madd 68 | #define ge_msub crypto_sign_ed25519_ref10_ge_msub 69 | #define ge_add crypto_sign_ed25519_ref10_ge_add 70 | #define ge_sub crypto_sign_ed25519_ref10_ge_sub 71 | #define ge_scalarmult_base crypto_sign_ed25519_ref10_ge_scalarmult_base 72 | #define ge_double_scalarmult_vartime crypto_sign_ed25519_ref10_ge_double_scalarmult_vartime 73 | 74 | extern void ge_tobytes(unsigned char *,const ge_p2 *); 75 | extern void ge_p3_tobytes(unsigned char *,const ge_p3 *); 76 | extern int ge_frombytes_negate_vartime(ge_p3 *,const unsigned char *); 77 | 78 | extern void ge_p2_0(ge_p2 *); 79 | extern void ge_p3_0(ge_p3 *); 80 | extern void ge_precomp_0(ge_precomp *); 81 | extern void ge_p3_to_p2(ge_p2 *,const ge_p3 *); 82 | extern void ge_p3_to_cached(ge_cached *,const ge_p3 *); 83 | extern void ge_p1p1_to_p2(ge_p2 *,const ge_p1p1 *); 84 | extern void ge_p1p1_to_p3(ge_p3 *,const ge_p1p1 *); 85 | extern void ge_p2_dbl(ge_p1p1 *,const ge_p2 *); 86 | extern void ge_p3_dbl(ge_p1p1 *,const ge_p3 *); 87 | 88 | extern void ge_madd(ge_p1p1 *,const ge_p3 *,const ge_precomp *); 89 | extern void ge_msub(ge_p1p1 *,const ge_p3 *,const ge_precomp *); 90 | extern void ge_add(ge_p1p1 *,const ge_p3 *,const ge_cached *); 91 | extern void ge_sub(ge_p1p1 *,const ge_p3 *,const ge_cached *); 92 | extern void ge_scalarmult_base(ge_p3 *,const unsigned char *); 93 | extern void ge_double_scalarmult_vartime(ge_p2 *,const unsigned char *,const ge_p3 *,const unsigned char *); 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_add.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p + q 5 | */ 6 | 7 | void ge_add(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q) 8 | { 9 | fe t0; 10 | #include "ge_add.h" 11 | } 12 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_add.h: -------------------------------------------------------------------------------- 1 | 2 | /* qhasm: enter ge_add */ 3 | 4 | /* qhasm: fe X1 */ 5 | 6 | /* qhasm: fe Y1 */ 7 | 8 | /* qhasm: fe Z1 */ 9 | 10 | /* qhasm: fe Z2 */ 11 | 12 | /* qhasm: fe T1 */ 13 | 14 | /* qhasm: fe ZZ */ 15 | 16 | /* qhasm: fe YpX2 */ 17 | 18 | /* qhasm: fe YmX2 */ 19 | 20 | /* qhasm: fe T2d2 */ 21 | 22 | /* qhasm: fe X3 */ 23 | 24 | /* qhasm: fe Y3 */ 25 | 26 | /* qhasm: fe Z3 */ 27 | 28 | /* qhasm: fe T3 */ 29 | 30 | /* qhasm: fe YpX1 */ 31 | 32 | /* qhasm: fe YmX1 */ 33 | 34 | /* qhasm: fe A */ 35 | 36 | /* qhasm: fe B */ 37 | 38 | /* qhasm: fe C */ 39 | 40 | /* qhasm: fe D */ 41 | 42 | /* qhasm: YpX1 = Y1+X1 */ 43 | /* asm 1: fe_add(>YpX1=fe#1,YpX1=r->X,Y,X); */ 45 | fe_add(r->X,p->Y,p->X); 46 | 47 | /* qhasm: YmX1 = Y1-X1 */ 48 | /* asm 1: fe_sub(>YmX1=fe#2,YmX1=r->Y,Y,X); */ 50 | fe_sub(r->Y,p->Y,p->X); 51 | 52 | /* qhasm: A = YpX1*YpX2 */ 53 | /* asm 1: fe_mul(>A=fe#3,A=r->Z,X,YplusX); */ 55 | fe_mul(r->Z,r->X,q->YplusX); 56 | 57 | /* qhasm: B = YmX1*YmX2 */ 58 | /* asm 1: fe_mul(>B=fe#2,B=r->Y,Y,YminusX); */ 60 | fe_mul(r->Y,r->Y,q->YminusX); 61 | 62 | /* qhasm: C = T2d2*T1 */ 63 | /* asm 1: fe_mul(>C=fe#4,C=r->T,T2d,T); */ 65 | fe_mul(r->T,q->T2d,p->T); 66 | 67 | /* qhasm: ZZ = Z1*Z2 */ 68 | /* asm 1: fe_mul(>ZZ=fe#1,ZZ=r->X,Z,Z); */ 70 | fe_mul(r->X,p->Z,q->Z); 71 | 72 | /* qhasm: D = 2*ZZ */ 73 | /* asm 1: fe_add(>D=fe#5,D=t0,X,X); */ 75 | fe_add(t0,r->X,r->X); 76 | 77 | /* qhasm: X3 = A-B */ 78 | /* asm 1: fe_sub(>X3=fe#1,X3=r->X,Z,Y); */ 80 | fe_sub(r->X,r->Z,r->Y); 81 | 82 | /* qhasm: Y3 = A+B */ 83 | /* asm 1: fe_add(>Y3=fe#2,Y3=r->Y,Z,Y); */ 85 | fe_add(r->Y,r->Z,r->Y); 86 | 87 | /* qhasm: Z3 = D+C */ 88 | /* asm 1: fe_add(>Z3=fe#3,Z3=r->Z,T); */ 90 | fe_add(r->Z,t0,r->T); 91 | 92 | /* qhasm: T3 = D-C */ 93 | /* asm 1: fe_sub(>T3=fe#4,T3=r->T,T); */ 95 | fe_sub(r->T,t0,r->T); 96 | 97 | /* qhasm: return */ 98 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_double_scalarmult.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | static void slide(signed char *r,const unsigned char *a) 4 | { 5 | int i; 6 | int b; 7 | int k; 8 | 9 | for (i = 0;i < 256;++i) 10 | r[i] = 1 & (a[i >> 3] >> (i & 7)); 11 | 12 | for (i = 0;i < 256;++i) 13 | if (r[i]) { 14 | for (b = 1;b <= 6 && i + b < 256;++b) { 15 | if (r[i + b]) { 16 | if (r[i] + (r[i + b] << b) <= 15) { 17 | r[i] += r[i + b] << b; r[i + b] = 0; 18 | } else if (r[i] - (r[i + b] << b) >= -15) { 19 | r[i] -= r[i + b] << b; 20 | for (k = i + b;k < 256;++k) { 21 | if (!r[k]) { 22 | r[k] = 1; 23 | break; 24 | } 25 | r[k] = 0; 26 | } 27 | } else 28 | break; 29 | } 30 | } 31 | } 32 | 33 | } 34 | 35 | static ge_precomp Bi[8] = { 36 | #include "base2.h" 37 | } ; 38 | 39 | /* 40 | r = a * A + b * B 41 | where a = a[0]+256*a[1]+...+256^31 a[31]. 42 | and b = b[0]+256*b[1]+...+256^31 b[31]. 43 | B is the Ed25519 base point (x,4/5) with x positive. 44 | */ 45 | 46 | void ge_double_scalarmult_vartime(ge_p2 *r,const unsigned char *a,const ge_p3 *A,const unsigned char *b) 47 | { 48 | signed char aslide[256]; 49 | signed char bslide[256]; 50 | ge_cached Ai[8]; /* A,3A,5A,7A,9A,11A,13A,15A */ 51 | ge_p1p1 t; 52 | ge_p3 u; 53 | ge_p3 A2; 54 | int i; 55 | 56 | slide(aslide,a); 57 | slide(bslide,b); 58 | 59 | ge_p3_to_cached(&Ai[0],A); 60 | ge_p3_dbl(&t,A); ge_p1p1_to_p3(&A2,&t); 61 | ge_add(&t,&A2,&Ai[0]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[1],&u); 62 | ge_add(&t,&A2,&Ai[1]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[2],&u); 63 | ge_add(&t,&A2,&Ai[2]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[3],&u); 64 | ge_add(&t,&A2,&Ai[3]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[4],&u); 65 | ge_add(&t,&A2,&Ai[4]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[5],&u); 66 | ge_add(&t,&A2,&Ai[5]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[6],&u); 67 | ge_add(&t,&A2,&Ai[6]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[7],&u); 68 | 69 | ge_p2_0(r); 70 | 71 | for (i = 255;i >= 0;--i) { 72 | if (aslide[i] || bslide[i]) break; 73 | } 74 | 75 | for (;i >= 0;--i) { 76 | ge_p2_dbl(&t,r); 77 | 78 | if (aslide[i] > 0) { 79 | ge_p1p1_to_p3(&u,&t); 80 | ge_add(&t,&u,&Ai[aslide[i]/2]); 81 | } else if (aslide[i] < 0) { 82 | ge_p1p1_to_p3(&u,&t); 83 | ge_sub(&t,&u,&Ai[(-aslide[i])/2]); 84 | } 85 | 86 | if (bslide[i] > 0) { 87 | ge_p1p1_to_p3(&u,&t); 88 | ge_madd(&t,&u,&Bi[bslide[i]/2]); 89 | } else if (bslide[i] < 0) { 90 | ge_p1p1_to_p3(&u,&t); 91 | ge_msub(&t,&u,&Bi[(-bslide[i])/2]); 92 | } 93 | 94 | ge_p1p1_to_p2(r,&t); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_frombytes.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | static const fe d = { 4 | #include "d.h" 5 | } ; 6 | 7 | static const fe sqrtm1 = { 8 | #include "sqrtm1.h" 9 | } ; 10 | 11 | int ge_frombytes_negate_vartime(ge_p3 *h,const unsigned char *s) 12 | { 13 | fe u; 14 | fe v; 15 | fe v3; 16 | fe vxx; 17 | fe check; 18 | 19 | fe_frombytes(h->Y,s); 20 | fe_1(h->Z); 21 | fe_sq(u,h->Y); 22 | fe_mul(v,u,d); 23 | fe_sub(u,u,h->Z); /* u = y^2-1 */ 24 | fe_add(v,v,h->Z); /* v = dy^2+1 */ 25 | 26 | fe_sq(v3,v); 27 | fe_mul(v3,v3,v); /* v3 = v^3 */ 28 | fe_sq(h->X,v3); 29 | fe_mul(h->X,h->X,v); 30 | fe_mul(h->X,h->X,u); /* x = uv^7 */ 31 | 32 | fe_pow22523(h->X,h->X); /* x = (uv^7)^((q-5)/8) */ 33 | fe_mul(h->X,h->X,v3); 34 | fe_mul(h->X,h->X,u); /* x = uv^3(uv^7)^((q-5)/8) */ 35 | 36 | fe_sq(vxx,h->X); 37 | fe_mul(vxx,vxx,v); 38 | fe_sub(check,vxx,u); /* vx^2-u */ 39 | if (fe_isnonzero(check)) { 40 | fe_add(check,vxx,u); /* vx^2+u */ 41 | if (fe_isnonzero(check)) return -1; 42 | fe_mul(h->X,h->X,sqrtm1); 43 | } 44 | 45 | if (fe_isnegative(h->X) == (s[31] >> 7)) 46 | fe_neg(h->X,h->X); 47 | 48 | fe_mul(h->T,h->X,h->Y); 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_madd.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p + q 5 | */ 6 | 7 | void ge_madd(ge_p1p1 *r,const ge_p3 *p,const ge_precomp *q) 8 | { 9 | fe t0; 10 | #include "ge_madd.h" 11 | } 12 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_madd.h: -------------------------------------------------------------------------------- 1 | 2 | /* qhasm: enter ge_madd */ 3 | 4 | /* qhasm: fe X1 */ 5 | 6 | /* qhasm: fe Y1 */ 7 | 8 | /* qhasm: fe Z1 */ 9 | 10 | /* qhasm: fe T1 */ 11 | 12 | /* qhasm: fe ypx2 */ 13 | 14 | /* qhasm: fe ymx2 */ 15 | 16 | /* qhasm: fe xy2d2 */ 17 | 18 | /* qhasm: fe X3 */ 19 | 20 | /* qhasm: fe Y3 */ 21 | 22 | /* qhasm: fe Z3 */ 23 | 24 | /* qhasm: fe T3 */ 25 | 26 | /* qhasm: fe YpX1 */ 27 | 28 | /* qhasm: fe YmX1 */ 29 | 30 | /* qhasm: fe A */ 31 | 32 | /* qhasm: fe B */ 33 | 34 | /* qhasm: fe C */ 35 | 36 | /* qhasm: fe D */ 37 | 38 | /* qhasm: YpX1 = Y1+X1 */ 39 | /* asm 1: fe_add(>YpX1=fe#1,YpX1=r->X,Y,X); */ 41 | fe_add(r->X,p->Y,p->X); 42 | 43 | /* qhasm: YmX1 = Y1-X1 */ 44 | /* asm 1: fe_sub(>YmX1=fe#2,YmX1=r->Y,Y,X); */ 46 | fe_sub(r->Y,p->Y,p->X); 47 | 48 | /* qhasm: A = YpX1*ypx2 */ 49 | /* asm 1: fe_mul(>A=fe#3,A=r->Z,X,yplusx); */ 51 | fe_mul(r->Z,r->X,q->yplusx); 52 | 53 | /* qhasm: B = YmX1*ymx2 */ 54 | /* asm 1: fe_mul(>B=fe#2,B=r->Y,Y,yminusx); */ 56 | fe_mul(r->Y,r->Y,q->yminusx); 57 | 58 | /* qhasm: C = xy2d2*T1 */ 59 | /* asm 1: fe_mul(>C=fe#4,C=r->T,xy2d,T); */ 61 | fe_mul(r->T,q->xy2d,p->T); 62 | 63 | /* qhasm: D = 2*Z1 */ 64 | /* asm 1: fe_add(>D=fe#5,D=t0,Z,Z); */ 66 | fe_add(t0,p->Z,p->Z); 67 | 68 | /* qhasm: X3 = A-B */ 69 | /* asm 1: fe_sub(>X3=fe#1,X3=r->X,Z,Y); */ 71 | fe_sub(r->X,r->Z,r->Y); 72 | 73 | /* qhasm: Y3 = A+B */ 74 | /* asm 1: fe_add(>Y3=fe#2,Y3=r->Y,Z,Y); */ 76 | fe_add(r->Y,r->Z,r->Y); 77 | 78 | /* qhasm: Z3 = D+C */ 79 | /* asm 1: fe_add(>Z3=fe#3,Z3=r->Z,T); */ 81 | fe_add(r->Z,t0,r->T); 82 | 83 | /* qhasm: T3 = D-C */ 84 | /* asm 1: fe_sub(>T3=fe#4,T3=r->T,T); */ 86 | fe_sub(r->T,t0,r->T); 87 | 88 | /* qhasm: return */ 89 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_msub.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p - q 5 | */ 6 | 7 | void ge_msub(ge_p1p1 *r,const ge_p3 *p,const ge_precomp *q) 8 | { 9 | fe t0; 10 | #include "ge_msub.h" 11 | } 12 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_msub.h: -------------------------------------------------------------------------------- 1 | 2 | /* qhasm: enter ge_msub */ 3 | 4 | /* qhasm: fe X1 */ 5 | 6 | /* qhasm: fe Y1 */ 7 | 8 | /* qhasm: fe Z1 */ 9 | 10 | /* qhasm: fe T1 */ 11 | 12 | /* qhasm: fe ypx2 */ 13 | 14 | /* qhasm: fe ymx2 */ 15 | 16 | /* qhasm: fe xy2d2 */ 17 | 18 | /* qhasm: fe X3 */ 19 | 20 | /* qhasm: fe Y3 */ 21 | 22 | /* qhasm: fe Z3 */ 23 | 24 | /* qhasm: fe T3 */ 25 | 26 | /* qhasm: fe YpX1 */ 27 | 28 | /* qhasm: fe YmX1 */ 29 | 30 | /* qhasm: fe A */ 31 | 32 | /* qhasm: fe B */ 33 | 34 | /* qhasm: fe C */ 35 | 36 | /* qhasm: fe D */ 37 | 38 | /* qhasm: YpX1 = Y1+X1 */ 39 | /* asm 1: fe_add(>YpX1=fe#1,YpX1=r->X,Y,X); */ 41 | fe_add(r->X,p->Y,p->X); 42 | 43 | /* qhasm: YmX1 = Y1-X1 */ 44 | /* asm 1: fe_sub(>YmX1=fe#2,YmX1=r->Y,Y,X); */ 46 | fe_sub(r->Y,p->Y,p->X); 47 | 48 | /* qhasm: A = YpX1*ymx2 */ 49 | /* asm 1: fe_mul(>A=fe#3,A=r->Z,X,yminusx); */ 51 | fe_mul(r->Z,r->X,q->yminusx); 52 | 53 | /* qhasm: B = YmX1*ypx2 */ 54 | /* asm 1: fe_mul(>B=fe#2,B=r->Y,Y,yplusx); */ 56 | fe_mul(r->Y,r->Y,q->yplusx); 57 | 58 | /* qhasm: C = xy2d2*T1 */ 59 | /* asm 1: fe_mul(>C=fe#4,C=r->T,xy2d,T); */ 61 | fe_mul(r->T,q->xy2d,p->T); 62 | 63 | /* qhasm: D = 2*Z1 */ 64 | /* asm 1: fe_add(>D=fe#5,D=t0,Z,Z); */ 66 | fe_add(t0,p->Z,p->Z); 67 | 68 | /* qhasm: X3 = A-B */ 69 | /* asm 1: fe_sub(>X3=fe#1,X3=r->X,Z,Y); */ 71 | fe_sub(r->X,r->Z,r->Y); 72 | 73 | /* qhasm: Y3 = A+B */ 74 | /* asm 1: fe_add(>Y3=fe#2,Y3=r->Y,Z,Y); */ 76 | fe_add(r->Y,r->Z,r->Y); 77 | 78 | /* qhasm: Z3 = D-C */ 79 | /* asm 1: fe_sub(>Z3=fe#3,Z3=r->Z,T); */ 81 | fe_sub(r->Z,t0,r->T); 82 | 83 | /* qhasm: T3 = D+C */ 84 | /* asm 1: fe_add(>T3=fe#4,T3=r->T,T); */ 86 | fe_add(r->T,t0,r->T); 87 | 88 | /* qhasm: return */ 89 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_p1p1_to_p2.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p 5 | */ 6 | 7 | extern void ge_p1p1_to_p2(ge_p2 *r,const ge_p1p1 *p) 8 | { 9 | fe_mul(r->X,p->X,p->T); 10 | fe_mul(r->Y,p->Y,p->Z); 11 | fe_mul(r->Z,p->Z,p->T); 12 | } 13 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_p1p1_to_p3.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p 5 | */ 6 | 7 | extern void ge_p1p1_to_p3(ge_p3 *r,const ge_p1p1 *p) 8 | { 9 | fe_mul(r->X,p->X,p->T); 10 | fe_mul(r->Y,p->Y,p->Z); 11 | fe_mul(r->Z,p->Z,p->T); 12 | fe_mul(r->T,p->X,p->Y); 13 | } 14 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_p2_0.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | void ge_p2_0(ge_p2 *h) 4 | { 5 | fe_0(h->X); 6 | fe_1(h->Y); 7 | fe_1(h->Z); 8 | } 9 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_p2_dbl.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = 2 * p 5 | */ 6 | 7 | void ge_p2_dbl(ge_p1p1 *r,const ge_p2 *p) 8 | { 9 | fe t0; 10 | #include "ge_p2_dbl.h" 11 | } 12 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_p2_dbl.h: -------------------------------------------------------------------------------- 1 | 2 | /* qhasm: enter ge_p2_dbl */ 3 | 4 | /* qhasm: fe X1 */ 5 | 6 | /* qhasm: fe Y1 */ 7 | 8 | /* qhasm: fe Z1 */ 9 | 10 | /* qhasm: fe A */ 11 | 12 | /* qhasm: fe AA */ 13 | 14 | /* qhasm: fe XX */ 15 | 16 | /* qhasm: fe YY */ 17 | 18 | /* qhasm: fe B */ 19 | 20 | /* qhasm: fe X3 */ 21 | 22 | /* qhasm: fe Y3 */ 23 | 24 | /* qhasm: fe Z3 */ 25 | 26 | /* qhasm: fe T3 */ 27 | 28 | /* qhasm: XX=X1^2 */ 29 | /* asm 1: fe_sq(>XX=fe#1,XX=r->X,X); */ 31 | fe_sq(r->X,p->X); 32 | 33 | /* qhasm: YY=Y1^2 */ 34 | /* asm 1: fe_sq(>YY=fe#3,YY=r->Z,Y); */ 36 | fe_sq(r->Z,p->Y); 37 | 38 | /* qhasm: B=2*Z1^2 */ 39 | /* asm 1: fe_sq2(>B=fe#4,B=r->T,Z); */ 41 | fe_sq2(r->T,p->Z); 42 | 43 | /* qhasm: A=X1+Y1 */ 44 | /* asm 1: fe_add(>A=fe#2,A=r->Y,X,Y); */ 46 | fe_add(r->Y,p->X,p->Y); 47 | 48 | /* qhasm: AA=A^2 */ 49 | /* asm 1: fe_sq(>AA=fe#5,AA=t0,Y); */ 51 | fe_sq(t0,r->Y); 52 | 53 | /* qhasm: Y3=YY+XX */ 54 | /* asm 1: fe_add(>Y3=fe#2,Y3=r->Y,Z,X); */ 56 | fe_add(r->Y,r->Z,r->X); 57 | 58 | /* qhasm: Z3=YY-XX */ 59 | /* asm 1: fe_sub(>Z3=fe#3,Z3=r->Z,Z,X); */ 61 | fe_sub(r->Z,r->Z,r->X); 62 | 63 | /* qhasm: X3=AA-Y3 */ 64 | /* asm 1: fe_sub(>X3=fe#1,X3=r->X,Y); */ 66 | fe_sub(r->X,t0,r->Y); 67 | 68 | /* qhasm: T3=B-Z3 */ 69 | /* asm 1: fe_sub(>T3=fe#4,T3=r->T,T,Z); */ 71 | fe_sub(r->T,r->T,r->Z); 72 | 73 | /* qhasm: return */ 74 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_p3_0.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | void ge_p3_0(ge_p3 *h) 4 | { 5 | fe_0(h->X); 6 | fe_1(h->Y); 7 | fe_1(h->Z); 8 | fe_0(h->T); 9 | } 10 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_p3_dbl.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = 2 * p 5 | */ 6 | 7 | void ge_p3_dbl(ge_p1p1 *r,const ge_p3 *p) 8 | { 9 | ge_p2 q; 10 | ge_p3_to_p2(&q,p); 11 | ge_p2_dbl(r,&q); 12 | } 13 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_p3_to_cached.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p 5 | */ 6 | 7 | static const fe d2 = { 8 | #include "d2.h" 9 | } ; 10 | 11 | extern void ge_p3_to_cached(ge_cached *r,const ge_p3 *p) 12 | { 13 | fe_add(r->YplusX,p->Y,p->X); 14 | fe_sub(r->YminusX,p->Y,p->X); 15 | fe_copy(r->Z,p->Z); 16 | fe_mul(r->T2d,p->T,d2); 17 | } 18 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_p3_to_p2.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p 5 | */ 6 | 7 | extern void ge_p3_to_p2(ge_p2 *r,const ge_p3 *p) 8 | { 9 | fe_copy(r->X,p->X); 10 | fe_copy(r->Y,p->Y); 11 | fe_copy(r->Z,p->Z); 12 | } 13 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_p3_tobytes.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | void ge_p3_tobytes(unsigned char *s,const ge_p3 *h) 4 | { 5 | fe recip; 6 | fe x; 7 | fe y; 8 | 9 | fe_invert(recip,h->Z); 10 | fe_mul(x,h->X,recip); 11 | fe_mul(y,h->Y,recip); 12 | fe_tobytes(s,y); 13 | s[31] ^= fe_isnegative(x) << 7; 14 | } 15 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_precomp_0.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | void ge_precomp_0(ge_precomp *h) 4 | { 5 | fe_1(h->yplusx); 6 | fe_1(h->yminusx); 7 | fe_0(h->xy2d); 8 | } 9 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_scalarmult_base.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | #include "crypto_uint32.h" 3 | 4 | static unsigned char equal(signed char b,signed char c) 5 | { 6 | unsigned char ub = b; 7 | unsigned char uc = c; 8 | unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */ 9 | crypto_uint32 y = x; /* 0: yes; 1..255: no */ 10 | y -= 1; /* 4294967295: yes; 0..254: no */ 11 | y >>= 31; /* 1: yes; 0: no */ 12 | return y; 13 | } 14 | 15 | static unsigned char negative(signed char b) 16 | { 17 | unsigned long long x = b; /* 18446744073709551361..18446744073709551615: yes; 0..255: no */ 18 | x >>= 63; /* 1: yes; 0: no */ 19 | return x; 20 | } 21 | 22 | static void cmov(ge_precomp *t,ge_precomp *u,unsigned char b) 23 | { 24 | fe_cmov(t->yplusx,u->yplusx,b); 25 | fe_cmov(t->yminusx,u->yminusx,b); 26 | fe_cmov(t->xy2d,u->xy2d,b); 27 | } 28 | 29 | /* base[i][j] = (j+1)*256^i*B */ 30 | static ge_precomp base[32][8] = { 31 | #include "base.h" 32 | } ; 33 | 34 | static void select(ge_precomp *t,int pos,signed char b) 35 | { 36 | ge_precomp minust; 37 | unsigned char bnegative = negative(b); 38 | unsigned char babs = b - (((-bnegative) & b) << 1); 39 | 40 | ge_precomp_0(t); 41 | cmov(t,&base[pos][0],equal(babs,1)); 42 | cmov(t,&base[pos][1],equal(babs,2)); 43 | cmov(t,&base[pos][2],equal(babs,3)); 44 | cmov(t,&base[pos][3],equal(babs,4)); 45 | cmov(t,&base[pos][4],equal(babs,5)); 46 | cmov(t,&base[pos][5],equal(babs,6)); 47 | cmov(t,&base[pos][6],equal(babs,7)); 48 | cmov(t,&base[pos][7],equal(babs,8)); 49 | fe_copy(minust.yplusx,t->yminusx); 50 | fe_copy(minust.yminusx,t->yplusx); 51 | fe_neg(minust.xy2d,t->xy2d); 52 | cmov(t,&minust,bnegative); 53 | } 54 | 55 | /* 56 | h = a * B 57 | where a = a[0]+256*a[1]+...+256^31 a[31] 58 | B is the Ed25519 base point (x,4/5) with x positive. 59 | 60 | Preconditions: 61 | a[31] <= 127 62 | */ 63 | 64 | void ge_scalarmult_base(ge_p3 *h,const unsigned char *a) 65 | { 66 | signed char e[64]; 67 | signed char carry; 68 | ge_p1p1 r; 69 | ge_p2 s; 70 | ge_precomp t; 71 | int i; 72 | 73 | for (i = 0;i < 32;++i) { 74 | e[2 * i + 0] = (a[i] >> 0) & 15; 75 | e[2 * i + 1] = (a[i] >> 4) & 15; 76 | } 77 | /* each e[i] is between 0 and 15 */ 78 | /* e[63] is between 0 and 7 */ 79 | 80 | carry = 0; 81 | for (i = 0;i < 63;++i) { 82 | e[i] += carry; 83 | carry = e[i] + 8; 84 | carry >>= 4; 85 | e[i] -= carry << 4; 86 | } 87 | e[63] += carry; 88 | /* each e[i] is between -8 and 8 */ 89 | 90 | ge_p3_0(h); 91 | for (i = 1;i < 64;i += 2) { 92 | select(&t,i / 2,e[i]); 93 | ge_madd(&r,h,&t); ge_p1p1_to_p3(h,&r); 94 | } 95 | 96 | ge_p3_dbl(&r,h); ge_p1p1_to_p2(&s,&r); 97 | ge_p2_dbl(&r,&s); ge_p1p1_to_p2(&s,&r); 98 | ge_p2_dbl(&r,&s); ge_p1p1_to_p2(&s,&r); 99 | ge_p2_dbl(&r,&s); ge_p1p1_to_p3(h,&r); 100 | 101 | for (i = 0;i < 64;i += 2) { 102 | select(&t,i / 2,e[i]); 103 | ge_madd(&r,h,&t); ge_p1p1_to_p3(h,&r); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_sub.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | /* 4 | r = p - q 5 | */ 6 | 7 | void ge_sub(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q) 8 | { 9 | fe t0; 10 | #include "ge_sub.h" 11 | } 12 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_sub.h: -------------------------------------------------------------------------------- 1 | 2 | /* qhasm: enter ge_sub */ 3 | 4 | /* qhasm: fe X1 */ 5 | 6 | /* qhasm: fe Y1 */ 7 | 8 | /* qhasm: fe Z1 */ 9 | 10 | /* qhasm: fe Z2 */ 11 | 12 | /* qhasm: fe T1 */ 13 | 14 | /* qhasm: fe ZZ */ 15 | 16 | /* qhasm: fe YpX2 */ 17 | 18 | /* qhasm: fe YmX2 */ 19 | 20 | /* qhasm: fe T2d2 */ 21 | 22 | /* qhasm: fe X3 */ 23 | 24 | /* qhasm: fe Y3 */ 25 | 26 | /* qhasm: fe Z3 */ 27 | 28 | /* qhasm: fe T3 */ 29 | 30 | /* qhasm: fe YpX1 */ 31 | 32 | /* qhasm: fe YmX1 */ 33 | 34 | /* qhasm: fe A */ 35 | 36 | /* qhasm: fe B */ 37 | 38 | /* qhasm: fe C */ 39 | 40 | /* qhasm: fe D */ 41 | 42 | /* qhasm: YpX1 = Y1+X1 */ 43 | /* asm 1: fe_add(>YpX1=fe#1,YpX1=r->X,Y,X); */ 45 | fe_add(r->X,p->Y,p->X); 46 | 47 | /* qhasm: YmX1 = Y1-X1 */ 48 | /* asm 1: fe_sub(>YmX1=fe#2,YmX1=r->Y,Y,X); */ 50 | fe_sub(r->Y,p->Y,p->X); 51 | 52 | /* qhasm: A = YpX1*YmX2 */ 53 | /* asm 1: fe_mul(>A=fe#3,A=r->Z,X,YminusX); */ 55 | fe_mul(r->Z,r->X,q->YminusX); 56 | 57 | /* qhasm: B = YmX1*YpX2 */ 58 | /* asm 1: fe_mul(>B=fe#2,B=r->Y,Y,YplusX); */ 60 | fe_mul(r->Y,r->Y,q->YplusX); 61 | 62 | /* qhasm: C = T2d2*T1 */ 63 | /* asm 1: fe_mul(>C=fe#4,C=r->T,T2d,T); */ 65 | fe_mul(r->T,q->T2d,p->T); 66 | 67 | /* qhasm: ZZ = Z1*Z2 */ 68 | /* asm 1: fe_mul(>ZZ=fe#1,ZZ=r->X,Z,Z); */ 70 | fe_mul(r->X,p->Z,q->Z); 71 | 72 | /* qhasm: D = 2*ZZ */ 73 | /* asm 1: fe_add(>D=fe#5,D=t0,X,X); */ 75 | fe_add(t0,r->X,r->X); 76 | 77 | /* qhasm: X3 = A-B */ 78 | /* asm 1: fe_sub(>X3=fe#1,X3=r->X,Z,Y); */ 80 | fe_sub(r->X,r->Z,r->Y); 81 | 82 | /* qhasm: Y3 = A+B */ 83 | /* asm 1: fe_add(>Y3=fe#2,Y3=r->Y,Z,Y); */ 85 | fe_add(r->Y,r->Z,r->Y); 86 | 87 | /* qhasm: Z3 = D-C */ 88 | /* asm 1: fe_sub(>Z3=fe#3,Z3=r->Z,T); */ 90 | fe_sub(r->Z,t0,r->T); 91 | 92 | /* qhasm: T3 = D+C */ 93 | /* asm 1: fe_add(>T3=fe#4,T3=r->T,T); */ 95 | fe_add(r->T,t0,r->T); 96 | 97 | /* qhasm: return */ 98 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/ge_tobytes.c: -------------------------------------------------------------------------------- 1 | #include "ge.h" 2 | 3 | void ge_tobytes(unsigned char *s,const ge_p2 *h) 4 | { 5 | fe recip; 6 | fe x; 7 | fe y; 8 | 9 | fe_invert(recip,h->Z); 10 | fe_mul(x,h->X,recip); 11 | fe_mul(y,h->Y,recip); 12 | fe_tobytes(s,y); 13 | s[31] ^= fe_isnegative(x) << 7; 14 | } 15 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/nacl_includes/crypto_int32.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_int32_h 2 | #define crypto_int32_h 3 | 4 | typedef int crypto_int32; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/nacl_includes/crypto_int64.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_int64_h 2 | #define crypto_int64_h 3 | 4 | typedef long long crypto_int64; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/nacl_includes/crypto_sign.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_sign_H 2 | #define crypto_sign_H 3 | 4 | #include "crypto_sign_edwards25519sha512batch.h" 5 | 6 | #define crypto_sign crypto_sign_edwards25519sha512batch 7 | #define crypto_sign_open crypto_sign_edwards25519sha512batch_open 8 | #define crypto_sign_keypair crypto_sign_edwards25519sha512batch_keypair 9 | #define crypto_sign_BYTES crypto_sign_edwards25519sha512batch_BYTES 10 | #define crypto_sign_PUBLICKEYBYTES crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES 11 | #define crypto_sign_SECRETKEYBYTES crypto_sign_edwards25519sha512batch_SECRETKEYBYTES 12 | #define crypto_sign_PRIMITIVE "edwards25519sha512batch" 13 | #define crypto_sign_IMPLEMENTATION crypto_sign_edwards25519sha512batch_IMPLEMENTATION 14 | #define crypto_sign_VERSION crypto_sign_edwards25519sha512batch_VERSION 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/nacl_includes/crypto_sign_edwards25519sha512batch.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_sign_edwards25519sha512batch_H 2 | #define crypto_sign_edwards25519sha512batch_H 3 | 4 | #define crypto_sign_edwards25519sha512batch_ref10_SECRETKEYBYTES 64 5 | #define crypto_sign_edwards25519sha512batch_ref10_PUBLICKEYBYTES 32 6 | #define crypto_sign_edwards25519sha512batch_ref10_BYTES 64 7 | #ifdef __cplusplus 8 | #include 9 | extern std::string crypto_sign_edwards25519sha512batch_ref10(const std::string &,const std::string &); 10 | extern std::string crypto_sign_edwards25519sha512batch_ref10_open(const std::string &,const std::string &); 11 | extern std::string crypto_sign_edwards25519sha512batch_ref10_keypair(std::string *); 12 | extern "C" { 13 | #endif 14 | extern int crypto_sign_edwards25519sha512batch_ref10(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *); 15 | extern int crypto_sign_edwards25519sha512batch_ref10_open(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *); 16 | extern int crypto_sign_edwards25519sha512batch_ref10_keypair(unsigned char *,unsigned char *); 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #define crypto_sign_edwards25519sha512batch crypto_sign_edwards25519sha512batch_ref10 22 | #define crypto_sign_edwards25519sha512batch_open crypto_sign_edwards25519sha512batch_ref10_open 23 | #define crypto_sign_edwards25519sha512batch_keypair crypto_sign_edwards25519sha512batch_ref10_keypair 24 | #define crypto_sign_edwards25519sha512batch_BYTES crypto_sign_edwards25519sha512batch_ref10_BYTES 25 | #define crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES crypto_sign_edwards25519sha512batch_ref10_PUBLICKEYBYTES 26 | #define crypto_sign_edwards25519sha512batch_SECRETKEYBYTES crypto_sign_edwards25519sha512batch_ref10_SECRETKEYBYTES 27 | #define crypto_sign_edwards25519sha512batch_IMPLEMENTATION "crypto_sign/edwards25519sha512batch/ref10" 28 | #ifndef crypto_sign_edwards25519sha512batch_ref10_VERSION 29 | #define crypto_sign_edwards25519sha512batch_ref10_VERSION "-" 30 | #endif 31 | #define crypto_sign_edwards25519sha512batch_VERSION crypto_sign_edwards25519sha512batch_ref10_VERSION 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/nacl_includes/crypto_uint32.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_uint32_h 2 | #define crypto_uint32_h 3 | 4 | typedef unsigned int crypto_uint32; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/nacl_includes/crypto_uint64.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_uint64_h 2 | #define crypto_uint64_h 3 | 4 | typedef unsigned long long crypto_uint64; 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/nacl_includes/crypto_verify_32.h: -------------------------------------------------------------------------------- 1 | #ifndef crypto_verify_32_H 2 | #define crypto_verify_32_H 3 | 4 | #define crypto_verify_32_ref_BYTES 32 5 | #ifdef __cplusplus 6 | #include 7 | extern "C" { 8 | #endif 9 | extern int crypto_verify_32_ref(const unsigned char *,const unsigned char *); 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #define crypto_verify_32 crypto_verify_32_ref 15 | #define crypto_verify_32_BYTES crypto_verify_32_ref_BYTES 16 | #define crypto_verify_32_IMPLEMENTATION "crypto_verify/32/ref" 17 | #ifndef crypto_verify_32_ref_VERSION 18 | #define crypto_verify_32_ref_VERSION "-" 19 | #endif 20 | #define crypto_verify_32_VERSION crypto_verify_32_ref_VERSION 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/nacl_sha512/hash.c: -------------------------------------------------------------------------------- 1 | /* 2 | 20080913 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include 8 | typedef uint64_t uint64; 9 | 10 | extern int crypto_hashblocks_sha512(unsigned char *statebytes,const unsigned char *in,unsigned long long inlen); 11 | 12 | #define blocks crypto_hashblocks_sha512 13 | 14 | static const unsigned char iv[64] = { 15 | 0x6a,0x09,0xe6,0x67,0xf3,0xbc,0xc9,0x08, 16 | 0xbb,0x67,0xae,0x85,0x84,0xca,0xa7,0x3b, 17 | 0x3c,0x6e,0xf3,0x72,0xfe,0x94,0xf8,0x2b, 18 | 0xa5,0x4f,0xf5,0x3a,0x5f,0x1d,0x36,0xf1, 19 | 0x51,0x0e,0x52,0x7f,0xad,0xe6,0x82,0xd1, 20 | 0x9b,0x05,0x68,0x8c,0x2b,0x3e,0x6c,0x1f, 21 | 0x1f,0x83,0xd9,0xab,0xfb,0x41,0xbd,0x6b, 22 | 0x5b,0xe0,0xcd,0x19,0x13,0x7e,0x21,0x79 23 | } ; 24 | 25 | int crypto_hash_sha512(unsigned char *out,const unsigned char *in,unsigned long long inlen) 26 | { 27 | unsigned char h[64]; 28 | unsigned char padded[256]; 29 | int i; 30 | unsigned long long bytes = inlen; 31 | 32 | for (i = 0;i < 64;++i) h[i] = iv[i]; 33 | 34 | blocks(h,in,inlen); 35 | in += inlen; 36 | inlen &= 127; 37 | in -= inlen; 38 | 39 | for (i = 0;i < inlen;++i) padded[i] = in[i]; 40 | padded[inlen] = 0x80; 41 | 42 | if (inlen < 112) { 43 | for (i = inlen + 1;i < 119;++i) padded[i] = 0; 44 | padded[119] = bytes >> 61; 45 | padded[120] = bytes >> 53; 46 | padded[121] = bytes >> 45; 47 | padded[122] = bytes >> 37; 48 | padded[123] = bytes >> 29; 49 | padded[124] = bytes >> 21; 50 | padded[125] = bytes >> 13; 51 | padded[126] = bytes >> 5; 52 | padded[127] = bytes << 3; 53 | blocks(h,padded,128); 54 | } else { 55 | for (i = inlen + 1;i < 247;++i) padded[i] = 0; 56 | padded[247] = bytes >> 61; 57 | padded[248] = bytes >> 53; 58 | padded[249] = bytes >> 45; 59 | padded[250] = bytes >> 37; 60 | padded[251] = bytes >> 29; 61 | padded[252] = bytes >> 21; 62 | padded[253] = bytes >> 13; 63 | padded[254] = bytes >> 5; 64 | padded[255] = bytes << 3; 65 | blocks(h,padded,256); 66 | } 67 | 68 | for (i = 0;i < 64;++i) out[i] = h[i]; 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/open.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_sign.h" 3 | #include "crypto_hash_sha512.h" 4 | #include "crypto_verify_32.h" 5 | #include "ge.h" 6 | #include "sc.h" 7 | 8 | int crypto_sign_open( 9 | unsigned char *m,unsigned long long *mlen, 10 | const unsigned char *sm,unsigned long long smlen, 11 | const unsigned char *pk 12 | ) 13 | { 14 | unsigned char pkcopy[32]; 15 | unsigned char rcopy[32]; 16 | unsigned char scopy[32]; 17 | unsigned char h[64]; 18 | unsigned char rcheck[32]; 19 | ge_p3 A; 20 | ge_p2 R; 21 | 22 | if (smlen < 64) goto badsig; 23 | if (sm[63] & 224) goto badsig; 24 | if (ge_frombytes_negate_vartime(&A,pk) != 0) goto badsig; 25 | 26 | memmove(pkcopy,pk,32); 27 | memmove(rcopy,sm,32); 28 | memmove(scopy,sm + 32,32); 29 | 30 | memmove(m,sm,smlen); 31 | memmove(m + 32,pkcopy,32); 32 | crypto_hash_sha512(h,m,smlen); 33 | sc_reduce(h); 34 | 35 | ge_double_scalarmult_vartime(&R,h,&A,scopy); 36 | ge_tobytes(rcheck,&R); 37 | if (crypto_verify_32(rcheck,rcopy) == 0) { 38 | memmove(m,m + 64,smlen - 64); 39 | memset(m + smlen - 64,0,64); 40 | *mlen = smlen - 64; 41 | return 0; 42 | } 43 | 44 | badsig: 45 | *mlen = -1; 46 | memset(m,0,smlen); 47 | return -1; 48 | } 49 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/sc.h: -------------------------------------------------------------------------------- 1 | #ifndef SC_H 2 | #define SC_H 3 | 4 | /* 5 | The set of scalars is \Z/l 6 | where l = 2^252 + 27742317777372353535851937790883648493. 7 | */ 8 | 9 | #define sc_reduce crypto_sign_ed25519_ref10_sc_reduce 10 | #define sc_muladd crypto_sign_ed25519_ref10_sc_muladd 11 | 12 | extern void sc_reduce(unsigned char *); 13 | extern void sc_muladd(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/sign.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_sign.h" 3 | #include "crypto_hash_sha512.h" 4 | #include "ge.h" 5 | #include "sc.h" 6 | 7 | int crypto_sign( 8 | unsigned char *sm,unsigned long long *smlen, 9 | const unsigned char *m,unsigned long long mlen, 10 | const unsigned char *sk 11 | ) 12 | { 13 | unsigned char pk[32]; 14 | unsigned char az[64]; 15 | unsigned char nonce[64]; 16 | unsigned char hram[64]; 17 | ge_p3 R; 18 | 19 | memmove(pk,sk + 32,32); 20 | 21 | crypto_hash_sha512(az,sk,32); 22 | az[0] &= 248; 23 | az[31] &= 63; 24 | az[31] |= 64; 25 | 26 | *smlen = mlen + 64; 27 | memmove(sm + 64,m,mlen); 28 | memmove(sm + 32,az + 32,32); 29 | crypto_hash_sha512(nonce,sm + 32,mlen + 32); 30 | memmove(sm + 32,pk,32); 31 | 32 | sc_reduce(nonce); 33 | ge_scalarmult_base(&R,nonce); 34 | ge_p3_tobytes(sm,&R); 35 | 36 | crypto_hash_sha512(hram,sm,mlen + 64); 37 | sc_reduce(hram); 38 | sc_muladd(sm + 32,hram,az,nonce); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/sqrtm1.h: -------------------------------------------------------------------------------- 1 | -32595792,-7943725,9377950,3500415,12389472,-272473,-25146209,-2005654,326686,11406482 2 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/tests/internal_fast_tests.h: -------------------------------------------------------------------------------- 1 | #ifndef __INTERNAL_FAST_TESTS_H__ 2 | #define __INTERNAL_FAST_TESTS_H__ 3 | 4 | /* silent = 0 : prints info+error messages to stdout, abort() on test failure 5 | * silent = 1 : returns 0 for success, anything else for failure 6 | */ 7 | 8 | int sha512_fast_test(int silent); 9 | int strict_fast_test(int silent); 10 | int elligator_fast_test(int silent); 11 | int curvesigs_fast_test(int silent); 12 | int xeddsa_fast_test(int silent); 13 | int vxeddsa_fast_test(int silent); 14 | int generalized_xeddsa_fast_test(int silent); 15 | int generalized_xveddsa_fast_test(int silent); 16 | 17 | int all_fast_tests(int silent); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/ed25519/tests/internal_slow_tests.h: -------------------------------------------------------------------------------- 1 | #ifndef __INTERNAL_SLOW_TESTS_H__ 2 | #define __INTERNAL_SLOW_TESTS_H__ 3 | 4 | /* silent = 0 : prints info+error messages to stdout, abort() on test failure 5 | * silent = 1 : returns 0 for success, anything else for failure 6 | * iterations : hardcoded known-good values are at 10000, so run at least this many 7 | */ 8 | 9 | int curvesigs_slow_test(int silent, int iterations); 10 | int xeddsa_slow_test(int silent, int iterations); 11 | int xeddsa_to_curvesigs_slow_test(int silent, int iterations); 12 | int generalized_xveddsa_slow_test(int silent, int iterations); 13 | 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/curve25519/lib/curve25519.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icew4y/whatsapp_protocol/d9c64dc854404c29eb28438246330de1bc564e13/whatsappcpp/3rd/curve25519/lib/curve25519.lib -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.sln 3 | *.vcxproj 4 | mbedtls/check_config 5 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | option(INSTALL_MBEDTLS_HEADERS "Install mbed TLS headers." ON) 2 | 3 | if(INSTALL_MBEDTLS_HEADERS) 4 | 5 | file(GLOB headers "mbedtls/*.h") 6 | file(GLOB psa_headers "psa/*.h") 7 | 8 | install(FILES ${headers} 9 | DESTINATION include/mbedtls 10 | PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) 11 | 12 | install(FILES ${psa_headers} 13 | DESTINATION include/psa 14 | PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) 15 | 16 | endif(INSTALL_MBEDTLS_HEADERS) 17 | 18 | # Make config.h available in an out-of-source build. ssl-opt.sh requires it. 19 | if (ENABLE_TESTING AND NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) 20 | link_to_source(mbedtls) 21 | link_to_source(psa) 22 | endif() 23 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/arc4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file arc4.h 3 | * 4 | * \brief The ARCFOUR stream cipher 5 | * 6 | * \warning ARC4 is considered a weak cipher and its use constitutes a 7 | * security risk. We recommend considering stronger ciphers instead. 8 | */ 9 | /* 10 | * Copyright The Mbed TLS Contributors 11 | * SPDX-License-Identifier: Apache-2.0 12 | * 13 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 14 | * not use this file except in compliance with the License. 15 | * You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, software 20 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 21 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 | * See the License for the specific language governing permissions and 23 | * limitations under the License. 24 | * 25 | */ 26 | #ifndef MBEDTLS_ARC4_H 27 | #define MBEDTLS_ARC4_H 28 | 29 | #if !defined(MBEDTLS_CONFIG_FILE) 30 | #include "mbedtls/config.h" 31 | #else 32 | #include MBEDTLS_CONFIG_FILE 33 | #endif 34 | 35 | #include 36 | 37 | /* MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED is deprecated and should not be used. */ 38 | #define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019 /**< ARC4 hardware accelerator failed. */ 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | #if !defined(MBEDTLS_ARC4_ALT) 45 | // Regular implementation 46 | // 47 | 48 | /** 49 | * \brief ARC4 context structure 50 | * 51 | * \warning ARC4 is considered a weak cipher and its use constitutes a 52 | * security risk. We recommend considering stronger ciphers instead. 53 | * 54 | */ 55 | typedef struct mbedtls_arc4_context 56 | { 57 | int x; /*!< permutation index */ 58 | int y; /*!< permutation index */ 59 | unsigned char m[256]; /*!< permutation table */ 60 | } 61 | mbedtls_arc4_context; 62 | 63 | #else /* MBEDTLS_ARC4_ALT */ 64 | #include "arc4_alt.h" 65 | #endif /* MBEDTLS_ARC4_ALT */ 66 | 67 | /** 68 | * \brief Initialize ARC4 context 69 | * 70 | * \param ctx ARC4 context to be initialized 71 | * 72 | * \warning ARC4 is considered a weak cipher and its use constitutes a 73 | * security risk. We recommend considering stronger ciphers 74 | * instead. 75 | * 76 | */ 77 | void mbedtls_arc4_init( mbedtls_arc4_context *ctx ); 78 | 79 | /** 80 | * \brief Clear ARC4 context 81 | * 82 | * \param ctx ARC4 context to be cleared 83 | * 84 | * \warning ARC4 is considered a weak cipher and its use constitutes a 85 | * security risk. We recommend considering stronger ciphers 86 | * instead. 87 | * 88 | */ 89 | void mbedtls_arc4_free( mbedtls_arc4_context *ctx ); 90 | 91 | /** 92 | * \brief ARC4 key schedule 93 | * 94 | * \param ctx ARC4 context to be setup 95 | * \param key the secret key 96 | * \param keylen length of the key, in bytes 97 | * 98 | * \warning ARC4 is considered a weak cipher and its use constitutes a 99 | * security risk. We recommend considering stronger ciphers 100 | * instead. 101 | * 102 | */ 103 | void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key, 104 | unsigned int keylen ); 105 | 106 | /** 107 | * \brief ARC4 cipher function 108 | * 109 | * \param ctx ARC4 context 110 | * \param length length of the input data 111 | * \param input buffer holding the input data 112 | * \param output buffer for the output data 113 | * 114 | * \return 0 if successful 115 | * 116 | * \warning ARC4 is considered a weak cipher and its use constitutes a 117 | * security risk. We recommend considering stronger ciphers 118 | * instead. 119 | * 120 | */ 121 | int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input, 122 | unsigned char *output ); 123 | 124 | #if defined(MBEDTLS_SELF_TEST) 125 | 126 | /** 127 | * \brief Checkup routine 128 | * 129 | * \return 0 if successful, or 1 if the test failed 130 | * 131 | * \warning ARC4 is considered a weak cipher and its use constitutes a 132 | * security risk. We recommend considering stronger ciphers 133 | * instead. 134 | * 135 | */ 136 | int mbedtls_arc4_self_test( int verbose ); 137 | 138 | #endif /* MBEDTLS_SELF_TEST */ 139 | 140 | #ifdef __cplusplus 141 | } 142 | #endif 143 | 144 | #endif /* arc4.h */ 145 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/base64.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file base64.h 3 | * 4 | * \brief RFC 1521 base64 encoding/decoding 5 | */ 6 | /* 7 | * Copyright The Mbed TLS Contributors 8 | * SPDX-License-Identifier: Apache-2.0 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 | * not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | #ifndef MBEDTLS_BASE64_H 23 | #define MBEDTLS_BASE64_H 24 | 25 | #if !defined(MBEDTLS_CONFIG_FILE) 26 | #include "mbedtls/config.h" 27 | #else 28 | #include MBEDTLS_CONFIG_FILE 29 | #endif 30 | 31 | #include 32 | 33 | #define MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */ 34 | #define MBEDTLS_ERR_BASE64_INVALID_CHARACTER -0x002C /**< Invalid character in input. */ 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** 41 | * \brief Encode a buffer into base64 format 42 | * 43 | * \param dst destination buffer 44 | * \param dlen size of the destination buffer 45 | * \param olen number of bytes written 46 | * \param src source buffer 47 | * \param slen amount of data to be encoded 48 | * 49 | * \return 0 if successful, or MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL. 50 | * *olen is always updated to reflect the amount 51 | * of data that has (or would have) been written. 52 | * If that length cannot be represented, then no data is 53 | * written to the buffer and *olen is set to the maximum 54 | * length representable as a size_t. 55 | * 56 | * \note Call this function with dlen = 0 to obtain the 57 | * required buffer size in *olen 58 | */ 59 | int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, 60 | const unsigned char *src, size_t slen ); 61 | 62 | /** 63 | * \brief Decode a base64-formatted buffer 64 | * 65 | * \param dst destination buffer (can be NULL for checking size) 66 | * \param dlen size of the destination buffer 67 | * \param olen number of bytes written 68 | * \param src source buffer 69 | * \param slen amount of data to be decoded 70 | * 71 | * \return 0 if successful, MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL, or 72 | * MBEDTLS_ERR_BASE64_INVALID_CHARACTER if the input data is 73 | * not correct. *olen is always updated to reflect the amount 74 | * of data that has (or would have) been written. 75 | * 76 | * \note Call this function with *dst = NULL or dlen = 0 to obtain 77 | * the required buffer size in *olen 78 | */ 79 | int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, 80 | const unsigned char *src, size_t slen ); 81 | 82 | #if defined(MBEDTLS_SELF_TEST) 83 | /** 84 | * \brief Checkup routine 85 | * 86 | * \return 0 if successful, or 1 if the test failed 87 | */ 88 | int mbedtls_base64_self_test( int verbose ); 89 | 90 | #endif /* MBEDTLS_SELF_TEST */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* base64.h */ 97 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/config_psa.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file mbedtls/config_psa.h 3 | * \brief PSA crypto configuration options (set of defines) 4 | * 5 | * This set of compile-time options takes settings defined in 6 | * include/mbedtls/config.h and include/psa/crypto_config.h and uses 7 | * those definitions to define symbols used in the library code. 8 | * 9 | * Users and integrators should not edit this file, please edit 10 | * include/mbedtls/config.h for MBETLS_XXX settings or 11 | * include/psa/crypto_config.h for PSA_WANT_XXX settings. 12 | */ 13 | /* 14 | * Copyright The Mbed TLS Contributors 15 | * SPDX-License-Identifier: Apache-2.0 16 | * 17 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 18 | * not use this file except in compliance with the License. 19 | * You may obtain a copy of the License at 20 | * 21 | * http://www.apache.org/licenses/LICENSE-2.0 22 | * 23 | * Unless required by applicable law or agreed to in writing, software 24 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 25 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | * See the License for the specific language governing permissions and 27 | * limitations under the License. 28 | */ 29 | 30 | #ifndef MBEDTLS_CONFIG_PSA_H 31 | #define MBEDTLS_CONFIG_PSA_H 32 | 33 | #if defined(MBEDTLS_PSA_CRYPTO_CONFIG) 34 | #include "psa/crypto_config.h" 35 | #endif /* defined(MBEDTLS_PSA_CRYPTO_CONFIG) */ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | #if defined(MBEDTLS_PSA_CRYPTO_CONFIG) 42 | 43 | #if defined(PSA_WANT_ALG_ECDSA) 44 | #if !defined(MBEDTLS_PSA_ACCEL_ALG_ECDSA) 45 | #define MBEDTLS_PSA_BUILTIN_ALG_ECDSA 1 46 | #define MBEDTLS_ECDSA_C 47 | #endif /* !MBEDTLS_PSA_ACCEL_ALG_ECDSA */ 48 | #endif /* PSA_WANT_ALG_ECDSA */ 49 | 50 | #if defined(PSA_WANT_ALG_DETERMINISTIC_ECDSA) 51 | #if !defined(MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA) 52 | #define MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA 1 53 | #define MBEDTLS_ECDSA_DETERMINISTIC 54 | #define MBEDTLS_ECDSA_C 55 | #define MBEDTLS_HMAC_DRBG_C 56 | #define MBEDTLS_MD_C 57 | #endif /* MBEDTLS_PSA_ACCEL_ALG_DETERMINISTIC_ECDSA */ 58 | #endif /* PSA_WANT_ALG_DETERMINISTIC_ECDSA */ 59 | 60 | #else /* MBEDTLS_PSA_CRYPTO_CONFIG */ 61 | 62 | /* 63 | * Ensure PSA_WANT_* defines are setup properly if MBEDTLS_PSA_CRYPTO_CONFIG 64 | * is not defined 65 | */ 66 | #if defined(MBEDTLS_ECDSA_C) 67 | #define MBEDTLS_PSA_BUILTIN_ALG_ECDSA 68 | 69 | // Only add in DETERMINISTIC support if ECDSA is also enabled 70 | #if defined(MBEDTLS_ECDSA_DETERMINISTIC) 71 | #define MBEDTLS_PSA_BUILTIN_ALG_DETERMINISTIC_ECDSA 72 | #endif /* MBEDTLS_ECDSA_DETERMINISTIC */ 73 | 74 | #endif /* MBEDTLS_ECDSA_C */ 75 | 76 | #endif /* MBEDTLS_PSA_CRYPTO_CONFIG */ 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /* MBEDTLS_CONFIG_PSA_H */ 83 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/entropy_poll.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file entropy_poll.h 3 | * 4 | * \brief Platform-specific and custom entropy polling functions 5 | */ 6 | /* 7 | * Copyright The Mbed TLS Contributors 8 | * SPDX-License-Identifier: Apache-2.0 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 | * not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | #ifndef MBEDTLS_ENTROPY_POLL_H 23 | #define MBEDTLS_ENTROPY_POLL_H 24 | 25 | #if !defined(MBEDTLS_CONFIG_FILE) 26 | #include "mbedtls/config.h" 27 | #else 28 | #include MBEDTLS_CONFIG_FILE 29 | #endif 30 | 31 | #include 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* 38 | * Default thresholds for built-in sources, in bytes 39 | */ 40 | #define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */ 41 | #define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */ 42 | #define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */ 43 | #if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE) 44 | #define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */ 45 | #endif 46 | 47 | /** 48 | * \brief Entropy poll callback that provides 0 entropy. 49 | */ 50 | #if defined(MBEDTLS_TEST_NULL_ENTROPY) 51 | int mbedtls_null_entropy_poll( void *data, 52 | unsigned char *output, size_t len, size_t *olen ); 53 | #endif 54 | 55 | #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY) 56 | /** 57 | * \brief Platform-specific entropy poll callback 58 | */ 59 | int mbedtls_platform_entropy_poll( void *data, 60 | unsigned char *output, size_t len, size_t *olen ); 61 | #endif 62 | 63 | #if defined(MBEDTLS_HAVEGE_C) 64 | /** 65 | * \brief HAVEGE based entropy poll callback 66 | * 67 | * Requires an HAVEGE state as its data pointer. 68 | */ 69 | int mbedtls_havege_poll( void *data, 70 | unsigned char *output, size_t len, size_t *olen ); 71 | #endif 72 | 73 | #if defined(MBEDTLS_TIMING_C) 74 | /** 75 | * \brief mbedtls_timing_hardclock-based entropy poll callback 76 | */ 77 | int mbedtls_hardclock_poll( void *data, 78 | unsigned char *output, size_t len, size_t *olen ); 79 | #endif 80 | 81 | #if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) 82 | /** 83 | * \brief Entropy poll callback for a hardware source 84 | * 85 | * \warning This is not provided by mbed TLS! 86 | * See \c MBEDTLS_ENTROPY_HARDWARE_ALT in config.h. 87 | * 88 | * \note This must accept NULL as its first argument. 89 | */ 90 | int mbedtls_hardware_poll( void *data, 91 | unsigned char *output, size_t len, size_t *olen ); 92 | #endif 93 | 94 | #if defined(MBEDTLS_ENTROPY_NV_SEED) 95 | /** 96 | * \brief Entropy poll callback for a non-volatile seed file 97 | * 98 | * \note This must accept NULL as its first argument. 99 | */ 100 | int mbedtls_nv_seed_poll( void *data, 101 | unsigned char *output, size_t len, size_t *olen ); 102 | #endif 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif /* entropy_poll.h */ 109 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/havege.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file havege.h 3 | * 4 | * \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion 5 | */ 6 | /* 7 | * Copyright The Mbed TLS Contributors 8 | * SPDX-License-Identifier: Apache-2.0 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 | * not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | #ifndef MBEDTLS_HAVEGE_H 23 | #define MBEDTLS_HAVEGE_H 24 | 25 | #if !defined(MBEDTLS_CONFIG_FILE) 26 | #include "mbedtls/config.h" 27 | #else 28 | #include MBEDTLS_CONFIG_FILE 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** 41 | * \brief HAVEGE state structure 42 | */ 43 | typedef struct mbedtls_havege_state 44 | { 45 | uint32_t PT1, PT2, offset[2]; 46 | uint32_t pool[MBEDTLS_HAVEGE_COLLECT_SIZE]; 47 | uint32_t WALK[8192]; 48 | } 49 | mbedtls_havege_state; 50 | 51 | /** 52 | * \brief HAVEGE initialization 53 | * 54 | * \param hs HAVEGE state to be initialized 55 | */ 56 | void mbedtls_havege_init( mbedtls_havege_state *hs ); 57 | 58 | /** 59 | * \brief Clear HAVEGE state 60 | * 61 | * \param hs HAVEGE state to be cleared 62 | */ 63 | void mbedtls_havege_free( mbedtls_havege_state *hs ); 64 | 65 | /** 66 | * \brief HAVEGE rand function 67 | * 68 | * \param p_rng A HAVEGE state 69 | * \param output Buffer to fill 70 | * \param len Length of buffer 71 | * 72 | * \return 0 73 | */ 74 | int mbedtls_havege_random( void *p_rng, unsigned char *output, size_t len ); 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* havege.h */ 81 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/md_internal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file md_internal.h 3 | * 4 | * \brief Message digest wrappers. 5 | * 6 | * \warning This in an internal header. Do not include directly. 7 | * 8 | * \author Adriaan de Jong 9 | */ 10 | /* 11 | * Copyright The Mbed TLS Contributors 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | */ 26 | #ifndef MBEDTLS_MD_WRAP_H 27 | #define MBEDTLS_MD_WRAP_H 28 | 29 | #if !defined(MBEDTLS_CONFIG_FILE) 30 | #include "mbedtls/config.h" 31 | #else 32 | #include MBEDTLS_CONFIG_FILE 33 | #endif 34 | 35 | #include "mbedtls/md.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /** 42 | * Message digest information. 43 | * Allows message digest functions to be called in a generic way. 44 | */ 45 | struct mbedtls_md_info_t 46 | { 47 | /** Name of the message digest */ 48 | const char * name; 49 | 50 | /** Digest identifier */ 51 | mbedtls_md_type_t type; 52 | 53 | /** Output length of the digest function in bytes */ 54 | unsigned char size; 55 | 56 | /** Block length of the digest function in bytes */ 57 | unsigned char block_size; 58 | }; 59 | 60 | #if defined(MBEDTLS_MD2_C) 61 | extern const mbedtls_md_info_t mbedtls_md2_info; 62 | #endif 63 | #if defined(MBEDTLS_MD4_C) 64 | extern const mbedtls_md_info_t mbedtls_md4_info; 65 | #endif 66 | #if defined(MBEDTLS_MD5_C) 67 | extern const mbedtls_md_info_t mbedtls_md5_info; 68 | #endif 69 | #if defined(MBEDTLS_RIPEMD160_C) 70 | extern const mbedtls_md_info_t mbedtls_ripemd160_info; 71 | #endif 72 | #if defined(MBEDTLS_SHA1_C) 73 | extern const mbedtls_md_info_t mbedtls_sha1_info; 74 | #endif 75 | #if defined(MBEDTLS_SHA256_C) 76 | extern const mbedtls_md_info_t mbedtls_sha224_info; 77 | extern const mbedtls_md_info_t mbedtls_sha256_info; 78 | #endif 79 | #if defined(MBEDTLS_SHA512_C) 80 | #if !defined(MBEDTLS_SHA512_NO_SHA384) 81 | extern const mbedtls_md_info_t mbedtls_sha384_info; 82 | #endif 83 | extern const mbedtls_md_info_t mbedtls_sha512_info; 84 | #endif 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* MBEDTLS_MD_WRAP_H */ 91 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/net.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file net.h 3 | * 4 | * \brief Deprecated header file that includes net_sockets.h 5 | * 6 | * \deprecated Superseded by mbedtls/net_sockets.h 7 | */ 8 | /* 9 | * Copyright The Mbed TLS Contributors 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | #if !defined(MBEDTLS_CONFIG_FILE) 25 | #include "mbedtls/config.h" 26 | #else 27 | #include MBEDTLS_CONFIG_FILE 28 | #endif 29 | 30 | #if !defined(MBEDTLS_DEPRECATED_REMOVED) 31 | #include "mbedtls/net_sockets.h" 32 | #if defined(MBEDTLS_DEPRECATED_WARNING) 33 | #warning "Deprecated header file: Superseded by mbedtls/net_sockets.h" 34 | #endif /* MBEDTLS_DEPRECATED_WARNING */ 35 | #endif /* !MBEDTLS_DEPRECATED_REMOVED */ 36 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/padlock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file padlock.h 3 | * 4 | * \brief VIA PadLock ACE for HW encryption/decryption supported by some 5 | * processors 6 | * 7 | * \warning These functions are only for internal use by other library 8 | * functions; you must not call them directly. 9 | */ 10 | /* 11 | * Copyright The Mbed TLS Contributors 12 | * SPDX-License-Identifier: Apache-2.0 13 | * 14 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 15 | * not use this file except in compliance with the License. 16 | * You may obtain a copy of the License at 17 | * 18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | * 20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 22 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | */ 26 | #ifndef MBEDTLS_PADLOCK_H 27 | #define MBEDTLS_PADLOCK_H 28 | 29 | #if !defined(MBEDTLS_CONFIG_FILE) 30 | #include "mbedtls/config.h" 31 | #else 32 | #include MBEDTLS_CONFIG_FILE 33 | #endif 34 | 35 | #include "mbedtls/aes.h" 36 | 37 | #define MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED -0x0030 /**< Input data should be aligned. */ 38 | 39 | #if defined(__has_feature) 40 | #if __has_feature(address_sanitizer) 41 | #define MBEDTLS_HAVE_ASAN 42 | #endif 43 | #endif 44 | 45 | /* Some versions of ASan result in errors about not enough registers */ 46 | #if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && defined(__i386__) && \ 47 | !defined(MBEDTLS_HAVE_ASAN) 48 | 49 | #ifndef MBEDTLS_HAVE_X86 50 | #define MBEDTLS_HAVE_X86 51 | #endif 52 | 53 | #include 54 | 55 | #define MBEDTLS_PADLOCK_RNG 0x000C 56 | #define MBEDTLS_PADLOCK_ACE 0x00C0 57 | #define MBEDTLS_PADLOCK_PHE 0x0C00 58 | #define MBEDTLS_PADLOCK_PMM 0x3000 59 | 60 | #define MBEDTLS_PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t) (x) & ~15)) 61 | 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | /** 67 | * \brief Internal PadLock detection routine 68 | * 69 | * \note This function is only for internal use by other library 70 | * functions; you must not call it directly. 71 | * 72 | * \param feature The feature to detect 73 | * 74 | * \return 1 if CPU has support for the feature, 0 otherwise 75 | */ 76 | int mbedtls_padlock_has_support( int feature ); 77 | 78 | /** 79 | * \brief Internal PadLock AES-ECB block en(de)cryption 80 | * 81 | * \note This function is only for internal use by other library 82 | * functions; you must not call it directly. 83 | * 84 | * \param ctx AES context 85 | * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT 86 | * \param input 16-byte input block 87 | * \param output 16-byte output block 88 | * 89 | * \return 0 if success, 1 if operation failed 90 | */ 91 | int mbedtls_padlock_xcryptecb( mbedtls_aes_context *ctx, 92 | int mode, 93 | const unsigned char input[16], 94 | unsigned char output[16] ); 95 | 96 | /** 97 | * \brief Internal PadLock AES-CBC buffer en(de)cryption 98 | * 99 | * \note This function is only for internal use by other library 100 | * functions; you must not call it directly. 101 | * 102 | * \param ctx AES context 103 | * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT 104 | * \param length length of the input data 105 | * \param iv initialization vector (updated after use) 106 | * \param input buffer holding the input data 107 | * \param output buffer holding the output data 108 | * 109 | * \return 0 if success, 1 if operation failed 110 | */ 111 | int mbedtls_padlock_xcryptcbc( mbedtls_aes_context *ctx, 112 | int mode, 113 | size_t length, 114 | unsigned char iv[16], 115 | const unsigned char *input, 116 | unsigned char *output ); 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif /* HAVE_X86 */ 123 | 124 | #endif /* padlock.h */ 125 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/pkcs5.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file pkcs5.h 3 | * 4 | * \brief PKCS#5 functions 5 | * 6 | * \author Mathias Olsson 7 | */ 8 | /* 9 | * Copyright The Mbed TLS Contributors 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * http://www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | #ifndef MBEDTLS_PKCS5_H 25 | #define MBEDTLS_PKCS5_H 26 | 27 | #if !defined(MBEDTLS_CONFIG_FILE) 28 | #include "mbedtls/config.h" 29 | #else 30 | #include MBEDTLS_CONFIG_FILE 31 | #endif 32 | 33 | #include "mbedtls/asn1.h" 34 | #include "mbedtls/md.h" 35 | 36 | #include 37 | #include 38 | 39 | #define MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA -0x2f80 /**< Bad input parameters to function. */ 40 | #define MBEDTLS_ERR_PKCS5_INVALID_FORMAT -0x2f00 /**< Unexpected ASN.1 data. */ 41 | #define MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE -0x2e80 /**< Requested encryption or digest alg not available. */ 42 | #define MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH -0x2e00 /**< Given private key password does not allow for correct decryption. */ 43 | 44 | #define MBEDTLS_PKCS5_DECRYPT 0 45 | #define MBEDTLS_PKCS5_ENCRYPT 1 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | #if defined(MBEDTLS_ASN1_PARSE_C) 52 | 53 | /** 54 | * \brief PKCS#5 PBES2 function 55 | * 56 | * \param pbe_params the ASN.1 algorithm parameters 57 | * \param mode either MBEDTLS_PKCS5_DECRYPT or MBEDTLS_PKCS5_ENCRYPT 58 | * \param pwd password to use when generating key 59 | * \param pwdlen length of password 60 | * \param data data to process 61 | * \param datalen length of data 62 | * \param output output buffer 63 | * 64 | * \returns 0 on success, or a MBEDTLS_ERR_XXX code if verification fails. 65 | */ 66 | int mbedtls_pkcs5_pbes2( const mbedtls_asn1_buf *pbe_params, int mode, 67 | const unsigned char *pwd, size_t pwdlen, 68 | const unsigned char *data, size_t datalen, 69 | unsigned char *output ); 70 | 71 | #endif /* MBEDTLS_ASN1_PARSE_C */ 72 | 73 | /** 74 | * \brief PKCS#5 PBKDF2 using HMAC 75 | * 76 | * \param ctx Generic HMAC context 77 | * \param password Password to use when generating key 78 | * \param plen Length of password 79 | * \param salt Salt to use when generating key 80 | * \param slen Length of salt 81 | * \param iteration_count Iteration count 82 | * \param key_length Length of generated key in bytes 83 | * \param output Generated key. Must be at least as big as key_length 84 | * 85 | * \returns 0 on success, or a MBEDTLS_ERR_XXX code if verification fails. 86 | */ 87 | int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx, const unsigned char *password, 88 | size_t plen, const unsigned char *salt, size_t slen, 89 | unsigned int iteration_count, 90 | uint32_t key_length, unsigned char *output ); 91 | 92 | #if defined(MBEDTLS_SELF_TEST) 93 | 94 | /** 95 | * \brief Checkup routine 96 | * 97 | * \return 0 if successful, or 1 if the test failed 98 | */ 99 | int mbedtls_pkcs5_self_test( int verbose ); 100 | 101 | #endif /* MBEDTLS_SELF_TEST */ 102 | 103 | #ifdef __cplusplus 104 | } 105 | #endif 106 | 107 | #endif /* pkcs5.h */ 108 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/platform_time.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file platform_time.h 3 | * 4 | * \brief mbed TLS Platform time abstraction 5 | */ 6 | /* 7 | * Copyright The Mbed TLS Contributors 8 | * SPDX-License-Identifier: Apache-2.0 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 | * not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | #ifndef MBEDTLS_PLATFORM_TIME_H 23 | #define MBEDTLS_PLATFORM_TIME_H 24 | 25 | #if !defined(MBEDTLS_CONFIG_FILE) 26 | #include "mbedtls/config.h" 27 | #else 28 | #include MBEDTLS_CONFIG_FILE 29 | #endif 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /** 36 | * \name SECTION: Module settings 37 | * 38 | * The configuration options you can set for this module are in this section. 39 | * Either change them in config.h or define them on the compiler command line. 40 | * \{ 41 | */ 42 | 43 | /* 44 | * The time_t datatype 45 | */ 46 | #if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) 47 | typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t; 48 | #else 49 | /* For time_t */ 50 | #include 51 | typedef time_t mbedtls_time_t; 52 | #endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */ 53 | 54 | /* 55 | * The function pointers for time 56 | */ 57 | #if defined(MBEDTLS_PLATFORM_TIME_ALT) 58 | extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time ); 59 | 60 | /** 61 | * \brief Set your own time function pointer 62 | * 63 | * \param time_func the time function implementation 64 | * 65 | * \return 0 66 | */ 67 | int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) ); 68 | #else 69 | #if defined(MBEDTLS_PLATFORM_TIME_MACRO) 70 | #define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO 71 | #else 72 | #define mbedtls_time time 73 | #endif /* MBEDTLS_PLATFORM_TIME_MACRO */ 74 | #endif /* MBEDTLS_PLATFORM_TIME_ALT */ 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif /* platform_time.h */ 81 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/ssl_cookie.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file ssl_cookie.h 3 | * 4 | * \brief DTLS cookie callbacks implementation 5 | */ 6 | /* 7 | * Copyright The Mbed TLS Contributors 8 | * SPDX-License-Identifier: Apache-2.0 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 | * not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | #ifndef MBEDTLS_SSL_COOKIE_H 23 | #define MBEDTLS_SSL_COOKIE_H 24 | 25 | #if !defined(MBEDTLS_CONFIG_FILE) 26 | #include "mbedtls/config.h" 27 | #else 28 | #include MBEDTLS_CONFIG_FILE 29 | #endif 30 | 31 | #include "mbedtls/ssl.h" 32 | 33 | #if defined(MBEDTLS_THREADING_C) 34 | #include "mbedtls/threading.h" 35 | #endif 36 | 37 | /** 38 | * \name SECTION: Module settings 39 | * 40 | * The configuration options you can set for this module are in this section. 41 | * Either change them in config.h or define them on the compiler command line. 42 | * \{ 43 | */ 44 | #ifndef MBEDTLS_SSL_COOKIE_TIMEOUT 45 | #define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ 46 | #endif 47 | 48 | /* \} name SECTION: Module settings */ 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | /** 55 | * \brief Context for the default cookie functions. 56 | */ 57 | typedef struct mbedtls_ssl_cookie_ctx 58 | { 59 | mbedtls_md_context_t hmac_ctx; /*!< context for the HMAC portion */ 60 | #if !defined(MBEDTLS_HAVE_TIME) 61 | unsigned long serial; /*!< serial number for expiration */ 62 | #endif 63 | unsigned long timeout; /*!< timeout delay, in seconds if HAVE_TIME, 64 | or in number of tickets issued */ 65 | 66 | #if defined(MBEDTLS_THREADING_C) 67 | mbedtls_threading_mutex_t mutex; 68 | #endif 69 | } mbedtls_ssl_cookie_ctx; 70 | 71 | /** 72 | * \brief Initialize cookie context 73 | */ 74 | void mbedtls_ssl_cookie_init( mbedtls_ssl_cookie_ctx *ctx ); 75 | 76 | /** 77 | * \brief Setup cookie context (generate keys) 78 | */ 79 | int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx, 80 | int (*f_rng)(void *, unsigned char *, size_t), 81 | void *p_rng ); 82 | 83 | /** 84 | * \brief Set expiration delay for cookies 85 | * (Default MBEDTLS_SSL_COOKIE_TIMEOUT) 86 | * 87 | * \param ctx Cookie contex 88 | * \param delay Delay, in seconds if HAVE_TIME, or in number of cookies 89 | * issued in the meantime. 90 | * 0 to disable expiration (NOT recommended) 91 | */ 92 | void mbedtls_ssl_cookie_set_timeout( mbedtls_ssl_cookie_ctx *ctx, unsigned long delay ); 93 | 94 | /** 95 | * \brief Free cookie context 96 | */ 97 | void mbedtls_ssl_cookie_free( mbedtls_ssl_cookie_ctx *ctx ); 98 | 99 | /** 100 | * \brief Generate cookie, see \c mbedtls_ssl_cookie_write_t 101 | */ 102 | mbedtls_ssl_cookie_write_t mbedtls_ssl_cookie_write; 103 | 104 | /** 105 | * \brief Verify cookie, see \c mbedtls_ssl_cookie_write_t 106 | */ 107 | mbedtls_ssl_cookie_check_t mbedtls_ssl_cookie_check; 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /* ssl_cookie.h */ 114 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file version.h 3 | * 4 | * \brief Run-time version information 5 | */ 6 | /* 7 | * Copyright The Mbed TLS Contributors 8 | * SPDX-License-Identifier: Apache-2.0 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 | * not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | /* 23 | * This set of compile-time defines and run-time variables can be used to 24 | * determine the version number of the mbed TLS library used. 25 | */ 26 | #ifndef MBEDTLS_VERSION_H 27 | #define MBEDTLS_VERSION_H 28 | 29 | #if !defined(MBEDTLS_CONFIG_FILE) 30 | #include "mbedtls/config.h" 31 | #else 32 | #include MBEDTLS_CONFIG_FILE 33 | #endif 34 | 35 | /** 36 | * The version number x.y.z is split into three parts. 37 | * Major, Minor, Patchlevel 38 | */ 39 | #define MBEDTLS_VERSION_MAJOR 2 40 | #define MBEDTLS_VERSION_MINOR 24 41 | #define MBEDTLS_VERSION_PATCH 0 42 | 43 | /** 44 | * The single version number has the following structure: 45 | * MMNNPP00 46 | * Major version | Minor version | Patch version 47 | */ 48 | #define MBEDTLS_VERSION_NUMBER 0x02180000 49 | #define MBEDTLS_VERSION_STRING "2.24.0" 50 | #define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.24.0" 51 | 52 | #if defined(MBEDTLS_VERSION_C) 53 | 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | /** 59 | * Get the version number. 60 | * 61 | * \return The constructed version number in the format 62 | * MMNNPP00 (Major, Minor, Patch). 63 | */ 64 | unsigned int mbedtls_version_get_number( void ); 65 | 66 | /** 67 | * Get the version string ("x.y.z"). 68 | * 69 | * \param string The string that will receive the value. 70 | * (Should be at least 9 bytes in size) 71 | */ 72 | void mbedtls_version_get_string( char *string ); 73 | 74 | /** 75 | * Get the full version string ("mbed TLS x.y.z"). 76 | * 77 | * \param string The string that will receive the value. The mbed TLS version 78 | * string will use 18 bytes AT MOST including a terminating 79 | * null byte. 80 | * (So the buffer should be at least 18 bytes to receive this 81 | * version string). 82 | */ 83 | void mbedtls_version_get_string_full( char *string ); 84 | 85 | /** 86 | * \brief Check if support for a feature was compiled into this 87 | * mbed TLS binary. This allows you to see at runtime if the 88 | * library was for instance compiled with or without 89 | * Multi-threading support. 90 | * 91 | * \note only checks against defines in the sections "System 92 | * support", "mbed TLS modules" and "mbed TLS feature 93 | * support" in config.h 94 | * 95 | * \param feature The string for the define to check (e.g. "MBEDTLS_AES_C") 96 | * 97 | * \return 0 if the feature is present, 98 | * -1 if the feature is not present and 99 | * -2 if support for feature checking as a whole was not 100 | * compiled in. 101 | */ 102 | int mbedtls_version_check_feature( const char *feature ); 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif /* MBEDTLS_VERSION_C */ 109 | 110 | #endif /* version.h */ 111 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/mbedtls/xtea.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file xtea.h 3 | * 4 | * \brief XTEA block cipher (32-bit) 5 | */ 6 | /* 7 | * Copyright The Mbed TLS Contributors 8 | * SPDX-License-Identifier: Apache-2.0 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 11 | * not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 18 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | #ifndef MBEDTLS_XTEA_H 23 | #define MBEDTLS_XTEA_H 24 | 25 | #if !defined(MBEDTLS_CONFIG_FILE) 26 | #include "mbedtls/config.h" 27 | #else 28 | #include MBEDTLS_CONFIG_FILE 29 | #endif 30 | 31 | #include 32 | #include 33 | 34 | #define MBEDTLS_XTEA_ENCRYPT 1 35 | #define MBEDTLS_XTEA_DECRYPT 0 36 | 37 | #define MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH -0x0028 /**< The data input has an invalid length. */ 38 | 39 | /* MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED is deprecated and should not be used. */ 40 | #define MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED -0x0029 /**< XTEA hardware accelerator failed. */ 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #if !defined(MBEDTLS_XTEA_ALT) 47 | // Regular implementation 48 | // 49 | 50 | /** 51 | * \brief XTEA context structure 52 | */ 53 | typedef struct mbedtls_xtea_context 54 | { 55 | uint32_t k[4]; /*!< key */ 56 | } 57 | mbedtls_xtea_context; 58 | 59 | #else /* MBEDTLS_XTEA_ALT */ 60 | #include "xtea_alt.h" 61 | #endif /* MBEDTLS_XTEA_ALT */ 62 | 63 | /** 64 | * \brief Initialize XTEA context 65 | * 66 | * \param ctx XTEA context to be initialized 67 | */ 68 | void mbedtls_xtea_init( mbedtls_xtea_context *ctx ); 69 | 70 | /** 71 | * \brief Clear XTEA context 72 | * 73 | * \param ctx XTEA context to be cleared 74 | */ 75 | void mbedtls_xtea_free( mbedtls_xtea_context *ctx ); 76 | 77 | /** 78 | * \brief XTEA key schedule 79 | * 80 | * \param ctx XTEA context to be initialized 81 | * \param key the secret key 82 | */ 83 | void mbedtls_xtea_setup( mbedtls_xtea_context *ctx, const unsigned char key[16] ); 84 | 85 | /** 86 | * \brief XTEA cipher function 87 | * 88 | * \param ctx XTEA context 89 | * \param mode MBEDTLS_XTEA_ENCRYPT or MBEDTLS_XTEA_DECRYPT 90 | * \param input 8-byte input block 91 | * \param output 8-byte output block 92 | * 93 | * \return 0 if successful 94 | */ 95 | int mbedtls_xtea_crypt_ecb( mbedtls_xtea_context *ctx, 96 | int mode, 97 | const unsigned char input[8], 98 | unsigned char output[8] ); 99 | 100 | #if defined(MBEDTLS_CIPHER_MODE_CBC) 101 | /** 102 | * \brief XTEA CBC cipher function 103 | * 104 | * \param ctx XTEA context 105 | * \param mode MBEDTLS_XTEA_ENCRYPT or MBEDTLS_XTEA_DECRYPT 106 | * \param length the length of input, multiple of 8 107 | * \param iv initialization vector for CBC mode 108 | * \param input input block 109 | * \param output output block 110 | * 111 | * \return 0 if successful, 112 | * MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH if the length % 8 != 0 113 | */ 114 | int mbedtls_xtea_crypt_cbc( mbedtls_xtea_context *ctx, 115 | int mode, 116 | size_t length, 117 | unsigned char iv[8], 118 | const unsigned char *input, 119 | unsigned char *output); 120 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ 121 | 122 | #if defined(MBEDTLS_SELF_TEST) 123 | 124 | /** 125 | * \brief Checkup routine 126 | * 127 | * \return 0 if successful, or 1 if the test failed 128 | */ 129 | int mbedtls_xtea_self_test( int verbose ); 130 | 131 | #endif /* MBEDTLS_SELF_TEST */ 132 | 133 | #ifdef __cplusplus 134 | } 135 | #endif 136 | 137 | #endif /* xtea.h */ 138 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/psa/crypto_config.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file psa/crypto_config.h 3 | * \brief PSA crypto configuration options (set of defines) 4 | * 5 | */ 6 | #if defined(MBEDTLS_PSA_CRYPTO_CONFIG) 7 | /** 8 | * When #MBEDTLS_PSA_CRYPTO_CONFIG is enabled in config.h, 9 | * this file determines which cryptographic mechanisms are enabled 10 | * through the PSA Cryptography API (\c psa_xxx() functions). 11 | * 12 | * To enable a cryptographic mechanism, uncomment the definition of 13 | * the corresponding \c PSA_WANT_xxx preprocessor symbol. 14 | * To disable a cryptographic mechanism, comment out the definition of 15 | * the corresponding \c PSA_WANT_xxx preprocessor symbol. 16 | * The names of cryptographic mechanisms correspond to values 17 | * defined in psa/crypto_values.h, with the prefix \c PSA_WANT_ instead 18 | * of \c PSA_. 19 | * 20 | * Note that many cryptographic mechanisms involve two symbols: one for 21 | * the key type (\c PSA_WANT_KEY_TYPE_xxx) and one for the algorithm 22 | * (\c PSA_WANT_ALG_xxx). Mechanisms with additional parameters may involve 23 | * additional symbols. 24 | */ 25 | #else 26 | /** 27 | * When \c MBEDTLS_PSA_CRYPTO_CONFIG is disabled in config.h, 28 | * this file is not used, and cryptographic mechanisms are supported 29 | * through the PSA API if and only if they are supported through the 30 | * mbedtls_xxx API. 31 | */ 32 | #endif 33 | /* 34 | * Copyright The Mbed TLS Contributors 35 | * SPDX-License-Identifier: Apache-2.0 36 | * 37 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 38 | * not use this file except in compliance with the License. 39 | * You may obtain a copy of the License at 40 | * 41 | * http://www.apache.org/licenses/LICENSE-2.0 42 | * 43 | * Unless required by applicable law or agreed to in writing, software 44 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 45 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 46 | * See the License for the specific language governing permissions and 47 | * limitations under the License. 48 | */ 49 | 50 | #ifndef PSA_CRYPTO_CONFIG_H 51 | #define PSA_CRYPTO_CONFIG_H 52 | 53 | #define PSA_WANT_ALG_ECDSA 1 54 | #define PSA_WANT_ALG_DETERMINISTIC_ECDSA 1 55 | 56 | #endif /* PSA_CRYPTO_CONFIG_H */ 57 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/psa/crypto_driver_common.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file psa/crypto_driver_common.h 3 | * \brief Definitions for all PSA crypto drivers 4 | * 5 | * This file contains common definitions shared by all PSA crypto drivers. 6 | * Do not include it directly: instead, include the header file(s) for 7 | * the type(s) of driver that you are implementing. For example, if 8 | * you are writing a driver for a chip that provides both a hardware 9 | * random generator and an accelerator for some cryptographic algorithms, 10 | * include `psa/crypto_entropy_driver.h` and `psa/crypto_accel_driver.h`. 11 | * 12 | * This file is part of the PSA Crypto Driver Model, containing functions for 13 | * driver developers to implement to enable hardware to be called in a 14 | * standardized way by a PSA Cryptographic API implementation. The functions 15 | * comprising the driver model, which driver authors implement, are not 16 | * intended to be called by application developers. 17 | */ 18 | 19 | /* 20 | * Copyright The Mbed TLS Contributors 21 | * SPDX-License-Identifier: Apache-2.0 22 | * 23 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 24 | * not use this file except in compliance with the License. 25 | * You may obtain a copy of the License at 26 | * 27 | * http://www.apache.org/licenses/LICENSE-2.0 28 | * 29 | * Unless required by applicable law or agreed to in writing, software 30 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 31 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 32 | * See the License for the specific language governing permissions and 33 | * limitations under the License. 34 | */ 35 | #ifndef PSA_CRYPTO_DRIVER_COMMON_H 36 | #define PSA_CRYPTO_DRIVER_COMMON_H 37 | 38 | #include 39 | #include 40 | 41 | /* Include type definitions (psa_status_t, psa_algorithm_t, 42 | * psa_key_type_t, etc.) and macros to build and analyze values 43 | * of these types. */ 44 | #include "crypto_types.h" 45 | #include "crypto_values.h" 46 | 47 | /** For encrypt-decrypt functions, whether the operation is an encryption 48 | * or a decryption. */ 49 | typedef enum { 50 | PSA_CRYPTO_DRIVER_DECRYPT, 51 | PSA_CRYPTO_DRIVER_ENCRYPT 52 | } psa_encrypt_or_decrypt_t; 53 | 54 | #endif /* PSA_CRYPTO_DRIVER_COMMON_H */ 55 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/psa/crypto_entropy_driver.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file psa/crypto_entropy_driver.h 3 | * \brief PSA entropy source driver module 4 | * 5 | * This header declares types and function signatures for entropy sources. 6 | * 7 | * This file is part of the PSA Crypto Driver Model, containing functions for 8 | * driver developers to implement to enable hardware to be called in a 9 | * standardized way by a PSA Cryptographic API implementation. The functions 10 | * comprising the driver model, which driver authors implement, are not 11 | * intended to be called by application developers. 12 | */ 13 | 14 | /* 15 | * Copyright The Mbed TLS Contributors 16 | * SPDX-License-Identifier: Apache-2.0 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 19 | * not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * http://www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | */ 30 | #ifndef PSA_CRYPTO_ENTROPY_DRIVER_H 31 | #define PSA_CRYPTO_ENTROPY_DRIVER_H 32 | 33 | #include "crypto_driver_common.h" 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** \defgroup driver_rng Entropy Generation 40 | */ 41 | /**@{*/ 42 | 43 | /** \brief Initialize an entropy driver 44 | * 45 | * 46 | * \param[in,out] p_context A hardware-specific structure 47 | * containing any context information for 48 | * the implementation 49 | * 50 | * \retval PSA_SUCCESS 51 | */ 52 | typedef psa_status_t (*psa_drv_entropy_init_t)(void *p_context); 53 | 54 | /** \brief Get a specified number of bits from the entropy source 55 | * 56 | * It retrives `buffer_size` bytes of data from the entropy source. The entropy 57 | * source will always fill the provided buffer to its full size, however, most 58 | * entropy sources have biases, and the actual amount of entropy contained in 59 | * the buffer will be less than the number of bytes. 60 | * The driver will return the actual number of bytes of entropy placed in the 61 | * buffer in `p_received_entropy_bytes`. 62 | * A PSA Crypto API implementation will likely feed the output of this function 63 | * into a Digital Random Bit Generator (DRBG), and typically has a minimum 64 | * amount of entropy that it needs. 65 | * To accomplish this, the PSA Crypto implementation should be designed to call 66 | * this function multiple times until it has received the required amount of 67 | * entropy from the entropy source. 68 | * 69 | * \param[in,out] p_context A hardware-specific structure 70 | * containing any context information 71 | * for the implementation 72 | * \param[out] p_buffer A caller-allocated buffer for the 73 | * retrieved entropy to be placed in 74 | * \param[in] buffer_size The allocated size of `p_buffer` 75 | * \param[out] p_received_entropy_bits The amount of entropy (in bits) 76 | * actually provided in `p_buffer` 77 | * 78 | * \retval PSA_SUCCESS 79 | */ 80 | typedef psa_status_t (*psa_drv_entropy_get_bits_t)(void *p_context, 81 | uint8_t *p_buffer, 82 | uint32_t buffer_size, 83 | uint32_t *p_received_entropy_bits); 84 | 85 | /** 86 | * \brief A struct containing all of the function pointers needed to interface 87 | * to an entropy source 88 | * 89 | * PSA Crypto API implementations should populate instances of the table as 90 | * appropriate upon startup. 91 | * 92 | * If one of the functions is not implemented, it should be set to NULL. 93 | */ 94 | typedef struct { 95 | /** The driver-specific size of the entropy context */ 96 | const size_t context_size; 97 | /** Function that performs initialization for the entropy source */ 98 | psa_drv_entropy_init_t p_init; 99 | /** Function that performs the get_bits operation for the entropy source */ 100 | psa_drv_entropy_get_bits_t p_get_bits; 101 | } psa_drv_entropy_t; 102 | /**@}*/ 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | #endif /* PSA_CRYPTO_ENTROPY_DRIVER_H */ 109 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/include/psa/crypto_platform.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file psa/crypto_platform.h 3 | * 4 | * \brief PSA cryptography module: Mbed TLS platform definitions 5 | * 6 | * \note This file may not be included directly. Applications must 7 | * include psa/crypto.h. 8 | * 9 | * This file contains platform-dependent type definitions. 10 | * 11 | * In implementations with isolation between the application and the 12 | * cryptography module, implementers should take care to ensure that 13 | * the definitions that are exposed to applications match what the 14 | * module implements. 15 | */ 16 | /* 17 | * Copyright The Mbed TLS Contributors 18 | * SPDX-License-Identifier: Apache-2.0 19 | * 20 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 21 | * not use this file except in compliance with the License. 22 | * You may obtain a copy of the License at 23 | * 24 | * http://www.apache.org/licenses/LICENSE-2.0 25 | * 26 | * Unless required by applicable law or agreed to in writing, software 27 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 28 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 | * See the License for the specific language governing permissions and 30 | * limitations under the License. 31 | */ 32 | 33 | #ifndef PSA_CRYPTO_PLATFORM_H 34 | #define PSA_CRYPTO_PLATFORM_H 35 | 36 | /* Include the Mbed TLS configuration file, the way Mbed TLS does it 37 | * in each of its header files. */ 38 | #if !defined(MBEDTLS_CONFIG_FILE) 39 | #include "mbedtls/config.h" 40 | #else 41 | #include MBEDTLS_CONFIG_FILE 42 | #endif 43 | 44 | /* Translate between classic MBEDTLS_xxx feature symbols and PSA_xxx 45 | * feature symbols. */ 46 | #include "mbedtls/config_psa.h" 47 | 48 | /* PSA requires several types which C99 provides in stdint.h. */ 49 | #include 50 | 51 | #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ 52 | !defined(inline) && !defined(__cplusplus) 53 | #define inline __inline 54 | #endif 55 | 56 | /* Integral type representing a key handle. */ 57 | typedef uint16_t psa_key_handle_t; 58 | 59 | #if defined(MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER) 60 | 61 | /* Building for the PSA Crypto service on a PSA platform, a key owner is a PSA 62 | * partition identifier. 63 | * 64 | * The function psa_its_identifier_of_slot() in psa_crypto_storage.c that 65 | * translates a key identifier to a key storage file name assumes that 66 | * mbedtls_key_owner_id_t is an 32 bits integer. This function thus needs 67 | * reworking if mbedtls_key_owner_id_t is not defined as a 32 bits integer 68 | * here anymore. 69 | */ 70 | typedef int32_t mbedtls_key_owner_id_t; 71 | 72 | /** Compare two key owner identifiers. 73 | * 74 | * \param id1 First key owner identifier. 75 | * \param id2 Second key owner identifier. 76 | * 77 | * \return Non-zero if the two key owner identifiers are equal, zero otherwise. 78 | */ 79 | static inline int mbedtls_key_owner_id_equal( mbedtls_key_owner_id_t id1, 80 | mbedtls_key_owner_id_t id2 ) 81 | { 82 | return( id1 == id2 ); 83 | } 84 | 85 | #endif /* MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER */ 86 | 87 | #endif /* PSA_CRYPTO_PLATFORM_H */ 88 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/lib/mbedcrypto.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icew4y/whatsapp_protocol/d9c64dc854404c29eb28438246330de1bc564e13/whatsappcpp/3rd/mbedtls/lib/mbedcrypto.lib -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/lib/mbedtls.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icew4y/whatsapp_protocol/d9c64dc854404c29eb28438246330de1bc564e13/whatsappcpp/3rd/mbedtls/lib/mbedtls.lib -------------------------------------------------------------------------------- /whatsappcpp/3rd/mbedtls/lib/mbedx509.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icew4y/whatsapp_protocol/d9c64dc854404c29eb28438246330de1bc564e13/whatsappcpp/3rd/mbedtls/lib/mbedx509.lib -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/bin/openssl.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icew4y/whatsapp_protocol/d9c64dc854404c29eb28438246330de1bc564e13/whatsappcpp/3rd/openssl/bin/openssl.exe -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/cmac.h: -------------------------------------------------------------------------------- 1 | /* crypto/cmac/cmac.h */ 2 | /* 3 | * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 4 | * project. 5 | */ 6 | /* ==================================================================== 7 | * Copyright (c) 2010 The OpenSSL Project. All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in 18 | * the documentation and/or other materials provided with the 19 | * distribution. 20 | * 21 | * 3. All advertising materials mentioning features or use of this 22 | * software must display the following acknowledgment: 23 | * "This product includes software developed by the OpenSSL Project 24 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 25 | * 26 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 27 | * endorse or promote products derived from this software without 28 | * prior written permission. For written permission, please contact 29 | * licensing@OpenSSL.org. 30 | * 31 | * 5. Products derived from this software may not be called "OpenSSL" 32 | * nor may "OpenSSL" appear in their names without prior written 33 | * permission of the OpenSSL Project. 34 | * 35 | * 6. Redistributions of any form whatsoever must retain the following 36 | * acknowledgment: 37 | * "This product includes software developed by the OpenSSL Project 38 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 41 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 43 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 44 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 46 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 47 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 49 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 50 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51 | * OF THE POSSIBILITY OF SUCH DAMAGE. 52 | * ==================================================================== 53 | */ 54 | 55 | #ifndef HEADER_CMAC_H 56 | # define HEADER_CMAC_H 57 | 58 | #ifdef __cplusplus 59 | extern "C" { 60 | #endif 61 | 62 | # include 63 | 64 | /* Opaque */ 65 | typedef struct CMAC_CTX_st CMAC_CTX; 66 | 67 | CMAC_CTX *CMAC_CTX_new(void); 68 | void CMAC_CTX_cleanup(CMAC_CTX *ctx); 69 | void CMAC_CTX_free(CMAC_CTX *ctx); 70 | EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx); 71 | int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in); 72 | 73 | int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, 74 | const EVP_CIPHER *cipher, ENGINE *impl); 75 | int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); 76 | int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); 77 | int CMAC_resume(CMAC_CTX *ctx); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #endif 83 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/comp.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef HEADER_COMP_H 3 | # define HEADER_COMP_H 4 | 5 | # include 6 | 7 | # ifdef OPENSSL_NO_COMP 8 | # error COMP is disabled. 9 | # endif 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | typedef struct comp_ctx_st COMP_CTX; 16 | 17 | struct comp_method_st { 18 | int type; /* NID for compression library */ 19 | const char *name; /* A text string to identify the library */ 20 | int (*init) (COMP_CTX *ctx); 21 | void (*finish) (COMP_CTX *ctx); 22 | int (*compress) (COMP_CTX *ctx, 23 | unsigned char *out, unsigned int olen, 24 | unsigned char *in, unsigned int ilen); 25 | int (*expand) (COMP_CTX *ctx, 26 | unsigned char *out, unsigned int olen, 27 | unsigned char *in, unsigned int ilen); 28 | /* 29 | * The following two do NOTHING, but are kept for backward compatibility 30 | */ 31 | long (*ctrl) (void); 32 | long (*callback_ctrl) (void); 33 | }; 34 | 35 | struct comp_ctx_st { 36 | COMP_METHOD *meth; 37 | unsigned long compress_in; 38 | unsigned long compress_out; 39 | unsigned long expand_in; 40 | unsigned long expand_out; 41 | CRYPTO_EX_DATA ex_data; 42 | }; 43 | 44 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); 45 | void COMP_CTX_free(COMP_CTX *ctx); 46 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, 47 | unsigned char *in, int ilen); 48 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, 49 | unsigned char *in, int ilen); 50 | COMP_METHOD *COMP_rle(void); 51 | COMP_METHOD *COMP_zlib(void); 52 | void COMP_zlib_cleanup(void); 53 | 54 | # ifdef HEADER_BIO_H 55 | # ifdef ZLIB 56 | BIO_METHOD *BIO_f_zlib(void); 57 | # endif 58 | # endif 59 | 60 | /* BEGIN ERROR CODES */ 61 | /* 62 | * The following lines are auto generated by the script mkerr.pl. Any changes 63 | * made after this point may be overwritten when the script is next run. 64 | */ 65 | void ERR_load_COMP_strings(void); 66 | 67 | /* Error codes for the COMP functions. */ 68 | 69 | /* Function codes. */ 70 | # define COMP_F_BIO_ZLIB_FLUSH 99 71 | # define COMP_F_BIO_ZLIB_NEW 100 72 | # define COMP_F_BIO_ZLIB_READ 101 73 | # define COMP_F_BIO_ZLIB_WRITE 102 74 | 75 | /* Reason codes. */ 76 | # define COMP_R_ZLIB_DEFLATE_ERROR 99 77 | # define COMP_R_ZLIB_INFLATE_ERROR 100 78 | # define COMP_R_ZLIB_NOT_SUPPORTED 101 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #endif 84 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/conf_api.h: -------------------------------------------------------------------------------- 1 | /* conf_api.h */ 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 | * All rights reserved. 4 | * 5 | * This package is an SSL implementation written 6 | * by Eric Young (eay@cryptsoft.com). 7 | * The implementation was written so as to conform with Netscapes SSL. 8 | * 9 | * This library is free for commercial and non-commercial use as long as 10 | * the following conditions are aheared to. The following conditions 11 | * apply to all code found in this distribution, be it the RC4, RSA, 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 | * included with this distribution is covered by the same copyright terms 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 | * 16 | * Copyright remains Eric Young's, and as such any Copyright notices in 17 | * the code are not to be removed. 18 | * If this package is used in a product, Eric Young should be given attribution 19 | * as the author of the parts of the library used. 20 | * This can be in the form of a textual message at program startup or 21 | * in documentation (online or textual) provided with the package. 22 | * 23 | * Redistribution and use in source and binary forms, with or without 24 | * modification, are permitted provided that the following conditions 25 | * are met: 26 | * 1. Redistributions of source code must retain the copyright 27 | * notice, this list of conditions and the following disclaimer. 28 | * 2. Redistributions in binary form must reproduce the above copyright 29 | * notice, this list of conditions and the following disclaimer in the 30 | * documentation and/or other materials provided with the distribution. 31 | * 3. All advertising materials mentioning features or use of this software 32 | * must display the following acknowledgement: 33 | * "This product includes cryptographic software written by 34 | * Eric Young (eay@cryptsoft.com)" 35 | * The word 'cryptographic' can be left out if the rouines from the library 36 | * being used are not cryptographic related :-). 37 | * 4. If you include any Windows specific code (or a derivative thereof) from 38 | * the apps directory (application code) you must include an acknowledgement: 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 | * SUCH DAMAGE. 52 | * 53 | * The licence and distribution terms for any publically available version or 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be 55 | * copied and put under another distribution licence 56 | * [including the GNU Public Licence.] 57 | */ 58 | 59 | #ifndef HEADER_CONF_API_H 60 | # define HEADER_CONF_API_H 61 | 62 | # include 63 | # include 64 | 65 | #ifdef __cplusplus 66 | extern "C" { 67 | #endif 68 | 69 | /* Up until OpenSSL 0.9.5a, this was new_section */ 70 | CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); 71 | /* Up until OpenSSL 0.9.5a, this was get_section */ 72 | CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); 73 | /* Up until OpenSSL 0.9.5a, this was CONF_get_section */ 74 | STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, 75 | const char *section); 76 | 77 | int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); 78 | char *_CONF_get_string(const CONF *conf, const char *section, 79 | const char *name); 80 | long _CONF_get_number(const CONF *conf, const char *section, 81 | const char *name); 82 | 83 | int _CONF_new_data(CONF *conf); 84 | void _CONF_free_data(CONF *conf); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #endif 90 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/ebcdic.h: -------------------------------------------------------------------------------- 1 | /* crypto/ebcdic.h */ 2 | 3 | #ifndef HEADER_EBCDIC_H 4 | # define HEADER_EBCDIC_H 5 | 6 | # include 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | /* Avoid name clashes with other applications */ 13 | # define os_toascii _openssl_os_toascii 14 | # define os_toebcdic _openssl_os_toebcdic 15 | # define ebcdic2ascii _openssl_ebcdic2ascii 16 | # define ascii2ebcdic _openssl_ascii2ebcdic 17 | 18 | extern const unsigned char os_toascii[256]; 19 | extern const unsigned char os_toebcdic[256]; 20 | void *ebcdic2ascii(void *dest, const void *srce, size_t count); 21 | void *ascii2ebcdic(void *dest, const void *srce, size_t count); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | #endif 27 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/mdc2.h: -------------------------------------------------------------------------------- 1 | /* crypto/mdc2/mdc2.h */ 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 | * All rights reserved. 4 | * 5 | * This package is an SSL implementation written 6 | * by Eric Young (eay@cryptsoft.com). 7 | * The implementation was written so as to conform with Netscapes SSL. 8 | * 9 | * This library is free for commercial and non-commercial use as long as 10 | * the following conditions are aheared to. The following conditions 11 | * apply to all code found in this distribution, be it the RC4, RSA, 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 | * included with this distribution is covered by the same copyright terms 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 | * 16 | * Copyright remains Eric Young's, and as such any Copyright notices in 17 | * the code are not to be removed. 18 | * If this package is used in a product, Eric Young should be given attribution 19 | * as the author of the parts of the library used. 20 | * This can be in the form of a textual message at program startup or 21 | * in documentation (online or textual) provided with the package. 22 | * 23 | * Redistribution and use in source and binary forms, with or without 24 | * modification, are permitted provided that the following conditions 25 | * are met: 26 | * 1. Redistributions of source code must retain the copyright 27 | * notice, this list of conditions and the following disclaimer. 28 | * 2. Redistributions in binary form must reproduce the above copyright 29 | * notice, this list of conditions and the following disclaimer in the 30 | * documentation and/or other materials provided with the distribution. 31 | * 3. All advertising materials mentioning features or use of this software 32 | * must display the following acknowledgement: 33 | * "This product includes cryptographic software written by 34 | * Eric Young (eay@cryptsoft.com)" 35 | * The word 'cryptographic' can be left out if the rouines from the library 36 | * being used are not cryptographic related :-). 37 | * 4. If you include any Windows specific code (or a derivative thereof) from 38 | * the apps directory (application code) you must include an acknowledgement: 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 | * SUCH DAMAGE. 52 | * 53 | * The licence and distribution terms for any publically available version or 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be 55 | * copied and put under another distribution licence 56 | * [including the GNU Public Licence.] 57 | */ 58 | 59 | #ifndef HEADER_MDC2_H 60 | # define HEADER_MDC2_H 61 | 62 | # include 63 | 64 | #ifdef __cplusplus 65 | extern "C" { 66 | #endif 67 | 68 | # ifdef OPENSSL_NO_MDC2 69 | # error MDC2 is disabled. 70 | # endif 71 | 72 | # define MDC2_BLOCK 8 73 | # define MDC2_DIGEST_LENGTH 16 74 | 75 | typedef struct mdc2_ctx_st { 76 | unsigned int num; 77 | unsigned char data[MDC2_BLOCK]; 78 | DES_cblock h, hh; 79 | int pad_type; /* either 1 or 2, default 1 */ 80 | } MDC2_CTX; 81 | 82 | # ifdef OPENSSL_FIPS 83 | int private_MDC2_Init(MDC2_CTX *c); 84 | # endif 85 | int MDC2_Init(MDC2_CTX *c); 86 | int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len); 87 | int MDC2_Final(unsigned char *md, MDC2_CTX *c); 88 | unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md); 89 | 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/opensslv.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_OPENSSLV_H 2 | # define HEADER_OPENSSLV_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /*- 9 | * Numeric release version identifier: 10 | * MNNFFPPS: major minor fix patch status 11 | * The status nibble has one of the values 0 for development, 1 to e for betas 12 | * 1 to 14, and f for release. The patch level is exactly that. 13 | * For example: 14 | * 0.9.3-dev 0x00903000 15 | * 0.9.3-beta1 0x00903001 16 | * 0.9.3-beta2-dev 0x00903002 17 | * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) 18 | * 0.9.3 0x0090300f 19 | * 0.9.3a 0x0090301f 20 | * 0.9.4 0x0090400f 21 | * 1.2.3z 0x102031af 22 | * 23 | * For continuity reasons (because 0.9.5 is already out, and is coded 24 | * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level 25 | * part is slightly different, by setting the highest bit. This means 26 | * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start 27 | * with 0x0090600S... 28 | * 29 | * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) 30 | * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for 31 | * major minor fix final patch/beta) 32 | */ 33 | # define OPENSSL_VERSION_NUMBER 0x100020cfL 34 | # ifdef OPENSSL_FIPS 35 | # define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2l-fips 25 May 2017" 36 | # else 37 | # define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2l 25 May 2017" 38 | # endif 39 | # define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT 40 | 41 | /*- 42 | * The macros below are to be used for shared library (.so, .dll, ...) 43 | * versioning. That kind of versioning works a bit differently between 44 | * operating systems. The most usual scheme is to set a major and a minor 45 | * number, and have the runtime loader check that the major number is equal 46 | * to what it was at application link time, while the minor number has to 47 | * be greater or equal to what it was at application link time. With this 48 | * scheme, the version number is usually part of the file name, like this: 49 | * 50 | * libcrypto.so.0.9 51 | * 52 | * Some unixen also make a softlink with the major verson number only: 53 | * 54 | * libcrypto.so.0 55 | * 56 | * On Tru64 and IRIX 6.x it works a little bit differently. There, the 57 | * shared library version is stored in the file, and is actually a series 58 | * of versions, separated by colons. The rightmost version present in the 59 | * library when linking an application is stored in the application to be 60 | * matched at run time. When the application is run, a check is done to 61 | * see if the library version stored in the application matches any of the 62 | * versions in the version string of the library itself. 63 | * This version string can be constructed in any way, depending on what 64 | * kind of matching is desired. However, to implement the same scheme as 65 | * the one used in the other unixen, all compatible versions, from lowest 66 | * to highest, should be part of the string. Consecutive builds would 67 | * give the following versions strings: 68 | * 69 | * 3.0 70 | * 3.0:3.1 71 | * 3.0:3.1:3.2 72 | * 4.0 73 | * 4.0:4.1 74 | * 75 | * Notice how version 4 is completely incompatible with version, and 76 | * therefore give the breach you can see. 77 | * 78 | * There may be other schemes as well that I haven't yet discovered. 79 | * 80 | * So, here's the way it works here: first of all, the library version 81 | * number doesn't need at all to match the overall OpenSSL version. 82 | * However, it's nice and more understandable if it actually does. 83 | * The current library version is stored in the macro SHLIB_VERSION_NUMBER, 84 | * which is just a piece of text in the format "M.m.e" (Major, minor, edit). 85 | * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, 86 | * we need to keep a history of version numbers, which is done in the 87 | * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and 88 | * should only keep the versions that are binary compatible with the current. 89 | */ 90 | # define SHLIB_VERSION_HISTORY "" 91 | # define SHLIB_VERSION_NUMBER "1.0.0" 92 | 93 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | #endif /* HEADER_OPENSSLV_H */ 98 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/pem2.h: -------------------------------------------------------------------------------- 1 | /* ==================================================================== 2 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * 3. All advertising materials mentioning features or use of this 17 | * software must display the following acknowledgment: 18 | * "This product includes software developed by the OpenSSL Project 19 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 20 | * 21 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 22 | * endorse or promote products derived from this software without 23 | * prior written permission. For written permission, please contact 24 | * licensing@OpenSSL.org. 25 | * 26 | * 5. Products derived from this software may not be called "OpenSSL" 27 | * nor may "OpenSSL" appear in their names without prior written 28 | * permission of the OpenSSL Project. 29 | * 30 | * 6. Redistributions of any form whatsoever must retain the following 31 | * acknowledgment: 32 | * "This product includes software developed by the OpenSSL Project 33 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 34 | * 35 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 36 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 37 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 38 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 41 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 42 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 43 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 44 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 45 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 46 | * OF THE POSSIBILITY OF SUCH DAMAGE. 47 | * ==================================================================== 48 | * 49 | * This product includes cryptographic software written by Eric Young 50 | * (eay@cryptsoft.com). This product includes software written by Tim 51 | * Hudson (tjh@cryptsoft.com). 52 | * 53 | */ 54 | 55 | /* 56 | * This header only exists to break a circular dependency between pem and err 57 | * Ben 30 Jan 1999. 58 | */ 59 | 60 | #ifdef __cplusplus 61 | extern "C" { 62 | #endif 63 | 64 | #ifndef HEADER_PEM_H 65 | void ERR_load_PEM_strings(void); 66 | #endif 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/pqueue.h: -------------------------------------------------------------------------------- 1 | /* crypto/pqueue/pqueue.h */ 2 | /* 3 | * DTLS implementation written by Nagendra Modadugu 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. 5 | */ 6 | /* ==================================================================== 7 | * Copyright (c) 1999-2005 The OpenSSL Project. All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in 18 | * the documentation and/or other materials provided with the 19 | * distribution. 20 | * 21 | * 3. All advertising materials mentioning features or use of this 22 | * software must display the following acknowledgment: 23 | * "This product includes software developed by the OpenSSL Project 24 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 25 | * 26 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 27 | * endorse or promote products derived from this software without 28 | * prior written permission. For written permission, please contact 29 | * openssl-core@OpenSSL.org. 30 | * 31 | * 5. Products derived from this software may not be called "OpenSSL" 32 | * nor may "OpenSSL" appear in their names without prior written 33 | * permission of the OpenSSL Project. 34 | * 35 | * 6. Redistributions of any form whatsoever must retain the following 36 | * acknowledgment: 37 | * "This product includes software developed by the OpenSSL Project 38 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 41 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 43 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 44 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 46 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 47 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 49 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 50 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51 | * OF THE POSSIBILITY OF SUCH DAMAGE. 52 | * ==================================================================== 53 | * 54 | * This product includes cryptographic software written by Eric Young 55 | * (eay@cryptsoft.com). This product includes software written by Tim 56 | * Hudson (tjh@cryptsoft.com). 57 | * 58 | */ 59 | 60 | #ifndef HEADER_PQUEUE_H 61 | # define HEADER_PQUEUE_H 62 | 63 | # include 64 | # include 65 | # include 66 | 67 | #ifdef __cplusplus 68 | extern "C" { 69 | #endif 70 | typedef struct _pqueue *pqueue; 71 | 72 | typedef struct _pitem { 73 | unsigned char priority[8]; /* 64-bit value in big-endian encoding */ 74 | void *data; 75 | struct _pitem *next; 76 | } pitem; 77 | 78 | typedef struct _pitem *piterator; 79 | 80 | pitem *pitem_new(unsigned char *prio64be, void *data); 81 | void pitem_free(pitem *item); 82 | 83 | pqueue pqueue_new(void); 84 | void pqueue_free(pqueue pq); 85 | 86 | pitem *pqueue_insert(pqueue pq, pitem *item); 87 | pitem *pqueue_peek(pqueue pq); 88 | pitem *pqueue_pop(pqueue pq); 89 | pitem *pqueue_find(pqueue pq, unsigned char *prio64be); 90 | pitem *pqueue_iterator(pqueue pq); 91 | pitem *pqueue_next(piterator *iter); 92 | 93 | void pqueue_print(pqueue pq); 94 | int pqueue_size(pqueue pq); 95 | 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | #endif /* ! HEADER_PQUEUE_H */ 100 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/rc4.h: -------------------------------------------------------------------------------- 1 | /* crypto/rc4/rc4.h */ 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 3 | * All rights reserved. 4 | * 5 | * This package is an SSL implementation written 6 | * by Eric Young (eay@cryptsoft.com). 7 | * The implementation was written so as to conform with Netscapes SSL. 8 | * 9 | * This library is free for commercial and non-commercial use as long as 10 | * the following conditions are aheared to. The following conditions 11 | * apply to all code found in this distribution, be it the RC4, RSA, 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 | * included with this distribution is covered by the same copyright terms 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 | * 16 | * Copyright remains Eric Young's, and as such any Copyright notices in 17 | * the code are not to be removed. 18 | * If this package is used in a product, Eric Young should be given attribution 19 | * as the author of the parts of the library used. 20 | * This can be in the form of a textual message at program startup or 21 | * in documentation (online or textual) provided with the package. 22 | * 23 | * Redistribution and use in source and binary forms, with or without 24 | * modification, are permitted provided that the following conditions 25 | * are met: 26 | * 1. Redistributions of source code must retain the copyright 27 | * notice, this list of conditions and the following disclaimer. 28 | * 2. Redistributions in binary form must reproduce the above copyright 29 | * notice, this list of conditions and the following disclaimer in the 30 | * documentation and/or other materials provided with the distribution. 31 | * 3. All advertising materials mentioning features or use of this software 32 | * must display the following acknowledgement: 33 | * "This product includes cryptographic software written by 34 | * Eric Young (eay@cryptsoft.com)" 35 | * The word 'cryptographic' can be left out if the rouines from the library 36 | * being used are not cryptographic related :-). 37 | * 4. If you include any Windows specific code (or a derivative thereof) from 38 | * the apps directory (application code) you must include an acknowledgement: 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 | * SUCH DAMAGE. 52 | * 53 | * The licence and distribution terms for any publically available version or 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be 55 | * copied and put under another distribution licence 56 | * [including the GNU Public Licence.] 57 | */ 58 | 59 | #ifndef HEADER_RC4_H 60 | # define HEADER_RC4_H 61 | 62 | # include /* OPENSSL_NO_RC4, RC4_INT */ 63 | # ifdef OPENSSL_NO_RC4 64 | # error RC4 is disabled. 65 | # endif 66 | 67 | # include 68 | 69 | #ifdef __cplusplus 70 | extern "C" { 71 | #endif 72 | 73 | typedef struct rc4_key_st { 74 | RC4_INT x, y; 75 | RC4_INT data[256]; 76 | } RC4_KEY; 77 | 78 | const char *RC4_options(void); 79 | void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); 80 | void private_RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); 81 | void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, 82 | unsigned char *outdata); 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/ripemd.h: -------------------------------------------------------------------------------- 1 | /* crypto/ripemd/ripemd.h */ 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 | * All rights reserved. 4 | * 5 | * This package is an SSL implementation written 6 | * by Eric Young (eay@cryptsoft.com). 7 | * The implementation was written so as to conform with Netscapes SSL. 8 | * 9 | * This library is free for commercial and non-commercial use as long as 10 | * the following conditions are aheared to. The following conditions 11 | * apply to all code found in this distribution, be it the RC4, RSA, 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 | * included with this distribution is covered by the same copyright terms 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 | * 16 | * Copyright remains Eric Young's, and as such any Copyright notices in 17 | * the code are not to be removed. 18 | * If this package is used in a product, Eric Young should be given attribution 19 | * as the author of the parts of the library used. 20 | * This can be in the form of a textual message at program startup or 21 | * in documentation (online or textual) provided with the package. 22 | * 23 | * Redistribution and use in source and binary forms, with or without 24 | * modification, are permitted provided that the following conditions 25 | * are met: 26 | * 1. Redistributions of source code must retain the copyright 27 | * notice, this list of conditions and the following disclaimer. 28 | * 2. Redistributions in binary form must reproduce the above copyright 29 | * notice, this list of conditions and the following disclaimer in the 30 | * documentation and/or other materials provided with the distribution. 31 | * 3. All advertising materials mentioning features or use of this software 32 | * must display the following acknowledgement: 33 | * "This product includes cryptographic software written by 34 | * Eric Young (eay@cryptsoft.com)" 35 | * The word 'cryptographic' can be left out if the rouines from the library 36 | * being used are not cryptographic related :-). 37 | * 4. If you include any Windows specific code (or a derivative thereof) from 38 | * the apps directory (application code) you must include an acknowledgement: 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 | * SUCH DAMAGE. 52 | * 53 | * The licence and distribution terms for any publically available version or 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be 55 | * copied and put under another distribution licence 56 | * [including the GNU Public Licence.] 57 | */ 58 | 59 | #ifndef HEADER_RIPEMD_H 60 | # define HEADER_RIPEMD_H 61 | 62 | # include 63 | # include 64 | 65 | #ifdef __cplusplus 66 | extern "C" { 67 | #endif 68 | 69 | # ifdef OPENSSL_NO_RIPEMD 70 | # error RIPEMD is disabled. 71 | # endif 72 | 73 | # if defined(__LP32__) 74 | # define RIPEMD160_LONG unsigned long 75 | # elif defined(OPENSSL_SYS_CRAY) || defined(__ILP64__) 76 | # define RIPEMD160_LONG unsigned long 77 | # define RIPEMD160_LONG_LOG2 3 78 | # else 79 | # define RIPEMD160_LONG unsigned int 80 | # endif 81 | 82 | # define RIPEMD160_CBLOCK 64 83 | # define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) 84 | # define RIPEMD160_DIGEST_LENGTH 20 85 | 86 | typedef struct RIPEMD160state_st { 87 | RIPEMD160_LONG A, B, C, D, E; 88 | RIPEMD160_LONG Nl, Nh; 89 | RIPEMD160_LONG data[RIPEMD160_LBLOCK]; 90 | unsigned int num; 91 | } RIPEMD160_CTX; 92 | 93 | # ifdef OPENSSL_FIPS 94 | int private_RIPEMD160_Init(RIPEMD160_CTX *c); 95 | # endif 96 | int RIPEMD160_Init(RIPEMD160_CTX *c); 97 | int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); 98 | int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); 99 | unsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md); 100 | void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/ssl23.h: -------------------------------------------------------------------------------- 1 | /* ssl/ssl23.h */ 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3 | * All rights reserved. 4 | * 5 | * This package is an SSL implementation written 6 | * by Eric Young (eay@cryptsoft.com). 7 | * The implementation was written so as to conform with Netscapes SSL. 8 | * 9 | * This library is free for commercial and non-commercial use as long as 10 | * the following conditions are aheared to. The following conditions 11 | * apply to all code found in this distribution, be it the RC4, RSA, 12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 | * included with this distribution is covered by the same copyright terms 14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 | * 16 | * Copyright remains Eric Young's, and as such any Copyright notices in 17 | * the code are not to be removed. 18 | * If this package is used in a product, Eric Young should be given attribution 19 | * as the author of the parts of the library used. 20 | * This can be in the form of a textual message at program startup or 21 | * in documentation (online or textual) provided with the package. 22 | * 23 | * Redistribution and use in source and binary forms, with or without 24 | * modification, are permitted provided that the following conditions 25 | * are met: 26 | * 1. Redistributions of source code must retain the copyright 27 | * notice, this list of conditions and the following disclaimer. 28 | * 2. Redistributions in binary form must reproduce the above copyright 29 | * notice, this list of conditions and the following disclaimer in the 30 | * documentation and/or other materials provided with the distribution. 31 | * 3. All advertising materials mentioning features or use of this software 32 | * must display the following acknowledgement: 33 | * "This product includes cryptographic software written by 34 | * Eric Young (eay@cryptsoft.com)" 35 | * The word 'cryptographic' can be left out if the rouines from the library 36 | * being used are not cryptographic related :-). 37 | * 4. If you include any Windows specific code (or a derivative thereof) from 38 | * the apps directory (application code) you must include an acknowledgement: 39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 | * 41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 | * SUCH DAMAGE. 52 | * 53 | * The licence and distribution terms for any publically available version or 54 | * derivative of this code cannot be changed. i.e. this code cannot simply be 55 | * copied and put under another distribution licence 56 | * [including the GNU Public Licence.] 57 | */ 58 | 59 | #ifndef HEADER_SSL23_H 60 | # define HEADER_SSL23_H 61 | 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | /* 67 | * client 68 | */ 69 | /* write to server */ 70 | # define SSL23_ST_CW_CLNT_HELLO_A (0x210|SSL_ST_CONNECT) 71 | # define SSL23_ST_CW_CLNT_HELLO_B (0x211|SSL_ST_CONNECT) 72 | /* read from server */ 73 | # define SSL23_ST_CR_SRVR_HELLO_A (0x220|SSL_ST_CONNECT) 74 | # define SSL23_ST_CR_SRVR_HELLO_B (0x221|SSL_ST_CONNECT) 75 | 76 | /* server */ 77 | /* read from client */ 78 | # define SSL23_ST_SR_CLNT_HELLO_A (0x210|SSL_ST_ACCEPT) 79 | # define SSL23_ST_SR_CLNT_HELLO_B (0x211|SSL_ST_ACCEPT) 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | #endif 85 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/ui_compat.h: -------------------------------------------------------------------------------- 1 | /* crypto/ui/ui.h */ 2 | /* 3 | * Written by Richard Levitte (richard@levitte.org) for the OpenSSL project 4 | * 2001. 5 | */ 6 | /* ==================================================================== 7 | * Copyright (c) 2001 The OpenSSL Project. All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in 18 | * the documentation and/or other materials provided with the 19 | * distribution. 20 | * 21 | * 3. All advertising materials mentioning features or use of this 22 | * software must display the following acknowledgment: 23 | * "This product includes software developed by the OpenSSL Project 24 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 25 | * 26 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 27 | * endorse or promote products derived from this software without 28 | * prior written permission. For written permission, please contact 29 | * openssl-core@openssl.org. 30 | * 31 | * 5. Products derived from this software may not be called "OpenSSL" 32 | * nor may "OpenSSL" appear in their names without prior written 33 | * permission of the OpenSSL Project. 34 | * 35 | * 6. Redistributions of any form whatsoever must retain the following 36 | * acknowledgment: 37 | * "This product includes software developed by the OpenSSL Project 38 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 39 | * 40 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 41 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 43 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 44 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 46 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 47 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 49 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 50 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51 | * OF THE POSSIBILITY OF SUCH DAMAGE. 52 | * ==================================================================== 53 | * 54 | * This product includes cryptographic software written by Eric Young 55 | * (eay@cryptsoft.com). This product includes software written by Tim 56 | * Hudson (tjh@cryptsoft.com). 57 | * 58 | */ 59 | 60 | #ifndef HEADER_UI_COMPAT_H 61 | # define HEADER_UI_COMPAT_H 62 | 63 | # include 64 | # include 65 | 66 | #ifdef __cplusplus 67 | extern "C" { 68 | #endif 69 | 70 | /* 71 | * The following functions were previously part of the DES section, and are 72 | * provided here for backward compatibility reasons. 73 | */ 74 | 75 | # define des_read_pw_string(b,l,p,v) \ 76 | _ossl_old_des_read_pw_string((b),(l),(p),(v)) 77 | # define des_read_pw(b,bf,s,p,v) \ 78 | _ossl_old_des_read_pw((b),(bf),(s),(p),(v)) 79 | 80 | int _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, 81 | int verify); 82 | int _ossl_old_des_read_pw(char *buf, char *buff, int size, const char *prompt, 83 | int verify); 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | #endif 89 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/include/openssl/whrlpool.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_WHRLPOOL_H 2 | # define HEADER_WHRLPOOL_H 3 | 4 | # include 5 | # include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | # define WHIRLPOOL_DIGEST_LENGTH (512/8) 12 | # define WHIRLPOOL_BBLOCK 512 13 | # define WHIRLPOOL_COUNTER (256/8) 14 | 15 | typedef struct { 16 | union { 17 | unsigned char c[WHIRLPOOL_DIGEST_LENGTH]; 18 | /* double q is here to ensure 64-bit alignment */ 19 | double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)]; 20 | } H; 21 | unsigned char data[WHIRLPOOL_BBLOCK / 8]; 22 | unsigned int bitoff; 23 | size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)]; 24 | } WHIRLPOOL_CTX; 25 | 26 | # ifndef OPENSSL_NO_WHIRLPOOL 27 | # ifdef OPENSSL_FIPS 28 | int private_WHIRLPOOL_Init(WHIRLPOOL_CTX *c); 29 | # endif 30 | int WHIRLPOOL_Init(WHIRLPOOL_CTX *c); 31 | int WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes); 32 | void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits); 33 | int WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c); 34 | unsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md); 35 | # endif 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/lib/libeay32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icew4y/whatsapp_protocol/d9c64dc854404c29eb28438246330de1bc564e13/whatsappcpp/3rd/openssl/lib/libeay32.lib -------------------------------------------------------------------------------- /whatsappcpp/3rd/openssl/lib/ssleay32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icew4y/whatsapp_protocol/d9c64dc854404c29eb28438246330de1bc564e13/whatsappcpp/3rd/openssl/lib/ssleay32.lib -------------------------------------------------------------------------------- /whatsappcpp/whatsappcpp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30711.63 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "whatsappcpp", "whatsappcpp\whatsappcpp.vcxproj", "{3E2F6198-A766-4B9C-B58C-1100A72E18B9}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {3E2F6198-A766-4B9C-B58C-1100A72E18B9}.Debug|x64.ActiveCfg = Debug|x64 17 | {3E2F6198-A766-4B9C-B58C-1100A72E18B9}.Debug|x64.Build.0 = Debug|x64 18 | {3E2F6198-A766-4B9C-B58C-1100A72E18B9}.Debug|x86.ActiveCfg = Debug|Win32 19 | {3E2F6198-A766-4B9C-B58C-1100A72E18B9}.Debug|x86.Build.0 = Debug|Win32 20 | {3E2F6198-A766-4B9C-B58C-1100A72E18B9}.Release|x64.ActiveCfg = Release|x64 21 | {3E2F6198-A766-4B9C-B58C-1100A72E18B9}.Release|x64.Build.0 = Release|x64 22 | {3E2F6198-A766-4B9C-B58C-1100A72E18B9}.Release|x86.ActiveCfg = Release|Win32 23 | {3E2F6198-A766-4B9C-B58C-1100A72E18B9}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {BBD4F480-110D-4F19-80C8-D04EE1460372} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /whatsappcpp/whatsappcpp/curve/curve.cpp: -------------------------------------------------------------------------------- 1 | #include "curve.h" 2 | #include 3 | #include 4 | #include "curve25519-donna.h" 5 | 6 | 7 | int test_random_generator(uint8_t* data, size_t len) 8 | { 9 | if (RAND_bytes(data, len)) { 10 | return 0; 11 | } 12 | else { 13 | return -1; 14 | } 15 | } 16 | 17 | int curve_generate_private_key(ec_private_key** private_key) 18 | { 19 | int result = 0; 20 | ec_private_key* key = 0; 21 | 22 | 23 | key = (ec_private_key *)malloc(sizeof(ec_private_key)); 24 | if (!key) { 25 | result = -1; 26 | goto complete; 27 | } 28 | 29 | 30 | result = test_random_generator(key->data, DJB_KEY_LEN); 31 | if (result < 0) { 32 | goto complete; 33 | } 34 | 35 | key->data[0] &= 248; 36 | key->data[31] &= 127; 37 | key->data[31] |= 64; 38 | 39 | complete: 40 | if (result < 0) { 41 | if (key) { 42 | free(key); 43 | } 44 | } 45 | else { 46 | *private_key = key; 47 | } 48 | 49 | return result; 50 | } 51 | 52 | int curve_generate_public_key(ec_public_key** public_key, const ec_private_key* private_key) 53 | { 54 | static const uint8_t basepoint[32] = { 9 }; 55 | int result = 0; 56 | 57 | ec_public_key* key = (ec_public_key*)malloc(sizeof(ec_public_key)); 58 | if (!key) { 59 | return -1; 60 | } 61 | 62 | 63 | result = curve25519_donna(key->data, private_key->data, basepoint); 64 | 65 | if (result == 0) { 66 | *public_key = key; 67 | return 0; 68 | } 69 | else { 70 | if (key) { 71 | free(key); 72 | } 73 | return -1; 74 | } 75 | } 76 | 77 | int ec_key_pair_create(ec_key_pair** key_pair, ec_public_key* public_key, ec_private_key* private_key) 78 | { 79 | ec_key_pair* result = (ec_key_pair*)malloc(sizeof(ec_key_pair)); 80 | if (!result) { 81 | return -1; 82 | } 83 | 84 | result->public_key = public_key; 85 | result->private_key = private_key; 86 | *key_pair = result; 87 | 88 | return 0; 89 | } 90 | 91 | int curve_generate_key_pair(ec_key_pair** key_pair) 92 | { 93 | int result = 0; 94 | ec_key_pair* pair_result = 0; 95 | ec_private_key* key_private = 0; 96 | ec_public_key* key_public = 0; 97 | 98 | 99 | result = curve_generate_private_key(&key_private); 100 | if (result < 0) { 101 | goto complete; 102 | } 103 | 104 | result = curve_generate_public_key(&key_public, key_private); 105 | if (result < 0) { 106 | goto complete; 107 | } 108 | 109 | result = ec_key_pair_create(&pair_result, key_public, key_private); 110 | if (result < 0) { 111 | goto complete; 112 | } 113 | 114 | *key_pair = pair_result; 115 | 116 | complete: 117 | 118 | return result; 119 | } 120 | 121 | 122 | 123 | int curve_calculate_agreement(uint8_t** shared_key_data, const ec_public_key* public_key, const ec_private_key* private_key) 124 | { 125 | uint8_t* key = 0; 126 | int result = 0; 127 | 128 | if (!public_key || !private_key) { 129 | return -1; 130 | } 131 | 132 | key = (uint8_t*)malloc(DJB_KEY_LEN); 133 | if (!key) { 134 | return -1; 135 | } 136 | 137 | result = curve25519_donna(key, private_key->data, public_key->data); 138 | 139 | if (result == 0) { 140 | *shared_key_data = key; 141 | return DJB_KEY_LEN; 142 | } 143 | else { 144 | if (key) { 145 | free(key); 146 | } 147 | return -1; 148 | } 149 | } -------------------------------------------------------------------------------- /whatsappcpp/whatsappcpp/curve/curve.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #define DJB_KEY_LEN 32 6 | 7 | 8 | struct ec_public_key 9 | { 10 | uint8_t data[DJB_KEY_LEN]; 11 | }; 12 | 13 | struct ec_private_key 14 | { 15 | uint8_t data[DJB_KEY_LEN]; 16 | }; 17 | 18 | struct ec_key_pair 19 | { 20 | ec_public_key* public_key; 21 | ec_private_key* private_key; 22 | }; 23 | 24 | 25 | int curve_generate_private_key(ec_private_key** private_key); 26 | int curve_generate_public_key(ec_public_key** public_key, const ec_private_key* private_key); 27 | int ec_key_pair_create(ec_key_pair** key_pair, ec_public_key* public_key, ec_private_key* private_key); 28 | int curve_generate_key_pair(ec_key_pair** key_pair); 29 | int curve_calculate_agreement(uint8_t** shared_key_data, const ec_public_key* public_key, const ec_private_key* private_key); -------------------------------------------------------------------------------- /whatsappcpp/whatsappcpp/curve/curve25519-donna.h: -------------------------------------------------------------------------------- 1 | #ifndef CURVE25519_DONNA_H 2 | #define CURVE25519_DONNA_H 3 | 4 | int curve25519_donna(uint8_t *, const uint8_t *, const uint8_t *); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /whatsappcpp/whatsappcpp/main.cpp: -------------------------------------------------------------------------------- 1 |  2 | #include 3 | #include "whatsapp/whatsapp.h" 4 | int main() 5 | { 6 | //Check if the phone number already exists 7 | test1(); 8 | } 9 | -------------------------------------------------------------------------------- /whatsappcpp/whatsappcpp/whatsapp/whatsapp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void test1(); -------------------------------------------------------------------------------- /whatsappcpp/whatsappcpp/whatsappcpp.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {422da49b-e735-4efa-a538-6548d76f4354} 18 | 19 | 20 | {8cea95be-0d66-46ad-8e86-a416f35e200d} 21 | 22 | 23 | 24 | 25 | curve 26 | 27 | 28 | curve 29 | 30 | 31 | 源文件 32 | 33 | 34 | whatsapp 35 | 36 | 37 | 38 | 39 | curve 40 | 41 | 42 | curve 43 | 44 | 45 | whatsapp 46 | 47 | 48 | -------------------------------------------------------------------------------- /whatsappcpp/whatsappcpp/whatsappcpp.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | --------------------------------------------------------------------------------