This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * _ec_c25519_m15.c — BearSSL Curve25519 (X25519) implementation using ESP32 ROM-backed Montgomery arithmetic | |
| * | |
| * This file provides a fast Montgomery ladder implementation for Curve25519 scalar | |
| * multiplication (X25519), leveraging the ESP32's ROM bigint accelerator for modular | |
| * multiplication in the prime field p = 2^255 - 19. | |
| * | |
| * Key features: | |
| * - Field arithmetic in the normal domain using single-step ROM-backed multiply/square. | |
| * - 8×32-bit little-endian limb representation for all field elements. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * _ec_p256_m15.c — BearSSL P-256 implementation using ESP32 ROM-backed Montgomery arithmetic | |
| * | |
| * This file provides a fast elliptic curve implementation for secp256r1 (P-256), | |
| * leveraging the ESP32's ROM bigint accelerator for modular multiplication. | |
| * | |
| * Key features: | |
| * - Field arithmetic in normal domain using Montgomery-backed multiply/square. | |
| * - Jacobian point representation with full group law (point add/double). | |
| * - Scalar multiplication via double-and-add, supporting arbitrary base points. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * _sha_hal_idf5x.c — BearSSL drop‑in with ESP32 HAL SHA acceleration | |
| * | |
| * This file provides hardware-accelerated implementations of BearSSL-compatible | |
| * hash functions (SHA-1, SHA-224, SHA-256, SHA-384, SHA-512) using the ESP-IDF 5.x | |
| * SHA HAL. It replaces the software digest core with direct access to the ESP32's | |
| * SHA engine, preserving BearSSL's context structure and API semantics. | |
| * | |
| * Each hash context uses a minimal layout: | |
| * - val[] holds the midstate as a raw little-endian byte image. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import crypto | |
| var start = tasmota.millis() | |
| print("=== SHA256 ===") | |
| var h = crypto.SHA256() | |
| assert(h.out() == bytes("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")) | |
| print("=== SHA256 (abc after 'empty')===") | |
| h.update( bytes().fromstring("abc") ) | |
| assert(h.out() == bytes("ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import crypto | |
| var start = tasmota.millis() | |
| import crypto | |
| var w0 = bytes("bb8e1bbcf3c48f62c08db243652ae55d3e5586053fca77102994f23ad95491b3") | |
| var w1 = bytes("7e945f34d78785b8a3ef44d0df5a1a97d6b3b460409a345ca7830387a74b1dba") | |
| var L = bytes("04eb7c9db3d9a9eb1f8adab81b5794c1f13ae3e225efbe91ea487425854c7fc00f00bfedcbd09b2400142d40a14f2064ef31dfaa903b91d1faea7093d835966efd") | |
| var spake_matter = crypto.SPAKE2P_Matter(w0, w1, L) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import crypto | |
| def sha256_of_bytes(b) | |
| var h = crypto.SHA256() | |
| h.update(b) | |
| return h.out() | |
| end | |
| # 1) Non-destructive out(): repeated out() must match; further updates must continue the stream | |
| def test_non_destructive_out() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Copyright (c) 2017 Thomas Pornin <pornin@bolet.org> | |
| * | |
| * Permission is hereby granted, free of charge, to any person obtaining | |
| * a copy of this software and associated documentation files (the | |
| * "Software"), to deal in the Software without restriction, including | |
| * without limitation the rights to use, copy, modify, merge, publish, | |
| * distribute, sublicense, and/or sell copies of the Software, and to | |
| * permit persons to whom the Software is furnished to do so, subject to | |
| * the following conditions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Tasmota Berry SHA-256 benchmark (multi-size) | |
| # Uses crypto.SHA256 with update()/out() | |
| # Timing via tasmota.millis() | |
| # Compares hashes in uppercase | |
| import crypto | |
| # Hash utility: returns uppercase hex (native .tohex()) | |
| def sha256_hex(data) | |
| var h = crypto.SHA256() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "t_inner.h" | |
| #if defined(USE_SHA_ROM) | |
| #if defined(ESP_PLATFORM) && !defined(ESP8266) | |
| #include <stdint.h> | |
| #include <stddef.h> | |
| #include <string.h> | |
| #include "freertos/FreeRTOS.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #------------------------------------------------------------------------------ | |
| - Matter BLE | |
| -------------------------------------------------------------------------------# | |
| import BLE | |
| import matter | |
| var cbuf = bytes(-255) | |
| class BTP_CONTROL_FLAGS | |
| static var H_BIT = 6 # Handshake | |
| static var M_BIT = 5 # Management Message |