├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── help-and-question.md └── stale.yml ├── LICENSE ├── README.md ├── docs └── index.rst ├── examples ├── Basic │ └── Basic.ino ├── Ethernet │ ├── ESP32 │ │ ├── ESP32.ino │ │ └── modified_LAN8720_board_images │ │ │ ├── lan8720_modified_board.png │ │ │ └── lan8720_modified_schematic.png │ ├── ESP8266 │ │ └── ESP8266.ino │ └── Pico │ │ └── Pico.ino ├── GSM │ └── GSM.ino └── Service_Account_File │ ├── Service_Account_File.ino │ └── data │ └── gtsr1.pem ├── keywords.txt ├── library.json ├── library.properties ├── media └── images │ ├── ESP32-PSRAM.png │ ├── ESP8266_VM.png │ ├── GC_Create_SA.png │ ├── GC_Create_SA2.png │ ├── GC_Create_SA3.png │ ├── GC_Create_SA4.png │ ├── GC_Create_SA5.png │ ├── GC_Create_SA6.png │ ├── GC_Create_SA7.png │ ├── GC_Create_SA8.png │ ├── GC_Create_SA9.png │ └── GC_Select_Project.png └── src ├── ESP_Signer.cpp ├── ESP_Signer.h ├── ESP_Signer_Const.h ├── ESP_Signer_ESP8266_Supports.h ├── ESP_Signer_Error.h ├── ESP_Signer_Helper.h ├── ESP_Signer_Network.h ├── ESP_Signer_SD_Helper.h ├── FS_Config.h ├── auth ├── GAuth_OAuth2_Client.cpp └── GAuth_OAuth2_Client.h ├── client ├── GAuth_TCP_Client.h ├── SSLClient │ ├── Custom_ESP_SSLClient_FS.h │ ├── ESP_SSLClient.h │ ├── ESP_SSLClient_Const.h │ ├── ESP_SSLClient_FS.h │ ├── bssl │ │ ├── aes_big_cbcdec.c │ │ ├── aes_big_cbcenc.c │ │ ├── aes_big_ctr.c │ │ ├── aes_big_ctrcbc.c │ │ ├── aes_big_dec.c │ │ ├── aes_big_enc.c │ │ ├── aes_common.c │ │ ├── aes_ct.c │ │ ├── aes_ct64.c │ │ ├── aes_ct64_cbcdec.c │ │ ├── aes_ct64_cbcenc.c │ │ ├── aes_ct64_ctr.c │ │ ├── aes_ct64_ctrcbc.c │ │ ├── aes_ct64_dec.c │ │ ├── aes_ct64_enc.c │ │ ├── aes_ct_cbcdec.c │ │ ├── aes_ct_cbcenc.c │ │ ├── aes_ct_ctr.c │ │ ├── aes_ct_ctrcbc.c │ │ ├── aes_ct_dec.c │ │ ├── aes_ct_enc.c │ │ ├── aes_pwr8.c │ │ ├── aes_pwr8_cbcdec.c │ │ ├── aes_pwr8_cbcenc.c │ │ ├── aes_pwr8_ctr.c │ │ ├── aes_pwr8_ctrcbc.c │ │ ├── aes_small_cbcdec.c │ │ ├── aes_small_cbcenc.c │ │ ├── aes_small_ctr.c │ │ ├── aes_small_ctrcbc.c │ │ ├── aes_small_dec.c │ │ ├── aes_small_enc.c │ │ ├── aes_x86ni.c │ │ ├── aes_x86ni_cbcdec.c │ │ ├── aes_x86ni_cbcenc.c │ │ ├── aes_x86ni_ctr.c │ │ ├── aes_x86ni_ctrcbc.c │ │ ├── aesctr_drbg.c │ │ ├── asn1.t0 │ │ ├── asn1enc.c │ │ ├── bearssl.h │ │ ├── bearssl_aead.h │ │ ├── bearssl_block.h │ │ ├── bearssl_ec.h │ │ ├── bearssl_hash.h │ │ ├── bearssl_hmac.h │ │ ├── bearssl_kdf.h │ │ ├── bearssl_pem.h │ │ ├── bearssl_prf.h │ │ ├── bearssl_rand.h │ │ ├── bearssl_rsa.h │ │ ├── bearssl_ssl.h │ │ ├── bearssl_x509.h │ │ ├── ccm.c │ │ ├── ccopy.c │ │ ├── chacha20_ct.c │ │ ├── chacha20_sse2.c │ │ ├── config.h │ │ ├── dec16be.c │ │ ├── dec16le.c │ │ ├── dec32be.c │ │ ├── dec32le.c │ │ ├── dec64be.c │ │ ├── dec64le.c │ │ ├── des_ct.c │ │ ├── des_ct_cbcdec.c │ │ ├── des_ct_cbcenc.c │ │ ├── des_support.c │ │ ├── des_tab.c │ │ ├── des_tab_cbcdec.c │ │ ├── des_tab_cbcenc.c │ │ ├── dig_oid.c │ │ ├── dig_size.c │ │ ├── eax.c │ │ ├── ec_all_m15.c │ │ ├── ec_all_m31.c │ │ ├── ec_c25519_i15.c │ │ ├── ec_c25519_i31.c │ │ ├── ec_c25519_m15.c │ │ ├── ec_c25519_m31.c │ │ ├── ec_c25519_m62.c │ │ ├── ec_c25519_m64.c │ │ ├── ec_curve25519.c │ │ ├── ec_default.c │ │ ├── ec_keygen.c │ │ ├── ec_p256_m15.c │ │ ├── ec_p256_m31.c │ │ ├── ec_p256_m62.c │ │ ├── ec_p256_m64.c │ │ ├── ec_prime_i15.c │ │ ├── ec_prime_i31.c │ │ ├── ec_pubkey.c │ │ ├── ec_secp256r1.c │ │ ├── ec_secp384r1.c │ │ ├── ec_secp521r1.c │ │ ├── ecdsa_atr.c │ │ ├── ecdsa_default_sign_asn1.c │ │ ├── ecdsa_default_sign_raw.c │ │ ├── ecdsa_default_vrfy_asn1.c │ │ ├── ecdsa_default_vrfy_raw.c │ │ ├── ecdsa_i15_bits.c │ │ ├── ecdsa_i15_sign_asn1.c │ │ ├── ecdsa_i15_sign_raw.c │ │ ├── ecdsa_i15_vrfy_asn1.c │ │ ├── ecdsa_i15_vrfy_raw.c │ │ ├── ecdsa_i31_bits.c │ │ ├── ecdsa_i31_sign_asn1.c │ │ ├── ecdsa_i31_sign_raw.c │ │ ├── ecdsa_i31_vrfy_asn1.c │ │ ├── ecdsa_i31_vrfy_raw.c │ │ ├── ecdsa_rta.c │ │ ├── enc16be.c │ │ ├── enc16le.c │ │ ├── enc32be.c │ │ ├── enc32le.c │ │ ├── enc64be.c │ │ ├── enc64le.c │ │ ├── encode_ec_pk8der.c │ │ ├── encode_ec_rawder.c │ │ ├── encode_rsa_pk8der.c │ │ ├── encode_rsa_rawder.c │ │ ├── gcm.c │ │ ├── ghash_ctmul.c │ │ ├── ghash_ctmul32.c │ │ ├── ghash_ctmul64.c │ │ ├── ghash_pclmul.c │ │ ├── ghash_pwr8.c │ │ ├── hkdf.c │ │ ├── hmac.c │ │ ├── hmac_ct.c │ │ ├── hmac_drbg.c │ │ ├── i15_add.c │ │ ├── i15_bitlen.c │ │ ├── i15_decmod.c │ │ ├── i15_decode.c │ │ ├── i15_decred.c │ │ ├── i15_encode.c │ │ ├── i15_fmont.c │ │ ├── i15_iszero.c │ │ ├── i15_moddiv.c │ │ ├── i15_modpow.c │ │ ├── i15_modpow2.c │ │ ├── i15_montmul.c │ │ ├── i15_mulacc.c │ │ ├── i15_muladd.c │ │ ├── i15_ninv15.c │ │ ├── i15_reduce.c │ │ ├── i15_rshift.c │ │ ├── i15_sub.c │ │ ├── i15_tmont.c │ │ ├── i31_add.c │ │ ├── i31_bitlen.c │ │ ├── i31_decmod.c │ │ ├── i31_decode.c │ │ ├── i31_decred.c │ │ ├── i31_encode.c │ │ ├── i31_fmont.c │ │ ├── i31_iszero.c │ │ ├── i31_moddiv.c │ │ ├── i31_modpow.c │ │ ├── i31_modpow2.c │ │ ├── i31_montmul.c │ │ ├── i31_mulacc.c │ │ ├── i31_muladd.c │ │ ├── i31_ninv31.c │ │ ├── i31_reduce.c │ │ ├── i31_rshift.c │ │ ├── i31_sub.c │ │ ├── i31_tmont.c │ │ ├── i32_add.c │ │ ├── i32_bitlen.c │ │ ├── i32_decmod.c │ │ ├── i32_decode.c │ │ ├── i32_decred.c │ │ ├── i32_div32.c │ │ ├── i32_encode.c │ │ ├── i32_fmont.c │ │ ├── i32_iszero.c │ │ ├── i32_modpow.c │ │ ├── i32_montmul.c │ │ ├── i32_mulacc.c │ │ ├── i32_muladd.c │ │ ├── i32_ninv32.c │ │ ├── i32_reduce.c │ │ ├── i32_sub.c │ │ ├── i32_tmont.c │ │ ├── i62_modpow2.c │ │ ├── inner.h │ │ ├── md5.c │ │ ├── md5sha1.c │ │ ├── mgf1.c │ │ ├── multihash.c │ │ ├── pemdec.c │ │ ├── pemdec.t0 │ │ ├── pemenc.c │ │ ├── pkey_decoder.c │ │ ├── poly1305_ctmul.c │ │ ├── poly1305_ctmul32.c │ │ ├── poly1305_ctmulq.c │ │ ├── poly1305_i15.c │ │ ├── prf.c │ │ ├── prf_md5sha1.c │ │ ├── prf_sha256.c │ │ ├── prf_sha384.c │ │ ├── rsa_default_keygen.c │ │ ├── rsa_default_modulus.c │ │ ├── rsa_default_oaep_decrypt.c │ │ ├── rsa_default_oaep_encrypt.c │ │ ├── rsa_default_pkcs1_sign.c │ │ ├── rsa_default_pkcs1_vrfy.c │ │ ├── rsa_default_priv.c │ │ ├── rsa_default_privexp.c │ │ ├── rsa_default_pss_sign.c │ │ ├── rsa_default_pss_vrfy.c │ │ ├── rsa_default_pub.c │ │ ├── rsa_default_pubexp.c │ │ ├── rsa_i15_keygen.c │ │ ├── rsa_i15_modulus.c │ │ ├── rsa_i15_oaep_decrypt.c │ │ ├── rsa_i15_oaep_encrypt.c │ │ ├── rsa_i15_pkcs1_sign.c │ │ ├── rsa_i15_pkcs1_vrfy.c │ │ ├── rsa_i15_priv.c │ │ ├── rsa_i15_privexp.c │ │ ├── rsa_i15_pss_sign.c │ │ ├── rsa_i15_pss_vrfy.c │ │ ├── rsa_i15_pub.c │ │ ├── rsa_i15_pubexp.c │ │ ├── rsa_i31_keygen.c │ │ ├── rsa_i31_keygen_inner.c │ │ ├── rsa_i31_modulus.c │ │ ├── rsa_i31_oaep_decrypt.c │ │ ├── rsa_i31_oaep_encrypt.c │ │ ├── rsa_i31_pkcs1_sign.c │ │ ├── rsa_i31_pkcs1_vrfy.c │ │ ├── rsa_i31_priv.c │ │ ├── rsa_i31_privexp.c │ │ ├── rsa_i31_pss_sign.c │ │ ├── rsa_i31_pss_vrfy.c │ │ ├── rsa_i31_pub.c │ │ ├── rsa_i31_pubexp.c │ │ ├── rsa_i32_oaep_decrypt.c │ │ ├── rsa_i32_oaep_encrypt.c │ │ ├── rsa_i32_pkcs1_sign.c │ │ ├── rsa_i32_pkcs1_vrfy.c │ │ ├── rsa_i32_priv.c │ │ ├── rsa_i32_pss_sign.c │ │ ├── rsa_i32_pss_vrfy.c │ │ ├── rsa_i32_pub.c │ │ ├── rsa_i62_keygen.c │ │ ├── rsa_i62_oaep_decrypt.c │ │ ├── rsa_i62_oaep_encrypt.c │ │ ├── rsa_i62_pkcs1_sign.c │ │ ├── rsa_i62_pkcs1_vrfy.c │ │ ├── rsa_i62_priv.c │ │ ├── rsa_i62_pss_sign.c │ │ ├── rsa_i62_pss_vrfy.c │ │ ├── rsa_i62_pub.c │ │ ├── rsa_oaep_pad.c │ │ ├── rsa_oaep_unpad.c │ │ ├── rsa_pkcs1_sig_pad.c │ │ ├── rsa_pkcs1_sig_unpad.c │ │ ├── rsa_pss_sig_pad.c │ │ ├── rsa_pss_sig_unpad.c │ │ ├── rsa_ssl_decrypt.c │ │ ├── settings.c │ │ ├── sha1.c │ │ ├── sha2big.c │ │ ├── sha2small.c │ │ ├── shake.c │ │ ├── skey_decoder.c │ │ ├── skey_decoder.t0 │ │ ├── ssl_ccert_single_ec.c │ │ ├── ssl_ccert_single_rsa.c │ │ ├── ssl_client.c │ │ ├── ssl_client_default_rsapub.c │ │ ├── ssl_client_full.c │ │ ├── ssl_engine.c │ │ ├── ssl_engine_default_aescbc.c │ │ ├── ssl_engine_default_aesccm.c │ │ ├── ssl_engine_default_aesgcm.c │ │ ├── ssl_engine_default_chapol.c │ │ ├── ssl_engine_default_descbc.c │ │ ├── ssl_engine_default_ec.c │ │ ├── ssl_engine_default_ecdsa.c │ │ ├── ssl_engine_default_rsavrfy.c │ │ ├── ssl_hashes.c │ │ ├── ssl_hs_client.c │ │ ├── ssl_hs_client.t0 │ │ ├── ssl_hs_common.t0 │ │ ├── ssl_hs_server.c │ │ ├── ssl_hs_server.t0 │ │ ├── ssl_io.c │ │ ├── ssl_keyexport.c │ │ ├── ssl_lru.c │ │ ├── ssl_rec_cbc.c │ │ ├── ssl_rec_ccm.c │ │ ├── ssl_rec_chapol.c │ │ ├── ssl_rec_gcm.c │ │ ├── ssl_scert_single_ec.c │ │ ├── ssl_scert_single_rsa.c │ │ ├── ssl_server.c │ │ ├── ssl_server_full_ec.c │ │ ├── ssl_server_full_rsa.c │ │ ├── ssl_server_mine2c.c │ │ ├── ssl_server_mine2g.c │ │ ├── ssl_server_minf2c.c │ │ ├── ssl_server_minf2g.c │ │ ├── ssl_server_minr2g.c │ │ ├── ssl_server_minu2g.c │ │ ├── ssl_server_minv2g.c │ │ ├── sysrng.c │ │ ├── x509_decoder.c │ │ ├── x509_decoder.t0 │ │ ├── x509_knownkey.c │ │ ├── x509_minimal.c │ │ ├── x509_minimal.t0 │ │ └── x509_minimal_full.c │ └── client │ │ ├── BSSL_CertStore.cpp │ │ ├── BSSL_CertStore.h │ │ ├── BSSL_Helper.cpp │ │ ├── BSSL_Helper.h │ │ ├── BSSL_SSL_Client.cpp │ │ ├── BSSL_SSL_Client.h │ │ ├── BSSL_TCP_Client.cpp │ │ └── BSSL_TCP_Client.h └── WiFiClientImpl.h ├── json ├── FirebaseJson.cpp ├── FirebaseJson.h ├── MB_JSON │ ├── MB_JSON.c │ └── MB_JSON.h ├── MB_List.h ├── MB_String.h └── extras │ └── print │ ├── fb_json_print.c │ └── fb_json_print.h └── mbfs ├── MB_FS.h ├── MB_FS_Interfaces.h └── MB_MCU.h /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: 13 | - https://www.paypal.me/mobizt 14 | - https://www.buymeacoffee.com/Mobizt -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: BUG 5 | labels: bug, good first issue, invalid, wontfix 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **IDE and its version:** 27 | - Arduino, PlatformIO 28 | - Version [e.g. 1.8.9] 29 | 30 | **ESP8266 Arduino Core SDK version** 31 | - Version [e.g. 2.5.1] 32 | 33 | **Additional context** 34 | Add any other context about the problem here. 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: ENHANCEMENT 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/help-and-question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Help and Question 3 | about: Usage problems and how to (should read the readme or try the examples first) 4 | title: HELP 5 | labels: help wanted, question 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 20 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 5 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - security 9 | # Label to use when marking an issue as stale 10 | staleLabel: wontfix 11 | # Comment to post when marking an issue as stale. Set to `false` to disable 12 | markComment: > 13 | This issue has been automatically marked as stale because it has not had 14 | recent activity. It will be closed if no further activity occurs. Thank you 15 | for your contributions. 16 | # Comment to post when closing a stale issue. Set to `false` to disable 17 | closeComment: false 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 mobizt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/docs/index.rst -------------------------------------------------------------------------------- /examples/Ethernet/ESP32/modified_LAN8720_board_images/lan8720_modified_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/examples/Ethernet/ESP32/modified_LAN8720_board_images/lan8720_modified_board.png -------------------------------------------------------------------------------- /examples/Ethernet/ESP32/modified_LAN8720_board_images/lan8720_modified_schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/examples/Ethernet/ESP32/modified_LAN8720_board_images/lan8720_modified_schematic.png -------------------------------------------------------------------------------- /examples/Service_Account_File/data/gtsr1.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIFVzCCAz+gAwIBAgINAgPlk28xsBNJiGuiFzANBgkqhkiG9w0BAQwFADBHMQsw 3 | CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU 4 | MBIGA1UEAxMLR1RTIFJvb3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw 5 | MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp 6 | Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIiMA0GCSqGSIb3DQEBAQUA 7 | A4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx9vaMf/vo 8 | 27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7w 9 | Cl7raKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjw 10 | TcLCeoiKu7rPWRnWr4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0Pfybl 11 | qAj+lug8aJRT7oM6iCsVlgmy4HqMLnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaH 12 | szVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly4cpk9+aCEI3oncKKiPo4Zor8 13 | Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr06zqkUspzBmk 14 | MiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92 15 | wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70p 16 | aDPvOmbsB4om3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrN 17 | VjzRlwW5y0vtOUucxD/SVRNuJLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQID 18 | AQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E 19 | FgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEMBQADggIBAJ+qQibb 20 | C5u+/x6Wki4+omVKapi6Ist9wTrYggoGxval3sBOh2Z5ofmmWJyq+bXmYOfg6LEe 21 | QkEzCzc9zolwFcq1JKjPa7XSQCGYzyI0zzvFIoTgxQ6KfF2I5DUkzps+GlQebtuy 22 | h6f88/qBVRRiClmpIgUxPoLW7ttXNLwzldMXG+gnoot7TiYaelpkttGsN/H9oPM4 23 | 7HLwEXWdyzRSjeZ2axfG34arJ45JK3VmgRAhpuo+9K4l/3wV3s6MJT/KYnAK9y8J 24 | ZgfIPxz88NtFMN9iiMG1D53Dn0reWVlHxYciNuaCp+0KueIHoI17eko8cdLiA6Ef 25 | MgfdG+RCzgwARWGAtQsgWSl4vflVy2PFPEz0tv/bal8xa5meLMFrUKTX5hgUvYU/ 26 | Z6tGn6D/Qqc6f1zLXbBwHSs09dR2CQzreExZBfMzQsNhFRAbd03OIozUhfJFfbdT 27 | 6u9AWpQKXCBfTkBdYiJ23//OYb2MI3jSNwLgjt7RETeJ9r/tSQdirpLsQBqvFAnZ 28 | 0E6yove+7u7Y/9waLd64NnHi/Hm3lCXRSHNboTXns5lndcEZOitHTtNCjv0xyBZm 29 | 2tIMPNuzjsmhDYAPexZ3FL//2wmUspO8IFgV6dtxQ/PeEMMA3KgqlbbC1j+Qa3bb 30 | bP6MvPJwNQzcmRk13NfIRmPVNnGuV/u3gm3c 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /keywords.txt: -------------------------------------------------------------------------------- 1 | ######################################### 2 | # Syntax Coloring Map ESP Signer 3 | ######################################### 4 | 5 | ######################################### 6 | # Classes (KEYWORD1) 7 | ######################################### 8 | 9 | Signer KEYWORD1 10 | 11 | ############################################### 12 | # Methods and Functions (KEYWORD2) 13 | ############################################### 14 | 15 | begin KEYWORD2 16 | end KEYWORD2 17 | tokenReady KEYWORD2 18 | accessToken KEYWORD2 19 | getTokenType KEYWORD2 20 | getTokenStatus KEYWORD2 21 | getTokenError KEYWORD2 22 | sdBegin KEYWORD2 23 | getExpiredTimestamp KEYWORD2 24 | getCurrentTimestamp KEYWORD2 25 | getFreeHeap KEYWORD2 26 | refreshToken KEYWORD2 27 | setSystemTime KEYWORD2 28 | sdBegin KEYWORD2 29 | sdMMCBegin KEYWORD2 30 | setExternalClient KEYWORD2 31 | setUDPClient KEYWORD2 32 | 33 | 34 | ###################################### 35 | # Struct (LITERAL1) 36 | ####################################### 37 | 38 | SignerConfig LITERAL1 39 | TokenInfo LITERAL1 -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ESP Signer", 3 | "version": "1.4.2", 4 | "keywords": "communication, REST, esp32, esp8266, raspberrypi, arduino", 5 | "description": "The Google OAuth2.0 access token generation for Arduino devices. This library also supports external networking devices wirh Arduino Clients e.g. WiFiClient, EthernetClient, and GSMClient.", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/mobizt/ESP-Signer.git" 9 | }, 10 | "authors": [{ 11 | "name": "Mobizt", 12 | "email": "k_suwatchai@hotmail.com" 13 | }], 14 | "frameworks": "arduino", 15 | "platforms": "espressif32, espressif8266, atmelsam, ststm32, teensy, rp2040, renesas-ra" 16 | } 17 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=ESP Signer 2 | 3 | version=1.4.2 4 | 5 | author=Mobizt 6 | 7 | maintainer=Mobizt 8 | 9 | sentence=The Google OAuth2.0 access token generation for Arduino devices. 10 | 11 | paragraph=This library also supports external networking devices wirh Arduino Clients e.g. WiFiClient, EthernetClient, and GSMClient. 12 | 13 | category=Communication 14 | 15 | url=https://github.com/mobizt/ESP-Signer 16 | 17 | architectures=esp8266, esp32, sam,samd, stm32, STM32F1, STM32F4, teensy, mbed_nano, mbed_rp2040, rp2040, mbed_nano, mbed_portenta, mbed_nicla, mbed_opta, mbed_giga, renesas_portenta, renesas_uno 18 | -------------------------------------------------------------------------------- /media/images/ESP32-PSRAM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/ESP32-PSRAM.png -------------------------------------------------------------------------------- /media/images/ESP8266_VM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/ESP8266_VM.png -------------------------------------------------------------------------------- /media/images/GC_Create_SA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/GC_Create_SA.png -------------------------------------------------------------------------------- /media/images/GC_Create_SA2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/GC_Create_SA2.png -------------------------------------------------------------------------------- /media/images/GC_Create_SA3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/GC_Create_SA3.png -------------------------------------------------------------------------------- /media/images/GC_Create_SA4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/GC_Create_SA4.png -------------------------------------------------------------------------------- /media/images/GC_Create_SA5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/GC_Create_SA5.png -------------------------------------------------------------------------------- /media/images/GC_Create_SA6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/GC_Create_SA6.png -------------------------------------------------------------------------------- /media/images/GC_Create_SA7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/GC_Create_SA7.png -------------------------------------------------------------------------------- /media/images/GC_Create_SA8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/GC_Create_SA8.png -------------------------------------------------------------------------------- /media/images/GC_Create_SA9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/GC_Create_SA9.png -------------------------------------------------------------------------------- /media/images/GC_Select_Project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/ESP-Signer/bc080dbcdaee6f59c017644db203f85f8da3bb8d/media/images/GC_Select_Project.png -------------------------------------------------------------------------------- /src/ESP_Signer_ESP8266_Supports.h: -------------------------------------------------------------------------------- 1 | #ifndef ESP_SIGNER_ESP8266_SUPPORTS_h 2 | #define ESP_SIGNER_ESP8266_SUPPORTS_h 3 | #include 4 | #include "mbfs/MB_MCU.h" 5 | #if defined(ESP8266) || defined(MB_ARDUINO_PICO) 6 | 7 | #include 8 | 9 | //__GNUC__ 10 | //__GNUC_MINOR__ 11 | //__GNUC_PATCHLEVEL__ 12 | 13 | #ifdef __GNUC__ 14 | #if __GNUC__ > 4 || __GNUC__ == 10 15 | #if defined(ARDUINO_ESP8266_GIT_VER) 16 | #if ARDUINO_ESP8266_GIT_VER > 0 17 | #define ESP8266_CORE_SDK_V3_X_X 18 | #endif 19 | #endif 20 | #endif 21 | #endif 22 | 23 | #if defined __has_include 24 | 25 | #if __has_include() 26 | #include 27 | #endif 28 | 29 | #if __has_include()&& defined(ENABLE_ESP8266_ENC28J60_ETH) 30 | #define INC_ENC28J60_LWIP 31 | #include 32 | #endif 33 | 34 | #if __has_include() && defined(ENABLE_ESP8266_W5100_ETH) 35 | #define INC_W5100_LWIP 36 | #include 37 | #endif 38 | 39 | #if __has_include()&& defined(ENABLE_ESP8266_W5500_ETH) 40 | #define INC_W5500_LWIP 41 | #include 42 | #endif 43 | 44 | #if defined(MB_ARDUINO_PICO) 45 | 46 | #endif 47 | 48 | #endif 49 | 50 | #endif 51 | 52 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/Custom_ESP_SSLClient_FS.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CUSTOM_ESP_SSLCLIENT_FS_H 3 | #define CUSTOM_ESP_SSLCLIENT_FS_H 4 | 5 | #include "../../FS_Config.h" 6 | 7 | #if defined(ESP_SIGNER_USE_PSRAM) 8 | #if !defined(ESP_SSLCLIENT_USE_PSRAM) 9 | #define ESP_SSLCLIENT_USE_PSRAM 10 | #endif 11 | #else 12 | #undef ESP_SSLCLIENT_USE_PSRAM 13 | #endif 14 | 15 | #undef ESP_SSLCLIENT_ENABLE_DEBUG 16 | #undef ESP_SSLCLIENT_ENABLE_SSL_ERROR_STRING 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/client/SSLClient/ESP_SSLClient_FS.h: -------------------------------------------------------------------------------- 1 | #ifndef ESP_SSLClient_FS_H 2 | #define ESP_SSLClient_FS_H 3 | 4 | #if (defined(ESP8266) || defined(ARDUINO_ARCH_RP2040)) && !defined(ARDUINO_NANO_RP2040_CONNECT) 5 | // for ESP8266 and Raspberry Pi Pico (RP2040) only except for Arduino Nano RP2040 Connect 6 | #define USE_EMBED_SSL_ENGINE 7 | #else 8 | #define USE_LIB_SSL_ENGINE 9 | #endif 10 | 11 | #pragma once 12 | 13 | // for enable debugging 14 | #define ESP_SSLCLIENT_ENABLE_DEBUG 15 | 16 | /** Call ssl_client.setDebugLevel(x) to set the debug 17 | * esp_ssl_debug_none = 0 18 | * esp_ssl_debug_error = 1 19 | * esp_ssl_debug_warn = 2 20 | * esp_ssl_debug_info = 3 21 | * esp_ssl_debug_dump = 4 22 | */ 23 | 24 | // for debug port 25 | #define ESP_SSLCLIENT_DEBUG_PORT Serial 26 | 27 | // for SSL Error String 28 | #define ESP_SSLCLIENT_ENABLE_SSL_ERROR_STRING 29 | 30 | // for Filesystem support that required for CertStore 31 | #define ESP_SSLCLIENT_USE_FILESYSTEM 32 | 33 | // For external SRAM (PSRAM) support 34 | #define ESP_SSLCLIENT_USE_PSRAM 35 | 36 | #if defined __has_include 37 | #if __has_include() 38 | #include "Custom_ESP_SSLClient_FS.h" 39 | #endif 40 | #endif 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ccopy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_ccopy(uint32_t ctl, void *dst, const void *src, size_t len) 33 | { 34 | unsigned char *d; 35 | const unsigned char *s; 36 | 37 | d = dst; 38 | s = src; 39 | while (len -- > 0) { 40 | uint32_t x, y; 41 | 42 | x = *s ++; 43 | y = *d; 44 | *d = MUX(ctl, x, y); 45 | d ++; 46 | } 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec16be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec16be(uint16_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec16be(buf); 39 | buf += 2; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec16le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec16le(uint16_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec16le(buf); 39 | buf += 2; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec32be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec32be(uint32_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec32be(buf); 39 | buf += 4; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec32le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec32le(uint32_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec32le(buf); 39 | buf += 4; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec64be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec64be(uint64_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec64be(buf); 39 | buf += 8; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec64le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec64le(uint64_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec64le(buf); 39 | buf += 8; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dig_size.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | size_t 32 | br_digest_size_by_ID(int digest_id) 33 | { 34 | switch (digest_id) { 35 | case br_md5sha1_ID: 36 | return br_md5_SIZE + br_sha1_SIZE; 37 | case br_md5_ID: 38 | return br_md5_SIZE; 39 | case br_sha1_ID: 40 | return br_sha1_SIZE; 41 | case br_sha224_ID: 42 | return br_sha224_SIZE; 43 | case br_sha256_ID: 44 | return br_sha256_SIZE; 45 | case br_sha384_ID: 46 | return br_sha384_SIZE; 47 | case br_sha512_ID: 48 | return br_sha512_SIZE; 49 | default: 50 | /* abort(); */ 51 | return 0; 52 | } 53 | } 54 | 55 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ec_curve25519.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | static const unsigned char GEN[] = { 31 | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 35 | }; 36 | 37 | static const unsigned char ORDER[] = { 38 | 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 39 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 40 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 41 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF 42 | }; 43 | 44 | /* see inner.h */ 45 | const br_ec_curve_def br_curve25519 = { 46 | BR_EC_curve25519, 47 | ORDER, sizeof ORDER, 48 | GEN, sizeof GEN 49 | }; 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ec_default.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ec.h */ 31 | const br_ec_impl * 32 | br_ec_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_ec_all_m15; 36 | #else 37 | return &br_ec_all_m31; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ec_secp256r1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | static const unsigned char P256_N[] = { 31 | 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 32 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 33 | 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84, 34 | 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51 35 | }; 36 | 37 | static const unsigned char P256_G[] = { 38 | 0x04, 0x6B, 0x17, 0xD1, 0xF2, 0xE1, 0x2C, 0x42, 39 | 0x47, 0xF8, 0xBC, 0xE6, 0xE5, 0x63, 0xA4, 0x40, 40 | 0xF2, 0x77, 0x03, 0x7D, 0x81, 0x2D, 0xEB, 0x33, 41 | 0xA0, 0xF4, 0xA1, 0x39, 0x45, 0xD8, 0x98, 0xC2, 42 | 0x96, 0x4F, 0xE3, 0x42, 0xE2, 0xFE, 0x1A, 0x7F, 43 | 0x9B, 0x8E, 0xE7, 0xEB, 0x4A, 0x7C, 0x0F, 0x9E, 44 | 0x16, 0x2B, 0xCE, 0x33, 0x57, 0x6B, 0x31, 0x5E, 45 | 0xCE, 0xCB, 0xB6, 0x40, 0x68, 0x37, 0xBF, 0x51, 46 | 0xF5 47 | }; 48 | 49 | /* see inner.h */ 50 | const br_ec_curve_def br_secp256r1 = { 51 | BR_EC_secp256r1, 52 | P256_N, sizeof P256_N, 53 | P256_G, sizeof P256_G 54 | }; 55 | 56 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_default_sign_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ec.h */ 31 | br_ecdsa_sign 32 | br_ecdsa_sign_asn1_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_ecdsa_i15_sign_asn1; 36 | #else 37 | return &br_ecdsa_i31_sign_asn1; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_default_sign_raw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ec.h */ 31 | br_ecdsa_sign 32 | br_ecdsa_sign_raw_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_ecdsa_i15_sign_raw; 36 | #else 37 | return &br_ecdsa_i31_sign_raw; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_default_vrfy_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ec.h */ 31 | br_ecdsa_vrfy 32 | br_ecdsa_vrfy_asn1_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_ecdsa_i15_vrfy_asn1; 36 | #else 37 | return &br_ecdsa_i31_vrfy_asn1; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_default_vrfy_raw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ec.h */ 31 | br_ecdsa_vrfy 32 | br_ecdsa_vrfy_raw_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_ecdsa_i15_vrfy_raw; 36 | #else 37 | return &br_ecdsa_i31_vrfy_raw; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i15_bits.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_ecdsa_i15_bits2int(uint16_t *x, 33 | const void *src, size_t len, uint32_t ebitlen) 34 | { 35 | uint32_t bitlen, hbitlen; 36 | int sc; 37 | 38 | bitlen = ebitlen - (ebitlen >> 4); 39 | hbitlen = (uint32_t)len << 3; 40 | if (hbitlen > bitlen) { 41 | len = (bitlen + 7) >> 3; 42 | sc = (int)((hbitlen - bitlen) & 7); 43 | } else { 44 | sc = 0; 45 | } 46 | br_i15_zero(x, ebitlen); 47 | br_i15_decode(x, src, len); 48 | br_i15_rshift(x, sc); 49 | x[0] = ebitlen; 50 | } 51 | 52 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i15_sign_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #define ORDER_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 31 | 32 | /* see bearssl_ec.h */ 33 | size_t 34 | br_ecdsa_i15_sign_asn1(const br_ec_impl *impl, 35 | const br_hash_class *hf, const void *hash_value, 36 | const br_ec_private_key *sk, void *sig) 37 | { 38 | unsigned char rsig[(ORDER_LEN << 1) + 12]; 39 | size_t sig_len; 40 | 41 | sig_len = br_ecdsa_i15_sign_raw(impl, hf, hash_value, sk, rsig); 42 | if (sig_len == 0) { 43 | return 0; 44 | } 45 | sig_len = br_ecdsa_raw_to_asn1(rsig, sig_len); 46 | memcpy(sig, rsig, sig_len); 47 | return sig_len; 48 | } 49 | 50 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i15_vrfy_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | #include "../ESP_SSLClient_FS.h" 27 | #if defined(USE_LIB_SSL_ENGINE) 28 | 29 | #include "inner.h" 30 | 31 | #define FIELD_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 32 | 33 | /* see bearssl_ec.h */ 34 | uint32_t 35 | br_ecdsa_i15_vrfy_asn1(const br_ec_impl *impl, 36 | const void *hash, size_t hash_len, 37 | const br_ec_public_key *pk, 38 | const void *sig, size_t sig_len) 39 | { 40 | /* 41 | * We use a double-sized buffer because a malformed ASN.1 signature 42 | * may trigger a size expansion when converting to "raw" format. 43 | */ 44 | unsigned char rsig[(FIELD_LEN << 2) + 24]; 45 | 46 | if (sig_len > ((sizeof rsig) >> 1)) { 47 | return 0; 48 | } 49 | memcpy(rsig, sig, sig_len); 50 | sig_len = br_ecdsa_asn1_to_raw(rsig, sig_len); 51 | return br_ecdsa_i15_vrfy_raw(impl, hash, hash_len, pk, rsig, sig_len); 52 | } 53 | 54 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i31_bits.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | #include "../ESP_SSLClient_FS.h" 27 | #if defined(USE_LIB_SSL_ENGINE) 28 | 29 | #include "inner.h" 30 | 31 | /* see inner.h */ 32 | void 33 | br_ecdsa_i31_bits2int(uint32_t *x, 34 | const void *src, size_t len, uint32_t ebitlen) 35 | { 36 | uint32_t bitlen, hbitlen; 37 | int sc; 38 | 39 | bitlen = ebitlen - (ebitlen >> 5); 40 | hbitlen = (uint32_t)len << 3; 41 | if (hbitlen > bitlen) { 42 | len = (bitlen + 7) >> 3; 43 | sc = (int)((hbitlen - bitlen) & 7); 44 | } else { 45 | sc = 0; 46 | } 47 | br_i31_zero(x, ebitlen); 48 | br_i31_decode(x, src, len); 49 | br_i31_rshift(x, sc); 50 | x[0] = ebitlen; 51 | } 52 | 53 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i31_sign_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | #include "../ESP_SSLClient_FS.h" 27 | #if defined(USE_LIB_SSL_ENGINE) 28 | 29 | #include "inner.h" 30 | 31 | #define ORDER_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 32 | 33 | /* see bearssl_ec.h */ 34 | size_t 35 | br_ecdsa_i31_sign_asn1(const br_ec_impl *impl, 36 | const br_hash_class *hf, const void *hash_value, 37 | const br_ec_private_key *sk, void *sig) 38 | { 39 | unsigned char rsig[(ORDER_LEN << 1) + 12]; 40 | size_t sig_len; 41 | 42 | sig_len = br_ecdsa_i31_sign_raw(impl, hf, hash_value, sk, rsig); 43 | if (sig_len == 0) { 44 | return 0; 45 | } 46 | sig_len = br_ecdsa_raw_to_asn1(rsig, sig_len); 47 | memcpy(sig, rsig, sig_len); 48 | return sig_len; 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i31_vrfy_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | #include "../ESP_SSLClient_FS.h" 27 | #if defined(USE_LIB_SSL_ENGINE) 28 | 29 | #include "inner.h" 30 | 31 | #define FIELD_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 32 | 33 | /* see bearssl_ec.h */ 34 | uint32_t 35 | br_ecdsa_i31_vrfy_asn1(const br_ec_impl *impl, 36 | const void *hash, size_t hash_len, 37 | const br_ec_public_key *pk, 38 | const void *sig, size_t sig_len) 39 | { 40 | /* 41 | * We use a double-sized buffer because a malformed ASN.1 signature 42 | * may trigger a size expansion when converting to "raw" format. 43 | */ 44 | unsigned char rsig[(FIELD_LEN << 2) + 24]; 45 | 46 | if (sig_len > ((sizeof rsig) >> 1)) { 47 | return 0; 48 | } 49 | memcpy(rsig, sig, sig_len); 50 | sig_len = br_ecdsa_asn1_to_raw(rsig, sig_len); 51 | return br_ecdsa_i31_vrfy_raw(impl, hash, hash_len, pk, rsig, sig_len); 52 | } 53 | 54 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc16be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc16be(void *dst, const uint16_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc16be(buf, *v ++); 39 | buf += 2; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc16le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc16le(void *dst, const uint16_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc16le(buf, *v ++); 39 | buf += 2; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc32be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc32be(void *dst, const uint32_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc32be(buf, *v ++); 39 | buf += 4; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc32le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc32le(void *dst, const uint32_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc32le(buf, *v ++); 39 | buf += 4; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc64be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc64be(void *dst, const uint64_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc64be(buf, *v ++); 39 | buf += 8; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc64le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc64le(void *dst, const uint64_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc64le(buf, *v ++); 39 | buf += 8; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_add.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | #include "../ESP_SSLClient_FS.h" 27 | #if defined(USE_LIB_SSL_ENGINE) 28 | 29 | #include "inner.h" 30 | 31 | /* see inner.h */ 32 | uint32_t 33 | br_i15_add(uint16_t *a, const uint16_t *b, uint32_t ctl) 34 | { 35 | uint32_t cc; 36 | size_t u, m; 37 | 38 | cc = 0; 39 | m = (a[0] + 31) >> 4; 40 | for (u = 1; u < m; u ++) { 41 | uint32_t aw, bw, naw; 42 | 43 | aw = a[u]; 44 | bw = b[u]; 45 | naw = aw + bw + cc; 46 | cc = naw >> 15; 47 | a[u] = MUX(ctl, naw & 0x7FFF, aw); 48 | } 49 | return cc; 50 | } 51 | 52 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_bitlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i15_bit_length(uint16_t *x, size_t xlen) 33 | { 34 | uint32_t tw, twk; 35 | 36 | tw = 0; 37 | twk = 0; 38 | while (xlen -- > 0) { 39 | uint32_t w, c; 40 | 41 | c = EQ(tw, 0); 42 | w = x[xlen]; 43 | tw = MUX(c, w, tw); 44 | twk = MUX(c, (uint32_t)xlen, twk); 45 | } 46 | return (twk << 4) + BIT_LENGTH(tw); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_decode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_decode(uint16_t *x, const void *src, size_t len) 33 | { 34 | const unsigned char *buf; 35 | size_t v; 36 | uint32_t acc; 37 | int acc_len; 38 | 39 | buf = src; 40 | v = 1; 41 | acc = 0; 42 | acc_len = 0; 43 | while (len -- > 0) { 44 | uint32_t b; 45 | 46 | b = buf[len]; 47 | acc |= (b << acc_len); 48 | acc_len += 8; 49 | if (acc_len >= 15) { 50 | x[v ++] = acc & 0x7FFF; 51 | acc_len -= 15; 52 | acc >>= 15; 53 | } 54 | } 55 | if (acc_len != 0) { 56 | x[v ++] = acc; 57 | } 58 | x[0] = br_i15_bit_length(x + 1, v - 1); 59 | } 60 | 61 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_encode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_encode(void *dst, size_t len, const uint16_t *x) 33 | { 34 | unsigned char *buf; 35 | size_t u, xlen; 36 | uint32_t acc; 37 | int acc_len; 38 | 39 | xlen = (x[0] + 15) >> 4; 40 | if (xlen == 0) { 41 | memset(dst, 0, len); 42 | return; 43 | } 44 | u = 1; 45 | acc = 0; 46 | acc_len = 0; 47 | buf = dst; 48 | while (len -- > 0) { 49 | if (acc_len < 8) { 50 | if (u <= xlen) { 51 | acc += (uint32_t)x[u ++] << acc_len; 52 | } 53 | acc_len += 15; 54 | } 55 | buf[len] = (unsigned char)acc; 56 | acc >>= 8; 57 | acc_len -= 8; 58 | } 59 | } 60 | 61 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_fmont.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_from_monty(uint16_t *x, const uint16_t *m, uint16_t m0i) 33 | { 34 | size_t len, u, v; 35 | 36 | len = (m[0] + 15) >> 4; 37 | for (u = 0; u < len; u ++) { 38 | uint32_t f, cc; 39 | 40 | f = MUL15(x[1], m0i) & 0x7FFF; 41 | cc = 0; 42 | for (v = 0; v < len; v ++) { 43 | uint32_t z; 44 | 45 | z = (uint32_t)x[v + 1] + MUL15(f, m[v + 1]) + cc; 46 | cc = z >> 15; 47 | if (v != 0) { 48 | x[v] = z & 0x7FFF; 49 | } 50 | } 51 | x[len] = cc; 52 | } 53 | 54 | /* 55 | * We may have to do an extra subtraction, but only if the 56 | * value in x[] is indeed greater than or equal to that of m[], 57 | * which is why we must do two calls (first call computes the 58 | * carry, second call performs the subtraction only if the carry 59 | * is 0). 60 | */ 61 | br_i15_sub(x, m, NOT(br_i15_sub(x, m, 0))); 62 | } 63 | 64 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_iszero.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i15_iszero(const uint16_t *x) 33 | { 34 | uint32_t z; 35 | size_t u; 36 | 37 | z = 0; 38 | for (u = (x[0] + 15) >> 4; u > 0; u --) { 39 | z |= x[u]; 40 | } 41 | return ~(z | -z) >> 31; 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_modpow.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_modpow(uint16_t *x, 33 | const unsigned char *e, size_t elen, 34 | const uint16_t *m, uint16_t m0i, uint16_t *t1, uint16_t *t2) 35 | { 36 | size_t mlen; 37 | unsigned k; 38 | 39 | mlen = ((m[0] + 31) >> 4) * sizeof m[0]; 40 | memcpy(t1, x, mlen); 41 | br_i15_to_monty(t1, m); 42 | br_i15_zero(x, m[0]); 43 | x[1] = 1; 44 | for (k = 0; k < ((unsigned)elen << 3); k ++) { 45 | uint32_t ctl; 46 | 47 | ctl = (e[elen - 1 - (k >> 3)] >> (k & 7)) & 1; 48 | br_i15_montymul(t2, x, t1, m, m0i); 49 | CCOPY(ctl, x, t2, mlen); 50 | br_i15_montymul(t2, t1, t1, m, m0i); 51 | memcpy(t1, t2, mlen); 52 | } 53 | } 54 | 55 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_mulacc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_mulacc(uint16_t *d, const uint16_t *a, const uint16_t *b) 33 | { 34 | size_t alen, blen, u; 35 | unsigned dl, dh; 36 | 37 | alen = (a[0] + 15) >> 4; 38 | blen = (b[0] + 15) >> 4; 39 | 40 | /* 41 | * Announced bit length of d[] will be the sum of the announced 42 | * bit lengths of a[] and b[]; but the lengths are encoded. 43 | */ 44 | dl = (a[0] & 15) + (b[0] & 15); 45 | dh = (a[0] >> 4) + (b[0] >> 4); 46 | d[0] = (dh << 4) + dl + (~(uint32_t)(dl - 15) >> 31); 47 | 48 | for (u = 0; u < blen; u ++) { 49 | uint32_t f; 50 | size_t v; 51 | uint32_t cc; 52 | 53 | f = b[1 + u]; 54 | cc = 0; 55 | for (v = 0; v < alen; v ++) { 56 | uint32_t z; 57 | 58 | z = (uint32_t)d[1 + u + v] + MUL15(f, a[1 + v]) + cc; 59 | cc = z >> 15; 60 | d[1 + u + v] = z & 0x7FFF; 61 | } 62 | d[1 + u + alen] = cc; 63 | } 64 | } 65 | 66 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_ninv15.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint16_t 32 | br_i15_ninv15(uint16_t x) 33 | { 34 | uint32_t y; 35 | 36 | y = 2 - x; 37 | y = MUL15(y, 2 - MUL15(x, y)); 38 | y = MUL15(y, 2 - MUL15(x, y)); 39 | y = MUL15(y, 2 - MUL15(x, y)); 40 | return MUX(x & 1, -y, 0) & 0x7FFF; 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_rshift.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_rshift(uint16_t *x, int count) 33 | { 34 | size_t u, len; 35 | unsigned r; 36 | 37 | len = (x[0] + 15) >> 4; 38 | if (len == 0) { 39 | return; 40 | } 41 | r = x[1] >> count; 42 | for (u = 2; u <= len; u ++) { 43 | unsigned w; 44 | 45 | w = x[u]; 46 | x[u - 1] = ((w << (15 - count)) | r) & 0x7FFF; 47 | r = w >> count; 48 | } 49 | x[len] = r; 50 | } 51 | 52 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_sub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i15_sub(uint16_t *a, const uint16_t *b, uint32_t ctl) 33 | { 34 | uint32_t cc; 35 | size_t u, m; 36 | 37 | cc = 0; 38 | m = (a[0] + 31) >> 4; 39 | for (u = 1; u < m; u ++) { 40 | uint32_t aw, bw, naw; 41 | 42 | aw = a[u]; 43 | bw = b[u]; 44 | naw = aw - bw - cc; 45 | cc = naw >> 31; 46 | a[u] = MUX(ctl, naw & 0x7FFF, aw); 47 | } 48 | return cc; 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_tmont.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_to_monty(uint16_t *x, const uint16_t *m) 33 | { 34 | unsigned k; 35 | 36 | for (k = (m[0] + 15) >> 4; k > 0; k --) { 37 | br_i15_muladd_small(x, 0, m); 38 | } 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_add.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i31_add(uint32_t *a, const uint32_t *b, uint32_t ctl) 33 | { 34 | uint32_t cc; 35 | size_t u, m; 36 | 37 | cc = 0; 38 | m = (a[0] + 63) >> 5; 39 | for (u = 1; u < m; u ++) { 40 | uint32_t aw, bw, naw; 41 | 42 | aw = a[u]; 43 | bw = b[u]; 44 | naw = aw + bw + cc; 45 | cc = naw >> 31; 46 | a[u] = MUX(ctl, naw & (uint32_t)0x7FFFFFFF, aw); 47 | } 48 | return cc; 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_bitlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i31_bit_length(uint32_t *x, size_t xlen) 33 | { 34 | uint32_t tw, twk; 35 | 36 | tw = 0; 37 | twk = 0; 38 | while (xlen -- > 0) { 39 | uint32_t w, c; 40 | 41 | c = EQ(tw, 0); 42 | w = x[xlen]; 43 | tw = MUX(c, w, tw); 44 | twk = MUX(c, (uint32_t)xlen, twk); 45 | } 46 | return (twk << 5) + BIT_LENGTH(tw); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_decode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i31_decode(uint32_t *x, const void *src, size_t len) 33 | { 34 | const unsigned char *buf; 35 | size_t u, v; 36 | uint32_t acc; 37 | int acc_len; 38 | 39 | buf = src; 40 | u = len; 41 | v = 1; 42 | acc = 0; 43 | acc_len = 0; 44 | while (u -- > 0) { 45 | uint32_t b; 46 | 47 | b = buf[u]; 48 | acc |= (b << acc_len); 49 | acc_len += 8; 50 | if (acc_len >= 31) { 51 | x[v ++] = acc & (uint32_t)0x7FFFFFFF; 52 | acc_len -= 31; 53 | acc = b >> (8 - acc_len); 54 | } 55 | } 56 | if (acc_len != 0) { 57 | x[v ++] = acc; 58 | } 59 | x[0] = br_i31_bit_length(x + 1, v - 1); 60 | } 61 | 62 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_fmont.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i31_from_monty(uint32_t *x, const uint32_t *m, uint32_t m0i) 33 | { 34 | size_t len, u, v; 35 | 36 | len = (m[0] + 31) >> 5; 37 | for (u = 0; u < len; u ++) { 38 | uint32_t f; 39 | uint64_t cc; 40 | 41 | f = MUL31_lo(x[1], m0i); 42 | cc = 0; 43 | for (v = 0; v < len; v ++) { 44 | uint64_t z; 45 | 46 | z = (uint64_t)x[v + 1] + MUL31(f, m[v + 1]) + cc; 47 | cc = z >> 31; 48 | if (v != 0) { 49 | x[v] = (uint32_t)z & 0x7FFFFFFF; 50 | } 51 | } 52 | x[len] = (uint32_t)cc; 53 | } 54 | 55 | /* 56 | * We may have to do an extra subtraction, but only if the 57 | * value in x[] is indeed greater than or equal to that of m[], 58 | * which is why we must do two calls (first call computes the 59 | * carry, second call performs the subtraction only if the carry 60 | * is 0). 61 | */ 62 | br_i31_sub(x, m, NOT(br_i31_sub(x, m, 0))); 63 | } 64 | 65 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_iszero.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i31_iszero(const uint32_t *x) 33 | { 34 | uint32_t z; 35 | size_t u; 36 | 37 | z = 0; 38 | for (u = (x[0] + 31) >> 5; u > 0; u --) { 39 | z |= x[u]; 40 | } 41 | return ~(z | -z) >> 31; 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_ninv31.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i31_ninv31(uint32_t x) 33 | { 34 | uint32_t y; 35 | 36 | y = 2 - x; 37 | y *= 2 - y * x; 38 | y *= 2 - y * x; 39 | y *= 2 - y * x; 40 | y *= 2 - y * x; 41 | return MUX(x & 1, -y, 0) & 0x7FFFFFFF; 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_rshift.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i31_rshift(uint32_t *x, int count) 33 | { 34 | size_t u, len; 35 | uint32_t r; 36 | 37 | len = (x[0] + 31) >> 5; 38 | if (len == 0) { 39 | return; 40 | } 41 | r = x[1] >> count; 42 | for (u = 2; u <= len; u ++) { 43 | uint32_t w; 44 | 45 | w = x[u]; 46 | x[u - 1] = ((w << (31 - count)) | r) & 0x7FFFFFFF; 47 | r = w >> count; 48 | } 49 | x[len] = r; 50 | } 51 | 52 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_sub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i31_sub(uint32_t *a, const uint32_t *b, uint32_t ctl) 33 | { 34 | uint32_t cc; 35 | size_t u, m; 36 | 37 | cc = 0; 38 | m = (a[0] + 63) >> 5; 39 | for (u = 1; u < m; u ++) { 40 | uint32_t aw, bw, naw; 41 | 42 | aw = a[u]; 43 | bw = b[u]; 44 | naw = aw - bw - cc; 45 | cc = naw >> 31; 46 | a[u] = MUX(ctl, naw & 0x7FFFFFFF, aw); 47 | } 48 | return cc; 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_tmont.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i31_to_monty(uint32_t *x, const uint32_t *m) 33 | { 34 | uint32_t k; 35 | 36 | for (k = (m[0] + 31) >> 5; k > 0; k --) { 37 | br_i31_muladd_small(x, 0, m); 38 | } 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_add.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i32_add(uint32_t *a, const uint32_t *b, uint32_t ctl) 33 | { 34 | uint32_t cc; 35 | size_t u, m; 36 | 37 | cc = 0; 38 | m = (a[0] + 63) >> 5; 39 | for (u = 1; u < m; u ++) { 40 | uint32_t aw, bw, naw; 41 | 42 | aw = a[u]; 43 | bw = b[u]; 44 | naw = aw + bw + cc; 45 | 46 | /* 47 | * Carry is 1 if naw < aw. Carry is also 1 if naw == aw 48 | * AND the carry was already 1. 49 | */ 50 | cc = (cc & EQ(naw, aw)) | LT(naw, aw); 51 | a[u] = MUX(ctl, naw, aw); 52 | } 53 | return cc; 54 | } 55 | 56 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_bitlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i32_bit_length(uint32_t *x, size_t xlen) 33 | { 34 | uint32_t tw, twk; 35 | 36 | tw = 0; 37 | twk = 0; 38 | while (xlen -- > 0) { 39 | uint32_t w, c; 40 | 41 | c = EQ(tw, 0); 42 | w = x[xlen]; 43 | tw = MUX(c, w, tw); 44 | twk = MUX(c, (uint32_t)xlen, twk); 45 | } 46 | return (twk << 5) + BIT_LENGTH(tw); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_decode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i32_decode(uint32_t *x, const void *src, size_t len) 33 | { 34 | const unsigned char *buf; 35 | size_t u, v; 36 | 37 | buf = src; 38 | u = len; 39 | v = 1; 40 | for (;;) { 41 | if (u < 4) { 42 | uint32_t w; 43 | 44 | if (u < 2) { 45 | if (u == 0) { 46 | break; 47 | } else { 48 | w = buf[0]; 49 | } 50 | } else { 51 | if (u == 2) { 52 | w = br_dec16be(buf); 53 | } else { 54 | w = ((uint32_t)buf[0] << 16) 55 | | br_dec16be(buf + 1); 56 | } 57 | } 58 | x[v ++] = w; 59 | break; 60 | } else { 61 | u -= 4; 62 | x[v ++] = br_dec32be(buf + u); 63 | } 64 | } 65 | x[0] = br_i32_bit_length(x + 1, v - 1); 66 | } 67 | 68 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_div32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_divrem(uint32_t hi, uint32_t lo, uint32_t d, uint32_t *r) 33 | { 34 | /* TODO: optimize this */ 35 | uint32_t q; 36 | uint32_t ch, cf; 37 | int k; 38 | 39 | q = 0; 40 | ch = EQ(hi, d); 41 | hi = MUX(ch, 0, hi); 42 | for (k = 31; k > 0; k --) { 43 | int j; 44 | uint32_t w, ctl, hi2, lo2; 45 | 46 | j = 32 - k; 47 | w = (hi << j) | (lo >> k); 48 | ctl = GE(w, d) | (hi >> k); 49 | hi2 = (w - d) >> j; 50 | lo2 = lo - (d << k); 51 | hi = MUX(ctl, hi2, hi); 52 | lo = MUX(ctl, lo2, lo); 53 | q |= ctl << k; 54 | } 55 | cf = GE(lo, d) | hi; 56 | q |= cf; 57 | *r = MUX(cf, lo - d, lo); 58 | return q; 59 | } 60 | 61 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_encode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i32_encode(void *dst, size_t len, const uint32_t *x) 33 | { 34 | unsigned char *buf; 35 | size_t k; 36 | 37 | buf = dst; 38 | 39 | /* 40 | * Compute the announced size of x in bytes; extra bytes are 41 | * filled with zeros. 42 | */ 43 | k = (x[0] + 7) >> 3; 44 | while (len > k) { 45 | *buf ++ = 0; 46 | len --; 47 | } 48 | 49 | /* 50 | * Now we use k as index within x[]. That index starts at 1; 51 | * we initialize it to the topmost complete word, and process 52 | * any remaining incomplete word. 53 | */ 54 | k = (len + 3) >> 2; 55 | switch (len & 3) { 56 | case 3: 57 | *buf ++ = x[k] >> 16; 58 | /* fall through */ 59 | case 2: 60 | *buf ++ = x[k] >> 8; 61 | /* fall through */ 62 | case 1: 63 | *buf ++ = x[k]; 64 | k --; 65 | } 66 | 67 | /* 68 | * Encode all complete words. 69 | */ 70 | while (k > 0) { 71 | br_enc32be(buf, x[k]); 72 | k --; 73 | buf += 4; 74 | } 75 | } 76 | 77 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_fmont.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i32_from_monty(uint32_t *x, const uint32_t *m, uint32_t m0i) 33 | { 34 | size_t len, u, v; 35 | 36 | len = (m[0] + 31) >> 5; 37 | for (u = 0; u < len; u ++) { 38 | uint32_t f; 39 | uint64_t cc; 40 | 41 | f = x[1] * m0i; 42 | cc = 0; 43 | for (v = 0; v < len; v ++) { 44 | uint64_t z; 45 | 46 | z = (uint64_t)x[v + 1] + MUL(f, m[v + 1]) + cc; 47 | cc = z >> 32; 48 | if (v != 0) { 49 | x[v] = (uint32_t)z; 50 | } 51 | } 52 | x[len] = (uint32_t)cc; 53 | } 54 | 55 | /* 56 | * We may have to do an extra subtraction, but only if the 57 | * value in x[] is indeed greater than or equal to that of m[], 58 | * which is why we must do two calls (first call computes the 59 | * carry, second call performs the subtraction only if the carry 60 | * is 0). 61 | */ 62 | br_i32_sub(x, m, NOT(br_i32_sub(x, m, 0))); 63 | } 64 | 65 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_iszero.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i32_iszero(const uint32_t *x) 33 | { 34 | uint32_t z; 35 | size_t u; 36 | 37 | z = 0; 38 | for (u = (x[0] + 31) >> 5; u > 0; u --) { 39 | z |= x[u]; 40 | } 41 | return ~(z | -z) >> 31; 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_mulacc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i32_mulacc(uint32_t *d, const uint32_t *a, const uint32_t *b) 33 | { 34 | size_t alen, blen, u; 35 | 36 | alen = (a[0] + 31) >> 5; 37 | blen = (b[0] + 31) >> 5; 38 | d[0] = a[0] + b[0]; 39 | for (u = 0; u < blen; u ++) { 40 | uint32_t f; 41 | size_t v; 42 | #if BR_64 43 | uint64_t cc; 44 | #else 45 | uint32_t cc; 46 | #endif 47 | 48 | f = b[1 + u]; 49 | cc = 0; 50 | for (v = 0; v < alen; v ++) { 51 | uint64_t z; 52 | 53 | z = (uint64_t)d[1 + u + v] + MUL(f, a[1 + v]) + cc; 54 | cc = z >> 32; 55 | d[1 + u + v] = (uint32_t)z; 56 | } 57 | d[1 + u + alen] = (uint32_t)cc; 58 | } 59 | } 60 | 61 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_ninv32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i32_ninv32(uint32_t x) 33 | { 34 | uint32_t y; 35 | 36 | y = 2 - x; 37 | y *= 2 - y * x; 38 | y *= 2 - y * x; 39 | y *= 2 - y * x; 40 | y *= 2 - y * x; 41 | return MUX(x & 1, -y, 0); 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_sub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i32_sub(uint32_t *a, const uint32_t *b, uint32_t ctl) 33 | { 34 | uint32_t cc; 35 | size_t u, m; 36 | 37 | cc = 0; 38 | m = (a[0] + 63) >> 5; 39 | for (u = 1; u < m; u ++) { 40 | uint32_t aw, bw, naw; 41 | 42 | aw = a[u]; 43 | bw = b[u]; 44 | naw = aw - bw - cc; 45 | 46 | /* 47 | * Carry is 1 if naw > aw. Carry is 1 also if naw == aw 48 | * AND the carry was already 1. 49 | */ 50 | cc = (cc & EQ(naw, aw)) | GT(naw, aw); 51 | a[u] = MUX(ctl, naw, aw); 52 | } 53 | return cc; 54 | } 55 | 56 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_tmont.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i32_to_monty(uint32_t *x, const uint32_t *m) 33 | { 34 | uint32_t k; 35 | 36 | for (k = (m[0] + 31) >> 5; k > 0; k --) { 37 | br_i32_muladd_small(x, 0, m); 38 | } 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/mgf1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_mgf1_xor(void *data, size_t len, 33 | const br_hash_class *dig, const void *seed, size_t seed_len) 34 | { 35 | unsigned char *buf; 36 | size_t u, hlen; 37 | uint32_t c; 38 | 39 | buf = data; 40 | hlen = br_digest_size(dig); 41 | for (u = 0, c = 0; u < len; u += hlen, c ++) { 42 | br_hash_compat_context hc; 43 | unsigned char tmp[64]; 44 | size_t v; 45 | 46 | hc.vtable = dig; 47 | dig->init(&hc.vtable); 48 | dig->update(&hc.vtable, seed, seed_len); 49 | br_enc32be(tmp, c); 50 | dig->update(&hc.vtable, tmp, 4); 51 | dig->out(&hc.vtable, tmp); 52 | for (v = 0; v < hlen; v ++) { 53 | if ((u + v) >= len) { 54 | break; 55 | } 56 | buf[u + v] ^= tmp[v]; 57 | } 58 | } 59 | } 60 | 61 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/prf_md5sha1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl.h */ 31 | void 32 | br_tls10_prf(void *dst, size_t len, 33 | const void *secret, size_t secret_len, const char *label, 34 | size_t seed_num, const br_tls_prf_seed_chunk *seed) 35 | { 36 | const unsigned char *s1; 37 | size_t slen; 38 | 39 | s1 = secret; 40 | slen = (secret_len + 1) >> 1; 41 | memset(dst, 0, len); 42 | br_tls_phash(dst, len, &br_md5_vtable, 43 | s1, slen, label, seed_num, seed); 44 | br_tls_phash(dst, len, &br_sha1_vtable, 45 | s1 + secret_len - slen, slen, label, seed_num, seed); 46 | } 47 | 48 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/prf_sha256.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl.h */ 31 | void 32 | br_tls12_sha256_prf(void *dst, size_t len, 33 | const void *secret, size_t secret_len, const char *label, 34 | size_t seed_num, const br_tls_prf_seed_chunk *seed) 35 | { 36 | memset(dst, 0, len); 37 | br_tls_phash(dst, len, &br_sha256_vtable, 38 | secret, secret_len, label, seed_num, seed); 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/prf_sha384.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl.h */ 31 | void 32 | br_tls12_sha384_prf(void *dst, size_t len, 33 | const void *secret, size_t secret_len, const char *label, 34 | size_t seed_num, const br_tls_prf_seed_chunk *seed) 35 | { 36 | memset(dst, 0, len); 37 | br_tls_phash(dst, len, &br_sha384_vtable, 38 | secret, secret_len, label, seed_num, seed); 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_keygen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_keygen 32 | br_rsa_keygen_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_keygen; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_keygen; 38 | #else 39 | return &br_rsa_i31_keygen; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_modulus.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_compute_modulus 32 | br_rsa_compute_modulus_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_rsa_i15_compute_modulus; 36 | #else 37 | return &br_rsa_i31_compute_modulus; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_oaep_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_oaep_decrypt 32 | br_rsa_oaep_decrypt_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_oaep_decrypt; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_oaep_decrypt; 38 | #else 39 | return &br_rsa_i31_oaep_decrypt; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_oaep_encrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_oaep_encrypt 32 | br_rsa_oaep_encrypt_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_oaep_encrypt; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_oaep_encrypt; 38 | #else 39 | return &br_rsa_i31_oaep_encrypt; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pkcs1_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_pkcs1_sign 32 | br_rsa_pkcs1_sign_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_pkcs1_sign; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_pkcs1_sign; 38 | #else 39 | return &br_rsa_i31_pkcs1_sign; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pkcs1_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_pkcs1_vrfy 32 | br_rsa_pkcs1_vrfy_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_pkcs1_vrfy; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_pkcs1_vrfy; 38 | #else 39 | return &br_rsa_i31_pkcs1_vrfy; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_priv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_private 32 | br_rsa_private_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_private; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_private; 38 | #else 39 | return &br_rsa_i31_private; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_privexp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_compute_privexp 32 | br_rsa_compute_privexp_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_rsa_i15_compute_privexp; 36 | #else 37 | return &br_rsa_i31_compute_privexp; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pss_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_pss_sign 32 | br_rsa_pss_sign_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_pss_sign; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_pss_sign; 38 | #else 39 | return &br_rsa_i31_pss_sign; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pss_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_pss_vrfy 32 | br_rsa_pss_vrfy_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_pss_vrfy; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_pss_vrfy; 38 | #else 39 | return &br_rsa_i31_pss_vrfy; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_public 32 | br_rsa_public_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_public; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_public; 38 | #else 39 | return &br_rsa_i31_public; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pubexp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_compute_pubexp 32 | br_rsa_compute_pubexp_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_rsa_i15_compute_pubexp; 36 | #else 37 | return &br_rsa_i31_compute_pubexp; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_oaep_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i15_oaep_decrypt(const br_hash_class *dig, 33 | const void *label, size_t label_len, 34 | const br_rsa_private_key *sk, void *data, size_t *len) 35 | { 36 | uint32_t r; 37 | 38 | if (*len != ((sk->n_bitlen + 7) >> 3)) { 39 | return 0; 40 | } 41 | r = br_rsa_i15_private(data, sk); 42 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 43 | return r; 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_oaep_encrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | size_t 32 | br_rsa_i15_oaep_encrypt( 33 | const br_prng_class **rnd, const br_hash_class *dig, 34 | const void *label, size_t label_len, 35 | const br_rsa_public_key *pk, 36 | void *dst, size_t dst_max_len, 37 | const void *src, size_t src_len) 38 | { 39 | size_t dlen; 40 | 41 | dlen = br_rsa_oaep_pad(rnd, dig, label, label_len, 42 | pk, dst, dst_max_len, src, src_len); 43 | if (dlen == 0) { 44 | return 0; 45 | } 46 | return dlen & -(size_t)br_rsa_i15_public(dst, dlen, pk); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_pkcs1_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i15_pkcs1_sign(const unsigned char *hash_oid, 33 | const unsigned char *hash, size_t hash_len, 34 | const br_rsa_private_key *sk, unsigned char *x) 35 | { 36 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) { 37 | return 0; 38 | } 39 | return br_rsa_i15_private(x, sk); 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_pkcs1_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i15_pkcs1_vrfy(const unsigned char *x, size_t xlen, 33 | const unsigned char *hash_oid, size_t hash_len, 34 | const br_rsa_public_key *pk, unsigned char *hash_out) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i15_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 46 | } 47 | 48 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_pss_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i15_pss_sign(const br_prng_class **rng, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const unsigned char *hash, size_t salt_len, 35 | const br_rsa_private_key *sk, unsigned char *x) 36 | { 37 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 38 | salt_len, sk->n_bitlen, x)) 39 | { 40 | return 0; 41 | } 42 | return br_rsa_i15_private(x, sk); 43 | } 44 | 45 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_pss_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i15_pss_vrfy(const unsigned char *x, size_t xlen, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const void *hash, size_t salt_len, const br_rsa_public_key *pk) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i15_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pss_sig_unpad(hf_data, hf_mgf1, 46 | hash, salt_len, pk, sig); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_keygen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_keygen(const br_prng_class **rng, 33 | br_rsa_private_key *sk, void *kbuf_priv, 34 | br_rsa_public_key *pk, void *kbuf_pub, 35 | unsigned size, uint32_t pubexp) 36 | { 37 | return br_rsa_i31_keygen_inner(rng, 38 | sk, kbuf_priv, pk, kbuf_pub, size, pubexp, 39 | &br_i31_modpow_opt); 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_oaep_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_oaep_decrypt(const br_hash_class *dig, 33 | const void *label, size_t label_len, 34 | const br_rsa_private_key *sk, void *data, size_t *len) 35 | { 36 | uint32_t r; 37 | 38 | if (*len != ((sk->n_bitlen + 7) >> 3)) { 39 | return 0; 40 | } 41 | r = br_rsa_i31_private(data, sk); 42 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 43 | return r; 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_oaep_encrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | size_t 32 | br_rsa_i31_oaep_encrypt( 33 | const br_prng_class **rnd, const br_hash_class *dig, 34 | const void *label, size_t label_len, 35 | const br_rsa_public_key *pk, 36 | void *dst, size_t dst_max_len, 37 | const void *src, size_t src_len) 38 | { 39 | size_t dlen; 40 | 41 | dlen = br_rsa_oaep_pad(rnd, dig, label, label_len, 42 | pk, dst, dst_max_len, src, src_len); 43 | if (dlen == 0) { 44 | return 0; 45 | } 46 | return dlen & -(size_t)br_rsa_i31_public(dst, dlen, pk); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_pkcs1_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_pkcs1_sign(const unsigned char *hash_oid, 33 | const unsigned char *hash, size_t hash_len, 34 | const br_rsa_private_key *sk, unsigned char *x) 35 | { 36 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) { 37 | return 0; 38 | } 39 | return br_rsa_i31_private(x, sk); 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_pkcs1_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_pkcs1_vrfy(const unsigned char *x, size_t xlen, 33 | const unsigned char *hash_oid, size_t hash_len, 34 | const br_rsa_public_key *pk, unsigned char *hash_out) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i31_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 46 | } 47 | 48 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_pss_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_pss_sign(const br_prng_class **rng, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const unsigned char *hash, size_t salt_len, 35 | const br_rsa_private_key *sk, unsigned char *x) 36 | { 37 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 38 | salt_len, sk->n_bitlen, x)) 39 | { 40 | return 0; 41 | } 42 | return br_rsa_i31_private(x, sk); 43 | } 44 | 45 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_pss_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_pss_vrfy(const unsigned char *x, size_t xlen, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const void *hash, size_t salt_len, const br_rsa_public_key *pk) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i31_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pss_sig_unpad(hf_data, hf_mgf1, 46 | hash, salt_len, pk, sig); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_oaep_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i32_oaep_decrypt(const br_hash_class *dig, 33 | const void *label, size_t label_len, 34 | const br_rsa_private_key *sk, void *data, size_t *len) 35 | { 36 | uint32_t r; 37 | 38 | if (*len != ((sk->n_bitlen + 7) >> 3)) { 39 | return 0; 40 | } 41 | r = br_rsa_i32_private(data, sk); 42 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 43 | return r; 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_oaep_encrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | size_t 32 | br_rsa_i32_oaep_encrypt( 33 | const br_prng_class **rnd, const br_hash_class *dig, 34 | const void *label, size_t label_len, 35 | const br_rsa_public_key *pk, 36 | void *dst, size_t dst_max_len, 37 | const void *src, size_t src_len) 38 | { 39 | size_t dlen; 40 | 41 | dlen = br_rsa_oaep_pad(rnd, dig, label, label_len, 42 | pk, dst, dst_max_len, src, src_len); 43 | if (dlen == 0) { 44 | return 0; 45 | } 46 | return dlen & -(size_t)br_rsa_i32_public(dst, dlen, pk); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_pkcs1_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i32_pkcs1_sign(const unsigned char *hash_oid, 33 | const unsigned char *hash, size_t hash_len, 34 | const br_rsa_private_key *sk, unsigned char *x) 35 | { 36 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) { 37 | return 0; 38 | } 39 | return br_rsa_i32_private(x, sk); 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_pkcs1_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i32_pkcs1_vrfy(const unsigned char *x, size_t xlen, 33 | const unsigned char *hash_oid, size_t hash_len, 34 | const br_rsa_public_key *pk, unsigned char *hash_out) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i32_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 46 | } 47 | 48 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_pss_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i32_pss_sign(const br_prng_class **rng, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const unsigned char *hash, size_t salt_len, 35 | const br_rsa_private_key *sk, unsigned char *x) 36 | { 37 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 38 | salt_len, sk->n_bitlen, x)) 39 | { 40 | return 0; 41 | } 42 | return br_rsa_i32_private(x, sk); 43 | } 44 | 45 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_pss_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i32_pss_vrfy(const unsigned char *x, size_t xlen, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const void *hash, size_t salt_len, const br_rsa_public_key *pk) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i32_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pss_sig_unpad(hf_data, hf_mgf1, 46 | hash, salt_len, pk, sig); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_keygen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_keygen(const br_prng_class **rng, 35 | br_rsa_private_key *sk, void *kbuf_priv, 36 | br_rsa_public_key *pk, void *kbuf_pub, 37 | unsigned size, uint32_t pubexp) 38 | { 39 | return br_rsa_i31_keygen_inner(rng, 40 | sk, kbuf_priv, pk, kbuf_pub, size, pubexp, 41 | &br_i62_modpow_opt_as_i31); 42 | } 43 | 44 | /* see bearssl_rsa.h */ 45 | br_rsa_keygen 46 | br_rsa_i62_keygen_get() 47 | { 48 | return &br_rsa_i62_keygen; 49 | } 50 | 51 | #else 52 | 53 | /* see bearssl_rsa.h */ 54 | br_rsa_keygen 55 | br_rsa_i62_keygen_get() 56 | { 57 | return 0; 58 | } 59 | 60 | #endif 61 | 62 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_oaep_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_oaep_decrypt(const br_hash_class *dig, 35 | const void *label, size_t label_len, 36 | const br_rsa_private_key *sk, void *data, size_t *len) 37 | { 38 | uint32_t r; 39 | 40 | if (*len != ((sk->n_bitlen + 7) >> 3)) { 41 | return 0; 42 | } 43 | r = br_rsa_i62_private(data, sk); 44 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 45 | return r; 46 | } 47 | 48 | /* see bearssl_rsa.h */ 49 | br_rsa_oaep_decrypt 50 | br_rsa_i62_oaep_decrypt_get(void) 51 | { 52 | return &br_rsa_i62_oaep_decrypt; 53 | } 54 | 55 | #else 56 | 57 | /* see bearssl_rsa.h */ 58 | br_rsa_oaep_decrypt 59 | br_rsa_i62_oaep_decrypt_get(void) 60 | { 61 | return 0; 62 | } 63 | 64 | #endif 65 | 66 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_oaep_encrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | size_t 34 | br_rsa_i62_oaep_encrypt( 35 | const br_prng_class **rnd, const br_hash_class *dig, 36 | const void *label, size_t label_len, 37 | const br_rsa_public_key *pk, 38 | void *dst, size_t dst_max_len, 39 | const void *src, size_t src_len) 40 | { 41 | size_t dlen; 42 | 43 | dlen = br_rsa_oaep_pad(rnd, dig, label, label_len, 44 | pk, dst, dst_max_len, src, src_len); 45 | if (dlen == 0) { 46 | return 0; 47 | } 48 | return dlen & -(size_t)br_rsa_i62_public(dst, dlen, pk); 49 | } 50 | 51 | /* see bearssl_rsa.h */ 52 | br_rsa_oaep_encrypt 53 | br_rsa_i62_oaep_encrypt_get(void) 54 | { 55 | return &br_rsa_i62_oaep_encrypt; 56 | } 57 | 58 | #else 59 | 60 | /* see bearssl_rsa.h */ 61 | br_rsa_oaep_encrypt 62 | br_rsa_i62_oaep_encrypt_get(void) 63 | { 64 | return 0; 65 | } 66 | 67 | #endif 68 | 69 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_pkcs1_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_pkcs1_sign(const unsigned char *hash_oid, 35 | const unsigned char *hash, size_t hash_len, 36 | const br_rsa_private_key *sk, unsigned char *x) 37 | { 38 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) { 39 | return 0; 40 | } 41 | return br_rsa_i62_private(x, sk); 42 | } 43 | 44 | /* see bearssl_rsa.h */ 45 | br_rsa_pkcs1_sign 46 | br_rsa_i62_pkcs1_sign_get(void) 47 | { 48 | return &br_rsa_i62_pkcs1_sign; 49 | } 50 | 51 | #else 52 | 53 | /* see bearssl_rsa.h */ 54 | br_rsa_pkcs1_sign 55 | br_rsa_i62_pkcs1_sign_get(void) 56 | { 57 | return 0; 58 | } 59 | 60 | #endif 61 | 62 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_pkcs1_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_pkcs1_vrfy(const unsigned char *x, size_t xlen, 35 | const unsigned char *hash_oid, size_t hash_len, 36 | const br_rsa_public_key *pk, unsigned char *hash_out) 37 | { 38 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 39 | 40 | if (xlen > (sizeof sig)) { 41 | return 0; 42 | } 43 | memcpy(sig, x, xlen); 44 | if (!br_rsa_i62_public(sig, xlen, pk)) { 45 | return 0; 46 | } 47 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 48 | } 49 | 50 | /* see bearssl_rsa.h */ 51 | br_rsa_pkcs1_vrfy 52 | br_rsa_i62_pkcs1_vrfy_get(void) 53 | { 54 | return &br_rsa_i62_pkcs1_vrfy; 55 | } 56 | 57 | #else 58 | 59 | /* see bearssl_rsa.h */ 60 | br_rsa_pkcs1_vrfy 61 | br_rsa_i62_pkcs1_vrfy_get(void) 62 | { 63 | return 0; 64 | } 65 | 66 | #endif 67 | 68 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_pss_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_pss_sign(const br_prng_class **rng, 35 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 36 | const unsigned char *hash, size_t salt_len, 37 | const br_rsa_private_key *sk, unsigned char *x) 38 | { 39 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 40 | salt_len, sk->n_bitlen, x)) 41 | { 42 | return 0; 43 | } 44 | return br_rsa_i62_private(x, sk); 45 | } 46 | 47 | /* see bearssl_rsa.h */ 48 | br_rsa_pss_sign 49 | br_rsa_i62_pss_sign_get(void) 50 | { 51 | return &br_rsa_i62_pss_sign; 52 | } 53 | 54 | #else 55 | 56 | /* see bearssl_rsa.h */ 57 | br_rsa_pss_sign 58 | br_rsa_i62_pss_sign_get(void) 59 | { 60 | return 0; 61 | } 62 | 63 | #endif 64 | 65 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_pss_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_pss_vrfy(const unsigned char *x, size_t xlen, 35 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 36 | const void *hash, size_t salt_len, const br_rsa_public_key *pk) 37 | { 38 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 39 | 40 | if (xlen > (sizeof sig)) { 41 | return 0; 42 | } 43 | memcpy(sig, x, xlen); 44 | if (!br_rsa_i62_public(sig, xlen, pk)) { 45 | return 0; 46 | } 47 | return br_rsa_pss_sig_unpad(hf_data, hf_mgf1, 48 | hash, salt_len, pk, sig); 49 | } 50 | 51 | /* see bearssl_rsa.h */ 52 | br_rsa_pss_vrfy 53 | br_rsa_i62_pss_vrfy_get(void) 54 | { 55 | return &br_rsa_i62_pss_vrfy; 56 | } 57 | 58 | #else 59 | 60 | /* see bearssl_rsa.h */ 61 | br_rsa_pss_vrfy 62 | br_rsa_i62_pss_vrfy_get(void) 63 | { 64 | return 0; 65 | } 66 | 67 | #endif 68 | 69 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_ssl_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_ssl_decrypt(br_rsa_private core, const br_rsa_private_key *sk, 33 | unsigned char *data, size_t len) 34 | { 35 | uint32_t x; 36 | size_t u; 37 | 38 | /* 39 | * A first check on length. Since this test works only on the 40 | * buffer length, it needs not (and cannot) be constant-time. 41 | */ 42 | if (len < 59 || len != (sk->n_bitlen + 7) >> 3) { 43 | return 0; 44 | } 45 | x = core(data, sk); 46 | 47 | x &= EQ(data[0], 0x00); 48 | x &= EQ(data[1], 0x02); 49 | for (u = 2; u < (len - 49); u ++) { 50 | x &= NEQ(data[u], 0); 51 | } 52 | x &= EQ(data[len - 49], 0x00); 53 | memmove(data, data + len - 48, 48); 54 | return x; 55 | } 56 | 57 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_client_default_rsapub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_client_set_default_rsapub(br_ssl_client_context *cc) 33 | { 34 | br_ssl_client_set_rsapub(cc, br_rsa_public_get_default()); 35 | } 36 | 37 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_engine_default_chapol.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_engine_set_default_chapol(br_ssl_engine_context *cc) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | br_poly1305_run bp; 36 | #endif 37 | #if BR_SSE2 38 | br_chacha20_run bc; 39 | #endif 40 | 41 | br_ssl_engine_set_chapol(cc, 42 | &br_sslrec_in_chapol_vtable, 43 | &br_sslrec_out_chapol_vtable); 44 | #if BR_SSE2 45 | bc = br_chacha20_sse2_get(); 46 | if (bc) { 47 | br_ssl_engine_set_chacha20(cc, bc); 48 | } else { 49 | #endif 50 | br_ssl_engine_set_chacha20(cc, &br_chacha20_ct_run); 51 | #if BR_SSE2 52 | } 53 | #endif 54 | #if BR_INT128 || BR_UMUL128 55 | bp = br_poly1305_ctmulq_get(); 56 | if (bp) { 57 | br_ssl_engine_set_poly1305(cc, bp); 58 | } else { 59 | #endif 60 | #if BR_LOMUL 61 | br_ssl_engine_set_poly1305(cc, &br_poly1305_ctmul32_run); 62 | #else 63 | br_ssl_engine_set_poly1305(cc, &br_poly1305_ctmul_run); 64 | #endif 65 | #if BR_INT128 || BR_UMUL128 66 | } 67 | #endif 68 | } 69 | 70 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_engine_default_descbc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_engine_set_default_des_cbc(br_ssl_engine_context *cc) 33 | { 34 | br_ssl_engine_set_cbc(cc, 35 | &br_sslrec_in_cbc_vtable, 36 | &br_sslrec_out_cbc_vtable); 37 | br_ssl_engine_set_des_cbc(cc, 38 | &br_des_ct_cbcenc_vtable, 39 | &br_des_ct_cbcdec_vtable); 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_engine_default_ec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_engine_set_default_ec(br_ssl_engine_context *cc) 33 | { 34 | #if BR_LOMUL 35 | br_ssl_engine_set_ec(cc, &br_ec_all_m15); 36 | #else 37 | br_ssl_engine_set_ec(cc, &br_ec_all_m31); 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_engine_default_ecdsa.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_engine_set_default_ecdsa(br_ssl_engine_context *cc) 33 | { 34 | #if BR_LOMUL 35 | br_ssl_engine_set_ec(cc, &br_ec_all_m15); 36 | br_ssl_engine_set_ecdsa(cc, &br_ecdsa_i15_vrfy_asn1); 37 | #else 38 | br_ssl_engine_set_ec(cc, &br_ec_all_m31); 39 | br_ssl_engine_set_ecdsa(cc, &br_ecdsa_i31_vrfy_asn1); 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_engine_default_rsavrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_engine_set_default_rsavrfy(br_ssl_engine_context *cc) 33 | { 34 | br_ssl_engine_set_rsavrfy(cc, br_rsa_pkcs1_vrfy_get_default()); 35 | } 36 | 37 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_hashes.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | int 32 | br_ssl_choose_hash(unsigned bf) 33 | { 34 | static const unsigned char pref[] = { 35 | br_sha256_ID, br_sha384_ID, br_sha512_ID, 36 | br_sha224_ID, br_sha1_ID 37 | }; 38 | size_t u; 39 | 40 | for (u = 0; u < sizeof pref; u ++) { 41 | int x; 42 | 43 | x = pref[u]; 44 | if ((bf >> x) & 1) { 45 | return x; 46 | } 47 | } 48 | return 0; 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_server.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_server_zero(br_ssl_server_context *cc) 33 | { 34 | /* 35 | * For really standard C, we should explicitly set to NULL all 36 | * pointers, and 0 all other fields. However, on all our target 37 | * architectures, a direct memset() will work, be faster, and 38 | * use a lot less code. 39 | */ 40 | memset(cc, 0, sizeof *cc); 41 | } 42 | 43 | /* see bearssl_ssl.h */ 44 | int 45 | br_ssl_server_reset(br_ssl_server_context *cc) 46 | { 47 | br_ssl_engine_set_buffer(&cc->eng, NULL, 0, 0); 48 | if (!br_ssl_engine_init_rand(&cc->eng)) { 49 | return 0; 50 | } 51 | cc->eng.reneg = 0; 52 | br_ssl_engine_hs_reset(&cc->eng, 53 | br_ssl_hs_server_init_main, br_ssl_hs_server_run); 54 | return br_ssl_engine_last_error(&cc->eng) == BR_ERR_OK; 55 | } 56 | 57 | #endif -------------------------------------------------------------------------------- /src/mbfs/MB_MCU.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef MB_MCU_H 4 | #define MB_MCU_H 5 | 6 | 7 | #if defined(ESP8266) || defined(ESP32) 8 | #ifndef MB_ARDUINO_ESP 9 | #define MB_ARDUINO_ESP 10 | #endif 11 | #endif 12 | 13 | #if defined(__arm__) 14 | #ifndef MB_ARDUINO_ARM 15 | #define MB_ARDUINO_ARM 16 | #endif 17 | #endif 18 | 19 | // Renesas 20 | #if defined(ARDUINO_PORTENTA_C33) 21 | 22 | #endif 23 | 24 | // Renesas 25 | #if defined(ARDUINO_UNOWIFIR4) 26 | 27 | #endif 28 | 29 | // Renesas 30 | #if defined(ARDUINO_MINIMA) 31 | 32 | #endif 33 | 34 | #if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_X8) 35 | 36 | #endif 37 | 38 | 39 | #if defined(ARDUINO_ARCH_SAMD) 40 | #ifndef MB_ARDUINO_ARCH_SAMD 41 | #define MB_ARDUINO_ARCH_SAMD 42 | #endif 43 | #endif 44 | 45 | #if defined(ARDUINO_ARCH_RP2040) 46 | 47 | #if defined(ARDUINO_NANO_RP2040_CONNECT) 48 | #ifndef MB_ARDUINO_NANO_RP2040_CONNECT 49 | #define MB_ARDUINO_NANO_RP2040_CONNECT 50 | #endif 51 | #else 52 | #ifndef MB_ARDUINO_PICO 53 | #define MB_ARDUINO_PICO 54 | #endif 55 | #endif 56 | 57 | #endif 58 | 59 | 60 | #if defined(TEENSYDUINO) 61 | #ifndef MB_ARDUINO_TEENSY 62 | #define MB_ARDUINO_TEENSY 63 | #endif 64 | #endif 65 | 66 | 67 | #endif --------------------------------------------------------------------------------