├── .codespellrc ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml ├── stale.yml └── workflows │ ├── auto-github-actions.yml │ ├── check-arduino.yml │ ├── report-size-deltas.yml │ └── spell-check.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── LibraryPatches ├── Ethernet │ └── src │ │ ├── Ethernet.cpp │ │ ├── Ethernet.h │ │ ├── EthernetServer.cpp │ │ └── utility │ │ ├── w5100.cpp │ │ └── w5100.h ├── Ethernet2 │ └── src │ │ ├── Ethernet2.cpp │ │ ├── Ethernet2.h │ │ ├── EthernetUdp2.cpp │ │ └── EthernetUdp2.h ├── Ethernet3 │ └── src │ │ ├── Ethernet3.cpp │ │ └── Ethernet3.h ├── EthernetLarge │ └── src │ │ ├── EthernetLarge.cpp │ │ ├── EthernetLarge.h │ │ ├── EthernetServer.cpp │ │ └── utility │ │ ├── w5100.cpp │ │ └── w5100.h ├── UIPEthernet-2.0.9 │ ├── UIPEthernet.cpp │ ├── UIPEthernet.h │ └── utility │ │ ├── Enc28J60Network.cpp │ │ └── Enc28J60Network.h ├── UIPEthernet │ ├── UIPEthernet.cpp │ ├── UIPEthernet.h │ └── utility │ │ ├── Enc28J60Network.cpp │ │ └── Enc28J60Network.h └── esp32 │ └── cores │ └── esp32 │ └── Server.h ├── Packages_Patches └── STM32 │ └── hardware │ └── stm32 │ ├── 1.9.0 │ ├── system │ │ ├── STM32F4xx │ │ │ └── stm32f4xx_hal_conf_default.h │ │ └── STM32F7xx │ │ │ └── stm32f7xx_hal_conf_default.h │ └── variants │ │ ├── NUCLEO_F767ZI │ │ └── variant.h │ │ └── NUCLEO_L053R8 │ │ └── variant.h │ ├── 2.0.0 │ ├── system │ │ ├── STM32F4xx │ │ │ └── stm32f4xx_hal_conf_default.h │ │ └── STM32F7xx │ │ │ └── stm32f7xx_hal_conf_default.h │ └── variants │ │ ├── F765Z(G-I)T_F767Z(G-I)T_F777ZIT │ │ └── variant_NUCLEO_F767ZI.h │ │ ├── L052R(6-8)H_L053R(6-8)H │ │ └── variant_generic.h │ │ ├── STM32F7xx │ │ └── F765Z(G-I)T_F767Z(G-I)T_F777ZIT │ │ │ └── variant_NUCLEO_F767ZI.h │ │ └── STM32L0xx │ │ └── L052R(6-8)T_L053R(6-8)T_L063R8T │ │ └── variant_generic.h │ ├── 2.1.0 │ ├── system │ │ ├── STM32F4xx │ │ │ └── stm32f4xx_hal_conf_default.h │ │ └── STM32F7xx │ │ │ └── stm32f7xx_hal_conf_default.h │ └── variants │ │ ├── STM32F7xx │ │ └── F765Z(G-I)T_F767Z(G-I)T_F777ZIT │ │ │ └── variant_NUCLEO_F767ZI.h │ │ └── STM32L0xx │ │ └── L052R(6-8)T_L053R(6-8)T_L063R8T │ │ └── variant_generic.h │ ├── 2.2.0 │ ├── system │ │ ├── STM32F4xx │ │ │ └── stm32f4xx_hal_conf_default.h │ │ └── STM32F7xx │ │ │ └── stm32f7xx_hal_conf_default.h │ └── variants │ │ ├── STM32F7xx │ │ └── F765Z(G-I)T_F767Z(G-I)T_F777ZIT │ │ │ └── variant_NUCLEO_F767ZI.h │ │ └── STM32L0xx │ │ └── L052R(6-8)T_L053R(6-8)T_L063R8T │ │ └── variant_generic.h │ └── 2.3.0 │ ├── system │ ├── STM32F4xx │ │ └── stm32f4xx_hal_conf_default.h │ └── STM32F7xx │ │ └── stm32f7xx_hal_conf_default.h │ └── variants │ ├── STM32F7xx │ └── F765Z(G-I)T_F767Z(G-I)T_F777ZIT │ │ └── variant_NUCLEO_F767ZI.h │ └── STM32L0xx │ └── L052R(6-8)T_L053R(6-8)T_L063R8T │ └── variant_generic.h ├── README.md ├── TrustAnchors.md ├── changelog.md ├── examples ├── AWS_IoT │ ├── AWS_IoT.ino │ ├── AWS_Root_CA.h │ └── defines.h ├── AdvancedWebServer │ ├── AdvancedWebServer.ino │ └── defines.h ├── HTTPClient │ ├── BasicAuthGet │ │ ├── BasicAuthGet.ino │ │ └── defines.h │ ├── CustomHeader │ │ ├── CustomHeader.ino │ │ └── defines.h │ ├── DweetGet │ │ ├── DweetGet.ino │ │ └── defines.h │ ├── DweetPost │ │ ├── DweetPost.ino │ │ └── defines.h │ ├── HueBlink │ │ ├── HueBlink.ino │ │ └── defines.h │ ├── PostWithHeaders │ │ ├── PostWithHeaders.ino │ │ └── defines.h │ ├── SimpleDelete │ │ ├── SimpleDelete.ino │ │ └── defines.h │ ├── SimpleGet │ │ ├── SimpleGet.ino │ │ └── defines.h │ ├── SimpleHTTPExample │ │ ├── SimpleHTTPExample.ino │ │ └── defines.h │ ├── SimplePost │ │ ├── SimplePost.ino │ │ └── defines.h │ ├── SimplePut │ │ ├── SimplePut.ino │ │ └── defines.h │ ├── SimpleWebSocket │ │ ├── SimpleWebSocket.ino │ │ └── defines.h │ └── node_test_server │ │ ├── getPostPutDelete.js │ │ └── package.json ├── HelloServer │ ├── HelloServer.ino │ └── defines.h ├── HelloServer2 │ ├── HelloServer2.ino │ └── defines.h ├── HttpBasicAuth │ ├── HttpBasicAuth.ino │ └── defines.h ├── MQTTClient_Auth │ ├── MQTTClient_Auth.ino │ └── defines.h ├── MQTTClient_Basic │ ├── MQTTClient_Basic.ino │ └── defines.h ├── MQTTClient_SSL │ ├── MQTTClient_SSL.ino │ ├── broker.emqx.io-ca.crt │ ├── certificates.h │ └── defines.h ├── MQTTClient_SSL_Auth │ ├── MQTTClient_SSL_Auth.ino │ ├── certificates.h │ └── defines.h ├── MQTTClient_SSL_Complex │ ├── MQTTClient_SSL_Complex.ino │ ├── certificates.h │ └── defines.h ├── MQTTS_ThingStream │ ├── MQTTS_ThingStream.ino │ ├── broker.emqx.io-ca.crt │ ├── certificates.h │ └── defines.h ├── MQTT_ThingStream │ ├── MQTT_ThingStream.ino │ └── defines.h ├── PostServer │ ├── PostServer.ino │ └── defines.h ├── STM32_LAN8720 │ ├── MQTTClient_SSL_Auth_LAN8720 │ │ ├── MQTTClient_SSL_Auth_LAN8720.ino │ │ ├── certificates.h │ │ ├── defines.h │ │ └── hal_conf_extra.h │ ├── MQTTClient_SSL_Complex_LAN8720 │ │ ├── MQTTClient_SSL_Complex_LAN8720.ino │ │ ├── certificates.h │ │ ├── defines.h │ │ └── hal_conf_extra.h │ ├── MQTTClient_SSL_LAN8720 │ │ ├── MQTTClient_SSL_LAN8720.ino │ │ ├── broker.emqx.io-ca.crt │ │ ├── certificates.h │ │ ├── defines.h │ │ └── hal_conf_extra.h │ ├── MQTTS_ThingStream_LAN8720 │ │ ├── MQTTS_ThingStream_LAN8720.ino │ │ ├── broker.emqx.io-ca.crt │ │ ├── certificates.h │ │ ├── defines.h │ │ └── hal_conf_extra.h │ ├── WebClientMulti_SSL_LAN8720 │ │ ├── WebClientMulti_SSL_LAN8720.ino │ │ ├── defines.h │ │ ├── hal_conf_extra.h │ │ └── trustanchors.h │ └── WebClient_SSL_LAN8720 │ │ ├── WebClient_SSL_LAN8720.ino │ │ ├── defines.h │ │ ├── hal_conf_extra.h │ │ └── trust_anchors.h ├── SimpleAuthentication │ ├── SimpleAuthentication.ino │ └── defines.h ├── UdpNTPClient │ ├── UdpNTPClient.ino │ └── defines.h ├── UdpSendReceive │ ├── UdpSendReceive.ino │ └── defines.h ├── WebClient │ ├── WebClient.ino │ └── defines.h ├── WebClientMulti_SSL │ ├── WebClientMulti_SSL.ino │ ├── defines.h │ └── trustanchors.h ├── WebClientRepeating │ ├── WebClientRepeating.ino │ └── defines.h ├── WebClient_SSL │ ├── WebClient_SSL.ino │ ├── defines.h │ └── trust_anchors.h ├── WebServer │ ├── WebServer.ino │ └── defines.h └── multiFileProject │ ├── multiFileProject.cpp │ ├── multiFileProject.h │ └── multiFileProject.ino ├── keywords.txt ├── library.json ├── library.properties ├── pics ├── AdvancedWebServer.png ├── AdvancedWebServer_NUCLEO_L552ZE_Q.png ├── LAN8720_STM32F4_Wiring.png └── STM32F407VET6.png ├── platformio └── platformio.ini ├── src ├── EthernetHttpClient_SSL_STM32.h ├── EthernetWebServer_SSL_STM32-impl.h ├── EthernetWebServer_SSL_STM32.h ├── EthernetWebServer_SSL_STM32.hpp ├── Ethernet_HTTPClient │ ├── Ethernet_HttpClient.cpp │ ├── Ethernet_HttpClient.h │ ├── Ethernet_URLEncoder.cpp │ ├── Ethernet_URLEncoder.h │ ├── Ethernet_WebSocketClient.cpp │ └── Ethernet_WebSocketClient.h ├── Parsing_SSL_STM32-impl.h ├── SSLClient │ ├── SSLClient.h │ ├── SSLClientParameters.cpp │ ├── SSLClientParameters.h │ ├── SSLClient_Impl.h │ ├── SSLSession.h │ ├── TLS12_only_profile.c │ ├── bearssl.h │ ├── bearssl │ │ └── src │ │ │ ├── aead │ │ │ ├── ccm.c │ │ │ ├── eax.c │ │ │ └── gcm.c │ │ │ ├── codec │ │ │ ├── ccopy.c │ │ │ ├── dec16be.c │ │ │ ├── dec16le.c │ │ │ ├── dec32be.c │ │ │ ├── dec32le.c │ │ │ ├── dec64be.c │ │ │ ├── dec64le.c │ │ │ ├── enc16be.c │ │ │ ├── enc16le.c │ │ │ ├── enc32be.c │ │ │ ├── enc32le.c │ │ │ ├── enc64be.c │ │ │ ├── enc64le.c │ │ │ ├── pemdec.c │ │ │ ├── pemdec.t0 │ │ │ └── pemenc.c │ │ │ ├── ec │ │ │ ├── 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 │ │ │ ├── hash │ │ │ ├── dig_oid.c │ │ │ ├── dig_size.c │ │ │ ├── ghash_ctmul.c │ │ │ ├── ghash_ctmul32.c │ │ │ ├── ghash_ctmul64.c │ │ │ ├── ghash_pclmul.c │ │ │ ├── ghash_pwr8.c │ │ │ ├── md5.c │ │ │ ├── md5sha1.c │ │ │ ├── mgf1.c │ │ │ ├── multihash.c │ │ │ ├── sha1.c │ │ │ ├── sha2big.c │ │ │ └── sha2small.c │ │ │ ├── int │ │ │ ├── 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 │ │ │ ├── kdf │ │ │ ├── hkdf.c │ │ │ └── shake.c │ │ │ ├── mac │ │ │ ├── hmac.c │ │ │ └── hmac_ct.c │ │ │ ├── rand │ │ │ ├── aesctr_drbg.c │ │ │ ├── hmac_drbg.c │ │ │ └── sysrng.c │ │ │ ├── rsa │ │ │ ├── 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 │ │ │ ├── ssl │ │ │ ├── prf.c │ │ │ ├── prf_md5sha1.c │ │ │ ├── prf_sha256.c │ │ │ ├── prf_sha384.c │ │ │ ├── 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 │ │ │ ├── symcipher │ │ │ ├── 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 │ │ │ ├── chacha20_ct.c │ │ │ ├── chacha20_sse2.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 │ │ │ ├── poly1305_ctmul.c │ │ │ ├── poly1305_ctmul32.c │ │ │ ├── poly1305_ctmulq.c │ │ │ └── poly1305_i15.c │ │ │ └── x509 │ │ │ ├── asn1.t0 │ │ │ ├── asn1enc.c │ │ │ ├── encode_ec_pk8der.c │ │ │ ├── encode_ec_rawder.c │ │ │ ├── encode_rsa_pk8der.c │ │ │ ├── encode_rsa_rawder.c │ │ │ ├── skey_decoder.c │ │ │ ├── skey_decoder.t0 │ │ │ ├── x509_decoder.c │ │ │ ├── x509_decoder.t0 │ │ │ ├── x509_knownkey.c │ │ │ ├── x509_minimal.c │ │ │ ├── x509_minimal.t0 │ │ │ └── x509_minimal_full.c │ ├── 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 │ ├── config.h │ ├── ec_prime_fast_256.c │ ├── inner.h │ └── time_macros.h ├── detail │ ├── Debug_STM32.h │ ├── RequestHandler_STM32.h │ ├── RequestHandlersImpl_STM32.h │ └── mimetable.h ├── inner.h ├── libb64 │ ├── base64.cpp │ ├── base64.h │ ├── cdecode.c │ ├── cdecode.h │ ├── cencode.c │ └── cencode.h └── time_macros.h ├── tools └── pycert_bearssl │ ├── cert_util.py │ └── pycert_bearssl.py └── utils ├── astyle_library.conf └── restyle.sh /.codespellrc: -------------------------------------------------------------------------------- 1 | # See: https://github.com/codespell-project/codespell#using-a-config-file 2 | [codespell] 3 | # In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: 4 | ignore-words-list = , 5 | check-filenames = 6 | check-hidden = 7 | skip = ./.git,./src,./examples,./Packages_Patches,./LibraryPatches 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Is your feature request related to a problem? Please describe. 11 | 12 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 13 | 14 | ### Describe the solution you'd like 15 | 16 | A clear and concise description of what you want to happen. 17 | 18 | ### Describe alternatives you've considered 19 | 20 | A clear and concise description of any alternative solutions or features you've considered. 21 | 22 | ### Additional context 23 | 24 | Add any other context or screenshots about the feature request here. 25 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # See: https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#about-the-dependabotyml-file 2 | version: 2 3 | 4 | updates: 5 | # Configure check for outdated GitHub Actions actions in workflows. 6 | # See: https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot 7 | - package-ecosystem: github-actions 8 | directory: / # Check the repository's workflows under /.github/workflows/ 9 | schedule: 10 | interval: daily 11 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-stale - https://github.com/probot/stale 2 | 3 | daysUntilStale: 60 4 | daysUntilClose: 14 5 | limitPerRun: 30 6 | staleLabel: stale 7 | exemptLabels: 8 | - pinned 9 | - security 10 | - "to be implemented" 11 | - "for reference" 12 | - "move to PR" 13 | - "enhancement" 14 | 15 | only: issues 16 | onlyLabels: [] 17 | exemptProjects: false 18 | exemptMilestones: false 19 | exemptAssignees: false 20 | 21 | markComment: > 22 | [STALE_SET] This issue has been automatically marked as stale because it has not had 23 | recent activity. It will be closed in 14 days if no further activity occurs. Thank you 24 | for your contributions. 25 | 26 | unmarkComment: > 27 | [STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it opening the future. 28 | 29 | closeComment: > 30 | [STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions. 31 | 32 | -------------------------------------------------------------------------------- /.github/workflows/auto-github-actions.yml: -------------------------------------------------------------------------------- 1 | name: auto-github-actions 2 | on: [push] 3 | jobs: 4 | check-bats-version: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v3 8 | - uses: actions/setup-node@v3 9 | with: 10 | node-version: '14' 11 | - run: npm install -g bats 12 | - run: bats -v 13 | -------------------------------------------------------------------------------- /.github/workflows/check-arduino.yml: -------------------------------------------------------------------------------- 1 | name: Check Arduino 2 | 3 | # See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows 4 | on: 5 | push: 6 | pull_request: 7 | schedule: 8 | # Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint. 9 | - cron: "0 8 * * TUE" 10 | workflow_dispatch: 11 | repository_dispatch: 12 | 13 | jobs: 14 | lint: 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Checkout repository 19 | uses: actions/checkout@v3 20 | 21 | - name: Arduino Lint 22 | uses: arduino/arduino-lint-action@v1 23 | with: 24 | compliance: specification 25 | library-manager: update 26 | # Always use this setting for official repositories. Remove for 3rd party projects. 27 | official: true 28 | project-type: library 29 | -------------------------------------------------------------------------------- /.github/workflows/report-size-deltas.yml: -------------------------------------------------------------------------------- 1 | name: Report Size Deltas 2 | 3 | on: 4 | schedule: 5 | - cron: '*/5 * * * *' 6 | 7 | jobs: 8 | report: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Comment size deltas reports to PRs 13 | uses: arduino/report-size-deltas@v1 14 | with: 15 | # The name of the workflow artifact created by the "Compile Examples" workflow 16 | sketches-reports-source: sketches-reports 17 | -------------------------------------------------------------------------------- /.github/workflows/spell-check.yml: -------------------------------------------------------------------------------- 1 | name: Spell Check 2 | 3 | on: 4 | pull_request: 5 | push: 6 | schedule: 7 | # run every Tuesday at 3 AM UTC 8 | - cron: "0 3 * * 2" 9 | workflow_dispatch: 10 | repository_dispatch: 11 | 12 | jobs: 13 | spellcheck: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v3 19 | 20 | # See: https://github.com/codespell-project/actions-codespell/blob/master/README.md 21 | - name: Spell check 22 | uses: codespell-project/actions-codespell@master 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /LibraryPatches/esp32/cores/esp32/Server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Server.h - Base class that provides Server 3 | Copyright (c) 2011 Adrian McEwen. All right reserved. 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #ifndef server_h 21 | #define server_h 22 | 23 | #include "Print.h" 24 | 25 | class Server: public Print 26 | { 27 | public: 28 | // KH, change to fix compiler error for EthernetWebServer 29 | // error: cannot declare field 'EthernetWebServer::_server' to be of abstract type 'EthernetServer' 30 | // virtual void begin(uint16_t port=0) =0; 31 | //virtual void begin() = 0; 32 | void begin() {}; 33 | }; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /examples/HTTPClient/node_test_server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "node_test_server", 3 | "version": "0.0.1", 4 | "author": { 5 | "name": "Tom Igoe" 6 | }, 7 | "dependencies": { 8 | "body-parser": ">=1.11.0", 9 | "express": ">=4.0.0", 10 | "multer": "*", 11 | "ws": ">=5.2.3" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/MQTTClient_SSL/broker.emqx.io-ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB 3 | iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl 4 | cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV 5 | BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw 6 | MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV 7 | BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU 8 | aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2Vy 9 | dGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK 10 | AoICAQCAEmUXNg7D2wiz0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B 11 | 3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2jY0K2dvKpOyuR+OJv0OwWIJAJPuLodMkY 12 | tJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFnRghRy4YUVD+8M/5+bJz/ 13 | Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O+T23LLb2 14 | VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT 15 | 79uq/nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6 16 | c0Plfg6lZrEpfDKEY1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmT 17 | Yo61Zs8liM2EuLE/pDkP2QKe6xJMlXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97l 18 | c6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8yexDJtC/QV9AqURE9JnnV4ee 19 | UB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+eLf8ZxXhyVeE 20 | Hg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd 21 | BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8G 22 | A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPF 23 | Up/L+M+ZBn8b2kMVn54CVVeWFPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KO 24 | VWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ7l8wXEskEVX/JJpuXior7gtNn3/3 25 | ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQEg9zKC7F4iRO/Fjs 26 | 8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM8WcR 27 | iQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYze 28 | Sf7dNXGiFSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZ 29 | XHlKYC6SQK5MNyosycdiyA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/ 30 | qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB 31 | VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB 32 | L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG 33 | jjxDah2nGN59PRbxYvnKkKj9 34 | -----END CERTIFICATE----- 35 | -------------------------------------------------------------------------------- /examples/MQTTS_ThingStream/broker.emqx.io-ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB 3 | iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl 4 | cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV 5 | BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw 6 | MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV 7 | BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU 8 | aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2Vy 9 | dGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK 10 | AoICAQCAEmUXNg7D2wiz0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B 11 | 3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2jY0K2dvKpOyuR+OJv0OwWIJAJPuLodMkY 12 | tJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFnRghRy4YUVD+8M/5+bJz/ 13 | Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O+T23LLb2 14 | VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT 15 | 79uq/nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6 16 | c0Plfg6lZrEpfDKEY1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmT 17 | Yo61Zs8liM2EuLE/pDkP2QKe6xJMlXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97l 18 | c6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8yexDJtC/QV9AqURE9JnnV4ee 19 | UB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+eLf8ZxXhyVeE 20 | Hg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd 21 | BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8G 22 | A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPF 23 | Up/L+M+ZBn8b2kMVn54CVVeWFPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KO 24 | VWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ7l8wXEskEVX/JJpuXior7gtNn3/3 25 | ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQEg9zKC7F4iRO/Fjs 26 | 8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM8WcR 27 | iQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYze 28 | Sf7dNXGiFSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZ 29 | XHlKYC6SQK5MNyosycdiyA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/ 30 | qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB 31 | VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB 32 | L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG 33 | jjxDah2nGN59PRbxYvnKkKj9 34 | -----END CERTIFICATE----- 35 | -------------------------------------------------------------------------------- /examples/STM32_LAN8720/MQTTClient_SSL_Auth_LAN8720/hal_conf_extra.h: -------------------------------------------------------------------------------- 1 | // Note: Must replace 2 | // .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h 3 | // as described in README.md 4 | 5 | #define HAL_ETH_MODULE_ENABLED 6 | 7 | #define LAN8742A_PHY_ADDRESS 0x01U 8 | -------------------------------------------------------------------------------- /examples/STM32_LAN8720/MQTTClient_SSL_Complex_LAN8720/hal_conf_extra.h: -------------------------------------------------------------------------------- 1 | // Note: Must replace 2 | // .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h 3 | // as described in README.md 4 | 5 | #define HAL_ETH_MODULE_ENABLED 6 | 7 | #define LAN8742A_PHY_ADDRESS 0x01U 8 | -------------------------------------------------------------------------------- /examples/STM32_LAN8720/MQTTClient_SSL_LAN8720/broker.emqx.io-ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCB 3 | iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl 4 | cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV 5 | BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAw 6 | MjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNV 7 | BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU 8 | aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2Vy 9 | dGlmaWNhdGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK 10 | AoICAQCAEmUXNg7D2wiz0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B 11 | 3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2jY0K2dvKpOyuR+OJv0OwWIJAJPuLodMkY 12 | tJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFnRghRy4YUVD+8M/5+bJz/ 13 | Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O+T23LLb2 14 | VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT 15 | 79uq/nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6 16 | c0Plfg6lZrEpfDKEY1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmT 17 | Yo61Zs8liM2EuLE/pDkP2QKe6xJMlXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97l 18 | c6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8yexDJtC/QV9AqURE9JnnV4ee 19 | UB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+eLf8ZxXhyVeE 20 | Hg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd 21 | BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8G 22 | A1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPF 23 | Up/L+M+ZBn8b2kMVn54CVVeWFPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KO 24 | VWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ7l8wXEskEVX/JJpuXior7gtNn3/3 25 | ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQEg9zKC7F4iRO/Fjs 26 | 8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM8WcR 27 | iQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYze 28 | Sf7dNXGiFSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZ 29 | XHlKYC6SQK5MNyosycdiyA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/ 30 | qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9cJ2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRB 31 | VXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGwsAvgnEzDHNb842m1R0aB 32 | L6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gxQ+6IHdfG 33 | jjxDah2nGN59PRbxYvnKkKj9 34 | -----END CERTIFICATE----- 35 | -------------------------------------------------------------------------------- /examples/STM32_LAN8720/MQTTClient_SSL_LAN8720/hal_conf_extra.h: -------------------------------------------------------------------------------- 1 | // Note: Must replace 2 | // .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h 3 | // as described in README.md 4 | 5 | #define HAL_ETH_MODULE_ENABLED 6 | 7 | #define LAN8742A_PHY_ADDRESS 0x01U 8 | -------------------------------------------------------------------------------- /examples/STM32_LAN8720/MQTTS_ThingStream_LAN8720/hal_conf_extra.h: -------------------------------------------------------------------------------- 1 | // Note: Must replace 2 | // .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h 3 | // as described in README.md 4 | 5 | #define HAL_ETH_MODULE_ENABLED 6 | 7 | #define LAN8742A_PHY_ADDRESS 0x01U 8 | -------------------------------------------------------------------------------- /examples/STM32_LAN8720/WebClientMulti_SSL_LAN8720/hal_conf_extra.h: -------------------------------------------------------------------------------- 1 | // Note: Must replace 2 | // .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h 3 | // as described in README.md 4 | 5 | #define HAL_ETH_MODULE_ENABLED 6 | 7 | #define LAN8742A_PHY_ADDRESS 0x01U 8 | -------------------------------------------------------------------------------- /examples/STM32_LAN8720/WebClient_SSL_LAN8720/hal_conf_extra.h: -------------------------------------------------------------------------------- 1 | // Note: Must replace 2 | // .arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h 3 | // as described in README.md 4 | 5 | #define HAL_ETH_MODULE_ENABLED 6 | 7 | #define LAN8742A_PHY_ADDRESS 0x01U 8 | -------------------------------------------------------------------------------- /examples/multiFileProject/multiFileProject.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | multiFileProject.cpp 3 | For STM32F/L/H/G/WB/MP1 with built-in Ethernet LAN8742A (Nucleo-144, DISCOVERY, etc) or W5x00/ENC28J60 shield/module 4 | 5 | EthernetWebServer_SSL_STM32 is a library for STM32 using the Ethernet shields to run WebServer and Client with/without SSL 6 | 7 | Use SSLClient Library code from https://github.com/OPEnSLab-OSU/SSLClient 8 | 9 | Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer_SSL_STM32 10 | *****************************************************************************************************************************/ 11 | 12 | // To demo how to include files in multi-file Projects 13 | 14 | #include "multiFileProject.h" 15 | -------------------------------------------------------------------------------- /examples/multiFileProject/multiFileProject.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | multiFileProject.h 3 | For STM32F/L/H/G/WB/MP1 with built-in Ethernet LAN8742A (Nucleo-144, DISCOVERY, etc) or W5x00/ENC28J60 shield/module 4 | 5 | EthernetWebServer_SSL_STM32 is a library for STM32 using the Ethernet shields to run WebServer and Client with/without SSL 6 | 7 | Use SSLClient Library code from https://github.com/OPEnSLab-OSU/SSLClient 8 | 9 | Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer_SSL_STM32 10 | *****************************************************************************************************************************/ 11 | 12 | // To demo how to include files in multi-file Projects 13 | 14 | #pragma once 15 | 16 | #define _ETHERNET_WEBSERVER_LOGLEVEL_ 1 17 | 18 | // Can be included as many times as necessary, without `Multiple Definitions` Linker Error 19 | #include // https://github.com/khoih-prog/EthernetWebServer_SSL_STM32 20 | 21 | #include // https://github.com/khoih-prog/EthernetWebServer_SSL_STM32 22 | -------------------------------------------------------------------------------- /examples/multiFileProject/multiFileProject.ino: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | multiFileProject.ino 3 | For STM32F/L/H/G/WB/MP1 with built-in Ethernet LAN8742A (Nucleo-144, DISCOVERY, etc) or W5x00/ENC28J60 shield/module 4 | 5 | EthernetWebServer_SSL_STM32 is a library for STM32 using the Ethernet shields to run WebServer and Client with/without SSL 6 | 7 | Use SSLClient Library code from https://github.com/OPEnSLab-OSU/SSLClient 8 | 9 | Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer_SSL_STM32 10 | *****************************************************************************************************************************/ 11 | 12 | // To demo how to include files in multi-file Projects 13 | 14 | #define ETHERNET_WEBSERVER_SSL_STM32_VERSION_MIN_TARGET "EthernetWebServer_SSL_STM32 v1.6.0" 15 | #define ETHERNET_WEBSERVER_SSL_STM32_VERSION_MIN 1006000 16 | 17 | #include "multiFileProject.h" 18 | 19 | // To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error 20 | #include // https://github.com/khoih-prog/EthernetWebServer_SSL_STM32 21 | 22 | void setup() 23 | { 24 | Serial.begin(115200); 25 | 26 | while (!Serial && millis() < 5000); 27 | 28 | delay(500); 29 | 30 | Serial.println("\nStart multiFileProject"); 31 | Serial.println(ETHERNET_WEBSERVER_SSL_STM32_VERSION); 32 | 33 | #if defined(ETHERNET_WEBSERVER_SSL_STM32_VERSION_MIN) 34 | 35 | if (ETHERNET_WEBSERVER_SSL_STM32_VERSION_INT < ETHERNET_WEBSERVER_SSL_STM32_VERSION_MIN) 36 | { 37 | Serial.print("Warning. Must use this example on Version equal or later than : "); 38 | Serial.println(ETHERNET_WEBSERVER_SSL_STM32_VERSION_MIN_TARGET); 39 | } 40 | 41 | #endif 42 | 43 | Serial.print("You're OK now"); 44 | } 45 | 46 | void loop() 47 | { 48 | // put your main code here, to run repeatedly: 49 | } 50 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=EthernetWebServer_SSL_STM32 2 | version=1.6.0 3 | author=Khoi Hoang 4 | license=GPLv3 5 | maintainer=Khoi Hoang 6 | sentence=Simple TLS/SSL Ethernet WebServer, HTTP Client and WebSocket Client library for STM32F/L/H/G/WB/MP1 boards running WebServer using built-in Ethernet LAN8742A, Ethernet LAN8720, W5x00 or ENC28J60 shields. It now supports Ethernet TLS/SSL Client. 7 | paragraph=The WebServer supports HTTP/HTTPS GET and POST requests, provides argument parsing, handles one client at a time. It now provides HTTP(S) Client and Secured WebSockets Client. It supports Arduino STM32F/L/H/G/WB/MP1 series with 32+ Kbytes of Flash, using built-in LAN8742A Ethernet (Nucleo-144: F429ZI, F767ZI, Discovery: STM32F746G-DISCOVERY), or LAN8720, ENC28J60, W5x00 Ethernet shields. Ethernet_Generic library is used as default for W5x00. Now W5x00 can use any custom hardware / software SPI 8 | category=Communication 9 | url=https://github.com/khoih-prog/EthernetWebServer_SSL_STM32 10 | architectures=stm32 11 | depends=STM32duino LwIP, STM32duino STM32Ethernet, Functional-Vlpp, Ethernet_Generic 12 | includes=EthernetWebServer_SSL_STM32.h, EthernetWebServer_SSL_STM32.hpp, EthernetHttpClient_SSL_STM32.h 13 | -------------------------------------------------------------------------------- /pics/AdvancedWebServer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoih-prog/EthernetWebServer_SSL_STM32/7f330a04193077296961a5cc3a68072f87028fc8/pics/AdvancedWebServer.png -------------------------------------------------------------------------------- /pics/AdvancedWebServer_NUCLEO_L552ZE_Q.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoih-prog/EthernetWebServer_SSL_STM32/7f330a04193077296961a5cc3a68072f87028fc8/pics/AdvancedWebServer_NUCLEO_L552ZE_Q.png -------------------------------------------------------------------------------- /pics/LAN8720_STM32F4_Wiring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoih-prog/EthernetWebServer_SSL_STM32/7f330a04193077296961a5cc3a68072f87028fc8/pics/LAN8720_STM32F4_Wiring.png -------------------------------------------------------------------------------- /pics/STM32F407VET6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khoih-prog/EthernetWebServer_SSL_STM32/7f330a04193077296961a5cc3a68072f87028fc8/pics/STM32F407VET6.png -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_ccopy(uint32_t ctl, void *dst, const void *src, size_t len) 30 | { 31 | unsigned char *d; 32 | const unsigned char *s; 33 | 34 | d = dst; 35 | s = src; 36 | 37 | while (len -- > 0) 38 | { 39 | uint32_t x, y; 40 | 41 | x = *s ++; 42 | y = *d; 43 | *d = MUX(ctl, x, y); 44 | d ++; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_dec16be(uint16_t *v, size_t num, const void *src) 30 | { 31 | const unsigned char *buf; 32 | 33 | buf = src; 34 | 35 | while (num -- > 0) 36 | { 37 | *v ++ = br_dec16be(buf); 38 | buf += 2; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_dec16le(uint16_t *v, size_t num, const void *src) 30 | { 31 | const unsigned char *buf; 32 | 33 | buf = src; 34 | 35 | while (num -- > 0) 36 | { 37 | *v ++ = br_dec16le(buf); 38 | buf += 2; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_dec32be(uint32_t *v, size_t num, const void *src) 30 | { 31 | const unsigned char *buf; 32 | 33 | buf = src; 34 | 35 | while (num -- > 0) 36 | { 37 | *v ++ = br_dec32be(buf); 38 | buf += 4; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_dec32le(uint32_t *v, size_t num, const void *src) 30 | { 31 | const unsigned char *buf; 32 | 33 | buf = src; 34 | 35 | while (num -- > 0) 36 | { 37 | *v ++ = br_dec32le(buf); 38 | buf += 4; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_dec64be(uint64_t *v, size_t num, const void *src) 30 | { 31 | const unsigned char *buf; 32 | 33 | buf = src; 34 | 35 | while (num -- > 0) 36 | { 37 | *v ++ = br_dec64be(buf); 38 | buf += 8; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_dec64le(uint64_t *v, size_t num, const void *src) 30 | { 31 | const unsigned char *buf; 32 | 33 | buf = src; 34 | 35 | while (num -- > 0) 36 | { 37 | *v ++ = br_dec64le(buf); 38 | buf += 8; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_enc16be(void *dst, const uint16_t *v, size_t num) 30 | { 31 | unsigned char *buf; 32 | 33 | buf = dst; 34 | 35 | while (num -- > 0) 36 | { 37 | br_enc16be(buf, *v ++); 38 | buf += 2; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_enc16le(void *dst, const uint16_t *v, size_t num) 30 | { 31 | unsigned char *buf; 32 | 33 | buf = dst; 34 | 35 | while (num -- > 0) 36 | { 37 | br_enc16le(buf, *v ++); 38 | buf += 2; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_enc32be(void *dst, const uint32_t *v, size_t num) 30 | { 31 | unsigned char *buf; 32 | 33 | buf = dst; 34 | 35 | while (num -- > 0) 36 | { 37 | br_enc32be(buf, *v ++); 38 | buf += 4; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_enc32le(void *dst, const uint32_t *v, size_t num) 30 | { 31 | unsigned char *buf; 32 | 33 | buf = dst; 34 | 35 | while (num -- > 0) 36 | { 37 | br_enc32le(buf, *v ++); 38 | buf += 4; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_enc64be(void *dst, const uint64_t *v, size_t num) 30 | { 31 | unsigned char *buf; 32 | 33 | buf = dst; 34 | 35 | while (num -- > 0) 36 | { 37 | br_enc64be(buf, *v ++); 38 | buf += 8; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/codec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_range_enc64le(void *dst, const uint64_t *v, size_t num) 30 | { 31 | unsigned char *buf; 32 | 33 | buf = dst; 34 | 35 | while (num -- > 0) 36 | { 37 | br_enc64le(buf, *v ++); 38 | buf += 8; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 "inner.h" 26 | 27 | static const unsigned char GEN[] = 28 | { 29 | 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 33 | }; 34 | 35 | static const unsigned char ORDER[] = 36 | { 37 | 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 38 | 0xFF, 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 | }; 42 | 43 | /* see inner.h */ 44 | const br_ec_curve_def br_curve25519 = 45 | { 46 | BR_EC_curve25519, 47 | ORDER, sizeof ORDER, 48 | GEN, sizeof GEN 49 | }; 50 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 "inner.h" 26 | 27 | /* see bearssl_ec.h */ 28 | const br_ec_impl * 29 | br_ec_get_default(void) 30 | { 31 | #if BR_LOMUL 32 | return &br_ec_all_m15; 33 | #else 34 | return &br_ec_all_m31; 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/ec_secp256r1.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016 Thomas Pornin 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | #include "inner.h" 26 | 27 | static const unsigned char P256_N[] = 28 | { 29 | 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 30 | 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 31 | 0xBC, 0xE6, 0xFA, 0xAD, 0xA7, 0x17, 0x9E, 0x84, 32 | 0xF3, 0xB9, 0xCA, 0xC2, 0xFC, 0x63, 0x25, 0x51 33 | }; 34 | 35 | static const unsigned char P256_G[] = 36 | { 37 | 0x04, 0x6B, 0x17, 0xD1, 0xF2, 0xE1, 0x2C, 0x42, 38 | 0x47, 0xF8, 0xBC, 0xE6, 0xE5, 0x63, 0xA4, 0x40, 39 | 0xF2, 0x77, 0x03, 0x7D, 0x81, 0x2D, 0xEB, 0x33, 40 | 0xA0, 0xF4, 0xA1, 0x39, 0x45, 0xD8, 0x98, 0xC2, 41 | 0x96, 0x4F, 0xE3, 0x42, 0xE2, 0xFE, 0x1A, 0x7F, 42 | 0x9B, 0x8E, 0xE7, 0xEB, 0x4A, 0x7C, 0x0F, 0x9E, 43 | 0x16, 0x2B, 0xCE, 0x33, 0x57, 0x6B, 0x31, 0x5E, 44 | 0xCE, 0xCB, 0xB6, 0x40, 0x68, 0x37, 0xBF, 0x51, 45 | 0xF5 46 | }; 47 | 48 | /* see inner.h */ 49 | const br_ec_curve_def br_secp256r1 = 50 | { 51 | BR_EC_secp256r1, 52 | P256_N, sizeof P256_N, 53 | P256_G, sizeof P256_G 54 | }; 55 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 "inner.h" 26 | 27 | /* see bearssl_ec.h */ 28 | br_ecdsa_sign 29 | br_ecdsa_sign_asn1_get_default(void) 30 | { 31 | #if BR_LOMUL 32 | return &br_ecdsa_i15_sign_asn1; 33 | #else 34 | return &br_ecdsa_i31_sign_asn1; 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 "inner.h" 26 | 27 | /* see bearssl_ec.h */ 28 | br_ecdsa_sign 29 | br_ecdsa_sign_raw_get_default(void) 30 | { 31 | #if BR_LOMUL 32 | return &br_ecdsa_i15_sign_raw; 33 | #else 34 | return &br_ecdsa_i31_sign_raw; 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 "inner.h" 26 | 27 | /* see bearssl_ec.h */ 28 | br_ecdsa_vrfy 29 | br_ecdsa_vrfy_asn1_get_default(void) 30 | { 31 | #if BR_LOMUL 32 | return &br_ecdsa_i15_vrfy_asn1; 33 | #else 34 | return &br_ecdsa_i31_vrfy_asn1; 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 "inner.h" 26 | 27 | /* see bearssl_ec.h */ 28 | br_ecdsa_vrfy 29 | br_ecdsa_vrfy_raw_get_default(void) 30 | { 31 | #if BR_LOMUL 32 | return &br_ecdsa_i15_vrfy_raw; 33 | #else 34 | return &br_ecdsa_i31_vrfy_raw; 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_ecdsa_i15_bits2int(uint16_t *x, 30 | const void *src, size_t len, uint32_t ebitlen) 31 | { 32 | uint32_t bitlen, hbitlen; 33 | int sc; 34 | 35 | bitlen = ebitlen - (ebitlen >> 4); 36 | hbitlen = (uint32_t)len << 3; 37 | 38 | if (hbitlen > bitlen) 39 | { 40 | len = (bitlen + 7) >> 3; 41 | sc = (int)((hbitlen - bitlen) & 7); 42 | } 43 | else 44 | { 45 | sc = 0; 46 | } 47 | 48 | br_i15_zero(x, ebitlen); 49 | br_i15_decode(x, src, len); 50 | br_i15_rshift(x, sc); 51 | x[0] = ebitlen; 52 | } 53 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 "inner.h" 26 | 27 | #define ORDER_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 28 | 29 | /* see bearssl_ec.h */ 30 | size_t 31 | br_ecdsa_i15_sign_asn1(const br_ec_impl *impl, 32 | const br_hash_class *hf, const void *hash_value, 33 | const br_ec_private_key *sk, void *sig) 34 | { 35 | unsigned char rsig[(ORDER_LEN << 1) + 12]; 36 | size_t sig_len; 37 | 38 | sig_len = br_ecdsa_i15_sign_raw(impl, hf, hash_value, sk, rsig); 39 | 40 | if (sig_len == 0) 41 | { 42 | return 0; 43 | } 44 | 45 | sig_len = br_ecdsa_raw_to_asn1(rsig, sig_len); 46 | memcpy(sig, rsig, sig_len); 47 | return sig_len; 48 | } 49 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 | #include "inner.h" 26 | 27 | #define FIELD_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 28 | 29 | /* see bearssl_ec.h */ 30 | uint32_t 31 | br_ecdsa_i15_vrfy_asn1(const br_ec_impl *impl, 32 | const void *hash, size_t hash_len, 33 | const br_ec_public_key *pk, 34 | const void *sig, size_t sig_len) 35 | { 36 | /* 37 | We use a double-sized buffer because a malformed ASN.1 signature 38 | may trigger a size expansion when converting to "raw" format. 39 | */ 40 | unsigned char rsig[(FIELD_LEN << 2) + 24]; 41 | 42 | if (sig_len > ((sizeof rsig) >> 1)) 43 | { 44 | return 0; 45 | } 46 | 47 | memcpy(rsig, sig, sig_len); 48 | sig_len = br_ecdsa_asn1_to_raw(rsig, sig_len); 49 | return br_ecdsa_i15_vrfy_raw(impl, hash, hash_len, pk, rsig, sig_len); 50 | } 51 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 | #include "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_ecdsa_i31_bits2int(uint32_t *x, 30 | const void *src, size_t len, uint32_t ebitlen) 31 | { 32 | uint32_t bitlen, hbitlen; 33 | int sc; 34 | 35 | bitlen = ebitlen - (ebitlen >> 5); 36 | hbitlen = (uint32_t)len << 3; 37 | 38 | if (hbitlen > bitlen) 39 | { 40 | len = (bitlen + 7) >> 3; 41 | sc = (int)((hbitlen - bitlen) & 7); 42 | } 43 | else 44 | { 45 | sc = 0; 46 | } 47 | 48 | br_i31_zero(x, ebitlen); 49 | br_i31_decode(x, src, len); 50 | br_i31_rshift(x, sc); 51 | x[0] = ebitlen; 52 | } 53 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 | #include "inner.h" 26 | 27 | #define ORDER_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 28 | 29 | /* see bearssl_ec.h */ 30 | size_t 31 | br_ecdsa_i31_sign_asn1(const br_ec_impl *impl, 32 | const br_hash_class *hf, const void *hash_value, 33 | const br_ec_private_key *sk, void *sig) 34 | { 35 | unsigned char rsig[(ORDER_LEN << 1) + 12]; 36 | size_t sig_len; 37 | 38 | sig_len = br_ecdsa_i31_sign_raw(impl, hf, hash_value, sk, rsig); 39 | 40 | if (sig_len == 0) 41 | { 42 | return 0; 43 | } 44 | 45 | sig_len = br_ecdsa_raw_to_asn1(rsig, sig_len); 46 | memcpy(sig, rsig, sig_len); 47 | return sig_len; 48 | } 49 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ec/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 | #include "inner.h" 26 | 27 | #define FIELD_LEN ((BR_MAX_EC_SIZE + 7) >> 3) 28 | 29 | /* see bearssl_ec.h */ 30 | uint32_t 31 | br_ecdsa_i31_vrfy_asn1(const br_ec_impl *impl, 32 | const void *hash, size_t hash_len, 33 | const br_ec_public_key *pk, 34 | const void *sig, size_t sig_len) 35 | { 36 | /* 37 | We use a double-sized buffer because a malformed ASN.1 signature 38 | may trigger a size expansion when converting to "raw" format. 39 | */ 40 | unsigned char rsig[(FIELD_LEN << 2) + 24]; 41 | 42 | if (sig_len > ((sizeof rsig) >> 1)) 43 | { 44 | return 0; 45 | } 46 | 47 | memcpy(rsig, sig, sig_len); 48 | sig_len = br_ecdsa_asn1_to_raw(rsig, sig_len); 49 | return br_ecdsa_i31_vrfy_raw(impl, hash, hash_len, pk, rsig, sig_len); 50 | } 51 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/hash/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | size_t 29 | br_digest_size_by_ID(int digest_id) 30 | { 31 | switch (digest_id) 32 | { 33 | case br_md5sha1_ID: 34 | return br_md5_SIZE + br_sha1_SIZE; 35 | 36 | case br_md5_ID: 37 | return br_md5_SIZE; 38 | 39 | case br_sha1_ID: 40 | return br_sha1_SIZE; 41 | 42 | case br_sha224_ID: 43 | return br_sha224_SIZE; 44 | 45 | case br_sha256_ID: 46 | return br_sha256_SIZE; 47 | 48 | case br_sha384_ID: 49 | return br_sha384_SIZE; 50 | 51 | case br_sha512_ID: 52 | return br_sha512_SIZE; 53 | 54 | default: 55 | /* abort(); */ 56 | return 0; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/hash/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_mgf1_xor(void *data, size_t len, 30 | const br_hash_class *dig, const void *seed, size_t seed_len) 31 | { 32 | unsigned char *buf; 33 | size_t u, hlen; 34 | uint32_t c; 35 | 36 | buf = data; 37 | hlen = br_digest_size(dig); 38 | 39 | for (u = 0, c = 0; u < len; u += hlen, c ++) 40 | { 41 | br_hash_compat_context hc; 42 | unsigned char tmp[64]; 43 | size_t v; 44 | 45 | hc.vtable = dig; 46 | dig->init(&hc.vtable); 47 | dig->update(&hc.vtable, seed, seed_len); 48 | br_enc32be(tmp, c); 49 | dig->update(&hc.vtable, tmp, 4); 50 | dig->out(&hc.vtable, tmp); 51 | 52 | for (v = 0; v < hlen; v ++) 53 | { 54 | if ((u + v) >= len) 55 | { 56 | break; 57 | } 58 | 59 | buf[u + v] ^= tmp[v]; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 | #include "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i15_add(uint16_t *a, const uint16_t *b, uint32_t ctl) 30 | { 31 | uint32_t cc; 32 | size_t u, m; 33 | 34 | cc = 0; 35 | m = (a[0] + 31) >> 4; 36 | 37 | for (u = 1; u < m; u ++) 38 | { 39 | uint32_t aw, bw, naw; 40 | 41 | aw = a[u]; 42 | bw = b[u]; 43 | naw = aw + bw + cc; 44 | cc = naw >> 15; 45 | a[u] = MUX(ctl, naw & 0x7FFF, aw); 46 | } 47 | 48 | return cc; 49 | } 50 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i15_bit_length(uint16_t *x, size_t xlen) 30 | { 31 | uint32_t tw, twk; 32 | 33 | tw = 0; 34 | twk = 0; 35 | 36 | while (xlen -- > 0) 37 | { 38 | uint32_t w, c; 39 | 40 | c = EQ(tw, 0); 41 | w = x[xlen]; 42 | tw = MUX(c, w, tw); 43 | twk = MUX(c, (uint32_t)xlen, twk); 44 | } 45 | 46 | return (twk << 4) + BIT_LENGTH(tw); 47 | } 48 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i15_decode(uint16_t *x, const void *src, size_t len) 30 | { 31 | const unsigned char *buf; 32 | size_t v; 33 | uint32_t acc; 34 | int acc_len; 35 | 36 | buf = src; 37 | v = 1; 38 | acc = 0; 39 | acc_len = 0; 40 | 41 | while (len -- > 0) 42 | { 43 | uint32_t b; 44 | 45 | b = buf[len]; 46 | acc |= (b << acc_len); 47 | acc_len += 8; 48 | 49 | if (acc_len >= 15) 50 | { 51 | x[v ++] = acc & 0x7FFF; 52 | acc_len -= 15; 53 | acc >>= 15; 54 | } 55 | } 56 | 57 | if (acc_len != 0) 58 | { 59 | x[v ++] = acc; 60 | } 61 | 62 | x[0] = br_i15_bit_length(x + 1, v - 1); 63 | } 64 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i15_encode(void *dst, size_t len, const uint16_t *x) 30 | { 31 | unsigned char *buf; 32 | size_t u, xlen; 33 | uint32_t acc; 34 | int acc_len; 35 | 36 | xlen = (x[0] + 15) >> 4; 37 | 38 | if (xlen == 0) 39 | { 40 | memset(dst, 0, len); 41 | return; 42 | } 43 | 44 | u = 1; 45 | acc = 0; 46 | acc_len = 0; 47 | buf = dst; 48 | 49 | while (len -- > 0) 50 | { 51 | if (acc_len < 8) 52 | { 53 | if (u <= xlen) 54 | { 55 | acc += (uint32_t)x[u ++] << acc_len; 56 | } 57 | 58 | acc_len += 15; 59 | } 60 | 61 | buf[len] = (unsigned char)acc; 62 | acc >>= 8; 63 | acc_len -= 8; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i15_from_monty(uint16_t *x, const uint16_t *m, uint16_t m0i) 30 | { 31 | size_t len, u, v; 32 | 33 | len = (m[0] + 15) >> 4; 34 | 35 | for (u = 0; u < len; u ++) 36 | { 37 | uint32_t f, cc; 38 | 39 | f = MUL15(x[1], m0i) & 0x7FFF; 40 | cc = 0; 41 | 42 | for (v = 0; v < len; v ++) 43 | { 44 | uint32_t z; 45 | 46 | z = (uint32_t)x[v + 1] + MUL15(f, m[v + 1]) + cc; 47 | cc = z >> 15; 48 | 49 | if (v != 0) 50 | { 51 | x[v] = z & 0x7FFF; 52 | } 53 | } 54 | 55 | x[len] = cc; 56 | } 57 | 58 | /* 59 | We may have to do an extra subtraction, but only if the 60 | value in x[] is indeed greater than or equal to that of m[], 61 | which is why we must do two calls (first call computes the 62 | carry, second call performs the subtraction only if the carry 63 | is 0). 64 | */ 65 | br_i15_sub(x, m, NOT(br_i15_sub(x, m, 0))); 66 | } 67 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i15_iszero(const uint16_t *x) 30 | { 31 | uint32_t z; 32 | size_t u; 33 | 34 | z = 0; 35 | 36 | for (u = (x[0] + 15) >> 4; u > 0; u --) 37 | { 38 | z |= x[u]; 39 | } 40 | 41 | return ~(z | -z) >> 31; 42 | } 43 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i15_modpow(uint16_t *x, 30 | const unsigned char *e, size_t elen, 31 | const uint16_t *m, uint16_t m0i, uint16_t *t1, uint16_t *t2) 32 | { 33 | size_t mlen; 34 | unsigned k; 35 | 36 | mlen = ((m[0] + 31) >> 4) * sizeof m[0]; 37 | memcpy(t1, x, mlen); 38 | br_i15_to_monty(t1, m); 39 | br_i15_zero(x, m[0]); 40 | x[1] = 1; 41 | 42 | for (k = 0; k < ((unsigned)elen << 3); k ++) 43 | { 44 | uint32_t ctl; 45 | 46 | ctl = (e[elen - 1 - (k >> 3)] >> (k & 7)) & 1; 47 | br_i15_montymul(t2, x, t1, m, m0i); 48 | CCOPY(ctl, x, t2, mlen); 49 | br_i15_montymul(t2, t1, t1, m, m0i); 50 | memcpy(t1, t2, mlen); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/i15_mulacc.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 Thomas Pornin 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | #include "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i15_mulacc(uint16_t *d, const uint16_t *a, const uint16_t *b) 30 | { 31 | size_t alen, blen, u; 32 | unsigned dl, dh; 33 | 34 | alen = (a[0] + 15) >> 4; 35 | blen = (b[0] + 15) >> 4; 36 | 37 | /* 38 | Announced bit length of d[] will be the sum of the announced 39 | bit lengths of a[] and b[]; but the lengths are encoded. 40 | */ 41 | dl = (a[0] & 15) + (b[0] & 15); 42 | dh = (a[0] >> 4) + (b[0] >> 4); 43 | d[0] = (dh << 4) + dl + (~(uint32_t)(dl - 15) >> 31); 44 | 45 | for (u = 0; u < blen; u ++) 46 | { 47 | uint32_t f; 48 | size_t v; 49 | uint32_t cc; 50 | 51 | f = b[1 + u]; 52 | cc = 0; 53 | 54 | for (v = 0; v < alen; v ++) 55 | { 56 | uint32_t z; 57 | 58 | z = (uint32_t)d[1 + u + v] + MUL15(f, a[1 + v]) + cc; 59 | cc = z >> 15; 60 | d[1 + u + v] = z & 0x7FFF; 61 | } 62 | 63 | d[1 + u + alen] = cc; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint16_t 29 | br_i15_ninv15(uint16_t x) 30 | { 31 | uint32_t y; 32 | 33 | y = 2 - x; 34 | y = MUL15(y, 2 - MUL15(x, y)); 35 | y = MUL15(y, 2 - MUL15(x, y)); 36 | y = MUL15(y, 2 - MUL15(x, y)); 37 | return MUX(x & 1, -y, 0) & 0x7FFF; 38 | } 39 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i15_rshift(uint16_t *x, int count) 30 | { 31 | size_t u, len; 32 | unsigned r; 33 | 34 | len = (x[0] + 15) >> 4; 35 | 36 | if (len == 0) 37 | { 38 | return; 39 | } 40 | 41 | r = x[1] >> count; 42 | 43 | for (u = 2; u <= len; u ++) 44 | { 45 | unsigned w; 46 | 47 | w = x[u]; 48 | x[u - 1] = ((w << (15 - count)) | r) & 0x7FFF; 49 | r = w >> count; 50 | } 51 | 52 | x[len] = r; 53 | } 54 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i15_sub(uint16_t *a, const uint16_t *b, uint32_t ctl) 30 | { 31 | uint32_t cc; 32 | size_t u, m; 33 | 34 | cc = 0; 35 | m = (a[0] + 31) >> 4; 36 | 37 | for (u = 1; u < m; u ++) 38 | { 39 | uint32_t aw, bw, naw; 40 | 41 | aw = a[u]; 42 | bw = b[u]; 43 | naw = aw - bw - cc; 44 | cc = naw >> 31; 45 | a[u] = MUX(ctl, naw & 0x7FFF, aw); 46 | } 47 | 48 | return cc; 49 | } 50 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i15_to_monty(uint16_t *x, const uint16_t *m) 30 | { 31 | unsigned k; 32 | 33 | for (k = (m[0] + 15) >> 4; k > 0; k --) 34 | { 35 | br_i15_muladd_small(x, 0, m); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i31_add(uint32_t *a, const uint32_t *b, uint32_t ctl) 30 | { 31 | uint32_t cc; 32 | size_t u, m; 33 | 34 | cc = 0; 35 | m = (a[0] + 63) >> 5; 36 | 37 | for (u = 1; u < m; u ++) 38 | { 39 | uint32_t aw, bw, naw; 40 | 41 | aw = a[u]; 42 | bw = b[u]; 43 | naw = aw + bw + cc; 44 | cc = naw >> 31; 45 | a[u] = MUX(ctl, naw & (uint32_t)0x7FFFFFFF, aw); 46 | } 47 | 48 | return cc; 49 | } 50 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i31_bit_length(uint32_t *x, size_t xlen) 30 | { 31 | uint32_t tw, twk; 32 | 33 | tw = 0; 34 | twk = 0; 35 | 36 | while (xlen -- > 0) 37 | { 38 | uint32_t w, c; 39 | 40 | c = EQ(tw, 0); 41 | w = x[xlen]; 42 | tw = MUX(c, w, tw); 43 | twk = MUX(c, (uint32_t)xlen, twk); 44 | } 45 | 46 | return (twk << 5) + BIT_LENGTH(tw); 47 | } 48 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i31_decode(uint32_t *x, const void *src, size_t len) 30 | { 31 | const unsigned char *buf; 32 | size_t u, v; 33 | uint32_t acc; 34 | int acc_len; 35 | 36 | buf = src; 37 | u = len; 38 | v = 1; 39 | acc = 0; 40 | acc_len = 0; 41 | 42 | while (u -- > 0) 43 | { 44 | uint32_t b; 45 | 46 | b = buf[u]; 47 | acc |= (b << acc_len); 48 | acc_len += 8; 49 | 50 | if (acc_len >= 31) 51 | { 52 | x[v ++] = acc & (uint32_t)0x7FFFFFFF; 53 | acc_len -= 31; 54 | acc = b >> (8 - acc_len); 55 | } 56 | } 57 | 58 | if (acc_len != 0) 59 | { 60 | x[v ++] = acc; 61 | } 62 | 63 | x[0] = br_i31_bit_length(x + 1, v - 1); 64 | } 65 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i31_iszero(const uint32_t *x) 30 | { 31 | uint32_t z; 32 | size_t u; 33 | 34 | z = 0; 35 | 36 | for (u = (x[0] + 31) >> 5; u > 0; u --) 37 | { 38 | z |= x[u]; 39 | } 40 | 41 | return ~(z | -z) >> 31; 42 | } 43 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i31_ninv31(uint32_t x) 30 | { 31 | uint32_t y; 32 | 33 | y = 2 - x; 34 | y *= 2 - y * x; 35 | y *= 2 - y * x; 36 | y *= 2 - y * x; 37 | y *= 2 - y * x; 38 | return MUX(x & 1, -y, 0) & 0x7FFFFFFF; 39 | } 40 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i31_rshift(uint32_t *x, int count) 30 | { 31 | size_t u, len; 32 | uint32_t r; 33 | 34 | len = (x[0] + 31) >> 5; 35 | 36 | if (len == 0) 37 | { 38 | return; 39 | } 40 | 41 | r = x[1] >> count; 42 | 43 | for (u = 2; u <= len; u ++) 44 | { 45 | uint32_t w; 46 | 47 | w = x[u]; 48 | x[u - 1] = ((w << (31 - count)) | r) & 0x7FFFFFFF; 49 | r = w >> count; 50 | } 51 | 52 | x[len] = r; 53 | } 54 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i31_sub(uint32_t *a, const uint32_t *b, uint32_t ctl) 30 | { 31 | uint32_t cc; 32 | size_t u, m; 33 | 34 | cc = 0; 35 | m = (a[0] + 63) >> 5; 36 | 37 | for (u = 1; u < m; u ++) 38 | { 39 | uint32_t aw, bw, naw; 40 | 41 | aw = a[u]; 42 | bw = b[u]; 43 | naw = aw - bw - cc; 44 | cc = naw >> 31; 45 | a[u] = MUX(ctl, naw & 0x7FFFFFFF, aw); 46 | } 47 | 48 | return cc; 49 | } 50 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i31_to_monty(uint32_t *x, const uint32_t *m) 30 | { 31 | uint32_t k; 32 | 33 | for (k = (m[0] + 31) >> 5; k > 0; k --) 34 | { 35 | br_i31_muladd_small(x, 0, m); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i32_add(uint32_t *a, const uint32_t *b, uint32_t ctl) 30 | { 31 | uint32_t cc; 32 | size_t u, m; 33 | 34 | cc = 0; 35 | m = (a[0] + 63) >> 5; 36 | 37 | for (u = 1; u < m; u ++) 38 | { 39 | uint32_t aw, bw, naw; 40 | 41 | aw = a[u]; 42 | bw = b[u]; 43 | naw = aw + bw + cc; 44 | 45 | /* 46 | Carry is 1 if naw < aw. Carry is also 1 if naw == aw 47 | AND the carry was already 1. 48 | */ 49 | cc = (cc & EQ(naw, aw)) | LT(naw, aw); 50 | a[u] = MUX(ctl, naw, aw); 51 | } 52 | 53 | return cc; 54 | } 55 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i32_bit_length(uint32_t *x, size_t xlen) 30 | { 31 | uint32_t tw, twk; 32 | 33 | tw = 0; 34 | twk = 0; 35 | 36 | while (xlen -- > 0) 37 | { 38 | uint32_t w, c; 39 | 40 | c = EQ(tw, 0); 41 | w = x[xlen]; 42 | tw = MUX(c, w, tw); 43 | twk = MUX(c, (uint32_t)xlen, twk); 44 | } 45 | 46 | return (twk << 5) + BIT_LENGTH(tw); 47 | } 48 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i32_decode(uint32_t *x, const void *src, size_t len) 30 | { 31 | const unsigned char *buf; 32 | size_t u, v; 33 | 34 | buf = src; 35 | u = len; 36 | v = 1; 37 | 38 | for (;;) 39 | { 40 | if (u < 4) 41 | { 42 | uint32_t w; 43 | 44 | if (u < 2) 45 | { 46 | if (u == 0) 47 | { 48 | break; 49 | } 50 | else 51 | { 52 | w = buf[0]; 53 | } 54 | } 55 | else 56 | { 57 | if (u == 2) 58 | { 59 | w = br_dec16be(buf); 60 | } 61 | else 62 | { 63 | w = ((uint32_t)buf[0] << 16) 64 | | br_dec16be(buf + 1); 65 | } 66 | } 67 | 68 | x[v ++] = w; 69 | break; 70 | } 71 | else 72 | { 73 | u -= 4; 74 | x[v ++] = br_dec32be(buf + u); 75 | } 76 | } 77 | 78 | x[0] = br_i32_bit_length(x + 1, v - 1); 79 | } 80 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_divrem(uint32_t hi, uint32_t lo, uint32_t d, uint32_t *r) 30 | { 31 | /* TODO: optimize this */ 32 | uint32_t q; 33 | uint32_t ch, cf; 34 | int k; 35 | 36 | q = 0; 37 | ch = EQ(hi, d); 38 | hi = MUX(ch, 0, hi); 39 | 40 | for (k = 31; k > 0; k --) 41 | { 42 | int j; 43 | uint32_t w, ctl, hi2, lo2; 44 | 45 | j = 32 - k; 46 | w = (hi << j) | (lo >> k); 47 | ctl = GE(w, d) | (hi >> k); 48 | hi2 = (w - d) >> j; 49 | lo2 = lo - (d << k); 50 | hi = MUX(ctl, hi2, hi); 51 | lo = MUX(ctl, lo2, lo); 52 | q |= ctl << k; 53 | } 54 | 55 | cf = GE(lo, d) | hi; 56 | q |= cf; 57 | *r = MUX(cf, lo - d, lo); 58 | return q; 59 | } 60 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i32_iszero(const uint32_t *x) 30 | { 31 | uint32_t z; 32 | size_t u; 33 | 34 | z = 0; 35 | 36 | for (u = (x[0] + 31) >> 5; u > 0; u --) 37 | { 38 | z |= x[u]; 39 | } 40 | 41 | return ~(z | -z) >> 31; 42 | } 43 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i32_mulacc(uint32_t *d, const uint32_t *a, const uint32_t *b) 30 | { 31 | size_t alen, blen, u; 32 | 33 | alen = (a[0] + 31) >> 5; 34 | blen = (b[0] + 31) >> 5; 35 | d[0] = a[0] + b[0]; 36 | 37 | for (u = 0; u < blen; u ++) 38 | { 39 | uint32_t f; 40 | size_t v; 41 | #if BR_64 42 | uint64_t cc; 43 | #else 44 | uint32_t cc; 45 | #endif 46 | 47 | f = b[1 + u]; 48 | cc = 0; 49 | 50 | for (v = 0; v < alen; v ++) 51 | { 52 | uint64_t z; 53 | 54 | z = (uint64_t)d[1 + u + v] + MUL(f, a[1 + v]) + cc; 55 | cc = z >> 32; 56 | d[1 + u + v] = (uint32_t)z; 57 | } 58 | 59 | d[1 + u + alen] = (uint32_t)cc; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i32_ninv32(uint32_t x) 30 | { 31 | uint32_t y; 32 | 33 | y = 2 - x; 34 | y *= 2 - y * x; 35 | y *= 2 - y * x; 36 | y *= 2 - y * x; 37 | y *= 2 - y * x; 38 | return MUX(x & 1, -y, 0); 39 | } 40 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | uint32_t 29 | br_i32_sub(uint32_t *a, const uint32_t *b, uint32_t ctl) 30 | { 31 | uint32_t cc; 32 | size_t u, m; 33 | 34 | cc = 0; 35 | m = (a[0] + 63) >> 5; 36 | 37 | for (u = 1; u < m; u ++) 38 | { 39 | uint32_t aw, bw, naw; 40 | 41 | aw = a[u]; 42 | bw = b[u]; 43 | naw = aw - bw - cc; 44 | 45 | /* 46 | Carry is 1 if naw > aw. Carry is 1 also if naw == aw 47 | AND the carry was already 1. 48 | */ 49 | cc = (cc & EQ(naw, aw)) | GT(naw, aw); 50 | a[u] = MUX(ctl, naw, aw); 51 | } 52 | 53 | return cc; 54 | } 55 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/int/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | void 29 | br_i32_to_monty(uint32_t *x, const uint32_t *m) 30 | { 31 | uint32_t k; 32 | 33 | for (k = (m[0] + 31) >> 5; k > 0; k --) 34 | { 35 | br_i32_muladd_small(x, 0, m); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_keygen 29 | br_rsa_keygen_get_default(void) 30 | { 31 | #if BR_INT128 || BR_UMUL128 32 | return &br_rsa_i62_keygen; 33 | #elif BR_LOMUL 34 | return &br_rsa_i15_keygen; 35 | #else 36 | return &br_rsa_i31_keygen; 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_compute_modulus 29 | br_rsa_compute_modulus_get_default(void) 30 | { 31 | #if BR_LOMUL 32 | return &br_rsa_i15_compute_modulus; 33 | #else 34 | return &br_rsa_i31_compute_modulus; 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_oaep_decrypt 29 | br_rsa_oaep_decrypt_get_default(void) 30 | { 31 | #if BR_INT128 || BR_UMUL128 32 | return &br_rsa_i62_oaep_decrypt; 33 | #elif BR_LOMUL 34 | return &br_rsa_i15_oaep_decrypt; 35 | #else 36 | return &br_rsa_i31_oaep_decrypt; 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_oaep_encrypt 29 | br_rsa_oaep_encrypt_get_default(void) 30 | { 31 | #if BR_INT128 || BR_UMUL128 32 | return &br_rsa_i62_oaep_encrypt; 33 | #elif BR_LOMUL 34 | return &br_rsa_i15_oaep_encrypt; 35 | #else 36 | return &br_rsa_i31_oaep_encrypt; 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_pkcs1_sign 29 | br_rsa_pkcs1_sign_get_default(void) 30 | { 31 | #if BR_INT128 || BR_UMUL128 32 | return &br_rsa_i62_pkcs1_sign; 33 | #elif BR_LOMUL 34 | return &br_rsa_i15_pkcs1_sign; 35 | #else 36 | return &br_rsa_i31_pkcs1_sign; 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_pkcs1_vrfy 29 | br_rsa_pkcs1_vrfy_get_default(void) 30 | { 31 | #if BR_INT128 || BR_UMUL128 32 | return &br_rsa_i62_pkcs1_vrfy; 33 | #elif BR_LOMUL 34 | return &br_rsa_i15_pkcs1_vrfy; 35 | #else 36 | return &br_rsa_i31_pkcs1_vrfy; 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_private 29 | br_rsa_private_get_default(void) 30 | { 31 | #if BR_INT128 || BR_UMUL128 32 | return &br_rsa_i62_private; 33 | #elif BR_LOMUL 34 | return &br_rsa_i15_private; 35 | #else 36 | return &br_rsa_i31_private; 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_compute_privexp 29 | br_rsa_compute_privexp_get_default(void) 30 | { 31 | #if BR_LOMUL 32 | return &br_rsa_i15_compute_privexp; 33 | #else 34 | return &br_rsa_i31_compute_privexp; 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_pss_sign 29 | br_rsa_pss_sign_get_default(void) 30 | { 31 | #if BR_INT128 || BR_UMUL128 32 | return &br_rsa_i62_pss_sign; 33 | #elif BR_LOMUL 34 | return &br_rsa_i15_pss_sign; 35 | #else 36 | return &br_rsa_i31_pss_sign; 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_pss_vrfy 29 | br_rsa_pss_vrfy_get_default(void) 30 | { 31 | #if BR_INT128 || BR_UMUL128 32 | return &br_rsa_i62_pss_vrfy; 33 | #elif BR_LOMUL 34 | return &br_rsa_i15_pss_vrfy; 35 | #else 36 | return &br_rsa_i31_pss_vrfy; 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_public 29 | br_rsa_public_get_default(void) 30 | { 31 | #if BR_INT128 || BR_UMUL128 32 | return &br_rsa_i62_public; 33 | #elif BR_LOMUL 34 | return &br_rsa_i15_public; 35 | #else 36 | return &br_rsa_i31_public; 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | br_rsa_compute_pubexp 29 | br_rsa_compute_pubexp_get_default(void) 30 | { 31 | #if BR_LOMUL 32 | return &br_rsa_i15_compute_pubexp; 33 | #else 34 | return &br_rsa_i31_compute_pubexp; 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i15_oaep_decrypt(const br_hash_class *dig, 30 | const void *label, size_t label_len, 31 | const br_rsa_private_key *sk, void *data, size_t *len) 32 | { 33 | uint32_t r; 34 | 35 | if (*len != ((sk->n_bitlen + 7) >> 3)) 36 | { 37 | return 0; 38 | } 39 | 40 | r = br_rsa_i15_private(data, sk); 41 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 42 | return r; 43 | } 44 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | size_t 29 | br_rsa_i15_oaep_encrypt( 30 | const br_prng_class **rnd, const br_hash_class *dig, 31 | const void *label, size_t label_len, 32 | const br_rsa_public_key *pk, 33 | void *dst, size_t dst_max_len, 34 | const void *src, size_t src_len) 35 | { 36 | size_t dlen; 37 | 38 | dlen = br_rsa_oaep_pad(rnd, dig, label, label_len, 39 | pk, dst, dst_max_len, src, src_len); 40 | 41 | if (dlen == 0) 42 | { 43 | return 0; 44 | } 45 | 46 | return dlen & -(size_t)br_rsa_i15_public(dst, dlen, pk); 47 | } 48 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i15_pkcs1_sign(const unsigned char *hash_oid, 30 | const unsigned char *hash, size_t hash_len, 31 | const br_rsa_private_key *sk, unsigned char *x) 32 | { 33 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) 34 | { 35 | return 0; 36 | } 37 | 38 | return br_rsa_i15_private(x, sk); 39 | } 40 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i15_pkcs1_vrfy(const unsigned char *x, size_t xlen, 30 | const unsigned char *hash_oid, size_t hash_len, 31 | const br_rsa_public_key *pk, unsigned char *hash_out) 32 | { 33 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 34 | 35 | if (xlen > (sizeof sig)) 36 | { 37 | return 0; 38 | } 39 | 40 | memcpy(sig, x, xlen); 41 | 42 | if (!br_rsa_i15_public(sig, xlen, pk)) 43 | { 44 | return 0; 45 | } 46 | 47 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 48 | } 49 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i15_pss_sign(const br_prng_class **rng, 30 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 31 | const unsigned char *hash, size_t salt_len, 32 | const br_rsa_private_key *sk, unsigned char *x) 33 | { 34 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 35 | salt_len, sk->n_bitlen, x)) 36 | { 37 | return 0; 38 | } 39 | 40 | return br_rsa_i15_private(x, sk); 41 | } 42 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i15_pss_vrfy(const unsigned char *x, size_t xlen, 30 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 31 | const void *hash, size_t salt_len, const br_rsa_public_key *pk) 32 | { 33 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 34 | 35 | if (xlen > (sizeof sig)) 36 | { 37 | return 0; 38 | } 39 | 40 | memcpy(sig, x, xlen); 41 | 42 | if (!br_rsa_i15_public(sig, xlen, pk)) 43 | { 44 | return 0; 45 | } 46 | 47 | return br_rsa_pss_sig_unpad(hf_data, hf_mgf1, 48 | hash, salt_len, pk, sig); 49 | } 50 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i31_keygen(const br_prng_class **rng, 30 | br_rsa_private_key *sk, void *kbuf_priv, 31 | br_rsa_public_key *pk, void *kbuf_pub, 32 | unsigned size, uint32_t pubexp) 33 | { 34 | return br_rsa_i31_keygen_inner(rng, 35 | sk, kbuf_priv, pk, kbuf_pub, size, pubexp, 36 | &br_i31_modpow_opt); 37 | } 38 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i31_oaep_decrypt(const br_hash_class *dig, 30 | const void *label, size_t label_len, 31 | const br_rsa_private_key *sk, void *data, size_t *len) 32 | { 33 | uint32_t r; 34 | 35 | if (*len != ((sk->n_bitlen + 7) >> 3)) 36 | { 37 | return 0; 38 | } 39 | 40 | r = br_rsa_i31_private(data, sk); 41 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 42 | return r; 43 | } 44 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | size_t 29 | br_rsa_i31_oaep_encrypt( 30 | const br_prng_class **rnd, const br_hash_class *dig, 31 | const void *label, size_t label_len, 32 | const br_rsa_public_key *pk, 33 | void *dst, size_t dst_max_len, 34 | const void *src, size_t src_len) 35 | { 36 | size_t dlen; 37 | 38 | dlen = br_rsa_oaep_pad(rnd, dig, label, label_len, 39 | pk, dst, dst_max_len, src, src_len); 40 | 41 | if (dlen == 0) 42 | { 43 | return 0; 44 | } 45 | 46 | return dlen & -(size_t)br_rsa_i31_public(dst, dlen, pk); 47 | } 48 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i31_pkcs1_sign(const unsigned char *hash_oid, 30 | const unsigned char *hash, size_t hash_len, 31 | const br_rsa_private_key *sk, unsigned char *x) 32 | { 33 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) 34 | { 35 | return 0; 36 | } 37 | 38 | return br_rsa_i31_private(x, sk); 39 | } 40 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i31_pkcs1_vrfy(const unsigned char *x, size_t xlen, 30 | const unsigned char *hash_oid, size_t hash_len, 31 | const br_rsa_public_key *pk, unsigned char *hash_out) 32 | { 33 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 34 | 35 | if (xlen > (sizeof sig)) 36 | { 37 | return 0; 38 | } 39 | 40 | memcpy(sig, x, xlen); 41 | 42 | if (!br_rsa_i31_public(sig, xlen, pk)) 43 | { 44 | return 0; 45 | } 46 | 47 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 48 | } 49 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i31_pss_sign(const br_prng_class **rng, 30 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 31 | const unsigned char *hash, size_t salt_len, 32 | const br_rsa_private_key *sk, unsigned char *x) 33 | { 34 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 35 | salt_len, sk->n_bitlen, x)) 36 | { 37 | return 0; 38 | } 39 | 40 | return br_rsa_i31_private(x, sk); 41 | } 42 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i31_pss_vrfy(const unsigned char *x, size_t xlen, 30 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 31 | const void *hash, size_t salt_len, const br_rsa_public_key *pk) 32 | { 33 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 34 | 35 | if (xlen > (sizeof sig)) 36 | { 37 | return 0; 38 | } 39 | 40 | memcpy(sig, x, xlen); 41 | 42 | if (!br_rsa_i31_public(sig, xlen, pk)) 43 | { 44 | return 0; 45 | } 46 | 47 | return br_rsa_pss_sig_unpad(hf_data, hf_mgf1, 48 | hash, salt_len, pk, sig); 49 | } 50 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i32_oaep_decrypt(const br_hash_class *dig, 30 | const void *label, size_t label_len, 31 | const br_rsa_private_key *sk, void *data, size_t *len) 32 | { 33 | uint32_t r; 34 | 35 | if (*len != ((sk->n_bitlen + 7) >> 3)) 36 | { 37 | return 0; 38 | } 39 | 40 | r = br_rsa_i32_private(data, sk); 41 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 42 | return r; 43 | } 44 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | size_t 29 | br_rsa_i32_oaep_encrypt( 30 | const br_prng_class **rnd, const br_hash_class *dig, 31 | const void *label, size_t label_len, 32 | const br_rsa_public_key *pk, 33 | void *dst, size_t dst_max_len, 34 | const void *src, size_t src_len) 35 | { 36 | size_t dlen; 37 | 38 | dlen = br_rsa_oaep_pad(rnd, dig, label, label_len, 39 | pk, dst, dst_max_len, src, src_len); 40 | 41 | if (dlen == 0) 42 | { 43 | return 0; 44 | } 45 | 46 | return dlen & -(size_t)br_rsa_i32_public(dst, dlen, pk); 47 | } 48 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i32_pkcs1_sign(const unsigned char *hash_oid, 30 | const unsigned char *hash, size_t hash_len, 31 | const br_rsa_private_key *sk, unsigned char *x) 32 | { 33 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) 34 | { 35 | return 0; 36 | } 37 | 38 | return br_rsa_i32_private(x, sk); 39 | } 40 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i32_pkcs1_vrfy(const unsigned char *x, size_t xlen, 30 | const unsigned char *hash_oid, size_t hash_len, 31 | const br_rsa_public_key *pk, unsigned char *hash_out) 32 | { 33 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 34 | 35 | if (xlen > (sizeof sig)) 36 | { 37 | return 0; 38 | } 39 | 40 | memcpy(sig, x, xlen); 41 | 42 | if (!br_rsa_i32_public(sig, xlen, pk)) 43 | { 44 | return 0; 45 | } 46 | 47 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 48 | } 49 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i32_pss_sign(const br_prng_class **rng, 30 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 31 | const unsigned char *hash, size_t salt_len, 32 | const br_rsa_private_key *sk, unsigned char *x) 33 | { 34 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 35 | salt_len, sk->n_bitlen, x)) 36 | { 37 | return 0; 38 | } 39 | 40 | return br_rsa_i32_private(x, sk); 41 | } 42 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_i32_pss_vrfy(const unsigned char *x, size_t xlen, 30 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 31 | const void *hash, size_t salt_len, const br_rsa_public_key *pk) 32 | { 33 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 34 | 35 | if (xlen > (sizeof sig)) 36 | { 37 | return 0; 38 | } 39 | 40 | memcpy(sig, x, xlen); 41 | 42 | if (!br_rsa_i32_public(sig, xlen, pk)) 43 | { 44 | return 0; 45 | } 46 | 47 | return br_rsa_pss_sig_unpad(hf_data, hf_mgf1, 48 | hash, salt_len, pk, sig); 49 | } 50 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | #if BR_INT128 || BR_UMUL128 28 | 29 | /* see bearssl_rsa.h */ 30 | uint32_t 31 | br_rsa_i62_keygen(const br_prng_class **rng, 32 | br_rsa_private_key *sk, void *kbuf_priv, 33 | br_rsa_public_key *pk, void *kbuf_pub, 34 | unsigned size, uint32_t pubexp) 35 | { 36 | return br_rsa_i31_keygen_inner(rng, 37 | sk, kbuf_priv, pk, kbuf_pub, size, pubexp, 38 | &br_i62_modpow_opt_as_i31); 39 | } 40 | 41 | /* see bearssl_rsa.h */ 42 | br_rsa_keygen 43 | br_rsa_i62_keygen_get() 44 | { 45 | return &br_rsa_i62_keygen; 46 | } 47 | 48 | #else 49 | 50 | /* see bearssl_rsa.h */ 51 | br_rsa_keygen 52 | br_rsa_i62_keygen_get() 53 | { 54 | return 0; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | #if BR_INT128 || BR_UMUL128 28 | 29 | /* see bearssl_rsa.h */ 30 | uint32_t 31 | br_rsa_i62_oaep_decrypt(const br_hash_class *dig, 32 | const void *label, size_t label_len, 33 | const br_rsa_private_key *sk, void *data, size_t *len) 34 | { 35 | uint32_t r; 36 | 37 | if (*len != ((sk->n_bitlen + 7) >> 3)) 38 | { 39 | return 0; 40 | } 41 | 42 | r = br_rsa_i62_private(data, sk); 43 | r &= br_rsa_oaep_unpad(dig, label, label_len, data, len); 44 | return r; 45 | } 46 | 47 | /* see bearssl_rsa.h */ 48 | br_rsa_oaep_decrypt 49 | br_rsa_i62_oaep_decrypt_get(void) 50 | { 51 | return &br_rsa_i62_oaep_decrypt; 52 | } 53 | 54 | #else 55 | 56 | /* see bearssl_rsa.h */ 57 | br_rsa_oaep_decrypt 58 | br_rsa_i62_oaep_decrypt_get(void) 59 | { 60 | return 0; 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/rsa_i62_oaep_encrypt.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2018 Thomas Pornin 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | */ 24 | 25 | #include "inner.h" 26 | 27 | #if BR_INT128 || BR_UMUL128 28 | 29 | /* see bearssl_rsa.h */ 30 | size_t 31 | br_rsa_i62_oaep_encrypt( 32 | const br_prng_class **rnd, const br_hash_class *dig, 33 | const void *label, size_t label_len, 34 | const br_rsa_public_key *pk, 35 | void *dst, size_t dst_max_len, 36 | const void *src, size_t src_len) 37 | { 38 | size_t dlen; 39 | 40 | dlen = br_rsa_oaep_pad(rnd, dig, label, label_len, 41 | pk, dst, dst_max_len, src, src_len); 42 | 43 | if (dlen == 0) 44 | { 45 | return 0; 46 | } 47 | 48 | return dlen & -(size_t)br_rsa_i62_public(dst, dlen, pk); 49 | } 50 | 51 | /* see bearssl_rsa.h */ 52 | br_rsa_oaep_encrypt 53 | br_rsa_i62_oaep_encrypt_get(void) 54 | { 55 | return &br_rsa_i62_oaep_encrypt; 56 | } 57 | 58 | #else 59 | 60 | /* see bearssl_rsa.h */ 61 | br_rsa_oaep_encrypt 62 | br_rsa_i62_oaep_encrypt_get(void) 63 | { 64 | return 0; 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | #if BR_INT128 || BR_UMUL128 28 | 29 | /* see bearssl_rsa.h */ 30 | uint32_t 31 | br_rsa_i62_pkcs1_sign(const unsigned char *hash_oid, 32 | const unsigned char *hash, size_t hash_len, 33 | const br_rsa_private_key *sk, unsigned char *x) 34 | { 35 | if (!br_rsa_pkcs1_sig_pad(hash_oid, hash, hash_len, sk->n_bitlen, x)) 36 | { 37 | return 0; 38 | } 39 | 40 | return br_rsa_i62_private(x, sk); 41 | } 42 | 43 | /* see bearssl_rsa.h */ 44 | br_rsa_pkcs1_sign 45 | br_rsa_i62_pkcs1_sign_get(void) 46 | { 47 | return &br_rsa_i62_pkcs1_sign; 48 | } 49 | 50 | #else 51 | 52 | /* see bearssl_rsa.h */ 53 | br_rsa_pkcs1_sign 54 | br_rsa_i62_pkcs1_sign_get(void) 55 | { 56 | return 0; 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | #if BR_INT128 || BR_UMUL128 28 | 29 | /* see bearssl_rsa.h */ 30 | uint32_t 31 | br_rsa_i62_pkcs1_vrfy(const unsigned char *x, size_t xlen, 32 | const unsigned char *hash_oid, size_t hash_len, 33 | const br_rsa_public_key *pk, unsigned char *hash_out) 34 | { 35 | unsigned char sig[BR_MAX_RSA_SIZE >> 3]; 36 | 37 | if (xlen > (sizeof sig)) 38 | { 39 | return 0; 40 | } 41 | 42 | memcpy(sig, x, xlen); 43 | 44 | if (!br_rsa_i62_public(sig, xlen, pk)) 45 | { 46 | return 0; 47 | } 48 | 49 | return br_rsa_pkcs1_sig_unpad(sig, xlen, hash_oid, hash_len, hash_out); 50 | } 51 | 52 | /* see bearssl_rsa.h */ 53 | br_rsa_pkcs1_vrfy 54 | br_rsa_i62_pkcs1_vrfy_get(void) 55 | { 56 | return &br_rsa_i62_pkcs1_vrfy; 57 | } 58 | 59 | #else 60 | 61 | /* see bearssl_rsa.h */ 62 | br_rsa_pkcs1_vrfy 63 | br_rsa_i62_pkcs1_vrfy_get(void) 64 | { 65 | return 0; 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | #if BR_INT128 || BR_UMUL128 28 | 29 | /* see bearssl_rsa.h */ 30 | uint32_t 31 | br_rsa_i62_pss_sign(const br_prng_class **rng, 32 | const br_hash_class *hf_data, const br_hash_class *hf_mgf1, 33 | const unsigned char *hash, size_t salt_len, 34 | const br_rsa_private_key *sk, unsigned char *x) 35 | { 36 | if (!br_rsa_pss_sig_pad(rng, hf_data, hf_mgf1, hash, 37 | salt_len, sk->n_bitlen, x)) 38 | { 39 | return 0; 40 | } 41 | 42 | return br_rsa_i62_private(x, sk); 43 | } 44 | 45 | /* see bearssl_rsa.h */ 46 | br_rsa_pss_sign 47 | br_rsa_i62_pss_sign_get(void) 48 | { 49 | return &br_rsa_i62_pss_sign; 50 | } 51 | 52 | #else 53 | 54 | /* see bearssl_rsa.h */ 55 | br_rsa_pss_sign 56 | br_rsa_i62_pss_sign_get(void) 57 | { 58 | return 0; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/rsa/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 "inner.h" 26 | 27 | /* see bearssl_rsa.h */ 28 | uint32_t 29 | br_rsa_ssl_decrypt(br_rsa_private core, const br_rsa_private_key *sk, 30 | unsigned char *data, size_t len) 31 | { 32 | uint32_t x; 33 | size_t u; 34 | 35 | /* 36 | A first check on length. Since this test works only on the 37 | buffer length, it needs not (and cannot) be constant-time. 38 | */ 39 | if (len < 59 || len != (sk->n_bitlen + 7) >> 3) 40 | { 41 | return 0; 42 | } 43 | 44 | x = core(data, sk); 45 | 46 | x &= EQ(data[0], 0x00); 47 | x &= EQ(data[1], 0x02); 48 | 49 | for (u = 2; u < (len - 49); u ++) 50 | { 51 | x &= NEQ(data[u], 0); 52 | } 53 | 54 | x &= EQ(data[len - 49], 0x00); 55 | memmove(data, data + len - 48, 48); 56 | return x; 57 | } 58 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ssl/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 "inner.h" 26 | 27 | /* see bearssl.h */ 28 | void 29 | br_tls10_prf(void *dst, size_t len, 30 | const void *secret, size_t secret_len, const char *label, 31 | size_t seed_num, const br_tls_prf_seed_chunk *seed) 32 | { 33 | const unsigned char *s1; 34 | size_t slen; 35 | 36 | s1 = secret; 37 | slen = (secret_len + 1) >> 1; 38 | memset(dst, 0, len); 39 | br_tls_phash(dst, len, &br_md5_vtable, 40 | s1, slen, label, seed_num, seed); 41 | br_tls_phash(dst, len, &br_sha1_vtable, 42 | s1 + secret_len - slen, slen, label, seed_num, seed); 43 | } 44 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ssl/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 "inner.h" 26 | 27 | /* see bearssl.h */ 28 | void 29 | br_tls12_sha256_prf(void *dst, size_t len, 30 | const void *secret, size_t secret_len, const char *label, 31 | size_t seed_num, const br_tls_prf_seed_chunk *seed) 32 | { 33 | memset(dst, 0, len); 34 | br_tls_phash(dst, len, &br_sha256_vtable, 35 | secret, secret_len, label, seed_num, seed); 36 | } 37 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ssl/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 "inner.h" 26 | 27 | /* see bearssl.h */ 28 | void 29 | br_tls12_sha384_prf(void *dst, size_t len, 30 | const void *secret, size_t secret_len, const char *label, 31 | size_t seed_num, const br_tls_prf_seed_chunk *seed) 32 | { 33 | memset(dst, 0, len); 34 | br_tls_phash(dst, len, &br_sha384_vtable, 35 | secret, secret_len, label, seed_num, seed); 36 | } 37 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ssl/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 "inner.h" 26 | 27 | /* see bearssl_ssl.h */ 28 | void 29 | br_ssl_client_set_default_rsapub(br_ssl_client_context *cc) 30 | { 31 | br_ssl_client_set_rsapub(cc, br_rsa_public_get_default()); 32 | } 33 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ssl/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 "inner.h" 26 | 27 | /* see bearssl_ssl.h */ 28 | void 29 | br_ssl_engine_set_default_des_cbc(br_ssl_engine_context *cc) 30 | { 31 | br_ssl_engine_set_cbc(cc, 32 | &br_sslrec_in_cbc_vtable, 33 | &br_sslrec_out_cbc_vtable); 34 | br_ssl_engine_set_des_cbc(cc, 35 | &br_des_ct_cbcenc_vtable, 36 | &br_des_ct_cbcdec_vtable); 37 | } 38 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ssl/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 "inner.h" 26 | 27 | /* see bearssl_ssl.h */ 28 | void 29 | br_ssl_engine_set_default_ec(br_ssl_engine_context *cc) 30 | { 31 | #if BR_LOMUL 32 | br_ssl_engine_set_ec(cc, &br_ec_all_m15); 33 | #else 34 | br_ssl_engine_set_ec(cc, &br_ec_all_m31); 35 | #endif 36 | } 37 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ssl/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 "inner.h" 26 | 27 | /* see bearssl_ssl.h */ 28 | void 29 | br_ssl_engine_set_default_ecdsa(br_ssl_engine_context *cc) 30 | { 31 | #if BR_LOMUL 32 | br_ssl_engine_set_ec(cc, &br_ec_all_m15); 33 | br_ssl_engine_set_ecdsa(cc, &br_ecdsa_i15_vrfy_asn1); 34 | #else 35 | br_ssl_engine_set_ec(cc, &br_ec_all_m31); 36 | br_ssl_engine_set_ecdsa(cc, &br_ecdsa_i31_vrfy_asn1); 37 | #endif 38 | } 39 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ssl/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 "inner.h" 26 | 27 | /* see bearssl_ssl.h */ 28 | void 29 | br_ssl_engine_set_default_rsavrfy(br_ssl_engine_context *cc) 30 | { 31 | br_ssl_engine_set_rsavrfy(cc, br_rsa_pkcs1_vrfy_get_default()); 32 | } 33 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ssl/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 "inner.h" 26 | 27 | /* see inner.h */ 28 | int 29 | br_ssl_choose_hash(unsigned bf) 30 | { 31 | static const unsigned char pref[] = 32 | { 33 | br_sha256_ID, br_sha384_ID, br_sha512_ID, 34 | br_sha224_ID, br_sha1_ID 35 | }; 36 | size_t u; 37 | 38 | for (u = 0; u < sizeof pref; u ++) 39 | { 40 | int x; 41 | 42 | x = pref[u]; 43 | 44 | if ((bf >> x) & 1) 45 | { 46 | return x; 47 | } 48 | } 49 | 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /src/SSLClient/bearssl/src/ssl/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 "inner.h" 26 | 27 | /* see bearssl_ssl.h */ 28 | void 29 | br_ssl_server_zero(br_ssl_server_context *cc) 30 | { 31 | /* 32 | For really standard C, we should explicitly set to NULL all 33 | pointers, and 0 all other fields. However, on all our target 34 | architectures, a direct memset() will work, be faster, and 35 | use a lot less code. 36 | */ 37 | memset(cc, 0, sizeof * cc); 38 | } 39 | 40 | /* see bearssl_ssl.h */ 41 | int 42 | br_ssl_server_reset(br_ssl_server_context *cc) 43 | { 44 | br_ssl_engine_set_buffer(&cc->eng, NULL, 0, 0); 45 | 46 | if (!br_ssl_engine_init_rand(&cc->eng)) 47 | { 48 | return 0; 49 | } 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 | -------------------------------------------------------------------------------- /src/inner.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | inner.h 3 | 4 | For STM32F/L/H/G/WB/MP1 with built-in Ethernet LAN8742A (Nucleo-144, DISCOVERY, etc) or W5x00/ENC28J60 shield/module 5 | 6 | EthernetWebServer_SSL_STM32 is a library for STM32 using the Ethernet shields to run WebServer and Client with/without SSL 7 | 8 | Use SSLClient Library code from https://github.com/OPEnSLab-OSU/SSLClient 9 | 10 | Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases 11 | Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer_SSL_STM32 12 | 13 | Version: 1.6.0 14 | 15 | Version Modified By Date Comments 16 | ------- ----------- ---------- ----------- 17 | 1.1.0 K Hoang 14/11/2020 Initial coding for STM32F/L/H/G/WB/MP1 to support Ethernet shields using SSL. Supporting BI LAN8742A, 18 | W5x00 using Ethernetx, ENC28J60 using EthernetENC and UIPEthernet libraries 19 | ... 20 | 1.4.0 K Hoang 25/12/2021 Reduce usage of Arduino String with std::string. Fix bug 21 | 1.4.1 K Hoang 27/12/2021 Fix wrong http status header bug and authenticate issue caused by libb64 22 | 1.4.2 K Hoang 11/01/2022 Fix libb64 fallthrough compile warning 23 | 1.4.3 K Hoang 02/03/2022 Fix decoding error bug 24 | 1.4.4 K Hoang 19/03/2022 Change licence from `MIT` to `GPLv3` 25 | 1.4.5 K Hoang 29/03/2022 Sync with `SSLClient` v1.6.11 26 | 1.5.0 K Hoang 05/04/2022 Use Ethernet_Generic library as default 27 | 1.5.1 K Hoang 27/04/2022 Change from `arduino.cc` to `arduino.tips` in examples 28 | 1.6.0 K Hoang 03/05/2022 Add support to STM32L5 and to custom SPI, such as SPI2, SPI3, SPI_New, etc. 29 | ****************************************************************************************************************************/ 30 | 31 | #pragma once 32 | 33 | #ifndef ETHERNET_WEBSERVER_SSL_STM32_INNER_H 34 | #define ETHERNET_WEBSERVER_SSL_STM32_INNER_H 35 | 36 | #include "SSLClient/inner.h" 37 | 38 | #endif // ETHERNET_WEBSERVER_SSL_STM32_INNER_H 39 | -------------------------------------------------------------------------------- /src/libb64/base64.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | base64.h - c source to a base64 encoding algorithm implementation 3 | 4 | For STM32F/L/H/G/WB/MP1 with built-in Ethernet LAN8742A (Nucleo-144, DISCOVERY, etc) or W5x00/ENC28J60 shield/module 5 | 6 | EthernetWebServer_SSL_STM32 is a library for STM32 using the Ethernet shields to run WebServer and Client with/without SSL 7 | 8 | Use SSLClient Library code from https://github.com/OPEnSLab-OSU/SSLClient 9 | 10 | Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases 11 | Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer_SSL_STM32 12 | 13 | Version: 1.6.0 14 | 15 | Version Modified By Date Comments 16 | ------- ----------- ---------- ----------- 17 | 1.1.0 K Hoang 14/11/2020 Initial coding for STM32F/L/H/G/WB/MP1 to support Ethernet shields using SSL. Supporting BI LAN8742A, 18 | W5x00 using Ethernetx, ENC28J60 using EthernetENC and UIPEthernet libraries 19 | ... 20 | 1.4.0 K Hoang 25/12/2021 Reduce usage of Arduino String with std::string. Fix bug 21 | 1.4.1 K Hoang 27/12/2021 Fix wrong http status header bug and authenticate issue caused by libb64 22 | 1.4.2 K Hoang 11/01/2022 Fix libb64 fallthrough compile warning 23 | 1.4.3 K Hoang 02/03/2022 Fix decoding error bug 24 | 1.4.4 K Hoang 19/03/2022 Change licence from `MIT` to `GPLv3` 25 | 1.4.5 K Hoang 29/03/2022 Sync with `SSLClient` v1.6.11 26 | 1.5.0 K Hoang 05/04/2022 Use Ethernet_Generic library as default 27 | 1.5.1 K Hoang 27/04/2022 Change from `arduino.cc` to `arduino.tips` in examples 28 | 1.6.0 K Hoang 03/05/2022 Add support to STM32L5 and to custom SPI, such as SPI2, SPI3, SPI_New, etc. 29 | ****************************************************************************************************************************/ 30 | 31 | #pragma once 32 | 33 | #ifndef base64_h 34 | #define base64_h 35 | 36 | int base64_encode(const unsigned char* aInput, int aInputLen, unsigned char* aOutput, int aOutputLen); 37 | 38 | #endif //base64_h 39 | -------------------------------------------------------------------------------- /src/libb64/cencode.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | cencoder.h - c source to a base64 decoding algorithm implementation 3 | 4 | For STM32F/L/H/G/WB/MP1 with built-in Ethernet LAN8742A (Nucleo-144, DISCOVERY, etc) or W5x00/ENC28J60 shield/module 5 | 6 | EthernetWebServer_SSL_STM32 is a library for STM32 using the Ethernet shields to run WebServer and Client with/without SSL 7 | 8 | Use SSLClient Library code from https://github.com/OPEnSLab-OSU/SSLClient 9 | 10 | Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases 11 | 12 | ****************************************************************************************************************************/ 13 | 14 | #pragma once 15 | 16 | // Reintroduce to prevent duplication compile error if other lib/core already has LIB64 17 | // pragma once can't prevent that 18 | #ifndef BASE64_CENCODE_H 19 | #define BASE64_CENCODE_H 20 | 21 | #define base64_encode_expected_len(n) ((((4 * n) / 3) + 3) & ~3) 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | typedef enum 28 | { 29 | step_A, step_B, step_C 30 | } base64_encodestep; 31 | 32 | typedef struct 33 | { 34 | base64_encodestep step; 35 | char result; 36 | int stepcount; 37 | } base64_encodestate; 38 | 39 | void base64_init_encodestate(base64_encodestate* state_in); 40 | 41 | char base64_encode_value(char value_in); 42 | 43 | int base64_encode_block(const char* plaintext_in, int length_in, char* code_out, base64_encodestate* state_in); 44 | 45 | int base64_encode_blockend(char* code_out, base64_encodestate* state_in); 46 | 47 | int base64_encode_chars(const char* plaintext_in, int length_in, char* code_out); 48 | 49 | #ifdef __cplusplus 50 | } // extern "C" 51 | #endif 52 | 53 | #endif /* BASE64_CENCODE_H */ 54 | 55 | -------------------------------------------------------------------------------- /src/time_macros.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************************************************************** 2 | time_macros.h 3 | 4 | For STM32F/L/H/G/WB/MP1 with built-in Ethernet LAN8742A (Nucleo-144, DISCOVERY, etc) or W5x00/ENC28J60 shield/module 5 | 6 | EthernetWebServer_SSL_STM32 is a library for STM32 using the Ethernet shields to run WebServer and Client with/without SSL 7 | 8 | Use SSLClient Library code from https://github.com/OPEnSLab-OSU/SSLClient 9 | 10 | Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases 11 | Built by Khoi Hoang https://github.com/khoih-prog/EthernetWebServer_SSL_STM32 12 | 13 | Version: 1.6.0 14 | 15 | Version Modified By Date Comments 16 | ------- ----------- ---------- ----------- 17 | 1.1.0 K Hoang 14/11/2020 Initial coding for STM32F/L/H/G/WB/MP1 to support Ethernet shields using SSL. Supporting BI LAN8742A, 18 | W5x00 using Ethernetx, ENC28J60 using EthernetENC and UIPEthernet libraries 19 | ... 20 | 1.4.0 K Hoang 25/12/2021 Reduce usage of Arduino String with std::string. Fix bug 21 | 1.4.1 K Hoang 27/12/2021 Fix wrong http status header bug and authenticate issue caused by libb64 22 | 1.4.2 K Hoang 11/01/2022 Fix libb64 fallthrough compile warning 23 | 1.4.3 K Hoang 02/03/2022 Fix decoding error bug 24 | 1.4.4 K Hoang 19/03/2022 Change licence from `MIT` to `GPLv3` 25 | 1.4.5 K Hoang 29/03/2022 Sync with `SSLClient` v1.6.11 26 | 1.5.0 K Hoang 05/04/2022 Use Ethernet_Generic library as default 27 | 1.5.1 K Hoang 27/04/2022 Change from `arduino.cc` to `arduino.tips` in examples 28 | 1.6.0 K Hoang 03/05/2022 Add support to STM32L5 and to custom SPI, such as SPI2, SPI3, SPI_New, etc. 29 | ****************************************************************************************************************************/ 30 | 31 | #pragma once 32 | 33 | #ifndef ETHERNET_WEBSERVER_SSL_STM32_TIME_MCROS_H 34 | #define ETHERNET_WEBSERVER_SSL_STM32_TIME_MCROS_H 35 | 36 | #include "SSLClient/time_macros.h" 37 | 38 | #endif // ETHERNET_WEBSERVER_SSL_STM32_TIME_MCROS_H 39 | -------------------------------------------------------------------------------- /utils/astyle_library.conf: -------------------------------------------------------------------------------- 1 | # Code formatting rules for Arduino libraries, modified from for KH libraries: 2 | # 3 | # https://github.com/arduino/Arduino/blob/master/build/shared/examples_formatter.conf 4 | # 5 | 6 | # astyle --style=allman -s2 -t2 -C -S -xW -Y -M120 -f -p -xg -H -xb -c --xC120 -xL *.h *.cpp *.ino 7 | 8 | --mode=c 9 | --lineend=linux 10 | --style=allman 11 | 12 | # -r or -R 13 | #--recursive 14 | 15 | # -c => Converts tabs into spaces 16 | convert-tabs 17 | 18 | # -s2 => 2 spaces indentation 19 | --indent=spaces=2 20 | 21 | # -t2 => tab =2 spaces 22 | #--indent=tab=2 23 | 24 | # -C 25 | --indent-classes 26 | 27 | # -S 28 | --indent-switches 29 | 30 | # -xW 31 | --indent-preproc-block 32 | 33 | # -Y => indent classes, switches (and cases), comments starting at column 1 34 | --indent-col1-comments 35 | 36 | # -M120 => maximum of 120 spaces to indent a continuation line 37 | --max-continuation-indent=120 38 | 39 | # -xC120 => max‑code‑length will break a line if the code exceeds # characters 40 | --max-code-length=120 41 | 42 | # -f => 43 | --break-blocks 44 | 45 | # -p => put a space around operators 46 | --pad-oper 47 | 48 | # -xg => Insert space padding after commas 49 | --pad-comma 50 | 51 | # -H => put a space after if/for/while 52 | pad-header 53 | 54 | # -xb => Break one line headers (e.g. if/for/while) 55 | --break-one-line-headers 56 | 57 | # -c => Converts tabs into spaces 58 | #--convert-tabs 59 | 60 | # if you like one-liners, keep them 61 | #keep-one-line-statements 62 | 63 | # -xV 64 | --attach-closing-while 65 | 66 | #unpad-paren 67 | 68 | # -xp 69 | remove-comment-prefix 70 | 71 | -------------------------------------------------------------------------------- /utils/restyle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for dir in . ; do 4 | find $dir -type f \( -name "*.c" -o -name "*.h" -o -name "*.cpp" -o -name "*.ino" \) -exec astyle --suffix=none --options=./utils/astyle_library.conf \{\} \; 5 | done 6 | 7 | --------------------------------------------------------------------------------