This file contains 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
diff --git a/include/mbedtls/compat-1.3.h b/include/mbedtls/compat-1.3.h | |
index 40177512c..efa1f78bb 100644 | |
--- a/include/mbedtls/compat-1.3.h | |
+++ b/include/mbedtls/compat-1.3.h | |
@@ -2390,6 +2390,7 @@ | |
#define ssl_set_sni mbedtls_ssl_conf_sni | |
#define ssl_set_transport mbedtls_ssl_conf_transport | |
#define ssl_set_truncated_hmac mbedtls_ssl_conf_truncated_hmac | |
+#define ssl_set_record_size_limit mbedtls_ssl_conf_record_size_limit | |
#define ssl_set_verify mbedtls_ssl_conf_verify |
This file contains 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
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
index 058e61b..c16551d 100644 | |
--- a/CMakeLists.txt | |
+++ b/CMakeLists.txt | |
@@ -127,7 +127,7 @@ if ("${TOIT_SYSTEM_NAME}" MATCHES "esp32") | |
set(MBEDTLS_C_FLAGS "-DMBEDTLS_CONFIG_FILE=\\\"mbedtls/esp_config.h\\\"") | |
else() | |
# These constants should stay in sync with the ones in the sdkconfig file of the ESP32 toolchain. | |
- set(MBEDTLS_C_FLAGS "-DMBEDTLS_SSL_IN_CONTENT_LEN=8100 -DMBEDTLS_SSL_OUT_CONTENT_LEN=3700 -DMBEDTLS_PLATFORM_MEMORY=1") | |
+ set(MBEDTLS_C_FLAGS "-DMBEDTLS_SSL_IN_CONTENT_LEN=8100 -DMBEDTLS_SSL_RECORD_SIZE_LIMIT=1 -DMBEDTLS_SSL_DEBUG_ALL=1 -DDEBUG_TLS=1 -DMBEDTLS_SSL_OUT_CONTENT_LEN=3700 -DMBEDTLS_PLATFORM_MEMORY=1") |
This file contains 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) 2021 Toitware ApS. | |
// Use of this source code is governed by a Zero-Clause BSD license that can | |
// be found in the EXAMPLES_LICENSE file. | |
import http | |
import net | |
import net.x509 | |
import certificate_roots | |
main: |
This file contains 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 bitmap show blit | |
import expect show * | |
/** | |
Takes a byte array of little endian 16 bit values. | |
Returns a new byte array of little endian 32 bit values, sign extended. | |
For each input 16 bit value there are two (copied) 32 bit output values. | |
*/ | |
expand input/ByteArray -> ByteArray: | |
output := ByteArray input.size * 4 |
This file contains 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
package main | |
func main() { | |
// Two new vars, with :=. | |
x, y := returns_one_and_two() | |
print("x = ", x, "\n") // 1 | |
print("y = ", y, "\n") // 2 | |
// One of the vars is new, use := for both. | |
y, z := returns_one_and_two() |
This file contains 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
check_illegal_utf_8 [244, 65, 48] // Low continuation bytes. | |
check_illegal_utf_8 [244, 244, 48] // High continuation bytes. | |
check_illegal_utf_8 [48, 244] // Missing continuation bytes. | |
check_illegal_utf_8 [0xc0, 0xdc] // Overlong encoding of backslash. | |
check_illegal_utf_8 [0xc1, 0xdf] // Overlong encoding of DEL. | |
check_illegal_utf_8 [0xe0, 0x9f, 0xbf] // Overlong encoding of character 0x7ff. | |
check_illegal_utf_8 [0xe0, 0x9f, 0xb9] // Overlong encoding of N'Ko exclamation mark. | |
check_illegal_utf_8 [0xf0, 0x82, 0x98, 0x83] // Overlong encoding of Unicode snowman. | |
check_illegal_utf_8 [0xed, 0xa0, 0x80] // 0xd800: First surrogate. | |
check_illegal_utf_8 [0xed, 0xbf, 0xbf] // 0xdfff: Last surrogate. |
This file contains 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
Ainos-MBP:~ erik$ ./toit/build/release64/bin/toitvm fly.toit | |
2 iterations, 7.0us per operation | |
4 iterations, 4.0us per operation | |
8 iterations, 3.375us per operation | |
16 iterations, 2.8125us per operation | |
32 iterations, 2.6875us per operation | |
64 iterations, 2.25us per operation | |
128 iterations, 2.046875us per operation | |
256 iterations, 1.91015625us per operation | |
512 iterations, 2.25us per operation |
This file contains 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
package main | |
// Existing classes we can't extend because they are | |
// in a different package. | |
type Foo struct { | |
Name string | |
} | |
type Bar struct { | |
Name string |
This file contains 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
package main | |
// Demonstrates how taking the address of an embedded struct | |
// leaks the embedding struct's memory. | |
type Inner struct { | |
x int | |
} | |
type Outer struct { |
This file contains 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
package main | |
func main() { | |
myMap := map[string]bool{} | |
populateMap(myMap) | |
println(len(myMap)) // Prints 1 because maps are passed by reference. | |
mySlice := []int{} | |
populateSlice(mySlice) | |
println(len(mySlice)) // Prints 0 because slices are passed by value. |