├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── stale.yml └── workflows │ ├── compile_examples.yml │ ├── compile_library.yml │ └── cpp_lint.yml ├── LICENSE ├── README.md ├── _config.yml ├── examples ├── Authentications │ ├── LegacyTokenAuthen │ │ └── LegacyTokenAuthen.ino │ ├── ReAuthenticate │ │ └── ReAuthenticate.ino │ ├── SignInAsAdmin │ │ └── AccessTokenFile │ │ │ ├── AccessTokenFile.ino │ │ │ └── data │ │ │ ├── gtsr1.der │ │ │ └── gtsr1.pem │ ├── SignInAsGuest │ │ └── AnonymousSignin │ │ │ └── AnonymousSignin.ino │ ├── SignInAsUser │ │ ├── CustomToken │ │ │ └── CustomToken.ino │ │ ├── CustomTokenFile │ │ │ └── CustomTokenFile.ino │ │ └── EmailPassword │ │ │ └── EmailPassword.ino │ ├── SignInWithAccessToken │ │ └── SignInWithAccessToken.ino │ ├── SignInWithCustomToken │ │ └── SignInWithCustomToken.ino │ ├── SignInWithIDToken │ │ └── SignInWithIDToken.ino │ ├── SignInWithRefreshAccessToken │ │ └── SignInWithRefreshAccessToken.ino │ ├── SignInWithRefreshIDToken │ │ └── SignInWithRefreshIDToken.ino │ ├── TestMode │ │ └── TestMode.ino │ └── UserManagement │ │ ├── ResetPassword │ │ └── ResetPassword.ino │ │ ├── SendVerification │ │ └── SendVerification.ino │ │ └── Signup │ │ └── Signup.ino ├── CloudFunctions │ ├── CallFunction │ │ └── CallFunction.ino │ ├── CreateFunction │ │ ├── CreateFunctionFromSources │ │ │ └── CreateFunctionFromSources.ino │ │ ├── CreateFunctionWithCallback │ │ │ ├── CreateFunctionWithCallback.ino │ │ │ └── data │ │ │ │ └── helloWorld.zip │ │ ├── CreateFunctionWithEventTrigger │ │ │ ├── CreateFunctionWithEventTrigger.ino │ │ │ ├── data │ │ │ │ └── gcf.zip │ │ │ └── example.png │ │ ├── CreateFunctionWithReturnStatus │ │ │ ├── CreateFunctionWithReturnStatus.ino │ │ │ └── data │ │ │ │ └── helloWorld.zip │ │ └── DeployAutoZipFunction │ │ │ ├── AutoZip.h │ │ │ └── DeployAutoZipFunction.ino │ ├── DeleteFunction │ │ └── DeleteFunction.ino │ ├── DownloadFunction │ │ └── DownloadFunction.ino │ ├── IAMPolicy │ │ ├── CreatePolicy │ │ │ └── CreatePolicy.ino │ │ ├── GetPolicy │ │ │ └── GetPolicy.ino │ │ └── SetPolicy │ │ │ └── SetPolicy.ino │ ├── ListFunctions │ │ └── ListFunctions.ino │ └── PatchFunction │ │ └── PatchFunction.ino ├── ExternalClient │ ├── FCM │ │ └── Ethernet │ │ │ └── ESP32 │ │ │ └── HTTPv1 │ │ │ └── SendMessage │ │ │ └── SendMessage.ino │ └── RTDB │ │ ├── Ethernet │ │ ├── ESP32 │ │ │ ├── Basic │ │ │ │ └── Basic.ino │ │ │ └── StreamCallback │ │ │ │ └── StreamCallback.ino │ │ ├── ESP8266 │ │ │ ├── Basic │ │ │ │ └── Basic.ino │ │ │ └── StreamCallback │ │ │ │ └── StreamCallback.ino │ │ ├── Others │ │ │ └── Basic │ │ │ │ └── Basic.ino │ │ └── Pico │ │ │ ├── Basic │ │ │ └── Basic.ino │ │ │ └── StreamCallback │ │ │ └── StreamCallback.ino │ │ ├── GSM │ │ ├── Basic │ │ │ └── Basic.ino │ │ └── StreamCallback │ │ │ └── StreamCallback.ino │ │ └── Generic │ │ ├── Basic │ │ └── Basic.ino │ │ └── StreamCallback │ │ └── StreamCallback.ino ├── FirebaseJson │ ├── BasicUsage │ │ └── Create_Edit_Parse │ │ │ └── Create_Edit_Parse.ino │ ├── Client │ │ ├── ArduinoMQTT │ │ │ └── ArduinoMQTT.ino │ │ ├── Firebase │ │ │ └── Firebase.ino │ │ ├── WiFiClient │ │ │ └── WiFiClient.ino │ │ └── WiFiClientSecure │ │ │ └── WiFiClientSecure.ino │ └── Stream │ │ ├── File │ │ └── File.ino │ │ └── Serial │ │ └── Serial.ino ├── Firestore │ ├── BatchGetDocuments │ │ └── BatchGetDocuments.ino │ ├── BatchWriteDocuments │ │ └── BatchWriteDocuments.ino │ ├── CommitDocument │ │ ├── AppendArray │ │ │ └── AppendArray.ino │ │ ├── AppendMapValue │ │ │ └── AppendMapValue.ino │ │ ├── AppendMapValueArray │ │ │ └── AppendMapValueArray.ino │ │ ├── AppendMapValueTimestamp │ │ │ └── AppendMapValueTimestamp.ino │ │ ├── IncrementFieldValue │ │ │ └── IncrementFieldValue.ino │ │ └── SetUpdateDelete │ │ │ └── SetUpdateDelete.ino │ ├── CreateDocuments │ │ └── CreateDocuments.ino │ ├── DataQuery │ │ └── DataQuery.ino │ ├── DeleteDocument │ │ └── DeleteDocument.ino │ ├── ExportDocuments │ │ └── ExportDocuments.ino │ ├── GetDocument │ │ └── GetDocument.ino │ ├── ImportDocuments │ │ └── ImportDocuments.ino │ ├── Indexes │ │ ├── CreateIndex │ │ │ └── CreateIndex.ino │ │ └── DeleteIndex │ │ │ └── DeleteIndex.ino │ ├── ListCollectionIds │ │ └── ListCollectionIds.ino │ ├── ListDocuments │ │ └── ListDocuments.ino │ └── PatchDocument │ │ ├── AppendMapValue │ │ └── AppendMapValue.ino │ │ └── UpdateDocument │ │ └── UpdateDocument.ino ├── Messaging │ ├── AppInstanceInfo │ │ └── AppInstanceInfo.ino │ ├── RegistAPNsTokens │ │ └── RegistAPNsTokens.ino │ ├── Send │ │ ├── HTTPv1 │ │ │ ├── SendMessage │ │ │ │ └── SendMessage.ino │ │ │ └── SendTopic │ │ │ │ └── SendTopic.ino │ │ └── LegacyAPI │ │ │ ├── BroadcastMessage │ │ │ └── BroadcastMessage.ino │ │ │ ├── SendMessage │ │ │ └── SendMessage.ino │ │ │ ├── SendMessageEthernet │ │ │ ├── ESP32 │ │ │ │ ├── ESP32.ino │ │ │ │ └── modified_LAN8720_board_images │ │ │ │ │ ├── lan8720_modified_board.png │ │ │ │ │ └── lan8720_modified_schematic.png │ │ │ └── ESP8266 │ │ │ │ └── ESP8266.ino │ │ │ └── SendTopic │ │ │ └── SendTopic.ino │ ├── SubscribeTopic │ │ └── SubscribeTopic.ino │ └── UnsubscribeTopic │ │ └── UnsubscribeTopic.ino ├── README.md ├── RTDB │ ├── BackupRestore │ │ ├── Flash │ │ │ └── Flash.ino │ │ └── SD │ │ │ └── SD.ino │ ├── Basic │ │ └── Basic.ino │ ├── BasicCert │ │ ├── BasicCert.ino │ │ └── data │ │ │ ├── gtsr1.der │ │ │ └── gtsr1.pem │ ├── BasicEthernet │ │ ├── ESP32 │ │ │ ├── ESP32.ino │ │ │ └── modified_LAN8720_board_images │ │ │ │ ├── lan8720_modified_board.png │ │ │ │ └── lan8720_modified_schematic.png │ │ └── ESP8266 │ │ │ └── ESP8266.ino │ ├── Blob │ │ └── Blob.ino │ ├── Blynk │ │ └── Blynk.ino │ ├── Browser │ │ └── index.html │ ├── DataChangesListener │ │ ├── Callback │ │ │ └── Callback.ino │ │ ├── MultiPath │ │ │ └── MultiPath.ino │ │ ├── NoCallback │ │ │ └── NoCallback.ino │ │ └── SingleDataObject │ │ │ └── SingleDataObject.ino │ ├── DataFilter │ │ └── DataFilter.ino │ ├── DataRetaining │ │ └── DataRetaining.ino │ ├── DatabaseRules │ │ └── DatabaseRules.ino │ ├── DownloadFileOTA │ │ └── DownloadFileOTA.ino │ ├── ETag │ │ └── ETag.ino │ ├── File │ │ ├── Flash │ │ │ └── Flash.ino │ │ └── SD │ │ │ └── SD.ino │ ├── Priority │ │ └── Priority.ino │ ├── Queue │ │ └── Queue.ino │ ├── ShallowedData │ │ └── ShallowedData.ino │ └── Timestamp │ │ └── Timestamp.ino └── Storage │ ├── FirebaseStorage │ ├── DeleteFile │ │ └── DeleteFile.ino │ ├── DownloadFile │ │ └── DownloadFile.ino │ ├── DownloadFileOTA │ │ └── DownloadFileOTA.ino │ ├── ListFiles │ │ └── ListFiles.ino │ ├── Metadata │ │ └── Metadata.ino │ ├── UploadByteArrayMemory │ │ └── UploadByteArrayMemory.ino │ └── UploadFile │ │ ├── UploadFile.ino │ │ └── data │ │ └── media.mp4 │ └── GoogleCloudStorage │ ├── DeleteFile │ └── DeleteFile.ino │ ├── DownloadFile │ └── DownloadFile.ino │ ├── DownloadFileOTA │ └── DownloadFileOTA.ino │ ├── ListFiles │ └── ListFiles.ino │ ├── Metadata │ └── Metadata.ino │ └── UploadFile │ ├── UploadFile.ino │ └── data │ └── media.mp4 ├── keywords.txt ├── library.json ├── library.properties ├── media └── images │ ├── API_Key.png │ ├── Anonymous1.png │ ├── Anonymous2.png │ ├── Anonymous3.png │ ├── ArduinoIDE.png │ ├── Create_New_RTDB.png │ ├── Create_New_RTDB2.png │ ├── Create_New_RTDB3.png │ ├── Create_New_RTDB4.png │ ├── ESP32-PSRAM.png │ ├── ESP8266_VM.png │ ├── Enable_Email_Password_Provider.png │ ├── Enable_Email_Password_Provider2.png │ ├── Enable_Email_Password_Provider3.png │ ├── IAM_Permission_Role1.png │ ├── IAM_Permission_Role2.png │ ├── IAM_Permission_Role3.png │ ├── IAM_Permission_Role4.png │ ├── PEM_Download.png │ ├── RTDB_Secret.png │ ├── RTDB_URL.png │ └── Service_Account_Key.png └── src ├── FB_Const.h ├── FB_Error.h ├── FB_Network.h ├── FB_Utils.h ├── Firebase.cpp ├── Firebase.h ├── FirebaseFS.h ├── Firebase_ESP_Client.h ├── README.md ├── addons ├── FireSense │ ├── FireSense.h │ ├── README.md │ └── library.properties ├── RTDBHelper.h ├── SDHelper.h └── TokenHelper.h ├── client ├── FB_TCP_Client.h ├── SSLClient │ ├── ESP_SSLClient.h │ ├── ESP_SSLClient_Const.h │ ├── ESP_SSLClient_FS.h │ ├── bssl │ │ ├── aes_big_cbcdec.c │ │ ├── aes_big_cbcenc.c │ │ ├── aes_big_ctr.c │ │ ├── aes_big_ctrcbc.c │ │ ├── aes_big_dec.c │ │ ├── aes_big_enc.c │ │ ├── aes_common.c │ │ ├── aes_ct.c │ │ ├── aes_ct64.c │ │ ├── aes_ct64_cbcdec.c │ │ ├── aes_ct64_cbcenc.c │ │ ├── aes_ct64_ctr.c │ │ ├── aes_ct64_ctrcbc.c │ │ ├── aes_ct64_dec.c │ │ ├── aes_ct64_enc.c │ │ ├── aes_ct_cbcdec.c │ │ ├── aes_ct_cbcenc.c │ │ ├── aes_ct_ctr.c │ │ ├── aes_ct_ctrcbc.c │ │ ├── aes_ct_dec.c │ │ ├── aes_ct_enc.c │ │ ├── aes_pwr8.c │ │ ├── aes_pwr8_cbcdec.c │ │ ├── aes_pwr8_cbcenc.c │ │ ├── aes_pwr8_ctr.c │ │ ├── aes_pwr8_ctrcbc.c │ │ ├── aes_small_cbcdec.c │ │ ├── aes_small_cbcenc.c │ │ ├── aes_small_ctr.c │ │ ├── aes_small_ctrcbc.c │ │ ├── aes_small_dec.c │ │ ├── aes_small_enc.c │ │ ├── aes_x86ni.c │ │ ├── aes_x86ni_cbcdec.c │ │ ├── aes_x86ni_cbcenc.c │ │ ├── aes_x86ni_ctr.c │ │ ├── aes_x86ni_ctrcbc.c │ │ ├── aesctr_drbg.c │ │ ├── asn1.t0 │ │ ├── asn1enc.c │ │ ├── bearssl.h │ │ ├── bearssl_aead.h │ │ ├── bearssl_block.h │ │ ├── bearssl_ec.h │ │ ├── bearssl_hash.h │ │ ├── bearssl_hmac.h │ │ ├── bearssl_kdf.h │ │ ├── bearssl_pem.h │ │ ├── bearssl_prf.h │ │ ├── bearssl_rand.h │ │ ├── bearssl_rsa.h │ │ ├── bearssl_ssl.h │ │ ├── bearssl_x509.h │ │ ├── ccm.c │ │ ├── ccopy.c │ │ ├── chacha20_ct.c │ │ ├── chacha20_sse2.c │ │ ├── config.h │ │ ├── dec16be.c │ │ ├── dec16le.c │ │ ├── dec32be.c │ │ ├── dec32le.c │ │ ├── dec64be.c │ │ ├── dec64le.c │ │ ├── des_ct.c │ │ ├── des_ct_cbcdec.c │ │ ├── des_ct_cbcenc.c │ │ ├── des_support.c │ │ ├── des_tab.c │ │ ├── des_tab_cbcdec.c │ │ ├── des_tab_cbcenc.c │ │ ├── dig_oid.c │ │ ├── dig_size.c │ │ ├── eax.c │ │ ├── ec_all_m15.c │ │ ├── ec_all_m31.c │ │ ├── ec_c25519_i15.c │ │ ├── ec_c25519_i31.c │ │ ├── ec_c25519_m15.c │ │ ├── ec_c25519_m31.c │ │ ├── ec_c25519_m62.c │ │ ├── ec_c25519_m64.c │ │ ├── ec_curve25519.c │ │ ├── ec_default.c │ │ ├── ec_keygen.c │ │ ├── ec_p256_m15.c │ │ ├── ec_p256_m31.c │ │ ├── ec_p256_m62.c │ │ ├── ec_p256_m64.c │ │ ├── ec_prime_i15.c │ │ ├── ec_prime_i31.c │ │ ├── ec_pubkey.c │ │ ├── ec_secp256r1.c │ │ ├── ec_secp384r1.c │ │ ├── ec_secp521r1.c │ │ ├── ecdsa_atr.c │ │ ├── ecdsa_default_sign_asn1.c │ │ ├── ecdsa_default_sign_raw.c │ │ ├── ecdsa_default_vrfy_asn1.c │ │ ├── ecdsa_default_vrfy_raw.c │ │ ├── ecdsa_i15_bits.c │ │ ├── ecdsa_i15_sign_asn1.c │ │ ├── ecdsa_i15_sign_raw.c │ │ ├── ecdsa_i15_vrfy_asn1.c │ │ ├── ecdsa_i15_vrfy_raw.c │ │ ├── ecdsa_i31_bits.c │ │ ├── ecdsa_i31_sign_asn1.c │ │ ├── ecdsa_i31_sign_raw.c │ │ ├── ecdsa_i31_vrfy_asn1.c │ │ ├── ecdsa_i31_vrfy_raw.c │ │ ├── ecdsa_rta.c │ │ ├── enc16be.c │ │ ├── enc16le.c │ │ ├── enc32be.c │ │ ├── enc32le.c │ │ ├── enc64be.c │ │ ├── enc64le.c │ │ ├── encode_ec_pk8der.c │ │ ├── encode_ec_rawder.c │ │ ├── encode_rsa_pk8der.c │ │ ├── encode_rsa_rawder.c │ │ ├── gcm.c │ │ ├── ghash_ctmul.c │ │ ├── ghash_ctmul32.c │ │ ├── ghash_ctmul64.c │ │ ├── ghash_pclmul.c │ │ ├── ghash_pwr8.c │ │ ├── hkdf.c │ │ ├── hmac.c │ │ ├── hmac_ct.c │ │ ├── hmac_drbg.c │ │ ├── i15_add.c │ │ ├── i15_bitlen.c │ │ ├── i15_decmod.c │ │ ├── i15_decode.c │ │ ├── i15_decred.c │ │ ├── i15_encode.c │ │ ├── i15_fmont.c │ │ ├── i15_iszero.c │ │ ├── i15_moddiv.c │ │ ├── i15_modpow.c │ │ ├── i15_modpow2.c │ │ ├── i15_montmul.c │ │ ├── i15_mulacc.c │ │ ├── i15_muladd.c │ │ ├── i15_ninv15.c │ │ ├── i15_reduce.c │ │ ├── i15_rshift.c │ │ ├── i15_sub.c │ │ ├── i15_tmont.c │ │ ├── i31_add.c │ │ ├── i31_bitlen.c │ │ ├── i31_decmod.c │ │ ├── i31_decode.c │ │ ├── i31_decred.c │ │ ├── i31_encode.c │ │ ├── i31_fmont.c │ │ ├── i31_iszero.c │ │ ├── i31_moddiv.c │ │ ├── i31_modpow.c │ │ ├── i31_modpow2.c │ │ ├── i31_montmul.c │ │ ├── i31_mulacc.c │ │ ├── i31_muladd.c │ │ ├── i31_ninv31.c │ │ ├── i31_reduce.c │ │ ├── i31_rshift.c │ │ ├── i31_sub.c │ │ ├── i31_tmont.c │ │ ├── i32_add.c │ │ ├── i32_bitlen.c │ │ ├── i32_decmod.c │ │ ├── i32_decode.c │ │ ├── i32_decred.c │ │ ├── i32_div32.c │ │ ├── i32_encode.c │ │ ├── i32_fmont.c │ │ ├── i32_iszero.c │ │ ├── i32_modpow.c │ │ ├── i32_montmul.c │ │ ├── i32_mulacc.c │ │ ├── i32_muladd.c │ │ ├── i32_ninv32.c │ │ ├── i32_reduce.c │ │ ├── i32_sub.c │ │ ├── i32_tmont.c │ │ ├── i62_modpow2.c │ │ ├── inner.h │ │ ├── md5.c │ │ ├── md5sha1.c │ │ ├── mgf1.c │ │ ├── multihash.c │ │ ├── pemdec.c │ │ ├── pemdec.t0 │ │ ├── pemenc.c │ │ ├── pkey_decoder.c │ │ ├── poly1305_ctmul.c │ │ ├── poly1305_ctmul32.c │ │ ├── poly1305_ctmulq.c │ │ ├── poly1305_i15.c │ │ ├── prf.c │ │ ├── prf_md5sha1.c │ │ ├── prf_sha256.c │ │ ├── prf_sha384.c │ │ ├── rsa_default_keygen.c │ │ ├── rsa_default_modulus.c │ │ ├── rsa_default_oaep_decrypt.c │ │ ├── rsa_default_oaep_encrypt.c │ │ ├── rsa_default_pkcs1_sign.c │ │ ├── rsa_default_pkcs1_vrfy.c │ │ ├── rsa_default_priv.c │ │ ├── rsa_default_privexp.c │ │ ├── rsa_default_pss_sign.c │ │ ├── rsa_default_pss_vrfy.c │ │ ├── rsa_default_pub.c │ │ ├── rsa_default_pubexp.c │ │ ├── rsa_i15_keygen.c │ │ ├── rsa_i15_modulus.c │ │ ├── rsa_i15_oaep_decrypt.c │ │ ├── rsa_i15_oaep_encrypt.c │ │ ├── rsa_i15_pkcs1_sign.c │ │ ├── rsa_i15_pkcs1_vrfy.c │ │ ├── rsa_i15_priv.c │ │ ├── rsa_i15_privexp.c │ │ ├── rsa_i15_pss_sign.c │ │ ├── rsa_i15_pss_vrfy.c │ │ ├── rsa_i15_pub.c │ │ ├── rsa_i15_pubexp.c │ │ ├── rsa_i31_keygen.c │ │ ├── rsa_i31_keygen_inner.c │ │ ├── rsa_i31_modulus.c │ │ ├── rsa_i31_oaep_decrypt.c │ │ ├── rsa_i31_oaep_encrypt.c │ │ ├── rsa_i31_pkcs1_sign.c │ │ ├── rsa_i31_pkcs1_vrfy.c │ │ ├── rsa_i31_priv.c │ │ ├── rsa_i31_privexp.c │ │ ├── rsa_i31_pss_sign.c │ │ ├── rsa_i31_pss_vrfy.c │ │ ├── rsa_i31_pub.c │ │ ├── rsa_i31_pubexp.c │ │ ├── rsa_i32_oaep_decrypt.c │ │ ├── rsa_i32_oaep_encrypt.c │ │ ├── rsa_i32_pkcs1_sign.c │ │ ├── rsa_i32_pkcs1_vrfy.c │ │ ├── rsa_i32_priv.c │ │ ├── rsa_i32_pss_sign.c │ │ ├── rsa_i32_pss_vrfy.c │ │ ├── rsa_i32_pub.c │ │ ├── rsa_i62_keygen.c │ │ ├── rsa_i62_oaep_decrypt.c │ │ ├── rsa_i62_oaep_encrypt.c │ │ ├── rsa_i62_pkcs1_sign.c │ │ ├── rsa_i62_pkcs1_vrfy.c │ │ ├── rsa_i62_priv.c │ │ ├── rsa_i62_pss_sign.c │ │ ├── rsa_i62_pss_vrfy.c │ │ ├── rsa_i62_pub.c │ │ ├── rsa_oaep_pad.c │ │ ├── rsa_oaep_unpad.c │ │ ├── rsa_pkcs1_sig_pad.c │ │ ├── rsa_pkcs1_sig_unpad.c │ │ ├── rsa_pss_sig_pad.c │ │ ├── rsa_pss_sig_unpad.c │ │ ├── rsa_ssl_decrypt.c │ │ ├── settings.c │ │ ├── sha1.c │ │ ├── sha2big.c │ │ ├── sha2small.c │ │ ├── shake.c │ │ ├── skey_decoder.c │ │ ├── skey_decoder.t0 │ │ ├── ssl_ccert_single_ec.c │ │ ├── ssl_ccert_single_rsa.c │ │ ├── ssl_client.c │ │ ├── ssl_client_default_rsapub.c │ │ ├── ssl_client_full.c │ │ ├── ssl_engine.c │ │ ├── ssl_engine_default_aescbc.c │ │ ├── ssl_engine_default_aesccm.c │ │ ├── ssl_engine_default_aesgcm.c │ │ ├── ssl_engine_default_chapol.c │ │ ├── ssl_engine_default_descbc.c │ │ ├── ssl_engine_default_ec.c │ │ ├── ssl_engine_default_ecdsa.c │ │ ├── ssl_engine_default_rsavrfy.c │ │ ├── ssl_hashes.c │ │ ├── ssl_hs_client.c │ │ ├── ssl_hs_client.t0 │ │ ├── ssl_hs_common.t0 │ │ ├── ssl_hs_server.c │ │ ├── ssl_hs_server.t0 │ │ ├── ssl_io.c │ │ ├── ssl_keyexport.c │ │ ├── ssl_lru.c │ │ ├── ssl_rec_cbc.c │ │ ├── ssl_rec_ccm.c │ │ ├── ssl_rec_chapol.c │ │ ├── ssl_rec_gcm.c │ │ ├── ssl_scert_single_ec.c │ │ ├── ssl_scert_single_rsa.c │ │ ├── ssl_server.c │ │ ├── ssl_server_full_ec.c │ │ ├── ssl_server_full_rsa.c │ │ ├── ssl_server_mine2c.c │ │ ├── ssl_server_mine2g.c │ │ ├── ssl_server_minf2c.c │ │ ├── ssl_server_minf2g.c │ │ ├── ssl_server_minr2g.c │ │ ├── ssl_server_minu2g.c │ │ ├── ssl_server_minv2g.c │ │ ├── sysrng.c │ │ ├── x509_decoder.c │ │ ├── x509_decoder.t0 │ │ ├── x509_knownkey.c │ │ ├── x509_minimal.c │ │ ├── x509_minimal.t0 │ │ └── x509_minimal_full.c │ └── client │ │ ├── BSSL_CertStore.cpp │ │ ├── BSSL_CertStore.h │ │ ├── BSSL_Helper.cpp │ │ ├── BSSL_Helper.h │ │ ├── BSSL_SSL_Client.cpp │ │ ├── BSSL_SSL_Client.h │ │ ├── BSSL_TCP_Client.cpp │ │ ├── BSSL_TCP_Client.h │ │ └── stm32_time_fix.c └── WiFiClientImpl.h ├── core ├── FirebaseCore.cpp ├── FirebaseCore.h ├── Firebase_Build_Options.h └── Firebase_Client_Version.h ├── firestore ├── FB_Firestore.cpp └── FB_Firestore.h ├── functions ├── FB_Functions.cpp ├── FB_Functions.h ├── FunctionsConfig.cpp ├── FunctionsConfig.h ├── PocicyBuilder.cpp └── PolicyBuilder.h ├── gcs ├── GCS.cpp └── GCS.h ├── json ├── FirebaseJson.cpp ├── FirebaseJson.h ├── MB_JSON │ ├── MB_JSON.c │ └── MB_JSON.h ├── MB_List.h ├── MB_String.h └── extras │ └── print │ ├── fb_json_print.c │ └── fb_json_print.h ├── mbfs ├── MB_FS.h ├── MB_FS_Interfaces.h └── MB_MCU.h ├── message ├── FCM.cpp ├── FCM.h └── LFCM.h ├── rtdb ├── FB_RTDB.cpp ├── FB_RTDB.h ├── QueryFilter.cpp ├── QueryFilter.h ├── QueueInfo.cpp ├── QueueInfo.h ├── QueueManager.cpp ├── QueueManager.h └── stream │ ├── FB_MP_Stream.cpp │ ├── FB_MP_Stream.h │ ├── FB_Stream.cpp │ └── FB_Stream.h ├── session ├── FB_Session.cpp └── FB_Session.h └── storage ├── FCS.cpp └── FCS.h /.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 | -------------------------------------------------------------------------------- /.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/Firebase-ESP-Client/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 | -------------------------------------------------------------------------------- /.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/Firebase-ESP-Client/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/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/workflows/cpp_lint.yml: -------------------------------------------------------------------------------- 1 | name: cpplint 2 | 3 | on: 4 | pull_request: 5 | paths-ignore: 6 | - '.github/workflows/compile_*.yml' 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - name: cpplint 13 | uses: reviewdog/action-cpplint@master 14 | with: 15 | github_token: ${{ secrets.GITHUB_TOKEN }} 16 | reporter: github-pr-check 17 | flags: --linelength=100 18 | filter: "-whitespace/tab\ 19 | ,-readability/braces\ 20 | ,-whitespace/braces\ 21 | ,-whitespace/comments\ 22 | ,-whitespace/indent\ 23 | ,-whitespace/newline\ 24 | ,-whitespace/operators\ 25 | ,-whitespace/parens\ 26 | " -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-slate -------------------------------------------------------------------------------- /examples/Authentications/SignInAsAdmin/AccessTokenFile/data/gtsr1.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/Authentications/SignInAsAdmin/AccessTokenFile/data/gtsr1.der -------------------------------------------------------------------------------- /examples/Authentications/SignInAsAdmin/AccessTokenFile/data/gtsr1.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIFVzCCAz+gAwIBAgINAgPlk28xsBNJiGuiFzANBgkqhkiG9w0BAQwFADBHMQsw 3 | CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU 4 | MBIGA1UEAxMLR1RTIFJvb3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw 5 | MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp 6 | Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIiMA0GCSqGSIb3DQEBAQUA 7 | A4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx9vaMf/vo 8 | 27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7w 9 | Cl7raKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjw 10 | TcLCeoiKu7rPWRnWr4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0Pfybl 11 | qAj+lug8aJRT7oM6iCsVlgmy4HqMLnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaH 12 | szVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly4cpk9+aCEI3oncKKiPo4Zor8 13 | Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr06zqkUspzBmk 14 | MiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92 15 | wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70p 16 | aDPvOmbsB4om3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrN 17 | VjzRlwW5y0vtOUucxD/SVRNuJLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQID 18 | AQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E 19 | FgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEMBQADggIBAJ+qQibb 20 | C5u+/x6Wki4+omVKapi6Ist9wTrYggoGxval3sBOh2Z5ofmmWJyq+bXmYOfg6LEe 21 | QkEzCzc9zolwFcq1JKjPa7XSQCGYzyI0zzvFIoTgxQ6KfF2I5DUkzps+GlQebtuy 22 | h6f88/qBVRRiClmpIgUxPoLW7ttXNLwzldMXG+gnoot7TiYaelpkttGsN/H9oPM4 23 | 7HLwEXWdyzRSjeZ2axfG34arJ45JK3VmgRAhpuo+9K4l/3wV3s6MJT/KYnAK9y8J 24 | ZgfIPxz88NtFMN9iiMG1D53Dn0reWVlHxYciNuaCp+0KueIHoI17eko8cdLiA6Ef 25 | MgfdG+RCzgwARWGAtQsgWSl4vflVy2PFPEz0tv/bal8xa5meLMFrUKTX5hgUvYU/ 26 | Z6tGn6D/Qqc6f1zLXbBwHSs09dR2CQzreExZBfMzQsNhFRAbd03OIozUhfJFfbdT 27 | 6u9AWpQKXCBfTkBdYiJ23//OYb2MI3jSNwLgjt7RETeJ9r/tSQdirpLsQBqvFAnZ 28 | 0E6yove+7u7Y/9waLd64NnHi/Hm3lCXRSHNboTXns5lndcEZOitHTtNCjv0xyBZm 29 | 2tIMPNuzjsmhDYAPexZ3FL//2wmUspO8IFgV6dtxQ/PeEMMA3KgqlbbC1j+Qa3bb 30 | bP6MvPJwNQzcmRk13NfIRmPVNnGuV/u3gm3c 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /examples/CloudFunctions/CreateFunction/CreateFunctionWithCallback/data/helloWorld.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/CloudFunctions/CreateFunction/CreateFunctionWithCallback/data/helloWorld.zip -------------------------------------------------------------------------------- /examples/CloudFunctions/CreateFunction/CreateFunctionWithEventTrigger/data/gcf.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/CloudFunctions/CreateFunction/CreateFunctionWithEventTrigger/data/gcf.zip -------------------------------------------------------------------------------- /examples/CloudFunctions/CreateFunction/CreateFunctionWithEventTrigger/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/CloudFunctions/CreateFunction/CreateFunctionWithEventTrigger/example.png -------------------------------------------------------------------------------- /examples/CloudFunctions/CreateFunction/CreateFunctionWithReturnStatus/data/helloWorld.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/CloudFunctions/CreateFunction/CreateFunctionWithReturnStatus/data/helloWorld.zip -------------------------------------------------------------------------------- /examples/FirebaseJson/Stream/Serial/Serial.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by K. Suwatchai (Mobizt) 3 | * 4 | * Email: k_suwatchai@hotmail.com 5 | * 6 | * Github: https://github.com/mobizt/FirebaseJson 7 | * 8 | * Copyright (c) 2023 mobizt 9 | * 10 | */ 11 | 12 | #include 13 | #include 14 | 15 | FirebaseJson json; 16 | 17 | void setup() 18 | { 19 | Serial.begin(115200); 20 | Serial.println(); 21 | } 22 | 23 | void loop() 24 | { 25 | // No matter what JSON data separation is newline or any. 26 | if (json.readFrom(Serial)) 27 | { 28 | Serial.println("JSON Data received..."); 29 | json.toString(Serial, true); 30 | Serial.println(); 31 | } 32 | } -------------------------------------------------------------------------------- /examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP32/modified_LAN8720_board_images/lan8720_modified_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP32/modified_LAN8720_board_images/lan8720_modified_board.png -------------------------------------------------------------------------------- /examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP32/modified_LAN8720_board_images/lan8720_modified_schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/Messaging/Send/LegacyAPI/SendMessageEthernet/ESP32/modified_LAN8720_board_images/lan8720_modified_schematic.png -------------------------------------------------------------------------------- /examples/RTDB/BasicCert/data/gtsr1.der: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/RTDB/BasicCert/data/gtsr1.der -------------------------------------------------------------------------------- /examples/RTDB/BasicCert/data/gtsr1.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIFVzCCAz+gAwIBAgINAgPlk28xsBNJiGuiFzANBgkqhkiG9w0BAQwFADBHMQsw 3 | CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU 4 | MBIGA1UEAxMLR1RTIFJvb3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw 5 | MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp 6 | Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIiMA0GCSqGSIb3DQEBAQUA 7 | A4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx9vaMf/vo 8 | 27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7w 9 | Cl7raKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjw 10 | TcLCeoiKu7rPWRnWr4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0Pfybl 11 | qAj+lug8aJRT7oM6iCsVlgmy4HqMLnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaH 12 | szVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly4cpk9+aCEI3oncKKiPo4Zor8 13 | Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr06zqkUspzBmk 14 | MiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92 15 | wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70p 16 | aDPvOmbsB4om3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrN 17 | VjzRlwW5y0vtOUucxD/SVRNuJLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQID 18 | AQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E 19 | FgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEMBQADggIBAJ+qQibb 20 | C5u+/x6Wki4+omVKapi6Ist9wTrYggoGxval3sBOh2Z5ofmmWJyq+bXmYOfg6LEe 21 | QkEzCzc9zolwFcq1JKjPa7XSQCGYzyI0zzvFIoTgxQ6KfF2I5DUkzps+GlQebtuy 22 | h6f88/qBVRRiClmpIgUxPoLW7ttXNLwzldMXG+gnoot7TiYaelpkttGsN/H9oPM4 23 | 7HLwEXWdyzRSjeZ2axfG34arJ45JK3VmgRAhpuo+9K4l/3wV3s6MJT/KYnAK9y8J 24 | ZgfIPxz88NtFMN9iiMG1D53Dn0reWVlHxYciNuaCp+0KueIHoI17eko8cdLiA6Ef 25 | MgfdG+RCzgwARWGAtQsgWSl4vflVy2PFPEz0tv/bal8xa5meLMFrUKTX5hgUvYU/ 26 | Z6tGn6D/Qqc6f1zLXbBwHSs09dR2CQzreExZBfMzQsNhFRAbd03OIozUhfJFfbdT 27 | 6u9AWpQKXCBfTkBdYiJ23//OYb2MI3jSNwLgjt7RETeJ9r/tSQdirpLsQBqvFAnZ 28 | 0E6yove+7u7Y/9waLd64NnHi/Hm3lCXRSHNboTXns5lndcEZOitHTtNCjv0xyBZm 29 | 2tIMPNuzjsmhDYAPexZ3FL//2wmUspO8IFgV6dtxQ/PeEMMA3KgqlbbC1j+Qa3bb 30 | bP6MvPJwNQzcmRk13NfIRmPVNnGuV/u3gm3c 31 | -----END CERTIFICATE----- 32 | -------------------------------------------------------------------------------- /examples/RTDB/BasicEthernet/ESP32/modified_LAN8720_board_images/lan8720_modified_board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/RTDB/BasicEthernet/ESP32/modified_LAN8720_board_images/lan8720_modified_board.png -------------------------------------------------------------------------------- /examples/RTDB/BasicEthernet/ESP32/modified_LAN8720_board_images/lan8720_modified_schematic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/RTDB/BasicEthernet/ESP32/modified_LAN8720_board_images/lan8720_modified_schematic.png -------------------------------------------------------------------------------- /examples/Storage/FirebaseStorage/UploadFile/data/media.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/Storage/FirebaseStorage/UploadFile/data/media.mp4 -------------------------------------------------------------------------------- /examples/Storage/GoogleCloudStorage/UploadFile/data/media.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/examples/Storage/GoogleCloudStorage/UploadFile/data/media.mp4 -------------------------------------------------------------------------------- /library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Firebase Arduino Client Library for ESP8266 and ESP32", 3 | "version": "4.4.17", 4 | "keywords": "communication, REST, esp32, esp8266, arduino", 5 | "description": "The library supports Firebase products e.g. Realtime database, Cloud Firestore database, Firebase Storage and Google Cloud Storage, Cloud Functions for Firebase and Cloud Messaging. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/mobizt/Firebase-ESP-Client.git" 9 | }, 10 | "authors": [{ 11 | "name": "Mobizt", 12 | "email": "k_suwatchai@hotmail.com" 13 | }], 14 | "frameworks": "arduino", 15 | "platforms": "espressif32, espressif8266, atmelsam, rp2040, atmelavr, atmelmegaavr, ststm32, teensy" 16 | } 17 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=Firebase Arduino Client Library for ESP8266 and ESP32 2 | 3 | version=4.4.17 4 | 5 | author=Mobizt 6 | 7 | maintainer=Mobizt 8 | 9 | sentence=Google Firebase Arduino Client Library for Espressif ESP8266 and ESP32 10 | 11 | paragraph=The library supports Firebase products e.g. Realtime database, Cloud Firestore database, Firebase Storage and Google Cloud Storage, Cloud Functions for Firebase and Cloud Messaging. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient. 12 | 13 | category=Communication 14 | 15 | url=https://github.com/mobizt/Firebase-ESP-Client 16 | 17 | architectures=esp8266,esp32,sam,samd,stm32,STM32F1,STM32F4,teensy,avr,megaavr,mbed_nano,mbed_rp2040,rp2040 18 | -------------------------------------------------------------------------------- /media/images/API_Key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/API_Key.png -------------------------------------------------------------------------------- /media/images/Anonymous1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/Anonymous1.png -------------------------------------------------------------------------------- /media/images/Anonymous2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/Anonymous2.png -------------------------------------------------------------------------------- /media/images/Anonymous3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/Anonymous3.png -------------------------------------------------------------------------------- /media/images/ArduinoIDE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/ArduinoIDE.png -------------------------------------------------------------------------------- /media/images/Create_New_RTDB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/Create_New_RTDB.png -------------------------------------------------------------------------------- /media/images/Create_New_RTDB2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/Create_New_RTDB2.png -------------------------------------------------------------------------------- /media/images/Create_New_RTDB3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/Create_New_RTDB3.png -------------------------------------------------------------------------------- /media/images/Create_New_RTDB4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/Create_New_RTDB4.png -------------------------------------------------------------------------------- /media/images/ESP32-PSRAM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/ESP32-PSRAM.png -------------------------------------------------------------------------------- /media/images/ESP8266_VM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/ESP8266_VM.png -------------------------------------------------------------------------------- /media/images/Enable_Email_Password_Provider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/Enable_Email_Password_Provider.png -------------------------------------------------------------------------------- /media/images/Enable_Email_Password_Provider2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/Enable_Email_Password_Provider2.png -------------------------------------------------------------------------------- /media/images/Enable_Email_Password_Provider3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/Enable_Email_Password_Provider3.png -------------------------------------------------------------------------------- /media/images/IAM_Permission_Role1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/IAM_Permission_Role1.png -------------------------------------------------------------------------------- /media/images/IAM_Permission_Role2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/IAM_Permission_Role2.png -------------------------------------------------------------------------------- /media/images/IAM_Permission_Role3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/IAM_Permission_Role3.png -------------------------------------------------------------------------------- /media/images/IAM_Permission_Role4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/IAM_Permission_Role4.png -------------------------------------------------------------------------------- /media/images/PEM_Download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/PEM_Download.png -------------------------------------------------------------------------------- /media/images/RTDB_Secret.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/RTDB_Secret.png -------------------------------------------------------------------------------- /media/images/RTDB_URL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/RTDB_URL.png -------------------------------------------------------------------------------- /media/images/Service_Account_Key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mobizt/Firebase-ESP-Client/3d2629898db4cd8f9460b0558e84987e696d6a43/media/images/Service_Account_Key.png -------------------------------------------------------------------------------- /src/Firebase_ESP_Client.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Google's Firebase ESP Client Main class, Firebase_ESP_Client.h 4 | * 5 | * This library supports Arduino devices except for AVR. 6 | * 7 | * Created April 5, 2023 8 | * 9 | * 10 | * This work is a part of Firebase ESP Client library 11 | * Copyright (c) 2023 K. Suwatchai (Mobizt) 12 | * 13 | * The MIT License (MIT) 14 | * Copyright (c) 2023 K. Suwatchai (Mobizt) 15 | * 16 | * 17 | * Permission is hereby granted, free of charge, to any person returning a copy of 18 | * this software and associated documentation files (the "Software"), to deal in 19 | * the Software without restriction, including without limitation the rights to 20 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 21 | * the Software, and to permit persons to whom the Software is furnished to do so, 22 | * subject to the following conditions: 23 | * 24 | * The above copyright notice and this permission notice shall be included in all 25 | * copies or substantial portions of the Software. 26 | * 27 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 29 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 30 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 31 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 | */ 34 | #include "Firebase.h" -------------------------------------------------------------------------------- /src/addons/FireSense/library.properties: -------------------------------------------------------------------------------- 1 | name=FireSense Addon for Firebase ESP Client. 2 | 3 | version=1.0.14 4 | 5 | author=Mobizt 6 | 7 | maintainer=Mobizt 8 | 9 | sentence=The Programmable Data Logging and IO Control library. 10 | 11 | paragraph=This addon library is the programmable IO controller which works with Firebase. 12 | 13 | category=Communication 14 | 15 | url=https://github.com/mobizt/Firebase-ESP-Client/src/addons/FireSense 16 | 17 | architectures=esp8266,esp32,sam,samd,stm32,STM32F1,STM32F4,teensy,avr,megaavr,mbed_nano,mbed_rp2040 18 | -------------------------------------------------------------------------------- /src/client/SSLClient/ESP_SSLClient_FS.h: -------------------------------------------------------------------------------- 1 | #ifndef ESP_SSLClient_FS_H 2 | #define ESP_SSLClient_FS_H 3 | 4 | #if (defined(ESP8266) || defined(ARDUINO_ARCH_RP2040)) && !defined(ARDUINO_NANO_RP2040_CONNECT) 5 | // for ESP8266 and Raspberry Pi Pico (RP2040) only except for Arduino Nano RP2040 Connect 6 | #define USE_EMBED_SSL_ENGINE 7 | #else 8 | #define USE_LIB_SSL_ENGINE 9 | #endif 10 | 11 | #pragma once 12 | 13 | // for enable debugging 14 | #define ESP_SSLCLIENT_ENABLE_DEBUG 15 | 16 | /** Call ssl_client.setDebugLevel(x) to set the debug 17 | * esp_ssl_debug_none = 0 18 | * esp_ssl_debug_error = 1 19 | * esp_ssl_debug_warn = 2 20 | * esp_ssl_debug_info = 3 21 | * esp_ssl_debug_dump = 4 22 | */ 23 | 24 | // for debug port 25 | #define ESP_SSLCLIENT_DEBUG_PORT Serial 26 | 27 | // for SSL Error String 28 | #define ESP_SSLCLIENT_ENABLE_SSL_ERROR_STRING 29 | 30 | // for Filesystem support that required for CertStore 31 | #define ESP_SSLCLIENT_USE_FILESYSTEM 32 | 33 | // For external SRAM (PSRAM) support 34 | #define ESP_SSLCLIENT_USE_PSRAM 35 | 36 | #if defined __has_include 37 | #if __has_include() 38 | #include "Custom_ESP_SSLClient_FS.h" 39 | #endif 40 | #endif 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ccopy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_ccopy(uint32_t ctl, void *dst, const void *src, size_t len) 33 | { 34 | unsigned char *d; 35 | const unsigned char *s; 36 | 37 | d = dst; 38 | s = src; 39 | while (len -- > 0) { 40 | uint32_t x, y; 41 | 42 | x = *s ++; 43 | y = *d; 44 | *d = MUX(ctl, x, y); 45 | d ++; 46 | } 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec16be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec16be(uint16_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec16be(buf); 39 | buf += 2; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec16le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec16le(uint16_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec16le(buf); 39 | buf += 2; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec32be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec32be(uint32_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec32be(buf); 39 | buf += 4; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec32le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec32le(uint32_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec32le(buf); 39 | buf += 4; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec64be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec64be(uint64_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec64be(buf); 39 | buf += 8; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dec64le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_dec64le(uint64_t *v, size_t num, const void *src) 33 | { 34 | const unsigned char *buf; 35 | 36 | buf = src; 37 | while (num -- > 0) { 38 | *v ++ = br_dec64le(buf); 39 | buf += 8; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/dig_size.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | size_t 32 | br_digest_size_by_ID(int digest_id) 33 | { 34 | switch (digest_id) { 35 | case br_md5sha1_ID: 36 | return br_md5_SIZE + br_sha1_SIZE; 37 | case br_md5_ID: 38 | return br_md5_SIZE; 39 | case br_sha1_ID: 40 | return br_sha1_SIZE; 41 | case br_sha224_ID: 42 | return br_sha224_SIZE; 43 | case br_sha256_ID: 44 | return br_sha256_SIZE; 45 | case br_sha384_ID: 46 | return br_sha384_SIZE; 47 | case br_sha512_ID: 48 | return br_sha512_SIZE; 49 | default: 50 | /* abort(); */ 51 | return 0; 52 | } 53 | } 54 | 55 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ec_curve25519.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | static const unsigned char GEN[] = { 31 | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 35 | }; 36 | 37 | static const unsigned char ORDER[] = { 38 | 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 39 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 40 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 41 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF 42 | }; 43 | 44 | /* see inner.h */ 45 | const br_ec_curve_def br_curve25519 = { 46 | BR_EC_curve25519, 47 | ORDER, sizeof ORDER, 48 | GEN, sizeof GEN 49 | }; 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ec_default.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ec.h */ 31 | const br_ec_impl * 32 | br_ec_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_ec_all_m15; 36 | #else 37 | return &br_ec_all_m31; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_default_sign_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ec.h */ 31 | br_ecdsa_sign 32 | br_ecdsa_sign_asn1_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_ecdsa_i15_sign_asn1; 36 | #else 37 | return &br_ecdsa_i31_sign_asn1; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_default_sign_raw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ec.h */ 31 | br_ecdsa_sign 32 | br_ecdsa_sign_raw_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_ecdsa_i15_sign_raw; 36 | #else 37 | return &br_ecdsa_i31_sign_raw; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_default_vrfy_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ec.h */ 31 | br_ecdsa_vrfy 32 | br_ecdsa_vrfy_asn1_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_ecdsa_i15_vrfy_asn1; 36 | #else 37 | return &br_ecdsa_i31_vrfy_asn1; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_default_vrfy_raw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ec.h */ 31 | br_ecdsa_vrfy 32 | br_ecdsa_vrfy_raw_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_ecdsa_i15_vrfy_raw; 36 | #else 37 | return &br_ecdsa_i31_vrfy_raw; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i15_bits.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_ecdsa_i15_bits2int(uint16_t *x, 33 | const void *src, size_t len, uint32_t ebitlen) 34 | { 35 | uint32_t bitlen, hbitlen; 36 | int sc; 37 | 38 | bitlen = ebitlen - (ebitlen >> 4); 39 | hbitlen = (uint32_t)len << 3; 40 | if (hbitlen > bitlen) { 41 | len = (bitlen + 7) >> 3; 42 | sc = (int)((hbitlen - bitlen) & 7); 43 | } else { 44 | sc = 0; 45 | } 46 | br_i15_zero(x, ebitlen); 47 | br_i15_decode(x, src, len); 48 | br_i15_rshift(x, sc); 49 | x[0] = ebitlen; 50 | } 51 | 52 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i15_sign_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #define ORDER_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 31 | 32 | /* see bearssl_ec.h */ 33 | size_t 34 | br_ecdsa_i15_sign_asn1(const br_ec_impl *impl, 35 | const br_hash_class *hf, const void *hash_value, 36 | const br_ec_private_key *sk, void *sig) 37 | { 38 | unsigned char rsig[(ORDER_LEN << 1) + 12]; 39 | size_t sig_len; 40 | 41 | sig_len = br_ecdsa_i15_sign_raw(impl, hf, hash_value, sk, rsig); 42 | if (sig_len == 0) { 43 | return 0; 44 | } 45 | sig_len = br_ecdsa_raw_to_asn1(rsig, sig_len); 46 | memcpy(sig, rsig, sig_len); 47 | return sig_len; 48 | } 49 | 50 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i15_vrfy_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | #include "../ESP_SSLClient_FS.h" 27 | #if defined(USE_LIB_SSL_ENGINE) 28 | 29 | #include "inner.h" 30 | 31 | #define FIELD_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 32 | 33 | /* see bearssl_ec.h */ 34 | uint32_t 35 | br_ecdsa_i15_vrfy_asn1(const br_ec_impl *impl, 36 | const void *hash, size_t hash_len, 37 | const br_ec_public_key *pk, 38 | const void *sig, size_t sig_len) 39 | { 40 | /* 41 | * We use a double-sized buffer because a malformed ASN.1 signature 42 | * may trigger a size expansion when converting to "raw" format. 43 | */ 44 | unsigned char rsig[(FIELD_LEN << 2) + 24]; 45 | 46 | if (sig_len > ((sizeof rsig) >> 1)) { 47 | return 0; 48 | } 49 | memcpy(rsig, sig, sig_len); 50 | sig_len = br_ecdsa_asn1_to_raw(rsig, sig_len); 51 | return br_ecdsa_i15_vrfy_raw(impl, hash, hash_len, pk, rsig, sig_len); 52 | } 53 | 54 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i31_bits.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | #include "../ESP_SSLClient_FS.h" 27 | #if defined(USE_LIB_SSL_ENGINE) 28 | 29 | #include "inner.h" 30 | 31 | /* see inner.h */ 32 | void 33 | br_ecdsa_i31_bits2int(uint32_t *x, 34 | const void *src, size_t len, uint32_t ebitlen) 35 | { 36 | uint32_t bitlen, hbitlen; 37 | int sc; 38 | 39 | bitlen = ebitlen - (ebitlen >> 5); 40 | hbitlen = (uint32_t)len << 3; 41 | if (hbitlen > bitlen) { 42 | len = (bitlen + 7) >> 3; 43 | sc = (int)((hbitlen - bitlen) & 7); 44 | } else { 45 | sc = 0; 46 | } 47 | br_i31_zero(x, ebitlen); 48 | br_i31_decode(x, src, len); 49 | br_i31_rshift(x, sc); 50 | x[0] = ebitlen; 51 | } 52 | 53 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i31_sign_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | #include "../ESP_SSLClient_FS.h" 27 | #if defined(USE_LIB_SSL_ENGINE) 28 | 29 | #include "inner.h" 30 | 31 | #define ORDER_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 32 | 33 | /* see bearssl_ec.h */ 34 | size_t 35 | br_ecdsa_i31_sign_asn1(const br_ec_impl *impl, 36 | const br_hash_class *hf, const void *hash_value, 37 | const br_ec_private_key *sk, void *sig) 38 | { 39 | unsigned char rsig[(ORDER_LEN << 1) + 12]; 40 | size_t sig_len; 41 | 42 | sig_len = br_ecdsa_i31_sign_raw(impl, hf, hash_value, sk, rsig); 43 | if (sig_len == 0) { 44 | return 0; 45 | } 46 | sig_len = br_ecdsa_raw_to_asn1(rsig, sig_len); 47 | memcpy(sig, rsig, sig_len); 48 | return sig_len; 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ecdsa_i31_vrfy_asn1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | #include "../ESP_SSLClient_FS.h" 27 | #if defined(USE_LIB_SSL_ENGINE) 28 | 29 | #include "inner.h" 30 | 31 | #define FIELD_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 32 | 33 | /* see bearssl_ec.h */ 34 | uint32_t 35 | br_ecdsa_i31_vrfy_asn1(const br_ec_impl *impl, 36 | const void *hash, size_t hash_len, 37 | const br_ec_public_key *pk, 38 | const void *sig, size_t sig_len) 39 | { 40 | /* 41 | * We use a double-sized buffer because a malformed ASN.1 signature 42 | * may trigger a size expansion when converting to "raw" format. 43 | */ 44 | unsigned char rsig[(FIELD_LEN << 2) + 24]; 45 | 46 | if (sig_len > ((sizeof rsig) >> 1)) { 47 | return 0; 48 | } 49 | memcpy(rsig, sig, sig_len); 50 | sig_len = br_ecdsa_asn1_to_raw(rsig, sig_len); 51 | return br_ecdsa_i31_vrfy_raw(impl, hash, hash_len, pk, rsig, sig_len); 52 | } 53 | 54 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc16be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc16be(void *dst, const uint16_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc16be(buf, *v ++); 39 | buf += 2; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc16le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc16le(void *dst, const uint16_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc16le(buf, *v ++); 39 | buf += 2; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc32be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc32be(void *dst, const uint32_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc32be(buf, *v ++); 39 | buf += 4; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc32le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc32le(void *dst, const uint32_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc32le(buf, *v ++); 39 | buf += 4; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc64be.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc64be(void *dst, const uint64_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc64be(buf, *v ++); 39 | buf += 8; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/enc64le.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_range_enc64le(void *dst, const uint64_t *v, size_t num) 33 | { 34 | unsigned char *buf; 35 | 36 | buf = dst; 37 | while (num -- > 0) { 38 | br_enc64le(buf, *v ++); 39 | buf += 8; 40 | } 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_add.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | 26 | #include "../ESP_SSLClient_FS.h" 27 | #if defined(USE_LIB_SSL_ENGINE) 28 | 29 | #include "inner.h" 30 | 31 | /* see inner.h */ 32 | uint32_t 33 | br_i15_add(uint16_t *a, const uint16_t *b, uint32_t ctl) 34 | { 35 | uint32_t cc; 36 | size_t u, m; 37 | 38 | cc = 0; 39 | m = (a[0] + 31) >> 4; 40 | for (u = 1; u < m; u ++) { 41 | uint32_t aw, bw, naw; 42 | 43 | aw = a[u]; 44 | bw = b[u]; 45 | naw = aw + bw + cc; 46 | cc = naw >> 15; 47 | a[u] = MUX(ctl, naw & 0x7FFF, aw); 48 | } 49 | return cc; 50 | } 51 | 52 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_bitlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i15_bit_length(uint16_t *x, size_t xlen) 33 | { 34 | uint32_t tw, twk; 35 | 36 | tw = 0; 37 | twk = 0; 38 | while (xlen -- > 0) { 39 | uint32_t w, c; 40 | 41 | c = EQ(tw, 0); 42 | w = x[xlen]; 43 | tw = MUX(c, w, tw); 44 | twk = MUX(c, (uint32_t)xlen, twk); 45 | } 46 | return (twk << 4) + BIT_LENGTH(tw); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_decode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_decode(uint16_t *x, const void *src, size_t len) 33 | { 34 | const unsigned char *buf; 35 | size_t v; 36 | uint32_t acc; 37 | int acc_len; 38 | 39 | buf = src; 40 | v = 1; 41 | acc = 0; 42 | acc_len = 0; 43 | while (len -- > 0) { 44 | uint32_t b; 45 | 46 | b = buf[len]; 47 | acc |= (b << acc_len); 48 | acc_len += 8; 49 | if (acc_len >= 15) { 50 | x[v ++] = acc & 0x7FFF; 51 | acc_len -= 15; 52 | acc >>= 15; 53 | } 54 | } 55 | if (acc_len != 0) { 56 | x[v ++] = acc; 57 | } 58 | x[0] = br_i15_bit_length(x + 1, v - 1); 59 | } 60 | 61 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_encode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_encode(void *dst, size_t len, const uint16_t *x) 33 | { 34 | unsigned char *buf; 35 | size_t u, xlen; 36 | uint32_t acc; 37 | int acc_len; 38 | 39 | xlen = (x[0] + 15) >> 4; 40 | if (xlen == 0) { 41 | memset(dst, 0, len); 42 | return; 43 | } 44 | u = 1; 45 | acc = 0; 46 | acc_len = 0; 47 | buf = dst; 48 | while (len -- > 0) { 49 | if (acc_len < 8) { 50 | if (u <= xlen) { 51 | acc += (uint32_t)x[u ++] << acc_len; 52 | } 53 | acc_len += 15; 54 | } 55 | buf[len] = (unsigned char)acc; 56 | acc >>= 8; 57 | acc_len -= 8; 58 | } 59 | } 60 | 61 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_fmont.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_from_monty(uint16_t *x, const uint16_t *m, uint16_t m0i) 33 | { 34 | size_t len, u, v; 35 | 36 | len = (m[0] + 15) >> 4; 37 | for (u = 0; u < len; u ++) { 38 | uint32_t f, cc; 39 | 40 | f = MUL15(x[1], m0i) & 0x7FFF; 41 | cc = 0; 42 | for (v = 0; v < len; v ++) { 43 | uint32_t z; 44 | 45 | z = (uint32_t)x[v + 1] + MUL15(f, m[v + 1]) + cc; 46 | cc = z >> 15; 47 | if (v != 0) { 48 | x[v] = z & 0x7FFF; 49 | } 50 | } 51 | x[len] = cc; 52 | } 53 | 54 | /* 55 | * We may have to do an extra subtraction, but only if the 56 | * value in x[] is indeed greater than or equal to that of m[], 57 | * which is why we must do two calls (first call computes the 58 | * carry, second call performs the subtraction only if the carry 59 | * is 0). 60 | */ 61 | br_i15_sub(x, m, NOT(br_i15_sub(x, m, 0))); 62 | } 63 | 64 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_iszero.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i15_iszero(const uint16_t *x) 33 | { 34 | uint32_t z; 35 | size_t u; 36 | 37 | z = 0; 38 | for (u = (x[0] + 15) >> 4; u > 0; u --) { 39 | z |= x[u]; 40 | } 41 | return ~(z | -z) >> 31; 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_modpow.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_modpow(uint16_t *x, 33 | const unsigned char *e, size_t elen, 34 | const uint16_t *m, uint16_t m0i, uint16_t *t1, uint16_t *t2) 35 | { 36 | size_t mlen; 37 | unsigned k; 38 | 39 | mlen = ((m[0] + 31) >> 4) * sizeof m[0]; 40 | memcpy(t1, x, mlen); 41 | br_i15_to_monty(t1, m); 42 | br_i15_zero(x, m[0]); 43 | x[1] = 1; 44 | for (k = 0; k < ((unsigned)elen << 3); k ++) { 45 | uint32_t ctl; 46 | 47 | ctl = (e[elen - 1 - (k >> 3)] >> (k & 7)) & 1; 48 | br_i15_montymul(t2, x, t1, m, m0i); 49 | CCOPY(ctl, x, t2, mlen); 50 | br_i15_montymul(t2, t1, t1, m, m0i); 51 | memcpy(t1, t2, mlen); 52 | } 53 | } 54 | 55 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_ninv15.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint16_t 32 | br_i15_ninv15(uint16_t x) 33 | { 34 | uint32_t y; 35 | 36 | y = 2 - x; 37 | y = MUL15(y, 2 - MUL15(x, y)); 38 | y = MUL15(y, 2 - MUL15(x, y)); 39 | y = MUL15(y, 2 - MUL15(x, y)); 40 | return MUX(x & 1, -y, 0) & 0x7FFF; 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_rshift.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_rshift(uint16_t *x, int count) 33 | { 34 | size_t u, len; 35 | unsigned r; 36 | 37 | len = (x[0] + 15) >> 4; 38 | if (len == 0) { 39 | return; 40 | } 41 | r = x[1] >> count; 42 | for (u = 2; u <= len; u ++) { 43 | unsigned w; 44 | 45 | w = x[u]; 46 | x[u - 1] = ((w << (15 - count)) | r) & 0x7FFF; 47 | r = w >> count; 48 | } 49 | x[len] = r; 50 | } 51 | 52 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_sub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i15_sub(uint16_t *a, const uint16_t *b, uint32_t ctl) 33 | { 34 | uint32_t cc; 35 | size_t u, m; 36 | 37 | cc = 0; 38 | m = (a[0] + 31) >> 4; 39 | for (u = 1; u < m; u ++) { 40 | uint32_t aw, bw, naw; 41 | 42 | aw = a[u]; 43 | bw = b[u]; 44 | naw = aw - bw - cc; 45 | cc = naw >> 31; 46 | a[u] = MUX(ctl, naw & 0x7FFF, aw); 47 | } 48 | return cc; 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i15_tmont.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i15_to_monty(uint16_t *x, const uint16_t *m) 33 | { 34 | unsigned k; 35 | 36 | for (k = (m[0] + 15) >> 4; k > 0; k --) { 37 | br_i15_muladd_small(x, 0, m); 38 | } 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_add.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i31_add(uint32_t *a, const uint32_t *b, uint32_t ctl) 33 | { 34 | uint32_t cc; 35 | size_t u, m; 36 | 37 | cc = 0; 38 | m = (a[0] + 63) >> 5; 39 | for (u = 1; u < m; u ++) { 40 | uint32_t aw, bw, naw; 41 | 42 | aw = a[u]; 43 | bw = b[u]; 44 | naw = aw + bw + cc; 45 | cc = naw >> 31; 46 | a[u] = MUX(ctl, naw & (uint32_t)0x7FFFFFFF, aw); 47 | } 48 | return cc; 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_bitlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i31_bit_length(uint32_t *x, size_t xlen) 33 | { 34 | uint32_t tw, twk; 35 | 36 | tw = 0; 37 | twk = 0; 38 | while (xlen -- > 0) { 39 | uint32_t w, c; 40 | 41 | c = EQ(tw, 0); 42 | w = x[xlen]; 43 | tw = MUX(c, w, tw); 44 | twk = MUX(c, (uint32_t)xlen, twk); 45 | } 46 | return (twk << 5) + BIT_LENGTH(tw); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_decode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i31_decode(uint32_t *x, const void *src, size_t len) 33 | { 34 | const unsigned char *buf; 35 | size_t u, v; 36 | uint32_t acc; 37 | int acc_len; 38 | 39 | buf = src; 40 | u = len; 41 | v = 1; 42 | acc = 0; 43 | acc_len = 0; 44 | while (u -- > 0) { 45 | uint32_t b; 46 | 47 | b = buf[u]; 48 | acc |= (b << acc_len); 49 | acc_len += 8; 50 | if (acc_len >= 31) { 51 | x[v ++] = acc & (uint32_t)0x7FFFFFFF; 52 | acc_len -= 31; 53 | acc = b >> (8 - acc_len); 54 | } 55 | } 56 | if (acc_len != 0) { 57 | x[v ++] = acc; 58 | } 59 | x[0] = br_i31_bit_length(x + 1, v - 1); 60 | } 61 | 62 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_iszero.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i31_iszero(const uint32_t *x) 33 | { 34 | uint32_t z; 35 | size_t u; 36 | 37 | z = 0; 38 | for (u = (x[0] + 31) >> 5; u > 0; u --) { 39 | z |= x[u]; 40 | } 41 | return ~(z | -z) >> 31; 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_ninv31.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i31_ninv31(uint32_t x) 33 | { 34 | uint32_t y; 35 | 36 | y = 2 - x; 37 | y *= 2 - y * x; 38 | y *= 2 - y * x; 39 | y *= 2 - y * x; 40 | y *= 2 - y * x; 41 | return MUX(x & 1, -y, 0) & 0x7FFFFFFF; 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_rshift.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i31_rshift(uint32_t *x, int count) 33 | { 34 | size_t u, len; 35 | uint32_t r; 36 | 37 | len = (x[0] + 31) >> 5; 38 | if (len == 0) { 39 | return; 40 | } 41 | r = x[1] >> count; 42 | for (u = 2; u <= len; u ++) { 43 | uint32_t w; 44 | 45 | w = x[u]; 46 | x[u - 1] = ((w << (31 - count)) | r) & 0x7FFFFFFF; 47 | r = w >> count; 48 | } 49 | x[len] = r; 50 | } 51 | 52 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_sub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i31_sub(uint32_t *a, const uint32_t *b, uint32_t ctl) 33 | { 34 | uint32_t cc; 35 | size_t u, m; 36 | 37 | cc = 0; 38 | m = (a[0] + 63) >> 5; 39 | for (u = 1; u < m; u ++) { 40 | uint32_t aw, bw, naw; 41 | 42 | aw = a[u]; 43 | bw = b[u]; 44 | naw = aw - bw - cc; 45 | cc = naw >> 31; 46 | a[u] = MUX(ctl, naw & 0x7FFFFFFF, aw); 47 | } 48 | return cc; 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i31_tmont.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i31_to_monty(uint32_t *x, const uint32_t *m) 33 | { 34 | uint32_t k; 35 | 36 | for (k = (m[0] + 31) >> 5; k > 0; k --) { 37 | br_i31_muladd_small(x, 0, m); 38 | } 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_add.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i32_add(uint32_t *a, const uint32_t *b, uint32_t ctl) 33 | { 34 | uint32_t cc; 35 | size_t u, m; 36 | 37 | cc = 0; 38 | m = (a[0] + 63) >> 5; 39 | for (u = 1; u < m; u ++) { 40 | uint32_t aw, bw, naw; 41 | 42 | aw = a[u]; 43 | bw = b[u]; 44 | naw = aw + bw + cc; 45 | 46 | /* 47 | * Carry is 1 if naw < aw. Carry is also 1 if naw == aw 48 | * AND the carry was already 1. 49 | */ 50 | cc = (cc & EQ(naw, aw)) | LT(naw, aw); 51 | a[u] = MUX(ctl, naw, aw); 52 | } 53 | return cc; 54 | } 55 | 56 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_bitlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i32_bit_length(uint32_t *x, size_t xlen) 33 | { 34 | uint32_t tw, twk; 35 | 36 | tw = 0; 37 | twk = 0; 38 | while (xlen -- > 0) { 39 | uint32_t w, c; 40 | 41 | c = EQ(tw, 0); 42 | w = x[xlen]; 43 | tw = MUX(c, w, tw); 44 | twk = MUX(c, (uint32_t)xlen, twk); 45 | } 46 | return (twk << 5) + BIT_LENGTH(tw); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_decode.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i32_decode(uint32_t *x, const void *src, size_t len) 33 | { 34 | const unsigned char *buf; 35 | size_t u, v; 36 | 37 | buf = src; 38 | u = len; 39 | v = 1; 40 | for (;;) { 41 | if (u < 4) { 42 | uint32_t w; 43 | 44 | if (u < 2) { 45 | if (u == 0) { 46 | break; 47 | } else { 48 | w = buf[0]; 49 | } 50 | } else { 51 | if (u == 2) { 52 | w = br_dec16be(buf); 53 | } else { 54 | w = ((uint32_t)buf[0] << 16) 55 | | br_dec16be(buf + 1); 56 | } 57 | } 58 | x[v ++] = w; 59 | break; 60 | } else { 61 | u -= 4; 62 | x[v ++] = br_dec32be(buf + u); 63 | } 64 | } 65 | x[0] = br_i32_bit_length(x + 1, v - 1); 66 | } 67 | 68 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_div32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_divrem(uint32_t hi, uint32_t lo, uint32_t d, uint32_t *r) 33 | { 34 | /* TODO: optimize this */ 35 | uint32_t q; 36 | uint32_t ch, cf; 37 | int k; 38 | 39 | q = 0; 40 | ch = EQ(hi, d); 41 | hi = MUX(ch, 0, hi); 42 | for (k = 31; k > 0; k --) { 43 | int j; 44 | uint32_t w, ctl, hi2, lo2; 45 | 46 | j = 32 - k; 47 | w = (hi << j) | (lo >> k); 48 | ctl = GE(w, d) | (hi >> k); 49 | hi2 = (w - d) >> j; 50 | lo2 = lo - (d << k); 51 | hi = MUX(ctl, hi2, hi); 52 | lo = MUX(ctl, lo2, lo); 53 | q |= ctl << k; 54 | } 55 | cf = GE(lo, d) | hi; 56 | q |= cf; 57 | *r = MUX(cf, lo - d, lo); 58 | return q; 59 | } 60 | 61 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_iszero.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i32_iszero(const uint32_t *x) 33 | { 34 | uint32_t z; 35 | size_t u; 36 | 37 | z = 0; 38 | for (u = (x[0] + 31) >> 5; u > 0; u --) { 39 | z |= x[u]; 40 | } 41 | return ~(z | -z) >> 31; 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_mulacc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i32_mulacc(uint32_t *d, const uint32_t *a, const uint32_t *b) 33 | { 34 | size_t alen, blen, u; 35 | 36 | alen = (a[0] + 31) >> 5; 37 | blen = (b[0] + 31) >> 5; 38 | d[0] = a[0] + b[0]; 39 | for (u = 0; u < blen; u ++) { 40 | uint32_t f; 41 | size_t v; 42 | #if BR_64 43 | uint64_t cc; 44 | #else 45 | uint32_t cc; 46 | #endif 47 | 48 | f = b[1 + u]; 49 | cc = 0; 50 | for (v = 0; v < alen; v ++) { 51 | uint64_t z; 52 | 53 | z = (uint64_t)d[1 + u + v] + MUL(f, a[1 + v]) + cc; 54 | cc = z >> 32; 55 | d[1 + u + v] = (uint32_t)z; 56 | } 57 | d[1 + u + alen] = (uint32_t)cc; 58 | } 59 | } 60 | 61 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_ninv32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i32_ninv32(uint32_t x) 33 | { 34 | uint32_t y; 35 | 36 | y = 2 - x; 37 | y *= 2 - y * x; 38 | y *= 2 - y * x; 39 | y *= 2 - y * x; 40 | y *= 2 - y * x; 41 | return MUX(x & 1, -y, 0); 42 | } 43 | 44 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_sub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | uint32_t 32 | br_i32_sub(uint32_t *a, const uint32_t *b, uint32_t ctl) 33 | { 34 | uint32_t cc; 35 | size_t u, m; 36 | 37 | cc = 0; 38 | m = (a[0] + 63) >> 5; 39 | for (u = 1; u < m; u ++) { 40 | uint32_t aw, bw, naw; 41 | 42 | aw = a[u]; 43 | bw = b[u]; 44 | naw = aw - bw - cc; 45 | 46 | /* 47 | * Carry is 1 if naw > aw. Carry is 1 also if naw == aw 48 | * AND the carry was already 1. 49 | */ 50 | cc = (cc & EQ(naw, aw)) | GT(naw, aw); 51 | a[u] = MUX(ctl, naw, aw); 52 | } 53 | return cc; 54 | } 55 | 56 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/i32_tmont.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_i32_to_monty(uint32_t *x, const uint32_t *m) 33 | { 34 | uint32_t k; 35 | 36 | for (k = (m[0] + 31) >> 5; k > 0; k --) { 37 | br_i32_muladd_small(x, 0, m); 38 | } 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/mgf1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | void 32 | br_mgf1_xor(void *data, size_t len, 33 | const br_hash_class *dig, const void *seed, size_t seed_len) 34 | { 35 | unsigned char *buf; 36 | size_t u, hlen; 37 | uint32_t c; 38 | 39 | buf = data; 40 | hlen = br_digest_size(dig); 41 | for (u = 0, c = 0; u < len; u += hlen, c ++) { 42 | br_hash_compat_context hc; 43 | unsigned char tmp[64]; 44 | size_t v; 45 | 46 | hc.vtable = dig; 47 | dig->init(&hc.vtable); 48 | dig->update(&hc.vtable, seed, seed_len); 49 | br_enc32be(tmp, c); 50 | dig->update(&hc.vtable, tmp, 4); 51 | dig->out(&hc.vtable, tmp); 52 | for (v = 0; v < hlen; v ++) { 53 | if ((u + v) >= len) { 54 | break; 55 | } 56 | buf[u + v] ^= tmp[v]; 57 | } 58 | } 59 | } 60 | 61 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/prf_md5sha1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl.h */ 31 | void 32 | br_tls10_prf(void *dst, size_t len, 33 | const void *secret, size_t secret_len, const char *label, 34 | size_t seed_num, const br_tls_prf_seed_chunk *seed) 35 | { 36 | const unsigned char *s1; 37 | size_t slen; 38 | 39 | s1 = secret; 40 | slen = (secret_len + 1) >> 1; 41 | memset(dst, 0, len); 42 | br_tls_phash(dst, len, &br_md5_vtable, 43 | s1, slen, label, seed_num, seed); 44 | br_tls_phash(dst, len, &br_sha1_vtable, 45 | s1 + secret_len - slen, slen, label, seed_num, seed); 46 | } 47 | 48 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/prf_sha256.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl.h */ 31 | void 32 | br_tls12_sha256_prf(void *dst, size_t len, 33 | const void *secret, size_t secret_len, const char *label, 34 | size_t seed_num, const br_tls_prf_seed_chunk *seed) 35 | { 36 | memset(dst, 0, len); 37 | br_tls_phash(dst, len, &br_sha256_vtable, 38 | secret, secret_len, label, seed_num, seed); 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/prf_sha384.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl.h */ 31 | void 32 | br_tls12_sha384_prf(void *dst, size_t len, 33 | const void *secret, size_t secret_len, const char *label, 34 | size_t seed_num, const br_tls_prf_seed_chunk *seed) 35 | { 36 | memset(dst, 0, len); 37 | br_tls_phash(dst, len, &br_sha384_vtable, 38 | secret, secret_len, label, seed_num, seed); 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_keygen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_keygen 32 | br_rsa_keygen_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_keygen; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_keygen; 38 | #else 39 | return &br_rsa_i31_keygen; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_modulus.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_compute_modulus 32 | br_rsa_compute_modulus_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_rsa_i15_compute_modulus; 36 | #else 37 | return &br_rsa_i31_compute_modulus; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_oaep_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_oaep_decrypt 32 | br_rsa_oaep_decrypt_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_oaep_decrypt; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_oaep_decrypt; 38 | #else 39 | return &br_rsa_i31_oaep_decrypt; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_oaep_encrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_oaep_encrypt 32 | br_rsa_oaep_encrypt_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_oaep_encrypt; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_oaep_encrypt; 38 | #else 39 | return &br_rsa_i31_oaep_encrypt; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pkcs1_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_pkcs1_sign 32 | br_rsa_pkcs1_sign_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_pkcs1_sign; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_pkcs1_sign; 38 | #else 39 | return &br_rsa_i31_pkcs1_sign; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pkcs1_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_pkcs1_vrfy 32 | br_rsa_pkcs1_vrfy_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_pkcs1_vrfy; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_pkcs1_vrfy; 38 | #else 39 | return &br_rsa_i31_pkcs1_vrfy; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_priv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_private 32 | br_rsa_private_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_private; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_private; 38 | #else 39 | return &br_rsa_i31_private; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_privexp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_compute_privexp 32 | br_rsa_compute_privexp_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_rsa_i15_compute_privexp; 36 | #else 37 | return &br_rsa_i31_compute_privexp; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pss_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_pss_sign 32 | br_rsa_pss_sign_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_pss_sign; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_pss_sign; 38 | #else 39 | return &br_rsa_i31_pss_sign; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pss_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_pss_vrfy 32 | br_rsa_pss_vrfy_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_pss_vrfy; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_pss_vrfy; 38 | #else 39 | return &br_rsa_i31_pss_vrfy; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_public 32 | br_rsa_public_get_default(void) 33 | { 34 | #if BR_INT128 || BR_UMUL128 35 | return &br_rsa_i62_public; 36 | #elif BR_LOMUL 37 | return &br_rsa_i15_public; 38 | #else 39 | return &br_rsa_i31_public; 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_default_pubexp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | br_rsa_compute_pubexp 32 | br_rsa_compute_pubexp_get_default(void) 33 | { 34 | #if BR_LOMUL 35 | return &br_rsa_i15_compute_pubexp; 36 | #else 37 | return &br_rsa_i31_compute_pubexp; 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_oaep_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i15_oaep_decrypt(const br_hash_class *dig, 33 | const void *label, size_t label_len, 34 | const br_rsa_private_key *sk, void *data, size_t *len) 35 | { 36 | uint32_t r; 37 | 38 | if (*len != ((sk->n_bitlen + 7) >> 3)) { 39 | return 0; 40 | } 41 | r = br_rsa_i15_private(data, sk); 42 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 43 | return r; 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_oaep_encrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | size_t 32 | br_rsa_i15_oaep_encrypt( 33 | const br_prng_class **rnd, const br_hash_class *dig, 34 | const void *label, size_t label_len, 35 | const br_rsa_public_key *pk, 36 | void *dst, size_t dst_max_len, 37 | const void *src, size_t src_len) 38 | { 39 | size_t dlen; 40 | 41 | dlen = br_rsa_oaep_pad(rnd, dig, label, label_len, 42 | pk, dst, dst_max_len, src, src_len); 43 | if (dlen == 0) { 44 | return 0; 45 | } 46 | return dlen & -(size_t)br_rsa_i15_public(dst, dlen, pk); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_pkcs1_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i15_pkcs1_sign(const unsigned char *hash_oid, 33 | const unsigned char *hash, size_t hash_len, 34 | const br_rsa_private_key *sk, unsigned char *x) 35 | { 36 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) { 37 | return 0; 38 | } 39 | return br_rsa_i15_private(x, sk); 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_pkcs1_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i15_pkcs1_vrfy(const unsigned char *x, size_t xlen, 33 | const unsigned char *hash_oid, size_t hash_len, 34 | const br_rsa_public_key *pk, unsigned char *hash_out) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i15_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 46 | } 47 | 48 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_pss_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i15_pss_sign(const br_prng_class **rng, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const unsigned char *hash, size_t salt_len, 35 | const br_rsa_private_key *sk, unsigned char *x) 36 | { 37 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 38 | salt_len, sk->n_bitlen, x)) 39 | { 40 | return 0; 41 | } 42 | return br_rsa_i15_private(x, sk); 43 | } 44 | 45 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i15_pss_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i15_pss_vrfy(const unsigned char *x, size_t xlen, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const void *hash, size_t salt_len, const br_rsa_public_key *pk) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i15_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pss_sig_unpad(hf_data, hf_mgf1, 46 | hash, salt_len, pk, sig); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_keygen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_keygen(const br_prng_class **rng, 33 | br_rsa_private_key *sk, void *kbuf_priv, 34 | br_rsa_public_key *pk, void *kbuf_pub, 35 | unsigned size, uint32_t pubexp) 36 | { 37 | return br_rsa_i31_keygen_inner(rng, 38 | sk, kbuf_priv, pk, kbuf_pub, size, pubexp, 39 | &br_i31_modpow_opt); 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_oaep_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_oaep_decrypt(const br_hash_class *dig, 33 | const void *label, size_t label_len, 34 | const br_rsa_private_key *sk, void *data, size_t *len) 35 | { 36 | uint32_t r; 37 | 38 | if (*len != ((sk->n_bitlen + 7) >> 3)) { 39 | return 0; 40 | } 41 | r = br_rsa_i31_private(data, sk); 42 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 43 | return r; 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_oaep_encrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | size_t 32 | br_rsa_i31_oaep_encrypt( 33 | const br_prng_class **rnd, const br_hash_class *dig, 34 | const void *label, size_t label_len, 35 | const br_rsa_public_key *pk, 36 | void *dst, size_t dst_max_len, 37 | const void *src, size_t src_len) 38 | { 39 | size_t dlen; 40 | 41 | dlen = br_rsa_oaep_pad(rnd, dig, label, label_len, 42 | pk, dst, dst_max_len, src, src_len); 43 | if (dlen == 0) { 44 | return 0; 45 | } 46 | return dlen & -(size_t)br_rsa_i31_public(dst, dlen, pk); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_pkcs1_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_pkcs1_sign(const unsigned char *hash_oid, 33 | const unsigned char *hash, size_t hash_len, 34 | const br_rsa_private_key *sk, unsigned char *x) 35 | { 36 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) { 37 | return 0; 38 | } 39 | return br_rsa_i31_private(x, sk); 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_pkcs1_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_pkcs1_vrfy(const unsigned char *x, size_t xlen, 33 | const unsigned char *hash_oid, size_t hash_len, 34 | const br_rsa_public_key *pk, unsigned char *hash_out) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i31_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 46 | } 47 | 48 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_pss_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_pss_sign(const br_prng_class **rng, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const unsigned char *hash, size_t salt_len, 35 | const br_rsa_private_key *sk, unsigned char *x) 36 | { 37 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 38 | salt_len, sk->n_bitlen, x)) 39 | { 40 | return 0; 41 | } 42 | return br_rsa_i31_private(x, sk); 43 | } 44 | 45 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i31_pss_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i31_pss_vrfy(const unsigned char *x, size_t xlen, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const void *hash, size_t salt_len, const br_rsa_public_key *pk) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i31_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pss_sig_unpad(hf_data, hf_mgf1, 46 | hash, salt_len, pk, sig); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_oaep_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i32_oaep_decrypt(const br_hash_class *dig, 33 | const void *label, size_t label_len, 34 | const br_rsa_private_key *sk, void *data, size_t *len) 35 | { 36 | uint32_t r; 37 | 38 | if (*len != ((sk->n_bitlen + 7) >> 3)) { 39 | return 0; 40 | } 41 | r = br_rsa_i32_private(data, sk); 42 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 43 | return r; 44 | } 45 | 46 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_oaep_encrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | size_t 32 | br_rsa_i32_oaep_encrypt( 33 | const br_prng_class **rnd, const br_hash_class *dig, 34 | const void *label, size_t label_len, 35 | const br_rsa_public_key *pk, 36 | void *dst, size_t dst_max_len, 37 | const void *src, size_t src_len) 38 | { 39 | size_t dlen; 40 | 41 | dlen = br_rsa_oaep_pad(rnd, dig, label, label_len, 42 | pk, dst, dst_max_len, src, src_len); 43 | if (dlen == 0) { 44 | return 0; 45 | } 46 | return dlen & -(size_t)br_rsa_i32_public(dst, dlen, pk); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_pkcs1_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i32_pkcs1_sign(const unsigned char *hash_oid, 33 | const unsigned char *hash, size_t hash_len, 34 | const br_rsa_private_key *sk, unsigned char *x) 35 | { 36 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) { 37 | return 0; 38 | } 39 | return br_rsa_i32_private(x, sk); 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_pkcs1_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i32_pkcs1_vrfy(const unsigned char *x, size_t xlen, 33 | const unsigned char *hash_oid, size_t hash_len, 34 | const br_rsa_public_key *pk, unsigned char *hash_out) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i32_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 46 | } 47 | 48 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_pss_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i32_pss_sign(const br_prng_class **rng, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const unsigned char *hash, size_t salt_len, 35 | const br_rsa_private_key *sk, unsigned char *x) 36 | { 37 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 38 | salt_len, sk->n_bitlen, x)) 39 | { 40 | return 0; 41 | } 42 | return br_rsa_i32_private(x, sk); 43 | } 44 | 45 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i32_pss_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_i32_pss_vrfy(const unsigned char *x, size_t xlen, 33 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 34 | const void *hash, size_t salt_len, const br_rsa_public_key *pk) 35 | { 36 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 37 | 38 | if (xlen > (sizeof sig)) { 39 | return 0; 40 | } 41 | memcpy(sig, x, xlen); 42 | if (!br_rsa_i32_public(sig, xlen, pk)) { 43 | return 0; 44 | } 45 | return br_rsa_pss_sig_unpad(hf_data, hf_mgf1, 46 | hash, salt_len, pk, sig); 47 | } 48 | 49 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_keygen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_keygen(const br_prng_class **rng, 35 | br_rsa_private_key *sk, void *kbuf_priv, 36 | br_rsa_public_key *pk, void *kbuf_pub, 37 | unsigned size, uint32_t pubexp) 38 | { 39 | return br_rsa_i31_keygen_inner(rng, 40 | sk, kbuf_priv, pk, kbuf_pub, size, pubexp, 41 | &br_i62_modpow_opt_as_i31); 42 | } 43 | 44 | /* see bearssl_rsa.h */ 45 | br_rsa_keygen 46 | br_rsa_i62_keygen_get() 47 | { 48 | return &br_rsa_i62_keygen; 49 | } 50 | 51 | #else 52 | 53 | /* see bearssl_rsa.h */ 54 | br_rsa_keygen 55 | br_rsa_i62_keygen_get() 56 | { 57 | return 0; 58 | } 59 | 60 | #endif 61 | 62 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_oaep_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_oaep_decrypt(const br_hash_class *dig, 35 | const void *label, size_t label_len, 36 | const br_rsa_private_key *sk, void *data, size_t *len) 37 | { 38 | uint32_t r; 39 | 40 | if (*len != ((sk->n_bitlen + 7) >> 3)) { 41 | return 0; 42 | } 43 | r = br_rsa_i62_private(data, sk); 44 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 45 | return r; 46 | } 47 | 48 | /* see bearssl_rsa.h */ 49 | br_rsa_oaep_decrypt 50 | br_rsa_i62_oaep_decrypt_get(void) 51 | { 52 | return &br_rsa_i62_oaep_decrypt; 53 | } 54 | 55 | #else 56 | 57 | /* see bearssl_rsa.h */ 58 | br_rsa_oaep_decrypt 59 | br_rsa_i62_oaep_decrypt_get(void) 60 | { 61 | return 0; 62 | } 63 | 64 | #endif 65 | 66 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_pkcs1_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_pkcs1_sign(const unsigned char *hash_oid, 35 | const unsigned char *hash, size_t hash_len, 36 | const br_rsa_private_key *sk, unsigned char *x) 37 | { 38 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) { 39 | return 0; 40 | } 41 | return br_rsa_i62_private(x, sk); 42 | } 43 | 44 | /* see bearssl_rsa.h */ 45 | br_rsa_pkcs1_sign 46 | br_rsa_i62_pkcs1_sign_get(void) 47 | { 48 | return &br_rsa_i62_pkcs1_sign; 49 | } 50 | 51 | #else 52 | 53 | /* see bearssl_rsa.h */ 54 | br_rsa_pkcs1_sign 55 | br_rsa_i62_pkcs1_sign_get(void) 56 | { 57 | return 0; 58 | } 59 | 60 | #endif 61 | 62 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_pkcs1_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_pkcs1_vrfy(const unsigned char *x, size_t xlen, 35 | const unsigned char *hash_oid, size_t hash_len, 36 | const br_rsa_public_key *pk, unsigned char *hash_out) 37 | { 38 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 39 | 40 | if (xlen > (sizeof sig)) { 41 | return 0; 42 | } 43 | memcpy(sig, x, xlen); 44 | if (!br_rsa_i62_public(sig, xlen, pk)) { 45 | return 0; 46 | } 47 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 48 | } 49 | 50 | /* see bearssl_rsa.h */ 51 | br_rsa_pkcs1_vrfy 52 | br_rsa_i62_pkcs1_vrfy_get(void) 53 | { 54 | return &br_rsa_i62_pkcs1_vrfy; 55 | } 56 | 57 | #else 58 | 59 | /* see bearssl_rsa.h */ 60 | br_rsa_pkcs1_vrfy 61 | br_rsa_i62_pkcs1_vrfy_get(void) 62 | { 63 | return 0; 64 | } 65 | 66 | #endif 67 | 68 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_pss_sign.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_pss_sign(const br_prng_class **rng, 35 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 36 | const unsigned char *hash, size_t salt_len, 37 | const br_rsa_private_key *sk, unsigned char *x) 38 | { 39 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 40 | salt_len, sk->n_bitlen, x)) 41 | { 42 | return 0; 43 | } 44 | return br_rsa_i62_private(x, sk); 45 | } 46 | 47 | /* see bearssl_rsa.h */ 48 | br_rsa_pss_sign 49 | br_rsa_i62_pss_sign_get(void) 50 | { 51 | return &br_rsa_i62_pss_sign; 52 | } 53 | 54 | #else 55 | 56 | /* see bearssl_rsa.h */ 57 | br_rsa_pss_sign 58 | br_rsa_i62_pss_sign_get(void) 59 | { 60 | return 0; 61 | } 62 | 63 | #endif 64 | 65 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_i62_pss_vrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | #if BR_INT128 || BR_UMUL128 31 | 32 | /* see bearssl_rsa.h */ 33 | uint32_t 34 | br_rsa_i62_pss_vrfy(const unsigned char *x, size_t xlen, 35 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 36 | const void *hash, size_t salt_len, const br_rsa_public_key *pk) 37 | { 38 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 39 | 40 | if (xlen > (sizeof sig)) { 41 | return 0; 42 | } 43 | memcpy(sig, x, xlen); 44 | if (!br_rsa_i62_public(sig, xlen, pk)) { 45 | return 0; 46 | } 47 | return br_rsa_pss_sig_unpad(hf_data, hf_mgf1, 48 | hash, salt_len, pk, sig); 49 | } 50 | 51 | /* see bearssl_rsa.h */ 52 | br_rsa_pss_vrfy 53 | br_rsa_i62_pss_vrfy_get(void) 54 | { 55 | return &br_rsa_i62_pss_vrfy; 56 | } 57 | 58 | #else 59 | 60 | /* see bearssl_rsa.h */ 61 | br_rsa_pss_vrfy 62 | br_rsa_i62_pss_vrfy_get(void) 63 | { 64 | return 0; 65 | } 66 | 67 | #endif 68 | 69 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/rsa_ssl_decrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_rsa.h */ 31 | uint32_t 32 | br_rsa_ssl_decrypt(br_rsa_private core, const br_rsa_private_key *sk, 33 | unsigned char *data, size_t len) 34 | { 35 | uint32_t x; 36 | size_t u; 37 | 38 | /* 39 | * A first check on length. Since this test works only on the 40 | * buffer length, it needs not (and cannot) be constant-time. 41 | */ 42 | if (len < 59 || len != (sk->n_bitlen + 7) >> 3) { 43 | return 0; 44 | } 45 | x = core(data, sk); 46 | 47 | x &= EQ(data[0], 0x00); 48 | x &= EQ(data[1], 0x02); 49 | for (u = 2; u < (len - 49); u ++) { 50 | x &= NEQ(data[u], 0); 51 | } 52 | x &= EQ(data[len - 49], 0x00); 53 | memmove(data, data + len - 48, 48); 54 | return x; 55 | } 56 | 57 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_client_default_rsapub.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_client_set_default_rsapub(br_ssl_client_context *cc) 33 | { 34 | br_ssl_client_set_rsapub(cc, br_rsa_public_get_default()); 35 | } 36 | 37 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_engine_default_descbc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_engine_set_default_des_cbc(br_ssl_engine_context *cc) 33 | { 34 | br_ssl_engine_set_cbc(cc, 35 | &br_sslrec_in_cbc_vtable, 36 | &br_sslrec_out_cbc_vtable); 37 | br_ssl_engine_set_des_cbc(cc, 38 | &br_des_ct_cbcenc_vtable, 39 | &br_des_ct_cbcdec_vtable); 40 | } 41 | 42 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_engine_default_ec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_engine_set_default_ec(br_ssl_engine_context *cc) 33 | { 34 | #if BR_LOMUL 35 | br_ssl_engine_set_ec(cc, &br_ec_all_m15); 36 | #else 37 | br_ssl_engine_set_ec(cc, &br_ec_all_m31); 38 | #endif 39 | } 40 | 41 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_engine_default_ecdsa.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_engine_set_default_ecdsa(br_ssl_engine_context *cc) 33 | { 34 | #if BR_LOMUL 35 | br_ssl_engine_set_ec(cc, &br_ec_all_m15); 36 | br_ssl_engine_set_ecdsa(cc, &br_ecdsa_i15_vrfy_asn1); 37 | #else 38 | br_ssl_engine_set_ec(cc, &br_ec_all_m31); 39 | br_ssl_engine_set_ecdsa(cc, &br_ecdsa_i31_vrfy_asn1); 40 | #endif 41 | } 42 | 43 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_engine_default_rsavrfy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_engine_set_default_rsavrfy(br_ssl_engine_context *cc) 33 | { 34 | br_ssl_engine_set_rsavrfy(cc, br_rsa_pkcs1_vrfy_get_default()); 35 | } 36 | 37 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_hashes.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see inner.h */ 31 | int 32 | br_ssl_choose_hash(unsigned bf) 33 | { 34 | static const unsigned char pref[] = { 35 | br_sha256_ID, br_sha384_ID, br_sha512_ID, 36 | br_sha224_ID, br_sha1_ID 37 | }; 38 | size_t u; 39 | 40 | for (u = 0; u < sizeof pref; u ++) { 41 | int x; 42 | 43 | x = pref[u]; 44 | if ((bf >> x) & 1) { 45 | return x; 46 | } 47 | } 48 | return 0; 49 | } 50 | 51 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/bssl/ssl_server.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Thomas Pornin 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining 5 | * a copy of this software and associated documentation files (the 6 | * "Software"), to deal in the Software without restriction, including 7 | * without limitation the rights to use, copy, modify, merge, publish, 8 | * distribute, sublicense, and/or sell copies of the Software, and to 9 | * permit persons to whom the Software is furnished to do so, subject to 10 | * the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be 13 | * included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | #include "../ESP_SSLClient_FS.h" 26 | #if defined(USE_LIB_SSL_ENGINE) 27 | 28 | #include "inner.h" 29 | 30 | /* see bearssl_ssl.h */ 31 | void 32 | br_ssl_server_zero(br_ssl_server_context *cc) 33 | { 34 | /* 35 | * For really standard C, we should explicitly set to NULL all 36 | * pointers, and 0 all other fields. However, on all our target 37 | * architectures, a direct memset() will work, be faster, and 38 | * use a lot less code. 39 | */ 40 | memset(cc, 0, sizeof *cc); 41 | } 42 | 43 | /* see bearssl_ssl.h */ 44 | int 45 | br_ssl_server_reset(br_ssl_server_context *cc) 46 | { 47 | br_ssl_engine_set_buffer(&cc->eng, NULL, 0, 0); 48 | if (!br_ssl_engine_init_rand(&cc->eng)) { 49 | return 0; 50 | } 51 | cc->eng.reneg = 0; 52 | br_ssl_engine_hs_reset(&cc->eng, 53 | br_ssl_hs_server_init_main, br_ssl_hs_server_run); 54 | return br_ssl_engine_last_error(&cc->eng) == BR_ERR_OK; 55 | } 56 | 57 | #endif -------------------------------------------------------------------------------- /src/client/SSLClient/client/stm32_time_fix.c: -------------------------------------------------------------------------------- 1 | 2 | // _gettimeofday link missing in STM32 3 | 4 | #if !defined(STM32_TIME_FIX_C) && defined(ARDUINO_ARCH_STM32) 5 | #define STM32_TIME_FIX_C 6 | 7 | #include 8 | 9 | __attribute__((weak)) int _gettimeofday(struct timeval *tv, void *ignore __attribute__((unused))) 10 | { 11 | uint64_t t = 0; 12 | tv->tv_sec = t / 1000000000; 13 | tv->tv_usec = (t % 1000000000) / 1000; 14 | return 0; 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /src/core/Firebase_Client_Version.h: -------------------------------------------------------------------------------- 1 | #ifndef FIREBASE_CLIENT_VERSION 2 | #define FIREBASE_CLIENT_VERSION "4.4.17" 3 | #define FIREBASE_CLIENT_VERSION_NUM 40417 4 | 5 | #endif -------------------------------------------------------------------------------- /src/mbfs/MB_MCU.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef MB_MCU_H 4 | #define MB_MCU_H 5 | 6 | 7 | #if defined(ESP8266) || defined(ESP32) 8 | #ifndef MB_ARDUINO_ESP 9 | #define MB_ARDUINO_ESP 10 | #endif 11 | #endif 12 | 13 | #if defined(__arm__) 14 | #ifndef MB_ARDUINO_ARM 15 | #define MB_ARDUINO_ARM 16 | #endif 17 | #endif 18 | 19 | #if defined(ARDUINO_ARCH_SAMD) 20 | #ifndef MB_ARDUINO_ARCH_SAMD 21 | #define MB_ARDUINO_ARCH_SAMD 22 | #endif 23 | #endif 24 | 25 | #if defined(ARDUINO_ARCH_RP2040) 26 | 27 | #if defined(ARDUINO_NANO_RP2040_CONNECT) 28 | #ifndef MB_ARDUINO_NANO_RP2040_CONNECT 29 | #define MB_ARDUINO_NANO_RP2040_CONNECT 30 | #endif 31 | #else 32 | #ifndef MB_ARDUINO_PICO 33 | #define MB_ARDUINO_PICO 34 | #endif 35 | #endif 36 | 37 | #endif 38 | 39 | 40 | #if defined(TEENSYDUINO) 41 | #ifndef MB_ARDUINO_TEENSY 42 | #define MB_ARDUINO_TEENSY 43 | #endif 44 | #endif 45 | 46 | 47 | #endif -------------------------------------------------------------------------------- /src/message/LFCM.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include "./mbfs/MB_MCU.h" 4 | #include "./FirebaseFS.h" 5 | 6 | #if defined(ENABLE_FCM) || defined(FIREBASE_ENABLE_FCM) 7 | 8 | #ifndef FIREBASE_LFCM_H 9 | #define FIREBASE_LFCM_H 10 | #include "./FB_Utils.h" 11 | 12 | class FCMObject 13 | { 14 | 15 | friend class FIREBASE_CLASS; 16 | friend class FirebaseData; 17 | 18 | public: 19 | FCMObject(){}; 20 | ~FCMObject(){}; 21 | 22 | template 23 | void begin(T serverKey, SPI_ETH_Module *spi_ethernet_module = NULL) 24 | { 25 | FB_DEFAULT_DEBUG_PORT.println(FPSTR("This method was deprecated, please see examples/Messaging for how to use new methods.")); 26 | } 27 | template 28 | void addDeviceToken(T deviceToken) {} 29 | void removeDeviceToken(uint16_t index) {} 30 | void clearDeviceToken() {} 31 | template 32 | void setNotifyMessage(T1 title, T2 body) {} 33 | template 34 | void setNotifyMessage(T1 title, T2 body, T3 icon) {} 35 | template 36 | void setNotifyMessage(T1 title, T2 body, T3 icon, T4 click_action) {} 37 | template 38 | void addCustomNotifyMessage(T1 key, T2 value) {} 39 | void clearNotifyMessage() {} 40 | template 41 | void setDataMessage(T jsonString) {} 42 | void setDataMessage(FirebaseJson &json) {} 43 | void clearDataMessage() {} 44 | template 45 | void setPriority(T priority) {} 46 | template 47 | void setCollapseKey(T key) {} 48 | void setTimeToLive(uint32_t seconds) {} 49 | template 50 | void setTopic(T topic) {} 51 | const char *getSendResult() { return ""; }; 52 | }; 53 | 54 | #endif 55 | #endif -------------------------------------------------------------------------------- /src/rtdb/QueueManager.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * Google's Firebase QueueManager class, QueueManager.h version 1.0.5 4 | * 5 | * Created November 1, 2022 6 | * 7 | * The MIT License (MIT) 8 | * Copyright (c) 2023 K. Suwatchai (Mobizt) 9 | * 10 | * 11 | * Permission is hereby granted, free of charge, to any person returning a copy of 12 | * this software and associated documentation files (the "Software"), to deal in 13 | * the Software without restriction, including without limitation the rights to 14 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 | * the Software, and to permit persons to whom the Software is furnished to do so, 16 | * subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in all 19 | * copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 23 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 25 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | */ 28 | 29 | #include "./FirebaseFS.h" 30 | 31 | #if defined(ENABLE_RTDB) || defined(FIREBASE_ENABLE_RTDB) 32 | 33 | #ifndef FIREBASE_QUEUE_MANAGER_H 34 | #define FIREBASE_QUEUE_MANAGER_H 35 | #include 36 | #include "./FB_Utils.h" 37 | #include "QueueInfo.h" 38 | 39 | class QueueManager 40 | { 41 | friend class FB_RTDB; 42 | friend class FirebaseData; 43 | 44 | public: 45 | QueueManager(); 46 | ~QueueManager(); 47 | 48 | bool add(QueueItem q); 49 | void remove(uint8_t index); 50 | size_t size(); 51 | 52 | private: 53 | void clear(); 54 | MB_VECTOR *_queueCollection = nullptr; 55 | uint8_t _maxQueue = 10; 56 | }; 57 | 58 | #endif 59 | 60 | #endif // ENABLE --------------------------------------------------------------------------------