├── keywords.txt ├── library.properties ├── src ├── core │ └── Core.h ├── spreadsheets │ └── requests │ │ ├── NamedRange.h │ │ ├── GridCoordinate.h │ │ ├── GridRange.h │ │ ├── charts │ │ ├── PieChartSpec.h │ │ └── LineStyle.h │ │ └── TextPosition.h ├── client │ └── SSLClient │ │ ├── ESP_SSLClient_FS.h │ │ └── bssl │ │ ├── ec_default.c │ │ ├── ssl_client_default_rsapub.c │ │ ├── ssl_engine_default_rsavrfy.c │ │ ├── i15_tmont.c │ │ ├── i31_tmont.c │ │ ├── i32_tmont.c │ │ ├── ecdsa_default_sign_asn1.c │ │ ├── ecdsa_default_sign_raw.c │ │ ├── ecdsa_default_vrfy_asn1.c │ │ ├── ecdsa_default_vrfy_raw.c │ │ ├── enc16be.c │ │ ├── enc16le.c │ │ ├── enc32be.c │ │ ├── enc32le.c │ │ ├── enc64be.c │ │ ├── enc64le.c │ │ ├── i32_ninv32.c │ │ ├── dec16be.c │ │ ├── dec16le.c │ │ ├── dec32be.c │ │ ├── dec32le.c │ │ ├── dec64be.c │ │ ├── dec64le.c │ │ ├── i15_iszero.c │ │ ├── i31_iszero.c │ │ ├── i32_iszero.c │ │ ├── rsa_default_pubexp.c │ │ ├── rsa_default_modulus.c │ │ ├── rsa_default_privexp.c │ │ ├── i31_ninv31.c │ │ ├── ssl_engine_default_ec.c │ │ ├── i15_ninv15.c │ │ ├── rsa_default_keygen.c │ │ ├── rsa_default_pub.c │ │ ├── rsa_default_priv.c │ │ ├── rsa_default_pss_sign.c │ │ ├── rsa_default_pss_vrfy.c │ │ ├── rsa_default_pkcs1_sign.c │ │ ├── rsa_default_pkcs1_vrfy.c │ │ ├── rsa_default_oaep_decrypt.c │ │ ├── rsa_default_oaep_encrypt.c │ │ ├── ccopy.c │ │ ├── ssl_engine_default_descbc.c │ │ ├── prf_sha256.c │ │ ├── prf_sha384.c │ │ ├── rsa_i31_keygen.c │ │ ├── rsa_i15_pkcs1_sign.c │ │ ├── rsa_i31_pkcs1_sign.c │ │ ├── rsa_i32_pkcs1_sign.c │ │ ├── i15_bitlen.c │ │ ├── i31_bitlen.c │ │ ├── i32_bitlen.c │ │ ├── ssl_engine_default_ecdsa.c │ │ ├── ssl_hashes.c │ │ ├── i15_rshift.c │ │ ├── i15_sub.c │ │ ├── i15_add.c │ │ ├── i31_rshift.c │ │ ├── i31_sub.c │ │ ├── i31_add.c │ │ ├── rsa_i15_oaep_decrypt.c │ │ ├── rsa_i31_oaep_decrypt.c │ │ ├── rsa_i32_oaep_decrypt.c │ │ ├── rsa_i15_pss_sign.c │ │ ├── rsa_i31_pss_sign.c │ │ ├── rsa_i32_pss_sign.c │ │ ├── ecdsa_i15_bits.c │ │ ├── rsa_i15_pkcs1_vrfy.c │ │ ├── rsa_i31_pkcs1_vrfy.c │ │ ├── rsa_i32_pkcs1_vrfy.c │ │ ├── ecdsa_i31_bits.c │ │ ├── prf_md5sha1.c │ │ ├── rsa_i15_oaep_encrypt.c │ │ ├── rsa_i31_oaep_encrypt.c │ │ ├── rsa_i32_oaep_encrypt.c │ │ ├── rsa_i15_pss_vrfy.c │ │ ├── rsa_i31_pss_vrfy.c │ │ ├── rsa_i32_pss_vrfy.c │ │ ├── i32_add.c │ │ ├── i32_sub.c │ │ ├── dig_size.c │ │ ├── ecdsa_i15_sign_asn1.c │ │ ├── ecdsa_i31_sign_asn1.c │ │ ├── i15_decode.c │ │ ├── i15_encode.c │ │ ├── i31_decode.c │ │ ├── i32_mulacc.c │ │ ├── i15_modpow.c │ │ ├── i32_div32.c │ │ ├── rsa_i62_keygen.c │ │ ├── ec_curve25519.c │ │ ├── rsa_i62_pkcs1_sign.c │ │ ├── rsa_ssl_decrypt.c │ │ ├── i32_decode.c │ │ ├── ecdsa_i15_vrfy_asn1.c │ │ ├── ecdsa_i31_vrfy_asn1.c │ │ ├── mgf1.c │ │ ├── rsa_i62_pss_sign.c │ │ ├── rsa_i62_oaep_decrypt.c │ │ ├── ssl_server.c │ │ ├── rsa_i62_pkcs1_vrfy.c │ │ ├── rsa_i62_pss_vrfy.c │ │ ├── i15_fmont.c │ │ ├── i15_mulacc.c │ │ ├── rsa_i62_oaep_encrypt.c │ │ ├── i32_fmont.c │ │ ├── ec_secp256r1.c │ │ ├── i31_fmont.c │ │ └── i32_encode.c └── README.md ├── .github ├── FUNDING.yml ├── stale.yml └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── library.json ├── LICENSE └── README.md /keywords.txt: -------------------------------------------------------------------------------- 1 | ######################################### 2 | # Syntax Coloring Map for GSheetClient 3 | ######################################### -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=FirebaseClient 2 | 3 | version=0.0.1 4 | 5 | author=Mobizt 6 | 7 | maintainer=Mobizt 8 | 9 | sentence=Async Google Sheet REST client library for Arduino devices. 10 | 11 | paragraph=This library provides the functions to read, edit and delete the spreadsheets via the Google Sheet APIs. 12 | 13 | category=Communication 14 | 15 | url=https://github.com/mobizt/GSheetClient 16 | 17 | architectures=esp8266,esp32,sam,samd,stm32,STM32F1,STM32F4,teensy,mbed_nano,mbed_rp2040,rp2040 18 | -------------------------------------------------------------------------------- /src/core/Core.h: -------------------------------------------------------------------------------- 1 | #ifndef GSHEET_CORE_CORE_H_ 2 | #define GSHEET_CORE_CORE_H_ 3 | 4 | #include 5 | 6 | #if defined(GSHEET_CLIENT_VERSION) 7 | #undef GSHEET_CLIENT_VERSION 8 | #endif 9 | 10 | #define GSHEET_CLIENT_VERSION "0.0.1" 11 | 12 | static void gsheet_sys_idle() 13 | { 14 | #if defined(ARDUINO_ESP8266_MAJOR) && defined(ARDUINO_ESP8266_MINOR) && defined(ARDUINO_ESP8266_REVISION) && ((ARDUINO_ESP8266_MAJOR == 3 && ARDUINO_ESP8266_MINOR >= 1) || ARDUINO_ESP8266_MAJOR > 3) 15 | esp_yield(); 16 | #else 17 | delay(0); 18 | #endif 19 | } 20 | 21 | #endif -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: mobizt 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.buymeacoffee.com/Mobizt 14 | -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GSheetClient", 3 | "version": "0.0.1", 4 | "keywords": "communication, REST, esp32, esp8266, raspberrypi, arduino", 5 | "description": "Async Google Sheet REST client library for Arduino devices. This library provides the functions to read, edit and delete the spreadsheets via the Google Sheet APIs.", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/mobizt/GSheetClient.git" 9 | }, 10 | "authors": [{ 11 | "name": "Mobizt", 12 | "email": "suwatchai@outlook.com" 13 | }], 14 | "frameworks": "arduino", 15 | "platforms": "espressif32, espressif8266, atmelsam, rp2040, ststm32, teensy" 16 | } 17 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 2 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 1 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 | -------------------------------------------------------------------------------- /.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 | **Just ask something** 11 | If you have questions, use [Discussions](https://github.com/mobizt/GSheetClient/discussions) instead. 12 | 13 | **Is your feature request related to a problem? Please describe.** 14 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 15 | 16 | **Describe the solution you'd like** 17 | A clear and concise description of what you want to happen. 18 | 19 | **Describe alternatives you've considered** 20 | A clear and concise description of any alternative solutions or features you've considered. 21 | 22 | **Additional context** 23 | Add any other context or screenshots about the feature request here. 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Just ask something** 11 | If you have questions, use [Discussions](https://github.com/mobizt/GSheetClient/discussions) instead. 12 | 13 | **Describe the bug** 14 | A clear and concise description of what the bug is. 15 | 16 | **To Reproduce** 17 | Create minimal, clean and clear testing code that addressed the issue. 18 | The third party libraries should be removed. 19 | And post the testing code here. 20 | 21 | 22 | **Expected behavior** 23 | A clear and concise description of what you expected to happen. 24 | 25 | **Screenshots** 26 | If applicable, add screenshots to help explain your problem. 27 | 28 | **IDE and its version:** 29 | - Arduino, PlatformIO 30 | - Version [e.g. 1.8.9] 31 | 32 | **ESP8266 Arduino Core SDK version** 33 | - Version [e.g. 2.5.1] 34 | 35 | **Additional context** 36 | Add any other context about the problem here. 37 | -------------------------------------------------------------------------------- /src/spreadsheets/requests/NamedRange.h: -------------------------------------------------------------------------------- 1 | #ifndef NAMED_RANGE_H 2 | #define NAMED_RANGE_H 3 | 4 | #include 5 | #include "./Config.h" 6 | #include "./core/JSON.h" 7 | #include "./core/ObjectWriter.h" 8 | #include "./spreadsheets/requests/GridRange.h" 9 | 10 | namespace GSHEET 11 | { 12 | /** 13 | * A named range. 14 | */ 15 | class NamedRange : public BaseG4 16 | { 17 | 18 | public: 19 | NamedRange() {} 20 | 21 | // The ID of the named range. 22 | NamedRange &namedRangeId(const String &value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } 23 | 24 | // The name of the named range. 25 | NamedRange &name(const String &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } 26 | 27 | // The range this represents. 28 | NamedRange &range(const GridRange &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } 29 | }; 30 | 31 | } 32 | #endif -------------------------------------------------------------------------------- /src/spreadsheets/requests/GridCoordinate.h: -------------------------------------------------------------------------------- 1 | #ifndef GRID_COORDINATE_H 2 | #define GRID_COORDINATE_H 3 | 4 | #include 5 | #include "./Config.h" 6 | #include "./core/JSON.h" 7 | #include "./core/ObjectWriter.h" 8 | 9 | namespace GSHEET 10 | { 11 | 12 | /** 13 | * A coordinate in a sheet. All indexes are zero-based. 14 | */ 15 | class GridCoordinate : public BaseG4 16 | { 17 | public: 18 | GridCoordinate() {} 19 | 20 | // The sheet this coordinate is on. 21 | GridCoordinate &sheetId(int value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } 22 | 23 | // The row index of the coordinate. 24 | GridCoordinate &rowIndex(int value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } 25 | 26 | // The column index of the coordinate. 27 | GridCoordinate &columnIndex(int value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } 28 | }; 29 | 30 | } 31 | #endif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 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 | -------------------------------------------------------------------------------- /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/README.md: -------------------------------------------------------------------------------- 1 | # GSheetClient 2 | 3 | Async Google Sheet REST client library for Arduino devices. 4 | 5 | ## License 6 | 7 | The MIT License (MIT) 8 | 9 | Copyright (c) 2024 K. Suwatchai (Mobizt) 10 | 11 | 12 | Permission is hereby granted, free of charge, to any person returning a copy of 13 | this software and associated documentation files (the "Software"), to deal in 14 | the Software without restriction, including without limitation the rights to 15 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 16 | the Software, and to permit persons to whom the Software is furnished to do so, 17 | subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in all 20 | copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 24 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 25 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 26 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 27 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GSheetClient 2 | 3 | Async Google Sheet REST client library for Arduino devices. 4 | 5 | This library provides the functions to read, edit and delete the spreadsheets via the Google Sheet APIs. 6 | 7 | This library is under development. 8 | 9 | ## License 10 | 11 | The MIT License (MIT) 12 | 13 | Copyright (c) 2024 K. Suwatchai (Mobizt) 14 | 15 | 16 | Permission is hereby granted, free of charge, to any person returning a copy of 17 | this software and associated documentation files (the "Software"), to deal in 18 | the Software without restriction, including without limitation the rights to 19 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 20 | the Software, and to permit persons to whom the Software is furnished to do so, 21 | subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be included in all 24 | copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 28 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 29 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 30 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | -------------------------------------------------------------------------------- /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/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_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/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_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_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/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/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/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/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/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/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/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/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_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_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/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/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/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/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_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_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_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_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_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/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/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/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_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/spreadsheets/requests/GridRange.h: -------------------------------------------------------------------------------- 1 | #ifndef GRID_RANGE_H 2 | #define GRID_RANGE_H 3 | #include 4 | #include "./Config.h" 5 | #include "./core/JSON.h" 6 | #include "./core/ObjectWriter.h" 7 | #include "./spreadsheets/requests/Common.h" 8 | 9 | namespace GSHEET 10 | { 11 | /** 12 | * A range on a sheet. All indexes are zero-based. Indexes are half open, i.e. the start index is inclusive and the end index is exclusive -- [startIndex, endIndex). Missing indexes indicate the range is unbounded on that side. 13 | */ 14 | class GridRange : public BaseG6 15 | { 16 | 17 | public: 18 | GridRange() {} 19 | 20 | // The sheet this range is on. 21 | GridRange &sheetId(int value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } 22 | 23 | // The start row (inclusive) of the range, or not set if unbounded. 24 | GridRange &startRowIndex(int value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } 25 | 26 | // The end row (exclusive) of the range, or not set if unbounded. 27 | GridRange &endRowIndex(int value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } 28 | 29 | // The start column (inclusive) of the range, or not set if unbounded. 30 | GridRange &startColumnIndex(int value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } 31 | 32 | // The end column (exclusive) of the range, or not set if unbounded. 33 | GridRange &endColumnIndex(int value) { return wr.set(*this, value, buf, bufSize, 5, FPSTR(__func__)); } 34 | }; 35 | } 36 | 37 | #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_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_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/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/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/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/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_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/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_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/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_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/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_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_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_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_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_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/spreadsheets/requests/charts/PieChartSpec.h: -------------------------------------------------------------------------------- 1 | #ifndef PIE_CHART_SPEC_H 2 | #define PIE_CHART_SPEC_H 3 | 4 | #include 5 | #include "./Config.h" 6 | #include "./core/JSON.h" 7 | #include "./core/ObjectWriter.h" 8 | #include "./spreadsheets/requests/charts/ChartData.h" 9 | 10 | /** 11 | * PIE CHART CLASS DEPENDENCIES 12 | * 13 | * PieChartSpec (enum) PieChartLegendPosition 14 | * ChartData* 15 | * 16 | * See ChartData.h 17 | */ 18 | 19 | namespace GSHEET 20 | { 21 | 22 | /** 23 | * A pie chart. 24 | */ 25 | class PieChartSpec : public BaseG6 26 | { 27 | 28 | public: 29 | PieChartSpec() {} 30 | 31 | // Where the legend of the pie chart should be drawn. 32 | PieChartSpec &legendPosition(PieChart::LegendPosition value) { return wr.set(*this, _PieChartLegendPosition[value].text, buf, bufSize, 1, FPSTR(__func__)); } 33 | 34 | // The data that covers the domain of the pie chart. 35 | PieChartSpec &domain(const ChartData &value) { return wr.set(*this, value, buf, bufSize, 2, FPSTR(__func__)); } 36 | 37 | // The data that covers the one and only series of the pie chart. 38 | PieChartSpec &series(const ChartData &value) { return wr.set(*this, value, buf, bufSize, 3, FPSTR(__func__)); } 39 | 40 | // True if the pie is three dimensional. 41 | PieChartSpec &threeDimensional(bool value) { return wr.set(*this, value, buf, bufSize, 4, FPSTR(__func__)); } 42 | 43 | // The size of the hole in the pie chart. 44 | PieChartSpec &pieHole(double value) { return wr.set(*this, value, buf, bufSize, 5, FPSTR(__func__)); } 45 | }; 46 | } 47 | 48 | #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/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_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_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/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/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/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_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_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_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_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_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/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_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/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/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_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/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/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/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/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/spreadsheets/requests/charts/LineStyle.h: -------------------------------------------------------------------------------- 1 | #ifndef LINE_STYLE_H 2 | #define LINE_STYLE_H 3 | 4 | #include 5 | #include "./Config.h" 6 | #include "./core/JSON.h" 7 | #include "./core/ObjectWriter.h" 8 | 9 | namespace GSHEET 10 | { 11 | // The dash type of a line. 12 | enum LineDashType 13 | { 14 | LINE_DASH_TYPE_UNSPECIFIED, // Default value, do not use. 15 | INVISIBLE, // No dash type, which is equivalent to a non-visible line. 16 | CUSTOM_DASH, // A custom dash for a line. Modifying the exact custom dash style is currently unsupported. 17 | SOLID_LINE, // A solid line. 18 | DOTTED_LINE, // A dotted line. 19 | MEDIUM_DASHED, // A dashed line where the dashes have "medium" length. 20 | MEDIUM_DASHED_DOTTED, // A line that alternates between a "medium" dash and a dot. 21 | LONG_DASHED, // A dashed line where the dashes have "long" length. 22 | LONG_DASHED_DOTTED // A line that alternates between a "long" dash and a dot. 23 | 24 | }; 25 | 26 | const struct key_str_40 _LineDashType[LineDashType::LONG_DASHED_DOTTED + 1] PROGMEM = {"LINE_DASH_TYPE_UNSPECIFIED", "INVISIBLE", "CUSTOM_DASH", "SOLID_LINE", "DOTTED_LINE", "MEDIUM_DASHED", "MEDIUM_DASHED_DOTTED", "LONG_DASHED", "LONG_DASHED_DOTTED"}; 27 | 28 | /** 29 | * Properties that describe the style of a line. 30 | */ 31 | class LineStyle : public BaseG4 32 | { 33 | 34 | public: 35 | LineStyle() {} 36 | 37 | // The thickness of the line, in px. 38 | LineStyle &width(int value) { return wr.set(*this, value, buf, bufSize, 1, FPSTR(__func__)); } 39 | 40 | // The dash type of the line. 41 | LineStyle &type(LineDashType value) { return wr.set(*this, _LineDashType[value].text, buf, bufSize, 2, FPSTR(__func__)); } 42 | }; 43 | 44 | } 45 | 46 | #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/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/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/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_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/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/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_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/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/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_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/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/spreadsheets/requests/TextPosition.h: -------------------------------------------------------------------------------- 1 | #ifndef TEXT_POSITION_H 2 | #define TEXT_POSITION_H 3 | 4 | #include 5 | #include "./Config.h" 6 | #include "./core/JSON.h" 7 | #include "./core/ObjectWriter.h" 8 | #include "./spreadsheets/requests/Common.h" 9 | 10 | namespace TextAlignment 11 | { 12 | // The horizontal alignment of text in a cell. 13 | enum HorizontalAlign 14 | { 15 | HORIZONTAL_ALIGN_UNSPECIFIED, // The horizontal alignment is not specified. Do not use this. 16 | LEFT, // The text is explicitly aligned to the left of the cell. 17 | CENTER, // The text is explicitly aligned to the center of the cell. 18 | RIGHT // The text is explicitly aligned to the right of the cell. 19 | }; 20 | 21 | // The vertical alignment of text in a cell. 22 | enum VerticalAlign 23 | { 24 | VERTICAL_ALIGN_UNSPECIFIED, // The vertical alignment is not specified. Do not use this. 25 | TOP, // The text is explicitly aligned to the top of the cell. 26 | MIDDLE, // The text is explicitly aligned to the middle of the cell. 27 | BOTTOM // The text is explicitly aligned to the bottom of the cell. 28 | }; 29 | 30 | const struct GSHEET::key_str_30 _HorizontalAlign[HorizontalAlign::RIGHT + 1] PROGMEM = {"HORIZONTAL_ALIGN_UNSPECIFIED", "LEFT", "CENTER", "RIGHT"}; 31 | 32 | const struct GSHEET::key_str_30 _VerticalAlign[VerticalAlign::BOTTOM + 1] PROGMEM = {"VERTICAL_ALIGN_UNSPECIFIED", "TOP", "MIDDLE", "BOTTOM"}; 33 | 34 | } 35 | 36 | namespace GSHEET 37 | { 38 | 39 | /** 40 | * Position settings for text. 41 | */ 42 | class TextPosition : public BaseG1 43 | { 44 | public: 45 | TextPosition() {} 46 | 47 | // Horizontal alignment setting for the piece of text. 48 | TextPosition &horizontalAlignment(TextAlignment::HorizontalAlign value) { return wr.add(*this, TextAlignment::_HorizontalAlign[value].text, buf, FPSTR(__func__)); } 49 | }; 50 | 51 | } 52 | 53 | #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_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/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_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/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/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/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/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/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 --------------------------------------------------------------------------------