var eslintRecommended = {
'no-console': 0,
'no-empty': 0, // TODO: remove this feature
+ 'no-constant-condition': [2, { 'checkLoops': false }]
}
var style = {
'no-caller': 2,
'no-extend-native': 2,
'no-new-wrappers': 2,
- 'new-cap': 2,
+ 'new-cap': [2, { 'capIsNew': false, 'newIsCapExceptions': ['native'] }],
'no-array-constructor': 2,
'no-new-object': 2,
'semi': 2,
'node': true,
'es6': false,
},
+ 'globals': {
+ 'native': true,
+ },
'rules': Object.assign(
eslintRecommended,
style,
# Dependency directories
node_modules/
+iotjs_modules/
# Coverage directory used by tools like istanbul
coverage
- docker
before_install:
- - if [[ "$RUN_DOCKER" == "yes" ]]; then docker pull iotjs/ubuntu:0.3; fi
+ - if [[ "$RUN_DOCKER" == "yes" ]]; then docker pull iotjs/ubuntu:0.6; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then tools/brew-install-deps.sh; fi
- if [[ "$OPTS" == "misc" ]]; then tools/apt-get-install-deps.sh; fi
install:
+ pip install --user jsonmerge
script:
tools/travis_script.py
- OPTS="rpi2" RUN_DOCKER=yes
- OPTS="stm32f4dis" RUN_DOCKER=yes
- OPTS="artik053" RUN_DOCKER=yes
+ - OPTS="tizen" RUN_DOCKER=yes
+ - OPTS="es2015" RUN_DOCKER=yes
- OPTS="external-modules" RUN_DOCKER=yes
- OPTS="no-snapshot" RUN_DOCKER=yes
- - OPTS="misc"
+ - OPTS="misc" RUN_DOCKER=yes
matrix:
include:
- os: osx
env: OPTS="host-darwin"
+ install: pip2 install --user jsonmerge
- compiler: gcc-4.9
before_install: tools/apt-get-install-travis-i686.sh
addons:
iotjs_add_compile_flags(-DDEBUG -DENABLE_DEBUG_LOG)
endif()
+if(EXPERIMENTAL)
+ iotjs_add_compile_flags(-DEXPERIMENTAL)
+endif()
+
# Add arch-dependant flags
if("${TARGET_ARCH}" STREQUAL "arm")
iotjs_add_compile_flags(-D__arm__ -mthumb -fno-short-enums -mlittle-endian)
iotjs_add_compile_flags(-D__i686__ -D__x86__ -march=i686 -m32)
elseif("${TARGET_ARCH}" STREQUAL "x86_64")
iotjs_add_compile_flags(-D__x86_64__)
+elseif("${TARGET_ARCH}" STREQUAL "mips")
+ message("MIPS support is experimental!")
+ if(NOT EXPERIMENTAL)
+ message(FATAL_ERROR "Missing --experimental build option for MIPS!")
+ endif()
+
+ if(ENABLE_SNAPSHOT)
+ message(FATAL_ERROR "Cross endian snapshots are not supported. "
+ "Please disable snapshot mode for mips!")
+ endif()
elseif("${TARGET_ARCH}" STREQUAL "noarch")
else()
message(WARNING "Unknown target arch: ${TARGET_ARCH}.")
if("${TARGET_OS}" STREQUAL "darwin")
iotjs_add_compile_flags(-D__DARWIN__ -fno-builtin)
elseif("${TARGET_OS}" STREQUAL "linux")
- iotjs_add_compile_flags(-D__LINUX__ -fno-builtin)
+ iotjs_add_compile_flags(-D__LINUX__ -fno-builtin -rdynamic)
iotjs_add_link_flags(-pthread)
iotjs_add_flags(EXTERNAL_LIBS m rt)
elseif("${TARGET_OS}" STREQUAL "nuttx")
iotjs_add_compile_flags(-D__NUTTX__ -Os -fno-strict-aliasing)
iotjs_add_compile_flags(-fno-strength-reduce -fomit-frame-pointer)
elseif("${TARGET_OS}" STREQUAL "tizen")
- iotjs_add_compile_flags(-D__LINUX__ -fno-builtin)
+ iotjs_add_compile_flags(-D__TIZEN__ -fno-builtin -rdynamic)
iotjs_add_link_flags(-pthread)
iotjs_add_flags(EXTERNAL_LIBS m rt)
elseif("${TARGET_OS}" STREQUAL "tizenrt")
iotjs_add_compile_flags(-D__TIZENRT__ -Os -fno-strict-aliasing)
iotjs_add_compile_flags(-fno-strength-reduce -fomit-frame-pointer)
+elseif("${TARGET_OS}" STREQUAL "openwrt")
+ message("OpenWrt support is experimental!")
+ if(NOT EXPERIMENTAL)
+ message(FATAL_ERROR "Missing --experimental build option for OpenWrt!")
+ endif()
+
+ iotjs_add_compile_flags(-D__OPENWRT__ -D_GNU_SOURCE)
+ iotjs_add_link_flags(-pthread)
else()
message(WARNING "Unknown target os: ${TARGET_OS}.")
endif()
include(cmake/jerry.cmake)
include(cmake/http-parser.cmake)
include(cmake/libtuv.cmake)
-include(cmake/mbedtls.cmake)
include(cmake/iotjs.cmake)
You can find project details on our [project page](http://samsung.github.io/iotjs/) and [wiki](https://github.com/Samsung/iotjs/wiki).
-Memory usage and Binary footprint are measured at [here](https://samsung.github.io/js-remote-test) with real target daily.
+Memory usage and Binary footprint are measured at [here](https://samsung.github.io/iotjs-test-results) with real target daily.
The following table shows the latest results on the devices:
-| Artik053 | [![Remote Testrunner](https://samsung.github.io/js-remote-test/status/artik053.svg)](https://samsung.github.io/js-remote-test/?view=artik053) |
+| Artik053 | [![Remote Testrunner](https://firebasestorage.googleapis.com/v0/b/remote-testrunner.appspot.com/o/status%2Fiotjs%2Fartik053.svg?alt=media&token=1)](https://samsung.github.io/iotjs-test-results/?view=artik053) |
| :---: | :---: |
-| **Raspberry Pi 2** | [![Remote Testrunner](https://samsung.github.io/js-remote-test/status/rpi2.svg)](https://samsung.github.io/js-remote-test/?view=rpi2) |
-| **STM32F4-Discovery** | [![Remote Testrunner](https://samsung.github.io/js-remote-test/status/stm32f4dis.svg)](https://samsung.github.io/js-remote-test/?view=stm32) |
+| **Raspberry Pi 2** | [![Remote Testrunner](https://firebasestorage.googleapis.com/v0/b/remote-testrunner.appspot.com/o/status%2Fiotjs%2Frpi2.svg?alt=media&token=1)](https://samsung.github.io/iotjs-test-results/?view=rpi2) |
+| **STM32F4-Discovery** | [![Remote Testrunner](https://firebasestorage.googleapis.com/v0/b/remote-testrunner.appspot.com/o/status%2Fiotjs%2Fstm32f4dis.svg?alt=media&token=1)](https://samsung.github.io/iotjs-test-results/?view=stm32f4dis) |
IRC channel: #iotjs on [freenode](https://freenode.net)
### How to Test
```bash
-build/x86_64-linux/debug/bin/iotjs tools/check_test.js
+tools/testrunner.py build/x86_64-linux/debug/bin/iotjs
```
--- /dev/null
+# Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set(CMAKE_SYSTEM_NAME Openwrt)
+set(CMAKE_SYSTEM_PROCESSOR mips)
+
+set(CMAKE_C_COMPILER mips-openwrt-linux-gcc)
+set(CMAKE_C_COMPILER_WORKS TRUE)
+
string(TOUPPER ${module} MODULE)
set(moduleDefines)
- if(NOT "${${IOTJS_MODULE_${MODULE}_JSON}.modules.${module}.require}"
+ set(MODULE_PREFIX ${IOTJS_MODULE_${MODULE}_JSON}.modules.${module})
+
+ if(NOT "${${MODULE_PREFIX}.require}"
STREQUAL "")
foreach(idx
- ${${IOTJS_MODULE_${MODULE}_JSON}.modules.${module}.require})
+ ${${MODULE_PREFIX}.require})
set(dependency
- ${${IOTJS_MODULE_${MODULE}_JSON}.modules.${module}.require_${idx}})
+ ${${MODULE_PREFIX}.require_${idx}})
string(TOUPPER ${dependency} DEPENDENCY)
if(NOT ${ENABLE_MODULE_${DEPENDENCY}})
list(APPEND moduleDefines ENABLE_MODULE_${DEPENDENCY})
endforeach()
endif()
+ set(PLATFORM_REQUIRE_PREFIX ${MODULE_PREFIX}.platforms.${IOTJS_SYSTEM_OS})
+ foreach(idx ${${PLATFORM_REQUIRE_PREFIX}.require})
+ set(dependency ${${PLATFORM_REQUIRE_PREFIX}.require_${idx}})
+ string(TOUPPER ${dependency} DEPENDENCY)
+ if (NOT ${ENABLE_MODULE_${DEPENDENCY}})
+ list(APPEND moduleDefines ENABLE_MODULE_${DEPENDENCY})
+ addModuleDependencies(${dependency} deps)
+ list(APPEND varResult ${deps})
+ list(REMOVE_DUPLICATES varResult)
+ endif()
+ endforeach()
+
set(${varResult} ${moduleDefines} PARENT_SCOPE)
endfunction()
endif()
endforeach()
+set(EXTRA_CMAKE_FILES)
+
# Collect the files of enabled modules
foreach(MODULE ${IOTJS_ENABLED_MODULES})
if(${ENABLE_MODULE_${MODULE}})
endif()
endif()
+ # Check extra cmake file
+ set(EXTRA_CMAKE_FILE ${${MODULE_PREFIX}cmakefile})
+ if(NOT "${EXTRA_CMAKE_FILE}" STREQUAL "")
+ set(EXTRA_CMAKE_FILE_PATH "${MODULE_BASE_DIR}/${EXTRA_CMAKE_FILE}")
+ if(EXISTS "${EXTRA_CMAKE_FILE_PATH}")
+ list(APPEND EXTRA_CMAKE_FILES "${EXTRA_CMAKE_FILE_PATH}")
+ else()
+ message(FATAL_ERROR
+ "CMake file doesn't exists: ${EXTRA_CMAKE_FILE_PATH}")
+ endif()
+ endif()
+
# Add platform-related native source
if(NOT "${${MODULE_PREFIX}native_files}" STREQUAL ""
AND NOT "${${MODULE_PREFIX}init}" STREQUAL "")
${IOTJS_JS_MODULE_SRC}
)
+# Load all external module cmake files
+foreach(MODULE_EXTRA_CMAKE_FILE ${EXTRA_CMAKE_FILES})
+ message("Using CMake file: ${MODULE_EXTRA_CMAKE_FILE}")
+
+ set(MODULE_BINARY_DIR ${CMAKE_BINARY_DIR}/external/)
+ set(MODULE_LIBS)
+ get_filename_component(MODULE_DIR ${MODULE_EXTRA_CMAKE_FILE} DIRECTORY)
+
+ # Variables which should be used by the external module(s):
+ # - MODULE_DIR - the modules root directory
+ # - MODULE_BINARY_DIR - the build directory for the current module
+ # - MODULE_LIBS - list of libraries to use during linking (set this)
+ include(${MODULE_EXTRA_CMAKE_FILE})
+
+ if (NOT MODULE_NAME)
+ message(FATAL_ERROR
+ "MODULE_NAME was not specified in ${MODULE_EXTRA_CMAKE_FILE}")
+ endif()
+
+ list(APPEND EXTERNAL_LIBS ${MODULE_LIBS})
+
+ # Just to make sure it will always be unset
+ unset(MODULE_NAME) # This is usually set by the included cmake file
+ unset(MODULE_BINARY_DIR)
+ unset(MODULE_LIBS)
+endforeach()
+
# Collect all sources into LIB_IOTJS_SRC
file(GLOB LIB_IOTJS_SRC ${IOTJS_SOURCE_DIR}/*.c)
list(APPEND LIB_IOTJS_SRC
target_include_directories(${TARGET_IOTJS} PRIVATE ${IOTJS_INCLUDE_DIRS})
target_link_libraries(${TARGET_IOTJS} ${TARGET_LIB_IOTJS})
install(TARGETS ${TARGET_IOTJS} DESTINATION ${BIN_INSTALL_DIR})
+
+ add_subdirectory(test)
endif()
-DEXTERNAL_LIBC_INTERFACE=${EXTERNAL_LIBC_INTERFACE}
-DEXTERNAL_CMAKE_SYSTEM_PROCESSOR=${EXTERNAL_CMAKE_SYSTEM_PROCESSOR}
)
-elseif("${TARGET_OS}" MATCHES "LINUX|TIZEN|DARWIN")
+elseif("${TARGET_OS}" MATCHES "LINUX|TIZEN|DARWIN|OPENWRT")
list(APPEND JERRY_LIBS m)
list(APPEND DEPS_LIB_JERRY_ARGS
-DJERRY_LIBC=OFF
-DFEATURE_SNAPSHOT_EXEC=${ENABLE_SNAPSHOT}
-DFEATURE_SNAPSHOT_SAVE=OFF
-DFEATURE_PROFILE=${FEATURE_PROFILE}
+ -DFEATURE_LINE_INFO=${FEATURE_JS_BACKTRACE}
-DFEATURE_VM_EXEC_STOP=ON
-DENABLE_LTO=${ENABLE_LTO}
${DEPS_LIB_JERRY_ARGS}
set(JERRY_PORT_DIR ${DEPS_LIB_JERRY_SRC}/jerry-port/default)
endif()
-set(JERRY_INCLUDE_DIR ${DEPS_LIB_JERRY}/jerry-core/include)
+set(JERRY_INCLUDE_DIR ${DEPS_LIB_JERRY_SRC}/jerry-core/include)
cmake_minimum_required(VERSION 2.8)
-if(NOT EXPERIMENTAL_BUILD_MBEDTLS)
- return()
-endif()
-
-if(NOT "${TARGET_BOARD}" STREQUAL "None")
- return()
-endif()
-
set(DEPS_MBEDTLS deps/mbedtls)
set(DEPS_MBEDTLS_SRC ${ROOT_DIR}/${DEPS_MBEDTLS})
set(DEPS_MBEDTLS_BUILD_DIR ${CMAKE_BINARY_DIR}/${DEPS_MBEDTLS}/library)
+set(MODULE_NAME "tls")
+set(MODULE_BINARY_DIR ${DEPS_MBEDTLS_BUILD_DIR})
+
+if("${TARGET_OS}" STREQUAL "TIZEN")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-cpp")
+endif()
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-sign-conversion")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${ROOT_DIR}/config/mbedtls")
+set(CMAKE_C_FLAGS
+ "${CMAKE_C_FLAGS} -DMBEDTLS_CONFIG_FILE='<config-for-iotjs.h>'")
+
+# FIXME:
+# Remove this workaround when the related bug is fixed in
+# mbedtls. https://github.com/ARMmbed/mbedtls/issues/1550
+set(CMAKE_C_FLAGS_BCK "${CMAKE_C_FLAGS}")
+string(REPLACE "-fsanitize=address" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
ExternalProject_Add(mbedtls
PREFIX ${DEPS_MBEDTLS}
set(MBEDTLS_LIBS libmbedtls libmbedx509 libmbedcrypto)
set(MBEDTLS_INCLUDE_DIR ${DEPS_MBEDTLS}/include)
+
+# FIXME:
+# Remove this workaround when the related bug is fixed in
+# mbedtls. https://github.com/ARMmbed/mbedtls/issues/1550
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_BCK}")
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * Minimal configuration for TLS 1.1 (RFC 4346)
+ *
+ * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This file is part of mbed TLS (https://tls.mbed.org)
+ */
+
+#ifndef MBEDTLS_CONFIG_H
+#define MBEDTLS_CONFIG_H
+
+/**
+ * \name SECTION: System support
+ *
+ * This section sets system specific settings.
+ * \{
+ */
+
+/**
+ * \def MBEDTLS_HAVE_ASM
+ *
+ * The compiler has support for asm().
+ *
+ * Requires support for asm() in compiler.
+ *
+ * Used in:
+ * library/timing.c
+ * library/padlock.c
+ * include/mbedtls/bn_mul.h
+ *
+ * Comment to disable the use of assembly code.
+ */
+#define MBEDTLS_HAVE_ASM
+
+/**
+ * \def MBEDTLS_HAVE_TIME
+ *
+ * System has time.h and time().
+ * The time does not need to be correct, only time differences are used,
+ * by contrast with MBEDTLS_HAVE_TIME_DATE
+ *
+ * Defining MBEDTLS_HAVE_TIME allows you to specify MBEDTLS_PLATFORM_TIME_ALT,
+ * MBEDTLS_PLATFORM_TIME_MACRO, MBEDTLS_PLATFORM_TIME_TYPE_MACRO and
+ * MBEDTLS_PLATFORM_STD_TIME.
+ *
+ * Comment if your system does not support time functions
+ */
+#define MBEDTLS_HAVE_TIME
+
+/**
+ * \def MBEDTLS_AES_ROM_TABLES
+ *
+ * Store the AES tables in ROM.
+ *
+ * Uncomment this macro to store the AES tables in ROM.
+ */
+#define MBEDTLS_AES_ROM_TABLES
+
+/**
+ * \def MBEDTLS_CIPHER_MODE_CBC
+ *
+ * Enable Cipher Block Chaining mode (CBC) for symmetric ciphers.
+ */
+#define MBEDTLS_CIPHER_MODE_CBC
+
+/**
+ * \def MBEDTLS_REMOVE_ARC4_CIPHERSUITES
+ *
+ * Remove RC4 ciphersuites by default in SSL / TLS.
+ * This flag removes the ciphersuites based on RC4 from the default list as
+ * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible to
+ * enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including them
+ * explicitly.
+ *
+ * Uncomment this macro to remove RC4 ciphersuites by default.
+ */
+#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES
+
+/**
+ * \def MBEDTLS_ECP_DP_SECP192R1_ENABLED
+ *
+ * MBEDTLS_ECP_XXXX_ENABLED: Enables specific curves within the Elliptic Curve
+ * module. By default all supported curves are enabled.
+ *
+ * Comment macros to disable the curve and functions for it
+ */
+#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
+#define MBEDTLS_ECP_DP_SECP384R1_ENABLED
+#define MBEDTLS_ECP_DP_SECP256K1_ENABLED
+#define MBEDTLS_ECP_DP_BP256R1_ENABLED
+#define MBEDTLS_ECP_DP_BP384R1_ENABLED
+
+/**
+ * \def MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
+ *
+ * Enable the RSA-only based ciphersuite modes in SSL / TLS.
+ *
+ * Requires: MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15,
+ * MBEDTLS_X509_CRT_PARSE_C
+ *
+ * This enables the following ciphersuites (if other requisites are
+ * enabled as well):
+ * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384
+ * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256
+ * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA
+ */
+#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
+
+/**
+ * \def MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
+ *
+ * Enable the DHE-RSA based ciphersuite modes in SSL / TLS.
+ *
+ * Requires: MBEDTLS_DHM_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15,
+ * MBEDTLS_X509_CRT_PARSE_C
+ *
+ * This enables the following ciphersuites (if other requisites are
+ * enabled as well):
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA
+ */
+#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
+
+/**
+ * \def MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
+ *
+ * Enable the ECDHE-RSA based ciphersuite modes in SSL / TLS.
+ *
+ * Requires: MBEDTLS_ECDH_C, MBEDTLS_RSA_C, MBEDTLS_PKCS1_V15,
+ * MBEDTLS_X509_CRT_PARSE_C
+ *
+ * This enables the following ciphersuites (if other requisites are
+ * enabled as well):
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
+ */
+#define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
+
+/**
+ * \def MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
+ *
+ * Enable the ECDHE-ECDSA based ciphersuite modes in SSL / TLS.
+ *
+ * Requires: MBEDTLS_ECDH_C, MBEDTLS_ECDSA_C, MBEDTLS_X509_CRT_PARSE_C,
+ *
+ * This enables the following ciphersuites (if other requisites are
+ * enabled as well):
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
+ */
+#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
+
+/**
+ * \def MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
+ *
+ * Enable the ECDH-ECDSA based ciphersuite modes in SSL / TLS.
+ *
+ * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C
+ *
+ * This enables the following ciphersuites (if other requisites are
+ * enabled as well):
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
+ */
+#define MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
+
+/**
+ * \def MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
+ *
+ * Enable the ECDH-RSA based ciphersuite modes in SSL / TLS.
+ *
+ * Requires: MBEDTLS_ECDH_C, MBEDTLS_X509_CRT_PARSE_C
+ *
+ * This enables the following ciphersuites (if other requisites are
+ * enabled as well):
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
+ */
+#define MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
+
+/**
+ * \def MBEDTLS_PKCS1_V15
+ *
+ * Enable support for PKCS#1 v1.5 encoding.
+ *
+ * Requires: MBEDTLS_RSA_C
+ *
+ * This enables support for PKCS#1 v1.5 operations.
+ */
+#define MBEDTLS_PKCS1_V15
+
+/**
+ * \def MBEDTLS_PKCS1_V21
+ *
+ * Enable support for PKCS#1 v2.1 encoding.
+ *
+ * Requires: MBEDTLS_MD_C, MBEDTLS_RSA_C
+ *
+ * This enables support for RSAES-OAEP and RSASSA-PSS operations.
+ */
+#define MBEDTLS_PKCS1_V21
+
+/**
+ * \def MBEDTLS_SHA256_SMALLER
+ *
+ * Enable an implementation of SHA-256 that has lower ROM footprint but also
+ * lower performance.
+ *
+ * The default implementation is meant to be a reasonnable compromise between
+ * performance and size. This version optimizes more aggressively for size at
+ * the expense of performance. Eg on Cortex-M4 it reduces the size of
+ * mbedtls_sha256_process() from ~2KB to ~0.5KB for a performance hit of about
+ * 30%.
+ *
+ * Uncomment to enable the smaller implementation of SHA256.
+ */
+#define MBEDTLS_SHA256_SMALLER
+
+/**
+ * \def MBEDTLS_SSL_PROTO_TLS1
+ *
+ * Enable support for TLS 1.0.
+ *
+ * Requires: MBEDTLS_MD5_C
+ * MBEDTLS_SHA1_C
+ *
+ * Comment this macro to disable support for TLS 1.0
+ */
+#define MBEDTLS_SSL_PROTO_TLS1
+
+/**
+ * \def MBEDTLS_SSL_PROTO_TLS1_1
+ *
+ * Enable support for TLS 1.1 (and DTLS 1.0 if DTLS is enabled).
+ *
+ * Requires: MBEDTLS_MD5_C
+ * MBEDTLS_SHA1_C
+ *
+ * Comment this macro to disable support for TLS 1.1 / DTLS 1.0
+ */
+#define MBEDTLS_SSL_PROTO_TLS1_1
+
+/**
+ * \def MBEDTLS_SSL_PROTO_TLS1_2
+ *
+ * Enable support for TLS 1.2 (and DTLS 1.2 if DTLS is enabled).
+ *
+ * Requires: MBEDTLS_SHA1_C or MBEDTLS_SHA256_C or MBEDTLS_SHA512_C
+ * (Depends on ciphersuites)
+ *
+ * Comment this macro to disable support for TLS 1.2 / DTLS 1.2
+ */
+#define MBEDTLS_SSL_PROTO_TLS1_2
+
+/**
+ * \def MBEDTLS_SSL_SERVER_NAME_INDICATION
+ *
+ * Enable support for RFC 6066 server name indication (SNI) in SSL.
+ *
+ * Requires: MBEDTLS_X509_CRT_PARSE_C
+ *
+ * Comment this macro to disable support for server name indication in SSL
+ */
+#define MBEDTLS_SSL_SERVER_NAME_INDICATION
+
+/* \} name SECTION: mbed TLS feature support */
+
+/**
+ * \name SECTION: mbed TLS modules
+ *
+ * This section enables or disables entire modules in mbed TLS
+ * \{
+ */
+
+/**
+ * \def MBEDTLS_AES_C
+ *
+ * Enable the AES block cipher.
+ *
+ * Module: library/aes.c
+ * Caller: library/ssl_tls.c
+ * library/pem.c
+ * library/ctr_drbg.c
+ *
+ * This module enables the following ciphersuites (if other requisites are
+ * enabled as well):
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
+ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
+ * MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA
+ * MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384
+ * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256
+ * MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA
+ * MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256
+ * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256
+ * MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA
+ *
+ * PEM_PARSE uses AES for decrypting encrypted keys.
+ */
+#define MBEDTLS_AES_C
+
+/**
+ * \def MBEDTLS_ASN1_PARSE_C
+ *
+ * Enable the generic ASN1 parser.
+ *
+ * Module: library/asn1.c
+ * Caller: library/x509.c
+ * library/dhm.c
+ * library/pkcs12.c
+ * library/pkcs5.c
+ * library/pkparse.c
+ */
+#define MBEDTLS_ASN1_PARSE_C
+
+/**
+ * \def MBEDTLS_ASN1_WRITE_C
+ *
+ * Enable the generic ASN1 writer.
+ *
+ * Module: library/asn1write.c
+ * Caller: library/ecdsa.c
+ * library/pkwrite.c
+ * library/x509_create.c
+ * library/x509write_crt.c
+ * library/mbedtls_x509write_csr.c
+ */
+#define MBEDTLS_ASN1_WRITE_C
+
+/**
+ * \def MBEDTLS_BASE64_C
+ *
+ * Enable the Base64 module.
+ *
+ * Module: library/base64.c
+ * Caller: library/pem.c
+ *
+ * This module is required for PEM support (required by X.509).
+ */
+#define MBEDTLS_BASE64_C
+
+/**
+ * \def MBEDTLS_BIGNUM_C
+ *
+ * Enable the multi-precision integer library.
+ *
+ * Module: library/bignum.c
+ * Caller: library/dhm.c
+ * library/ecp.c
+ * library/ecdsa.c
+ * library/rsa.c
+ * library/ssl_tls.c
+ *
+ * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support.
+ */
+#define MBEDTLS_BIGNUM_C
+
+/**
+ * \def MBEDTLS_CIPHER_C
+ *
+ * Enable the generic cipher layer.
+ *
+ * Module: library/cipher.c
+ * Caller: library/ssl_tls.c
+ *
+ * Uncomment to enable generic cipher wrappers.
+ */
+#define MBEDTLS_CIPHER_C
+
+/**
+ * \def MBEDTLS_CTR_DRBG_C
+ *
+ * Enable the CTR_DRBG AES-256-based random generator.
+ *
+ * Module: library/ctr_drbg.c
+ * Caller:
+ *
+ * Requires: MBEDTLS_AES_C
+ *
+ * This module provides the CTR_DRBG AES-256 random number generator.
+ */
+#define MBEDTLS_CTR_DRBG_C
+
+/**
+ * \def MBEDTLS_DHM_C
+ *
+ * Enable the Diffie-Hellman-Merkle module.
+ *
+ * Module: library/dhm.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ *
+ * This module is used by the following key exchanges:
+ * DHE-RSA, DHE-PSK
+ */
+#define MBEDTLS_DHM_C
+
+/**
+ * \def MBEDTLS_ECDH_C
+ *
+ * Enable the elliptic curve Diffie-Hellman library.
+ *
+ * Module: library/ecdh.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ *
+ * This module is used by the following key exchanges:
+ * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK
+ *
+ * Requires: MBEDTLS_ECP_C
+ */
+#define MBEDTLS_ECDH_C
+
+/**
+ * \def MBEDTLS_ECDSA_C
+ *
+ * Enable the elliptic curve DSA library.
+ *
+ * Module: library/ecdsa.c
+ * Caller:
+ *
+ * This module is used by the following key exchanges:
+ * ECDHE-ECDSA
+ *
+ * Requires: MBEDTLS_ECP_C, MBEDTLS_ASN1_WRITE_C, MBEDTLS_ASN1_PARSE_C
+ */
+#define MBEDTLS_ECDSA_C
+
+/**
+ * \def MBEDTLS_ECP_C
+ *
+ * Enable the elliptic curve over GF(p) library.
+ *
+ * Module: library/ecp.c
+ * Caller: library/ecdh.c
+ * library/ecdsa.c
+ * library/ecjpake.c
+ *
+ * Requires: MBEDTLS_BIGNUM_C and at least one MBEDTLS_ECP_DP_XXX_ENABLED
+ */
+#define MBEDTLS_ECP_C
+
+/**
+ * \def MBEDTLS_ENTROPY_C
+ *
+ * Enable the platform-specific entropy code.
+ *
+ * Module: library/entropy.c
+ * Caller:
+ *
+ * Requires: MBEDTLS_SHA512_C or MBEDTLS_SHA256_C
+ *
+ * This module provides a generic entropy pool
+ */
+#define MBEDTLS_ENTROPY_C
+
+/**
+ * \def MBEDTLS_GCM_C
+ *
+ * Enable the Galois/Counter Mode (GCM) for AES.
+ *
+ * Module: library/gcm.c
+ *
+ * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C
+ *
+ * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other
+ * requisites are enabled as well.
+ */
+#define MBEDTLS_GCM_C
+
+/**
+ * \def MBEDTLS_MD_C
+ *
+ * Enable the generic message digest layer.
+ *
+ * Module: library/mbedtls_md.c
+ * Caller:
+ *
+ * Uncomment to enable generic message digest wrappers.
+ */
+#define MBEDTLS_MD_C
+
+/**
+ * \def MBEDTLS_MD5_C
+ *
+ * Enable the MD5 hash algorithm.
+ *
+ * Module: library/mbedtls_md5.c
+ * Caller: library/mbedtls_md.c
+ * library/pem.c
+ * library/ssl_tls.c
+ *
+ * This module is required for SSL/TLS and X.509.
+ * PEM_PARSE uses MD5 for decrypting encrypted keys.
+ */
+#define MBEDTLS_MD5_C
+
+/**
+ * \def MBEDTLS_OID_C
+ *
+ * Enable the OID database.
+ *
+ * Module: library/oid.c
+ * Caller: library/asn1write.c
+ * library/pkcs5.c
+ * library/pkparse.c
+ * library/pkwrite.c
+ * library/rsa.c
+ * library/x509.c
+ * library/x509_create.c
+ * library/mbedtls_x509_crl.c
+ * library/mbedtls_x509_crt.c
+ * library/mbedtls_x509_csr.c
+ * library/x509write_crt.c
+ * library/mbedtls_x509write_csr.c
+ *
+ * This modules translates between OIDs and internal values.
+ */
+#define MBEDTLS_OID_C
+
+/**
+ * \def MBEDTLS_PEM_PARSE_C
+ *
+ * Enable PEM decoding / parsing.
+ *
+ * Module: library/pem.c
+ * Caller: library/dhm.c
+ * library/pkparse.c
+ * library/mbedtls_x509_crl.c
+ * library/mbedtls_x509_crt.c
+ * library/mbedtls_x509_csr.c
+ *
+ * Requires: MBEDTLS_BASE64_C
+ *
+ * This modules adds support for decoding / parsing PEM files.
+ */
+#define MBEDTLS_PEM_PARSE_C
+
+/**
+ * \def MBEDTLS_PK_C
+ *
+ * Enable the generic public (asymetric) key layer.
+ *
+ * Module: library/pk.c
+ * Caller: library/ssl_tls.c
+ * library/ssl_cli.c
+ * library/ssl_srv.c
+ *
+ * Requires: MBEDTLS_RSA_C or MBEDTLS_ECP_C
+ *
+ * Uncomment to enable generic public key wrappers.
+ */
+#define MBEDTLS_PK_C
+
+/**
+ * \def MBEDTLS_PK_PARSE_C
+ *
+ * Enable the generic public (asymetric) key parser.
+ *
+ * Module: library/pkparse.c
+ * Caller: library/mbedtls_x509_crt.c
+ * library/mbedtls_x509_csr.c
+ *
+ * Requires: MBEDTLS_PK_C
+ *
+ * Uncomment to enable generic public key parse functions.
+ */
+#define MBEDTLS_PK_PARSE_C
+
+/**
+ * \def MBEDTLS_RSA_C
+ *
+ * Enable the RSA public-key cryptosystem.
+ *
+ * Module: library/rsa.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ * library/x509.c
+ *
+ * This module is used by the following key exchanges:
+ * RSA, DHE-RSA, ECDHE-RSA, RSA-PSK
+ *
+ * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_OID_C
+ */
+#define MBEDTLS_RSA_C
+
+/**
+ * \def MBEDTLS_SHA1_C
+ *
+ * Enable the SHA1 cryptographic hash algorithm.
+ *
+ * Module: library/mbedtls_sha1.c
+ * Caller: library/mbedtls_md.c
+ * library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ * library/x509write_crt.c
+ *
+ * This module is required for SSL/TLS and SHA1-signed certificates.
+ */
+#define MBEDTLS_SHA1_C
+
+/**
+ * \def MBEDTLS_SHA256_C
+ *
+ * Enable the SHA-224 and SHA-256 cryptographic hash algorithms.
+ *
+ * Module: library/mbedtls_sha256.c
+ * Caller: library/entropy.c
+ * library/mbedtls_md.c
+ * library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ *
+ * This module adds support for SHA-224 and SHA-256.
+ * This module is required for the SSL/TLS 1.2 PRF function.
+ */
+#define MBEDTLS_SHA256_C
+
+/**
+ * \def MBEDTLS_SSL_CLI_C
+ *
+ * Enable the SSL/TLS client code.
+ *
+ * Module: library/ssl_cli.c
+ * Caller:
+ *
+ * Requires: MBEDTLS_SSL_TLS_C
+ *
+ * This module is required for SSL/TLS client support.
+ */
+#define MBEDTLS_SSL_CLI_C
+
+/**
+ * \def MBEDTLS_SSL_SRV_C
+ *
+ * Enable the SSL/TLS server code.
+ *
+ * Module: library/ssl_srv.c
+ * Caller:
+ *
+ * Requires: MBEDTLS_SSL_TLS_C
+ *
+ * This module is required for SSL/TLS server support.
+ */
+#define MBEDTLS_SSL_SRV_C
+
+/**
+ * \def MBEDTLS_SSL_TLS_C
+ *
+ * Enable the generic SSL/TLS code.
+ *
+ * Module: library/ssl_tls.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ *
+ * Requires: MBEDTLS_CIPHER_C, MBEDTLS_MD_C
+ * and at least one of the MBEDTLS_SSL_PROTO_XXX defines
+ *
+ * This module is required for SSL/TLS.
+ */
+#define MBEDTLS_SSL_TLS_C
+
+/**
+ * \def MBEDTLS_X509_USE_C
+ *
+ * Enable X.509 core for using certificates.
+ *
+ * Module: library/x509.c
+ * Caller: library/mbedtls_x509_crl.c
+ * library/mbedtls_x509_crt.c
+ * library/mbedtls_x509_csr.c
+ *
+ * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C,
+ * MBEDTLS_PK_PARSE_C
+ *
+ * This module is required for the X.509 parsing modules.
+ */
+#define MBEDTLS_X509_USE_C
+
+/**
+ * \def MBEDTLS_X509_CRT_PARSE_C
+ *
+ * Enable X.509 certificate parsing.
+ *
+ * Module: library/mbedtls_x509_crt.c
+ * Caller: library/ssl_cli.c
+ * library/ssl_srv.c
+ * library/ssl_tls.c
+ *
+ * Requires: MBEDTLS_X509_USE_C
+ *
+ * This module is required for X.509 certificate parsing.
+ */
+#define MBEDTLS_X509_CRT_PARSE_C
+
+/* \} name SECTION: mbed TLS modules */
+
+#endif /* MBEDTLS_CONFIG_H */
--- /dev/null
+[general]
+upstream_branch = ${upstreamversion}
+upstream_tag = ${upstreamversion}
+packaging_dir = config/tizen/packaging
# See the License for the specific language governing permissions and
# limitations under the License.
-cd ..
+function print_usage {
+ echo "USAGE: $0 [--debug|--clean]"
+ echo ""
+ echo "Optional arguments:"
+ echo "--debug: Build IoT.js in debug mode. The default is release mode."
+ echo "--clean: Make a clean gbs build by deleting the old build root."
+ echo ""
+}
+
+buildtype="release"
+unset cleanbuild
+
+while [ -n "$1" ]; do
+ case $1 in
+ --debug )
+ buildtype="debug"
+ ;;
+ --clean )
+ cleanbuild=true
+ ;;
+ * )
+ print_usage
+ exit 1;
+ ;;
+ esac
+ shift
+done
echo "******************************************************************"
echo "* Tizen GBS build *"
echo "* ~/.gbs.conf sample is at 'config/tizen/sample.gbs.conf'. *"
echo "******************************************************************"
-read -p "[Warning] This working folder will be copied to ../iotjs_tizen_gbs \
-Are you sure to continue? (y/n) " -n 1 -r
-
echo ""
-if [[ $REPLY =~ ^[Yy]$ ]]
+echo "This working folder will be copied to ../iotjs_tizen_gbs"
+
+cd ..
+echo copy from $OLDPWD to ../iotjs_tizen_gbs
+cp -ra $OLDPWD iotjs_tizen_gbs
+cd iotjs_tizen_gbs
+echo -e "\n(1) Now, cloning submodules. "
+git submodule init
+echo -e "\n(2) Update submodules... "
+git submodule update
+
+find ./ -name '.git' | xargs rm -rf
+# Initialize Git repositoryã…£
+if [ ! -d .git ]
then
- echo copy from $OLDPWD to ../iotjs_tizen_gbs
- cp -ra $OLDPWD iotjs_tizen_gbs
- cd iotjs_tizen_gbs
- echo -e "\n(1) Now, cloning submodules. "
- git submodule init
- echo -e "\n(2) Update submodules... "
- git submodule update
-
- find ./ -name '.git' | xargs rm -rf
- # Initialize Git repositoryã…£
- if [ ! -d .git ]
- then
- git init ./
- git checkout -b tizen_gbs
- git add ./
- git commit -m "Initial commit"
- fi
-
- echo -e "\n(3) Calling core gbs build command"
- gbsconf="config/tizen/sample.gbs.conf"
- gbscommand="gbs -c $gbsconf build -A armv7l --include-all --clean"
- echo $gbscommand
- if eval $gbscommand
- then
- echo "========================================================"
- echo "1. GBS Build is successful."
- echo "2. You can find rpm packages in below folder"
- echo " GBS-ROOT/local/repos/tizen_unified_preview1/armv7l/RPMS"
- else
- echo "GBS Build failed!"
- fi
+ git init ./
+ git checkout -b tizen_gbs
+ git add ./
+ git commit -m "Initial commit"
+fi
+
+echo -e "\n(3) Calling core gbs build command"
+gbsconf="config/tizen/sample.gbs.conf"
+gbscommand="gbs -c $gbsconf build -A armv7l --include-all"
+gbscommand+=" ${cleanbuild:+--clean} --define='build_mode $buildtype'"
+gbscommand+=" --define='external_build_options $IOTJS_BUILD_OPTION'"
+
+ret=0
+echo $gbscommand
+if eval $gbscommand
+then
+ echo "========================================================"
+ echo "1. GBS Build is successful."
+ echo "2. You can find rpm packages in below folder"
+ echo " GBS-ROOT/local/repos/tizen_unified_rreview2/armv7l/RPMS"
+else
+ echo "GBS Build failed!"
+ ret=1
+fi
cd ..
rm -rf iotjs_tizen_gbs
cd iotjs
-fi
+exit $ret
Name: iotjs
Description: Platform for Internet of Things with JavaScript
Version: 1.0.0
-Libs:
-Cflags: -I${includedir}
+Libs: -L${libdir} -liotjs -lcapi-system-peripheral-io -lpthread -lcurl -ldlog -lappcore-agent
+Cflags: -I${includedir}/iotjs
BuildRequires: cmake
BuildRequires: glibc-static
#BuildRequires: aul
-#BuildRequires: pkgconfig(appcore-agent)
-#BuildRequires: pkgconfig(capi-appfw-service-application)
-#BuildRequires: pkgconfig(capi-appfw-app-common)
+BuildRequires: pkgconfig(appcore-agent)
+BuildRequires: pkgconfig(capi-appfw-service-application)
+BuildRequires: pkgconfig(capi-appfw-app-common)
#BuildRequires: pkgconfig(capi-appfw-package-manager)
-#BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(capi-system-peripheral-io)
BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(capi-appfw-app-control)
+BuildRequires: pkgconfig(bundle)
#BuildRequires: pkgconfig(st_things_sdkapi)
#for https
%description
Platform for Internet of Things with JavaScript
-# default is RELEASE mode.
-# If DEBUG mode is needed, please use tizen_build_devel_mode
-%define RELEASE False
-# For Example
-%if %{RELEASE} == "True"
-%define build_mode release
-%else
-%define build_mode debug
-%endif
-
-# Default values to be eventually overiden BEFORE or as gbs params:
-%{!?RELEASE: %define RELEASE 0}
+# Initialize the variables
+%{!?build_mode: %define build_mode release}
+%{!?external_build_options: %define external_build_options %{nil}}
%package service
Summary: Development files for %{name}
cp %{SOURCE1001} .
%build
-./tools/build.py --clean --buildtype=%{build_mode} --target-arch=noarch \
- --target-os=tizen --target-board=rpi3 \
- --external-lib=capi-system-peripheral-io \
- --compile-flag=-D__TIZEN__ \
- --cmake-param=-DENABLE_MODULE_DGRAM=ON \
- --cmake-param=-DENABLE_MODULE_GPIO=ON \
- --jerry-cmake-param=-DENABLE_STATIC_LINK=OFF \
- --no-init-submodule --no-parallel-build
+./tools/build.py \
+ --clean \
+ --buildtype=%{build_mode} \
+ --profile=test/profiles/tizen.profile \
+ --target-arch=noarch \
+ --target-os=tizen \
+ --target-board=rpi3 \
+ --external-lib=capi-system-peripheral-io \
+ --external-lib=capi-appfw-app-common \
+ --external-lib=dlog \
+ --external-lib=bundle \
+ --external-lib=capi-appfw-app-control \
+ --external-include-dir=/usr/include/dlog/ \
+ --external-include-dir=/usr/include/appcore-agent/ \
+ --external-include-dir=/usr/include/appfw/ \
+ --external-include-dir=/usr/include/glib-2.0/ \
+ --external-include-dir=/usr/lib/glib-2.0/include/ \
+ --compile-flag=-D__TIZEN__ \
+ --compile-flag=-fPIC \
+ --jerry-cmake-param=-DENABLE_STATIC_LINK=OFF \
+ --no-init-submodule \
+ --no-parallel-build \
+ %{external_build_options}
# --external-lib=sdkapi \
+# Create shared library
+%define iotjs_target_lib libjerry-core.a libjerry-port-default.a libhttpparser.a libtuv.a \\\
+ libmbedx509.a libmbedtls.a libmbedcrypto.a libiotjs.a
+%define iotjs_lib_flag -lcapi-system-peripheral-io -lpthread -lcurl -ldlog -lappcore-agent -lcapi-appfw-app-common -lbundle -lcapi-appfw-app-control
+cd ./build/noarch-tizen/%{build_mode}/lib/
+gcc -shared -o libiotjs.so -Wl,--whole-archive %{iotjs_target_lib} -Wl,--no-whole-archive %{iotjs_lib_flag}
%install
mkdir -p %{buildroot}%{_bindir}
cp ./build/noarch-tizen/%{build_mode}/bin/iotjs %{buildroot}%{_bindir}/
-cp ./build/noarch-tizen/%{build_mode}/lib/* %{buildroot}%{_libdir}/iotjs/
+cp ./build/noarch-tizen/%{build_mode}/lib/*.so %{buildroot}%{_libdir}/
-cp ./include/*.h %{buildroot}%{_includedir}
-cp ./src/*.h %{buildroot}%{_includedir}
+cp ./src/platform/tizen/iotjs_tizen_service_app.h %{buildroot}%{_includedir}/iotjs
cp ./config/tizen/packaging/%{name}.pc.in %{buildroot}/%{_libdir}/pkgconfig/%{name}.pc
%post -p /sbin/ldconfig
%{_bindir}/*
%files devel
+%manifest config/tizen/packaging/%{name}.manifest
%defattr(-,root,root,-)
-%{_libdir}/iotjs/*.a
+%{_libdir}/libiotjs.so
%{_libdir}/pkgconfig/%{name}.pc
%{_includedir}/*
[general]
-profile = profile.tizen_unified_preview1
+profile = profile.tizen_unified_preview2
+#profile = profile.tizen_4.0_unified
+#profile = profile.tizen_unified
upstream_branch = ${upstreamversion}
upstream_tag = ${upstreamversion}
packaging_dir = config/tizen/packaging
-[profile.tizen_unified_preview1]
+[profile.tizen_unified_preview2]
obs = obs.spin
-repos = repo.tizen_local, repo.public_4.0_base_arm_20170929.1, repo.tizen_unified_20171016.1
+repos = repo.tizen_local, repo.tizen_4.0_base_arm_20171222.1, repo.tizen_4.0_unified_20180118.1
+
+[profile.tizen_4.0_unified]
+obs = obs.spin
+repos = repo.public_4.0_base_arm, repo.tizen_4.0_unified
[profile.tizen_unified]
obs = obs.spin
-repos = repo.public_4.0_base_arm, repo.tizen_unified
+repos = repo.tizen_base_arm, repo.tizen_unified
[profile.tizen_artik10]
obs = obs.spin
user = obs_viewer
passwdx = QlpoOTFBWSZTWRP5nYMAAB6fgCAAeUA9mr+QBvzF4CAAVGAZDTRoDI0YBlCKeptQBoA0aGZIAottAkltEPOK7BAFXE9mTUzocPMzQRkPoPpNwEZx3rRQhxkXmGHS6wCjHskyVCP4u5IpwoSAn8zsGA==
+
[repo.public_3_arm]
url = http://download.tizen.org/releases/milestone/tizen/3.0.m2/common_artik/tizen-common-artik_20170111.3/repos/arm-wayland/packages/
user =
passwdx =
-[repo.tizen_unified]
-url=http://download.tizen.org/snapshots/tizen/unified/latest/repos/standard/packages/
-user=
-passwdx=
-
-[repo.base_arm]
-url=http://download.tizen.org/snapshots/tizen/base/latest/repos/arm/
-user=
-passwdx=
-
-
[repo.public_3.0_base_arm]
url = http://download.tizen.org/snapshots/tizen/base/latest/repos/arm/packages/armv7l/
user =
passwdx =
-[repo.public_4.0_base_arm]
+
+[repo.tizen_unified]
+url = http://download.tizen.org/snapshots/tizen/unified/latest/repos/standard/packages/
+user =
+passwdx =
+
+[repo.tizen_base_arm]
url = http://download.tizen.org/snapshots/tizen/base/latest/repos/standard/packages/
+user =
+passwdx =
+
+
+[repo.tizen_4.0_unified]
+url = http://download.tizen.org/snapshots/tizen/4.0-unified/latest/repos/standard/packages/
+user =
+passwdx =
+
+[repo.public_4.0_base_arm]
+url = http://download.tizen.org/snapshots/tizen/4.0-base/latest/repos/arm/packages/
user =
passwdx =
-[repo.public_4.0_base_arm_20170929.1]
-url = http://download.tizen.org/releases/previews/iot/preview1/tizen-4.0-base_20170929.1/repos/arm/packages/
+
+[repo.tizen_4.0_base_arm_20171222.1]
+url = http://download.tizen.org/releases/previews/iot/preview2/tizen-4.0-base_20171222.1/repos/arm/packages/
user =
passwdx =
-[repo.tizen_unified_20171016.1]
-url=http://download.tizen.org/releases/previews/iot/preview1/tizen-4.0-unified_20171016.1/repos/standard/packages/
+[repo.tizen_4.0_unified_20180118.1]
+url = http://download.tizen.org/releases/previews/iot/preview2/tizen-4.0-unified_20180118.1/repos/standard/packages/
user =
passwdx =
[repo.tizen_local]
-url = ~/GBS-ROOT/local/repos/tizen_unified_preview1/
+url = ~/GBS-ROOT/local/repos/tizen_unified_preview2/
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Overview version="0.0.1">
+ <SampleName>IoTjs App</SampleName>
+ <SampleVersion>1.0</SampleVersion>
+ <PlatformList>
+ <Profile>
+ <ProfileName>iot-headless</ProfileName>
+ <RequiredVersion>4.0</RequiredVersion>
+ </Profile>
+ </PlatformList>
+ <ProjectType>org.tizen.nativecore.buildArtefactType.app</ProjectType>
+ <HasOption>False</HasOption>
+ <CategoryList>
+ <Category>Template</Category>
+ </CategoryList>
+ <IconSet>
+ <IconSmall>ic_s_service.png</IconSmall>
+ <IconMediumNormal>ic_m_service_n.png</IconMediumNormal>
+ <IconMediumSelect>ic_m_service_s.png</IconMediumSelect>
+ <IconLarge>ic_l_service.png</IconLarge>
+ </IconSet>
+ <Description>
+ This is the empty template for developing IoT.js application.
+ </Description>
+</Overview>
--- /dev/null
+#ifndef __$(appName)_H__
+#define __$(appName)_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "$(appName)"
+
+
+#endif /* __$(appName)_H__ */
--- /dev/null
+APPNAME = $(appName)
+
+type = app
+profile = $(platform)
+
+USER_SRCS = src/$(appName).c
+USER_DEFS =
+USER_INC_DIRS = inc
+USER_OBJS =
+USER_LIBS =
+USER_EDCS =
--- /dev/null
+console.log('Hello IoT.js');
+
--- /dev/null
+#include <tizen.h>
+#include <service_app.h>
+#include <iotjs_tizen_service_app.h>
+#include "$(appName).h"
+
+
+bool service_app_create(void *data)
+{
+ // Todo: add your code here.
+ return true;
+}
+
+void service_app_terminate(void *data)
+{
+ // Todo: add your code here.
+ return;
+}
+
+void service_app_control(app_control_h app_control, void *data)
+{
+ // Todo: add your code here.
+ return;
+}
+
+static void
+service_app_lang_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LANGUAGE_CHANGED*/
+ return;
+}
+
+static void
+service_app_region_changed(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_REGION_FORMAT_CHANGED*/
+}
+
+static void
+service_app_low_battery(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_BATTERY*/
+}
+
+static void
+service_app_low_memory(app_event_info_h event_info, void *user_data)
+{
+ /*APP_EVENT_LOW_MEMORY*/
+}
+
+int main(int argc, char* argv[])
+{
+ char ad[50] = {0,};
+ service_app_lifecycle_callback_s event_callback;
+ app_event_handler_h handlers[5] = {NULL, };
+
+ event_callback.create = service_app_create;
+ event_callback.terminate = service_app_terminate;
+ event_callback.app_control = service_app_control;
+
+ service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
+ service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
+ service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
+ service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
+
+ return iotjs_service_app_start(argc, argv, "index.js", &event_callback, ad);
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="4.0" package="$(packageName)" version="1.0.0">
+ <profile name="$(packageProfile)" />
+ <service-application appid="$(packageName)" exec="$(appNameLower)" type="capp" multiple="false" taskmanage="false" nodisplay="true">
+ <icon>$(appName).png</icon>
+ <label>$(appName)</label>
+ <background-category value="iot-communication"/>
+ </service-application>
+ <privileges>
+ <privilege>http://tizen.org/privilege/network.get</privilege>
+ <privilege>http://tizen.org/privilege/network.set</privilege>
+ <privilege>http://tizen.org/privilege/internet</privilege>
+ <privilege>http://tizen.org/privilege/alarm.set</privilege>
+ <privilege>http://tizen.org/privilege/network.profile</privilege>
+ <privilege>http://tizen.org/privilege/peripheralio</privilege>
+ </privileges>
+</manifest>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<template>
+ <slp-property>
+ <property-group>
+ <sample-name>IoT.js Application</sample-name>
+ <category>Platform Template</category>
+ <sdk-version>1.00</sdk-version>
+ <project-type>org.tizen.nativecore.buildArtefactType.app</project-type>
+ <sample-description>description.xml</sample-description>
+ </property-group>
+ </slp-property>
+ <process type="org.tizen.nativeappcommon.TizenCopyFolder">
+ <simple name="projectName" value="$(projectName)"/>
+ <simple name="folderPath" value="project"/>
+ <complex-array name="replaceableFiles">
+ <element>
+ <simple name="sourcePath" value="src/main.c"/>
+ <simple name="targetPath" value="src/$(appName).c"/>
+ <simple name="replaceable" value="true"/>
+ </element>
+ <element>
+ <simple name="sourcePath" value="inc/main.h"/>
+ <simple name="targetPath" value="inc/$(appName).h"/>
+ <simple name="replaceable" value="true"/>
+ </element>
+ <element>
+ <simple name="sourcePath" value="tizen-manifest.xml"/>
+ <simple name="targetPath" value="tizen-manifest.xml"/>
+ <simple name="replaceable" value="true"/>
+ </element>
+ <element>
+ <simple name="sourcePath" value="shared/res/mainmenu.png"/>
+ <simple name="targetPath" value="shared/res/$(appName).png"/>
+ <simple name="replaceable" value="false"/>
+ </element>
+ <element>
+ <simple name="sourcePath" value="project_def.prop"/>
+ <simple name="targetPath" value="project_def.prop"/>
+ <simple name="replaceable" value="true"/>
+ </element>
+ </complex-array>
+ </process>
+ <process type="org.tizen.nativecore.SetDefaultCoreFrameworks">
+ <simple name="projectName" value="$(projectName)"/>
+ <complex-array name="frameworkList">
+ <element>
+ <simple name="framework" value="Native_API"/>
+ </element>
+ </complex-array>
+ </process>
+</template>
--- /dev/null
+#
+# For a description of the syntax of this configuration file,
+# see kconfig-language at https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt
+#
+
+config ENABLE_IOTJS
+ bool "IoT.js"
+ default n
+ select SPI_EXCHANGE
+ select IOTBUS
+ select IOTBUS_GPIO
+ select IOTBUS_I2C
+ select IOTBUS_PWM
+ select IOTBUS_SPI
+ select IOTBUS_UART
+ ---help---
+ Enable IoT.js framework
+
+if ENABLE_IOTJS
+
+config IOTJS_PRIORITY
+ int "IoT.js task priority"
+ default 100
+
+config IOTJS_STACKSIZE
+ int "IoT.js stack size"
+ default 32768
+
+config IOTJS_JERRY_HEAP
+ int "Jerryscript Heaplimit"
+ default 128
+
+endif #ENABLE_IOTJS
+
# All the job definitions in the matrix.
matrix:
include:
- - env: OPTS="--check-signed-off=travis --check-cppcheck --check-doxygen --check-vera --check-license --check-magic-strings"
+ - env: OPTS="--check-signed-off=travis --check-cppcheck --check-doxygen --check-vera --check-license --check-magic-strings --check-pylint"
+ install: pip install --user pylint==1.6.5
- env: OPTS="--jerry-debugger"
- - env: OPTS="--jerry-tests --jerry-test-suite"
- - env: OPTS="--jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l.cmake" TIMEOUT=300
+ - env: OPTS="--quiet --jerry-tests --jerry-test-suite"
+ - env: OPTS="--quiet --jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l.cmake" TIMEOUT=300
install: tools/apt-get-install-qemu-arm.sh
- env: OPTS="--buildoption-test"
- - env: OPTS="--jerry-tests --jerry-test-suite --buildoptions=--jerry-libc=off,--compile-flag=-m32,--cpointer-32bit=on"
+ - env: OPTS="--quiet --jerry-tests --jerry-test-suite --buildoptions=--jerry-libc=off,--compile-flag=-m32,--cpointer-32bit=on"
- env: OPTS="--unittests"
- env: OPTS="--unittests --buildoptions=--cmake-param=-DFEATURE_INIT_FINI=ON"
- env: OPTS="--test262"
install: sudo timedatectl set-timezone America/Los_Angeles
- - env: OPTS="--check-pylint"
- install: pip install --user pylint==1.6.5
- os: osx
before_install: tools/brew-install-deps.sh
- env: OPTS="--jerry-tests --jerry-test-suite --unittests"
+ env: OPTS="--quiet --jerry-tests --jerry-test-suite --unittests"
- install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
env:
# Declaration of the encrypted COVERITY_SCAN_TOKEN, created via the
packages:
- gcc-5
- gcc-5-multilib
- env: OPTS="--jerry-tests --jerry-test-suite --skip-list=parser-oom.js --buildoptions=--compile-flag=-fsanitize=address,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--compile-flag=-O2,--debug,--jerry-libc=off,--static-link=off,--system-allocator=on,--linker-flag=-fuse-ld=gold" ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=true:strict_init_order=true TIMEOUT=600
+ env: OPTS="--quiet --jerry-tests --jerry-test-suite --skip-list=parser-oom.js --buildoptions=--compile-flag=-fsanitize=address,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--compile-flag=-O2,--debug,--jerry-libc=off,--static-link=off,--system-allocator=on,--linker-flag=-fuse-ld=gold" ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=true:strict_init_order=true TIMEOUT=600
- compiler: gcc-5
addons:
apt:
packages:
- gcc-5
- gcc-5-multilib
- env: OPTS="--jerry-tests --jerry-test-suite --skip-list=parser-oom.js --buildoptions=--compile-flag=-fsanitize=undefined,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--debug,--jerry-libc=off,--static-link=off,--system-allocator=on,--linker-flag=-fuse-ld=gold" UBSAN_OPTIONS=print_stacktrace=1 TIMEOUT=600
+ env: OPTS="--quiet --jerry-tests --jerry-test-suite --skip-list=parser-oom.js --buildoptions=--compile-flag=-fsanitize=undefined,--compile-flag=-m32,--compile-flag=-fno-omit-frame-pointer,--compile-flag=-fno-common,--debug,--jerry-libc=off,--static-link=off,--system-allocator=on,--linker-flag=-fuse-ld=gold" UBSAN_OPTIONS=print_stacktrace=1 TIMEOUT=600
- env: JOBNAME="ESP8266 Build Test"
cache: ccache
install: make -f ./targets/zephyr/Makefile.travis install
script: make -f ./targets/zephyr/Makefile.travis script
allow_failures:
- - env: OPTS="--check-pylint"
- env: JOBNAME="Mbed/K64F Build Test"
+ - env: JOBNAME="Zephyr/Arduino 101 Build Test"
fast_finish: true
# The channel name "chat.freenode.net#jerryscript"
# External compiler & linker flags
if(DEFINED EXTERNAL_COMPILE_FLAGS)
jerry_add_compile_flags(${EXTERNAL_COMPILE_FLAGS})
+ jerry_add_flags(CMAKE_ASM_FLAGS "${EXTERNAL_COMPILE_FLAGS}")
endif()
if(DEFINED EXTERNAL_LINKER_FLAGS)
--- /dev/null
+# Copyright JS Foundation and other contributors, http://js.foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set(CMAKE_SYSTEM_NAME TizenRT)
+set(CMAKE_SYSTEM_PROCESSOR armv7l)
+set(CMAKE_SYSTEM_VERSION ARTIK053)
+
+set(FLAGS_COMMON_ARCH -mcpu=cortex-r4 -mfpu=vfpv3 -fno-builtin -fno-strict-aliasing -fomit-frame-pointer -fno-strength-reduce -Wall -Werror -Wshadow -Wno-error=conversion)
+
+set(CMAKE_C_COMPILER arm-none-eabi-gcc)
+set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_SYSTEM_NAME Openwrt)
set(CMAKE_SYSTEM_PROCESSOR mips)
-set(CMAKE_C_COMPILER mipsel-openwrt-linux-gcc)
+set(CMAKE_C_COMPILER mips-openwrt-linux-gcc)
--- /dev/null
+# Copyright JS Foundation and other contributors, http://js.foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set(CMAKE_SYSTEM_NAME Openwrt)
+set(CMAKE_SYSTEM_PROCESSOR mips)
+
+set(CMAKE_C_COMPILER mipsel-openwrt-linux-gcc)
- JERRY_INIT_MEM_STATS_SEPARATE - dump memory statistics and reset peak values after parse
- JERRY_INIT_DEBUGGER - deprecated, an unused placeholder now
+## jerry_type_t
+
+Enum that contains a set of elements to represent JavaScript type:
+
+ - JERRY_TYPE_NONE - no type information
+ - JERRY_TYPE_UNDEFINED - undefined value
+ - JERRY_TYPE_NULL - null value
+ - JERRY_TYPE_BOOLEAN - boolean value
+ - JERRY_TYPE_NUMBER - number value
+ - JERRY_TYPE_STRING - string value
+ - JERRY_TYPE_OBJECT - object value
+ - JERRY_TYPE_FUNCTION - function value
+
## jerry_error_t
Possible types of an error:
- JERRY_ERROR_TYPE - type error
- JERRY_ERROR_URI - URI error
+There is also a special value `JERRY_ERROR_NONE` which is not an error type
+this value can only be returned by the [jerry_get_error_type](#jerry_get_error_type).
+
## jerry_feature_t
Possible compile time enabled feature types:
- JERRY_FEATURE_SNAPSHOT_EXEC - executing snapshot files
- JERRY_FEATURE_DEBUGGER - debugging
- JERRY_FEATURE_VM_EXEC_STOP - stopping ECMAScript execution
+ - JERRY_FEATURE_JSON - JSON support
+ - JERRY_FEATURE_PROMISE - promise support
+ - JERRY_FEATURE_TYPEDARRAY - Typedarray support
+ - JERRY_FEATURE_DATE - Date support
+ - JERRY_FEATURE_REGEXP - RegExp support
+ - JERRY_FEATURE_LINE_INFO - line info available
+
+## jerry_parse_opts_t
+
+Option bits for [jerry_parse](#jerry_parse) and
+[jerry_parse_function](#jerry_parse_function) functions:
+
+ - JERRY_PARSE_NO_OPTS - no options passed
+ - JERRY_PARSE_STRICT_MODE - enable strict mode
+
+## jerry_generate_snapshot_opts_t
+
+Flags for [jerry_generate_snapshot](#jerry_generate_snapshot) and
+[jerry_generate_function_snapshot](#jerry_generate_function_snapshot) functions:
+
+ - JERRY_SNAPSHOT_SAVE_STATIC - generate static snapshot (see below)
+ - JERRY_SNAPSHOT_SAVE_STRICT - strict source code provided
+
+**Generate static snapshots**
+Snapshots contain literal pools, and these literal pools contain references
+to constant literals (strings, numbers, etc.). When a snapshot is executed,
+these literals are converted to jerry values and the literal pool entries
+are changed to their corresponding jerry value. To support this conversion,
+the literals and literal pools are copied into RAM even if the
+`JERRY_SNAPSHOT_EXEC_COPY_DATA` option is passed to
+[jerry_exec_snapshot](#jerry_exec_snapshot). This non-negligible memory
+consumption can be avoided by using static snapshots. The literals of
+these snapshots are limited to magic strings and 28 bit signed integers,
+so their constant pools do not need to be loaded into the memory.
+Hence these snapshots can be executed from ROM.
+
+***Important note:*** The [jerry_exec_snapshot](#jerry_exec_snapshot)
+function rejects static snaphots unless the `JERRY_SNAPSHOT_EXEC_ALLOW_STATIC`
+option bit is set. The caller must also ensure that the same magic
+strings are set by [jerry_register_magic_strings](#jerry_register_magic_strings)
+when the snapshot is generated and executed. Furthermore the
+`JERRY_SNAPSHOT_EXEC_COPY_DATA` option is not allowed.
+
+## jerry_exec_snapshot_opts_t
+
+Flags for [jerry_exec_snapshot](#jerry_exec_snapshot) and
+[jerry_load_function_snapshot](#jerry_load_function_snapshot) functions:
+
+ - JERRY_SNAPSHOT_EXEC_COPY_DATA - copy snapshot data into memory (see below)
+ - JERRY_SNAPSHOT_EXEC_ALLOW_STATIC - allow executing static snapshots
+
+**Copy snapshot data into memory**
+
+By default the snapshot buffer is expected to be present in memory until
+[jerry_cleanup](#jerry_cleanup) is called. For example `static const` buffers
+compiled into the application binary satisfy this requirement.
+
+If the snapshot buffer is freed after [jerry_exec_snapshot](#jerry_exec_snapshot)
+is called the `JERRY_SNAPSHOT_EXEC_COPY_DATA` must be passed to copy the necessary
+parts of the snapshot buffer into memory.
+
+The `JERRY_SNAPSHOT_EXEC_COPY_DATA` option is not allowed for static snapshots.
+
## jerry_char_t
**Summary**
Structure that defines how a context data item will be initialized and deinitialized. JerryScript zeroes out the memory
-for the item by default, and if the `init_cb` field is not NULL, it will be called with the pointer to the memory as
-an additional custom initializer.
+for the item by default, and if the `init_cb` field is not NULL, it will be called with the pointer to the memory as
+an additional custom initializer. The `deinit_cb` (if non-`NULL`) is called during a call to `jerry_cleanup ()` to run
+any custom deinitialization *before* the VM has been fully cleaned up. The `finalize_cb` (if non-`NULL`) is also called
+during a call to `jerry_cleanup ()` to run any custom deinitialization *after* the VM has been fully cleaned up.
**Prototype**
```c
typedef struct
{
- void (*init_cb) (void *); /**< callback responsible for initializing a context item, or NULL */
- void (*deinit_cb) (void *); /**< callback responsible for deinitializing a context item */
- size_t bytes_needed; /**< number of bytes to allocate for this manager */
+ /**
+ * Callback responsible for initializing a context item, or NULL to zero out the memory. This is called lazily, the
+ * first time jerry_get_context_data () is called with this manager.
+ *
+ * @param [in] data The buffer that JerryScript allocated for the manager. The buffer is zeroed out. The size is
+ * determined by the bytes_needed field. The buffer is kept alive until jerry_cleanup () is called.
+ */
+ void (*init_cb) (void *data);
+
+ /**
+ * Callback responsible for deinitializing a context item, or NULL. This is called as part of jerry_cleanup (),
+ * right *before* the VM has been cleaned up. This is a good place to release strong references to jerry_value_t's
+ * that the manager may be holding.
+ * Note: because the VM has not been fully cleaned up yet, jerry_object_native_info_t free_cb's can still get called
+ * *after* all deinit_cb's have been run. See finalize_cb for a callback that is guaranteed to run *after* all
+ * free_cb's have been run.
+ *
+ * @param [in] data The buffer that JerryScript allocated for the manager.
+ */
+ void (*deinit_cb) (void *data);
+
+ /**
+ * Callback responsible for finalizing a context item, or NULL. This is called as part of jerry_cleanup (),
+ * right *after* the VM has been cleaned up and destroyed and jerry_... APIs cannot be called any more. At this point,
+ * all values in the VM have been cleaned up. This is a good place to clean up native state that can only be cleaned
+ * up at the very end when there are no more VM values around that may need to access that state.
+ *
+ * @param [in] data The buffer that JerryScript allocated for the manager. After returning from this callback,
+ * the data pointer may no longer be used.
+ */
+ void (*finalize_cb) (void *data);
+
+ /**
+ * Number of bytes to allocate for this manager. This is the size of the buffer that JerryScript will allocate on
+ * behalf of the manager. The pointer to this buffer is passed into init_cb, deinit_cb and finalize_cb. It is also
+ * returned from the jerry_get_context_data () API.
+ */
+ size_t bytes_needed;
} jerry_context_data_manager_t;
```
void *user_data_p);
```
+## jerry_objects_foreach_t
+
+**Summary**
+
+Function type applied for each object in the engine
+
+**Prototype**
+
+```c
+typedef bool (*jerry_objects_foreach_t) (const jerry_value_t object,
+ void *user_data_p);
+```
+
+## jerry_objects_foreach_by_native_info_t
+
+**Summary**
+
+Function type applied for each matching object in the engine
+
+**Prototype**
+
+```c
+typedef bool (*jerry_objects_foreach_by_native_info_t) (const jerry_value_t object,
+ void *object_data_p,
+ void *user_data_p);
+```
+
## jerry_vm_exec_stop_callback_t
**Summary**
- [jerry_set_vm_exec_stop_callback](#jerry_set_vm_exec_stop_callback)
+## jerry_typedarray_type_t
+
+Enum which describes the TypedArray types.
+Possible values:
+
+ - JERRY_TYPEDARRAY_UINT8 - represents the Uint8Array TypedArray
+ - JERRY_TYPEDARRAY_UINT8CLAMPED - represents the Uint8ClampedArray TypedArray
+ - JERRY_TYPEDARRAY_INT8 - represents the Int8Array TypedArray
+ - JERRY_TYPEDARRAY_UINT16 - represents the Uint16Array TypedArray
+ - JERRY_TYPEDARRAY_INT16 - represents the Int16Array TypedArray
+ - JERRY_TYPEDARRAY_UINT32 - represents the Uint32Array TypedArray
+ - JERRY_TYPEDARRAY_INT32 - represents the Int32Array TypedArray
+ - JERRY_TYPEDARRAY_FLOAT32 - represents the Float32Array TypedArray
+ - JERRY_TYPEDARRAY_FLOAT64 - represents the Float64Array TypedArray
+ - JERRY_TYPEDARRAY_INVALID - represents an invalid TypedArray
+
+API functions can return the `JERRY_TYPEDARRAY_INVALID` value if the
+TypedArray support is not in the engine.
+
+
# General engine functions
## jerry_init
**Summary**
-Parse script and construct an EcmaScript function. The
-lexical environment is set to the global lexical environment.
+Parse script and construct an EcmaScript function. The lexical environment is
+set to the global lexical environment. The resource name can be used by
+debugging systems to provide line / backtrace info.
*Note*: Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
is no longer needed.
```c
jerry_value_t
-jerry_parse (const jerry_char_t *source_p,
+jerry_parse (const jerry_char_t *resource_name_p, /**< resource name (usually a file name) */
+ size_t resource_name_length, /**< length of resource name */
+ const jerry_char_t *source_p,
size_t source_size,
- bool is_strict);
+ uint32_t parse_opts);
```
+- `resource_name_p` - resource name, usually a file name (must be a valid UTF8 string).
+- `resource_name_length` - size of the resource name, in bytes.
- `source_p` - string, containing source code to parse (must be a valid UTF8 string).
- `source_size` - size of the string, in bytes.
-- `is_strict` - defines strict mode.
+- `parse_opts` - any combination of [jerry_parse_opts_t](#jerry_parse_opts_t) flags.
- return value
- function object value, if script was parsed successfully,
- thrown error, otherwise
const jerry_char_t script[] = "print ('Hello, World!');";
size_t script_size = strlen ((const char *) script);
- jerry_value_t parsed_code = jerry_parse (script, script_size, false);
+ jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
jerry_release_value (parsed_code);
jerry_cleanup ();
- [jerry_run](#jerry_run)
-## jerry_parse_named_resource
-
-**Summary**
-
-Parse script and construct an ECMAScript function. The lexical
-environment is set to the global lexical environment. The resource
-name (usually a file name) is also passed to this function which is
-used by the debugger to find the source code.
-
-*Note*: The returned value must be freed with [jerry_release_value](#jerry_release_value) when it
-is no longer needed.
-
-**Prototype**
-
-```c
-jerry_value_t
-jerry_parse_named_resource (const jerry_char_t *resource_name_p, /**< resource name (usually a file name) */
- size_t resource_name_length, /**< length of resource name */
- const jerry_char_t *source_p, /**< script source */
- size_t source_size, /**< script source size */
- bool is_strict) /**< strict mode */
-```
-
-- `resource_name_p` - resource name, usually a file name (must be a valid UTF8 string).
-- `resource_name_length` - size of the resource name, in bytes.
-- `source_p` - string, containing source code to parse (must be a valid UTF8 string).
-- `source_size` - size of the string, in bytes.
-- `is_strict` - defines strict mode.
-- return value
- - function object value, if script was parsed successfully,
- - thrown error, otherwise
-
-This function is identical to [jerry_parse](#jerry_parse), except that an additional filename parameter has been added.
-
## jerry_parse_function
**Summary**
size_t arg_list_size, /**< script source size */
const jerry_char_t *source_p, /**< script source */
size_t source_size, /**< script source size */
- bool is_strict) /**< strict mode */
+ uint32_t parse_opts) /**< strict mode */
```
- `resource_name_p` - resource name, usually a file name (must be a valid UTF8 string).
- `arg_list_size` - size of the argument list, in bytes.
- `source_p` - string, containing source code to parse (must be a valid UTF8 string).
- `source_size` - size of the string, in bytes.
-- `is_strict` - defines strict mode.
+- `parse_opts` - any combination of [jerry_parse_opts_t](#jerry_parse_opts_t) flags.
- return value
- function object value, if script was parsed successfully,
- thrown error, otherwise
jerry_init (JERRY_INIT_EMPTY);
/* Setup Global scope code */
- jerry_value_t parsed_code = jerry_parse (script, script_size, false);
+ jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (parsed_code))
{
const jerry_char_t script[] = "new Promise(function(f,r) { f('Hello, World!'); }).then(function(x) { print(x); });";
size_t script_size = strlen ((const char *) script);
- jerry_value_t parsed_code = jerry_parse (script, script_size, false);
+ jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
jerry_value_t script_value = jerry_run (parsed_code);
jerry_value_t job_value = jerry_run_all_enqueued_jobs ();
- [jerry_release_value](#jerry_release_value)
+## jerry_value_is_arraybuffer
+
+**Summary**
+
+Returns whether the given `jerry_value_t` is an ArrayBuffer object.
+
+**Prototype**
+
+```c
+bool
+jerry_value_is_arraybuffer (const jerry_value_t value)
+```
+
+- `value` - api value
+- return value
+ - true, if the given `jerry_value_t` is an ArrayBuffer object.
+ - false, otherwise
+
+**Example**
+
+```c
+{
+ jerry_value_t value;
+ ... // create or acquire value
+
+ if (jerry_value_is_arraybuffer (value))
+ {
+ ...
+ }
+
+ jerry_release_value (value);
+}
+```
+
+**See also**
+
+- [jerry_create_arraybuffer](#jerry_create_arraybuffer)
+- [jerry_create_arraybuffer_external](#jerry_create_arraybuffer_external)
+
## jerry_value_is_boolean
- [jerry_release_value](#jerry_release_value)
+## jerry_value_is_typedarray
+
+**Summary**
+
+Checks whether the given `jerry_value_t` is a TypedArray object or not.
+
+**Prototype**
+
+```c
+bool
+jerry_value_is_typedarray (const jerry_value_t value)
+```
+
+- `value` - object to check
+- return value
+ - true, if the given `jerry_value_t` is a TypedArray object.
+ - false, otherwise
+
+**Example**
+
+```c
+{
+ jerry_value_t value;
+ ... // create or acquire value
+
+ if (jerry_value_is_typedarray (value))
+ {
+ ...
+ }
+
+ jerry_release_value (value);
+}
+```
+
+**See also**
+
+- [jerry_create_typedarray](#jerry_create_typedarray)
+
+
## jerry_value_is_undefined
**Summary**
- [jerry_release_value](#jerry_release_value)
+## jerry_value_get_type
+
+**Summary**
+
+Returns the JavaScript type
+for a given value as a [jerry_type_t](#jerry_type_t) enum value.
+
+This is a similar operation as the 'typeof' operator
+in the standard with an exception that the 'null'
+value has its own enum value.
+
+**Prototype**
+
+```c
+jerry_type_t
+jerry_value_get_type (const jerry_value_t value);
+```
+
+**Example**
+
+```c
+{
+ jerry_value_t number = jerry_create_number (3.3);
+
+ jerry_type_t type_info = jerry_value_get_type (number);
+
+ if (type_info == JERRY_TYPE_NUMBER)
+ {
+ ...
+ }
+
+ jerry_value_release (number);
+}
+```
+
+**See also**
+- [jerry_type_t](#jerry_type_t)
+
## jerry_is_feature_enabled
**Summary**
}
```
-# Error flag manipulation functions
+# Error manipulation functions
+
+## jerry_get_error_type
+
+**Summary**
+
+Returns the type of the Error object if possible.
+
+If a non-error object is used as the input for the function the method
+will return `JERRY_ERROR_NONE` indicating that the value was not
+an Error object. However it is still possible that the value contains
+error semantics. To correctly detect if a value have error use the
+[jerry_value_has_error_flag](#jerry_value_has_error_flag) method.
+
+**Prototype**
+
+```c
+jerry_error_t
+jerry_get_error_type (const jerry_value_t value);
+```
+
+- `value` - api value (possible error object)
+- return value
+ - JERRY_ERROR_NONE if the input is not an error object
+ - one of the [jerry_error_t](#jerry_error_t) value
+
+**Example**
+
+```c
+{
+ jerry_value_t error_obj = jerry_create_error (JERRY_ERROR_RANGE,
+ (const jerry_char_t *) "error msg");
+ jerry_error_t error_type = jerry_get_error_type (error_obj);
+
+ // error_type is now JERRY_ERROR_RANGE.
+
+ jerry_release_value (error_obj);
+}
+```
+
+**See also**
+
+- [jerry_create_error](#jerry_create_error)
+- [jerry_value_has_error_flag](#jerry_value_has_error_flag)
## jerry_value_has_error_flag
**See also**
- [jerry_value_t](#jerry_value_t)
+- [jerry_value_has_abort_flag](#jerry_value_has_abort_flag)
-## jerry_value_clear_error_flag
+## jerry_value_has_abort_flag
**Summary**
-Clear the error flag.
+Returns whether the given `jerry_value_t` has the error and abort flags set.
**Prototype**
```c
-void
-jerry_value_clear_error_flag (jerry_value_t *value_p);
+bool
+jerry_value_has_abort_flag (const jerry_value_t value);
```
-- `value_p` - pointer to an api value
+- `value` - api value
+- return value
+ - true, if the given `jerry_value_t` has the error and abort flags set
+ - false, otherwise
**Example**
jerry_value_t value;
... // create or acquire value
- jerry_value_clear_error_flag (&value);
+ if (jerry_value_has_abort_flag (value))
+ {
+ ...
+ }
jerry_release_value (value);
}
**See also**
- [jerry_value_t](#jerry_value_t)
+- [jerry_value_has_error_flag](#jerry_value_has_error_flag)
-## jerry_value_set_error_flag
+## jerry_value_clear_error_flag
**Summary**
-Set the error flag.
+Clear both the error and abort flags.
**Prototype**
```c
void
-jerry_value_set_error_flag (jerry_value_t *value_p);
+jerry_value_clear_error_flag (jerry_value_t *value_p);
```
- `value_p` - pointer to an api value
jerry_value_t value;
... // create or acquire value
- jerry_value_set_error_flag (&value);
+ jerry_value_clear_error_flag (&value);
jerry_release_value (value);
}
**See also**
- [jerry_value_t](#jerry_value_t)
+- [jerry_value_set_error_flag](#jerry_value_set_error_flag)
+- [jerry_value_set_abort_flag](#jerry_value_set_abort_flag)
-## jerry_get_value_without_error_flag
+## jerry_value_set_error_flag
**Summary**
-If the input value is an error value, then return a new reference to its referenced value.
-Otherwise, return a new reference to the value itself.
-
-*Note*: Returned value must be freed with [jerry_release_value](#jerry_release_value)
-when it is no longer needed.
+Set the error flag.
**Prototype**
```c
-jerry_value_t
-jerry_get_value_without_error_flag (jerry_value_t value)
+void
+jerry_value_set_error_flag (jerry_value_t *value_p);
```
-- `value` - api value
+- `value_p` - pointer to an api value
**Example**
{
jerry_value_t value;
... // create or acquire value
-
+
jerry_value_set_error_flag (&value);
-
- jerry_value_t real_value = jerry_get_value_without_error_flag (value);
- ... // process the real_value. Different from `jerry_value_clear_error_flag`,
- // the error `value` will not be automatically released after calling
- // `jerry_get_value_without_error_flag`.
jerry_release_value (value);
- jerry_release_value (real_value);
}
```
**See also**
-- [jerry_acquire_value](#jerry_acquire_value)
+- [jerry_value_t](#jerry_value_t)
- [jerry_value_clear_error_flag](#jerry_value_clear_error_flag)
+- [jerry_value_set_abort_flag](#jerry_value_set_abort_flag)
-# Getter functions of 'jerry_value_t'
-
-Get raw data from API values.
-## jerry_get_boolean_value
+## jerry_value_set_abort_flag
**Summary**
-Gets the raw bool value from a `jerry_value_t`.
+Set both the error and abort flags.
**Prototype**
```c
-bool
-jerry_get_boolean_value (const jerry_value_t value);
+void
+jerry_value_set_abort_flag (jerry_value_t *value_p);
```
-- `value` - api value
-- return value - boolean value represented by the argument.
+- `value_p` - pointer to an api value
**Example**
jerry_value_t value;
... // create or acquire value
- if (jerry_value_is_boolean (value))
- {
- bool raw_value = jerry_get_boolean_value (value);
-
- ... // usage of raw value
-
- }
+ jerry_value_set_abort_flag (&value);
jerry_release_value (value);
}
-
```
**See also**
-- [jerry_value_is_boolean](#jerry_value_is_boolean)
-- [jerry_release_value](#jerry_release_value)
+- [jerry_value_t](#jerry_value_t)
+- [jerry_value_clear_error_flag](#jerry_value_clear_error_flag)
+- [jerry_value_set_error_flag](#jerry_value_set_error_flag)
-## jerry_get_number_value
+## jerry_get_value_without_error_flag
**Summary**
-Gets the number value of the given `jerry_value_t` parameter as a raw double.
+If the input value is an error value, then return a new reference to its referenced value.
+Otherwise, return a new reference to the value itself.
+
+*Note*: Returned value must be freed with [jerry_release_value](#jerry_release_value)
+when it is no longer needed.
+
+**Prototype**
+
+```c
+jerry_value_t
+jerry_get_value_without_error_flag (jerry_value_t value)
+```
+
+- `value` - api value
+
+**Example**
+
+```c
+{
+ jerry_value_t value;
+ ... // create or acquire value
+
+ jerry_value_set_error_flag (&value);
+
+ jerry_value_t real_value = jerry_get_value_without_error_flag (value);
+ ... // process the real_value. Different from `jerry_value_clear_error_flag`,
+ // the error `value` will not be automatically released after calling
+ // `jerry_get_value_without_error_flag`.
+
+ jerry_release_value (value);
+ jerry_release_value (real_value);
+}
+```
+
+**See also**
+
+- [jerry_acquire_value](#jerry_acquire_value)
+- [jerry_value_clear_error_flag](#jerry_value_clear_error_flag)
+
+# Getter functions of 'jerry_value_t'
+
+Get raw data from API values.
+
+## jerry_get_boolean_value
+
+**Summary**
+
+Gets the raw bool value from a `jerry_value_t`.
+
+**Prototype**
+
+```c
+bool
+jerry_get_boolean_value (const jerry_value_t value);
+```
+
+- `value` - api value
+- return value - boolean value represented by the argument.
+
+**Example**
+
+```c
+{
+ jerry_value_t value;
+ ... // create or acquire value
+
+ if (jerry_value_is_boolean (value))
+ {
+ bool raw_value = jerry_get_boolean_value (value);
+
+ ... // usage of raw value
+
+ }
+
+ jerry_release_value (value);
+}
+
+```
+
+**See also**
+
+- [jerry_value_is_boolean](#jerry_value_is_boolean)
+- [jerry_release_value](#jerry_release_value)
+
+
+## jerry_get_number_value
+
+**Summary**
+
+Gets the number value of the given `jerry_value_t` parameter as a raw double.
**Prototype**
*Note*: Does not put '\0' to the end of string, the return value identifies
the number of valid bytes in the output buffer.
+*Note*: If the size of the string in jerry value is larger than the size of the
+target buffer, the copy will fail. To copy a substring the
+[jerry_substring_to_char_buffer](#jerry_substring_to_char_buffer) API function
+is recommended instead.
+
+
**Prototype**
```c
- [jerry_create_string](#jerry_create_string)
- [jerry_get_string_size](#jerry_get_string_size)
- [jerry_is_valid_cesu8_string](#jerry_is_valid_cesu8_string)
+- [jerry_substring_to_char_buffer](#jerry_substring_to_char_buffer)
## jerry_string_to_utf8_char_buffer
*Note*: Does not put '\0' to the end of string, the return value identifies
the number of valid bytes in the output buffer.
+*Note*: If the size of the string in jerry value is larger than the size of the
+target buffer, the copy will fail. To copy a substring the
+[jerry_substring_to_utf8_char_buffer](#jerry_substring_to_utf8_char_buffer)
+API function is recommended instead.
+
**Prototype**
```c
- [jerry_create_string_from_utf8](#jerry_create_string_from_utf8)
- [jerry_get_utf8_string_size](#jerry_get_utf8_string_size)
- [jerry_is_valid_utf8_string](#jerry_is_valid_utf8_string)
+- [jerry_substring_to_utf8_char_buffer](#jerry_substring_to_utf8_char_buffer)
## jerry_substring_to_char_buffer
- [jerry_get_property_by_index](#jerry_get_property_by_index)
+## jerry_create_arraybuffer
+
+**Summary**
+
+Create a jerry_value_t representing an ArrayBuffer object.
+
+**Prototype**
+
+```c
+jerry_value_t
+jerry_create_arraybuffer (jerry_length_t size);
+```
+
+ - `size` - size of the ArrayBuffer to create **in bytes**
+ - return value - the new ArrayBuffer as a `jerry_value_t`
+
+**Example**
+
+```c
+{
+ jerry_value_t buffer_value = jerry_create_arraybuffer (15);
+
+ ... // use the ArrayBuffer
+
+ jerry_release_value (buffer_value);
+}
+```
+
+**See also**
+
+- [jerry_arraybuffer_read](#jerry_arraybuffer_read)
+- [jerry_arraybuffer_write](#jerry_arraybuffer_write)
+- [jerry_value_is_arraybuffer](#jerry_value_is_arraybuffer)
+- [jerry_release_value](#jerry_release_value)
+
+
+## jerry_create_arraybuffer_external
+
+**Summary**
+
+Creates a jerry_value_t representing an ArrayBuffer object with
+user specified back-buffer.
+
+User must pass a buffer pointer which is at least `size` big.
+After the object is not needed the GC will call the `free_cb`
+so the user can release the buffer which was provided.
+
+**Prototype**
+
+```c
+jerry_value_t
+jerry_create_arraybuffer_external (const jerry_length_t size
+ uint8_t *buffer_p,
+ jerry_object_native_free_callback_t free_cb);
+```
+
+- `size` - size of the buffer to use **in bytes** (should not be 0)
+- `buffer_p` - the buffer used for the Array Buffer object (should not be a null pointer)
+- `free_cb` - the callback function called when the object is released
+- return value
+ - the new ArrayBuffer as a `jerry_value_t`
+ - if the `size` is zero or `buffer_p` is a null pointer will return RangeError
+
+**Example**
+
+```c
+{
+ uint8_t buffer_p[15];
+ jerry_value_t buffer_value = jerry_create_arraybuffer_external (15, buffer_p, NULL);
+
+ ... // use the array buffer
+
+ jerry_release_value (buffer_value);
+}
+```
+
+**See also**
+
+- [jerry_get_arraybuffer_pointer](#jerry_get_arraybuffer_pointer)
+- [jerry_arraybuffer_read](#jerry_arraybuffer_read)
+- [jerry_arraybuffer_write](#jerry_arraybuffer_write)
+- [jerry_value_is_arraybuffer](#jerry_value_is_arraybuffer)
+- [jerry_release_value](#jerry_release_value)
+- [jerry_object_native_free_callback_t](#jerry_object_native_free_callback_t)
+
+
## jerry_create_boolean
**Summary**
Create new JavaScript error object.
+Important! The `error_type` argument *must not be*
+`JERRY_ERROR_NONE`.
+Creating an error with no error type is not valid.
+
+
**Prototype**
```c
- [jerry_create_string_from_utf8](#jerry_create_string_from_utf8)
+## jerry_create_typedarray
+
+**Summary**
+
+Create a jerry_value_t representing an TypedArray object.
+
+For the new object the type of the TypedArray (see: [jerry_typedarray_type_t](#jerry_typedarray_type_t))
+and element count can be specified.
+
+**Prototype**
+
+```c
+jerry_value_t
+jerry_create_typedarray (jerry_typedarray_type_t type_name, jerry_length_t item_count);
+```
+
+- `type_name` - type of TypedArray to create
+- `item_count` - number of items in the new TypedArray
+- return value - the new TypedArray as a `jerry_value_t`
+
+**Example**
+
+```c
+{
+ jerry_value_t array = jerry_create_typedarray (JERRY_TYPEDARRAY_UINT16, 15);
+
+ ... // use the TypedArray
+
+ jerry_release_value (array);
+}
+```
+
+**See also**
+
+- [jerry_typedarray_type_t](#jerry_typedarray_type_t)
+- [jerry_value_is_typedarray](#jerry_value_is_typedarray)
+- [jerry_release_value](#jerry_release_value)
+
+
+## jerry_create_typedarray_for_arraybuffer
+
+**Summary**
+
+Create a jerry_value_t representing an TypedArray object using
+an already existing ArrayBuffer object.
+
+For the new object the type of the TypedArray (see: [jerry_typedarray_type_t](#jerry_typedarray_type_t))
+and element count can be specified.
+
+The developer must ensure that the ArrayBuffer has the correct length for the given
+type of TypedArray otherwise an error is generated.
+
+The JavaScript equivalent of this function is: `new %TypedArray%(arraybuffer)` where `%TypedArray%` is
+one of the allowed TypedArray functions.
+
+**Prototype**
+
+```c
+jerry_value_t
+jerry_create_typedarray_for_arraybuffer (jerry_typedarray_type_t type_name,
+ const jerry_value_t arraybuffer);
+```
+
+- `type_name` - type of TypedArray to create
+- `arraybuffer` - the ArrayBuffer to use for the new TypedArray
+- return value
+ - the new TypedArray as a `jerry_value_t`
+ - Error if the ArrayBuffer does not have enough space for the given type of TypedArray
+
+**Example**
+
+```c
+{
+ jerry_value_t buffer = jerry_create_array_buffer (12 * 2);
+ jerry_value_t array = jerry_create_typedarray_for_arraybuffer (JERRY_TYPEDARRAY_UINT16, buffer);
+ jerry_release_value (buffer);
+
+ ... // use the TypedArray
+
+ jerry_release_value (array);
+}
+```
+
+**See also**
+
+- [jerry_typedarray_type_t](#jerry_typedarray_type_t)
+- [jerry_value_is_typedarray](#jerry_value_is_typedarray)
+- [jerry_release_value](#jerry_release_value)
+
+
+## jerry_create_typedarray_for_arraybuffer_sz
+
+**Summary**
+
+Create a jerry_value_t representing an TypedArray object using
+an already existing ArrayBuffer object and by specifying the byteOffset, and length properties.
+
+For the new object the type of the TypedArray (see: [jerry_typedarray_type_t](#jerry_typedarray_type_t))
+and element count can be specified.
+
+The developer must ensure that the ArrayBuffer has the correct length for the given
+type of TypedArray otherwise an error is generated.
+
+The JavaScript equivalent of this function is: `new %TypedArray%(arraybuffer, byteOffset, length)` where `%TypedArray%` is
+one of the allowed TypedArray functions.
+
+**Prototype**
+
+```c
+jerry_value_t
+jerry_create_typedarray_for_arraybuffer_sz (jerry_typedarray_type_t type_name,
+ const jerry_value_t arraybuffer,
+ jerry_length_t byte_offset,
+ jerry_length_t length);
+```
+
+- `type_name` - type of TypedArray to create
+- `arraybuffer` - the ArrayBuffer to use for the new TypedArray
+- `byte_offset` - start offset to use for the ArrayBuffer
+- `length` - number of elements to used from the ArrayBuffer (this is not the same as the byteLength)
+- return value
+ - the new TypedArray as a `jerry_value_t`
+ - Error if the ArrayBuffer does not have enough space for the given type of TypedArray
+
+**Example**
+
+```c
+{
+ jerry_value_t buffer = jerry_create_array_buffer (12 * 2);
+ jerry_value_t array = jerry_create_typedarray_for_arraybuffer_sz (JERRY_TYPEDARRAY_UINT16, buffer, 4, 10);
+ jerry_release_value (buffer);
+
+ ... // use the TypedArray
+
+ jerry_release_value (array);
+}
+```
+
+**See also**
+
+- [jerry_typedarray_type_t](#jerry_typedarray_type_t)
+- [jerry_value_is_typedarray](#jerry_value_is_typedarray)
+- [jerry_release_value](#jerry_release_value)
+
+
## jerry_create_undefined
**Summary**
- [jerry_object_property_foreach_t](#jerry_object_property_foreach_t)
-
-# Input validator functions
-
-## jerry_is_valid_utf8_string
+## jerry_objects_foreach
**Summary**
-Validate UTF-8 string.
+Iterate over objects.
+
+*Note*: Values obtained in `foreach_p` must be retained using [jerry_acquire_value](#jerry_acquire_value).
**Prototype**
```c
-bool
-jerry_is_valid_utf8_string (const jerry_char_t *utf8_buf_p, /**< UTF-8 string */
- jerry_size_t buf_size) /**< string size */
+bool jerry_objects_foreach (jerry_objects_foreach_t foreach_p,
+ void *user_data_p);
```
-- `utf8_buf_p` - UTF-8 input string
-- `buf_size` - input string size
+- `foreach_p` - function that will be invoked for each object.
+- `user_data_p` - User data to pass to the function.
+- return value
+ - `true`, if the search function terminated the traversal by returning `false`
+ - `false`, if the end of the list of objects was reached
**Example**
-[doctest]: # ()
-
```c
-#include <string.h>
-#include "jerryscript.h"
-
-int
-main (void)
+typedef struct
{
- const jerry_char_t script[] = "print ('Hello, World!');";
- size_t script_size = strlen ((const char *) script);
+ jerry_value_t property_name;
+ jerry_value_t result;
+} find_my_object_info_t;
- if (jerry_is_valid_utf8_string (script, (jerry_size_t) script_size))
+/*
+ * Find the first object with the given property.
+ */
+static bool
+find_my_object(const jerry_value_t candidate,
+ void *user_data_p)
+{
+ find_my_object_info_t *info_p = (find_my_object_info_t *) user_data_p;
+ jerry_value_t has_property = jerry_object_has_property (candidate, info_p->property_name);
+ bool keep_searching = (jerry_value_has_error_flag (has_property) || !jerry_get_boolean_value ());
+ if (!keep_searching)
{
- jerry_run_simple (script, script_size, JERRY_INIT_EMPTY);
+ /* We found it, so we acquire the value and record it. */
+ info_p->result = jerry_acquire_value (candidate);
}
-}
+ jerry_release_value (has_property);
+ return keep_searching;
+} /* find_my_object */
+
+{
+ find_my_object_info_t search_info =
+ {
+ .property_name = jerry_create_string ("desired_property")
+ };
+
+ if (jerry_object_foreach (find_my_object, &search_info))
+ {
+ /* The search was successful. Do something useful with search_info.result. */
+ ...
+
+ /* Release the found object after we're done using it. */
+ jerry_release_value (search_info.result);
+ }
+ else
+ {
+ /* The search has failed. */
+ }
+
+ jerry_release_value (search_info.desired_property);
+}
+```
+**See also**
+
+- [jerry_objects_foreach_t](#jerry_objects_foreach_t)
+
+## jerry_objects_foreach_by_native_info
+
+**Summary**
+
+Iterate over objects matching a certain native data type.
+
+*Note*: Values obtained in `foreach_p` must be retained using [jerry_acquire_value](#jerry_acquire_value).
+
+**Prototype**
+
+```c
+bool jerry_objects_foreach_by_native_info (const jerry_object_native_info_t *native_info_p,
+ jerry_objects_foreach_by_native_info_t foreach_p,
+ void *user_data_p);
+```
+
+- `native_info_p` - native pointer's type infomation.
+- return value
+ - `true`, if the search function terminated the traversal by returning `false`
+ - `false`, if the end of the list of objects was reached
+
+**Example**
+
+```c
+typedef struct
+{
+ int foo;
+ bool bar;
+} native_obj_t;
+
+typedef struct
+{
+ jerry_value_t found_object;
+ void *match_data_p;
+} find_object_data_t;
+
+static void native_freecb (void *native_p)
+{
+ ... // free the native pointer
+} /* native_freecb */
+
+// NOTE: The address (!) of type_info acts as a way to uniquely "identify" the
+// C type `native_obj_t *`.
+static const jerry_object_native_info_t native_obj_type_info =
+{
+ .free_cb = native_freecb
+};
+
+// Function creating JS object that is "backed" by a native_obj_t *:
+{
+ ...
+
+ // construct object and native_set value:
+ jerry_value_t object = ...;
+ native_obj_t *native_obj_p = malloc (sizeof (*native_obj_p));
+ jerry_set_object_native_pointer (object, native_obj_p, &native_obj_type_info);
+
+ ...
+}
+
+// Native method that retrieves the JavaScript object by way of its native data:
+static bool find_object (const jerry_value_t candidate, void *data_p, void *user_data_p)
+{
+ find_object_data_t *find_data_p = (find_object_data_t *) user_data_p;
+
+ if (find_data_p->match_data_p == data_p)
+ {
+ // If the object was found, acquire it and store it in the user data.
+ find_data_p->found_object = jerry_acquire_value (candidate);
+
+ // Stop traversing over the objects.
+ return false;
+ }
+
+ // Indicate that the object was not found, so traversal must continue.
+ return true;
+} /* find_object */
+...
+{
+ find_object_data_t find_data =
+ {
+ .match_data = native_obj
+ };
+
+ if (jerry_objects_foreach_by_native_info (&native_obj_type_info, find_object, &find_data))
+ {
+ // The object was found and is now stored in find_data.found_object. After using it, it must be released.
+ ...
+ jerry_release_value (find_data.found_object);
+ }
+ else
+ {
+ // The object was not found.
+ }
+ ...
+}
+```
+
+**See also**
+
+- [jerry_create_object](#jerry_create_object)
+- [jerry_set_object_native_pointer](#jerry_set_object_native_pointer)
+- [jerry_get_object_native_pointer](#jerry_get_object_native_pointer)
+- [jerry_object_native_info_t](#jerry_object_native_info_t)
+- [jerry_objects_foreach](#jerry_objects_foreach)
+
+
+# Input validator functions
+
+## jerry_is_valid_utf8_string
+
+**Summary**
+
+Validate UTF-8 string.
+
+**Prototype**
+
+```c
+bool
+jerry_is_valid_utf8_string (const jerry_char_t *utf8_buf_p, /**< UTF-8 string */
+ jerry_size_t buf_size) /**< string size */
+```
+
+- `utf8_buf_p` - UTF-8 input string
+- `buf_size` - input string size
+
+**Example**
+
+[doctest]: # ()
+
+```c
+#include <string.h>
+#include "jerryscript.h"
+
+int
+main (void)
+{
+ const jerry_char_t script[] = "print ('Hello, World!');";
+ size_t script_size = strlen ((const char *) script);
+
+ if (jerry_is_valid_utf8_string (script, (jerry_size_t) script_size))
+ {
+ jerry_run_simple (script, script_size, JERRY_INIT_EMPTY);
+ }
+}
```
**See also**
# Snapshot functions
-## jerry_parse_and_save_snapshot
+## jerry_generate_snapshot
**Summary**
**Prototype**
```c
-size_t
-jerry_parse_and_save_snapshot (const jerry_char_t *source_p,
- size_t source_size,
- bool is_for_global,
- bool is_strict,
- uint32_t *buffer_p,
- size_t buffer_size);
+jerry_value_t
+jerry_generate_snapshot (const jerry_char_t *resource_name_p,
+ size_t resource_name_length,
+ const jerry_char_t *source_p,
+ size_t source_size,
+ uint32_t generate_snapshot_opts,
+ uint32_t *buffer_p,
+ size_t buffer_size);
```
+- `resource_name_p` - resource (file) name of the source code. Currently unused, the debugger may use it in the future.
+- `resource_name_length` - length of resource name.
- `source_p` - script source, it must be a valid utf8 string.
- `source_size` - script source size, in bytes.
-- `is_for_global` - snapshot would be executed as global (true) or eval (false).
-- `is_strict` - strict mode
+- `generate_snapshot_opts` - any combination of [jerry_generate_snapshot_opts_t](#jerry_generate_snapshot_opts_t) flags.
- `buffer_p` - buffer to save snapshot to.
- `buffer_size` - the buffer's size.
- return value
- - the size of snapshot, if it was generated succesfully (i.e. there are no syntax errors in source
- code, buffer size is sufficient, and snapshot support is enabled in current configuration through
- JERRY_ENABLE_SNAPSHOT_SAVE)
- - 0 otherwise.
+ - the size of the snapshot as a number value, if it was generated succesfully (i.e. there are no syntax
+ errors in source code, buffer size is sufficient, and snapshot support is enabled in current configuration
+ through JERRY_ENABLE_SNAPSHOT_SAVE)
+ - thrown error, otherwise.
**Example**
static uint32_t global_mode_snapshot_buffer[256];
const jerry_char_t *code_to_snapshot_p = (const jerry_char_t *) "(function () { return 'string from snapshot'; }) ();";
- size_t global_mode_snapshot_size = jerry_parse_and_save_snapshot (code_to_snapshot_p,
- strlen ((const char *) code_to_snapshot_p),
- true,
- false,
- global_mode_snapshot_buffer,
- sizeof (global_mode_snapshot_buffer) / sizeof (uint32_t));
+ jerry_value_t generate_result;
+ generate_result = jerry_generate_snapshot (NULL,
+ 0,
+ code_to_snapshot_p,
+ strlen ((const char *) code_to_snapshot_p),
+ 0,
+ global_mode_snapshot_buffer,
+ sizeof (global_mode_snapshot_buffer) / sizeof (uint32_t));
+
+ size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
+ jerry_release_value (generate_result);
jerry_cleanup ();
}
- [jerry_init](#jerry_init)
- [jerry_cleanup](#jerry_cleanup)
+- [jerry_generate_function_snapshot](#jerry_generate_function_snapshot)
- [jerry_exec_snapshot](#jerry_exec_snapshot)
-## jerry_parse_and_save_function_snapshot
+## jerry_generate_function_snapshot
**Summary**
**Prototype**
```c
-size_t
-jerry_parse_and_save_function_snapshot (const jerry_char_t *source_p,
- size_t source_size,
- const jerry_char_t *args_p,
- size_t args_size,
- bool is_strict,
- uint32_t *buffer_p,
- size_t buffer_size)
-```
-
+jerry_value_t
+jerry_generate_function_snapshot (const jerry_char_t *resource_name_p,
+ size_t resource_name_length,
+ const jerry_char_t *source_p,
+ size_t source_size,
+ const jerry_char_t *args_p,
+ size_t args_size,
+ uint32_t generate_snapshot_opts,
+ uint32_t *buffer_p,
+ size_t buffer_size)
+```
+
+- `resource_name_p` - resource (file) name of the source code. Currently unused, the debugger may use it in the future.
+- `resource_name_length` - length of resource name.
- `source_p` - script source, it must be a valid utf8 string.
- `source_size` - script source size, in bytes.
- `args_p` - function arguments, it must be a valid utf8 string.
- `args_size` - function argument size, in bytes.
-- `is_strict` - strict mode
+- `generate_snapshot_opts` - any combination of [jerry_generate_snapshot_opts_t](#jerry_generate_snapshot_opts_t) flags.
- `buffer_p` - buffer to save snapshot to.
- `buffer_size` - the buffer's size.
- return value
- - the size of snapshot, if it was generated succesfully (i.e. there are no syntax errors in source
- code, buffer size is sufficient, and snapshot support is enabled in current configuration through
- JERRY_ENABLE_SNAPSHOT_SAVE)
- - 0 otherwise.
+ - the size of the snapshot as a number value, if it was generated succesfully (i.e. there are no syntax
+ errors in source code, buffer size is sufficient, and snapshot support is enabled in current configuration
+ through JERRY_ENABLE_SNAPSHOT_SAVE)
+ - thrown error, otherwise.
**Example**
const jerry_char_t *args_p = (const jerry_char_t *) "a, b";
const jerry_char_t *src_p = (const jerry_char_t *) "return a + b;";
- size_t func_snapshot_size = jerry_parse_and_save_function_snapshot (src_p,
- strlen ((const char *) src_p),
- args_p,
- strlen ((const char *) args_p),
- false,
- func_snapshot_buffer,
- sizeof (func_snapshot_buffer) / sizeof (uint32_t));
+ jerry_value_t generate_result;
+ generate_result = jerry_generate_function_snapshot (NULL,
+ 0,
+ src_p,
+ strlen ((const char *) src_p),
+ args_p,
+ strlen ((const char *) args_p),
+ 0,
+ func_snapshot_buffer,
+ sizeof (func_snapshot_buffer) / sizeof (uint32_t));
+
+ size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
+ jerry_release_value (generate_result);
jerry_cleanup ();
}
- [jerry_init](#jerry_init)
- [jerry_cleanup](#jerry_cleanup)
+- [jerry_generate_snapshot](#jerry_generate_snapshot)
- [jerry_load_function_snapshot_at](#jerry_load_function_snapshot_at)
jerry_value_t
jerry_exec_snapshot (const uint32_t *snapshot_p,
size_t snapshot_size,
- bool copy_bytecode);
+ size_t func_index,
+ uint32_t exec_snapshot_opts);
```
- `snapshot_p` - pointer to snapshot
- `snapshot_size` - size of snapshot
-- `copy_bytecode` - flag, indicating whether the passed snapshot buffer should be copied to the
- engine's memory. If set the engine should not reference the buffer after the function returns
- (in this case, the passed buffer could be freed after the call). Otherwise (if the flag is not
- set) - the buffer could only be freed after the engine stops (i.e. after call to jerry_cleanup).
+- `func_index` - index of executed function
+- `exec_snapshot_opts` - any combination of [jerry_exec_snapshot_opts_t](#jerry_exec_snapshot_opts_t) flags.
- return value
- result of bytecode, if run was successful
- thrown error, otherwise
const jerry_char_t *code_to_snapshot_p = (const jerry_char_t *) "(function () { return 'string from snapshot'; }) ();";
jerry_init (JERRY_INIT_EMPTY);
- size_t global_mode_snapshot_size = jerry_parse_and_save_snapshot (code_to_snapshot_p,
- strlen ((const char *) code_to_snapshot_p),
- true,
- false,
- global_mode_snapshot_buffer,
- sizeof (global_mode_snapshot_buffer) / sizeof (uint32_t));
- jerry_cleanup ();
-
- jerry_init (JERRY_INIT_EMPTY);
-
- jerry_value_t res = jerry_exec_snapshot (global_mode_snapshot_buffer,
- global_mode_snapshot_size,
- false);
- jerry_release_value (res);
-
- jerry_cleanup ();
-}
-```
-
-**See also**
-
-- [jerry_init](#jerry_init)
-- [jerry_cleanup](#jerry_cleanup)
-- [jerry_exec_snapshot_at](#jerry_exec_snapshot_at)
-- [jerry_parse_and_save_snapshot](#jerry_parse_and_save_snapshot)
-
-
-## jerry_exec_snapshot_at
-
-**Summary**
-
-Execute the selected snapshot function from the specified buffer.
-
-Same function as [jerry_exec_snapshot](#jerry_exec_snapshot) except
-the executed function index can be specified.
-
-*Note*: Returned value must be freed with [jerry_release_value](#jerry_release_value) when it
-is no longer needed.
-
-**Prototype**
-
-```c
-jerry_value_t
-jerry_exec_snapshot_at (const uint32_t *snapshot_p,
- size_t snapshot_size,
- size_t func_index,
- bool copy_bytecode);
-```
-
-- `snapshot_p` - pointer to snapshot
-- `snapshot_size` - size of snapshot
-- `func_index` - index of executed function
-- `copy_bytecode` - flag, indicating whether the passed snapshot buffer should be copied to the
- engine's memory. If set the engine should not reference the buffer after the function returns
- (in this case, the passed buffer could be freed after the call). Otherwise (if the flag is not
- set) - the buffer could only be freed after the engine stops (i.e. after call to jerry_cleanup).
-- return value
- - result of bytecode, if run was successful
- - thrown error, otherwise
-
-**Example**
-
-[doctest]: # ()
-```c
-#include <string.h>
-#include "jerryscript.h"
+ jerry_value_t generate_result;
+ generate_result = jerry_generate_snapshot (NULL,
+ 0,
+ code_to_snapshot_p,
+ strlen ((const char *) code_to_snapshot_p),
+ 0,
+ global_mode_snapshot_buffer,
+ sizeof (global_mode_snapshot_buffer) / sizeof (uint32_t));
-int
-main (void)
-{
- static uint32_t global_mode_snapshot_buffer[256];
- const jerry_char_t *code_to_snapshot_p = (const jerry_char_t *) "(function () { return 'string from snapshot'; }) ();";
+ size_t global_mode_snapshot_size = (size_t) jerry_get_number_value (generate_result);
+ jerry_release_value (generate_result);
- jerry_init (JERRY_INIT_EMPTY);
- size_t global_mode_snapshot_size = jerry_parse_and_save_snapshot (code_to_snapshot_p,
- strlen ((const char *) code_to_snapshot_p),
- true,
- false,
- global_mode_snapshot_buffer,
- sizeof (global_mode_snapshot_buffer) / sizeof (uint32_t));
jerry_cleanup ();
jerry_init (JERRY_INIT_EMPTY);
- jerry_value_t res = jerry_exec_snapshot_at (global_mode_snapshot_buffer,
- global_mode_snapshot_size,
- 0,
- false);
-
+ jerry_value_t res = jerry_exec_snapshot (global_mode_snapshot_buffer,
+ global_mode_snapshot_size,
+ 0,
+ 0);
jerry_release_value (res);
jerry_cleanup ();
- return 0;
}
```
- [jerry_init](#jerry_init)
- [jerry_cleanup](#jerry_cleanup)
-- [jerry_exec_snapshot](#jerry_exec_snapshot)
- [jerry_parse_and_save_snapshot](#jerry_parse_and_save_snapshot)
-## jerry_load_function_snapshot_at
+## jerry_load_function_snapshot
**Summary**
```c
jerry_value_t
-jerry_load_function_snapshot_at (const uint32_t *snapshot_p,
- size_t snapshot_size,
- size_t func_index,
- bool copy_bytecode);
+jerry_load_function_snapshot (const uint32_t *snapshot_p,
+ size_t snapshot_size,
+ size_t func_index,
+ uint32_t exec_snapshot_opts);
```
- `snapshot_p` - pointer to snapshot
- `snapshot_size` - size of snapshot
- `func_index` - index of function to load
-- `copy_bytecode` - flag, indicating whether the passed snapshot buffer should be copied to the
- engine's memory. If set the engine should not reference the buffer after the function returns
- (in this case, the passed buffer could be freed after the call). Otherwise (if the flag is not
- set) - the buffer could only be freed after the engine stops (i.e. after call to jerry_cleanup).
+- `exec_snapshot_opts` - any combination of [jerry_exec_snapshot_opts_t](#jerry_exec_snapshot_opts_t) flags.
- return value
- function object built from the snapshot
- thrown error, otherwise
const jerry_char_t *src_p = (const jerry_char_t *) "return a + b;";
jerry_init (JERRY_INIT_EMPTY);
- size_t snapshot_size = jerry_parse_and_save_function_snapshot (src_p,
- strlen ((const char *) src_p),
- args_p,
- strlen ((const char *) args_p),
- false,
- snapshot_buffer,
- sizeof (snapshot_buffer) / sizeof (uint32_t));
+
+ jerry_value_t generate_result;
+ generate_result = jerry_generate_function_snapshot (NULL,
+ 0,
+ src_p,
+ strlen ((const char *) src_p),
+ args_p,
+ strlen ((const char *) args_p),
+ false,
+ snapshot_buffer,
+ sizeof (snapshot_buffer) / sizeof (uint32_t));
+
+ size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
+ jerry_release_value (generate_result);
+
jerry_cleanup ();
jerry_init (JERRY_INIT_EMPTY);
- jerry_value_t func = jerry_load_function_snapshot_at (snapshot_buffer,
- snapshot_size,
- 0,
- false);
+ jerry_value_t func = jerry_load_function_snapshot (snapshot_buffer,
+ snapshot_size,
+ 0,
+ 0);
/* 'func' can be used now as a function object */
jerry_value_t this_value = jerry_create_undefined ();
// Inifinte loop.
const char *src_p = "while(true) {}";
- jerry_value_t src = jerry_parse ((jerry_char_t *) src_p, strlen (src_p), false);
+ jerry_value_t src = jerry_parse (NULL, 0, (jerry_char_t *) src_p, strlen (src_p), JERRY_PARSE_NO_OPTS);
jerry_release_value (jerry_run (src));
jerry_release_value (src);
jerry_cleanup ();
- [jerry_parse](#jerry_parse)
- [jerry_run](#jerry_run)
- [jerry_vm_exec_stop_callback_t](#jerry_vm_exec_stop_callback_t)
+
+## jerry_get_backtrace
+
+**Summary**
+
+Get backtrace. The backtrace is an array of strings where
+each string contains the position of the corresponding frame.
+The array length is zero if the backtrace is not available.
+
+This function is typically called from native callbacks.
+
+**Prototype**
+
+```c
+jerry_value_t
+jerry_get_backtrace (uint32_t max_depth);
+```
+
+- `max_depth` - backtrace collection stops after reaching this value, 0 = unlimited
+- return value
+ - a new array
+
+**See also**
+
+- [jerry_create_external_function](#jerry_create_external_function)
+
+
+# ArrayBuffer and TypedArray functions
+
+## jerry_get_arraybuffer_byte_length
+
+**Summary**
+
+Get the byte length property of the ArrayBuffer. This is the
+same value which was passed to the ArrayBuffer constructor call.
+
+**Prototype**
+
+```c
+jerry_length_t
+jerry_get_arraybuffer_byte_length (const jerry_value_t value);
+```
+
+- `value` - ArrayBuffer object
+- return value
+ - size of the ArrayBuffer in bytes
+ - 0 if the `value` parameter is not an ArrayBuffer
+
+**Example**
+
+```c
+{
+ jerry_value_t buffer = jerry_create_arraybuffer (15);
+ jerry_length_t length = jerry_get_arraybuffer_byte_length (buffer);
+ // length should be 15
+
+ jerry_release_value (buffer);
+}
+```
+
+**See also**
+- [jerry_create_arraybuffer](#jerry_create_arraybuffer)
+
+
+## jerry_arraybuffer_read
+
+**Summary**
+
+Copy the portion of the ArrayBuffer into a user provided buffer.
+The start offset of the read operation can be specified.
+
+The number bytes to be read can be specified via the `buf_size`
+parameter. It is not possible to read more than the length of
+the ArrayBuffer.
+
+Function returns the number of bytes read from the ArrayBuffer
+(and written to the buffer parameter). This value is
+calculated in the following way: `min(array buffer length - offset, buf_size)`.
+
+**Prototype**
+
+```c
+jerry_length_t
+jerry_arraybuffer_read (const jerry_value_t value,
+ jerry_length_t offset,
+ uint8_t *buf_p,
+ jerry_length_t buf_size);
+```
+
+- `value` - ArrayBuffer to read from
+- `offset` - start offset of the read operation
+- `buf_p` - buffer to read the data to
+- `buf_size` - maximum number of bytes to read into the buffer
+- return value
+ - number of bytes written into the buffer (read from the ArrayBuffer)
+ - 0 if the `value` is not an ArrayBuffer object
+ - 0 if the `buf_size` is zero or there is nothing to read
+
+**Example**
+
+```c
+{
+ uint8_t data[20];
+ jerry_value_t buffer;
+ // ... create the ArrayBuffer or acuiqre it from somewhere.
+
+ jerry_value_t bytes_read;
+
+ // read 10 bytes from the start of the ArrayBuffer.
+ bytes_read = jerry_arraybuffer_read (buffer, 0, data, 10);
+ // read the next 10 bytes
+ bytes_read += jerry_arraybuffer_read (buffer, bytes_read, data + bytes_read, 10);
+
+ // process the data variable
+
+ jerry_release_value (buffer);
+}
+```
+
+**See also**
+
+- [jerry_create_arraybuffer](#jerry_create_arraybuffer)
+- [jerry_arraybuffer_write](#jerry_arraybuffer_write)
+- [jerry_get_arraybuffer_byte_length](#jerry_get_arraybuffer_byte_length)
+
+
+## jerry_arraybuffer_write
+
+**Summary**
+
+Copy the contents of a buffer into the ArrayBuffer.
+The start offset of the write operation can be specified.
+
+The number bytes to be written can be specified via the `buf_size`
+parameter. It is not possible to write more than the length of
+the ArrayBuffer.
+
+Function returns the number of bytes written into the ArrayBuffer
+(and read from the buffer parameter). This value is
+calculated in the following way: `min(array buffer length - offset, buf_size)`.
+
+**Prototype**
+
+```c
+jerry_length_t
+jerry_arraybuffer_write (const jerry_value_t value,
+ jerry_length_t offset,
+ const uint8_t *buf_p,
+ jerry_length_t buf_size);
+```
+
+- `value` - ArrayBuffer to write to
+- `offset` - start offset of the write operation
+- `buf_p` - buffer to read the data from
+- `buf_size` - maximum number of bytes to write into the ArrayBuffer
+- return value
+ - number of bytes written into the ArrayBuffer (read from the buffer parameter)
+ - 0 if the `value` is not an ArrayBuffer object
+ - 0 if the `buf_size` is zero or there is nothing to write
+
+**Example**
+
+```c
+{
+ uint8_t data[20];
+
+ // fill the data with values
+ for (int i = 0; i < 20; i++)
+ {
+ data[i] = (uint8_t) (i * 2);
+ }
+
+ jerry_value_t buffer;
+ // ... create the ArrayBuffer or acquire it from somewhere.
+
+ jerry_value_t bytes_written;
+
+ // write 10 bytes from to the start of the ArrayBuffer.
+ bytes_written = jerry_arraybuffer_write (buffer, 0, data, 10);
+ // read the next 10 bytes
+ bytes_written += jerry_arraybuffer_write (buffer, bytes_written, data + bytes_written, 10);
+
+ // use the ArrayBuffer
+
+ jerry_release_value (buffer);
+}
+```
+
+**See also**
+
+- [jerry_create_arraybuffer](#jerry_create_arraybuffer)
+- [jerry_arraybuffer_write](#jerry_arraybuffer_write)
+- [jerry_get_arraybuffer_byte_length](#jerry_get_arraybuffer_byte_length)
+
+
+## jerry_get_arraybuffer_pointer
+
+**Summary**
+
+The function allows access to the contents of the Array Buffer directly.
+Only allowed for Array Buffers which were created with
+[jerry_create_arraybuffer_external](#jerry_create_arraybuffer_external)
+function calls. In any other case this function will return `NULL`.
+
+After using the pointer the [jerry_release_value](#jerry_release_value)
+function must be called.
+
+**WARNING!** This operation is for expert use only! The programmer must
+ensure that the returned memory area is used correctly. That is
+there is no out of bounds reads or writes.
+
+**Prototype**
+
+```c
+uint8_t *
+jerry_get_arraybuffer_pointer (const jerry_value_t value);
+```
+
+- `value` - Array Buffer object.
+- return value
+ - pointer to the Array Buffer's data area.
+ - NULL if the `value` is not an Array Buffer object with external memory.
+
+**Example**
+
+```c
+{
+ jerry_value_t buffer;
+
+ // acquire buffer somewhere which was created by a jerry_create_array_buffer_external call.
+
+ uint8_t *const data = jerry_get_arraybuffer_pointer (buffer);
+
+ for (int i = 0; i < 22; i++)
+ {
+ data[i] = (uint8_t) (i + 4);
+ }
+
+ // required after jerry_get_arraybuffer_pointer call.
+ jerry_release_value (buffer);
+
+ // use the Array Buffer
+
+ // release buffer as it is not needed after this point
+ jerry_release_value (buffer);
+}
+```
+
+**See also**
+
+- [jerry_create_arraybuffer_external](#jerry_create_arraybuffer_external)
+
+
+## jerry_get_typedarray_type
+
+**Summary**
+
+Get the type of the TypedArray.
+
+The returned type is one of the [jerry_typedarray_type_t](#jerry_typedarray_type_t)
+enum value.
+
+**Prototype**
+
+```c
+jerry_typedarray_type_t
+jerry_get_typedarray_type (jerry_value_t value);
+```
+
+- `value` - TypedArray object to query for type.
+- return
+ - the type of the TypedArray
+ - JERRY_TYPEDARRAY_INVALID if the object was not a TypedArray
+
+**Example**
+
+```c
+{
+ jerry_typedarray_type_t expected_type = JERRY_TYPEDARRAY_UINT32;
+ jerry_value_t typedarray = jerry_create_typedarray (expected_klass, 25);
+
+ jerry_typedarray_type_t type = jerry_get_typedarray_type (typedarray);
+
+ // 'type' is now JERRY_TYPEDARRAY_UINT32
+
+ jerry_release_value (typedarray);
+}
+```
+
+**See also**
+
+- [jerry_create_typedarray](#jerry_create_typedarray)
+- [jerry_typedarray_type_t](#jerry_typedarray_type_t)
+
+
+## jerry_get_typedarray_length
+
+**Summary**
+
+Get the element count of the TypedArray as specified during creation.
+
+This is not the same as the byteLength property of a TypedArray object.
+
+**Prototype**
+
+```
+jerry_length_t
+jerry_get_typedarray_length (jerry_value_t value);
+```
+
+- `value` - TypedArray object to query
+- return
+ - length (element count) of the TypedArray object
+ - 0 if the object is not a TypedArray
+
+**Example**
+
+```c
+{
+ jerry_value_t array = jerry_create_typedarray (JERRY_TYPEDARRAY_INT32, 21);
+
+ jerry_length_t element_count = jerry_get_typedarray_length (array);
+
+ // element_count is now 21.
+
+ jerry_release_value (array);
+}
+```
+
+**See also**
+
+- [jerry_create_typedarray](#jerry_create_typedarray)
+
+
+## jerry_get_typedarray_buffer
+
+**Summary**
+
+Get the ArrayBuffer object used by a TypedArray object.
+Additionally returns the byteLength and byteOffset properties
+of the TypedArray object.
+
+For the returned ArrayBuffer the [jerry_release_value](#jerry_release_value)
+must be called.
+
+**Prototype**
+
+```c
+jerry_value_t jerry_get_typedarray_buffer (jerry_value_t value,
+ jerry_length_t *byteOffset,
+ jerry_length_t *byteLength);
+```
+
+- `value` - TypedArray to get the ArrayBuffer from
+- `byteOffset` - (Optional) returns the start offset of the ArrayBuffer for the TypedArray
+- `byteLength` - (Optional) returns the number of bytes used from the ArrayBuffer for the TypedArray
+- return
+ - TypedArray object's underlying ArrayBuffer object
+ - TypeError if the `value` is not a TypedArray object
+
+**Example**
+
+```c
+{
+ jerry_value_t array = jerry_create_typedarray (JERRY_TYPEDARRAY_INT16, 11);
+
+ jerry_length_t byteLength = 0;
+ jerry_length_t byteOffset = 0;
+ jerry_value_t buffer = jerry_get_typedarray_buffer (array, &byteOffset, &byteLength);
+
+ // buffer is an ArrayBuffer object and ArrayBuffer operations can be performed on it
+ // byteLength is 11 * 2 (2 as the TypedArray stores Int16 that is 2 byte elements)
+ // byteOffset is 0
+
+ jerry_release_value (buffer);
+ jerry_release_value (array);
+}
+```
+
+**See also**
+
+- [jerry_create_typedarray](#jerry_create_typedarray)
+
+# JSON functions
+
+## jerry_json_parse
+
+**Summary**
+
+Returns the same result as JSON.parse ecmascript function.
+
+**Prototype**
+
+```c
+jerry_value_t jerry_json_parse (const jerry_char_t *string_p, jerry_size_t string_size)
+```
+
+- `string_p` - a JSON string
+- `string_size` - size of the string
+- return
+ - jerry_value_t containing the same as json.parse()
+ - jerry_value_t containing error massage
+
+**Example**
+
+```c
+{
+ const char *data = "{\"name\": \"John\", \"age\": 5}";
+ jerry_size_t str_length = (jerry_size_t)strlen (data);
+ jerry_value_t parsed_json = jerry_json_parse ((jerry_char_t*)data, str_length);
+
+ // parsed_json now conatins all data stored in data_in_json
+
+ jerry_release_value (parsed_json);
+}
+```
+
+## jerry_stringify
+
+ **Summary**
+
+ Returns the same value as JSON.stringify() ecmascript function.
+
+ **Prototype**
+
+```c
+jerry_value_t jerry_json_stringfy (const jerry_value_t object_to_stringify)
+```
+
+- `object_to_stringify` - a jerry_value_t object to stringify
+- return
+ - jerry_value_t containing the same as json.stringify()
+ - jerry_value_t containing error massage
+
+**Example**
+
+```c
+{
+ jerry_value_t obj = jerry_create_object ();
+ jerry_value_t key = jerry_create_string ((const jerry_char_t *) "name");
+ jerry_value_t value = jerry_create_string ((const jerry_char_t *) "John");
+ jerry_set_property (obj, key, value);
+ jerry_value_t stringified = jerry_json_stringfy (obj);
+
+ //stringified now contains a json formated string
+
+ jerry_release_value (obj);
+ jerry_release_value (key);
+ jerry_release_value (value);
+ jerry_release_value (stringified);
+}
+```
\ No newline at end of file
jerryx_handler_print);
/* Setup Global scope code */
- jerry_value_t parsed_code = jerry_parse (script, script_size, false);
+ jerry_value_t parsed_code = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (parsed_code))
{
# Byte-code
-This section describes the compact byte-code (CBC) byte-code representation. The key focus is reducing memory consumption of the byte-code representation without sacrificing considerable performance. Other byte-code representations often focus on performance only so inventing this representation is an original research.
+This section describes the compact byte-code (CBC) representation. The key focus is reducing memory consumption of the byte-code representation without sacrificing considerable performance. Other byte-code representations often focus on performance only so inventing this representation is an original research.
CBC is a CISC like instruction set which assigns shorter instructions for frequent operations. Many instructions represent multiple atomic tasks which reduces the byte code size. This technique is basically a data compression method.
struct jerry_instance_t *jerry_port_get_current_instance (void);
```
+## Sleep
+
+```c
+/**
+ * Makes the process sleep for a given time.
+ */
+void jerry_port_sleep (uint32_t sleep_time);
+```
+
# How to port JerryScript
This section describes a basic port implementation which was created for Unix based systems.
return current_instance_p;
} /* jerry_port_get_current_instance */
```
+
+## Sleep
+
+```c
+#include "jerryscript-port.h"
+#include "jerryscript-port-default.h"
+
+#ifdef HAVE_TIME_H
+#include <time.h>
+#elif defined (HAVE_UNISTD_H)
+#include <unistd.h>
+#endif /* HAVE_TIME_H */
+
+#ifdef JERRY_DEBUGGER
+void jerry_port_sleep (uint32_t sleep_time)
+{
+#ifdef HAVE_TIME_H
+ nanosleep (&(const struct timespec)
+ {
+ sleep_time / 1000, (sleep_time % 1000) * 1000000L /* Seconds, nanoseconds */
+ }
+ , NULL);
+#elif defined (HAVE_UNISTD_H)
+ usleep ((useconds_t) sleep_time * 1000);
+#endif /* HAVE_TIME_H */
+ (void) sleep_time;
+} /* jerry_port_sleep */
+#endif /* JERRY_DEBUGGER */
+```
function after the `jerry_init ()` function. It initializes the debugger
and blocks until a client connects.
-When the debugger is enabled it is recommended to use
-`jerry_parse_named_resource ()` instead of `jerry_parse ()` because
-the resource name (usually a file name) is also passed to this
-function. This resource name is used by the client to identify
-the corresponding resource. In general it is always recommended to
-use `jerry_parse_named_resource ()` when the resource name is
-available because it silently ignores the resource name if the
-debugger is disabled.
+The resource name provided to `jerry_parse ()` is used by the client
+to identify the resource name of the source code. This resource name
+is usually a file name.
## JerryScript debugger C-API interface
size_t source_size, /**< source code size */
void *user_p __attribute__((unused))) /**< user pointer */
{
- jerry_value_t ret_val = jerry_parse_named_resource (resource_name_p,
- resource_name_size,
- source_p,
- source_size,
- false);
+ jerry_value_t ret_val = jerry_parse (resource_name_p,
+ resource_name_size,
+ source_p,
+ source_size,
+ JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (ret_val))
{
/* Field descriptions do not start with capital letters
* and there is no full stop at the end. */
field1_t field1; /**< description of field 1 */
- field2_t field2; /**< description of field 1 */
+ field2_t field2; /**< description of field 2 */
field_n_t field_n; /**< description of field n */
} structure_name_t;
project (${JERRY_CORE_NAME} C)
# Optional features
-set(FEATURE_CPOINTER_32_BIT OFF CACHE BOOL "Enable 32 bit compressed pointers?")
-set(FEATURE_DEBUGGER OFF CACHE BOOL "Enable JerryScript debugger?")
-set(FEATURE_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
-set(FEATURE_EXTERNAL_CONTEXT OFF CACHE BOOL "Enable external context?")
-set(FEATURE_JS_PARSER ON CACHE BOOL "Enable js-parser?")
-set(FEATURE_MEM_STATS OFF CACHE BOOL "Enable memory statistics?")
-set(FEATURE_MEM_STRESS_TEST OFF CACHE BOOL "Enable mem-stress test?")
-set(FEATURE_PARSER_DUMP OFF CACHE BOOL "Enable parser byte-code dumps?")
-set(FEATURE_PROFILE "es5.1" CACHE STRING "Use default or other profile?")
-set(FEATURE_REGEXP_DUMP OFF CACHE BOOL "Enable regexp byte-code dumps?")
-set(FEATURE_SNAPSHOT_EXEC OFF CACHE BOOL "Enable executing snapshot files?")
-set(FEATURE_SNAPSHOT_SAVE OFF CACHE BOOL "Enable saving snapshot files?")
-set(FEATURE_SYSTEM_ALLOCATOR OFF CACHE BOOL "Enable system allocator?")
-set(FEATURE_VALGRIND OFF CACHE BOOL "Enable Valgrind support?")
-set(FEATURE_VALGRIND_FREYA OFF CACHE BOOL "Enable Valgrind-Freya support?")
-set(FEATURE_VM_EXEC_STOP OFF CACHE BOOL "Enable VM execution stopping?")
-set(MEM_HEAP_SIZE_KB "512" CACHE STRING "Size of memory heap, in kilobytes")
+set(FEATURE_CPOINTER_32_BIT OFF CACHE BOOL "Enable 32 bit compressed pointers?")
+set(FEATURE_DEBUGGER OFF CACHE BOOL "Enable JerryScript debugger?")
+set(FEATURE_ERROR_MESSAGES OFF CACHE BOOL "Enable error messages?")
+set(FEATURE_EXTERNAL_CONTEXT OFF CACHE BOOL "Enable external context?")
+set(FEATURE_JS_PARSER ON CACHE BOOL "Enable js-parser?")
+set(FEATURE_LINE_INFO OFF CACHE BOOL "Enable line info?")
+set(FEATURE_MEM_STATS OFF CACHE BOOL "Enable memory statistics?")
+set(FEATURE_MEM_STRESS_TEST OFF CACHE BOOL "Enable mem-stress test?")
+set(FEATURE_PARSER_DUMP OFF CACHE BOOL "Enable parser byte-code dumps?")
+set(FEATURE_PROFILE "es5.1" CACHE STRING "Use default or other profile?")
+set(FEATURE_REGEXP_STRICT_MODE OFF CACHE BOOL "Enable regexp strict mode?")
+set(FEATURE_REGEXP_DUMP OFF CACHE BOOL "Enable regexp byte-code dumps?")
+set(FEATURE_SNAPSHOT_EXEC OFF CACHE BOOL "Enable executing snapshot files?")
+set(FEATURE_SNAPSHOT_SAVE OFF CACHE BOOL "Enable saving snapshot files?")
+set(FEATURE_SYSTEM_ALLOCATOR OFF CACHE BOOL "Enable system allocator?")
+set(FEATURE_VALGRIND OFF CACHE BOOL "Enable Valgrind support?")
+set(FEATURE_VALGRIND_FREYA OFF CACHE BOOL "Enable Valgrind-Freya support?")
+set(FEATURE_VM_EXEC_STOP OFF CACHE BOOL "Enable VM execution stopping?")
+set(MEM_HEAP_SIZE_KB "512" CACHE STRING "Size of memory heap, in kilobytes")
# Option overrides
if(FEATURE_SYSTEM_ALLOCATOR)
endif()
# Status messages
-message(STATUS "FEATURE_CPOINTER_32_BIT " ${FEATURE_CPOINTER_32_BIT} ${FEATURE_CPOINTER_32_BIT_MESSAGE})
-message(STATUS "FEATURE_DEBUGGER " ${FEATURE_DEBUGGER})
-message(STATUS "FEATURE_ERROR_MESSAGES " ${FEATURE_ERROR_MESSAGES})
-message(STATUS "FEATURE_EXTERNAL_CONTEXT " ${FEATURE_EXTERNAL_CONTEXT})
-message(STATUS "FEATURE_JS_PARSER " ${FEATURE_JS_PARSER})
-message(STATUS "FEATURE_MEM_STATS " ${FEATURE_MEM_STATS})
-message(STATUS "FEATURE_MEM_STRESS_TEST " ${FEATURE_MEM_STRESS_TEST})
-message(STATUS "FEATURE_PARSER_DUMP " ${FEATURE_PARSER_DUMP} ${FEATURE_PARSER_DUMP_MESSAGE})
-message(STATUS "FEATURE_PROFILE " ${FEATURE_PROFILE})
-message(STATUS "FEATURE_REGEXP_DUMP " ${FEATURE_REGEXP_DUMP})
-message(STATUS "FEATURE_SNAPSHOT_EXEC " ${FEATURE_SNAPSHOT_EXEC} ${FEATURE_SNAPSHOT_EXEC_MESSAGE})
-message(STATUS "FEATURE_SNAPSHOT_SAVE " ${FEATURE_SNAPSHOT_SAVE} ${FEATURE_SNAPSHOT_SAVE_MESSAGE})
-message(STATUS "FEATURE_SYSTEM_ALLOCATOR " ${FEATURE_SYSTEM_ALLOCATOR})
-message(STATUS "FEATURE_VALGRIND " ${FEATURE_VALGRIND})
-message(STATUS "FEATURE_VALGRIND_FREYA " ${FEATURE_VALGRIND_FREYA})
-message(STATUS "FEATURE_VM_EXEC_STOP " ${FEATURE_VM_EXEC_STOP})
-message(STATUS "MEM_HEAP_SIZE_KB " ${MEM_HEAP_SIZE_KB})
+message(STATUS "FEATURE_CPOINTER_32_BIT " ${FEATURE_CPOINTER_32_BIT} ${FEATURE_CPOINTER_32_BIT_MESSAGE})
+message(STATUS "FEATURE_DEBUGGER " ${FEATURE_DEBUGGER})
+message(STATUS "FEATURE_ERROR_MESSAGES " ${FEATURE_ERROR_MESSAGES})
+message(STATUS "FEATURE_EXTERNAL_CONTEXT " ${FEATURE_EXTERNAL_CONTEXT})
+message(STATUS "FEATURE_JS_PARSER " ${FEATURE_JS_PARSER})
+message(STATUS "FEATURE_LINE_INFO " ${FEATURE_LINE_INFO})
+message(STATUS "FEATURE_MEM_STATS " ${FEATURE_MEM_STATS})
+message(STATUS "FEATURE_MEM_STRESS_TEST " ${FEATURE_MEM_STRESS_TEST})
+message(STATUS "FEATURE_PARSER_DUMP " ${FEATURE_PARSER_DUMP} ${FEATURE_PARSER_DUMP_MESSAGE})
+message(STATUS "FEATURE_PROFILE " ${FEATURE_PROFILE})
+message(STATUS "FEATURE_REGEXP_STRICT_MODE " ${FEATURE_REGEXP_STRICT_MODE})
+message(STATUS "FEATURE_REGEXP_DUMP " ${FEATURE_REGEXP_DUMP})
+message(STATUS "FEATURE_SNAPSHOT_EXEC " ${FEATURE_SNAPSHOT_EXEC} ${FEATURE_SNAPSHOT_EXEC_MESSAGE})
+message(STATUS "FEATURE_SNAPSHOT_SAVE " ${FEATURE_SNAPSHOT_SAVE} ${FEATURE_SNAPSHOT_SAVE_MESSAGE})
+message(STATUS "FEATURE_SYSTEM_ALLOCATOR " ${FEATURE_SYSTEM_ALLOCATOR})
+message(STATUS "FEATURE_VALGRIND " ${FEATURE_VALGRIND})
+message(STATUS "FEATURE_VALGRIND_FREYA " ${FEATURE_VALGRIND_FREYA})
+message(STATUS "FEATURE_VM_EXEC_STOP " ${FEATURE_VM_EXEC_STOP})
+message(STATUS "MEM_HEAP_SIZE_KB " ${MEM_HEAP_SIZE_KB})
# Include directories
set(INCLUDE_CORE
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_DISABLE_JS_PARSER)
endif()
+# JS line info
+if(FEATURE_LINE_INFO)
+ set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_LINE_INFO)
+endif()
+
# Memory statistics
if(FEATURE_MEM_STATS)
set(DEFINES_JERRY ${DEFINES_JERRY} JMEM_STATS)
MESSAGE(FATAL_ERROR "This configuration is not supported. Please build against your system libc to enable the system allocator.")
endif()
+# RegExp strict mode
+if(FEATURE_REGEXP_STRICT_MODE)
+ set(DEFINES_JERRY ${DEFINES_JERRY} ENABLE_REGEXP_STRICT_MODE)
+endif()
+
# RegExp byte-code dumps
if(FEATURE_REGEXP_DUMP)
set(DEFINES_JERRY ${DEFINES_JERRY} REGEXP_DUMP_BYTE_CODE)
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
{
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_STOP);
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
JERRY_CONTEXT (debugger_stop_context) = NULL;
}
#endif /* JERRY_DEBUGGER */
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
{
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) & ~JERRY_DEBUGGER_VM_STOP);
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_STOP);
JERRY_CONTEXT (debugger_stop_context) = NULL;
}
#endif /* JERRY_DEBUGGER */
{
if (enable_stop_at_breakpoint)
{
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_IGNORE);
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
}
else
{
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) & ~JERRY_DEBUGGER_VM_IGNORE);
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
}
}
#else /* !JERRY_DEBUGGER */
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
&& !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_BREAKPOINT_MODE))
{
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
jerry_debugger_uint8_data_t *client_source_data_p = NULL;
jerry_debugger_wait_for_source_status_t ret_type = JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED;
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONTEXT_RESET_MODE))
{
ret_type = JERRY_DEBUGGER_CONTEXT_RESET_RECEIVED;
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags)
- & ~JERRY_DEBUGGER_CONTEXT_RESET_MODE);
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_CONTEXT_RESET_MODE);
break;
}
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CLIENT_NO_SOURCE))
{
ret_type = JERRY_DEBUGGER_SOURCE_END;
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags)
- & ~JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
break;
}
* limitations under the License.
*/
+#include "ecma-conversion.h"
#include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-helpers.h"
+#include "ecma-lex-env.h"
#include "ecma-literal-storage.h"
#include "jcontext.h"
#include "jerryscript.h"
#include "jerry-snapshot.h"
#include "js-parser.h"
-#include "ecma-lex-env.h"
#include "lit-char-helpers.h"
#include "re-compiler.h"
typedef struct
{
size_t snapshot_buffer_write_offset;
- bool snapshot_error_occured;
+ ecma_value_t snapshot_error;
bool regex_found;
} snapshot_globals_t;
} /* snapshot_write_to_buffer_by_offset */
/**
- * Snapshot callback for byte codes.
+ * Maximum snapshot write buffer offset.
+ */
+#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32
+#define JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET (0x7fffff >> 1)
+#else
+#define JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET (UINT32_MAX >> 1)
+#endif
+
+/**
+ * Save snapshot helper.
*
* @return start offset
*/
-static uint16_t
+static uint32_t
snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled code */
uint8_t *snapshot_buffer_p, /**< snapshot buffer */
size_t snapshot_buffer_size, /**< snapshot buffer size */
snapshot_globals_t *globals_p) /**< snapshot globals */
{
- if (globals_p->snapshot_error_occured)
+ const jerry_char_t *error_buffer_too_small_p = (const jerry_char_t *) "Snapshot buffer too small.";
+
+ if (!ecma_is_value_empty (globals_p->snapshot_error))
{
return 0;
}
JERRY_ASSERT ((globals_p->snapshot_buffer_write_offset & (JMEM_ALIGNMENT - 1)) == 0);
- if ((globals_p->snapshot_buffer_write_offset >> JMEM_ALIGNMENT_LOG) > 0xffffu)
+ if (globals_p->snapshot_buffer_write_offset > JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET)
{
- globals_p->snapshot_error_occured = true;
+ const char *error_message_p = "Maximum snapshot size reached.";
+ globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
return 0;
}
/* The snapshot generator always parses a single file,
* so the base always starts right after the snapshot header. */
- size_t buffer_offset = globals_p->snapshot_buffer_write_offset - sizeof (jerry_snapshot_header_t);
- uint16_t start_offset = (uint16_t) (buffer_offset >> JMEM_ALIGNMENT_LOG);
+ uint32_t start_offset = (uint32_t) (globals_p->snapshot_buffer_write_offset - sizeof (jerry_snapshot_header_t));
uint8_t *copied_code_start_p = snapshot_buffer_p + globals_p->snapshot_buffer_write_offset;
ecma_compiled_code_t *copied_code_p = (ecma_compiled_code_t *) copied_code_start_p;
/* Regular expression. */
if (globals_p->snapshot_buffer_write_offset + sizeof (ecma_compiled_code_t) > snapshot_buffer_size)
{
- globals_p->snapshot_error_occured = true;
+ globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, error_buffer_too_small_p);
return 0;
}
globals_p->snapshot_buffer_write_offset += sizeof (ecma_compiled_code_t);
- jmem_cpointer_t pattern_cp = ((re_compiled_code_t *) compiled_code_p)->pattern_cp;
- ecma_string_t *pattern_string_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
- pattern_cp);
+ ecma_value_t pattern = ((re_compiled_code_t *) compiled_code_p)->pattern;
+ ecma_string_t *pattern_string_p = ecma_get_string_from_value (pattern);
ecma_length_t pattern_size = 0;
buffer_p,
buffer_size))
{
- globals_p->snapshot_error_occured = true;
+ globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, error_buffer_too_small_p);
+ /* cannot return inside ECMA_FINALIZE_UTF8_STRING */
}
ECMA_FINALIZE_UTF8_STRING (buffer_p, buffer_size);
+ if (!ecma_is_value_empty (globals_p->snapshot_error))
+ {
+ return 0;
+ }
+
globals_p->regex_found = true;
globals_p->snapshot_buffer_write_offset = JERRY_ALIGNUP (globals_p->snapshot_buffer_write_offset,
JMEM_ALIGNMENT);
compiled_code_p,
((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG))
{
- globals_p->snapshot_error_occured = true;
+ globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, error_buffer_too_small_p);
return 0;
}
/* Sub-functions and regular expressions are stored recursively. */
- uint8_t *src_buffer_p = (uint8_t *) compiled_code_p;
- uint8_t *dst_buffer_p = (uint8_t *) copied_code_p;
- jmem_cpointer_t *src_literal_start_p;
- jmem_cpointer_t *dst_literal_start_p;
+ uint8_t *buffer_p = (uint8_t *) copied_code_p;
+ ecma_value_t *literal_start_p;
uint32_t const_literal_end;
uint32_t literal_end;
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{
- src_literal_start_p = (jmem_cpointer_t *) (src_buffer_p + sizeof (cbc_uint16_arguments_t));
- dst_literal_start_p = (jmem_cpointer_t *) (dst_buffer_p + sizeof (cbc_uint16_arguments_t));
+ literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint16_arguments_t));
- cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) src_buffer_p;
- literal_end = args_p->literal_end;
- const_literal_end = args_p->const_literal_end;
+ cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) buffer_p;
+ literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
else
{
- src_literal_start_p = (jmem_cpointer_t *) (src_buffer_p + sizeof (cbc_uint8_arguments_t));
- dst_literal_start_p = (jmem_cpointer_t *) (dst_buffer_p + sizeof (cbc_uint8_arguments_t));
+ literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint8_arguments_t));
- cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) src_buffer_p;
- literal_end = args_p->literal_end;
- const_literal_end = args_p->const_literal_end;
+ cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) buffer_p;
+ literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
for (uint32_t i = const_literal_end; i < literal_end; i++)
{
- ecma_compiled_code_t *bytecode_p = ECMA_GET_NON_NULL_POINTER (ecma_compiled_code_t,
- src_literal_start_p[i]);
+ ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
+ literal_start_p[i]);
if (bytecode_p == compiled_code_p)
{
- dst_literal_start_p[i] = start_offset;
+ literal_start_p[i] = 0;
}
else
{
- dst_literal_start_p[i] = snapshot_add_compiled_code (bytecode_p,
+ uint32_t offset = snapshot_add_compiled_code (bytecode_p,
+ snapshot_buffer_p,
+ snapshot_buffer_size,
+ globals_p);
+
+ JERRY_ASSERT (!ecma_is_value_empty (globals_p->snapshot_error) || offset > start_offset);
+
+ literal_start_p[i] = offset - start_offset;
+ }
+ }
+
+ return start_offset;
+} /* snapshot_add_compiled_code */
+
+/**
+ * Create unsupported literal error.
+ */
+static void
+static_snapshot_error_unsupported_literal (snapshot_globals_t *globals_p, /**< snapshot globals */
+ ecma_value_t literal) /**< literal form the literal pool */
+{
+ const char *error_prefix_p = "Unsupported static snapshot literal: ";
+
+ ecma_string_t *error_message_p = ecma_new_ecma_string_from_utf8 ((const lit_utf8_byte_t *) error_prefix_p,
+ (lit_utf8_size_t) strlen (error_prefix_p));
+
+ literal = ecma_op_to_string (literal);
+ JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (literal));
+
+ ecma_string_t *literal_string_p = ecma_get_string_from_value (literal);
+ error_message_p = ecma_concat_ecma_strings (error_message_p, literal_string_p);
+ ecma_deref_ecma_string (literal_string_p);
+
+ ecma_object_t *error_object_p = ecma_new_standard_error_with_message (ECMA_ERROR_RANGE, error_message_p);
+ ecma_deref_ecma_string (error_message_p);
+
+ globals_p->snapshot_error = ecma_create_error_object_reference (error_object_p);
+} /* static_snapshot_error_unsupported_literal */
+
+/**
+ * Save static snapshot helper.
+ *
+ * @return start offset
+ */
+static uint32_t
+static_snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled code */
+ uint8_t *snapshot_buffer_p, /**< snapshot buffer */
+ size_t snapshot_buffer_size, /**< snapshot buffer size */
+ snapshot_globals_t *globals_p) /**< snapshot globals */
+{
+ if (!ecma_is_value_empty (globals_p->snapshot_error))
+ {
+ return 0;
+ }
+
+ JERRY_ASSERT ((globals_p->snapshot_buffer_write_offset & (JMEM_ALIGNMENT - 1)) == 0);
+
+ if (globals_p->snapshot_buffer_write_offset >= JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET)
+ {
+ const char *error_message_p = "Maximum snapshot size reached.";
+ globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
+ return 0;
+ }
+
+ /* The snapshot generator always parses a single file,
+ * so the base always starts right after the snapshot header. */
+ uint32_t start_offset = (uint32_t) (globals_p->snapshot_buffer_write_offset - sizeof (jerry_snapshot_header_t));
+
+ uint8_t *copied_code_start_p = snapshot_buffer_p + globals_p->snapshot_buffer_write_offset;
+ ecma_compiled_code_t *copied_code_p = (ecma_compiled_code_t *) copied_code_start_p;
+
+ if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
+ {
+ /* Regular expression literals are not supported. */
+ const char *error_message_p = "Regular expression literals are not supported.";
+ globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
+ return 0;
+ }
+
+ if (!snapshot_write_to_buffer_by_offset (snapshot_buffer_p,
+ snapshot_buffer_size,
+ &globals_p->snapshot_buffer_write_offset,
+ compiled_code_p,
+ ((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG))
+ {
+ const char *error_message_p = "Snapshot buffer too small.";
+ globals_p->snapshot_error = jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
+ return 0;
+ }
+
+ /* Sub-functions and regular expressions are stored recursively. */
+ uint8_t *buffer_p = (uint8_t *) copied_code_p;
+ ecma_value_t *literal_start_p;
+ uint32_t argument_end;
+ uint32_t const_literal_end;
+ uint32_t literal_end;
+
+ ((ecma_compiled_code_t *) copied_code_p)->status_flags |= CBC_CODE_FLAGS_STATIC_FUNCTION;
+
+ if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
+ {
+ literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint16_arguments_t));
+
+ cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) buffer_p;
+ argument_end = args_p->argument_end;
+ literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
+ }
+ else
+ {
+ literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint8_arguments_t));
+
+ cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) buffer_p;
+ argument_end = args_p->argument_end;
+ literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
+ }
+
+ for (uint32_t i = 0; i < const_literal_end; i++)
+ {
+ if (!ecma_is_value_direct (literal_start_p[i])
+ && !ecma_is_value_direct_string (literal_start_p[i]))
+ {
+ static_snapshot_error_unsupported_literal (globals_p, literal_start_p[i]);
+ return 0;
+ }
+ }
+
+ for (uint32_t i = const_literal_end; i < literal_end; i++)
+ {
+ ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
+ literal_start_p[i]);
+
+ if (bytecode_p == compiled_code_p)
+ {
+ literal_start_p[i] = 0;
+ }
+ else
+ {
+ uint32_t offset = static_snapshot_add_compiled_code (bytecode_p,
snapshot_buffer_p,
snapshot_buffer_size,
globals_p);
+
+ JERRY_ASSERT (!ecma_is_value_empty (globals_p->snapshot_error) || offset > start_offset);
+
+ literal_start_p[i] = offset - start_offset;
+ }
+ }
+
+ if (compiled_code_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED)
+ {
+ buffer_p += ((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG;
+ literal_start_p = ((ecma_value_t *) buffer_p) - argument_end;
+
+ for (uint32_t i = 0; i < argument_end; i++)
+ {
+ if (!ecma_is_value_direct_string (literal_start_p[i]))
+ {
+ static_snapshot_error_unsupported_literal (globals_p, literal_start_p[i]);
+ return 0;
+ }
}
}
return start_offset;
-} /* snapshot_add_compiled_code */
+} /* static_snapshot_add_compiled_code */
/**
* Set the uint16_t offsets in the code area.
if (bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
{
- jmem_cpointer_t *literal_start_p;
+ ecma_value_t *literal_start_p;
uint32_t argument_end;
- uint32_t register_end;
uint32_t const_literal_end;
if (bytecode_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{
- literal_start_p = (jmem_cpointer_t *) (((uint8_t *) buffer_p) + sizeof (cbc_uint16_arguments_t));
+ literal_start_p = (ecma_value_t *) (((uint8_t *) buffer_p) + sizeof (cbc_uint16_arguments_t));
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) buffer_p;
argument_end = args_p->argument_end;
- register_end = args_p->register_end;
- const_literal_end = args_p->const_literal_end;
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
else
{
- literal_start_p = (jmem_cpointer_t *) (((uint8_t *) buffer_p) + sizeof (cbc_uint8_arguments_t));
+ literal_start_p = (ecma_value_t *) (((uint8_t *) buffer_p) + sizeof (cbc_uint8_arguments_t));
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) buffer_p;
argument_end = args_p->argument_end;
- register_end = args_p->register_end;
- const_literal_end = args_p->const_literal_end;
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
- uint32_t register_clear_start = 0;
+ for (uint32_t i = 0; i < const_literal_end; i++)
+ {
+ if (ecma_is_value_string (literal_start_p[i])
+ || ecma_is_value_float_number (literal_start_p[i]))
+ {
+ lit_mem_to_snapshot_id_map_entry_t *current_p = lit_map_p;
+
+ while (current_p->literal_id != literal_start_p[i])
+ {
+ current_p++;
+ }
+
+ literal_start_p[i] = current_p->literal_offset;
+ }
+ }
- if ((bytecode_p->status_flags & CBC_CODE_FLAGS_ARGUMENTS_NEEDED)
- && !(bytecode_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE))
+ if (bytecode_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED)
{
+ uint8_t *byte_p = (uint8_t *) bytecode_p;
+ byte_p += ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
+ literal_start_p = ((ecma_value_t *) byte_p) - argument_end;
+
for (uint32_t i = 0; i < argument_end; i++)
{
- if (literal_start_p[i] != JMEM_CP_NULL)
+ if (literal_start_p[i] != ECMA_VALUE_EMPTY)
{
+ JERRY_ASSERT (ecma_is_value_string (literal_start_p[i]));
+
lit_mem_to_snapshot_id_map_entry_t *current_p = lit_map_p;
while (current_p->literal_id != literal_start_p[i])
literal_start_p[i] = current_p->literal_offset;
}
}
-
- register_clear_start = argument_end;
- }
-
- for (uint32_t i = register_clear_start; i < register_end; i++)
- {
- literal_start_p[i] = JMEM_CP_NULL;
- }
-
- for (uint32_t i = register_end; i < const_literal_end; i++)
- {
- lit_mem_to_snapshot_id_map_entry_t *current_p = lit_map_p;
-
- if (literal_start_p[i] != JMEM_CP_NULL)
- {
- while (current_p->literal_id != literal_start_p[i])
- {
- current_p++;
- }
-
- literal_start_p[i] = current_p->literal_offset;
- }
}
/* Set reference counter to 1. */
static ecma_compiled_code_t *
snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of the
* current primary function */
- size_t offset, /**< byte code offset */
const uint8_t *literal_base_p, /**< literal start */
- const uint8_t *number_base_p, /**< literal number start */
bool copy_bytecode) /**< byte code should be copied to memory */
{
- ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) (base_addr_p + offset);
+ ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) base_addr_p;
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
}
size_t header_size;
- uint32_t literal_end;
+ uint32_t argument_end = 0;
uint32_t const_literal_end;
+ uint32_t literal_end;
if (bytecode_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{
uint8_t *byte_p = (uint8_t *) bytecode_p;
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) byte_p;
- literal_end = args_p->literal_end;
- const_literal_end = args_p->const_literal_end;
+
+ if (bytecode_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED)
+ {
+ argument_end = args_p->argument_end;
+ }
+
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
+ literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
header_size = sizeof (cbc_uint16_arguments_t);
}
else
{
uint8_t *byte_p = (uint8_t *) bytecode_p;
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) byte_p;
- literal_end = args_p->literal_end;
- const_literal_end = args_p->const_literal_end;
+
+ if (bytecode_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED)
+ {
+ argument_end = args_p->argument_end;
+ }
+
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
+ literal_end = (uint32_t) (args_p->literal_end - args_p->register_end);
header_size = sizeof (cbc_uint8_arguments_t);
}
jmem_stats_allocate_byte_code_bytes (code_size);
#endif /* JMEM_STATS */
- memcpy (bytecode_p, base_addr_p + offset, code_size);
+ memcpy (bytecode_p, base_addr_p, code_size);
}
else
{
- code_size = (uint32_t) (header_size + literal_end * sizeof (jmem_cpointer_t));
+ uint32_t start_offset = (uint32_t) (header_size + literal_end * sizeof (ecma_value_t));
+
+ uint8_t *real_bytecode_p = ((uint8_t *) bytecode_p) + start_offset;
+ uint32_t new_code_size = (uint32_t) (start_offset + 1 + sizeof (uint8_t *));
- uint8_t *real_bytecode_p = ((uint8_t *) bytecode_p) + code_size;
- uint32_t total_size = JERRY_ALIGNUP (code_size + 1 + sizeof (uint8_t *), JMEM_ALIGNMENT);
+ if (argument_end != 0)
+ {
+ new_code_size += (uint32_t) (argument_end * sizeof (ecma_value_t));
+ }
+
+ new_code_size = JERRY_ALIGNUP (new_code_size, JMEM_ALIGNMENT);
- bytecode_p = (ecma_compiled_code_t *) jmem_heap_alloc_block (total_size);
+ bytecode_p = (ecma_compiled_code_t *) jmem_heap_alloc_block (new_code_size);
#ifdef JMEM_STATS
- jmem_stats_allocate_byte_code_bytes (total_size);
+ jmem_stats_allocate_byte_code_bytes (new_code_size);
#endif /* JMEM_STATS */
- memcpy (bytecode_p, base_addr_p + offset, code_size);
+ memcpy (bytecode_p, base_addr_p, start_offset);
- bytecode_p->size = (uint16_t) (total_size >> JMEM_ALIGNMENT_LOG);
+ bytecode_p->size = (uint16_t) (new_code_size >> JMEM_ALIGNMENT_LOG);
- uint8_t *instructions_p = ((uint8_t *) bytecode_p);
+ uint8_t *byte_p = (uint8_t *) bytecode_p;
- instructions_p[code_size] = CBC_SET_BYTECODE_PTR;
- memcpy (instructions_p + code_size + 1, &real_bytecode_p, sizeof (uint8_t *));
+ if (argument_end != 0)
+ {
+ uint32_t argument_size = (uint32_t) (argument_end * sizeof (ecma_value_t));
+ memcpy (byte_p + new_code_size - argument_size,
+ base_addr_p + code_size - argument_size,
+ argument_size);
+ }
+
+ byte_p[start_offset] = CBC_SET_BYTECODE_PTR;
+ memcpy (byte_p + start_offset + 1, &real_bytecode_p, sizeof (uint8_t *));
+
+ code_size = new_code_size;
}
JERRY_ASSERT (bytecode_p->refs == 1);
bytecode_p->status_flags = (uint16_t) (bytecode_p->status_flags | CBC_CODE_FLAGS_DEBUGGER_IGNORE);
#endif /* JERRY_DEBUGGER */
- jmem_cpointer_t *literal_start_p = (jmem_cpointer_t *) (((uint8_t *) bytecode_p) + header_size);
+ ecma_value_t *literal_start_p = (ecma_value_t *) (((uint8_t *) bytecode_p) + header_size);
for (uint32_t i = 0; i < const_literal_end; i++)
{
- literal_start_p[i] = ecma_snapshot_get_literal (literal_base_p,
- number_base_p,
- literal_start_p[i]);
+ if ((literal_start_p[i] & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET)
+ {
+ literal_start_p[i] = ecma_snapshot_get_literal (literal_base_p, literal_start_p[i]);
+ }
}
for (uint32_t i = const_literal_end; i < literal_end; i++)
{
- size_t literal_offset = ((size_t) literal_start_p[i]) << JMEM_ALIGNMENT_LOG;
+ size_t literal_offset = (size_t) literal_start_p[i];
- if (literal_offset == offset)
+ if (literal_offset == 0)
{
/* Self reference */
- ECMA_SET_NON_NULL_POINTER (literal_start_p[i],
- bytecode_p);
+ ECMA_SET_INTERNAL_VALUE_POINTER (literal_start_p[i],
+ bytecode_p);
}
else
{
ecma_compiled_code_t *literal_bytecode_p;
- literal_bytecode_p = snapshot_load_compiled_code (base_addr_p,
- literal_offset,
+ literal_bytecode_p = snapshot_load_compiled_code (base_addr_p + literal_offset,
literal_base_p,
- number_base_p,
copy_bytecode);
- ECMA_SET_NON_NULL_POINTER (literal_start_p[i],
- literal_bytecode_p);
+ ECMA_SET_INTERNAL_VALUE_POINTER (literal_start_p[i],
+ literal_bytecode_p);
+ }
+ }
+
+ if (argument_end != 0)
+ {
+ literal_start_p = (ecma_value_t *) (((uint8_t *) bytecode_p) + code_size);
+ literal_start_p -= argument_end;
+
+ for (uint32_t i = 0; i < argument_end; i++)
+ {
+ if ((literal_start_p[i] & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET)
+ {
+ literal_start_p[i] = ecma_snapshot_get_literal (literal_base_p, literal_start_p[i]);
+ }
}
}
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
+
/**
* Generate snapshot from specified source and arguments
*
- * @return size of snapshot, if it was generated succesfully
+ * @return size of snapshot (a number value), if it was generated succesfully
* (i.e. there are no syntax errors in source code, buffer size is sufficient,
* and snapshot support is enabled in current configuration through JERRY_ENABLE_SNAPSHOT_SAVE),
- * 0 - otherwise.
+ * error object otherwise
*/
-static size_t
-jerry_parse_and_save_snapshot_with_args (const jerry_char_t *source_p, /**< script source */
- size_t source_size, /**< script source size */
- const jerry_char_t *args_p, /**< arguments string */
- size_t args_size, /**< arguments string size */
- bool is_for_global, /**< snapshot would be executed as global (true)
- * or eval (false) */
- bool is_strict, /**< strict mode */
- uint32_t *buffer_p, /**< buffer to save snapshot to */
- size_t buffer_size) /**< the buffer's size */
+static jerry_value_t
+jerry_generate_snapshot_with_args (const jerry_char_t *resource_name_p, /**< script resource name */
+ size_t resource_name_length, /**< script resource name length */
+ const jerry_char_t *source_p, /**< script source */
+ size_t source_size, /**< script source size */
+ const jerry_char_t *args_p, /**< arguments string */
+ size_t args_size, /**< arguments string size */
+ uint32_t generate_snapshot_opts, /**< jerry_generate_snapshot_opts_t option bits */
+ uint32_t *buffer_p, /**< buffer to save snapshot to */
+ size_t buffer_size) /**< the buffer's size */
{
+ /* Currently unused arguments. */
+ JERRY_UNUSED (resource_name_p);
+ JERRY_UNUSED (resource_name_length);
+
+#ifdef JERRY_ENABLE_LINE_INFO
+ JERRY_CONTEXT (resource_name) = ECMA_VALUE_UNDEFINED;
+#endif /* JERRY_ENABLE_LINE_INFO */
+
snapshot_globals_t globals;
ecma_value_t parse_status;
ecma_compiled_code_t *bytecode_data_p;
JMEM_ALIGNMENT);
globals.snapshot_buffer_write_offset = aligned_header_size;
- globals.snapshot_error_occured = false;
+ globals.snapshot_error = ECMA_VALUE_EMPTY;
globals.regex_found = false;
parse_status = parser_parse_script (args_p,
args_size,
source_p,
source_size,
- is_strict,
+ (generate_snapshot_opts & JERRY_SNAPSHOT_SAVE_STRICT) != 0,
&bytecode_data_p);
if (ECMA_IS_VALUE_ERROR (parse_status))
{
- ecma_free_value (JERRY_CONTEXT (error_value));
- return 0;
+ return ecma_create_error_reference (JERRY_CONTEXT (error_value), true);
}
- snapshot_add_compiled_code (bytecode_data_p, (uint8_t *) buffer_p, buffer_size, &globals);
+ if (generate_snapshot_opts & JERRY_SNAPSHOT_SAVE_STATIC)
+ {
+ static_snapshot_add_compiled_code (bytecode_data_p, (uint8_t *) buffer_p, buffer_size, &globals);
+ }
+ else
+ {
+ snapshot_add_compiled_code (bytecode_data_p, (uint8_t *) buffer_p, buffer_size, &globals);
+ }
- if (globals.snapshot_error_occured)
+ if (!ecma_is_value_empty (globals.snapshot_error))
{
- return 0;
+ return globals.snapshot_error;
}
jerry_snapshot_header_t header;
header.number_of_funcs = 1;
header.func_offsets[0] = aligned_header_size;
- if (!is_for_global)
- {
- header.func_offsets[0] |= JERRY_SNAPSHOT_EVAL_CONTEXT;
- }
-
lit_mem_to_snapshot_id_map_entry_t *lit_map_p = NULL;
- uint32_t literals_num;
+ uint32_t literals_num = 0;
- if (!ecma_save_literals_for_snapshot (buffer_p,
- buffer_size,
- &globals.snapshot_buffer_write_offset,
- &lit_map_p,
- &literals_num))
+ if (!(generate_snapshot_opts & JERRY_SNAPSHOT_SAVE_STATIC))
{
- JERRY_ASSERT (lit_map_p == NULL);
- return 0;
- }
+ ecma_collection_header_t *lit_pool_p = ecma_new_values_collection ();
+
+ ecma_save_literals_add_compiled_code (bytecode_data_p, lit_pool_p);
+
+ if (!ecma_save_literals_for_snapshot (lit_pool_p,
+ buffer_p,
+ buffer_size,
+ &globals.snapshot_buffer_write_offset,
+ &lit_map_p,
+ &literals_num))
+ {
+ JERRY_ASSERT (lit_map_p == NULL);
+ const char *error_message_p = "Cannot allocate memory for literals.";
+ return jerry_create_error (JERRY_ERROR_COMMON, (const jerry_char_t *) error_message_p);
+ }
- jerry_snapshot_set_offsets (buffer_p + (aligned_header_size / sizeof (uint32_t)),
- (uint32_t) (header.lit_table_offset - aligned_header_size),
- lit_map_p);
+ jerry_snapshot_set_offsets (buffer_p + (aligned_header_size / sizeof (uint32_t)),
+ (uint32_t) (header.lit_table_offset - aligned_header_size),
+ lit_map_p);
+ }
size_t header_offset = 0;
ecma_bytecode_deref (bytecode_data_p);
- return globals.snapshot_buffer_write_offset;
-} /* jerry_parse_and_save_snapshot_with_args */
+ return ecma_make_number_value ((ecma_number_t) globals.snapshot_buffer_write_offset);
+} /* jerry_generate_snapshot_with_args */
+
#endif /* JERRY_ENABLE_SNAPSHOT_SAVE */
/**
- * Generate snapshot from specified source
+ * Generate snapshot from specified source and arguments
*
- * @return size of snapshot, if it was generated succesfully
+ * @return size of snapshot (a number value), if it was generated succesfully
* (i.e. there are no syntax errors in source code, buffer size is sufficient,
* and snapshot support is enabled in current configuration through JERRY_ENABLE_SNAPSHOT_SAVE),
- * 0 - otherwise.
+ * error object otherwise
*/
-size_t
-jerry_parse_and_save_snapshot (const jerry_char_t *source_p, /**< script source */
- size_t source_size, /**< script source size */
- bool is_for_global, /**< snapshot would be executed as global (true)
- * or eval (false) */
- bool is_strict, /**< strict mode */
- uint32_t *buffer_p, /**< buffer to save snapshot to */
- size_t buffer_size) /**< the buffer's size */
+jerry_value_t
+jerry_generate_snapshot (const jerry_char_t *resource_name_p, /**< script resource name */
+ size_t resource_name_length, /**< script resource name length */
+ const jerry_char_t *source_p, /**< script source */
+ size_t source_size, /**< script source size */
+ uint32_t generate_snapshot_opts, /**< jerry_generate_snapshot_opts_t option bits */
+ uint32_t *buffer_p, /**< buffer to save snapshot to */
+ size_t buffer_size) /**< the buffer's size */
{
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
- return jerry_parse_and_save_snapshot_with_args (source_p,
- source_size,
- NULL,
- 0,
- is_for_global,
- is_strict,
- buffer_p,
- buffer_size);
+ uint32_t allowed_opts = (JERRY_SNAPSHOT_SAVE_STATIC | JERRY_SNAPSHOT_SAVE_STRICT);
+
+ if ((generate_snapshot_opts & ~(allowed_opts)) != 0)
+ {
+ const char *error_message_p = "Unsupported generate snapshot flags specified.";
+ return jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
+ }
+
+ return jerry_generate_snapshot_with_args (resource_name_p,
+ resource_name_length,
+ source_p,
+ source_size,
+ NULL,
+ 0,
+ generate_snapshot_opts,
+ buffer_p,
+ buffer_size);
#else /* !JERRY_ENABLE_SNAPSHOT_SAVE */
+ JERRY_UNUSED (resource_name_p);
+ JERRY_UNUSED (resource_name_length);
JERRY_UNUSED (source_p);
JERRY_UNUSED (source_size);
- JERRY_UNUSED (is_for_global);
- JERRY_UNUSED (is_strict);
+ JERRY_UNUSED (generate_snapshot_opts);
JERRY_UNUSED (buffer_p);
JERRY_UNUSED (buffer_size);
return 0;
#endif /* JERRY_ENABLE_SNAPSHOT_SAVE */
-} /* jerry_parse_and_save_snapshot */
+} /* jerry_generate_snapshot */
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
/**
* thrown error - otherwise
*/
static jerry_value_t
-jerry_snapshot_result_at (const uint32_t *snapshot_p, /**< snapshot */
- size_t snapshot_size, /**< size of snapshot */
- size_t func_index, /**< index of primary function */
- bool copy_bytecode, /**< flag, indicating whether the passed snapshot
- * buffer should be copied to the engine's memory.
- * If set the engine should not reference the buffer
- * after the function returns (in this case, the passed
- * buffer could be freed after the call).
- * Otherwise (if the flag is not set) - the buffer could only be
- * freed after the engine stops (i.e. after call to jerry_cleanup). */
- bool as_function) /** < specify if the loaded snapshot should be returned as a function */
+jerry_snapshot_result (const uint32_t *snapshot_p, /**< snapshot */
+ size_t snapshot_size, /**< size of snapshot */
+ size_t func_index, /**< index of primary function */
+ uint32_t exec_snapshot_opts, /**< jerry_exec_snapshot_opts_t option bits */
+ bool as_function) /** < specify if the loaded snapshot should be returned as a function */
{
JERRY_ASSERT (snapshot_p != NULL);
+ uint32_t allowed_opts = (JERRY_SNAPSHOT_EXEC_COPY_DATA | JERRY_SNAPSHOT_EXEC_ALLOW_STATIC);
+
+ if ((exec_snapshot_opts & ~(allowed_opts)) != 0)
+ {
+ ecma_raise_range_error (ECMA_ERR_MSG ("Unsupported exec snapshot flags specified."));
+ return ecma_create_error_reference_from_context ();
+ }
+
static const char * const invalid_version_error_p = "Invalid snapshot version or unsupported features present";
static const char * const invalid_format_error_p = "Invalid snapshot format";
const uint8_t *snapshot_data_p = (uint8_t *) snapshot_p;
if (snapshot_size <= sizeof (jerry_snapshot_header_t))
{
- return ecma_raise_type_error (invalid_format_error_p);
+ ecma_raise_type_error (invalid_format_error_p);
+ return ecma_create_error_reference_from_context ();
}
const jerry_snapshot_header_t *header_p = (const jerry_snapshot_header_t *) snapshot_data_p;
|| header_p->version != JERRY_SNAPSHOT_VERSION
|| !snapshot_check_global_flags (header_p->global_flags))
{
- return ecma_raise_type_error (invalid_version_error_p);
+ ecma_raise_type_error (invalid_version_error_p);
+ return ecma_create_error_reference_from_context ();
}
- if (header_p->lit_table_offset >= snapshot_size)
+ if (header_p->lit_table_offset > snapshot_size)
{
- return ecma_raise_type_error (invalid_version_error_p);
+ ecma_raise_type_error (invalid_version_error_p);
+ return ecma_create_error_reference_from_context ();
}
if (func_index >= header_p->number_of_funcs)
{
- return ecma_raise_range_error (ECMA_ERR_MSG ("Function index is higher than maximum"));
+ ecma_raise_range_error (ECMA_ERR_MSG ("Function index is higher than maximum"));
+ return ecma_create_error_reference_from_context ();
}
JERRY_ASSERT ((header_p->lit_table_offset % sizeof (uint32_t)) == 0);
- const uint8_t *literal_base_p;
- const uint8_t *number_base_p;
+ uint32_t func_offset = header_p->func_offsets[func_index];
+ ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) (snapshot_data_p + func_offset);
- literal_base_p = ecma_snapshot_get_literals_base ((uint32_t *) (snapshot_data_p + header_p->lit_table_offset),
- &number_base_p);
+ if (bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION)
+ {
+ if (!(exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_ALLOW_STATIC))
+ {
+ ecma_raise_common_error (ECMA_ERR_MSG ("Static snapshots not allowed"));
+ return ecma_create_error_reference_from_context ();
+ }
- ecma_compiled_code_t *bytecode_p;
+ if (exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_COPY_DATA)
+ {
+ ecma_raise_common_error (ECMA_ERR_MSG ("Static snapshots cannot be copied into memory"));
+ return ecma_create_error_reference_from_context ();
+ }
+ }
+ else
+ {
+ const uint8_t *literal_base_p = (uint8_t *) (snapshot_data_p + header_p->lit_table_offset);
- uint32_t func_offset = header_p->func_offsets[func_index] & ~JERRY_SNAPSHOT_EVAL_CONTEXT;
- bytecode_p = snapshot_load_compiled_code (snapshot_data_p + func_offset,
- 0,
- literal_base_p,
- number_base_p,
- copy_bytecode);
+ bytecode_p = snapshot_load_compiled_code ((const uint8_t *) bytecode_p,
+ literal_base_p,
+ (exec_snapshot_opts & JERRY_SNAPSHOT_EXEC_COPY_DATA) != 0);
- if (bytecode_p == NULL)
- {
- return ecma_raise_type_error (invalid_format_error_p);
+ if (bytecode_p == NULL)
+ {
+ return ecma_raise_type_error (invalid_format_error_p);
+ }
}
ecma_value_t ret_val;
ecma_object_t *lex_env_p = ecma_get_global_environment ();
ecma_object_t *func_obj_p = ecma_op_create_function_object (lex_env_p,
bytecode_p);
- ecma_bytecode_deref (bytecode_p);
+ if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
+ {
+ ecma_bytecode_deref (bytecode_p);
+ }
ret_val = ecma_make_object_value (func_obj_p);
}
- else if (header_p->func_offsets[func_index] & JERRY_SNAPSHOT_EVAL_CONTEXT)
- {
- ret_val = vm_run_eval (bytecode_p, false);
- }
else
{
ret_val = vm_run_global (bytecode_p);
- ecma_bytecode_deref (bytecode_p);
+ if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
+ {
+ ecma_bytecode_deref (bytecode_p);
+ }
}
if (ECMA_IS_VALUE_ERROR (ret_val))
{
- return ecma_create_error_reference (JERRY_CONTEXT (error_value));
+ return ecma_create_error_reference_from_context ();
}
return ret_val;
-} /* jerry_snapshot_result_at */
+} /* jerry_snapshot_result */
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
/**
* thrown error - otherwise
*/
jerry_value_t
-jerry_exec_snapshot_at (const uint32_t *snapshot_p, /**< snapshot */
- size_t snapshot_size, /**< size of snapshot */
- size_t func_index, /**< index of primary function */
- bool copy_bytecode) /**< flag, indicating whether the passed snapshot
- * buffer should be copied to the engine's memory.
- * If set the engine should not reference the buffer
- * after the function returns (in this case, the passed
- * buffer could be freed after the call).
- * Otherwise (if the flag is not set) - the buffer could only be
- * freed after the engine stops (i.e. after call to jerry_cleanup). */
-{
-#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
- return jerry_snapshot_result_at (snapshot_p, snapshot_size, func_index, copy_bytecode, false);
-#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
- JERRY_UNUSED (snapshot_p);
- JERRY_UNUSED (snapshot_size);
- JERRY_UNUSED (func_index);
- JERRY_UNUSED (copy_bytecode);
-
- return ECMA_VALUE_FALSE;
-#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
-} /* jerry_exec_snapshot_at */
-
-/**
- * Execute snapshot from specified buffer
- *
- * Note:
- * returned value must be freed with jerry_release_value, when it is no longer needed.
- *
- * @return result of bytecode - if run was successful
- * thrown error - otherwise
- */
-jerry_value_t
jerry_exec_snapshot (const uint32_t *snapshot_p, /**< snapshot */
size_t snapshot_size, /**< size of snapshot */
- bool copy_bytecode) /**< flag, indicating whether the passed snapshot
- * buffer should be copied to the engine's memory.
- * If set the engine should not reference the buffer
- * after the function returns (in this case, the passed
- * buffer could be freed after the call).
- * Otherwise (if the flag is not set) - the buffer could only be
- * freed after the engine stops (i.e. after call to jerry_cleanup). */
+ size_t func_index, /**< index of primary function */
+ uint32_t exec_snapshot_opts) /**< jerry_exec_snapshot_opts_t option bits */
{
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
- return jerry_exec_snapshot_at (snapshot_p, snapshot_size, 0, copy_bytecode);
+ return jerry_snapshot_result (snapshot_p, snapshot_size, func_index, exec_snapshot_opts, false);
#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
JERRY_UNUSED (snapshot_p);
JERRY_UNUSED (snapshot_size);
- JERRY_UNUSED (copy_bytecode);
+ JERRY_UNUSED (func_index);
+ JERRY_UNUSED (exec_snapshot_opts);
return ECMA_VALUE_FALSE;
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
static void
scan_snapshot_functions (const uint8_t *buffer_p, /**< snapshot buffer start */
const uint8_t *buffer_end_p, /**< snapshot buffer end */
- const uint8_t *literal_base_p, /**< start of literal data */
- const uint8_t *number_base_p) /**< start of number data */
+ ecma_collection_header_t *lit_pool_p, /**< list of known values */
+ const uint8_t *literal_base_p) /**< start of literal data */
{
JERRY_ASSERT (buffer_end_p > buffer_p);
ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
- if (bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
+ if ((bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
+ && !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
{
- jmem_cpointer_t *literal_start_p;
+ ecma_value_t *literal_start_p;
+ uint32_t argument_end;
uint32_t const_literal_end;
if (bytecode_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{
- literal_start_p = (jmem_cpointer_t *) (buffer_p + sizeof (cbc_uint16_arguments_t));
+ literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint16_arguments_t));
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) buffer_p;
- const_literal_end = args_p->const_literal_end;
+ argument_end = args_p->argument_end;
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
else
{
- literal_start_p = (jmem_cpointer_t *) (buffer_p + sizeof (cbc_uint8_arguments_t));
+ literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint8_arguments_t));
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) buffer_p;
- const_literal_end = args_p->const_literal_end;
+ argument_end = args_p->argument_end;
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
for (uint32_t i = 0; i < const_literal_end; i++)
{
- if (literal_start_p[i] != JMEM_CP_NULL)
+ if ((literal_start_p[i] & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET)
+ {
+ ecma_value_t lit_value = ecma_snapshot_get_literal (literal_base_p, literal_start_p[i]);
+ literal_start_p[i] = lit_value;
+ ecma_save_literals_append_value (lit_value, lit_pool_p);
+ }
+ }
+
+ if (bytecode_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED)
+ {
+ uint8_t *byte_p = (uint8_t *) bytecode_p;
+ byte_p += ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
+ literal_start_p = ((ecma_value_t *) byte_p) - argument_end;
+
+ for (uint32_t i = 0; i < argument_end; i++)
{
- literal_start_p[i] = ecma_snapshot_get_literal (literal_base_p, number_base_p, literal_start_p[i]);
+ if ((literal_start_p[i] & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET)
+ {
+ ecma_value_t lit_value = ecma_snapshot_get_literal (literal_base_p, literal_start_p[i]);
+ literal_start_p[i] = lit_value;
+ ecma_save_literals_append_value (lit_value, lit_pool_p);
+ }
}
}
}
*/
static void
update_literal_offsets (uint8_t *buffer_p, /**< snapshot buffer start */
- const uint8_t *buffer_end_p, /**< snapshot buffer start */
+ const uint8_t *buffer_end_p, /**< snapshot buffer end */
lit_mem_to_snapshot_id_map_entry_t *lit_map_p) /**< literal map */
{
JERRY_ASSERT (buffer_end_p > buffer_p);
ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) buffer_p;
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
- if (bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
+ if ((bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
+ && !(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
{
- jmem_cpointer_t *literal_start_p;
+ ecma_value_t *literal_start_p;
+ uint32_t argument_end;
uint32_t const_literal_end;
if (bytecode_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{
- literal_start_p = (jmem_cpointer_t *) (buffer_p + sizeof (cbc_uint16_arguments_t));
+ literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint16_arguments_t));
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) buffer_p;
- const_literal_end = args_p->const_literal_end;
+ argument_end = args_p->argument_end;
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
else
{
- literal_start_p = (jmem_cpointer_t *) (buffer_p + sizeof (cbc_uint8_arguments_t));
+ literal_start_p = (ecma_value_t *) (buffer_p + sizeof (cbc_uint8_arguments_t));
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) buffer_p;
- const_literal_end = args_p->const_literal_end;
+ argument_end = args_p->argument_end;
+ const_literal_end = (uint32_t) (args_p->const_literal_end - args_p->register_end);
}
for (uint32_t i = 0; i < const_literal_end; i++)
{
- if (literal_start_p[i] != JMEM_CP_NULL)
+ if (ecma_is_value_string (literal_start_p[i])
+ || ecma_is_value_float_number (literal_start_p[i]))
{
lit_mem_to_snapshot_id_map_entry_t *current_p = lit_map_p;
literal_start_p[i] = current_p->literal_offset;
}
}
+
+ if (bytecode_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED)
+ {
+ uint8_t *byte_p = (uint8_t *) bytecode_p;
+ byte_p += ((size_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
+ literal_start_p = ((ecma_value_t *) byte_p) - argument_end;
+
+ for (uint32_t i = 0; i < argument_end; i++)
+ {
+ if (literal_start_p[i] != ECMA_VALUE_EMPTY)
+ {
+ lit_mem_to_snapshot_id_map_entry_t *current_p = lit_map_p;
+
+ while (current_p->literal_id != literal_start_p[i])
+ {
+ current_p++;
+ }
+
+ literal_start_p[i] = current_p->literal_offset;
+ }
+ }
+ }
}
buffer_p += code_size;
return 0;
}
+ ecma_collection_header_t *lit_pool_p = ecma_new_values_collection ();
+
for (uint32_t i = 0; i < number_of_snapshots; i++)
{
if (inp_buffer_sizes_p[i] < sizeof (jerry_snapshot_header_t))
{
*error_p = "invalid snapshot file";
+ ecma_free_values_collection (lit_pool_p, ECMA_COLLECTION_NO_COPY);
return 0;
}
|| !snapshot_check_global_flags (header_p->global_flags))
{
*error_p = "invalid snapshot version or unsupported features present";
+ ecma_free_values_collection (lit_pool_p, ECMA_COLLECTION_NO_COPY);
return 0;
}
merged_global_flags |= header_p->global_flags;
- uint32_t start_offset = header_p->func_offsets[0] & ~JERRY_SNAPSHOT_EVAL_CONTEXT;
+ uint32_t start_offset = header_p->func_offsets[0];
const uint8_t *data_p = (const uint8_t *) inp_buffers_p[i];
- const uint8_t *literal_base_p;
- const uint8_t *number_base_p;
-
- literal_base_p = ecma_snapshot_get_literals_base ((uint32_t *) (data_p + header_p->lit_table_offset),
- &number_base_p);
+ const uint8_t *literal_base_p = (uint8_t *) (data_p + header_p->lit_table_offset);
JERRY_ASSERT (header_p->number_of_funcs > 0);
scan_snapshot_functions (data_p + start_offset,
data_p + header_p->lit_table_offset,
- literal_base_p,
- number_base_p);
+ lit_pool_p,
+ literal_base_p);
}
JERRY_ASSERT (number_of_funcs > 0);
if (functions_size >= out_buffer_size)
{
*error_p = "output buffer is too small";
+ ecma_free_values_collection (lit_pool_p, ECMA_COLLECTION_NO_COPY);
return 0;
}
lit_mem_to_snapshot_id_map_entry_t *lit_map_p;
uint32_t literals_num;
- if (!ecma_save_literals_for_snapshot (out_buffer_p,
+ if (!ecma_save_literals_for_snapshot (lit_pool_p,
+ out_buffer_p,
out_buffer_size,
&functions_size,
&lit_map_p,
{
const jerry_snapshot_header_t *current_header_p = (const jerry_snapshot_header_t *) inp_buffers_p[i];
- uint32_t start_offset = current_header_p->func_offsets[0] & ~JERRY_SNAPSHOT_EVAL_CONTEXT;
+ uint32_t start_offset = current_header_p->func_offsets[0];
memcpy (dst_p,
((const uint8_t *) inp_buffers_p[i]) + start_offset,
JERRY_ASSERT ((uint32_t) (dst_p - (uint8_t *) out_buffer_p) == header_p->lit_table_offset);
- jmem_heap_free_block (lit_map_p, literals_num * sizeof (lit_mem_to_snapshot_id_map_entry_t));
+ if (lit_map_p != NULL)
+ {
+ jmem_heap_free_block (lit_map_p, literals_num * sizeof (lit_mem_to_snapshot_id_map_entry_t));
+ }
*error_p = NULL;
return functions_size;
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
ecma_value_t parse_status;
ecma_compiled_code_t *bytecode_data_p;
+
+#ifdef JERRY_ENABLE_LINE_INFO
+ JERRY_CONTEXT (resource_name) = ECMA_VALUE_UNDEFINED;
+#endif /* JERRY_ENABLE_LINE_INFO */
+
parse_status = parser_parse_script (NULL,
0,
source_p,
ecma_free_value (parse_status);
+ ecma_collection_header_t *lit_pool_p = ecma_new_values_collection ();
+ ecma_save_literals_add_compiled_code (bytecode_data_p, lit_pool_p);
+
ecma_bytecode_deref (bytecode_data_p);
- ecma_lit_storage_item_t *string_list_p = JERRY_CONTEXT (string_list_first_p);
lit_utf8_size_t literal_count = 0;
+ ecma_value_t *iterator_p = ecma_collection_iterator_init (lit_pool_p);
/* Count the valid and non-magic identifiers in the list. */
- while (string_list_p != NULL)
+ while (iterator_p != NULL)
{
- for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
+ if (ecma_is_value_string (*iterator_p))
{
- if (string_list_p->values[i] != JMEM_CP_NULL)
+ ecma_string_t *literal_p = ecma_get_string_from_value (*iterator_p);
+
+ /* We don't save a literal which isn't a valid identifier or it's a magic string. */
+ if (ecma_get_string_magic (literal_p) == LIT_MAGIC_STRING__COUNT
+ && ecma_string_is_valid_identifier (literal_p))
{
- ecma_string_t *literal_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- string_list_p->values[i]);
- /* We don't save a literal which isn't a valid identifier
- or it's a magic string. */
- if (ecma_get_string_magic (literal_p) == LIT_MAGIC_STRING__COUNT
- && ecma_string_is_valid_identifier (literal_p))
- {
- literal_count++;
- }
+ literal_count++;
}
}
- string_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, string_list_p->next_cp);
+ iterator_p = ecma_collection_iterator_next (iterator_p);
}
if (literal_count == 0)
{
+ ecma_free_values_collection (lit_pool_p, ECMA_COLLECTION_NO_COPY);
return 0;
}
JMEM_DEFINE_LOCAL_ARRAY (literal_array, literal_count, ecma_string_t *);
lit_utf8_size_t literal_idx = 0;
- string_list_p = JERRY_CONTEXT (string_list_first_p);
+ iterator_p = ecma_collection_iterator_init (lit_pool_p);
- while (string_list_p != NULL)
+ while (iterator_p != NULL)
{
- for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
+ if (ecma_is_value_string (*iterator_p))
{
- if (string_list_p->values[i] != JMEM_CP_NULL)
- {
- ecma_string_t *literal_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- string_list_p->values[i]);
+ ecma_string_t *literal_p = ecma_get_string_from_value (*iterator_p);
- if (ecma_get_string_magic (literal_p) == LIT_MAGIC_STRING__COUNT
- && ecma_string_is_valid_identifier (literal_p))
- {
- literal_array[literal_idx++] = literal_p;
- }
+ if (ecma_get_string_magic (literal_p) == LIT_MAGIC_STRING__COUNT
+ && ecma_string_is_valid_identifier (literal_p))
+ {
+ literal_array[literal_idx++] = literal_p;
}
}
- string_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, string_list_p->next_cp);
+ iterator_p = ecma_collection_iterator_next (iterator_p);
}
+ ecma_free_values_collection (lit_pool_p, ECMA_COLLECTION_NO_COPY);
+
/* Sort the strings by size at first, then lexicographically. */
jerry_save_literals_sort (literal_array, literal_count);
#endif /* JERRY_ENABLE_SNAPSHOT_SAVE */
} /* jerry_parse_and_save_literals */
-size_t jerry_parse_and_save_function_snapshot (const jerry_char_t *source_p, /**< function body source */
- size_t source_size, /**< function body size */
- const jerry_char_t *args_p, /**< arguments string */
- size_t args_size, /**< arguments string size */
- bool is_strict, /**< strict mode */
- uint32_t *buffer_p, /**< buffer to save snapshot to */
- size_t buffer_size) /**< the buffer's size */
+/**
+ * Generate snapshot function from specified source and arguments
+ *
+ * @return size of snapshot (a number value), if it was generated succesfully
+ * (i.e. there are no syntax errors in source code, buffer size is sufficient,
+ * and snapshot support is enabled in current configuration through JERRY_ENABLE_SNAPSHOT_SAVE),
+ * error object otherwise
+ */
+jerry_value_t
+jerry_generate_function_snapshot (const jerry_char_t *resource_name_p, /**< script resource name */
+ size_t resource_name_length, /**< script resource name length */
+ const jerry_char_t *source_p, /**< script source */
+ size_t source_size, /**< script source size */
+ const jerry_char_t *args_p, /**< arguments string */
+ size_t args_size, /**< arguments string size */
+ uint32_t generate_snapshot_opts, /**< jerry_generate_snapshot_opts_t option bits */
+ uint32_t *buffer_p, /**< buffer to save snapshot to */
+ size_t buffer_size) /**< the buffer's size */
{
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
- return jerry_parse_and_save_snapshot_with_args (source_p,
- source_size,
- args_p,
- args_size,
- true,
- is_strict,
- buffer_p,
- buffer_size);
+ uint32_t allowed_opts = (JERRY_SNAPSHOT_SAVE_STATIC | JERRY_SNAPSHOT_SAVE_STRICT);
+
+ if ((generate_snapshot_opts & ~(allowed_opts)) != 0)
+ {
+ const char *error_message_p = "Unsupported generate snapshot flags specified.";
+ return jerry_create_error (JERRY_ERROR_RANGE, (const jerry_char_t *) error_message_p);
+ }
+
+ return jerry_generate_snapshot_with_args (resource_name_p,
+ resource_name_length,
+ source_p,
+ source_size,
+ args_p,
+ args_size,
+ generate_snapshot_opts,
+ buffer_p,
+ buffer_size);
#else /* !JERRY_ENABLE_SNAPSHOT_SAVE */
+ JERRY_UNUSED (resource_name_p);
+ JERRY_UNUSED (resource_name_length);
JERRY_UNUSED (source_p);
JERRY_UNUSED (source_size);
JERRY_UNUSED (args_p);
JERRY_UNUSED (args_size);
- JERRY_UNUSED (is_strict);
+ JERRY_UNUSED (generate_snapshot_opts);
JERRY_UNUSED (buffer_p);
JERRY_UNUSED (buffer_size);
return 0;
#endif /* JERRY_ENABLE_SNAPSHOT_SAVE */
-} /* jerry_parse_and_save_function_snapshot */
-
-jerry_value_t jerry_load_function_snapshot_at (const uint32_t *function_snapshot_p, /**< snapshot of the function(s) */
- const size_t function_snapshot_size, /**< size of the snapshot */
- size_t func_index, /**< index of the function to load */
- bool copy_bytecode) /**< flag, indicating whether the passed snapshot
- * buffer should be copied to the engine's memory.
- * If set the engine should not reference
- * the buffer after the function returns
- * (in this case, the passed buffer could be freed
- * after the call).
- * Otherwise (if the flag is not set) - the buffer
- * could only be freed after the engine stops
- * (i.e. after call to jerry_cleanup). */
+} /* jerry_generate_function_snapshot */
+
+/**
+ * Load function from specified snapshot buffer
+ *
+ * Note:
+ * returned value must be freed with jerry_release_value, when it is no longer needed.
+ *
+ * @return result of bytecode - if run was successful
+ * thrown error - otherwise
+ */
+jerry_value_t
+jerry_load_function_snapshot (const uint32_t *function_snapshot_p, /**< snapshot of the function(s) */
+ const size_t function_snapshot_size, /**< size of the snapshot */
+ size_t func_index, /**< index of the function to load */
+ uint32_t exec_snapshot_opts) /**< jerry_exec_snapshot_opts_t option bits */
{
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
- return jerry_snapshot_result_at (function_snapshot_p, function_snapshot_size, func_index, copy_bytecode, true);
+ return jerry_snapshot_result (function_snapshot_p, function_snapshot_size, func_index, exec_snapshot_opts, true);
#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
JERRY_UNUSED (function_snapshot_p);
JERRY_UNUSED (function_snapshot_size);
JERRY_UNUSED (func_index);
- JERRY_UNUSED (copy_bytecode);
+ JERRY_UNUSED (exec_snapshot_opts);
return ECMA_VALUE_FALSE;
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
-} /* jerry_load_function_snapshot_at */
+} /* jerry_load_function_snapshot */
} jerry_snapshot_header_t;
/**
- * Evaluate this function on the top of the scope chain.
- */
-#define JERRY_SNAPSHOT_EVAL_CONTEXT 0x1u
-
-/**
* Jerry snapshot magic marker.
*/
#define JERRY_SNAPSHOT_MAGIC (0x5952524Au)
/**
* Jerry snapshot format version.
*/
-#define JERRY_SNAPSHOT_VERSION (8u)
+#define JERRY_SNAPSHOT_VERSION (12u)
/**
* Snapshot configuration flags.
#include "debugger.h"
#include "ecma-alloc.h"
#include "ecma-array-object.h"
+#include "ecma-arraybuffer-object.h"
#include "ecma-builtin-helpers.h"
#include "ecma-builtins.h"
#include "ecma-exceptions.h"
#include "ecma-objects.h"
#include "ecma-objects-general.h"
#include "ecma-promise-object.h"
+#include "ecma-typedarray-object.h"
#include "jcontext.h"
#include "jerryscript.h"
#include "jmem.h"
JERRY_STATIC_ASSERT (sizeof (jerry_value_t) == sizeof (ecma_value_t),
size_of_jerry_value_t_must_be_equal_to_size_of_ecma_value_t);
-JERRY_STATIC_ASSERT ((int) ECMA_ERROR_COMMON == (int) JERRY_ERROR_COMMON
+JERRY_STATIC_ASSERT ((int) ECMA_ERROR_NONE == (int) JERRY_ERROR_NONE
+ && (int) ECMA_ERROR_COMMON == (int) JERRY_ERROR_COMMON
&& (int) ECMA_ERROR_EVAL == (int) JERRY_ERROR_EVAL
&& (int) ECMA_ERROR_RANGE == (int) JERRY_ERROR_RANGE
&& (int) ECMA_ERROR_REFERENCE == (int) JERRY_ERROR_REFERENCE
* Assert that it is correct to call API in current state.
*
* Note:
- * By convention, there can be some states when API could not be invoked.
+ * By convention, there are some states when API could not be invoked.
*
- * While, API can be invoked jerry_api_available flag is set,
- * and while it is incorrect to invoke API - it is not set.
+ * The API can be and only be invoked when the ECMA_STATUS_API_AVAILABLE
+ * flag is set.
*
* This procedure checks whether the API is available, and terminates
* the engine if it is unavailable. Otherwise it is a no-op.
static inline void __attr_always_inline___
jerry_assert_api_available (void)
{
- if (unlikely (!JERRY_CONTEXT (jerry_api_available)))
+ if (unlikely (!(JERRY_CONTEXT (status_flags) & ECMA_STATUS_API_AVAILABLE)))
{
/* Terminates the execution. */
JERRY_UNREACHABLE ();
static inline void __attr_always_inline___
jerry_make_api_available (void)
{
- JERRY_CONTEXT (jerry_api_available) = true;
+ JERRY_CONTEXT (status_flags) |= ECMA_STATUS_API_AVAILABLE;
} /* jerry_make_api_available */
/**
static inline void __attr_always_inline___
jerry_make_api_unavailable (void)
{
- JERRY_CONTEXT (jerry_api_available) = false;
+ JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_API_AVAILABLE;
} /* jerry_make_api_unavailable */
/**
{
if (ECMA_IS_VALUE_ERROR (value))
{
- value = ecma_create_error_reference (JERRY_CONTEXT (error_value));
+ value = ecma_create_error_reference_from_context ();
}
return value;
jerry_throw (jerry_value_t value) /**< return value */
{
JERRY_ASSERT (ECMA_IS_VALUE_ERROR (value));
- return ecma_create_error_reference (JERRY_CONTEXT (error_value));
+ return ecma_create_error_reference_from_context ();
} /* jerry_throw */
/**
void
jerry_init (jerry_init_flag_t flags) /**< combination of Jerry flags */
{
- if (unlikely (JERRY_CONTEXT (jerry_api_available)))
+ if (unlikely (JERRY_CONTEXT (status_flags) & ECMA_STATUS_API_AVAILABLE))
{
/* This function cannot be called twice unless jerry_cleanup is called. */
JERRY_UNREACHABLE ();
}
#endif /* JERRY_DEBUGGER */
+ for (jerry_context_data_header_t *this_p = JERRY_CONTEXT (context_data_p);
+ this_p != NULL;
+ this_p = this_p->next_p)
+ {
+ if (this_p->manager_p->deinit_cb)
+ {
+ this_p->manager_p->deinit_cb (JERRY_CONTEXT_DATA_HEADER_USER_DATA (this_p));
+ }
+ }
+
+#ifndef CONFIG_DISABLE_ES2015_PROMISE_BUILTIN
+ ecma_free_all_enqueued_jobs ();
+#endif /* CONFIG_DISABLE_ES2015_PROMISE_BUILTIN */
+ ecma_finalize ();
+ jerry_make_api_unavailable ();
+
for (jerry_context_data_header_t *this_p = JERRY_CONTEXT (context_data_p), *next_p = NULL;
this_p != NULL;
this_p = next_p)
{
next_p = this_p->next_p;
- this_p->manager_p->deinit_cb (JERRY_CONTEXT_DATA_HEADER_USER_DATA (this_p));
+ if (this_p->manager_p->finalize_cb)
+ {
+ this_p->manager_p->finalize_cb (JERRY_CONTEXT_DATA_HEADER_USER_DATA (this_p));
+ }
jmem_heap_free_block (this_p, sizeof (jerry_context_data_header_t) + this_p->manager_p->bytes_needed);
}
- ecma_finalize ();
jmem_finalize ();
- jerry_make_api_unavailable ();
} /* jerry_cleanup */
/**
return false;
}
- jmem_heap_stats_t jmem_heap_stats = {0};
+ jmem_heap_stats_t jmem_heap_stats;
+ memset (&jmem_heap_stats, 0, sizeof (jmem_heap_stats));
jmem_heap_get_stats (&jmem_heap_stats);
*out_stats_p = (jerry_heap_stats_t)
jerry_init (flags);
- jerry_value_t parse_ret_val = jerry_parse (script_source_p, script_source_size, false);
+ jerry_value_t parse_ret_val = jerry_parse (NULL, 0, script_source_p, script_source_size, JERRY_PARSE_NO_OPTS);
if (!ecma_is_value_error_reference (parse_ret_val))
{
* thrown error - otherwise
*/
jerry_value_t
-jerry_parse (const jerry_char_t *source_p, /**< script source */
+jerry_parse (const jerry_char_t *resource_name_p, /**< resource name (usually a file name) */
+ size_t resource_name_length, /**< length of resource name */
+ const jerry_char_t *source_p, /**< script source */
size_t source_size, /**< script source size */
- bool is_strict) /**< strict mode */
+ uint32_t parse_opts) /**< jerry_parse_opts_t option bits */
{
+#if defined JERRY_DEBUGGER && !defined JERRY_DISABLE_JS_PARSER
+ if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
+ && resource_name_length > 0)
+ {
+ jerry_debugger_send_string (JERRY_DEBUGGER_SOURCE_CODE_NAME,
+ JERRY_DEBUGGER_NO_SUBTYPE,
+ resource_name_p,
+ resource_name_length);
+ }
+#else /* !(JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER) */
+ JERRY_UNUSED (resource_name_p);
+ JERRY_UNUSED (resource_name_length);
+#endif /* JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER */
+
#ifndef JERRY_DISABLE_JS_PARSER
jerry_assert_api_available ();
+#if defined JERRY_ENABLE_LINE_INFO && !defined JERRY_DISABLE_JS_PARSER
+ JERRY_CONTEXT (resource_name) = ecma_find_or_create_literal_string (resource_name_p,
+ (lit_utf8_size_t) resource_name_length);
+#endif /* JERRY_ENABLE_LINE_INFO && !JERRY_DISABLE_JS_PARSER */
+
ecma_compiled_code_t *bytecode_data_p;
ecma_value_t parse_status;
0,
source_p,
source_size,
- is_strict,
+ (parse_opts & JERRY_PARSE_STRICT_MODE) != 0,
&bytecode_data_p);
if (ECMA_IS_VALUE_ERROR (parse_status))
{
- return ecma_create_error_reference (JERRY_CONTEXT (error_value));
+ return ecma_create_error_reference_from_context ();
}
ecma_free_value (parse_status);
#else /* JERRY_DISABLE_JS_PARSER */
JERRY_UNUSED (source_p);
JERRY_UNUSED (source_size);
- JERRY_UNUSED (is_strict);
+ JERRY_UNUSED (parse_opts);
return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG ("The parser has been disabled.")));
#endif /* !JERRY_DISABLE_JS_PARSER */
} /* jerry_parse */
/**
- * Parse script and construct an ECMAScript function. The lexical
- * environment is set to the global lexical environment. The name
- * (usually a file name) is also passed to this function which is
- * used by the debugger to find the source code.
- *
- * @return function object value - if script was parsed successfully,
- * thrown error - otherwise
- */
-jerry_value_t
-jerry_parse_named_resource (const jerry_char_t *resource_name_p, /**< resource name (usually a file name) */
- size_t resource_name_length, /**< length of resource name */
- const jerry_char_t *source_p, /**< script source */
- size_t source_size, /**< script source size */
- bool is_strict) /**< strict mode */
-{
-#if defined JERRY_DEBUGGER && !defined JERRY_DISABLE_JS_PARSER
- if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
- {
- jerry_debugger_send_string (JERRY_DEBUGGER_SOURCE_CODE_NAME,
- JERRY_DEBUGGER_NO_SUBTYPE,
- resource_name_p,
- resource_name_length);
- }
-#else /* !(JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER) */
- JERRY_UNUSED (resource_name_p);
- JERRY_UNUSED (resource_name_length);
-#endif /* JERRY_DEBUGGER && !JERRY_DISABLE_JS_PARSER */
-
- return jerry_parse (source_p, source_size, is_strict);
-} /* jerry_parse_named_resource */
-
-/**
* Parse function and construct an EcmaScript function. The lexical
* environment is set to the global lexical environment.
*
size_t arg_list_size, /**< script source size */
const jerry_char_t *source_p, /**< script source */
size_t source_size, /**< script source size */
- bool is_strict) /**< strict mode */
+ uint32_t parse_opts) /**< jerry_parse_opts_t option bits */
{
#if defined JERRY_DEBUGGER && !defined JERRY_DISABLE_JS_PARSER
if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
ecma_compiled_code_t *bytecode_data_p;
ecma_value_t parse_status;
+#ifdef JERRY_ENABLE_LINE_INFO
+ JERRY_CONTEXT (resource_name) = ecma_find_or_create_literal_string (resource_name_p,
+ (lit_utf8_size_t) resource_name_length);
+#endif /* JERRY_ENABLE_LINE_INFO */
+
if (arg_list_p == NULL)
{
/* Must not be a NULL value. */
arg_list_size,
source_p,
source_size,
- is_strict,
+ (parse_opts & JERRY_PARSE_STRICT_MODE) != 0,
&bytecode_data_p);
if (ECMA_IS_VALUE_ERROR (parse_status))
{
- return ecma_create_error_reference (JERRY_CONTEXT (error_value));
+ return ecma_create_error_reference_from_context ();
}
ecma_free_value (parse_status);
JERRY_UNUSED (arg_list_size);
JERRY_UNUSED (source_p);
JERRY_UNUSED (source_size);
- JERRY_UNUSED (is_strict);
+ JERRY_UNUSED (parse_opts);
return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG ("The parser has been disabled.")));
#endif /* !JERRY_DISABLE_JS_PARSER */
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (wrong_args_msg_p)));
}
- const ecma_compiled_code_t *bytecode_data_p;
- bytecode_data_p = ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t,
- ext_func_p->u.function.bytecode_cp);
-
- return jerry_return (vm_run_global (bytecode_data_p));
+ return jerry_return (vm_run_global (ecma_op_function_get_compiled_code (ext_func_p)));
} /* jerry_run */
/**
} /* jerry_value_is_undefined */
/**
+ * Perform the base type of the JavaScript value.
+ *
+ * @return jerry_type_t value
+ */
+jerry_type_t
+jerry_value_get_type (const jerry_value_t value) /**< input value to check */
+{
+ jerry_assert_api_available ();
+
+ jerry_value_t argument = jerry_get_arg_value (value);
+ lit_magic_string_id_t lit_id = ecma_get_typeof_lit_id (argument);
+
+ JERRY_ASSERT (lit_id != LIT_MAGIC_STRING__EMPTY);
+
+ switch (lit_id)
+ {
+ case LIT_MAGIC_STRING_UNDEFINED:
+ {
+ return JERRY_TYPE_UNDEFINED;
+ }
+ case LIT_MAGIC_STRING_BOOLEAN:
+ {
+ return JERRY_TYPE_BOOLEAN;
+ }
+ case LIT_MAGIC_STRING_NUMBER:
+ {
+ return JERRY_TYPE_NUMBER;
+ }
+ case LIT_MAGIC_STRING_STRING:
+ {
+ return JERRY_TYPE_STRING;
+ }
+ case LIT_MAGIC_STRING_FUNCTION:
+ {
+ return JERRY_TYPE_FUNCTION;
+ }
+ case LIT_MAGIC_STRING_OBJECT:
+ {
+ /* Based on the ECMA 262 5.1 standard the 'null' value is an object.
+ * Thus we'll do an extra check for 'null' here.
+ */
+ return ecma_is_value_null (argument) ? JERRY_TYPE_NULL : JERRY_TYPE_OBJECT;
+ }
+ default:
+ {
+ JERRY_UNREACHABLE ();
+ break;
+ }
+ }
+
+ return JERRY_TYPE_NONE;
+} /* jerry_value_get_type */
+
+/**
* Check if the specified feature is enabled.
*
* @return true - if the specified feature is enabled,
#ifdef JERRY_VM_EXEC_STOP
|| feature == JERRY_FEATURE_VM_EXEC_STOP
#endif /* JERRY_VM_EXEC_STOP */
+#ifndef CONFIG_DISABLE_JSON_BUILTIN
+ || feature == JERRY_FEATURE_JSON
+#endif /* !CONFIG_DISABLE_JSON_BUILTIN */
+#ifndef CONFIG_DISABLE_ES2015_PROMISE_BUILTIN
+ || feature == JERRY_FEATURE_PROMISE
+#endif /* !CONFIG_DISABLE_ES2015_PROMISE_BUILTIN */
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ || feature == JERRY_FEATURE_TYPEDARRAY
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+#ifndef CONFIG_DISABLE_DATE_BUILTIN
+ || feature == JERRY_FEATURE_DATE
+#endif /* !CONFIG_DISABLE_DATE_BUILTIN */
+#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
+ || feature == JERRY_FEATURE_REGEXP
+#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
+#ifdef JERRY_ENABLE_LINE_INFO
+ || feature == JERRY_FEATURE_LINE_INFO
+#endif /* JERRY_ENABLE_LINE_INFO */
);
} /* jerry_is_feature_enabled */
/**
- * Check if the specified value is an error value.
+ * Check if the specified value is an error or abort value.
*
* @return true - if the error flag of the specified value is true,
* false - otherwise
} /* jerry_value_has_error_flag */
/**
+ * Check if the specified value is an abort value.
+ *
+ * @return true - if both the error and abort flags of the specified value are true,
+ * false - otherwise
+ */
+bool
+jerry_value_has_abort_flag (const jerry_value_t value) /**< api value */
+{
+ jerry_assert_api_available ();
+
+ if (!ecma_is_value_error_reference (value))
+ {
+ return false;
+ }
+
+ ecma_error_reference_t *error_ref_p = ecma_get_error_reference_from_value (value);
+
+ return (error_ref_p->refs_and_flags & ECMA_ERROR_REF_ABORT) != 0;
+} /* jerry_value_has_abort_flag */
+
+/**
* Clear the error flag
*/
void
if (ecma_is_value_error_reference (*value_p))
{
- *value_p = ecma_clear_error_reference (*value_p);
+ *value_p = ecma_clear_error_reference (*value_p, false);
}
} /* jerry_value_clear_error_flag */
/**
- * Set the error flag.
+ * Set the error flag if the value is not an error reference.
*/
void
jerry_value_set_error_flag (jerry_value_t *value_p)
{
jerry_assert_api_available ();
- if (!ecma_is_value_error_reference (*value_p))
+ if (unlikely (ecma_is_value_error_reference (*value_p)))
{
- *value_p = ecma_create_error_reference (*value_p);
+ /* This is a rare case so it is optimized for
+ * binary size rather than performance. */
+ if (!jerry_value_has_abort_flag (*value_p))
+ {
+ return;
+ }
+
+ jerry_value_clear_error_flag (value_p);
}
+
+ *value_p = ecma_create_error_reference (*value_p, true);
} /* jerry_value_set_error_flag */
/**
+ * Set both the abort and error flags if the value is not an error reference.
+ */
+void
+jerry_value_set_abort_flag (jerry_value_t *value_p)
+{
+ jerry_assert_api_available ();
+
+ if (unlikely (ecma_is_value_error_reference (*value_p)))
+ {
+ /* This is a rare case so it is optimized for
+ * binary size rather than performance. */
+ if (jerry_value_has_abort_flag (*value_p))
+ {
+ return;
+ }
+
+ jerry_value_clear_error_flag (value_p);
+ }
+
+ *value_p = ecma_create_error_reference (*value_p, false);
+} /* jerry_value_set_abort_flag */
+
+/**
* If the input value is an error value, then return a new reference to its referenced value.
* Otherwise, return a new reference to the value itself.
*
} /* jerry_get_value_without_error_flag */
/**
+ * Return the type of the Error object if possible.
+ *
+ * @return one of the jerry_error_t value as the type of the Error object
+ * JERRY_ERROR_NONE - if the input value is not an Error object
+ */
+jerry_error_t
+jerry_get_error_type (const jerry_value_t value) /**< api value */
+{
+ jerry_value_t object = jerry_get_arg_value (value);
+
+ if (!ecma_is_value_object (object))
+ {
+ return JERRY_ERROR_NONE;
+ }
+
+ ecma_object_t *object_p = ecma_get_object_from_value (object);
+ ecma_standard_error_t error_type = ecma_get_error_type (object_p);
+
+ return (jerry_error_t) error_type;
+} /* jerry_get_error_type */
+
+/**
* Get boolean from the specified value.
*
* @return true or false.
* Returns 0, if the value parameter is not a string or
* the buffer is not large enough for the whole string.
*
+ * Note:
+ * If the size of the string in jerry value is larger than the size of the
+ * target buffer, the copy will fail.
+ * To copy substring use jerry_substring_to_char_buffer() instead.
+ *
* @return number of bytes, actually copied to the buffer.
*/
jerry_size_t
* Returns 0, if the value parameter is not a string or the buffer
* is not large enough for the whole string.
*
+ * Note:
+ * If the size of the string in jerry value is larger than the size of the
+ * target buffer, the copy will fail.
+ * To copy a substring use jerry_substring_to_utf8_char_buffer() instead.
+ *
* @return number of bytes copied to the buffer.
*/
jerry_size_t
return false;
}
- ecma_string_t str_idx;
- ecma_init_ecma_string_from_uint32 (&str_idx, index);
+ ecma_string_t *str_idx_p = ecma_new_ecma_string_from_uint32 (index);
ecma_value_t ret_value = ecma_op_object_delete (ecma_get_object_from_value (obj_value),
- &str_idx,
+ str_idx_p,
false);
+ ecma_deref_ecma_string (str_idx_p);
+
return ecma_is_value_true (ret_value);
} /* jerry_delete_property_by_index */
return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (wrong_args_msg_p)));
}
- ecma_string_t str_idx;
- ecma_init_ecma_string_from_uint32 (&str_idx, index);
- ecma_value_t ret_value = ecma_op_object_get (ecma_get_object_from_value (obj_value), &str_idx);
+ ecma_string_t *str_idx_p = ecma_new_ecma_string_from_uint32 (index);
+ ecma_value_t ret_value = ecma_op_object_get (ecma_get_object_from_value (obj_value), str_idx_p);
+ ecma_deref_ecma_string (str_idx_p);
return jerry_return (ret_value);
} /* jerry_get_property_by_index */
} /* jerry_set_object_native_handle */
/**
+ * Traverse objects.
+ *
+ * @return true - traversal was interrupted by the callback.
+ * false - otherwise - traversal visited all objects.
+ */
+bool jerry_objects_foreach (jerry_objects_foreach_t foreach_p,
+ void *user_data_p)
+{
+ jerry_assert_api_available ();
+
+ JERRY_ASSERT (foreach_p != NULL);
+
+ for (ecma_object_t *iter_p = JERRY_CONTEXT (ecma_gc_objects_p);
+ iter_p != NULL;
+ iter_p = ECMA_GET_POINTER (ecma_object_t, iter_p->gc_next_cp))
+ {
+ if (!ecma_is_lexical_environment (iter_p)
+ && !foreach_p (ecma_make_object_value (iter_p), user_data_p))
+ {
+ return true;
+ }
+ }
+
+ return false;
+} /* jerry_objects_foreach */
+
+/**
+ * Traverse objects having a given native type info.
+ *
+ * @return true - traversal was interrupted by the callback.
+ * false - otherwise - traversal visited all objects.
+ */
+bool
+jerry_objects_foreach_by_native_info (const jerry_object_native_info_t *native_info_p,
+ jerry_objects_foreach_by_native_info_t foreach_p,
+ void *user_data_p)
+{
+ jerry_assert_api_available ();
+
+ JERRY_ASSERT (native_info_p != NULL);
+ JERRY_ASSERT (foreach_p != NULL);
+
+ ecma_native_pointer_t *native_pointer_p;
+
+ for (ecma_object_t *iter_p = JERRY_CONTEXT (ecma_gc_objects_p);
+ iter_p != NULL;
+ iter_p = ECMA_GET_POINTER (ecma_object_t, iter_p->gc_next_cp))
+ {
+ if (!ecma_is_lexical_environment (iter_p))
+ {
+ native_pointer_p = ecma_get_native_pointer_value (iter_p, LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
+ if (native_pointer_p
+ && ((const jerry_object_native_info_t *) native_pointer_p->u.info_p) == native_info_p
+ && !foreach_p (ecma_make_object_value (iter_p), native_pointer_p->data_p, user_data_p))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+} /* jerry_objects_foreach_by_native_info */
+
+/**
* Get native pointer and its type information, associated with specified object.
*
* Note:
return false;
}
- ecma_collection_iterator_t names_iter;
ecma_object_t *object_p = ecma_get_object_from_value (obj_value);
ecma_collection_header_t *names_p = ecma_op_object_get_property_names (object_p, false, true, true);
- ecma_collection_iterator_init (&names_iter, names_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (names_p);
ecma_value_t property_value = ECMA_VALUE_EMPTY;
bool continuous = true;
- while (continuous
- && ecma_collection_iterator_next (&names_iter))
+ while (continuous && ecma_value_p != NULL)
{
- ecma_string_t *property_name_p = ecma_get_string_from_value (*names_iter.current_value_p);
+ ecma_string_t *property_name_p = ecma_get_string_from_value (*ecma_value_p);
+
property_value = ecma_op_object_get (object_p, property_name_p);
if (ECMA_IS_VALUE_ERROR (property_value))
break;
}
- continuous = foreach_p (*names_iter.current_value_p, property_value, user_data_p);
+ continuous = foreach_p (*ecma_value_p, property_value, user_data_p);
ecma_free_value (property_value);
+
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
}
- ecma_free_values_collection (names_p, true);
+ ecma_free_values_collection (names_p, 0);
if (!ECMA_IS_VALUE_ERROR (property_value))
{
} /* jerry_set_vm_exec_stop_callback */
/**
+ * Get backtrace. The backtrace is an array of strings where
+ * each string contains the position of the corresponding frame.
+ * The array length is zero if the backtrace is not available.
+ *
+ * @return array value
+ */
+jerry_value_t
+jerry_get_backtrace (uint32_t max_depth)
+{
+ return vm_get_backtrace (max_depth);
+} /* jerry_get_backtrace */
+
+/**
+ * Check if the given value is an ArrayBuffer object.
+ *
+ * @return true - if it is an ArrayBuffer object
+ * false - otherwise
+ */
+bool
+jerry_value_is_arraybuffer (const jerry_value_t value) /**< value to check if it is an ArrayBuffer */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ jerry_value_t buffer = jerry_get_arg_value (value);
+ return ecma_is_arraybuffer (buffer);
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (value);
+ return false;
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+} /* jerry_value_is_arraybuffer */
+
+/**
+ * Creates an ArrayBuffer object with the given length (size).
+ *
+ * Notes:
+ * * the length is specified in bytes.
+ * * returned value must be freed with jerry_release_value, when it is no longer needed.
+ * * if the typed arrays are disabled this will return a TypeError.
+ *
+ * @return value of the constructed ArrayBuffer object
+ */
+jerry_value_t
+jerry_create_arraybuffer (const jerry_length_t size) /**< size of the ArrayBuffer to create */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ return jerry_return (ecma_make_object_value (ecma_arraybuffer_new_object (size)));
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (size);
+ return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer not supported.")));
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+} /* jerry_create_arraybuffer */
+
+/**
+ * Creates an ArrayBuffer object with user specified buffer.
+ *
+ * Notes:
+ * * the size is specified in bytes.
+ * * the buffer passed should be at least the specified bytes big.
+ * * if the typed arrays are disabled this will return a TypeError.
+ * * if the size is zero or the buffer_p is a null pointer this will return a RangeError.
+ *
+ * @return value of the construced ArrayBuffer object
+ */
+jerry_value_t
+jerry_create_arraybuffer_external (const jerry_length_t size, /**< size of the buffer to used */
+ uint8_t *buffer_p, /**< buffer to use as the ArrayBuffer's backing */
+ jerry_object_native_free_callback_t free_cb) /**< buffer free callback */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ if (size == 0 || buffer_p == NULL)
+ {
+ return jerry_throw (ecma_raise_range_error (ECMA_ERR_MSG ("invalid buffer size or storage reference")));
+ }
+
+ ecma_object_t *arraybuffer = ecma_arraybuffer_new_object_external (size,
+ buffer_p,
+ (ecma_object_native_free_callback_t) free_cb);
+ return jerry_return (ecma_make_object_value (arraybuffer));
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (size);
+ JERRY_UNUSED (buffer_p);
+ JERRY_UNUSED (free_cb);
+ return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("ArrayBuffer not supported.")));
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+} /* jerry_create_arraybuffer_external */
+
+/**
+ * Copy bytes into the ArrayBuffer from a buffer.
+ *
+ * Note:
+ * * if the object passed is not an ArrayBuffer will return 0.
+ *
+ * @return number of bytes copied into the ArrayBuffer.
+ */
+jerry_length_t
+jerry_arraybuffer_write (const jerry_value_t value, /**< target ArrayBuffer */
+ jerry_length_t offset, /**< start offset of the ArrayBuffer */
+ const uint8_t *buf_p, /**< buffer to copy from */
+ jerry_length_t buf_size) /**< number of bytes to copy from the buffer */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ jerry_value_t buffer = jerry_get_arg_value (value);
+
+ if (!ecma_is_arraybuffer (buffer))
+ {
+ return 0;
+ }
+
+ ecma_object_t *buffer_p = ecma_get_object_from_value (buffer);
+ jerry_length_t length = ecma_arraybuffer_get_length (buffer_p);
+
+ if (offset >= length)
+ {
+ return 0;
+ }
+
+ jerry_length_t copy_count = JERRY_MIN (length - offset, buf_size);
+
+ if (copy_count > 0)
+ {
+ lit_utf8_byte_t *mem_buffer_p = ecma_arraybuffer_get_buffer (buffer_p);
+
+ memcpy ((void *) (mem_buffer_p + offset), (void *) buf_p, copy_count);
+ }
+
+ return copy_count;
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (value);
+ JERRY_UNUSED (offset);
+ JERRY_UNUSED (buf_p);
+ JERRY_UNUSED (buf_size);
+ return 0;
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+} /* jerry_arraybuffer_write */
+
+/**
+ * Copy bytes from a buffer into an ArrayBuffer.
+ *
+ * Note:
+ * * if the object passed is not an ArrayBuffer will return 0.
+ *
+ * @return number of bytes read from the ArrayBuffer.
+ */
+jerry_length_t
+jerry_arraybuffer_read (const jerry_value_t value, /**< ArrayBuffer to read from */
+ jerry_length_t offset, /**< start offset of the ArrayBuffer */
+ uint8_t *buf_p, /**< destination buffer to copy to */
+ jerry_length_t buf_size) /**< number of bytes to copy into the buffer */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ jerry_value_t buffer = jerry_get_arg_value (value);
+
+ if (!ecma_is_arraybuffer (buffer))
+ {
+ return 0;
+ }
+
+ ecma_object_t *buffer_p = ecma_get_object_from_value (buffer);
+ jerry_length_t length = ecma_arraybuffer_get_length (buffer_p);
+
+ if (offset >= length)
+ {
+ return 0;
+ }
+
+ jerry_length_t copy_count = JERRY_MIN (length - offset, buf_size);
+
+ if (copy_count > 0)
+ {
+ lit_utf8_byte_t *mem_buffer_p = ecma_arraybuffer_get_buffer (buffer_p);
+
+ memcpy ((void *) buf_p, (void *) (mem_buffer_p + offset), copy_count);
+ }
+
+ return copy_count;
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (value);
+ JERRY_UNUSED (offset);
+ JERRY_UNUSED (buf_p);
+ JERRY_UNUSED (buf_size);
+ return 0;
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+} /* jerry_arraybuffer_read */
+
+/**
+ * Get the length (size) of the ArrayBuffer in bytes.
+ *
+ * Note:
+ * This is the 'byteLength' property of an ArrayBuffer.
+ *
+ * @return the length of the ArrayBuffer in bytes.
+ */
+jerry_length_t
+jerry_get_arraybuffer_byte_length (const jerry_value_t value) /**< ArrayBuffer */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ jerry_value_t buffer = jerry_get_arg_value (value);
+ if (ecma_is_arraybuffer (buffer))
+ {
+ ecma_object_t *buffer_p = ecma_get_object_from_value (buffer);
+ return ecma_arraybuffer_get_length (buffer_p);
+ }
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (value);
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ return 0;
+} /* jerry_get_arraybuffer_byte_length */
+
+/**
+ * Get a pointer for the start of the ArrayBuffer.
+ *
+ * Note:
+ * * Only valid for ArrayBuffers created with jerry_create_arraybuffer_external.
+ * * This is a high-risk operation as the bounds are not checked
+ * when accessing the pointer elements.
+ * * jerry_release_value must be called on the ArrayBuffer when the pointer is no longer needed.
+ *
+ * @return pointer to the back-buffer of the ArrayBuffer.
+ * pointer is NULL if the parameter is not an ArrayBuffer with external memory
+ or it is not an ArrayBuffer at all.
+ */
+uint8_t *
+jerry_get_arraybuffer_pointer (const jerry_value_t value) /**< Array Buffer to use */
+{
+ jerry_assert_api_available ();
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ jerry_value_t buffer = jerry_get_arg_value (value);
+
+ if (!ecma_is_arraybuffer (buffer))
+ {
+ return NULL;
+ }
+
+ ecma_object_t *buffer_p = ecma_get_object_from_value (buffer);
+ if (ECMA_ARRAYBUFFER_HAS_EXTERNAL_MEMORY (buffer_p))
+ {
+ jerry_acquire_value (value);
+ lit_utf8_byte_t *mem_buffer_p = ecma_arraybuffer_get_buffer (buffer_p);
+ return (uint8_t *const) mem_buffer_p;
+ }
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (value);
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+
+ return NULL;
+} /* jerry_get_arraybuffer_pointer */
+
+
+/**
+ * TypedArray related functions
+ */
+
+/**
+ * Check if the given value is a TypedArray object.
+ *
+ * @return true - if it is a TypedArray object
+ * false - otherwise
+ */
+bool
+jerry_value_is_typedarray (jerry_value_t value) /**< value to check if it is a TypedArray */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ jerry_value_t array = jerry_get_arg_value (value);
+ return ecma_is_typedarray (array);
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (value);
+ return false;
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+} /* jerry_value_is_typedarray */
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+typedef struct
+{
+ jerry_typedarray_type_t api_type;
+ ecma_builtin_id_t prototype_id;
+ lit_magic_string_id_t lit_id;
+ uint8_t element_size_shift;
+} jerry_typedarray_mapping_t;
+
+static jerry_typedarray_mapping_t jerry_typedarray_mappings[] =
+{
+#define TYPEDARRAY_ENTRY(NAME, LIT_NAME, SIZE_SHIFT) \
+ { JERRY_TYPEDARRAY_ ## NAME, ECMA_BUILTIN_ID_ ## NAME ## ARRAY_PROTOTYPE, \
+ LIT_MAGIC_STRING_ ## LIT_NAME ## _ARRAY_UL, SIZE_SHIFT }
+
+ TYPEDARRAY_ENTRY (UINT8, UINT8, 0),
+ TYPEDARRAY_ENTRY (UINT8CLAMPED, UINT8_CLAMPED, 0),
+ TYPEDARRAY_ENTRY (INT8, INT8, 0),
+ TYPEDARRAY_ENTRY (UINT16, UINT16, 1),
+ TYPEDARRAY_ENTRY (INT16, INT16, 1),
+ TYPEDARRAY_ENTRY (UINT32, UINT32, 2),
+ TYPEDARRAY_ENTRY (INT32, INT32, 2),
+ TYPEDARRAY_ENTRY (FLOAT32, FLOAT32, 2),
+#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64
+ TYPEDARRAY_ENTRY (FLOAT64, FLOAT64, 3),
+#endif
+
+#undef TYPEDARRAY_ENTRY
+};
+
+/**
+ * Helper function to get the TypedArray prototype, literal id, and element size shift
+ * information.
+ *
+ * @return true - if the TypedArray information was found
+ * false - if there is no such TypedArray type
+ */
+static bool
+jerry_typedarray_find_by_type (jerry_typedarray_type_t type_name, /**< type of the TypedArray */
+ ecma_builtin_id_t *prototype_id, /**< [out] found prototype object id */
+ lit_magic_string_id_t *lit_id, /**< [out] found literal id */
+ uint8_t *element_size_shift) /**< [out] found element size shift value */
+{
+ JERRY_ASSERT (prototype_id != NULL);
+ JERRY_ASSERT (lit_id != NULL);
+ JERRY_ASSERT (element_size_shift != NULL);
+
+ for (uint32_t i = 0; i < sizeof (jerry_typedarray_mappings) / sizeof (jerry_typedarray_mappings[0]); i++)
+ {
+ if (type_name == jerry_typedarray_mappings[i].api_type)
+ {
+ *prototype_id = jerry_typedarray_mappings[i].prototype_id;
+ *lit_id = jerry_typedarray_mappings[i].lit_id;
+ *element_size_shift = jerry_typedarray_mappings[i].element_size_shift;
+ return true;
+ }
+ }
+
+ return false;
+} /* jerry_typedarray_find_by_type */
+
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+
+/**
+ * Create a TypedArray object with a given type and length.
+ *
+ * Notes:
+ * * returns TypeError if an incorrect type (type_name) is specified.
+ * * byteOffset property will be set to 0.
+ * * byteLength property will be a multiple of the length parameter (based on the type).
+ *
+ * @return - new TypedArray object
+ */
+jerry_value_t
+jerry_create_typedarray (jerry_typedarray_type_t type_name, /**< type of TypedArray to create */
+ jerry_length_t length) /**< element count of the new TypedArray */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ ecma_builtin_id_t prototype_id = 0;
+ lit_magic_string_id_t lit_id = 0;
+ uint8_t element_size_shift = 0;
+
+ if (!jerry_typedarray_find_by_type (type_name, &prototype_id, &lit_id, &element_size_shift))
+ {
+ return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("incorrect type for TypedArray.")));
+ }
+
+ ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id);
+
+ ecma_value_t array_value = ecma_typedarray_create_object_with_length (length,
+ prototype_obj_p,
+ element_size_shift,
+ lit_id);
+ ecma_deref_object (prototype_obj_p);
+
+ JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (array_value));
+
+ return array_value;
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (type_name);
+ JERRY_UNUSED (length);
+ return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("TypedArray not supported.")));
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+} /* jerry_create_typedarray */
+
+/**
+ * Create a TypedArray object using the given arraybuffer and size information.
+ *
+ * Notes:
+ * * returns TypeError if an incorrect type (type_name) is specified.
+ * * this is the 'new %TypedArray%(arraybuffer, byteOffset, length)' equivalent call.
+ *
+ * @return - new TypedArray object
+ */
+jerry_value_t
+jerry_create_typedarray_for_arraybuffer_sz (jerry_typedarray_type_t type_name, /**< type of TypedArray to create */
+ const jerry_value_t arraybuffer, /**< ArrayBuffer to use */
+ jerry_length_t byte_offset, /**< offset for the ArrayBuffer */
+ jerry_length_t length) /**< number of elements to use from ArrayBuffer */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ ecma_builtin_id_t prototype_id = 0;
+ lit_magic_string_id_t lit_id = 0;
+ uint8_t element_size_shift = 0;
+
+ if (!jerry_typedarray_find_by_type (type_name, &prototype_id, &lit_id, &element_size_shift))
+ {
+ return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("incorrect type for TypedArray.")));
+ }
+
+ jerry_value_t buffer = jerry_get_arg_value (arraybuffer);
+ if (!ecma_is_arraybuffer (buffer))
+ {
+ return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Argument is not an ArrayBuffer")));
+ }
+
+ ecma_object_t *prototype_obj_p = ecma_builtin_get (prototype_id);
+ ecma_value_t arguments_p[3] =
+ {
+ arraybuffer,
+ ecma_make_uint32_value (byte_offset),
+ ecma_make_uint32_value (length)
+ };
+
+ ecma_value_t array_value = ecma_op_create_typedarray (arguments_p, 3, prototype_obj_p, element_size_shift, lit_id);
+ ecma_free_value (arguments_p[1]);
+ ecma_free_value (arguments_p[2]);
+ ecma_deref_object (prototype_obj_p);
+
+ return jerry_return (array_value);
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (type_name);
+ JERRY_UNUSED (arraybuffer);
+ JERRY_UNUSED (byte_offset);
+ JERRY_UNUSED (length);
+ return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("TypedArray not supported.")));
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+} /* jerry_create_typedarray_for_arraybuffer_sz */
+
+/**
+ * Create a TypedArray object using the given arraybuffer and size information.
+ *
+ * Notes:
+ * * returns TypeError if an incorrect type (type_name) is specified.
+ * * this is the 'new %TypedArray%(arraybuffer)' equivalent call.
+ *
+ * @return - new TypedArray object
+ */
+jerry_value_t
+jerry_create_typedarray_for_arraybuffer (jerry_typedarray_type_t type_name, /**< type of TypedArray to create */
+ const jerry_value_t arraybuffer) /**< ArrayBuffer to use */
+{
+ jerry_assert_api_available ();
+ jerry_length_t byteLength = jerry_get_arraybuffer_byte_length (arraybuffer);
+ return jerry_create_typedarray_for_arraybuffer_sz (type_name, arraybuffer, 0, byteLength);
+} /* jerry_create_typedarray_for_arraybuffer */
+
+/**
+ * Get the type of the TypedArray.
+ *
+ * @return - type of the TypedArray
+ * - JERRY_TYPEDARRAY_INVALID if the argument is not a TypedArray
+ */
+jerry_typedarray_type_t
+jerry_get_typedarray_type (jerry_value_t value) /**< object to get the TypedArray type */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ jerry_value_t array = jerry_get_arg_value (value);
+ if (!ecma_is_typedarray (array))
+ {
+ return JERRY_TYPEDARRAY_INVALID;
+ }
+
+ ecma_object_t *array_p = ecma_get_object_from_value (array);
+
+ lit_magic_string_id_t class_name_id = ecma_object_get_class_name (array_p);
+ for (uint32_t i = 0; i < sizeof (jerry_typedarray_mappings) / sizeof (jerry_typedarray_mappings[0]); i++)
+ {
+ if (class_name_id == jerry_typedarray_mappings[i].lit_id)
+ {
+ return jerry_typedarray_mappings[i].api_type;
+ }
+ }
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (value);
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+
+ return JERRY_TYPEDARRAY_INVALID;
+} /* jerry_get_typedarray_type */
+
+/**
+ * Get the element count of the TypedArray.
+ *
+ * @return length of the TypedArray.
+ */
+jerry_length_t
+jerry_get_typedarray_length (jerry_value_t value) /**< TypedArray to query */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ jerry_value_t array = jerry_get_arg_value (value);
+ if (ecma_is_typedarray (array))
+ {
+ ecma_object_t *array_p = ecma_get_object_from_value (array);
+ return ecma_typedarray_get_length (array_p);
+ }
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (value);
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+
+ return 0;
+} /* jerry_get_typedarray_length */
+
+/**
+ * Get the underlying ArrayBuffer from a TypedArray.
+ *
+ * Additionally the byteLength and byteOffset properties are also returned
+ * which were specified when the TypedArray was created.
+ *
+ * Note:
+ * the returned value must be freed with a jerry_release_value call
+ *
+ * @return ArrayBuffer of a TypedArray
+ * TypeError if the object is not a TypedArray.
+ */
+jerry_value_t
+jerry_get_typedarray_buffer (jerry_value_t value, /**< TypedArray to get the arraybuffer from */
+ jerry_length_t *byte_offset, /**< [out] byteOffset property */
+ jerry_length_t *byte_length) /**< [out] byteLength property */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
+ jerry_value_t array = jerry_get_arg_value (value);
+ if (!ecma_is_typedarray (array))
+ {
+ return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("Object is not a TypedArray.")));
+ }
+
+ ecma_object_t *array_p = ecma_get_object_from_value (array);
+ uint8_t shift = ecma_typedarray_get_element_size_shift (array_p);
+
+ if (byte_length != NULL)
+ {
+ *byte_length = (jerry_length_t) (ecma_typedarray_get_length (array_p) << shift);
+ }
+
+ if (byte_offset != NULL)
+ {
+ *byte_offset = (jerry_length_t) ecma_typedarray_get_offset (array_p);
+ }
+
+ ecma_object_t *arraybuffer_p = ecma_typedarray_get_arraybuffer (array_p);
+ ecma_ref_object (arraybuffer_p);
+ return jerry_return (ecma_make_object_value (arraybuffer_p));
+#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+ JERRY_UNUSED (value);
+ JERRY_UNUSED (byte_length);
+ JERRY_UNUSED (byte_offset);
+ return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG ("TypedArray is not supported.")));
+#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
+} /* jerry_get_typedarray_buffer */
+
+/**
+ * Create an object from JSON
+ *
+ * Note:
+ * The returned value must be freed with jerry_release_value
+ * @return jerry_value_t from json formated string or an error massage
+ */
+jerry_value_t
+jerry_json_parse (const jerry_char_t *string_p, /**< json string */
+ jerry_size_t string_size) /**< json string size */
+{
+ jerry_assert_api_available ();
+
+#ifndef CONFIG_DISABLE_JSON_BUILTIN
+ ecma_value_t ret_value = ecma_builtin_json_parse_buffer (string_p, string_size);
+
+ if (ecma_is_value_undefined (ret_value))
+ {
+ ret_value = jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG ("JSON string parse error.")));
+ }
+
+ return ret_value;
+#else /* CONFIG_DISABLE_JSON_BUILTIN */
+ JERRY_UNUSED (string_p);
+ JERRY_UNUSED (string_size);
+
+ return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG ("The JSON has been disabled.")));
+#endif /* !CONFIG_DISABLE_JSON_BUILTIN */
+} /* jerry_json_parse */
+
+/**
+ * Create a Json formated string from an object
+ *
+ * Note:
+ * The returned value must be freed with jerry_release_value
+ * @return json formated jerry_value_t or an error massage
+ */
+jerry_value_t
+jerry_json_stringfy (const jerry_value_t object_to_stringify) /**< a jerry_object_t to stringify */
+{
+ jerry_assert_api_available ();
+#ifndef CONFIG_DISABLE_JSON_BUILTIN
+ ecma_value_t ret_value = ecma_builtin_json_string_from_object (object_to_stringify);
+
+ if (ecma_is_value_undefined (ret_value))
+ {
+ ret_value = jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG ("JSON stringify error.")));
+ }
+
+ return ret_value;
+#else /* CONFIG_DISABLE_JSON_BUILTIN */
+ JERRY_UNUSED (object_to_stringify);
+
+ return jerry_throw (ecma_raise_syntax_error (ECMA_ERR_MSG ("The JSON has been disabled.")));
+#endif /* !CONFIG_DISABLE_JSON_BUILTIN */
+} /* jerry_json_stringfy */
+
+/**
* @}
*/
#include <fcntl.h>
#include <unistd.h>
+/* JerryScript debugger protocol is a simplified version of RFC-6455 (WebSockets). */
+
+/**
+ * Last fragment of a Websocket package.
+ */
+#define JERRY_DEBUGGER_WEBSOCKET_FIN_BIT 0x80
+
/**
* Masking-key is available.
*/
#define JERRY_DEBUGGER_WEBSOCKET_LENGTH_MASK 0x7fu
/**
+ * Size of websocket header size.
+ */
+#define JERRY_DEBUGGER_WEBSOCKET_HEADER_SIZE 2
+
+/**
* Payload mask size in bytes of a websocket package.
*/
#define JERRY_DEBUGGER_WEBSOCKET_MASK_SIZE 4
/**
- *
+ * Maximum message size with 1 byte size field.
+ */
+#define JERRY_DEBUGGER_WEBSOCKET_ONE_BYTE_LEN_MAX 125
+
+/**
+ * Waiting for data from the client.
*/
#define JERRY_DEBUGGER_RECEIVE_DATA_MODE \
(JERRY_DEBUGGER_BREAKPOINT_MODE | JERRY_DEBUGGER_CLIENT_SOURCE_MODE)
+/**
+ * WebSocket opcode types.
+ */
+typedef enum
+{
+ JERRY_DEBUGGER_WEBSOCKET_TEXT_FRAME = 1, /**< text frame */
+ JERRY_DEBUGGER_WEBSOCKET_BINARY_FRAME = 2, /**< binary frame */
+ JERRY_DEBUGGER_WEBSOCKET_CLOSE_CONNECTION = 8, /**< close connection */
+ JERRY_DEBUGGER_WEBSOCKET_PING = 9, /**< ping (keep alive) frame */
+ JERRY_DEBUGGER_WEBSOCKET_PONG = 10, /**< reply to ping frame */
+} jerry_websocket_opcode_type_t;
/**
* Header for incoming packets.
{
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED);
- JERRY_CONTEXT (debugger_flags) = (uint8_t) JERRY_DEBUGGER_VM_IGNORE;
+ JERRY_CONTEXT (debugger_flags) = JERRY_DEBUGGER_VM_IGNORE;
if (log_error)
{
struct sockaddr_in addr;
socklen_t sin_size = sizeof (struct sockaddr_in);
+ uint8_t *payload_p = JERRY_CONTEXT (debugger_send_buffer) + JERRY_DEBUGGER_WEBSOCKET_HEADER_SIZE;
+ JERRY_CONTEXT (debugger_send_buffer_payload_p) = payload_p;
+
+ uint8_t max_send_size = (JERRY_DEBUGGER_MAX_BUFFER_SIZE - JERRY_DEBUGGER_WEBSOCKET_HEADER_SIZE);
+ if (max_send_size > JERRY_DEBUGGER_WEBSOCKET_ONE_BYTE_LEN_MAX)
+ {
+ max_send_size = JERRY_DEBUGGER_WEBSOCKET_ONE_BYTE_LEN_MAX;
+ }
+ JERRY_CONTEXT (debugger_max_send_size) = max_send_size;
+
+ uint8_t receive_header_size = (JERRY_DEBUGGER_WEBSOCKET_HEADER_SIZE + JERRY_DEBUGGER_WEBSOCKET_MASK_SIZE);
+ uint8_t max_receive_size = (uint8_t) (JERRY_DEBUGGER_MAX_BUFFER_SIZE - receive_header_size);
+
+ if (max_receive_size > JERRY_DEBUGGER_WEBSOCKET_ONE_BYTE_LEN_MAX)
+ {
+ max_receive_size = JERRY_DEBUGGER_WEBSOCKET_ONE_BYTE_LEN_MAX;
+ }
+ JERRY_CONTEXT (debugger_max_receive_size) = max_receive_size;
+
addr.sin_family = AF_INET;
addr.sin_port = htons (JERRY_CONTEXT (debugger_port));
addr.sin_addr.s_addr = INADDR_ANY;
close (server_socket);
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_CONNECTED);
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_CONNECTED);
bool is_handshake_ok = false;
return false;
}
- if (!jerry_debugger_send_configuration (JERRY_DEBUGGER_MAX_RECEIVE_SIZE))
+ if (!jerry_debugger_send_configuration (max_receive_size))
{
return false;
}
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Connected from: %s\n", inet_ntoa (addr.sin_addr));
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_STOP);
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
JERRY_CONTEXT (debugger_stop_context) = NULL;
return true;
* @return true - if the data was sent successfully to the debugger client,
* false - otherwise
*/
-inline bool __attr_always_inline___
+bool
jerry_debugger_send (size_t data_size) /**< data size */
{
- return jerry_debugger_send_tcp (JERRY_CONTEXT (debugger_send_buffer), data_size);
-} /* jerry_debugger_send */
+ JERRY_ASSERT (data_size <= JERRY_CONTEXT (debugger_max_send_size));
+
+ uint8_t *header_p = JERRY_CONTEXT (debugger_send_buffer);
+ header_p[0] = JERRY_DEBUGGER_WEBSOCKET_FIN_BIT | JERRY_DEBUGGER_WEBSOCKET_BINARY_FRAME;
+ header_p[1] = (uint8_t) data_size;
-JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MAX_RECEIVE_SIZE < 126,
- maximum_debug_message_receive_size_must_be_smaller_than_126);
+ return jerry_debugger_send_tcp (header_p, data_size + JERRY_DEBUGGER_WEBSOCKET_HEADER_SIZE);
+} /* jerry_debugger_send */
/**
* Receive message from the client.
jerry_debugger_receive (jerry_debugger_uint8_data_t **message_data_p) /**< [out] data received from client */
{
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED);
+ JERRY_ASSERT (JERRY_CONTEXT (debugger_max_receive_size) <= JERRY_DEBUGGER_WEBSOCKET_ONE_BYTE_LEN_MAX);
- JERRY_ASSERT (message_data_p != NULL ? (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_RECEIVE_DATA_MODE)
+ JERRY_ASSERT (message_data_p != NULL ? !!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_RECEIVE_DATA_MODE)
: !(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_RECEIVE_DATA_MODE));
JERRY_CONTEXT (debugger_message_delay) = JERRY_DEBUGGER_MESSAGE_FREQUENCY;
}
if ((recv_buffer_p[0] & ~JERRY_DEBUGGER_WEBSOCKET_OPCODE_MASK) != JERRY_DEBUGGER_WEBSOCKET_FIN_BIT
- || (recv_buffer_p[1] & JERRY_DEBUGGER_WEBSOCKET_LENGTH_MASK) > JERRY_DEBUGGER_MAX_RECEIVE_SIZE
+ || (recv_buffer_p[1] & JERRY_DEBUGGER_WEBSOCKET_LENGTH_MASK) > JERRY_CONTEXT (debugger_max_receive_size)
|| !(recv_buffer_p[1] & JERRY_DEBUGGER_WEBSOCKET_MASK_BIT))
{
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Unsupported Websocket message.\n");
#define JERRY_DEBUGGER_MAX_BUFFER_SIZE 128
/**
- * Maximum number of bytes can be received in a single message.
- */
-#define JERRY_DEBUGGER_MAX_SEND_SIZE (JERRY_DEBUGGER_MAX_BUFFER_SIZE - 1)
-
-/**
- * Maximum number of bytes can be received in a single message.
- */
-#define JERRY_DEBUGGER_MAX_RECEIVE_SIZE (JERRY_DEBUGGER_MAX_BUFFER_SIZE - 6)
-
-/**
- * Last fragment of a Websocket package.
- */
-#define JERRY_DEBUGGER_WEBSOCKET_FIN_BIT 0x80
-
-/**
- * WebSocket opcode types.
- */
-typedef enum
-{
- JERRY_DEBUGGER_WEBSOCKET_TEXT_FRAME = 1, /**< text frame */
- JERRY_DEBUGGER_WEBSOCKET_BINARY_FRAME = 2, /**< binary frame */
- JERRY_DEBUGGER_WEBSOCKET_CLOSE_CONNECTION = 8, /**< close connection */
- JERRY_DEBUGGER_WEBSOCKET_PING = 9, /**< ping (keep alive) frame */
- JERRY_DEBUGGER_WEBSOCKET_PONG = 10, /**< reply to ping frame */
-} jerry_websocket_opcode_type_t;
-
-/**
- * Header for outgoing packets.
- */
-typedef struct
-{
- uint8_t ws_opcode; /**< Websocket opcode */
- uint8_t size; /**< size of the message */
-} jerry_debugger_send_header_t;
-
-/**
* Incoming message: next message of string data.
*/
typedef struct
uint32_t uint8_offset; /**< current offset in the client source */
} jerry_debugger_uint8_data_t;
-/**
- * Initialize the header of an outgoing message.
- */
-#define JERRY_DEBUGGER_INIT_SEND_MESSAGE(message_p) \
- (message_p)->header.ws_opcode = JERRY_DEBUGGER_WEBSOCKET_FIN_BIT | JERRY_DEBUGGER_WEBSOCKET_BINARY_FRAME
-
-/**
- * Set the size of an outgoing message from type.
- */
-#define JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE(message_p, type) \
- (message_p)->header.size = (uint8_t) (sizeof (type) - sizeof (jerry_debugger_send_header_t))
-
-/**
- * Set the size of an outgoing message.
- */
-#define JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE(message_p, byte_size) \
- (message_p)->header.size = (uint8_t) (byte_size)
-
bool jerry_debugger_accept_connection (void);
void jerry_debugger_close_connection (void);
#ifdef JERRY_DEBUGGER
-#ifdef HAVE_TIME_H
-#include <time.h>
-#elif defined (HAVE_UNISTD_H)
-#include <unistd.h>
-#endif /* HAVE_TIME_H */
+/**
+ * The number of message types in the debugger should reflect the
+ * debugger versioning.
+ */
+JERRY_STATIC_ASSERT (JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT == 27
+ && JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT == 19
+ && JERRY_DEBUGGER_VERSION == 3,
+ debugger_version_correlates_to_message_type_count);
/**
* Type cast the debugger send buffer into a specific type.
*/
#define JERRY_DEBUGGER_SEND_BUFFER_AS(type, name_p) \
- type *name_p = (type *) (&JERRY_CONTEXT (debugger_send_buffer))
+ type *name_p = (type *) (JERRY_CONTEXT (debugger_send_buffer_payload_p))
/**
* Type cast the debugger receive buffer into a specific type.
* Send backtrace.
*/
static void
-jerry_debugger_send_backtrace (uint8_t *recv_buffer_p) /**< pointer the the received data */
+jerry_debugger_send_backtrace (uint8_t *recv_buffer_p) /**< pointer to the received data */
{
JERRY_DEBUGGER_RECEIVE_BUFFER_AS (jerry_debugger_receive_get_backtrace_t, get_backtrace_p);
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_backtrace_t, backtrace_p);
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (backtrace_p);
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (backtrace_p, jerry_debugger_send_backtrace_t);
backtrace_p->type = JERRY_DEBUGGER_BACKTRACE;
vm_frame_ctx_t *frame_ctx_p = JERRY_CONTEXT (vm_top_context_p);
- uint32_t current_frame = 0;
+ size_t current_frame = 0;
+ const size_t max_frame_count = JERRY_DEBUGGER_SEND_MAX (jerry_debugger_frame_t);
+ const size_t max_message_size = JERRY_DEBUGGER_SEND_SIZE (max_frame_count, jerry_debugger_frame_t);
while (frame_ctx_p != NULL && max_depth > 0)
{
continue;
}
- if (current_frame >= JERRY_DEBUGGER_SEND_MAX (jerry_debugger_frame_t))
+ if (current_frame >= max_frame_count)
{
- if (!jerry_debugger_send (sizeof (jerry_debugger_send_backtrace_t)))
+ if (!jerry_debugger_send (max_message_size))
{
return;
}
size_t message_size = current_frame * sizeof (jerry_debugger_frame_t);
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE (backtrace_p, 1 + message_size);
backtrace_p->type = JERRY_DEBUGGER_BACKTRACE_END;
jerry_debugger_send (sizeof (jerry_debugger_send_type_t) + message_size);
} /* jerry_debugger_send_backtrace */
/**
- * Send result of evaluated expression.
+ * Send result of evaluated expression or throw an error.
*
- * @return true - if no error is occured
+ * @return true - if execution should be resumed
* false - otherwise
*/
static bool
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED);
JERRY_ASSERT (!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_IGNORE));
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_IGNORE);
- ecma_value_t result = ecma_op_eval_chars_buffer (eval_string_p, eval_string_size, true, false);
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) & ~JERRY_DEBUGGER_VM_IGNORE);
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
+ ecma_value_t result = ecma_op_eval_chars_buffer (eval_string_p + 1, eval_string_size - 1, true, false);
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_IGNORE);
if (!ECMA_IS_VALUE_ERROR (result))
{
- ecma_value_t to_string_value = ecma_op_to_string (result);
- ecma_free_value (result);
- result = to_string_value;
+ if (eval_string_p[0] != JERRY_DEBUGGER_EVAL_EVAL)
+ {
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_EXCEPTION_THROWN);
+ JERRY_CONTEXT (error_value) = result;
+
+ /* Stop where the error is caught. */
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
+ JERRY_CONTEXT (debugger_stop_context) = NULL;
+
+ if (eval_string_p[0] == JERRY_DEBUGGER_EVAL_THROW)
+ {
+ JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
+ }
+ else
+ {
+ JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_EXCEPTION;
+ }
+
+ return true;
+ }
+
+ if (!ecma_is_value_string (result))
+ {
+ ecma_value_t to_string_value = ecma_op_to_string (result);
+ ecma_free_value (result);
+ result = to_string_value;
+ }
}
ecma_value_t message = result;
if (ecma_is_value_object (result))
{
- ecma_string_t *message_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE);
-
message = ecma_op_object_find (ecma_get_object_from_value (result),
- message_string_p);
-
- ecma_deref_ecma_string (message_string_p);
+ ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
if (!ecma_is_value_string (message)
|| ecma_string_is_empty (ecma_get_string_from_value (message)))
ecma_free_value (result);
const lit_utf8_byte_t *string_p = lit_get_magic_string_utf8 (id);
- return jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT,
- type,
- string_p,
- strlen ((const char *) string_p));
+ jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT,
+ type,
+ string_p,
+ strlen ((const char *) string_p));
+ return false;
}
}
else
{
- /* Primitve type. */
+ /* Primitive type. */
message = ecma_op_to_string (result);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (message));
}
ecma_string_t *string_p = ecma_get_string_from_value (message);
ECMA_STRING_TO_UTF8_STRING (string_p, buffer_p, buffer_size);
- bool success = jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT, type, buffer_p, buffer_size);
+ jerry_debugger_send_string (JERRY_DEBUGGER_EVAL_RESULT, type, buffer_p, buffer_size);
ECMA_FINALIZE_UTF8_STRING (buffer_p, buffer_size);
ecma_free_value (message);
- return success;
+ return false;
} /* jerry_debugger_send_eval */
/**
void
jerry_debugger_sleep (void)
{
-#ifdef HAVE_TIME_H
- nanosleep (&(const struct timespec)
- {
- JERRY_DEBUGGER_TIMEOUT / 1000, (JERRY_DEBUGGER_TIMEOUT % 1000) * 1000000L /* Seconds, nanoseconds */
- }
- , NULL);
-#elif defined (HAVE_UNISTD_H)
- usleep ((useconds_t) JERRY_DEBUGGER_TIMEOUT * 1000);
-#endif /* HAVE_TIME_H */
+ jerry_port_sleep (JERRY_DEBUGGER_TIMEOUT);
} /* jerry_debugger_sleep */
/**
* false - otherwise
*/
inline bool __attr_always_inline___
-jerry_debugger_process_message (uint8_t *recv_buffer_p, /**< pointer the the received data */
+jerry_debugger_process_message (uint8_t *recv_buffer_p, /**< pointer to the received data */
uint32_t message_size, /**< message size */
bool *resume_exec_p, /**< pointer to the resume exec flag */
uint8_t *expected_message_type_p, /**< message type */
return true;
}
- bool result = false;
+ bool result;
+
if (*expected_message_type_p == JERRY_DEBUGGER_EVAL_PART)
{
- result = jerry_debugger_send_eval (string_p, uint8_data_p->uint8_size);
+ if (jerry_debugger_send_eval (string_p, uint8_data_p->uint8_size))
+ {
+ *resume_exec_p = true;
+ }
+ result = (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) != 0;
}
else
{
result = true;
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags)
- & ~JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
*resume_exec_p = true;
}
{
JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t);
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_STOP);
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
JERRY_CONTEXT (debugger_stop_context) = NULL;
*resume_exec_p = false;
return true;
{
JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t);
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) & ~JERRY_DEBUGGER_VM_STOP);
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_STOP);
JERRY_CONTEXT (debugger_stop_context) = NULL;
*resume_exec_p = true;
return true;
{
JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t);
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_STOP);
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
JERRY_CONTEXT (debugger_stop_context) = NULL;
*resume_exec_p = true;
return true;
{
JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t);
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_VM_STOP);
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
JERRY_CONTEXT (debugger_stop_context) = JERRY_CONTEXT (vm_top_context_p);
*resume_exec_p = true;
return true;
}
+ case JERRY_DEBUGGER_FINISH:
+ {
+ JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t);
+
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_STOP);
+
+ /* This will point to the current context's parent (where the function was called)
+ * and in case of NULL the result will the same as in case of STEP. */
+ JERRY_CONTEXT (debugger_stop_context) = JERRY_CONTEXT (vm_top_context_p->prev_context_p);
+ *resume_exec_p = true;
+ return true;
+ }
+
case JERRY_DEBUGGER_GET_BACKTRACE:
{
JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_get_backtrace_t);
JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_exception_config_t);
JERRY_DEBUGGER_RECEIVE_BUFFER_AS (jerry_debugger_receive_exception_config_t, exception_config_p);
- uint8_t debugger_flags = JERRY_CONTEXT (debugger_flags);
-
if (exception_config_p->enable == 0)
{
- debugger_flags = (uint8_t) (debugger_flags | JERRY_DEBUGGER_VM_IGNORE_EXCEPTION);
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_IGNORE_EXCEPTION);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Stop at exception disabled\n");
}
else
{
- debugger_flags = (uint8_t) (debugger_flags & ~JERRY_DEBUGGER_VM_IGNORE_EXCEPTION);
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_IGNORE_EXCEPTION);
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Stop at exception enabled\n");
}
- JERRY_CONTEXT (debugger_flags) = debugger_flags;
+ return true;
+ }
+
+ case JERRY_DEBUGGER_PARSER_CONFIG:
+ {
+ JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_parser_config_t);
+ JERRY_DEBUGGER_RECEIVE_BUFFER_AS (jerry_debugger_receive_parser_config_t, parser_config_p);
+
+ if (parser_config_p->enable_wait != 0)
+ {
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_PARSER_WAIT);
+ jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Waiting after parsing enabled\n");
+ }
+ else
+ {
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_PARSER_WAIT);
+ jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Waiting after parsing disabled\n");
+ }
+
+ return true;
+ }
+
+ case JERRY_DEBUGGER_PARSER_RESUME:
+ {
+ JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t);
+
+ if (!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_PARSER_WAIT_MODE))
+ {
+ jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Not in parser wait mode\n");
+ jerry_debugger_close_connection ();
+ return false;
+ }
+
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_PARSER_WAIT_MODE);
return true;
}
uint32_t eval_size;
memcpy (&eval_size, eval_first_p->eval_size, sizeof (uint32_t));
- if (eval_size <= JERRY_DEBUGGER_MAX_RECEIVE_SIZE - sizeof (jerry_debugger_receive_eval_first_t))
+ if (eval_size <= JERRY_CONTEXT (debugger_max_receive_size) - sizeof (jerry_debugger_receive_eval_first_t))
{
if (eval_size != message_size - sizeof (jerry_debugger_receive_eval_first_t))
{
return false;
}
- return jerry_debugger_send_eval ((lit_utf8_byte_t *) (eval_first_p + 1), eval_size);
+ if (jerry_debugger_send_eval ((lit_utf8_byte_t *) (eval_first_p + 1), eval_size))
+ {
+ *resume_exec_p = true;
+ }
+
+ return (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED) != 0;
}
jerry_debugger_uint8_data_t *eval_uint8_data_p;
*message_data_p = eval_uint8_data_p;
*expected_message_type_p = JERRY_DEBUGGER_EVAL_PART;
+
return true;
}
uint32_t client_source_size;
memcpy (&client_source_size, client_source_first_p->code_size, sizeof (uint32_t));
- if (client_source_size <= JERRY_DEBUGGER_MAX_RECEIVE_SIZE - sizeof (jerry_debugger_receive_client_source_first_t)
- && client_source_size != message_size - sizeof (jerry_debugger_receive_client_source_first_t))
+ uint32_t header_size = sizeof (jerry_debugger_receive_client_source_first_t);
+
+ if (client_source_size <= JERRY_CONTEXT (debugger_max_receive_size) - header_size
+ && client_source_size != message_size - header_size)
{
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Invalid message size\n");
jerry_debugger_close_connection ();
}
else
{
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags)
- & ~JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
*resume_exec_p = true;
}
return true;
JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t);
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) & ~JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_CLIENT_NO_SOURCE);
+ JERRY_DEBUGGER_UPDATE_FLAGS (JERRY_DEBUGGER_CLIENT_NO_SOURCE, JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
*resume_exec_p = true;
JERRY_DEBUGGER_CHECK_PACKET_SIZE (jerry_debugger_receive_type_t);
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) & ~JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_CONTEXT_RESET_MODE);
+ JERRY_DEBUGGER_UPDATE_FLAGS (JERRY_DEBUGGER_CONTEXT_RESET_MODE, JERRY_DEBUGGER_CLIENT_SOURCE_MODE);
*resume_exec_p = true;
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_breakpoint_hit_t, breakpoint_hit_p);
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (breakpoint_hit_p);
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (breakpoint_hit_p, jerry_debugger_send_breakpoint_hit_t);
breakpoint_hit_p->type = message_type;
vm_frame_ctx_t *frame_ctx_p = JERRY_CONTEXT (vm_top_context_p);
return;
}
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) | JERRY_DEBUGGER_BREAKPOINT_MODE);
+ JERRY_DEBUGGER_UPDATE_FLAGS (JERRY_DEBUGGER_BREAKPOINT_MODE, JERRY_DEBUGGER_VM_EXCEPTION_THROWN);
jerry_debugger_uint8_data_t *uint8_data = NULL;
uint8_data->uint8_size + sizeof (jerry_debugger_uint8_data_t));
}
- JERRY_CONTEXT (debugger_flags) = (uint8_t) (JERRY_CONTEXT (debugger_flags) & ~JERRY_DEBUGGER_BREAKPOINT_MODE);
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_BREAKPOINT_MODE);
JERRY_CONTEXT (debugger_message_delay) = JERRY_DEBUGGER_MESSAGE_FREQUENCY;
} /* jerry_debugger_breakpoint_hit */
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_type_t, message_type_p);
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (message_type_p);
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (message_type_p, jerry_debugger_send_type_t);
message_type_p->type = (uint8_t) type;
jerry_debugger_send (sizeof (jerry_debugger_send_type_t));
endian_data.uint16_value = 1;
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (configuration_p);
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (configuration_p, jerry_debugger_send_configuration_t);
configuration_p->type = JERRY_DEBUGGER_CONFIGURATION;
configuration_p->max_message_size = max_message_size;
configuration_p->cpointer_size = sizeof (jmem_cpointer_t);
configuration_p->little_endian = (endian_data.uint8_value[0] == 1);
+ configuration_p->version = JERRY_DEBUGGER_VERSION;
return jerry_debugger_send (sizeof (jerry_debugger_send_configuration_t));
} /* jerry_debugger_send_configuration */
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_type_t, message_type_p);
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (message_type_p);
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE (message_type_p, 1 + size);
message_type_p->type = type;
memcpy (message_type_p + 1, data, size);
{
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED);
- const size_t max_fragment_len = JERRY_DEBUGGER_SEND_MAX (uint8_t);
+ const size_t max_byte_count = JERRY_DEBUGGER_SEND_MAX (uint8_t);
+ const size_t max_message_size = JERRY_DEBUGGER_SEND_SIZE (max_byte_count, uint8_t);
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_string_t, message_string_p);
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (message_string_p);
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (message_string_p, jerry_debugger_send_string_t);
message_string_p->type = message_type;
- while (string_length > max_fragment_len)
+ if (sub_type != JERRY_DEBUGGER_NO_SUBTYPE)
+ {
+ string_length += 1;
+ }
+
+ while (string_length > max_byte_count)
{
- memcpy (message_string_p->string, string_p, max_fragment_len);
+ memcpy (message_string_p->string, string_p, max_byte_count);
- if (!jerry_debugger_send (sizeof (jerry_debugger_send_string_t)))
+ if (!jerry_debugger_send (max_message_size))
{
return false;
}
- string_length -= max_fragment_len;
- string_p += max_fragment_len;
+ string_length -= max_byte_count;
+ string_p += max_byte_count;
}
- if (sub_type != JERRY_DEBUGGER_NO_SUBTYPE)
- {
- string_length += 1;
- }
-
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE (message_string_p, 1 + string_length);
message_string_p->type = (uint8_t) (message_type + 1);
- memcpy (message_string_p->string, string_p, string_length);
if (sub_type != JERRY_DEBUGGER_NO_SUBTYPE)
{
+ memcpy (message_string_p->string, string_p, string_length - 1);
message_string_p->string[string_length - 1] = sub_type;
}
+ else
+ {
+ memcpy (message_string_p->string, string_p, string_length);
+ }
return jerry_debugger_send (sizeof (jerry_debugger_send_type_t) + string_length);
} /* jerry_debugger_send_string */
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_byte_code_cp_t, byte_code_cp_p);
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (byte_code_cp_p);
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (byte_code_cp_p, jerry_debugger_send_byte_code_cp_t);
byte_code_cp_p->type = (uint8_t) type;
jmem_cpointer_t compiled_code_cp;
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_parse_function_t, message_parse_function_p);
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (message_parse_function_p);
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (message_parse_function_p, jerry_debugger_send_parse_function_t);
message_parse_function_p->type = JERRY_DEBUGGER_PARSE_FUNCTION;
memcpy (message_parse_function_p->line, &line, sizeof (uint32_t));
memcpy (message_parse_function_p->column, &column, sizeof (uint32_t));
JERRY_ASSERT (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED);
JERRY_DEBUGGER_SEND_BUFFER_AS (jerry_debugger_send_memstats_t, memstats_p);
- JERRY_DEBUGGER_INIT_SEND_MESSAGE (memstats_p);
- JERRY_DEBUGGER_SET_SEND_MESSAGE_SIZE_FROM_TYPE (memstats_p, jerry_debugger_send_memstats_t);
memstats_p->type = JERRY_DEBUGGER_MEMSTATS_RECEIVE;
lit_utf8_byte_t data[16];
memcpy (data, lit_get_magic_string_utf8 (string_id), size);
- ecma_string_t message_string;
- ecma_init_ecma_magic_string (&message_string, LIT_MAGIC_STRING_MESSAGE);
-
ecma_property_t *property_p;
property_p = ecma_find_named_property (ecma_get_object_from_value (exception_obj_value),
- &message_string);
+ ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE));
if (property_p == NULL
|| ECMA_PROPERTY_GET_TYPE (*property_p) != ECMA_PROPERTY_TYPE_NAMEDDATA)
/* JerryScript debugger protocol is a simplified version of RFC-6455 (WebSockets). */
/**
+ * JerryScript debugger protocol version.
+ */
+#define JERRY_DEBUGGER_VERSION (3)
+
+/**
* Frequency of calling jerry_debugger_receive() by the VM.
*/
#define JERRY_DEBUGGER_MESSAGE_FREQUENCY 5
/**
* Calculate the maximum number of items for a given type
- * which can be transmitted by one message.
+ * which can be transmitted in one message.
*/
#define JERRY_DEBUGGER_SEND_MAX(type) \
- ((JERRY_DEBUGGER_MAX_SEND_SIZE - sizeof (jerry_debugger_send_header_t) - 1) / sizeof (type))
+ ((size_t) ((JERRY_CONTEXT (debugger_max_send_size) - sizeof (jerry_debugger_send_type_t)) / sizeof (type)))
+
+/**
+ * Calculate the size of a message when a count number of items transmitted.
+ */
+#define JERRY_DEBUGGER_SEND_SIZE(count, type) \
+ ((size_t) ((count * sizeof (type)) + sizeof (jerry_debugger_send_type_t)))
/**
* Debugger operation modes:
{
JERRY_DEBUGGER_CONNECTED = 1u << 0, /**< debugger is connected */
JERRY_DEBUGGER_BREAKPOINT_MODE = 1u << 1, /**< debugger waiting at a breakpoint */
- JERRY_DEBUGGER_VM_STOP = 1u << 2, /**< stop at the next breakpoint regardless it is enabled */
+ JERRY_DEBUGGER_VM_STOP = 1u << 2, /**< stop at the next breakpoint even if disabled */
JERRY_DEBUGGER_VM_IGNORE = 1u << 3, /**< ignore all breakpoints */
- JERRY_DEBUGGER_VM_IGNORE_EXCEPTION = 1u << 4, /**< debugger stop at an exception */
- JERRY_DEBUGGER_CLIENT_SOURCE_MODE = 1u << 5, /**< debugger waiting for client code */
- JERRY_DEBUGGER_CLIENT_NO_SOURCE = 1u << 6, /**< debugger leaving the client source loop */
- JERRY_DEBUGGER_CONTEXT_RESET_MODE = 1u << 7, /**< debugger and engine reinitialization mode */
+ JERRY_DEBUGGER_VM_IGNORE_EXCEPTION = 1u << 4, /**< debugger doesn't stop at any exception */
+ JERRY_DEBUGGER_VM_EXCEPTION_THROWN = 1u << 5, /**< no need to stop for this exception */
+ JERRY_DEBUGGER_PARSER_WAIT = 1u << 6, /**< debugger should wait after parsing is completed */
+ JERRY_DEBUGGER_PARSER_WAIT_MODE = 1u << 7, /**< debugger is waiting after parsing is completed */
+ JERRY_DEBUGGER_CLIENT_SOURCE_MODE = 1u << 8, /**< debugger waiting for client code */
+ JERRY_DEBUGGER_CLIENT_NO_SOURCE = 1u << 9, /**< debugger leaving the client source loop */
+ JERRY_DEBUGGER_CONTEXT_RESET_MODE = 1u << 10, /**< debugger and engine reinitialization mode */
} jerry_debugger_flags_t;
/**
+ * Set debugger flags.
+ */
+#define JERRY_DEBUGGER_SET_FLAGS(flags) \
+ JERRY_CONTEXT (debugger_flags) = (JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags))
+
+/**
+ * Clear debugger flags.
+ */
+#define JERRY_DEBUGGER_CLEAR_FLAGS(flags) \
+ JERRY_CONTEXT (debugger_flags) = (JERRY_CONTEXT (debugger_flags) & (uint32_t) ~(flags))
+
+/**
+ * Set and clear debugger flags.
+ */
+#define JERRY_DEBUGGER_UPDATE_FLAGS(flags_to_set, flags_to_clear) \
+ JERRY_CONTEXT (debugger_flags) = ((JERRY_CONTEXT (debugger_flags) | (uint32_t) (flags_to_set)) \
+ & (uint32_t) ~(flags_to_clear))
+
+/**
* Types for the package.
*/
typedef enum
{
/* Messages sent by the server to client. */
+ /* This is a handshake message, sent once during initialization. */
JERRY_DEBUGGER_CONFIGURATION = 1, /**< debugger configuration */
+ /* These messages are sent by the parser. */
JERRY_DEBUGGER_PARSE_ERROR = 2, /**< parse error */
JERRY_DEBUGGER_BYTE_CODE_CP = 3, /**< byte code compressed pointer */
JERRY_DEBUGGER_PARSE_FUNCTION = 4, /**< parsing a new function */
JERRY_DEBUGGER_SOURCE_CODE_NAME_END = 10, /**< source code name last fragment */
JERRY_DEBUGGER_FUNCTION_NAME = 11, /**< function name fragment */
JERRY_DEBUGGER_FUNCTION_NAME_END = 12, /**< function name last fragment */
- JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP = 13, /**< invalidate byte code compressed pointer */
- JERRY_DEBUGGER_MEMSTATS_RECEIVE = 14, /**< memstats sent to the client*/
- JERRY_DEBUGGER_BREAKPOINT_HIT = 15, /**< notify breakpoint hit */
- JERRY_DEBUGGER_EXCEPTION_HIT = 16, /**< notify exception hit */
- JERRY_DEBUGGER_EXCEPTION_STR = 17, /**< exception string fragment */
- JERRY_DEBUGGER_EXCEPTION_STR_END = 18, /**< exception string last fragment */
- JERRY_DEBUGGER_BACKTRACE = 19, /**< backtrace data */
- JERRY_DEBUGGER_BACKTRACE_END = 20, /**< last backtrace data */
- JERRY_DEBUGGER_EVAL_RESULT = 21, /**< eval result */
- JERRY_DEBUGGER_EVAL_RESULT_END = 22, /**< last part of eval result */
- JERRY_DEBUGGER_WAIT_FOR_SOURCE = 23, /**< engine waiting for a source code */
- JERRY_DEBUGGER_OUTPUT_RESULT = 24, /**< output sent by the program to the debugger */
- JERRY_DEBUGGER_OUTPUT_RESULT_END = 25, /**< last output result data */
+ JERRY_DEBUGGER_WAITING_AFTER_PARSE = 13, /**< engine waiting for a parser resume */
+ /* These messages are generic messages. */
+ JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP = 14, /**< invalidate byte code compressed pointer */
+ JERRY_DEBUGGER_MEMSTATS_RECEIVE = 15, /**< memstats sent to the client */
+ JERRY_DEBUGGER_BREAKPOINT_HIT = 16, /**< notify breakpoint hit */
+ JERRY_DEBUGGER_EXCEPTION_HIT = 17, /**< notify exception hit */
+ JERRY_DEBUGGER_EXCEPTION_STR = 18, /**< exception string fragment */
+ JERRY_DEBUGGER_EXCEPTION_STR_END = 19, /**< exception string last fragment */
+ JERRY_DEBUGGER_BACKTRACE = 20, /**< backtrace data */
+ JERRY_DEBUGGER_BACKTRACE_END = 21, /**< last backtrace data */
+ JERRY_DEBUGGER_EVAL_RESULT = 22, /**< eval result */
+ JERRY_DEBUGGER_EVAL_RESULT_END = 23, /**< last part of eval result */
+ JERRY_DEBUGGER_WAIT_FOR_SOURCE = 24, /**< engine waiting for source code */
+ JERRY_DEBUGGER_OUTPUT_RESULT = 25, /**< output sent by the program to the debugger */
+ JERRY_DEBUGGER_OUTPUT_RESULT_END = 26, /**< last output result data */
+
+ JERRY_DEBUGGER_MESSAGES_OUT_MAX_COUNT, /**< number of different type of output messages by the debugger */
/* Messages sent by the client to server. */
JERRY_DEBUGGER_FREE_BYTE_CODE_CP = 1, /**< free byte code compressed pointer */
JERRY_DEBUGGER_UPDATE_BREAKPOINT = 2, /**< update breakpoint status */
JERRY_DEBUGGER_EXCEPTION_CONFIG = 3, /**< exception handler config */
- JERRY_DEBUGGER_MEMSTATS = 4, /**< list memory statistics */
- JERRY_DEBUGGER_STOP = 5, /**< stop execution */
- JERRY_DEBUGGER_CLIENT_SOURCE = 6, /**< first message of client source */
- JERRY_DEBUGGER_CLIENT_SOURCE_PART = 7, /**< next message of client source */
- JERRY_DEBUGGER_NO_MORE_SOURCES = 8, /**< no more sources notification */
- JERRY_DEBUGGER_CONTEXT_RESET = 9, /**< context reset request */
+ JERRY_DEBUGGER_PARSER_CONFIG = 4, /**< parser config */
+ JERRY_DEBUGGER_MEMSTATS = 5, /**< list memory statistics */
+ JERRY_DEBUGGER_STOP = 6, /**< stop execution */
+ /* The following message is only available in waiting after parse mode. */
+ JERRY_DEBUGGER_PARSER_RESUME = 7, /**< stop waiting after parse */
+ /* The following four messages are only available in client switch mode. */
+ JERRY_DEBUGGER_CLIENT_SOURCE = 8, /**< first message of client source */
+ JERRY_DEBUGGER_CLIENT_SOURCE_PART = 9, /**< next message of client source */
+ JERRY_DEBUGGER_NO_MORE_SOURCES = 10, /**< no more sources notification */
+ JERRY_DEBUGGER_CONTEXT_RESET = 11, /**< context reset request */
/* The following messages are only available in breakpoint
* mode and they switch the engine to run mode. */
- JERRY_DEBUGGER_CONTINUE = 10, /**< continue execution */
- JERRY_DEBUGGER_STEP = 11, /**< next breakpoint, step into functions */
- JERRY_DEBUGGER_NEXT = 12, /**< next breakpoint in the same context */
+ JERRY_DEBUGGER_CONTINUE = 12, /**< continue execution */
+ JERRY_DEBUGGER_STEP = 13, /**< next breakpoint, step into functions */
+ JERRY_DEBUGGER_NEXT = 14, /**< next breakpoint in the same context */
+ JERRY_DEBUGGER_FINISH = 15, /**< Continue running just after the function in the current stack frame returns */
/* The following messages are only available in breakpoint
* mode and this mode is kept after the message is processed. */
- JERRY_DEBUGGER_GET_BACKTRACE = 13, /**< get backtrace */
- JERRY_DEBUGGER_EVAL = 14, /**< first message of evaluating a string */
- JERRY_DEBUGGER_EVAL_PART = 15, /**< next message of evaluating a string */
+ JERRY_DEBUGGER_GET_BACKTRACE = 16, /**< get backtrace */
+ JERRY_DEBUGGER_EVAL = 17, /**< first message of evaluating a string */
+ JERRY_DEBUGGER_EVAL_PART = 18, /**< next message of evaluating a string */
+
+ JERRY_DEBUGGER_MESSAGES_IN_MAX_COUNT, /**< number of different type of input messages */
} jerry_debugger_header_type_t;
/**
- * Subtypes of eval_result.
- */
+ * Subtypes of eval.
+ */
+typedef enum
+{
+ JERRY_DEBUGGER_EVAL_EVAL = 0, /**< evaluate expression */
+ JERRY_DEBUGGER_EVAL_THROW = 1, /**< evaluate expression and throw the result */
+ JERRY_DEBUGGER_EVAL_ABORT = 2, /**< evaluate expression and abrot with the result */
+} jerry_debugger_eval_type_t;
+
+/**
+ * Subtypes of eval_result.
+ */
typedef enum
{
JERRY_DEBUGGER_EVAL_OK = 1, /**< eval result, no error */
- JERRY_DEBUGGER_EVAL_ERROR = 2, /**< eval result when an error is occured */
-} jerry_debugger_eval_subtype_t;
+ JERRY_DEBUGGER_EVAL_ERROR = 2, /**< eval result when an error has occurred */
+} jerry_debugger_eval_result_type_t;
/**
- * Subtypes of output_result.
- */
+ * Subtypes of output_result.
+ */
typedef enum
{
JERRY_DEBUGGER_OUTPUT_OK = 1, /**< output result, no error */
*/
typedef struct
{
- jerry_debugger_send_header_t header; /**< message header */
uint8_t type; /**< type of the message */
uint8_t max_message_size; /**< maximum incoming message size */
uint8_t cpointer_size; /**< size of compressed pointers */
uint8_t little_endian; /**< little endian machine */
+ uint8_t version; /**< debugger version */
} jerry_debugger_send_configuration_t;
/**
*/
typedef struct
{
- jerry_debugger_send_header_t header; /**< message header */
uint8_t type; /**< type of the message */
} jerry_debugger_send_type_t;
*/
typedef struct
{
- jerry_debugger_send_header_t header; /**< message header */
uint8_t type; /**< type of the message */
- uint8_t string[JERRY_DEBUGGER_SEND_MAX (uint8_t)]; /**< string data */
+ uint8_t string[]; /**< string data */
} jerry_debugger_send_string_t;
/**
*/
typedef struct
{
- jerry_debugger_send_header_t header; /**< message header */
uint8_t type; /**< type of the message */
uint8_t line[sizeof (uint32_t)]; /**< value data */
uint8_t column[sizeof (uint32_t)]; /**< value data */
*/
typedef struct
{
- jerry_debugger_send_header_t header; /**< message header */
uint8_t type; /**< type of the message */
uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */
} jerry_debugger_send_byte_code_cp_t;
*/
typedef struct
{
- jerry_debugger_send_header_t header; /**< message header */
uint8_t type; /**< type of the message */
uint8_t allocated_bytes[sizeof (uint32_t)]; /**< allocated bytes */
uint8_t byte_code_bytes[sizeof (uint32_t)]; /**< byte code bytes */
*/
typedef struct
{
- jerry_debugger_send_header_t header; /**< message header */
uint8_t type; /**< type of the message */
uint8_t byte_code_cp[sizeof (jmem_cpointer_t)]; /**< byte code compressed pointer */
uint8_t offset[sizeof (uint32_t)]; /**< breakpoint offset */
*/
typedef struct
{
- jerry_debugger_send_header_t header; /**< message header */
uint8_t type; /**< type of the message */
- jerry_debugger_frame_t frames[JERRY_DEBUGGER_SEND_MAX (jerry_debugger_frame_t)]; /**< frames */
+ jerry_debugger_frame_t frames[]; /**< frames */
} jerry_debugger_send_backtrace_t;
+/**
+ * Incoming message: set behaviour when exception occures.
+ */
typedef struct
{
uint8_t type; /**< type of the message */
} jerry_debugger_receive_exception_config_t;
/**
+ * Incoming message: set parser configuration.
+ */
+typedef struct
+{
+ uint8_t type; /**< type of the message */
+ uint8_t enable_wait; /**< non-zero: wait after parsing is completed */
+} jerry_debugger_receive_parser_config_t;
+
+/**
* Incoming message: get backtrace.
*/
typedef struct
DEALLOC (ecma_type)
DECLARE_ROUTINES_FOR (number)
-DECLARE_ROUTINES_FOR (collection_header)
-DECLARE_ROUTINES_FOR (collection_chunk)
/**
* Allocate memory for ecma-object
void ecma_dealloc_number (ecma_number_t *number_p);
/**
- * Allocate memory for header of a collection
- *
- * @return pointer to allocated memory
- */
-ecma_collection_header_t *ecma_alloc_collection_header (void);
-
-/**
- * Dealloc memory from the collection's header
- */
-void ecma_dealloc_collection_header (ecma_collection_header_t *collection_header_p);
-
-/**
- * Allocate memory for non-first chunk of a collection
- *
- * @return pointer to allocated memory
- */
-ecma_collection_chunk_t *ecma_alloc_collection_chunk (void);
-
-/**
- * Dealloc memory from non-first chunk of a collection
- */
-void ecma_dealloc_collection_chunk (ecma_collection_chunk_t *collection_chunk_p);
-
-/**
* Allocate memory for ecma-string descriptor
*
* @return pointer to allocated memory
{
case ECMA_PROPERTY_TYPE_NAMEDDATA:
{
- if (ECMA_PROPERTY_GET_NAME_TYPE (property) == ECMA_STRING_CONTAINER_MAGIC_STRING
+ if (ECMA_PROPERTY_GET_NAME_TYPE (property) == ECMA_DIRECT_STRING_MAGIC
&& property_pair_p->names_cp[index] >= LIT_NEED_MARK_MAGIC_STRING__COUNT)
{
break;
}
case ECMA_PROPERTY_TYPE_SPECIAL:
{
- JERRY_ASSERT (ECMA_PROPERTY_GET_SPECIAL_PROPERTY_TYPE (&property) == ECMA_SPECIAL_PROPERTY_DELETED
- || ECMA_PROPERTY_GET_SPECIAL_PROPERTY_TYPE (&property) == ECMA_SPECIAL_PROPERTY_HASHMAP);
+ JERRY_ASSERT (property == ECMA_PROPERTY_TYPE_HASHMAP
+ || property == ECMA_PROPERTY_TYPE_DELETED);
break;
}
default:
}
/* Mark all reactions. */
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, ((ecma_promise_object_t *) ext_object_p)->fulfill_reactions);
+ ecma_value_t *ecma_value_p;
+ ecma_value_p = ecma_collection_iterator_init (((ecma_promise_object_t *) ext_object_p)->fulfill_reactions);
- while (ecma_collection_iterator_next (&iter))
+ while (ecma_value_p != NULL)
{
- ecma_gc_set_object_visited (ecma_get_object_from_value (*iter.current_value_p));
+ ecma_gc_set_object_visited (ecma_get_object_from_value (*ecma_value_p));
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
}
- ecma_collection_iterator_init (&iter, ((ecma_promise_object_t *) ext_object_p)->reject_reactions);
+ ecma_value_p = ecma_collection_iterator_init (((ecma_promise_object_t *) ext_object_p)->reject_reactions);
- while (ecma_collection_iterator_next (&iter))
+ while (ecma_value_p != NULL)
{
- ecma_gc_set_object_visited (ecma_get_object_from_value (*iter.current_value_p));
+ ecma_gc_set_object_visited (ecma_get_object_from_value (*ecma_value_p));
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
}
}
{
ecma_property_header_t *prop_iter_p = ecma_get_property_list (object_p);
+ if (prop_iter_p != NULL && prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP)
+ {
+ prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
+ prop_iter_p->next_property_cp);
+ }
+
while (prop_iter_p != NULL)
{
- JERRY_ASSERT (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP
- || ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
+ JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
ecma_gc_mark_property ((ecma_property_pair_t *) prop_iter_p, 0);
ecma_gc_mark_property ((ecma_property_pair_t *) prop_iter_p, 1);
jmem_cpointer_t name_cp = prop_pair_p->names_cp[i];
/* Call the native's free callback. */
- if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_STRING_CONTAINER_MAGIC_STRING
+ if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_MAGIC
&& (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|| name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER))
{
}
}
- /* Both must be deleted. */
- JERRY_ASSERT (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_DELETED
- && prop_iter_p->types[1] == ECMA_PROPERTY_TYPE_DELETED);
-
prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
prop_iter_p->next_property_cp);
case LIT_MAGIC_STRING_REGEXP_UL:
{
- ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
- ext_object_p->u.class_prop.u.value);
+ ecma_compiled_code_t *bytecode_p;
+ bytecode_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t,
+ ext_object_p->u.class_prop.u.value);
+
if (bytecode_p != NULL)
{
ecma_bytecode_deref (bytecode_p);
case LIT_MAGIC_STRING_ARRAY_BUFFER_UL:
{
ecma_length_t arraybuffer_length = ext_object_p->u.class_prop.u.length;
- size_t size = sizeof (ecma_extended_object_t) + arraybuffer_length;
+ size_t size;
+
+ if (ECMA_ARRAYBUFFER_HAS_EXTERNAL_MEMORY (ext_object_p))
+ {
+ size = sizeof (ecma_arraybuffer_external_info);
+
+ /* Call external free callback if any. */
+ ecma_arraybuffer_external_info *array_p = (ecma_arraybuffer_external_info *) ext_object_p;
+ JERRY_ASSERT (array_p != NULL);
+
+ if (array_p->free_cb != NULL)
+ {
+ (array_p->free_cb) (array_p->buffer_p);
+ }
+ }
+ else
+ {
+ size = sizeof (ecma_extended_object_t) + arraybuffer_length;
+ }
+
ecma_dealloc_extended_object (object_p, size);
return;
}
-
#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
#ifndef CONFIG_DISABLE_ES2015_PROMISE_BUILTIN
case LIT_MAGIC_STRING_PROMISE_UL:
{
ecma_free_value_if_not_object (ext_object_p->u.class_prop.u.value);
- ecma_free_values_collection (((ecma_promise_object_t *) object_p)->fulfill_reactions, false);
- ecma_free_values_collection (((ecma_promise_object_t *) object_p)->reject_reactions, false);
+ ecma_free_values_collection (((ecma_promise_object_t *) object_p)->fulfill_reactions,
+ ECMA_COLLECTION_NO_REF_OBJECTS);
+ ecma_free_values_collection (((ecma_promise_object_t *) object_p)->reject_reactions,
+ ECMA_COLLECTION_NO_REF_OBJECTS);
ecma_dealloc_extended_object (object_p, sizeof (ecma_promise_object_t));
return;
}
/* Function with byte-code (not a built-in function). */
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+ if (ext_func_p->u.function.bytecode_cp != ECMA_NULL_POINTER)
+ {
+ ecma_bytecode_deref (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
+ ext_func_p->u.function.bytecode_cp));
+ ecma_dealloc_extended_object (object_p, sizeof (ecma_extended_object_t));
+ }
+ else
+ {
+ ecma_dealloc_extended_object (object_p, sizeof (ecma_static_function_t));
+ }
+#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
ecma_bytecode_deref (ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
ext_func_p->u.function.bytecode_cp));
-
ecma_dealloc_extended_object (object_p, sizeof (ecma_extended_object_t));
+#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
return;
}
{
ecma_arrow_function_t *arrow_func_p = (ecma_arrow_function_t *) object_p;
- ecma_bytecode_deref (ECMA_GET_NON_NULL_POINTER (ecma_compiled_code_t,
- arrow_func_p->bytecode_cp));
-
ecma_free_value_if_not_object (arrow_func_p->this_binding);
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+ if (arrow_func_p->bytecode_cp != ECMA_NULL_POINTER)
+ {
+ ecma_bytecode_deref (ECMA_GET_NON_NULL_POINTER (ecma_compiled_code_t,
+ arrow_func_p->bytecode_cp));
+ ecma_dealloc_extended_object (object_p, sizeof (ecma_arrow_function_t));
+ }
+ else
+ {
+ ecma_dealloc_extended_object (object_p, sizeof (ecma_static_arrow_function_t));
+ }
+#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
+ ecma_bytecode_deref (ECMA_GET_NON_NULL_POINTER (ecma_compiled_code_t,
+ arrow_func_p->bytecode_cp));
ecma_dealloc_extended_object (object_p, sizeof (ecma_arrow_function_t));
+#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
return;
}
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
case ECMA_PSEUDO_ARRAY_ARGUMENTS:
{
ecma_length_t formal_params_number = ext_object_p->u.pseudo_array.u1.length;
- jmem_cpointer_t *arg_Literal_p = (jmem_cpointer_t *) (ext_object_p + 1);
+ ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
for (ecma_length_t i = 0; i < formal_params_number; i++)
{
- if (arg_Literal_p[i] != JMEM_CP_NULL)
+ if (arg_Literal_p[i] != ECMA_VALUE_EMPTY)
{
- ecma_string_t *name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, arg_Literal_p[i]);
+ ecma_string_t *name_p = ecma_get_string_from_value (arg_Literal_p[i]);
ecma_deref_ecma_string (name_p);
}
}
- size_t formal_params_size = formal_params_number * sizeof (jmem_cpointer_t);
+ size_t formal_params_size = formal_params_number * sizeof (ecma_value_t);
ecma_dealloc_extended_object (object_p, sizeof (ecma_extended_object_t) + formal_params_size);
return;
}
{
--JERRY_CONTEXT (ecma_prop_hashmap_alloc_state);
}
- JERRY_CONTEXT (ecma_prop_hashmap_alloc_last_is_hs_gc) = false;
+ JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_HIGH_SEV_GC;
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
/*
JERRY_ASSERT (severity == JMEM_FREE_UNUSED_MEMORY_SEVERITY_HIGH);
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
- if (JERRY_CONTEXT (ecma_prop_hashmap_alloc_last_is_hs_gc))
+ if (JERRY_CONTEXT (status_flags) & ECMA_STATUS_HIGH_SEV_GC)
{
JERRY_CONTEXT (ecma_prop_hashmap_alloc_state) = ECMA_PROP_HASHMAP_ALLOC_MAX;
}
else if (JERRY_CONTEXT (ecma_prop_hashmap_alloc_state) < ECMA_PROP_HASHMAP_ALLOC_MAX)
{
++JERRY_CONTEXT (ecma_prop_hashmap_alloc_state);
- JERRY_CONTEXT (ecma_prop_hashmap_alloc_last_is_hs_gc) = true;
+ JERRY_CONTEXT (status_flags) |= ECMA_STATUS_HIGH_SEV_GC;
}
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
} ecma_init_flag_t;
/**
+ * JerryScript status flags.
+ */
+typedef enum
+{
+ ECMA_STATUS_API_AVAILABLE = (1u << 0), /**< api available */
+ ECMA_STATUS_DIRECT_EVAL = (1u << 1), /**< eval is called directly */
+#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
+ ECMA_STATUS_HIGH_SEV_GC = (1u << 2), /**< last gc run was a high severity run */
+#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
+ ECMA_STATUS_EXCEPTION = (1u << 3), /**< last exception is a normal exception */
+} ecma_status_flag_t;
+
+/**
* Type of ecma value
*/
typedef enum
{
ECMA_TYPE_DIRECT = 0, /**< directly encoded value, a 28 bit signed integer or a simple value */
- ECMA_TYPE_FLOAT = 1, /**< pointer to a 64 or 32 bit floating point number */
- ECMA_TYPE_STRING = 2, /**< pointer to description of a string */
+ ECMA_TYPE_STRING = 1, /**< pointer to description of a string */
+ ECMA_TYPE_FLOAT = 2, /**< pointer to a 64 or 32 bit floating point number */
ECMA_TYPE_OBJECT = 3, /**< pointer to description of an object */
+ ECMA_TYPE_DIRECT_STRING = 5, /**< directly encoded string values */
ECMA_TYPE_ERROR = 7, /**< pointer to description of an error reference */
+ ECMA_TYPE_COLLECTION_CHUNK = ECMA_TYPE_ERROR, /**< pointer to description of a collection chunk */
+ ECMA_TYPE_SNAPSHOT_OFFSET = ECMA_TYPE_ERROR, /**< offset to a snapshot number/string */
ECMA_TYPE___MAX = ECMA_TYPE_ERROR /** highest value for ecma types */
} ecma_type_t;
/**
* Description of an ecma value
*
- * Bit-field structure: type (2) | error (1) | value (29)
+ * Bit-field structure: type (3) | value (29)
*/
typedef uint32_t ecma_value_t;
#endif /* UINTPTR_MAX <= UINT32_MAX */
/**
- * Mask for ecma types in ecma_type_t
+ * Mask for ecma types in ecma_value_t
*/
#define ECMA_VALUE_TYPE_MASK 0x7u
/**
- * Shift for value part in ecma_type_t
+ * Shift for value part in ecma_value_t
*/
#define ECMA_VALUE_SHIFT 3
} ecma_native_pointer_t;
/**
- * Special property identifiers.
- */
-typedef enum
-{
- ECMA_SPECIAL_PROPERTY_DELETED, /**< deleted property */
-
- /* Note: when new special types are added
- * ECMA_PROPERTY_IS_PROPERTY_PAIR must be updated as well. */
- ECMA_SPECIAL_PROPERTY_HASHMAP, /**< hashmap property */
-
- ECMA_SPECIAL_PROPERTY__COUNT /**< Number of special property types */
-} ecma_internal_property_id_t;
-
-/**
* Property's 'Writable' attribute's values description.
*/
typedef enum
#define ECMA_PROPERTY_FLAG_SHIFT 2
/**
- * Define special property type.
- */
-#define ECMA_SPECIAL_PROPERTY_VALUE(type) \
- ((uint8_t) (ECMA_PROPERTY_TYPE_SPECIAL | ((type) << ECMA_PROPERTY_FLAG_SHIFT)))
-
-/**
- * Type of deleted property.
- */
-#define ECMA_PROPERTY_TYPE_DELETED ECMA_SPECIAL_PROPERTY_VALUE (ECMA_SPECIAL_PROPERTY_DELETED)
-
-/**
- * Type of hash-map property.
- */
-#define ECMA_PROPERTY_TYPE_HASHMAP ECMA_SPECIAL_PROPERTY_VALUE (ECMA_SPECIAL_PROPERTY_HASHMAP)
-
-/**
- * Type of property not found.
- */
-#define ECMA_PROPERTY_TYPE_NOT_FOUND ECMA_PROPERTY_TYPE_DELETED
-
-/**
- * Type of property not found and no more searching in the proto chain.
- */
-#define ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP ECMA_PROPERTY_TYPE_HASHMAP
-
-/**
* Property flag list (for ECMA_PROPERTY_TYPE_NAMEDDATA
* and ECMA_PROPERTY_TYPE_NAMEDACCESSOR).
*/
#define ECMA_PROPERTY_NAME_TYPE_SHIFT (ECMA_PROPERTY_FLAG_SHIFT + 4)
/**
- * Property name is a generic string.
+ * Special property identifiers.
+ */
+typedef enum
+{
+ /* Note: when new special types are added
+ * ECMA_PROPERTY_IS_PROPERTY_PAIR must be updated as well. */
+ ECMA_SPECIAL_PROPERTY_HASHMAP, /**< hashmap property */
+ ECMA_SPECIAL_PROPERTY_DELETED, /**< deleted property */
+
+ ECMA_SPECIAL_PROPERTY__COUNT /**< Number of special property types */
+} ecma_internal_property_id_t;
+
+/**
+ * Define special property type.
+ */
+#define ECMA_SPECIAL_PROPERTY_VALUE(type) \
+ ((uint8_t) (ECMA_PROPERTY_TYPE_SPECIAL | ((type) << ECMA_PROPERTY_NAME_TYPE_SHIFT)))
+
+/**
+ * Type of deleted property.
*/
-#define ECMA_PROPERTY_NAME_TYPE_STRING 3
+#define ECMA_PROPERTY_TYPE_DELETED ECMA_SPECIAL_PROPERTY_VALUE (ECMA_SPECIAL_PROPERTY_DELETED)
+
+/**
+ * Type of hash-map property.
+ */
+#define ECMA_PROPERTY_TYPE_HASHMAP ECMA_SPECIAL_PROPERTY_VALUE (ECMA_SPECIAL_PROPERTY_HASHMAP)
+
+/**
+ * Name constant of a deleted property.
+ */
+#ifdef JERRY_CPOINTER_32_BIT
+#define ECMA_PROPERTY_DELETED_NAME 0xffffffffu
+#else /* !JERRY_CPOINTER_32_BIT */
+#define ECMA_PROPERTY_DELETED_NAME 0xffffu
+#endif /* JERRY_CPOINTER_32_BIT */
+
+/**
+ * Type of property not found.
+ */
+#define ECMA_PROPERTY_TYPE_NOT_FOUND ECMA_PROPERTY_TYPE_HASHMAP
+
+/**
+ * Type of property not found and no more searching in the proto chain.
+ */
+#define ECMA_PROPERTY_TYPE_NOT_FOUND_AND_STOP ECMA_PROPERTY_TYPE_DELETED
/**
* Abstract property representation.
(ECMA_PROPERTY_GET_TYPE (property) != ECMA_PROPERTY_TYPE_SPECIAL)
/**
- * Returns the internal property type
- */
-#define ECMA_PROPERTY_GET_SPECIAL_PROPERTY_TYPE(property_p) \
- ((ecma_internal_property_id_t) (*(property_p) >> ECMA_PROPERTY_FLAG_SHIFT))
-
-/**
* Add the offset part to a property for computing its property data pointer.
*/
#define ECMA_PROPERTY_VALUE_ADD_OFFSET(property_p) \
struct
{
uint16_t class_id; /**< class id of the object */
+ uint16_t extra_info; /**< extra information for the object
+ e.g. array buffer type info (external/internal) */
/*
* Description of extra fields. These extra fields depends on the class_id.
ecma_built_in_props_t built_in; /**< built-in object part */
} ecma_extended_built_in_object_t;
+/**
+ * Compiled byte code data.
+ */
+typedef struct
+{
+ uint16_t size; /**< real size >> JMEM_ALIGNMENT_LOG */
+ uint16_t refs; /**< reference counter for the byte code */
+ uint16_t status_flags; /**< various status flags:
+ * CBC_CODE_FLAGS_FUNCTION flag tells whether
+ * the byte code is function or regular expression.
+ * If function, the other flags must be CBC_CODE_FLAGS...
+ * If regexp, the other flags must be RE_FLAG... */
+} ecma_compiled_code_t;
+
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+
+/**
+ * Description of static function objects.
+ */
+typedef struct
+{
+ ecma_extended_object_t header;
+ const ecma_compiled_code_t *bytecode_p;
+} ecma_static_function_t;
+
+#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
+
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
/**
jmem_cpointer_t bytecode_cp; /**< function byte code */
} ecma_arrow_function_t;
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+
+/**
+ * Description of static arrow function objects.
+ */
+typedef struct
+{
+ ecma_arrow_function_t header;
+ const ecma_compiled_code_t *bytecode_p;
+} ecma_static_arrow_function_t;
+
+#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
+
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
/**
*/
#define ECMA_STRING_NOT_ARRAY_INDEX UINT32_MAX
+/*
+ * Ecma-collection: a growable list of ecma-values. Currently the list is
+ * a chain list, where appending new items at the end is cheap operation.
+ *
+ * Enumerating elements is also cheap, since each page is terminated by a
+ * special ecma-value: collection-type. This type has a pointer to the next
+ * chunk. The last chunk is terminated by a NULL pointer. There when the
+ * next value is requested from the iterator it simply checks the next
+ * memory location. If it is not a collection-type value, it returns with
+ * the value. Otherwise it gets the start address of the next chunk, and
+ * return the value there.
+ *
+ * The collection-type value is always the last item of a collection chunk,
+ * even if the chunk is not completely filled with values (this is only true
+ * for the last chunk). Each chunk must have at least one non collection-type
+ * value as well.
+ */
+
+/**
+ * Collection flags.
+ */
+typedef enum
+{
+ ECMA_COLLECTION_NO_REF_OBJECTS = (1u << 0), /**< do not increase the refcount of objects */
+ ECMA_COLLECTION_NO_COPY = (1u << 1), /**< do not copy values */
+} ecma_collection_flag_t;
+
/**
* Description of a collection's header.
*/
typedef struct
{
- /** Number of elements in the collection */
- ecma_length_t unit_number;
-
- /** Compressed pointer to first chunk with collection's data */
- jmem_cpointer_t first_chunk_cp;
-
- /** Compressed pointer to last chunk with collection's data */
- jmem_cpointer_t last_chunk_cp;
+ jmem_cpointer_t first_chunk_cp; /**< compressed pointer to first chunk with collection's data */
+ jmem_cpointer_t last_chunk_cp; /**< compressed pointer to last chunk with collection's data */
+ ecma_length_t item_count; /**< number of items in the collection */
} ecma_collection_header_t;
/**
- * Description of non-first chunk in a collection's chain of chunks
+ * Maximum number of items stored by a collection chunk (excluding the last collection-type value).
+ */
+#define ECMA_COLLECTION_CHUNK_ITEMS 5
+
+/**
+ * Collection chunk item.
*/
typedef struct
{
- /** Characters */
- lit_utf8_byte_t data[ sizeof (uint64_t) - sizeof (jmem_cpointer_t) ];
-
- /** Compressed pointer to next chunk */
- jmem_cpointer_t next_chunk_cp;
+ ecma_value_t items[ECMA_COLLECTION_CHUNK_ITEMS + 1]; /**< ecma-value list, where the last value is a special
+ * collection-type value which points to the next chunk,
+ * so the chunk area is enlarged by one for this value */
} ecma_collection_chunk_t;
/**
+ * Direct string types (2 bit).
+ */
+typedef enum
+{
+ ECMA_DIRECT_STRING_PTR = 0, /**< string is a string pointer, only used by property names */
+ ECMA_DIRECT_STRING_MAGIC = 1, /**< string is a magic string */
+ ECMA_DIRECT_STRING_UINT = 2, /**< string is an unsigned int */
+ ECMA_DIRECT_STRING_MAGIC_EX = 3, /**< string is an extended magic string */
+} ecma_direct_string_type_t;
+
+/**
+ * Maximum value of the immediate part of a direct magic string.
+ * Must be compatible with the immediate property name.
+ */
+#ifdef JERRY_CPOINTER_32_BIT
+#define ECMA_DIRECT_STRING_MAX_IMM 0x07ffffff
+#else /* !JERRY_CPOINTER_32_BIT */
+#define ECMA_DIRECT_STRING_MAX_IMM 0x0000ffff
+#endif /* JERRY_CPOINTER_32_BIT */
+
+/**
+ * Shift for direct string value part in ecma_value_t.
+ */
+#define ECMA_DIRECT_STRING_SHIFT (ECMA_VALUE_SHIFT + 2)
+
+/**
+ * Full mask for direct strings.
+ */
+#define ECMA_DIRECT_STRING_MASK ((uintptr_t) (ECMA_DIRECT_TYPE_MASK | (0x3u << ECMA_VALUE_SHIFT)))
+
+/**
+ * Create an ecma direct string.
+ */
+#define ECMA_CREATE_DIRECT_STRING(type, value) \
+ ((uintptr_t) (ECMA_TYPE_DIRECT_STRING | ((type) << ECMA_VALUE_SHIFT) | (value) << ECMA_DIRECT_STRING_SHIFT))
+
+/**
+ * Checks whether the string is direct.
+ */
+#define ECMA_IS_DIRECT_STRING(string_p) \
+ ((((uintptr_t) (string_p)) & 0x1) != 0)
+
+/**
+ * Checks whether the string is direct.
+ */
+#define ECMA_IS_DIRECT_STRING_WITH_TYPE(string_p, type) \
+ ((((uintptr_t) (string_p)) & ECMA_DIRECT_STRING_MASK) == ECMA_CREATE_DIRECT_STRING (type, 0))
+
+/**
+ * Returns the type of a direct string.
+ */
+#define ECMA_GET_DIRECT_STRING_TYPE(string_p) \
+ ((((uintptr_t) (string_p)) >> ECMA_VALUE_SHIFT) & 0x3)
+
+/**
+ * Shift applied to type conversions.
+ */
+#define ECMA_STRING_TYPE_CONVERSION_SHIFT (ECMA_PROPERTY_NAME_TYPE_SHIFT - ECMA_VALUE_SHIFT)
+
+/**
+ * Converts direct string type to property name type.
+ */
+#define ECMA_DIRECT_STRING_TYPE_TO_PROP_NAME_TYPE(string_p) \
+ ((((uintptr_t) (string_p)) & (0x3 << ECMA_VALUE_SHIFT)) << ECMA_STRING_TYPE_CONVERSION_SHIFT)
+
+/**
+ * Returns the value of a direct string.
+ */
+#define ECMA_GET_DIRECT_STRING_VALUE(string_p) \
+ (((uintptr_t) (string_p)) >> ECMA_DIRECT_STRING_SHIFT)
+
+/**
* Identifier for ecma-string's actual data container
*/
typedef enum
{
- ECMA_STRING_CONTAINER_UINT32_IN_DESC, /**< actual data is UInt32-represeneted Number
- stored locally in the string's descriptor */
- ECMA_STRING_CONTAINER_MAGIC_STRING, /**< the ecma-string is equal to one of ECMA magic strings */
- ECMA_STRING_CONTAINER_MAGIC_STRING_EX, /**< the ecma-string is equal to one of external magic strings */
ECMA_STRING_CONTAINER_HEAP_UTF8_STRING, /**< actual data is on the heap as an utf-8 (cesu8) string
* maximum size is 2^16. */
ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING, /**< actual data is on the heap as an utf-8 (cesu8) string
* maximum size is 2^32. */
+ ECMA_STRING_CONTAINER_UINT32_IN_DESC, /**< actual data is UInt32-represeneted Number
+ stored locally in the string's descriptor */
+ ECMA_STRING_CONTAINER_MAGIC_STRING_EX, /**< the ecma-string is equal to one of external magic strings */
ECMA_STRING_LITERAL_NUMBER, /**< a literal number which is used solely by the literal storage
* so no string processing function supports this type except
lit_utf8_size_t long_utf8_string_size; /**< size of this long utf-8 string in bytes */
uint32_t uint32_number; /**< uint32-represented number placed locally in the descriptor */
- uint32_t magic_string_id; /**< identifier of a magic string (lit_magic_string_id_t) */
uint32_t magic_string_ex_id; /**< identifier of an external magic string (lit_magic_string_ex_id_t) */
- ecma_value_t lit_number; /**< literal number (note: not a regular string type) */
+ ecma_value_t lit_number; /**< number (see ECMA_STRING_LITERAL_NUMBER) */
uint32_t common_uint32_field; /**< for zeroing and comparison in some cases */
} u;
} ecma_string_t;
} ecma_long_string_t;
/**
- * Representation of a thrown value on API level.
+ * Abort flag for error reference.
*/
-typedef struct
-{
- uint32_t refs; /**< reference counter */
- ecma_value_t value; /**< referenced value */
-} ecma_error_reference_t;
+#define ECMA_ERROR_REF_ABORT 0x1
/**
- * Compiled byte code data.
+ * Value for increasing or decreasing the reference counter.
+ */
+#define ECMA_ERROR_REF_ONE (1u << 1)
+
+/**
+ * Maximum value of the reference counter.
+ */
+#define ECMA_ERROR_MAX_REF (UINT32_MAX - 1u)
+
+/**
+ * Representation of a thrown value on API level.
*/
typedef struct
{
- uint16_t size; /**< real size >> JMEM_ALIGNMENT_LOG */
- uint16_t refs; /**< reference counter for the byte code */
- uint16_t status_flags; /**< various status flags:
- * CBC_CODE_FLAGS_FUNCTION flag tells whether
- * the byte code is function or regular expression.
- * If function, the other flags must be CBC_CODE_FLAGS...
- * If regexp, the other flags must be RE_FLAG... */
-} ecma_compiled_code_t;
+ uint32_t refs_and_flags; /**< reference counter */
+ ecma_value_t value; /**< referenced value */
+} ecma_error_reference_t;
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
/**
+ * Extra information for ArrayBuffers.
+ */
+typedef enum
+{
+ ECMA_ARRAYBUFFER_INTERNAL_MEMORY = 0u, /* ArrayBuffer memory is handled internally. */
+ ECMA_ARRAYBUFFER_EXTERNAL_MEMORY = (1u << 0), /* ArrayBuffer created via jerry_create_arraybuffer_external. */
+} ecma_arraybuffer_extra_flag_t;
+
+#define ECMA_ARRAYBUFFER_HAS_EXTERNAL_MEMORY(object_p) \
+ ((((ecma_extended_object_t *) object_p)->u.class_prop.extra_info & ECMA_ARRAYBUFFER_EXTERNAL_MEMORY) != 0)
+
+/**
+ * Struct to store information for ArrayBuffers with external memory.
+ *
+ * The following elements are stored in Jerry memory.
+ *
+ * buffer_p - pointer to the external memory.
+ * free_cb - pointer to a callback function which is called when the ArrayBuffer is freed.
+ */
+typedef struct
+{
+ ecma_extended_object_t extended_object; /**< extended object part */
+ void *buffer_p; /**< external buffer pointer */
+ ecma_object_native_free_callback_t free_cb; /**< the free callback for the above buffer pointer */
+} ecma_arraybuffer_external_info;
+
+/**
* Some internal properties of TypedArray object.
* It is only used when the offset is not 0, and
* the array-length is not buffer-length / element_size.
JERRY_ASSERT (id == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|| id == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
- ecma_string_t name;
- ecma_init_ecma_magic_string (&name, id);
+ ecma_string_t *name_p = ecma_get_magic_string (id);
+ ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
- ecma_property_t *property_p = ecma_find_named_property (obj_p, &name);
bool is_new = (property_p == NULL);
ecma_native_pointer_t *native_pointer_p;
if (is_new)
{
ecma_property_value_t *value_p;
- value_p = ecma_create_named_data_property (obj_p, &name, ECMA_PROPERTY_FLAG_WRITABLE, NULL);
+ value_p = ecma_create_named_data_property (obj_p, name_p, ECMA_PROPERTY_FLAG_WRITABLE, NULL);
native_pointer_p = jmem_heap_alloc_block (sizeof (ecma_native_pointer_t));
native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
}
- JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (&name));
-
native_pointer_p->data_p = data_p;
native_pointer_p->u.info_p = info_p;
JERRY_ASSERT (id == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|| id == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
- ecma_string_t name;
- ecma_init_ecma_magic_string (&name, id);
-
- ecma_property_t *property_p = ecma_find_named_property (obj_p, &name);
-
- JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (&name));
+ ecma_property_t *property_p = ecma_find_named_property (obj_p, ecma_get_magic_string (id));
if (property_p == NULL)
{
JERRY_STATIC_ASSERT (ECMA_STRING_NOT_ARRAY_INDEX == UINT32_MAX,
ecma_string_not_array_index_must_be_equal_to_uint32_max);
-static void
-ecma_init_ecma_string_from_magic_string_id (ecma_string_t *string_p,
- lit_magic_string_id_t magic_string_id);
+JERRY_STATIC_ASSERT ((ECMA_TYPE_DIRECT_STRING & 0x1) != 0,
+ ecma_type_direct_string_must_be_odd_number);
-static void
-ecma_init_ecma_string_from_magic_string_ex_id (ecma_string_t *string_p,
- lit_magic_string_ex_id_t magic_string_ex_id);
+JERRY_STATIC_ASSERT (LIT_MAGIC_STRING__COUNT <= ECMA_DIRECT_STRING_MAX_IMM,
+ all_magic_strings_must_be_encoded_as_direct_string);
-/**
- * Initialize ecma-string descriptor with specified magic string
- */
-static void
-ecma_init_ecma_string_from_magic_string_id (ecma_string_t *string_p, /**< descriptor to initialize */
- lit_magic_string_id_t magic_string_id) /**< identifier of
- the magic string */
-{
- string_p->refs_and_container = ECMA_STRING_CONTAINER_MAGIC_STRING | ECMA_STRING_REF_ONE;
- string_p->hash = (lit_string_hash_t) magic_string_id;
-
- string_p->u.magic_string_id = magic_string_id;
-} /* ecma_init_ecma_string_from_magic_string_id */
+JERRY_STATIC_ASSERT ((int) ECMA_DIRECT_STRING_UINT == (int) ECMA_STRING_CONTAINER_UINT32_IN_DESC
+ && (int) ECMA_DIRECT_STRING_MAGIC_EX == (int) ECMA_STRING_CONTAINER_MAGIC_STRING_EX,
+ ecma_direct_and_container_types_must_match);
-/**
- * Initialize external ecma-string descriptor with specified magic string
- */
-static void
-ecma_init_ecma_string_from_magic_string_ex_id (ecma_string_t *string_p, /**< descriptor to initialize */
- lit_magic_string_ex_id_t magic_string_ex_id) /**< identifier of
- the external magic string */
-{
- string_p->refs_and_container = ECMA_STRING_CONTAINER_MAGIC_STRING_EX | ECMA_STRING_REF_ONE;
- string_p->hash = (lit_string_hash_t) (LIT_MAGIC_STRING__COUNT + magic_string_ex_id);
+JERRY_STATIC_ASSERT (ECMA_PROPERTY_NAME_TYPE_SHIFT > ECMA_VALUE_SHIFT,
+ ecma_property_name_type_shift_must_be_greater_than_ecma_value_shift);
- string_p->u.magic_string_ex_id = magic_string_ex_id;
-} /* ecma_init_ecma_string_from_magic_string_ex_id */
/**
* Convert a string to an unsigned 32 bit value if possible
} /* ecma_string_to_array_index */
/**
+ * Returns the characters and size of a string.
+ *
+ * Note:
+ * UINT type is not supported
+ *
+ * @return byte array start - if the byte array of a string is available
+ * NULL - otherwise
+ */
+static const lit_utf8_byte_t *
+ecma_string_get_chars_fast (const ecma_string_t *string_p, /**< ecma-string */
+ lit_utf8_size_t *size_p) /**< [out] size of the ecma string */
+{
+ if (ECMA_IS_DIRECT_STRING (string_p))
+ {
+ if (ECMA_GET_DIRECT_STRING_TYPE (string_p) == ECMA_DIRECT_STRING_MAGIC)
+ {
+ lit_magic_string_id_t id = (lit_magic_string_id_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+
+ *size_p = lit_get_magic_string_size (id);
+ return lit_get_magic_string_utf8 (id);
+ }
+
+ JERRY_ASSERT (ECMA_GET_DIRECT_STRING_TYPE (string_p) == ECMA_DIRECT_STRING_MAGIC_EX);
+
+ lit_magic_string_ex_id_t id = (lit_magic_string_ex_id_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+
+ *size_p = lit_get_magic_string_ex_size (id);
+ return lit_get_magic_string_ex_utf8 (id);
+ }
+
+ JERRY_ASSERT (string_p->refs_and_container >= ECMA_STRING_REF_ONE);
+
+ switch (ECMA_STRING_GET_CONTAINER (string_p))
+ {
+ case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
+ {
+ *size_p = string_p->u.utf8_string.size;
+ return (const lit_utf8_byte_t *) (string_p + 1);
+ }
+ case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
+ {
+ *size_p = string_p->u.long_utf8_string_size;
+ ecma_long_string_t *long_string_p = (ecma_long_string_t *) string_p;
+ return (const lit_utf8_byte_t *) (long_string_p + 1);
+ }
+ default:
+ {
+ JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
+
+ *size_p = lit_get_magic_string_ex_size (string_p->u.magic_string_ex_id);
+ return lit_get_magic_string_ex_utf8 (string_p->u.magic_string_ex_id);
+ }
+ }
+} /* ecma_string_get_chars_fast */
+
+/**
* Allocate new ecma-string and fill it with characters from the utf8 string
*
* @return pointer to ecma-string descriptor
if (magic_string_ex_id < lit_get_magic_string_ex_count ())
{
- return ecma_get_magic_string_ex (magic_string_ex_id);
+ return ecma_new_ecma_string_from_magic_string_ex_id (magic_string_ex_id);
}
}
} /* ecma_new_ecma_string_from_code_unit */
/**
- * Initialize an ecma-string with an ecma-number
+ * Allocate new ecma-string and fill it with ecma-number
+ *
+ * @return pointer to ecma-string descriptor
*/
-inline void __attr_always_inline___
-ecma_init_ecma_string_from_uint32 (ecma_string_t *string_desc_p, /**< ecma-string */
- uint32_t uint32_number) /**< uint32 value of the string */
+ecma_string_t *
+ecma_new_ecma_string_from_uint32 (uint32_t uint32_number) /**< uint32 value of the string */
{
- string_desc_p->refs_and_container = ECMA_STRING_CONTAINER_UINT32_IN_DESC | ECMA_STRING_REF_ONE;
- string_desc_p->hash = (lit_string_hash_t) uint32_number;
+ if (likely (uint32_number <= ECMA_DIRECT_STRING_MAX_IMM))
+ {
+ return (ecma_string_t *) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_UINT, (uintptr_t) uint32_number);
+ }
- string_desc_p->u.uint32_number = uint32_number;
-} /* ecma_init_ecma_string_from_uint32 */
+ ecma_string_t *string_p = ecma_alloc_string ();
-/**
- * Initialize a magic ecma-string
- */
-void
-ecma_init_ecma_magic_string (ecma_string_t *string_desc_p, /**< ecma-string */
- lit_magic_string_id_t id) /**< literal id */
-{
- string_desc_p->refs_and_container = ECMA_STRING_CONTAINER_MAGIC_STRING | ECMA_STRING_REF_ONE;
- string_desc_p->hash = (lit_string_hash_t) id;
+ string_p->refs_and_container = ECMA_STRING_CONTAINER_UINT32_IN_DESC | ECMA_STRING_REF_ONE;
+ string_p->hash = (lit_string_hash_t) uint32_number;
+ string_p->u.uint32_number = uint32_number;
- string_desc_p->u.magic_string_id = (uint32_t) id;
-} /* ecma_init_ecma_magic_string */
+ return string_p;
+} /* ecma_new_ecma_string_from_uint32 */
/**
- * Allocate new ecma-string and fill it with ecma-number
+ * Returns the constant assigned to the uint32 number.
+ *
+ * Note:
+ * Calling ecma_deref_ecma_string on the returned pointer is optional.
*
* @return pointer to ecma-string descriptor
*/
ecma_string_t *
-ecma_new_ecma_string_from_uint32 (uint32_t uint32_number) /**< uint32 value of the string */
+ecma_get_ecma_string_from_uint32 (uint32_t uint32_number)
{
- ecma_string_t *string_desc_p = ecma_alloc_string ();
+ JERRY_ASSERT (uint32_number <= ECMA_DIRECT_STRING_MAX_IMM);
- ecma_init_ecma_string_from_uint32 (string_desc_p, uint32_number);
- return string_desc_p;
-} /* ecma_new_ecma_string_from_uint32 */
+ return (ecma_string_t *) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_UINT, (uintptr_t) uint32_number);
+} /* ecma_get_ecma_string_from_uint32 */
/**
* Allocate new ecma-string and fill it with ecma-number
} /* ecma_new_ecma_string_from_number */
/**
- * Allocate new ecma-string and fill it with reference to ECMA magic string
+ * Returns the constant assigned to the magic string id.
+ *
+ * Note:
+ * Calling ecma_deref_ecma_string on the returned pointer is optional.
*
* @return pointer to ecma-string descriptor
*/
-ecma_string_t *
-ecma_new_ecma_string_from_magic_string_id (lit_magic_string_id_t id) /**< identifier of magic string */
+inline ecma_string_t * __attr_always_inline___
+ecma_get_magic_string (lit_magic_string_id_t id) /**< identifier of magic string */
{
JERRY_ASSERT (id < LIT_MAGIC_STRING__COUNT);
-
- ecma_string_t *string_desc_p = ecma_alloc_string ();
- ecma_init_ecma_string_from_magic_string_id (string_desc_p, id);
-
- return string_desc_p;
-} /* ecma_new_ecma_string_from_magic_string_id */
+ return (ecma_string_t *) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_MAGIC, (uintptr_t) id);
+} /* ecma_get_magic_string */
/**
* Allocate new ecma-string and fill it with reference to ECMA magic string
{
JERRY_ASSERT (id < lit_get_magic_string_ex_count ());
- ecma_string_t *string_desc_p = ecma_alloc_string ();
- ecma_init_ecma_string_from_magic_string_ex_id (string_desc_p, id);
-
- return string_desc_p;
-} /* ecma_new_ecma_string_from_magic_string_ex_id */
+ if (likely (id <= ECMA_DIRECT_STRING_MAX_IMM))
+ {
+ return (ecma_string_t *) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_MAGIC_EX, (uintptr_t) id);
+ }
-/**
- * Allocate new ecma-string and fill it with reference to length magic string
- *
- * @return pointer to ecma-string descriptor
- */
-ecma_string_t *
-ecma_new_ecma_length_string (void)
-{
ecma_string_t *string_desc_p = ecma_alloc_string ();
- ecma_init_ecma_magic_string (string_desc_p, LIT_MAGIC_STRING_LENGTH);
+
+ string_desc_p->refs_and_container = ECMA_STRING_CONTAINER_MAGIC_STRING_EX | ECMA_STRING_REF_ONE;
+ string_desc_p->hash = (lit_string_hash_t) (LIT_MAGIC_STRING__COUNT + id);
+ string_desc_p->u.magic_string_ex_id = id;
return string_desc_p;
-} /* ecma_new_ecma_length_string */
+} /* ecma_new_ecma_string_from_magic_string_ex_id */
/**
* Append a cesu8 string after an ecma-string
if (unlikely (ecma_string_is_empty (string1_p)))
{
- ecma_deref_ecma_string (string1_p);
return ecma_new_ecma_string_from_utf8 (cesu8_string2_p, cesu8_string2_size);
}
bool string1_is_uint32 = false;
bool string1_rehash_needed = false;
- switch (ECMA_STRING_GET_CONTAINER (string1_p))
+ if (ECMA_IS_DIRECT_STRING (string1_p))
{
- case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
- {
- cesu8_string1_p = (lit_utf8_byte_t *) (string1_p + 1);
- cesu8_string1_size = string1_p->u.utf8_string.size;
- cesu8_string1_length = string1_p->u.utf8_string.length;
- break;
- }
- case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
- {
- ecma_long_string_t *long_string_desc_p = (ecma_long_string_t *) string1_p;
+ string1_rehash_needed = true;
- cesu8_string1_p = (lit_utf8_byte_t *) (long_string_desc_p + 1);
- cesu8_string1_size = string1_p->u.long_utf8_string_size;
- cesu8_string1_length = long_string_desc_p->long_utf8_string_length;
- break;
- }
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- {
- cesu8_string1_size = ecma_uint32_to_utf8_string (string1_p->u.uint32_number,
- uint32_to_string_buffer,
- ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
- cesu8_string1_p = uint32_to_string_buffer;
- cesu8_string1_length = cesu8_string1_size;
- string1_is_uint32 = true;
- string1_rehash_needed = true;
- break;
- }
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
+ switch (ECMA_GET_DIRECT_STRING_TYPE (string1_p))
{
- cesu8_string1_p = lit_get_magic_string_utf8 (string1_p->u.magic_string_id);
- cesu8_string1_size = lit_get_magic_string_size (string1_p->u.magic_string_id);
- cesu8_string1_length = cesu8_string1_size;
- string1_rehash_needed = true;
- break;
+ case ECMA_DIRECT_STRING_MAGIC:
+ {
+ lit_magic_string_id_t id = (lit_magic_string_id_t) ECMA_GET_DIRECT_STRING_VALUE (string1_p);
+ cesu8_string1_p = lit_get_magic_string_utf8 (id);
+ cesu8_string1_size = lit_get_magic_string_size (id);
+ cesu8_string1_length = cesu8_string1_size;
+ break;
+ }
+ case ECMA_DIRECT_STRING_UINT:
+ {
+ cesu8_string1_size = ecma_uint32_to_utf8_string ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string1_p),
+ uint32_to_string_buffer,
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
+ cesu8_string1_p = uint32_to_string_buffer;
+ cesu8_string1_length = cesu8_string1_size;
+ string1_is_uint32 = true;
+ break;
+ }
+ default:
+ {
+ JERRY_ASSERT (ECMA_GET_DIRECT_STRING_TYPE (string1_p) == ECMA_DIRECT_STRING_MAGIC_EX);
+
+ lit_magic_string_ex_id_t id = (lit_magic_string_ex_id_t) ECMA_GET_DIRECT_STRING_VALUE (string1_p);
+ cesu8_string1_p = lit_get_magic_string_ex_utf8 (id);
+ cesu8_string1_size = lit_get_magic_string_ex_size (id);
+ cesu8_string1_length = lit_utf8_string_length (cesu8_string1_p, cesu8_string1_size);
+ break;
+ }
}
- default:
+ }
+ else
+ {
+ JERRY_ASSERT (string1_p->refs_and_container >= ECMA_STRING_REF_ONE);
+
+ switch (ECMA_STRING_GET_CONTAINER (string1_p))
{
- JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string1_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
+ case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
+ {
+ cesu8_string1_p = (lit_utf8_byte_t *) (string1_p + 1);
+ cesu8_string1_size = string1_p->u.utf8_string.size;
+ cesu8_string1_length = string1_p->u.utf8_string.length;
+ break;
+ }
+ case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
+ {
+ ecma_long_string_t *long_string_desc_p = (ecma_long_string_t *) string1_p;
- cesu8_string1_p = lit_get_magic_string_ex_utf8 (string1_p->u.magic_string_id);
- cesu8_string1_size = lit_get_magic_string_ex_size (string1_p->u.magic_string_id);
- cesu8_string1_length = lit_utf8_string_length (cesu8_string1_p, cesu8_string1_size);
- string1_rehash_needed = true;
- break;
+ cesu8_string1_p = (lit_utf8_byte_t *) (long_string_desc_p + 1);
+ cesu8_string1_size = string1_p->u.long_utf8_string_size;
+ cesu8_string1_length = long_string_desc_p->long_utf8_string_length;
+ break;
+ }
+ case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
+ {
+ cesu8_string1_size = ecma_uint32_to_utf8_string (string1_p->u.uint32_number,
+ uint32_to_string_buffer,
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
+ cesu8_string1_p = uint32_to_string_buffer;
+ cesu8_string1_length = cesu8_string1_size;
+ string1_is_uint32 = true;
+ string1_rehash_needed = true;
+ break;
+ }
+ default:
+ {
+ JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string1_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
+
+ cesu8_string1_p = lit_get_magic_string_ex_utf8 (string1_p->u.magic_string_ex_id);
+ cesu8_string1_size = lit_get_magic_string_ex_size (string1_p->u.magic_string_ex_id);
+ cesu8_string1_length = lit_utf8_string_length (cesu8_string1_p, cesu8_string1_size);
+ string1_rehash_needed = true;
+ break;
+ }
}
}
if (magic_string_ex_id < lit_get_magic_string_ex_count ())
{
ecma_deref_ecma_string (string1_p);
- return ecma_get_magic_string_ex (magic_string_ex_id);
+ return ecma_new_ecma_string_from_magic_string_ex_id (magic_string_ex_id);
}
}
data_p = (lit_utf8_byte_t *) (long_string_desc_p + 1);
}
- lit_string_hash_t hash_start = string1_p->hash;
+ lit_string_hash_t hash_start;
if (string1_rehash_needed)
{
hash_start = lit_utf8_string_calc_hash (cesu8_string1_p, cesu8_string1_size);
}
+ else
+ {
+ JERRY_ASSERT (!ECMA_IS_DIRECT_STRING (string1_p));
+ hash_start = string1_p->hash;
+ }
string_desc_p->hash = lit_utf8_string_hash_combine (hash_start, cesu8_string2_p, cesu8_string2_size);
ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */
ecma_string_t *string2_p) /**< second ecma-string */
{
- JERRY_ASSERT (string1_p != NULL
- && string2_p != NULL);
+ JERRY_ASSERT (string1_p != NULL && string2_p != NULL);
if (unlikely (ecma_string_is_empty (string1_p)))
{
- ecma_deref_ecma_string (string1_p);
ecma_ref_ecma_string (string2_p);
return string2_p;
}
lit_utf8_byte_t uint32_to_string_buffer[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
- switch (ECMA_STRING_GET_CONTAINER (string2_p))
+ if (ECMA_IS_DIRECT_STRING (string2_p))
{
- case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
- {
- cesu8_string2_p = (lit_utf8_byte_t *) (string2_p + 1);
- cesu8_string2_size = string2_p->u.utf8_string.size;
- cesu8_string2_length = string2_p->u.utf8_string.length;
- break;
- }
- case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
+ switch (ECMA_GET_DIRECT_STRING_TYPE (string2_p))
{
- ecma_long_string_t *long_string_desc_p = (ecma_long_string_t *) string2_p;
+ case ECMA_DIRECT_STRING_MAGIC:
+ {
+ lit_magic_string_id_t id = (lit_magic_string_id_t) ECMA_GET_DIRECT_STRING_VALUE (string2_p);
+ cesu8_string2_p = lit_get_magic_string_utf8 (id);
+ cesu8_string2_size = lit_get_magic_string_size (id);
+ cesu8_string2_length = cesu8_string2_size;
+ break;
+ }
+ case ECMA_DIRECT_STRING_UINT:
+ {
+ cesu8_string2_size = ecma_uint32_to_utf8_string ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string2_p),
+ uint32_to_string_buffer,
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
+ cesu8_string2_p = uint32_to_string_buffer;
+ cesu8_string2_length = cesu8_string2_size;
+ break;
+ }
+ default:
+ {
+ JERRY_ASSERT (ECMA_GET_DIRECT_STRING_TYPE (string2_p) == ECMA_DIRECT_STRING_MAGIC_EX);
- cesu8_string2_p = (lit_utf8_byte_t *) (long_string_desc_p + 1);
- cesu8_string2_size = string2_p->u.long_utf8_string_size;
- cesu8_string2_length = long_string_desc_p->long_utf8_string_length;
- break;
- }
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- {
- cesu8_string2_size = ecma_uint32_to_utf8_string (string2_p->u.uint32_number,
- uint32_to_string_buffer,
- ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
- cesu8_string2_p = uint32_to_string_buffer;
- cesu8_string2_length = cesu8_string2_size;
- break;
- }
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- {
- cesu8_string2_p = lit_get_magic_string_utf8 (string2_p->u.magic_string_id);
- cesu8_string2_size = lit_get_magic_string_size (string2_p->u.magic_string_id);
- cesu8_string2_length = cesu8_string2_size;
- break;
+ lit_magic_string_ex_id_t id = (lit_magic_string_ex_id_t) ECMA_GET_DIRECT_STRING_VALUE (string2_p);
+ cesu8_string2_p = lit_get_magic_string_ex_utf8 (id);
+ cesu8_string2_size = lit_get_magic_string_ex_size (id);
+ cesu8_string2_length = lit_utf8_string_length (cesu8_string2_p, cesu8_string2_size);
+ break;
+ }
}
- default:
+ }
+ else
+ {
+ JERRY_ASSERT (string2_p->refs_and_container >= ECMA_STRING_REF_ONE);
+
+ switch (ECMA_STRING_GET_CONTAINER (string2_p))
{
- JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string2_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
+ case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
+ {
+ cesu8_string2_p = (lit_utf8_byte_t *) (string2_p + 1);
+ cesu8_string2_size = string2_p->u.utf8_string.size;
+ cesu8_string2_length = string2_p->u.utf8_string.length;
+ break;
+ }
+ case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
+ {
+ ecma_long_string_t *long_string_desc_p = (ecma_long_string_t *) string2_p;
- cesu8_string2_p = lit_get_magic_string_ex_utf8 (string2_p->u.magic_string_id);
- cesu8_string2_size = lit_get_magic_string_ex_size (string2_p->u.magic_string_id);
- cesu8_string2_length = lit_utf8_string_length (cesu8_string2_p, cesu8_string2_size);
- break;
+ cesu8_string2_p = (lit_utf8_byte_t *) (long_string_desc_p + 1);
+ cesu8_string2_size = string2_p->u.long_utf8_string_size;
+ cesu8_string2_length = long_string_desc_p->long_utf8_string_length;
+ break;
+ }
+ case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
+ {
+ cesu8_string2_size = ecma_uint32_to_utf8_string (string2_p->u.uint32_number,
+ uint32_to_string_buffer,
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
+ cesu8_string2_p = uint32_to_string_buffer;
+ cesu8_string2_length = cesu8_string2_size;
+ break;
+ }
+ default:
+ {
+ JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string2_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
+
+ cesu8_string2_p = lit_get_magic_string_ex_utf8 (string2_p->u.magic_string_ex_id);
+ cesu8_string2_size = lit_get_magic_string_ex_size (string2_p->u.magic_string_ex_id);
+ cesu8_string2_length = lit_utf8_string_length (cesu8_string2_p, cesu8_string2_size);
+ break;
+ }
}
}
{
if (unlikely (ecma_string_is_empty (string1_p)))
{
- ecma_deref_ecma_string (string1_p);
- return ecma_new_ecma_string_from_magic_string_id (string2_id);
+ return ecma_get_magic_string (string2_id);
}
const lit_utf8_byte_t *cesu8_string2_p = lit_get_magic_string_utf8 (string2_id);
ecma_ref_ecma_string (ecma_string_t *string_p) /**< string descriptor */
{
JERRY_ASSERT (string_p != NULL);
+
+ if (ECMA_IS_DIRECT_STRING (string_p))
+ {
+ return;
+ }
+
JERRY_ASSERT (string_p->refs_and_container >= ECMA_STRING_REF_ONE);
if (likely (string_p->refs_and_container < ECMA_STRING_MAX_REF))
ecma_deref_ecma_string (ecma_string_t *string_p) /**< ecma-string */
{
JERRY_ASSERT (string_p != NULL);
+
+ if (ECMA_IS_DIRECT_STRING (string_p))
+ {
+ return;
+ }
+
JERRY_ASSERT (string_p->refs_and_container >= ECMA_STRING_REF_ONE);
/* Decrease reference counter. */
return;
}
case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
case ECMA_STRING_CONTAINER_MAGIC_STRING_EX:
{
/* only the string descriptor itself should be freed */
}
case ECMA_STRING_LITERAL_NUMBER:
{
- ecma_fast_free_value (string_p->u.lit_number);
+ ecma_free_value (string_p->u.lit_number);
break;
}
default:
* Convert ecma-string to number
*/
ecma_number_t
-ecma_string_to_number (const ecma_string_t *str_p) /**< ecma-string */
+ecma_string_to_number (const ecma_string_t *string_p) /**< ecma-string */
{
- JERRY_ASSERT (str_p != NULL);
+ JERRY_ASSERT (string_p != NULL);
- switch (ECMA_STRING_GET_CONTAINER (str_p))
+ if (ECMA_IS_DIRECT_STRING (string_p))
{
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
+ if (ECMA_IS_DIRECT_STRING_WITH_TYPE (string_p, ECMA_DIRECT_STRING_UINT))
{
- return ((ecma_number_t) str_p->u.uint32_number);
+ return (ecma_number_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
}
+ }
+ else if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
+ {
+ return ((ecma_number_t) string_p->u.uint32_number);
+ }
- case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
- case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- case ECMA_STRING_CONTAINER_MAGIC_STRING_EX:
- {
- ecma_number_t num;
-
- ECMA_STRING_TO_UTF8_STRING (str_p, str_buffer_p, str_buffer_size);
-
- if (str_buffer_size == 0)
- {
- return ECMA_NUMBER_ZERO;
- }
-
- num = ecma_utf8_string_to_number (str_buffer_p, str_buffer_size);
-
- ECMA_FINALIZE_UTF8_STRING (str_buffer_p, str_buffer_size);
+ lit_utf8_size_t size;
+ const lit_utf8_byte_t *chars_p = ecma_string_get_chars_fast (string_p, &size);
- return num;
- }
+ JERRY_ASSERT (chars_p != NULL);
- default:
- {
- JERRY_UNREACHABLE ();
- }
+ if (size == 0)
+ {
+ return ECMA_NUMBER_ZERO;
}
+
+ return ecma_utf8_string_to_number (chars_p, size);
} /* ecma_string_to_number */
/**
inline uint32_t __attr_always_inline___
ecma_string_get_array_index (const ecma_string_t *str_p) /**< ecma-string */
{
- const ecma_string_container_t type = ECMA_STRING_GET_CONTAINER (str_p);
+ if (ECMA_IS_DIRECT_STRING (str_p))
+ {
+ if (ECMA_IS_DIRECT_STRING_WITH_TYPE (str_p, ECMA_DIRECT_STRING_UINT))
+ {
+ /* Value cannot be equal to the maximum value of a 32 bit unsigned number. */
+ return (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (str_p);
+ }
+
+ return ECMA_STRING_NOT_ARRAY_INDEX;
+ }
- if (type == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
+ if (ECMA_STRING_GET_CONTAINER (str_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
{
- /* When the uint32_number is equal to the maximum value of 32 bit
- * unsigned integer number, it is also an invalid array index.
- * The comparison to ECMA_STRING_NOT_ARRAY_INDEX will be true
- * in this case. */
+ /* When the uint32_number is equal to the maximum value of 32 bit unsigned integer number,
+ * it is also an invalid array index. The comparison to ECMA_STRING_NOT_ARRAY_INDEX will
+ * be true in this case. */
return str_p->u.uint32_number;
}
* @return number of bytes, actually copied to the buffer.
*/
lit_utf8_size_t __attr_return_value_should_be_checked___
-ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_desc_p, /**< ecma-string descriptor */
+ecma_string_copy_to_cesu8_buffer (const ecma_string_t *string_p, /**< ecma-string descriptor */
lit_utf8_byte_t *buffer_p, /**< destination buffer pointer
* (can be NULL if buffer_size == 0) */
lit_utf8_size_t buffer_size) /**< size of buffer */
{
- JERRY_ASSERT (string_desc_p != NULL);
- JERRY_ASSERT (string_desc_p->refs_and_container >= ECMA_STRING_REF_ONE);
+ JERRY_ASSERT (string_p != NULL);
JERRY_ASSERT (buffer_p != NULL || buffer_size == 0);
- JERRY_ASSERT (ecma_string_get_size (string_desc_p) <= buffer_size);
+ JERRY_ASSERT (ecma_string_get_size (string_p) <= buffer_size);
lit_utf8_size_t size;
- switch (ECMA_STRING_GET_CONTAINER (string_desc_p))
+ if (ECMA_IS_DIRECT_STRING (string_p))
{
- case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
- {
- size = string_desc_p->u.utf8_string.size;
- memcpy (buffer_p, string_desc_p + 1, size);
- break;
- }
- case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
- {
- size = string_desc_p->u.long_utf8_string_size;
- memcpy (buffer_p, ((ecma_long_string_t *) string_desc_p) + 1, size);
- break;
- }
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
+ if (ECMA_IS_DIRECT_STRING_WITH_TYPE (string_p, ECMA_DIRECT_STRING_UINT))
{
- const uint32_t uint32_number = string_desc_p->u.uint32_number;
+ uint32_t uint32_number = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
size = ecma_uint32_to_utf8_string (uint32_number, buffer_p, buffer_size);
- break;
- }
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- {
- const lit_magic_string_id_t id = string_desc_p->u.magic_string_id;
- size = lit_get_magic_string_size (id);
- memcpy (buffer_p, lit_get_magic_string_utf8 (id), size);
- break;
+ JERRY_ASSERT (size <= buffer_size);
+ return size;
}
- default:
- {
- JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_desc_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
+ }
+ else
+ {
+ JERRY_ASSERT (string_p->refs_and_container >= ECMA_STRING_REF_ONE);
- const lit_magic_string_ex_id_t id = string_desc_p->u.magic_string_ex_id;
- size = lit_get_magic_string_ex_size (id);
- memcpy (buffer_p, lit_get_magic_string_ex_utf8 (id), size);
- break;
+ if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
+ {
+ uint32_t uint32_number = string_p->u.uint32_number;
+ size = ecma_uint32_to_utf8_string (uint32_number, buffer_p, buffer_size);
+ JERRY_ASSERT (size <= buffer_size);
+ return size;
}
}
+ const lit_utf8_byte_t *chars_p = ecma_string_get_chars_fast (string_p, &size);
+
+ JERRY_ASSERT (chars_p != NULL);
JERRY_ASSERT (size <= buffer_size);
+
+ memcpy (buffer_p, chars_p, size);
return size;
} /* ecma_string_copy_to_cesu8_buffer */
* @return number of bytes, actually copied to the buffer.
*/
lit_utf8_size_t __attr_return_value_should_be_checked___
-ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_desc_p, /**< ecma-string descriptor */
+ecma_string_copy_to_utf8_buffer (const ecma_string_t *string_p, /**< ecma-string descriptor */
lit_utf8_byte_t *buffer_p, /**< destination buffer pointer
* (can be NULL if buffer_size == 0) */
lit_utf8_size_t buffer_size) /**< size of buffer */
{
- JERRY_ASSERT (string_desc_p != NULL);
- JERRY_ASSERT (string_desc_p->refs_and_container >= ECMA_STRING_REF_ONE);
+ JERRY_ASSERT (string_p != NULL);
JERRY_ASSERT (buffer_p != NULL || buffer_size == 0);
- JERRY_ASSERT (ecma_string_get_utf8_size (string_desc_p) <= buffer_size);
+ JERRY_ASSERT (ecma_string_get_utf8_size (string_p) <= buffer_size);
lit_utf8_size_t size;
- switch (ECMA_STRING_GET_CONTAINER (string_desc_p))
+ if (ECMA_IS_DIRECT_STRING (string_p))
{
- case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
- {
- size = lit_convert_cesu8_string_to_utf8_string ((lit_utf8_byte_t *) (string_desc_p + 1),
- string_desc_p->u.utf8_string.size,
- buffer_p,
- buffer_size);
- break;
- }
- case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
+ if (ECMA_IS_DIRECT_STRING_WITH_TYPE (string_p, ECMA_DIRECT_STRING_UINT))
{
- size = lit_convert_cesu8_string_to_utf8_string ((lit_utf8_byte_t *) (((ecma_long_string_t *) string_desc_p) + 1),
- string_desc_p->u.long_utf8_string_size,
- buffer_p,
- buffer_size);
- break;
+ uint32_t uint32_number = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+ size = ecma_uint32_to_utf8_string (uint32_number, buffer_p, buffer_size);
+ JERRY_ASSERT (size <= buffer_size);
+ return size;
}
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
+ }
+ else
+ {
+ JERRY_ASSERT (string_p->refs_and_container >= ECMA_STRING_REF_ONE);
+
+ if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
{
- const uint32_t uint32_number = string_desc_p->u.uint32_number;
+ uint32_t uint32_number = string_p->u.uint32_number;
size = ecma_uint32_to_utf8_string (uint32_number, buffer_p, buffer_size);
- break;
+ JERRY_ASSERT (size <= buffer_size);
+ return size;
}
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- {
- const lit_magic_string_id_t id = string_desc_p->u.magic_string_id;
- size = lit_get_magic_string_size (id);
- memcpy (buffer_p, lit_get_magic_string_utf8 (id), size);
- break;
- }
- default:
- {
- JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_desc_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
+ }
- const lit_magic_string_ex_id_t id = string_desc_p->u.magic_string_ex_id;
- size = lit_convert_cesu8_string_to_utf8_string (lit_get_magic_string_ex_utf8 (id),
- lit_get_magic_string_ex_size (id),
- buffer_p,
- buffer_size);
- break;
- }
+ uint8_t flags = ECMA_STRING_FLAG_IS_ASCII;
+ const lit_utf8_byte_t *chars_p = ecma_string_get_chars (string_p, &size, &flags);
+
+ JERRY_ASSERT (chars_p != NULL);
+
+ if (flags & ECMA_STRING_FLAG_IS_ASCII)
+ {
+ JERRY_ASSERT (size <= buffer_size);
+ memcpy (buffer_p, chars_p, size);
+ return size;
+ }
+
+ size = lit_convert_cesu8_string_to_utf8_string (chars_p,
+ size,
+ buffer_p,
+ buffer_size);
+
+ if (flags & ECMA_STRING_FLAG_MUST_BE_FREED)
+ {
+ jmem_heap_free_block ((void *) chars_p, size);
}
JERRY_ASSERT (size <= buffer_size);
lit_utf8_size_t buffer_size) /**< size of buffer */
{
JERRY_ASSERT (string_desc_p != NULL);
- JERRY_ASSERT (string_desc_p->refs_and_container >= ECMA_STRING_REF_ONE);
JERRY_ASSERT (buffer_p != NULL || buffer_size == 0);
ecma_length_t string_length = ecma_string_get_length (string_desc_p);
} /* ecma_string_to_utf8_bytes */
/**
- * Lengths for numeric string values
- */
-static const uint32_t nums_with_ascending_length[] =
-{
- 1u,
- 10u,
- 100u,
- 1000u,
- 10000u,
- 100000u,
- 1000000u,
- 10000000u,
- 100000000u,
- 1000000000u
-};
-
-/**
- * Maximum length of numeric strings
- */
-static const uint32_t max_uint32_len = (uint32_t) (sizeof (nums_with_ascending_length) / sizeof (uint32_t));
-
-/**
- * Get size of the number stored locally in the string's descriptor
+ * Get size of the uint32 number stored locally in the string's descriptor
*
* Note: the represented number size and length are equal
*
* @return size in bytes
*/
static inline ecma_length_t __attr_always_inline___
-ecma_string_get_number_in_desc_size (const uint32_t uint32_number) /**< number in the string-descriptor */
+ecma_string_get_uint32_size (const uint32_t uint32_number) /**< number in the string-descriptor */
{
+ uint32_t prev_number = 1;
+ uint32_t next_number = 100;
ecma_length_t size = 1;
- while (size < max_uint32_len && uint32_number >= nums_with_ascending_length[size])
+ const uint32_t max_size = 9;
+
+ while (size < max_size && uint32_number >= next_number)
+ {
+ prev_number = next_number;
+ next_number *= 100;
+ size += 2;
+ }
+
+ if (uint32_number >= prev_number * 10)
{
size++;
}
+
return size;
-} /* ecma_string_get_number_in_desc_size */
+} /* ecma_string_get_uint32_size */
/**
* Checks whether the given string is a sequence of ascii characters.
#define ECMA_STRING_IS_ASCII(char_p, size) ((size) == lit_utf8_string_length ((char_p), (size)))
/**
- * Returns with the raw byte array of the string, if it is available.
+ * Returns with the cesu8 character array of a string.
*
- * @return byte array start - if the byte array of a string is available
- * NULL - otherwise
+ * Note:
+ * - This function returns with a newly allocated buffer for uint32 strings,
+ * which must be freed.
+ * - The ASCII check only happens if the flags parameter gets
+ * 'ECMA_STRING_FLAG_IS_ASCII' as an input.
+ *
+ * @return start of cesu8 characters
*/
const lit_utf8_byte_t *
-ecma_string_raw_chars (const ecma_string_t *string_p, /**< ecma-string */
+ecma_string_get_chars (const ecma_string_t *string_p, /**< ecma-string */
lit_utf8_size_t *size_p, /**< [out] size of the ecma string */
- bool *is_ascii_p) /**< [out] true, if the string is an ascii
- * character sequence (size == length)
- * false, otherwise */
+ uint8_t *flags_p) /**< [in,out] flags: ECMA_STRING_FLAG_EMPTY,
+ ECMA_STRING_FLAG_IS_ASCII,
+ ECMA_STRING_FLAG_MUST_BE_FREED */
{
ecma_length_t length;
lit_utf8_size_t size;
const lit_utf8_byte_t *result_p;
- switch (ECMA_STRING_GET_CONTAINER (string_p))
+ if (ECMA_IS_DIRECT_STRING (string_p))
{
- case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
+ switch (ECMA_GET_DIRECT_STRING_TYPE (string_p))
{
- size = string_p->u.utf8_string.size;
- length = string_p->u.utf8_string.length;
- result_p = (const lit_utf8_byte_t *) (string_p + 1);
- break;
- }
- case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
- {
- size = string_p->u.long_utf8_string_size;
- ecma_long_string_t *long_string_p = (ecma_long_string_t *) string_p;
- length = long_string_p->long_utf8_string_length;
- result_p = (const lit_utf8_byte_t *) (long_string_p + 1);
- break;
- }
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- {
- size = (lit_utf8_size_t) ecma_string_get_number_in_desc_size (string_p->u.uint32_number);
+ case ECMA_DIRECT_STRING_MAGIC:
+ {
+ lit_magic_string_id_t id = (lit_magic_string_id_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
- /* All numbers must be ascii strings. */
- JERRY_ASSERT (ecma_string_get_length (string_p) == size);
+ size = lit_get_magic_string_size (id);
+ length = size;
- length = size;
- result_p = NULL;
- break;
- }
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- {
- size = lit_get_magic_string_size (string_p->u.magic_string_id);
+ result_p = lit_get_magic_string_utf8 (id);
- length = size;
- result_p = lit_get_magic_string_utf8 (string_p->u.magic_string_id);
+ /* All magic strings must be ascii strings. */
+ JERRY_ASSERT (ECMA_STRING_IS_ASCII (result_p, size));
+ break;
+ }
+ case ECMA_DIRECT_STRING_UINT:
+ {
+ uint32_t uint32_number = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+ size = (lit_utf8_size_t) ecma_string_get_uint32_size (uint32_number);
- /* All magic strings must be ascii strings. */
- JERRY_ASSERT (ECMA_STRING_IS_ASCII (result_p, size));
- break;
+ result_p = (const lit_utf8_byte_t *) jmem_heap_alloc_block (size);
+ length = ecma_uint32_to_utf8_string (uint32_number, (lit_utf8_byte_t *) result_p, size);
+ JERRY_ASSERT (length == size);
+ *flags_p |= ECMA_STRING_FLAG_MUST_BE_FREED;
+ break;
+ }
+ default:
+ {
+ JERRY_ASSERT (ECMA_GET_DIRECT_STRING_TYPE (string_p) == ECMA_DIRECT_STRING_MAGIC_EX);
+
+ lit_magic_string_ex_id_t id = (lit_magic_string_ex_id_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+
+ size = lit_get_magic_string_ex_size (id);
+ result_p = lit_get_magic_string_ex_utf8 (id);
+ length = 0;
+
+ if (unlikely (*flags_p & ECMA_STRING_FLAG_IS_ASCII))
+ {
+ length = lit_utf8_string_length (result_p, size);
+ }
+ break;
+ }
}
- default:
+ }
+ else
+ {
+ JERRY_ASSERT (string_p->refs_and_container >= ECMA_STRING_REF_ONE);
+
+ switch (ECMA_STRING_GET_CONTAINER (string_p))
{
- JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
+ case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
+ {
+ size = string_p->u.utf8_string.size;
+ length = string_p->u.utf8_string.length;
+ result_p = (const lit_utf8_byte_t *) (string_p + 1);
+ break;
+ }
+ case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
+ {
+ size = string_p->u.long_utf8_string_size;
+ ecma_long_string_t *long_string_p = (ecma_long_string_t *) string_p;
+ length = long_string_p->long_utf8_string_length;
+ result_p = (const lit_utf8_byte_t *) (long_string_p + 1);
+ break;
+ }
+ case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
+ {
+ size = (lit_utf8_size_t) ecma_string_get_uint32_size (string_p->u.uint32_number);
- size = lit_get_magic_string_ex_size (string_p->u.magic_string_ex_id);
- length = lit_utf8_string_length (lit_get_magic_string_ex_utf8 (string_p->u.magic_string_ex_id),
- lit_get_magic_string_ex_size (string_p->u.magic_string_ex_id));
+ result_p = (const lit_utf8_byte_t *) jmem_heap_alloc_block (size);
+ length = ecma_uint32_to_utf8_string (string_p->u.uint32_number, (lit_utf8_byte_t *) result_p, size);
+ JERRY_ASSERT (length == size);
+ *flags_p |= ECMA_STRING_FLAG_MUST_BE_FREED;
+ break;
- result_p = lit_get_magic_string_ex_utf8 (string_p->u.magic_string_ex_id);
- break;
+ }
+ default:
+ {
+ JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
+
+ size = lit_get_magic_string_ex_size (string_p->u.magic_string_ex_id);
+ length = 0;
+
+ if (unlikely (*flags_p & ECMA_STRING_FLAG_IS_ASCII))
+ {
+ length = lit_utf8_string_length (lit_get_magic_string_ex_utf8 (string_p->u.magic_string_ex_id), size);
+ }
+
+ result_p = lit_get_magic_string_ex_utf8 (string_p->u.magic_string_ex_id);
+ break;
+ }
}
}
*size_p = size;
- *is_ascii_p = (length == size);
+ if (*flags_p & ECMA_STRING_FLAG_IS_ASCII)
+ {
+ if (length != size)
+ {
+ *flags_p = (uint8_t) (*flags_p & ~ECMA_STRING_FLAG_IS_ASCII);
+ }
+ }
+
return result_p;
-} /* ecma_string_raw_chars */
+} /* ecma_string_get_chars */
/**
* Checks whether the string equals to the magic string id.
ecma_compare_ecma_string_to_magic_id (const ecma_string_t *string_p, /**< property name */
lit_magic_string_id_t id) /**< magic string id */
{
- return (string_p->u.magic_string_id == id
- && ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING);
+ return (string_p == ecma_get_magic_string (id));
} /* ecma_compare_ecma_string_to_magic_id */
/**
return ecma_compare_ecma_string_to_magic_id (string_p, LIT_MAGIC_STRING_LENGTH);
} /* ecma_string_is_length */
+
+static inline ecma_string_t * __attr_always_inline___
+ecma_property_to_string (ecma_property_t property, /**< property name type */
+ jmem_cpointer_t prop_name_cp) /**< property name compressed pointer */
+{
+ uintptr_t property_string = ((uintptr_t) (property)) & (0x3 << ECMA_PROPERTY_NAME_TYPE_SHIFT);
+ property_string = (property_string >> ECMA_STRING_TYPE_CONVERSION_SHIFT) | ECMA_TYPE_DIRECT_STRING;
+ return (ecma_string_t *) (property_string | (((uintptr_t) prop_name_cp) << ECMA_DIRECT_STRING_SHIFT));
+} /* ecma_property_to_string */
+
/**
* Converts a string into a property name
*
ecma_string_to_property_name (ecma_string_t *prop_name_p, /**< property name */
ecma_property_t *name_type_p) /**< [out] property name type */
{
- ecma_string_container_t container = ECMA_STRING_GET_CONTAINER (prop_name_p);
-
- switch (container)
+ if (ECMA_IS_DIRECT_STRING (prop_name_p))
{
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- case ECMA_STRING_CONTAINER_MAGIC_STRING_EX:
- {
-#ifdef JERRY_CPOINTER_32_BIT
-
- *name_type_p = (ecma_property_t) (container << ECMA_PROPERTY_NAME_TYPE_SHIFT);
- return (jmem_cpointer_t) prop_name_p->u.common_uint32_field;
-
-#else /* !JERRY_CPOINTER_32_BIT */
-
- if (prop_name_p->u.common_uint32_field < (UINT16_MAX + 1))
- {
- *name_type_p = (ecma_property_t) (container << ECMA_PROPERTY_NAME_TYPE_SHIFT);
- return (jmem_cpointer_t) prop_name_p->u.common_uint32_field;
- }
-
-#endif /* JERRY_CPOINTER_32_BIT */
-
- break;
- }
- default:
- {
- break;
- }
+ *name_type_p = (ecma_property_t) ECMA_DIRECT_STRING_TYPE_TO_PROP_NAME_TYPE (prop_name_p);
+ return (jmem_cpointer_t) ECMA_GET_DIRECT_STRING_VALUE (prop_name_p);
}
- *name_type_p = ECMA_PROPERTY_NAME_TYPE_STRING << ECMA_PROPERTY_NAME_TYPE_SHIFT;
+ *name_type_p = ECMA_DIRECT_STRING_PTR << ECMA_PROPERTY_NAME_TYPE_SHIFT;
ecma_ref_ecma_string (prop_name_p);
* Converts a property name into a string
*
* @return the string pointer
+ * string must be released with ecma_deref_ecma_string
*/
ecma_string_t *
ecma_string_from_property_name (ecma_property_t property, /**< property name type */
jmem_cpointer_t prop_name_cp) /**< property name compressed pointer */
{
- /* If string_buf_p is NULL this function returns with a new string
- * instance which needs to be released with ecma_deref_ecma_string. */
-
- switch (ECMA_PROPERTY_GET_NAME_TYPE (property))
+ if (ECMA_PROPERTY_GET_NAME_TYPE (property) != ECMA_DIRECT_STRING_PTR)
{
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- {
- return ecma_new_ecma_string_from_uint32 ((uint32_t) prop_name_cp);
- }
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- {
- return ecma_new_ecma_string_from_magic_string_id ((lit_magic_string_id_t) prop_name_cp);
- }
- case ECMA_STRING_CONTAINER_MAGIC_STRING_EX:
- {
- return ecma_new_ecma_string_from_magic_string_ex_id ((lit_magic_string_ex_id_t) prop_name_cp);
- }
- default:
- {
- JERRY_ASSERT (ECMA_PROPERTY_GET_NAME_TYPE (property) == ECMA_PROPERTY_NAME_TYPE_STRING);
-
- ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, prop_name_cp);
- ecma_ref_ecma_string (prop_name_p);
- return prop_name_p;
- }
+ return ecma_property_to_string (property, prop_name_cp);
}
+
+ ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, prop_name_cp);
+ ecma_ref_ecma_string (prop_name_p);
+ return prop_name_p;
} /* ecma_string_from_property_name */
/**
{
switch (ECMA_PROPERTY_GET_NAME_TYPE (property))
{
- case ECMA_STRING_CONTAINER_MAGIC_STRING_EX:
+ case ECMA_DIRECT_STRING_PTR:
{
- return (lit_string_hash_t) (LIT_MAGIC_STRING__COUNT + prop_name_cp);
+ ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, prop_name_cp);
+ return prop_name_p->hash;
}
- case ECMA_PROPERTY_NAME_TYPE_STRING:
+ case ECMA_DIRECT_STRING_MAGIC_EX:
{
- ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, prop_name_cp);
- return ecma_string_hash (prop_name_p);
+ return (lit_string_hash_t) (LIT_MAGIC_STRING__COUNT + prop_name_cp);
}
default:
{
{
switch (ECMA_PROPERTY_GET_NAME_TYPE (property))
{
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
+ case ECMA_DIRECT_STRING_UINT:
{
return (uint32_t) prop_name_cp;
}
-#ifndef JERRY_CPOINTER_32_BIT
- case ECMA_PROPERTY_NAME_TYPE_STRING:
+ case ECMA_DIRECT_STRING_PTR:
{
ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, prop_name_cp);
return ecma_string_get_array_index (prop_name_p);
}
-#endif /* !JERRY_CPOINTER_32_BIT */
default:
{
return ECMA_STRING_NOT_ARRAY_INDEX;
jmem_cpointer_t prop_name_cp, /**< property name compressed pointer */
const ecma_string_t *string_p) /**< other string */
{
- uint32_t property_name_type = ECMA_PROPERTY_GET_NAME_TYPE (property);
-
- switch (property_name_type)
+ if (ECMA_PROPERTY_GET_NAME_TYPE (property) != ECMA_DIRECT_STRING_PTR)
{
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- case ECMA_STRING_CONTAINER_MAGIC_STRING_EX:
- {
- return (ECMA_STRING_GET_CONTAINER (string_p) == property_name_type
- && string_p->u.common_uint32_field == (uint32_t) prop_name_cp);
- }
- default:
- {
- JERRY_ASSERT (property_name_type == ECMA_PROPERTY_NAME_TYPE_STRING);
+ return ecma_property_to_string (property, prop_name_cp) == string_p;
+ }
- ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, prop_name_cp);
- return ecma_compare_ecma_strings (prop_name_p, string_p);
- }
+ if (ECMA_IS_DIRECT_STRING (string_p))
+ {
+ return false;
}
+
+ ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, prop_name_cp);
+ return ecma_compare_ecma_non_direct_strings (prop_name_p, string_p);
} /* ecma_string_compare_to_property_name */
/**
* false - otherwise
*/
static bool __attr_noinline___
-ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /* ecma-string */
- const ecma_string_t *string2_p) /* ecma-string */
+ecma_compare_ecma_strings_longpath (const ecma_string_t *string1_p, /**< ecma-string */
+ const ecma_string_t *string2_p) /**< ecma-string */
{
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string1_p) == ECMA_STRING_GET_CONTAINER (string2_p));
} /* ecma_compare_ecma_strings_longpath */
/**
- * Compare ecma-string to ecma-string
+ * Compare two ecma-strings
*
* @return true - if strings are equal;
* false - otherwise
*/
inline bool __attr_always_inline___
-ecma_compare_ecma_strings (const ecma_string_t *string1_p, /* ecma-string */
- const ecma_string_t *string2_p) /* ecma-string */
+ecma_compare_ecma_strings (const ecma_string_t *string1_p, /**< ecma-string */
+ const ecma_string_t *string2_p) /**< ecma-string */
{
JERRY_ASSERT (string1_p != NULL && string2_p != NULL);
return true;
}
+ /* Either string is direct, return with false. */
+ if (ECMA_IS_DIRECT_STRING (((uintptr_t) string1_p) | ((uintptr_t) string2_p)))
+ {
+ return false;
+ }
+
if (string1_p->hash != string2_p->hash)
{
return false;
return false;
}
- if (string1_container < ECMA_STRING_CONTAINER_HEAP_UTF8_STRING)
+ if (string1_container >= ECMA_STRING_CONTAINER_UINT32_IN_DESC)
{
return string1_p->u.common_uint32_field == string2_p->u.common_uint32_field;
}
} /* ecma_compare_ecma_strings */
/**
+ * Compare two non-direct ecma-strings
+ *
+ * @return true - if strings are equal;
+ * false - otherwise
+ */
+inline bool __attr_always_inline___
+ecma_compare_ecma_non_direct_strings (const ecma_string_t *string1_p, /**< ecma-string */
+ const ecma_string_t *string2_p) /**< ecma-string */
+{
+ JERRY_ASSERT (string1_p != NULL && string2_p != NULL);
+ JERRY_ASSERT (!ECMA_IS_DIRECT_STRING (string1_p) && !ECMA_IS_DIRECT_STRING (string2_p));
+
+ /* Fast paths first. */
+ if (string1_p == string2_p)
+ {
+ return true;
+ }
+
+ if (string1_p->hash != string2_p->hash)
+ {
+ return false;
+ }
+
+ ecma_string_container_t string1_container = ECMA_STRING_GET_CONTAINER (string1_p);
+
+ if (string1_container != ECMA_STRING_GET_CONTAINER (string2_p))
+ {
+ return false;
+ }
+
+ if (string1_container >= ECMA_STRING_CONTAINER_UINT32_IN_DESC)
+ {
+ return string1_p->u.common_uint32_field == string2_p->u.common_uint32_field;
+ }
+
+ return ecma_compare_ecma_strings_longpath (string1_p, string2_p);
+} /* ecma_compare_ecma_non_direct_strings */
+
+/**
* Relational compare of ecma-strings.
*
* First string is less than second string if:
lit_utf8_byte_t uint32_to_string_buffer1[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
lit_utf8_byte_t uint32_to_string_buffer2[ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32];
- switch (ECMA_STRING_GET_CONTAINER (string1_p))
+ if (ECMA_IS_DIRECT_STRING (string1_p))
{
- case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
+ if (ECMA_GET_DIRECT_STRING_TYPE (string1_p) != ECMA_DIRECT_STRING_UINT)
{
- utf8_string1_p = (lit_utf8_byte_t *) (string1_p + 1);
- utf8_string1_size = string1_p->u.utf8_string.size;
- break;
+ utf8_string1_p = ecma_string_get_chars_fast (string1_p, &utf8_string1_size);
}
- case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
- {
- utf8_string1_p = (lit_utf8_byte_t *) (((ecma_long_string_t *) string1_p) + 1);
- utf8_string1_size = string1_p->u.long_utf8_string_size;
- break;
- }
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
+ else
{
- utf8_string1_size = ecma_uint32_to_utf8_string (string1_p->u.uint32_number,
+ utf8_string1_size = ecma_uint32_to_utf8_string ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string1_p),
uint32_to_string_buffer1,
ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
utf8_string1_p = uint32_to_string_buffer1;
- break;
}
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
+ }
+ else
+ {
+ JERRY_ASSERT (string1_p->refs_and_container >= ECMA_STRING_REF_ONE);
+
+ if (ECMA_STRING_GET_CONTAINER (string1_p) != ECMA_STRING_CONTAINER_UINT32_IN_DESC)
{
- utf8_string1_p = lit_get_magic_string_utf8 (string1_p->u.magic_string_id);
- utf8_string1_size = lit_get_magic_string_size (string1_p->u.magic_string_id);
- break;
+ utf8_string1_p = ecma_string_get_chars_fast (string1_p, &utf8_string1_size);
}
- default:
+ else
{
- JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string1_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
-
- utf8_string1_p = lit_get_magic_string_ex_utf8 (string1_p->u.magic_string_id);
- utf8_string1_size = lit_get_magic_string_ex_size (string1_p->u.magic_string_id);
- break;
+ utf8_string1_size = ecma_uint32_to_utf8_string (string1_p->u.uint32_number,
+ uint32_to_string_buffer1,
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
+ utf8_string1_p = uint32_to_string_buffer1;
}
}
- switch (ECMA_STRING_GET_CONTAINER (string2_p))
+ if (ECMA_IS_DIRECT_STRING (string2_p))
{
- case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
- {
- utf8_string2_p = (lit_utf8_byte_t *) (string2_p + 1);
- utf8_string2_size = string2_p->u.utf8_string.size;
- break;
- }
- case ECMA_STRING_CONTAINER_HEAP_LONG_UTF8_STRING:
+ if (ECMA_GET_DIRECT_STRING_TYPE (string2_p) != ECMA_DIRECT_STRING_UINT)
{
- utf8_string2_p = (lit_utf8_byte_t *) (((ecma_long_string_t *) string2_p) + 1);
- utf8_string2_size = string2_p->u.long_utf8_string_size;
- break;
+ utf8_string2_p = ecma_string_get_chars_fast (string2_p, &utf8_string2_size);
}
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
+ else
{
- utf8_string2_size = ecma_uint32_to_utf8_string (string2_p->u.uint32_number,
+ utf8_string2_size = ecma_uint32_to_utf8_string ((uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string2_p),
uint32_to_string_buffer2,
ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
utf8_string2_p = uint32_to_string_buffer2;
- break;
}
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
+ }
+ else
+ {
+ JERRY_ASSERT (string2_p->refs_and_container >= ECMA_STRING_REF_ONE);
+
+ if (ECMA_STRING_GET_CONTAINER (string2_p) != ECMA_STRING_CONTAINER_UINT32_IN_DESC)
{
- utf8_string2_p = lit_get_magic_string_utf8 (string2_p->u.magic_string_id);
- utf8_string2_size = lit_get_magic_string_size (string2_p->u.magic_string_id);
- break;
+ utf8_string2_p = ecma_string_get_chars_fast (string2_p, &utf8_string2_size);
}
- default:
+ else
{
- JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string2_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
-
- utf8_string2_p = lit_get_magic_string_ex_utf8 (string2_p->u.magic_string_id);
- utf8_string2_size = lit_get_magic_string_ex_size (string2_p->u.magic_string_id);
- break;
+ utf8_string2_size = ecma_uint32_to_utf8_string (string2_p->u.uint32_number,
+ uint32_to_string_buffer2,
+ ECMA_MAX_CHARS_IN_STRINGIFIED_UINT32);
+ utf8_string2_p = uint32_to_string_buffer2;
}
}
utf8_string2_size);
} /* ecma_compare_ecma_strings_relational */
+/*
+ * Special value to represent that no size is available.
+ */
+#define ECMA_STRING_NO_ASCII_SIZE 0xffff
+
+/**
+ * Return the size of uint32 and magic strings.
+ * The length of these strings are equal to thier size.
+ *
+ * @return number of characters in the string
+ */
+static ecma_length_t
+ecma_string_get_ascii_size (const ecma_string_t *string_p) /**< ecma-string */
+{
+ if (ECMA_IS_DIRECT_STRING (string_p))
+ {
+ switch (ECMA_GET_DIRECT_STRING_TYPE (string_p))
+ {
+ case ECMA_DIRECT_STRING_MAGIC:
+ {
+ lit_magic_string_id_t id = (lit_magic_string_id_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+
+ JERRY_ASSERT (ECMA_STRING_IS_ASCII (lit_get_magic_string_utf8 (id),
+ lit_get_magic_string_size (id)));
+ return lit_get_magic_string_size (id);
+ }
+ case ECMA_DIRECT_STRING_UINT:
+ {
+ uint32_t uint32_number = (uint32_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+ return ecma_string_get_uint32_size (uint32_number);
+ }
+ default:
+ {
+ JERRY_ASSERT (ECMA_GET_DIRECT_STRING_TYPE (string_p) == ECMA_DIRECT_STRING_MAGIC_EX);
+
+ return ECMA_STRING_NO_ASCII_SIZE;
+ }
+ }
+ }
+
+ JERRY_ASSERT (string_p->refs_and_container >= ECMA_STRING_REF_ONE);
+
+ if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
+ {
+ return ecma_string_get_uint32_size (string_p->u.uint32_number);
+ }
+
+ return ECMA_STRING_NO_ASCII_SIZE;
+} /* ecma_string_get_ascii_size */
+
/**
* Get length of ecma-string
*
ecma_length_t
ecma_string_get_length (const ecma_string_t *string_p) /**< ecma-string */
{
+ ecma_length_t length = ecma_string_get_ascii_size (string_p);
+
+ if (length != ECMA_STRING_NO_ASCII_SIZE)
+ {
+ return length;
+ }
+
+ if (ECMA_IS_DIRECT_STRING (string_p))
+ {
+ JERRY_ASSERT (ECMA_GET_DIRECT_STRING_TYPE (string_p) == ECMA_DIRECT_STRING_MAGIC_EX);
+
+ lit_magic_string_ex_id_t id = (lit_magic_string_ex_id_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+ return lit_utf8_string_length (lit_get_magic_string_ex_utf8 (id),
+ lit_get_magic_string_ex_size (id));
+ }
+
switch (ECMA_STRING_GET_CONTAINER (string_p))
{
case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
{
return (ecma_length_t) (((ecma_long_string_t *) string_p)->long_utf8_string_length);
}
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- {
- return ecma_string_get_number_in_desc_size (string_p->u.uint32_number);
- }
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- {
- JERRY_ASSERT (ECMA_STRING_IS_ASCII (lit_get_magic_string_utf8 (string_p->u.magic_string_id),
- lit_get_magic_string_size (string_p->u.magic_string_id)));
- return lit_get_magic_string_size (string_p->u.magic_string_id);
- }
default:
{
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
ecma_length_t
ecma_string_get_utf8_length (const ecma_string_t *string_p) /**< ecma-string */
{
+ ecma_length_t length = ecma_string_get_ascii_size (string_p);
+
+ if (length != ECMA_STRING_NO_ASCII_SIZE)
+ {
+ return length;
+ }
+
+ if (ECMA_IS_DIRECT_STRING (string_p))
+ {
+ JERRY_ASSERT (ECMA_GET_DIRECT_STRING_TYPE (string_p) == ECMA_DIRECT_STRING_MAGIC_EX);
+
+ lit_magic_string_ex_id_t id = (lit_magic_string_ex_id_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+ return lit_get_utf8_length_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
+ lit_get_magic_string_ex_size (id));
+ }
+
switch (ECMA_STRING_GET_CONTAINER (string_p))
{
case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
return lit_get_utf8_length_of_cesu8_string ((const lit_utf8_byte_t *) (string_p + 1),
(lit_utf8_size_t) string_p->u.long_utf8_string_size);
}
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- {
- return ecma_string_get_number_in_desc_size (string_p->u.uint32_number);
- }
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- {
- JERRY_ASSERT (ECMA_STRING_IS_ASCII (lit_get_magic_string_utf8 (string_p->u.magic_string_id),
- lit_get_magic_string_size (string_p->u.magic_string_id)));
- return lit_get_magic_string_size (string_p->u.magic_string_id);
- }
default:
{
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
lit_utf8_size_t
ecma_string_get_size (const ecma_string_t *string_p) /**< ecma-string */
{
+ ecma_length_t length = ecma_string_get_ascii_size (string_p);
+
+ if (length != ECMA_STRING_NO_ASCII_SIZE)
+ {
+ return length;
+ }
+
+ if (ECMA_IS_DIRECT_STRING (string_p))
+ {
+ JERRY_ASSERT (ECMA_GET_DIRECT_STRING_TYPE (string_p) == ECMA_DIRECT_STRING_MAGIC_EX);
+
+ lit_magic_string_ex_id_t id = (lit_magic_string_ex_id_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+ return lit_get_magic_string_ex_size (id);
+ }
+
switch (ECMA_STRING_GET_CONTAINER (string_p))
{
case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
{
return (lit_utf8_size_t) string_p->u.long_utf8_string_size;
}
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- {
- return (lit_utf8_size_t) ecma_string_get_number_in_desc_size (string_p->u.uint32_number);
- }
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- {
- return lit_get_magic_string_size (string_p->u.magic_string_id);
- }
default:
{
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
lit_utf8_size_t
ecma_string_get_utf8_size (const ecma_string_t *string_p) /**< ecma-string */
{
+ ecma_length_t length = ecma_string_get_ascii_size (string_p);
+
+ if (length != ECMA_STRING_NO_ASCII_SIZE)
+ {
+ return length;
+ }
+
+ if (ECMA_IS_DIRECT_STRING (string_p))
+ {
+ JERRY_ASSERT (ECMA_GET_DIRECT_STRING_TYPE (string_p) == ECMA_DIRECT_STRING_MAGIC_EX);
+
+ lit_magic_string_ex_id_t id = (lit_magic_string_ex_id_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+ return lit_get_utf8_size_of_cesu8_string (lit_get_magic_string_ex_utf8 (id),
+ lit_get_magic_string_ex_size (id));
+ }
+
switch (ECMA_STRING_GET_CONTAINER (string_p))
{
case ECMA_STRING_CONTAINER_HEAP_UTF8_STRING:
return lit_get_utf8_size_of_cesu8_string ((const lit_utf8_byte_t *) (string_p + 1),
(lit_utf8_size_t) string_p->u.long_utf8_string_size);
}
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- {
- return (lit_utf8_size_t) ecma_string_get_number_in_desc_size (string_p->u.uint32_number);
- }
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- {
- return lit_get_magic_string_size (string_p->u.magic_string_id);
- }
default:
{
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING_EX);
JERRY_ASSERT (index < ecma_string_get_length (string_p));
lit_utf8_size_t buffer_size;
- bool is_ascii;
- const lit_utf8_byte_t *chars_p = ecma_string_raw_chars (string_p, &buffer_size, &is_ascii);
+ uint8_t flags = ECMA_STRING_FLAG_IS_ASCII;
+ const lit_utf8_byte_t *chars_p = ecma_string_get_chars (string_p, &buffer_size, &flags);
- if (chars_p != NULL)
+ ecma_char_t ch;
+ if (flags & ECMA_STRING_FLAG_IS_ASCII)
{
- if (is_ascii)
- {
- return chars_p[index];
- }
-
- return lit_utf8_string_code_unit_at (chars_p, buffer_size, index);
+ ch = chars_p[index];
+ }
+ else
+ {
+ ch = lit_utf8_string_code_unit_at (chars_p, buffer_size, index);
}
- ecma_char_t ch;
-
- JMEM_DEFINE_LOCAL_ARRAY (utf8_str_p, buffer_size, lit_utf8_byte_t);
-
- ecma_string_to_utf8_bytes (string_p, utf8_str_p, buffer_size);
-
- JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC);
- /* Both above must be ascii strings. */
- JERRY_ASSERT (is_ascii);
-
- ch = utf8_str_p[index];
-
- JMEM_FINALIZE_LOCAL_ARRAY (utf8_str_p);
+ if (flags & ECMA_STRING_FLAG_MUST_BE_FREED)
+ {
+ jmem_heap_free_block ((void *) chars_p, buffer_size);
+ }
return ch;
} /* ecma_string_get_char_at_pos */
/**
- * Get specified magic string
- *
- * @return ecma-string containing specified magic string
- */
-ecma_string_t *
-ecma_get_magic_string (lit_magic_string_id_t id) /**< magic string id */
-{
- return ecma_new_ecma_string_from_magic_string_id (id);
-} /* ecma_get_magic_string */
-
-/**
- * Get specified external magic string
- *
- * @return ecma-string containing specified external magic string
- */
-ecma_string_t *
-ecma_get_magic_string_ex (lit_magic_string_ex_id_t id) /**< external magic string id */
-{
- return ecma_new_ecma_string_from_magic_string_ex_id (id);
-} /* ecma_get_magic_string_ex */
-
-/**
* Check if passed string equals to one of magic strings
* and if equal magic string was found, return it's id in 'out_id_p' argument.
*
lit_magic_string_id_t
ecma_get_string_magic (const ecma_string_t *string_p) /**< ecma-string */
{
- if (ECMA_STRING_GET_CONTAINER (string_p) == ECMA_STRING_CONTAINER_MAGIC_STRING)
+ if (ECMA_IS_DIRECT_STRING_WITH_TYPE (string_p, ECMA_DIRECT_STRING_MAGIC))
{
- return (lit_magic_string_id_t) string_p->u.magic_string_id;
+ return (lit_magic_string_id_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
}
return LIT_MAGIC_STRING__COUNT;
inline lit_string_hash_t __attr_always_inline___
ecma_string_hash (const ecma_string_t *string_p) /**< ecma-string to calculate hash for */
{
- return (string_p->hash);
+ if (!ECMA_IS_DIRECT_STRING (string_p))
+ {
+ return (string_p->hash);
+ }
+
+ lit_string_hash_t hash = (lit_string_hash_t) ECMA_GET_DIRECT_STRING_VALUE (string_p);
+
+ if (ECMA_GET_DIRECT_STRING_TYPE (string_p) == ECMA_DIRECT_STRING_MAGIC_EX)
+ {
+ hash = (lit_string_hash_t) (hash + LIT_MAGIC_STRING__COUNT);
+ }
+
+ return hash;
} /* ecma_string_hash */
/**
#include "jrt-bit-fields.h"
#include "vm-defines.h"
+#include "ecma-function-object.h"
+
/** \addtogroup ecma ECMA
* @{
*
{
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
+ JERRY_ASSERT (ptr != NULL);
uintptr_t uint_ptr = (uintptr_t) ptr;
JERRY_ASSERT ((uint_ptr & ECMA_VALUE_TYPE_MASK) == 0);
return (ecma_value_t) uint_ptr;
ecma_get_pointer_from_ecma_value (ecma_value_t value) /**< value */
{
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
- return (void *) (uintptr_t) ((value) & ~ECMA_VALUE_TYPE_MASK);
+ void *ptr = (void *) (uintptr_t) ((value) & ~ECMA_VALUE_TYPE_MASK);
+ JERRY_ASSERT (ptr != NULL);
+ return ptr;
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
- return ECMA_GET_NON_NULL_POINTER (ecma_number_t,
- value >> ECMA_VALUE_SHIFT);
+ return ECMA_GET_NON_NULL_POINTER (void, value >> ECMA_VALUE_SHIFT);
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
} /* ecma_get_pointer_from_ecma_value */
|| ecma_is_value_float_number (value));
} /* ecma_is_value_number */
+JERRY_STATIC_ASSERT ((ECMA_TYPE_STRING | 0x4) == ECMA_TYPE_DIRECT_STRING,
+ ecma_type_string_and_direct_string_must_have_one_bit_difference);
+
/**
* Check if the value is ecma-string.
*
inline bool __attr_const___ __attr_always_inline___
ecma_is_value_string (ecma_value_t value) /**< ecma value */
{
- return (ecma_get_value_type_field (value) == ECMA_TYPE_STRING);
+ return ((value & (ECMA_VALUE_TYPE_MASK - 0x4)) == ECMA_TYPE_STRING);
} /* ecma_is_value_string */
/**
+ * Check if the value is direct_ecma-string.
+ *
+ * @return true - if the value contains ecma-string value,
+ * false - otherwise
+ */
+inline bool __attr_const___ __attr_always_inline___
+ecma_is_value_direct_string (ecma_value_t value) /**< ecma value */
+{
+ return (ecma_get_value_type_field (value) == ECMA_TYPE_DIRECT_STRING);
+} /* ecma_is_value_direct_string */
+
+/**
* Check if the value is object.
*
* @return true - if the value contains object value,
/**
* Check if the value is error reference.
*
- * @return true - if the value contains object value,
+ * @return true - if the value contains an error reference,
* false - otherwise
*/
inline bool __attr_const___ __attr_always_inline___
} /* ecma_is_value_error_reference */
/**
+ * Check if the value is collection chunk.
+ *
+ * @return true - if the value contains a collection chunk,
+ * false - otherwise
+ */
+inline bool __attr_const___ __attr_always_inline___
+ecma_is_value_collection_chunk (ecma_value_t value) /**< ecma value */
+{
+ return (ecma_get_value_type_field (value) == ECMA_TYPE_COLLECTION_CHUNK);
+} /* ecma_is_value_collection_chunk */
+
+/**
* Debug assertion that specified value's type is one of ECMA-defined
* script-visible types, i.e.: undefined, null, boolean, number, string, object.
*/
{
JERRY_ASSERT (ecma_string_p != NULL);
+ if ((((uintptr_t) ecma_string_p) & ECMA_VALUE_TYPE_MASK) != 0)
+ {
+ return (ecma_value_t) (uintptr_t) ecma_string_p;
+ }
+
return ecma_pointer_to_ecma_value (ecma_string_p) | ECMA_TYPE_STRING;
} /* ecma_make_string_value */
/**
+ * String value constructor
+ */
+inline ecma_value_t __attr_pure___ __attr_always_inline___
+ecma_make_magic_string_value (lit_magic_string_id_t id) /**< magic string id */
+{
+ return (ecma_value_t) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_MAGIC, (uintptr_t) id);
+} /* ecma_make_magic_string_value */
+
+/**
* Object value constructor
*/
inline ecma_value_t __attr_pure___ __attr_always_inline___
} /* ecma_make_error_reference_value */
/**
+ * Collection chunk constructor
+ */
+inline ecma_value_t __attr_pure___ __attr_always_inline___
+ecma_make_collection_chunk_value (const ecma_collection_chunk_t *collection_chunk_p) /**< collection chunk */
+{
+#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
+
+ uintptr_t uint_ptr = (uintptr_t) collection_chunk_p;
+ JERRY_ASSERT ((uint_ptr & ECMA_VALUE_TYPE_MASK) == 0);
+ return ((ecma_value_t) uint_ptr) | ECMA_TYPE_COLLECTION_CHUNK;
+
+#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
+
+ jmem_cpointer_t ptr_cp;
+ ECMA_SET_POINTER (ptr_cp, collection_chunk_p);
+ return (((ecma_value_t) ptr_cp) << ECMA_VALUE_SHIFT) | ECMA_TYPE_COLLECTION_CHUNK;
+
+#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
+} /* ecma_make_collection_chunk_value */
+
+/**
* Get integer value from an integer ecma value
*
* @return floating point value
inline ecma_string_t *__attr_pure___ __attr_always_inline___
ecma_get_string_from_value (ecma_value_t value) /**< ecma value */
{
- JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_STRING);
+ JERRY_ASSERT (ecma_is_value_string (value));
+
+ if ((value & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_DIRECT_STRING)
+ {
+ return (ecma_string_t *) (uintptr_t) value;
+ }
return (ecma_string_t *) ecma_get_pointer_from_ecma_value (value);
} /* ecma_get_string_from_value */
inline ecma_object_t *__attr_pure___ __attr_always_inline___
ecma_get_object_from_value (ecma_value_t value) /**< ecma value */
{
- JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_OBJECT);
+ JERRY_ASSERT (ecma_is_value_object (value));
return (ecma_object_t *) ecma_get_pointer_from_ecma_value (value);
} /* ecma_get_object_from_value */
} /* ecma_get_error_reference_from_value */
/**
+ * Get pointer to collection chunk from ecma value
+ *
+ * @return the pointer
+ */
+inline ecma_collection_chunk_t *__attr_pure___ __attr_always_inline___
+ecma_get_collection_chunk_from_value (ecma_value_t value) /**< ecma value */
+{
+ JERRY_ASSERT (ecma_get_value_type_field (value) == ECMA_TYPE_COLLECTION_CHUNK);
+
+#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
+ return (ecma_collection_chunk_t *) (uintptr_t) ((value) & ~ECMA_VALUE_TYPE_MASK);
+#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
+ return ECMA_GET_POINTER (ecma_collection_chunk_t, value >> ECMA_VALUE_SHIFT);
+#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
+} /* ecma_get_collection_chunk_from_value */
+
+/**
* Invert a boolean value
*
* @return ecma value
switch (ecma_get_value_type_field (value))
{
case ECMA_TYPE_DIRECT:
+ case ECMA_TYPE_DIRECT_STRING:
{
return value;
}
switch (ecma_get_value_type_field (value))
{
case ECMA_TYPE_DIRECT:
+ case ECMA_TYPE_DIRECT_STRING:
{
/* no memory is allocated */
break;
} /* ecma_free_value_if_not_object */
/**
+ * Get the literal id associated with the given ecma_value type.
+ * This operation is equivalent to the JavaScript 'typeof' operator.
+ *
+ * @returns one of the following value:
+ * - LIT_MAGIC_STRING_UNDEFINED
+ * - LIT_MAGIC_STRING_OBJECT
+ * - LIT_MAGIC_STRING_BOOLEAN
+ * - LIT_MAGIC_STRING_NUMBER
+ * - LIT_MAGIC_STRING_STRING
+ * - LIT_MAGIC_STRING_FUNCTION
+ */
+lit_magic_string_id_t
+ecma_get_typeof_lit_id (ecma_value_t value) /**< input ecma value */
+{
+ lit_magic_string_id_t ret_value = LIT_MAGIC_STRING__EMPTY;
+
+ if (ecma_is_value_undefined (value))
+ {
+ ret_value = LIT_MAGIC_STRING_UNDEFINED;
+ }
+ else if (ecma_is_value_null (value))
+ {
+ ret_value = LIT_MAGIC_STRING_OBJECT;
+ }
+ else if (ecma_is_value_boolean (value))
+ {
+ ret_value = LIT_MAGIC_STRING_BOOLEAN;
+ }
+ else if (ecma_is_value_number (value))
+ {
+ ret_value = LIT_MAGIC_STRING_NUMBER;
+ }
+ else if (ecma_is_value_string (value))
+ {
+ ret_value = LIT_MAGIC_STRING_STRING;
+ }
+ else
+ {
+ JERRY_ASSERT (ecma_is_value_object (value));
+
+ ret_value = ecma_op_is_callable (value) ? LIT_MAGIC_STRING_FUNCTION : LIT_MAGIC_STRING_OBJECT;
+ }
+
+ JERRY_ASSERT (ret_value != LIT_MAGIC_STRING__EMPTY);
+
+ return ret_value;
+} /* ecma_get_typeof_lit_id */
+
+/**
* @}
* @}
*/
*/
/**
+ * The type of ecma error and ecma collection chunk must be the same.
+ */
+JERRY_STATIC_ASSERT (ECMA_TYPE_ERROR == ECMA_TYPE_COLLECTION_CHUNK,
+ ecma_type_error_must_be_the_same_as_ecma_type_collection_chunk);
+
+/**
* Allocate a collection of ecma values.
*
* @return pointer to the collection's header
*/
ecma_collection_header_t *
-ecma_new_values_collection (const ecma_value_t values_buffer[], /**< ecma values */
- ecma_length_t values_number, /**< number of ecma values */
- bool do_ref_if_object) /**< if the value is object value,
- increase reference counter of the object */
+ecma_new_values_collection (void)
{
- JERRY_ASSERT (values_buffer != NULL || values_number == 0);
-
- const size_t values_in_chunk = JERRY_SIZE_OF_STRUCT_MEMBER (ecma_collection_chunk_t, data) / sizeof (ecma_value_t);
-
- ecma_collection_header_t *header_p = ecma_alloc_collection_header ();
-
- header_p->unit_number = values_number;
-
- jmem_cpointer_t *next_chunk_cp_p = &header_p->first_chunk_cp;
- ecma_collection_chunk_t *last_chunk_p = NULL;
- ecma_value_t *cur_value_buf_iter_p = NULL;
- ecma_value_t *cur_value_buf_end_p = NULL;
-
- for (ecma_length_t value_index = 0;
- value_index < values_number;
- value_index++)
- {
- if (cur_value_buf_iter_p == cur_value_buf_end_p)
- {
- ecma_collection_chunk_t *chunk_p = ecma_alloc_collection_chunk ();
- ECMA_SET_POINTER (*next_chunk_cp_p, chunk_p);
- next_chunk_cp_p = &chunk_p->next_chunk_cp;
-
- cur_value_buf_iter_p = (ecma_value_t *) chunk_p->data;
- cur_value_buf_end_p = cur_value_buf_iter_p + values_in_chunk;
-
- last_chunk_p = chunk_p;
- }
-
- JERRY_ASSERT (cur_value_buf_iter_p + 1 <= cur_value_buf_end_p);
+ ecma_collection_header_t *header_p;
+ header_p = (ecma_collection_header_t *) jmem_pools_alloc (sizeof (ecma_collection_header_t));
- if (do_ref_if_object)
- {
- *cur_value_buf_iter_p++ = ecma_copy_value (values_buffer[value_index]);
- }
- else
- {
- *cur_value_buf_iter_p++ = ecma_copy_value_if_not_object (values_buffer[value_index]);
- }
- }
-
- *next_chunk_cp_p = ECMA_NULL_POINTER;
- ECMA_SET_POINTER (header_p->last_chunk_cp, last_chunk_p);
+ header_p->item_count = 0;
+ header_p->first_chunk_cp = ECMA_NULL_POINTER;
+ header_p->last_chunk_cp = ECMA_NULL_POINTER;
return header_p;
} /* ecma_new_values_collection */
*/
void
ecma_free_values_collection (ecma_collection_header_t *header_p, /**< collection's header */
- bool do_deref_if_object) /**< if the value is object value,
- decrement reference counter of the object */
+ uint32_t flags) /**< combination of ecma_collection_flag_t flags */
{
- JERRY_ASSERT (header_p != NULL);
-
- const size_t values_in_chunk = JERRY_SIZE_OF_STRUCT_MEMBER (ecma_collection_chunk_t, data) / sizeof (ecma_value_t);
-
ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
header_p->first_chunk_cp);
- ecma_length_t value_index = 0;
- while (chunk_p != NULL)
+ jmem_heap_free_block (header_p, sizeof (ecma_collection_header_t));
+
+ if (chunk_p == NULL)
{
- JERRY_ASSERT (value_index < header_p->unit_number);
+ return;
+ }
- ecma_value_t *cur_value_buf_iter_p = (ecma_value_t *) chunk_p->data;
- ecma_value_t *cur_value_buf_end_p = cur_value_buf_iter_p + values_in_chunk;
+ do
+ {
+ ecma_value_t *item_p = chunk_p->items;
- while (cur_value_buf_iter_p != cur_value_buf_end_p
- && value_index < header_p->unit_number)
- {
- JERRY_ASSERT (cur_value_buf_iter_p < cur_value_buf_end_p);
+ JERRY_ASSERT (!ecma_is_value_collection_chunk (*item_p));
- if (do_deref_if_object)
- {
- ecma_free_value (*cur_value_buf_iter_p);
- }
- else
+ do
+ {
+ if (!(flags & ECMA_COLLECTION_NO_COPY)
+ && (!ecma_is_value_object (*item_p)
+ || !(flags & ECMA_COLLECTION_NO_REF_OBJECTS)))
{
- ecma_free_value_if_not_object (*cur_value_buf_iter_p);
+ ecma_free_value (*item_p);
}
- cur_value_buf_iter_p++;
- value_index++;
+ item_p++;
}
+ while (!ecma_is_value_collection_chunk (*item_p));
+
+ ecma_collection_chunk_t *next_chunk_p = ecma_get_collection_chunk_from_value (*item_p);
+
+ jmem_heap_free_block (chunk_p, sizeof (ecma_collection_chunk_t));
- ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
- chunk_p->next_chunk_cp);
- ecma_dealloc_collection_chunk (chunk_p);
chunk_p = next_chunk_p;
}
-
- ecma_dealloc_collection_header (header_p);
+ while (chunk_p != NULL);
} /* ecma_free_values_collection */
/**
*/
void
ecma_append_to_values_collection (ecma_collection_header_t *header_p, /**< collection's header */
- ecma_value_t v, /**< ecma value to append */
- bool do_ref_if_object) /**< if the value is object value,
- increase reference counter of the object */
+ ecma_value_t value, /**< ecma value to append */
+ uint32_t flags) /**< combination of ecma_collection_flag_t flags */
{
- const size_t values_in_chunk = JERRY_SIZE_OF_STRUCT_MEMBER (ecma_collection_chunk_t, data) / sizeof (ecma_value_t);
-
- size_t values_number = header_p->unit_number;
- size_t pos_of_new_value_in_chunk = values_number % values_in_chunk;
-
- values_number++;
+ ecma_length_t item_index;
+ ecma_collection_chunk_t *chunk_p;
- if ((ecma_length_t) values_number == values_number)
+ if (unlikely (header_p->item_count == 0))
{
- header_p->unit_number = (ecma_length_t) values_number;
+ item_index = 0;
+ chunk_p = (ecma_collection_chunk_t *) jmem_heap_alloc_block (sizeof (ecma_collection_chunk_t));
+
+ ECMA_SET_POINTER (header_p->first_chunk_cp, chunk_p);
+ header_p->last_chunk_cp = header_p->first_chunk_cp;
}
else
{
- jerry_fatal (ERR_OUT_OF_MEMORY);
- }
+ item_index = header_p->item_count % ECMA_COLLECTION_CHUNK_ITEMS;
- ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
- header_p->last_chunk_cp);
+ chunk_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
+ header_p->last_chunk_cp);
- if (pos_of_new_value_in_chunk == 0)
- {
- /* all chunks are currently filled with values */
+ if (unlikely (item_index == 0))
+ {
+ JERRY_ASSERT (ecma_is_value_collection_chunk (chunk_p->items[ECMA_COLLECTION_CHUNK_ITEMS])
+ && ecma_get_collection_chunk_from_value (chunk_p->items[ECMA_COLLECTION_CHUNK_ITEMS]) == NULL);
- chunk_p = ecma_alloc_collection_chunk ();
- chunk_p->next_chunk_cp = ECMA_NULL_POINTER;
+ ecma_collection_chunk_t *next_chunk_p;
+ next_chunk_p = (ecma_collection_chunk_t *) jmem_heap_alloc_block (sizeof (ecma_collection_chunk_t));
- if (header_p->last_chunk_cp == ECMA_NULL_POINTER)
- {
- JERRY_ASSERT (header_p->first_chunk_cp == ECMA_NULL_POINTER);
+ chunk_p->items[ECMA_COLLECTION_CHUNK_ITEMS] = ecma_make_collection_chunk_value (next_chunk_p);
+ ECMA_SET_POINTER (header_p->last_chunk_cp, next_chunk_p);
- ECMA_SET_NON_NULL_POINTER (header_p->first_chunk_cp, chunk_p);
+ chunk_p = next_chunk_p;
}
else
{
- ecma_collection_chunk_t *last_chunk_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
- header_p->last_chunk_cp);
-
- JERRY_ASSERT (last_chunk_p->next_chunk_cp == ECMA_NULL_POINTER);
-
- ECMA_SET_NON_NULL_POINTER (last_chunk_p->next_chunk_cp, chunk_p);
+ JERRY_ASSERT (ecma_is_value_collection_chunk (chunk_p->items[item_index])
+ && ecma_get_collection_chunk_from_value (chunk_p->items[item_index]) == NULL);
}
-
- ECMA_SET_NON_NULL_POINTER (header_p->last_chunk_cp, chunk_p);
}
- else
- {
- /* last chunk can be appended with the new value */
- JERRY_ASSERT (chunk_p != NULL);
- }
-
- ecma_value_t *values_p = (ecma_value_t *) chunk_p->data;
-
- JERRY_ASSERT ((uint8_t *) (values_p + pos_of_new_value_in_chunk + 1) <= (uint8_t *) (chunk_p + 1));
- if (do_ref_if_object)
+ if (!(flags & ECMA_COLLECTION_NO_COPY)
+ && (!ecma_is_value_object (value)
+ || !(flags & ECMA_COLLECTION_NO_REF_OBJECTS)))
{
- values_p[pos_of_new_value_in_chunk] = ecma_copy_value (v);
+ value = ecma_copy_value (value);
}
- else
- {
- values_p[pos_of_new_value_in_chunk] = ecma_copy_value_if_not_object (v);
- }
-} /* ecma_append_to_values_collection */
-/**
- * Remove last element of the collection
- *
- * Warning:
- * the function invalidates all iterators that are configured to access the passed collection
- */
-void
-ecma_remove_last_value_from_values_collection (ecma_collection_header_t *header_p) /**< collection's header */
-{
- JERRY_ASSERT (header_p != NULL && header_p->unit_number > 0);
-
- const size_t values_in_chunk = JERRY_SIZE_OF_STRUCT_MEMBER (ecma_collection_chunk_t, data) / sizeof (ecma_value_t);
- size_t values_number = header_p->unit_number;
- size_t pos_of_value_to_remove_in_chunk = (values_number - 1u) % values_in_chunk;
-
- ecma_collection_chunk_t *last_chunk_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
- header_p->last_chunk_cp);
-
- ecma_value_t *values_p = (ecma_value_t *) last_chunk_p->data;
- JERRY_ASSERT ((uint8_t *) (values_p + pos_of_value_to_remove_in_chunk + 1) <= (uint8_t *) (last_chunk_p + 1));
-
- ecma_value_t value_to_remove = values_p[pos_of_value_to_remove_in_chunk];
-
- ecma_free_value (value_to_remove);
-
- header_p->unit_number--;
-
- if (pos_of_value_to_remove_in_chunk == 0)
- {
- ecma_collection_chunk_t *chunk_to_remove_p = last_chunk_p;
-
- /* free last chunk */
- if (header_p->first_chunk_cp == header_p->last_chunk_cp)
- {
- header_p->first_chunk_cp = ECMA_NULL_POINTER;
- header_p->last_chunk_cp = ECMA_NULL_POINTER;
- }
- else
- {
- ecma_collection_chunk_t *chunk_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
- header_p->first_chunk_cp);
-
- while (chunk_iter_p->next_chunk_cp != header_p->last_chunk_cp)
- {
- chunk_iter_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
- chunk_iter_p->next_chunk_cp);
- }
-
- ecma_collection_chunk_t *new_last_chunk_p = chunk_iter_p;
-
- JERRY_ASSERT (ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
- new_last_chunk_p->next_chunk_cp) == chunk_to_remove_p);
-
- ECMA_SET_NON_NULL_POINTER (header_p->last_chunk_cp, new_last_chunk_p);
- new_last_chunk_p->next_chunk_cp = ECMA_NULL_POINTER;
- }
-
- ecma_dealloc_collection_chunk (chunk_to_remove_p);
- }
-} /* ecma_remove_last_value_from_values_collection */
+ chunk_p->items[item_index] = value;
+ chunk_p->items[item_index + 1] = ecma_make_collection_chunk_value (NULL);
+ header_p->item_count++;
+} /* ecma_append_to_values_collection */
/**
- * Allocate a collection of ecma-strings.
+ * Initialize new collection iterator for the collection
*
- * @return pointer to the collection's header
+ * @return pointer to the first item
*/
-ecma_collection_header_t *
-ecma_new_strings_collection (ecma_string_t *string_ptrs_buffer[], /**< pointers to ecma-strings */
- ecma_length_t strings_number) /**< number of ecma-strings */
+ecma_value_t *
+ecma_collection_iterator_init (ecma_collection_header_t *header_p) /**< header of collection */
{
- JERRY_ASSERT (string_ptrs_buffer != NULL || strings_number == 0);
-
- ecma_collection_header_t *new_collection_p;
-
- new_collection_p = ecma_new_values_collection (NULL, 0, false);
-
- for (ecma_length_t string_index = 0;
- string_index < strings_number;
- string_index++)
+ if (unlikely (!header_p || header_p->item_count == 0))
{
- ecma_append_to_values_collection (new_collection_p,
- ecma_make_string_value (string_ptrs_buffer[string_index]),
- false);
+ return NULL;
}
- return new_collection_p;
-} /* ecma_new_strings_collection */
+ ecma_collection_chunk_t *chunk_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
+ header_p->first_chunk_cp);
-/**
- * Initialize new collection iterator for the collection
- */
-void
-ecma_collection_iterator_init (ecma_collection_iterator_t *iterator_p, /**< context of iterator */
- ecma_collection_header_t *collection_p) /**< header of collection */
-{
- iterator_p->header_p = collection_p;
- iterator_p->next_chunk_cp = (collection_p != NULL ? collection_p->first_chunk_cp : JMEM_CP_NULL);
- iterator_p->current_index = 0;
- iterator_p->current_value_p = NULL;
- iterator_p->current_chunk_end_p = NULL;
+ return chunk_p->items;
} /* ecma_collection_iterator_init */
/**
* Move collection iterator to next element if there is any.
*
- * @return true - if iterator moved,
- * false - otherwise (current element is last element in the collection)
+ * @return pointer to the next item
*/
-bool
-ecma_collection_iterator_next (ecma_collection_iterator_t *iterator_p) /**< context of iterator */
+ecma_value_t *
+ecma_collection_iterator_next (ecma_value_t *ecma_value_p) /**< current value */
{
- if (iterator_p->header_p == NULL
- || unlikely (iterator_p->header_p->unit_number == 0)
- || unlikely (iterator_p->header_p->first_chunk_cp == JMEM_CP_NULL))
- {
- return false;
- }
+ JERRY_ASSERT (ecma_value_p != NULL);
- const size_t values_in_chunk = JERRY_SIZE_OF_STRUCT_MEMBER (ecma_collection_chunk_t, data) / sizeof (ecma_value_t);
+ ecma_value_p++;
- if (iterator_p->current_value_p == NULL)
+ if (unlikely (ecma_is_value_collection_chunk (*ecma_value_p)))
{
- JERRY_ASSERT (iterator_p->current_index == 0);
-
- ecma_collection_chunk_t *first_chunk_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
- iterator_p->header_p->first_chunk_cp);
+ ecma_value_p = ecma_get_collection_chunk_from_value (*ecma_value_p)->items;
- iterator_p->next_chunk_cp = first_chunk_p->next_chunk_cp;
- iterator_p->current_value_p = (ecma_value_t *) &first_chunk_p->data;
- iterator_p->current_chunk_end_p = (iterator_p->current_value_p + values_in_chunk);
- }
- else
- {
- if (iterator_p->current_index + 1 == iterator_p->header_p->unit_number)
- {
- return false;
- }
-
- JERRY_ASSERT (iterator_p->current_index + 1 < iterator_p->header_p->unit_number);
-
- iterator_p->current_index++;
- iterator_p->current_value_p++;
- }
-
- if (iterator_p->current_value_p == iterator_p->current_chunk_end_p)
- {
- ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
- iterator_p->next_chunk_cp);
- JERRY_ASSERT (next_chunk_p != NULL);
-
- iterator_p->next_chunk_cp = next_chunk_p->next_chunk_cp;
- iterator_p->current_value_p = (ecma_value_t *) &next_chunk_p->data;
- iterator_p->current_chunk_end_p = iterator_p->current_value_p + values_in_chunk;
- }
- else
- {
- JERRY_ASSERT (iterator_p->current_value_p < iterator_p->current_chunk_end_p);
+ JERRY_ASSERT (ecma_value_p == NULL || !ecma_is_value_collection_chunk (*ecma_value_p));
+ return ecma_value_p;
}
- return true;
+ return ecma_value_p;
} /* ecma_collection_iterator_next */
/**
#include "ecma-helpers.h"
#include "ecma-lcache.h"
#include "ecma-property-hashmap.h"
+#include "jcontext.h"
#include "jrt-bit-fields.h"
#include "byte-code.h"
#include "re-compiler.h"
#ifdef JERRY_DEBUGGER
#include "debugger.h"
-#include "jcontext.h"
#endif /* JERRY_DEBUGGER */
/** \addtogroup ecma ECMA
* @{
*/
-/**
- * The ecma property types must be lower than the container mask.
- */
JERRY_STATIC_ASSERT (ECMA_PROPERTY_TYPE_MASK >= ECMA_PROPERTY_TYPE__MAX,
ecma_property_types_must_be_lower_than_the_container_mask);
-/**
- * The ecma object types must be lower than the container mask.
- */
JERRY_STATIC_ASSERT (ECMA_OBJECT_TYPE_MASK >= ECMA_OBJECT_TYPE__MAX - 1,
ecma_object_types_must_be_lower_than_the_container_mask);
-/**
- * The ecma lexical environment types must be lower than the container mask.
- */
JERRY_STATIC_ASSERT (ECMA_OBJECT_TYPE_MASK >= ECMA_LEXICAL_ENVIRONMENT_TYPE__MAX,
ecma_lexical_environment_types_must_be_lower_than_the_container_mask);
-/**
- * The ecma built in flag must follow the object type.
- */
JERRY_STATIC_ASSERT (ECMA_OBJECT_TYPE_MASK + 1 == ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV,
ecma_built_in_flag_must_follow_the_object_type);
-/**
- * The ecma extensible flag must follow the gc visited flag.
- */
JERRY_STATIC_ASSERT (ECMA_OBJECT_FLAG_EXTENSIBLE == (ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV << 1),
ecma_extensible_flag_must_follow_the_built_in_flag);
-/**
- * The ecma object ref one must follow the extensible flag.
- */
JERRY_STATIC_ASSERT (ECMA_OBJECT_REF_ONE == (ECMA_OBJECT_FLAG_EXTENSIBLE << 1),
ecma_object_ref_one_must_follow_the_extensible_flag);
-/**
- * The ecma object max ref does not fill the remaining bits.
- */
JERRY_STATIC_ASSERT ((ECMA_OBJECT_MAX_REF | (ECMA_OBJECT_REF_ONE - 1)) == UINT16_MAX,
ecma_object_max_ref_does_not_fill_the_remaining_bits);
+JERRY_STATIC_ASSERT (ECMA_PROPERTY_TYPE_DELETED == (ECMA_DIRECT_STRING_MAGIC << ECMA_PROPERTY_NAME_TYPE_SHIFT),
+ ecma_property_type_deleted_must_have_magic_string_name_type);
+
+JERRY_STATIC_ASSERT (ECMA_PROPERTY_DELETED_NAME >= LIT_MAGIC_STRING__COUNT,
+ ecma_property_deleted_name_must_not_be_valid_maigc_string_id);
+
/**
* Create an object with specified prototype object
* (or NULL prototype if there is not prototype for the object)
/* Just copy the previous value (no need to decompress, compress). */
first_property_pair_p->header.next_property_cp = *property_list_head_p;
first_property_pair_p->header.types[0] = ECMA_PROPERTY_TYPE_DELETED;
- first_property_pair_p->names_cp[0] = ECMA_NULL_POINTER;
+ first_property_pair_p->names_cp[0] = ECMA_PROPERTY_DELETED_NAME;
if (name_p == NULL)
{
}
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
- property_p = NULL;
- jmem_cpointer_t property_name_cp = ECMA_NULL_POINTER;
+ JERRY_ASSERT (ECMA_PROPERTY_PAIR_ITEM_COUNT == 2);
uint32_t steps = 0;
+ jmem_cpointer_t property_name_cp = ECMA_NULL_POINTER;
- while (prop_iter_p != NULL)
+ if (ECMA_IS_DIRECT_STRING (name_p))
{
- JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
-
- ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
+ ecma_property_t prop_name_type = (ecma_property_t) ECMA_GET_DIRECT_STRING_TYPE (name_p);
+ property_name_cp = (jmem_cpointer_t) ECMA_GET_DIRECT_STRING_VALUE (name_p);
- JERRY_ASSERT (ECMA_PROPERTY_PAIR_ITEM_COUNT == 2);
+ JERRY_ASSERT (prop_name_type > 0);
- if (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[0]))
+ while (prop_iter_p != NULL)
{
- if (ecma_string_compare_to_property_name (prop_iter_p->types[0],
- prop_pair_p->names_cp[0],
- name_p))
+ JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
+
+ ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
+
+ if (prop_pair_p->names_cp[0] == property_name_cp
+ && ECMA_PROPERTY_GET_NAME_TYPE (prop_iter_p->types[0]) == prop_name_type)
{
- property_name_cp = prop_pair_p->names_cp[0];
+ JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[0]));
+
property_p = prop_iter_p->types + 0;
break;
}
- }
- if (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[1]))
- {
- if (ecma_string_compare_to_property_name (prop_iter_p->types[1],
- prop_pair_p->names_cp[1],
- name_p))
+ if (prop_pair_p->names_cp[1] == property_name_cp
+ && ECMA_PROPERTY_GET_NAME_TYPE (prop_iter_p->types[1]) == prop_name_type)
{
- property_name_cp = prop_pair_p->names_cp[1];
+ JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (prop_iter_p->types[1]));
+
property_p = prop_iter_p->types + 1;
break;
}
+
+ steps++;
+
+ prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
+ prop_iter_p->next_property_cp);
}
+ }
+ else
+ {
+ while (prop_iter_p != NULL)
+ {
+ JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
- steps++;
+ ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
- prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
- prop_iter_p->next_property_cp);
+ if (ECMA_PROPERTY_GET_NAME_TYPE (prop_iter_p->types[0]) == ECMA_DIRECT_STRING_PTR)
+ {
+ property_name_cp = prop_pair_p->names_cp[0];
+ ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, property_name_cp);
+
+ if (ecma_compare_ecma_non_direct_strings (name_p, prop_name_p))
+ {
+ property_p = prop_iter_p->types + 0;
+ break;
+ }
+ }
+
+ if (ECMA_PROPERTY_GET_NAME_TYPE (prop_iter_p->types[1]) == ECMA_DIRECT_STRING_PTR)
+ {
+ property_name_cp = prop_pair_p->names_cp[1];
+ ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, property_name_cp);
+
+ if (ecma_compare_ecma_non_direct_strings (name_p, prop_name_p))
+ {
+ property_p = prop_iter_p->types + 1;
+ break;
+ }
+ }
+
+ steps++;
+
+ prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
+ prop_iter_p->next_property_cp);
+ }
}
if (steps >= (ECMA_PROPERTY_HASMAP_MINIMUM_SIZE / 2))
{
case ECMA_PROPERTY_TYPE_NAMEDDATA:
{
- if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_STRING_CONTAINER_MAGIC_STRING)
+ if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_MAGIC)
{
if (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|| name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER)
ecma_lcache_invalidate (object_p, name_cp, property_p);
}
- if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_PROPERTY_NAME_TYPE_STRING)
+ if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_PTR)
{
ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, name_cp);
ecma_deref_ecma_string (prop_name_p);
}
-
- *property_p = ECMA_PROPERTY_TYPE_DELETED;
} /* ecma_free_property */
/**
}
ecma_free_property (object_p, prop_pair_p->names_cp[i], cur_prop_p->types + i);
+ cur_prop_p->types[i] = ECMA_PROPERTY_TYPE_DELETED;
+ prop_pair_p->names_cp[i] = ECMA_PROPERTY_DELETED_NAME;
JERRY_ASSERT (ECMA_PROPERTY_PAIR_ITEM_COUNT == 2);
}
ecma_free_property (object_p, prop_pair_p->names_cp[i], current_prop_p->types + i);
-
- JERRY_ASSERT (current_prop_p->types[i] == ECMA_PROPERTY_TYPE_DELETED);
+ current_prop_p->types[i] = ECMA_PROPERTY_TYPE_DELETED;
+ prop_pair_p->names_cp[i] = ECMA_PROPERTY_DELETED_NAME;
}
}
}
* @return error reference value
*/
ecma_value_t
-ecma_create_error_reference (ecma_value_t value) /**< referenced value */
+ecma_create_error_reference (ecma_value_t value, /**< referenced value */
+ bool is_exception) /**< error reference is an exception */
{
ecma_error_reference_t *error_ref_p = (ecma_error_reference_t *) jmem_pools_alloc (sizeof (ecma_error_reference_t));
- error_ref_p->refs = 1;
+ error_ref_p->refs_and_flags = ECMA_ERROR_REF_ONE | (is_exception ? 0 : ECMA_ERROR_REF_ABORT);
error_ref_p->value = value;
return ecma_make_error_reference_value (error_ref_p);
} /* ecma_create_error_reference */
/**
+ * Create an error reference from the currently thrown error value.
+ *
+ * @return error reference value
+ */
+ecma_value_t
+ecma_create_error_reference_from_context (void)
+{
+ return ecma_create_error_reference (JERRY_CONTEXT (error_value),
+ (JERRY_CONTEXT (status_flags) & ECMA_STATUS_EXCEPTION) != 0);
+} /* ecma_create_error_reference_from_context */
+
+/**
* Create an error reference from a given object.
*
* Note:
inline ecma_value_t __attr_always_inline___
ecma_create_error_object_reference (ecma_object_t *object_p) /**< referenced object */
{
- return ecma_create_error_reference (ecma_make_object_value (object_p));
+ return ecma_create_error_reference (ecma_make_object_value (object_p), true);
} /* ecma_create_error_object_reference */
/**
void
ecma_ref_error_reference (ecma_error_reference_t *error_ref_p) /**< error reference */
{
- if (likely (error_ref_p->refs < UINT32_MAX))
+ if (likely (error_ref_p->refs_and_flags < ECMA_ERROR_MAX_REF))
{
- error_ref_p->refs++;
+ error_ref_p->refs_and_flags += ECMA_ERROR_REF_ONE;
}
else
{
void
ecma_deref_error_reference (ecma_error_reference_t *error_ref_p) /**< error reference */
{
- JERRY_ASSERT (error_ref_p->refs > 0);
+ JERRY_ASSERT (error_ref_p->refs_and_flags >= ECMA_ERROR_REF_ONE);
- error_ref_p->refs--;
+ error_ref_p->refs_and_flags -= ECMA_ERROR_REF_ONE;
- if (error_ref_p->refs == 0)
+ if (error_ref_p->refs_and_flags < ECMA_ERROR_REF_ONE)
{
ecma_free_value (error_ref_p->value);
jmem_pools_free (error_ref_p, sizeof (ecma_error_reference_t));
* @return value referenced by the error
*/
ecma_value_t
-ecma_clear_error_reference (ecma_value_t value)
+ecma_clear_error_reference (ecma_value_t value, /**< error reference */
+ bool set_abort_flag) /**< set abort flag */
{
ecma_error_reference_t *error_ref_p = ecma_get_error_reference_from_value (value);
- JERRY_ASSERT (error_ref_p->refs > 0);
+ if (set_abort_flag)
+ {
+ if (error_ref_p->refs_and_flags & ECMA_ERROR_REF_ABORT)
+ {
+ JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_EXCEPTION;
+ }
+ else
+ {
+ JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
+ }
+ }
+
+ JERRY_ASSERT (error_ref_p->refs_and_flags >= ECMA_ERROR_REF_ONE);
- if (error_ref_p->refs > 1)
+ if (error_ref_p->refs_and_flags >= 2 * ECMA_ERROR_REF_ONE)
{
- error_ref_p->refs--;
+ error_ref_p->refs_and_flags -= ECMA_ERROR_REF_ONE;
return ecma_copy_value (error_ref_p->value);
}
ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
{
JERRY_ASSERT (bytecode_p->refs > 0);
+ JERRY_ASSERT (!(bytecode_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION));
bytecode_p->refs--;
if (bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
{
- jmem_cpointer_t *literal_start_p = NULL;
+ ecma_value_t *literal_start_p = NULL;
uint32_t literal_end;
uint32_t const_literal_end;
if (bytecode_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{
- uint8_t *byte_p = (uint8_t *) bytecode_p;
- literal_start_p = (jmem_cpointer_t *) (byte_p + sizeof (cbc_uint16_arguments_t));
-
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) bytecode_p;
literal_end = args_p->literal_end;
const_literal_end = args_p->const_literal_end;
+
+ literal_start_p = (ecma_value_t *) ((uint8_t *) bytecode_p + sizeof (cbc_uint16_arguments_t));
+ literal_start_p -= args_p->register_end;
}
else
{
- uint8_t *byte_p = (uint8_t *) bytecode_p;
- literal_start_p = (jmem_cpointer_t *) (byte_p + sizeof (cbc_uint8_arguments_t));
-
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) bytecode_p;
literal_end = args_p->literal_end;
const_literal_end = args_p->const_literal_end;
+
+ literal_start_p = (ecma_value_t *) ((uint8_t *) bytecode_p + sizeof (cbc_uint8_arguments_t));
+ literal_start_p -= args_p->register_end;
}
for (uint32_t i = const_literal_end; i < literal_end; i++)
{
- jmem_cpointer_t bytecode_cpointer = literal_start_p[i];
- ecma_compiled_code_t *bytecode_literal_p = ECMA_GET_NON_NULL_POINTER (ecma_compiled_code_t,
- bytecode_cpointer);
+ ecma_compiled_code_t *bytecode_literal_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
+ literal_start_p[i]);
/* Self references are ignored. */
if (bytecode_literal_p != bytecode_p)
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
re_compiled_code_t *re_bytecode_p = (re_compiled_code_t *) bytecode_p;
- ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t, re_bytecode_p->pattern_cp));
+ ecma_deref_ecma_string (ecma_get_string_from_value (re_bytecode_p->pattern));
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
}
*/
#define ECMA_SET_POINTER(field, non_compressed_pointer) JMEM_CP_SET_POINTER (field, non_compressed_pointer)
+typedef enum
+{
+ ECMA_STRING_FLAG_EMPTY = 0,
+ ECMA_STRING_FLAG_IS_ASCII,
+ ECMA_STRING_FLAG_MUST_BE_FREED
+} ecma_string_flag_t;
+
/**
* Convert ecma-string's contents to a cesu-8 string and put it into a buffer.
*/
utf8_ptr, /**< [out] output buffer pointer */ \
utf8_str_size) /**< [out] output buffer size */ \
lit_utf8_size_t utf8_str_size; \
- bool utf8_ptr ## must_be_freed; \
- const lit_utf8_byte_t *utf8_ptr = ecma_string_raw_chars (ecma_str_ptr, &utf8_str_size, &utf8_ptr ## must_be_freed); \
- utf8_ptr ## must_be_freed = false; /* it was used as 'is_ascii' in 'ecma_string_raw_chars', so we must reset it */ \
- \
- if (utf8_ptr == NULL) \
+ uint8_t utf8_ptr ## flags = ECMA_STRING_FLAG_EMPTY; \
+ const lit_utf8_byte_t *utf8_ptr = ecma_string_get_chars (ecma_str_ptr, &utf8_str_size, &utf8_ptr ## flags);
+
+/**
+ * Free the cesu-8 string buffer allocated by 'ECMA_STRING_TO_UTF8_STRING'
+ */
+#define ECMA_FINALIZE_UTF8_STRING(utf8_ptr, /**< pointer to character buffer */ \
+ utf8_str_size) /**< buffer size */ \
+ if (utf8_ptr ## flags & ECMA_STRING_FLAG_MUST_BE_FREED) \
{ \
- utf8_ptr = (const lit_utf8_byte_t *) jmem_heap_alloc_block (utf8_str_size); \
- ecma_string_to_utf8_bytes (ecma_str_ptr, (lit_utf8_byte_t *) utf8_ptr, utf8_str_size); \
- utf8_ptr ## must_be_freed = true; \
+ JERRY_ASSERT (utf8_ptr != NULL); \
+ jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
}
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
/**
- * Set an internal property value of pointer
+ * Set an internal property value from pointer.
*/
#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \
(field) = ((ecma_value_t) pointer)
/**
- * Get an internal property value of pointer
+ * Set an internal property value from pointer. Pointer can be NULL.
+ */
+#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \
+ (field) = ((ecma_value_t) pointer)
+
+/**
+ * Convert an internal property value to pointer.
*/
#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
((type *) field)
+/**
+ * Convert an internal property value to pointer. Result can be NULL.
+ */
+#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
+ ((type *) field)
+
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
/**
- * Set an internal property value of non-null pointer so that it will correspond
- * to specified non_compressed_pointer.
+ * Set an internal property value from pointer.
*/
-#define ECMA_SET_INTERNAL_VALUE_POINTER(field, non_compressed_pointer) \
- ECMA_SET_NON_NULL_POINTER (field, non_compressed_pointer)
+#define ECMA_SET_INTERNAL_VALUE_POINTER(field, pointer) \
+ ECMA_SET_NON_NULL_POINTER (field, pointer)
/**
- * Get an internal property value of pointer from specified compressed pointer.
+ * Set an internal property value from pointer. Pointer can be NULL.
*/
-#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
- ECMA_GET_POINTER (type, field)
+#define ECMA_SET_INTERNAL_VALUE_ANY_POINTER(field, pointer) \
+ ECMA_SET_POINTER (field, pointer)
-#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
+/**
+ * Convert an internal property value to pointer.
+ */
+#define ECMA_GET_INTERNAL_VALUE_POINTER(type, field) \
+ ECMA_GET_NON_NULL_POINTER (type, field)
/**
- * Free the cesu-8 string buffer allocated by 'ECMA_STRING_TO_UTF8_STRING'
+ * Convert an internal property value to pointer. Result can be NULL.
*/
-#define ECMA_FINALIZE_UTF8_STRING(utf8_ptr, /**< pointer to character buffer */ \
- utf8_str_size) /**< buffer size */ \
- if (utf8_ptr ## must_be_freed) \
- { \
- JERRY_ASSERT (utf8_ptr != NULL); \
- jmem_heap_free_block ((void *) utf8_ptr, utf8_str_size); \
- }
+#define ECMA_GET_INTERNAL_VALUE_ANY_POINTER(type, field) \
+ ECMA_GET_POINTER (type, field)
+
+#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
/**
* Convert boolean to bitfield value.
bool ecma_is_value_float_number (ecma_value_t value) __attr_const___;
bool ecma_is_value_number (ecma_value_t value) __attr_const___;
bool ecma_is_value_string (ecma_value_t value) __attr_const___;
+bool ecma_is_value_direct_string (ecma_value_t value) __attr_const___;
bool ecma_is_value_object (ecma_value_t value) __attr_const___;
bool ecma_is_value_error_reference (ecma_value_t value) __attr_const___;
+bool ecma_is_value_collection_chunk (ecma_value_t value) __attr_const___;
void ecma_check_value_type_is_spec_defined (ecma_value_t value);
ecma_value_t ecma_make_int32_value (int32_t int32_number);
ecma_value_t ecma_make_uint32_value (uint32_t uint32_number);
ecma_value_t ecma_make_string_value (const ecma_string_t *ecma_string_p) __attr_pure___;
+ecma_value_t ecma_make_magic_string_value (lit_magic_string_id_t id) __attr_pure___;
ecma_value_t ecma_make_object_value (const ecma_object_t *object_p) __attr_pure___;
ecma_value_t ecma_make_error_reference_value (const ecma_error_reference_t *error_ref_p) __attr_pure___;
+ecma_value_t ecma_make_collection_chunk_value (const ecma_collection_chunk_t *collection_chunk_p) __attr_pure___;
ecma_integer_value_t ecma_get_integer_from_value (ecma_value_t value) __attr_const___;
ecma_number_t ecma_get_float_from_value (ecma_value_t value) __attr_pure___;
ecma_number_t ecma_get_number_from_value (ecma_value_t value) __attr_pure___;
ecma_string_t *ecma_get_string_from_value (ecma_value_t value) __attr_pure___;
ecma_object_t *ecma_get_object_from_value (ecma_value_t value) __attr_pure___;
ecma_error_reference_t *ecma_get_error_reference_from_value (ecma_value_t value) __attr_pure___;
+ecma_collection_chunk_t *ecma_get_collection_chunk_from_value (ecma_value_t value) __attr_pure___;
ecma_value_t ecma_invert_boolean_value (ecma_value_t value) __attr_const___;
ecma_value_t ecma_copy_value (ecma_value_t value);
ecma_value_t ecma_fast_copy_value (ecma_value_t value);
void ecma_free_value (ecma_value_t value);
void ecma_fast_free_value (ecma_value_t value);
void ecma_free_value_if_not_object (ecma_value_t value);
+lit_magic_string_id_t ecma_get_typeof_lit_id (ecma_value_t value);
/* ecma-helpers-string.c */
ecma_string_t *ecma_new_ecma_string_from_utf8 (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
lit_utf8_size_t string_size);
ecma_string_t *ecma_new_ecma_string_from_code_unit (ecma_char_t code_unit);
ecma_string_t *ecma_new_ecma_string_from_uint32 (uint32_t uint32_number);
+ecma_string_t *ecma_get_ecma_string_from_uint32 (uint32_t uint32_number);
ecma_string_t *ecma_new_ecma_string_from_number (ecma_number_t num);
-ecma_string_t *ecma_new_ecma_string_from_magic_string_id (lit_magic_string_id_t id);
+ecma_string_t *ecma_get_magic_string (lit_magic_string_id_t id);
ecma_string_t *ecma_new_ecma_string_from_magic_string_ex_id (lit_magic_string_ex_id_t id);
-ecma_string_t *ecma_new_ecma_length_string (void);
ecma_string_t *ecma_append_chars_to_string (ecma_string_t *string1_p,
const lit_utf8_byte_t *cesu8_string2_p,
lit_utf8_size_t cesu8_string2_size,
lit_utf8_size_t buffer_size);
void ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byte_t *buffer_p,
lit_utf8_size_t buffer_size);
-const lit_utf8_byte_t *ecma_string_raw_chars (const ecma_string_t *string_p, lit_utf8_size_t *size_p, bool *is_ascii_p);
-void ecma_init_ecma_string_from_uint32 (ecma_string_t *string_desc_p, uint32_t uint32_number);
-void ecma_init_ecma_magic_string (ecma_string_t *string_desc_p, lit_magic_string_id_t id);
+const lit_utf8_byte_t *ecma_string_get_chars (const ecma_string_t *string_p, lit_utf8_size_t *size_p, uint8_t *flags_p);
bool ecma_compare_ecma_string_to_magic_id (const ecma_string_t *string_p, lit_magic_string_id_t id);
bool ecma_string_is_empty (const ecma_string_t *string_p);
bool ecma_string_is_length (const ecma_string_t *string_p);
const ecma_string_t *string_p);
bool ecma_compare_ecma_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
+bool ecma_compare_ecma_non_direct_strings (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
bool ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, const ecma_string_t *string2_p);
ecma_length_t ecma_string_get_length (const ecma_string_t *string_p);
ecma_length_t ecma_string_get_utf8_length (const ecma_string_t *string_p);
lit_utf8_size_t ecma_string_get_utf8_size (const ecma_string_t *string_p);
ecma_char_t ecma_string_get_char_at_pos (const ecma_string_t *string_p, ecma_length_t index);
-ecma_string_t *ecma_get_magic_string (lit_magic_string_id_t id);
-ecma_string_t *ecma_get_magic_string_ex (lit_magic_string_ex_id_t id);
lit_magic_string_id_t ecma_get_string_magic (const ecma_string_t *string_p);
lit_string_hash_t ecma_string_hash (const ecma_string_t *string_p);
int32_t *out_decimal_exp_p);
/* ecma-helpers-values-collection.c */
-ecma_collection_header_t *ecma_new_values_collection (const ecma_value_t values_buffer[], ecma_length_t values_number,
- bool do_ref_if_object);
-void ecma_free_values_collection (ecma_collection_header_t *header_p, bool do_deref_if_object);
-void ecma_append_to_values_collection (ecma_collection_header_t *header_p, ecma_value_t v, bool do_ref_if_object);
-void ecma_remove_last_value_from_values_collection (ecma_collection_header_t *header_p);
-ecma_collection_header_t *ecma_new_strings_collection (ecma_string_t *string_ptrs_buffer[],
- ecma_length_t strings_number);
+ecma_collection_header_t *ecma_new_values_collection (void);
+void ecma_free_values_collection (ecma_collection_header_t *header_p, uint32_t flags);
+void ecma_append_to_values_collection (ecma_collection_header_t *header_p, ecma_value_t v, uint32_t flags);
-/**
- * Context of ecma values' collection iterator
- */
-typedef struct
-{
- ecma_collection_header_t *header_p; /**< collection header */
- jmem_cpointer_t next_chunk_cp; /**< compressed pointer to next chunk */
- ecma_length_t current_index; /**< index of current element */
- const ecma_value_t *current_value_p; /**< pointer to current element */
- const ecma_value_t *current_chunk_beg_p; /**< pointer to beginning of current chunk's data */
- const ecma_value_t *current_chunk_end_p; /**< pointer to place right after the end of current chunk's data */
-} ecma_collection_iterator_t;
-
-void
-ecma_collection_iterator_init (ecma_collection_iterator_t *iterator_p, ecma_collection_header_t *collection_p);
-bool
-ecma_collection_iterator_next (ecma_collection_iterator_t *iterator_p);
+ecma_value_t *
+ecma_collection_iterator_init (ecma_collection_header_t *header_p);
+ecma_value_t *
+ecma_collection_iterator_next (ecma_value_t *iterator_p);
/* ecma-helpers.c */
ecma_object_t *ecma_create_object (ecma_object_t *prototype_object_p, size_t ext_object_size, ecma_object_type_t type);
ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
void ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p);
-ecma_value_t ecma_create_error_reference (ecma_value_t value);
+ecma_value_t ecma_create_error_reference (ecma_value_t value, bool is_exception);
+ecma_value_t ecma_create_error_reference_from_context (void);
ecma_value_t ecma_create_error_object_reference (ecma_object_t *object_p);
void ecma_ref_error_reference (ecma_error_reference_t *error_ref_p);
void ecma_deref_error_reference (ecma_error_reference_t *error_ref_p);
-ecma_value_t ecma_clear_error_reference (ecma_value_t value);
+ecma_value_t ecma_clear_error_reference (ecma_value_t value, bool set_abort_flag);
void ecma_bytecode_ref (ecma_compiled_code_t *bytecode_p);
void ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p);
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
JERRY_CONTEXT (ecma_prop_hashmap_alloc_state) = ECMA_PROP_HASHMAP_ALLOC_ON;
- JERRY_CONTEXT (ecma_prop_hashmap_alloc_last_is_hs_gc) = false;
+ JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_HIGH_SEV_GC;
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
#ifndef CONFIG_DISABLE_ES2015_PROMISE_BUILTIN
#ifndef CONFIG_ECMA_LCACHE_DISABLE
-/**
- * Converts a string into a property name
- *
- * @return the compressed pointer part of the name
- */
-static inline jmem_cpointer_t __attr_always_inline___
-ecma_string_to_lcache_property_name (const ecma_string_t *prop_name_p, /**< property name */
- ecma_property_t *name_type_p) /**< [out] property name type */
-{
- ecma_string_container_t container = ECMA_STRING_GET_CONTAINER (prop_name_p);
-
- switch (container)
- {
- case ECMA_STRING_CONTAINER_UINT32_IN_DESC:
- case ECMA_STRING_CONTAINER_MAGIC_STRING:
- case ECMA_STRING_CONTAINER_MAGIC_STRING_EX:
- {
-#ifdef JERRY_CPOINTER_32_BIT
-
- *name_type_p = (ecma_property_t) container;
- return (jmem_cpointer_t) prop_name_p->u.uint32_number;
-
-#else /* !JERRY_CPOINTER_32_BIT */
-
- if (prop_name_p->u.uint32_number < (UINT16_MAX + 1))
- {
- *name_type_p = (ecma_property_t) container;
- return (jmem_cpointer_t) prop_name_p->u.uint32_number;
- }
-
-#endif /* JERRY_CPOINTER_32_BIT */
-
- break;
- }
- default:
- {
- break;
- }
- }
- *name_type_p = ECMA_PROPERTY_NAME_TYPE_STRING;
-
- jmem_cpointer_t prop_name_cp;
- ECMA_SET_NON_NULL_POINTER (prop_name_cp, prop_name_p);
- return prop_name_cp;
-} /* ecma_string_to_lcache_property_name */
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
jmem_cpointer_t object_cp;
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
- size_t row_index = ecma_lcache_row_index (object_cp, ecma_string_hash (prop_name_p));
+ ecma_property_t prop_name_type;
+ jmem_cpointer_t prop_name_cp;
+ lit_string_hash_t name_hash;
+
+ if (ECMA_IS_DIRECT_STRING (prop_name_p))
+ {
+ prop_name_type = (ecma_property_t) ECMA_GET_DIRECT_STRING_TYPE (prop_name_p);
+
+ uintptr_t value = ECMA_GET_DIRECT_STRING_VALUE (prop_name_p);
+ prop_name_cp = (jmem_cpointer_t) value;
+ name_hash = (lit_string_hash_t) value;
+
+ if (prop_name_type == ECMA_DIRECT_STRING_MAGIC_EX)
+ {
+ name_hash = (lit_string_hash_t) (name_hash + LIT_MAGIC_STRING__COUNT);
+ }
+ }
+ else
+ {
+ prop_name_type = ECMA_DIRECT_STRING_PTR;
+
+ ECMA_SET_NON_NULL_POINTER (prop_name_cp, prop_name_p);
+ name_hash = prop_name_p->hash;
+ }
+
+ size_t row_index = ecma_lcache_row_index (object_cp, name_hash);
+
ecma_lcache_hash_entry_t *entry_p = JERRY_HASH_TABLE_CONTEXT (table) [row_index];
ecma_lcache_hash_entry_t *entry_end_p = entry_p + ECMA_LCACHE_HASH_ROW_LENGTH;
- ecma_property_t prop_name_type;
- jmem_cpointer_t prop_name_cp = ecma_string_to_lcache_property_name (prop_name_p, &prop_name_type);
-
while (entry_p < entry_end_p)
{
if (entry_p->object_cp == object_cp
*
* @return ecma_string_t compressed pointer
*/
-jmem_cpointer_t
+ecma_value_t
ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string to be searched */
lit_utf8_size_t size) /**< size of the string */
{
ecma_string_t *string_p = ecma_new_ecma_string_from_utf8 (chars_p, size);
+ if (ECMA_IS_DIRECT_STRING (string_p))
+ {
+ return ecma_make_string_value (string_p);
+ }
+
ecma_lit_storage_item_t *string_list_p = JERRY_CONTEXT (string_list_first_p);
jmem_cpointer_t *empty_cpointer_p = NULL;
{
/* Return with string if found in the list. */
ecma_deref_ecma_string (string_p);
- return string_list_p->values[i];
+ return ecma_make_string_value (value_p);
}
}
}
if (empty_cpointer_p != NULL)
{
*empty_cpointer_p = result;
- return result;
+ return ecma_make_string_value (string_p);
}
ecma_lit_storage_item_t *new_item_p;
JMEM_CP_SET_POINTER (new_item_p->next_cp, JERRY_CONTEXT (string_list_first_p));
JERRY_CONTEXT (string_list_first_p) = new_item_p;
- return result;
+ return ecma_make_string_value (string_p);
} /* ecma_find_or_create_literal_string */
/**
*
* @return ecma_string_t compressed pointer
*/
-jmem_cpointer_t
+ecma_value_t
ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be searched */
{
ecma_value_t num = ecma_make_number_value (number_arg);
+ if (ecma_is_value_integer_number (num))
+ {
+ return num;
+ }
+
+ JERRY_ASSERT (ecma_is_value_float_number (num));
+
ecma_lit_storage_item_t *number_list_p = JERRY_CONTEXT (number_list_first_p);
jmem_cpointer_t *empty_cpointer_p = NULL;
number_list_p->values[i]);
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (value_p) == ECMA_STRING_LITERAL_NUMBER);
+ JERRY_ASSERT (ecma_is_value_float_number (value_p->u.lit_number));
- if (ecma_is_value_integer_number (num))
- {
- if (value_p->u.lit_number == num)
- {
- return number_list_p->values[i];
- }
- }
- else
+ if (ecma_get_float_from_value (value_p->u.lit_number) == number_arg)
{
- if (ecma_is_value_float_number (value_p->u.lit_number)
- && ecma_get_float_from_value (value_p->u.lit_number) == ecma_get_float_from_value (num))
- {
- ecma_free_value (num);
- return number_list_p->values[i];
- }
+ ecma_free_value (num);
+ return value_p->u.lit_number;
}
}
}
if (empty_cpointer_p != NULL)
{
*empty_cpointer_p = result;
- return result;
+ return num;
}
ecma_lit_storage_item_t *new_item_p;
JMEM_CP_SET_POINTER (new_item_p->next_cp, JERRY_CONTEXT (number_list_first_p));
JERRY_CONTEXT (number_list_first_p) = new_item_p;
- return result;
+ return num;
} /* ecma_find_or_create_literal_number */
/**
* Log2 of snapshot literal alignment.
*/
-#define JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG 2
+#define JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG 1
/**
* Snapshot literal alignment.
*/
#define JERRY_SNAPSHOT_LITERAL_ALIGNMENT (1u << JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG)
+/**
+ * Literal offset shift.
+ */
+#define JERRY_SNAPSHOT_LITERAL_SHIFT (ECMA_VALUE_SHIFT + 1)
+
+/**
+ * Literal value is number.
+ */
+#define JERRY_SNAPSHOT_LITERAL_IS_NUMBER (1u << ECMA_VALUE_SHIFT)
+
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
/**
- * Save literals to specified snapshot buffer.
- *
- * @return true - if save was performed successfully (i.e. buffer size is sufficient),
- * false - otherwise
+ * Append the value at the end of the appropriate list if it is not present there.
*/
-bool
-ecma_save_literals_for_snapshot (uint32_t *buffer_p, /**< [out] output snapshot buffer */
- size_t buffer_size, /**< size of the buffer */
- size_t *in_out_buffer_offset_p, /**< [in,out] write position in the buffer */
- lit_mem_to_snapshot_id_map_entry_t **out_map_p, /**< [out] map from literal identifiers
- * to the literal offsets
- * in snapshot */
- uint32_t *out_map_len_p) /**< [out] number of literals */
+void ecma_save_literals_append_value (ecma_value_t value, /**< value to be appended */
+ ecma_collection_header_t *lit_pool_p) /**< list of known values */
{
- /* Count literals and literal space. */
- uint32_t lit_table_size = sizeof (uint32_t);
- uint32_t total_count = 0;
+ /* Unlike direct numbers, direct strings are converted to character literals. */
+ if (!ecma_is_value_string (value) && !ecma_is_value_float_number (value))
+ {
+ return;
+ }
- ecma_lit_storage_item_t *string_list_p = JERRY_CONTEXT (string_list_first_p);
+ ecma_value_t *iterator_p = ecma_collection_iterator_init (lit_pool_p);
- while (string_list_p != NULL)
+ while (iterator_p != NULL)
{
- for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
+ /* Strings / numbers are direct strings or stored in the literal storage.
+ * Therefore direct comparison is enough to find the same strings / numbers. */
+ if (*iterator_p == value)
{
- if (string_list_p->values[i] != JMEM_CP_NULL)
- {
- ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- string_list_p->values[i]);
-
- lit_table_size += (uint32_t) JERRY_ALIGNUP (sizeof (uint16_t) + ecma_string_get_size (string_p),
- JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
- total_count++;
- }
+ return;
}
- string_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, string_list_p->next_cp);
+ iterator_p = ecma_collection_iterator_next (iterator_p);
}
- uint32_t number_offset = lit_table_size;
+ ecma_append_to_values_collection (lit_pool_p, value, ECMA_COLLECTION_NO_COPY);
+} /* ecma_save_literals_append_value */
- ecma_lit_storage_item_t *number_list_p = JERRY_CONTEXT (number_list_first_p);
+/**
+ * Add names from a byte-code data to a list.
+ */
+void
+ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p, /**< byte-code data */
+ ecma_collection_header_t *lit_pool_p) /**< list of known values */
+{
+ ecma_value_t *literal_p;
+ uint32_t argument_end = 0;
+ uint32_t register_end;
+ uint32_t const_literal_end;
+ uint32_t literal_end;
- while (number_list_p != NULL)
+ JERRY_ASSERT (compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION);
+
+ if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{
- for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
+ cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) compiled_code_p;
+ uint8_t *byte_p = (uint8_t *) compiled_code_p;
+
+ literal_p = (ecma_value_t *) (byte_p + sizeof (cbc_uint16_arguments_t));
+ register_end = args_p->register_end;
+ const_literal_end = args_p->const_literal_end - register_end;
+ literal_end = args_p->literal_end - register_end;
+
+ if (compiled_code_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED)
{
- if (number_list_p->values[i] != JMEM_CP_NULL)
- {
- lit_table_size += (uint32_t) sizeof (ecma_number_t);
- total_count++;
- }
+ argument_end = args_p->argument_end;
}
+ }
+ else
+ {
+ cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) compiled_code_p;
+ uint8_t *byte_p = (uint8_t *) compiled_code_p;
- number_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, number_list_p->next_cp);
+ literal_p = (ecma_value_t *) (byte_p + sizeof (cbc_uint8_arguments_t));
+ register_end = args_p->register_end;
+ const_literal_end = args_p->const_literal_end - register_end;
+ literal_end = args_p->literal_end - register_end;
+
+ if (compiled_code_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED)
+ {
+ argument_end = args_p->argument_end;
+ }
}
- /* Check whether enough space is available. */
- if (*in_out_buffer_offset_p + lit_table_size > buffer_size)
+ for (uint32_t i = 0; i < argument_end; i++)
{
- return false;
+ ecma_save_literals_append_value (literal_p[i], lit_pool_p);
}
- /* Check whether the maximum literal table size is reached. */
- if ((lit_table_size >> JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG) > UINT16_MAX)
+ for (uint32_t i = 0; i < const_literal_end; i++)
{
- return false;
+ ecma_save_literals_append_value (literal_p[i], lit_pool_p);
}
- lit_mem_to_snapshot_id_map_entry_t *map_p;
+ for (uint32_t i = const_literal_end; i < literal_end; i++)
+ {
+ ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
+ literal_p[i]);
- map_p = jmem_heap_alloc_block (total_count * sizeof (lit_mem_to_snapshot_id_map_entry_t));
+ if ((bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION)
+ && bytecode_p != compiled_code_p)
+ {
+ ecma_save_literals_add_compiled_code (bytecode_p, lit_pool_p);
+ }
+ }
- /* Set return values (no error is possible from here). */
- JERRY_ASSERT ((*in_out_buffer_offset_p % sizeof (uint32_t)) == 0);
- buffer_p += *in_out_buffer_offset_p / sizeof (uint32_t);
- *in_out_buffer_offset_p += lit_table_size;
- *out_map_p = map_p;
- *out_map_len_p = total_count;
+ if (argument_end != 0)
+ {
+ uint8_t *byte_p = (uint8_t *) compiled_code_p;
+ byte_p += ((size_t) compiled_code_p->size) << JMEM_ALIGNMENT_LOG;
+ literal_p = ((ecma_value_t *) byte_p) - argument_end;
- /* Write data into the buffer. */
+ for (uint32_t i = 0; i < argument_end; i++)
+ {
+ ecma_save_literals_append_value (literal_p[i], lit_pool_p);
+ }
+ }
+} /* ecma_save_literals_add_compiled_code */
- /* The zero value is reserved for NULL (no literal)
- * constant so the first literal must have offset one. */
- uint32_t literal_offset = JERRY_SNAPSHOT_LITERAL_ALIGNMENT;
+/**
+ * Save literals to specified snapshot buffer.
+ *
+ * Note:
+ * Frees lit_pool_p regardless of success.
+ *
+ * @return true - if save was performed successfully (i.e. buffer size is sufficient),
+ * false - otherwise
+ */
+bool
+ecma_save_literals_for_snapshot (ecma_collection_header_t *lit_pool_p, /**< list of known values */
+ uint32_t *buffer_p, /**< [out] output snapshot buffer */
+ size_t buffer_size, /**< size of the buffer */
+ size_t *in_out_buffer_offset_p, /**< [in,out] write position in the buffer */
+ lit_mem_to_snapshot_id_map_entry_t **out_map_p, /**< [out] map from literal identifiers
+ * to the literal offsets
+ * in snapshot */
+ uint32_t *out_map_len_p) /**< [out] number of literals */
+{
+ if (lit_pool_p->item_count == 0)
+ {
+ *out_map_p = NULL;
+ *out_map_len_p = 0;
+ }
- *buffer_p++ = number_offset;
+ uint32_t lit_table_size = 0;
+ size_t max_lit_table_size = buffer_size - *in_out_buffer_offset_p;
- string_list_p = JERRY_CONTEXT (string_list_first_p);
+ if (max_lit_table_size > (UINT32_MAX >> JERRY_SNAPSHOT_LITERAL_SHIFT))
+ {
+ max_lit_table_size = (UINT32_MAX >> JERRY_SNAPSHOT_LITERAL_SHIFT);
+ }
- uint16_t *destination_p = (uint16_t *) buffer_p;
+ ecma_value_t *iterator_p = ecma_collection_iterator_init (lit_pool_p);
- while (string_list_p != NULL)
+ /* Compute the size of the literal pool. */
+ while (iterator_p != NULL)
{
- for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
+ if (ecma_is_value_float_number (*iterator_p))
{
- if (string_list_p->values[i] != JMEM_CP_NULL)
- {
- map_p->literal_id = string_list_p->values[i];
- map_p->literal_offset = (jmem_cpointer_t) (literal_offset >> JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG);
- map_p++;
+ lit_table_size += (uint32_t) sizeof (ecma_number_t);
+ }
+ else
+ {
+ ecma_string_t *string_p = ecma_get_string_from_value (*iterator_p);
- ecma_string_t *string_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- string_list_p->values[i]);
+ lit_table_size += (uint32_t) JERRY_ALIGNUP (sizeof (uint16_t) + ecma_string_get_size (string_p),
+ JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
+ }
+
+ /* Check whether enough space is available and the maximum size is not reached. */
+ if (lit_table_size > max_lit_table_size)
+ {
+ ecma_free_values_collection (lit_pool_p, ECMA_COLLECTION_NO_COPY);
+ return false;
+ }
- ecma_length_t length = ecma_string_get_size (string_p);
+ iterator_p = ecma_collection_iterator_next (iterator_p);
+ }
- *destination_p = (uint16_t) length;
- ecma_string_to_utf8_bytes (string_p, ((lit_utf8_byte_t *) destination_p) + sizeof (uint16_t), length);
+ lit_mem_to_snapshot_id_map_entry_t *map_p;
+ ecma_length_t total_count = lit_pool_p->item_count;
- length = JERRY_ALIGNUP (sizeof (uint16_t) + length,
- JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
+ map_p = jmem_heap_alloc_block (total_count * sizeof (lit_mem_to_snapshot_id_map_entry_t));
- JERRY_ASSERT ((length % sizeof (uint16_t)) == 0);
- destination_p += length / sizeof (uint16_t);
- literal_offset += length;
- }
- }
+ /* Set return values (no error is possible from here). */
+ JERRY_ASSERT ((*in_out_buffer_offset_p % sizeof (uint32_t)) == 0);
- string_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, string_list_p->next_cp);
- }
+ uint8_t *destination_p = (uint8_t *) (buffer_p + (*in_out_buffer_offset_p / sizeof (uint32_t)));
+ uint32_t literal_offset = 0;
- number_list_p = JERRY_CONTEXT (number_list_first_p);
+ *in_out_buffer_offset_p += lit_table_size;
+ *out_map_p = map_p;
+ *out_map_len_p = total_count;
- while (number_list_p != NULL)
+ iterator_p = ecma_collection_iterator_init (lit_pool_p);
+
+ /* Generate literal pool data. */
+ while (iterator_p != NULL)
{
- for (int i = 0; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
+ map_p->literal_id = *iterator_p;
+ map_p->literal_offset = (literal_offset << JERRY_SNAPSHOT_LITERAL_SHIFT) | ECMA_TYPE_SNAPSHOT_OFFSET;
+
+ ecma_length_t length;
+
+ if (ecma_is_value_float_number (*iterator_p))
{
- if (number_list_p->values[i] != JMEM_CP_NULL)
- {
- map_p->literal_id = number_list_p->values[i];
- map_p->literal_offset = (jmem_cpointer_t) (literal_offset >> JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG);
- map_p++;
+ map_p->literal_offset |= JERRY_SNAPSHOT_LITERAL_IS_NUMBER;
- ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- number_list_p->values[i]);
+ ecma_number_t num = ecma_get_float_from_value (*iterator_p);
+ memcpy (destination_p, &num, sizeof (ecma_number_t));
- JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (value_p) == ECMA_STRING_LITERAL_NUMBER);
+ length = JERRY_ALIGNUP (sizeof (ecma_number_t), JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
+ }
+ else
+ {
+ ecma_string_t *string_p = ecma_get_string_from_value (*iterator_p);
+ length = ecma_string_get_size (string_p);
- ecma_number_t num = ecma_get_number_from_value (value_p->u.lit_number);
- memcpy (destination_p, &num, sizeof (ecma_number_t));
+ *(uint16_t *) destination_p = (uint16_t) length;
- ecma_length_t length = JERRY_ALIGNUP (sizeof (ecma_number_t),
- JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
+ ecma_string_to_utf8_bytes (string_p, destination_p + sizeof (uint16_t), length);
- JERRY_ASSERT ((length % sizeof (uint16_t)) == 0);
- destination_p += length / sizeof (uint16_t);
- literal_offset += length;
- }
+ length = JERRY_ALIGNUP (sizeof (uint16_t) + length, JERRY_SNAPSHOT_LITERAL_ALIGNMENT);
}
- number_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, number_list_p->next_cp);
+ JERRY_ASSERT ((length % sizeof (uint16_t)) == 0);
+ destination_p += length;
+ literal_offset += length;
+
+ iterator_p = ecma_collection_iterator_next (iterator_p);
+ map_p++;
}
+ ecma_free_values_collection (lit_pool_p, ECMA_COLLECTION_NO_COPY);
return true;
} /* ecma_save_literals_for_snapshot */
#if defined JERRY_ENABLE_SNAPSHOT_EXEC || defined JERRY_ENABLE_SNAPSHOT_SAVE
/**
- * Computes the base pointer of the literals and starting offset of numbers.
- *
- * @return the base pointer of the literals
- */
-const uint8_t *
-ecma_snapshot_get_literals_base (uint32_t *buffer_p, /**< literal buffer start */
- const uint8_t **number_base_p) /**< [out] literal number start */
-{
- *number_base_p = ((uint8_t *) buffer_p) + buffer_p[0];
-
- return ((uint8_t *) (buffer_p + 1)) - JERRY_SNAPSHOT_LITERAL_ALIGNMENT;
-} /* ecma_snapshot_get_literals_base */
-
-/**
* Get the compressed pointer of a given literal.
*
* @return literal compressed pointer
*/
-jmem_cpointer_t
+ecma_value_t
ecma_snapshot_get_literal (const uint8_t *literal_base_p, /**< literal start */
- const uint8_t *number_base_p, /**< literal number start */
- jmem_cpointer_t offset)
+ ecma_value_t literal_value) /**< string / number offset */
{
- if (offset == 0)
- {
- return ECMA_NULL_POINTER;
- }
+ JERRY_ASSERT ((literal_value & ECMA_VALUE_TYPE_MASK) == ECMA_TYPE_SNAPSHOT_OFFSET);
- const uint8_t *literal_p = literal_base_p + (((size_t) offset) << JERRY_SNAPSHOT_LITERAL_ALIGNMENT_LOG);
+ const uint8_t *literal_p = literal_base_p + (literal_value >> JERRY_SNAPSHOT_LITERAL_SHIFT);
- if (literal_p >= number_base_p)
+ if (literal_value & JERRY_SNAPSHOT_LITERAL_IS_NUMBER)
{
ecma_number_t num;
memcpy (&num, literal_p, sizeof (ecma_number_t));
* @{
*/
+#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
/**
* Snapshot literal - offset map
*/
typedef struct
{
- jmem_cpointer_t literal_id; /**< literal id */
- jmem_cpointer_t literal_offset; /**< literal offset */
+ ecma_value_t literal_id; /**< literal id */
+ ecma_value_t literal_offset; /**< literal offset */
} lit_mem_to_snapshot_id_map_entry_t;
+#endif /* JERRY_ENABLE_SNAPSHOT_SAVE */
void ecma_finalize_lit_storage (void);
-jmem_cpointer_t ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, lit_utf8_size_t size);
-jmem_cpointer_t ecma_find_or_create_literal_number (ecma_number_t number_arg);
+ecma_value_t ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, lit_utf8_size_t size);
+ecma_value_t ecma_find_or_create_literal_number (ecma_number_t number_arg);
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
-bool
-ecma_save_literals_for_snapshot (uint32_t *buffer_p, size_t buffer_size, size_t *in_out_buffer_offset_p,
- lit_mem_to_snapshot_id_map_entry_t **out_map_p, uint32_t *out_map_len_p);
+void ecma_save_literals_append_value (ecma_value_t value, ecma_collection_header_t *lit_pool_p);
+void ecma_save_literals_add_compiled_code (const ecma_compiled_code_t *compiled_code_p,
+ ecma_collection_header_t *lit_pool_p);
+bool ecma_save_literals_for_snapshot (ecma_collection_header_t *lit_pool_p, uint32_t *buffer_p, size_t buffer_size,
+ size_t *in_out_buffer_offset_p, lit_mem_to_snapshot_id_map_entry_t **out_map_p,
+ uint32_t *out_map_len_p);
#endif /* JERRY_ENABLE_SNAPSHOT_SAVE */
#if defined JERRY_ENABLE_SNAPSHOT_EXEC || defined JERRY_ENABLE_SNAPSHOT_SAVE
-const uint8_t *
-ecma_snapshot_get_literals_base (uint32_t *buffer_p, const uint8_t **number_base_p);
-jmem_cpointer_t
-ecma_snapshot_get_literal (const uint8_t *literal_base_p, const uint8_t *number_base_p,
- jmem_cpointer_t offset);
+ecma_value_t
+ecma_snapshot_get_literal (const uint8_t *literal_base_p, ecma_value_t literal_value);
#endif /* JERRY_ENABLE_SNAPSHOT_EXEC || JERRY_ENABLE_SNAPSHOT_SAVE */
/**
memset (hashmap_p, 0, total_size);
hashmap_p->header.types[0] = ECMA_PROPERTY_TYPE_HASHMAP;
- hashmap_p->header.types[1] = ECMA_PROPERTY_TYPE_DELETED;
+ hashmap_p->header.types[1] = 0;
hashmap_p->header.next_property_cp = object_p->property_list_or_bound_object_cp;
hashmap_p->max_property_count = max_property_count;
hashmap_p->null_count = max_property_count - named_property_count;
uint8_t shift_counter = 0;
- if (max_property_count <= LIT_STRING_HASH_LIMIT)
+ while (max_property_count > LIT_STRING_HASH_LIMIT)
{
- hashmap_p->header.types[1] = 0;
- }
- else
- {
- while (max_property_count > LIT_STRING_HASH_LIMIT)
- {
- shift_counter++;
- max_property_count >>= 1;
- }
+ shift_counter++;
+ max_property_count >>= 1;
}
hashmap_p->header.types[1] = shift_counter;
JERRY_ASSERT (property_index < ECMA_PROPERTY_PAIR_ITEM_COUNT);
- uint32_t entry_index = name_p->hash;
+ uint32_t entry_index = ecma_string_hash (name_p);
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
uint32_t mask = hashmap_p->max_property_count - 1;
}
#endif /* !JERRY_NDEBUG */
- uint32_t entry_index = name_p->hash;
+ uint32_t entry_index = ecma_string_hash (name_p);
uint32_t step = ecma_property_hashmap_steps[entry_index & (ECMA_PROPERTY_HASHMAP_NUMBER_OF_STEPS - 1)];
uint32_t mask = hashmap_p->max_property_count - 1;
jmem_cpointer_t *pair_list_p = (jmem_cpointer_t *) (hashmap_p + 1);
uint32_t start_entry_index = entry_index;
#endif /* !JERRY_NDEBUG */
+ if (ECMA_IS_DIRECT_STRING (name_p))
+ {
+ ecma_property_t prop_name_type = (ecma_property_t) ECMA_GET_DIRECT_STRING_TYPE (name_p);
+ jmem_cpointer_t property_name_cp = (jmem_cpointer_t) ECMA_GET_DIRECT_STRING_VALUE (name_p);
+
+ JERRY_ASSERT (prop_name_type > 0);
+
+ while (true)
+ {
+ if (pair_list_p[entry_index] != ECMA_NULL_POINTER)
+ {
+ size_t offset = 0;
+ if (ECMA_PROPERTY_HASHMAP_GET_BIT (bits_p, entry_index))
+ {
+ offset = 1;
+ }
+
+ ecma_property_pair_t *property_pair_p = ECMA_GET_NON_NULL_POINTER (ecma_property_pair_t,
+ pair_list_p[entry_index]);
+
+ ecma_property_t *property_p = property_pair_p->header.types + offset;
+
+ JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*property_p));
+
+ if (property_pair_p->names_cp[offset] == property_name_cp
+ && ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == prop_name_type)
+ {
+#ifndef JERRY_NDEBUG
+ JERRY_ASSERT (property_found);
+#endif /* !JERRY_NDEBUG */
+
+ *property_real_name_cp = property_name_cp;
+ return property_p;
+ }
+ }
+ else
+ {
+ if (!ECMA_PROPERTY_HASHMAP_GET_BIT (bits_p, entry_index))
+ {
+#ifndef JERRY_NDEBUG
+ JERRY_ASSERT (!property_found);
+#endif /* !JERRY_NDEBUG */
+
+ return NULL;
+ }
+ /* Otherwise it is a deleted entry. */
+ }
+
+ entry_index = (entry_index + step) & mask;
+
+#ifndef JERRY_NDEBUG
+ JERRY_ASSERT (entry_index != start_entry_index);
+#endif /* !JERRY_NDEBUG */
+ }
+
+ JERRY_UNREACHABLE ();
+ }
+
while (true)
{
if (pair_list_p[entry_index] != ECMA_NULL_POINTER)
JERRY_ASSERT (ECMA_PROPERTY_IS_NAMED_PROPERTY (*property_p));
- if (ecma_string_compare_to_property_name (*property_p,
- property_pair_p->names_cp[offset],
- name_p))
+ if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_PTR)
{
+ ecma_string_t *prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, property_pair_p->names_cp[offset]);
+
+ if (ecma_compare_ecma_non_direct_strings (prop_name_p, name_p))
+ {
#ifndef JERRY_NDEBUG
- JERRY_ASSERT (property_found);
+ JERRY_ASSERT (property_found);
#endif /* !JERRY_NDEBUG */
- *property_real_name_cp = property_pair_p->names_cp[offset];
- return property_p;
+
+ *property_real_name_cp = property_pair_p->names_cp[offset];
+ return property_p;
+ }
}
}
else
#ifndef JERRY_NDEBUG
JERRY_ASSERT (!property_found);
#endif /* !JERRY_NDEBUG */
+
return NULL;
}
/* Otherwise it is a deleted entry. */
ecma_number_t length) /**< new length */
{
ecma_value_t ret_value;
- ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
ecma_value_t length_value = ecma_make_number_value (length);
ret_value = ecma_op_object_put (object,
- magic_string_length_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
length_value,
true),
ecma_free_value (length_value);
- ecma_deref_ecma_string (magic_string_length_p);
-
return ret_value;
} /* ecma_builtin_array_prototype_helper_set_length */
/* 5. */
if (length == 0)
{
- ecma_string_t *empty_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
- ret_value = ecma_make_string_value (empty_string_p);
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
else
{
{
if (ecma_is_value_undefined (separator))
{
- ecma_string_t *comma_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_COMMA_CHAR);
- return ecma_make_string_value (comma_string_p);
- }
- else
- {
- return ecma_op_to_string (separator);
+ return ecma_make_magic_string_value (LIT_MAGIC_STRING_COMMA_CHAR);
}
+
+ return ecma_op_to_string (separator);
} /* ecma_op_array_get_separator_string */
/**
if (ecma_is_value_undefined (index_value)
|| ecma_is_value_null (index_value))
{
- ecma_string_t *empty_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
- ret_value = ecma_make_string_value (empty_string_p);
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
else
{
if (length == 0)
{
/* 6. */
- ecma_string_t *empty_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
- ret_value = ecma_make_string_value (empty_string_p);
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
else
{
}
else
{
- ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (0);
-
/* 5. */
- ECMA_TRY_CATCH (first_value, ecma_op_object_get (obj_p, index_str_p), ret_value);
+ ECMA_TRY_CATCH (first_value,
+ ecma_op_object_get (obj_p, ecma_get_ecma_string_from_uint32 (0)),
+ ret_value);
/* 6. and 7. */
for (uint32_t k = 1; k < len && ecma_is_value_empty (ret_value); k++)
}
ECMA_FINALIZE (first_value);
- ecma_deref_ecma_string (index_str_p);
}
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
uint32_t defined_prop_count = 0;
uint32_t copied_num = 0;
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, array_index_props_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (array_index_props_p);
/* Count properties with name that is array index less than len */
- while (ecma_collection_iterator_next (&iter)
- && ecma_is_value_empty (ret_value))
+ while (ecma_value_p != NULL && ecma_is_value_empty (ret_value))
{
- ecma_string_t *property_name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *property_name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
uint32_t index = ecma_string_get_array_index (property_name_p);
JERRY_ASSERT (index != ECMA_STRING_NOT_ARRAY_INDEX);
JMEM_DEFINE_LOCAL_ARRAY (values_buffer, defined_prop_count, ecma_value_t);
- ecma_collection_iterator_init (&iter, array_index_props_p);
+ ecma_value_p = ecma_collection_iterator_init (array_index_props_p);
/* Copy unsorted array into a native c array. */
- while (ecma_collection_iterator_next (&iter)
- && ecma_is_value_empty (ret_value))
+ while (ecma_value_p != NULL && ecma_is_value_empty (ret_value))
{
- ecma_string_t *property_name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *property_name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
uint32_t index = ecma_string_get_array_index (property_name_p);
JERRY_ASSERT (index != ECMA_STRING_NOT_ARRAY_INDEX);
/* Undefined properties should be in the back of the array. */
- ecma_collection_iterator_init (&iter, array_index_props_p);
+ ecma_value_p = ecma_collection_iterator_init (array_index_props_p);
- while (ecma_collection_iterator_next (&iter)
- && ecma_is_value_empty (ret_value))
+ while (ecma_value_p != NULL && ecma_is_value_empty (ret_value))
{
- ecma_string_t *property_name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *property_name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
uint32_t index = ecma_string_get_array_index (property_name_p);
JERRY_ASSERT (index != ECMA_STRING_NOT_ARRAY_INDEX);
}
}
- ecma_free_values_collection (array_index_props_p, true);
+ ecma_free_values_collection (array_index_props_p, 0);
if (ecma_is_value_empty (ret_value))
{
} /* ecma_builtin_array_prototype_object_last_index_of */
/**
- * The Array.prototype object's 'every' routine
- *
- * See also:
- * ECMA-262 v5, 15.4.4.16
+ * Type of array routine.
+ */
+typedef enum
+{
+ ARRAY_ROUTINE_EVERY, /**< Array.every: ECMA-262 v5, 15.4.4.16 */
+ ARRAY_ROUTINE_SOME, /**< Array.some: ECMA-262 v5, 15.4.4.17 */
+ ARRAY_ROUTINE_FOREACH, /**< Array.forEach: ECMA-262 v5, 15.4.4.18 */
+ ARRAY_ROUTINE__COUNT /**< count of the modes */
+} array_routine_mode;
+
+/**
+ * Applies the provided function to each element of the array as long as
+ * the return value stays empty. The common function for 'every', 'some'
+ * and 'forEach' of the Array prototype.
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
-ecma_builtin_array_prototype_object_every (ecma_value_t this_arg, /**< this argument */
- ecma_value_t arg1, /**< callbackfn */
- ecma_value_t arg2) /**< thisArg */
+ecma_builtin_array_apply (ecma_value_t this_arg, /**< this argument */
+ ecma_value_t arg1, /**< callbackfn */
+ ecma_value_t arg2, /**< thisArg */
+ array_routine_mode mode) /**< array routine mode */
+
{
+ JERRY_ASSERT (mode < ARRAY_ROUTINE__COUNT);
+
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
/* 1. */
ECMA_TRY_CATCH (call_value, ecma_op_function_call (func_object_p, arg2, call_args, 3), ret_value);
/* 7.c.iii */
- if (!ecma_op_to_boolean (call_value))
+ if (mode == ARRAY_ROUTINE_EVERY && !ecma_op_to_boolean (call_value))
{
ret_value = ECMA_VALUE_FALSE;
}
+ else if (mode == ARRAY_ROUTINE_SOME && ecma_op_to_boolean (call_value))
+ {
+ ret_value = ECMA_VALUE_TRUE;
+ }
ECMA_FINALIZE (call_value);
}
ecma_free_value (to_object_comp);
+ /* 8. */
if (ecma_is_value_empty (ret_value))
{
- /* 8. */
- ret_value = ECMA_VALUE_TRUE;
+ if (mode == ARRAY_ROUTINE_EVERY)
+ {
+ ret_value = ECMA_VALUE_TRUE;
+ }
+ else if (mode == ARRAY_ROUTINE_SOME)
+ {
+ ret_value = ECMA_VALUE_FALSE;
+ }
+ else
+ {
+ ret_value = ECMA_VALUE_UNDEFINED;
+ }
}
}
ECMA_FINALIZE (obj_this);
return ret_value;
+} /* ecma_builtin_array_apply */
+
+/**
+ * The Array.prototype object's 'every' routine
+ *
+ * See also:
+ * ECMA-262 v5, 15.4.4.16
+ *
+ * @return ecma value
+ * Returned value must be freed with ecma_free_value.
+ */
+static ecma_value_t
+ecma_builtin_array_prototype_object_every (ecma_value_t this_arg, /**< this argument */
+ ecma_value_t arg1, /**< callbackfn */
+ ecma_value_t arg2) /**< thisArg */
+{
+ return ecma_builtin_array_apply (this_arg, arg1, arg2, ARRAY_ROUTINE_EVERY);
} /* ecma_builtin_array_prototype_object_every */
/**
ecma_value_t arg1, /**< callbackfn */
ecma_value_t arg2) /**< thisArg */
{
- ecma_value_t ret_value = ECMA_VALUE_EMPTY;
-
- /* 1. */
- ECMA_TRY_CATCH (obj_this,
- ecma_op_to_object (this_arg),
- ret_value);
-
- ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
-
- /* 2. */
- ECMA_TRY_CATCH (len_value,
- ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
- ret_value);
-
- ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
-
- /* 3. */
- uint32_t len = ecma_number_to_uint32 (len_number);
-
- /* 4. */
- if (!ecma_op_is_callable (arg1))
- {
- ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Callback function is not callable."));
- }
- else
- {
- ecma_value_t current_index;
- ecma_object_t *func_object_p;
-
- /* We already checked that arg1 is callable, so it will always coerce to an object. */
- ecma_value_t to_object_comp = ecma_op_to_object (arg1);
- JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (to_object_comp));
-
- func_object_p = ecma_get_object_from_value (to_object_comp);
-
- /* 7. */
- for (uint32_t index = 0; index < len && ecma_is_value_empty (ret_value); index++)
- {
- /* 7.a */
- ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (index);
-
- /* 7.c */
- ECMA_TRY_CATCH (get_value, ecma_op_object_find (obj_p, index_str_p), ret_value);
-
- if (ecma_is_value_found (get_value))
- {
- /* 7.c.i */
- current_index = ecma_make_uint32_value (index);
-
- ecma_value_t call_args[] = { get_value, current_index, obj_this };
-
- /* 7.c.ii */
- ECMA_TRY_CATCH (call_value, ecma_op_function_call (func_object_p, arg2, call_args, 3), ret_value);
-
- /* 7.c.iii */
- if (ecma_op_to_boolean (call_value))
- {
- ret_value = ECMA_VALUE_TRUE;
- }
-
- ECMA_FINALIZE (call_value);
- }
-
- ECMA_FINALIZE (get_value);
-
- ecma_deref_ecma_string (index_str_p);
- }
-
- ecma_free_value (to_object_comp);
-
- if (ecma_is_value_empty (ret_value))
- {
- /* 8. */
- ret_value = ECMA_VALUE_FALSE;
- }
- }
-
- ECMA_OP_TO_NUMBER_FINALIZE (len_number);
- ECMA_FINALIZE (len_value);
- ECMA_FINALIZE (obj_this);
-
- return ret_value;
+ return ecma_builtin_array_apply (this_arg, arg1, arg2, ARRAY_ROUTINE_SOME);
} /* ecma_builtin_array_prototype_object_some */
/**
ecma_value_t arg1, /**< callbackfn */
ecma_value_t arg2) /**< thisArg */
{
- ecma_value_t ret_value = ECMA_VALUE_EMPTY;
- /* 1. */
- ECMA_TRY_CATCH (obj_this,
- ecma_op_to_object (this_arg),
- ret_value);
-
- ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
-
- /* 2. */
- ECMA_TRY_CATCH (len_value,
- ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
- ret_value);
-
- ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
-
- /* 3. */
- uint32_t len = ecma_number_to_uint32 (len_number);
-
- /* 4. */
- if (!ecma_op_is_callable (arg1))
- {
- ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Callback function is not callable."));
- }
- else
- {
- ecma_value_t current_index;
- ecma_object_t *func_object_p;
-
- /* We already checked that arg1 is callable, so it will always coerce to an object. */
- ecma_value_t to_object_comp = ecma_op_to_object (arg1);
- JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (to_object_comp));
-
- func_object_p = ecma_get_object_from_value (to_object_comp);
-
- /* Iterate over array and call callbackfn on every element */
- for (uint32_t index = 0; index < len && ecma_is_value_empty (ret_value); index++)
- {
- /* 7.a */
- ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (index);
-
- /* 7.b */
- ECMA_TRY_CATCH (current_value, ecma_op_object_find (obj_p, index_str_p), ret_value);
-
- if (ecma_is_value_found (current_value))
- {
- /* 7.c.i */
- current_index = ecma_make_uint32_value (index);
-
- /* 7.c.ii */
- ecma_value_t call_args[] = {current_value, current_index, obj_this};
- ECMA_TRY_CATCH (call_value, ecma_op_function_call (func_object_p, arg2, call_args, 3), ret_value);
-
- ECMA_FINALIZE (call_value);
- }
-
- ECMA_FINALIZE (current_value);
-
- ecma_deref_ecma_string (index_str_p);
- }
-
- if (ecma_is_value_empty (ret_value))
- {
- /* 8. */
- ret_value = ECMA_VALUE_UNDEFINED;
- }
-
- ecma_free_value (to_object_comp);
- }
-
- ECMA_OP_TO_NUMBER_FINALIZE (len_number);
- ECMA_FINALIZE (len_value);
- ECMA_FINALIZE (obj_this);
-
- return ret_value;
+ return ecma_builtin_array_apply (this_arg, arg1, arg2, ARRAY_ROUTINE_FOREACH);
} /* ecma_builtin_array_prototype_object_for_each */
/**
} /* ecma_builtin_array_prototype_object_filter */
/**
- * The Array.prototype object's 'reduce' routine
+ * Reduces the Array starting from left or right
*
* See also:
- * ECMA-262 v5, 15.4.4.21
+ * Array.prototype.reduce
+ * Array.prototype.reduceRight
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
-ecma_builtin_array_prototype_object_reduce (ecma_value_t this_arg, /**< this argument */
- const ecma_value_t args[], /**< arguments list */
- ecma_length_t args_number) /**< number of arguments */
+ecma_builtin_array_reduce_from (ecma_value_t this_arg, /**< this argument */
+ const ecma_value_t args[], /**< arguments list */
+ ecma_length_t args_number, /**< number of arguments */
+ bool start_from_left) /**< whether the reduce starts from left or right */
{
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
ecma_value_t callbackfn = (args_number > 0) ? args[0] : ECMA_VALUE_UNDEFINED;
JERRY_ASSERT (ecma_is_value_object (callbackfn));
func_object_p = ecma_get_object_from_value (callbackfn);
- ecma_value_t accumulator = ECMA_VALUE_UNDEFINED;
/* 5. */
if (len_number == ECMA_NUMBER_ZERO && ecma_is_value_undefined (initial_value))
}
else
{
+ ecma_value_t accumulator = ECMA_VALUE_UNDEFINED;
+
/* 6. */
uint32_t index = 0;
+ const uint32_t last_index = len - 1;
/* 7.a */
if (args_number > 1)
while (!k_present && index < len && ecma_is_value_empty (ret_value))
{
/* 8.b.i */
- ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (index);
+ ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (start_from_left ? index
+ : last_index - index);
k_present = true;
/* 8.b.ii-iii */
for (; index < len && ecma_is_value_empty (ret_value); index++)
{
+ const uint32_t corrected_index = start_from_left ? index : last_index - index;
+
/* 9.a */
- ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (index);
+ ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (corrected_index);
/* 9.b */
ECMA_TRY_CATCH (current_value, ecma_op_object_find (obj_p, index_str_p), ret_value);
if (ecma_is_value_found (current_value))
{
/* 9.c.i, 9.c.ii */
- current_index = ecma_make_uint32_value (index);
+ current_index = ecma_make_uint32_value (corrected_index);
ecma_value_t call_args[] = {accumulator, current_value, current_index, obj_this};
ECMA_TRY_CATCH (call_value,
ECMA_FINALIZE (current_value);
ecma_deref_ecma_string (index_str_p);
+
/* 9.d in for loop */
}
{
ret_value = ecma_copy_value (accumulator);
}
- }
- ecma_free_value (accumulator);
+ ecma_free_value (accumulator);
+ }
}
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (obj_this);
return ret_value;
+} /* ecma_builtin_array_reduce_from */
+
+/**
+ * The Array.prototype object's 'reduce' routine
+ *
+ * See also:
+ * ECMA-262 v5, 15.4.4.21
+ *
+ * @return ecma value
+ * Returned value must be freed with ecma_free_value.
+ */
+static ecma_value_t
+ecma_builtin_array_prototype_object_reduce (ecma_value_t this_arg, /**< this argument */
+ const ecma_value_t args[], /**< arguments list */
+ ecma_length_t args_number) /**< number of arguments */
+{
+ return ecma_builtin_array_reduce_from (this_arg, args, args_number, true);
} /* ecma_builtin_array_prototype_object_reduce */
/**
const ecma_value_t args[], /**< arguments list */
ecma_length_t args_number) /**< number of arguments */
{
- ecma_value_t ret_value = ECMA_VALUE_EMPTY;
- ecma_value_t callbackfn = (args_number > 0) ? args[0] : ECMA_VALUE_UNDEFINED;
- ecma_value_t initial_value = (args_number > 1) ? args[1] : ECMA_VALUE_UNDEFINED;
-
- /* 1. */
- ECMA_TRY_CATCH (obj_this,
- ecma_op_to_object (this_arg),
- ret_value);
-
- ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
-
- /* 2. */
- ECMA_TRY_CATCH (len_value,
- ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
- ret_value);
-
- ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
-
- /* 3. */
- uint32_t len = ecma_number_to_uint32 (len_number);
-
- /* 4. */
- if (!ecma_op_is_callable (callbackfn))
- {
- ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Callback function is not callable."));
- }
- else
- {
- ecma_object_t *func_object_p;
-
- JERRY_ASSERT (ecma_is_value_object (callbackfn));
- func_object_p = ecma_get_object_from_value (callbackfn);
-
- /* 5. */
- if (len_number == ECMA_NUMBER_ZERO && ecma_is_value_undefined (initial_value))
- {
- ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Initial value cannot be undefined."));
- }
- else
- {
- ecma_value_t accumulator = ECMA_VALUE_UNDEFINED;
-
- /* 6. */
- int64_t index = (int64_t) len - 1;
-
- /* 7.a */
- if (args_number > 1)
- {
- accumulator = ecma_copy_value (initial_value);
- }
- else
- {
- /* 8.a */
- bool k_present = false;
-
- /* 8.b */
- while (!k_present && index >= 0 && ecma_is_value_empty (ret_value))
- {
- /* 8.b.i */
- ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 ((uint32_t) index);
- k_present = true;
-
- /* 8.b.ii-iii */
- ECMA_TRY_CATCH (current_value, ecma_op_object_find (obj_p, index_str_p), ret_value);
-
- if (ecma_is_value_found (current_value))
- {
- accumulator = ecma_copy_value (current_value);
- }
- else
- {
- k_present = false;
- }
-
- ECMA_FINALIZE (current_value);
-
- /* 8.b.iv */
- index--;
-
- ecma_deref_ecma_string (index_str_p);
- }
-
- /* 8.c */
- if (!k_present)
- {
- ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Missing array element."));
- }
- }
- /* 9. */
- ecma_value_t current_index;
-
- for (; index >= 0 && ecma_is_value_empty (ret_value); index--)
- {
- /* 9.a */
- ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 ((uint32_t) index);
-
- /* 9.b */
- ECMA_TRY_CATCH (current_value, ecma_op_object_find (obj_p, index_str_p), ret_value);
-
- if (ecma_is_value_found (current_value))
- {
- /* 9.c.i, 9.c.ii */
- current_index = ecma_make_uint32_value ((uint32_t) index);
- ecma_value_t call_args[] = {accumulator, current_value, current_index, obj_this};
-
- ECMA_TRY_CATCH (call_value,
- ecma_op_function_call (func_object_p,
- ECMA_VALUE_UNDEFINED,
- call_args,
- 4),
- ret_value);
-
- ecma_free_value (accumulator);
- accumulator = ecma_copy_value (call_value);
-
- ECMA_FINALIZE (call_value);
- }
-
- ECMA_FINALIZE (current_value);
-
- ecma_deref_ecma_string (index_str_p);
- /* 9.d in for loop */
- }
-
- if (ecma_is_value_empty (ret_value))
- {
- ret_value = ecma_copy_value (accumulator);
- }
-
- ecma_free_value (accumulator);
- }
- }
-
- ECMA_OP_TO_NUMBER_FINALIZE (len_number);
- ECMA_FINALIZE (len_value);
- ECMA_FINALIZE (obj_this);
-
- return ret_value;
+ return ecma_builtin_array_reduce_from (this_arg, args, args_number, false);
} /* ecma_builtin_array_prototype_object_reduce_right */
/**
ECMA_OP_TO_NUMBER_FINALIZE (start_num);
+ if (ret_value != ECMA_VALUE_EMPTY)
+ {
+ return ret_value;
+ }
+
JERRY_ASSERT (start <= len && end <= len);
ecma_length_t new_len = (end >= start) ? (end - start) : 0;
ecma_object_t *new_arraybuffer_p = ecma_arraybuffer_new_object (new_len);
ecma_builtin_boolean_prototype_object_value_of (this_arg),
ret_value);
- ecma_string_t *ret_str_p;
-
if (ecma_is_value_true (value_of_ret))
{
- ret_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_TRUE);
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_TRUE);
}
else
{
JERRY_ASSERT (ecma_is_value_boolean (value_of_ret));
- ret_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_FALSE);
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_FALSE);
}
- ret_value = ecma_make_string_value (ret_str_p);
-
ECMA_FINALIZE (value_of_ret);
return ret_value;
{
if (ecma_number_is_nan (date_num))
{
- ecma_string_t *nan_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NAN);
- return ecma_make_string_value (nan_str_p);
+ return ecma_make_magic_string_value (LIT_MAGIC_STRING_NAN);
}
switch (builtin_routine_id)
if (ecma_number_is_nan (*prim_value_p))
{
- ecma_string_t *magic_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INVALID_DATE_UL);
- return ecma_make_string_value (magic_str_p);
+ return ecma_make_magic_string_value (LIT_MAGIC_STRING_INVALID_DATE_UL);
}
switch (builtin_routine_id)
#include "ecma-helpers.h"
#include "ecma-try-catch-macro.h"
#include "lit-char-helpers.h"
+#include "math.h"
#ifndef CONFIG_DISABLE_DATE_BUILTIN
ecma_builtin_date_now (ecma_value_t this_arg) /**< this argument */
{
JERRY_UNUSED (this_arg);
- return ecma_make_number_value (DOUBLE_TO_ECMA_NUMBER_T (jerry_port_get_current_time ()));
+ return ecma_make_number_value (floor (DOUBLE_TO_ECMA_NUMBER_T (jerry_port_get_current_time ())));
} /* ecma_builtin_date_now */
/**
if (ecma_is_value_undefined (name_get_ret_value))
{
- ecma_string_t *error_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_ERROR_UL);
-
- name_to_str_completion = ecma_make_string_value (error_magic_string_p);
+ name_to_str_completion = ecma_make_magic_string_value (LIT_MAGIC_STRING_ERROR_UL);
}
else
{
if (ecma_is_value_undefined (msg_get_ret_value))
{
- ecma_string_t *empty_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
-
- msg_to_str_completion = ecma_make_string_value (empty_magic_string_p);
+ msg_to_str_completion = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
else
{
*/
/**
+ * Maximum number of arguments for an apply function.
+ */
+#define ECMA_FUNCTION_APPLY_ARGUMENT_COUNT_LIMIT 65535
+
+/**
* The Function.prototype object's 'toString' routine
*
* See also:
}
else
{
- ecma_string_t *function_to_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__FUNCTION_TO_STRING);
- ret_value = ecma_make_string_value (function_to_string_p);
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__FUNCTION_TO_STRING);
}
return ret_value;
} /* ecma_builtin_function_prototype_object_to_string */
ecma_object_t *obj_p = ecma_get_object_from_value (arg2);
/* 4. */
- ECMA_TRY_CATCH (length_value,
- ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
- ret_value);
-
- ECMA_OP_TO_NUMBER_TRY_CATCH (length_number,
- length_value,
- ret_value);
-
- /* 5. */
- const uint32_t length = ecma_number_to_uint32 (length_number);
-
- /* 6. */
- JMEM_DEFINE_LOCAL_ARRAY (arguments_list_p, length, ecma_value_t);
- uint32_t last_index = 0;
-
- /* 7. */
- for (uint32_t index = 0;
- index < length && ecma_is_value_empty (ret_value);
- index++)
+ ecma_value_t length_value = ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH);
+ if (ECMA_IS_VALUE_ERROR (length_value))
{
- ecma_string_t *curr_idx_str_p = ecma_new_ecma_string_from_uint32 (index);
+ return length_value;
+ }
- ECMA_TRY_CATCH (get_value,
- ecma_op_object_get (obj_p, curr_idx_str_p),
- ret_value);
+ ecma_number_t length_number;
+ ecma_value_t get_result = ecma_get_number (length_value, &length_number);
- arguments_list_p[index] = ecma_copy_value (get_value);
- last_index = index + 1;
+ ecma_free_value (length_value);
- ECMA_FINALIZE (get_value);
- ecma_deref_ecma_string (curr_idx_str_p);
+ if (ECMA_IS_VALUE_ERROR (get_result))
+ {
+ return get_result;
}
+ JERRY_ASSERT (ecma_is_value_empty (get_result));
+
+ /* 5. */
+ const uint32_t length = ecma_number_to_uint32 (length_number);
- if (ecma_is_value_empty (ret_value))
+ if (length >= ECMA_FUNCTION_APPLY_ARGUMENT_COUNT_LIMIT)
{
- JERRY_ASSERT (last_index == length);
- ret_value = ecma_op_function_call (func_obj_p,
- arg1,
- arguments_list_p,
- length);
+ ret_value = ecma_raise_range_error (ECMA_ERR_MSG ("Too many arguments declared for Function.apply()."));
}
-
- for (uint32_t index = 0; index < last_index; index++)
+ else
{
- ecma_free_value (arguments_list_p[index]);
+ /* 6. */
+ JMEM_DEFINE_LOCAL_ARRAY (arguments_list_p, length, ecma_value_t);
+ uint32_t index = 0;
+
+ /* 7. */
+ for (index = 0; index < length; index++)
+ {
+ ecma_string_t *curr_idx_str_p = ecma_new_ecma_string_from_uint32 (index);
+ ecma_value_t get_value = ecma_op_object_get (obj_p, curr_idx_str_p);
+ ecma_deref_ecma_string (curr_idx_str_p);
+
+ if (ECMA_IS_VALUE_ERROR (get_value))
+ {
+ ret_value = get_value;
+ break;
+ }
+
+ arguments_list_p[index] = get_value;
+ }
+
+ if (ecma_is_value_empty (ret_value))
+ {
+ JERRY_ASSERT (index == length);
+ ret_value = ecma_op_function_call (func_obj_p,
+ arg1,
+ arguments_list_p,
+ length);
+ }
+
+ for (uint32_t remove_index = 0; remove_index < index; remove_index++)
+ {
+ ecma_free_value (arguments_list_p[remove_index]);
+ }
+
+ JMEM_FINALIZE_LOCAL_ARRAY (arguments_list_p);
}
-
- JMEM_FINALIZE_LOCAL_ARRAY (arguments_list_p);
-
- ECMA_OP_TO_NUMBER_FINALIZE (length_number);
- ECMA_FINALIZE (length_value);
}
}
}
#include "ecma-function-object.h"
#include "ecma-lex-env.h"
#include "ecma-try-catch-macro.h"
-#include "lit-magic-strings.h"
#include "js-parser.h"
+#include "lit-magic-strings.h"
+
+#ifdef JERRY_ENABLE_LINE_INFO
+#include "jcontext.h"
+#endif /* JERRY_ENABLE_LINE_INFO */
#define ECMA_BUILTINS_INTERNAL
#include "ecma-builtins-internal.h"
if (arguments_list_len <= 1)
{
- return ecma_make_string_value (ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY));
+ return ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
ecma_value_t final_str = ecma_op_to_string (arguments_list_p[0]);
else
{
/* Very unlikely code path, not optimized. */
- function_body_value = ecma_make_string_value (ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY));
+ function_body_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
ecma_string_t *arguments_str_p = ecma_get_string_from_value (arguments_value);
ECMA_STRING_TO_UTF8_STRING (arguments_str_p, arguments_buffer_p, arguments_buffer_size);
ECMA_STRING_TO_UTF8_STRING (function_body_str_p, function_body_buffer_p, function_body_buffer_size);
+#ifdef JERRY_ENABLE_LINE_INFO
+ JERRY_CONTEXT (resource_name) = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
+#endif /* JERRY_ENABLE_LINE_INFO */
+
ecma_compiled_code_t *bytecode_data_p = NULL;
ecma_value_t ret_value = parser_parse_script (arguments_buffer_p,
#include "ecma-builtin-helpers.h"
#include "lit-char-helpers.h"
+#ifndef CONFIG_DISABLE_JSON_BUILTIN
+
/** \addtogroup ecma ECMA
* @{
*
*/
/**
- * Check the object value existance in the collection.
+ * Check whether the object is pushed onto the occurence stack
*
* Used by:
* - ecma_builtin_json_object step 1
* - ecma_builtin_json_array step 1
*
- * @return true, if the object is already in the collection.
+ * @return true - if the object is pushed onto the occurence stack
+ * false - otherwise
*/
bool
-ecma_has_object_value_in_collection (ecma_collection_header_t *collection_p, /**< collection */
- ecma_value_t object_value) /**< object value */
+ecma_json_has_object_in_stack (ecma_json_occurence_stack_item_t *stack_p, /**< stack */
+ ecma_object_t *object_p) /**< object */
{
- JERRY_ASSERT (ecma_is_value_object (object_value));
-
- ecma_object_t *obj_p = ecma_get_object_from_value (object_value);
-
- ecma_collection_iterator_t iterator;
- ecma_collection_iterator_init (&iterator, collection_p);
-
- while (ecma_collection_iterator_next (&iterator))
+ while (stack_p != NULL)
{
- ecma_value_t value = *iterator.current_value_p;
- ecma_object_t *current_p = ecma_get_object_from_value (value);
-
- if (current_p == obj_p)
+ if (stack_p->object_p == object_p)
{
return true;
}
+
+ stack_p = stack_p->next_p;
}
return false;
-} /* ecma_has_object_value_in_collection */
+} /* ecma_json_has_object_in_stack */
/**
* Check the string value existance in the collection.
ecma_string_t *string_p = ecma_get_string_from_value (string_value);
- ecma_collection_iterator_t iterator;
- ecma_collection_iterator_init (&iterator, collection_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (collection_p);
- while (ecma_collection_iterator_next (&iterator))
+ while (ecma_value_p != NULL)
{
- ecma_value_t value = *iterator.current_value_p;
- ecma_string_t *current_p = ecma_get_string_from_value (value);
+ ecma_string_t *current_p = ecma_get_string_from_value (*ecma_value_p);
if (ecma_compare_ecma_strings (current_p, string_p))
{
return true;
}
+
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
}
return false;
{
ecma_string_t *properties_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
- ecma_collection_iterator_t iterator;
- ecma_collection_iterator_init (&iterator, partial_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (partial_p);
bool first = true;
- while (ecma_collection_iterator_next (&iterator))
+ while (ecma_value_p != NULL)
{
- ecma_value_t name_value = *iterator.current_value_p;
- ecma_string_t *current_p = ecma_get_string_from_value (name_value);
+ ecma_string_t *current_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
if (likely (!first))
{
/* 10.a.i */
properties_str_p = ecma_builtin_helper_json_create_separated_properties (partial_p, comma_str_p);
- ecma_deref_ecma_string (comma_str_p);
/* 10.a.ii */
ecma_string_t *result_str_p = ecma_new_ecma_string_from_code_unit (left_bracket);
return ecma_make_string_value (result_str_p);
} /* ecma_builtin_helper_json_create_non_formatted_json */
+#endif /* !CONFIG_DISABLE_JSON_BUILTIN */
+
/**
* @}
* @}
if (ecma_is_value_undefined (index_value) || ecma_is_value_null (index_value))
{
- ecma_string_t *return_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
- ret_value = ecma_make_string_value (return_string_p);
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
else
{
only_enumerable_properties,
false);
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, props_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
- while (ecma_collection_iterator_next (&iter))
+ while (ecma_value_p != NULL)
{
ecma_string_t *index_string_p = ecma_new_ecma_string_from_uint32 (index);
ecma_value_t completion = ecma_builtin_helper_def_prop (new_array_p,
index_string_p,
- *iter.current_value_p,
+ *ecma_value_p,
true, /* Writable */
true, /* Enumerable */
true, /* Configurable */
ecma_deref_ecma_string (index_string_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
+
index++;
}
- ecma_free_values_collection (props_p, true);
+ ecma_free_values_collection (props_p, 0);
return new_array;
} /* ecma_builtin_helper_object_get_properties */
/* ecma-builtin-helper-json.c */
/**
+ * Occurence stack item of JSON.stringify()
+ */
+typedef struct struct_ecma_json_occurence_stack_item_t
+{
+ struct struct_ecma_json_occurence_stack_item_t *next_p; /**< next stack item */
+ ecma_object_t *object_p; /**< current object */
+} ecma_json_occurence_stack_item_t;
+
+/**
* Context for JSON.stringify()
*/
typedef struct
ecma_collection_header_t *property_list_p;
/** Collection for traversing objects. */
- ecma_collection_header_t *occurence_stack_p;
+ ecma_json_occurence_stack_item_t *occurence_stack_last_p;
/** The actual indentation text. */
ecma_string_t *indent_str_p;
ecma_object_t *replacer_function_p;
} ecma_json_stringify_context_t;
-bool ecma_has_object_value_in_collection (ecma_collection_header_t *collection_p, ecma_value_t object_value);
+ecma_value_t ecma_builtin_json_parse_buffer (const lit_utf8_byte_t * str_start_p,
+ lit_utf8_size_t string_size);
+ecma_value_t ecma_builtin_json_string_from_object (const ecma_value_t arg1);
+bool ecma_json_has_object_in_stack (ecma_json_occurence_stack_item_t *stack_p, ecma_object_t *object_p);
bool ecma_has_string_value_in_collection (ecma_collection_header_t *collection_p, ecma_value_t string_value);
ecma_string_t *
#define BUILTIN_UNDERSCORED_ID json
#include "ecma-builtin-internal-routines-template.inc.h"
+/**
+ * The number of expected hexidecimal characters in a hex escape sequence
+ */
+#define ECMA_JSON_HEX_ESCAPE_SEQUENCE_LENGTH (4)
+
/** \addtogroup ecma ECMA
* @{
*
current_p++;
has_escape_sequence = true;
+ /* If there is an escape sequence but there's no escapable character just return */
+ if (current_p >= end_p)
+ {
+ return;
+ }
+
switch (*current_p)
{
case LIT_CHAR_DOUBLE_QUOTE:
}
case LIT_CHAR_LOWERCASE_U:
{
- ecma_char_t code_unit;
+ if ((end_p - current_p <= ECMA_JSON_HEX_ESCAPE_SEQUENCE_LENGTH))
+ {
+ return;
+ }
- if (!(lit_read_code_unit_from_hex (current_p + 1, 4, &code_unit)))
+ ecma_char_t code_unit;
+ if (!(lit_read_code_unit_from_hex (current_p + 1, ECMA_JSON_HEX_ESCAPE_SEQUENCE_LENGTH, &code_unit)))
{
return;
}
- current_p += 5;
+ current_p += ECMA_JSON_HEX_ESCAPE_SEQUENCE_LENGTH + 1;
lit_utf8_byte_t char_buffer[LIT_UTF8_MAX_BYTES_IN_CODE_UNIT];
buffer_size += lit_code_unit_to_utf8 (code_unit, char_buffer);
{
ecma_char_t code_unit;
- lit_read_code_unit_from_hex (current_p + 1, 4, &code_unit);
+ lit_read_code_unit_from_hex (current_p + 1, ECMA_JSON_HEX_ESCAPE_SEQUENCE_LENGTH, &code_unit);
- current_p += 5;
+ current_p += ECMA_JSON_HEX_ESCAPE_SEQUENCE_LENGTH + 1;
write_p += lit_code_unit_to_utf8 (code_unit, write_p);
continue;
}
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (object_p, false, true, false);
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, props_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
- while (ecma_collection_iterator_next (&iter)
- && ecma_is_value_empty (ret_value))
+ while (ecma_value_p != NULL && ecma_is_value_empty (ret_value))
{
- ecma_string_t *property_name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *property_name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
ECMA_TRY_CATCH (value_walk,
ecma_builtin_json_walk (reviver_p,
ECMA_FINALIZE (value_walk);
}
- ecma_free_values_collection (props_p, true);
+ ecma_free_values_collection (props_p, 0);
}
if (ecma_is_value_empty (ret_value))
} /* ecma_builtin_json_walk */
/**
+ * Function to set a string token from the given arguments, fills its fields and advances the string pointer.
+ *
+ * @return ecma_value_t containing an object or an error massage
+ * Returned value must be freed with ecma_free_value.
+ */
+ecma_value_t
+ecma_builtin_json_parse_buffer (const lit_utf8_byte_t * str_start_p, /**< String to parse */
+ lit_utf8_size_t string_size) /**< size of the string */
+{
+ ecma_json_token_t token;
+ token.current_p = str_start_p;
+ token.end_p = str_start_p + string_size;
+
+ ecma_value_t final_result = ecma_builtin_json_parse_value (&token);
+
+ if (!ecma_is_value_undefined (final_result))
+ {
+ ecma_builtin_json_parse_next_token (&token, false);
+
+ if (token.type != end_token)
+ {
+ ecma_free_value (final_result);
+ final_result = ECMA_VALUE_UNDEFINED;
+ }
+ }
+ return final_result;
+} /*ecma_builtin_json_parse_buffer*/
+
+/**
* The JSON object's 'parse' routine
*
* See also:
ECMA_STRING_TO_UTF8_STRING (string_p, str_start_p, string_size);
- ecma_json_token_t token;
- token.current_p = str_start_p;
- token.end_p = str_start_p + string_size;
-
- ecma_value_t final_result = ecma_builtin_json_parse_value (&token);
-
- if (!ecma_is_value_undefined (final_result))
- {
- ecma_builtin_json_parse_next_token (&token, false);
-
- if (token.type != end_token)
- {
- ecma_free_value (final_result);
- final_result = ECMA_VALUE_UNDEFINED;
- }
- }
+ ecma_value_t final_result = ecma_builtin_json_parse_buffer (str_start_p, string_size);
if (ecma_is_value_undefined (final_result))
{
if (ecma_op_is_callable (arg2))
{
ecma_object_t *object_p = ecma_op_create_object_object_noarg ();
- ecma_string_t *name_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
ecma_property_value_t *prop_value_p;
prop_value_p = ecma_create_named_data_property (object_p,
- name_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY),
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
NULL);
ret_value = ecma_builtin_json_walk (ecma_get_object_from_value (arg2),
object_p,
- name_p);
+ ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY));
ecma_deref_object (object_p);
- ecma_deref_ecma_string (name_p);
}
else
{
ecma_builtin_json_array (ecma_object_t *obj_p, ecma_json_stringify_context_t *context_p);
/**
+ * Helper function to stringify an object in JSON format representing an ecma_value.
+ *
+ * @return ecma_value_t string created from an abject formating by a given context
+ * Returned value must be freed with ecma_free_value.
+ *
+ */
+static ecma_value_t ecma_builtin_json_str_helper (const ecma_value_t arg1, /**< object argument */
+ ecma_json_stringify_context_t context) /**< context argument */
+{
+ ecma_value_t ret_value = ECMA_VALUE_EMPTY;
+ ecma_object_t *obj_wrapper_p = ecma_op_create_object_object_noarg ();
+ ecma_string_t *empty_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
+ ecma_value_t put_comp_val = ecma_op_object_put (obj_wrapper_p,
+ empty_str_p,
+ arg1,
+ false);
+ JERRY_ASSERT (ecma_is_value_true (put_comp_val));
+ ecma_free_value (put_comp_val);
+ ECMA_TRY_CATCH (str_val,
+ ecma_builtin_json_str (empty_str_p, obj_wrapper_p, &context),
+ ret_value);
+ ret_value = ecma_copy_value (str_val);
+ ECMA_FINALIZE (str_val);
+ ecma_free_value (put_comp_val);
+ ecma_deref_ecma_string (empty_str_p);
+ ecma_deref_object (obj_wrapper_p);
+
+ return ret_value;
+} /* ecma_builtin_json_str_helper */
+
+/**
+ * Function to create a json formated string from an object
+ *
+ * @return ecma_value_t containing a json string
+ * Returned value must be freed with ecma_free_value.
+ */
+ecma_value_t
+ecma_builtin_json_string_from_object (const ecma_value_t arg1) /**< object argument */
+{
+ ecma_json_stringify_context_t context;
+ context.occurence_stack_last_p = NULL;
+ context.indent_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
+ context.property_list_p = ecma_new_values_collection ();
+ context.replacer_function_p = NULL;
+ context.gap_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
+
+ ecma_value_t ret_value = ecma_builtin_json_str_helper (arg1, context);
+
+ ecma_deref_ecma_string (context.gap_str_p);
+ ecma_deref_ecma_string (context.indent_str_p);
+ ecma_free_values_collection (context.property_list_p, 0);
+ return ret_value;
+} /*ecma_builtin_json_string_from_object*/
+
+/**
* The JSON object's 'stringify' routine
*
* See also:
ecma_json_stringify_context_t context;
/* 1. */
- context.occurence_stack_p = ecma_new_values_collection (NULL, 0, false);
+ context.occurence_stack_last_p = NULL;
/* 2. */
context.indent_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
/* 3. */
- context.property_list_p = ecma_new_values_collection (NULL, 0, false);
+ context.property_list_p = ecma_new_values_collection ();
context.replacer_function_p = NULL;
{
if (!ecma_has_string_value_in_collection (context.property_list_p, item))
{
- ecma_append_to_values_collection (context.property_list_p, item, true);
+ ecma_append_to_values_collection (context.property_list_p, item, 0);
ecma_deref_ecma_string (ecma_get_string_from_value (item));
}
else
if (ecma_is_value_empty (ret_value))
{
/* 9. */
- ecma_object_t *obj_wrapper_p = ecma_op_create_object_object_noarg ();
- ecma_string_t *empty_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
-
- /* 10. */
- ecma_value_t put_comp_val = ecma_op_object_put (obj_wrapper_p,
- empty_str_p,
- arg1,
- false);
-
- JERRY_ASSERT (ecma_is_value_true (put_comp_val));
- ecma_free_value (put_comp_val);
-
- /* 11. */
- ECMA_TRY_CATCH (str_val,
- ecma_builtin_json_str (empty_str_p, obj_wrapper_p, &context),
- ret_value);
-
- ret_value = ecma_copy_value (str_val);
-
- ECMA_FINALIZE (str_val);
-
- ecma_deref_object (obj_wrapper_p);
- ecma_deref_ecma_string (empty_str_p);
+ ret_value = ecma_builtin_json_str_helper (arg1, context);
}
ecma_deref_ecma_string (context.gap_str_p);
ecma_deref_ecma_string (context.indent_str_p);
- ecma_free_values_collection (context.property_list_p, true);
- ecma_free_values_collection (context.occurence_stack_p, true);
+ ecma_free_values_collection (context.property_list_p, 0);
return ret_value;
} /* ecma_builtin_json_stringify */
else
{
/* 9.b */
- ecma_string_t *null_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NULL);
- ret_value = ecma_make_string_value (null_str_p);
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_NULL);
}
}
/* 10. */
ecma_builtin_json_object (ecma_object_t *obj_p, /**< the object*/
ecma_json_stringify_context_t *context_p) /**< context*/
{
- ecma_value_t obj_value = ecma_make_object_value (obj_p);
-
/* 1. */
- if (ecma_has_object_value_in_collection (context_p->occurence_stack_p, obj_value))
+ if (ecma_json_has_object_in_stack (context_p->occurence_stack_last_p, obj_p))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("The structure is cyclical."));
}
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
/* 2. */
- ecma_append_to_values_collection (context_p->occurence_stack_p, obj_value, true);
+ ecma_json_occurence_stack_item_t stack_item;
+ stack_item.next_p = context_p->occurence_stack_last_p;
+ stack_item.object_p = obj_p;
+ context_p->occurence_stack_last_p = &stack_item;
/* 3. */
ecma_string_t *stepback_p = context_p->indent_str_p;
ecma_collection_header_t *property_keys_p;
/* 5. */
- if (context_p->property_list_p->unit_number > 0)
+ if (context_p->property_list_p->item_count > 0)
{
property_keys_p = context_p->property_list_p;
}
/* 6. */
else
{
- property_keys_p = ecma_new_values_collection (NULL, 0, true);
+ property_keys_p = ecma_new_values_collection ();
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (obj_p, false, true, false);
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, props_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
- while (ecma_collection_iterator_next (&iter))
+ while (ecma_value_p != NULL)
{
- ecma_string_t *property_name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *property_name_p = ecma_get_string_from_value (*ecma_value_p);
ecma_property_t property = ecma_op_object_get_own_property (obj_p,
property_name_p,
JERRY_ASSERT (ecma_is_property_enumerable (property));
- if (ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDDATA)
+ if (ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_NAMEDDATA
+ || ECMA_PROPERTY_GET_TYPE (property) == ECMA_PROPERTY_TYPE_VIRTUAL)
{
- ecma_append_to_values_collection (property_keys_p, *iter.current_value_p, true);
+ ecma_append_to_values_collection (property_keys_p, *ecma_value_p, 0);
}
+
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
}
- ecma_free_values_collection (props_p, true);
+ ecma_free_values_collection (props_p, 0);
}
/* 7. */
- ecma_collection_header_t *partial_p = ecma_new_values_collection (NULL, 0, true);
+ ecma_collection_header_t *partial_p = ecma_new_values_collection ();
/* 8. */
- ecma_collection_iterator_t iterator;
- ecma_collection_iterator_init (&iterator, property_keys_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (property_keys_p);
- while (ecma_collection_iterator_next (&iterator) && ecma_is_value_empty (ret_value))
+ while (ecma_value_p != NULL && ecma_is_value_empty (ret_value))
{
- ecma_value_t value = *iterator.current_value_p;
- ecma_string_t *key_p = ecma_get_string_from_value (value);
+ ecma_string_t *key_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
/* 8.a */
ECMA_TRY_CATCH (str_val,
/* 8.b.v */
ecma_value_t member_value = ecma_make_string_value (member_str_p);
- ecma_append_to_values_collection (partial_p, member_value, true);
+ ecma_append_to_values_collection (partial_p, member_value, 0);
ecma_deref_ecma_string (member_str_p);
}
ECMA_FINALIZE (str_val);
}
- if (context_p->property_list_p->unit_number == 0)
+ if (context_p->property_list_p->item_count == 0)
{
- ecma_free_values_collection (property_keys_p, true);
+ ecma_free_values_collection (property_keys_p, 0);
}
if (!ecma_is_value_empty (ret_value))
{
- ecma_free_values_collection (partial_p, true);
+ ecma_free_values_collection (partial_p, 0);
ecma_deref_ecma_string (stepback_p);
return ret_value;
}
/* 9. */
- if (partial_p->unit_number == 0)
+ if (partial_p->item_count == 0)
{
lit_utf8_byte_t chars[2] = { LIT_CHAR_LEFT_BRACE, LIT_CHAR_RIGHT_BRACE };
}
}
- ecma_free_values_collection (partial_p, true);
+ ecma_free_values_collection (partial_p, 0);
/* 11. */
- ecma_remove_last_value_from_values_collection (context_p->occurence_stack_p);
+ context_p->occurence_stack_last_p = stack_item.next_p;
/* 12. */
ecma_deref_ecma_string (context_p->indent_str_p);
ecma_builtin_json_array (ecma_object_t *obj_p, /**< the array object*/
ecma_json_stringify_context_t *context_p) /**< context*/
{
- ecma_value_t obj_value = ecma_make_object_value (obj_p);
-
/* 1. */
- if (ecma_has_object_value_in_collection (context_p->occurence_stack_p, obj_value))
+ if (ecma_json_has_object_in_stack (context_p->occurence_stack_last_p, obj_p))
{
return ecma_raise_type_error (ECMA_ERR_MSG ("The structure is cyclical."));
}
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
/* 2. */
- ecma_append_to_values_collection (context_p->occurence_stack_p, obj_value, true);
+ ecma_json_occurence_stack_item_t stack_item;
+ stack_item.next_p = context_p->occurence_stack_last_p;
+ stack_item.object_p = obj_p;
+ context_p->occurence_stack_last_p = &stack_item;
/* 3. */
ecma_string_t *stepback_p = context_p->indent_str_p;
context_p->indent_str_p = ecma_concat_ecma_strings (stepback_p, context_p->gap_str_p);
/* 5. */
- ecma_collection_header_t *partial_p = ecma_new_values_collection (NULL, 0, true);
+ ecma_collection_header_t *partial_p = ecma_new_values_collection ();
/* 6. */
ECMA_TRY_CATCH (array_length,
/* 8.b */
if (ecma_is_value_undefined (str_val))
{
- ecma_string_t *null_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NULL);
- ecma_append_to_values_collection (partial_p, ecma_make_string_value (null_str_p), true);
- ecma_deref_ecma_string (null_str_p);
+ ecma_append_to_values_collection (partial_p, ecma_make_magic_string_value (LIT_MAGIC_STRING_NULL), 0);
}
/* 8.c */
else
{
- ecma_append_to_values_collection (partial_p, str_val, true);
+ ecma_append_to_values_collection (partial_p, str_val, 0);
}
ECMA_FINALIZE (str_val);
if (ecma_is_value_empty (ret_value))
{
/* 9. */
- if (partial_p->unit_number == 0)
+ if (partial_p->item_count == 0)
{
lit_utf8_byte_t chars[2] = { LIT_CHAR_LEFT_SQUARE, LIT_CHAR_RIGHT_SQUARE };
ECMA_OP_TO_NUMBER_FINALIZE (array_length_num);
ECMA_FINALIZE (array_length);
- ecma_free_values_collection (partial_p, true);
+ ecma_free_values_collection (partial_p, 0);
/* 11. */
- ecma_remove_last_value_from_values_collection (context_p->occurence_stack_p);
+ context_p->occurence_stack_last_p = stack_item.next_p;
/* 12. */
ecma_deref_ecma_string (context_p->indent_str_p);
/* 4. */
if (ecma_number_is_nan (this_num))
{
- ecma_string_t *nan_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NAN);
- ret_value = ecma_make_string_value (nan_str_p);
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_NAN);
}
else
{
lit_magic_string_id_t id = (is_negative ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL
: LIT_MAGIC_STRING_INFINITY_UL);
- ret_value = ecma_make_string_value (ecma_get_magic_string (id));
+ ret_value = ecma_make_magic_string_value (id);
}
else
{
/* 3. */
if (ecma_number_is_nan (this_num))
{
- ecma_string_t *nan_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NAN);
- ret_value = ecma_make_string_value (nan_str_p);
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_NAN);
}
else
{
lit_magic_string_id_t id = (is_negative ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL
: LIT_MAGIC_STRING_INFINITY_UL);
- ret_value = ecma_make_string_value (ecma_get_magic_string (id));
+ ret_value = ecma_make_magic_string_value (id);
}
else
{
/* 4. */
if (ecma_number_is_nan (this_num))
{
- ecma_string_t *nan_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NAN);
- ret_value = ecma_make_string_value (nan_str_p);
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING_NAN);
}
else
{
lit_magic_string_id_t id = (is_negative ? LIT_MAGIC_STRING_NEGATIVE_INFINITY_UL
: LIT_MAGIC_STRING_INFINITY_UL);
- ret_value = ecma_make_string_value (ecma_get_magic_string (id));
+ ret_value = ecma_make_magic_string_value (id);
}
/* 8. */
else if (arg_num < 1.0 || arg_num >= 22.0)
*/
#include "ecma-alloc.h"
-#include "ecma-array-object.h"
#include "ecma-builtin-helpers.h"
#include "ecma-builtins.h"
#include "ecma-conversion.h"
{
JERRY_UNUSED (this_arg);
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
+ bool was_object = ecma_is_value_object (arg);
/* 1. */
- if (!ecma_is_value_object (arg))
+ if (!was_object)
{
- ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Argument is not an object."));
+#ifndef CONFIG_DISABLE_ES2015_BUILTIN
+ arg = ecma_op_to_object (arg);
+ if (ECMA_IS_VALUE_ERROR (arg))
+ {
+ return arg;
+ }
+#else /* CONFIG_DISABLE_ES2015_BUILTIN */
+ return ecma_raise_type_error (ECMA_ERR_MSG ("Argument is not an object."));
+#endif /* !CONFIG_DISABLE_ES2015_BUILTIN */
+ }
+ /* 2. */
+ ecma_object_t *obj_p = ecma_get_object_from_value (arg);
+ ecma_object_t *prototype_p = ecma_get_object_prototype (obj_p);
+
+ if (prototype_p)
+ {
+ ret_value = ecma_make_object_value (prototype_p);
+ ecma_ref_object (prototype_p);
}
else
{
- /* 2. */
- ecma_object_t *obj_p = ecma_get_object_from_value (arg);
- ecma_object_t *prototype_p = ecma_get_object_prototype (obj_p);
+ ret_value = ECMA_VALUE_NULL;
+ }
- if (prototype_p)
- {
- ret_value = ecma_make_object_value (prototype_p);
- ecma_ref_object (prototype_p);
- }
- else
- {
- ret_value = ECMA_VALUE_NULL;
- }
+#ifndef CONFIG_DISABLE_ES2015_BUILTIN
+ if (!was_object)
+ {
+ ecma_free_value (arg);
}
+#endif /* !CONFIG_DISABLE_ES2015_BUILTIN */
return ret_value;
} /* ecma_builtin_object_object_get_prototype_of */
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (obj_p, false, false, false);
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, props_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
- while (ecma_collection_iterator_next (&iter)
- && ecma_is_value_empty (ret_value))
+ while (ecma_value_p != NULL && ecma_is_value_empty (ret_value))
{
- ecma_string_t *property_name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *property_name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
/* 2.a */
ecma_property_descriptor_t prop_desc;
ecma_free_property_descriptor (&prop_desc);
}
- ecma_free_values_collection (props_p, true);
+ ecma_free_values_collection (props_p, 0);
if (ecma_is_value_empty (ret_value))
{
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (obj_p, false, false, false);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, props_p);
-
- while (ecma_collection_iterator_next (&iter)
- && ecma_is_value_empty (ret_value))
+ while (ecma_value_p != NULL && ecma_is_value_empty (ret_value))
{
- ecma_string_t *property_name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *property_name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
/* 2.a */
ecma_property_descriptor_t prop_desc;
ecma_free_property_descriptor (&prop_desc);
}
- ecma_free_values_collection (props_p, true);
+ ecma_free_values_collection (props_p, 0);
if (ecma_is_value_empty (ret_value))
{
/* 2. */
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (obj_p, false, false, false);
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, props_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
- while (ecma_collection_iterator_next (&iter))
+ while (ecma_value_p != NULL)
{
- ecma_string_t *property_name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *property_name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
/* 2.a */
ecma_property_t property = ecma_op_object_get_own_property (obj_p,
}
}
- ecma_free_values_collection (props_p, true);
+ ecma_free_values_collection (props_p, 0);
}
/* 4. */
/* 2. */
ecma_collection_header_t *props_p = ecma_op_object_get_property_names (obj_p, false, false, false);
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, props_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (props_p);
- while (ecma_collection_iterator_next (&iter))
+ while (ecma_value_p != NULL)
{
- ecma_string_t *property_name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *property_name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
/* 2.a */
ecma_property_t property = ecma_op_object_get_own_property (obj_p,
}
}
- ecma_free_values_collection (props_p, true);
+ ecma_free_values_collection (props_p, 0);
}
/* 4 */
ecma_object_t *props_p = ecma_get_object_from_value (props);
/* 3. */
ecma_collection_header_t *prop_names_p = ecma_op_object_get_property_names (props_p, false, true, false);
- uint32_t property_number = prop_names_p->unit_number;
+ uint32_t property_number = prop_names_p->item_count;
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, prop_names_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (prop_names_p);
/* 4. */
JMEM_DEFINE_LOCAL_ARRAY (property_descriptors, property_number, ecma_property_descriptor_t);
uint32_t property_descriptor_number = 0;
- while (ecma_collection_iterator_next (&iter)
- && ecma_is_value_empty (ret_value))
+ while (ecma_value_p != NULL && ecma_is_value_empty (ret_value))
{
/* 5.a */
ECMA_TRY_CATCH (desc_obj,
- ecma_op_object_get (props_p, ecma_get_string_from_value (*iter.current_value_p)),
+ ecma_op_object_get (props_p, ecma_get_string_from_value (*ecma_value_p)),
ret_value);
/* 5.b */
ECMA_FINALIZE (conv_result);
ECMA_FINALIZE (desc_obj);
+
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
}
/* 6. */
- ecma_collection_iterator_init (&iter, prop_names_p);
+ ecma_value_p = ecma_collection_iterator_init (prop_names_p);
+
for (uint32_t index = 0;
index < property_number && ecma_is_value_empty (ret_value);
index++)
{
- bool is_next = ecma_collection_iterator_next (&iter);
- JERRY_ASSERT (is_next);
-
ECMA_TRY_CATCH (define_own_prop_ret,
ecma_op_object_define_own_property (obj_p,
- ecma_get_string_from_value (*iter.current_value_p),
+ ecma_get_string_from_value (*ecma_value_p),
&property_descriptors[index],
true),
ret_value);
ECMA_FINALIZE (define_own_prop_ret);
+
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
}
/* Clean up. */
JMEM_FINALIZE_LOCAL_ARRAY (property_descriptors);
- ecma_free_values_collection (prop_names_p, true);
+ ecma_free_values_collection (prop_names_p, 0);
/* 7. */
if (ecma_is_value_empty (ret_value))
return capability;
}
- ecma_string_t *str;
+ ecma_string_t *property_str_p;
if (is_resolve)
{
- str = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
+ property_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
}
else
{
- str = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
+ property_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
}
- ecma_value_t func = ecma_op_object_get (ecma_get_object_from_value (capability), str);
- ecma_deref_ecma_string (str);
+ ecma_value_t func = ecma_op_object_get (ecma_get_object_from_value (capability), property_str_p);
ecma_value_t call_ret = ecma_op_function_call (ecma_get_object_from_value (func),
ECMA_VALUE_UNDEFINED,
ecma_free_value (call_ret);
- ecma_string_t *str_promise = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
- ecma_value_t promise_new = ecma_op_object_get (ecma_get_object_from_value (capability), str_promise);
- ecma_deref_ecma_string (str_promise);
+ ecma_string_t *promise_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
+ ecma_value_t promise_new = ecma_op_object_get (ecma_get_object_from_value (capability), promise_str_p);
ecma_free_value (capability);
return promise_new;
ecma_builtin_promise_reject_abrupt (ecma_value_t capability) /**< reject description */
{
ecma_value_t reason = JERRY_CONTEXT (error_value);
- ecma_string_t *str_reject = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
- ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability), str_reject);
- ecma_deref_ecma_string (str_reject);
+ ecma_string_t *reject_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
+ ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability), reject_str_p);
ecma_value_t call_ret = ecma_op_function_call (ecma_get_object_from_value (reject),
ECMA_VALUE_UNDEFINED,
ecma_free_value (call_ret);
- ecma_string_t *str_promise = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
- ecma_value_t promise_new = ecma_op_object_get (ecma_get_object_from_value (capability), str_promise);
- ecma_deref_ecma_string (str_promise);
+ ecma_string_t *promise_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
+ ecma_value_t promise_new = ecma_op_object_get (ecma_get_object_from_value (capability), promise_str_p);
return promise_new;
} /* ecma_builtin_promise_reject_abrupt */
ecma_length_t len = (ecma_length_t) ecma_get_integer_from_value (len_value);
ecma_fast_free_value (len_value);
- ecma_string_t *str_promise = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
- ecma_string_t *str_resolve = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
- ecma_string_t *str_reject = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
+ ecma_string_t *promise_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
+ ecma_string_t *resolve_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
+ ecma_string_t *reject_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability),
- str_resolve);
+ resolve_str_p);
ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability),
- str_reject);
+ reject_str_p);
for (ecma_length_t index = 0; index <= len; index++)
{
/* b-d. */
if (index == len)
{
- ret = ecma_op_object_get (ecma_get_object_from_value (capability), str_promise);
+ ret = ecma_op_object_get (ecma_get_object_from_value (capability), promise_str_p);
break;
}
/* e. */
- ecma_string_t *str_index = ecma_new_ecma_string_from_uint32 (index);
- ecma_value_t array_item = ecma_op_object_get (array_p, str_index);
- ecma_deref_ecma_string (str_index);
+ ecma_string_t *index_to_str_p = ecma_new_ecma_string_from_uint32 (index);
+ ecma_value_t array_item = ecma_op_object_get (array_p, index_to_str_p);
+ ecma_deref_ecma_string (index_to_str_p);
/* h. */
ecma_value_t next_promise = ecma_builtin_promise_resolve (ctor, array_item);
ecma_free_value (reject);
ecma_free_value (resolve);
- ecma_deref_ecma_string (str_promise);
- ecma_deref_ecma_string (str_resolve);
- ecma_deref_ecma_string (str_reject);
JERRY_ASSERT (!ecma_is_value_empty (ret));
ecma_value_t ret = ECMA_VALUE_UNDEFINED;
/* 1. */
ecma_object_t *function_p = ecma_get_object_from_value (function);
- ecma_string_t *str_already_called = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_ALREADY_CALLED);
- ecma_value_t already_called = ecma_op_object_get (function_p, str_already_called);
+ ecma_string_t *already_called_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_ALREADY_CALLED);
+ ecma_value_t already_called = ecma_op_object_get (function_p, already_called_str_p);
JERRY_ASSERT (ecma_is_value_boolean (already_called));
if (ecma_is_value_true (already_called))
{
ecma_fast_free_value (already_called);
- ecma_deref_ecma_string (str_already_called);
-
return ret;
}
/* 3. */
ecma_op_object_put (function_p,
- str_already_called,
+ already_called_str_p,
ecma_make_boolean_value (true),
false);
- ecma_string_t *str_index = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_INDEX);
- ecma_string_t *str_value = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_VALUE);
- ecma_string_t *str_capability = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
- ecma_string_t *str_remaining = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REMAINING_ELEMENT);
+ ecma_string_t *str_index_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_INDEX);
+ ecma_string_t *str_value_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_VALUE);
+ ecma_string_t *str_capability_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
+ ecma_string_t *str_remaining_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REMAINING_ELEMENT);
/* 4-7. */
- ecma_value_t index_val = ecma_op_object_get (function_p, str_index);
- ecma_value_t value_array = ecma_op_object_get (function_p, str_value);
- ecma_value_t capability = ecma_op_object_get (function_p, str_capability);
- ecma_value_t remaining = ecma_op_object_get (function_p, str_remaining);
+ ecma_value_t index_val = ecma_op_object_get (function_p, str_index_p);
+ ecma_value_t value_array = ecma_op_object_get (function_p, str_value_p);
+ ecma_value_t capability = ecma_op_object_get (function_p, str_capability_p);
+ ecma_value_t remaining = ecma_op_object_get (function_p, str_remaining_p);
JERRY_ASSERT (ecma_is_value_integer_number (index_val));
/* 8. */
- ecma_string_t *index_str = ecma_new_ecma_string_from_uint32 ((uint32_t) ecma_get_integer_from_value (index_val));
+ ecma_string_t *index_to_str_p = ecma_new_ecma_string_from_uint32 ((uint32_t) ecma_get_integer_from_value (index_val));
ecma_op_object_put (ecma_get_object_from_value (value_array),
- index_str,
+ index_to_str_p,
argv[0],
false);
- ecma_deref_ecma_string (index_str);
+ ecma_deref_ecma_string (index_to_str_p);
/* 9-10. */
if (ecma_builtin_promise_remaining_inc_or_dec (remaining, false) == 0)
{
- ecma_string_t *str_resolve = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
- ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability),
- str_resolve);
- ecma_deref_ecma_string (str_resolve);
+ ecma_string_t *resolve_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
+ ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability), resolve_str_p);
+
ret = ecma_op_function_call (ecma_get_object_from_value (resolve),
ECMA_VALUE_UNDEFINED,
&value_array,
ecma_free_value (value_array);
ecma_fast_free_value (index_val);
ecma_fast_free_value (already_called);
- ecma_deref_ecma_string (str_already_called);
- ecma_deref_ecma_string (str_index);
- ecma_deref_ecma_string (str_value);
- ecma_deref_ecma_string (str_capability);
- ecma_deref_ecma_string (str_remaining);
return ret;
} /* ecma_builtin_promise_all_handler */
ecma_length_t len = (ecma_length_t) ecma_get_integer_from_value (len_value);
ecma_fast_free_value (len_value);
- ecma_string_t *str_promise = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
- ecma_string_t *str_resolve = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
- ecma_string_t *str_reject = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
- ecma_string_t *str_already_called = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_ALREADY_CALLED);
- ecma_string_t *str_index = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_INDEX);
- ecma_string_t *str_value = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_VALUE);
- ecma_string_t *str_capability = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
- ecma_string_t *str_remaining = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REMAINING_ELEMENT);
+ ecma_string_t *promise_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
+ ecma_string_t *resolve_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
+ ecma_string_t *reject_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
+ ecma_string_t *already_called_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_ALREADY_CALLED);
+ ecma_string_t *index_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_INDEX);
+ ecma_string_t *value_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_VALUE);
+ ecma_string_t *capability_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
+ ecma_string_t *remaining_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REMAINING_ELEMENT);
ecma_value_t undefined_val = ECMA_VALUE_UNDEFINED;
/* String '1' indicates [[Resolve]] and '2' indicates [[Reject]]. */
ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability),
- str_resolve);
+ resolve_str_p);
ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability),
- str_reject);
+ reject_str_p);
/* 3. */
ecma_value_t result_array_length_val = ecma_make_uint32_value (0);
ecma_value_t value_array = ecma_op_create_array_object (&result_array_length_val, 1, true);
}
/* iv. */
- ret = ecma_op_object_get (ecma_get_object_from_value (capability), str_promise);
+ ret = ecma_op_object_get (ecma_get_object_from_value (capability), promise_str_p);
break;
}
/* e. h. */
- ecma_string_t *index_str = ecma_new_ecma_string_from_uint32 (index);
- ecma_value_t array_item = ecma_op_object_get (array_p, index_str);
+ ecma_string_t *index_to_str_p = ecma_new_ecma_string_from_uint32 (index);
+ ecma_value_t array_item = ecma_op_object_get (array_p, index_to_str_p);
ecma_op_object_put (ecma_get_object_from_value (value_array),
- index_str,
+ index_to_str_p,
undefined_val,
false);
- ecma_deref_ecma_string (index_str);
+ ecma_deref_ecma_string (index_to_str_p);
/* i. */
ecma_value_t next_promise = ecma_builtin_promise_resolve (ctor, array_item);
ecma_free_value (array_item);
res_ele_p = ecma_op_create_external_function_object (ecma_builtin_promise_all_handler);
/* l. */
ecma_op_object_put (res_ele_p,
- str_already_called,
+ already_called_str_p,
ecma_make_boolean_value (false),
false);
/* m. */
ecma_op_object_put (res_ele_p,
- str_index,
+ index_str_p,
ecma_make_uint32_value (index),
false);
/* n. */
ecma_op_object_put (res_ele_p,
- str_value,
+ value_str_p,
value_array,
false);
/* o. */
ecma_op_object_put (res_ele_p,
- str_capability,
+ capability_str_p,
capability,
false);
/* p. */
ecma_op_object_put (res_ele_p,
- str_remaining,
+ remaining_str_p,
remaining,
false);
ecma_free_value (resolve);
ecma_free_value (remaining);
ecma_free_value (value_array);
- ecma_deref_ecma_string (str_already_called);
- ecma_deref_ecma_string (str_index);
- ecma_deref_ecma_string (str_value);
- ecma_deref_ecma_string (str_capability);
- ecma_deref_ecma_string (str_remaining);
- ecma_deref_ecma_string (str_resolve);
- ecma_deref_ecma_string (str_reject);
- ecma_deref_ecma_string (str_promise);
JERRY_ASSERT (!ecma_is_value_empty (ret));
/* Get source. */
ecma_string_t *magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_SOURCE);
ecma_value_t source_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p);
- ecma_deref_ecma_string (magic_string_p);
ecma_string_t *pattern_string_p = ecma_get_string_from_value (source_value);
/* Get flags. */
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GLOBAL);
ecma_value_t global_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p);
- ecma_deref_ecma_string (magic_string_p);
JERRY_ASSERT (ecma_is_value_boolean (global_value));
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_IGNORECASE_UL);
ecma_value_t ignore_case_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p);
- ecma_deref_ecma_string (magic_string_p);
JERRY_ASSERT (ecma_is_value_boolean (ignore_case_value));
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MULTILINE);
ecma_value_t multiline_value = ecma_op_object_get_own_data_prop (target_p, magic_string_p);
- ecma_deref_ecma_string (magic_string_p);
JERRY_ASSERT (ecma_is_value_boolean (multiline_value));
ecma_deref_ecma_string (pattern_string_p);
- re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, *bc_prop_p);
+ re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (re_compiled_code_t, *bc_prop_p);
if (old_bc_p != NULL)
{
re_compile_bytecode (&new_bc_p, pattern_string_p, flags),
ret_value);
- re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t, *bc_prop_p);
+ re_compiled_code_t *old_bc_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (re_compiled_code_t, *bc_prop_p);
if (old_bc_p != NULL)
{
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_value_t *bytecode_prop_p = &(((ecma_extended_object_t *) obj_p)->u.class_prop.u.value);
- void *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (void, *bytecode_prop_p);
+ void *bytecode_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (void, *bytecode_prop_p);
if (bytecode_p == NULL)
{
/* Missing bytecode means empty RegExp: '/(?:)/', so always return empty string. */
- ecma_string_t *capture_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
-
ecma_value_t arguments_list[1];
- arguments_list[0] = ecma_make_string_value (capture_str_p);
+ arguments_list[0] = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
ret_value = ecma_op_create_array_object (arguments_list, 1, false);
- ecma_deref_ecma_string (capture_str_p);
-
re_set_result_array_properties (ecma_get_object_from_value (ret_value),
ecma_get_string_from_value (input_str_value),
1,
/* Get RegExp source from the source property */
ecma_string_t *magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_SOURCE);
ecma_value_t source_value = ecma_op_object_get_own_data_prop (obj_p, magic_string_p);
- ecma_deref_ecma_string (magic_string_p);
ecma_string_t *output_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_SLASH_CHAR);
ecma_string_t *source_str_p = ecma_get_string_from_value (source_value);
/* Check the global flag */
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GLOBAL);
ecma_value_t global_value = ecma_op_object_get_own_data_prop (obj_p, magic_string_p);
- ecma_deref_ecma_string (magic_string_p);
JERRY_ASSERT (ecma_is_value_boolean (global_value));
/* Check the ignoreCase flag */
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_IGNORECASE_UL);
ecma_value_t ignore_case_value = ecma_op_object_get_own_data_prop (obj_p, magic_string_p);
- ecma_deref_ecma_string (magic_string_p);
JERRY_ASSERT (ecma_is_value_boolean (ignore_case_value));
/* Check the multiline flag */
magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MULTILINE);
ecma_value_t multiline_value = ecma_op_object_get_own_data_prop (obj_p, magic_string_p);
- ecma_deref_ecma_string (magic_string_p);
JERRY_ASSERT (ecma_is_value_boolean (multiline_value));
/* 5 */
if (index_num < 0 || index_num >= len || !len)
{
- ret_value = ecma_make_string_value (ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY));
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
else
{
else
{
/* 8.a. */
- ecma_string_t *index_zero_string_p = ecma_new_ecma_string_from_uint32 (0);
-
- ecma_string_t *last_index_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL);
+ ecma_string_t *index_zero_string_p = ecma_get_ecma_string_from_uint32 (0);
ECMA_TRY_CATCH (put_value,
ecma_op_object_put (regexp_obj_p,
- last_index_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
ecma_make_integer_value (0),
true),
ret_value);
/* 8.f.iii.2.a. */
ECMA_TRY_CATCH (index_put_value,
ecma_op_object_put (regexp_obj_p,
- last_index_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
ecma_make_number_value (this_index + 1),
true),
ret_value);
ECMA_FINALIZE (new_array_value);
ECMA_FINALIZE (put_value);
-
- ecma_deref_ecma_string (last_index_string_p);
- ecma_deref_ecma_string (index_zero_string_p);
}
ECMA_FINALIZE (global_value);
JERRY_ASSERT (ecma_is_value_object (match_value));
ecma_object_t *match_object_p = ecma_get_object_from_value (match_value);
- ecma_string_t *zero_string_p = ecma_new_ecma_string_from_uint32 (0);
-
ECMA_TRY_CATCH (index_value,
ecma_op_object_get_by_magic_id (match_object_p, LIT_MAGIC_STRING_INDEX),
ret_value);
ECMA_TRY_CATCH (result_string_value,
- ecma_op_object_get (match_object_p, zero_string_p),
+ ecma_op_object_get (match_object_p, ecma_get_ecma_string_from_uint32 (0)),
ret_value);
/* We directly call the built-in exec, so
ECMA_FINALIZE (result_string_value);
ECMA_FINALIZE (index_value);
-
- ecma_deref_ecma_string (zero_string_p);
}
else
{
}
else
{
- ecma_string_t *last_index_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL);
ecma_object_t *regexp_obj_p = ecma_get_object_from_value (context_p->regexp_or_search_string);
ECMA_TRY_CATCH (put_value,
ecma_op_object_put (regexp_obj_p,
- last_index_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
ecma_make_uint32_value (context_p->match_end + 1),
true),
ret_value);
ECMA_FINALIZE (put_value);
- ecma_deref_ecma_string (last_index_string_p);
}
}
}
if (context.is_global)
{
- ecma_string_t *last_index_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL);
-
ECMA_TRY_CATCH (put_value,
ecma_op_object_put (regexp_obj_p,
- last_index_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
ecma_make_integer_value (0),
true),
ret_value);
ECMA_FINALIZE (put_value);
- ecma_deref_ecma_string (last_index_string_p);
}
if (ecma_is_value_empty (ret_value))
{
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
ecma_value_t regexp_value = ecma_copy_value_if_not_object (separator);
- ecma_string_t *substr_str_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
ecma_value_t match_result;
- match_result = ecma_regexp_exec_helper (regexp_value, ecma_make_string_value (substr_str_p), true);
+ match_result = ecma_regexp_exec_helper (regexp_value,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY),
+ true);
should_return = !ecma_is_value_null (match_result);
if (ECMA_IS_VALUE_ERROR (match_result))
match_result = JERRY_CONTEXT (error_value);
}
- ecma_deref_ecma_string (substr_str_p);
ecma_free_value (match_result);
#else
return ecma_raise_type_error (ECMA_ERR_MSG ("REGEXP separator is disabled in split method."));
else
{
ecma_object_t *match_obj_p = ecma_get_object_from_value (match_result);
- ecma_string_t *zero_str_p = ecma_new_ecma_string_from_uint32 (0);
+ ecma_string_t *zero_str_p = ecma_get_ecma_string_from_uint32 (0);
ecma_string_t *magic_index_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INDEX);
ecma_property_value_t *index_prop_value_p;
-
if (separator_is_regexp)
{
index_prop_value_p = ecma_get_named_data_property (match_obj_p, magic_index_str_p);
magic_index_str_p,
ECMA_PROPERTY_FLAG_WRITABLE,
NULL);
+
ecma_named_data_property_assign_value (match_obj_p,
index_prop_value_p,
ecma_make_uint32_value (curr_pos));
-
}
- ecma_deref_ecma_string (magic_index_str_p);
-
ecma_value_t match_comp_value = ecma_op_object_get (match_obj_p, zero_str_p);
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (match_comp_value));
ecma_string_t *match_str_p = ecma_get_string_from_value (match_comp_value);
ecma_length_t match_str_length = ecma_string_get_length (match_str_p);
- ecma_string_t *magic_empty_str_p = ecma_new_ecma_string_from_magic_string_id (LIT_MAGIC_STRING__EMPTY);
- separator_is_empty = ecma_compare_ecma_strings (magic_empty_str_p, match_str_p);
+ separator_is_empty = ecma_string_is_empty (match_str_p);
- ecma_deref_ecma_string (magic_empty_str_p);
ecma_free_value (match_comp_value);
- ecma_deref_ecma_string (zero_str_p);
ecma_number_t index_num = ecma_get_number_from_value (index_prop_value_p->value);
JERRY_ASSERT (index_num >= 0);
ecma_length_t args_number) /**< number of arguments */
{
JERRY_UNUSED (this_arg);
- ecma_value_t ret_value = ECMA_VALUE_EMPTY;
- ecma_string_t *ret_string_p = NULL;
if (args_number == 0)
{
- ret_string_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
+ return ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
- else
- {
- lit_utf8_size_t utf8_buf_size = args_number * LIT_CESU8_MAX_BYTES_IN_CODE_UNIT;
- JMEM_DEFINE_LOCAL_ARRAY (utf8_buf_p,
- utf8_buf_size,
- lit_utf8_byte_t);
+ ecma_value_t ret_value = ECMA_VALUE_EMPTY;
+ ecma_string_t *ret_string_p = NULL;
+ lit_utf8_size_t utf8_buf_size = args_number * LIT_CESU8_MAX_BYTES_IN_CODE_UNIT;
- lit_utf8_size_t utf8_buf_used = 0;
+ JMEM_DEFINE_LOCAL_ARRAY (utf8_buf_p,
+ utf8_buf_size,
+ lit_utf8_byte_t);
- for (ecma_length_t arg_index = 0;
- arg_index < args_number && ecma_is_value_empty (ret_value);
- arg_index++)
- {
- ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, args[arg_index], ret_value);
+ lit_utf8_size_t utf8_buf_used = 0;
- uint32_t uint32_char_code = ecma_number_to_uint32 (arg_num);
- ecma_char_t code_unit = (uint16_t) uint32_char_code;
+ for (ecma_length_t arg_index = 0;
+ arg_index < args_number && ecma_is_value_empty (ret_value);
+ arg_index++)
+ {
+ ECMA_OP_TO_NUMBER_TRY_CATCH (arg_num, args[arg_index], ret_value);
- JERRY_ASSERT (utf8_buf_used <= utf8_buf_size - LIT_UTF8_MAX_BYTES_IN_CODE_UNIT);
- utf8_buf_used += lit_code_unit_to_utf8 (code_unit, utf8_buf_p + utf8_buf_used);
- JERRY_ASSERT (utf8_buf_used <= utf8_buf_size);
+ uint32_t uint32_char_code = ecma_number_to_uint32 (arg_num);
+ ecma_char_t code_unit = (uint16_t) uint32_char_code;
- ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
- }
+ JERRY_ASSERT (utf8_buf_used <= utf8_buf_size - LIT_UTF8_MAX_BYTES_IN_CODE_UNIT);
+ utf8_buf_used += lit_code_unit_to_utf8 (code_unit, utf8_buf_p + utf8_buf_used);
+ JERRY_ASSERT (utf8_buf_used <= utf8_buf_size);
- if (ecma_is_value_empty (ret_value))
- {
- ret_string_p = ecma_new_ecma_string_from_utf8 (utf8_buf_p, utf8_buf_used);
- }
+ ECMA_OP_TO_NUMBER_FINALIZE (arg_num);
+ }
- JMEM_FINALIZE_LOCAL_ARRAY (utf8_buf_p);
+ if (ecma_is_value_empty (ret_value))
+ {
+ ret_string_p = ecma_new_ecma_string_from_utf8 (utf8_buf_p, utf8_buf_used);
}
+ JMEM_FINALIZE_LOCAL_ARRAY (utf8_buf_p);
+
if (ecma_is_value_empty (ret_value))
{
ret_value = ecma_make_string_value (ret_string_p);
if (arguments_list_len == 0)
{
- ecma_string_t *str_p = ecma_new_ecma_string_from_magic_string_id (LIT_MAGIC_STRING__EMPTY);
- ecma_value_t str_value = ecma_make_string_value (str_p);
-
- ret_value = str_value;
+ ret_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
}
else
{
uint16_t value; /**< value of the property */
} ecma_builtin_property_descriptor_t;
-#define BUILTIN(builtin_id, \
- object_type, \
- object_prototype_builtin_id, \
- is_extensible, \
- is_static, \
- lowercase_name) \
+#define BUILTIN_ROUTINE(builtin_id, \
+ object_type, \
+ object_prototype_builtin_id, \
+ is_extensible, \
+ lowercase_name) \
extern const ecma_builtin_property_descriptor_t \
ecma_builtin_ ## lowercase_name ## _property_descriptor_list[]; \
ecma_value_t \
ecma_value_t this_arg_value, \
const ecma_value_t [], \
ecma_length_t);
+#define BUILTIN(builtin_id, \
+ object_type, \
+ object_prototype_builtin_id, \
+ is_extensible, \
+ lowercase_name) \
+extern const ecma_builtin_property_descriptor_t \
+ecma_builtin_ ## lowercase_name ## _property_descriptor_list[]; \
+ecma_value_t \
+ecma_builtin_ ## lowercase_name ## _dispatch_routine (uint16_t builtin_routine_id, \
+ ecma_value_t this_arg_value, \
+ const ecma_value_t [], \
+ ecma_length_t);
#include "ecma-builtins.inc.h"
+#undef BUILTIN_ROUTINE
+#undef BUILTIN
+
#endif /* !ECMA_BUILTINS_INTERNAL_H */
*/
typedef const ecma_builtin_property_descriptor_t *ecma_builtin_property_list_reference_t;
+typedef ecma_value_t (*ecma_builtin_dispatch_routine_t)(uint16_t builtin_routine_id,
+ ecma_value_t this_arg,
+ const ecma_value_t arguments_list[],
+ ecma_length_t arguments_number);
+typedef ecma_value_t (*ecma_builtin_dispatch_call_t)(const ecma_value_t arguments_list[],
+ ecma_length_t arguments_number);
+
+static const ecma_builtin_dispatch_routine_t ecma_builtin_routines[] =
+{
+ #define BUILTIN(a, b, c, d, e)
+ #define BUILTIN_ROUTINE(builtin_id, \
+ object_type, \
+ object_prototype_builtin_id, \
+ is_extensible, \
+ lowercase_name) \
+ ecma_builtin_ ## lowercase_name ## _dispatch_routine,
+ #include "ecma-builtins.inc.h"
+ #undef BUILTIN
+ #undef BUILTIN_ROUTINE
+ #define BUILTIN_ROUTINE(a, b, c, d, e)
+ #define BUILTIN(builtin_id, \
+ object_type, \
+ object_prototype_builtin_id, \
+ is_extensible, \
+ lowercase_name) \
+ ecma_builtin_ ## lowercase_name ## _dispatch_routine,
+ #include "ecma-builtins.inc.h"
+ #undef BUILTIN
+ #undef BUILTIN_ROUTINE
+};
+
+static const ecma_builtin_dispatch_call_t ecma_builtin_call_functions[] =
+{
+ #define BUILTIN(a, b, c, d, e)
+ #define BUILTIN_ROUTINE(builtin_id, \
+ object_type, \
+ object_prototype_builtin_id, \
+ is_extensible, \
+ lowercase_name) \
+ ecma_builtin_ ## lowercase_name ## _dispatch_call,
+ #include "ecma-builtins.inc.h"
+ #undef BUILTIN_ROUTINE
+ #undef BUILTIN
+};
+
+static const ecma_builtin_dispatch_call_t ecma_builtin_construct_functions[] =
+{
+ #define BUILTIN(a, b, c, d, e)
+ #define BUILTIN_ROUTINE(builtin_id, \
+ object_type, \
+ object_prototype_builtin_id, \
+ is_extensible, \
+ lowercase_name) \
+ ecma_builtin_ ## lowercase_name ## _dispatch_construct,
+ #include "ecma-builtins.inc.h"
+ #undef BUILTIN_ROUTINE
+ #undef BUILTIN
+};
+
/**
* Property descriptor lists for all built-ins.
*/
static const ecma_builtin_property_list_reference_t ecma_builtin_property_list_references[] =
{
+#define BUILTIN(a, b, c, d, e)
+#define BUILTIN_ROUTINE(builtin_id, \
+ object_type, \
+ object_prototype_builtin_id, \
+ is_extensible, \
+ lowercase_name) \
+ ecma_builtin_ ## lowercase_name ## _property_descriptor_list,
+#include "ecma-builtins.inc.h"
+#undef BUILTIN
+#undef BUILTIN_ROUTINE
+#define BUILTIN_ROUTINE(a, b, c, d, e)
#define BUILTIN(builtin_id, \
object_type, \
object_prototype_builtin_id, \
is_extensible, \
- is_static, \
lowercase_name) \
ecma_builtin_ ## lowercase_name ## _property_descriptor_list,
#include "ecma-builtins.inc.h"
+#undef BUILTIN_ROUTINE
+#undef BUILTIN
};
/**
ecma_object_t *obj_p = ecma_create_object (prototype_obj_p, ext_object_size, obj_type);
- if (!is_extensible)
+ if (unlikely (!is_extensible))
{
ecma_set_object_extensible (obj_p, false);
}
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_STRING_UL;
- ecma_string_t *prim_prop_str_value_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
- ext_object_p->u.class_prop.u.value = ecma_make_string_value (prim_prop_str_value_p);
+ ext_object_p->u.class_prop.u.value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
break;
}
#endif /* !CONFIG_DISABLE_STRING_BUILTIN */
} /* ecma_builtin_init_object */
/**
+ * Helper function for 'ecma_instantiate_builtin'
+ */
+static void
+ecma_instantiate_builtin_helper (ecma_builtin_id_t builtin_id, /**< built-in id */
+ ecma_object_type_t object_type, /**< object type */
+ ecma_builtin_id_t object_prototype_builtin_id, /**< built-in id of prototype */
+ bool is_extensible) /**< value of object's [[Extensible]] property */
+{
+ JERRY_ASSERT (JERRY_CONTEXT (ecma_builtin_objects)[builtin_id] == NULL);
+
+ ecma_object_t *prototype_obj_p;
+ if (object_prototype_builtin_id == ECMA_BUILTIN_ID__COUNT)
+ {
+ prototype_obj_p = NULL;
+ }
+ else
+ {
+ if (JERRY_CONTEXT (ecma_builtin_objects)[object_prototype_builtin_id] == NULL)
+ {
+ ecma_instantiate_builtin (object_prototype_builtin_id);
+ }
+ prototype_obj_p = JERRY_CONTEXT (ecma_builtin_objects)[object_prototype_builtin_id];
+ JERRY_ASSERT (prototype_obj_p != NULL);
+ }
+
+ ecma_object_t *builtin_obj_p = ecma_builtin_init_object (builtin_id,
+ prototype_obj_p,
+ object_type,
+ is_extensible);
+ JERRY_CONTEXT (ecma_builtin_objects)[builtin_id] = builtin_obj_p;
+} /* ecma_instantiate_builtin_helper */
+
+/**
* Instantiate specified ECMA built-in object
*/
static void
object_type, \
object_prototype_builtin_id, \
is_extensible, \
- is_static, \
lowercase_name) \
case builtin_id: \
{ \
- JERRY_ASSERT (JERRY_CONTEXT (ecma_builtin_objects)[builtin_id] == NULL); \
- \
- ecma_object_t *prototype_obj_p; \
- if (object_prototype_builtin_id == ECMA_BUILTIN_ID__COUNT) \
- { \
- prototype_obj_p = NULL; \
- } \
- else \
- { \
- if (JERRY_CONTEXT (ecma_builtin_objects)[object_prototype_builtin_id] == NULL) \
- { \
- ecma_instantiate_builtin (object_prototype_builtin_id); \
- } \
- prototype_obj_p = JERRY_CONTEXT (ecma_builtin_objects)[object_prototype_builtin_id]; \
- JERRY_ASSERT (prototype_obj_p != NULL); \
- } \
- \
- ecma_object_t *builtin_obj_p = ecma_builtin_init_object (builtin_id, \
- prototype_obj_p, \
- object_type, \
- is_extensible); \
- JERRY_CONTEXT (ecma_builtin_objects)[builtin_id] = builtin_obj_p; \
- \
+ ecma_instantiate_builtin_helper (builtin_id, \
+ object_type, \
+ object_prototype_builtin_id, \
+ is_extensible); \
break; \
}
+#define BUILTIN_ROUTINE(a, b, c, d, e) BUILTIN(a, b, c, d, e)
#include "ecma-builtins.inc.h"
-
+#undef BUILTIN
+#undef BUILTIN_ROUTINE
default:
{
JERRY_ASSERT (id < ECMA_BUILTIN_ID__COUNT);
}
case ECMA_BUILTIN_PROPERTY_STRING:
{
- value = ecma_make_string_value (ecma_get_magic_string (curr_property_p->value));
+ value = ecma_make_magic_string_value (curr_property_p->value);
break;
}
case ECMA_BUILTIN_PROPERTY_OBJECT:
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
/* 'length' property is non-enumerable (ECMA-262 v5, 15) */
- ecma_string_t *name_p = ecma_new_ecma_length_string ();
- ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (name_p), true);
- ecma_deref_ecma_string (name_p);
+ ecma_append_to_values_collection (for_non_enumerable_p,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH),
+ 0);
}
else
{
if (!(*bitset_p & bit_for_index) || ecma_op_object_has_own_property (object_p, name_p))
{
ecma_append_to_values_collection (for_non_enumerable_p,
- ecma_make_string_value (name_p),
- true);
+ ecma_make_magic_string_value (curr_property_p->magic_string_id),
+ 0);
}
ecma_deref_ecma_string (name_p);
* of the built-in object's
* routine property */
ecma_value_t this_arg_value, /**< 'this' argument value */
- const ecma_value_t arguments_list[], /**< list of arguments passed to routine */
- ecma_length_t arguments_number) /**< length of arguments' list */
+ const ecma_value_t *arguments_list_p, /**< list of arguments passed to routine */
+ ecma_length_t arguments_list_len) /**< length of arguments' list */
{
- switch (builtin_object_id)
- {
-#define BUILTIN(builtin_id, \
- object_type, \
- object_prototype_builtin_id, \
- is_extensible, \
- is_static, \
- lowercase_name) \
- case builtin_id: \
- { \
- return ecma_builtin_ ## lowercase_name ## _dispatch_routine (builtin_routine_id, \
- this_arg_value, \
- arguments_list, \
- arguments_number); \
- }
-#include "ecma-builtins.inc.h"
-
- case ECMA_BUILTIN_ID__COUNT:
- {
- JERRY_UNREACHABLE ();
- }
-
- default:
- {
- JERRY_UNREACHABLE (); /* The built-in is not implemented. */
- }
- }
-
- JERRY_UNREACHABLE ();
+ JERRY_ASSERT (builtin_object_id < ECMA_BUILTIN_ID__COUNT);
+ return ecma_builtin_routines[builtin_object_id] (builtin_routine_id,
+ this_arg_value,
+ arguments_list_p,
+ arguments_list_len);
} /* ecma_builtin_dispatch_routine */
/**
}
else
{
- switch ((ecma_builtin_id_t) ext_obj_p->u.built_in.id)
- {
-#define BUILTIN(builtin_id, \
- object_type, \
- object_prototype_builtin_id, \
- is_extensible, \
- is_static, \
- lowercase_name) \
- case builtin_id: \
- { \
- if (object_type == ECMA_OBJECT_TYPE_FUNCTION) \
- { \
- ret_value = ecma_builtin_ ## lowercase_name ## _dispatch_call (arguments_list_p, \
- arguments_list_len); \
- } \
- break; \
- }
-#include "ecma-builtins.inc.h"
-
- case ECMA_BUILTIN_ID__COUNT:
- {
- JERRY_UNREACHABLE ();
- }
-
- default:
- {
- JERRY_UNREACHABLE (); /* The built-in is not implemented. */
- }
- }
+ ecma_builtin_id_t builtin_object_id = ext_obj_p->u.built_in.id;
+ JERRY_ASSERT (builtin_object_id < sizeof (ecma_builtin_call_functions) / sizeof (ecma_builtin_dispatch_call_t));
+ return ecma_builtin_call_functions[builtin_object_id] (arguments_list_p, arguments_list_len);
}
JERRY_ASSERT (!ecma_is_value_empty (ret_value));
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_FUNCTION);
JERRY_ASSERT (ecma_get_object_is_builtin (obj_p));
- ecma_value_t ret_value = ECMA_VALUE_EMPTY;
-
ecma_extended_object_t *ext_obj_p = (ecma_extended_object_t *) obj_p;
-
- switch (ext_obj_p->u.built_in.id)
- {
-#define BUILTIN(builtin_id, \
- object_type, \
- object_prototype_builtin_id, \
- is_extensible, \
- is_static, \
- lowercase_name) \
- case builtin_id: \
- { \
- if (object_type == ECMA_OBJECT_TYPE_FUNCTION) \
- { \
- ret_value = ecma_builtin_ ## lowercase_name ## _dispatch_construct (arguments_list_p, \
- arguments_list_len); \
- } \
- break; \
- }
-#include "ecma-builtins.inc.h"
-
- case ECMA_BUILTIN_ID__COUNT:
- {
- JERRY_UNREACHABLE ();
- }
-
- default:
- {
- JERRY_UNREACHABLE (); /* The built-in is not implemented. */
- }
- }
-
- JERRY_ASSERT (!ecma_is_value_empty (ret_value));
-
- return ret_value;
+ ecma_builtin_id_t builtin_object_id = ext_obj_p->u.built_in.id;
+ JERRY_ASSERT (builtin_object_id < sizeof (ecma_builtin_construct_functions) / sizeof (ecma_builtin_dispatch_call_t));
+ return ecma_builtin_construct_functions[builtin_object_id] (arguments_list_p, arguments_list_len);
} /* ecma_builtin_dispatch_construct */
/**
*/
typedef enum
{
+#define BUILTIN(a, b, c, d, e)
+#define BUILTIN_ROUTINE(builtin_id, \
+ object_type, \
+ object_prototype_builtin_id, \
+ is_extensible, \
+ lowercase_name) \
+ builtin_id,
+#include "ecma-builtins.inc.h"
+#undef BUILTIN
+#undef BUILTIN_ROUTINE
+#define BUILTIN_ROUTINE(a, b, c, d, e)
#define BUILTIN(builtin_id, \
object_type, \
object_prototype_builtin_id, \
is_extensible, \
- is_static, \
lowercase_name) \
builtin_id,
#include "ecma-builtins.inc.h"
+#undef BUILTIN
+#undef BUILTIN_ROUTINE
ECMA_BUILTIN_ID__COUNT /**< number of built-in objects */
} ecma_builtin_id_t;
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID__COUNT /* no prototype */,
true,
- true,
object_prototype)
/* The Object object (15.2.1) */
-BUILTIN (ECMA_BUILTIN_ID_OBJECT,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- object)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_OBJECT,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ object)
#ifndef CONFIG_DISABLE_ARRAY_BUILTIN
/* The Array.prototype object (15.4.4) */
ECMA_OBJECT_TYPE_ARRAY,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
array_prototype)
/* The Array object (15.4.1) */
-BUILTIN (ECMA_BUILTIN_ID_ARRAY,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- array)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_ARRAY,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ array)
#endif /* !CONFIG_DISABLE_ARRAY_BUILTIN*/
#ifndef CONFIG_DISABLE_STRING_BUILTIN
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
string_prototype)
/* The String object (15.5.1) */
-BUILTIN (ECMA_BUILTIN_ID_STRING,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- string)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_STRING,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ string)
#endif /* !CONFIG_DISABLE_STRING_BUILTIN */
#ifndef CONFIG_DISABLE_BOOLEAN_BUILTIN
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
boolean_prototype)
/* The Boolean object (15.6.1) */
-BUILTIN (ECMA_BUILTIN_ID_BOOLEAN,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- boolean)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_BOOLEAN,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ boolean)
#endif /* !CONFIG_DISABLE_BOOLEAN_BUILTIN */
#ifndef CONFIG_DISABLE_NUMBER_BUILTIN
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
number_prototype)
/* The Number object (15.7.1) */
-BUILTIN (ECMA_BUILTIN_ID_NUMBER,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- number)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_NUMBER,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ number)
#endif /* !CONFIG_DISABLE_NUMBER_BUILTIN */
/* The Function.prototype object (15.3.4) */
-BUILTIN (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
- true,
- true,
- function_prototype)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
+ true,
+ function_prototype)
/* The Function object (15.3.1) */
-BUILTIN (ECMA_BUILTIN_ID_FUNCTION,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- function)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_FUNCTION,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ function)
#ifndef CONFIG_DISABLE_MATH_BUILTIN
/* The Math object (15.8) */
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
math)
#endif /* !CONFIG_DISABLE_MATH_BUILTIN */
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
json)
#endif /* !CONFIG_DISABLE_JSON_BUILTIN */
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
date_prototype)
/* The Date object (15.9.3) */
-BUILTIN (ECMA_BUILTIN_ID_DATE,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- date)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_DATE,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ date)
#endif /* !CONFIG_DISABLE_DATE_BUILTIN */
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
ECMA_OBJECT_TYPE_CLASS,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
regexp_prototype)
/* The RegExp object (15.10) */
-BUILTIN (ECMA_BUILTIN_ID_REGEXP,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- regexp)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_REGEXP,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ regexp)
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
/* The Error object (15.11.1) */
-BUILTIN (ECMA_BUILTIN_ID_ERROR,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- error)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_ERROR,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ error)
/* The Error.prototype object (15.11.4) */
BUILTIN (ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
error_prototype)
#ifndef CONFIG_DISABLE_ERROR_BUILTINS
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
true,
- true,
eval_error_prototype)
/* The EvalError object (15.11.6.1) */
-BUILTIN (ECMA_BUILTIN_ID_EVAL_ERROR,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- eval_error)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_EVAL_ERROR,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ eval_error)
/* The RangeError.prototype object (15.11.6.2) */
BUILTIN (ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
true,
- true,
range_error_prototype)
/* The RangeError object (15.11.6.2) */
-BUILTIN (ECMA_BUILTIN_ID_RANGE_ERROR,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- range_error)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_RANGE_ERROR,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ range_error)
/* The ReferenceError.prototype object (15.11.6.3) */
BUILTIN (ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
true,
- true,
reference_error_prototype)
/* The ReferenceError object (15.11.6.3) */
-BUILTIN (ECMA_BUILTIN_ID_REFERENCE_ERROR,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- reference_error)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_REFERENCE_ERROR,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ reference_error)
/* The SyntaxError.prototype object (15.11.6.4) */
BUILTIN (ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
true,
- true,
syntax_error_prototype)
/* The SyntaxError object (15.11.6.4) */
-BUILTIN (ECMA_BUILTIN_ID_SYNTAX_ERROR,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- syntax_error)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_SYNTAX_ERROR,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ syntax_error)
/* The TypeError.prototype object (15.11.6.5) */
BUILTIN (ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
true,
- true,
type_error_prototype)
/* The TypeError object (15.11.6.5) */
-BUILTIN (ECMA_BUILTIN_ID_TYPE_ERROR,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- type_error)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_TYPE_ERROR,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ type_error)
/* The URIError.prototype object (15.11.6.6) */
BUILTIN (ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
true,
- true,
uri_error_prototype)
/* The URIError object (15.11.6.6) */
-BUILTIN (ECMA_BUILTIN_ID_URI_ERROR,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- uri_error)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_URI_ERROR,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ uri_error)
#endif /* !CONFIG_DISABLE_ERROR_BUILTINS */
/**< The [[ThrowTypeError]] object (13.2.3) */
-BUILTIN (ECMA_BUILTIN_ID_TYPE_ERROR_THROWER,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- false,
- true,
- type_error_thrower)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_TYPE_ERROR_THROWER,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ false,
+ type_error_thrower)
#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
arraybuffer_prototype)
/* The ArrayBuffer object (ES2015 24.1.2) */
-BUILTIN (ECMA_BUILTIN_ID_ARRAYBUFFER,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- arraybuffer)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_ARRAYBUFFER,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ arraybuffer)
/* The %TypedArrayPrototype% object (ES2015 24.2.3) */
BUILTIN (ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
typedarray_prototype)
/* The %TypedArray% intrinsic object (ES2015 22.2.1) */
-BUILTIN (ECMA_BUILTIN_ID_TYPEDARRAY,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- typedarray)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_TYPEDARRAY,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ typedarray)
BUILTIN (ECMA_BUILTIN_ID_INT8ARRAY_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
true,
- true,
int8array_prototype)
-BUILTIN (ECMA_BUILTIN_ID_INT8ARRAY,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_TYPEDARRAY,
- true,
- true,
- int8array)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_INT8ARRAY,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_TYPEDARRAY,
+ true,
+ int8array)
BUILTIN (ECMA_BUILTIN_ID_UINT8ARRAY_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
true,
- true,
uint8array_prototype)
-BUILTIN (ECMA_BUILTIN_ID_UINT8ARRAY,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_TYPEDARRAY,
- true,
- true,
- uint8array)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_UINT8ARRAY,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_TYPEDARRAY,
+ true,
+ uint8array)
BUILTIN (ECMA_BUILTIN_ID_INT16ARRAY_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
true,
- true,
int16array_prototype)
-BUILTIN (ECMA_BUILTIN_ID_INT16ARRAY,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_TYPEDARRAY,
- true,
- true,
- int16array)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_INT16ARRAY,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_TYPEDARRAY,
+ true,
+ int16array)
BUILTIN (ECMA_BUILTIN_ID_UINT16ARRAY_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
true,
- true,
uint16array_prototype)
-BUILTIN (ECMA_BUILTIN_ID_UINT16ARRAY,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_TYPEDARRAY,
- true,
- true,
- uint16array)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_UINT16ARRAY,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_TYPEDARRAY,
+ true,
+ uint16array)
BUILTIN (ECMA_BUILTIN_ID_INT32ARRAY_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
true,
- true,
int32array_prototype)
-BUILTIN (ECMA_BUILTIN_ID_INT32ARRAY,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_TYPEDARRAY,
- true,
- true,
- int32array)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_INT32ARRAY,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_TYPEDARRAY,
+ true,
+ int32array)
BUILTIN (ECMA_BUILTIN_ID_UINT32ARRAY_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
true,
- true,
uint32array_prototype)
-BUILTIN (ECMA_BUILTIN_ID_UINT32ARRAY,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_TYPEDARRAY,
- true,
- true,
- uint32array)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_UINT32ARRAY,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_TYPEDARRAY,
+ true,
+ uint32array)
BUILTIN (ECMA_BUILTIN_ID_FLOAT32ARRAY_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
true,
- true,
float32array_prototype)
-BUILTIN (ECMA_BUILTIN_ID_FLOAT32ARRAY,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_TYPEDARRAY,
- true,
- true,
- float32array)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_FLOAT32ARRAY,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_TYPEDARRAY,
+ true,
+ float32array)
#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64
BUILTIN (ECMA_BUILTIN_ID_FLOAT64ARRAY_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
true,
- true,
float64array_prototype)
-BUILTIN (ECMA_BUILTIN_ID_FLOAT64ARRAY,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_TYPEDARRAY,
- true,
- true,
- float64array)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_FLOAT64ARRAY,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_TYPEDARRAY,
+ true,
+ float64array)
#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 */
BUILTIN (ECMA_BUILTIN_ID_UINT8CLAMPEDARRAY_PROTOTYPE,
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_TYPEDARRAY_PROTOTYPE,
true,
- true,
uint8clampedarray_prototype)
-BUILTIN (ECMA_BUILTIN_ID_UINT8CLAMPEDARRAY,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_TYPEDARRAY,
- true,
- true,
- uint8clampedarray)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_UINT8CLAMPEDARRAY,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_TYPEDARRAY,
+ true,
+ uint8clampedarray)
#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
true,
- true,
promise_prototype)
-BUILTIN (ECMA_BUILTIN_ID_PROMISE,
- ECMA_OBJECT_TYPE_FUNCTION,
- ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
- true,
- true,
- promise)
+BUILTIN_ROUTINE (ECMA_BUILTIN_ID_PROMISE,
+ ECMA_OBJECT_TYPE_FUNCTION,
+ ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
+ true,
+ promise)
#endif /* !CONFIG_DISABLE_ES2015_PROMISE_BUILTIN */
ECMA_OBJECT_TYPE_GENERAL,
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, /* Implementation-dependent */
true,
- true,
global)
#undef BUILTIN
while (k < source_length_uint32 && ecma_is_value_empty (ret_val))
{
- ecma_string_t k_str;
- ecma_init_ecma_string_from_uint32 (&k_str, k);
+ ecma_string_t *k_str_p = ecma_new_ecma_string_from_uint32 (k);
ECMA_TRY_CATCH (elem,
- ecma_op_object_get (source_obj_p, &k_str),
+ ecma_op_object_get (source_obj_p, k_str_p),
ret_val);
ECMA_OP_TO_NUMBER_TRY_CATCH (elem_num, elem, ret_val);
ECMA_OP_TO_NUMBER_FINALIZE (elem_num);
ECMA_FINALIZE (elem);
+ ecma_deref_ecma_string (k_str_p);
+
k++;
target_byte_index += element_size;
}
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
- ecma_string_t *length_str_p = ecma_new_ecma_length_string ();
- ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (length_str_p), true);
- ecma_deref_ecma_string (length_str_p);
+ ecma_append_to_values_collection (for_non_enumerable_p,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH),
+ 0);
} /* ecma_op_array_list_lazy_property_names */
/**
ECMA_OBJECT_TYPE_CLASS);
ecma_deref_object (prototype_obj_p);
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
+ ext_object_p->u.class_prop.extra_info = ECMA_ARRAYBUFFER_INTERNAL_MEMORY;
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_ARRAY_BUFFER_UL;
ext_object_p->u.class_prop.u.length = length;
} /* ecma_arraybuffer_new_object */
/**
+ * Helper function: create arraybuffer object with external buffer backing.
+ *
+ * The struct of external arraybuffer object:
+ * ecma_object_t
+ * extend_part
+ * arraybuffer external info part
+ *
+ * @return ecma_object_t *, pointer to the created ArrayBuffer object
+ */
+ecma_object_t *
+ecma_arraybuffer_new_object_external (ecma_length_t length, /**< length of the buffer_p to use */
+ void *buffer_p, /**< pointer for ArrayBuffer's buffer backing */
+ ecma_object_native_free_callback_t free_cb) /**< buffer free callback */
+{
+ ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE);
+ ecma_object_t *object_p = ecma_create_object (prototype_obj_p,
+ sizeof (ecma_arraybuffer_external_info),
+ ECMA_OBJECT_TYPE_CLASS);
+ ecma_deref_object (prototype_obj_p);
+ ecma_arraybuffer_external_info *array_object_p = (ecma_arraybuffer_external_info *) object_p;
+ array_object_p->extended_object.u.class_prop.extra_info = ECMA_ARRAYBUFFER_EXTERNAL_MEMORY;
+ array_object_p->extended_object.u.class_prop.class_id = LIT_MAGIC_STRING_ARRAY_BUFFER_UL;
+ array_object_p->extended_object.u.class_prop.u.length = length;
+
+ array_object_p->buffer_p = buffer_p;
+ array_object_p->free_cb = free_cb;
+
+ return object_p;
+} /* ecma_arraybuffer_new_object_external */
+
+
+/**
* ArrayBuffer object creation operation.
*
* See also: ES2015 24.1.1.1
JERRY_ASSERT (ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL));
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
- return (lit_utf8_byte_t *) (ext_object_p + 1);
+
+ if (ECMA_ARRAYBUFFER_HAS_EXTERNAL_MEMORY (ext_object_p))
+ {
+ ecma_arraybuffer_external_info *array_p = (ecma_arraybuffer_external_info *) ext_object_p;
+ return (lit_utf8_byte_t *) array_p->buffer_p;
+ }
+ else
+ {
+ return (lit_utf8_byte_t *) (ext_object_p + 1);
+ }
} /* ecma_arraybuffer_get_buffer */
/**
*/
ecma_object_t *
ecma_arraybuffer_new_object (ecma_length_t lengh);
+ecma_object_t *
+ecma_arraybuffer_new_object_external (ecma_length_t length,
+ void *buffer_p,
+ ecma_object_native_free_callback_t free_cb);
lit_utf8_byte_t *
ecma_arraybuffer_get_buffer (ecma_object_t *obj_p) __attr_pure___;
ecma_length_t
{
return value;
}
- else if (ecma_is_value_float_number (value))
+
+ if (ecma_is_value_float_number (value))
{
return ecma_copy_value (value);
}
- else if (ecma_is_value_string (value))
+
+ if (ecma_is_value_string (value))
{
ecma_string_t *str_p = ecma_get_string_from_value (value);
return ecma_make_number_value (ecma_string_to_number (str_p));
}
- else if (ecma_is_value_object (value))
+
+ if (ecma_is_value_object (value))
{
- ecma_value_t ret_value = ECMA_VALUE_EMPTY;
+ ecma_value_t primitive_value = ecma_op_to_primitive (value, ECMA_PREFERRED_TYPE_NUMBER);
- ECMA_TRY_CATCH (primitive_value,
- ecma_op_to_primitive (value, ECMA_PREFERRED_TYPE_NUMBER),
- ret_value);
+ if (ECMA_IS_VALUE_ERROR (primitive_value))
+ {
+ return primitive_value;
+ }
- ret_value = ecma_op_to_number (primitive_value);
+ ecma_value_t ret_value = ecma_op_to_number (primitive_value);
+ ecma_fast_free_value (primitive_value);
+ return ret_value;
+ }
- ECMA_FINALIZE (primitive_value);
+ if (ecma_is_value_undefined (value))
+ {
+ return ecma_make_nan_value ();
+ }
- return ret_value;
+ ecma_integer_value_t num = 0;
+
+ if (ecma_is_value_null (value))
+ {
+ num = 0;
}
else
{
- int16_t num = 0;
+ JERRY_ASSERT (ecma_is_value_boolean (value));
- if (ecma_is_value_undefined (value))
- {
- return ecma_make_nan_value ();
- }
- else if (ecma_is_value_null (value))
+ num = ecma_is_value_true (value) ? 1 : 0;
+ }
+
+ return ecma_make_integer_value (num);
+} /* ecma_op_to_number */
+
+/**
+ * Helper to get the number contained in an ecma value.
+ *
+ * See also:
+ * ECMA-262 v5, 9.3
+ *
+ * @return ECMA_VALUE_EMPTY if successful
+ * conversion error otherwise
+ * Returned value must be freed with ecma_free_value
+ */
+ecma_value_t
+ecma_get_number (ecma_value_t value, ecma_number_t *number_p)
+{
+ if (ecma_is_value_integer_number (value))
+ {
+ *number_p = ecma_get_integer_from_value (value);
+ return ECMA_VALUE_EMPTY;
+ }
+
+ if (ecma_is_value_float_number (value))
+ {
+ *number_p = ecma_get_float_from_value (value);
+ return ECMA_VALUE_EMPTY;
+ }
+
+ if (ecma_is_value_string (value))
+ {
+ ecma_string_t *str_p = ecma_get_string_from_value (value);
+ *number_p = ecma_string_to_number (str_p);
+ return ECMA_VALUE_EMPTY;
+ }
+
+ if (ecma_is_value_object (value))
+ {
+ ecma_value_t primitive_value = ecma_op_to_primitive (value, ECMA_PREFERRED_TYPE_NUMBER);
+
+ if (ECMA_IS_VALUE_ERROR (primitive_value))
{
- num = 0;
+ return primitive_value;
}
- else
- {
- JERRY_ASSERT (ecma_is_value_boolean (value));
- if (ecma_is_value_true (value))
- {
- num = 1;
- }
- else
- {
- num = 0;
- }
- }
+ ecma_value_t ret_value = ecma_get_number (primitive_value, number_p);
+ ecma_fast_free_value (primitive_value);
+ return ret_value;
+ }
- return ecma_make_integer_value (num);
+ if (ecma_is_value_undefined (value))
+ {
+ *number_p = ecma_number_make_nan ();
+ return ECMA_VALUE_EMPTY;
}
-} /* ecma_op_to_number */
+
+ if (ecma_is_value_null (value))
+ {
+ *number_p = 0;
+ return ECMA_VALUE_EMPTY;
+ }
+
+ JERRY_ASSERT (ecma_is_value_boolean (value));
+
+ *number_p = ecma_is_value_true (value) ? 1 : 0;
+ return ECMA_VALUE_EMPTY;
+} /* ecma_get_number */
/**
* ToString operation.
/* a. */
prop_desc.value = src_prop_desc_p->value;
- ecma_string_t *value_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_VALUE);
completion = ecma_op_object_define_own_property (obj_p,
- value_magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_VALUE),
&prop_desc,
false);
- ecma_deref_ecma_string (value_magic_string_p);
JERRY_ASSERT (ecma_is_value_true (completion));
/* b. */
const bool is_writable = (src_prop_desc_p->is_writable);
prop_desc.value = ecma_make_boolean_value (is_writable);
- ecma_string_t *writable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE);
completion = ecma_op_object_define_own_property (obj_p,
- writable_magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE),
&prop_desc,
false);
- ecma_deref_ecma_string (writable_magic_string_p);
JERRY_ASSERT (ecma_is_value_true (completion));
}
else
prop_desc.value = ecma_make_object_value (src_prop_desc_p->get_p);
}
- ecma_string_t *get_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GET);
completion = ecma_op_object_define_own_property (obj_p,
- get_magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_GET),
&prop_desc,
false);
- ecma_deref_ecma_string (get_magic_string_p);
JERRY_ASSERT (ecma_is_value_true (completion));
/* b. */
prop_desc.value = ecma_make_object_value (src_prop_desc_p->set_p);
}
- ecma_string_t *set_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_SET);
completion = ecma_op_object_define_own_property (obj_p,
- set_magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_SET),
&prop_desc,
false);
- ecma_deref_ecma_string (set_magic_string_p);
JERRY_ASSERT (ecma_is_value_true (completion));
}
const bool is_enumerable = src_prop_desc_p->is_enumerable;
prop_desc.value = ecma_make_boolean_value (is_enumerable);
- ecma_string_t *enumerable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE);
completion = ecma_op_object_define_own_property (obj_p,
- enumerable_magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE),
&prop_desc,
false);
- ecma_deref_ecma_string (enumerable_magic_string_p);
JERRY_ASSERT (ecma_is_value_true (completion));
const bool is_configurable = src_prop_desc_p->is_configurable;
prop_desc.value = ecma_make_boolean_value (is_configurable);
- ecma_string_t *configurable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE);
completion = ecma_op_object_define_own_property (obj_p,
- configurable_magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE),
&prop_desc,
false);
- ecma_deref_ecma_string (configurable_magic_string_p);
JERRY_ASSERT (ecma_is_value_true (completion));
return obj_p;
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
/* 3. */
- ecma_string_t *enumerable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE);
-
ECMA_TRY_CATCH (enumerable_prop_value,
- ecma_op_object_find (obj_p, enumerable_magic_string_p),
+ ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE)),
ret_value);
if (ecma_is_value_found (enumerable_prop_value))
ECMA_FINALIZE (enumerable_prop_value);
- ecma_deref_ecma_string (enumerable_magic_string_p);
-
if (!ECMA_IS_VALUE_ERROR (ret_value))
{
JERRY_ASSERT (ecma_is_value_empty (ret_value));
/* 4. */
- ecma_string_t *configurable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE);
-
ECMA_TRY_CATCH (configurable_prop_value,
- ecma_op_object_find (obj_p, configurable_magic_string_p),
+ ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE)),
ret_value);
if (ecma_is_value_found (configurable_prop_value))
}
ECMA_FINALIZE (configurable_prop_value);
-
- ecma_deref_ecma_string (configurable_magic_string_p);
}
if (!ECMA_IS_VALUE_ERROR (ret_value))
JERRY_ASSERT (ecma_is_value_empty (ret_value));
/* 5. */
- ecma_string_t *value_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_VALUE);
-
ECMA_TRY_CATCH (value_prop_value,
- ecma_op_object_find (obj_p, value_magic_string_p),
+ ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_VALUE)),
ret_value);
if (ecma_is_value_found (value_prop_value))
}
ECMA_FINALIZE (value_prop_value);
-
- ecma_deref_ecma_string (value_magic_string_p);
}
if (!ECMA_IS_VALUE_ERROR (ret_value))
JERRY_ASSERT (ecma_is_value_empty (ret_value));
/* 6. */
- ecma_string_t *writable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE);
-
ECMA_TRY_CATCH (writable_prop_value,
- ecma_op_object_find (obj_p, writable_magic_string_p),
+ ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE)),
ret_value);
if (ecma_is_value_found (writable_prop_value))
}
ECMA_FINALIZE (writable_prop_value);
-
- ecma_deref_ecma_string (writable_magic_string_p);
}
if (!ECMA_IS_VALUE_ERROR (ret_value))
JERRY_ASSERT (ecma_is_value_empty (ret_value));
/* 7. */
- ecma_string_t *get_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GET);
-
ECMA_TRY_CATCH (get_prop_value,
- ecma_op_object_find (obj_p, get_magic_string_p),
+ ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_GET)),
ret_value);
if (ecma_is_value_found (get_prop_value))
}
ECMA_FINALIZE (get_prop_value);
-
- ecma_deref_ecma_string (get_magic_string_p);
}
if (!ECMA_IS_VALUE_ERROR (ret_value))
JERRY_ASSERT (ecma_is_value_empty (ret_value));
/* 8. */
- ecma_string_t *set_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_SET);
-
ECMA_TRY_CATCH (set_prop_value,
- ecma_op_object_find (obj_p, set_magic_string_p),
+ ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_SET)),
ret_value);
if (ecma_is_value_found (set_prop_value))
}
ECMA_FINALIZE (set_prop_value);
-
- ecma_deref_ecma_string (set_magic_string_p);
}
if (!ECMA_IS_VALUE_ERROR (ret_value))
ecma_value_t ecma_op_to_primitive (ecma_value_t value, ecma_preferred_type_hint_t preferred_type);
bool ecma_op_to_boolean (ecma_value_t value);
ecma_value_t ecma_op_to_number (ecma_value_t value);
+ecma_value_t ecma_get_number (ecma_value_t value, ecma_number_t *number_p);
ecma_value_t ecma_op_to_string (ecma_value_t value);
ecma_value_t ecma_op_to_object (ecma_value_t value);
#include "js-parser.h"
#include "vm.h"
+#ifdef JERRY_ENABLE_LINE_INFO
+#include "jcontext.h"
+#endif /* JERRY_ENABLE_LINE_INFO */
+
/** \addtogroup ecma ECMA
* @{
*
bool is_strict_call = (is_direct && is_called_from_strict_mode_code);
+#ifdef JERRY_ENABLE_LINE_INFO
+ JERRY_CONTEXT (resource_name) = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
+#endif /* JERRY_ENABLE_LINE_INFO */
+
ecma_value_t parse_status = parser_parse_script (NULL,
0,
code_p,
#include "jcontext.h"
#include "jrt.h"
+#ifdef JERRY_ENABLE_LINE_INFO
+#include "vm.h"
+#endif /* JERRY_ENABLE_LINE_INFO */
+
/** \addtogroup ecma ECMA
* @{
*
* \addtogroup exceptions Exceptions
* @{
*/
+typedef struct
+{
+ ecma_standard_error_t error_type;
+ ecma_builtin_id_t error_prototype_id;
+} ecma_error_mapping_t;
+
+const ecma_error_mapping_t ecma_error_mappings[] =
+{
+#define ERROR_ELEMENT(TYPE, ID) { TYPE, ID }
+ ERROR_ELEMENT (ECMA_ERROR_COMMON, ECMA_BUILTIN_ID_ERROR_PROTOTYPE),
+
+#ifndef CONFIG_DISABLE_ERROR_BUILTINS
+ ERROR_ELEMENT (ECMA_ERROR_EVAL, ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE),
+ ERROR_ELEMENT (ECMA_ERROR_RANGE, ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE),
+ ERROR_ELEMENT (ECMA_ERROR_REFERENCE, ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE),
+ ERROR_ELEMENT (ECMA_ERROR_TYPE, ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE),
+ ERROR_ELEMENT (ECMA_ERROR_URI, ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE),
+ ERROR_ELEMENT (ECMA_ERROR_SYNTAX, ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE),
+#endif /* !CONFIG_DISABLE_ERROR_BUILTINS */
+
+#undef ERROR_ELEMENT
+};
/**
* Standard ecma-error object constructor.
*
+ * Note:
+ * calling with ECMA_ERROR_NONE does not make sense thus it will
+ * cause a fault in the system.
+ *
* @return pointer to ecma-object representing specified error
* with reference counter set to one.
*/
prototype_id = ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE;
break;
}
+
+ case ECMA_ERROR_NONE:
+ {
+ JERRY_UNREACHABLE ();
+ break;
+ }
}
#else
JERRY_UNUSED (error_type);
((ecma_extended_object_t *) new_error_obj_p)->u.class_prop.class_id = LIT_MAGIC_STRING_ERROR_UL;
+#ifdef JERRY_ENABLE_LINE_INFO
+ /* The "stack" identifier is not a magic string. */
+ const char *stack_id_p = "stack";
+
+ ecma_string_t *stack_str_p = ecma_new_ecma_string_from_utf8 ((const lit_utf8_byte_t *) stack_id_p, 5);
+
+ ecma_property_value_t *prop_value_p = ecma_create_named_data_property (new_error_obj_p,
+ stack_str_p,
+ ECMA_PROPERTY_CONFIGURABLE_WRITABLE,
+ NULL);
+ ecma_deref_ecma_string (stack_str_p);
+
+ ecma_value_t backtrace_value = vm_get_backtrace (0);
+
+ prop_value_p->value = backtrace_value;
+ ecma_deref_object (ecma_get_object_from_value (backtrace_value));
+#endif /* JERRY_ENABLE_LINE_INFO */
+
return new_error_obj_p;
} /* ecma_new_standard_error */
/**
+ * Return the error type for an Error object.
+ *
+ * @return one of the ecma_standard_error_t value
+ * if it is not an Error object then ECMA_ERROR_NONE will be returned
+ */
+ecma_standard_error_t
+ecma_get_error_type (ecma_object_t *error_object) /**< possible error object */
+{
+ ecma_object_t *prototype_p = ecma_get_object_prototype (error_object);
+ if (prototype_p != NULL)
+ {
+ uint8_t builtin_id = ecma_get_object_builtin_id (prototype_p);
+
+ for (uint8_t idx = 0; idx < sizeof (ecma_error_mappings) / sizeof (ecma_error_mappings[0]); idx++)
+ {
+ if (ecma_error_mappings[idx].error_prototype_id == builtin_id)
+ {
+ return ecma_error_mappings[idx].error_type;
+ }
+ }
+ }
+
+ return ECMA_ERROR_NONE;
+} /* ecma_get_error_type */
+
+/**
* Standard ecma-error object constructor.
*
* @return pointer to ecma-object representing specified error
{
ecma_object_t *new_error_obj_p = ecma_new_standard_error (error_type);
- ecma_string_t *message_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE);
-
ecma_property_value_t *prop_value_p;
prop_value_p = ecma_create_named_data_property (new_error_obj_p,
- message_magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE),
ECMA_PROPERTY_CONFIGURABLE_WRITABLE,
NULL);
- ecma_deref_ecma_string (message_magic_string_p);
ecma_ref_ecma_string (message_string_p);
prop_value_p->value = ecma_make_string_value (message_string_p);
}
JERRY_CONTEXT (error_value) = ecma_make_object_value (error_obj_p);
+ JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
return ECMA_VALUE_ERROR;
} /* ecma_raise_standard_error */
/* Convert an argument to string without side effects. */
ecma_string_t *arg_string_p;
const ecma_value_t arg_val = va_arg (args, ecma_value_t);
+
if (unlikely (ecma_is_value_object (arg_val)))
{
ecma_object_t *arg_object_p = ecma_get_object_from_value (arg_val);
ecma_deref_ecma_string (error_msg_p);
JERRY_CONTEXT (error_value) = ecma_make_object_value (error_obj_p);
+ JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
return ECMA_VALUE_ERROR;
} /* ecma_raise_standard_error_with_format */
*/
typedef enum
{
+ ECMA_ERROR_NONE, /**< Not an Error */
+
ECMA_ERROR_COMMON, /**< Error */
ECMA_ERROR_EVAL, /**< EvalError */
ECMA_ERROR_RANGE, /**< RangeError */
ECMA_ERROR_URI /**< URIError */
} ecma_standard_error_t;
+ecma_standard_error_t ecma_get_error_type (ecma_object_t *error_object);
ecma_object_t *ecma_new_standard_error (ecma_standard_error_t error_type);
ecma_object_t *ecma_new_standard_error_with_message (ecma_standard_error_t error_type, ecma_string_t *message_string_p);
ecma_value_t ecma_raise_standard_error (ecma_standard_error_t error_type, const lit_utf8_byte_t *msg_p);
/* 1., 4., 13. */
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
+ size_t function_object_size = sizeof (ecma_extended_object_t);
+
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+ if (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION)
+ {
+ function_object_size = sizeof (ecma_static_function_t);
+ }
+#endif
+
ecma_object_t *func_p = ecma_create_object (prototype_obj_p,
- sizeof (ecma_extended_object_t),
+ function_object_size,
ECMA_OBJECT_TYPE_FUNCTION);
ecma_deref_object (prototype_obj_p);
ECMA_SET_INTERNAL_VALUE_POINTER (ext_func_p->u.function.scope_cp, scope_p);
/* 10., 11., 12. */
+
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+ if (!(bytecode_data_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
+ {
+ ECMA_SET_INTERNAL_VALUE_POINTER (ext_func_p->u.function.bytecode_cp, bytecode_data_p);
+ ecma_bytecode_ref ((ecma_compiled_code_t *) bytecode_data_p);
+ }
+ else
+ {
+ ext_func_p->u.function.bytecode_cp = ECMA_NULL_POINTER;
+ ((ecma_static_function_t *) func_p)->bytecode_p = bytecode_data_p;
+ }
+#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
ECMA_SET_INTERNAL_VALUE_POINTER (ext_func_p->u.function.bytecode_cp, bytecode_data_p);
ecma_bytecode_ref ((ecma_compiled_code_t *) bytecode_data_p);
+#endif
/* 14., 15., 16., 17., 18. */
/*
{
ecma_object_t *prototype_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE);
+ size_t arrow_function_object_size = sizeof (ecma_arrow_function_t);
+
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+ if (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION)
+ {
+ arrow_function_object_size = sizeof (ecma_static_arrow_function_t);
+ }
+#endif
+
ecma_object_t *func_p = ecma_create_object (prototype_obj_p,
- sizeof (ecma_arrow_function_t),
+ arrow_function_object_size,
ECMA_OBJECT_TYPE_ARROW_FUNCTION);
ecma_deref_object (prototype_obj_p);
ECMA_SET_NON_NULL_POINTER (arrow_func_p->scope_cp, scope_p);
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+ if (!(bytecode_data_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
+ {
+ ECMA_SET_NON_NULL_POINTER (arrow_func_p->bytecode_cp, bytecode_data_p);
+ ecma_bytecode_ref ((ecma_compiled_code_t *) bytecode_data_p);
+ }
+ else
+ {
+ arrow_func_p->bytecode_cp = ECMA_NULL_POINTER;
+ ((ecma_static_arrow_function_t *) func_p)->bytecode_p = bytecode_data_p;
+ }
+#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
ECMA_SET_NON_NULL_POINTER (arrow_func_p->bytecode_cp, bytecode_data_p);
ecma_bytecode_ref ((ecma_compiled_code_t *) bytecode_data_p);
+#endif
arrow_func_p->this_binding = ecma_copy_value_if_not_object (this_binding);
return func_p;
} /* ecma_op_create_external_function_object */
/**
+ * Get compiled code of a function object.
+ *
+ * @return compiled code
+ */
+inline const ecma_compiled_code_t * __attr_always_inline___
+ecma_op_function_get_compiled_code (ecma_extended_object_t *function_p) /**< function pointer */
+{
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+ if (function_p->u.function.bytecode_cp != ECMA_NULL_POINTER)
+ {
+ return ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t,
+ function_p->u.function.bytecode_cp);
+ }
+ else
+ {
+ return ((ecma_static_function_t *) function_p)->bytecode_p;
+ }
+#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
+ return ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t,
+ function_p->u.function.bytecode_cp);
+#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
+} /* ecma_op_function_get_compiled_code */
+
+#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
+
+/**
+ * Get compiled code of an arrow function object.
+ *
+ * @return compiled code
+ */
+inline const ecma_compiled_code_t * __attr_always_inline___
+ecma_op_arrow_function_get_compiled_code (ecma_arrow_function_t *arrow_function_p) /**< arrow function pointer */
+{
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+ if (arrow_function_p->bytecode_cp != ECMA_NULL_POINTER)
+ {
+ return ECMA_GET_NON_NULL_POINTER (const ecma_compiled_code_t,
+ arrow_function_p->bytecode_cp);
+ }
+ else
+ {
+ return ((ecma_static_arrow_function_t *) arrow_function_p)->bytecode_p;
+ }
+#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
+ return ECMA_GET_NON_NULL_POINTER (const ecma_compiled_code_t,
+ arrow_function_p->bytecode_cp);
+#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
+} /* ecma_op_arrow_function_get_compiled_code */
+
+#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
+
+/**
* [[Call]] implementation for Function objects,
* created through 13.2 (ECMA_OBJECT_TYPE_FUNCTION)
* or 15.3.4.5 (ECMA_OBJECT_TYPE_BOUND_FUNCTION),
bool is_strict;
bool is_no_lex_env;
- const ecma_compiled_code_t *bytecode_data_p;
- bytecode_data_p = ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t,
- ext_func_p->u.function.bytecode_cp);
+ const ecma_compiled_code_t *bytecode_data_p = ecma_op_function_get_compiled_code (ext_func_p);
is_strict = (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE) ? true : false;
is_no_lex_env = (bytecode_data_p->status_flags & CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED) ? true : false;
bool is_no_lex_env;
- const ecma_compiled_code_t *bytecode_data_p;
- bytecode_data_p = ECMA_GET_NON_NULL_POINTER (const ecma_compiled_code_t,
- arrow_func_p->bytecode_cp);
+ const ecma_compiled_code_t *bytecode_data_p = ecma_op_arrow_function_get_compiled_code (arrow_func_p);
is_no_lex_env = (bytecode_data_p->status_flags & CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED) ? true : false;
if (unlikely (ecma_is_value_error_reference (ret_value)))
{
- JERRY_CONTEXT (error_value) = ecma_clear_error_reference (ret_value);
+ JERRY_CONTEXT (error_value) = ecma_clear_error_reference (ret_value, true);
ret_value = ECMA_VALUE_ERROR;
}
+ else
+ {
+#ifdef JERRY_DEBUGGER
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_EXCEPTION_THROWN);
+#endif /* JERRY_DEBUGGER */
+ }
}
else
{
JERRY_ASSERT (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
- JERRY_CONTEXT (is_direct_eval_form_call) = false;
+ JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_DIRECT_EVAL;
/* 2-3. */
ecma_extended_object_t *ext_function_p = (ecma_extended_object_t *) func_obj_p;
ecma_object_t *proto_object_p = ecma_op_create_object_object_noarg ();
/* 17. */
- ecma_string_t magic_string_constructor;
- ecma_init_ecma_magic_string (&magic_string_constructor, LIT_MAGIC_STRING_CONSTRUCTOR);
+ ecma_string_t *magic_string_constructor_p = ecma_get_magic_string (LIT_MAGIC_STRING_CONSTRUCTOR);
ecma_property_value_t *constructor_prop_value_p;
constructor_prop_value_p = ecma_create_named_data_property (proto_object_p,
- &magic_string_constructor,
+ magic_string_constructor_p,
ECMA_PROPERTY_CONFIGURABLE_WRITABLE,
NULL);
if (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_ARROW_FUNCTION)
{
ecma_arrow_function_t *arrow_func_p = (ecma_arrow_function_t *) object_p;
- bytecode_data_p = ECMA_GET_NON_NULL_POINTER (const ecma_compiled_code_t,
- arrow_func_p->bytecode_cp);
+ bytecode_data_p = ecma_op_arrow_function_get_compiled_code (arrow_func_p);
}
else
{
#endif /* CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
- bytecode_data_p = ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t,
- ext_func_p->u.function.bytecode_cp);
+ bytecode_data_p = ecma_op_function_get_compiled_code (ext_func_p);
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
}
#endif /* CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
/* 'length' property is non-enumerable (ECMA-262 v5, 13.2.5) */
- ecma_string_t *name_p = ecma_new_ecma_length_string ();
- ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (name_p), true);
- ecma_deref_ecma_string (name_p);
+ ecma_append_to_values_collection (for_non_enumerable_p,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH),
+ 0);
/* 'prototype' property is non-enumerable (ECMA-262 v5, 13.2.18) */
- name_p = ecma_get_magic_string (LIT_MAGIC_STRING_PROTOTYPE);
- ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (name_p), true);
- ecma_deref_ecma_string (name_p);
-
- ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
+ ecma_append_to_values_collection (for_non_enumerable_p,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING_PROTOTYPE),
+ 0);
const ecma_compiled_code_t *bytecode_data_p;
- bytecode_data_p = ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t,
- ext_func_p->u.function.bytecode_cp);
+ bytecode_data_p = ecma_op_function_get_compiled_code ((ecma_extended_object_t *) object_p);
if (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE)
{
/* 'caller' property is non-enumerable (ECMA-262 v5, 13.2.5) */
- name_p = ecma_get_magic_string (LIT_MAGIC_STRING_CALLER);
- ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (name_p), true);
- ecma_deref_ecma_string (name_p);
+ ecma_append_to_values_collection (for_non_enumerable_p,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER),
+ 0);
/* 'arguments' property is non-enumerable (ECMA-262 v5, 13.2.5) */
- name_p = ecma_get_magic_string (LIT_MAGIC_STRING_ARGUMENTS);
- ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (name_p), true);
- ecma_deref_ecma_string (name_p);
+ ecma_append_to_values_collection (for_non_enumerable_p,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING_ARGUMENTS),
+ 0);
}
} /* ecma_op_function_list_lazy_property_names */
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
/* 'prototype' property is non-enumerable (ECMA-262 v5, 13.2.18) */
- ecma_string_t *name_p = ecma_get_magic_string (LIT_MAGIC_STRING_PROTOTYPE);
- ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (name_p), true);
- ecma_deref_ecma_string (name_p);
+ ecma_append_to_values_collection (for_non_enumerable_p,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING_PROTOTYPE),
+ 0);
} /* ecma_op_external_function_list_lazy_property_names */
/**
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
/* 'length' property is non-enumerable (ECMA-262 v5, 13.2.5) */
- ecma_string_t *name_p = ecma_new_ecma_length_string ();
- ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (name_p), true);
- ecma_deref_ecma_string (name_p);
+ ecma_append_to_values_collection (for_non_enumerable_p,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH),
+ 0);
/* 'caller' property is non-enumerable (ECMA-262 v5, 13.2.5) */
- name_p = ecma_get_magic_string (LIT_MAGIC_STRING_CALLER);
- ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (name_p), true);
- ecma_deref_ecma_string (name_p);
+ ecma_append_to_values_collection (for_non_enumerable_p,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING_CALLER),
+ 0);
/* 'arguments' property is non-enumerable (ECMA-262 v5, 13.2.5) */
- name_p = ecma_get_magic_string (LIT_MAGIC_STRING_ARGUMENTS);
- ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (name_p), true);
- ecma_deref_ecma_string (name_p);
+ ecma_append_to_values_collection (for_non_enumerable_p,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING_ARGUMENTS),
+ 0);
} /* ecma_op_bound_function_list_lazy_property_names */
/**
ecma_object_t *
ecma_op_create_external_function_object (ecma_external_handler_t handler_cb);
+const ecma_compiled_code_t *
+ecma_op_function_get_compiled_code (ecma_extended_object_t *function_p);
+
+#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
+const ecma_compiled_code_t *
+ecma_op_arrow_function_get_compiled_code (ecma_arrow_function_t *arrow_function_p);
+#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
+
+ecma_value_t
+ecma_op_function_has_instance (ecma_object_t *func_obj_p, ecma_value_t value);
+
ecma_value_t
ecma_op_function_call (ecma_object_t *func_obj_p, ecma_value_t this_arg_value,
const ecma_value_t *arguments_list_p, ecma_length_t arguments_list_len);
ecma_op_function_construct (ecma_object_t *func_obj_p, const ecma_value_t *arguments_list_p,
ecma_length_t arguments_list_len);
-ecma_value_t
-ecma_op_function_has_instance (ecma_object_t *func_obj_p, ecma_value_t value);
-
ecma_property_t *
ecma_op_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, ecma_string_t *property_name_p);
|| ecma_is_value_number (base_value)
|| ecma_is_value_string (base_value));
- ecma_value_t ret_value = ECMA_VALUE_EMPTY;
-
- ECMA_TRY_CATCH (object_base, ecma_op_to_object (base_value), ret_value);
+ ecma_value_t object_base = ecma_op_to_object (base_value);
+ JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (object_base));
ecma_object_t *object_p = ecma_get_object_from_value (object_base);
JERRY_ASSERT (object_p != NULL
&& !ecma_is_lexical_environment (object_p));
- ret_value = ECMA_VALUE_UNDEFINED;
+ ecma_value_t ret_value = ECMA_VALUE_UNDEFINED;
/* Circular reference is possible in JavaScript and testing it is complicated. */
int max_depth = ECMA_PROPERTY_SEARCH_DEPTH_LIMIT;
}
while (object_p != NULL);
- ECMA_FINALIZE (object_base);
+ ecma_free_value (object_base);
return ret_value;
} /* ecma_op_get_value_object_base */
ecma_job_promise_reaction_t *job_p = (ecma_job_promise_reaction_t *) obj_p;
ecma_object_t *reaction_p = ecma_get_object_from_value (job_p->reaction);
- ecma_string_t *str_capability = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
- ecma_string_t *str_handler = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_HANDLER);
- ecma_string_t *str_resolve = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
- ecma_string_t *str_reject = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
+ ecma_string_t *capability_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
+ ecma_string_t *handler_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_HANDLER);
+ ecma_string_t *resolve_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
+ ecma_string_t *reject_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
/* 2. */
- ecma_value_t capability = ecma_op_object_get (reaction_p, str_capability);
+ ecma_value_t capability = ecma_op_object_get (reaction_p, capability_str_p);
/* 3. */
- ecma_value_t handler = ecma_op_object_get (reaction_p, str_handler);
+ ecma_value_t handler = ecma_op_object_get (reaction_p, handler_str_p);
JERRY_ASSERT (ecma_is_value_boolean (handler) || ecma_op_is_callable (handler));
}
/* 7. */
- ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability), str_reject);
+ ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability), reject_str_p);
JERRY_ASSERT (ecma_op_is_callable (reject));
else
{
/* 8. */
- ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability), str_resolve);
+ ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability), resolve_str_p);
JERRY_ASSERT (ecma_op_is_callable (resolve));
ecma_free_value (handler_result);
ecma_free_value (handler);
ecma_free_value (capability);
- ecma_deref_ecma_string (str_capability);
- ecma_deref_ecma_string (str_handler);
- ecma_deref_ecma_string (str_resolve);
- ecma_deref_ecma_string (str_reject);
ecma_free_promise_reaction_job (job_p);
return status;
ecma_job_promise_resolve_thenable_t *job_p = (ecma_job_promise_resolve_thenable_t *) obj_p;
ecma_object_t *promise_p = ecma_get_object_from_value (job_p->promise);
ecma_promise_resolving_functions_t *funcs = ecma_promise_create_resolving_functions (promise_p);
- ecma_string_t str_resolve, str_reject;
- ecma_init_ecma_magic_string (&str_resolve, LIT_INTERNAL_MAGIC_STRING_RESOLVE_FUNCTION);
- ecma_init_ecma_magic_string (&str_reject, LIT_INTERNAL_MAGIC_STRING_REJECT_FUNCTION);
+
+ ecma_string_t *str_resolve_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_RESOLVE_FUNCTION);
+ ecma_string_t *str_reject_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_REJECT_FUNCTION);
+
ecma_op_object_put (promise_p,
- &str_resolve,
+ str_resolve_p,
funcs->resolve,
false);
ecma_op_object_put (promise_p,
- &str_reject,
+ str_reject_p,
funcs->reject,
false);
} /* ecma_process_all_enqueued_jobs */
/**
+ * Release enqueued Promise jobs.
+ */
+void
+ecma_free_all_enqueued_jobs (void)
+{
+ while (JERRY_CONTEXT (job_queue_head_p) != NULL)
+ {
+ ecma_job_queueitem_t *item_p = JERRY_CONTEXT (job_queue_head_p);
+ JERRY_CONTEXT (job_queue_head_p) = item_p->next_p;
+ void *job_p = item_p->job_p;
+ jmem_heap_free_block (item_p, sizeof (ecma_job_queueitem_t));
+
+ ecma_free_promise_reaction_job (job_p);
+ }
+} /* ecma_free_all_enqueued_jobs */
+
+/**
* @}
* @}
*/
void ecma_enqueue_promise_reaction_job (ecma_value_t reaction, ecma_value_t argument);
void ecma_enqueue_promise_resolve_thenable_job (ecma_value_t promise, ecma_value_t thenable, ecma_value_t then);
+void ecma_free_all_enqueued_jobs (void);
ecma_value_t ecma_process_all_enqueued_jobs (void);
bool is_strict = (bytecode_data_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE) != 0;
ecma_length_t formal_params_number;
- jmem_cpointer_t *literal_p;
if (bytecode_data_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) bytecode_data_p;
- uint8_t *byte_p = (uint8_t *) bytecode_data_p;
formal_params_number = args_p->argument_end;
- literal_p = (jmem_cpointer_t *) (byte_p + sizeof (cbc_uint16_arguments_t));
}
else
{
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) bytecode_data_p;
- uint8_t *byte_p = (uint8_t *) bytecode_data_p;
formal_params_number = args_p->argument_end;
- literal_p = (jmem_cpointer_t *) (byte_p + sizeof (cbc_uint8_arguments_t));
}
ecma_object_t *prototype_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE);
if (!is_strict && arguments_number > 0 && formal_params_number > 0)
{
- size_t formal_params_size = formal_params_number * sizeof (jmem_cpointer_t);
+ size_t formal_params_size = formal_params_number * sizeof (ecma_value_t);
obj_p = ecma_create_object (prototype_p,
sizeof (ecma_extended_object_t) + formal_params_size,
ext_object_p->u.pseudo_array.u1.length = (uint16_t) formal_params_number;
- jmem_cpointer_t *arg_Literal_p = (jmem_cpointer_t *) (ext_object_p + 1);
+ ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
- memcpy (arg_Literal_p, literal_p, formal_params_size);
+ uint8_t *byte_p = (uint8_t *) bytecode_data_p;
+ byte_p += ((size_t) bytecode_data_p->size) << JMEM_ALIGNMENT_LOG;
+ byte_p -= formal_params_size;
+
+ memcpy (arg_Literal_p, byte_p, formal_params_size);
for (ecma_length_t i = 0; i < formal_params_number; i++)
{
- if (arg_Literal_p[i] != JMEM_CP_NULL)
+ if (arg_Literal_p[i] != ECMA_VALUE_EMPTY)
{
- ecma_string_t *name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, arg_Literal_p[i]);
+ ecma_string_t *name_p = ecma_get_string_from_value (arg_Literal_p[i]);
ecma_ref_ecma_string (name_p);
}
}
ecma_property_value_t *prop_value_p;
/* 11.a, 11.b */
- for (ecma_length_t indx = 0;
- indx < arguments_number;
- indx++)
+ for (ecma_length_t index = 0;
+ index < arguments_number;
+ index++)
{
- ecma_string_t *indx_string_p = ecma_new_ecma_string_from_uint32 (indx);
+ ecma_string_t *index_string_p = ecma_new_ecma_string_from_uint32 (index);
prop_value_p = ecma_create_named_data_property (obj_p,
- indx_string_p,
+ index_string_p,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
NULL);
- prop_value_p->value = ecma_copy_value_if_not_object (arguments_list_p[indx]);
+ prop_value_p->value = ecma_copy_value_if_not_object (arguments_list_p[index]);
- ecma_deref_ecma_string (indx_string_p);
+ ecma_deref_ecma_string (index_string_p);
}
/* 7. */
- ecma_string_t *length_magic_string_p = ecma_new_ecma_length_string ();
-
prop_value_p = ecma_create_named_data_property (obj_p,
- length_magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
ECMA_PROPERTY_CONFIGURABLE_WRITABLE,
NULL);
prop_value_p->value = ecma_make_uint32_value (arguments_number);
- ecma_deref_ecma_string (length_magic_string_p);
-
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
/* 13. */
if (!is_strict)
{
- ecma_string_t *callee_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_CALLEE);
-
prop_value_p = ecma_create_named_data_property (obj_p,
- callee_magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_CALLEE),
ECMA_PROPERTY_CONFIGURABLE_WRITABLE,
NULL);
prop_value_p->value = ecma_make_object_value (func_obj_p);
-
- ecma_deref_ecma_string (callee_magic_string_p);
}
else
{
prop_desc.is_configurable = false;
}
- ecma_string_t *callee_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_CALLEE);
-
ecma_value_t completion = ecma_op_object_define_own_property (obj_p,
- callee_magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_CALLEE),
&prop_desc,
false);
JERRY_ASSERT (ecma_is_value_true (completion));
- ecma_deref_ecma_string (callee_magic_string_p);
- ecma_string_t *caller_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_CALLER);
completion = ecma_op_object_define_own_property (obj_p,
- caller_magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_CALLER),
&prop_desc,
false);
JERRY_ASSERT (ecma_is_value_true (completion));
- ecma_deref_ecma_string (caller_magic_string_p);
ecma_deref_object (thrower_p);
}
JERRY_ASSERT (ecma_is_value_empty (completion));
}
- ecma_deref_ecma_string (arguments_string_p);
ecma_deref_object (obj_p);
} /* ecma_op_create_arguments_object */
return ret_value;
}
- jmem_cpointer_t *arg_Literal_p = (jmem_cpointer_t *) (ext_object_p + 1);
+ ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
- if (arg_Literal_p[index] == JMEM_CP_NULL)
+ if (arg_Literal_p[index] == ECMA_VALUE_EMPTY)
{
return ret_value;
}
- ecma_string_t *name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, arg_Literal_p[index]);
+ ecma_string_t *name_p = ecma_get_string_from_value (arg_Literal_p[index]);
if (property_desc_p->is_get_defined
|| property_desc_p->is_set_defined)
{
ecma_deref_ecma_string (name_p);
- arg_Literal_p[index] = JMEM_CP_NULL;
+ arg_Literal_p[index] = ECMA_VALUE_EMPTY;
}
else
{
&& !property_desc_p->is_writable)
{
ecma_deref_ecma_string (name_p);
- arg_Literal_p[index] = JMEM_CP_NULL;
+ arg_Literal_p[index] = ECMA_VALUE_EMPTY;
}
}
if (index < ext_object_p->u.pseudo_array.u1.length)
{
- jmem_cpointer_t *arg_Literal_p = (jmem_cpointer_t *) (ext_object_p + 1);
+ ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
- if (arg_Literal_p[index] != JMEM_CP_NULL)
+ if (arg_Literal_p[index] != ECMA_VALUE_EMPTY)
{
- ecma_string_t *name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, arg_Literal_p[index]);
+ ecma_string_t *name_p = ecma_get_string_from_value (arg_Literal_p[index]);
ecma_deref_ecma_string (name_p);
- arg_Literal_p[index] = JMEM_CP_NULL;
+ arg_Literal_p[index] = ECMA_VALUE_EMPTY;
}
}
}
/* ES2015 9.4.5.1 */
if (ecma_is_typedarray (ecma_make_object_value (object_p)))
{
- if (ECMA_STRING_GET_CONTAINER (property_name_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
+ uint32_t array_index = ecma_string_get_array_index (property_name_p);
+
+ if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
{
- ecma_value_t value = ecma_op_typedarray_get_index_prop (object_p, property_name_p->u.uint32_number);
+ ecma_value_t value = ecma_op_typedarray_get_index_prop (object_p, array_index);
if (!ecma_is_value_undefined (value))
{
if (type != ECMA_OBJECT_TYPE_ARROW_FUNCTION)
{
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
- bytecode_data_p = ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t,
- ext_func_p->u.function.bytecode_cp);
+ bytecode_data_p = ecma_op_function_get_compiled_code (ext_func_p);
}
else
{
ecma_arrow_function_t *arrow_func_p = (ecma_arrow_function_t *) object_p;
- bytecode_data_p = ECMA_GET_NON_NULL_POINTER (const ecma_compiled_code_t,
- arrow_func_p->bytecode_cp);
+ bytecode_data_p = ecma_op_arrow_function_get_compiled_code (arrow_func_p);
}
#else /* CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
- bytecode_data_p = ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t,
- ext_func_p->u.function.bytecode_cp);
+ bytecode_data_p = ecma_op_function_get_compiled_code (ext_func_p);
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
uint32_t len;
{
if (index < ext_object_p->u.pseudo_array.u1.length)
{
- jmem_cpointer_t *arg_Literal_p = (jmem_cpointer_t *) (ext_object_p + 1);
+ ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
- if (arg_Literal_p[index] != JMEM_CP_NULL)
+ if (arg_Literal_p[index] != ECMA_VALUE_EMPTY)
{
- ecma_string_t *arg_name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- arg_Literal_p[index]);
+ ecma_string_t *arg_name_p = ecma_get_string_from_value (arg_Literal_p[index]);
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
ext_object_p->u.pseudo_array.u2.lex_env_cp);
{
if (index < ext_object_p->u.pseudo_array.u1.length)
{
- jmem_cpointer_t *arg_Literal_p = (jmem_cpointer_t *) (ext_object_p + 1);
+ ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
- if (arg_Literal_p[index] != JMEM_CP_NULL)
+ if (arg_Literal_p[index] != ECMA_VALUE_EMPTY)
{
- ecma_string_t *arg_name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- arg_Literal_p[index]);
+ ecma_string_t *arg_name_p = ecma_get_string_from_value (arg_Literal_p[index]);
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
ext_object_p->u.pseudo_array.u2.lex_env_cp);
/* ES2015 9.4.5.4 */
if (ecma_is_typedarray (ecma_make_object_value (object_p)))
{
- if (ECMA_STRING_GET_CONTAINER (property_name_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
+ uint32_t array_index = ecma_string_get_array_index (property_name_p);
+
+ if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
{
- return ecma_op_typedarray_get_index_prop (object_p, property_name_p->u.uint32_number);
+ return ecma_op_typedarray_get_index_prop (object_p, array_index);
}
ecma_number_t num = ecma_string_to_number (property_name_p);
if (type != ECMA_OBJECT_TYPE_ARROW_FUNCTION)
{
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
- bytecode_data_p = ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t,
- ext_func_p->u.function.bytecode_cp);
+ bytecode_data_p = ecma_op_function_get_compiled_code (ext_func_p);
}
else
{
ecma_arrow_function_t *arrow_func_p = (ecma_arrow_function_t *) object_p;
- bytecode_data_p = ECMA_GET_NON_NULL_POINTER (const ecma_compiled_code_t,
- arrow_func_p->bytecode_cp);
+ bytecode_data_p = ecma_op_arrow_function_get_compiled_code (arrow_func_p);
}
#else /* CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) object_p;
- bytecode_data_p = ECMA_GET_INTERNAL_VALUE_POINTER (const ecma_compiled_code_t,
- ext_func_p->u.function.bytecode_cp);
+ bytecode_data_p = ecma_op_function_get_compiled_code (ext_func_p);
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
uint32_t len;
* @return ecma value
* Returned value must be freed with ecma_free_value
*/
-ecma_value_t
+inline ecma_value_t __attr_always_inline___
ecma_op_object_get_by_magic_id (ecma_object_t *object_p, /**< the object */
lit_magic_string_id_t property_id) /**< property magic string id */
{
- /* Circular reference is possible in JavaScript and testing it is complicated. */
- int max_depth = ECMA_PROPERTY_SEARCH_DEPTH_LIMIT;
-
- ecma_string_t property_name;
- ecma_init_ecma_magic_string (&property_name, property_id);
-
- ecma_value_t base_value = ecma_make_object_value (object_p);
- do
- {
- ecma_value_t value = ecma_op_object_find_own (base_value, object_p, &property_name);
-
- if (ecma_is_value_found (value))
- {
- return value;
- }
-
- if (--max_depth == 0)
- {
- break;
- }
-
- object_p = ecma_get_object_prototype (object_p);
- }
- while (object_p != NULL);
-
- return ECMA_VALUE_UNDEFINED;
+ return ecma_op_object_get (object_p, ecma_get_magic_string (property_id));
} /* ecma_op_object_get_by_magic_id */
/**
{
if (index < ext_object_p->u.pseudo_array.u1.length)
{
- jmem_cpointer_t *arg_Literal_p = (jmem_cpointer_t *) (ext_object_p + 1);
+ ecma_value_t *arg_Literal_p = (ecma_value_t *) (ext_object_p + 1);
- if (arg_Literal_p[index] != JMEM_CP_NULL)
+ if (arg_Literal_p[index] != ECMA_VALUE_EMPTY)
{
- ecma_string_t *arg_name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- arg_Literal_p[index]);
+ ecma_string_t *arg_name_p = ecma_get_string_from_value (arg_Literal_p[index]);
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
ext_object_p->u.pseudo_array.u2.lex_env_cp);
/* ES2015 9.4.5.5 */
if (ecma_is_typedarray (ecma_make_object_value (object_p)))
{
- if (ECMA_STRING_GET_CONTAINER (property_name_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
+ uint32_t array_index = ecma_string_get_array_index (property_name_p);
+
+ if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
{
- bool set_status = ecma_op_typedarray_set_index_prop (object_p, property_name_p->u.uint32_number, value);
+ bool set_status = ecma_op_typedarray_set_index_prop (object_p, array_index, value);
if (set_status)
{
/* ES2015 9.4.5.3 */
if (ecma_is_typedarray (ecma_make_object_value (obj_p)))
{
- if (ECMA_STRING_GET_CONTAINER (property_name_p) == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
+ uint32_t array_index = ecma_string_get_array_index (property_name_p);
+
+ if (array_index != ECMA_STRING_NOT_ARRAY_INDEX)
{
bool define_status = ecma_op_typedarray_define_index_prop (obj_p,
- property_name_p->u.uint32_number,
+ array_index,
property_desc_p);
if (define_status)
JERRY_ASSERT (obj_p != NULL
&& !ecma_is_lexical_environment (obj_p));
- ecma_collection_header_t *ret_p = ecma_new_strings_collection (NULL, 0);
- ecma_collection_header_t *skipped_non_enumerable_p = ecma_new_strings_collection (NULL, 0);
+ ecma_collection_header_t *ret_p = ecma_new_values_collection ();
+ ecma_collection_header_t *skipped_non_enumerable_p = ecma_new_values_collection ();
const ecma_object_type_t type = ecma_get_object_type (obj_p);
const bool obj_is_builtin = ecma_get_object_is_builtin (obj_p);
ecma_length_t string_named_properties_count = 0;
ecma_length_t array_index_named_properties_count = 0;
- ecma_collection_header_t *prop_names_p = ecma_new_strings_collection (NULL, 0);
+ ecma_collection_header_t *prop_names_p = ecma_new_values_collection ();
if (obj_is_builtin)
{
}
}
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, prop_names_p);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (prop_names_p);
uint32_t own_names_hashes_bitmap[ECMA_OBJECT_HASH_BITMAP_SIZE / bitmap_row_size];
memset (own_names_hashes_bitmap, 0, sizeof (own_names_hashes_bitmap));
- while (ecma_collection_iterator_next (&iter))
+ while (ecma_value_p != NULL)
{
- ecma_string_t *name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
- uint8_t hash = (uint8_t) name_p->hash;
+ uint8_t hash = (uint8_t) ecma_string_hash (name_p);
uint32_t bitmap_row = (uint32_t) (hash / bitmap_row_size);
uint32_t bitmap_column = (uint32_t) (hash % bitmap_row_size);
{
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
- if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_STRING_CONTAINER_MAGIC_STRING
+ if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_MAGIC
&& prop_pair_p->names_cp[i] >= LIT_NON_INTERNAL_MAGIC_STRING__COUNT)
{
/* Internal properties are never enumerated. */
if (!(is_enumerable_only && !ecma_is_property_enumerable (*property_p)))
{
- uint8_t hash = (uint8_t) name_p->hash;
+ uint8_t hash = (uint8_t) ecma_string_hash (name_p);
uint32_t bitmap_row = (uint32_t) (hash / bitmap_row_size);
uint32_t bitmap_column = (uint32_t) (hash % bitmap_row_size);
if ((own_names_hashes_bitmap[bitmap_row] & (1u << bitmap_column)) != 0)
{
- ecma_collection_iterator_init (&iter, prop_names_p);
+ ecma_value_p = ecma_collection_iterator_init (prop_names_p);
- while (ecma_collection_iterator_next (&iter))
+ while (ecma_value_p != NULL)
{
- ecma_string_t *name2_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *current_name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
- if (ecma_compare_ecma_strings (name_p, name2_p))
+ if (ecma_compare_ecma_strings (name_p, current_name_p))
{
is_add = false;
break;
ecma_append_to_values_collection (prop_names_p,
ecma_make_string_value (name_p),
- true);
+ 0);
}
}
else
ecma_append_to_values_collection (skipped_non_enumerable_p,
ecma_make_string_value (name_p),
- true);
+ 0);
}
ecma_deref_ecma_string (name_p);
prop_iter_p->next_property_cp);
}
- ecma_collection_iterator_init (&iter, prop_names_p);
- while (ecma_collection_iterator_next (&iter))
+ ecma_value_p = ecma_collection_iterator_init (prop_names_p);
+
+ while (ecma_value_p != NULL)
{
- ecma_string_t *name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
uint32_t index = ecma_string_get_array_index (name_p);
uint32_t name_pos = array_index_named_properties_count + string_named_properties_count;
uint32_t array_index_name_pos = 0;
- ecma_collection_iterator_init (&iter, prop_names_p);
- while (ecma_collection_iterator_next (&iter))
+ ecma_value_p = ecma_collection_iterator_init (prop_names_p);
+
+ while (ecma_value_p != NULL)
{
- ecma_string_t *name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
uint32_t index = ecma_string_get_array_index (name_p);
JMEM_FINALIZE_LOCAL_ARRAY (array_index_names_p);
- ecma_free_values_collection (prop_names_p, true);
+ ecma_free_values_collection (prop_names_p, 0);
/* Third pass:
* embedding own property names of current object of prototype chain to aggregate property names collection */
ecma_string_t *name_p = names_p[i];
- uint8_t hash = (uint8_t) name_p->hash;
+ uint8_t hash = (uint8_t) ecma_string_hash (name_p);
uint32_t bitmap_row = (uint32_t) (hash / bitmap_row_size);
uint32_t bitmap_column = (uint32_t) (hash % bitmap_row_size);
else
{
/* Name with same hash has already occured. */
- ecma_collection_iterator_init (&iter, ret_p);
+ ecma_value_p = ecma_collection_iterator_init (ret_p);
- while (ecma_collection_iterator_next (&iter))
+ while (ecma_value_p != NULL)
{
- ecma_string_t *iter_name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *current_name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
- if (ecma_compare_ecma_strings (name_p, iter_name_p))
+ if (ecma_compare_ecma_strings (name_p, current_name_p))
{
is_append = false;
break;
if (is_append)
{
- ecma_collection_iterator_init (&iter, skipped_non_enumerable_p);
- while (ecma_collection_iterator_next (&iter))
+ ecma_value_p = ecma_collection_iterator_init (skipped_non_enumerable_p);
+
+ while (ecma_value_p != NULL)
{
- ecma_string_t *iter_name_p = ecma_get_string_from_value (*iter.current_value_p);
+ ecma_string_t *current_name_p = ecma_get_string_from_value (*ecma_value_p);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
- if (ecma_compare_ecma_strings (name_p, iter_name_p))
+ if (ecma_compare_ecma_strings (name_p, current_name_p))
{
is_append = false;
break;
{
JERRY_ASSERT ((names_hashes_bitmap[bitmap_row] & (1u << bitmap_column)) != 0);
- ecma_append_to_values_collection (ret_p, ecma_make_string_value (names_p[i]), true);
+ ecma_append_to_values_collection (ret_p, ecma_make_string_value (names_p[i]), 0);
}
ecma_deref_ecma_string (name_p);
JMEM_FINALIZE_LOCAL_ARRAY (names_p);
}
- ecma_free_values_collection (skipped_non_enumerable_p, true);
+ ecma_free_values_collection (skipped_non_enumerable_p, 0);
return ret_p;
} /* ecma_op_object_get_property_names */
ecma_promise_trigger_reactions (ecma_collection_header_t *reactions, /**< lists of reactions */
ecma_value_t value) /**< value for resolve or reject */
{
- ecma_collection_iterator_t iter;
- ecma_collection_iterator_init (&iter, reactions);
+ ecma_value_t *ecma_value_p = ecma_collection_iterator_init (reactions);
- while (ecma_collection_iterator_next (&iter))
+ while (ecma_value_p != NULL)
{
- ecma_enqueue_promise_reaction_job (*iter.current_value_p, value);
+ ecma_enqueue_promise_reaction_job (*ecma_value_p, value);
+ ecma_value_p = ecma_collection_iterator_next (ecma_value_p);
}
- ecma_free_values_collection (reactions, false);
+ ecma_free_values_collection (reactions, ECMA_COLLECTION_NO_REF_OBJECTS);
} /* ecma_promise_trigger_reactions */
/**
ecma_promise_set_state (obj_p, ECMA_PROMISE_STATE_REJECTED);
ecma_promise_set_result (obj_p, ecma_copy_value_if_not_object (reason));
ecma_promise_object_t *promise_p = (ecma_promise_object_t *) obj_p;
- ecma_promise_trigger_reactions (promise_p->reject_reactions, reason);
- promise_p->reject_reactions = ecma_new_values_collection (NULL, 0, false);
- /* Free all fullfill_reactions. */
- ecma_free_values_collection (promise_p->fulfill_reactions, false);
- promise_p->fulfill_reactions = ecma_new_values_collection (NULL, 0, false);
+
+ /* GC can be triggered by ecma_new_values_collection so freeing the collection
+ first and creating a new one might cause a heap after use event. */
+ ecma_collection_header_t *reject_reactions = promise_p->reject_reactions;
+ ecma_collection_header_t *fulfill_reactions = promise_p->fulfill_reactions;
+ promise_p->reject_reactions = ecma_new_values_collection ();
+ promise_p->fulfill_reactions = ecma_new_values_collection ();
+
+ /* Fulfill reactions will never be triggered. */
+ ecma_free_values_collection (fulfill_reactions, ECMA_COLLECTION_NO_REF_OBJECTS);
+ ecma_promise_trigger_reactions (reject_reactions, reason);
} /* ecma_reject_promise */
/**
ecma_promise_set_state (obj_p, ECMA_PROMISE_STATE_FULFILLED);
ecma_promise_set_result (obj_p, ecma_copy_value_if_not_object (value));
ecma_promise_object_t *promise_p = (ecma_promise_object_t *) obj_p;
- ecma_promise_trigger_reactions (promise_p->fulfill_reactions, value);
- promise_p->fulfill_reactions = ecma_new_values_collection (NULL, 0, false);
- /* Free all reject_reactions. */
- ecma_free_values_collection (promise_p->reject_reactions, false);
- promise_p->reject_reactions = ecma_new_values_collection (NULL, 0, false);
+
+ /* GC can be triggered by ecma_new_values_collection so freeing the collection
+ first and creating a new one might cause a heap after use event. */
+ ecma_collection_header_t *reject_reactions = promise_p->reject_reactions;
+ ecma_collection_header_t *fulfill_reactions = promise_p->fulfill_reactions;
+ promise_p->reject_reactions = ecma_new_values_collection ();
+ promise_p->fulfill_reactions = ecma_new_values_collection ();
+
+ /* Reject reactions will never be triggered. */
+ ecma_free_values_collection (reject_reactions, ECMA_COLLECTION_NO_REF_OBJECTS);
+ ecma_promise_trigger_reactions (fulfill_reactions, value);
} /* ecma_fulfill_promise */
/**
{
JERRY_UNUSED (this);
- ecma_string_t str_promise;
- ecma_string_t str_already_resolved;
- ecma_init_ecma_magic_string (&str_promise, LIT_INTERNAL_MAGIC_STRING_PROMISE);
- ecma_init_ecma_magic_string (&str_already_resolved, LIT_INTERNAL_MAGIC_STRING_ALREADY_RESOLVED);
+ ecma_string_t *str_promise_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_PROMISE);
+ ecma_string_t *str_already_resolved_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_ALREADY_RESOLVED);
+
ecma_object_t *function_p = ecma_get_object_from_value (function);
/* 2. */
- ecma_value_t promise = ecma_op_object_get (function_p, &str_promise);
+ ecma_value_t promise = ecma_op_object_get (function_p, str_promise_p);
/* 1. */
JERRY_ASSERT (ecma_is_promise (ecma_get_object_from_value (promise)));
/* 3. */
- ecma_value_t already_resolved = ecma_op_object_get (function_p, &str_already_resolved);
+ ecma_value_t already_resolved = ecma_op_object_get (function_p, str_already_resolved_p);
/* 4. */
if (ecma_get_already_resolved_bool_value (already_resolved))
{
JERRY_UNUSED (this);
- ecma_string_t str_promise;
- ecma_string_t str_already_resolved;
- ecma_init_ecma_magic_string (&str_promise, LIT_INTERNAL_MAGIC_STRING_PROMISE);
- ecma_init_ecma_magic_string (&str_already_resolved, LIT_INTERNAL_MAGIC_STRING_ALREADY_RESOLVED);
+ ecma_string_t *str_promise_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_PROMISE);
+ ecma_string_t *str_already_resolved_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_ALREADY_RESOLVED);
+
ecma_object_t *function_p = ecma_get_object_from_value (function);
/* 2. */
- ecma_value_t promise = ecma_op_object_get (function_p, &str_promise);
+ ecma_value_t promise = ecma_op_object_get (function_p, str_promise_p);
/* 1. */
JERRY_ASSERT (ecma_is_promise (ecma_get_object_from_value (promise)));
/* 3. */
- ecma_value_t already_resolved = ecma_op_object_get (function_p, &str_already_resolved);
+ ecma_value_t already_resolved = ecma_op_object_get (function_p, str_already_resolved_p);
/* 4. */
if (ecma_get_already_resolved_bool_value (already_resolved))
ecma_value_t resolve_func, /**< the resolve function */
ecma_value_t reject_func) /**< the reject function */
{
- ecma_string_t *str_capability = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
- ecma_string_t *str_resolve = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
- ecma_string_t *str_reject = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
+ ecma_string_t *capability_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
+ ecma_string_t *resolve_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
+ ecma_string_t *reject_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
/* 2. */
- ecma_value_t capability = ecma_op_object_get (executor_p, str_capability);
+ ecma_value_t capability = ecma_op_object_get (executor_p, capability_str_p);
/* 3. */
- ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability), str_resolve);
+ ecma_value_t resolve = ecma_op_object_get (ecma_get_object_from_value (capability), resolve_str_p);
if (resolve != ECMA_VALUE_UNDEFINED)
{
ecma_free_value (resolve);
ecma_free_value (capability);
- ecma_deref_ecma_string (str_capability);
- ecma_deref_ecma_string (str_resolve);
- ecma_deref_ecma_string (str_reject);
return ecma_raise_type_error (ECMA_ERR_MSG ("'resolve' function should be undefined."));
}
/* 4. */
- ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability), str_reject);
+ ecma_value_t reject = ecma_op_object_get (ecma_get_object_from_value (capability), reject_str_p);
if (reject != ECMA_VALUE_UNDEFINED)
{
ecma_free_value (reject);
ecma_free_value (capability);
- ecma_deref_ecma_string (str_capability);
- ecma_deref_ecma_string (str_resolve);
- ecma_deref_ecma_string (str_reject);
return ecma_raise_type_error (ECMA_ERR_MSG ("'reject' function should be undefined."));
}
/* 5. */
ecma_op_object_put (ecma_get_object_from_value (capability),
- str_resolve,
+ resolve_str_p,
resolve_func,
false);
/* 6. */
ecma_op_object_put (ecma_get_object_from_value (capability),
- str_reject,
+ reject_str_p,
reject_func,
false);
ecma_free_value (capability);
- ecma_deref_ecma_string (str_capability);
- ecma_deref_ecma_string (str_resolve);
- ecma_deref_ecma_string (str_reject);
return ECMA_VALUE_UNDEFINED;
} /* ecma_call_builtin_executor */
/* 1. */
ecma_value_t already_resolved = ecma_op_create_boolean_object (ecma_make_boolean_value (false));
- ecma_string_t str_promise;
- ecma_string_t str_already_resolved;
- ecma_init_ecma_magic_string (&str_promise, LIT_INTERNAL_MAGIC_STRING_PROMISE);
- ecma_init_ecma_magic_string (&str_already_resolved, LIT_INTERNAL_MAGIC_STRING_ALREADY_RESOLVED);
+ ecma_string_t *str_promise_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_PROMISE);
+ ecma_string_t *str_already_resolved_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_ALREADY_RESOLVED);
+
/* 2. */
ecma_object_t *resolve_p;
resolve_p = ecma_op_create_external_function_object (ecma_promise_resolve_handler);
/* 3. */
ecma_op_object_put (resolve_p,
- &str_promise,
+ str_promise_p,
ecma_make_object_value (object_p),
false);
/* 4. */
ecma_op_object_put (resolve_p,
- &str_already_resolved,
+ str_already_resolved_p,
already_resolved,
false);
/* 5. */
reject_p = ecma_op_create_external_function_object (ecma_promise_reject_handler);
/* 6. */
ecma_op_object_put (reject_p,
- &str_promise,
+ str_promise_p,
ecma_make_object_value (object_p),
false);
/* 7. */
ecma_op_object_put (reject_p,
- &str_already_resolved,
+ str_already_resolved_p,
already_resolved,
false);
/* 5 */
ecma_promise_set_state (object_p, ECMA_PROMISE_STATE_PENDING);
/* 6-7. */
- promise_object_p->fulfill_reactions = ecma_new_values_collection (NULL, 0, false);
- promise_object_p->reject_reactions = ecma_new_values_collection (NULL, 0, false);
+ promise_object_p->fulfill_reactions = ecma_new_values_collection ();
+ promise_object_p->reject_reactions = ecma_new_values_collection ();
/* 8. */
ecma_promise_resolving_functions_t *funcs = ecma_promise_create_resolving_functions (object_p);
- ecma_string_t str_resolve, str_reject;
- ecma_init_ecma_magic_string (&str_resolve, LIT_INTERNAL_MAGIC_STRING_RESOLVE_FUNCTION);
- ecma_init_ecma_magic_string (&str_reject, LIT_INTERNAL_MAGIC_STRING_REJECT_FUNCTION);
+ ecma_string_t *str_resolve_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_RESOLVE_FUNCTION);
+ ecma_string_t *str_reject_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_REJECT_FUNCTION);
+
ecma_op_object_put (object_p,
- &str_resolve,
+ str_resolve_p,
funcs->resolve,
false);
ecma_op_object_put (object_p,
- &str_reject,
+ str_reject_p,
funcs->reject,
false);
{
/* 3. */
ecma_object_t *capability_p = ecma_op_create_object_object_noarg ();
- ecma_string_t *str_capability = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
- ecma_string_t *str_promise = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
+
+ ecma_string_t *capability_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
+ ecma_string_t *promise_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
/* 4. */
ecma_object_t *executor_p;
executor_p = ecma_op_create_object_object_noarg ();
ecma_value_t executor = ecma_make_object_value (executor_p);
/* 5. */
ecma_op_object_put (executor_p,
- str_capability,
+ capability_str_p,
ecma_make_object_value (capability_p),
false);
/* 10. */
ecma_op_object_put (capability_p,
- str_promise,
+ promise_str_p,
promise,
false);
ecma_deref_object (executor_p);
- ecma_deref_ecma_string (str_promise);
- ecma_deref_ecma_string (str_capability);
+
/* 7. */
if (ECMA_IS_VALUE_ERROR (promise))
{
ecma_free_value (promise);
/* 8. */
- ecma_string_t *str_resolve = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
- ecma_value_t resolve = ecma_op_object_get (capability_p, str_resolve);
- ecma_deref_ecma_string (str_resolve);
+ ecma_string_t *resolve_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_RESOLVE);
+ ecma_value_t resolve = ecma_op_object_get (capability_p, resolve_str_p);
if (!ecma_op_is_callable (resolve))
{
ecma_free_value (resolve);
/* 9. */
- ecma_string_t *str_reject = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
- ecma_value_t reject = ecma_op_object_get (capability_p, str_reject);
- ecma_deref_ecma_string (str_reject);
+ ecma_string_t *reject_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_REJECT);
+ ecma_value_t reject = ecma_op_object_get (capability_p, reject_str_p);
if (!ecma_op_is_callable (reject))
{
ecma_value_t on_rejected, /**< on_rejected function */
ecma_value_t result_capability) /**< promise capability */
{
- ecma_string_t *str_capability = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
- ecma_string_t *str_handler = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_HANDLER);
- ecma_string_t *str_promise = ecma_new_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
+ ecma_string_t *capability_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_CAPABILITY);
+ ecma_string_t *handler_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_HANDLER);
+ ecma_string_t *promise_str_p = ecma_get_ecma_string_from_uint32 (ECMA_PROMISE_PROPERTY_PROMISE);
/* 3. boolean true indicates "indentity" */
if (!ecma_op_is_callable (on_fulfilled))
ecma_object_t *fulfill_reaction_p = ecma_op_create_object_object_noarg ();
ecma_object_t *reject_reaction_p = ecma_op_create_object_object_noarg ();
ecma_op_object_put (fulfill_reaction_p,
- str_capability,
+ capability_str_p,
result_capability,
false);
ecma_op_object_put (fulfill_reaction_p,
- str_handler,
+ handler_str_p,
on_fulfilled,
false);
ecma_op_object_put (reject_reaction_p,
- str_capability,
+ capability_str_p,
result_capability,
false);
ecma_op_object_put (reject_reaction_p,
- str_handler,
+ handler_str_p,
on_rejected,
false);
/* 7. */
ecma_append_to_values_collection (promise_p->fulfill_reactions,
ecma_make_object_value (fulfill_reaction_p),
- false);
+ ECMA_COLLECTION_NO_REF_OBJECTS);
ecma_append_to_values_collection (promise_p->reject_reactions,
ecma_make_object_value (reject_reaction_p),
- false);
+ ECMA_COLLECTION_NO_REF_OBJECTS);
}
else if (ecma_promise_get_state (obj_p) == ECMA_PROMISE_STATE_FULFILLED)
{
}
/* 10. */
- ecma_value_t ret = ecma_op_object_get (ecma_get_object_from_value (result_capability), str_promise);
+ ecma_value_t ret = ecma_op_object_get (ecma_get_object_from_value (result_capability), promise_str_p);
ecma_deref_object (fulfill_reaction_p);
ecma_deref_object (reject_reaction_p);
- ecma_deref_ecma_string (str_capability);
- ecma_deref_ecma_string (str_handler);
- ecma_deref_ecma_string (str_promise);
return ret;
} /* ecma_promise_do_then */
ecma_string_t *source_p, /**< source string */
uint16_t flags) /**< flags */
{
- /* Set source property. ECMA-262 v5, 15.10.7.1 */
- ecma_string_t *magic_string_p;
-
- magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_SOURCE);
+ /* Set source property. ECMA-262 v5, 15.10.7.1 */
re_set_data_property (re_obj_p,
- magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_SOURCE),
ECMA_PROPERTY_FIXED,
ecma_make_string_value (source_p));
- ecma_deref_ecma_string (magic_string_p);
/* Set global property. ECMA-262 v5, 15.10.7.2 */
- magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GLOBAL);
re_set_data_property (re_obj_p,
- magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_GLOBAL),
ECMA_PROPERTY_FIXED,
ecma_make_boolean_value (flags & RE_FLAG_GLOBAL));
- ecma_deref_ecma_string (magic_string_p);
/* Set ignoreCase property. ECMA-262 v5, 15.10.7.3 */
- magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_IGNORECASE_UL);
re_set_data_property (re_obj_p,
- magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_IGNORECASE_UL),
ECMA_PROPERTY_FIXED,
ecma_make_boolean_value (flags & RE_FLAG_IGNORE_CASE));
- ecma_deref_ecma_string (magic_string_p);
/* Set multiline property. ECMA-262 v5, 15.10.7.4 */
- magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MULTILINE);
re_set_data_property (re_obj_p,
- magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_MULTILINE),
ECMA_PROPERTY_FIXED,
ecma_make_boolean_value (flags & RE_FLAG_MULTILINE));
- ecma_deref_ecma_string (magic_string_p);
/* Set lastIndex property. ECMA-262 v5, 15.10.7.5 */
- magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL);
re_set_data_property (re_obj_p,
- magic_string_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
ECMA_PROPERTY_FLAG_WRITABLE,
ecma_make_integer_value (0));
- ecma_deref_ecma_string (magic_string_p);
} /* re_initialize_props */
/**
/* Initialize RegExp object properties */
re_initialize_props (object_p,
- ECMA_GET_NON_NULL_POINTER (ecma_string_t, bytecode_p->pattern_cp),
+ ecma_get_string_from_value (bytecode_p->pattern),
bytecode_p->header.status_flags);
return ecma_make_object_value (object_p);
int32_t index) /**< index of matching */
{
/* Set index property of the result array */
- ecma_string_t *result_prop_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INDEX);
- {
- ecma_builtin_helper_def_prop (array_obj_p,
- result_prop_str_p,
- ecma_make_int32_value (index),
- true, /* Writable */
- true, /* Enumerable */
- true, /* Configurable */
- true); /* Failure handling */
- }
- ecma_deref_ecma_string (result_prop_str_p);
+ ecma_builtin_helper_def_prop (array_obj_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_INDEX),
+ ecma_make_int32_value (index),
+ true, /* Writable */
+ true, /* Enumerable */
+ true, /* Configurable */
+ true); /* Failure handling */
/* Set input property of the result array */
- result_prop_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INPUT);
-
ecma_builtin_helper_def_prop (array_obj_p,
- result_prop_str_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_INPUT),
ecma_make_string_value (input_str_p),
true, /* Writable */
true, /* Enumerable */
true, /* Configurable */
true); /* Failure handling */
- ecma_deref_ecma_string (result_prop_str_p);
-
/* Set length property of the result array */
- result_prop_str_p = ecma_new_ecma_length_string ();
{
ecma_property_descriptor_t array_item_prop_desc = ecma_make_empty_property_descriptor ();
array_item_prop_desc.is_value_defined = true;
array_item_prop_desc.value = ecma_make_uint32_value (num_of_elements);
ecma_op_object_define_own_property (array_obj_p,
- result_prop_str_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
&array_item_prop_desc,
true);
}
- ecma_deref_ecma_string (result_prop_str_p);
} /* re_set_result_array_properties */
/**
JERRY_ASSERT (ecma_object_class_is (regexp_object_p, LIT_MAGIC_STRING_REGEXP_UL));
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) regexp_object_p;
- re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_POINTER (re_compiled_code_t,
- ext_object_p->u.class_prop.u.value);
+ re_compiled_code_t *bc_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (re_compiled_code_t,
+ ext_object_p->u.class_prop.u.value);
if (bc_p == NULL)
{
ECMA_OP_TO_NUMBER_FINALIZE (lastindex_num);
ecma_fast_free_value (lastindex_value);
-
- ecma_deref_ecma_string (magic_str_p);
}
/* 2. Try to match */
{
if (re_ctx.flags & RE_FLAG_GLOBAL)
{
- ecma_string_t *magic_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL);
- ecma_op_object_put (regexp_object_p, magic_str_p, ecma_make_integer_value (0), true);
- ecma_deref_ecma_string (magic_str_p);
+ ecma_op_object_put (regexp_object_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
+ ecma_make_integer_value (0),
+ true);
}
is_match = false;
if (input_curr_p && (re_ctx.flags & RE_FLAG_GLOBAL))
{
- ecma_string_t *magic_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL);
ecma_number_t lastindex_num;
if (sub_str_p != NULL
lastindex_num = ECMA_NUMBER_ZERO;
}
- ecma_op_object_put (regexp_object_p, magic_str_p, ecma_make_number_value (lastindex_num), true);
- ecma_deref_ecma_string (magic_str_p);
+ ecma_op_object_put (regexp_object_p,
+ ecma_get_magic_string (LIT_MAGIC_STRING_LASTINDEX_UL),
+ ecma_make_number_value (lastindex_num),
+ true);
}
/* 3. Fill the result array or return with 'undefiend' */
JERRY_ASSERT (arguments_list_len == 0
|| arguments_list_p != NULL);
- ecma_string_t *prim_prop_str_value_p;
+ ecma_value_t prim_value = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
- if (arguments_list_len == 0)
+ if (arguments_list_len > 0)
{
- prim_prop_str_value_p = ecma_new_ecma_string_from_magic_string_id (LIT_MAGIC_STRING__EMPTY);
- }
- else
- {
- ecma_value_t to_str_arg_value = ecma_op_to_string (arguments_list_p[0]);
+ prim_value = ecma_op_to_string (arguments_list_p[0]);
- if (ECMA_IS_VALUE_ERROR (to_str_arg_value))
+ if (ECMA_IS_VALUE_ERROR (prim_value))
{
- return to_str_arg_value;
+ return prim_value;
}
- else
- {
- JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (to_str_arg_value));
- JERRY_ASSERT (ecma_is_value_string (to_str_arg_value));
- prim_prop_str_value_p = ecma_get_string_from_value (to_str_arg_value);
- }
+ JERRY_ASSERT (ecma_is_value_string (prim_value));
}
#ifndef CONFIG_DISABLE_STRING_BUILTIN
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_STRING_UL;
- ext_object_p->u.class_prop.u.value = ecma_make_string_value (prim_prop_str_value_p);
+ ext_object_p->u.class_prop.u.value = prim_value;
return ecma_make_object_value (object_p);
} /* ecma_op_create_string_object */
ecma_string_t *name_p = ecma_new_ecma_string_from_uint32 (i);
/* the properties are enumerable (ECMA-262 v5, 15.5.5.2.9) */
- ecma_append_to_values_collection (for_enumerable_p, ecma_make_string_value (name_p), true);
+ ecma_append_to_values_collection (for_enumerable_p, ecma_make_string_value (name_p), 0);
ecma_deref_ecma_string (name_p);
}
- ecma_string_t *length_str_p = ecma_new_ecma_length_string ();
- ecma_append_to_values_collection (for_non_enumerable_p, ecma_make_string_value (length_str_p), true);
- ecma_deref_ecma_string (length_str_p);
+ ecma_append_to_values_collection (for_non_enumerable_p,
+ ecma_make_magic_string_value (LIT_MAGIC_STRING_LENGTH),
+ 0);
} /* ecma_op_string_list_lazy_property_names */
/**
*/
#define ECMA_OP_TO_NUMBER_TRY_CATCH(num_var, value, return_value) \
JERRY_ASSERT (return_value == ECMA_VALUE_EMPTY); \
- ecma_number_t num_var = ecma_number_make_nan (); \
- if (ecma_is_value_number (value)) \
- { \
- num_var = ecma_get_number_from_value (value); \
- } \
- else \
- { \
- ECMA_TRY_CATCH (to_number_value, \
- ecma_op_to_number (value), \
- return_value); \
- \
- num_var = ecma_get_number_from_value (to_number_value); \
- \
- ECMA_FINALIZE (to_number_value); \
- } \
+ ecma_number_t num_var; \
+ return_value = ecma_get_number (value, &num_var); \
\
- if (ecma_is_value_empty (return_value)) \
+ if (likely (ecma_is_value_empty (return_value))) \
{
/**
* Each ECMA_OP_TO_NUMBER_TRY_CATCH should be followed by ECMA_OP_TO_NUMBER_FINALIZE
* with same argument as corresponding ECMA_OP_TO_NUMBER_TRY_CATCH's first argument.
*/
-#define ECMA_OP_TO_NUMBER_FINALIZE(num_var) } \
- else \
- { \
- JERRY_ASSERT (ecma_number_is_nan (num_var)); \
- }
+#define ECMA_OP_TO_NUMBER_FINALIZE(num_var) }
#endif /* !ECMA_TRY_CATCH_MACRO_H */
* @return ecma value of the new typedarray object
* Returned value must be freed with ecma_free_value
*/
-static ecma_value_t
+ecma_value_t
ecma_typedarray_create_object_with_length (ecma_length_t array_length, /**< length of the typedarray */
ecma_object_t *proto_p, /**< prototype object */
uint8_t element_size_shift, /**< the size shift of the element length */
{
ecma_string_t *name_p = ecma_new_ecma_string_from_uint32 (i);
- ecma_append_to_values_collection (main_collection_p, ecma_make_string_value (name_p), true);
+ ecma_append_to_values_collection (main_collection_p, ecma_make_string_value (name_p), 0);
ecma_deref_ecma_string (name_p);
}
bool ecma_op_typedarray_set_index_prop (ecma_object_t *obj_p, uint32_t index, ecma_value_t value);
ecma_value_t ecma_op_create_typedarray_with_type_and_length (ecma_object_t *obj_p,
ecma_length_t array_length);
+ecma_value_t ecma_typedarray_create_object_with_length (ecma_length_t array_length,
+ ecma_object_t *proto_p,
+ uint8_t element_size_shift,
+ lit_magic_string_id_t class_id);
/**
* @}
*/
typedef enum
{
+ JERRY_ERROR_NONE = 0, /**< No Error */
+
JERRY_ERROR_COMMON, /**< Error */
JERRY_ERROR_EVAL, /**< EvalError */
JERRY_ERROR_RANGE, /**< RangeError */
JERRY_FEATURE_SNAPSHOT_EXEC, /**< executing snapshot files */
JERRY_FEATURE_DEBUGGER, /**< debugging */
JERRY_FEATURE_VM_EXEC_STOP, /**< stopping ECMAScript execution */
+ JERRY_FEATURE_JSON, /**< JSON support */
+ JERRY_FEATURE_PROMISE, /**< promise support */
+ JERRY_FEATURE_TYPEDARRAY, /**< Typedarray support */
+ JERRY_FEATURE_DATE, /**< Date support */
+ JERRY_FEATURE_REGEXP, /**< Regexp support */
+ JERRY_FEATURE_LINE_INFO, /**< line info available */
JERRY_FEATURE__COUNT /**< number of features. NOTE: must be at the end of the list */
} jerry_feature_t;
/**
+ * Option flags for jerry_parse and jerry_parse_function functions.
+ */
+typedef enum
+{
+ JERRY_PARSE_NO_OPTS = 0, /**< no options passed */
+ JERRY_PARSE_STRICT_MODE = (1 << 0), /**< enable strict mode */
+} jerry_parse_opts_t;
+
+/**
* Character type of JerryScript.
*/
typedef uint8_t jerry_char_t;
typedef bool (*jerry_object_property_foreach_t) (const jerry_value_t property_name,
const jerry_value_t property_value,
void *user_data_p);
+/**
+ * Function type applied for each object in the engine.
+ */
+typedef bool (*jerry_objects_foreach_t) (const jerry_value_t object,
+ void *user_data_p);
+
+/**
+ * Function type applied for each matching object in the engine.
+ */
+typedef bool (*jerry_objects_foreach_by_native_info_t) (const jerry_value_t object,
+ void *object_data_p,
+ void *user_data_p);
/**
* User context item manager
*/
typedef struct
{
- void (*init_cb) (void *); /**< callback responsible for initializing a context item, or NULL to zero out the memory */
- void (*deinit_cb) (void *); /**< callback responsible for deinitializing a context item */
- size_t bytes_needed; /**< number of bytes to allocate for this manager */
+ /**
+ * Callback responsible for initializing a context item, or NULL to zero out the memory. This is called lazily, the
+ * first time jerry_get_context_data () is called with this manager.
+ *
+ * @param [in] data The buffer that JerryScript allocated for the manager. The buffer is zeroed out. The size is
+ * determined by the bytes_needed field. The buffer is kept alive until jerry_cleanup () is called.
+ */
+ void (*init_cb) (void *data);
+
+ /**
+ * Callback responsible for deinitializing a context item, or NULL. This is called as part of jerry_cleanup (),
+ * right *before* the VM has been cleaned up. This is a good place to release strong references to jerry_value_t's
+ * that the manager may be holding.
+ * Note: because the VM has not been fully cleaned up yet, jerry_object_native_info_t free_cb's can still get called
+ * *after* all deinit_cb's have been run. See finalize_cb for a callback that is guaranteed to run *after* all
+ * free_cb's have been run.
+ *
+ * @param [in] data The buffer that JerryScript allocated for the manager.
+ */
+ void (*deinit_cb) (void *data);
+
+ /**
+ * Callback responsible for finalizing a context item, or NULL. This is called as part of jerry_cleanup (),
+ * right *after* the VM has been cleaned up and destroyed and jerry_... APIs cannot be called any more. At this point,
+ * all values in the VM have been cleaned up. This is a good place to clean up native state that can only be cleaned
+ * up at the very end when there are no more VM values around that may need to access that state.
+ *
+ * @param [in] data The buffer that JerryScript allocated for the manager. After returning from this callback,
+ * the data pointer may no longer be used.
+ */
+ void (*finalize_cb) (void *data);
+
+ /**
+ * Number of bytes to allocate for this manager. This is the size of the buffer that JerryScript will allocate on
+ * behalf of the manager. The pointer to this buffer is passed into init_cb, deinit_cb and finalize_cb. It is also
+ * returned from the jerry_get_context_data () API.
+ */
+ size_t bytes_needed;
} jerry_context_data_manager_t;
/**
* Parser and executor functions.
*/
bool jerry_run_simple (const jerry_char_t *script_source_p, size_t script_source_size, jerry_init_flag_t flags);
-jerry_value_t jerry_parse (const jerry_char_t *source_p, size_t source_size, bool is_strict);
-jerry_value_t jerry_parse_named_resource (const jerry_char_t *resource_name_p, size_t resource_name_length,
- const jerry_char_t *source_p, size_t source_size, bool is_strict);
+jerry_value_t jerry_parse (const jerry_char_t *resource_name_p, size_t resource_name_length,
+ const jerry_char_t *source_p, size_t source_size, uint32_t parse_opts);
jerry_value_t jerry_parse_function (const jerry_char_t *resource_name_p, size_t resource_name_length,
const jerry_char_t *arg_list_p, size_t arg_list_size,
- const jerry_char_t *source_p, size_t source_size, bool is_strict);
+ const jerry_char_t *source_p, size_t source_size, uint32_t parse_opts);
jerry_value_t jerry_run (const jerry_value_t func_val);
jerry_value_t jerry_eval (const jerry_char_t *source_p, size_t source_size, bool is_strict);
bool jerry_value_is_undefined (const jerry_value_t value);
/**
+ * JerryScript API value type information.
+ */
+typedef enum
+{
+ JERRY_TYPE_NONE = 0u, /**< no type information */
+ JERRY_TYPE_UNDEFINED, /**< undefined type */
+ JERRY_TYPE_NULL, /**< null type */
+ JERRY_TYPE_BOOLEAN, /**< boolean type */
+ JERRY_TYPE_NUMBER, /**< number type */
+ JERRY_TYPE_STRING, /**< string type */
+ JERRY_TYPE_OBJECT, /**< object type */
+ JERRY_TYPE_FUNCTION, /**< function type */
+} jerry_type_t;
+
+jerry_type_t jerry_value_get_type (const jerry_value_t value);
+
+/**
* Checker function of whether the specified compile feature is enabled.
*/
bool jerry_is_feature_enabled (const jerry_feature_t feature);
* Error flag manipulation functions.
*/
bool jerry_value_has_error_flag (const jerry_value_t value);
+bool jerry_value_has_abort_flag (const jerry_value_t value);
void jerry_value_clear_error_flag (jerry_value_t *value_p);
void jerry_value_set_error_flag (jerry_value_t *value_p);
+void jerry_value_set_abort_flag (jerry_value_t *value_p);
jerry_value_t jerry_get_value_without_error_flag (jerry_value_t value);
/**
+ * Error object function(s).
+ */
+jerry_error_t jerry_get_error_type (const jerry_value_t value);
+
+/**
* Getter functions of 'jerry_value_t'.
*/
bool jerry_get_boolean_value (const jerry_value_t value);
bool jerry_delete_property_by_index (const jerry_value_t obj_val, uint32_t index);
jerry_value_t jerry_get_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val);
-jerry_value_t jerry_get_property_by_index (const jerry_value_t obj_val, uint32_t index);
+jerry_value_t jerry_get_property_by_index (const jerry_value_t obj_val, uint32_t index);
jerry_value_t jerry_set_property (const jerry_value_t obj_val, const jerry_value_t prop_name_val,
const jerry_value_t value_to_set);
jerry_value_t jerry_set_property_by_index (const jerry_value_t obj_val, uint32_t index,
bool jerry_get_object_native_pointer (const jerry_value_t obj_val,
void **out_native_pointer_p,
const jerry_object_native_info_t **out_pointer_info_p);
+bool jerry_objects_foreach (jerry_objects_foreach_t foreach_p,
+ void *user_data);
+bool jerry_objects_foreach_by_native_info (const jerry_object_native_info_t *native_info_p,
+ jerry_objects_foreach_by_native_info_t foreach_p,
+ void *user_data_p);
void jerry_set_object_native_pointer (const jerry_value_t obj_val,
void *native_pointer_p,
const jerry_object_native_info_t *native_info_p);
* Miscellaneous functions.
*/
void jerry_set_vm_exec_stop_callback (jerry_vm_exec_stop_callback_t stop_cb, void *user_p, uint32_t frequency);
+jerry_value_t jerry_get_backtrace (uint32_t max_depth);
+
+/**
+ * Array buffer components.
+ */
+bool jerry_value_is_arraybuffer (const jerry_value_t value);
+jerry_value_t jerry_create_arraybuffer (const jerry_length_t size);
+jerry_value_t jerry_create_arraybuffer_external (const jerry_length_t size,
+ uint8_t *buffer_p,
+ jerry_object_native_free_callback_t free_cb);
+jerry_length_t jerry_arraybuffer_write (const jerry_value_t value,
+ jerry_length_t offset,
+ const uint8_t *buf_p,
+ jerry_length_t buf_size);
+jerry_length_t jerry_arraybuffer_read (const jerry_value_t value,
+ jerry_length_t offset,
+ uint8_t *buf_p,
+ jerry_length_t buf_size);
+jerry_length_t jerry_get_arraybuffer_byte_length (const jerry_value_t value);
+uint8_t *jerry_get_arraybuffer_pointer (const jerry_value_t value);
+
+
+/**
+ * TypedArray functions.
+ */
+
+/**
+ * TypedArray types.
+ */
+typedef enum
+{
+ JERRY_TYPEDARRAY_INVALID = 0,
+ JERRY_TYPEDARRAY_UINT8,
+ JERRY_TYPEDARRAY_UINT8CLAMPED,
+ JERRY_TYPEDARRAY_INT8,
+ JERRY_TYPEDARRAY_UINT16,
+ JERRY_TYPEDARRAY_INT16,
+ JERRY_TYPEDARRAY_UINT32,
+ JERRY_TYPEDARRAY_INT32,
+ JERRY_TYPEDARRAY_FLOAT32,
+ JERRY_TYPEDARRAY_FLOAT64,
+} jerry_typedarray_type_t;
+
+
+bool jerry_value_is_typedarray (jerry_value_t value);
+jerry_value_t jerry_create_typedarray (jerry_typedarray_type_t type_name, jerry_length_t length);
+jerry_value_t jerry_create_typedarray_for_arraybuffer_sz (jerry_typedarray_type_t type_name,
+ const jerry_value_t arraybuffer,
+ jerry_length_t byte_offset,
+ jerry_length_t length);
+jerry_value_t jerry_create_typedarray_for_arraybuffer (jerry_typedarray_type_t type_name,
+ const jerry_value_t arraybuffer);
+jerry_typedarray_type_t jerry_get_typedarray_type (jerry_value_t value);
+jerry_length_t jerry_get_typedarray_length (jerry_value_t value);
+jerry_value_t jerry_get_typedarray_buffer (jerry_value_t value,
+ jerry_length_t *byte_offset,
+ jerry_length_t *byte_length);
+jerry_value_t jerry_json_parse (const jerry_char_t *string_p, jerry_size_t string_size);
+jerry_value_t jerry_json_stringfy (const jerry_value_t object_to_stringify);
/**
* @}
struct jerry_instance_t *jerry_port_get_current_instance (void);
/**
+ * Makes the process sleep for a given time.
+ */
+#ifdef JERRY_DEBUGGER
+void jerry_port_sleep (uint32_t sleep_time);
+#endif /* JERRY_DEBUGGER */
+
+/**
* @}
*/
*/
/**
+ * Flags for jerry_generate_snapshot and jerry_generate_function_snapshot.
+ */
+typedef enum
+{
+ JERRY_SNAPSHOT_SAVE_STATIC = (1u << 0), /**< static snapshot */
+ JERRY_SNAPSHOT_SAVE_STRICT = (1u << 1), /**< strict mode code */
+} jerry_generate_snapshot_opts_t;
+
+/**
+ * Flags for jerry_exec_snapshot_at and jerry_load_function_snapshot_at.
+ */
+typedef enum
+{
+ JERRY_SNAPSHOT_EXEC_COPY_DATA = (1u << 0), /**< copy snashot data */
+ JERRY_SNAPSHOT_EXEC_ALLOW_STATIC = (1u << 1), /**< static snapshots allowed */
+} jerry_exec_snapshot_opts_t;
+
+/**
* Snapshot functions.
*/
-size_t jerry_parse_and_save_snapshot (const jerry_char_t *source_p, size_t source_size, bool is_for_global,
- bool is_strict, uint32_t *buffer_p, size_t buffer_size);
-jerry_value_t jerry_exec_snapshot (const uint32_t *snapshot_p, size_t snapshot_size, bool copy_bytecode);
-jerry_value_t jerry_exec_snapshot_at (const uint32_t *snapshot_p, size_t snapshot_size,
- size_t func_index, bool copy_bytecode);
+jerry_value_t jerry_generate_snapshot (const jerry_char_t *resource_name_p, size_t resource_name_length,
+ const jerry_char_t *source_p, size_t source_size,
+ uint32_t generate_snapshot_opts, uint32_t *buffer_p, size_t buffer_size);
+jerry_value_t jerry_generate_function_snapshot (const jerry_char_t *resource_name_p, size_t resource_name_length,
+ const jerry_char_t *source_p, size_t source_size,
+ const jerry_char_t *args_p, size_t args_size,
+ uint32_t generate_snapshot_opts, uint32_t *buffer_p,
+ size_t buffer_size);
+
+jerry_value_t jerry_exec_snapshot (const uint32_t *snapshot_p, size_t snapshot_size,
+ size_t func_index, uint32_t exec_snapshot_opts);
+jerry_value_t jerry_load_function_snapshot (const uint32_t *function_snapshot_p,
+ const size_t function_snapshot_size,
+ size_t func_index, uint32_t exec_snapshot_opts);
+
size_t jerry_merge_snapshots (const uint32_t **inp_buffers_p, size_t *inp_buffer_sizes_p, size_t number_of_snapshots,
uint32_t *out_buffer_p, size_t out_buffer_size, const char **error_p);
size_t jerry_parse_and_save_literals (const jerry_char_t *source_p, size_t source_size, bool is_strict,
uint32_t *buffer_p, size_t buffer_size, bool is_c_format);
-
-size_t jerry_parse_and_save_function_snapshot (const jerry_char_t *source_p, size_t source_size,
- const jerry_char_t *args_p, size_t args_size,
- bool is_strict, uint32_t *buffer_p, size_t buffer_size);
-jerry_value_t jerry_load_function_snapshot_at (const uint32_t *function_snapshot_p,
- const size_t function_snapshot_size,
- size_t func_index,
- bool copy_bytecode);
/**
* @}
*/
ecma_value_t error_value; /**< currently thrown error value */
uint32_t lit_magic_string_ex_count; /**< external magic strings count */
uint32_t jerry_init_flags; /**< run-time configuration flags */
- uint8_t is_direct_eval_form_call; /**< direct call from eval */
- uint8_t jerry_api_available; /**< API availability flag */
+ uint32_t status_flags; /**< run-time flags */
#ifndef CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE
uint8_t ecma_prop_hashmap_alloc_state; /**< property hashmap allocation state: 0-4,
* if !0 property hashmap allocation is disabled */
- bool ecma_prop_hashmap_alloc_last_is_hs_gc; /**< true, if and only if the last gc action was a high severity gc */
#endif /* !CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE */
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
#ifdef JERRY_DEBUGGER
uint8_t debugger_send_buffer[JERRY_DEBUGGER_MAX_BUFFER_SIZE]; /**< buffer for sending messages */
uint8_t debugger_receive_buffer[JERRY_DEBUGGER_MAX_BUFFER_SIZE]; /**< buffer for receiving messages */
+ uint8_t *debugger_send_buffer_payload_p; /**< start where the outgoing message can be written */
vm_frame_ctx_t *debugger_stop_context; /**< stop only if the current context is equal to this context */
jmem_cpointer_t debugger_byte_code_free_head; /**< head of byte code free linked list */
jmem_cpointer_t debugger_byte_code_free_tail; /**< tail of byte code free linked list */
- uint8_t debugger_flags; /**< debugger flags */
- uint8_t debugger_message_delay; /**< call receive message when reaches zero */
+ uint32_t debugger_flags; /**< debugger flags */
uint16_t debugger_receive_buffer_offset; /**< receive buffer offset */
- int debugger_connection; /**< holds the file descriptor of the socket communication */
uint16_t debugger_port; /**< debugger socket communication port */
+ uint8_t debugger_message_delay; /**< call receive message when reaches zero */
+ uint8_t debugger_max_send_size; /**< maximum amount of data that can be written */
+ uint8_t debugger_max_receive_size; /**< maximum amount of data that can be received */
+ int debugger_connection; /**< holds the file descriptor of the socket communication */
#endif /* JERRY_DEBUGGER */
+#ifdef JERRY_ENABLE_LINE_INFO
+ ecma_value_t resource_name; /**< resource name (usually a file name) */
+#endif /* JERRY_ENABLE_LINE_INFO */
+
#ifdef JMEM_STATS
jmem_heap_stats_t jmem_heap_stats; /**< heap's memory usage statistics */
#endif /* JMEM_STATS */
#ifndef JRT_H
#define JRT_H
+#if !defined (_XOPEN_SOURCE) || _XOPEN_SOURCE < 500
+#undef _XOPEN_SOURCE
/* Required macro for sleep functions (nanosleep or usleep) */
#define _XOPEN_SOURCE 500
+#endif
#include <stdio.h>
#include <string.h>
return 2;
}
- JERRY_ASSERT (!(chr & ~LIT_UTF8_3_BYTE_CODE_POINT_MAX));
/* zzzzyyyy yyxxxxxx -> 1110zzzz 10yyyyyy 10xxxxxx */
*(dst_p++) = (uint8_t) (LIT_UTF8_3_BYTE_MARKER | ((chr >> 12) & LIT_UTF8_LAST_4_BITS_MASK));
*(dst_p++) = (uint8_t) (LIT_UTF8_EXTRA_BYTE_MARKER | ((chr >> 6) & LIT_UTF8_LAST_6_BITS_MASK));
}
/* zzzzyyyy yyxxxxxx */
- JERRY_ASSERT (!(chr & ~LIT_UTF8_3_BYTE_CODE_POINT_MAX));
return 3;
} /* lit_char_get_utf8_length */
/* Stack consumption of opcodes with context. */
/* PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION must be <= 4 */
-#define PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION 3
+#define PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION 4
/* PARSER_WITH_CONTEXT_STACK_ALLOCATION must be <= 4 */
#define PARSER_WITH_CONTEXT_STACK_ALLOCATION 2
/* PARSER_TRY_CONTEXT_STACK_ALLOCATION must be <= 3 */
/* Basic opcodes. */ \
CBC_OPCODE (CBC_EXT_DEBUGGER, CBC_NO_FLAG, 0, \
VM_OC_NONE) \
+ CBC_OPCODE (CBC_EXT_RESOURCE_NAME, CBC_NO_FLAG, 0, \
+ VM_OC_RESOURCE_NAME) \
+ CBC_OPCODE (CBC_EXT_LINE, CBC_NO_FLAG, 0, \
+ VM_OC_LINE) \
\
/* Binary compound assignment opcodes with pushing the result. */ \
CBC_EXT_BINARY_LVALUE_OPERATION (CBC_EXT_ASSIGN_ADD, \
uint16_t ident_end; /**< end position of the identifier group */
uint16_t const_literal_end; /**< end position of the const literal group */
uint16_t literal_end; /**< end position of the literal group */
-#ifdef JERRY_CPOINTER_32_BIT
uint16_t padding; /**< an unused value */
-#endif
} cbc_uint16_arguments_t;
/**
CBC_CODE_FLAGS_UINT16_ARGUMENTS = (1u << 2), /**< compiled code data is cbc_uint16_arguments_t */
CBC_CODE_FLAGS_STRICT_MODE = (1u << 3), /**< strict mode is enabled */
CBC_CODE_FLAGS_ARGUMENTS_NEEDED = (1u << 4), /**< arguments object must be constructed */
- CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED = (1u << 5), /**< no need to create a lexical environment */
- CBC_CODE_FLAGS_DEBUGGER_IGNORE = (1u << 6), /**< this function should be ignored by debugger */
+ CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED = (1u << 5), /**< non-strict arguments object must be constructed */
+ CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED = (1u << 6), /**< no need to create a lexical environment */
CBC_CODE_FLAGS_ARROW_FUNCTION = (1u << 7), /**< this function is an arrow function */
+ CBC_CODE_FLAGS_STATIC_FUNCTION = (1u << 8), /**< this function is a static snapshot function */
+ CBC_CODE_FLAGS_DEBUGGER_IGNORE = (1u << 9), /**< this function should be ignored by debugger */
} cbc_code_flags;
#define CBC_OPCODE(arg1, arg2, arg3, arg4) arg1,
}
else if (literal_p->type == LEXER_NUMBER_LITERAL)
{
- ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, literal_p->u.value);
-
- JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (value_p) == ECMA_STRING_LITERAL_NUMBER);
-
JERRY_DEBUG_MSG ("number(");
- util_print_number (ecma_get_number_from_value (value_p->u.lit_number));
+ util_print_number (ecma_get_number_from_value (literal_p->u.value));
}
else if (literal_p->type == LEXER_REGEXP_LITERAL)
{
#define LEXER_FLAG_LATE_INIT 0x80
/**
+ * Type of property length.
+ */
+#ifdef JERRY_CPOINTER_32_BIT
+typedef uint32_t prop_length_t;
+#else /* !JERRY_CPOINTER_32_BIT */
+typedef uint16_t prop_length_t;
+#endif /* JERRY_CPOINTER_32_BIT */
+
+/**
* Literal data.
*/
typedef struct
{
union
{
- jmem_cpointer_t value; /**< literal value (not processed by the parser) */
+ ecma_value_t value; /**< literal value (not processed by the parser) */
const uint8_t *char_p; /**< character value */
ecma_compiled_code_t *bytecode_p; /**< compiled function or regexp pointer */
uint32_t source_data; /**< encoded source literal */
union
#endif /* PARSER_DUMP_BYTE_CODE */
{
- uint16_t length; /**< length of ident / string literal */
+ prop_length_t length; /**< length of ident / string literal */
uint16_t index; /**< real index during post processing */
} prop;
{
/* Fill literal data. */
context_p->token.lit_location.char_p = ident_start_p;
- context_p->token.lit_location.length = (uint16_t) length;
+ context_p->token.lit_location.length = (prop_length_t) length;
}
context_p->source_p = source_p;
/* Fill literal data. */
context_p->token.lit_location.char_p = string_start_p;
- context_p->token.lit_location.length = (uint16_t) length;
+ context_p->token.lit_location.length = (prop_length_t) length;
context_p->token.lit_location.type = LEXER_STRING_LITERAL;
context_p->token.lit_location.has_escape = has_escape;
parser_raise_error (context_p, PARSER_ERR_NUMBER_TOO_LONG);
}
- context_p->token.lit_location.length = (uint16_t) length;
+ context_p->token.lit_location.length = (prop_length_t) length;
PARSER_PLUS_EQUAL_LC (context_p->column, length);
context_p->source_p = source_p;
} /* lexer_parse_number */
}
literal_p = (lexer_literal_t *) parser_list_append (context_p, &context_p->literal_pool);
- literal_p->prop.length = (uint16_t) length;
+ literal_p->prop.length = (prop_length_t) length;
literal_p->type = literal_type;
literal_p->status_flags = has_escape ? 0 : LEXER_FLAG_SOURCE_PTR;
lexer_literal_t *literal_p;
ecma_number_t num;
uint32_t literal_index = 0;
- uint16_t length = context_p->token.lit_location.length;
+ prop_length_t length = context_p->token.lit_location.length;
if (context_p->token.extra_value != LEXER_NUMBER_OCTAL)
{
num = -num;
}
- jmem_cpointer_t lit_cp = ecma_find_or_create_literal_number (num);
+ ecma_value_t lit_value = ecma_find_or_create_literal_number (num);
parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
while ((literal_p = (lexer_literal_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
{
if (literal_p->type == LEXER_NUMBER_LITERAL
- && literal_p->u.value == lit_cp)
+ && literal_p->u.value == lit_value)
{
context_p->lit_object.literal_p = literal_p;
context_p->lit_object.index = (uint16_t) literal_index;
context_p->literal_count++;
- literal_p->u.value = lit_cp;
+ literal_p->u.value = lit_value;
literal_p->type = LEXER_NUMBER_LITERAL;
context_p->lit_object.literal_p = literal_p;
}
literal_p = (lexer_literal_t *) parser_list_append (context_p, &context_p->literal_pool);
- literal_p->prop.length = (uint16_t) length;
+ literal_p->prop.length = (prop_length_t) length;
literal_p->type = LEXER_UNUSED_LITERAL;
literal_p->status_flags = 0;
typedef struct
{
const uint8_t *char_p; /**< start of identifier or string token */
- uint16_t length; /**< length or index of a literal */
+ prop_length_t length; /**< length or index of a literal */
uint8_t type; /**< type of the current literal */
uint8_t has_escape; /**< has escape sequences */
} lexer_lit_location_t;
#endif /* PARSER_DUMP_BYTE_CODE */
#ifdef JERRY_DEBUGGER
- parser_breakpoint_info_t breakpoint_info[JERRY_DEBUGGER_SEND_MAX (parser_list_t)]; /**< extra data for breakpoints */
+ /** extra data for each breakpoint */
+ parser_breakpoint_info_t breakpoint_info[JERRY_DEBUGGER_MAX_BUFFER_SIZE / sizeof (parser_breakpoint_info_t)];
uint16_t breakpoint_info_count; /**< current breakpoint index */
- parser_line_counter_t last_breakpoint_line; /**< last line where breakpoint was inserted */
+ parser_line_counter_t last_breakpoint_line; /**< last line where breakpoint has been inserted */
#endif /* JERRY_DEBUGGER */
+
+#ifdef JERRY_ENABLE_LINE_INFO
+ parser_line_counter_t last_line_info_line; /**< last line where line info has been inserted */
+#endif /* JERRY_ENABLE_LINE_INFO */
} parser_context_t;
/**
#endif /* JERRY_DEBUGGER */
+#ifdef JERRY_ENABLE_LINE_INFO
+
+void parser_emit_line_info (parser_context_t *context_p, uint32_t line, bool flush_cbc);
+
+#endif /* JERRY_ENABLE_LINE_INFO */
+
/**
* @}
* @}
#define PARSER_MAXIMUM_IDENT_LENGTH 255
#endif /* !PARSER_MAXIMUM_IDENT_LENGTH */
+/* Maximum string limit.
+ * Limit: 2147483647 / 65535. */
+#ifdef JERRY_CPOINTER_32_BIT
+#define PARSER_MAXIMUM_STRING_LIMIT 2147483647
+#else /* !JERRY_CPOINTER_32_BIT */
+#define PARSER_MAXIMUM_STRING_LIMIT 65535
+#endif /* JERRY_CPOINTER_32_BIT */
+
/* Maximum string length.
- * Limit: 65535. */
+ * Limit: PARSER_MAXIMUM_STRING_LIMIT. */
#ifndef PARSER_MAXIMUM_STRING_LENGTH
-#define PARSER_MAXIMUM_STRING_LENGTH 65535
+#define PARSER_MAXIMUM_STRING_LENGTH PARSER_MAXIMUM_STRING_LIMIT
#endif /* !PARSER_MAXIMUM_STRING_LENGTH */
/* Maximum number of literals.
/* Checks. */
-#if (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > 65535)
+#if (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > PARSER_MAXIMUM_STRING_LIMIT)
#error "Maximum string length is not within range."
-#endif /* (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > 65535) */
+#endif /* (PARSER_MAXIMUM_STRING_LENGTH < 1) || (PARSER_MAXIMUM_STRING_LENGTH > PARSER_MAXIMUM_STRING_LIMIT) */
#if (PARSER_MAXIMUM_IDENT_LENGTH < 1) || (PARSER_MAXIMUM_IDENT_LENGTH > PARSER_MAXIMUM_STRING_LENGTH)
#error "Maximum identifier length is not within range."
#ifndef JERRY_DISABLE_JS_PARSER
-#ifdef JERRY_DEBUGGER
+#if defined (JERRY_DEBUGGER) || defined (JERRY_ENABLE_LINE_INFO)
#include "jcontext.h"
-#endif /*JERRY_DEBUGGER */
+#endif /* JERRY_DEBUGGER || JERRY_ENABLE_LINE_INFO */
/** \addtogroup parser Parser
* @{
JERRY_ASSERT (context_p->token.type == LEXER_LITERAL
&& context_p->token.lit_location.type == LEXER_IDENT_LITERAL);
-#ifdef JERRY_DEBUGGER
+#if defined (JERRY_DEBUGGER) || defined (JERRY_ENABLE_LINE_INFO)
parser_line_counter_t ident_line_counter = context_p->token.line;
-#endif /* JERRY_DEBUGGER */
+#endif /* JERRY_DEBUGGER || JERRY_ENABLE_LINE_INFO */
context_p->lit_object.literal_p->status_flags |= LEXER_FLAG_VAR;
}
#endif /* JERRY_DEBUGGER */
+#ifdef JERRY_ENABLE_LINE_INFO
+ if (ident_line_counter != context_p->last_line_info_line)
+ {
+ parser_emit_line_info (context_p, ident_line_counter, false);
+ }
+#endif /* JERRY_ENABLE_LINE_INFO */
+
parser_parse_expression (context_p,
PARSE_EXPR_STATEMENT | PARSE_EXPR_NO_COMMA | PARSE_EXPR_HAS_LITERAL);
}
switch_case_was_found = false;
default_case_was_found = false;
+#ifdef JERRY_ENABLE_LINE_INFO
+ uint32_t last_line_info_line = context_p->last_line_info_line;
+#endif /* JERRY_ENABLE_LINE_INFO */
+
while (true)
{
parser_scan_until (context_p, &unused_range, LEXER_KEYW_CASE);
lexer_next_token (context_p);
+#ifdef JERRY_ENABLE_LINE_INFO
+ if (context_p->token.line != context_p->last_line_info_line)
+ {
+ parser_emit_line_info (context_p, context_p->token.line, true);
+ }
+#endif /* JERRY_ENABLE_LINE_INFO */
+
parser_parse_expression (context_p, PARSE_EXPR);
if (context_p->token.type != LEXER_COLON)
JERRY_ASSERT (switch_case_was_found || default_case_was_found);
+#ifdef JERRY_ENABLE_LINE_INFO
+ context_p->last_line_info_line = last_line_info_line;
+#endif /* JERRY_ENABLE_LINE_INFO */
+
if (!switch_case_was_found)
{
/* There was no case statement, so the expression result
}
#endif /* JERRY_DEBUGGER */
+#ifdef JERRY_ENABLE_LINE_INFO
+ if (JERRY_CONTEXT (resource_name) != ECMA_VALUE_UNDEFINED)
+ {
+ parser_emit_cbc_ext (context_p, CBC_EXT_RESOURCE_NAME);
+ parser_flush_cbc (context_p);
+ }
+ context_p->last_line_info_line = 0;
+#endif /* JERRY_ENABLE_LINE_INFO */
+
while (context_p->token.type == LEXER_LITERAL
&& context_p->token.lit_location.type == LEXER_STRING_LITERAL)
{
context_p->last_breakpoint_line = context_p->token.line;
}
#endif /* JERRY_DEBUGGER */
+#ifdef JERRY_ENABLE_LINE_INFO
+ parser_emit_line_info (context_p, context_p->token.line, false);
+#endif /* JERRY_ENABLE_LINE_INFO */
lexer_construct_literal_object (context_p, &lit_location, LEXER_STRING_LITERAL);
parser_emit_cbc_literal_from_token (context_p, CBC_PUSH_LITERAL);
}
#endif /* JERRY_DEBUGGER */
+#ifdef JERRY_ENABLE_LINE_INFO
+ if (context_p->token.line != context_p->last_line_info_line
+ && context_p->token.type != LEXER_SEMICOLON
+ && context_p->token.type != LEXER_LEFT_BRACE
+ && context_p->token.type != LEXER_RIGHT_BRACE
+ && context_p->token.type != LEXER_KEYW_VAR
+ && context_p->token.type != LEXER_KEYW_FUNCTION
+ && context_p->token.type != LEXER_KEYW_CASE
+ && context_p->token.type != LEXER_KEYW_DEFAULT)
+ {
+ parser_emit_line_info (context_p, context_p->token.line, true);
+ }
+#endif /* JERRY_ENABLE_LINE_INFO */
+
switch (context_p->token.type)
{
case LEXER_SEMICOLON:
#ifndef JERRY_DISABLE_JS_PARSER
+#ifdef JERRY_ENABLE_LINE_INFO
+#include "jcontext.h"
+#endif /* JERRY_ENABLE_LINE_INFO */
+
/** \addtogroup parser Parser
* @{
*
}
} /* parser_emit_cbc_push_number */
+#ifdef JERRY_ENABLE_LINE_INFO
+
+/**
+ * Append a line info data
+ */
+void
+parser_emit_line_info (parser_context_t *context_p, /**< context */
+ uint32_t line, /**< current line */
+ bool flush_cbc) /**< flush last byte code */
+{
+ if (JERRY_CONTEXT (resource_name) == ECMA_VALUE_UNDEFINED)
+ {
+ return;
+ }
+
+ if (flush_cbc && context_p->last_cbc_opcode != PARSER_CBC_UNAVAILABLE)
+ {
+ parser_flush_cbc (context_p);
+ }
+
+#ifdef PARSER_DUMP_BYTE_CODE
+ if (context_p->is_show_opcodes)
+ {
+ JERRY_DEBUG_MSG (" [%3d] CBC_EXT_LINE %d\n", (int) context_p->stack_depth, line);
+ }
+#endif /* PARSER_DUMP_BYTE_CODE */
+
+ parser_emit_two_bytes (context_p, CBC_EXT_OPCODE, CBC_EXT_LINE);
+ context_p->byte_code_size += 2;
+
+ context_p->last_line_info_line = line;
+
+ do
+ {
+ uint8_t byte = (uint8_t) (line & CBC_LOWER_SEVEN_BIT_MASK);
+
+ line >>= 7;
+
+ if (line > 0)
+ {
+ byte = (uint8_t) (byte | CBC_HIGHEST_BIT_MASK);
+ }
+
+ PARSER_APPEND_TO_BYTE_CODE (context_p, byte);
+ context_p->byte_code_size++;
+ }
+ while (line > 0);
+} /* parser_emit_line_info */
+
+#endif /* JERRY_ENABLE_LINE_INFO */
+
/**
* Append a byte code with a branch argument
*/
/* The literal data is updated at every iteration to handle out-of memory. */
parent_p->literal_pool_data = parent_literal_pool.data;
- parent_literal_p->prop.length = (uint16_t) length;
+ parent_literal_p->prop.length = (prop_length_t) length;
parent_literal_p->type = LEXER_IDENT_LITERAL;
parent_literal_p->status_flags = (uint8_t) (literal_p->status_flags & LEXER_FLAG_SOURCE_PTR);
parent_literal_p->status_flags |= LEXER_FLAG_NO_REG_STORE | LEXER_FLAG_UNUSED_IDENT;
static uint8_t *
parser_generate_initializers (parser_context_t *context_p, /**< context */
uint8_t *dst_p, /**< destination buffer */
- jmem_cpointer_t *literal_pool_p, /**< start of literal pool */
+ ecma_value_t *literal_pool_p, /**< start of literal pool */
uint16_t uninitialized_var_end, /**< end of the uninitialized var group */
uint16_t initialized_var_end, /**< end of the initialized var group */
uint16_t const_literal_end, /**< end of the const literal group */
{
parser_list_iterator_t literal_iterator;
lexer_literal_t *literal_p;
- uint16_t argument_count;
+ uint16_t argument_count, register_count;
if (uninitialized_var_end > context_p->register_count)
{
parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
argument_count = 0;
+ register_count = context_p->register_count;
while ((literal_p = (lexer_literal_t *) parser_list_iterator_next (&literal_iterator)))
{
if (literal_p->type == LEXER_IDENT_LITERAL
|| literal_p->type == LEXER_STRING_LITERAL)
{
-#ifdef PARSER_DUMP_BYTE_CODE
- if (!(literal_p->status_flags & LEXER_FLAG_UNUSED_IDENT))
+ if (literal_p->prop.index >= register_count)
{
- jmem_cpointer_t lit_cp = ecma_find_or_create_literal_string (literal_p->u.char_p,
- literal_p->prop.length);
- literal_pool_p[literal_p->prop.index] = lit_cp;
- }
+#ifdef PARSER_DUMP_BYTE_CODE
+ if (!(literal_p->status_flags & LEXER_FLAG_UNUSED_IDENT))
+ {
+ ecma_value_t lit_value = ecma_find_or_create_literal_string (literal_p->u.char_p,
+ literal_p->prop.length);
+ literal_pool_p[literal_p->prop.index] = lit_value;
+ }
- if (!context_p->is_show_opcodes
- && !(literal_p->status_flags & LEXER_FLAG_SOURCE_PTR))
- {
- jmem_heap_free_block ((void *) literal_p->u.char_p, literal_p->prop.length);
- }
+ if (!context_p->is_show_opcodes
+ && !(literal_p->status_flags & LEXER_FLAG_SOURCE_PTR))
+ {
+ jmem_heap_free_block ((void *) literal_p->u.char_p, literal_p->prop.length);
+ }
#else /* !PARSER_DUMP_BYTE_CODE */
- if (!(literal_p->status_flags & LEXER_FLAG_UNUSED_IDENT))
- {
- literal_pool_p[literal_p->prop.index] = literal_p->u.value;
- }
+ if (!(literal_p->status_flags & LEXER_FLAG_UNUSED_IDENT))
+ {
+ literal_pool_p[literal_p->prop.index] = literal_p->u.value;
+ }
#endif /* PARSER_DUMP_BYTE_CODE */
+ }
}
else if ((literal_p->type == LEXER_FUNCTION_LITERAL)
|| (literal_p->type == LEXER_REGEXP_LITERAL))
{
- ECMA_SET_NON_NULL_POINTER (literal_pool_p[literal_p->prop.index],
- literal_p->u.bytecode_p);
+ JERRY_ASSERT (literal_p->prop.index >= register_count);
+
+ ECMA_SET_INTERNAL_VALUE_POINTER (literal_pool_p[literal_p->prop.index],
+ literal_p->u.bytecode_p);
}
else
{
- JERRY_ASSERT (literal_p->type == LEXER_NUMBER_LITERAL);
+ JERRY_ASSERT (literal_p->type == LEXER_NUMBER_LITERAL
+ && literal_p->prop.index >= register_count);
+
literal_pool_p[literal_p->prop.index] = literal_p->u.value;
}
}
JERRY_ASSERT (literal_p != NULL
&& literal_p->type == LEXER_FUNCTION_LITERAL);
+
init_index = literal_p->prop.index;
- ECMA_SET_NON_NULL_POINTER (literal_pool_p[literal_p->prop.index],
- literal_p->u.bytecode_p);
+ JERRY_ASSERT (init_index >= register_count);
+
+ ECMA_SET_INTERNAL_VALUE_POINTER (literal_pool_p[init_index],
+ literal_p->u.bytecode_p);
}
*dst_p++ = CBC_INITIALIZE_VAR;
byte_code_start_p += sizeof (cbc_uint8_arguments_t);
}
- byte_code_start_p += literal_end * sizeof (jmem_cpointer_t);
+ byte_code_start_p += (unsigned int) (literal_end - register_end) * sizeof (ecma_value_t);
+ if (unlikely (compiled_code_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED))
+ {
+ byte_code_start_p += argument_end * sizeof (ecma_value_t);
+ }
+
byte_code_end_p = byte_code_start_p + length;
byte_code_p = byte_code_start_p;
flags = cbc_ext_flags[ext_opcode];
JERRY_DEBUG_MSG (" %3d : %s", (int) cbc_offset, cbc_ext_names[ext_opcode]);
byte_code_p += 2;
+
+#ifdef JERRY_ENABLE_LINE_INFO
+ if (ext_opcode == CBC_EXT_LINE)
+ {
+ uint32_t value = 0;
+ uint8_t byte;
+
+ do
+ {
+ byte = *byte_code_p++;
+ value = (value << 7) | (byte & CBC_LOWER_SEVEN_BIT_MASK);
+ }
+ while (byte & CBC_HIGHEST_BIT_MASK);
+
+ JERRY_DEBUG_MSG (" %d\n", (int) value);
+ continue;
+ }
+#endif /* JERRY_ENABLE_LINE_INFO */
}
if (flags & (CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2))
size_t last_position;
size_t offset;
size_t length;
+ size_t literal_length;
size_t total_size;
+#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
+ size_t total_size_used;
+#endif
size_t initializers_length;
uint8_t real_offset;
uint8_t *byte_code_p;
bool needs_uint16_arguments;
cbc_opcode_t last_opcode = CBC_EXT_OPCODE;
ecma_compiled_code_t *compiled_code_p;
- jmem_cpointer_t *literal_pool_p;
+ ecma_value_t *literal_pool_p;
uint8_t *dst_p;
if ((size_t) context_p->stack_limit + (size_t) context_p->register_count > PARSER_MAXIMUM_STACK_LIMIT)
flags = cbc_ext_flags[ext_opcode];
PARSER_NEXT_BYTE (page_p, offset);
length++;
+
+#ifdef JERRY_ENABLE_LINE_INFO
+ if (ext_opcode == CBC_EXT_LINE)
+ {
+ uint8_t last_byte = 0;
+
+ do
+ {
+ last_byte = page_p->bytes[offset];
+ PARSER_NEXT_BYTE (page_p, offset);
+ length++;
+ }
+ while (last_byte & CBC_HIGHEST_BIT_MASK);
+
+ continue;
+ }
+#endif /* JERRY_ENABLE_LINE_INFO */
}
while (flags & (CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2))
total_size = sizeof (cbc_uint16_arguments_t);
}
- total_size += length + context_p->literal_count * sizeof (jmem_cpointer_t);
+ literal_length = (size_t) (context_p->literal_count - context_p->register_count) * sizeof (ecma_value_t);
+
+ total_size += literal_length + length;
+
+ if ((context_p->status_flags & PARSER_ARGUMENTS_NEEDED)
+ && !(context_p->status_flags & PARSER_IS_STRICT))
+ {
+ total_size += context_p->argument_count * sizeof (ecma_value_t);
+ }
+
+#ifdef JERRY_ENABLE_LINE_INFO
+ if (JERRY_CONTEXT (resource_name) != ECMA_VALUE_UNDEFINED)
+ {
+ total_size += sizeof (ecma_value_t);
+ }
+#endif /* JERRY_ENABLE_LINE_INFO */
+
+#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
+ total_size_used = total_size;
+#endif
total_size = JERRY_ALIGNUP (total_size, JMEM_ALIGNMENT);
compiled_code_p = (ecma_compiled_code_t *) parser_malloc (context_p, total_size);
+#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
+ // Avoid getting junk bytes at the end when bytes at the end remain unused:
+ if (total_size_used < total_size)
+ {
+ memset (((uint8_t *) compiled_code_p) + total_size_used, 0, total_size - total_size_used);
+ }
+#endif
+
#ifdef JMEM_STATS
jmem_stats_allocate_byte_code_bytes (total_size);
#endif /* JMEM_STATS */
if (context_p->status_flags & PARSER_ARGUMENTS_NEEDED)
{
compiled_code_p->status_flags |= CBC_CODE_FLAGS_ARGUMENTS_NEEDED;
+
+ if (!(context_p->status_flags & PARSER_IS_STRICT))
+ {
+ compiled_code_p->status_flags |= CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED;
+ }
+
/* Arguments is stored in the lexical environment. */
context_p->status_flags |= PARSER_LEXICAL_ENV_NEEDED;
}
}
#endif /* !CONFIG_DISABLE_ES2015_ARROW_FUNCTION */
- literal_pool_p = (jmem_cpointer_t *) byte_code_p;
- byte_code_p += context_p->literal_count * sizeof (jmem_cpointer_t);
+ literal_pool_p = (ecma_value_t *) byte_code_p;
+ literal_pool_p -= context_p->register_count;
+ byte_code_p += literal_length;
dst_p = parser_generate_initializers (context_p,
byte_code_p,
opcode_p++;
real_offset++;
PARSER_NEXT_BYTE_UPDATE (page_p, offset, real_offset);
+
+#ifdef JERRY_ENABLE_LINE_INFO
+ if (ext_opcode == CBC_EXT_LINE)
+ {
+ uint8_t last_byte = 0;
+
+ do
+ {
+ last_byte = page_p->bytes[offset];
+ *dst_p++ = last_byte;
+
+ real_offset++;
+ PARSER_NEXT_BYTE_UPDATE (page_p, offset, real_offset);
+ }
+ while (last_byte & CBC_HIGHEST_BIT_MASK);
+
+ continue;
+ }
+#endif /* JERRY_ENABLE_LINE_INFO */
}
if (flags & CBC_HAS_BRANCH_ARG)
{
parser_list_iterator_t literal_iterator;
lexer_literal_t *literal_p;
+ uint16_t register_count = context_p->register_count;
parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
while ((literal_p = (lexer_literal_t *) parser_list_iterator_next (&literal_iterator)))
{
- if (literal_p->status_flags & LEXER_FLAG_LATE_INIT)
+ if ((literal_p->status_flags & LEXER_FLAG_LATE_INIT)
+ && literal_p->prop.index >= register_count)
{
uint32_t source_data = literal_p->u.source_data;
const uint8_t *char_p = context_p->source_end_p - (source_data & 0xfffff);
- jmem_cpointer_t lit_cp = ecma_find_or_create_literal_string (char_p,
+ ecma_value_t lit_value = ecma_find_or_create_literal_string (char_p,
source_data >> 20);
- literal_pool_p[literal_p->prop.index] = lit_cp;
+ literal_pool_p[literal_p->prop.index] = lit_value;
}
}
}
{
parser_list_iterator_t literal_iterator;
uint16_t argument_count = 0;
+ uint16_t register_count = context_p->register_count;
+ ecma_value_t *argument_base_p = (ecma_value_t *) (((uint8_t *) compiled_code_p) + total_size);
+ argument_base_p -= context_p->argument_count;
parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
while (argument_count < context_p->argument_count)
{
if (literal_p->u.char_p == NULL)
{
- literal_pool_p[argument_count] = JMEM_CP_NULL;
+ argument_base_p[argument_count] = ECMA_VALUE_EMPTY;
argument_count++;
continue;
}
JERRY_ASSERT (literal_p->type == LEXER_IDENT_LITERAL
&& (literal_p->status_flags & LEXER_FLAG_VAR));
- JERRY_ASSERT (argument_count < literal_p->prop.index);
+ JERRY_ASSERT (literal_p->prop.index >= register_count);
- literal_pool_p[argument_count] = literal_pool_p[literal_p->prop.index];
+ argument_base_p[argument_count] = literal_pool_p[literal_p->prop.index];
argument_count++;
}
}
+#ifdef JERRY_ENABLE_LINE_INFO
+ if (JERRY_CONTEXT (resource_name) != ECMA_VALUE_UNDEFINED)
+ {
+ ecma_value_t *resource_name_p = (ecma_value_t *) (((uint8_t *) compiled_code_p) + total_size);
+
+ if ((context_p->status_flags & PARSER_ARGUMENTS_NEEDED)
+ && !(context_p->status_flags & PARSER_IS_STRICT))
+ {
+ resource_name_p -= context_p->argument_count;
+ }
+
+ resource_name_p[-1] = JERRY_CONTEXT (resource_name);
+ }
+#endif /* JERRY_ENABLE_LINE_INFO */
+
if (context_p->status_flags & PARSER_NAMED_FUNCTION_EXP)
{
- ECMA_SET_NON_NULL_POINTER (literal_pool_p[const_literal_end],
- compiled_code_p);
+ ECMA_SET_INTERNAL_VALUE_POINTER (literal_pool_p[const_literal_end],
+ compiled_code_p);
}
#ifdef JERRY_DEBUGGER
JERRY_ASSERT (context_p->last_cbc_opcode == PARSER_CBC_UNAVAILABLE);
#ifdef JERRY_DEBUGGER
- if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED
+ if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
&& context_p->breakpoint_info_count > 0)
{
parser_send_breakpoints (context_p, JERRY_DEBUGGER_BREAKPOINT_LIST);
context_p->status_flags |= PARSER_DEBUGGER_BREAKPOINT_APPENDED;
- if (context_p->breakpoint_info_count >= JERRY_DEBUGGER_SEND_MAX (parser_list_t))
+ if (context_p->breakpoint_info_count >= JERRY_DEBUGGER_SEND_MAX (parser_breakpoint_info_t))
{
parser_send_breakpoints (context_p, type);
}
/* It is unlikely that memory can be allocated in an out-of-memory
* situation. However, a simple value can still be thrown. */
JERRY_CONTEXT (error_value) = ECMA_VALUE_NULL;
+ JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
return ECMA_VALUE_ERROR;
}
#ifdef JERRY_ENABLE_ERROR_MESSAGES
return ecma_raise_syntax_error ("");
#endif /* JERRY_ENABLE_ERROR_MESSAGES */
}
+
+#ifdef JERRY_DEBUGGER
+ if ((JERRY_CONTEXT (debugger_flags) & (JERRY_DEBUGGER_CONNECTED | JERRY_DEBUGGER_PARSER_WAIT))
+ == (JERRY_DEBUGGER_CONNECTED | JERRY_DEBUGGER_PARSER_WAIT))
+ {
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_PARSER_WAIT_MODE);
+ jerry_debugger_send_type (JERRY_DEBUGGER_WAITING_AFTER_PARSE);
+
+ while (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_PARSER_WAIT_MODE)
+ {
+ jerry_debugger_receive (NULL);
+
+ if (!(JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED))
+ {
+ break;
+ }
+
+ jerry_debugger_sleep ();
+ }
+ }
+#endif /* JERRY_DEBUGGER */
+
return ECMA_VALUE_TRUE;
#else /* JERRY_DISABLE_JS_PARSER */
JERRY_UNUSED (arg_list_p);
typedef struct
{
ecma_compiled_code_t header; /**< compiled code header */
- jmem_cpointer_t pattern_cp; /**< original RegExp pattern */
+ ecma_value_t pattern; /**< original RegExp pattern */
uint32_t num_of_captures; /**< number of capturing brackets */
uint32_t num_of_non_captures; /**< number of non capturing brackets */
} re_compiled_code_t;
/**
* Insert simple atom iterator
+ *
+ * @return empty ecma value - if inserted successfully
+ * error ecma value - otherwise
+ *
+ * Returned value must be freed with ecma_free_value
*/
-static void
+static ecma_value_t
re_insert_simple_iterator (re_compiler_ctx_t *re_ctx_p, /**< RegExp compiler context */
uint32_t new_atom_start_offset) /**< atom start offset */
{
qmin = re_ctx_p->current_token.qmin;
qmax = re_ctx_p->current_token.qmax;
- JERRY_ASSERT (qmin <= qmax);
+
+ if (qmin == 1 && qmax == 1)
+ {
+ return ECMA_VALUE_EMPTY;
+ }
+ else if (qmin > qmax)
+ {
+ return ecma_raise_syntax_error (ECMA_ERR_MSG ("RegExp quantifier error: qmin > qmax."));
+ }
/* TODO: optimize bytecode length. Store 0 rather than INF */
{
re_insert_opcode (re_ctx_p->bytecode_ctx_p, offset, RE_OP_NON_GREEDY_ITERATOR);
}
+
+ return ECMA_VALUE_EMPTY;
} /* re_insert_simple_iterator */
/**
while (ecma_is_value_empty (ret_value) && should_loop)
{
- ECMA_TRY_CATCH (empty,
- re_parse_next_token (re_ctx_p->parser_ctx_p,
- &(re_ctx_p->current_token)),
- ret_value);
+ ecma_value_t next_token_result = re_parse_next_token (re_ctx_p->parser_ctx_p,
+ &(re_ctx_p->current_token));
+ if (ECMA_IS_VALUE_ERROR (next_token_result))
+ {
+ ret_value = next_token_result;
+ break;
+ }
+ JERRY_ASSERT (next_token_result == ECMA_VALUE_EMPTY);
uint32_t new_atom_start_offset = re_get_bytecode_length (re_ctx_p->bytecode_ctx_p);
re_append_char (bc_ctx_p, re_canonicalize ((ecma_char_t) re_ctx_p->current_token.value,
re_ctx_p->flags & RE_FLAG_IGNORE_CASE));
- if ((re_ctx_p->current_token.qmin != 1) || (re_ctx_p->current_token.qmax != 1))
- {
- re_insert_simple_iterator (re_ctx_p, new_atom_start_offset);
- }
+ ret_value = re_insert_simple_iterator (re_ctx_p, new_atom_start_offset);
break;
}
case RE_TOK_PERIOD:
JERRY_TRACE_MSG ("Compile a period\n");
re_append_opcode (bc_ctx_p, RE_OP_PERIOD);
- if ((re_ctx_p->current_token.qmin != 1) || (re_ctx_p->current_token.qmax != 1))
- {
- re_insert_simple_iterator (re_ctx_p, new_atom_start_offset);
- }
+ ret_value = re_insert_simple_iterator (re_ctx_p, new_atom_start_offset);
break;
}
case RE_TOK_ALTERNATIVE:
: RE_OP_CHAR_CLASS);
uint32_t offset = re_get_bytecode_length (re_ctx_p->bytecode_ctx_p);
- ECMA_TRY_CATCH (empty_value,
- re_parse_char_class (re_ctx_p->parser_ctx_p,
- re_append_char_class,
- re_ctx_p,
- &(re_ctx_p->current_token)),
- ret_value);
- re_insert_u32 (bc_ctx_p, offset, re_ctx_p->parser_ctx_p->num_of_classes);
+ ret_value = re_parse_char_class (re_ctx_p->parser_ctx_p,
+ re_append_char_class,
+ re_ctx_p,
+ &(re_ctx_p->current_token));
- if ((re_ctx_p->current_token.qmin != 1) || (re_ctx_p->current_token.qmax != 1))
+ if (!ECMA_IS_VALUE_ERROR (ret_value))
{
- re_insert_simple_iterator (re_ctx_p, new_atom_start_offset);
+ re_insert_u32 (bc_ctx_p, offset, re_ctx_p->parser_ctx_p->num_of_classes);
+ ret_value = re_insert_simple_iterator (re_ctx_p, new_atom_start_offset);
}
- ECMA_FINALIZE (empty_value);
-
break;
}
case RE_TOK_END_GROUP:
break;
}
}
- ECMA_FINALIZE (empty);
}
return ret_value;
if (cached_bytecode_p != NULL)
{
- ecma_string_t *cached_pattern_str_p;
- cached_pattern_str_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t, cached_bytecode_p->pattern_cp);
+ ecma_string_t *cached_pattern_str_p = ecma_get_string_from_value (cached_bytecode_p->pattern);
if ((cached_bytecode_p->header.status_flags & RE_FLAGS_MASK) == flags
&& ecma_compare_ecma_strings (cached_pattern_str_p, pattern_str_p))
re_ctx.num_of_captures = 1;
re_append_opcode (&bc_ctx, RE_OP_SAVE_AT_START);
- ECMA_TRY_CATCH (empty, re_parse_alternative (&re_ctx, true), ret_value);
+ ecma_value_t parse_alt_result = re_parse_alternative (&re_ctx, true);
+ ECMA_FINALIZE_UTF8_STRING (pattern_start_p, pattern_start_size);
+
+ if (ECMA_IS_VALUE_ERROR (parse_alt_result))
+ {
+ ret_value = parse_alt_result;
+ }
/* 2. Check for invalid backreference */
- if (re_ctx.highest_backref >= re_ctx.num_of_captures)
+ else if (re_ctx.highest_backref >= re_ctx.num_of_captures)
{
ret_value = ecma_raise_syntax_error ("Invalid backreference.\n");
}
re_compiled_code.header.refs = 1;
re_compiled_code.header.status_flags = re_ctx.flags;
ecma_ref_ecma_string (pattern_str_p);
- ECMA_SET_NON_NULL_POINTER (re_compiled_code.pattern_cp, pattern_str_p);
+ re_compiled_code.pattern = ecma_make_string_value (pattern_str_p);
re_compiled_code.num_of_captures = re_ctx.num_of_captures * 2;
re_compiled_code.num_of_non_captures = re_ctx.num_of_non_captures;
sizeof (re_compiled_code_t));
}
- ECMA_FINALIZE (empty);
-
- ECMA_FINALIZE_UTF8_STRING (pattern_start_p, pattern_start_size);
-
size_t byte_code_size = (size_t) (bc_ctx.block_end_p - bc_ctx.block_start_p);
if (!ecma_is_value_empty (ret_value))
#include "ecma-exceptions.h"
#include "ecma-globals.h"
#include "ecma-try-catch-macro.h"
+#include "jcontext.h"
#include "jrt-libc-includes.h"
#include "lit-char-helpers.h"
#include "re-compiler.h"
JERRY_ASSERT (ecma_is_value_empty (ret_value));
- if (re_token_p->qmin > re_token_p->qmax)
- {
- ret_value = ecma_raise_syntax_error (ECMA_ERR_MSG ("RegExp quantifier error: qmin > qmax."));
- }
-
return ret_value;
} /* re_parse_iterator */
bool is_range = false;
parser_ctx_p->num_of_classes = 0;
- if (lit_utf8_peek_prev (parser_ctx_p->input_curr_p) != LIT_CHAR_LEFT_SQUARE)
+ const ecma_char_t prev_char = lit_utf8_peek_prev (parser_ctx_p->input_curr_p);
+ if (prev_char != LIT_CHAR_LEFT_SQUARE && prev_char != LIT_CHAR_CIRCUMFLEX)
{
lit_utf8_decr (&parser_ctx_p->input_curr_p);
lit_utf8_decr (&parser_ctx_p->input_curr_p);
case LIT_CHAR_QUESTION:
case LIT_CHAR_ASTERISK:
case LIT_CHAR_PLUS:
+ {
+ return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid RegExp token."));
+ }
case LIT_CHAR_LEFT_BRACE:
{
+#ifdef ENABLE_REGEXP_STRICT_MODE
return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid RegExp token."));
+#else /* !ENABLE_REGEXP_STRICT_MODE */
+ const lit_utf8_byte_t *input_curr_p = parser_ctx_p->input_curr_p;
+
+ lit_utf8_decr (&parser_ctx_p->input_curr_p);
+ ret_value = re_parse_iterator (parser_ctx_p, out_token_p);
+ if (ecma_is_value_empty (ret_value))
+ {
+ return ecma_raise_syntax_error (ECMA_ERR_MSG ("Invalid RegExp token."));
+ }
+
+ JERRY_ASSERT (ECMA_IS_VALUE_ERROR (ret_value));
+ ecma_free_value (JERRY_CONTEXT (error_value));
+
+ parser_ctx_p->input_curr_p = input_curr_p;
+
+ out_token_p->type = RE_TOK_CHAR;
+ out_token_p->value = ch;
+ ret_value = re_parse_iterator (parser_ctx_p, out_token_p);
+
+ if (!ecma_is_value_empty (ret_value))
+ {
+ parser_ctx_p->input_curr_p = input_curr_p;
+ ret_value = ECMA_VALUE_EMPTY;
+ }
+#endif /* ENABLE_REGEXP_STRICT_MODE */
+ break;
}
case LIT_CHAR_NULL:
{
opfunc_instanceof (ecma_value_t left_value, /**< left value */
ecma_value_t right_value) /**< right value */
{
- ecma_value_t ret_value = ECMA_VALUE_EMPTY;
-
if (!ecma_is_value_object (right_value))
{
- ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Expected an object in 'instanceof' check."));
- }
- else
- {
- ecma_object_t *right_value_obj_p = ecma_get_object_from_value (right_value);
-
- ECMA_TRY_CATCH (is_instance_of,
- ecma_op_object_has_instance (right_value_obj_p, left_value),
- ret_value);
-
- ret_value = is_instance_of;
-
- ECMA_FINALIZE (is_instance_of);
+ return ecma_raise_type_error (ECMA_ERR_MSG ("Expected an object in 'instanceof' check."));
}
- return ret_value;
+ ecma_object_t *right_value_obj_p = ecma_get_object_from_value (right_value);
+ return ecma_op_object_has_instance (right_value_obj_p, left_value);
} /* opfunc_instanceof */
/**
opfunc_in (ecma_value_t left_value, /**< left value */
ecma_value_t right_value) /**< right value */
{
- ecma_value_t ret_value = ECMA_VALUE_EMPTY;
-
if (!ecma_is_value_object (right_value))
{
- ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Expected an object in 'in' check."));
+ return ecma_raise_type_error (ECMA_ERR_MSG ("Expected an object in 'in' check."));
}
- else
- {
- ECMA_TRY_CATCH (str_left_value, ecma_op_to_string (left_value), ret_value);
- ecma_string_t *left_value_prop_name_p = ecma_get_string_from_value (str_left_value);
- ecma_object_t *right_value_obj_p = ecma_get_object_from_value (right_value);
+ ecma_value_t left_string_value = ecma_op_to_string (left_value);
+ if (ECMA_IS_VALUE_ERROR (left_string_value))
+ {
+ return left_string_value;
+ }
- ret_value = ecma_make_boolean_value (ecma_op_object_has_property (right_value_obj_p, left_value_prop_name_p));
+ ecma_string_t *left_value_prop_name_p = ecma_get_string_from_value (left_string_value);
+ ecma_object_t *right_value_obj_p = ecma_get_object_from_value (right_value);
- ECMA_FINALIZE (str_left_value);
- }
+ ecma_free_value (left_string_value);
- return ret_value;
+ return ecma_make_boolean_value (ecma_op_object_has_property (right_value_obj_p, left_value_prop_name_p));
} /* opfunc_in */
/**
ecma_value_t
opfunc_typeof (ecma_value_t left_value) /**< left value */
{
- ecma_value_t ret_value = ECMA_VALUE_EMPTY;
-
- ecma_string_t *type_str_p = NULL;
-
- if (ecma_is_value_undefined (left_value))
- {
- type_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_UNDEFINED);
- }
- else if (ecma_is_value_null (left_value))
- {
- type_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_OBJECT);
- }
- else if (ecma_is_value_boolean (left_value))
- {
- type_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_BOOLEAN);
- }
- else if (ecma_is_value_number (left_value))
- {
- type_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_NUMBER);
- }
- else if (ecma_is_value_string (left_value))
- {
- type_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_STRING);
- }
- else
- {
- JERRY_ASSERT (ecma_is_value_object (left_value));
-
- if (ecma_op_is_callable (left_value))
- {
- type_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_FUNCTION);
- }
- else
- {
- type_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_OBJECT);
- }
- }
-
- ret_value = ecma_make_string_value (type_str_p);
-
- return ret_value;
+ return ecma_make_magic_string_value (ecma_get_typeof_lit_id (left_value));
} /* opfunc_typeof */
/**
ecma_value_t property, /**< property name */
bool is_strict) /**< strict mode */
{
- ecma_value_t completion_value = ECMA_VALUE_EMPTY;
-
if (ecma_is_value_undefined (object))
{
- completion_value = ECMA_VALUE_TRUE;
+ return ECMA_VALUE_TRUE;
}
- else
- {
- completion_value = ECMA_VALUE_EMPTY;
- ECMA_TRY_CATCH (check_coercible_ret,
- ecma_op_check_object_coercible (object),
- completion_value);
- ECMA_TRY_CATCH (str_name_value,
- ecma_op_to_string (property),
- completion_value);
-
- JERRY_ASSERT (ecma_is_value_string (str_name_value));
- ecma_string_t *name_string_p = ecma_get_string_from_value (str_name_value);
-
- ECMA_TRY_CATCH (obj_value, ecma_op_to_object (object), completion_value);
+ ecma_value_t check_coercible = ecma_op_check_object_coercible (object);
+ if (ECMA_IS_VALUE_ERROR (check_coercible))
+ {
+ return check_coercible;
+ }
+ JERRY_ASSERT (check_coercible == ECMA_VALUE_EMPTY);
- JERRY_ASSERT (ecma_is_value_object (obj_value));
- ecma_object_t *obj_p = ecma_get_object_from_value (obj_value);
- JERRY_ASSERT (!ecma_is_lexical_environment (obj_p));
+ ecma_value_t str_name_value = ecma_op_to_string (property);
+ if (ECMA_IS_VALUE_ERROR (str_name_value))
+ {
+ return str_name_value;
+ }
- ECMA_TRY_CATCH (delete_op_ret_val,
- ecma_op_object_delete (obj_p, name_string_p, is_strict),
- completion_value);
+ JERRY_ASSERT (ecma_is_value_string (str_name_value));
+ ecma_string_t *name_string_p = ecma_get_string_from_value (str_name_value);
- completion_value = delete_op_ret_val;
+ ecma_value_t obj_value = ecma_op_to_object (object);
+ /* The ecma_op_check_object_coercible call already checked the op_to_object error cases. */
+ JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (obj_value));
+ JERRY_ASSERT (ecma_is_value_object (obj_value));
+ ecma_object_t *obj_p = ecma_get_object_from_value (obj_value);
+ JERRY_ASSERT (!ecma_is_lexical_environment (obj_p));
- ECMA_FINALIZE (delete_op_ret_val);
- ECMA_FINALIZE (obj_value);
- ECMA_FINALIZE (str_name_value);
- ECMA_FINALIZE (check_coercible_ret);
- }
+ ecma_value_t delete_op_ret = ecma_op_object_delete (obj_p, name_string_p, is_strict);
+ JERRY_ASSERT (ecma_is_value_boolean (delete_op_ret) || (is_strict == true && ECMA_IS_VALUE_ERROR (delete_op_ret)));
+ ecma_free_value (obj_value);
+ ecma_free_value (str_name_value);
- return completion_value;
+ return delete_op_ret;
} /* vm_op_delete_prop */
/**
* Returned value must be freed with ecma_free_value
*/
ecma_value_t
-vm_op_delete_var (jmem_cpointer_t name_literal, /**< name literal */
+vm_op_delete_var (ecma_value_t name_literal, /**< name literal */
ecma_object_t *lex_env_p) /**< lexical environment */
{
ecma_value_t completion_value = ECMA_VALUE_EMPTY;
- ecma_string_t *var_name_str_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, name_literal);
+ ecma_string_t *var_name_str_p = ecma_get_string_from_value (name_literal);
ecma_object_t *ref_base_lex_env_p = ecma_op_resolve_reference_base (lex_env_p, var_name_str_p);
* See also:
* ECMA-262 v5, 12.6.4
*
- * @return completion value
- * Returned value must be freed with ecma_free_value
+ * @return chain list of property names
*/
-ecma_collection_header_t *
+ecma_collection_chunk_t *
opfunc_for_in (ecma_value_t left_value, /**< left value */
ecma_value_t *result_obj_p) /**< expression object */
{
- ecma_value_t compl_val = ECMA_VALUE_EMPTY;
- ecma_collection_header_t *prop_names_p = NULL;
+ ecma_collection_chunk_t *prop_names_p = NULL;
/* 3. */
- if (!ecma_is_value_undefined (left_value)
- && !ecma_is_value_null (left_value))
+ if (ecma_is_value_undefined (left_value)
+ || ecma_is_value_null (left_value))
{
- /* 4. */
- ECMA_TRY_CATCH (obj_expr_value,
- ecma_op_to_object (left_value),
- compl_val);
+ return prop_names_p;
+ }
- ecma_object_t *obj_p = ecma_get_object_from_value (obj_expr_value);
- prop_names_p = ecma_op_object_get_property_names (obj_p, false, true, true);
+ /* 4. */
+ ecma_value_t obj_expr_value = ecma_op_to_object (left_value);
+ /* ecma_op_to_object will only raise error on null/undefined values but those are handled above. */
+ JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (obj_expr_value));
+ ecma_object_t *obj_p = ecma_get_object_from_value (obj_expr_value);
+ ecma_collection_header_t *prop_names_coll_p = ecma_op_object_get_property_names (obj_p, false, true, true);
- if (prop_names_p->unit_number != 0)
- {
- ecma_ref_object (obj_p);
- *result_obj_p = ecma_make_object_value (obj_p);
- }
- else
- {
- ecma_dealloc_collection_header (prop_names_p);
- prop_names_p = NULL;
- }
+ if (prop_names_coll_p->item_count != 0)
+ {
+ prop_names_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
+ prop_names_coll_p->first_chunk_cp);
- ECMA_FINALIZE (obj_expr_value);
+ ecma_ref_object (obj_p);
+ *result_obj_p = ecma_make_object_value (obj_p);
}
- JERRY_ASSERT (ecma_is_value_empty (compl_val));
+ jmem_heap_free_block (prop_names_coll_p, sizeof (ecma_collection_header_t));
+ ecma_free_value (obj_expr_value);
return prop_names_p;
} /* opfunc_for_in */
vm_op_delete_prop (ecma_value_t object, ecma_value_t property, bool is_strict);
ecma_value_t
-vm_op_delete_var (jmem_cpointer_t name_literal, ecma_object_t *lex_env_p);
+vm_op_delete_var (ecma_value_t name_literal, ecma_object_t *lex_env_p);
-ecma_collection_header_t *
+ecma_collection_chunk_t *
opfunc_for_in (ecma_value_t left_value, ecma_value_t *result_obj_p);
/**
uint8_t *byte_code_start_p; /**< byte code start pointer */
ecma_value_t *registers_p; /**< register start pointer */
ecma_value_t *stack_top_p; /**< stack top pointer */
- jmem_cpointer_t *literal_start_p; /**< literal list start pointer */
+ ecma_value_t *literal_start_p; /**< literal list start pointer */
ecma_object_t *lex_env_p; /**< current lexical environment */
struct vm_frame_ctx_t *prev_context_p; /**< previous context */
ecma_value_t this_binding; /**< this binding */
ecma_value_t call_block_result; /**< preserve block result during a call */
+#ifdef JERRY_ENABLE_LINE_INFO
+ ecma_value_t resource_name; /**< current resource name (usually a file name) */
+ uint32_t current_line; /**< currently executed line */
+#endif /* JERRY_ENABLE_LINE_INFO */
uint16_t context_depth; /**< current context depth */
uint8_t is_eval_code; /**< eval mode flag */
uint8_t call_operation; /**< perform a call or construct operation */
}
case VM_CONTEXT_FOR_IN:
{
- jmem_cpointer_t current = (jmem_cpointer_t) vm_stack_top_p[-2];
+ ecma_collection_chunk_t *chunk_p;
+ chunk_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_collection_chunk_t, vm_stack_top_p[-2]);
+ uint32_t index = vm_stack_top_p[-3];
- while (current != JMEM_CP_NULL)
+ while (chunk_p != NULL)
{
- ecma_collection_chunk_t *chunk_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_collection_chunk_t,
- current);
+ ecma_value_t value = chunk_p->items[index];
- lit_utf8_byte_t *data_ptr = chunk_p->data;
- ecma_free_value (*(ecma_value_t *) data_ptr);
+ if (unlikely (ecma_is_value_collection_chunk (value)))
+ {
+ ecma_collection_chunk_t *next_chunk_p = ecma_get_collection_chunk_from_value (value);
+ jmem_heap_free_block (chunk_p, sizeof (ecma_collection_chunk_t));
- current = chunk_p->next_chunk_cp;
- ecma_dealloc_collection_chunk (chunk_p);
+ chunk_p = next_chunk_p;
+ index = 0;
+ }
+ else
+ {
+ ecma_free_value (value);
+ index++;
+ }
}
- ecma_free_value (vm_stack_top_p[-3]);
+ ecma_free_value (vm_stack_top_p[-4]);
VM_MINUS_EQUAL_U16 (frame_ctx_p->context_depth, PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION);
vm_stack_top_p -= PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION;
--- /dev/null
+/* Copyright JS Foundation and other contributors, http://js.foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ecma-array-object.h"
+#include "ecma-helpers.h"
+#include "jcontext.h"
+#include "vm.h"
+
+/**
+ * Check whether currently executed code is strict mode code
+ *
+ * @return true - current code is executed in strict mode,
+ * false - otherwise
+ */
+bool
+vm_is_strict_mode (void)
+{
+ JERRY_ASSERT (JERRY_CONTEXT (vm_top_context_p) != NULL);
+
+ return JERRY_CONTEXT (vm_top_context_p)->bytecode_header_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE;
+} /* vm_is_strict_mode */
+
+/**
+ * Check whether currently performed call (on top of call-stack) is performed in form,
+ * meeting conditions of 'Direct Call to Eval' (see also: ECMA-262 v5, 15.1.2.1.1)
+ *
+ * Warning:
+ * the function should only be called from implementation
+ * of built-in 'eval' routine of Global object
+ *
+ * @return true - currently performed call is performed through 'eval' identifier,
+ * without 'this' argument,
+ * false - otherwise
+ */
+inline bool __attr_always_inline___
+vm_is_direct_eval_form_call (void)
+{
+ return (JERRY_CONTEXT (status_flags) & ECMA_STATUS_DIRECT_EVAL) != 0;
+} /* vm_is_direct_eval_form_call */
+
+/**
+ * Get backtrace. The backtrace is an array of strings where
+ * each string contains the position of the corresponding frame.
+ * The array length is zero if the backtrace is not available.
+ *
+ * @return array ecma value
+ */
+ecma_value_t
+vm_get_backtrace (uint32_t max_depth) /**< maximum backtrace depth, 0 = unlimited */
+{
+#ifdef JERRY_ENABLE_LINE_INFO
+ ecma_value_t result_array = ecma_op_create_array_object (NULL, 0, false);
+
+ if (max_depth == 0)
+ {
+ max_depth = UINT32_MAX;
+ }
+
+ vm_frame_ctx_t *context_p = JERRY_CONTEXT (vm_top_context_p);
+ ecma_object_t *array_p = ecma_get_object_from_value (result_array);
+ uint32_t index = 0;
+
+ while (context_p != NULL)
+ {
+ if (context_p->resource_name == ECMA_VALUE_UNDEFINED)
+ {
+ context_p = context_p->prev_context_p;
+ continue;
+ }
+
+ ecma_string_t *str_p = ecma_get_string_from_value (context_p->resource_name);
+
+ if (ecma_string_is_empty (str_p))
+ {
+ const char *unknown_str_p = "<unknown>:";
+ str_p = ecma_new_ecma_string_from_utf8 ((const lit_utf8_byte_t *) unknown_str_p,
+ (lit_utf8_size_t) strlen (unknown_str_p));
+ }
+ else
+ {
+ ecma_ref_ecma_string (str_p);
+ str_p = ecma_append_magic_string_to_string (str_p, LIT_MAGIC_STRING_COLON_CHAR);
+ }
+
+ ecma_string_t *line_str_p = ecma_new_ecma_string_from_uint32 (context_p->current_line);
+ str_p = ecma_concat_ecma_strings (str_p, line_str_p);
+ ecma_deref_ecma_string (line_str_p);
+
+ ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (index);
+ ecma_property_value_t *prop_value_p;
+ prop_value_p = ecma_create_named_data_property (array_p,
+ index_str_p,
+ ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE,
+ NULL);
+ ecma_deref_ecma_string (index_str_p);
+
+ prop_value_p->value = ecma_make_string_value (str_p);
+
+ context_p = context_p->prev_context_p;
+ index++;
+
+ if (index >= max_depth)
+ {
+ break;
+ }
+ }
+
+ if (index > 0)
+ {
+ JERRY_ASSERT (ecma_get_object_type (array_p) == ECMA_OBJECT_TYPE_ARRAY);
+
+ ((ecma_extended_object_t *) array_p)->u.array.length = index;
+ }
+
+ return result_array;
+#else /* !JERRY_ENABLE_LINE_INFO */
+ JERRY_UNUSED (max_depth);
+
+ return ecma_op_create_array_object (NULL, 0, false);
+#endif /* JERRY_ENABLE_LINE_INFO */
+} /* vm_get_backtrace */
{
ecma_object_t *object_p = ecma_get_object_from_value (object);
ecma_string_t *property_name_p = NULL;
- ecma_string_t uint32_string;
if (ecma_is_value_integer_number (property))
{
ecma_integer_value_t int_value = ecma_get_integer_from_value (property);
-#ifdef JERRY_CPOINTER_32_BIT
- bool limit_check = (int_value >= 0);
-#else /* !JERRY_CPOINTER_32_BIT */
- bool limit_check = (int_value >= 0 && int_value < (ecma_integer_value_t) (UINT16_MAX + 1));
-#endif
-
- if (limit_check)
+ if (int_value >= 0 && int_value <= ECMA_DIRECT_STRING_MAX_IMM)
{
- /* Statically allocated string for searching. */
- ecma_init_ecma_string_from_uint32 (&uint32_string, (uint32_t) int_value);
- property_name_p = &uint32_string;
+ property_name_p = (ecma_string_t *) ECMA_CREATE_DIRECT_STRING (ECMA_DIRECT_STRING_UINT,
+ (uintptr_t) int_value);
}
}
else if (ecma_is_value_string (property))
ecma_deref_object (lex_env_p);
ecma_free_value (this_binding);
+
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+ if (!(bytecode_data_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
+ {
+ ecma_bytecode_deref (bytecode_data_p);
+ }
+#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
ecma_bytecode_deref (bytecode_data_p);
+#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
return completion_value;
} /* vm_run_eval */
*/
static ecma_value_t
vm_construct_literal_object (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
- jmem_cpointer_t lit_cp) /**< literal */
+ ecma_value_t lit_value) /**< literal */
{
- ecma_compiled_code_t *bytecode_p = ECMA_GET_NON_NULL_POINTER (ecma_compiled_code_t,
- lit_cp);
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+ ecma_compiled_code_t *bytecode_p;
+
+ if (likely (!(frame_ctx_p->bytecode_header_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION)))
+ {
+ bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
+ lit_value);
+ }
+ else
+ {
+ uint8_t *byte_p = ((uint8_t *) frame_ctx_p->bytecode_header_p) + lit_value;
+ bytecode_p = (ecma_compiled_code_t *) byte_p;
+ }
+#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
+ ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
+ lit_value);
+#endif /* JERRY_ENABLE_SNAPSHOT_EXEC */
+
bool is_function = ((bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION) != 0);
if (is_function)
arguments_list_len);
}
- JERRY_CONTEXT (is_direct_eval_form_call) = false;
+ JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_DIRECT_EVAL;
/* Free registers. */
for (uint32_t i = 0; i < arguments_list_len; i++)
} \
else \
{ \
- ecma_string_t *name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, \
- literal_start_p[literal_index]); \
+ ecma_string_t *name_p = ecma_get_string_from_value (literal_start_p[literal_index]); \
+ \
result = ecma_op_resolve_reference_value (frame_ctx_p->lex_env_p, \
name_p); \
\
} \
else if (literal_index < const_literal_end) \
{ \
- ecma_string_t *value_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t, \
- literal_start_p[literal_index]); \
- \
- if (unlikely (ECMA_STRING_GET_CONTAINER (value_p) == ECMA_STRING_LITERAL_NUMBER)) \
- { \
- (target_value) = ecma_fast_copy_value (value_p->u.lit_number); \
- } \
- else \
- { \
- ecma_ref_ecma_string (value_p); \
- (target_value) = ecma_make_string_value (value_p); \
- } \
+ (target_value) = ecma_fast_copy_value (literal_start_p[literal_index]); \
} \
else \
{ \
/* Object construction. */ \
- (target_value) = vm_construct_literal_object (frame_ctx_p, literal_start_p[literal_index]); \
+ (target_value) = vm_construct_literal_object (frame_ctx_p, \
+ literal_start_p[literal_index]); \
} \
} \
while (0)
uint16_t encoding_limit;
uint16_t encoding_delta;
uint16_t register_end;
- jmem_cpointer_t *literal_start_p = frame_ctx_p->literal_start_p;
+ ecma_value_t *literal_start_p = frame_ctx_p->literal_start_p;
bool is_strict = ((frame_ctx_p->bytecode_header_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE) != 0);
- jmem_cpointer_t self_reference;
- ECMA_SET_NON_NULL_POINTER (self_reference, bytecode_header_p);
+ ecma_value_t self_reference;
+
+#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
+ self_reference = 0;
+ if (!(bytecode_header_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION))
+ {
+ ECMA_SET_INTERNAL_VALUE_POINTER (self_reference, bytecode_header_p);
+ }
+#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
+ ECMA_SET_INTERNAL_VALUE_POINTER (self_reference, bytecode_header_p);
+#endif
/* Prepare. */
if (!(bytecode_header_p->status_flags & CBC_CODE_FLAGS_FULL_LITERAL_ENCODING))
while (literal_index <= literal_index_end)
{
- ecma_string_t *name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- literal_start_p[literal_index]);
+ ecma_string_t *name_p = ecma_get_string_from_value (literal_start_p[literal_index]);
vm_var_decl (frame_ctx_p, name_p);
literal_index++;
}
{
uint32_t value_index;
ecma_value_t lit_value;
+ bool is_immutable_binding = false;
READ_LITERAL_INDEX (value_index);
}
else
{
+ is_immutable_binding = (self_reference == literal_start_p[value_index]);
lit_value = vm_construct_literal_object (frame_ctx_p,
literal_start_p[value_index]);
}
}
else
{
- ecma_string_t *name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- literal_start_p[literal_index]);
+ ecma_string_t *name_p = ecma_get_string_from_value (literal_start_p[literal_index]);
- if (self_reference == literal_start_p[value_index])
- {
- ecma_op_create_immutable_binding (frame_ctx_p->lex_env_p, name_p, lit_value);
- }
- else
+ if (likely (!is_immutable_binding))
{
vm_var_decl (frame_ctx_p, name_p);
ecma_free_value (JERRY_CONTEXT (error_value));
}
}
+ else
+ {
+ ecma_op_create_immutable_binding (frame_ctx_p->lex_env_p, name_p, lit_value);
+ }
if (value_index >= register_end)
{
{
const ecma_compiled_code_t *bytecode_header_p = frame_ctx_p->bytecode_header_p;
uint8_t *byte_code_p = frame_ctx_p->byte_code_p;
- jmem_cpointer_t *literal_start_p = frame_ctx_p->literal_start_p;
+ ecma_value_t *literal_start_p = frame_ctx_p->literal_start_p;
ecma_value_t *stack_top_p;
uint16_t encoding_limit;
}
else
{
- JERRY_CONTEXT (error_value) = ecma_clear_error_reference (result);
+ JERRY_CONTEXT (error_value) = ecma_clear_error_reference (result, false);
}
+
+ JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_EXCEPTION;
result = ECMA_VALUE_ERROR;
goto error;
}
}
else
{
- ecma_string_t *name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- literal_start_p[literal_index]);
- ecma_object_t *ref_base_lex_env_p;
+ ecma_string_t *name_p = ecma_get_string_from_value (literal_start_p[literal_index]);
+ ecma_object_t *ref_base_lex_env_p;
ref_base_lex_env_p = ecma_op_resolve_reference_base (frame_ctx_p->lex_env_p,
name_p);
case VM_OC_THROW:
{
JERRY_CONTEXT (error_value) = left_value;
+ JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
+
result = ECMA_VALUE_ERROR;
left_value = ECMA_VALUE_UNDEFINED;
goto error;
}
case VM_OC_EVAL:
{
- JERRY_CONTEXT (is_direct_eval_form_call) = true;
+ JERRY_CONTEXT (status_flags) |= ECMA_STATUS_DIRECT_EVAL;
JERRY_ASSERT (*byte_code_p >= CBC_CALL && *byte_code_p <= CBC_CALL2_PROP_BLOCK);
continue;
}
}
else
{
- ecma_string_t *name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- literal_start_p[literal_index]);
+ ecma_string_t *name_p = ecma_get_string_from_value (literal_start_p[literal_index]);
ecma_object_t *ref_base_lex_env_p = ecma_op_resolve_reference_base (frame_ctx_p->lex_env_p,
name_p);
JERRY_ASSERT (frame_ctx_p->registers_p + register_end + frame_ctx_p->context_depth == stack_top_p);
ecma_value_t expr_obj_value = ECMA_VALUE_UNDEFINED;
- ecma_collection_header_t *header_p = opfunc_for_in (value, &expr_obj_value);
+ ecma_collection_chunk_t *prop_names_p = opfunc_for_in (value, &expr_obj_value);
ecma_free_value (value);
- if (header_p == NULL)
+ if (prop_names_p == NULL)
{
byte_code_p = byte_code_start_p + branch_offset;
continue;
VM_PLUS_EQUAL_U16 (frame_ctx_p->context_depth, PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION);
stack_top_p += PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION;
stack_top_p[-1] = (ecma_value_t) VM_CREATE_CONTEXT (VM_CONTEXT_FOR_IN, branch_offset);
- stack_top_p[-2] = header_p->first_chunk_cp;
- stack_top_p[-3] = expr_obj_value;
+ ECMA_SET_INTERNAL_VALUE_ANY_POINTER (stack_top_p[-2], prop_names_p);
+ stack_top_p[-3] = 0;
+ stack_top_p[-4] = expr_obj_value;
- ecma_dealloc_collection_header (header_p);
continue;
}
case VM_OC_FOR_IN_GET_NEXT:
{
ecma_value_t *context_top_p = frame_ctx_p->registers_p + register_end + frame_ctx_p->context_depth;
- ecma_collection_chunk_t *chunk_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_collection_chunk_t, context_top_p[-2]);
+
+ ecma_collection_chunk_t *chunk_p;
+ chunk_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_collection_chunk_t, context_top_p[-2]);
JERRY_ASSERT (VM_GET_CONTEXT_TYPE (context_top_p[-1]) == VM_CONTEXT_FOR_IN);
- lit_utf8_byte_t *data_ptr = chunk_p->data;
- result = *(ecma_value_t *) data_ptr;
- context_top_p[-2] = chunk_p->next_chunk_cp;
+ uint32_t index = context_top_p[-3];
- ecma_dealloc_collection_chunk (chunk_p);
+ JERRY_ASSERT (!ecma_is_value_collection_chunk (chunk_p->items[index]));
- *stack_top_p++ = result;
+ *stack_top_p++ = chunk_p->items[index];
+ index++;
+
+ if (likely (!ecma_is_value_collection_chunk (chunk_p->items[index])))
+ {
+ context_top_p[-3] = index;
+ continue;
+ }
+
+ context_top_p[-3] = 0;
+
+ ecma_collection_chunk_t *next_chunk_p = ecma_get_collection_chunk_from_value (chunk_p->items[index]);
+ ECMA_SET_INTERNAL_VALUE_ANY_POINTER (context_top_p[-2], next_chunk_p);
+
+ jmem_heap_free_block (chunk_p, sizeof (ecma_collection_chunk_t));
continue;
}
case VM_OC_FOR_IN_HAS_NEXT:
{
JERRY_ASSERT (frame_ctx_p->registers_p + register_end + frame_ctx_p->context_depth == stack_top_p);
+ ecma_collection_chunk_t *chunk_p;
+ chunk_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_collection_chunk_t, stack_top_p[-2]);
+
+ uint32_t index = stack_top_p[-3];
+ ecma_object_t *object_p = ecma_get_object_from_value (stack_top_p[-4]);
+
while (true)
{
- if (stack_top_p[-2] == JMEM_CP_NULL)
+ if (chunk_p == NULL)
{
- ecma_free_value (stack_top_p[-3]);
+ ecma_deref_object (object_p);
VM_MINUS_EQUAL_U16 (frame_ctx_p->context_depth, PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION);
stack_top_p -= PARSER_FOR_IN_CONTEXT_STACK_ALLOCATION;
break;
}
- ecma_collection_chunk_t *chunk_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_collection_chunk_t, stack_top_p[-2]);
+ ecma_string_t *prop_name_p = ecma_get_string_from_value (chunk_p->items[index]);
- lit_utf8_byte_t *data_ptr = chunk_p->data;
- ecma_string_t *prop_name_p = ecma_get_string_from_value (*(ecma_value_t *) data_ptr);
+ if (likely (ecma_op_object_has_property (object_p, prop_name_p)))
+ {
+ byte_code_p = byte_code_start_p + branch_offset;
+ break;
+ }
+
+ index++;
+ ecma_value_t value = chunk_p->items[index];
- if (!ecma_op_object_has_property (ecma_get_object_from_value (stack_top_p[-3]),
- prop_name_p))
+ if (likely (!ecma_is_value_collection_chunk (value)))
{
- stack_top_p[-2] = chunk_p->next_chunk_cp;
- ecma_deref_ecma_string (prop_name_p);
- ecma_dealloc_collection_chunk (chunk_p);
+ stack_top_p[-3] = index;
}
else
{
- byte_code_p = byte_code_start_p + branch_offset;
- break;
+ index = 0;
+ stack_top_p[-3] = 0;
+
+ ecma_collection_chunk_t *next_chunk_p = ecma_get_collection_chunk_from_value (value);
+ ECMA_SET_INTERNAL_VALUE_ANY_POINTER (stack_top_p[-2], next_chunk_p);
+
+ jmem_heap_free_block (chunk_p, sizeof (ecma_collection_chunk_t));
+ chunk_p = next_chunk_p;
}
- }
+ ecma_deref_ecma_string (prop_name_p);
+ }
continue;
}
case VM_OC_TRY:
case VM_CONTEXT_FINALLY_THROW:
{
JERRY_CONTEXT (error_value) = stack_top_p[-2];
+ JERRY_CONTEXT (status_flags) |= ECMA_STATUS_EXCEPTION;
VM_MINUS_EQUAL_U16 (frame_ctx_p->context_depth,
PARSER_TRY_CONTEXT_STACK_ALLOCATION);
stack_top_p -= PARSER_TRY_CONTEXT_STACK_ALLOCATION;
result = ECMA_VALUE_ERROR;
+
+#ifdef JERRY_DEBUGGER
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_EXCEPTION_THROWN);
+#endif /* JERRY_DEBUGGER */
goto error;
}
case VM_CONTEXT_FINALLY_RETURN:
frame_ctx_p->byte_code_p = byte_code_start_p;
jerry_debugger_breakpoint_hit (JERRY_DEBUGGER_BREAKPOINT_HIT);
+ if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_EXCEPTION_THROWN)
+ {
+ result = ECMA_VALUE_ERROR;
+ goto error;
+ }
#endif /* JERRY_DEBUGGER */
continue;
}
|| JERRY_CONTEXT (debugger_stop_context) == JERRY_CONTEXT (vm_top_context_p)))
{
jerry_debugger_breakpoint_hit (JERRY_DEBUGGER_BREAKPOINT_HIT);
+ if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_EXCEPTION_THROWN)
+ {
+ result = ECMA_VALUE_ERROR;
+ goto error;
+ }
continue;
}
|| JERRY_CONTEXT (debugger_stop_context) == JERRY_CONTEXT (vm_top_context_p)))
{
jerry_debugger_breakpoint_hit (JERRY_DEBUGGER_BREAKPOINT_HIT);
+ if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_EXCEPTION_THROWN)
+ {
+ result = ECMA_VALUE_ERROR;
+ goto error;
+ }
}
#endif /* JERRY_DEBUGGER */
continue;
}
+#ifdef JERRY_ENABLE_LINE_INFO
+ case VM_OC_RESOURCE_NAME:
+ {
+ ecma_length_t formal_params_number = 0;
+
+ if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_NON_STRICT_ARGUMENTS_NEEDED)
+ {
+ if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
+ {
+ cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) bytecode_header_p;
+
+ formal_params_number = args_p->argument_end;
+ }
+ else
+ {
+ cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) bytecode_header_p;
+
+ formal_params_number = args_p->argument_end;
+ }
+ }
+
+ uint8_t *byte_p = (uint8_t *) bytecode_header_p;
+ byte_p += ((size_t) bytecode_header_p->size) << JMEM_ALIGNMENT_LOG;
+
+ ecma_value_t *resource_name_p = (ecma_value_t *) byte_p;
+ resource_name_p -= formal_params_number;
+
+ frame_ctx_p->resource_name = resource_name_p[-1];
+ continue;
+ }
+ case VM_OC_LINE:
+ {
+ uint32_t value = 0;
+ uint8_t byte;
+
+ do
+ {
+ byte = *byte_code_p++;
+ value = (value << 7) | (byte & CBC_LOWER_SEVEN_BIT_MASK);
+ }
+ while (byte & CBC_HIGHEST_BIT_MASK);
+
+ frame_ctx_p->current_line = value;
+ continue;
+ }
+#endif /* JERRY_ENABLE_LINE_INFO */
default:
{
JERRY_UNREACHABLE ();
}
else
{
- ecma_string_t *var_name_str_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- literal_start_p[literal_index]);
+ ecma_string_t *var_name_str_p = ecma_get_string_from_value (literal_start_p[literal_index]);
+
ecma_object_t *ref_base_lex_env_p = ecma_op_resolve_reference_base (frame_ctx_p->lex_env_p,
var_name_str_p);
stack_top_p = frame_ctx_p->registers_p + register_end + frame_ctx_p->context_depth;
#ifdef JERRY_DEBUGGER
+ const uint32_t dont_stop = (JERRY_DEBUGGER_VM_IGNORE_EXCEPTION
+ | JERRY_DEBUGGER_VM_IGNORE
+ | JERRY_DEBUGGER_VM_EXCEPTION_THROWN);
+
if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
&& !(frame_ctx_p->bytecode_header_p->status_flags & CBC_CODE_FLAGS_DEBUGGER_IGNORE)
- && !(JERRY_CONTEXT (debugger_flags) & (JERRY_DEBUGGER_VM_IGNORE_EXCEPTION | JERRY_DEBUGGER_VM_IGNORE)))
+ && !(JERRY_CONTEXT (debugger_flags) & dont_stop))
{
+ /* Save the error to a local value, because the engine enters breakpoint mode after,
+ therefore an evaluation error, or user-created error throw would overwrite it. */
+ ecma_value_t current_error_value = JERRY_CONTEXT (error_value);
+
if (jerry_debugger_send_exception_string ())
{
jerry_debugger_breakpoint_hit (JERRY_DEBUGGER_EXCEPTION_HIT);
+
+ if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_VM_EXCEPTION_THROWN)
+ {
+ ecma_free_value (current_error_value);
+ }
+ else
+ {
+ JERRY_CONTEXT (error_value) = current_error_value;
+ }
+
+ JERRY_DEBUGGER_SET_FLAGS (JERRY_DEBUGGER_VM_EXCEPTION_THROWN);
}
}
#endif /* JERRY_DEBUGGER */
if (!ECMA_IS_VALUE_ERROR (result))
{
- JERRY_ASSERT (frame_ctx_p->registers_p + register_end + frame_ctx_p->context_depth == stack_top_p);
-
- stack_top_p = frame_ctx_p->registers_p + register_end + frame_ctx_p->context_depth;
-
if (vm_stack_find_finally (frame_ctx_p,
&stack_top_p,
VM_CONTEXT_FINALLY_RETURN,
continue;
}
}
- else
+ else if (JERRY_CONTEXT (status_flags) & ECMA_STATUS_EXCEPTION)
{
if (vm_stack_find_finally (frame_ctx_p,
&stack_top_p,
{
JERRY_ASSERT (frame_ctx_p->registers_p + register_end + frame_ctx_p->context_depth == stack_top_p);
+#ifdef JERRY_DEBUGGER
+ JERRY_DEBUGGER_CLEAR_FLAGS (JERRY_DEBUGGER_VM_EXCEPTION_THROWN);
+#endif /* JERRY_DEBUGGER */
+
byte_code_p = frame_ctx_p->byte_code_p;
if (VM_GET_CONTEXT_TYPE (stack_top_p[-1]) == VM_CONTEXT_CATCH)
{
- uint32_t literal_index;
- ecma_object_t *catch_env_p;
- ecma_string_t *catch_name_p;
-
*stack_top_p++ = JERRY_CONTEXT (error_value);
JERRY_ASSERT (byte_code_p[0] == CBC_ASSIGN_SET_IDENT);
- literal_index = byte_code_p[1];
+ uint32_t literal_index = byte_code_p[1];
+
if (literal_index >= encoding_limit)
{
literal_index = ((literal_index << 8) | byte_code_p[2]) - encoding_delta;
}
- catch_env_p = ecma_create_decl_lex_env (frame_ctx_p->lex_env_p);
-
- catch_name_p = JMEM_CP_GET_NON_NULL_POINTER (ecma_string_t,
- literal_start_p[literal_index]);
+ ecma_object_t *catch_env_p = ecma_create_decl_lex_env (frame_ctx_p->lex_env_p);
+ ecma_string_t *catch_name_p = ecma_get_string_from_value (literal_start_p[literal_index]);
ecma_op_create_mutable_binding (catch_env_p, catch_name_p, false);
stack_top_p[-2 - 1] = ecma_make_object_value (frame_ctx_p->lex_env_p);
stack_top_p[-2] = JERRY_CONTEXT (error_value);
}
-#ifdef JERRY_VM_EXEC_STOP
- if (JERRY_CONTEXT (vm_exec_stop_cb) != NULL
- && --JERRY_CONTEXT (vm_exec_stop_counter) == 0)
- {
- result = JERRY_CONTEXT (vm_exec_stop_cb) (JERRY_CONTEXT (vm_exec_stop_user_p));
-
- if (ecma_is_value_undefined (result))
- {
- JERRY_CONTEXT (vm_exec_stop_counter) = JERRY_CONTEXT (vm_exec_stop_frequency);
- }
- else
- {
- JERRY_CONTEXT (vm_exec_stop_counter) = 1;
-
- left_value = ECMA_VALUE_UNDEFINED;
- right_value = ECMA_VALUE_UNDEFINED;
-
- if (!ecma_is_value_error_reference (result))
- {
- JERRY_CONTEXT (error_value) = result;
- }
- else
- {
- JERRY_CONTEXT (error_value) = ecma_clear_error_reference (result);
- }
- result = ECMA_VALUE_ERROR;
- goto error;
- }
- }
-#endif /* JERRY_VM_EXEC_STOP */
-
continue;
}
}
+ else
+ {
+ do
+ {
+ JERRY_ASSERT (frame_ctx_p->registers_p + register_end + frame_ctx_p->context_depth == stack_top_p);
+
+ stack_top_p = vm_stack_context_abort (frame_ctx_p, stack_top_p);
+ }
+ while (frame_ctx_p->context_depth > 0);
+ }
ecma_free_value (block_result);
return result;
}
}
- JERRY_CONTEXT (is_direct_eval_form_call) = false;
+ JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_DIRECT_EVAL;
JERRY_CONTEXT (vm_top_context_p) = frame_ctx_p;
const ecma_value_t *arg_list_p, /**< arguments list */
ecma_length_t arg_list_len) /**< length of arguments list */
{
- jmem_cpointer_t *literal_p;
+ ecma_value_t *literal_p;
vm_frame_ctx_t frame_ctx;
uint32_t call_stack_size;
if (bytecode_header_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
{
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) bytecode_header_p;
- uint8_t *byte_p = (uint8_t *) bytecode_header_p;
+ call_stack_size = (uint32_t) (args_p->register_end + args_p->stack_limit);
- literal_p = (jmem_cpointer_t *) (byte_p + sizeof (cbc_uint16_arguments_t));
+ literal_p = (ecma_value_t *) ((uint8_t *) bytecode_header_p + sizeof (cbc_uint16_arguments_t));
+ literal_p -= args_p->register_end;
frame_ctx.literal_start_p = literal_p;
literal_p += args_p->literal_end;
- call_stack_size = (uint32_t) (args_p->register_end + args_p->stack_limit);
}
else
{
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) bytecode_header_p;
- uint8_t *byte_p = (uint8_t *) bytecode_header_p;
+ call_stack_size = (uint32_t) (args_p->register_end + args_p->stack_limit);
- literal_p = (jmem_cpointer_t *) (byte_p + sizeof (cbc_uint8_arguments_t));
+ literal_p = (ecma_value_t *) ((uint8_t *) bytecode_header_p + sizeof (cbc_uint8_arguments_t));
+ literal_p -= args_p->register_end;
frame_ctx.literal_start_p = literal_p;
literal_p += args_p->literal_end;
- call_stack_size = (uint32_t) (args_p->register_end + args_p->stack_limit);
}
frame_ctx.bytecode_header_p = bytecode_header_p;
frame_ctx.lex_env_p = lex_env_p;
frame_ctx.prev_context_p = JERRY_CONTEXT (vm_top_context_p);
frame_ctx.this_binding = this_binding_value;
+#ifdef JERRY_ENABLE_LINE_INFO
+ frame_ctx.resource_name = ECMA_VALUE_UNDEFINED;
+ frame_ctx.current_line = 0;
+#endif /* JERRY_ENABLE_LINE_INFO */
frame_ctx.context_depth = 0;
frame_ctx.is_eval_code = is_eval_code;
frame_ctx.call_operation = VM_NO_EXEC_OP;
} /* vm_run */
/**
- * Check whether currently executed code is strict mode code
- *
- * @return true - current code is executed in strict mode,
- * false - otherwise
- */
-bool
-vm_is_strict_mode (void)
-{
- JERRY_ASSERT (JERRY_CONTEXT (vm_top_context_p) != NULL);
-
- return JERRY_CONTEXT (vm_top_context_p)->bytecode_header_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE;
-} /* vm_is_strict_mode */
-
-/**
- * Check whether currently performed call (on top of call-stack) is performed in form,
- * meeting conditions of 'Direct Call to Eval' (see also: ECMA-262 v5, 15.1.2.1.1)
- *
- * Warning:
- * the function should only be called from implementation
- * of built-in 'eval' routine of Global object
- *
- * @return true - currently performed call is performed through 'eval' identifier,
- * without 'this' argument,
- * false - otherwise
- */
-inline bool __attr_always_inline___
-vm_is_direct_eval_form_call (void)
-{
- return JERRY_CONTEXT (is_direct_eval_form_call);
-} /* vm_is_direct_eval_form_call */
-
-/**
* @}
* @}
*/
VM_OC_FINALLY, /**< finally */
VM_OC_CONTEXT_END, /**< context end */
VM_OC_JUMP_AND_EXIT_CONTEXT, /**< jump and exit context */
- VM_OC_BREAKPOINT_ENABLED, /**< enabled breakpoint for debugger */
- VM_OC_BREAKPOINT_DISABLED, /**< disabled breakpoint for debugger */
+ VM_OC_BREAKPOINT_ENABLED, /**< enabled breakpoint for debugger */
+ VM_OC_BREAKPOINT_DISABLED, /**< disabled breakpoint for debugger */
+ VM_OC_RESOURCE_NAME, /**< resource name of the current function */
+ VM_OC_LINE, /**< line number of the next statement */
} vm_oc_types;
/**
bool vm_is_strict_mode (void);
bool vm_is_direct_eval_form_call (void);
+ecma_value_t vm_get_backtrace (uint32_t max_depth);
+
/**
* @}
* @}
<div>
</div>
<script>
+// Expected JerryScript debugger protocol version
+var JERRY_DEBUGGER_VERSION = 3;
+
// Messages sent by the server to client.
var JERRY_DEBUGGER_CONFIGURATION = 1;
var JERRY_DEBUGGER_PARSE_ERROR = 2;
var JERRY_DEBUGGER_SOURCE_CODE_NAME_END = 10;
var JERRY_DEBUGGER_FUNCTION_NAME = 11;
var JERRY_DEBUGGER_FUNCTION_NAME_END = 12;
-var JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP = 13;
-var JERRY_DEBUGGER_MEMSTATS_RECEIVE = 14;
-var JERRY_DEBUGGER_BREAKPOINT_HIT = 15;
-var JERRY_DEBUGGER_EXCEPTION_HIT = 16;
-var JERRY_DEBUGGER_EXCEPTION_STR = 17;
-var JERRY_DEBUGGER_EXCEPTION_STR_END = 18;
-var JERRY_DEBUGGER_BACKTRACE = 19;
-var JERRY_DEBUGGER_BACKTRACE_END = 20;
-var JERRY_DEBUGGER_EVAL_RESULT = 21;
-var JERRY_DEBUGGER_EVAL_RESULT_END = 22;
-var JERRY_DEBUGGER_WAIT_FOR_SOURCE = 23;
-var JERRY_DEBUGGER_OUTPUT_RESULT = 24;
-var JERRY_DEBUGGER_OUTPUT_RESULT_END = 25;
+var JERRY_DEBUGGER_WAITING_AFTER_PARSE = 13;
+var JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP = 14;
+var JERRY_DEBUGGER_MEMSTATS_RECEIVE = 15;
+var JERRY_DEBUGGER_BREAKPOINT_HIT = 16;
+var JERRY_DEBUGGER_EXCEPTION_HIT = 17;
+var JERRY_DEBUGGER_EXCEPTION_STR = 18;
+var JERRY_DEBUGGER_EXCEPTION_STR_END = 19;
+var JERRY_DEBUGGER_BACKTRACE = 20;
+var JERRY_DEBUGGER_BACKTRACE_END = 21;
+var JERRY_DEBUGGER_EVAL_RESULT = 22;
+var JERRY_DEBUGGER_EVAL_RESULT_END = 23;
+var JERRY_DEBUGGER_WAIT_FOR_SOURCE = 24;
+var JERRY_DEBUGGER_OUTPUT_RESULT = 25;
+var JERRY_DEBUGGER_OUTPUT_RESULT_END = 26;
// Subtypes of eval
+JERRY_DEBUGGER_EVAL_EVAL = "\0"
+JERRY_DEBUGGER_EVAL_THROW = "\1"
+JERRY_DEBUGGER_EVAL_ABORT = "\2"
+
+// Subtypes of eval result
var JERRY_DEBUGGER_EVAL_OK = 1;
var JERRY_DEBUGGER_EVAL_ERROR = 2;
var JERRY_DEBUGGER_FREE_BYTE_CODE_CP = 1;
var JERRY_DEBUGGER_UPDATE_BREAKPOINT = 2;
var JERRY_DEBUGGER_EXCEPTION_CONFIG = 3;
-var JERRY_DEBUGGER_MEMSTATS = 4;
-var JERRY_DEBUGGER_STOP = 5;
-var JERRY_DEBUGGER_CLIENT_SOURCE = 6;
-var JERRY_DEBUGGER_CLIENT_SOURCE_PART = 7;
-var JERRY_DEBUGGER_NO_MORE_SOURCES = 8;
-var JERRY_DEBUGGER_CONTEXT_RESET = 9;
-var JERRY_DEBUGGER_CONTINUE = 10;
-var JERRY_DEBUGGER_STEP = 11;
-var JERRY_DEBUGGER_NEXT = 12;
-var JERRY_DEBUGGER_GET_BACKTRACE = 13;
-var JERRY_DEBUGGER_EVAL = 14;
-var JERRY_DEBUGGER_EVAL_PART = 15;
+var JERRY_DEBUGGER_PARSER_CONFIG = 4;
+var JERRY_DEBUGGER_MEMSTATS = 5;
+var JERRY_DEBUGGER_STOP = 6;
+var JERRY_DEBUGGER_PARSER_RESUME = 7;
+var JERRY_DEBUGGER_CLIENT_SOURCE = 8;
+var JERRY_DEBUGGER_CLIENT_SOURCE_PART = 9;
+var JERRY_DEBUGGER_NO_MORE_SOURCES = 10;
+var JERRY_DEBUGGER_CONTEXT_RESET = 11;
+var JERRY_DEBUGGER_CONTINUE = 12;
+var JERRY_DEBUGGER_STEP = 13;
+var JERRY_DEBUGGER_NEXT = 14;
+var JERRY_DEBUGGER_FINISH = 15;
+var JERRY_DEBUGGER_GET_BACKTRACE = 16;
+var JERRY_DEBUGGER_EVAL = 17;
+var JERRY_DEBUGGER_EVAL_PART = 18;
var textBox = document.getElementById("log");
var commandBox = document.getElementById("command");
var outputResult = null;
var exceptionData = null;
var display = 0;
+ var version = 0;
function assert(expr)
{
{
var chr = string.charCodeAt(i);
- if (chr >= 0x7ff)
+ if (chr > 0x7ff)
{
- byteLength ++;
+ byteLength++;
}
if (chr >= 0x7f)
{
var chr = string.charCodeAt(i);
- if (chr >= 0x7ff)
+ if (chr > 0x7ff)
{
result[offset] = 0xe0 | (chr >> 12);
result[offset + 1] = 0x80 | ((chr >> 6) & 0x3f);
if (cpointerSize == 0)
{
if (message[0] != JERRY_DEBUGGER_CONFIGURATION
- || message.byteLength != 4)
+ || message.byteLength != 5)
{
abortConnection("the first message must be configuration.");
}
cpointerSize = message[2]
littleEndian = (message[3] != 0);
+ version = message[4];
+
if (cpointerSize != 2 && cpointerSize != 4)
{
abortConnection("compressed pointer must be 2 or 4 byte long.");
}
+ if (version != JERRY_DEBUGGER_VERSION)
+ {
+ abortConnection("incorrect target debugger version detected: "
+ + version + " expected: " + JERRY_DEBUGGER_VERSION);
+ }
+
config = false;
return;
}
return;
}
- var array = stringToCesu8(str);
+ var array = stringToCesu8(JERRY_DEBUGGER_EVAL_EVAL + str);
var byteLength = array.byteLength;
if (byteLength <= maxMessageSize)
" continue|c - continue execution\n" +
" step|s - step-in execution\n" +
" next|n - execution until the next breakpoint\n" +
+ " finish|f - continue running until the current function returns\n" +
" eval|e - evaluate expression\n" +
" backtrace|bt <max-depth> - get backtrace\n" +
" src - print current source code\n" +
debuggerObj.sendResumeExec(JERRY_DEBUGGER_NEXT);
break;
+ case "f":
+ case "finish":
+ debuggerObj.sendResumeExec(JERRY_DEBUGGER_FINISH);
+ break;
+
case "e":
case "eval":
debuggerObj.sendEval(args[2]);
import socket
import struct
import sys
+import math
+import time
+
+# Expected debugger protocol version.
+JERRY_DEBUGGER_VERSION = 3
# Messages sent by the server to client.
JERRY_DEBUGGER_CONFIGURATION = 1
JERRY_DEBUGGER_SOURCE_CODE_NAME_END = 10
JERRY_DEBUGGER_FUNCTION_NAME = 11
JERRY_DEBUGGER_FUNCTION_NAME_END = 12
-JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP = 13
-JERRY_DEBUGGER_MEMSTATS_RECEIVE = 14
-JERRY_DEBUGGER_BREAKPOINT_HIT = 15
-JERRY_DEBUGGER_EXCEPTION_HIT = 16
-JERRY_DEBUGGER_EXCEPTION_STR = 17
-JERRY_DEBUGGER_EXCEPTION_STR_END = 18
-JERRY_DEBUGGER_BACKTRACE = 19
-JERRY_DEBUGGER_BACKTRACE_END = 20
-JERRY_DEBUGGER_EVAL_RESULT = 21
-JERRY_DEBUGGER_EVAL_RESULT_END = 22
-JERRY_DEBUGGER_WAIT_FOR_SOURCE = 23
-JERRY_DEBUGGER_OUTPUT_RESULT = 24
-JERRY_DEBUGGER_OUTPUT_RESULT_END = 25
+JERRY_DEBUGGER_WAITING_AFTER_PARSE = 13
+JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP = 14
+JERRY_DEBUGGER_MEMSTATS_RECEIVE = 15
+JERRY_DEBUGGER_BREAKPOINT_HIT = 16
+JERRY_DEBUGGER_EXCEPTION_HIT = 17
+JERRY_DEBUGGER_EXCEPTION_STR = 18
+JERRY_DEBUGGER_EXCEPTION_STR_END = 19
+JERRY_DEBUGGER_BACKTRACE = 20
+JERRY_DEBUGGER_BACKTRACE_END = 21
+JERRY_DEBUGGER_EVAL_RESULT = 22
+JERRY_DEBUGGER_EVAL_RESULT_END = 23
+JERRY_DEBUGGER_WAIT_FOR_SOURCE = 24
+JERRY_DEBUGGER_OUTPUT_RESULT = 25
+JERRY_DEBUGGER_OUTPUT_RESULT_END = 26
# Subtypes of eval
+JERRY_DEBUGGER_EVAL_EVAL = "\0"
+JERRY_DEBUGGER_EVAL_THROW = "\1"
+JERRY_DEBUGGER_EVAL_ABORT = "\2"
+
+# Subtypes of eval result
JERRY_DEBUGGER_EVAL_OK = 1
JERRY_DEBUGGER_EVAL_ERROR = 2
JERRY_DEBUGGER_FREE_BYTE_CODE_CP = 1
JERRY_DEBUGGER_UPDATE_BREAKPOINT = 2
JERRY_DEBUGGER_EXCEPTION_CONFIG = 3
-JERRY_DEBUGGER_MEMSTATS = 4
-JERRY_DEBUGGER_STOP = 5
-JERRY_DEBUGGER_CLIENT_SOURCE = 6
-JERRY_DEBUGGER_CLIENT_SOURCE_PART = 7
-JERRY_DEBUGGER_NO_MORE_SOURCES = 8
-JERRY_DEBUGGER_CONTEXT_RESET = 9
-JERRY_DEBUGGER_CONTINUE = 10
-JERRY_DEBUGGER_STEP = 11
-JERRY_DEBUGGER_NEXT = 12
-JERRY_DEBUGGER_GET_BACKTRACE = 13
-JERRY_DEBUGGER_EVAL = 14
-JERRY_DEBUGGER_EVAL_PART = 15
+JERRY_DEBUGGER_PARSER_CONFIG = 4
+JERRY_DEBUGGER_MEMSTATS = 5
+JERRY_DEBUGGER_STOP = 6
+JERRY_DEBUGGER_PARSER_RESUME = 7
+JERRY_DEBUGGER_CLIENT_SOURCE = 8
+JERRY_DEBUGGER_CLIENT_SOURCE_PART = 9
+JERRY_DEBUGGER_NO_MORE_SOURCES = 10
+JERRY_DEBUGGER_CONTEXT_RESET = 11
+JERRY_DEBUGGER_CONTINUE = 12
+JERRY_DEBUGGER_STEP = 13
+JERRY_DEBUGGER_NEXT = 14
+JERRY_DEBUGGER_FINISH = 15
+JERRY_DEBUGGER_GET_BACKTRACE = 16
+JERRY_DEBUGGER_EVAL = 17
+JERRY_DEBUGGER_EVAL_PART = 18
MAX_BUFFER_SIZE = 128
WEBSOCKET_BINARY_FRAME = 2
return result
-
class JerryFunction(object):
-
+ # pylint: disable=too-many-instance-attributes,too-many-arguments
def __init__(self, is_func, byte_code_cp, source, source_name, line, column, name, lines, offsets):
self.is_func = is_func
self.byte_code_cp = byte_code_cp
self.first_breakpoint_offset = offsets[0]
if len(self.source) > 1 and not self.source[-1]:
- self.source.pop()
+ self.source.pop()
- for i in range(len(lines)):
- line = lines[i]
+ for i, line in enumerate(lines):
offset = offsets[i]
breakpoint = JerryBreakpoint(line, offset, self)
self.lines[line] = breakpoint
def postcmd(self, stop, line):
return self.stop
- def disable_args(self, args):
- if args:
- print("Error: No argument expected")
- return True
- return False
-
def do_quit(self, args):
""" Exit JerryScript debugger """
self.do_delete("all")
self.do_exception("0") # disable the exception handler
- self.exec_command(args, JERRY_DEBUGGER_CONTINUE)
+ self._exec_command(args, JERRY_DEBUGGER_CONTINUE)
self.stop = True
self.quit = True
do_b = do_break
- def exec_command(self, args, command_id):
+ def _exec_command(self, args, command_id):
self.stop = True
if args != "":
print("Error: No argument expected")
def do_continue(self, args):
""" Continue execution """
- self.exec_command(args, JERRY_DEBUGGER_CONTINUE)
+ self._exec_command(args, JERRY_DEBUGGER_CONTINUE)
self.stop = True
self.cont = True
if not self.non_interactive:
def do_step(self, args):
""" Next breakpoint, step into functions """
- self.exec_command(args, JERRY_DEBUGGER_STEP)
+ self._exec_command(args, JERRY_DEBUGGER_STEP)
self.cont = True
do_s = do_step
def do_next(self, args):
""" Next breakpoint in the same context """
- self.exec_command(args, JERRY_DEBUGGER_NEXT)
+ if not args:
+ args = 0
+ else:
+ try:
+ args = int(args)
+ if args <= 0:
+ raise ValueError(args)
+ except ValueError as val_errno:
+ print("Error: expected a positive integer: %s" % val_errno)
+ return
+
+ args = min(args, len(self.debugger.last_breakpoint_hit.function.lines) -
+ self.debugger.last_breakpoint_hit.function.line) - 1
+ self.debugger.repeats_remain = args
+
+ self._exec_command("", JERRY_DEBUGGER_NEXT)
self.cont = True
do_n = do_next
- def do_list(self, args):
+ def do_finish(self, args):
+ """ Continue running until the current function returns """
+ self._exec_command(args, JERRY_DEBUGGER_FINISH)
+ self.cont = True
+
+ do_f = do_finish
+
+ def do_list(self, _):
""" Lists the available breakpoints """
if self.debugger.active_breakpoint_list:
print("=== %sActive breakpoints %s ===" % (self.debugger.green_bg, self.debugger.nocolor))
self.debugger.send_breakpoint(breakpoint)
elif breakpoint_index in self.debugger.pending_breakpoint_list:
del self.debugger.pending_breakpoint_list[breakpoint_index]
+ if not self.debugger.pending_breakpoint_list:
+ self.debugger.send_parser_config(0)
else:
print("Error: Breakpoint %d not found" % (breakpoint_index))
- def exec_backtrace(self, args):
+ def do_backtrace(self, args):
+ """ Get backtrace data from debugger """
max_depth = 0
if args:
self.debugger.send_message(message)
self.stop = True
- def do_backtrace(self, args):
- """ Get backtrace data from debugger """
- self.exec_backtrace(args)
-
do_bt = do_backtrace
def do_src(self, args):
if args:
line_num = src_check_args(args)
if line_num >= 0:
- print_source(self.debugger, line_num)
+ print_source(self.debugger, line_num, 0)
elif line_num == 0:
- print_source(self.debugger, self.debugger.default_viewrange)
+ print_source(self.debugger, self.debugger.default_viewrange, 0)
else:
return
do_source = do_src
+ def _scroll_direction(self, args):
+ """ Helper function for do_scroll """
+ self.debugger.src_offset_diff = int(max(math.floor(self.debugger.display / 3), 1))
+ if args in "up":
+ self.debugger.src_offset -= self.debugger.src_offset_diff
+ print_source(self.debugger, self.debugger.display, self.debugger.src_offset)
+ else:
+ self.debugger.src_offset += self.debugger.src_offset_diff
+ print_source(self.debugger, self.debugger.display, self.debugger.src_offset)
+
+ def do_scroll(self, _):
+ """ Scroll the source up or down """
+ while True:
+ key = sys.stdin.readline()
+ if key == 'w\n':
+ self._scroll_direction("up")
+ elif key == 's\n':
+ self._scroll_direction("down")
+ elif key == 'q\n':
+ break
+ else:
+ print("Invalid key")
+
def do_display(self, args):
""" Toggle source code display after breakpoints """
if args:
def do_dump(self, args):
""" Dump all of the debugger data """
- if self.disable_args(args):
+ if args:
+ print("Error: No argument expected")
return
pprint(self.debugger.function_list)
- def send_string(self, args, message_type):
+ def _send_string(self, args, message_type):
size = len(args)
- if size == 0:
- return
# 1: length of type byte
# 4: length of an uint32 value
def do_eval(self, args):
""" Evaluate JavaScript source code """
- self.send_string(args, JERRY_DEBUGGER_EVAL)
+ self._send_string(JERRY_DEBUGGER_EVAL_EVAL + args, JERRY_DEBUGGER_EVAL)
do_e = do_eval
+ def do_throw(self, args):
+ """ Throw an exception """
+ self._send_string(JERRY_DEBUGGER_EVAL_THROW + args, JERRY_DEBUGGER_EVAL)
+
+ def do_abort(self, args):
+ """ Throw an exception """
+ self._send_string(JERRY_DEBUGGER_EVAL_ABORT + args, JERRY_DEBUGGER_EVAL)
+
def do_exception(self, args):
""" Config the exception handler module """
if not args:
def do_memstats(self, args):
""" Memory statistics """
- self.exec_command(args, JERRY_DEBUGGER_MEMSTATS)
+ self._exec_command(args, JERRY_DEBUGGER_MEMSTATS)
return
do_ms = do_memstats
sys.exit("Error: Javascript file expected!")
return
- with open(path, 'r') as f:
- content = path + "\0" + f.read()
- self.send_string(content, JERRY_DEBUGGER_CLIENT_SOURCE)
+ with open(path, 'r') as src_file:
+ content = path + "\0" + src_file.read()
+ self._send_string(content, JERRY_DEBUGGER_CLIENT_SOURCE)
def send_no_more_source(self):
- self.exec_command("", JERRY_DEBUGGER_NO_MORE_SOURCES)
+ self._exec_command("", JERRY_DEBUGGER_NO_MORE_SOURCES)
self.cont = True
class Multimap(object):
class JerryDebugger(object):
-
+ # pylint: disable=too-many-instance-attributes,too-many-statements
def __init__(self, address):
if ":" not in address:
self.yellow_bg = ''
self.blue = ''
self.nocolor = ''
+ self.src_offset = 0
+ self.src_offset_diff = 0
self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.client_socket.connect((self.host, self.port))
+ self.repeats_remain = 0
self.send_message(b"GET /jerry-debugger HTTP/1.1\r\n" +
b"Upgrade: websocket\r\n" +
else:
result = b""
- len_expected = 6
+ len_expected = 7
# Network configurations, which has the following struct:
# header [2] - opcode[1], size[1]
# type [1]
# max_message_size [1]
# cpointer_size [1]
# little_endian [1]
+ # version [1]
while len(result) < len_expected:
result += self.client_socket.recv(1024)
expected = struct.pack("BBB",
WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT,
- 4,
+ 5,
JERRY_DEBUGGER_CONFIGURATION)
if result[0:3] != expected:
self.max_message_size = ord(result[3])
self.cp_size = ord(result[4])
self.little_endian = ord(result[5])
+ self.version = ord(result[6])
+
+ if self.version != JERRY_DEBUGGER_VERSION:
+ raise Exception("Incorrect debugger version from target: %d expected: %d" %
+ (self.version, JERRY_DEBUGGER_VERSION))
+
if self.little_endian:
self.byte_order = "<"
self.send_breakpoint(breakpoint)
def delete_pending(self):
- self.pending_breakpoint_list.clear()
+ if self.pending_breakpoint_list:
+ self.pending_breakpoint_list.clear()
+ self.send_parser_config(0)
def breakpoint_pending_exists(self, breakpoint):
for existing_bp in self.pending_breakpoint_list.values():
enable)
self.send_message(message)
+ def send_parser_config(self, enable):
+ message = struct.pack(self.byte_order + "BBIBB",
+ WEBSOCKET_BINARY_FRAME | WEBSOCKET_FIN_BIT,
+ WEBSOCKET_FIN_BIT + 1 + 1,
+ 0,
+ JERRY_DEBUGGER_PARSER_CONFIG,
+ enable)
+ self.send_message(message)
+
def set_colors(self):
- self.green = '\033[92m'
self.nocolor = '\033[0m'
+ self.green = '\033[92m'
self.red = '\033[31m'
self.yellow = '\033[93m'
- self.green_bg = '\033[42m'
- self.yellow_bg = '\033[43m'
+ self.green_bg = '\033[42m\033[30m'
+ self.yellow_bg = '\033[43m\033[30m'
self.blue = '\033[94m'
def get_message(self, blocking):
self.message_data += data
+# pylint: disable=too-many-branches,too-many-locals,too-many-statements
def parse_source(debugger, data):
source_code = ""
source_code_name = ""
debugger.line_list.insert(line, breakpoint)
# Try to set the pending breakpoints
- if len(debugger.pending_breakpoint_list) != 0:
+ if debugger.pending_breakpoint_list:
logging.debug("Pending breakpoints list: %s", debugger.pending_breakpoint_list)
bp_list = debugger.pending_breakpoint_list
- for breakpoint in bp_list:
+ for breakpoint_index, breakpoint in bp_list.items():
for src in debugger.function_list.values():
- if src.source_name == bp_list[breakpoint].source_name:
+ if src.source_name == breakpoint.source_name:
source_lines = len(src.source)
else:
source_lines = 0
- if bp_list[breakpoint].line:
- if bp_list[breakpoint].line <= source_lines:
- tmp_bp = breakpoint
- breakpoint = bp_list[breakpoint].source_name + ":" + str(bp_list[breakpoint].line)
- if set_breakpoint(debugger, breakpoint, True):
- del tmp_bp
- elif bp_list[breakpoint].function:
- tmp_bp = breakpoint
- breakpoint = bp_list[breakpoint].function
- if set_breakpoint(debugger, breakpoint, True):
- del tmp_bp
+ if breakpoint.line:
+ if breakpoint.line <= source_lines:
+ command = breakpoint.source_name + ":" + str(breakpoint.line)
+ if set_breakpoint(debugger, command, True):
+ del bp_list[breakpoint_index]
+ elif breakpoint.function:
+ command = breakpoint.function
+ if set_breakpoint(debugger, command, True):
+ del bp_list[breakpoint_index]
+ if not bp_list:
+ debugger.send_parser_config(0)
else:
logging.debug("No pending breakpoints")
return -1
-def print_source(debugger, line_num):
+def print_source(debugger, line_num, offset):
last_bp = debugger.last_breakpoint_hit
if not last_bp:
return
else:
start = max(last_bp.line - line_num, 0)
end = min(last_bp.line + line_num - 1, len(last_bp.function.source))
+ if offset:
+ if start + offset < 0:
+ debugger.src_offset += debugger.src_offset_diff
+ offset += debugger.src_offset_diff
+ elif end + offset > len(last_bp.function.source):
+ debugger.src_offset -= debugger.src_offset_diff
+ offset -= debugger.src_offset_diff
+
+ start = max(start + offset, 0)
+ end = min(end + offset, len(last_bp.function.source))
for i in range(start, end):
if i == last_bp.line - 1:
if not found and not pending:
print("No breakpoint found, do you want to add a %spending breakpoint%s? (y or [n])" % \
- (debugger.yellow, debugger.nocolor))
+ (debugger.yellow, debugger.nocolor))
+
ans = sys.stdin.readline()
if ans in ['yes\n', 'y\n']:
+ if not debugger.pending_breakpoint_list:
+ debugger.send_parser_config(1)
+
if line:
breakpoint = JerryPendingBreakpoint(int(line.group(2)), line.group(1))
else:
breakpoint = JerryPendingBreakpoint(function=string)
enable_breakpoint(debugger, breakpoint)
+
elif not found and pending:
return False
return (function.offsets[nearest_offset], False)
+# pylint: disable=too-many-branches,too-many-locals,too-many-statements
def main():
args = arguments_parse()
JERRY_DEBUGGER_FUNCTION_NAME_END]:
parse_source(debugger, data)
+ elif buffer_type == JERRY_DEBUGGER_WAITING_AFTER_PARSE:
+ debugger.send_command(JERRY_DEBUGGER_PARSER_RESUME)
+
elif buffer_type == JERRY_DEBUGGER_RELEASE_BYTE_CODE_CP:
release_function(debugger, data)
print("Stopped %s %s" % (breakpoint_info, breakpoint[0]))
if debugger.display:
- print_source(prompt.debugger, debugger.display)
+ print_source(prompt.debugger, debugger.display, 0)
+
+ if debugger.repeats_remain:
+ prompt.do_next(debugger.repeats_remain)
+ time.sleep(0.1)
+ else:
+ prompt.cmdloop()
- prompt.cmdloop()
if prompt.quit:
break
# Subtypes of output
if buffer_type == JERRY_DEBUGGER_OUTPUT_RESULT_END:
+ message = message.rstrip('\n')
if subtype in [JERRY_DEBUGGER_OUTPUT_OK,
JERRY_DEBUGGER_OUTPUT_DEBUG]:
print("%sout: %s%s" % (debugger.blue, debugger.nocolor, message))
try:
main()
except socket.error as error_msg:
- try:
- errno = error_msg.errno
- msg = str(error_msg)
- except:
- errno = error_msg[0]
- msg = error_msg[1]
-
- if errno == 111:
+ ERRNO = error_msg.errno
+ MSG = str(error_msg)
+
+ if ERRNO == 111:
sys.exit("Failed to connect to the JerryScript debugger.")
- elif errno == 32 or errno == 104:
+ elif ERRNO == 32 or ERRNO == 104:
sys.exit("Connection closed.")
else:
- sys.exit("Failed to connect to the JerryScript debugger.\nError: %s" % (msg))
+ sys.exit("Failed to connect to the JerryScript debugger.\nError: %s" % (MSG))
set(DEFINES_LIBC ${DEFINES_LIBC} ENABLE_INIT_FINI)
endif()
-# Architecture-specific configuration
-if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
- set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_x64)
-elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l")
- set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_HARD_FLOAT)
-elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "armv7l-el")
- set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_ARMv7 __TARGET_HOST_ARMv7_SOFT_FLOAT)
-elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
- set(DEFINES_LIBC ${DEFINES_LIBC} __TARGET_HOST_x86)
-else()
- message(FATAL_ERROR "Machine architecture ${CMAKE_SYSTEM_PROCESSOR} isn't supported")
-endif()
-
# Include directories
set(INCLUDE_LIBC "${CMAKE_CURRENT_SOURCE_DIR}")
* store s16-s31 vfp registers to buffer, pointed with r0 register,
* and increase the register on size of stored data.
*/
-#ifdef __TARGET_HOST_ARMv7_HARD_FLOAT
+#if defined (__VFP_FP__) && !defined (__SOFTFP__)
# define _STORE_VFP_S16_S31_IF_HARD_FLOAT \
vstm r0!, {s16 - s31};
# define _LOAD_VFP_S16_S31_IF_HARD_FLOAT \
vldm r0!, {s16 - s31};
-#else /* !__TARGET_HOST_ARMv7_HARD_FLOAT */
+#else /* !__VFP_FP__ || __SOFTFP__ */
# define _STORE_VFP_S16_S31_IF_HARD_FLOAT
# define _LOAD_VFP_S16_S31_IF_HARD_FLOAT
-#endif /* __TARGET_HOST_ARMv7_HARD_FLOAT */
+#endif /* __VFP_FP__ && !__SOFTFP__ */
/*
* setjmp
* limitations under the License.
*/
-#if defined (__TARGET_HOST_x64)
+#if defined (__x86_64__)
#include "arch/x86-64.h"
-#elif defined (__TARGET_HOST_x86)
+#elif defined (__i386__)
#include "arch/x86-32.h"
-#elif defined (__TARGET_HOST_ARMv7)
+#elif defined (__ARM_ARCH_7A__)
#include "arch/arm-v7.h"
-#else /* !__TARGET_HOST_x64 && !__TARGET_HOST_x86 && !__TARGET_HOST_ARMv7 */
+#else /* !__x86_64__ && !__i386__ && !__ARM_ARCH_7A__ */
#error "Unsupported architecture"
-#endif /* __TARGET_HOST_x64 */
+#endif /* __x86_64__ */
#if defined (__linux__)
.macro func _name
defined (i486) || defined (__i486) || defined (__i486__) || \
defined (intel) || defined (x86) || defined (i86pc) || \
defined (__alpha) || defined (__osf__) || \
- defined (__x86_64__) || defined (__arm__) || defined (__aarch64__))
+ defined (__x86_64__) || defined (__arm__) || defined (__aarch64__) || \
+ defined (__xtensa__))
#define __LITTLE_ENDIAN
#endif
* limitations under the License.
*/
+#include <assert.h>
#include <string.h>
#include "jerryscript.h"
} /* read_file */
/**
+ * Print error value
+ */
+static void
+print_unhandled_exception (jerry_value_t error_value) /**< error value */
+{
+ assert (!jerry_value_has_error_flag (error_value));
+
+ jerry_value_t err_str_val = jerry_value_to_string (error_value);
+
+ if (jerry_value_has_error_flag (err_str_val))
+ {
+ /* Avoid recursive error throws. */
+ jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Snapshot error: [value cannot be converted to string]\n");
+ jerry_release_value (err_str_val);
+ return;
+ }
+
+ jerry_size_t err_str_size = jerry_get_string_size (err_str_val);
+
+ if (err_str_size >= 256)
+ {
+ jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Snapshot error: [value cannot be converted to string]\n");
+ jerry_release_value (err_str_val);
+ return;
+ }
+
+ jerry_char_t err_str_buf[256];
+ jerry_size_t string_end = jerry_string_to_char_buffer (err_str_val, err_str_buf, err_str_size);
+ assert (string_end == err_str_size);
+ err_str_buf[string_end] = 0;
+
+ jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Snapshot error: %s\n", (char *) err_str_buf);
+ jerry_release_value (err_str_val);
+} /* print_unhandled_exception */
+
+/**
* Generate command line option IDs
*/
typedef enum
{
OPT_GENERATE_HELP,
- OPT_GENERATE_CONTEXT,
- OPT_GENERATE_SHOW_OP,
+ OPT_GENERATE_STATIC,
OPT_GENERATE_LITERAL_LIST,
OPT_GENERATE_LITERAL_C,
+ OPT_GENERATE_SHOW_OP,
OPT_GENERATE_OUT,
} generate_opt_id_t;
{
CLI_OPT_DEF (.id = OPT_GENERATE_HELP, .opt = "h", .longopt = "help",
.help = "print this help and exit"),
- CLI_OPT_DEF (.id = OPT_GENERATE_SHOW_OP, .longopt = "show-opcodes",
- .help = "print generated opcodes"),
- CLI_OPT_DEF (.id = OPT_GENERATE_CONTEXT, .opt = "c", .longopt = "context",
- .meta = "MODE",
- .help = "specify the execution context of the snapshot: "
- "global or eval (default: global)."),
+ CLI_OPT_DEF (.id = OPT_GENERATE_STATIC, .opt = "s", .longopt = "static",
+ .help = "generate static snapshot"),
CLI_OPT_DEF (.id = OPT_GENERATE_LITERAL_LIST, .longopt = "save-literals-list-format",
.meta = "FILE",
.help = "export literals found in parsed JS input (in list format)"),
CLI_OPT_DEF (.id = OPT_GENERATE_LITERAL_C, .longopt = "save-literals-c-format",
.meta = "FILE",
.help = "export literals found in parsed JS input (in C source format)"),
+ CLI_OPT_DEF (.id = OPT_GENERATE_SHOW_OP, .longopt = "show-opcodes",
+ .help = "print generated opcodes"),
CLI_OPT_DEF (.id = OPT_GENERATE_OUT, .opt = "o", .meta="FILE",
.help = "specify output file name (default: js.snapshot)"),
CLI_OPT_DEF (.id = CLI_OPT_DEFAULT, .meta = "FILE",
(void) argc;
bool is_save_literals_mode_in_c_format = false;
- bool is_snapshot_mode_for_global = true;
+ uint32_t snapshot_flags = 0;
jerry_init_flag_t flags = JERRY_INIT_EMPTY;
- uint32_t number_of_files = 0;
+ const char *file_name_p = NULL;
uint8_t *source_p = input_buffer;
size_t source_length = 0;
const char *save_literals_file_name_p = NULL;
cli_help (prog_name_p, "generate", generate_opts);
return JERRY_STANDALONE_EXIT_CODE_OK;
}
- case OPT_GENERATE_OUT:
+ case OPT_GENERATE_STATIC:
{
- output_file_name_p = cli_consume_string (cli_state_p);
+ snapshot_flags |= JERRY_SNAPSHOT_SAVE_STATIC;
break;
}
case OPT_GENERATE_LITERAL_LIST:
}
break;
}
- case OPT_GENERATE_CONTEXT:
+ case OPT_GENERATE_OUT:
{
- const char *mode_str_p = cli_consume_string (cli_state_p);
-
- if (cli_state_p->error != NULL)
- {
- break;
- }
-
- if (!strcmp ("global", mode_str_p))
- {
- is_snapshot_mode_for_global = true;
- }
- else if (!strcmp ("eval", mode_str_p))
- {
- is_snapshot_mode_for_global = false;
- }
- else
- {
- jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Incorrect argument for context mode: %s\n", mode_str_p);
- return JERRY_STANDALONE_EXIT_CODE_FAIL;
- }
+ output_file_name_p = cli_consume_string (cli_state_p);
break;
}
case CLI_OPT_DEFAULT:
{
- const char *file_name_p = cli_consume_string (cli_state_p);
+ if (file_name_p != NULL)
+ {
+ jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: Exactly one input file must be specified\n");
+ return JERRY_STANDALONE_EXIT_CODE_FAIL;
+ }
+
+ file_name_p = cli_consume_string (cli_state_p);
if (cli_state_p->error == NULL)
{
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Input file is empty\n");
return JERRY_STANDALONE_EXIT_CODE_FAIL;
}
-
- number_of_files++;
}
break;
}
return JERRY_STANDALONE_EXIT_CODE_FAIL;
}
- if (number_of_files != 1)
+ if (file_name_p == NULL)
{
- jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: No input file specified!\n");
+ jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: Exactly one input file must be specified\n");
return JERRY_STANDALONE_EXIT_CODE_FAIL;
}
return JERRY_STANDALONE_EXIT_CODE_FAIL;
}
- size_t snapshot_size = jerry_parse_and_save_snapshot ((jerry_char_t *) source_p,
- source_length,
- is_snapshot_mode_for_global,
- false,
- output_buffer,
- sizeof (output_buffer) / sizeof (uint32_t));
- if (snapshot_size == 0)
+ jerry_value_t snapshot_result;
+
+ snapshot_result = jerry_generate_snapshot ((jerry_char_t *) file_name_p,
+ (size_t) strlen (file_name_p),
+ (jerry_char_t *) source_p,
+ source_length,
+ snapshot_flags,
+ output_buffer,
+ sizeof (output_buffer) / sizeof (uint32_t));
+
+ if (jerry_value_has_error_flag (snapshot_result))
{
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: Generating snapshot failed!\n");
+
+ jerry_value_clear_error_flag (&snapshot_result);
+
+ print_unhandled_exception (snapshot_result);
+
+ jerry_release_value (snapshot_result);
return JERRY_STANDALONE_EXIT_CODE_FAIL;
}
+ size_t snapshot_size = (size_t) jerry_get_number_value (snapshot_result);
+ jerry_release_value (snapshot_result);
+
FILE *snapshot_file_p = fopen (output_file_name_p, "w");
if (snapshot_file_p == NULL)
{
}
else
{
- ret_value = jerry_parse (source_p, source_size, false);
+ ret_value = jerry_parse (NULL, 0, source_p, source_size, JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (ret_value))
{
} /* read_file */
/**
- * Check whether an error is a SyntaxError or not
- *
- * @return true - if param is SyntaxError
- * false - otherwise
+ * Print error value
*/
-static bool
-jerry_value_is_syntax_error (jerry_value_t error_value) /**< error value */
+static void
+print_unhandled_exception (jerry_value_t error_value) /**< error value */
{
- assert (jerry_is_feature_enabled (JERRY_FEATURE_ERROR_MESSAGES));
-
- if (!jerry_value_is_object (error_value))
- {
- return false;
- }
+ assert (!jerry_value_has_error_flag (error_value));
- jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *)"name");
- jerry_value_t error_name = jerry_get_property (error_value, prop_name);
- jerry_release_value (prop_name);
+ jerry_char_t err_str_buf[256];
- if (jerry_value_has_error_flag (error_name)
- || !jerry_value_is_string (error_name))
+ if (jerry_value_is_object (error_value))
{
- jerry_release_value (error_name);
- return false;
- }
+ jerry_value_t stack_str = jerry_create_string ((const jerry_char_t *) "stack");
+ jerry_value_t backtrace_val = jerry_get_property (error_value, stack_str);
+ jerry_release_value (stack_str);
- jerry_size_t err_str_size = jerry_get_string_size (error_name);
- const char syntax_error_str[] = "SyntaxError";
+ if (!jerry_value_has_error_flag (backtrace_val)
+ && jerry_value_is_array (backtrace_val))
+ {
+ printf ("Exception backtrace:\n");
- if (err_str_size != strlen (syntax_error_str) - 1)
- {
- jerry_release_value (error_name);
- return false;
- }
+ uint32_t length = jerry_get_array_length (backtrace_val);
- jerry_char_t err_str_buf[err_str_size];
+ /* This length should be enough. */
+ if (length > 32)
+ {
+ length = 32;
+ }
- jerry_size_t sz = jerry_string_to_char_buffer (error_name, err_str_buf, err_str_size);
- jerry_release_value (error_name);
+ for (uint32_t i = 0; i < length; i++)
+ {
+ jerry_value_t item_val = jerry_get_property_by_index (backtrace_val, i);
- if (sz == 0)
- {
- return false;
- }
+ if (!jerry_value_has_error_flag (item_val)
+ && jerry_value_is_string (item_val))
+ {
+ jerry_size_t str_size = jerry_get_string_size (item_val);
- if (!strncmp ((char *) err_str_buf, syntax_error_str, sizeof (syntax_error_str) - 1))
- {
- return true;
- }
+ if (str_size >= 256)
+ {
+ printf ("%3d: [Backtrace string too long]\n", i);
+ }
+ else
+ {
+ jerry_size_t string_end = jerry_string_to_char_buffer (item_val, err_str_buf, str_size);
+ assert (string_end == str_size);
+ err_str_buf[string_end] = 0;
- return false;
-} /* jerry_value_is_syntax_error */
+ printf ("%3d: %s\n", i, err_str_buf);
+ }
+ }
-/**
- * Print error value
- */
-static void
-print_unhandled_exception (jerry_value_t error_value) /**< error value */
-{
- assert (!jerry_value_has_error_flag (error_value));
+ jerry_release_value (item_val);
+ }
+ }
+ jerry_release_value (backtrace_val);
+ }
jerry_value_t err_str_val = jerry_value_to_string (error_value);
jerry_size_t err_str_size = jerry_get_string_size (err_str_val);
- jerry_char_t err_str_buf[256];
if (err_str_size >= 256)
{
const char msg[] = "[Error message too long]";
err_str_size = sizeof (msg) / sizeof (char) - 1;
- memcpy (err_str_buf, msg, err_str_size);
+ memcpy (err_str_buf, msg, err_str_size + 1);
}
else
{
- jerry_size_t sz = jerry_string_to_char_buffer (err_str_val, err_str_buf, err_str_size);
- assert (sz == err_str_size);
- err_str_buf[err_str_size] = 0;
+ jerry_size_t string_end = jerry_string_to_char_buffer (err_str_val, err_str_buf, err_str_size);
+ assert (string_end == err_str_size);
+ err_str_buf[string_end] = 0;
- if (jerry_is_feature_enabled (JERRY_FEATURE_ERROR_MESSAGES) && jerry_value_is_syntax_error (error_value))
+ if (jerry_is_feature_enabled (JERRY_FEATURE_ERROR_MESSAGES)
+ && jerry_get_error_type (error_value) == JERRY_ERROR_SYNTAX)
{
unsigned int err_line = 0;
unsigned int err_col = 0;
/* 1. parse column and line information */
- for (jerry_size_t i = 0; i < sz; i++)
+ for (jerry_size_t i = 0; i < string_end; i++)
{
if (!strncmp ((char *) (err_str_buf + i), "[line: ", 7))
{
char num_str[8];
unsigned int j = 0;
- while (i < sz && err_str_buf[i] != ',')
+ while (i < string_end && err_str_buf[i] != ',')
{
num_str[j] = (char) err_str_buf[i];
j++;
i += 10;
j = 0;
- while (i < sz && err_str_buf[i] != ']')
+ while (i < string_end && err_str_buf[i] != ']')
{
num_str[j] = (char) err_str_buf[i];
j++;
jerry_release_value (result_val);
} /* register_js_function */
-#ifdef JERRY_DEBUGGER
/**
* Runs the source code received by jerry_debugger_wait_for_client_source.
size_t source_size, /**< source code size */
void *user_p __attribute__((unused))) /**< user pointer */
{
- jerry_value_t ret_val = jerry_parse_named_resource (resource_name_p,
- resource_name_size,
- source_p,
- source_size,
- false);
+ jerry_value_t ret_val = jerry_parse (resource_name_p,
+ resource_name_size,
+ source_p,
+ source_size,
+ JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (ret_val))
{
return ret_val;
} /* wait_for_source_callback */
-#endif /* JERRY_DEBUGGER */
/**
* Command line option IDs
}
else
{
- ret_value = jerry_exec_snapshot_at (snapshot_p,
- snapshot_size,
- exec_snapshot_file_indices[i],
- true);
+ ret_value = jerry_exec_snapshot (snapshot_p,
+ snapshot_size,
+ exec_snapshot_file_indices[i],
+ JERRY_SNAPSHOT_EXEC_COPY_DATA);
}
if (jerry_value_has_error_flag (ret_value))
break;
}
- ret_value = jerry_parse_named_resource ((jerry_char_t *) file_names[i],
- strlen (file_names[i]),
- source_p,
- source_size,
- false);
+ ret_value = jerry_parse ((jerry_char_t *) file_names[i],
+ strlen (file_names[i]),
+ source_p,
+ source_size,
+ JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (ret_value) && !is_parse_only)
{
if (is_wait_mode)
{
is_repl_mode = false;
-#ifdef JERRY_DEBUGGER
- while (true)
+ if (jerry_is_feature_enabled (JERRY_FEATURE_DEBUGGER))
{
- jerry_debugger_wait_for_source_status_t receive_status;
-
- do
+ while (true)
{
- jerry_value_t run_result;
-
- receive_status = jerry_debugger_wait_for_client_source (wait_for_source_callback,
- NULL,
- &run_result);
+ jerry_debugger_wait_for_source_status_t receive_status;
- if (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED)
+ do
{
- ret_value = jerry_create_error (JERRY_ERROR_COMMON,
- (jerry_char_t *) "Connection aborted before source arrived.");
+ jerry_value_t run_result;
+
+ receive_status = jerry_debugger_wait_for_client_source (wait_for_source_callback,
+ NULL,
+ &run_result);
+
+ if (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVE_FAILED)
+ {
+ ret_value = jerry_create_error (JERRY_ERROR_COMMON,
+ (jerry_char_t *) "Connection aborted before source arrived.");
+ }
+
+ if (receive_status == JERRY_DEBUGGER_SOURCE_END)
+ {
+ jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "No more client source.\n");
+ }
+
+ jerry_release_value (run_result);
}
+ while (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVED);
- if (receive_status == JERRY_DEBUGGER_SOURCE_END)
+ if (receive_status != JERRY_DEBUGGER_CONTEXT_RESET_RECEIVED)
{
- jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "No more client source.\n");
+ break;
}
- jerry_release_value (run_result);
- }
- while (receive_status == JERRY_DEBUGGER_SOURCE_RECEIVED);
+ jerry_cleanup ();
- if (receive_status != JERRY_DEBUGGER_CONTEXT_RESET_RECEIVED)
- {
- break;
- }
-
- jerry_cleanup ();
+ jerry_init (flags);
+ jerry_debugger_init (debug_port);
- jerry_init (flags);
- jerry_debugger_init (debug_port);
+ register_js_function ("assert", jerryx_handler_assert);
+ register_js_function ("gc", jerryx_handler_gc);
+ register_js_function ("print", jerryx_handler_print);
- register_js_function ("assert", jerryx_handler_assert);
- register_js_function ("gc", jerryx_handler_gc);
- register_js_function ("print", jerryx_handler_print);
-
- ret_value = jerry_create_undefined ();
+ ret_value = jerry_create_undefined ();
+ }
}
-#endif /* JERRY_DEBUGGER */
}
if (is_repl_mode)
--- /dev/null
+/* Copyright JS Foundation and other contributors, http://js.foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "jerryscript-port.h"
+#include "jerryscript-port-default.h"
+
+#ifdef HAVE_TIME_H
+#include <time.h>
+#elif defined (HAVE_UNISTD_H)
+#include <unistd.h>
+#endif /* HAVE_TIME_H */
+
+#ifdef JERRY_DEBUGGER
+void jerry_port_sleep (uint32_t sleep_time)
+{
+#ifdef HAVE_TIME_H
+ nanosleep (&(const struct timespec)
+ {
+ sleep_time / 1000, (sleep_time % 1000) * 1000000L /* Seconds, nanoseconds */
+ }
+ , NULL);
+#elif defined (HAVE_UNISTD_H)
+ usleep ((useconds_t) sleep_time * 1000);
+#endif /* HAVE_TIME_H */
+ (void) sleep_time;
+} /* jerry_port_sleep */
+#endif /* JERRY_DEBUGGER */
js_entry();
- /* run js files */
+ /* run rest of the js files first */
show_free_mem(2);
- for (int src = 0; js_codes[src].source; src++) {
+ for (int src = 1; js_codes[src].source; src++) {
int retcode = js_eval(js_codes[src].source, js_codes[src].length);
if (retcode != 0) {
printf("js_eval failed code(%d) [%s]\r\n", retcode, js_codes[src].name);
- return -2;
+ return -1;
}
}
+
+ /* run main.js */
+ int retcode = js_eval(js_codes[0].source, js_codes[0].length);
+ if (retcode != 0) {
+ printf("js_eval failed code(%d) [%s]\r\n", retcode, js_codes[0].name);
+ return -2;
+ }
show_free_mem(3);
return 0;
}
js_register_functions ();
- jerry_value_t parsed_code = jerry_parse (jerry_src, source_size, false);
+ jerry_value_t parsed_code = jerry_parse (NULL, 0, jerry_src, source_size, JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (parsed_code))
{
const jerry_char_t* code = reinterpret_cast<const jerry_char_t*>(js_codes[src].source);
const size_t length = js_codes[src].length;
- jerry_value_t parsed_code = jerry_parse(code, length, false);
+ jerry_value_t parsed_code = jerry_parse(NULL, 0, code, length, JERRY_PARSE_NO_OPTS);
if (jerry_value_has_error_flag(parsed_code)) {
LOG_PRINT_ALWAYS("jerry_parse failed [%s]\r\n", js_codes[src].name);
install-kconfig:
git clone https://bitbucket.org/nuttx/tools.git ../tools
mkdir -p $(LOCAL_INSTALL)
- cd ../tools/kconfig-frontends && ./configure --disable-mconf --disable-nconf --disable-gconf --disable-qconf --disable-utils --disable-shared --enable-static --prefix=$(LOCAL_INSTALL)
+ # FIXME: 'autoreconf --force --install' is a workaround after
+ # https://bitbucket.org/nuttx/tools/commits/164450f982b404fdc2b3233db51dc3eaa1f08b7f
+ cd ../tools/kconfig-frontends && autoreconf --force --install && ./configure --disable-mconf --disable-nconf --disable-gconf --disable-qconf --disable-utils --disable-shared --enable-static --prefix=$(LOCAL_INSTALL)
$(MAKE) -C ../tools/kconfig-frontends
$(MAKE) -C ../tools/kconfig-frontends install
} /* read_file */
/**
- * Check whether an error is a SyntaxError or not
- *
- * @return true - if param is SyntaxError
- * false - otherwise
- */
-static bool
-jerry_value_is_syntax_error (jerry_value_t error_value) /**< error value */
-{
- assert (jerry_is_feature_enabled (JERRY_FEATURE_ERROR_MESSAGES));
-
- if (!jerry_value_is_object (error_value))
- {
- return false;
- }
-
- jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *)"name");
- jerry_value_t error_name = jerry_get_property (error_value, prop_name);
- jerry_release_value (prop_name);
-
- if (jerry_value_has_error_flag (error_name)
- || !jerry_value_is_string (error_name))
- {
- return false;
- }
-
- jerry_size_t err_str_size = jerry_get_string_size (error_name);
- const char syntax_error_str[] = "SyntaxError";
-
- if (err_str_size != strlen (syntax_error_str) - 1)
- {
- jerry_release_value (error_name);
- return false;
- }
-
- jerry_char_t err_str_buf[err_str_size];
-
- jerry_size_t sz = jerry_string_to_char_buffer (error_name, err_str_buf, err_str_size);
- jerry_release_value (error_name);
-
- if (sz == 0)
- {
- return false;
- }
-
- if (!strncmp ((char *) err_str_buf, syntax_error_str, sizeof (syntax_error_str) - 1))
- {
- return true;
- }
-
- return false;
-} /* jerry_value_is_syntax_error */
-
-/**
* Convert string into unsigned integer
*
* @return converted number
{
assert (jerry_value_has_error_flag (error_value));
- jerry_value_clear_error_flag (&error_value);
+ error_value = jerry_get_value_without_error_flag (error_value);
jerry_value_t err_str_val = jerry_value_to_string (error_value);
jerry_size_t err_str_size = jerry_get_string_size (err_str_val);
jerry_char_t err_str_buf[256];
+ jerry_release_value (error_value);
+
if (err_str_size >= 256)
{
const char msg[] = "[Error message too long]";
assert (sz == err_str_size);
err_str_buf[err_str_size] = 0;
- if (jerry_is_feature_enabled (JERRY_FEATURE_ERROR_MESSAGES) && jerry_value_is_syntax_error (error_value))
+ if (jerry_is_feature_enabled (JERRY_FEATURE_ERROR_MESSAGES)
+ && jerry_get_error_type (error_value) == JERRY_ERROR_SYNTAX)
{
uint32_t err_line = 0;
uint32_t err_col = 0;
const jerry_char_t script[] = "var str = 'Hello World'; print(str + ' from JerryScript')";
size_t script_size = strlen ((const char *) script);
- ret_value = jerry_parse (script, script_size, false);
+ ret_value = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (ret_value))
{
return JERRY_STANDALONE_EXIT_CODE_FAIL;
}
- ret_value = jerry_parse_named_resource ((jerry_char_t *) file_names[i],
- strlen (file_names[i]),
- source_p,
- source_size,
- false);
+ ret_value = jerry_parse ((jerry_char_t *) file_names[i],
+ strlen (file_names[i]),
+ source_p,
+ source_size,
+ JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (ret_value))
{
--- /dev/null
+# JerryScript for OpenWrt build guide
+
+This document describes the steps required to compile the JerryScript
+for OpenWrt. For target device the TP-Link WR1043ND v1.x router is
+used. Please be advised, that if you have a different one minor
+modifications to this document could be required.
+
+IMPORTANT!
+
+As the TP-Link WR1043ND is a mips based device and mips is a big-endian
+architecture a JerryScipt snapshot which was built on an little-endian
+system will not work correctly. Thus it is advised that the
+snapshot functionally should be used with caution, that is
+DO NOT run snapshots generated on little-endian system(s) on
+a big-endian system.
+
+## OpenWrt notes
+
+In 2018 ~January the OpenWrt and LEDE project merged into one
+and thus the old OpenWrt parts are now usable only from
+an archived repository: https://github.com/openwrt/archive
+
+## OpenWrt toolchain setup
+
+To build the JerryScript for OpenWrt a toolchain is required for
+the target router/device. The toolchain setup in this document was
+tested on an Ubuntu 16.04.3 LTS Linux.
+
+Steps required for toolchain creation:
+
+### 0. Install OpenWrt build requirements
+```sh
+$ sudo apt-get install git-core build-essential libssl-dev libncurses5-dev unzip gawk zlib1g-dev subversion mercurial
+```
+
+### 1. Clone OpenWrt (Chaos Calmer version)
+
+```sh
+$ git clone https://github.com/openwrt/archive openwrt -b chaos_calmer
+$ cd openwrt
+```
+
+### 2. Run Menuconfig and configure the OpenWrt
+
+```sh
+$ make menuconfig
+```
+
+Options which should be set:
+* Set "Target System" to "Atheros AR7xxx/AR9xxx".
+* Set "Target Profile" to "TP-LINK TL-WR1043N/ND".
+
+Save the configuration (as .config) and exit from the menuconfig.
+
+### 3. Configure the environment variables
+
+```sh
+$ export BUILDROOT=$(pwd) # where the openwrt root dir is
+$ export STAGING_DIR=${BUILDROOT}/staging_dir/ # required by the compiler
+$ export PATH=$PATH:${STAGING_DIR}/host/bin:${STAGING_DIR}/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/
+```
+
+The name `toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2` is created based on the menuconfig.
+This changes depending on the target device!
+
+### 4. Build the OpenWrt
+
+```sh
+$ make
+```
+
+### 5. Check if the compiler was built
+
+```sh
+$ mips-openwrt-linux-gcc --version # running this should print out the version information
+```
+
+At this point we have the required compiler for OpenWrt.
+
+## Build JerryScript for OpenWrt
+
+### 0. Check environment
+
+Please check if the `STAGING_DIR` is configured correctly and that the toolchain binary is on the `PATH`.
+
+### 1. Run the build with the OpenWrt toolchain file
+
+```
+$ ./tools/build.py --toolchain cmake/toolchain_openwrt_mips.cmake \
+ --jerry-libc OFF \
+ --lto OFF
+```
+
+Currenlty the JerryScript libc does not supports the mips platform, that's why the `--jerry-libc OFF` argument
+is passed during build.
+
+### 2. Copy the binary
+
+After a successful build the `build/bin/jerry` binary file can be copied to the target device.
+On how to copy a binary file to an OpenWrt target device please see the OpenWrt manual(s).
register_js_function ("print", jerryx_handler_print);
/* Setup Global scope code */
- ret_value = jerry_parse (script, script_size, false);
+ ret_value = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (ret_value))
{
# limitations under the License.
JERRYHEAP ?= 16
-BUILD_DIR ?= build/tizenrt-artik053
-LIBTARGET_DIR ?= $(abspath $(PWD)/../TizenRT/build/output/libraries)
+BUILD_DIR ?= build
-EXT_CFLAGS += -mcpu=cortex-r4 -mfpu=vfpv3
-EXT_CFLAGS += -fno-builtin -fno-strict-aliasing
-EXT_CFLAGS += -fomit-frame-pointer
-EXT_CFLAGS += -fno-strength-reduce
-EXT_CFLAGS += -Wall -Werror -Wshadow
-EXT_CFLAGS += -Wno-error=conversion
EXT_CFLAGS += -I. -isystem ../TizenRT/os/include
.PHONY: libjerry clean
all: libjerry
libjerry:
- mkdir -p $(BUILD_DIR)
- mkdir -p $(LIBTARGET_DIR)
cmake -B$(BUILD_DIR) -H./ \
- -DCMAKE_SYSTEM_NAME=TizenRT \
- -DCMAKE_SYSTEM_PROCESSOR=armv7l \
- -DCMAKE_C_COMPILER=arm-none-eabi-gcc \
- -DCMAKE_C_COMPILER_WORKS=TRUE \
-DENABLE_LTO=OFF \
-DENABLE_ALL_IN_ONE=OFF \
-DJERRY_LIBC=OFF \
-DJERRY_CMDLINE=OFF \
-DEXTERNAL_COMPILE_FLAGS="$(EXT_CFLAGS)" \
-DMEM_HEAP_SIZE_KB=$(JERRYHEAP) \
- -DCMAKE_BUILD_TYPE=Release
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_mcu_artik053.cmake
make -C$(BUILD_DIR) jerry-core jerry-libm jerry-ext
- cp $(BUILD_DIR)/lib/libjerry-core.a $(LIBTARGET_DIR)
- cp $(BUILD_DIR)/lib/libjerry-libm.a $(LIBTARGET_DIR)
- cp $(BUILD_DIR)/lib/libjerry-ext.a $(LIBTARGET_DIR)
clean:
rm -rf $(BUILD_DIR)
```
# assuming you are in jerry-tizenrt folder
+jerryscript/tools/build.py \
+ --clean \
+ --lto=OFF \
+ --jerry-cmdline=OFF \
+ --jerry-libc=OFF \
+ --all-in-one=OFF \
+ --mem-heap=70 \
+ --profile=es2015-subset \
+ --compile-flag="--sysroot=${PWD}/TizenRT/os" \
+ --toolchain=${PWD}/jerryscript/cmake/toolchain_mcu_artik053.cmake
+```
+
+**Note**: there is a Makefile in the `targets/tizenrt-artik053/` folder that also helps to build JerryScript for TizenRT.
+
+```
+# assuming you are in jerry-tizenrt folder
$ cd jerryscript
$ make -f targets/tizenrt-artik053/Makefile.tizenrt
```
int "Jerryscript stack size"
default 16384
-config JERRYSCRIPT_HEAPSIZE
- int "Jerryscript heap size"
- default 107520
-
-config JERRYSCRIPT_ERROR_MESSAGES
- bool "Enable error messages for builtin error objects"
- default n
-
-config JERRYSCRIPT_MEM_STATS
- bool "Enable memory statistics"
- default n
-
-config JERRYSCRIPT_SHOW_OPCODES
- bool "Enable parser byte-code dumps"
- default n
-
-config JERRYSCRIPT_DEBUGGER
- bool "Jerryscript debugger"
- default n
-endif
+endif # JERRYSCRIPT
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
-# Jerryscript built-in application info
-
+# JerryScript built-in application information.
CONFIG_JERRYSCRIPT_PRIORITY ?= SCHED_PRIORITY_DEFAULT
+CONFIG_JERRYSCRIPT_PROGNAME ?= jerry$(EXEEXT)
CONFIG_JERRYSCRIPT_STACKSIZE ?= 32768
-CONFIG_JERRYSCRIPT_HEAPSIZE ?= 64000
-APPNAME = jerry
-# path to the project dir, "tizenrt-artik053" by default
-ROOT_DIR = ../../../..
PRIORITY = $(CONFIG_JERRYSCRIPT_PRIORITY)
+PROGNAME = $(CONFIG_JERRYSCRIPT_PROGNAME)
STACKSIZE = $(CONFIG_JERRYSCRIPT_STACKSIZE)
-CFLAGS += -std=c99 -DJERRY_NDEBUG '-DCONFIG_MEM_HEAP_AREA_SIZE=$(CONFIG_JERRYSCRIPT_HEAPSIZE)'
-CFLAGS += -I$(ROOT_DIR)/ $(shell find $(ROOT_DIR)/jerryscript/jerry-core -type d | sed -r -e 's/^/-I/g')
-CFLAGS += -I$(ROOT_DIR)/jerryscript/jerry-ext/include
-ifeq ($(CONFIG_JERRYSCRIPT_MEM_STATS),y)
- CFLAGS += -DJMEM_STATS
-endif
-
-ifeq ($(CONFIG_JERRYSCRIPT_SHOW_OPCODES),y)
- CFLAGS += -DPARSER_DUMP_BYTE_CODE
-endif
-
-ifeq ($(CONFIG_JERRYSCRIPT_DEBUGGER),y)
- CFLAGS += -DJERRY_DEBUGGER
-endif
+# Path to the JerryScript project. If not specified, it is supposed
+# that JerryScript is located next to the TizenRT folder.
+JERRYSCRIPT_ROOT_DIR ?= ../../../../jerryscript
+CFLAGS += -std=c99
+CFLAGS += -I$(JERRYSCRIPT_ROOT_DIR)/jerry-core/include
+CFLAGS += -I$(JERRYSCRIPT_ROOT_DIR)/jerry-ext/include
EXTRA_LIBS += libjerry-core.a libjerry-libm.a
LINKLIBS=$(EXTRA_LIBS)
-
+APPNAME = jerry
ASRCS = setjmp.S
-CSRCS =
MAINSRC = jerry_main.c
AOBJS = $(ASRCS:.S=$(OBJEXT))
INSTALL_DIR = $(BIN_DIR)
endif
-CONFIG_JERRYSCRIPT_PROGNAME ?= jerry$(EXEEXT)
-PROGNAME = $(CONFIG_JERRYSCRIPT_PROGNAME)
ROOTDEPPATH = --dep-path .
VPATH =
-all: .built
-.PHONY: context depend clean distclean
+
+all: copylibs .built
+.PHONY: copylibs context depend clean distclean
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(call ARCHIVE, $(BIN), $(OBJS))
$(Q) touch .built
+copylibs:
+ cp $(JERRYSCRIPT_ROOT_DIR)/build/lib/lib*.a $(TOPDIR)/../build/output/libraries/
+
install:
context:
#include "jerryscript.h"
#include "jerryscript-ext/handler.h"
#include "jerryscript-port.h"
-#include "jmem.h"
#include "setjmp.h"
#include <apps/shell/tash.h> // To register tash command
/**
* Read source code into buffer.
*
- * Returned value must be freed with jmem_heap_free_block if it's not NULL.
+ * Returned value must be freed if it's not NULL.
* @return NULL, if read or allocation has failed
* pointer to the allocated memory block, otherwise
*/
rewind (file);
- uint8_t *buffer = jmem_heap_alloc_block_null_on_error (script_len);
+ uint8_t *buffer = (uint8_t *) malloc (script_len);
if (buffer == NULL)
{
if (!bytes_read || bytes_read != script_len)
{
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: failed to read file: %s\n", file_name);
- jmem_heap_free_block ((void*) buffer, script_len);
+ free ((void*) buffer);
fclose (file);
return NULL;
} /* read_file */
/**
- * Check whether an error is a SyntaxError or not
- *
- * @return true - if param is SyntaxError
- * false - otherwise
- */
-static bool
-jerry_value_is_syntax_error (jerry_value_t error_value) /**< error value */
-{
- assert (jerry_is_feature_enabled (JERRY_FEATURE_ERROR_MESSAGES));
-
- if (!jerry_value_is_object (error_value))
- {
- return false;
- }
-
- jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *)"name");
- jerry_value_t error_name = jerry_get_property (error_value, prop_name);
- jerry_release_value (prop_name);
-
- if (jerry_value_has_error_flag (error_name)
- || !jerry_value_is_string (error_name))
- {
- return false;
- }
-
- jerry_size_t err_str_size = jerry_get_string_size (error_name);
- const char syntax_error_str[] = "SyntaxError";
-
- if (err_str_size != strlen (syntax_error_str) - 1)
- {
- jerry_release_value (error_name);
- return false;
- }
-
- jerry_char_t err_str_buf[err_str_size];
-
- jerry_size_t sz = jerry_string_to_char_buffer (error_name, err_str_buf, err_str_size);
- jerry_release_value (error_name);
-
- if (sz == 0)
- {
- return false;
- }
-
- if (!strncmp ((char *) err_str_buf, syntax_error_str, sizeof (syntax_error_str) - 1))
- {
- return true;
- }
-
- return false;
-} /* jerry_value_is_syntax_error */
-
-/**
* Print error value
*/
static void
{
assert (jerry_value_has_error_flag (error_value));
- jerry_value_clear_error_flag (&error_value);
+ error_value = jerry_get_value_without_error_flag (error_value);
jerry_value_t err_str_val = jerry_value_to_string (error_value);
jerry_size_t err_str_size = jerry_get_string_size (err_str_val);
jerry_char_t err_str_buf[256];
+ jerry_release_value (error_value);
+
if (err_str_size >= 256)
{
const char msg[] = "[Error message too long]";
assert (sz == err_str_size);
err_str_buf[err_str_size] = 0;
- if (jerry_is_feature_enabled (JERRY_FEATURE_ERROR_MESSAGES) && jerry_value_is_syntax_error (error_value))
+ if (jerry_is_feature_enabled (JERRY_FEATURE_ERROR_MESSAGES)
+ && jerry_get_error_type (error_value) == JERRY_ERROR_SYNTAX)
{
unsigned int err_line = 0;
unsigned int err_col = 0;
const jerry_char_t script[] = "var str = 'Hello World'; print(str + ' from JerryScript')";
size_t script_size = strlen ((const char *) script);
- ret_value = jerry_parse (script, script_size, false);
+ ret_value = jerry_parse (NULL, 0, script, script_size, JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (ret_value))
{
return JERRY_STANDALONE_EXIT_CODE_FAIL;
}
- ret_value = jerry_parse_named_resource ((jerry_char_t *) file_names[i],
- strlen (file_names[i]),
- source_p,
- source_size,
- false);
+ ret_value = jerry_parse ((jerry_char_t *) file_names[i],
+ strlen (file_names[i]),
+ source_p,
+ source_size,
+ JERRY_PARSE_NO_OPTS);
if (!jerry_value_has_error_flag (ret_value))
{
if (jerry_value_has_error_flag (ret_value))
{
print_unhandled_exception (ret_value, source_p);
- jmem_heap_free_block ((void*) source_p, source_size);
+ free ((void*) source_p);
break;
}
- jmem_heap_free_block ((void*) source_p, source_size);
+ free ((void*) source_p);
jerry_release_value (ret_value);
ret_value = jerry_create_undefined ();
} /* jerry_cmd_main */
/**
+ * Run JerryScript and print its return value.
+ */
+static int
+jerry(int argc, char *argv[])
+{
+ int ret_code = jerry_cmd_main(argc, argv);
+
+#ifdef CONFIG_DEBUG_VERBOSE
+ jerry_port_log(JERRY_LOG_LEVEL_DEBUG, "JerryScript result: %d\n", ret_code);
+#endif
+
+ return ret_code;
+} /* jerry */
+
+/**
* Aborts the program.
*/
void jerry_port_fatal (jerry_fatal_code_t code)
int jerry_main (int argc, char *argv[])
#endif
{
- tash_cmd_install("jerry", jerry_cmd_main, TASH_EXECMD_SYNC);
+ tash_cmd_install("jerry", jerry, TASH_EXECMD_SYNC);
return 0;
} /* main */
--- /dev/null
+s
+s
+s
+s
+abort new Error('Fatal error :)')
--- /dev/null
+Connecting to: localhost:5001
+Stopped at tests/debugger/do_abort.js:24
+(jerry-debugger) s
+Stopped at tests/debugger/do_abort.js:25
+(jerry-debugger) s
+Stopped at tests/debugger/do_abort.js:26
+(jerry-debugger) s
+Stopped at tests/debugger/do_abort.js:20 (in g() at line:19, col:1)
+(jerry-debugger) s
+Stopped at tests/debugger/do_abort.js:16 (in f() at line:15, col:1)
+(jerry-debugger) abort new Error('Fatal error :)')
+err: Script Error: Error: Fatal error :)
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+function f() {
+ return 32;
+}
+
+function g() {
+ f();
+}
+
+// In regular JS, it is not possible to escape from this loop
+while (true) {
+ try {
+ g();
+ } catch (e) {
+ var s = "Don't stop here";
+ }
+}
--- /dev/null
+finish
+finish
+finish
+step
+finish
+continue
--- /dev/null
+Connecting to: localhost:5001
+Stopped at tests/debugger/do_finish.js:15
+(jerry-debugger) finish
+out: finish-test
+Stopped at tests/debugger/do_finish.js:26
+(jerry-debugger) finish
+Stopped at tests/debugger/do_finish.js:18 (in foo() at line:17, col:1)
+(jerry-debugger) finish
+out: foo
+out: bar
+Stopped at tests/debugger/do_finish.js:42
+(jerry-debugger) step
+Stopped at tests/debugger/do_finish.js:29 (in dog() at line:28, col:1)
+(jerry-debugger) finish
+out: *bark*
+out: *sit*
+out: *bark*
+Stopped at tests/debugger/do_finish.js:44
+(jerry-debugger) continue
+out: END: finish-test
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+print("finish-test");
+
+function foo() {
+ print("foo");
+ return bar();
+}
+
+function bar() {
+ return "bar";
+}
+
+print(foo());
+
+function dog() {
+ bark();
+ sit();
+ bark();
+}
+
+function bark() {
+ print("*bark*");
+}
+
+function sit() {
+ print("*sit*");
+}
+
+dog();
+
+print("END: finish-test");
Documented commands (type help <topic>):
========================================
-b bt delete e help ms quit src
-backtrace c display eval list n s step
-break continue dump exception memstats next source
+abort bt display exception list next source
+b c dump f memstats quit src
+backtrace continue e finish ms s step
+break delete eval help n scroll throw
(jerry-debugger) quit
+break :1
+y
break f
y
list
-n
-n
+c
+list
c
c
Connecting to: localhost:5001
Stopped at tests/debugger/do_pending_breakpoints.js:15
+(jerry-debugger) break :1
+No breakpoint found, do you want to add a pending breakpoint? (y or [n])
+Pending breakpoint at :1
(jerry-debugger) break f
No breakpoint found, do you want to add a pending breakpoint? (y or [n])
Pending breakpoint at f()
(jerry-debugger) list
=== Pending breakpoints ===
- 1: f() (pending)
-(jerry-debugger) n
+ 1: :1 (pending)
+ 2: f() (pending)
+(jerry-debugger) c
out: pending-breakpoints
-Stopped at tests/debugger/do_pending_breakpoints.js:17
-(jerry-debugger) n
-Breakpoint 2 at <unknown>:1 (in f() at line:1, col:1)
-Stopped at tests/debugger/do_pending_breakpoints.js:19
+Breakpoint 3 at <unknown>:1
+Breakpoint 4 at <unknown>:3 (in f() at line:2, col:1)
+Stopped at breakpoint:3 <unknown>:1
+(jerry-debugger) list
+=== Active breakpoints ===
+ 3: <unknown>:1
+ 4: <unknown>:3 (in f() at line:2, col:1)
(jerry-debugger) c
-Stopped at breakpoint:2 <unknown>:1 (in f() at line:1, col:1)
+Stopped at breakpoint:4 <unknown>:3 (in f() at line:2, col:1)
(jerry-debugger) c
print("pending-breakpoints");
-eval("function f(){ return 5 }");
+eval("1;\nfunction f()\n{ return 5 }");
var bird = "colibri";
f();
--- /dev/null
+s
+s
+s
+s
+s
+throw new Error('Escape')
+throw new Error('Once upon a time there lived in a certain village a little country girl, the prettiest creature who was ever seen. Her mother was excessively fond of her; and her grandmother doted on her still more. This good woman had a little red riding hood made for her. It suited the girl so extremely well that everybody called her Little Red Riding Hood. One day her mother, having made some cakes, said to her, "Go, my dear, and see how your grandmother is doing, for I hear she has been very ill. Take her a cake, and this little pot of butter."')
+eval e.message.length
+throw new Error('Exit')
--- /dev/null
+Connecting to: localhost:5001
+Stopped at tests/debugger/do_throw.js:23
+(jerry-debugger) s
+Stopped at tests/debugger/do_throw.js:24
+(jerry-debugger) s
+Stopped at tests/debugger/do_throw.js:26
+(jerry-debugger) s
+Stopped at tests/debugger/do_throw.js:27
+(jerry-debugger) s
+Stopped at tests/debugger/do_throw.js:20 (in g() at line:19, col:1)
+(jerry-debugger) s
+Stopped at tests/debugger/do_throw.js:16 (in f() at line:15, col:1)
+(jerry-debugger) throw new Error('Escape')
+Stopped at tests/debugger/do_throw.js:31
+(jerry-debugger) throw new Error('Once upon a time there lived in a certain village a little country girl, the prettiest creature who was ever seen. Her mother was excessively fond of her; and her grandmother doted on her still more. This good woman had a little red riding hood made for her. It suited the girl so extremely well that everybody called her Little Red Riding Hood. One day her mother, having made some cakes, said to her, "Go, my dear, and see how your grandmother is doing, for I hear she has been very ill. Take her a cake, and this little pot of butter."')
+Stopped at tests/debugger/do_throw.js:34
+(jerry-debugger) eval e.message.length
+538
+(jerry-debugger) throw new Error('Exit')
+err: Script Error: Error: Exit
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+function f() {
+ return 32;
+}
+
+function g() {
+ f();
+}
+
+try {
+ try {
+
+ while (true) {
+ g();
+ }
+
+ } catch (e) {
+ var s = "Stop here";
+ }
+} catch (e) {
+ var s = "Stop here again";
+}
--- /dev/null
+c
+s
+c
+c
+c
+c
+c
+c
+c
+c
+c
--- /dev/null
+Connecting to: localhost:5001
+Stopped at tests/debugger/do_throw_adv.js:15
+(jerry-debugger) c
+Exception throw detected (to disable automatic stop type exception 0)
+Exception hint: 2
+Stopped at tests/debugger/do_throw_adv.js:18 (in f() at line:17, col:1)
+(jerry-debugger) s
+Stopped at tests/debugger/do_throw_adv.js:32
+(jerry-debugger) c
+Exception throw detected (to disable automatic stop type exception 0)
+Exception hint: 4
+Stopped at tests/debugger/do_throw_adv.js:18 (in f() at line:17, col:1)
+(jerry-debugger) c
+Exception throw detected (to disable automatic stop type exception 0)
+Exception hint: Catch again
+Stopped at tests/debugger/do_throw_adv.js:41
+(jerry-debugger) c
+Exception throw detected (to disable automatic stop type exception 0)
+Exception hint: 7
+Stopped at tests/debugger/do_throw_adv.js:18 (in f() at line:17, col:1)
+(jerry-debugger) c
+Exception throw detected (to disable automatic stop type exception 0)
+Exception hint: 10
+Stopped at tests/debugger/do_throw_adv.js:18 (in f() at line:17, col:1)
+(jerry-debugger) c
+Exception throw detected (to disable automatic stop type exception 0)
+Exception hint: Replace the other error
+Stopped at tests/debugger/do_throw_adv.js:63
+(jerry-debugger) c
+Exception throw detected (to disable automatic stop type exception 0)
+Exception hint: 13
+Stopped at tests/debugger/do_throw_adv.js:18 (in f() at line:17, col:1)
+(jerry-debugger) c
+Exception throw detected (to disable automatic stop type exception 0)
+Exception hint: Should be caught
+Stopped at tests/debugger/do_throw_adv.js:76
+(jerry-debugger) c
+Exception throw detected (to disable automatic stop type exception 0)
+Exception hint: 16
+Stopped at tests/debugger/do_throw_adv.js:18 (in f() at line:17, col:1)
+(jerry-debugger) c
+err: Script Error: 16
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+var a = 1;
+
+function f() {
+ throw ++a;
+}
+
+function g() {
+ f();
+}
+
+function h() {
+ g();
+}
+
+try {
+ h();
+} catch (e) {
+ ++a;
+}
+
+try {
+ h();
+} catch (e) {
+ ++a;
+
+ try {
+ throw "Catch again";
+ } catch (e) {
+ ++a;
+ }
+}
+
+try {
+ try {
+ h();
+ } finally {
+ ++a;
+ }
+ ++a; /* Should not happen. */
+} catch (e) {
+ ++a;
+}
+
+try {
+ try {
+ h();
+ } finally {
+ ++a;
+ throw "Replace the other error";
+ }
+} catch (e) {
+ ++a;
+}
+
+try {
+ break_try_label: try {
+ h();
+ } finally {
+ ++a;
+ break break_try_label;
+ }
+ throw "Should be caught";
+} catch (e) {
+ ++a;
+}
+
+h();
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+function check_parse_error (txt) {
+ try {
+ eval (txt)
+ assert (false)
+ } catch (e) {
+ assert (e instanceof SyntaxError)
+ }
+}
+
+function f_args (a,b,c) {
+ return arguments;
+}
+
+check_parse_error ("f_args (1 2 3)");
+check_parse_error ("f_args (1; 2; 3)");
+check_parse_error ("f_args (())");
+check_parse_error ("f_args (1, 2, 3");
+check_parse_error ("f_args 1, 2, 3)");
+check_parse_error ("f_args 1, 2, 3");
+check_parse_error ("f_args 1; 2; 3");
+check_parse_error ("f_args{1, 2, 3}");
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+function parse (txt) {
+ try {
+ eval (txt)
+ assert (false)
+ } catch (e) {
+ assert (e instanceof SyntaxError)
+ }
+}
+
+var a = 21;
+var b = 10;
+var c;
+
+parse ("c = a++b");
+parse ("c = a--b");
+
+parse ("c = a +* b");
+parse ("c = a -* b");
+parse ("c = a +/ b");
+parse ("c = a -/ b");
+parse ("c = a +% b");
+parse ("c = a -% b");
+
+parse ("a =* b");
+parse ("a =/ b");
+parse ("a =% b");
+
+parse ("c = a+");
+parse ("c = a-");
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+var a = true;
+obj = Object.getPrototypeOf(a);
+assert (obj == Boolean.prototype);
+
+a = 5;
+obj = Object.getPrototypeOf(a);
+assert (obj == Number.prototype);
+
+a = "string";
+obj = Object.getPrototypeOf(a);
+assert (obj == String.prototype);
+
+a = [1,2,3];
+obj = Object.getPrototypeOf(a);
+assert (obj == Array.prototype);
+
+try {
+ a = null;
+ obj = Object.getPrototypeOf(a);
+ assert(false);
+} catch (e) {
+ assert(e instanceof TypeError);
+}
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+var error = {};
+
+try {
+ var arrayBuffer = new ArrayBuffer(1);
+ var start = { valueOf : function ( ) { throw error; } };
+ var end = { valueOf : function ( ) { } };
+
+ arrayBuffer.slice(start, end);
+ assert(false);
+} catch (e) {
+ assert(e === error);
+}
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+var float_array = new Float32Array([1.125, 5.5, -1.25, -0.0]);
+var int_array = new Int8Array([3, 2, 1, 100, -30])
+var uint_array = new Uint8Array([3, 2, 1, 100, -30])
+var empty_array = new Uint32Array();
+
+assert((JSON.stringify(float_array)) === '{"0":1.125,"1":5.5,"2":-1.25,"3":0}');
+assert((JSON.stringify(int_array)) === '{"0":3,"1":2,"2":1,"3":100,"4":-30}');
+assert((JSON.stringify(uint_array)) === '{"0":3,"1":2,"2":1,"3":100,"4":226}');
+assert((JSON.stringify(empty_array)) === '{}');
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+JSON.parse('"' + '\\');
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+JSON.parse('"' + '\\u');
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+function parse (txt) {
+ try {
+ eval (txt)
+ assert (false)
+ } catch (e) {
+ assert (e instanceof SyntaxError)
+ }
+}
+
+var obj = {a: 1, b: 2, c:3, d:4};
+
+var forIn =
+ "for var prop in obj" +
+ " obj [prop] += 4"
+parse (forIn)
+
+var forIn =
+ "for [var prop in obj]" +
+ " obj[prop] += 4;"
+parse (forIn)
+
+var forIn =
+ "for (var prop obj)" +
+ " obj[prop] += 4;"
+parse (forIn)
+
+var forIn =
+ "foreach (var prop in obj)" +
+ " obj[prop] += 4;"
+parse (forIn)
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+function parse(txt) {
+ try {
+ eval(txt)
+ assert(false)
+ } catch (e) {
+ assert(e instanceof SyntaxError)
+ }
+}
+
+parse("for (;;;) print('hello')")
+parse("for (,,) print('hello')")
+parse("for (i = 0; i < 10; i++; ) print('i: ' + i)")
+parse("for (i = 0; i < 10; i++)")
+parse("for i = 0; i < 10; i++ {}")
+parse("for (i = 0;; i < 10; i++) {}")
+parse("for (i = 0; j = 1; i < 10; i++) print('i: '+ i + ' j: ' + j)")
+parse("for (i = 0 j = 5;i<10 || j<10; i++, j++) {}")
+parse("for (i = 0, j = 5; i < 10 || j < 10; i++ j++) {}")
+parse("for (i = 0, j = 5; i < 10 j < 10; i++, j++) {}")
+
+var doubleFor =
+"for (i = 0; i < 5; i++) { "+
+" for (j = 0; j < 5; j++) { print('i: ' + i + ' j: ' + j) }";
+parse(doubleFor)
+
+var doubleFor2 =
+"for (i = 0; i < 5; i++) { "+
+" for (j = 0; j < 5; j++) { print('i: ' + i + ' j: ' + j)";
+parse(doubleFor2)
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+function test_parse_error (txt) {
+ try {
+ eval (txt)
+ assert (false)
+ } catch (e){
+ assert (e instanceof SyntaxError)
+ }
+}
+
+var if1=
+"if (false)() print ('t')" +
+"else print ('f')"
+test_parse_error (if1)
+
+test_parse_error ("if (true)() { print ('t') }")
+test_parse_error ("if {} (true) print ('t')")
+test_parse_error ("if (true false) print ('t')")
+test_parse_error ("if (true && || false) print ('t')")
+test_parse_error ("if (&& true) print ('t')")
+test_parse_error ("if (true ||) print ('t')")
+test_parse_error ("if (true && {false || true}) print ('t')")
+
+var elseif1 =
+"if (false) print ('if statement') " +
+"elseif (false) print ('else if statement') " +
+"else print ('else statement') "
+test_parse_error (elseif1);
+
+var elseif2 =
+"if (false) print ('if statement') " +
+"elif (false) print ('else if statement') " +
+"else print ('else statement') "
+test_parse_error (elseif2)
+
+var elseif3 =
+"if (false) print ('if statement') " +
+"else (false) print ('else if statement') " +
+"else print ('else statement') "
+test_parse_error (elseif3)
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Testcase from bugreport (issue: #2178).
+bad = "'detailForm','detailForm:j_id166', []);\" ><img alt=\"Export to XLS format\" />\n</a>"
+good = "'detailForm','detailForm:j_id166');\" ><img alt=\"Export to XLS format\" />\n</a>"
+r = /'(detailForm:j_id\d+)'[^>]+>[^>]+Export to XLS format/;
+assert(!!good.match(r) && !!bad.match(r));
+
+// Similar testcases.
+var regexPatternCharacters = ['^', '$', '\\', '.', '*', '+', '?', '(', ')', '[', ']', '{', '}'];
+regexPatternCharacters.forEach(function (str) {
+ assert(str.match(/[^>]/) == str);
+})
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+function test(len)
+{
+ function applyTest() { }
+ try {
+ applyTest.apply(null, { length : len });
+ assert(false);
+ } catch (e) {
+ assert(e instanceof RangeError);
+ }
+}
+
+test(65536);
+test(0x40000001);
+test(0xffffffff);
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+var id_0 = Object.prototype.toString ;
+Object.prototype.toString = function ( ) { return "SHIFTED" } ;
+RegExp ( '#1: __str = new String({}); typeof __str === "object". Actual: typeof __str ===');
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+[
+ // This input caused a buffer overrun,
+ // see https://github.com/jerryscript-project/jerryscript/issues/2200
+ '"\\ubad',
+ // Test similar malformations as well:
+ '"\\ubad"',
+ '"\\u',
+].forEach(function(badJson) {
+ try {
+ JSON.parse(badJson);
+ } catch (e) {
+ }
+});
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+try {
+ new RegExp("\{{91406,456}");
+ assert(false);
+} catch(e) {
+ assert(e instanceof SyntaxError)
+}
+
+try {
+ new RegExp("\{91406,456}");
+ assert(false);
+} catch(e) {
+ assert(e instanceof SyntaxError)
+}
+
+try {
+ new RegExp("\({91406,456}");
+ assert(false);
+} catch(e) {
+ assert(e instanceof SyntaxError)
+}
--- /dev/null
+// Copyright JS Foundation and other contributors, http://js.foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+Number.isInteger = Number.isInteger || function (value) {
+ return typeof value === 'number' &&
+ isFinite (value) &&
+ Math.floor (value) === value;
+};
+
+var now = Date.now ();
+
+assert (Number.isInteger (now));
+
+var date = new Date(now); // Should not throw an error
--- /dev/null
+/* Copyright JS Foundation and other contributors, http://js.foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "config.h"
+#include "jerryscript.h"
+
+#include "test-common.h"
+
+static jerry_value_t
+callback_func (const jerry_value_t function_obj,
+ const jerry_value_t this_val,
+ const jerry_value_t args_p[],
+ const jerry_length_t args_count)
+{
+ JERRY_UNUSED (function_obj);
+ JERRY_UNUSED (this_val);
+ JERRY_UNUSED (args_p);
+ JERRY_UNUSED (args_count);
+
+ jerry_value_t value = jerry_create_string ((jerry_char_t *) "Abort run!");
+ jerry_value_set_abort_flag (&value);
+ return value;
+} /* callback_func */
+
+int
+main (void)
+{
+ TEST_INIT ();
+
+ jerry_init (JERRY_INIT_EMPTY);
+
+ jerry_value_t global = jerry_get_global_object ();
+ jerry_value_t callback_name = jerry_create_string ((jerry_char_t *) "callback");
+ jerry_value_t func = jerry_create_external_function (callback_func);
+ jerry_value_t res = jerry_set_property (global, callback_name, func);
+ TEST_ASSERT (!jerry_value_has_error_flag (res));
+
+ jerry_release_value (res);
+ jerry_release_value (func);
+ jerry_release_value (callback_name);
+ jerry_release_value (global);
+
+ const char *inf_loop_code_src_p = ("while(true) {\n"
+ " with ({}) {\n"
+ " try {\n"
+ " callback();\n"
+ " } catch (e) {\n"
+ " } finally {\n"
+ " }\n"
+ " }\n"
+ "}");
+
+ jerry_value_t parsed_code_val = jerry_parse (NULL,
+ 0,
+ (jerry_char_t *) inf_loop_code_src_p,
+ strlen (inf_loop_code_src_p),
+ JERRY_PARSE_NO_OPTS);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val));
+ res = jerry_run (parsed_code_val);
+
+ TEST_ASSERT (jerry_value_has_abort_flag (res));
+
+ jerry_release_value (res);
+ jerry_release_value (parsed_code_val);
+
+ inf_loop_code_src_p = ("function f() {"
+ " while(true) {\n"
+ " with ({}) {\n"
+ " try {\n"
+ " callback();\n"
+ " } catch (e) {\n"
+ " } finally {\n"
+ " }\n"
+ " }\n"
+ " }"
+ "}\n"
+ "function g() {\n"
+ " for (a in { x:5 })\n"
+ " f();\n"
+ "}\n"
+ "\n"
+ "with({})\n"
+ " f();\n");
+
+ parsed_code_val = jerry_parse (NULL,
+ 0,
+ (jerry_char_t *) inf_loop_code_src_p,
+ strlen (inf_loop_code_src_p),
+ JERRY_PARSE_NO_OPTS);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val));
+ res = jerry_run (parsed_code_val);
+
+ TEST_ASSERT (jerry_value_has_abort_flag (res));
+
+ jerry_release_value (res);
+ jerry_release_value (parsed_code_val);
+
+ /* Test flag overwrites. */
+ jerry_value_t value = jerry_create_string ((jerry_char_t *) "Error description");
+ TEST_ASSERT (!jerry_value_has_abort_flag (value));
+ TEST_ASSERT (!jerry_value_has_error_flag (value));
+
+ jerry_value_set_abort_flag (&value);
+ TEST_ASSERT (jerry_value_has_abort_flag (value));
+ TEST_ASSERT (jerry_value_has_error_flag (value));
+
+ jerry_value_set_error_flag (&value);
+ TEST_ASSERT (!jerry_value_has_abort_flag (value));
+ TEST_ASSERT (jerry_value_has_error_flag (value));
+
+ jerry_value_set_abort_flag (&value);
+ TEST_ASSERT (jerry_value_has_abort_flag (value));
+ TEST_ASSERT (jerry_value_has_error_flag (value));
+
+ jerry_release_value (value);
+
+ jerry_cleanup ();
+ return 0;
+} /* main */
--- /dev/null
+/* Copyright JS Foundation and other contributors, http://js.foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "jerryscript.h"
+#include "test-common.h"
+
+int
+main (void)
+{
+ TEST_INIT ();
+
+ jerry_init (JERRY_INIT_EMPTY);
+
+ jerry_error_t errors[] =
+ {
+ JERRY_ERROR_COMMON,
+ JERRY_ERROR_EVAL,
+ JERRY_ERROR_RANGE,
+ JERRY_ERROR_REFERENCE,
+ JERRY_ERROR_SYNTAX,
+ JERRY_ERROR_TYPE,
+ JERRY_ERROR_URI
+ };
+
+ for (size_t idx = 0; idx < sizeof (errors) / sizeof (errors[0]); idx++)
+ {
+ jerry_value_t error_obj = jerry_create_error (errors[idx], (const jerry_char_t *)"test");
+ TEST_ASSERT (jerry_value_has_error_flag (error_obj));
+ TEST_ASSERT (jerry_get_error_type (error_obj) == errors[idx]);
+
+ jerry_value_clear_error_flag (&error_obj);
+
+ TEST_ASSERT (jerry_get_error_type (error_obj) == errors[idx]);
+
+ jerry_release_value (error_obj);
+ }
+
+ jerry_value_t test_values[] =
+ {
+ jerry_create_number (11),
+ jerry_create_string ((const jerry_char_t *) "message"),
+ jerry_create_boolean (true),
+ jerry_create_object (),
+ };
+
+ for (size_t idx = 0; idx < sizeof (test_values) / sizeof (test_values[0]); idx++)
+ {
+ jerry_error_t error_type = jerry_get_error_type (test_values[idx]);
+ TEST_ASSERT (error_type == JERRY_ERROR_NONE);
+ jerry_release_value (test_values[idx]);
+ }
+
+ jerry_cleanup ();
+} /* main */
--- /dev/null
+/* Copyright JS Foundation and other contributors, http://js.foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "jerryscript.h"
+#include "jerryscript-port.h"
+#include "jerryscript-port-default.h"
+#include "test-common.h"
+
+typedef struct
+{
+ jerry_type_t type_info;
+ jerry_value_t value;
+} test_entry_t;
+
+#define ENTRY(TYPE, VALUE) { TYPE, VALUE }
+
+static jerry_value_t
+test_ext_function (const jerry_value_t function_obj, /**< function object */
+ const jerry_value_t this_val, /**< function this value */
+ const jerry_value_t args_p[], /**< array of arguments */
+ const jerry_length_t args_cnt) /**< number of arguments */
+{
+ (void) function_obj;
+ (void) this_val;
+ (void) args_p;
+ (void) args_cnt;
+ return jerry_create_boolean (true);
+} /* test_ext_function */
+
+int
+main (void)
+{
+ TEST_INIT ();
+
+ jerry_init (JERRY_INIT_EMPTY);
+
+ jerry_char_t test_eval_function[] = "function demo(a) { return a + 1; }; demo";
+
+ test_entry_t entries[] =
+ {
+ ENTRY (JERRY_TYPE_NUMBER, jerry_create_number (-33.0)),
+ ENTRY (JERRY_TYPE_NUMBER, jerry_create_number (3)),
+ ENTRY (JERRY_TYPE_NUMBER, jerry_create_number_nan ()),
+ ENTRY (JERRY_TYPE_NUMBER, jerry_create_number_infinity (false)),
+ ENTRY (JERRY_TYPE_NUMBER, jerry_create_number_infinity (true)),
+
+ ENTRY (JERRY_TYPE_BOOLEAN, jerry_create_boolean (true)),
+ ENTRY (JERRY_TYPE_BOOLEAN, jerry_create_boolean (false)),
+
+ ENTRY (JERRY_TYPE_UNDEFINED, jerry_create_undefined ()),
+
+ ENTRY (JERRY_TYPE_OBJECT, jerry_create_object ()),
+ ENTRY (JERRY_TYPE_OBJECT, jerry_create_array (10)),
+ ENTRY (JERRY_TYPE_OBJECT, jerry_create_error (JERRY_ERROR_TYPE, (const jerry_char_t *) "error")),
+
+ ENTRY (JERRY_TYPE_NULL, jerry_create_null ()),
+
+ ENTRY (JERRY_TYPE_FUNCTION, jerry_eval (test_eval_function, strlen ((char *) test_eval_function), false)),
+ ENTRY (JERRY_TYPE_FUNCTION, jerry_create_external_function (test_ext_function)),
+
+ ENTRY (JERRY_TYPE_STRING, jerry_create_string (test_eval_function)),
+ ENTRY (JERRY_TYPE_STRING, jerry_create_string ((jerry_char_t *) "")),
+ };
+
+ for (size_t idx = 0; idx < sizeof (entries) / sizeof (entries[0]); idx++)
+ {
+ jerry_type_t type_info = jerry_value_get_type (entries[idx].value);
+
+ TEST_ASSERT (type_info != JERRY_TYPE_NONE);
+ TEST_ASSERT (type_info == entries[idx].type_info);
+
+ jerry_release_value (entries[idx].value);
+ }
+
+ jerry_cleanup ();
+
+ return 0;
+} /* main */
return jerry_create_boolean (true);
} /* handler_construct */
-static jerry_value_t
-vm_exec_stop_callback (void *user_p)
-{
- int *int_p = (int *) user_p;
-
- if (*int_p > 0)
- {
- (*int_p)--;
-
- return jerry_create_undefined ();
- }
-
- return jerry_create_string ((const jerry_char_t *) "Abort script");
-} /* vm_exec_stop_callback */
-
/**
* Extended Magic Strings
*/
jerry_init (JERRY_INIT_EMPTY);
- parsed_code_val = jerry_parse ((jerry_char_t *) test_source, strlen (test_source), false);
+ parsed_code_val = jerry_parse (NULL,
+ 0,
+ (jerry_char_t *) test_source,
+ strlen (test_source),
+ JERRY_PARSE_NO_OPTS);
TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val));
res = jerry_run (parsed_code_val);
strlen (func_arg_list),
(const jerry_char_t *) func_src,
strlen (func_src),
- false);
+ JERRY_PARSE_NO_OPTS);
TEST_ASSERT (!jerry_value_has_error_flag (func_val));
jerry_init (JERRY_INIT_SHOW_OPCODES);
const char *parser_err_src_p = "b = 'hello';\nvar a = (;";
- parsed_code_val = jerry_parse ((jerry_char_t *) parser_err_src_p,
+ parsed_code_val = jerry_parse (NULL,
+ 0,
+ (jerry_char_t *) parser_err_src_p,
strlen (parser_err_src_p),
- false);
+ JERRY_PARSE_NO_OPTS);
TEST_ASSERT (jerry_value_has_error_flag (parsed_code_val));
jerry_value_clear_error_flag (&parsed_code_val);
jerry_value_t err_str_val = jerry_value_to_string (parsed_code_val);
jerry_cleanup ();
}
- /* Test stopping an infinite loop. */
- if (jerry_is_feature_enabled (JERRY_FEATURE_VM_EXEC_STOP))
- {
- jerry_init (JERRY_INIT_EMPTY);
-
- int countdown = 6;
- jerry_set_vm_exec_stop_callback (vm_exec_stop_callback, &countdown, 16);
-
- const char *inf_loop_code_src_p = "while(true) {}";
- parsed_code_val = jerry_parse ((jerry_char_t *) inf_loop_code_src_p, strlen (inf_loop_code_src_p), false);
- TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val));
- res = jerry_run (parsed_code_val);
- TEST_ASSERT (countdown == 0);
-
- TEST_ASSERT (jerry_value_has_error_flag (res));
-
- jerry_release_value (res);
- jerry_release_value (parsed_code_val);
-
- /* A more complex example. Although the callback error is captured
- * by the catch block, it is automatically thrown again. */
-
- /* We keep the callback function, only the countdown is reset. */
- countdown = 6;
-
- inf_loop_code_src_p = ("function f() { while (true) ; }\n"
- "try { f(); } catch(e) {}");
-
- parsed_code_val = jerry_parse ((jerry_char_t *) inf_loop_code_src_p, strlen (inf_loop_code_src_p), false);
-
- TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val));
- res = jerry_run (parsed_code_val);
- TEST_ASSERT (countdown == 0);
-
- /* The result must have an error flag which proves that
- * the error is thrown again inside the catch block. */
- TEST_ASSERT (jerry_value_has_error_flag (res));
-
- jerry_release_value (res);
- jerry_release_value (parsed_code_val);
-
- jerry_cleanup ();
- }
-
/* External Magic String */
jerry_init (JERRY_INIT_SHOW_OPCODES);
magic_string_lengths);
const char *ms_code_src_p = "var global = {}; var console = [1]; var process = 1;";
- parsed_code_val = jerry_parse ((jerry_char_t *) ms_code_src_p, strlen (ms_code_src_p), false);
+ parsed_code_val = jerry_parse (NULL,
+ 0,
+ (jerry_char_t *) ms_code_src_p,
+ strlen (ms_code_src_p),
+ JERRY_PARSE_NO_OPTS);
TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val));
res = jerry_run (parsed_code_val);
jerry_release_value (args[0]);
+ const char *test_magic_str_access_src_p = "'console'.charAt(6) == 'e'";
+ res = jerry_eval ((const jerry_char_t *) test_magic_str_access_src_p,
+ strlen (test_magic_str_access_src_p),
+ false);
+ TEST_ASSERT (jerry_value_is_boolean (res));
+ TEST_ASSERT (jerry_get_boolean_value (res) == true);
+
+ jerry_release_value (res);
+
cesu8_length = jerry_get_string_length (args[1]);
cesu8_sz = jerry_get_string_size (args[1]);
jerry_release_value (args[1]);
+ {
+ /*json parser check*/
+ char data_check[]="John";
+ jerry_value_t key = jerry_create_string ((const jerry_char_t *) "name");
+ const char *data = "{\"name\": \"John\", \"age\": 5}";
+ jerry_size_t str_length = (jerry_size_t) strlen (data);
+ jerry_value_t parsed_json = jerry_json_parse ((jerry_char_t *) data, str_length);
+ jerry_value_t has_prop_js = jerry_has_property (parsed_json, key);
+ TEST_ASSERT (jerry_get_boolean_value (has_prop_js));
+ jerry_release_value (has_prop_js);
+ jerry_value_t parsed_data = jerry_get_property (parsed_json, key);
+ TEST_ASSERT (jerry_value_is_string (parsed_data)== true);
+ jerry_size_t buff_size = (jerry_size_t) jerry_get_string_length (parsed_data);
+ char buff[jerry_get_string_length (parsed_data)];
+ jerry_char_t *buff_p = (jerry_char_t *) buff;
+ jerry_string_to_char_buffer (parsed_data, buff_p, buff_size);
+ buff[buff_size] = '\0';
+ TEST_ASSERT (strcmp ((const char *) data_check, (const char *) buff) == false);
+ jerry_release_value (parsed_json);
+ jerry_release_value (key);
+ jerry_release_value (parsed_data);
+ }
+
+ /*json stringify test*/
+ {
+ jerry_value_t obj = jerry_create_object ();
+ char check_value[] = "{\"name\":\"John\"}";
+ jerry_value_t key = jerry_create_string ((const jerry_char_t *) "name");
+ jerry_value_t value = jerry_create_string ((const jerry_char_t *) "John");
+ jerry_set_property (obj, key, value);
+ jerry_value_t stringified = jerry_json_stringfy (obj);
+ TEST_ASSERT (jerry_value_is_string (stringified));
+ char buff[jerry_get_string_length (stringified)];
+ jerry_string_to_char_buffer (stringified, (jerry_char_t *) buff,
+ (jerry_size_t) jerry_get_string_length (stringified));
+ buff[jerry_get_string_length (stringified)] = '\0';
+ TEST_ASSERT (strcmp ((const char *) check_value, (const char *) buff) == 0);
+ jerry_release_value (stringified);
+ jerry_release_value (obj);
+ jerry_release_value (key);
+ jerry_release_value (value);
+ }
jerry_cleanup ();
return 0;
--- /dev/null
+/* Copyright JS Foundation and other contributors, http://js.foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "jerryscript.h"
+#include "jerryscript-port.h"
+#include "jerryscript-port-default.h"
+#include "test-common.h"
+
+/**
+ * Register a JavaScript value in the global object.
+ */
+static void
+register_js_value (const char *name_p, /**< name of the function */
+ jerry_value_t value) /**< JS value */
+{
+ jerry_value_t global_obj_val = jerry_get_global_object ();
+
+ jerry_value_t name_val = jerry_create_string ((const jerry_char_t *) name_p);
+ jerry_value_t result_val = jerry_set_property (global_obj_val, name_val, value);
+ TEST_ASSERT (jerry_value_is_boolean (result_val));
+
+ jerry_release_value (name_val);
+ jerry_release_value (global_obj_val);
+
+ jerry_release_value (result_val);
+} /* register_js_value */
+
+static jerry_value_t
+assert_handler (const jerry_value_t func_obj_val, /**< function object */
+ const jerry_value_t this_val, /**< this arg */
+ const jerry_value_t args_p[], /**< function arguments */
+ const jerry_length_t args_cnt) /**< number of function arguments */
+{
+ JERRY_UNUSED (func_obj_val);
+ JERRY_UNUSED (this_val);
+
+ if (args_cnt > 0
+ && jerry_value_is_boolean (args_p[0])
+ && jerry_get_boolean_value (args_p[0]))
+ {
+ return jerry_create_boolean (true);
+ }
+
+ if (args_cnt > 1
+ && jerry_value_is_string (args_p[1]))
+ {
+ jerry_length_t utf8_sz = jerry_get_string_size (args_p[1]);
+ char string_from_utf8[utf8_sz];
+ string_from_utf8[utf8_sz] = 0;
+
+ jerry_string_to_char_buffer (args_p[1], (jerry_char_t *) string_from_utf8, utf8_sz);
+
+ printf ("JS assert: %s\n", string_from_utf8);
+ }
+
+ TEST_ASSERT (false);
+} /* assert_handler */
+
+/**
+ * Checks whether global object has arraybuffer.
+ */
+static bool
+arraybuffer_is_available (void)
+{
+ jerry_value_t global_obj_val = jerry_get_global_object ();
+ jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "ArrayBuffer");
+
+ jerry_value_t prop_value = jerry_has_property (global_obj_val, prop_name);
+ bool has_prop = jerry_get_boolean_value (prop_value);
+
+ jerry_release_value (global_obj_val);
+ jerry_release_value (prop_name);
+ jerry_release_value (prop_value);
+
+ return has_prop;
+} /* arraybuffer_is_available */
+
+/**
+ * Test ArrayBuffer 'read' api call with various offset values.
+ */
+static void
+test_read_with_offset (uint8_t offset) /**< offset for buffer read. */
+{
+ const char *eval_arraybuffer_src_p = ("var array = new Uint8Array (15);"
+ "for (var i = 0; i < array.length; i++) { array[i] = i * 2; };"
+ "array.buffer");
+ jerry_value_t arraybuffer = jerry_eval ((jerry_char_t *) eval_arraybuffer_src_p,
+ strlen (eval_arraybuffer_src_p),
+ true);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (arraybuffer));
+ TEST_ASSERT (jerry_value_is_arraybuffer (arraybuffer));
+ TEST_ASSERT (jerry_get_arraybuffer_byte_length (arraybuffer) == 15);
+
+ uint8_t buffer[20];
+ memset (buffer, 120, 20);
+
+ /* Try to copy more than the target buffer size. */
+ jerry_length_t copied = jerry_arraybuffer_read (arraybuffer, offset, buffer, 20);
+ TEST_ASSERT (copied == (jerry_length_t)(15 - offset));
+
+ for (uint8_t i = 0; i < copied; i++)
+ {
+ TEST_ASSERT (buffer[i] == (i + offset) * 2);
+ }
+ TEST_ASSERT (buffer[15 - offset] == 120);
+
+ jerry_release_value (arraybuffer);
+} /* test_read_with_offset */
+
+/**
+ * Test ArrayBuffer 'write' api call with various offset values.
+ */
+static void test_write_with_offset (uint8_t offset) /**< offset for buffer write. */
+{
+ {
+ jerry_value_t offset_val = jerry_create_number (offset);
+ register_js_value ("offset", offset_val);
+ jerry_release_value (offset_val);
+ }
+
+ const char *eval_arraybuffer_src_p = "var array = new Uint8Array (15); array.buffer";
+ jerry_value_t arraybuffer = jerry_eval ((jerry_char_t *) eval_arraybuffer_src_p,
+ strlen (eval_arraybuffer_src_p),
+ true);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (arraybuffer));
+ TEST_ASSERT (jerry_value_is_arraybuffer (arraybuffer));
+ TEST_ASSERT (jerry_get_arraybuffer_byte_length (arraybuffer) == 15);
+
+ uint8_t buffer[20];
+
+ for (uint8_t i = 0; i < 20; i++)
+ {
+ buffer[i] = (uint8_t) (i * 3);
+ }
+
+ /* Intentionally copy more than the allowed space. */
+ jerry_length_t copied = jerry_arraybuffer_write (arraybuffer, offset, buffer, 20);
+ TEST_ASSERT (copied == (jerry_length_t)(15 - offset));
+
+ const char *eval_test_arraybuffer_p = (
+ "for (var i = 0; i < offset; i++)"
+ "{"
+ " assert (array[i] == 0, 'offset check for: ' + i + ' was: ' + array[i] + ' should be: 0');"
+ "};"
+ "for (var i = offset; i < array.length; i++)"
+ "{"
+ " var expected = (i - offset) * 3;"
+ " assert (array[i] == expected, 'calc check for: ' + i + ' was: ' + array[i] + ' should be: ' + expected);"
+ "};"
+ "assert (array[15] === undefined, 'ArrayBuffer out of bounds index should return undefined value');");
+ jerry_value_t res = jerry_eval ((jerry_char_t *) eval_test_arraybuffer_p,
+ strlen (eval_test_arraybuffer_p),
+ true);
+ jerry_release_value (res);
+ jerry_release_value (arraybuffer);
+} /* test_write_with_offset */
+
+static bool callback_called = false;
+
+static void test_free_cb (void *buffer) /**< buffer to free (if needed) */
+{
+ (void) buffer;
+ callback_called = true;
+} /* test_free_cb */
+
+int
+main (void)
+{
+ jerry_init (JERRY_INIT_EMPTY);
+
+ if (!arraybuffer_is_available ())
+ {
+ jerry_port_log (JERRY_LOG_LEVEL_ERROR, "ArrayBuffer is disabled!\n");
+ jerry_cleanup ();
+ return 0;
+ }
+
+ jerry_value_t function_val = jerry_create_external_function (assert_handler);
+ register_js_value ("assert", function_val);
+ jerry_release_value (function_val);
+
+ /* Test array buffer queries */
+ {
+ const char *eval_arraybuffer_src_p = "new ArrayBuffer (10)";
+ jerry_value_t eval_arraybuffer = jerry_eval ((jerry_char_t *) eval_arraybuffer_src_p,
+ strlen (eval_arraybuffer_src_p),
+ true);
+ TEST_ASSERT (!jerry_value_has_error_flag (eval_arraybuffer));
+ TEST_ASSERT (jerry_value_is_arraybuffer (eval_arraybuffer));
+ TEST_ASSERT (jerry_get_arraybuffer_byte_length (eval_arraybuffer) == 10);
+ jerry_release_value (eval_arraybuffer);
+ }
+
+ /* Test array buffer creation */
+ {
+ const uint32_t length = 15;
+ jerry_value_t arraybuffer = jerry_create_arraybuffer (length);
+ TEST_ASSERT (!jerry_value_has_error_flag (arraybuffer));
+ TEST_ASSERT (jerry_value_is_arraybuffer (arraybuffer));
+ TEST_ASSERT (jerry_get_arraybuffer_byte_length (arraybuffer) == length);
+ jerry_release_value (arraybuffer);
+ }
+
+ /* Test array buffer read operations */
+ for (uint8_t i = 0; i < 15; i++)
+ {
+ test_read_with_offset (i);
+ }
+
+ /* Test zero length ArrayBuffer read */
+ {
+ const uint32_t length = 0;
+ jerry_value_t arraybuffer = jerry_create_arraybuffer (length);
+ TEST_ASSERT (!jerry_value_has_error_flag (arraybuffer));
+ TEST_ASSERT (jerry_value_is_arraybuffer (arraybuffer));
+ TEST_ASSERT (jerry_get_arraybuffer_byte_length (arraybuffer) == length);
+
+ uint8_t data[20];
+ memset (data, 11, 20);
+
+ jerry_length_t bytes_read = jerry_arraybuffer_read (arraybuffer, 0, data, 20);
+ TEST_ASSERT (bytes_read == 0);
+
+ for (int i = 0; i < 20; i++)
+ {
+ TEST_ASSERT (data[i] == 11);
+ }
+
+ jerry_release_value (arraybuffer);
+ }
+
+ /* Test array buffer write operations */
+ for (uint8_t i = 0; i < 15; i++)
+ {
+ test_write_with_offset (i);
+ }
+
+ /* Test zero length ArrayBuffer write */
+ {
+ const uint32_t length = 0;
+ jerry_value_t arraybuffer = jerry_create_arraybuffer (length);
+ TEST_ASSERT (!jerry_value_has_error_flag (arraybuffer));
+ TEST_ASSERT (jerry_value_is_arraybuffer (arraybuffer));
+ TEST_ASSERT (jerry_get_arraybuffer_byte_length (arraybuffer) == length);
+
+ uint8_t data[20];
+ memset (data, 11, 20);
+
+ jerry_length_t bytes_written = jerry_arraybuffer_write (arraybuffer, 0, data, 20);
+ TEST_ASSERT (bytes_written == 0);
+
+ jerry_release_value (arraybuffer);
+ }
+
+ /* Test ArrayBuffer with buffer allocated externally */
+ {
+ const uint32_t buffer_size = 15;
+ const uint8_t base_value = 51;
+
+ uint8_t buffer_p[buffer_size];
+ memset (buffer_p, base_value, buffer_size);
+
+ jerry_value_t arrayb = jerry_create_arraybuffer_external (buffer_size, buffer_p, test_free_cb);
+ uint8_t new_value = 123;
+ jerry_length_t copied = jerry_arraybuffer_write (arrayb, 0, &new_value, 1);
+ TEST_ASSERT (copied == 1);
+ TEST_ASSERT (buffer_p[0] == new_value);
+ TEST_ASSERT (jerry_get_arraybuffer_byte_length (arrayb) == buffer_size);
+
+ for (uint32_t i = 1; i < buffer_size; i++)
+ {
+ TEST_ASSERT (buffer_p[i] == base_value);
+ }
+
+ uint8_t test_buffer[buffer_size];
+ jerry_length_t read = jerry_arraybuffer_read (arrayb, 0, test_buffer, buffer_size);
+ TEST_ASSERT (read == buffer_size);
+ TEST_ASSERT (test_buffer[0] == new_value);
+
+ for (uint32_t i = 1; i < buffer_size; i++)
+ {
+ TEST_ASSERT (test_buffer[i] == base_value);
+ }
+
+ TEST_ASSERT (jerry_value_is_arraybuffer (arrayb));
+ jerry_release_value (arrayb);
+ }
+
+ /* Test ArrayBuffer external memory map/unmap */
+ {
+ const uint32_t buffer_size = 20;
+ uint8_t buffer_p[buffer_size];
+ {
+ jerry_value_t input_buffer = jerry_create_arraybuffer_external (buffer_size, buffer_p, NULL);
+ register_js_value ("input_buffer", input_buffer);
+ jerry_release_value (input_buffer);
+ }
+
+ const char *eval_arraybuffer_src_p = (
+ "var array = new Uint8Array(input_buffer);"
+ "for (var i = 0; i < array.length; i++)"
+ "{"
+ " array[i] = i * 2;"
+ "};"
+ "array.buffer");
+ jerry_value_t buffer = jerry_eval ((jerry_char_t *) eval_arraybuffer_src_p,
+ strlen (eval_arraybuffer_src_p),
+ true);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (buffer));
+ TEST_ASSERT (jerry_value_is_arraybuffer (buffer));
+ TEST_ASSERT (jerry_get_arraybuffer_byte_length (buffer) == 20);
+
+ uint8_t *const data = jerry_get_arraybuffer_pointer (buffer);
+
+ /* test memory read */
+ for (int i = 0; i < 20; i++)
+ {
+ TEST_ASSERT (data[i] == (uint8_t) (i * 2));
+ }
+
+ /* "upload" new data */
+ double sum = 0;
+ for (int i = 0; i < 20; i++)
+ {
+ data[i] = (uint8_t)(i * 3);
+ sum += data[i];
+ }
+
+ jerry_release_value (buffer);
+
+ const char *eval_test_arraybuffer_p = (
+ "var sum = 0;"
+ "for (var i = 0; i < array.length; i++)"
+ "{"
+ " var expected = i * 3;"
+ " assert(array[i] == expected, 'Array at index ' + i + ' was: ' + array[i] + ' should be: ' + expected);"
+ " sum += array[i]"
+ "};"
+ "sum");
+ jerry_value_t res = jerry_eval ((jerry_char_t *) eval_test_arraybuffer_p,
+ strlen (eval_test_arraybuffer_p),
+ true);
+ TEST_ASSERT (jerry_value_is_number (res));
+ TEST_ASSERT (jerry_get_number_value (res) == sum);
+ jerry_release_value (res);
+
+ jerry_release_value (buffer);
+ }
+
+ /* Test ArrayBuffer external with invalid arguments */
+ {
+ jerry_value_t input_buffer = jerry_create_arraybuffer_external (0, NULL, NULL);
+ TEST_ASSERT (jerry_value_has_error_flag (input_buffer));
+ TEST_ASSERT (jerry_get_error_type (input_buffer) == JERRY_ERROR_RANGE);
+ jerry_release_value (input_buffer);
+ }
+
+ jerry_cleanup ();
+
+ TEST_ASSERT (callback_called == true);
+} /* main */
--- /dev/null
+/* Copyright JS Foundation and other contributors, http://js.foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "config.h"
+#include "jerryscript.h"
+#include "test-common.h"
+
+static jerry_value_t
+backtrace_handler (const jerry_value_t function_obj, /**< function object */
+ const jerry_value_t this_val, /**< this value */
+ const jerry_value_t args_p[], /**< argument list */
+ const jerry_length_t args_count) /**< argument count */
+{
+ JERRY_UNUSED (function_obj);
+ JERRY_UNUSED (this_val);
+
+ uint32_t max_depth = 0;
+
+ if (args_count > 0 && jerry_value_is_number (args_p[0]))
+ {
+ max_depth = (uint32_t) jerry_get_number_value (args_p[0]);
+ }
+
+ return jerry_get_backtrace (max_depth);
+} /* backtrace_handler */
+
+static jerry_value_t
+run (const char *resource_name_p, /**< resource name */
+ const char *source_p) /**< source code */
+{
+ jerry_value_t code = jerry_parse ((const jerry_char_t *) resource_name_p,
+ strlen (resource_name_p),
+ (const jerry_char_t *) source_p,
+ strlen (source_p),
+ JERRY_PARSE_NO_OPTS);
+ TEST_ASSERT (!jerry_value_has_error_flag (code));
+
+ jerry_value_t result = jerry_run (code);
+ jerry_release_value (code);
+
+ return result;
+} /* run */
+
+static void
+compare (jerry_value_t array, /**< array */
+ uint32_t index, /**< item index */
+ const char *str) /**< string to compare */
+{
+ jerry_char_t buf[64];
+
+ size_t len = strlen (str);
+
+ TEST_ASSERT (len < sizeof (buf));
+
+ jerry_value_t value = jerry_get_property_by_index (array, index);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (value)
+ && jerry_value_is_string (value));
+
+ TEST_ASSERT (jerry_get_string_size (value) == len);
+
+ jerry_size_t str_len = jerry_string_to_char_buffer (value, buf, (jerry_size_t) len);
+ TEST_ASSERT (str_len == len);
+
+ jerry_release_value (value);
+
+ TEST_ASSERT (memcmp (buf, str, len) == 0);
+} /* compare */
+
+int
+main (void)
+{
+ TEST_INIT ();
+
+ TEST_ASSERT (jerry_is_feature_enabled (JERRY_FEATURE_LINE_INFO));
+
+ jerry_init (JERRY_INIT_EMPTY);
+
+ jerry_value_t global = jerry_get_global_object ();
+
+ jerry_value_t func = jerry_create_external_function (backtrace_handler);
+ jerry_value_t name = jerry_create_string ((const jerry_char_t *) "backtrace");
+ jerry_value_t result = jerry_set_property (global, name, func);
+ TEST_ASSERT (!jerry_value_has_error_flag (result));
+
+ jerry_release_value (result);
+ jerry_release_value (name);
+ jerry_release_value (func);
+
+ jerry_release_value (global);
+
+ const char *source = ("function f() {\n"
+ " return backtrace(0);\n"
+ "}\n"
+ "\n"
+ "function g() {\n"
+ " return f();\n"
+ "}\n"
+ "\n"
+ "function h() {\n"
+ " return g();\n"
+ "}\n"
+ "\n"
+ "h();\n");
+
+ jerry_value_t backtrace = run ("something.js", source);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (backtrace)
+ && jerry_value_is_array (backtrace));
+
+ TEST_ASSERT (jerry_get_array_length (backtrace) == 4);
+
+ compare (backtrace, 0, "something.js:2");
+ compare (backtrace, 1, "something.js:6");
+ compare (backtrace, 2, "something.js:10");
+ compare (backtrace, 3, "something.js:13");
+
+ jerry_release_value (backtrace);
+
+ /* Depth set to 2 this time. */
+
+ source = ("function f() {\n"
+ " return backtrace(2);\n"
+ "}\n"
+ "\n"
+ "function g() {\n"
+ " return f();\n"
+ "}\n"
+ "\n"
+ "function h() {\n"
+ " return g();\n"
+ "}\n"
+ "\n"
+ "h();\n");
+
+ backtrace = run ("something_else.js", source);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (backtrace)
+ && jerry_value_is_array (backtrace));
+
+ TEST_ASSERT (jerry_get_array_length (backtrace) == 2);
+
+ compare (backtrace, 0, "something_else.js:2");
+ compare (backtrace, 1, "something_else.js:6");
+
+ jerry_release_value (backtrace);
+
+ jerry_cleanup ();
+
+ jerry_init (JERRY_INIT_EMPTY);
+
+ source = ("function f() {\n"
+ " undef_reference;\n"
+ "}\n"
+ "\n"
+ "function g() {\n"
+ " return f();\n"
+ "}\n"
+ "\n"
+ "g();\n");
+
+ jerry_value_t error = run ("bad.js", source);
+
+ TEST_ASSERT (jerry_value_has_error_flag (error));
+
+ jerry_value_clear_error_flag (&error);
+
+ TEST_ASSERT (jerry_value_is_object (error));
+
+ name = jerry_create_string ((const jerry_char_t *) "stack");
+ backtrace = jerry_get_property (error, name);
+
+ jerry_release_value (name);
+ jerry_release_value (error);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (backtrace)
+ && jerry_value_is_array (backtrace));
+
+ TEST_ASSERT (jerry_get_array_length (backtrace) == 3);
+
+ compare (backtrace, 0, "bad.js:2");
+ compare (backtrace, 1, "bad.js:6");
+ compare (backtrace, 2, "bad.js:9");
+
+ jerry_release_value (backtrace);
+
+ jerry_cleanup ();
+
+ return 0;
+} /* main */
static bool test_context_data1_new_called = false;
static bool test_context_data2_new_called = false;
+static bool test_context_data3_new_called = false;
static bool test_context_data1_free_called = false;
static bool test_context_data2_free_called = false;
+static bool test_context_data1_finalize_called = false;
/* Context item 1 */
const char *string1 = "item1";
{
test_context_data1_free_called = true;
TEST_ASSERT ((*(const char **) user_data_p) == string1);
+ TEST_ASSERT (!test_context_data1_finalize_called);
} /* test_context_data1_free */
+static void
+test_context_data1_finalize (void *user_data_p)
+{
+ TEST_ASSERT (test_context_data1_free_called);
+ TEST_ASSERT (!test_context_data1_finalize_called);
+ TEST_ASSERT ((*(const char **) user_data_p) == string1);
+ test_context_data1_finalize_called = true;
+} /* test_context_data1_finalize */
+
static const jerry_context_data_manager_t manager1 =
{
.init_cb = test_context_data1_new,
.deinit_cb = test_context_data1_free,
+ .finalize_cb = test_context_data1_finalize,
.bytes_needed = sizeof (const char *)
};
.bytes_needed = sizeof (const char *)
};
+/* Context item 3 */
+const char *string3 = "item3";
+
+static void
+test_context_data3_new (void *user_data_p)
+{
+ test_context_data3_new_called = true;
+ *((const char **) user_data_p) = string3;
+} /* test_context_data3_new */
+
+static const jerry_context_data_manager_t manager3 =
+{
+ .init_cb = test_context_data3_new,
+ /* NULL is allowed: */
+ .deinit_cb = NULL,
+ .finalize_cb = NULL,
+ .bytes_needed = 0,
+};
+
int
main (void)
{
TEST_ASSERT (!strcmp (*((const char **) jerry_get_context_data (&manager1)), "item1"));
TEST_ASSERT (!strcmp (*((const char **) jerry_get_context_data (&manager2)), "item2"));
+ TEST_ASSERT (!strcmp (*((const char **) jerry_get_context_data (&manager3)), "item3"));
TEST_ASSERT (test_context_data1_new_called);
TEST_ASSERT (test_context_data2_new_called);
+ TEST_ASSERT (test_context_data3_new_called);
TEST_ASSERT (!test_context_data1_free_called);
TEST_ASSERT (!test_context_data2_free_called);
--- /dev/null
+/* Copyright JS Foundation and other contributors, http://js.foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "config.h"
+#include "jerryscript.h"
+
+#include "test-common.h"
+
+static jerry_value_t
+vm_exec_stop_callback (void *user_p)
+{
+ int *int_p = (int *) user_p;
+
+ if (*int_p > 0)
+ {
+ (*int_p)--;
+
+ return jerry_create_undefined ();
+ }
+
+ return jerry_create_string ((const jerry_char_t *) "Abort script");
+} /* vm_exec_stop_callback */
+
+int
+main (void)
+{
+ TEST_INIT ();
+
+ /* Test stopping an infinite loop. */
+ if (!jerry_is_feature_enabled (JERRY_FEATURE_VM_EXEC_STOP))
+ {
+ return 0;
+ }
+
+ jerry_init (JERRY_INIT_EMPTY);
+
+ int countdown = 6;
+ jerry_set_vm_exec_stop_callback (vm_exec_stop_callback, &countdown, 16);
+
+ const char *inf_loop_code_src_p = "while(true) {}";
+ jerry_value_t parsed_code_val = jerry_parse (NULL,
+ 0,
+ (jerry_char_t *) inf_loop_code_src_p,
+ strlen (inf_loop_code_src_p),
+ JERRY_PARSE_NO_OPTS);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val));
+ jerry_value_t res = jerry_run (parsed_code_val);
+ TEST_ASSERT (countdown == 0);
+
+ TEST_ASSERT (jerry_value_has_error_flag (res));
+
+ jerry_release_value (res);
+ jerry_release_value (parsed_code_val);
+
+ /* A more complex example. Although the callback error is captured
+ * by the catch block, it is automatically thrown again. */
+
+ /* We keep the callback function, only the countdown is reset. */
+ countdown = 6;
+
+ inf_loop_code_src_p = ("function f() { while (true) ; }\n"
+ "try { f(); } catch(e) {}");
+
+ parsed_code_val = jerry_parse (NULL,
+ 0,
+ (jerry_char_t *) inf_loop_code_src_p,
+ strlen (inf_loop_code_src_p),
+ JERRY_PARSE_NO_OPTS);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val));
+ res = jerry_run (parsed_code_val);
+ TEST_ASSERT (countdown == 0);
+
+ /* The result must have an error flag which proves that
+ * the error is thrown again inside the catch block. */
+ TEST_ASSERT (jerry_value_has_error_flag (res));
+
+ jerry_release_value (res);
+ jerry_release_value (parsed_code_val);
+
+ jerry_cleanup ();
+ return 0;
+} /* main */
for (uint32_t j = 0; j < test_sub_iters; j++)
{
- jmem_cpointer_t lit1;
- jmem_cpointer_t lit2;
+ ecma_value_t lit1;
+ ecma_value_t lit2;
if (ptrs[j])
{
lit1 = ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
lit2 = ecma_find_or_create_literal_string (ptrs[j], lengths[j]);
+ TEST_ASSERT (ecma_is_value_string (lit1));
+ TEST_ASSERT (ecma_is_value_string (lit2));
TEST_ASSERT (lit1 == lit2);
}
else
{
lit1 = ecma_find_or_create_literal_number (numbers[j]);
lit2 = ecma_find_or_create_literal_number (numbers[j]);
+ TEST_ASSERT (ecma_is_value_number (lit1));
+ TEST_ASSERT (ecma_is_value_number (lit2));
TEST_ASSERT (lit1 == lit2);
}
- TEST_ASSERT (lit1);
- TEST_ASSERT (lit2);
- TEST_ASSERT (lit1 == lit2);
}
/* Check empty string exists. */
#include "jerryscript.h"
#include "test-common.h"
-#ifdef JMEM_STATS
-
-const char *test_source = (
- "var a = 'hello';"
- "var b = 'world';"
- "var c = a + ' ' + b;"
- );
int main (void)
{
+ if (!jerry_is_feature_enabled (JERRY_FEATURE_MEM_STATS))
+ {
+ return 0;
+ }
+ const char *test_source = (
+ "var a = 'hello';"
+ "var b = 'world';"
+ "var c = a + ' ' + b;"
+ );
+
jerry_init (JERRY_INIT_EMPTY);
- jerry_value_t parsed_code_val = jerry_parse ((jerry_char_t *) test_source, strlen (test_source), false);
+ jerry_value_t parsed_code_val = jerry_parse (NULL,
+ 0,
+ (jerry_char_t *) test_source,
+ strlen (test_source),
+ JERRY_PARSE_NO_OPTS);
TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val));
jerry_value_t res = jerry_run (parsed_code_val);
TEST_ASSERT (!jerry_value_has_error_flag (res));
- jerry_heap_stats_t stats = {0};
+ jerry_heap_stats_t stats;
+ memset (&stats, 0, sizeof (stats));
bool get_stats_ret = jerry_get_memory_stats (&stats);
TEST_ASSERT (get_stats_ret);
TEST_ASSERT (stats.version == 1);
return 0;
} /* main */
-
-#else /* JMEM_STATS */
-
-int
-main (void)
-{
- return 0;
-} /* main */
-
-#endif /* !JMEM_STATS */
--- /dev/null
+/* Copyright JS Foundation and other contributors, http://js.foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "jerryscript.h"
+#include "test-common.h"
+
+static int test_data = 1;
+
+static void free_test_data (void *data_p)
+{
+ TEST_ASSERT ((int *) data_p == &test_data);
+} /* free_test_data */
+
+static const jerry_object_native_info_t test_info =
+{
+ .free_cb = free_test_data
+};
+
+static const char *strict_equal_source = "var x = function(a, b) {return a === b;}; x";
+
+static bool
+find_test_object_by_data (const jerry_value_t candidate,
+ void *object_data_p,
+ void *context_p)
+{
+ if (object_data_p == &test_data)
+ {
+ *((jerry_value_t *) context_p) = jerry_acquire_value (candidate);
+ return false;
+ }
+ return true;
+} /* find_test_object_by_data */
+
+static bool
+find_test_object_by_property (const jerry_value_t candidate,
+ void *context_p)
+{
+ jerry_value_t *args_p = (jerry_value_t *) context_p;
+ jerry_value_t result = jerry_has_property (candidate, args_p[0]);
+
+ bool has_property = (!jerry_value_has_error_flag (result) && jerry_get_boolean_value (result));
+
+ /* If the object has the desired property, store a new reference to it in args_p[1]. */
+ if (has_property)
+ {
+ args_p[1] = jerry_acquire_value (candidate);
+ }
+
+ jerry_release_value (result);
+
+ /* Stop iterating if we've found our object. */
+ return !has_property;
+} /* find_test_object_by_property */
+
+int
+main (void)
+{
+ jerry_init (JERRY_INIT_EMPTY);
+
+ /* Render strict-equal as a function. */
+ jerry_value_t parse_result = jerry_parse (NULL,
+ 0,
+ (jerry_char_t *) strict_equal_source,
+ strlen (strict_equal_source),
+ JERRY_PARSE_STRICT_MODE);
+ TEST_ASSERT (!jerry_value_has_error_flag (parse_result));
+ jerry_value_t strict_equal = jerry_run (parse_result);
+ TEST_ASSERT (!jerry_value_has_error_flag (strict_equal));
+ jerry_release_value (parse_result);
+
+ /* Create an object and associate some native data with it. */
+ jerry_value_t object = jerry_create_object ();
+ jerry_set_object_native_pointer (object, &test_data, &test_info);
+
+ /* Retrieve the object by its native pointer. */
+
+ jerry_value_t found_object;
+ TEST_ASSERT (jerry_objects_foreach_by_native_info (&test_info, find_test_object_by_data, &found_object));
+ jerry_value_t args[2] = {object, found_object};
+
+ /* Assert that the correct object was retrieved. */
+ jerry_value_t undefined = jerry_create_undefined ();
+ jerry_value_t strict_equal_result = jerry_call_function (strict_equal, undefined, args, 2);
+ TEST_ASSERT (jerry_value_is_boolean (strict_equal_result) && jerry_get_boolean_value (strict_equal_result));
+ jerry_release_value (strict_equal_result);
+ jerry_release_value (found_object);
+ jerry_release_value (object);
+
+ /* Collect garbage. */
+ jerry_gc ();
+
+ /* Attempt to retrieve the object by its native pointer again. */
+ TEST_ASSERT (!jerry_objects_foreach_by_native_info (&test_info, find_test_object_by_data, &found_object));
+
+ /* Create an object and set a property on it. */
+ object = jerry_create_object ();
+ jerry_value_t property_name = jerry_create_string ((jerry_char_t *) "xyzzy");
+ jerry_value_t property_value = jerry_create_number (42);
+ jerry_release_value (jerry_set_property (object, property_name, property_value));
+ jerry_release_value (property_value);
+
+ /* Retrieve the object by the presence of its property, placing it at args[1]. */
+ args[0] = property_name;
+ TEST_ASSERT (jerry_objects_foreach (find_test_object_by_property, args));
+
+ /* Assert that the right object was retrieved and release both the original reference to it and the retrieved one. */
+ args[0] = object;
+ strict_equal_result = jerry_call_function (strict_equal, undefined, args, 2);
+ TEST_ASSERT (jerry_value_is_boolean (strict_equal_result) && jerry_get_boolean_value (strict_equal_result));
+ jerry_release_value (strict_equal_result);
+ jerry_release_value (args[0]);
+ jerry_release_value (args[1]);
+
+ /* Collect garbage. */
+ jerry_gc ();
+
+ /* Attempt to retrieve the object by the presence of its property again. */
+ args[0] = property_name;
+ TEST_ASSERT (!jerry_objects_foreach (find_test_object_by_property, args));
+
+ jerry_release_value (property_name);
+ jerry_release_value (undefined);
+ jerry_release_value (strict_equal);
+ jerry_cleanup ();
+} /* main */
register_js_function ("create_promise2", create_promise2_handler);
register_js_function ("assert", assert_handler);
- jerry_value_t parsed_code_val = jerry_parse ((jerry_char_t *) test_source, strlen (test_source), false);
+ jerry_value_t parsed_code_val = jerry_parse (NULL,
+ 0,
+ (jerry_char_t *) test_source,
+ strlen (test_source),
+ JERRY_PARSE_NO_OPTS);
TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val));
jerry_value_t res = jerry_run (parsed_code_val);
*/
#define SNAPSHOT_BUFFER_SIZE (256)
+/**
+ * Magic strings
+ */
+static const jerry_char_ptr_t magic_strings[] =
+{
+ (const jerry_char_ptr_t) " ",
+ (const jerry_char_ptr_t) "a",
+ (const jerry_char_ptr_t) "b",
+ (const jerry_char_ptr_t) "c",
+ (const jerry_char_ptr_t) "from",
+ (const jerry_char_ptr_t) "func",
+ (const jerry_char_ptr_t) "string",
+ (const jerry_char_ptr_t) "snapshot"
+};
+
+/**
+ * Magic string lengths
+ */
+static const jerry_length_t magic_string_lengths[] =
+{
+ 1, 1, 1, 1, 4, 4, 6, 8
+};
+
static void test_function_snapshot (void)
{
/* function to snapshot */
const char *code_to_snapshot_p = "return a + b";
jerry_init (flags);
- size_t function_snapshot_size = jerry_parse_and_save_function_snapshot ((jerry_char_t *) code_to_snapshot_p,
- strlen (code_to_snapshot_p),
- (jerry_char_t *) args_p,
- strlen (args_p),
- false,
- function_snapshot_buffer,
- SNAPSHOT_BUFFER_SIZE);
- TEST_ASSERT (function_snapshot_size != 0);
+ jerry_value_t generate_result;
+ generate_result = jerry_generate_function_snapshot (NULL,
+ 0,
+ (const jerry_char_t *) code_to_snapshot_p,
+ strlen (code_to_snapshot_p),
+ (jerry_char_t *) args_p,
+ strlen (args_p),
+ 0,
+ function_snapshot_buffer,
+ SNAPSHOT_BUFFER_SIZE);
+ TEST_ASSERT (!jerry_value_has_error_flag (generate_result)
+ && jerry_value_is_number (generate_result));
+
+ size_t function_snapshot_size = (size_t) jerry_get_number_value (generate_result);
+ jerry_release_value (generate_result);
+
jerry_cleanup ();
jerry_init (flags);
- jerry_value_t function_obj = jerry_load_function_snapshot_at (function_snapshot_buffer,
- function_snapshot_size,
- 0,
- false);
+ jerry_value_t function_obj = jerry_load_function_snapshot (function_snapshot_buffer,
+ function_snapshot_size,
+ 0,
+ 0);
TEST_ASSERT (!jerry_value_has_error_flag (function_obj));
TEST_ASSERT (jerry_value_is_function (function_obj));
jerry_cleanup ();
} /* test_function_snapshot */
-static void test_exec_snapshot (uint32_t *snapshot_p, size_t snapshot_size, bool copy_bytecode)
+static void arguments_test_exec_snapshot (uint32_t *snapshot_p, size_t snapshot_size, uint32_t exec_snapshot_flags)
+{
+ jerry_init (JERRY_INIT_EMPTY);
+ jerry_value_t res = jerry_exec_snapshot (snapshot_p, snapshot_size, 0, exec_snapshot_flags);
+ TEST_ASSERT (!jerry_value_has_error_flag (res));
+ TEST_ASSERT (jerry_value_is_number (res));
+ double raw_value = jerry_get_number_value (res);
+ TEST_ASSERT (raw_value == 15);
+ jerry_release_value (res);
+
+ jerry_cleanup ();
+} /* arguments_test_exec_snapshot */
+
+static void test_function_arguments_snapshot (void)
+{
+ if (jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE)
+ && jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_EXEC))
+ {
+ static uint32_t arguments_snapshot_buffer[SNAPSHOT_BUFFER_SIZE];
+
+ const char *code_to_snapshot_p = ("function f(a,b,c) {"
+ " arguments[0]++;"
+ " arguments[1]++;"
+ " arguments[2]++;"
+ " return a + b + c;"
+ "}"
+ "f(3,4,5);");
+ jerry_init (JERRY_INIT_EMPTY);
+
+ jerry_value_t generate_result;
+ generate_result = jerry_generate_snapshot (NULL,
+ 0,
+ (jerry_char_t *) code_to_snapshot_p,
+ strlen (code_to_snapshot_p),
+ 0,
+ arguments_snapshot_buffer,
+ SNAPSHOT_BUFFER_SIZE);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (generate_result)
+ && jerry_value_is_number (generate_result));
+
+ size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
+ jerry_release_value (generate_result);
+
+ jerry_cleanup ();
+
+ arguments_test_exec_snapshot (arguments_snapshot_buffer, snapshot_size, 0);
+ arguments_test_exec_snapshot (arguments_snapshot_buffer, snapshot_size, JERRY_SNAPSHOT_EXEC_COPY_DATA);
+ }
+} /* test_function_arguments_snapshot */
+
+static void test_exec_snapshot (uint32_t *snapshot_p, size_t snapshot_size, uint32_t exec_snapshot_flags)
{
char string_data[32];
jerry_init (JERRY_INIT_EMPTY);
- jerry_value_t res = jerry_exec_snapshot (snapshot_p,
- snapshot_size,
- copy_bytecode);
+ jerry_register_magic_strings (magic_strings,
+ sizeof (magic_string_lengths) / sizeof (jerry_length_t),
+ magic_string_lengths);
+
+ jerry_value_t res = jerry_exec_snapshot (snapshot_p, snapshot_size, 0, exec_snapshot_flags);
TEST_ASSERT (!jerry_value_has_error_flag (res));
TEST_ASSERT (jerry_value_is_string (res));
int
main (void)
{
+ static uint32_t snapshot_buffer[SNAPSHOT_BUFFER_SIZE];
+
TEST_INIT ();
/* Dump / execute snapshot */
if (jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE)
&& jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_EXEC))
{
- static uint32_t global_mode_snapshot_buffer[SNAPSHOT_BUFFER_SIZE];
- static uint32_t eval_mode_snapshot_buffer[SNAPSHOT_BUFFER_SIZE];
-
const char *code_to_snapshot_p = "(function () { return 'string from snapshot'; }) ();";
jerry_init (JERRY_INIT_EMPTY);
- size_t global_mode_snapshot_size = jerry_parse_and_save_snapshot ((jerry_char_t *) code_to_snapshot_p,
- strlen (code_to_snapshot_p),
- true,
- false,
- global_mode_snapshot_buffer,
- SNAPSHOT_BUFFER_SIZE);
- TEST_ASSERT (global_mode_snapshot_size != 0);
- jerry_cleanup ();
+ jerry_value_t generate_result;
+ generate_result = jerry_generate_snapshot (NULL,
+ 0,
+ (const jerry_char_t *) code_to_snapshot_p,
+ strlen (code_to_snapshot_p),
+ 0,
+ snapshot_buffer,
+ SNAPSHOT_BUFFER_SIZE);
+ TEST_ASSERT (!jerry_value_has_error_flag (generate_result)
+ && jerry_value_is_number (generate_result));
+
+ size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
+ jerry_release_value (generate_result);
+
+ /* Check the snapshot data. Unused bytes should be filled with zeroes */
+ const uint8_t expected_data[] =
+ {
+ 0x4A, 0x52, 0x52, 0x59, 0x0C, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x18, 0x00, 0x00, 0x00,
+ 0x28, 0x00, 0xB7, 0x46, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x01, 0x00, 0x41, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00,
+ 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x14, 0x00, 0x73, 0x74, 0x72, 0x69, 0x6E, 0x67,
+ 0x20, 0x66, 0x72, 0x6F, 0x6D, 0x20, 0x73, 0x6E,
+ 0x61, 0x70, 0x73, 0x68, 0x6F, 0x74
+ };
+ TEST_ASSERT (sizeof (expected_data) == snapshot_size);
+ TEST_ASSERT (0 == memcmp (expected_data, snapshot_buffer, sizeof (expected_data)));
- jerry_init (JERRY_INIT_EMPTY);
- size_t eval_mode_snapshot_size = jerry_parse_and_save_snapshot ((jerry_char_t *) code_to_snapshot_p,
- strlen (code_to_snapshot_p),
- false,
- false,
- eval_mode_snapshot_buffer,
- SNAPSHOT_BUFFER_SIZE);
- TEST_ASSERT (eval_mode_snapshot_size != 0);
jerry_cleanup ();
- test_exec_snapshot (global_mode_snapshot_buffer,
- global_mode_snapshot_size,
- false);
+ test_exec_snapshot (snapshot_buffer, snapshot_size, 0);
+ test_exec_snapshot (snapshot_buffer, snapshot_size, JERRY_SNAPSHOT_EXEC_COPY_DATA);
+ }
- test_exec_snapshot (global_mode_snapshot_buffer,
- global_mode_snapshot_size,
- true);
+ /* Static snapshot */
+ if (jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_SAVE)
+ && jerry_is_feature_enabled (JERRY_FEATURE_SNAPSHOT_EXEC))
+ {
+ const char *code_to_snapshot_p = ("function func(a, b, c) {"
+ " c = 'snapshot';"
+ " return arguments[0] + ' ' + b + ' ' + arguments[2];"
+ "};"
+ "func('string', 'from');");
- test_exec_snapshot (eval_mode_snapshot_buffer,
- eval_mode_snapshot_size,
- false);
+ jerry_init (JERRY_INIT_EMPTY);
+ jerry_register_magic_strings (magic_strings,
+ sizeof (magic_string_lengths) / sizeof (jerry_length_t),
+ magic_string_lengths);
+
+ jerry_value_t generate_result;
+ generate_result = jerry_generate_snapshot (NULL,
+ 0,
+ (jerry_char_t *) code_to_snapshot_p,
+ strlen (code_to_snapshot_p),
+ JERRY_SNAPSHOT_SAVE_STATIC,
+ snapshot_buffer,
+ SNAPSHOT_BUFFER_SIZE);
+ TEST_ASSERT (!jerry_value_has_error_flag (generate_result)
+ && jerry_value_is_number (generate_result));
+
+ size_t snapshot_size = (size_t) jerry_get_number_value (generate_result);
+ jerry_release_value (generate_result);
+
+ /* Static snapshots are not supported by default. */
+ jerry_value_t exec_result = jerry_exec_snapshot (snapshot_buffer, snapshot_size, 0, 0);
+ TEST_ASSERT (jerry_value_has_error_flag (exec_result));
+ jerry_release_value (exec_result);
- test_exec_snapshot (eval_mode_snapshot_buffer,
- eval_mode_snapshot_size,
- true);
+ jerry_cleanup ();
+
+ test_exec_snapshot (snapshot_buffer, snapshot_size, JERRY_SNAPSHOT_EXEC_ALLOW_STATIC);
}
/* Merge snapshot */
const char *code_to_snapshot_p = "123";
jerry_init (JERRY_INIT_EMPTY);
- snapshot_sizes[0] = jerry_parse_and_save_snapshot ((jerry_char_t *) code_to_snapshot_p,
- strlen (code_to_snapshot_p),
- true,
- false,
- snapshot_buffer_0,
- SNAPSHOT_BUFFER_SIZE);
- TEST_ASSERT (snapshot_sizes[0] != 0);
+ jerry_value_t generate_result;
+ generate_result = jerry_generate_snapshot (NULL,
+ 0,
+ (const jerry_char_t *) code_to_snapshot_p,
+ strlen (code_to_snapshot_p),
+ 0,
+ snapshot_buffer_0,
+ SNAPSHOT_BUFFER_SIZE);
+ TEST_ASSERT (!jerry_value_has_error_flag (generate_result)
+ && jerry_value_is_number (generate_result));
+
+ snapshot_sizes[0] = (size_t) jerry_get_number_value (generate_result);
+ jerry_release_value (generate_result);
+
jerry_cleanup ();
code_to_snapshot_p = "456";
jerry_init (JERRY_INIT_EMPTY);
- snapshot_sizes[1] = jerry_parse_and_save_snapshot ((jerry_char_t *) code_to_snapshot_p,
- strlen (code_to_snapshot_p),
- true,
- false,
- snapshot_buffer_1,
- SNAPSHOT_BUFFER_SIZE);
- TEST_ASSERT (snapshot_sizes[1] != 0);
+ generate_result = jerry_generate_snapshot (NULL,
+ 0,
+ (const jerry_char_t *) code_to_snapshot_p,
+ strlen (code_to_snapshot_p),
+ 0,
+ snapshot_buffer_1,
+ SNAPSHOT_BUFFER_SIZE);
+ TEST_ASSERT (!jerry_value_has_error_flag (generate_result)
+ && jerry_value_is_number (generate_result));
+
+ snapshot_sizes[1] = (size_t) jerry_get_number_value (generate_result);
+ jerry_release_value (generate_result);
+
jerry_cleanup ();
jerry_init (JERRY_INIT_EMPTY);
jerry_init (JERRY_INIT_EMPTY);
- jerry_value_t res = jerry_exec_snapshot_at (merged_snapshot_buffer, merged_size, 0, false);
+ jerry_value_t res = jerry_exec_snapshot (merged_snapshot_buffer, merged_size, 0, 0);
TEST_ASSERT (!jerry_value_has_error_flag (res));
TEST_ASSERT (jerry_get_number_value (res) == 123);
jerry_release_value (res);
- res = jerry_exec_snapshot_at (merged_snapshot_buffer, merged_size, 1, false);
+ res = jerry_exec_snapshot (merged_snapshot_buffer, merged_size, 1, 0);
TEST_ASSERT (!jerry_value_has_error_flag (res));
TEST_ASSERT (jerry_get_number_value (res) == 456);
jerry_release_value (res);
test_function_snapshot ();
+ test_function_arguments_snapshot ();
+
return 0;
} /* main */
--- /dev/null
+/* Copyright JS Foundation and other contributors, http://js.foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "jerryscript.h"
+#include "jerryscript-port.h"
+#include "jerryscript-port-default.h"
+#include "test-common.h"
+
+#include <stdio.h>
+
+/**
+ * Type to describe test cases.
+ */
+typedef struct
+{
+ jerry_typedarray_type_t typedarray_type; /**< what kind of TypedArray */
+ char *constructor_name; /**< JS constructor name for TypedArray */
+ uint32_t element_count; /**< number of elements for the TypedArray */
+ uint32_t bytes_per_element; /**< bytes per elment of the given typedarray_type */
+} test_entry_t;
+
+/**
+ * Register a JavaScript value in the global object.
+ */
+static void
+register_js_value (const char *name_p, /**< name of the function */
+ jerry_value_t value) /**< function callback */
+{
+ jerry_value_t global_obj_val = jerry_get_global_object ();
+
+ jerry_value_t name_val = jerry_create_string ((const jerry_char_t *) name_p);
+ jerry_value_t result_val = jerry_set_property (global_obj_val, name_val, value);
+
+ jerry_release_value (name_val);
+ jerry_release_value (global_obj_val);
+
+ jerry_release_value (result_val);
+} /* register_js_value */
+
+static jerry_value_t
+assert_handler (const jerry_value_t func_obj_val, /**< function object */
+ const jerry_value_t this_val, /**< this arg */
+ const jerry_value_t args_p[], /**< function arguments */
+ const jerry_length_t args_cnt) /**< number of function arguments */
+{
+ JERRY_UNUSED (func_obj_val);
+ JERRY_UNUSED (this_val);
+
+ if (jerry_value_is_boolean (args_p[0])
+ && jerry_get_boolean_value (args_p[0]))
+ {
+ return jerry_create_boolean (true);
+ }
+ else
+ {
+ if (args_cnt > 1
+ && jerry_value_is_string (args_p[1]))
+ {
+ jerry_length_t utf8_sz = jerry_get_string_size (args_p[1]);
+ char string_from_utf8[utf8_sz];
+ string_from_utf8[utf8_sz] = 0;
+
+ jerry_string_to_char_buffer (args_p[1], (jerry_char_t *) string_from_utf8, utf8_sz);
+
+ printf ("JS assert: %s\n", string_from_utf8);
+ }
+ TEST_ASSERT (false);
+ }
+} /* assert_handler */
+
+/**
+ * Checks whether global object has typedarray.
+ */
+static bool
+typedarray_is_available (void)
+{
+ jerry_value_t global_obj_val = jerry_get_global_object ();
+ jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) "Int8Array");
+
+ jerry_value_t prop_value = jerry_has_property (global_obj_val, prop_name);
+ bool has_prop = jerry_get_boolean_value (prop_value);
+
+ jerry_release_value (global_obj_val);
+ jerry_release_value (prop_name);
+ jerry_release_value (prop_value);
+
+ return has_prop;
+} /* typedarray_is_available */
+
+/**
+ * Do simple TypedArray property validation.
+ */
+static void
+test_typedarray_info (jerry_value_t typedarray, /**< target TypedArray to query */
+ jerry_typedarray_type_t typedarray_type, /**< expected TypedArray type */
+ jerry_length_t element_count, /**< expected element count */
+ jerry_length_t bytes_per_element) /**< bytes per element for the given type */
+{
+ TEST_ASSERT (!jerry_value_has_error_flag (typedarray));
+ TEST_ASSERT (jerry_value_is_typedarray (typedarray));
+ TEST_ASSERT (jerry_get_typedarray_type (typedarray) == typedarray_type);
+ TEST_ASSERT (jerry_get_typedarray_length (typedarray) == element_count);
+
+ jerry_length_t byte_length = (uint32_t) -1;
+ jerry_length_t byte_offset = (uint32_t) -1;
+ jerry_value_t arraybuffer = jerry_get_typedarray_buffer (typedarray, &byte_offset, &byte_length);
+ TEST_ASSERT (jerry_value_is_arraybuffer (arraybuffer));
+
+ TEST_ASSERT (byte_length == element_count * bytes_per_element);
+ TEST_ASSERT (byte_offset == 0);
+
+ jerry_release_value (arraybuffer);
+} /* test_typedarray_info */
+
+/**
+ * Test construction of TypedArrays and validate properties.
+ */
+static void
+test_typedarray_queries (test_entry_t test_entries[]) /**< test cases */
+{
+ jerry_value_t global_obj_val = jerry_get_global_object ();
+
+ for (uint32_t i = 0; test_entries[i].constructor_name != NULL; i++)
+ {
+ /* Create TypedArray via construct call */
+ {
+ jerry_value_t prop_name = jerry_create_string ((const jerry_char_t *) test_entries[i].constructor_name);
+ jerry_value_t prop_value = jerry_get_property (global_obj_val, prop_name);
+ TEST_ASSERT (!jerry_value_has_error_flag (prop_value));
+ jerry_value_t length_arg = jerry_create_number (test_entries[i].element_count);
+
+ jerry_value_t typedarray = jerry_construct_object (prop_value, &length_arg, 1);
+
+ jerry_release_value (prop_name);
+ jerry_release_value (prop_value);
+ jerry_release_value (length_arg);
+
+ test_typedarray_info (typedarray,
+ test_entries[i].typedarray_type,
+ test_entries[i].element_count,
+ test_entries[i].bytes_per_element);
+ jerry_release_value (typedarray);
+ }
+
+ /* Create TypedArray via api call */
+ {
+ jerry_value_t typedarray = jerry_create_typedarray (test_entries[i].typedarray_type,
+ test_entries[i].element_count);
+ test_typedarray_info (typedarray,
+ test_entries[i].typedarray_type,
+ test_entries[i].element_count,
+ test_entries[i].bytes_per_element);
+ jerry_release_value (typedarray);
+ }
+ }
+
+ jerry_release_value (global_obj_val);
+} /* test_typedarray_queries */
+
+/**
+ * Test value at given position in the buffer based on TypedArray type.
+ */
+static
+void test_buffer_value (uint64_t value, /**< value to test for */
+ const uint8_t *buffer, /**< buffer to read value from */
+ uint32_t start_offset, /**< start offset of the value */
+ jerry_typedarray_type_t typedarray_type, /**< type of TypedArray */
+ uint32_t bytes_per_element) /**< bytes per element for the given type */
+{
+ uint32_t offset = start_offset / bytes_per_element;
+
+#define TEST_VALUE_AT(TYPE, BUFFER, OFFSET, VALUE) TEST_ASSERT (((TYPE *) BUFFER)[OFFSET] == (TYPE) (VALUE))
+
+ switch (typedarray_type)
+ {
+ case JERRY_TYPEDARRAY_UINT8: TEST_VALUE_AT (uint8_t, buffer, offset, value); break;
+ case JERRY_TYPEDARRAY_INT8: TEST_VALUE_AT (int8_t, buffer, offset, value); break;
+ case JERRY_TYPEDARRAY_UINT16: TEST_VALUE_AT (uint16_t, buffer, offset, value); break;
+ case JERRY_TYPEDARRAY_INT16: TEST_VALUE_AT (int16_t, buffer, offset, value); break;
+ case JERRY_TYPEDARRAY_UINT32: TEST_VALUE_AT (uint32_t, buffer, offset, value); break;
+ case JERRY_TYPEDARRAY_INT32: TEST_VALUE_AT (int32_t, buffer, offset, value); break;
+ case JERRY_TYPEDARRAY_FLOAT32: TEST_VALUE_AT (float, buffer, offset, value); break;
+ case JERRY_TYPEDARRAY_FLOAT64: TEST_VALUE_AT (double, buffer, offset, value); break;
+
+ case JERRY_TYPEDARRAY_UINT8CLAMPED:
+ {
+ int64_t signed_value = (int64_t) value;
+ uint8_t expected = (uint8_t) value;
+
+ /* clamp the value if required*/
+ if (signed_value > 0xFF)
+ {
+ expected = 0xFF;
+ }
+ else if (signed_value < 0)
+ {
+ expected = 0;
+ }
+
+ TEST_VALUE_AT (uint8_t, buffer, offset, expected); break;
+ }
+ default: TEST_ASSERT (false); break;
+ }
+
+#undef TEST_VALUE_AT
+} /* test_buffer_value */
+
+static void
+test_typedarray_complex_creation (test_entry_t test_entries[], /**< test cases */
+ bool use_external_buffer) /**< run tests using arraybuffer with external memory */
+{
+ const uint32_t arraybuffer_size = 256;
+
+ uint8_t buffer_ext[arraybuffer_size];
+ memset (buffer_ext, 0, arraybuffer_size);
+
+ for (uint32_t i = 0; test_entries[i].constructor_name != NULL; i++)
+ {
+ const uint32_t offset = 8;
+ uint32_t element_count = test_entries[i].element_count;
+ uint32_t bytes_per_element = test_entries[i].bytes_per_element;
+
+ /* new %TypedArray% (buffer, offset, length); */
+ jerry_value_t typedarray;
+ {
+ jerry_value_t arraybuffer;
+
+ if (use_external_buffer)
+ {
+ arraybuffer = jerry_create_arraybuffer_external (arraybuffer_size, buffer_ext, NULL);
+ }
+ else
+ {
+ arraybuffer = jerry_create_arraybuffer (arraybuffer_size);
+ }
+
+ jerry_value_t js_offset = jerry_create_number (offset);
+ jerry_value_t js_element_count = jerry_create_number (element_count);
+
+ register_js_value ("expected_offset", js_offset);
+ register_js_value ("expected_length", js_element_count);
+
+ typedarray = jerry_create_typedarray_for_arraybuffer_sz (test_entries[i].typedarray_type,
+ arraybuffer,
+ offset,
+ element_count);
+ TEST_ASSERT (!jerry_value_has_error_flag (typedarray));
+
+ jerry_release_value (js_offset);
+ jerry_release_value (js_element_count);
+ jerry_release_value (arraybuffer);
+ }
+
+ register_js_value ("array", typedarray);
+
+ const char *eval_src_p = (
+ "assert (array.length == expected_length,"
+ " 'expected length: ' + expected_length + ' got: ' + array.length);"
+ "assert (array.byteOffset == expected_offset);"
+ "array[0] = 0x11223344;");
+ jerry_value_t result = jerry_eval ((jerry_char_t *) eval_src_p,
+ strlen (eval_src_p),
+ true);
+ TEST_ASSERT (!jerry_value_has_error_flag (result));
+ jerry_release_value (result);
+
+ {
+ jerry_length_t byte_length = 0;
+ jerry_length_t byte_offset = 0;
+ jerry_value_t buffer = jerry_get_typedarray_buffer (typedarray, &byte_offset, &byte_length);
+ TEST_ASSERT (byte_length == element_count * bytes_per_element);
+ TEST_ASSERT (byte_offset == offset);
+
+ uint8_t test_buffer[arraybuffer_size];
+
+ jerry_typedarray_type_t type = jerry_get_typedarray_type (typedarray);
+ jerry_value_t read_count = jerry_arraybuffer_read (buffer, 0, test_buffer, offset + byte_length);
+ TEST_ASSERT (read_count == offset + byte_length);
+ test_buffer_value (0x11223344, test_buffer, offset, type, bytes_per_element);
+
+ if (use_external_buffer)
+ {
+ test_buffer_value (0x11223344, buffer_ext, offset, type, bytes_per_element);
+ TEST_ASSERT (memcmp (buffer_ext, test_buffer, offset + byte_length) == 0);
+ }
+
+ jerry_release_value (buffer);
+ }
+
+ jerry_release_value (typedarray);
+ }
+} /* test_typedarray_complex_creation */
+
+int
+main (void)
+{
+ jerry_init (JERRY_INIT_EMPTY);
+
+ if (!typedarray_is_available ())
+ {
+ jerry_port_log (JERRY_LOG_LEVEL_ERROR, "TypedArray is disabled!\n");
+ jerry_cleanup ();
+ return 0;
+ }
+
+ jerry_value_t function_val = jerry_create_external_function (assert_handler);
+ register_js_value ("assert", function_val);
+ jerry_release_value (function_val);
+
+ test_entry_t test_entries[] =
+ {
+#define TEST_ENTRY(TYPE, CONSTRUCTOR, COUNT, BYTES_PER_ELEMENT) \
+ { TYPE, CONSTRUCTOR, COUNT, BYTES_PER_ELEMENT }
+
+ TEST_ENTRY (JERRY_TYPEDARRAY_UINT8, "Uint8Array", 12, 1),
+ TEST_ENTRY (JERRY_TYPEDARRAY_UINT8CLAMPED, "Uint8ClampedArray", 12, 1),
+ TEST_ENTRY (JERRY_TYPEDARRAY_INT8, "Int8Array", 12, 1),
+ TEST_ENTRY (JERRY_TYPEDARRAY_UINT16, "Uint16Array", 12, 2),
+ TEST_ENTRY (JERRY_TYPEDARRAY_INT16, "Int16Array", 12, 2),
+ TEST_ENTRY (JERRY_TYPEDARRAY_UINT16, "Uint16Array", 12, 2),
+ TEST_ENTRY (JERRY_TYPEDARRAY_INT32, "Int32Array", 12, 4),
+ TEST_ENTRY (JERRY_TYPEDARRAY_UINT32, "Uint32Array", 12, 4),
+ TEST_ENTRY (JERRY_TYPEDARRAY_FLOAT32, "Float32Array", 12, 4),
+ /* TODO: add check if the float64 is supported */
+ TEST_ENTRY (JERRY_TYPEDARRAY_FLOAT64, "Float64Array", 12, 8),
+
+ TEST_ENTRY (JERRY_TYPEDARRAY_INVALID, NULL, 0, 0)
+#undef TEST_ENTRY
+ };
+
+ /* Test TypedArray queries */
+ test_typedarray_queries (test_entries);
+
+ /* Test TypedArray operations in js */
+ {
+ const uint32_t element_count = 14;
+ uint8_t expected_value = 42;
+
+ jerry_value_t array = jerry_create_typedarray (JERRY_TYPEDARRAY_UINT8, element_count);
+
+ {
+ uint8_t expected_data[element_count];
+ memset (expected_data, expected_value, element_count);
+
+ jerry_length_t byte_length;
+ jerry_length_t offset;
+ jerry_value_t buffer = jerry_get_typedarray_buffer (array, &offset, &byte_length);
+ TEST_ASSERT (byte_length == element_count);
+ jerry_length_t written = jerry_arraybuffer_write (buffer, offset, expected_data, element_count);
+ TEST_ASSERT (written == element_count);
+ jerry_release_value (buffer);
+
+ jerry_value_t js_element_count = jerry_create_number (element_count);
+ jerry_value_t js_expected_value = jerry_create_number (expected_value);
+
+ register_js_value ("array", array);
+ register_js_value ("expected_length", js_element_count);
+ register_js_value ("expected_value", js_expected_value);
+
+ jerry_release_value (js_element_count);
+ jerry_release_value (js_expected_value);
+ }
+
+ /* Check read and to write */
+ const char *eval_src_p = (
+ "assert (array.length == expected_length, 'expected length: ' + expected_length + ' got: ' + array.length);"
+ "for (var i = 0; i < array.length; i++)"
+ "{"
+ " assert (array[i] == expected_value);"
+ " array[i] = i;"
+ "};");
+ jerry_value_t result = jerry_eval ((jerry_char_t *) eval_src_p,
+ strlen (eval_src_p),
+ true);
+
+ TEST_ASSERT (!jerry_value_has_error_flag (result));
+ jerry_release_value (result);
+
+ /* Check write results */
+ {
+ jerry_length_t byte_length;
+ jerry_length_t offset;
+ jerry_value_t buffer = jerry_get_typedarray_buffer (array, &offset, &byte_length);
+ TEST_ASSERT (byte_length == element_count);
+
+ uint8_t result_data[element_count];
+
+ jerry_length_t read_count = jerry_arraybuffer_read (buffer, offset, result_data, byte_length);
+ TEST_ASSERT (read_count == byte_length);
+
+ for (uint8_t i = 0; i < read_count; i++)
+ {
+ TEST_ASSERT (result_data[i] == i);
+ }
+
+ jerry_release_value (buffer);
+ }
+
+ jerry_release_value (array);
+ }
+
+ test_typedarray_complex_creation (test_entries, false);
+ test_typedarray_complex_creation (test_entries, true);
+
+ /* test invalid things */
+ {
+ jerry_value_t values[] =
+ {
+ jerry_create_number (11),
+ jerry_create_boolean (false),
+ jerry_create_string ((const jerry_char_t *) "test"),
+ jerry_create_object (),
+ jerry_create_null (),
+ jerry_create_arraybuffer (16),
+ jerry_create_error (JERRY_ERROR_TYPE, (const jerry_char_t *) "error"),
+ jerry_create_undefined (),
+ jerry_create_promise (),
+ };
+
+ for (size_t idx = 0; idx < sizeof (values) / sizeof (values[0]); idx++)
+ {
+ /* A non-TypedArray object should not be regarded a TypedArray. */
+ bool is_typedarray = jerry_value_is_typedarray (values[idx]);
+ TEST_ASSERT (is_typedarray == false);
+
+ /* JERRY_TYPEDARRAY_INVALID should be returned for non-TypedArray objects */
+ jerry_typedarray_type_t type = jerry_get_typedarray_type (values[idx]);
+ TEST_ASSERT (type == JERRY_TYPEDARRAY_INVALID);
+
+ /* Zero should be returned for non-TypedArray objects */
+ jerry_length_t length = jerry_get_typedarray_length (values[idx]);
+ TEST_ASSERT (length == 0);
+
+ /**
+ * Getting the ArrayBuffer from a non-TypedArray object(s) should return an error
+ * and should not modify the output parameter values.
+ */
+ {
+ jerry_length_t offset = 22;
+ jerry_length_t byte_count = 23;
+ jerry_value_t error = jerry_get_typedarray_buffer (values[idx], &offset, &byte_count);
+ TEST_ASSERT (jerry_value_has_error_flag (error));
+ TEST_ASSERT (offset == 22);
+ TEST_ASSERT (byte_count == 23);
+ jerry_release_value (error);
+ }
+
+ /**
+ * Creating a TypedArray from a non-ArrayBuffer should result an error.
+ */
+ if (!jerry_value_is_arraybuffer (values[idx]))
+ {
+ jerry_value_t error = jerry_create_typedarray_for_arraybuffer (JERRY_TYPEDARRAY_UINT8, values[idx]);
+ TEST_ASSERT (jerry_value_has_error_flag (error));
+ jerry_release_value (error);
+ }
+
+ jerry_release_value (values[idx]);
+ }
+ }
+
+ jerry_cleanup ();
+} /* main */
register_js_function ("test_validator_array1", test_validator_array1_handler);
register_js_function ("test_validator_array2", test_validator_array2_handler);
- jerry_value_t parsed_code_val = jerry_parse ((jerry_char_t *) test_source, strlen (test_source), false);
+ jerry_value_t parsed_code_val = jerry_parse (NULL,
+ 0,
+ (jerry_char_t *) test_source,
+ strlen (test_source),
+ JERRY_PARSE_NO_OPTS);
TEST_ASSERT (!jerry_value_has_error_flag (parsed_code_val));
jerry_value_t res = jerry_run (parsed_code_val);
help='build default jerry port implementation (%(choices)s; default: %(default)s)')
parser.add_argument('--js-parser', metavar='X', choices=['ON', 'OFF'], default='ON', type=str.upper,
help='enable js-parser (%(choices)s; default: %(default)s)')
+ parser.add_argument('--line-info', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
+ help='provide line info (%(choices)s; default: %(default)s)')
parser.add_argument('--link-lib', metavar='OPT', action='append', default=[],
help='add custom library to be linked')
parser.add_argument('--linker-flag', metavar='OPT', action='append', default=[],
help=devhelp('enable memory statistics (%(choices)s; default: %(default)s)'))
devgroup.add_argument('--mem-stress-test', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
help=devhelp('enable mem-stress test (%(choices)s; default: %(default)s)'))
+ devgroup.add_argument('--regexp-strict-mode', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
+ help=devhelp('enable regexp strict mode (%(choices)s; default: %(default)s)'))
devgroup.add_argument('--show-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
help=devhelp('enable parser byte-code dumps (%(choices)s; default: %(default)s)'))
devgroup.add_argument('--show-regexp-opcodes', metavar='X', choices=['ON', 'OFF'], default='OFF', type=str.upper,
build_options.append('-DENABLE_ALL_IN_ONE=%s' % arguments.all_in_one)
build_options.append('-DCMAKE_BUILD_TYPE=%s' % arguments.build_type)
- build_options.extend(arguments.cmake_param)
build_options.append('-DEXTERNAL_COMPILE_FLAGS=' + ' '.join(arguments.compile_flag))
build_options.append('-DFEATURE_CPOINTER_32_BIT=%s' % arguments.cpointer_32bit)
build_options.append('-DFEATURE_ERROR_MESSAGES=%s' % arguments.error_messages)
+ build_options.append('-DFEATURE_LINE_INFO=%s' % arguments.line_info)
build_options.append('-DJERRY_CMDLINE=%s' % arguments.jerry_cmdline)
build_options.append('-DJERRY_CMDLINE_TEST=%s' % arguments.jerry_cmdline_test)
build_options.append('-DJERRY_CMDLINE_SNAPSHOT=%s' % arguments.jerry_cmdline_snapshot)
build_options.append('-DFEATURE_MEM_STATS=%s' % arguments.mem_stats)
build_options.append('-DFEATURE_MEM_STRESS_TEST=%s' % arguments.mem_stress_test)
build_options.append('-DFEATURE_PARSER_DUMP=%s' % arguments.show_opcodes)
+ build_options.append('-DFEATURE_REGEXP_STRICT_MODE=%s' % arguments.regexp_strict_mode)
build_options.append('-DFEATURE_REGEXP_DUMP=%s' % arguments.show_regexp_opcodes)
build_options.append('-DFEATURE_VALGRIND=%s' % arguments.valgrind)
build_options.append('-DFEATURE_VALGRIND_FREYA=%s' % arguments.valgrind_freya)
+ build_options.extend(arguments.cmake_param)
+
return build_options
def configure_output_dir(arguments):
def check_files(opts):
files = [JERRY_BUILDER, opts.testfile]
- for file in files:
- if not os.path.isfile(file):
- sys.exit("File not found: %s" % file)
+ for _file in files:
+ if not os.path.isfile(_file):
+ sys.exit("File not found: %s" % _file)
def build_bin(heapsize, opts):
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
-disable=import-star-module-level,old-octal-literal,oct-method,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,missing-docstring
+disable=import-star-module-level,old-octal-literal,oct-method,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,missing-docstring,locally-disabled
[REPORTS]
no-space-check=trailing-comma,dict-separator
# Maximum number of lines in a module
-max-module-lines=1000
+max-module-lines=2000
# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
# tab).
max-attributes=7
# Minimum number of public methods for a class (see R0903).
-min-public-methods=2
+min-public-methods=0
# Maximum number of public methods for a class (see R0904).
-max-public-methods=20
+max-public-methods=25
# Maximum number of boolean expressions in a if statement
max-bool-expr=5
OUTPUT_DIR = os.path.join(settings.PROJECT_DIR, 'build', 'tests')
-class Options(object):
- def __init__(self, name, build_args=None, test_args=None):
- self.name = name
- self.build_args = build_args or []
- self.test_args = test_args or []
+Options = collections.namedtuple('Options', ['name', 'build_args', 'test_args'])
+Options.__new__.__defaults__ = ([], [])
def get_binary_path(bin_dir_path):
return os.path.join(bin_dir_path, 'jerry')
# Test options for unittests
JERRY_UNITTESTS_OPTIONS = [
Options('unittests',
- ['--unittests', '--jerry-cmdline=off', '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset', '--mem-stats=on']),
+ ['--unittests', '--profile=es2015-subset', '--jerry-cmdline=off', '--error-messages=on',
+ '--snapshot-save=on', '--snapshot-exec=on', '--line-info=on', '--vm-exec-stop=on',
+ '--mem-stats=on']),
Options('unittests-debug',
- ['--unittests', '--jerry-cmdline=off', '--debug', '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset', '--mem-stats=on']),
+ ['--unittests', '--debug', '--profile=es2015-subset', '--jerry-cmdline=off',
+ '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on', '--line-info=on',
+ '--vm-exec-stop=on', '--mem-stats=on']),
Options('doctests',
- ['--doctests', '--jerry-cmdline=off', '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset']),
+ ['--doctests', '--jerry-cmdline=off', '--error-messages=on', '--snapshot-save=on',
+ '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset']),
Options('doctests-debug',
- ['--doctests', '--jerry-cmdline=off', '--debug', '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset'])
+ ['--doctests', '--jerry-cmdline=off', '--debug', '--error-messages=on',
+ '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es2015-subset']),
+ Options('unittests-es5.1',
+ ['--unittests', '--profile=es5.1', '--jerry-cmdline=off', '--error-messages=on',
+ '--snapshot-save=on', '--snapshot-exec=on', '--line-info=on', '--vm-exec-stop=on',
+ '--mem-stats=on']),
+ Options('unittests-es5.1-debug',
+ ['--unittests', '--debug', '--profile=es5.1', '--jerry-cmdline=off',
+ '--error-messages=on', '--snapshot-save=on', '--snapshot-exec=on', '--line-info=on',
+ '--vm-exec-stop=on', '--mem-stats=on']),
+ Options('doctests-es5.1',
+ ['--doctests', '--jerry-cmdline=off', '--error-messages=on', '--snapshot-save=on',
+ '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es5.1']),
+ Options('doctests-es5.1-debug',
+ ['--doctests', '--jerry-cmdline=off', '--debug', '--error-messages=on',
+ '--snapshot-save=on', '--snapshot-exec=on', '--vm-exec-stop=on', '--profile=es5.1'])
]
# Test options for jerry-tests
['--snapshot']),
Options('jerry_tests-es2015_subset-debug',
['--debug', '--profile=es2015-subset']),
+ Options('jerry_tests-es5.1-debug',
+ ['--debug', '--profile=es5.1']),
Options('jerry_tests-debug-external_context',
['--debug', '--jerry-libc=off', '--external-context=on'])
]
Options('jerry_test_suite-minimal-debug',
['--debug', '--profile=minimal']),
Options('jerry_test_suite-minimal-debug-snapshot',
- ['--debug', '--profile=minimal', '--snapshot-save=on', '--snapshot-exec=on', '--jerry-cmdline-snapshot=on'],
+ ['--debug', '--profile=minimal', '--snapshot-save=on', '--snapshot-exec=on',
+ '--jerry-cmdline-snapshot=on'],
['--snapshot']),
Options('jerry_test_suite-es2015_subset',
['--profile=es2015-subset']),
['--profile=es2015-subset', '--snapshot-save=on', '--snapshot-exec=on', '--jerry-cmdline-snapshot=on'],
['--snapshot']),
Options('jerry_test_suite-es2015_subset-debug-snapshot',
- ['--debug', '--profile=es2015-subset', '--snapshot-save=on', '--snapshot-exec=on', '--jerry-cmdline-snapshot=on'],
+ ['--debug', '--profile=es2015-subset', '--snapshot-save=on', '--snapshot-exec=on',
+ '--jerry-cmdline-snapshot=on'],
+ ['--snapshot']),
+ Options('jerry_test_suite_es5.1',
+ ['--profile=es5.1']),
+ Options('jerry_test_suite-es5.1-snapshot',
+ ['--profile=es5.1', '--snapshot-save=on', '--snapshot-exec=on', '--jerry-cmdline-snapshot=on'],
+ ['--snapshot']),
+ Options('jerry_test_suite-es5.1-debug-snapshot',
+ ['--debug', '--profile=es5.1', '--snapshot-save=on', '--snapshot-exec=on',
+ '--jerry-cmdline-snapshot=on'],
['--snapshot'])
])
parser = argparse.ArgumentParser()
parser.add_argument('--toolchain', metavar='FILE',
help='Add toolchain file')
+ parser.add_argument('-q', '--quiet', action='store_true',
+ help='Only print out failing tests')
parser.add_argument('--buildoptions', metavar='LIST',
help='Add a comma separated list of extra build options to each test')
parser.add_argument('--skip-list', metavar='LIST',
if '--profile=es2015-subset' not in job.build_args:
skip_list.append(r"es2015\/")
+ else:
+ skip_list.append(r"es5.1\/")
if options.skip_list:
skip_list.append(options.skip_list)
+ if options.quiet:
+ test_cmd.append("-q")
+
if skip_list:
test_cmd.append("--skip-list=" + ",".join(skip_list))
else:
test_cmd.append(settings.JERRY_TEST_SUITE_ES51_LIST)
+ if options.quiet:
+ test_cmd.append("-q")
+
if options.skip_list:
test_cmd.append("--skip-list=" + options.skip_list)
ret_test |= run_check([
settings.UNITTEST_RUNNER_SCRIPT,
- bin_dir_path
+ bin_dir_path,
+ "-q" if options.quiet else "",
])
return ret_build | ret_test
return ret
-def main(options):
- Check = collections.namedtuple('Check', ['enabled', 'runner', 'arg'])
+Check = collections.namedtuple('Check', ['enabled', 'runner', 'arg'])
+def main(options):
checks = [
Check(options.check_signed_off, run_check, [settings.SIGNED_OFF_SCRIPT]
+ {'tolerant': ['--tolerant'], 'travis': ['--travis']}.get(options.check_signed_off, [])),
# limitations under the License.
# Usage:
-# ./tools/runners/run-test-suite.sh ENGINE TESTS [--skip-list=item1,item2] [--snapshot] ENGINE_ARGS....
+# ./tools/runners/run-test-suite.sh ENGINE TESTS [-q] [--skip-list=item1,item2] [--snapshot] ENGINE_ARGS....
TIMEOUT=${TIMEOUT:=5}
TIMEOUT_CMD=`which timeout`
TEST_FAILED=$OUTPUT_DIR/$TESTS_BASENAME.failed
TEST_PASSED=$OUTPUT_DIR/$TESTS_BASENAME.passed
+VERBOSE=1
+if [[ "$1" == "-q" ]]
+then
+ unset VERBOSE
+ shift
+fi
+
if [[ "$1" =~ ^--skip-list=.* ]]
then
SKIP_LIST=${1#--skip-list=}
# Testing snapshot
SNAPSHOT_TEMP=`mktemp $(basename -s .js $test).snapshot.XXXXXXXXXX`
- cmd_line="${SNAPSHOT_TOOL#$ROOT_DIR} generate --context global -o $SNAPSHOT_TEMP ${full_test#$ROOT_DIR}"
- $TIMEOUT_CMD $TIMEOUT $SNAPSHOT_TOOL generate --context global -o $SNAPSHOT_TEMP $full_test &> $ENGINE_TEMP
+ cmd_line="${SNAPSHOT_TOOL#$ROOT_DIR} generate -o $SNAPSHOT_TEMP ${full_test#$ROOT_DIR}"
+ $TIMEOUT_CMD $TIMEOUT $SNAPSHOT_TOOL generate -o $SNAPSHOT_TEMP $full_test &> $ENGINE_TEMP
status_code=$?
if [ $status_code -eq 0 ]
then
- echo "[$tested/$TOTAL] $cmd_line: PASS"
+ test $VERBOSE && echo "[$tested/$TOTAL] $cmd_line: PASS"
cmd_line="${ENGINE#$ROOT_DIR} $ENGINE_ARGS --exec-snapshot $SNAPSHOT_TEMP"
$TIMEOUT_CMD $TIMEOUT $ENGINE $ENGINE_ARGS --exec-snapshot $SNAPSHOT_TEMP &> $ENGINE_TEMP
failed=$((failed+1))
else
- echo "[$tested/$TOTAL] $cmd_line: $PASS"
+ test $VERBOSE && echo "[$tested/$TOTAL] $cmd_line: $PASS"
echo "$test" >> $TEST_PASSED
DIR="$1"
shift
+VERBOSE=1
+if [ "$1" == "-q" ]
+then
+ unset VERBOSE
+ shift
+fi
+
UNITTEST_ERROR=$DIR/unittests.failed
UNITTEST_OK=$DIR/unittests.passed
failed=$((failed+1))
else
- echo "[$tested/$total] $cmd_line: PASS"
+ test $VERBOSE && echo "[$tested/$total] $cmd_line: PASS"
echo "$unit_test" >> $UNITTEST_OK
set(CMAKE_SYSTEM_NAME Openwrt)
set(CMAKE_SYSTEM_PROCESSOR mips)
-set(CMAKE_C_COMPILER mipsel-openwrt-linux-gcc)
+set(CMAKE_C_COMPILER mips-openwrt-linux-gcc)
# linux common
include("cmake/option/option_unix_common.cmake")
-
-set(TUV_PLATFORM_PATH "linux")
-set(BUILDTESTER "no")
-set(BUILDAPIEMULTESTER "no")
-
-# linux specific source files
-set(LINUX_PATH "${SOURCE_ROOT}/${TUV_PLATFORM_PATH}")
-
-set(PLATFORM_SRCFILES ${PLATFORM_SRCFILES}
- "${LINUX_PATH}/uv_linux.c"
- "${LINUX_PATH}/uv_linux_loop.c"
- "${LINUX_PATH}/uv_linux_clock.c"
- "${LINUX_PATH}/uv_linux_io.c"
- "${LINUX_PATH}/uv_linux_syscall.c"
- "${LINUX_PATH}/uv_linux_thread.c"
- )
-
-set(PLATFORM_TESTFILES "${TEST_ROOT}/runner_linux.c"
- )
-
-set(TUV_LINK_LIBS "pthread")
-
-# mips-linux specific
-if(DEFINED TARGET_BOARD)
-endif()
+include("cmake/option/option_linux_common.cmake")
return UV_NAMED_PIPE;
#endif
switch (ss.ss_family) {
+
+#ifdef AF_UNIX
case AF_UNIX:
return UV_NAMED_PIPE;
+#endif
case AF_INET:
case AF_INET6:
return UV_TCP;
--- /dev/null
+Note: This is just a template, so feel free to use/remove the unnecessary things
+
+### Description
+- Type: Bug | Enhancement\Feature Request | Question
+- Priority: Blocker | Major | Minor
+
+---------------------------------------------------------------
+## Bug
+
+**OS**
+Mbed OS|linux|windows|
+
+**mbed TLS build:**
+Version: x.x.x or git commit id
+OS version: x.x.x
+Configuration: please attach config.h file where possible
+Compiler and options (if you used a pre-built binary, please indicate how you obtained it):
+Additional environment information:
+
+**Peer device TLS stack and version**
+OpenSSL|GnuTls|Chrome|NSS(Firefox)|SecureChannel (IIS/Internet Explorer/Edge)|Other
+Version:
+
+**Expected behavior**
+
+**Actual behavior**
+
+**Steps to reproduce**
+
+----------------------------------------------------------------
+## Enhancement\Feature Request
+
+**Justification - why does the library need this feature?**
+
+**Suggested enhancement**
+
+-----------------------------------------------------------------
+
+## Question
+
+**Please first check for answers in the [Mbed TLS knowledge Base](https://tls.mbed.org/kb), and preferably file an issue in the [Mbed TLS support forum](https://tls.mbed.org/discussions)**
--- /dev/null
+Notes:
+* Pull requests cannot be accepted until:
+- The submitter has [accepted the online agreement here with a click through](https://developer.mbed.org/contributor_agreement/)
+ or for companies or those that do not wish to create an mbed account, a slightly different agreement can be found [here](https://www.mbed.com/en/about-mbed/contributor-license-agreements/)
+- The PR follows the [mbed TLS coding standards](https://tls.mbed.org/kb/development/mbedtls-coding-standards)
+* This is just a template, so feel free to use/remove the unnecessary things
+## Description
+A few sentences describing the overall goals of the pull request's commits.
+
+
+## Status
+**READY/IN DEVELOPMENT/HOLD**
+
+## Requires Backporting
+When there is a bug fix, it should be backported to all maintained and supported branches.
+Changes do not have to be backported if:
+- This PR is a new feature\enhancement
+- This PR contains changes in the API. If this is true, and there is a need for the fix to be backported, the fix should be handled differently in the legacy branch
+
+Yes | NO
+Which branch?
+
+## Migrations
+If there is any API change, what's the incentive and logic for it.
+
+YES | NO
+
+## Additional comments
+Any additional information that could be of interest
+
+## Todos
+- [ ] Tests
+- [ ] Documentation
+- [ ] Changelog updated
+- [ ] Backported
+
+
+## Steps to test or reproduce
+Outline the steps to test or reproduce the PR here.
endif(CMAKE_COMPILER_IS_CLANG)
if(MSVC)
- set(CMAKE_C_FLAGS_CHECK "/WX")
+ # Strictest warnings, and treat as errors
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
endif(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
endif()
ADD_CUSTOM_TARGET(apidoc
- COMMAND doxygen doxygen/mbedtls.doxyfile
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+ COMMAND doxygen mbedtls.doxyfile
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen)
if(ENABLE_TESTING)
enable_testing()
--- /dev/null
+Contributing
+============
+We gratefully accept bug reports and contributions from the community. There are some requirements we need to fulfill in order to be able to integrate contributions:
+
+ - As with any open source project, contributions will be reviewed by the project team and community and may need some modifications to be accepted.
+ - The contribution should not break API or ABI, unless there is a real justification for that. If there is an API change, the contribution, if accepted, will be merged only when there will be a major release.
+
+Contributor License Agreement (CLA)
+-----------------------------------
+- All contributions, whether large or small, require a Contributor's License Agreement (CLA) to be accepted. This is because source code can possibly fall under copyright law and we need your consent to share in the ownership of the copyright.
+- To accept the Contributor’s License Agreement (CLA), individual contributors can do this by creating an Mbed account and [accepting the online agreement here with a click through](https://developer.mbed.org/contributor_agreement/). Alternatively, for contributions from corporations, or those that do not wish to create an Mbed account, a slightly different agreement can be found [here](https://www.mbed.com/en/about-mbed/contributor-license-agreements/). This agreement should be signed and returned to Arm as described in the instructions given.
+
+Coding Standards
+----------------
+- We would ask that contributions conform to [our coding standards](https://tls.mbed.org/kb/development/mbedtls-coding-standards), and that contributions are fully tested before submission, as mentioned in the [Tests](#tests) and [Continuous Integration](#continuous-integration-tests) sections.
+- The code should be written in a clean and readable style.
+- The code should be written in a portable generic way, that will benefit the whole community, and not only your own needs.
+- The code should be secure, and will be reviewed from a security point of view as well.
+
+Making a Contribution
+---------------------
+1. [Check for open issues](https://github.com/ARMmbed/mbedtls/issues) or [start a discussion](https://tls.mbed.org/discussions) around a feature idea or a bug.
+1. Fork the [Mbed TLS repository on GitHub](https://github.com/ARMmbed/mbedtls) to start making your changes. As a general rule, you should use the ["development" branch](https://github.com/ARMmbed/mbedtls/tree/development) as a basis.
+1. Write a test which shows that the bug was fixed or that the feature works as expected.
+1. Send a pull request (PR) and work with us until it gets merged and published. Contributions may need some modifications, so a few rounds of review and fixing may be necessary. We will include your name in the ChangeLog :)
+1. For quick merging, the contribution should be short, and concentrated on a single feature or topic. The larger the contribution is, the longer it would take to review it and merge it.
+1. Mbed TLS is released under the Apache license, and as such, all the added files should include the Apache license header.
+
+Backports
+---------
+Mbed TLS maintains some legacy branches, which are released as LTS versions. Mbed TLS should follow backwards compatibility rules, to fit with existing users. As such, backporting to these branches should be handled according to the following rules:
+
+1. If the contribution is a new feature or enhancement, no backporting is needed.
+1. Bug fixes should be backported to the legacy branches containing these bugs.
+1. Changes in the API do not require backporting. If a bug fix introduced a new API, such as new error codes, the bug fix should be implemented differently in the legacy branch.
+
+It would be highly appreciated if a contribution would be backported to a legacy branch in addition to the [development branch](https://github.com/ARMmbed/mbedtls/tree/development).
+At the moment, the legacy branches are:
+
+1. [mbedtls-1.3](https://github.com/ARMmbed/mbedtls/tree/mbedtls-1.3)
+1. [mbedtls-2.1](https://github.com/ARMmbed/mbedtls/tree/mbedtls-2.1)
+
+Tests
+-----
+As mentioned, tests that show the correctness of the feature or bug fix should be added to the pull request, if no such tests exist.
+Mbed TLS includes an elaborate test suite in `tests/` that initially requires Perl to generate the tests files (e.g. `test_suite_mpi.c`). These files are generated from a `function file` (e.g. `suites/test_suite_mpi.function`) and a `data file` (e.g. `suites/test_suite_mpi.data`). The function file contains the test functions. The data file contains the test cases, specified as parameters that will be passed to the test function.
+
+Sample applications, if needed, should be modified as well.
+
+Continuous Integration Tests
+----------------------------
+Once a PR has been made, the Continuous Integration (CI) tests are triggered and run. You should follow the result of the CI tests, and fix failures.
+It is advised to enable the [githooks scripts](https://github.com/ARMmbed/mbedtls/tree/development/tests/git-scripts) prior to pushing your changes, for catching some of the issues as early as possible.
+
+Documentation
+-------------
+Mbed TLS should be well documented. If documentation is needed, speak out!
+
+1. All interfaces should be documented through Doxygen. New APIs should introduce Doxygen documentation.
+1. Complex parts in the code should include comments.
+1. If needed, a Readme file is advised.
+1. If a [Knowledge Base (KB)](https://tls.mbed.org/kb) article should be added, write this as a comment in the PR description.
+1. A [ChangeLog](https://github.com/ARMmbed/mbedtls/blob/development/ChangeLog) entry should be added for this contribution.
mbed TLS ChangeLog (Sorted per branch, date)
+= mbed TLS 2.8.0 branch released 2018-03-16
+
+Default behavior changes
+ * The truncated HMAC extension now conforms to RFC 6066. This means
+ that when both sides of a TLS connection negotiate the truncated
+ HMAC extension, Mbed TLS can now interoperate with other
+ compliant implementations, but this breaks interoperability with
+ prior versions of Mbed TLS. To restore the old behavior, enable
+ the (deprecated) option MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT in
+ config.h. Found by Andreas Walz (ivESK, Offenburg University of
+ Applied Sciences).
+
+Security
+ * Fix implementation of the truncated HMAC extension. The previous
+ implementation allowed an offline 2^80 brute force attack on the
+ HMAC key of a single, uninterrupted connection (with no
+ resumption of the session).
+ * Verify results of RSA private key operations to defend
+ against Bellcore glitch attack.
+ * Fix a buffer overread in ssl_parse_server_key_exchange() that could cause
+ a crash on invalid input.
+ * Fix a buffer overread in ssl_parse_server_psk_hint() that could cause a
+ crash on invalid input.
+ * Fix CRL parsing to reject CRLs containing unsupported critical
+ extensions. Found by Falko Strenzke and Evangelos Karatsiolis.
+
+Features
+ * Extend PKCS#8 interface by introducing support for the entire SHA
+ algorithms family when encrypting private keys using PKCS#5 v2.0.
+ This allows reading encrypted PEM files produced by software that
+ uses PBKDF2-SHA2, such as OpenSSL 1.1. Submitted by Antonio Quartulli,
+ OpenVPN Inc. Fixes #1339
+ * Add support for public keys encoded in PKCS#1 format. #1122
+
+New deprecations
+ * Deprecate support for record compression (configuration option
+ MBEDTLS_ZLIB_SUPPORT).
+
+Bugfix
+ * Fix the name of a DHE parameter that was accidentally changed in 2.7.0.
+ Fixes #1358.
+ * Fix test_suite_pk to work on 64-bit ILP32 systems. #849
+ * Fix mbedtls_x509_crt_profile_suiteb, which used to reject all certificates
+ with flag MBEDTLS_X509_BADCERT_BAD_PK even when the key type was correct.
+ In the context of SSL, this resulted in handshake failure. Reported by
+ daniel in the Mbed TLS forum. #1351
+ * Fix Windows x64 builds with the included mbedTLS.sln file. #1347
+ * Fix setting version TLSv1 as minimal version, even if TLS 1
+ is not enabled. Set MBEDTLS_SSL_MIN_MAJOR_VERSION
+ and MBEDTLS_SSL_MIN_MINOR_VERSION instead of
+ MBEDTLS_SSL_MAJOR_VERSION_3 and MBEDTLS_SSL_MINOR_VERSION_1. #664
+ * Fix compilation error on Mingw32 when _TRUNCATE is defined. Use _TRUNCATE
+ only if __MINGW32__ not defined. Fix suggested by Thomas Glanzmann and
+ Nick Wilson on issue #355
+ * In test_suite_pk, pass valid parameters when testing for hash length
+ overflow. #1179
+ * Fix memory allocation corner cases in memory_buffer_alloc.c module. Found
+ by Guido Vranken. #639
+ * Log correct number of ciphersuites used in Client Hello message. #918
+ * Fix X509 CRT parsing that would potentially accept an invalid tag when
+ parsing the subject alternative names.
+ * Fix a possible arithmetic overflow in ssl_parse_server_key_exchange()
+ that could cause a key exchange to fail on valid data.
+ * Fix a possible arithmetic overflow in ssl_parse_server_psk_hint() that
+ could cause a key exchange to fail on valid data.
+ * Don't define mbedtls_aes_decrypt and mbedtls_aes_encrypt under
+ MBEDTLS_DEPRECATED_REMOVED. #1388
+ * Fix a 1-byte heap buffer overflow (read-only) during private key parsing.
+ Found through fuzz testing.
+
+Changes
+ * Fix tag lengths and value ranges in the documentation of CCM encryption.
+ Contributed by Mathieu Briand.
+ * Fix typo in a comment ctr_drbg.c. Contributed by Paul Sokolovsky.
+ * Remove support for the library reference configuration for picocoin.
+ * MD functions deprecated in 2.7.0 are no longer inline, to provide
+ a migration path for those depending on the library's ABI.
+ * Clarify the documentation of mbedtls_ssl_setup.
+ * Use (void) when defining functions with no parameters. Contributed by
+ Joris Aerts. #678
+
+= mbed TLS 2.7.0 branch released 2018-02-03
+
+Security
+ * Fix a heap corruption issue in the implementation of the truncated HMAC
+ extension. When the truncated HMAC extension is enabled and CBC is used,
+ sending a malicious application packet could be used to selectively corrupt
+ 6 bytes on the peer's heap, which could potentially lead to crash or remote
+ code execution. The issue could be triggered remotely from either side in
+ both TLS and DTLS. CVE-2018-0488
+ * Fix a buffer overflow in RSA-PSS verification when the hash was too large
+ for the key size, which could potentially lead to crash or remote code
+ execution. Found by Seth Terashima, Qualcomm Product Security Initiative,
+ Qualcomm Technologies Inc. CVE-2018-0487
+ * Fix buffer overflow in RSA-PSS verification when the unmasked data is all
+ zeros.
+ * Fix an unsafe bounds check in ssl_parse_client_psk_identity() when adding
+ 64 KiB to the address of the SSL buffer and causing a wrap around.
+ * Fix a potential heap buffer overflow in mbedtls_ssl_write(). When the (by
+ default enabled) maximum fragment length extension is disabled in the
+ config and the application data buffer passed to mbedtls_ssl_write
+ is larger than the internal message buffer (16384 bytes by default), the
+ latter overflows. The exploitability of this issue depends on whether the
+ application layer can be forced into sending such large packets. The issue
+ was independently reported by Tim Nordell via e-mail and by Florin Petriuc
+ and sjorsdewit on GitHub. Fix proposed by Florin Petriuc in #1022.
+ Fixes #707.
+ * Add a provision to prevent compiler optimizations breaking the time
+ constancy of mbedtls_ssl_safer_memcmp().
+ * Ensure that buffers are cleared after use if they contain sensitive data.
+ Changes were introduced in multiple places in the library.
+ * Set PEM buffer to zero before freeing it, to avoid decoded private keys
+ being leaked to memory after release.
+ * Fix dhm_check_range() failing to detect trivial subgroups and potentially
+ leaking 1 bit of the private key. Reported by prashantkspatil.
+ * Make mbedtls_mpi_read_binary() constant-time with respect to the input
+ data. Previously, trailing zero bytes were detected and omitted for the
+ sake of saving memory, but potentially leading to slight timing
+ differences. Reported by Marco Macchetti, Kudelski Group.
+ * Wipe stack buffer temporarily holding EC private exponent
+ after keypair generation.
+ * Fix a potential heap buffer over-read in ALPN extension parsing
+ (server-side). Could result in application crash, but only if an ALPN
+ name larger than 16 bytes had been configured on the server.
+ * Change default choice of DHE parameters from untrustworthy RFC 5114
+ to RFC 3526 containing parameters generated in a nothing-up-my-sleeve
+ manner.
+
+Features
+ * Allow comments in test data files.
+ * The selftest program can execute a subset of the tests based on command
+ line arguments.
+ * New unit tests for timing. Improve the self-test to be more robust
+ when run on a heavily-loaded machine.
+ * Add alternative implementation support for CCM and CMAC (MBEDTLS_CCM_ALT,
+ MBEDTLS_CMAC_ALT). Submitted by Steven Cooreman, Silicon Labs.
+ * Add support for alternative implementations of GCM, selected by the
+ configuration flag MBEDTLS_GCM_ALT.
+ * Add support for alternative implementations for ECDSA, controlled by new
+ configuration flags MBEDTLS_ECDSA_SIGN_ALT, MBEDTLS_ECDSA_VERIFY_ALT and
+ MBEDTLS_ECDSDA_GENKEY_AT in config.h.
+ The following functions from the ECDSA module can be replaced
+ with alternative implementation:
+ mbedtls_ecdsa_sign(), mbedtls_ecdsa_verify() and mbedtls_ecdsa_genkey().
+ * Add support for alternative implementation of ECDH, controlled by the
+ new configuration flags MBEDTLS_ECDH_COMPUTE_SHARED_ALT and
+ MBEDTLS_ECDH_GEN_PUBLIC_ALT in config.h.
+ The following functions from the ECDH module can be replaced
+ with an alternative implementation:
+ mbedtls_ecdh_gen_public() and mbedtls_ecdh_compute_shared().
+ * Add support for alternative implementation of ECJPAKE, controlled by
+ the new configuration flag MBEDTLS_ECJPAKE_ALT.
+ * Add mechanism to provide alternative implementation of the DHM module.
+
+API Changes
+ * Extend RSA interface by multiple functions allowing structure-
+ independent setup and export of RSA contexts. Most notably,
+ mbedtls_rsa_import() and mbedtls_rsa_complete() are introduced for setting
+ up RSA contexts from partial key material and having them completed to the
+ needs of the implementation automatically. This allows to setup private RSA
+ contexts from keys consisting of N,D,E only, even if P,Q are needed for the
+ purpose or CRT and/or blinding.
+ * The configuration option MBEDTLS_RSA_ALT can be used to define alternative
+ implementations of the RSA interface declared in rsa.h.
+ * The following functions in the message digest modules (MD2, MD4, MD5,
+ SHA1, SHA256, SHA512) have been deprecated and replaced as shown below.
+ The new functions change the return type from void to int to allow
+ returning error codes when using MBEDTLS_<MODULE>_ALT.
+ mbedtls_<MODULE>_starts() -> mbedtls_<MODULE>_starts_ret()
+ mbedtls_<MODULE>_update() -> mbedtls_<MODULE>_update_ret()
+ mbedtls_<MODULE>_finish() -> mbedtls_<MODULE>_finish_ret()
+ mbedtls_<MODULE>_process() -> mbedtls_internal_<MODULE>_process()
+
+New deprecations
+ * Deprecate usage of RSA primitives with non-matching key-type
+ (e.g. signing with a public key).
+ * Direct manipulation of structure fields of RSA contexts is deprecated.
+ Users are advised to use the extended RSA API instead.
+ * Deprecate usage of message digest functions that return void
+ (mbedtls_<MODULE>_starts, mbedtls_<MODULE>_update,
+ mbedtls_<MODULE>_finish and mbedtls_<MODULE>_process where <MODULE> is
+ any of MD2, MD4, MD5, SHA1, SHA256, SHA512) in favor of functions
+ that can return an error code.
+ * Deprecate untrustworthy DHE parameters from RFC 5114. Superseded by
+ parameters from RFC 3526 or the newly added parameters from RFC 7919.
+ * Deprecate hex string DHE constants MBEDTLS_DHM_RFC3526_MODP_2048_P etc.
+ Supserseded by binary encoded constants MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN
+ etc.
+ * Deprecate mbedtls_ssl_conf_dh_param() for setting default DHE parameters
+ from hex strings. Superseded by mbedtls_ssl_conf_dh_param_bin()
+ accepting DHM parameters in binary form, matching the new constants.
+
+Bugfix
+ * Fix ssl_parse_record_header() to silently discard invalid DTLS records
+ as recommended in RFC 6347 Section 4.1.2.7.
+ * Fix memory leak in mbedtls_ssl_set_hostname() when called multiple times.
+ Found by projectgus and jethrogb, #836.
+ * Fix usage help in ssl_server2 example. Found and fixed by Bei Lin.
+ * Parse signature algorithm extension when renegotiating. Previously,
+ renegotiated handshakes would only accept signatures using SHA-1
+ regardless of the peer's preferences, or fail if SHA-1 was disabled.
+ * Fix leap year calculation in x509_date_is_valid() to ensure that invalid
+ dates on leap years with 100 and 400 intervals are handled correctly. Found
+ by Nicholas Wilson. #694
+ * Fix some invalid RSA-PSS signatures with keys of size 8N+1 that were
+ accepted. Generating these signatures required the private key.
+ * Fix out-of-memory problem when parsing 4096-bit PKCS8-encrypted RSA keys.
+ Found independently by Florian in the mbed TLS forum and by Mishamax.
+ #878, #1019.
+ * Fix variable used before assignment compilation warnings with IAR
+ toolchain. Found by gkerrien38.
+ * Fix unchecked return codes from AES, DES and 3DES functions in
+ pem_aes_decrypt(), pem_des_decrypt() and pem_des3_decrypt() respectively.
+ If a call to one of the functions of the cryptographic primitive modules
+ failed, the error may not be noticed by the function
+ mbedtls_pem_read_buffer() causing it to return invalid values. Found by
+ Guido Vranken. #756
+ * Include configuration file in md.h, to fix compilation warnings.
+ Reported by aaronmdjones in #1001
+ * Correct extraction of signature-type from PK instance in X.509 CRT and CSR
+ writing routines that prevented these functions to work with alternative
+ RSA implementations. Raised by J.B. in the Mbed TLS forum. Fixes #1011.
+ * Don't print X.509 version tag for v1 CRT's, and omit extensions for
+ non-v3 CRT's.
+ * Fix bugs in RSA test suite under MBEDTLS_NO_PLATFORM_ENTROPY. #1023 #1024
+ * Fix net_would_block() to avoid modification by errno through fcntl() call.
+ Found by nkolban. Fixes #845.
+ * Fix handling of handshake messages in mbedtls_ssl_read() in case
+ MBEDTLS_SSL_RENEGOTIATION is disabled. Found by erja-gp.
+ * Add a check for invalid private parameters in mbedtls_ecdsa_sign().
+ Reported by Yolan Romailler.
+ * Fix word size check in in pk.c to not depend on MBEDTLS_HAVE_INT64.
+ * Fix incorrect unit in benchmark output. #850
+ * Add size-checks for record and handshake message content, securing
+ fragile yet non-exploitable code-paths.
+ * Fix crash when calling mbedtls_ssl_cache_free() twice. Found by
+ MilenkoMitrovic, #1104
+ * Fix mbedtls_timing_alarm(0) on Unix and MinGW.
+ * Fix use of uninitialized memory in mbedtls_timing_get_timer() when reset=1.
+ * Fix possible memory leaks in mbedtls_gcm_self_test().
+ * Added missing return code checks in mbedtls_aes_self_test().
+ * Fix issues in RSA key generation program programs/x509/rsa_genkey and the
+ RSA test suite where the failure of CTR DRBG initialization lead to
+ freeing an RSA context and several MPI's without proper initialization
+ beforehand.
+ * Fix error message in programs/pkey/gen_key.c. Found and fixed by Chris Xue.
+ * Fix programs/pkey/dh_server.c so that it actually works with dh_client.c.
+ Found and fixed by Martijn de Milliano.
+ * Fix an issue in the cipher decryption with the mode
+ MBEDTLS_PADDING_ONE_AND_ZEROS that sometimes accepted invalid padding.
+ Note, this padding mode is not used by the TLS protocol. Found and fixed by
+ Micha Kraus.
+ * Fix the entropy.c module to not call mbedtls_sha256_starts() or
+ mbedtls_sha512_starts() in the mbedtls_entropy_init() function.
+ * Fix the entropy.c module to ensure that mbedtls_sha256_init() or
+ mbedtls_sha512_init() is called before operating on the relevant context
+ structure. Do not assume that zeroizing a context is a correct way to
+ reset it. Found independently by ccli8 on Github.
+ * In mbedtls_entropy_free(), properly free the message digest context.
+ * Fix status handshake status message in programs/ssl/dtls_client.c. Found
+ and fixed by muddog.
+
+Changes
+ * Extend cert_write example program by options to set the certificate version
+ and the message digest. Further, allow enabling/disabling of authority
+ identifier, subject identifier and basic constraints extensions.
+ * Only check for necessary RSA structure fields in `mbedtls_rsa_private`. In
+ particular, don't require P,Q if neither CRT nor blinding are
+ used. Reported and fix proposed independently by satur9nine and sliai
+ on GitHub.
+ * Only run AES-192 self-test if AES-192 is available. Fixes #963.
+ * Tighten the RSA PKCS#1 v1.5 signature verification code and remove the
+ undeclared dependency of the RSA module on the ASN.1 module.
+ * Update all internal usage of deprecated message digest functions to the
+ new ones with return codes. In particular, this modifies the
+ mbedtls_md_info_t structure. Propagate errors from these functions
+ everywhere except some locations in the ssl_tls.c module.
+ * Improve CTR_DRBG error handling by propagating underlying AES errors.
+ * Add MBEDTLS_ERR_XXX_HW_ACCEL_FAILED error codes for all cryptography
+ modules where the software implementation can be replaced by a hardware
+ implementation.
+ * Add explicit warnings for the use of MD2, MD4, MD5, SHA-1, DES and ARC4
+ throughout the library.
+
+= mbed TLS 2.6.0 branch released 2017-08-10
+
+Security
+ * Fix authentication bypass in SSL/TLS: when authmode is set to optional,
+ mbedtls_ssl_get_verify_result() would incorrectly return 0 when the peer's
+ X.509 certificate chain had more than MBEDTLS_X509_MAX_INTERMEDIATE_CA
+ (default: 8) intermediates, even when it was not trusted. This could be
+ triggered remotely from either side. (With authmode set to 'required'
+ (the default), the handshake was correctly aborted).
+ * Reliably wipe sensitive data after use in the AES example applications
+ programs/aes/aescrypt2 and programs/aes/crypt_and_hash.
+ Found by Laurent Simon.
+
+Features
+ * Add the functions mbedtls_platform_setup() and mbedtls_platform_teardown()
+ and the context struct mbedtls_platform_context to perform
+ platform-specific setup and teardown operations. The macro
+ MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT allows the functions to be overridden
+ by the user in a platform_alt.h file. These new functions are required in
+ some embedded environments to provide a means of initialising underlying
+ cryptographic acceleration hardware.
+
+API Changes
+ * Reverted API/ABI breaking changes introduced in mbed TLS 2.5.1, to make the
+ API consistent with mbed TLS 2.5.0. Specifically removed the inline
+ qualifier from the functions mbedtls_aes_decrypt, mbedtls_aes_encrypt,
+ mbedtls_ssl_ciphersuite_uses_ec and mbedtls_ssl_ciphersuite_uses_psk. Found
+ by James Cowgill. #978
+ * Certificate verification functions now set flags to -1 in case the full
+ chain was not verified due to an internal error (including in the verify
+ callback) or chain length limitations.
+ * With authmode set to optional, the TLS handshake is now aborted if the
+ verification of the peer's certificate failed due to an overlong chain or
+ a fatal error in the verify callback.
+
+Bugfix
+ * Add a check if iv_len is zero in GCM, and return an error if it is zero.
+ Reported by roberto. #716
+ * Replace preprocessor condition from #if defined(MBEDTLS_THREADING_PTHREAD)
+ to #if defined(MBEDTLS_THREADING_C) as the library cannot assume they will
+ always be implemented by pthread support. #696
+ * Fix a resource leak on Windows platforms in mbedtls_x509_crt_parse_path(),
+ in the case of an error. Found by redplait. #590
+ * Add MBEDTLS_MPI_CHK to check for error value of mbedtls_mpi_fill_random.
+ Reported and fix suggested by guidovranken. #740
+ * Fix conditional preprocessor directives in bignum.h to enable 64-bit
+ compilation when using ARM Compiler 6.
+ * Fix a potential integer overflow in the version verification for DER
+ encoded X.509 CRLs. The overflow could enable maliciously constructed CRLs
+ to bypass the version verification check. Found by Peng Li/Yueh-Hsun Lin,
+ KNOX Security, Samsung Research America
+ * Fix potential integer overflow in the version verification for DER
+ encoded X.509 CSRs. The overflow could enable maliciously constructed CSRs
+ to bypass the version verification check. Found by Peng Li/Yueh-Hsun Lin,
+ KNOX Security, Samsung Research America
+ * Fix a potential integer overflow in the version verification for DER
+ encoded X.509 certificates. The overflow could enable maliciously
+ constructed certificates to bypass the certificate verification check.
+ * Fix a call to the libc function time() to call the platform abstraction
+ function mbedtls_time() instead. Found by wairua. #666
+ * Avoid shadowing of time and index functions through mbed TLS function
+ arguments. Found by inestlerode. #557.
+
+Changes
+ * Added config.h option MBEDTLS_NO_UDBL_DIVISION, to prevent the use of
+ 64-bit division. This is useful on embedded platforms where 64-bit division
+ created a dependency on external libraries. #708
+ * Removed mutexes from ECP hardware accelerator code. Now all hardware
+ accelerator code in the library leaves concurrency handling to the
+ platform. Reported by Steven Cooreman. #863
+ * Define the macro MBEDTLS_AES_ROM_TABLES in the configuration file
+ config-no-entropy.h to reduce the RAM footprint.
+ * Added a test script that can be hooked into git that verifies commits
+ before they are pushed.
+ * Improve documentation of PKCS1 decryption functions.
+
+= mbed TLS 2.5.1 released 2017-06-21
+
+Security
+ * Fixed unlimited overread of heap-based buffer in mbedtls_ssl_read().
+ The issue could only happen client-side with renegotiation enabled.
+ Could result in DoS (application crash) or information leak
+ (if the application layer sent data read from mbedtls_ssl_read()
+ back to the server or to a third party). Can be triggered remotely.
+ * Removed SHA-1 and RIPEMD-160 from the default hash algorithms for
+ certificate verification. SHA-1 can be turned back on with a compile-time
+ option if needed.
+ * Fixed offset in FALLBACK_SCSV parsing that caused TLS server to fail to
+ detect it sometimes. Reported by Hugo Leisink. #810
+ * Tighten parsing of RSA PKCS#1 v1.5 signatures, to avoid a
+ potential Bleichenbacher/BERserk-style attack.
+
+Bugfix
+ * Remove size zero arrays from ECJPAKE test suite. Size zero arrays are not
+ valid C and they prevented the test from compiling in Visual Studio 2015
+ and with GCC using the -Wpedantic compilation option.
+ * Fix insufficient support for signature-hash-algorithm extension,
+ resulting in compatibility problems with Chrome. Found by hfloyrd. #823
+ * Fix behaviour that hid the original cause of fatal alerts in some cases
+ when sending the alert failed. The fix makes sure not to hide the error
+ that triggered the alert.
+ * Fix SSLv3 renegotiation behaviour and stop processing data received from
+ peer after sending a fatal alert to refuse a renegotiation attempt.
+ Previous behaviour was to keep processing data even after the alert has
+ been sent.
+ * Accept empty trusted CA chain in authentication mode
+ MBEDTLS_SSL_VERIFY_OPTIONAL.
+ Found by jethrogb. #864
+ * Fix implementation of mbedtls_ssl_parse_certificate() to not annihilate
+ fatal errors in authentication mode MBEDTLS_SSL_VERIFY_OPTIONAL and to
+ reflect bad EC curves within verification result.
+ * Fix bug that caused the modular inversion function to accept the invalid
+ modulus 1 and therefore to hang. Found by blaufish. #641.
+ * Fix incorrect sign computation in modular exponentiation when the base is
+ a negative MPI. Previously the result was always negative. Found by Guido
+ Vranken.
+ * Fix a numerical underflow leading to stack overflow in mpi_read_file()
+ that was triggered uppon reading an empty line. Found by Guido Vranken.
+
+Changes
+ * Send fatal alerts in more cases. The previous behaviour was to skip
+ sending the fatal alert and just drop the connection.
+ * Clarify ECDSA documentation and improve the sample code to avoid
+ misunderstanding and potentially dangerous use of the API. Pointed out
+ by Jean-Philippe Aumasson.
+
+= mbed TLS 2.5.0 branch released 2017-05-17
+
+Security
+ * Wipe stack buffers in RSA private key operations
+ (rsa_rsaes_pkcs1_v15_decrypt(), rsa_rsaes_oaep_decrypt). Found by Laurent
+ Simon.
+ * Add exponent blinding to RSA private operations as a countermeasure
+ against side-channel attacks like the cache attack described in
+ https://arxiv.org/abs/1702.08719v2.
+ Found and fix proposed by Michael Schwarz, Samuel Weiser, Daniel Gruss,
+ Clémentine Maurice and Stefan Mangard.
+
+Features
+ * Add hardware acceleration support for the Elliptic Curve Point module.
+ This involved exposing parts of the internal interface to enable
+ replacing the core functions and adding and alternative, module level
+ replacement support for enabling the extension of the interface.
+ * Add a new configuration option to 'mbedtls_ssl_config' to enable
+ suppressing the CA list in Certificate Request messages. The default
+ behaviour has not changed, namely every configured CAs name is included.
+
+API Changes
+ * The following functions in the AES module have been deprecated and replaced
+ by the functions shown below. The new functions change the return type from
+ void to int to allow returning error codes when using MBEDTLS_AES_ALT,
+ MBEDTLS_AES_DECRYPT_ALT or MBEDTLS_AES_ENCRYPT_ALT.
+ mbedtls_aes_decrypt() -> mbedtls_internal_aes_decrypt()
+ mbedtls_aes_encrypt() -> mbedtls_internal_aes_encrypt()
+
+Bugfix
+ * Remove macros from compat-1.3.h that correspond to deleted items from most
+ recent versions of the library. Found by Kyle Keen.
+ * Fixed issue in the Threading module that prevented mutexes from
+ initialising. Found by sznaider. #667 #843
+ * Add checks in the PK module for the RSA functions on 64-bit systems.
+ The PK and RSA modules use different types for passing hash length and
+ without these checks the type cast could lead to data loss. Found by Guido
+ Vranken.
+
+= mbed TLS 2.4.2 branch released 2017-03-08
+
+Security
+ * Add checks to prevent signature forgeries for very large messages while
+ using RSA through the PK module in 64-bit systems. The issue was caused by
+ some data loss when casting a size_t to an unsigned int value in the
+ functions rsa_verify_wrap(), rsa_sign_wrap(), rsa_alt_sign_wrap() and
+ mbedtls_pk_sign(). Found by Jean-Philippe Aumasson.
+ * Fixed potential livelock during the parsing of a CRL in PEM format in
+ mbedtls_x509_crl_parse(). A string containing a CRL followed by trailing
+ characters after the footer could result in the execution of an infinite
+ loop. The issue can be triggered remotely. Found by Greg Zaverucha,
+ Microsoft.
+ * Removed MD5 from the allowed hash algorithms for CertificateRequest and
+ CertificateVerify messages, to prevent SLOTH attacks against TLS 1.2.
+ Introduced by interoperability fix for #513.
+ * Fixed a bug that caused freeing a buffer that was allocated on the stack,
+ when verifying the validity of a key on secp224k1. This could be
+ triggered remotely for example with a maliciously constructed certificate
+ and potentially could lead to remote code execution on some platforms.
+ Reported independently by rongsaws and Aleksandar Nikolic, Cisco Talos
+ team. #569 CVE-2017-2784
+
+Bugfix
+ * Fix output certificate verification flags set by x509_crt_verify_top() when
+ traversing a chain of trusted CA. The issue would cause both flags,
+ MBEDTLS_X509_BADCERT_NOT_TRUSTED and MBEDTLS_X509_BADCERT_EXPIRED, to be
+ set when the verification conditions are not met regardless of the cause.
+ Found by Harm Verhagen and inestlerode. #665 #561
+ * Fix the redefinition of macro ssl_set_bio to an undefined symbol
+ mbedtls_ssl_set_bio_timeout in compat-1.3.h, by removing it.
+ Found by omlib-lin. #673
+ * Fix unused variable/function compilation warnings in pem.c, x509_crt.c and
+ x509_csr.c that are reported when building mbed TLS with a config.h that
+ does not define MBEDTLS_PEM_PARSE_C. Found by omnium21. #562
+ * Fix incorrect renegotiation condition in ssl_check_ctr_renegotiate() that
+ would compare 64 bits of the record counter instead of 48 bits as indicated
+ in RFC 6347 Section 4.3.1. This could cause the execution of the
+ renegotiation routines at unexpected times when the protocol is DTLS. Found
+ by wariua. #687
+ * Fixed multiple buffer overreads in mbedtls_pem_read_buffer() when parsing
+ the input string in PEM format to extract the different components. Found
+ by Eyal Itkin.
+ * Fixed potential arithmetic overflow in mbedtls_ctr_drbg_reseed() that could
+ cause buffer bound checks to be bypassed. Found by Eyal Itkin.
+ * Fixed potential arithmetic overflows in mbedtls_cipher_update() that could
+ cause buffer bound checks to be bypassed. Found by Eyal Itkin.
+ * Fixed potential arithmetic overflow in mbedtls_md2_update() that could
+ cause buffer bound checks to be bypassed. Found by Eyal Itkin.
+ * Fixed potential arithmetic overflow in mbedtls_base64_decode() that could
+ cause buffer bound checks to be bypassed. Found by Eyal Itkin.
+ * Fixed heap overreads in mbedtls_x509_get_time(). Found by Peng
+ Li/Yueh-Hsun Lin, KNOX Security, Samsung Research America.
+ * Fix potential memory leak in mbedtls_x509_crl_parse(). The leak was caused
+ by missing calls to mbedtls_pem_free() in cases when a
+ MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT error was encountered. Found and
+ fix proposed by Guido Vranken. #722
+ * Fixed the templates used to generate project and solution files for Visual
+ Studio 2015 as well as the files themselves, to remove a build warning
+ generated in Visual Studio 2015. Reported by Steve Valliere. #742
+ * Fix a resource leak in ssl_cookie, when using MBEDTLS_THREADING_C.
+ Raised and fix suggested by Alan Gillingham in the mbed TLS forum. #771
+ * Fix 1 byte buffer overflow in mbedtls_mpi_write_string() when the MPI
+ number to write in hexadecimal is negative and requires an odd number of
+ digits. Found and fixed by Guido Vranken.
+ * Fix unlisted DES configuration dependency in some pkparse test cases. Found
+ by inestlerode. #555
+
+= mbed TLS 2.4.1 branch released 2016-12-13
+
+Changes
+ * Update to CMAC test data, taken from - NIST Special Publication 800-38B -
+ Recommendation for Block Cipher Modes of Operation: The CMAC Mode for
+ Authentication – October 2016
+
= mbed TLS 2.4.0 branch released 2016-10-17
Security
* Fix potential integer overflow to buffer overflow in
mbedtls_rsa_rsaes_pkcs1_v15_encrypt and mbedtls_rsa_rsaes_oaep_encrypt
(not triggerable remotely in (D)TLS).
- * Fix a potential integer underflow to buffer overread in
+ * Fix a potential integer underflow to buffer overread in
mbedtls_rsa_rsaes_oaep_decrypt. It is not triggerable remotely in
SSL/TLS.
* Fix an issue that caused valid certificates to be rejected whenever an
expired or not yet valid certificate was parsed before a valid certificate
in the trusted certificate list.
- * Fix bug in mbedtls_x509_crt_parse that caused trailing extra data in the
+ * Fix bug in mbedtls_x509_crt_parse that caused trailing extra data in the
buffer after DER certificates to be included in the raw representation.
* Fix issue that caused a hang when generating RSA keys of odd bitlength
* Fix bug in mbedtls_rsa_rsaes_pkcs1_v15_encrypt that made null pointer
Changes
* Allow enabling of dummy error_strerror() to support some use-cases
* Debug messages about padding errors during SSL message decryption are
- disabled by default and can be enabled with POLARSSL_SSL_DEBUG_ALL
+ disabled by default and can be enabled with POLARSSL_SSL_DEBUG_ALL
* Sending of security-relevant alert messages that do not break
interoperability can be switched on/off with the flag
POLARSSL_SSL_ALL_ALERT_MESSAGES
Changes
* Added p_hw_data to ssl_context for context specific hardware acceleration
data
- * During verify trust-CA is only checked for expiration and CRL presence
+ * During verify trust-CA is only checked for expiration and CRL presence
Bugfixes
* Fixed client authentication compatibility
with random data (Fixed ticket #10)
Changes
- * Debug print of MPI now removes leading zero octets and
+ * Debug print of MPI now removes leading zero octets and
displays actual bit size of the value.
- * x509parse_key() (and as a consequence x509parse_keyfile())
+ * x509parse_key() (and as a consequence x509parse_keyfile())
does not zeroize memory in advance anymore. Use rsa_init()
before parsing a key or keyfile!
printing of X509 CRLs from file
Changes
- * Parsing of PEM files moved to separate module (Fixes
+ * Parsing of PEM files moved to separate module (Fixes
ticket #13). Also possible to remove PEM support for
systems only using DER encoding
* Fixed HMAC-MD2 by modifying md2_starts(), so that the
required HMAC ipad and opad variables are not cleared.
(found by code coverage tests)
- * Prevented use of long long in bignum if
+ * Prevented use of long long in bignum if
POLARSSL_HAVE_LONGLONG not defined (found by Giles
Bathgate).
* Fixed incorrect handling of negative strings in
* Made definition of net_htons() endian-clean for big endian
systems (Found by Gernot).
* Undefining POLARSSL_HAVE_ASM now also handles prevents asm in
- padlock and timing code.
+ padlock and timing code.
* Fixed an off-by-one buffer allocation in ssl_set_hostname()
responsible for crashes and unwanted behaviour.
* Added support for Certificate Revocation List (CRL) parsing.
who maintains the Debian package :-)
= Version 0.1 released on 2006-11-01
-
apidoc:
mkdir -p apidoc
- doxygen doxygen/mbedtls.doxyfile
+ cd doxygen && doxygen mbedtls.doxyfile
apidoc_clean:
rm -rf apidoc
-README for mbed TLS
+README for Mbed TLS
===================
Configuration
-------------
-mbed TLS should build out of the box on most systems. Some platform specific options are available in the fully documented configuration file `include/mbedtls/config.h`, which is also the place where features can be selected. This file can be edited manually, or in a more programmatic way using the Perl script `scripts/config.pl` (use `--help` for usage instructions).
+Mbed TLS should build out of the box on most systems. Some platform specific options are available in the fully documented configuration file `include/mbedtls/config.h`, which is also the place where features can be selected. This file can be edited manually, or in a more programmatic way using the Perl script `scripts/config.pl` (use `--help` for usage instructions).
Compiler options can be set using conventional environment variables such as `CC` and `CFLAGS` when using the Make and CMake build system (see below).
Compiling
---------
-There are currently four active build systems used within mbed TLS releases:
+There are currently four active build systems used within Mbed TLS releases:
- yotta
-- Make
+- GNU Make
- CMake
-- Microsoft Visual Studio (Visual Studio 6 and Visual Studio 2010)
+- Microsoft Visual Studio (Microsoft Visual Studio 2010 or later)
-The main systems used for development are CMake and Make. Those systems are always complete and up-to-date. The others should reflect all changes present in the CMake and Make build system, although features may not be ported there automatically.
+The main systems used for development are CMake and GNU Make. Those systems are always complete and up-to-date. The others should reflect all changes present in the CMake and Make build system, although features may not be ported there automatically.
Yotta, as a build system, is slightly different from the other build systems:
- it provides a minimalistic configuration file by default
-- depending on the yotta target, features of mbed OS may be used in examples and tests
+- depending on the yotta target, features of Mbed OS may be used in examples and tests
The Make and CMake build systems create three libraries: libmbedcrypto, libmbedx509, and libmbedtls. Note that libmbedtls depends on libmbedx509 and libmbedcrypto, and libmbedx509 depends on libmbedcrypto. As a result, some linkers will expect flags to be in a specific order, for example the GNU linker wants `-lmbedtls -lmbedx509 -lmbedcrypto`. Also, when loading shared libraries using dlopen(), you'll need to load libmbedcrypto first, then libmbedx509, before you can load libmbedtls.
### Yotta
-[yotta](http://yottabuild.org) is a package manager and build system developed by mbed, and is the build system of mbed OS 16.03. To install it on your platform, please follow the yotta [installation instructions](http://docs.yottabuild.org/#installing).
+[yotta](http://yottabuild.org) is a package manager and build system developed by Mbed, and is the build system of Mbed OS 16.03. To install it on your platform, please follow the yotta [installation instructions](http://docs.yottabuild.org/#installing).
-Once yotta is installed, you can use it to download the latest version of mbed TLS from the yotta registry with:
+Once yotta is installed, you can use it to download the latest version of Mbed TLS from the yotta registry with:
yotta install mbedtls
yotta build
-If, on the other hand, you already have a copy of mbed TLS from a source other than the yotta registry, for example from cloning our GitHub repository, or from downloading a tarball of the standalone edition, then you'll first need to generate the yotta module by running:
+If, on the other hand, you already have a copy of Mbed TLS from a source other than the yotta registry, for example from cloning our GitHub repository, or from downloading a tarball of the standalone edition, then you'll first need to generate the yotta module by running:
yotta/create-module.sh
-This should be executed from the root mbed TLS project directory. This will create the yotta module in the `yotta/module` directory within it. You can then change to that directory and build as usual:
+This should be executed from the root Mbed TLS project directory. This will create the yotta module in the `yotta/module` directory within it. You can then change to that directory and build as usual:
cd yotta/module
yotta build
In any case, you'll probably want to set the yotta target before building unless it has already been set globally. For more information on using yotta, please consult the [yotta documentation](http://docs.yottabuild.org/).
-For more details on the yotta/mbed OS edition of mbed TLS, including example programs, please consult the [Readme at the root of the yotta module](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/README.md).
+For more details on the yotta/Mbed OS edition of Mbed TLS, including example programs, please consult the [Readme at the root of the yotta module](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/README.md).
### Make
-We intentionally only use the minimum of `Make` functionality, as a lot of `Make` features are not supported on all different implementations of Make or on different platforms. As such, the Makefiles sometimes require some manual changes or export statements in order to work for your platform.
+We require GNU Make. To build the library and the sample programs, GNU Make and a C compiler are sufficient. Some of the more advanced build targets require some Unix/Linux tools.
-In order to build from the source code using Make, just enter at the command line:
+We intentionally only use a minimum of functionality in the makefiles in order to keep them as simple and independent of different toolchains as possible, to allow users to more easily move between different platforms. Users who need more features are recommended to use CMake.
+
+In order to build from the source code using GNU Make, just enter at the command line:
make
In order to build for a Windows platform, you should use `WINDOWS_BUILD=1` if the target is Windows but the build environment is Unix-like (for instance when cross-compiling, or compiling from an MSYS shell), and `WINDOWS=1` if the build environment is a Windows shell (for instance using mingw32-make) (in that case some targets will not be available).
-Setting the variable `SHARED` in your environment will build shared libraries in addition to the static libraries. Setting `DEBUG` gives you a debug build. You can override `CFLAGS` and `LDFLAGS` by setting them in your environment or on the make command line; if you do so, essential parts such as `-I` will still be preserved. Warning options may be overridden separately using `WARNING_CFLAGS`.
+Setting the variable `SHARED` in your environment will build shared libraries in addition to the static libraries. Setting `DEBUG` gives you a debug build. You can override `CFLAGS` and `LDFLAGS` by setting them in your environment or on the make command line; compiler warning options may be overridden separately using `WARNING_CFLAGS`. Some directory-specific options (for example, `-I` directives) are still preserved.
+
+Please note that setting `CFLAGS` overrides its default value of `-O2` and setting `WARNING_CFLAGS` overrides its default value (starting with `-Wall -W`), so it you just want to add some warning options to the default ones, you can do so by setting `CFLAGS=-O2 -Werror` for example. Setting `WARNING_CFLAGS` is useful when you want to get rid of its default content (for example because your compiler doesn't accept `-Wall` as an option). Directory-specific options cannot be overriden from the command line.
-Depending on your platform, you might run into some issues. Please check the Makefiles in `library/`, `programs/` and `tests/` for options to manually add or remove for specific platforms. You can also check [the mbed TLS Knowledge Base](https://tls.mbed.org/kb) for articles on your platform or issue.
+Depending on your platform, you might run into some issues. Please check the Makefiles in `library/`, `programs/` and `tests/` for options to manually add or remove for specific platforms. You can also check [the Mbed TLS Knowledge Base](https://tls.mbed.org/kb) for articles on your platform or issue.
-In case you find that you need to do something else as well, please let us know what, so we can add it to the [mbed TLS knowledge base](https://tls.mbed.org/kb).
+In case you find that you need to do something else as well, please let us know what, so we can add it to the [Mbed TLS knowledge base](https://tls.mbed.org/kb).
### CMake
-In order to build the source using CMake, just enter at the command line:
+In order to build the source using CMake in a separate directory (recommended), just enter at the command line:
- cmake .
+ mkdir /path/to/build_dir && cd /path/to/build_dir
+ cmake /path/to/mbedtls_source
make
In order to run the tests, enter:
The test suites need Perl to be built. If you don't have Perl installed, you'll want to disable the test suites with:
- cmake -DENABLE_TESTING=Off .
+ cmake -DENABLE_TESTING=Off /path/to/mbedtls_source
If you disabled the test suites, but kept the programs enabled, you can still run a much smaller set of tests with:
To configure CMake for building shared libraries, use:
- cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On .
+ cmake -DUSE_SHARED_MBEDTLS_LIBRARY=On /path/to/mbedtls_source
There are many different build modes available within the CMake buildsystem. Most of them are available for gcc and clang, though some are compiler-specific:
-- Release. This generates the default code without any unnecessary information in the binary files.
-- Debug. This generates debug information and disables optimization of the code.
-- Coverage. This generates code coverage information in addition to debug information.
-- ASan. This instruments the code with AddressSanitizer to check for memory errors. (This includes LeakSanitizer, with recent version of gcc and clang.) (With recent version of clang, this mode also instruments the code with UndefinedSanitizer to check for undefined behaviour.)
-- ASanDbg. Same as ASan but slower, with debug information and better stack traces.
-- MemSan. This instruments the code with MemorySanitizer to check for uninitialised memory reads. Experimental, needs recent clang on Linux/x86\_64.
-- MemSanDbg. Same as MemSan but slower, with debug information, better stack traces and origin tracking.
-- Check. This activates the compiler warnings that depend on optimization and treats all warnings as errors.
+- `Release`. This generates the default code without any unnecessary information in the binary files.
+- `Debug`. This generates debug information and disables optimization of the code.
+- `Coverage`. This generates code coverage information in addition to debug information.
+- `ASan`. This instruments the code with AddressSanitizer to check for memory errors. (This includes LeakSanitizer, with recent version of gcc and clang.) (With recent version of clang, this mode also instruments the code with UndefinedSanitizer to check for undefined behaviour.)
+- `ASanDbg`. Same as ASan but slower, with debug information and better stack traces.
+- `MemSan`. This instruments the code with MemorySanitizer to check for uninitialised memory reads. Experimental, needs recent clang on Linux/x86\_64.
+- `MemSanDbg`. Same as MemSan but slower, with debug information, better stack traces and origin tracking.
+- `Check`. This activates the compiler warnings that depend on optimization and treats all warnings as errors.
Switching build modes in CMake is simple. For debug mode, enter at the command line:
- cmake -D CMAKE_BUILD_TYPE=Debug .
+ cmake -D CMAKE_BUILD_TYPE=Debug /path/to/mbedtls_source
To list other available CMake options, use:
cmake -LH
-Note that, with CMake, if you want to change the compiler or its options after you already ran CMake, you need to clear its cache first, e.g. (using GNU find):
+Note that, with CMake, you can't adjust the compiler or its flags after the
+initial invocation of cmake. This means that `CC=your_cc make` and `make
+CC=your_cc` will *not* work (similarly with `CFLAGS` and other variables).
+These variables need to be adjusted when invoking cmake for the first time,
+for example:
+
+ CC=your_cc cmake /path/to/mbedtls_source
+
+If you already invoked cmake and want to change those settings, you need to
+remove the build directory and create it again.
+
+Note that it is possible to build in-place; this will however overwrite the
+provided Makefiles (see `scripts/tmp_ignore_makefiles.sh` if you want to
+prevent `git status` from showing them as modified). In order to do so, from
+the Mbed TLS source directory, use:
+
+ cmake .
+ make
+
+If you want to change `CC` or `CFLAGS` afterwards, you will need to remove the
+CMake cache. This can be done with the following command using GNU find:
find . -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} +
- CC=gcc CFLAGS='-fstack-protector-strong -Wa,--noexecstack' cmake .
+
+You can now make the desired change:
+
+ CC=your_cc cmake .
+ make
+
+Regarding variables, also note that if you set CFLAGS when invoking cmake,
+your value of CFLAGS doesn't override the content provided by cmake (depending
+on the build mode as seen above), it's merely prepended to it.
### Microsoft Visual Studio
Tests
-----
-mbed TLS includes an elaborate test suite in `tests/` that initially requires Perl to generate the tests files (e.g. `test\_suite\_mpi.c`). These files are generated from a `function file` (e.g. `suites/test\_suite\_mpi.function`) and a `data file` (e.g. `suites/test\_suite\_mpi.data`). The `function file` contains the test functions. The `data file` contains the test cases, specified as parameters that will be passed to the test function.
+Mbed TLS includes an elaborate test suite in `tests/` that initially requires Perl to generate the tests files (e.g. `test\_suite\_mpi.c`). These files are generated from a `function file` (e.g. `suites/test\_suite\_mpi.function`) and a `data file` (e.g. `suites/test\_suite\_mpi.data`). The `function file` contains the test functions. The `data file` contains the test cases, specified as parameters that will be passed to the test function.
For machines with a Unix shell and OpenSSL (and optionally GnuTLS) installed, additional test scripts are available:
We provide some non-standard configurations focused on specific use cases in the `configs/` directory. You can read more about those in `configs/README.txt`
+Porting Mbed TLS
+----------------
+
+Mbed TLS can be ported to many different architectures, OS's and platforms. Before starting a port, you may find the following knowledge base articles useful:
+
+- [Porting Mbed TLS to a new environment or OS](https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS)
+- [What external dependencies does Mbed TLS rely on?](https://tls.mbed.org/kb/development/what-external-dependencies-does-mbedtls-rely-on)
+- [How do I configure Mbed TLS](https://tls.mbed.org/kb/compiling-and-building/how-do-i-configure-mbedtls)
+
Contributing
------------
- We would ask that contributions conform to [our coding standards](https://tls.mbed.org/kb/development/mbedtls-coding-standards), and that contributions should be fully tested before submission.
- As with any open source project, contributions will be reviewed by the project team and community and may need some modifications to be accepted.
-To accept the Contributor’s Licence Agreement (CLA), individual contributors can do this by creating an mbed account and [accepting the online agreement here with a click through](https://developer.mbed.org/contributor_agreement/). Alternatively, for contributions from corporations, or those that do not wish to create an mbed account, a slightly different agreeement can be found [here](https://www.mbed.com/en/about-mbed/contributor-license-agreements/). This agreement should be signed and returned to ARM as described in the instructions given.
+To accept the Contributor’s Licence Agreement (CLA), individual contributors can do this by creating an Mbed account and [accepting the online agreement here with a click through](https://os.mbed.com/contributor_agreement/). Alternatively, for contributions from corporations, or those that do not wish to create an Mbed account, a slightly different agreement can be found [here](https://www.mbed.com/en/about-mbed/contributor-license-agreements/). This agreement should be signed and returned to Arm as described in the instructions given.
### Making a Contribution
1. [Check for open issues](https://github.com/ARMmbed/mbedtls/issues) or [start a discussion](https://tls.mbed.org/discussions) around a feature idea or a bug.
-2. Fork the [mbed TLS repository on GitHub](https://github.com/ARMmbed/mbedtls) to start making your changes. As a general rule, you should use the "development" branch as a basis.
+2. Fork the [Mbed TLS repository on GitHub](https://github.com/ARMmbed/mbedtls) to start making your changes. As a general rule, you should use the "development" branch as a basis.
3. Write a test which shows that the bug was fixed or that the feature works as expected.
4. Send a pull request and bug us until it gets merged and published. Contributions may need some modifications, so work with us to get your change accepted. We will include your name in the ChangeLog :)
them, you can pick one of the following methods:
1. Replace the default file include/mbedtls/config.h with the chosen one.
- (Depending on your compiler, you may need to ajust the line with
+ (Depending on your compiler, you may need to adjust the line with
#include "mbedtls/check_config.h" then.)
2. Define MBEDTLS_CONFIG_FILE and adjust the include path accordingly.
-/*
- * Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites
+/**
+ * \file config-ccm-psk-tls1_2.h
*
+ * \brief Minimal configuration for TLS 1.2 with PSK and AES-CCM ciphersuites
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
-/*
- * Minimal configuration for TLS 1.1 (RFC 4346)
+/**
+ * \file config-mini-tls1_1.h
*
+ * \brief Minimal configuration for TLS 1.1 (RFC 4346)
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
/**
- * Minimal configuration of features that do not require an entropy source
+ * \file config-no-entropy.h
*
+ * \brief Minimal configuration of features that do not require an entropy source
+ */
+/*
* Copyright (C) 2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#define MBEDTLS_X509_CRT_PARSE_C
#define MBEDTLS_X509_CRL_PARSE_C
+/* Miscellaneous options */
+#define MBEDTLS_AES_ROM_TABLES
+
#include "check_config.h"
#endif /* MBEDTLS_CONFIG_H */
+++ /dev/null
-/*
- * Reduced configuration used by Picocoin.
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * This file is part of mbed TLS (https://tls.mbed.org)
- */
-/*
- * Reduced configuration used by Picocoin.
- *
- * See README.txt for usage instructions.
- *
- * Distinguishing features:
- * - no SSL/TLS;
- * - no X.509;
- * - ECDSA/PK and some other chosen crypto bits.
- */
-
-#ifndef MBEDTLS_CONFIG_H
-#define MBEDTLS_CONFIG_H
-
-/* System support */
-#define MBEDTLS_HAVE_ASM
-#define MBEDTLS_HAVE_TIME
-
-/* mbed TLS feature support */
-#define MBEDTLS_CIPHER_MODE_CBC
-#define MBEDTLS_CIPHER_PADDING_PKCS7
-#define MBEDTLS_ECP_DP_SECP256K1_ENABLED
-#define MBEDTLS_ECDSA_DETERMINISTIC
-#define MBEDTLS_PK_PARSE_EC_EXTENDED
-#define MBEDTLS_ERROR_STRERROR_DUMMY
-#define MBEDTLS_FS_IO
-
-/* mbed TLS modules */
-#define MBEDTLS_AESNI_C
-#define MBEDTLS_AES_C
-#define MBEDTLS_ASN1_PARSE_C
-#define MBEDTLS_ASN1_WRITE_C
-#define MBEDTLS_BASE64_C
-#define MBEDTLS_BIGNUM_C
-#define MBEDTLS_ECDSA_C
-#define MBEDTLS_ECP_C
-#define MBEDTLS_ENTROPY_C
-#define MBEDTLS_HMAC_DRBG_C
-#define MBEDTLS_MD_C
-#define MBEDTLS_OID_C
-#define MBEDTLS_PADLOCK_C
-#define MBEDTLS_PK_C
-#define MBEDTLS_PK_PARSE_C
-#define MBEDTLS_PK_WRITE_C
-#define MBEDTLS_RIPEMD160_C
-#define MBEDTLS_SHA1_C
-#define MBEDTLS_SHA256_C
-
-#include "mbedtls/check_config.h"
-
-#endif /* MBEDTLS_CONFIG_H */
-/*
- * Minimal configuration for TLS NSA Suite B Profile (RFC 6460)
+/**
+ * \file config-suite-b.h
*
+ * \brief Minimal configuration for TLS NSA Suite B Profile (RFC 6460)
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
-/*
- * Minimal configuration for using TLS as part of Thread
+/**
+ * \file config-thread.h
*
+ * \brief Minimal configuration for using TLS as part of Thread
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
/**
- * @file
- * Encryption/decryption module documentation file.
+ * \file doc_encdec.h
+ *
+ * \brief Encryption/decryption module documentation file.
+ */
+/*
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
/**
- * @file
- * Hashing module documentation file.
+ * \file doc_hashing.h
+ *
+ * \brief Hashing module documentation file.
+ */
+/*
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
/**
- * @file
- * Main page documentation file.
+ * \file doc_mainpage.h
+ *
+ * \brief Main page documentation file.
+ */
+/*
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
/**
- * @mainpage mbed TLS v2.4.0 source code documentation
+ * @mainpage mbed TLS v2.8.0 source code documentation
*
* This documentation describes the internal structure of mbed TLS. It was
* automatically generated from specially formatted comment blocks in
/**
- * @file
- * Random number generator (RNG) module documentation file.
+ * \file doc_rng.h
+ *
+ * \brief Random number generator (RNG) module documentation file.
+ */
+/*
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
/**
- * @file
- * SSL/TLS communication module documentation file.
+ * \file doc_ssltls.h
+ *
+ * \brief SSL/TLS communication module documentation file.
+ */
+/*
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
/**
- * @file
- * TCP/IP communication module documentation file.
+ * \file doc_tcpip.h
+ *
+ * \brief TCP/IP communication module documentation file.
+ */
+/*
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
/**
- * @file
- * X.509 module documentation file.
+ * \file doc_x509.h
+ *
+ * \brief X.509 module documentation file.
+ */
+/*
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
# identify the project. Note that if you do not use Doxywizard you need
# to put quotes around the project name if it contains spaces.
-PROJECT_NAME = "mbed TLS v2.4.0"
+PROJECT_NAME = "mbed TLS v2.8.0"
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
-OUTPUT_DIRECTORY = apidoc/
+OUTPUT_DIRECTORY = ../apidoc/
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
# comments will behave just like regular Qt-style comments
# (thus requiring an explicit @brief command for a brief description.)
-JAVADOC_AUTOBRIEF = YES
+JAVADOC_AUTOBRIEF = NO
# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
# interpret the first line (until the first dot) of a Qt-style
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = .
+INPUT = ..
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
# Note that relative paths are relative to the directory from which doxygen is
# run.
-EXCLUDE = configs yotta/module
+EXCLUDE = ../configs ../yotta/module
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
/**
* \file aes.h
*
- * \brief AES block cipher
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ * \brief The Advanced Encryption Standard (AES) specifies a FIPS-approved
+ * cryptographic algorithm that can be used to protect electronic
+ * data.
+ *
+ * The AES algorithm is a symmetric block cipher that can
+ * encrypt and decrypt information. For more information, see
+ * <em>FIPS Publication 197: Advanced Encryption Standard</em> and
+ * <em>ISO/IEC 18033-2:2006: Information technology -- Security
+ * techniques -- Encryption algorithms -- Part 2: Asymmetric
+ * ciphers</em>.
+ */
+/* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
+
#ifndef MBEDTLS_AES_H
#define MBEDTLS_AES_H
#include <stdint.h>
/* padlock.c and aesni.c rely on these values! */
-#define MBEDTLS_AES_ENCRYPT 1
-#define MBEDTLS_AES_DECRYPT 0
+#define MBEDTLS_AES_ENCRYPT 1 /**< AES encryption. */
+#define MBEDTLS_AES_DECRYPT 0 /**< AES decryption. */
+/* Error codes in range 0x0020-0x0022 */
#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */
#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */
+/* Error codes in range 0x0023-0x0025 */
+#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023 /**< Feature not available. For example, an unsupported AES key size. */
+#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025 /**< AES hardware accelerator failed. */
+
+#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
+ !defined(inline) && !defined(__cplusplus)
+#define inline __inline
+#endif
+
#if !defined(MBEDTLS_AES_ALT)
// Regular implementation
//
#endif
/**
- * \brief AES context structure
- *
- * \note buf is able to hold 32 extra bytes, which can be used:
- * - for alignment purposes if VIA padlock is used, and/or
- * - to simplify key expansion in the 256-bit case by
- * generating an extra round key
+ * \brief The AES context-type definition.
*/
typedef struct
{
- int nr; /*!< number of rounds */
- uint32_t *rk; /*!< AES round keys */
- uint32_t buf[68]; /*!< unaligned data */
+ int nr; /*!< The number of rounds. */
+ uint32_t *rk; /*!< AES round keys. */
+ uint32_t buf[68]; /*!< Unaligned data buffer. This buffer can
+ hold 32 extra Bytes, which can be used for
+ one of the following purposes:
+ <ul><li>Alignment if VIA padlock is
+ used.</li>
+ <li>Simplifying key expansion in the 256-bit
+ case by generating an extra round key.
+ </li></ul> */
}
mbedtls_aes_context;
/**
- * \brief Initialize AES context
+ * \brief This function initializes the specified AES context.
*
- * \param ctx AES context to be initialized
+ * It must be the first API called before using
+ * the context.
+ *
+ * \param ctx The AES context to initialize.
*/
void mbedtls_aes_init( mbedtls_aes_context *ctx );
/**
- * \brief Clear AES context
+ * \brief This function releases and clears the specified AES context.
*
- * \param ctx AES context to be cleared
+ * \param ctx The AES context to clear.
*/
void mbedtls_aes_free( mbedtls_aes_context *ctx );
/**
- * \brief AES key schedule (encryption)
+ * \brief This function sets the encryption key.
*
- * \param ctx AES context to be initialized
- * \param key encryption key
- * \param keybits must be 128, 192 or 256
+ * \param ctx The AES context to which the key should be bound.
+ * \param key The encryption key.
+ * \param keybits The size of data passed in bits. Valid options are:
+ * <ul><li>128 bits</li>
+ * <li>192 bits</li>
+ * <li>256 bits</li></ul>
*
- * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
+ * \return \c 0 on success or #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
+ * on failure.
*/
int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
unsigned int keybits );
/**
- * \brief AES key schedule (decryption)
+ * \brief This function sets the decryption key.
*
- * \param ctx AES context to be initialized
- * \param key decryption key
- * \param keybits must be 128, 192 or 256
+ * \param ctx The AES context to which the key should be bound.
+ * \param key The decryption key.
+ * \param keybits The size of data passed. Valid options are:
+ * <ul><li>128 bits</li>
+ * <li>192 bits</li>
+ * <li>256 bits</li></ul>
*
- * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
+ * \return \c 0 on success, or #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure.
*/
int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
unsigned int keybits );
/**
- * \brief AES-ECB block encryption/decryption
- *
- * \param ctx AES context
- * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
- * \param input 16-byte input block
- * \param output 16-byte output block
- *
- * \return 0 if successful
+ * \brief This function performs an AES single-block encryption or
+ * decryption operation.
+ *
+ * It performs the operation defined in the \p mode parameter
+ * (encrypt or decrypt), on the input data buffer defined in
+ * the \p input parameter.
+ *
+ * mbedtls_aes_init(), and either mbedtls_aes_setkey_enc() or
+ * mbedtls_aes_setkey_dec() must be called before the first
+ * call to this API with the same context.
+ *
+ * \param ctx The AES context to use for encryption or decryption.
+ * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
+ * #MBEDTLS_AES_DECRYPT.
+ * \param input The 16-Byte buffer holding the input data.
+ * \param output The 16-Byte buffer holding the output data.
+
+ * \return \c 0 on success.
*/
int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
int mode,
#if defined(MBEDTLS_CIPHER_MODE_CBC)
/**
- * \brief AES-CBC buffer encryption/decryption
- * Length should be a multiple of the block
- * size (16 bytes)
- *
- * \note Upon exit, the content of the IV is updated so that you can
- * call the function same function again on the following
- * block(s) of data and get the same result as if it was
- * encrypted in one call. This allows a "streaming" usage.
- * If on the other hand you need to retain the contents of the
- * IV, you should either save it manually or use the cipher
- * module instead.
- *
- * \param ctx AES context
- * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
- * \param length length of the input data
- * \param iv initialization vector (updated after use)
- * \param input buffer holding the input data
- * \param output buffer holding the output data
- *
- * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
+ * \brief This function performs an AES-CBC encryption or decryption operation
+ * on full blocks.
+ *
+ * It performs the operation defined in the \p mode
+ * parameter (encrypt/decrypt), on the input data buffer defined in
+ * the \p input parameter.
+ *
+ * It can be called as many times as needed, until all the input
+ * data is processed. mbedtls_aes_init(), and either
+ * mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called
+ * before the first call to this API with the same context.
+ *
+ * \note This function operates on aligned blocks, that is, the input size
+ * must be a multiple of the AES block size of 16 Bytes.
+ *
+ * \note Upon exit, the content of the IV is updated so that you can
+ * call the same function again on the next
+ * block(s) of data and get the same result as if it was
+ * encrypted in one call. This allows a "streaming" usage.
+ * If you need to retain the contents of the IV, you should
+ * either save it manually or use the cipher module instead.
+ *
+ *
+ * \param ctx The AES context to use for encryption or decryption.
+ * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
+ * #MBEDTLS_AES_DECRYPT.
+ * \param length The length of the input data in Bytes. This must be a
+ * multiple of the block size (16 Bytes).
+ * \param iv Initialization vector (updated after use).
+ * \param input The buffer holding the input data.
+ * \param output The buffer holding the output data.
+ *
+ * \return \c 0 on success, or #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
+ * on failure.
*/
int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
int mode,
#if defined(MBEDTLS_CIPHER_MODE_CFB)
/**
- * \brief AES-CFB128 buffer encryption/decryption.
- *
- * Note: Due to the nature of CFB you should use the same key schedule for
- * both encryption and decryption. So a context initialized with
- * mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT.
- *
- * \note Upon exit, the content of the IV is updated so that you can
- * call the function same function again on the following
- * block(s) of data and get the same result as if it was
- * encrypted in one call. This allows a "streaming" usage.
- * If on the other hand you need to retain the contents of the
- * IV, you should either save it manually or use the cipher
- * module instead.
- *
- * \param ctx AES context
- * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
- * \param length length of the input data
- * \param iv_off offset in IV (updated after use)
- * \param iv initialization vector (updated after use)
- * \param input buffer holding the input data
- * \param output buffer holding the output data
- *
- * \return 0 if successful
+ * \brief This function performs an AES-CFB128 encryption or decryption
+ * operation.
+ *
+ * It performs the operation defined in the \p mode
+ * parameter (encrypt or decrypt), on the input data buffer
+ * defined in the \p input parameter.
+ *
+ * For CFB, you must set up the context with mbedtls_aes_setkey_enc(),
+ * regardless of whether you are performing an encryption or decryption
+ * operation, that is, regardless of the \p mode parameter. This is
+ * because CFB mode uses the same key schedule for encryption and
+ * decryption.
+ *
+ * \note Upon exit, the content of the IV is updated so that you can
+ * call the same function again on the next
+ * block(s) of data and get the same result as if it was
+ * encrypted in one call. This allows a "streaming" usage.
+ * If you need to retain the contents of the
+ * IV, you must either save it manually or use the cipher
+ * module instead.
+ *
+ *
+ * \param ctx The AES context to use for encryption or decryption.
+ * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
+ * #MBEDTLS_AES_DECRYPT.
+ * \param length The length of the input data.
+ * \param iv_off The offset in IV (updated after use).
+ * \param iv The initialization vector (updated after use).
+ * \param input The buffer holding the input data.
+ * \param output The buffer holding the output data.
+ *
+ * \return \c 0 on success.
*/
int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
int mode,
unsigned char *output );
/**
- * \brief AES-CFB8 buffer encryption/decryption.
- *
- * Note: Due to the nature of CFB you should use the same key schedule for
- * both encryption and decryption. So a context initialized with
- * mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT.
- *
- * \note Upon exit, the content of the IV is updated so that you can
- * call the function same function again on the following
- * block(s) of data and get the same result as if it was
- * encrypted in one call. This allows a "streaming" usage.
- * If on the other hand you need to retain the contents of the
- * IV, you should either save it manually or use the cipher
- * module instead.
- *
- * \param ctx AES context
- * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
- * \param length length of the input data
- * \param iv initialization vector (updated after use)
- * \param input buffer holding the input data
- * \param output buffer holding the output data
- *
- * \return 0 if successful
+ * \brief This function performs an AES-CFB8 encryption or decryption
+ * operation.
+ *
+ * It performs the operation defined in the \p mode
+ * parameter (encrypt/decrypt), on the input data buffer defined
+ * in the \p input parameter.
+ *
+ * Due to the nature of CFB, you must use the same key schedule for
+ * both encryption and decryption operations. Therefore, you must
+ * use the context initialized with mbedtls_aes_setkey_enc() for
+ * both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
+ *
+ * \note Upon exit, the content of the IV is updated so that you can
+ * call the same function again on the next
+ * block(s) of data and get the same result as if it was
+ * encrypted in one call. This allows a "streaming" usage.
+ * If you need to retain the contents of the
+ * IV, you should either save it manually or use the cipher
+ * module instead.
+ *
+ *
+ * \param ctx The AES context to use for encryption or decryption.
+ * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
+ * #MBEDTLS_AES_DECRYPT
+ * \param length The length of the input data.
+ * \param iv The initialization vector (updated after use).
+ * \param input The buffer holding the input data.
+ * \param output The buffer holding the output data.
+ *
+ * \return \c 0 on success.
*/
int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
int mode,
#if defined(MBEDTLS_CIPHER_MODE_CTR)
/**
- * \brief AES-CTR buffer encryption/decryption
- *
- * Warning: You have to keep the maximum use of your counter in mind!
- *
- * Note: Due to the nature of CTR you should use the same key schedule for
- * both encryption and decryption. So a context initialized with
- * mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT.
- *
- * \param ctx AES context
- * \param length The length of the data
- * \param nc_off The offset in the current stream_block (for resuming
- * within current cipher stream). The offset pointer to
- * should be 0 at the start of a stream.
- * \param nonce_counter The 128-bit nonce and counter.
- * \param stream_block The saved stream-block for resuming. Is overwritten
- * by the function.
- * \param input The input data stream
- * \param output The output data stream
- *
- * \return 0 if successful
+ * \brief This function performs an AES-CTR encryption or decryption
+ * operation.
+ *
+ * This function performs the operation defined in the \p mode
+ * parameter (encrypt/decrypt), on the input data buffer
+ * defined in the \p input parameter.
+ *
+ * Due to the nature of CTR, you must use the same key schedule
+ * for both encryption and decryption operations. Therefore, you
+ * must use the context initialized with mbedtls_aes_setkey_enc()
+ * for both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT.
+ *
+ * \warning You must keep the maximum use of your counter in mind.
+ *
+ * \param ctx The AES context to use for encryption or decryption.
+ * \param length The length of the input data.
+ * \param nc_off The offset in the current \p stream_block, for
+ * resuming within the current cipher stream. The
+ * offset pointer should be 0 at the start of a stream.
+ * \param nonce_counter The 128-bit nonce and counter.
+ * \param stream_block The saved stream block for resuming. This is
+ * overwritten by the function.
+ * \param input The buffer holding the input data.
+ * \param output The buffer holding the output data.
+ *
+ * \return \c 0 on success.
*/
int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
size_t length,
#endif /* MBEDTLS_CIPHER_MODE_CTR */
/**
- * \brief Internal AES block encryption function
- * (Only exposed to allow overriding it,
- * see MBEDTLS_AES_ENCRYPT_ALT)
+ * \brief Internal AES block encryption function. This is only
+ * exposed to allow overriding it using
+ * \c MBEDTLS_AES_ENCRYPT_ALT.
+ *
+ * \param ctx The AES context to use for encryption.
+ * \param input The plaintext block.
+ * \param output The output (ciphertext) block.
+ *
+ * \return \c 0 on success.
+ */
+int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
+ const unsigned char input[16],
+ unsigned char output[16] );
+
+/**
+ * \brief Internal AES block decryption function. This is only
+ * exposed to allow overriding it using see
+ * \c MBEDTLS_AES_DECRYPT_ALT.
+ *
+ * \param ctx The AES context to use for decryption.
+ * \param input The ciphertext block.
+ * \param output The output (plaintext) block.
*
- * \param ctx AES context
- * \param input Plaintext block
- * \param output Output (ciphertext) block
+ * \return \c 0 on success.
*/
-void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
- const unsigned char input[16],
- unsigned char output[16] );
+int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
+ const unsigned char input[16],
+ unsigned char output[16] );
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
/**
- * \brief Internal AES block decryption function
- * (Only exposed to allow overriding it,
- * see MBEDTLS_AES_DECRYPT_ALT)
+ * \brief Deprecated internal AES block encryption function
+ * without return value.
+ *
+ * \deprecated Superseded by mbedtls_aes_encrypt_ext() in 2.5.0.
*
- * \param ctx AES context
- * \param input Ciphertext block
- * \param output Output (plaintext) block
+ * \param ctx The AES context to use for encryption.
+ * \param input Plaintext block.
+ * \param output Output (ciphertext) block.
*/
-void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
- const unsigned char input[16],
- unsigned char output[16] );
+MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
+ const unsigned char input[16],
+ unsigned char output[16] );
+
+/**
+ * \brief Deprecated internal AES block decryption function
+ * without return value.
+ *
+ * \deprecated Superseded by mbedtls_aes_decrypt_ext() in 2.5.0.
+ *
+ * \param ctx The AES context to use for decryption.
+ * \param input Ciphertext block.
+ * \param output Output (plaintext) block.
+ */
+MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
+ const unsigned char input[16],
+ unsigned char output[16] );
+
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
#endif
/**
- * \brief Checkup routine
+ * \brief Checkup routine.
*
- * \return 0 if successful, or 1 if the test failed
+ * \return \c 0 on success, or \c 1 on failure.
*/
int mbedtls_aes_self_test( int verbose );
* \file aesni.h
*
* \brief AES-NI for hardware AES acceleration on some Intel processors
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
*
* \brief The ARCFOUR stream cipher
*
+ * \warning ARC4 is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers instead.
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
+ *
*/
#ifndef MBEDTLS_ARC4_H
#define MBEDTLS_ARC4_H
#include <stddef.h>
+#define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019 /**< ARC4 hardware accelerator failed. */
+
#if !defined(MBEDTLS_ARC4_ALT)
// Regular implementation
//
#endif
/**
- * \brief ARC4 context structure
+ * \brief ARC4 context structure
+ *
+ * \warning ARC4 is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers instead.
+ *
*/
typedef struct
{
* \brief Initialize ARC4 context
*
* \param ctx ARC4 context to be initialized
+ *
+ * \warning ARC4 is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
+ *
*/
void mbedtls_arc4_init( mbedtls_arc4_context *ctx );
* \brief Clear ARC4 context
*
* \param ctx ARC4 context to be cleared
+ *
+ * \warning ARC4 is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
+ *
*/
void mbedtls_arc4_free( mbedtls_arc4_context *ctx );
* \param ctx ARC4 context to be setup
* \param key the secret key
* \param keylen length of the key, in bytes
+ *
+ * \warning ARC4 is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
+ *
*/
void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key,
unsigned int keylen );
* \param output buffer for the output data
*
* \return 0 if successful
+ *
+ * \warning ARC4 is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
+ *
*/
int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input,
unsigned char *output );
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
+ *
+ * \warning ARC4 is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
+ *
*/
int mbedtls_arc4_self_test( int verbose );
* \file asn1.h
*
* \brief Generic ASN.1 parsing
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
/**
* \name DER constants
- * These constants comply with DER encoded the ANS1 type tags.
+ * These constants comply with the DER encoded ASN.1 type tags.
* DER encoding uses hexadecimal representation.
* An example DER sequence is:\n
* - 0x02 -- tag indicating INTEGER
#define MBEDTLS_ASN1_PRIMITIVE 0x00
#define MBEDTLS_ASN1_CONSTRUCTED 0x20
#define MBEDTLS_ASN1_CONTEXT_SPECIFIC 0x80
+
+/*
+ * Bit masks for each of the components of an ASN.1 tag as specified in
+ * ITU X.690 (08/2015), section 8.1 "General rules for encoding",
+ * paragraph 8.1.2.2:
+ *
+ * Bit 8 7 6 5 1
+ * +-------+-----+------------+
+ * | Class | P/C | Tag number |
+ * +-------+-----+------------+
+ */
+#define MBEDTLS_ASN1_TAG_CLASS_MASK 0xC0
+#define MBEDTLS_ASN1_TAG_PC_MASK 0x20
+#define MBEDTLS_ASN1_TAG_VALUE_MASK 0x1F
+
/* \} name */
/* \} addtogroup asn1_module */
* \file asn1write.h
*
* \brief ASN.1 buffer writing functionality
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file base64.h
*
* \brief RFC 1521 base64 encoding/decoding
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
/**
* \file bignum.h
*
- * \brief Multi-precision integer library
- *
+ * \brief Multi-precision integer library
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Maximum size of MPIs allowed in bits and bytes for user-MPIs.
* ( Default: 512 bytes => 4096 bits, Maximum tested: 2048 bytes => 16384 bits )
*
- * Note: Calculations can results temporarily in larger MPIs. So the number
+ * Note: Calculations can temporarily result in larger MPIs. So the number
* of limbs required (MBEDTLS_MPI_MAX_LIMBS) is higher.
*/
#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */
/*
* Define the base integer type, architecture-wise.
*
- * 32-bit integers can be forced on 64-bit arches (eg. for testing purposes)
- * by defining MBEDTLS_HAVE_INT32 and undefining MBEDTLS_HAVE_ASM
- */
-#if ( ! defined(MBEDTLS_HAVE_INT32) && \
- defined(_MSC_VER) && defined(_M_AMD64) )
- #define MBEDTLS_HAVE_INT64
- typedef int64_t mbedtls_mpi_sint;
- typedef uint64_t mbedtls_mpi_uint;
-#else
- #if ( ! defined(MBEDTLS_HAVE_INT32) && \
- defined(__GNUC__) && ( \
- defined(__amd64__) || defined(__x86_64__) || \
- defined(__ppc64__) || defined(__powerpc64__) || \
- defined(__ia64__) || defined(__alpha__) || \
- (defined(__sparc__) && defined(__arch64__)) || \
- defined(__s390x__) || defined(__mips64) ) )
- #define MBEDTLS_HAVE_INT64
- typedef int64_t mbedtls_mpi_sint;
- typedef uint64_t mbedtls_mpi_uint;
- /* mbedtls_t_udbl defined as 128-bit unsigned int */
- typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI)));
- #define MBEDTLS_HAVE_UDBL
- #else
- #define MBEDTLS_HAVE_INT32
- typedef int32_t mbedtls_mpi_sint;
- typedef uint32_t mbedtls_mpi_uint;
- typedef uint64_t mbedtls_t_udbl;
- #define MBEDTLS_HAVE_UDBL
- #endif /* !MBEDTLS_HAVE_INT32 && __GNUC__ && 64-bit platform */
-#endif /* !MBEDTLS_HAVE_INT32 && _MSC_VER && _M_AMD64 */
+ * 32 or 64-bit integer types can be forced regardless of the underlying
+ * architecture by defining MBEDTLS_HAVE_INT32 or MBEDTLS_HAVE_INT64
+ * respectively and undefining MBEDTLS_HAVE_ASM.
+ *
+ * Double-width integers (e.g. 128-bit in 64-bit architectures) can be
+ * disabled by defining MBEDTLS_NO_UDBL_DIVISION.
+ */
+#if !defined(MBEDTLS_HAVE_INT32)
+ #if defined(_MSC_VER) && defined(_M_AMD64)
+ /* Always choose 64-bit when using MSC */
+ #if !defined(MBEDTLS_HAVE_INT64)
+ #define MBEDTLS_HAVE_INT64
+ #endif /* !MBEDTLS_HAVE_INT64 */
+ typedef int64_t mbedtls_mpi_sint;
+ typedef uint64_t mbedtls_mpi_uint;
+ #elif defined(__GNUC__) && ( \
+ defined(__amd64__) || defined(__x86_64__) || \
+ defined(__ppc64__) || defined(__powerpc64__) || \
+ defined(__ia64__) || defined(__alpha__) || \
+ ( defined(__sparc__) && defined(__arch64__) ) || \
+ defined(__s390x__) || defined(__mips64) )
+ #if !defined(MBEDTLS_HAVE_INT64)
+ #define MBEDTLS_HAVE_INT64
+ #endif /* MBEDTLS_HAVE_INT64 */
+ typedef int64_t mbedtls_mpi_sint;
+ typedef uint64_t mbedtls_mpi_uint;
+ #if !defined(MBEDTLS_NO_UDBL_DIVISION)
+ /* mbedtls_t_udbl defined as 128-bit unsigned int */
+ typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI)));
+ #define MBEDTLS_HAVE_UDBL
+ #endif /* !MBEDTLS_NO_UDBL_DIVISION */
+ #elif defined(__ARMCC_VERSION) && defined(__aarch64__)
+ /*
+ * __ARMCC_VERSION is defined for both armcc and armclang and
+ * __aarch64__ is only defined by armclang when compiling 64-bit code
+ */
+ #if !defined(MBEDTLS_HAVE_INT64)
+ #define MBEDTLS_HAVE_INT64
+ #endif /* !MBEDTLS_HAVE_INT64 */
+ typedef int64_t mbedtls_mpi_sint;
+ typedef uint64_t mbedtls_mpi_uint;
+ #if !defined(MBEDTLS_NO_UDBL_DIVISION)
+ /* mbedtls_t_udbl defined as 128-bit unsigned int */
+ typedef __uint128_t mbedtls_t_udbl;
+ #define MBEDTLS_HAVE_UDBL
+ #endif /* !MBEDTLS_NO_UDBL_DIVISION */
+ #elif defined(MBEDTLS_HAVE_INT64)
+ /* Force 64-bit integers with unknown compiler */
+ typedef int64_t mbedtls_mpi_sint;
+ typedef uint64_t mbedtls_mpi_uint;
+ #endif
+#endif /* !MBEDTLS_HAVE_INT32 */
+
+#if !defined(MBEDTLS_HAVE_INT64)
+ /* Default to 32-bit compilation */
+ #if !defined(MBEDTLS_HAVE_INT32)
+ #define MBEDTLS_HAVE_INT32
+ #endif /* !MBEDTLS_HAVE_INT32 */
+ typedef int32_t mbedtls_mpi_sint;
+ typedef uint32_t mbedtls_mpi_uint;
+ #if !defined(MBEDTLS_NO_UDBL_DIVISION)
+ typedef uint64_t mbedtls_t_udbl;
+ #define MBEDTLS_HAVE_UDBL
+ #endif /* !MBEDTLS_NO_UDBL_DIVISION */
+#endif /* !MBEDTLS_HAVE_INT64 */
#ifdef __cplusplus
extern "C" {
#if defined(MBEDTLS_FS_IO)
/**
- * \brief Read X from an opened file
+ * \brief Read MPI from a line in an opened file
*
* \param X Destination MPI
* \param radix Input numeric base
* \return 0 if successful, MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if
* the file read buffer is too small or a
* MBEDTLS_ERR_MPI_XXX error code
+ *
+ * \note On success, this function advances the file stream
+ * to the end of the current line or to EOF.
+ *
+ * The function returns 0 on an empty line.
+ *
+ * Leading whitespaces are ignored, as is a
+ * '0x' prefix for radix 16.
+ *
*/
int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin );
*
* \return 0 if successful,
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed
+ *
+ * \note The bytes obtained from the PRNG are interpreted
+ * as a big-endian representation of an MPI; this can
+ * be relevant in applications like deterministic ECDSA.
*/
int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size,
int (*f_rng)(void *, unsigned char *, size_t),
*
* \return 0 if successful,
* MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed,
- * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is negative or nil
- MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N
+ * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is <= 1,
+ MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N.
*/
int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N );
* \file blowfish.h
*
* \brief Blowfish block cipher
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#define MBEDTLS_BLOWFISH_BLOCKSIZE 8 /* Blowfish uses 64 bit blocks */
#define MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH -0x0016 /**< Invalid key length. */
+#define MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED -0x0017 /**< Blowfish hardware accelerator failed. */
#define MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH -0x0018 /**< Invalid data input length. */
#if !defined(MBEDTLS_BLOWFISH_ALT)
/**
* \file bn_mul.h
*
- * \brief Multi-precision integer library
- *
+ * \brief Multi-precision integer library
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file camellia.h
*
* \brief Camellia block cipher
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#define MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH -0x0024 /**< Invalid key length. */
#define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026 /**< Invalid data input length. */
+#define MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED -0x0027 /**< Camellia hardware accelerator failed. */
#if !defined(MBEDTLS_CAMELLIA_ALT)
// Regular implementation
/**
* \file ccm.h
*
- * \brief Counter with CBC-MAC (CCM) for 128-bit block ciphers
+ * \brief CCM combines Counter mode encryption with CBC-MAC authentication
+ * for 128-bit block ciphers.
*
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ * Input to CCM includes the following elements:
+ * <ul><li>Payload - data that is both authenticated and encrypted.</li>
+ * <li>Associated data (Adata) - data that is authenticated but not
+ * encrypted, For example, a header.</li>
+ * <li>Nonce - A unique value that is assigned to the payload and the
+ * associated data.</li></ul>
+ *
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
+
#ifndef MBEDTLS_CCM_H
#define MBEDTLS_CCM_H
#include "cipher.h"
-#define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /**< Bad input parameters to function. */
-#define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F /**< Authenticated decryption failed. */
+#define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /**< Bad input parameters to the function. */
+#define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F /**< Authenticated decryption failed. */
+#define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011 /**< CCM hardware accelerator failed. */
+
+#if !defined(MBEDTLS_CCM_ALT)
+// Regular implementation
+//
#ifdef __cplusplus
extern "C" {
#endif
/**
- * \brief CCM context structure
+ * \brief The CCM context-type definition. The CCM context is passed
+ * to the APIs called.
*/
typedef struct {
- mbedtls_cipher_context_t cipher_ctx; /*!< cipher context used */
+ mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */
}
mbedtls_ccm_context;
/**
- * \brief Initialize CCM context (just makes references valid)
- * Makes the context ready for mbedtls_ccm_setkey() or
- * mbedtls_ccm_free().
+ * \brief This function initializes the specified CCM context,
+ * to make references valid, and prepare the context
+ * for mbedtls_ccm_setkey() or mbedtls_ccm_free().
*
- * \param ctx CCM context to initialize
+ * \param ctx The CCM context to initialize.
*/
void mbedtls_ccm_init( mbedtls_ccm_context *ctx );
/**
- * \brief CCM initialization (encryption and decryption)
+ * \brief This function initializes the CCM context set in the
+ * \p ctx parameter and sets the encryption key.
*
- * \param ctx CCM context to be initialized
- * \param cipher cipher to use (a 128-bit block cipher)
- * \param key encryption key
- * \param keybits key size in bits (must be acceptable by the cipher)
+ * \param ctx The CCM context to initialize.
+ * \param cipher The 128-bit block cipher to use.
+ * \param key The encryption key.
+ * \param keybits The key size in bits. This must be acceptable by the cipher.
*
- * \return 0 if successful, or a cipher specific error code
+ * \return \c 0 on success, or a cipher-specific error code.
*/
int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx,
mbedtls_cipher_id_t cipher,
unsigned int keybits );
/**
- * \brief Free a CCM context and underlying cipher sub-context
+ * \brief This function releases and clears the specified CCM context
+ * and underlying cipher sub-context.
*
- * \param ctx CCM context to free
+ * \param ctx The CCM context to clear.
*/
void mbedtls_ccm_free( mbedtls_ccm_context *ctx );
/**
- * \brief CCM buffer encryption
- *
- * \param ctx CCM context
- * \param length length of the input data in bytes
- * \param iv nonce (initialization vector)
- * \param iv_len length of IV in bytes
- * must be 2, 3, 4, 5, 6, 7 or 8
- * \param add additional data
- * \param add_len length of additional data in bytes
- * must be less than 2^16 - 2^8
- * \param input buffer holding the input data
- * \param output buffer for holding the output data
- * must be at least 'length' bytes wide
- * \param tag buffer for holding the tag
- * \param tag_len length of the tag to generate in bytes
- * must be 4, 6, 8, 10, 14 or 16
- *
- * \note The tag is written to a separate buffer. To get the tag
- * concatenated with the output as in the CCM spec, use
- * tag = output + length and make sure the output buffer is
- * at least length + tag_len wide.
- *
- * \return 0 if successful
+ * \brief This function encrypts a buffer using CCM.
+ *
+ * \param ctx The CCM context to use for encryption.
+ * \param length The length of the input data in Bytes.
+ * \param iv Initialization vector (nonce).
+ * \param iv_len The length of the IV in Bytes: 7, 8, 9, 10, 11, 12, or 13.
+ * \param add The additional data field.
+ * \param add_len The length of additional data in Bytes.
+ * Must be less than 2^16 - 2^8.
+ * \param input The buffer holding the input data.
+ * \param output The buffer holding the output data.
+ * Must be at least \p length Bytes wide.
+ * \param tag The buffer holding the tag.
+ * \param tag_len The length of the tag to generate in Bytes:
+ * 4, 6, 8, 10, 12, 14 or 16.
+ *
+ * \note The tag is written to a separate buffer. To concatenate
+ * the \p tag with the \p output, as done in <em>RFC-3610:
+ * Counter with CBC-MAC (CCM)</em>, use
+ * \p tag = \p output + \p length, and make sure that the
+ * output buffer is at least \p length + \p tag_len wide.
+ *
+ * \return \c 0 on success.
*/
int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length,
const unsigned char *iv, size_t iv_len,
unsigned char *tag, size_t tag_len );
/**
- * \brief CCM buffer authenticated decryption
- *
- * \param ctx CCM context
- * \param length length of the input data
- * \param iv initialization vector
- * \param iv_len length of IV
- * \param add additional data
- * \param add_len length of additional data
- * \param input buffer holding the input data
- * \param output buffer for holding the output data
- * \param tag buffer holding the tag
- * \param tag_len length of the tag
- *
- * \return 0 if successful and authenticated,
- * MBEDTLS_ERR_CCM_AUTH_FAILED if tag does not match
+ * \brief This function performs a CCM authenticated decryption of a
+ * buffer.
+ *
+ * \param ctx The CCM context to use for decryption.
+ * \param length The length of the input data in Bytes.
+ * \param iv Initialization vector.
+ * \param iv_len The length of the IV in Bytes: 7, 8, 9, 10, 11, 12, or 13.
+ * \param add The additional data field.
+ * \param add_len The length of additional data in Bytes.
+ * Must be less than 2^16 - 2^8.
+ * \param input The buffer holding the input data.
+ * \param output The buffer holding the output data.
+ * Must be at least \p length Bytes wide.
+ * \param tag The buffer holding the tag.
+ * \param tag_len The length of the tag in Bytes.
+ * 4, 6, 8, 10, 12, 14 or 16.
+ *
+ * \return 0 if successful and authenticated, or
+ * #MBEDTLS_ERR_CCM_AUTH_FAILED if the tag does not match.
*/
int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length,
const unsigned char *iv, size_t iv_len,
const unsigned char *input, unsigned char *output,
const unsigned char *tag, size_t tag_len );
+#ifdef __cplusplus
+}
+#endif
+
+#else /* MBEDTLS_CCM_ALT */
+#include "ccm_alt.h"
+#endif /* MBEDTLS_CCM_ALT */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
/**
- * \brief Checkup routine
+ * \brief The CCM checkup routine.
*
- * \return 0 if successful, or 1 if the test failed
+ * \return \c 0 on success, or \c 1 on failure.
*/
int mbedtls_ccm_self_test( int verbose );
#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
* \file certs.h
*
* \brief Sample certificates and DHM parameters for testing
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file check_config.h
*
* \brief Consistency checks for configuration options
- *
+ */
+/*
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#error "MBEDTLS_DHM_C defined, but not all prerequisites"
#endif
+#if defined(MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT) && !defined(MBEDTLS_SSL_TRUNCATED_HMAC)
+#error "MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT defined, but not all prerequisites"
+#endif
+
#if defined(MBEDTLS_CMAC_C) && \
!defined(MBEDTLS_AES_C) && !defined(MBEDTLS_DES_C)
#error "MBEDTLS_CMAC_C defined, but not all prerequisites"
#error "MBEDTLS_GCM_C defined, but not all prerequisites"
#endif
+#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
+#error "MBEDTLS_ECP_RANDOMIZE_JAC_ALT defined, but not all prerequisites"
+#endif
+
+#if defined(MBEDTLS_ECP_ADD_MIXED_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
+#error "MBEDTLS_ECP_ADD_MIXED_ALT defined, but not all prerequisites"
+#endif
+
+#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
+#error "MBEDTLS_ECP_DOUBLE_JAC_ALT defined, but not all prerequisites"
+#endif
+
+#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
+#error "MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT defined, but not all prerequisites"
+#endif
+
+#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
+#error "MBEDTLS_ECP_NORMALIZE_JAC_ALT defined, but not all prerequisites"
+#endif
+
+#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
+#error "MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT defined, but not all prerequisites"
+#endif
+
+#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
+#error "MBEDTLS_ECP_RANDOMIZE_MXZ_ALT defined, but not all prerequisites"
+#endif
+
+#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) && !defined(MBEDTLS_ECP_INTERNAL_ALT)
+#error "MBEDTLS_ECP_NORMALIZE_MXZ_ALT defined, but not all prerequisites"
+#endif
+
#if defined(MBEDTLS_HAVEGE_C) && !defined(MBEDTLS_TIMING_C)
#error "MBEDTLS_HAVEGE_C defined, but not all prerequisites"
#endif
#error "MBEDTLS_X509_CSR_WRITE_C defined, but not all prerequisites"
#endif
+#if defined(MBEDTLS_HAVE_INT32) && defined(MBEDTLS_HAVE_INT64)
+#error "MBEDTLS_HAVE_INT32 and MBEDTLS_HAVE_INT64 cannot be defined simultaneously"
+#endif /* MBEDTLS_HAVE_INT32 && MBEDTLS_HAVE_INT64 */
+
+#if ( defined(MBEDTLS_HAVE_INT32) || defined(MBEDTLS_HAVE_INT64) ) && \
+ defined(MBEDTLS_HAVE_ASM)
+#error "MBEDTLS_HAVE_INT32/MBEDTLS_HAVE_INT64 and MBEDTLS_HAVE_ASM cannot be defined simultaneously"
+#endif /* (MBEDTLS_HAVE_INT32 || MBEDTLS_HAVE_INT64) && MBEDTLS_HAVE_ASM */
+
/*
* Avoid warning from -pedantic. This is a convenient place for this
* workaround since this is included by every single file before the
/**
* \file cipher.h
*
- * \brief Generic cipher wrapper.
+ * \brief The generic cipher wrapper.
*
* \author Adriaan de Jong <dejong@fox-it.com>
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_CIPHER_H
#define inline __inline
#endif
-#define MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE -0x6080 /**< The selected feature is not available. */
-#define MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA -0x6100 /**< Bad input parameters to function. */
-#define MBEDTLS_ERR_CIPHER_ALLOC_FAILED -0x6180 /**< Failed to allocate memory. */
-#define MBEDTLS_ERR_CIPHER_INVALID_PADDING -0x6200 /**< Input data contains invalid padding and is rejected. */
-#define MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED -0x6280 /**< Decryption of block requires a full block. */
-#define MBEDTLS_ERR_CIPHER_AUTH_FAILED -0x6300 /**< Authentication failed (for AEAD modes). */
-#define MBEDTLS_ERR_CIPHER_INVALID_CONTEXT -0x6380 /**< The context is invalid, eg because it was free()ed. */
+#define MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE -0x6080 /**< The selected feature is not available. */
+#define MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA -0x6100 /**< Bad input parameters. */
+#define MBEDTLS_ERR_CIPHER_ALLOC_FAILED -0x6180 /**< Failed to allocate memory. */
+#define MBEDTLS_ERR_CIPHER_INVALID_PADDING -0x6200 /**< Input data contains invalid padding and is rejected. */
+#define MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED -0x6280 /**< Decryption of block requires a full block. */
+#define MBEDTLS_ERR_CIPHER_AUTH_FAILED -0x6300 /**< Authentication failed (for AEAD modes). */
+#define MBEDTLS_ERR_CIPHER_INVALID_CONTEXT -0x6380 /**< The context is invalid. For example, because it was freed. */
+#define MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED -0x6400 /**< Cipher hardware accelerator failed. */
-#define MBEDTLS_CIPHER_VARIABLE_IV_LEN 0x01 /**< Cipher accepts IVs of variable length */
-#define MBEDTLS_CIPHER_VARIABLE_KEY_LEN 0x02 /**< Cipher accepts keys of variable length */
+#define MBEDTLS_CIPHER_VARIABLE_IV_LEN 0x01 /**< Cipher accepts IVs of variable length. */
+#define MBEDTLS_CIPHER_VARIABLE_KEY_LEN 0x02 /**< Cipher accepts keys of variable length. */
#ifdef __cplusplus
extern "C" {
#endif
+/**
+ * \brief An enumeration of supported ciphers.
+ *
+ * \warning ARC4 and DES are considered weak ciphers and their use
+ * constitutes a security risk. We recommend considering stronger
+ * ciphers instead.
+ */
typedef enum {
MBEDTLS_CIPHER_ID_NONE = 0,
MBEDTLS_CIPHER_ID_NULL,
MBEDTLS_CIPHER_ID_ARC4,
} mbedtls_cipher_id_t;
+/**
+ * \brief An enumeration of supported (cipher, mode) pairs.
+ *
+ * \warning ARC4 and DES are considered weak ciphers and their use
+ * constitutes a security risk. We recommend considering stronger
+ * ciphers instead.
+ */
typedef enum {
MBEDTLS_CIPHER_NONE = 0,
MBEDTLS_CIPHER_NULL,
MBEDTLS_CIPHER_CAMELLIA_256_CCM,
} mbedtls_cipher_type_t;
+/** Supported cipher modes. */
typedef enum {
MBEDTLS_MODE_NONE = 0,
MBEDTLS_MODE_ECB,
MBEDTLS_MODE_CCM,
} mbedtls_cipher_mode_t;
+/** Supported cipher padding types. */
typedef enum {
- MBEDTLS_PADDING_PKCS7 = 0, /**< PKCS7 padding (default) */
- MBEDTLS_PADDING_ONE_AND_ZEROS, /**< ISO/IEC 7816-4 padding */
- MBEDTLS_PADDING_ZEROS_AND_LEN, /**< ANSI X.923 padding */
- MBEDTLS_PADDING_ZEROS, /**< zero padding (not reversible!) */
- MBEDTLS_PADDING_NONE, /**< never pad (full blocks only) */
+ MBEDTLS_PADDING_PKCS7 = 0, /**< PKCS7 padding (default). */
+ MBEDTLS_PADDING_ONE_AND_ZEROS, /**< ISO/IEC 7816-4 padding. */
+ MBEDTLS_PADDING_ZEROS_AND_LEN, /**< ANSI X.923 padding. */
+ MBEDTLS_PADDING_ZEROS, /**< zero padding (not reversible). */
+ MBEDTLS_PADDING_NONE, /**< never pad (full blocks only). */
} mbedtls_cipher_padding_t;
+/** Type of operation. */
typedef enum {
MBEDTLS_OPERATION_NONE = -1,
MBEDTLS_DECRYPT = 0,
} mbedtls_operation_t;
enum {
- /** Undefined key length */
+ /** Undefined key length. */
MBEDTLS_KEY_LENGTH_NONE = 0,
- /** Key length, in bits (including parity), for DES keys */
+ /** Key length, in bits (including parity), for DES keys. */
MBEDTLS_KEY_LENGTH_DES = 64,
- /** Key length, in bits (including parity), for DES in two key EDE */
+ /** Key length in bits, including parity, for DES in two-key EDE. */
MBEDTLS_KEY_LENGTH_DES_EDE = 128,
- /** Key length, in bits (including parity), for DES in three-key EDE */
+ /** Key length in bits, including parity, for DES in three-key EDE. */
MBEDTLS_KEY_LENGTH_DES_EDE3 = 192,
};
-/** Maximum length of any IV, in bytes */
+/** Maximum length of any IV, in Bytes. */
#define MBEDTLS_MAX_IV_LENGTH 16
-/** Maximum block size of any cipher, in bytes */
+/** Maximum block size of any cipher, in Bytes. */
#define MBEDTLS_MAX_BLOCK_LENGTH 16
/**
typedef struct mbedtls_cmac_context_t mbedtls_cmac_context_t;
/**
- * Cipher information. Allows cipher functions to be called in a generic way.
+ * Cipher information. Allows calling cipher functions
+ * in a generic way.
*/
typedef struct {
- /** Full cipher identifier (e.g. MBEDTLS_CIPHER_AES_256_CBC) */
+ /** Full cipher identifier. For example,
+ * MBEDTLS_CIPHER_AES_256_CBC.
+ */
mbedtls_cipher_type_t type;
- /** Cipher mode (e.g. MBEDTLS_MODE_CBC) */
+ /** The cipher mode. For example, MBEDTLS_MODE_CBC. */
mbedtls_cipher_mode_t mode;
- /** Cipher key length, in bits (default length for variable sized ciphers)
- * (Includes parity bits for ciphers like DES) */
+ /** The cipher key length, in bits. This is the
+ * default length for variable sized ciphers.
+ * Includes parity bits for ciphers like DES.
+ */
unsigned int key_bitlen;
- /** Name of the cipher */
+ /** Name of the cipher. */
const char * name;
- /** IV/NONCE size, in bytes.
- * For cipher that accept many sizes: recommended size */
+ /** IV or nonce size, in Bytes.
+ * For ciphers that accept variable IV sizes,
+ * this is the recommended size.
+ */
unsigned int iv_size;
- /** Flags for variable IV size, variable key size, etc. */
+ /** Flags to set. For example, if the cipher supports variable IV sizes or variable key sizes. */
int flags;
- /** block size, in bytes */
+ /** The block size, in Bytes. */
unsigned int block_size;
- /** Base cipher information and functions */
+ /** Struct for base cipher information and functions. */
const mbedtls_cipher_base_t *base;
} mbedtls_cipher_info_t;
* Generic cipher context.
*/
typedef struct {
- /** Information about the associated cipher */
+ /** Information about the associated cipher. */
const mbedtls_cipher_info_t *cipher_info;
- /** Key length to use */
+ /** Key length to use. */
int key_bitlen;
- /** Operation that the context's key has been initialised for */
+ /** Operation that the key of the context has been
+ * initialized for.
+ */
mbedtls_operation_t operation;
#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING)
- /** Padding functions to use, if relevant for cipher mode */
+ /** Padding functions to use, if relevant for
+ * the specific cipher mode.
+ */
void (*add_padding)( unsigned char *output, size_t olen, size_t data_len );
int (*get_padding)( unsigned char *input, size_t ilen, size_t *data_len );
#endif
- /** Buffer for data that hasn't been encrypted yet */
+ /** Buffer for input that has not been processed yet. */
unsigned char unprocessed_data[MBEDTLS_MAX_BLOCK_LENGTH];
- /** Number of bytes that still need processing */
+ /** Number of Bytes that have not been processed yet. */
size_t unprocessed_len;
- /** Current IV or NONCE_COUNTER for CTR-mode */
+ /** Current IV or NONCE_COUNTER for CTR-mode. */
unsigned char iv[MBEDTLS_MAX_IV_LENGTH];
- /** IV size in bytes (for ciphers with variable-length IVs) */
+ /** IV size in Bytes, for ciphers with variable-length IVs. */
size_t iv_size;
- /** Cipher-specific context */
+ /** The cipher-specific context. */
void *cipher_ctx;
#if defined(MBEDTLS_CMAC_C)
- /** CMAC Specific context */
+ /** CMAC-specific context. */
mbedtls_cmac_context_t *cmac_ctx;
#endif
} mbedtls_cipher_context_t;
/**
- * \brief Returns the list of ciphers supported by the generic cipher module.
+ * \brief This function retrieves the list of ciphers supported by the generic
+ * cipher module.
*
- * \return a statically allocated array of ciphers, the last entry
- * is 0.
+ * \return A statically-allocated array of ciphers. The last entry
+ * is zero.
*/
const int *mbedtls_cipher_list( void );
/**
- * \brief Returns the cipher information structure associated
- * with the given cipher name.
+ * \brief This function retrieves the cipher-information
+ * structure associated with the given cipher name.
*
* \param cipher_name Name of the cipher to search for.
*
- * \return the cipher information structure associated with the
- * given cipher_name, or NULL if not found.
+ * \return The cipher information structure associated with the
+ * given \p cipher_name, or NULL if not found.
*/
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher_name );
/**
- * \brief Returns the cipher information structure associated
- * with the given cipher type.
+ * \brief This function retrieves the cipher-information
+ * structure associated with the given cipher type.
*
* \param cipher_type Type of the cipher to search for.
*
- * \return the cipher information structure associated with the
- * given cipher_type, or NULL if not found.
+ * \return The cipher information structure associated with the
+ * given \p cipher_type, or NULL if not found.
*/
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher_type_t cipher_type );
/**
- * \brief Returns the cipher information structure associated
- * with the given cipher id, key size and mode.
+ * \brief This function retrieves the cipher-information
+ * structure associated with the given cipher ID,
+ * key size and mode.
*
- * \param cipher_id Id of the cipher to search for
- * (e.g. MBEDTLS_CIPHER_ID_AES)
- * \param key_bitlen Length of the key in bits
- * \param mode Cipher mode (e.g. MBEDTLS_MODE_CBC)
+ * \param cipher_id The ID of the cipher to search for. For example,
+ * #MBEDTLS_CIPHER_ID_AES.
+ * \param key_bitlen The length of the key in bits.
+ * \param mode The cipher mode. For example, #MBEDTLS_MODE_CBC.
*
- * \return the cipher information structure associated with the
- * given cipher_type, or NULL if not found.
+ * \return The cipher information structure associated with the
+ * given \p cipher_id, or NULL if not found.
*/
const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_cipher_id_t cipher_id,
int key_bitlen,
const mbedtls_cipher_mode_t mode );
/**
- * \brief Initialize a cipher_context (as NONE)
+ * \brief This function initializes a \p cipher_context as NONE.
*/
void mbedtls_cipher_init( mbedtls_cipher_context_t *ctx );
/**
- * \brief Free and clear the cipher-specific context of ctx.
- * Freeing ctx itself remains the responsibility of the
- * caller.
+ * \brief This function frees and clears the cipher-specific
+ * context of \p ctx. Freeing \p ctx itself remains the
+ * responsibility of the caller.
*/
void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx );
+
/**
- * \brief Initialises and fills the cipher context structure with
- * the appropriate values.
- *
- * \note Currently also clears structure. In future versions you
- * will be required to call mbedtls_cipher_init() on the structure
- * first.
+ * \brief This function initializes and fills the cipher-context
+ * structure with the appropriate values. It also clears
+ * the structure.
*
- * \param ctx context to initialise. May not be NULL.
- * \param cipher_info cipher to use.
+ * \param ctx The context to initialize. May not be NULL.
+ * \param cipher_info The cipher to use.
*
- * \return 0 on success,
- * MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on parameter failure,
- * MBEDTLS_ERR_CIPHER_ALLOC_FAILED if allocation of the
+ * \return \c 0 on success,
+ * #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on parameter failure,
+ * #MBEDTLS_ERR_CIPHER_ALLOC_FAILED if allocation of the
* cipher-specific context failed.
+ *
+ * \internal Currently, the function also clears the structure.
+ * In future versions, the caller will be required to call
+ * mbedtls_cipher_init() on the structure first.
*/
int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info );
/**
- * \brief Returns the block size of the given cipher.
+ * \brief This function returns the block size of the given cipher.
*
- * \param ctx cipher's context. Must have been initialised.
+ * \param ctx The context of the cipher. Must be initialized.
*
- * \return size of the cipher's blocks, or 0 if ctx has not been
- * initialised.
+ * \return The size of the blocks of the cipher, or zero if \p ctx
+ * has not been initialized.
*/
static inline unsigned int mbedtls_cipher_get_block_size( const mbedtls_cipher_context_t *ctx )
{
}
/**
- * \brief Returns the mode of operation for the cipher.
- * (e.g. MBEDTLS_MODE_CBC)
+ * \brief This function returns the mode of operation for
+ * the cipher. For example, MBEDTLS_MODE_CBC.
*
- * \param ctx cipher's context. Must have been initialised.
+ * \param ctx The context of the cipher. Must be initialized.
*
- * \return mode of operation, or MBEDTLS_MODE_NONE if ctx
- * has not been initialised.
+ * \return The mode of operation, or #MBEDTLS_MODE_NONE if
+ * \p ctx has not been initialized.
*/
static inline mbedtls_cipher_mode_t mbedtls_cipher_get_cipher_mode( const mbedtls_cipher_context_t *ctx )
{
}
/**
- * \brief Returns the size of the cipher's IV/NONCE in bytes.
+ * \brief This function returns the size of the IV or nonce
+ * of the cipher, in Bytes.
*
- * \param ctx cipher's context. Must have been initialised.
+ * \param ctx The context of the cipher. Must be initialized.
*
- * \return If IV has not been set yet: (recommended) IV size
- * (0 for ciphers not using IV/NONCE).
- * If IV has already been set: actual size.
+ * \return <ul><li>If no IV has been set: the recommended IV size.
+ * 0 for ciphers not using IV or nonce.</li>
+ * <li>If IV has already been set: the actual size.</li></ul>
*/
static inline int mbedtls_cipher_get_iv_size( const mbedtls_cipher_context_t *ctx )
{
}
/**
- * \brief Returns the type of the given cipher.
+ * \brief This function returns the type of the given cipher.
*
- * \param ctx cipher's context. Must have been initialised.
+ * \param ctx The context of the cipher. Must be initialized.
*
- * \return type of the cipher, or MBEDTLS_CIPHER_NONE if ctx has
- * not been initialised.
+ * \return The type of the cipher, or #MBEDTLS_CIPHER_NONE if
+ * \p ctx has not been initialized.
*/
static inline mbedtls_cipher_type_t mbedtls_cipher_get_type( const mbedtls_cipher_context_t *ctx )
{
}
/**
- * \brief Returns the name of the given cipher, as a string.
+ * \brief This function returns the name of the given cipher
+ * as a string.
*
- * \param ctx cipher's context. Must have been initialised.
+ * \param ctx The context of the cipher. Must be initialized.
*
- * \return name of the cipher, or NULL if ctx was not initialised.
+ * \return The name of the cipher, or NULL if \p ctx has not
+ * been not initialized.
*/
static inline const char *mbedtls_cipher_get_name( const mbedtls_cipher_context_t *ctx )
{
}
/**
- * \brief Returns the key length of the cipher.
+ * \brief This function returns the key length of the cipher.
*
- * \param ctx cipher's context. Must have been initialised.
+ * \param ctx The context of the cipher. Must be initialized.
*
- * \return cipher's key length, in bits, or
- * MBEDTLS_KEY_LENGTH_NONE if ctx has not been
- * initialised.
+ * \return The key length of the cipher in bits, or
+ * #MBEDTLS_KEY_LENGTH_NONE if ctx \p has not been
+ * initialized.
*/
static inline int mbedtls_cipher_get_key_bitlen( const mbedtls_cipher_context_t *ctx )
{
}
/**
- * \brief Returns the operation of the given cipher.
+ * \brief This function returns the operation of the given cipher.
*
- * \param ctx cipher's context. Must have been initialised.
+ * \param ctx The context of the cipher. Must be initialized.
*
- * \return operation (MBEDTLS_ENCRYPT or MBEDTLS_DECRYPT),
- * or MBEDTLS_OPERATION_NONE if ctx has not been
- * initialised.
+ * \return The type of operation: #MBEDTLS_ENCRYPT or
+ * #MBEDTLS_DECRYPT, or #MBEDTLS_OPERATION_NONE if \p ctx
+ * has not been initialized.
*/
static inline mbedtls_operation_t mbedtls_cipher_get_operation( const mbedtls_cipher_context_t *ctx )
{
}
/**
- * \brief Set the key to use with the given context.
+ * \brief This function sets the key to use with the given context.
*
- * \param ctx generic cipher context. May not be NULL. Must have been
- * initialised using cipher_context_from_type or
- * cipher_context_from_string.
+ * \param ctx The generic cipher context. May not be NULL. Must have
+ * been initialized using mbedtls_cipher_info_from_type()
+ * or mbedtls_cipher_info_from_string().
* \param key The key to use.
- * \param key_bitlen key length to use, in bits.
- * \param operation Operation that the key will be used for, either
- * MBEDTLS_ENCRYPT or MBEDTLS_DECRYPT.
+ * \param key_bitlen The key length to use, in bits.
+ * \param operation The operation that the key will be used for:
+ * #MBEDTLS_ENCRYPT or #MBEDTLS_DECRYPT.
*
- * \returns 0 on success, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if
- * parameter verification fails or a cipher specific
+ * \returns \c 0 on success, #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if
+ * parameter verification fails, or a cipher-specific
* error code.
*/
int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *key,
#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING)
/**
- * \brief Set padding mode, for cipher modes that use padding.
- * (Default: PKCS7 padding.)
+ * \brief This function sets the padding mode, for cipher modes
+ * that use padding.
+ *
+ * The default passing mode is PKCS7 padding.
*
- * \param ctx generic cipher context
- * \param mode padding mode
+ * \param ctx The generic cipher context.
+ * \param mode The padding mode.
*
- * \returns 0 on success, MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE
- * if selected padding mode is not supported, or
- * MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if the cipher mode
+ * \returns \c 0 on success, #MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE
+ * if the selected padding mode is not supported, or
+ * #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if the cipher mode
* does not support padding.
*/
int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode );
#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
/**
- * \brief Set the initialization vector (IV) or nonce
+ * \brief This function sets the initialization vector (IV)
+ * or nonce.
*
- * \param ctx generic cipher context
- * \param iv IV to use (or NONCE_COUNTER for CTR-mode ciphers)
- * \param iv_len IV length for ciphers with variable-size IV;
- * discarded by ciphers with fixed-size IV.
+ * \param ctx The generic cipher context.
+ * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers.
+ * \param iv_len The IV length for ciphers with variable-size IV.
+ * This parameter is discarded by ciphers with fixed-size IV.
*
- * \returns 0 on success, or MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA
+ * \returns \c 0 on success, or #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA
*
- * \note Some ciphers don't use IVs nor NONCE. For these
- * ciphers, this function has no effect.
+ * \note Some ciphers do not use IVs nor nonce. For these
+ * ciphers, this function has no effect.
*/
int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx,
const unsigned char *iv, size_t iv_len );
/**
- * \brief Finish preparation of the given context
+ * \brief This function resets the cipher state.
*
- * \param ctx generic cipher context
+ * \param ctx The generic cipher context.
*
- * \returns 0 on success, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA
- * if parameter verification fails.
+ * \returns \c 0 on success, #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA
+ * if parameter verification fails.
*/
int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx );
#if defined(MBEDTLS_GCM_C)
/**
- * \brief Add additional data (for AEAD ciphers).
- * Currently only supported with GCM.
- * Must be called exactly once, after mbedtls_cipher_reset().
+ * \brief This function adds additional data for AEAD ciphers.
+ * Only supported with GCM. Must be called
+ * exactly once, after mbedtls_cipher_reset().
*
- * \param ctx generic cipher context
- * \param ad Additional data to use.
- * \param ad_len Length of ad.
+ * \param ctx The generic cipher context.
+ * \param ad The additional data to use.
+ * \param ad_len the Length of \p ad.
*
- * \return 0 on success, or a specific error code.
+ * \return \c 0 on success, or a specific error code on failure.
*/
int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx,
const unsigned char *ad, size_t ad_len );
#endif /* MBEDTLS_GCM_C */
/**
- * \brief Generic cipher update function. Encrypts/decrypts
- * using the given cipher context. Writes as many block
- * size'd blocks of data as possible to output. Any data
- * that cannot be written immediately will either be added
- * to the next block, or flushed when cipher_final is
- * called.
- * Exception: for MBEDTLS_MODE_ECB, expects single block
- * in size (e.g. 16 bytes for AES)
- *
- * \param ctx generic cipher context
- * \param input buffer holding the input data
- * \param ilen length of the input data
- * \param output buffer for the output data. Should be able to hold at
- * least ilen + block_size. Cannot be the same buffer as
- * input!
- * \param olen length of the output data, will be filled with the
- * actual number of bytes written.
- *
- * \returns 0 on success, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if
+ * \brief The generic cipher update function. It encrypts or
+ * decrypts using the given cipher context. Writes as
+ * many block-sized blocks of data as possible to output.
+ * Any data that cannot be written immediately is either
+ * added to the next block, or flushed when
+ * mbedtls_cipher_finish() is called.
+ * Exception: For MBEDTLS_MODE_ECB, expects a single block
+ * in size. For example, 16 Bytes for AES.
+ *
+ * \param ctx The generic cipher context.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ * \param output The buffer for the output data. Must be able to hold at
+ * least \p ilen + block_size. Must not be the same buffer
+ * as input.
+ * \param olen The length of the output data, to be updated with the
+ * actual number of Bytes written.
+ *
+ * \returns \c 0 on success, #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if
* parameter verification fails,
- * MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE on an
- * unsupported mode for a cipher or a cipher specific
+ * #MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE on an
+ * unsupported mode for a cipher, or a cipher-specific
* error code.
*
* \note If the underlying cipher is GCM, all calls to this
- * function, except the last one before mbedtls_cipher_finish(),
- * must have ilen a multiple of the block size.
+ * function, except the last one before
+ * mbedtls_cipher_finish(). Must have \p ilen as a
+ * multiple of the block_size.
*/
int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input,
size_t ilen, unsigned char *output, size_t *olen );
/**
- * \brief Generic cipher finalisation function. If data still
- * needs to be flushed from an incomplete block, data
- * contained within it will be padded with the size of
- * the last block, and written to the output buffer.
+ * \brief The generic cipher finalization function. If data still
+ * needs to be flushed from an incomplete block, the data
+ * contained in it is padded to the size of
+ * the last block, and written to the \p output buffer.
*
- * \param ctx Generic cipher context
- * \param output buffer to write data to. Needs block_size available.
- * \param olen length of the data written to the output buffer.
+ * \param ctx The generic cipher context.
+ * \param output The buffer to write data to. Needs block_size available.
+ * \param olen The length of the data written to the \p output buffer.
*
- * \returns 0 on success, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if
+ * \returns \c 0 on success, #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if
* parameter verification fails,
- * MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED if decryption
+ * #MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED if decryption
* expected a full block but was not provided one,
- * MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding
- * while decrypting or a cipher specific error code.
+ * #MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding
+ * while decrypting, or a cipher-specific error code
+ * on failure for any other reason.
*/
int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx,
unsigned char *output, size_t *olen );
#if defined(MBEDTLS_GCM_C)
/**
- * \brief Write tag for AEAD ciphers.
- * Currently only supported with GCM.
+ * \brief This function writes a tag for AEAD ciphers.
+ * Only supported with GCM.
* Must be called after mbedtls_cipher_finish().
*
- * \param ctx Generic cipher context
- * \param tag buffer to write the tag
- * \param tag_len Length of the tag to write
+ * \param ctx The generic cipher context.
+ * \param tag The buffer to write the tag to.
+ * \param tag_len The length of the tag to write.
*
- * \return 0 on success, or a specific error code.
+ * \return \c 0 on success, or a specific error code on failure.
*/
int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx,
unsigned char *tag, size_t tag_len );
/**
- * \brief Check tag for AEAD ciphers.
- * Currently only supported with GCM.
+ * \brief This function checks the tag for AEAD ciphers.
+ * Only supported with GCM.
* Must be called after mbedtls_cipher_finish().
*
- * \param ctx Generic cipher context
- * \param tag Buffer holding the tag
- * \param tag_len Length of the tag to check
+ * \param ctx The generic cipher context.
+ * \param tag The buffer holding the tag.
+ * \param tag_len The length of the tag to check.
*
- * \return 0 on success, or a specific error code.
+ * \return \c 0 on success, or a specific error code on failure.
*/
int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx,
const unsigned char *tag, size_t tag_len );
#endif /* MBEDTLS_GCM_C */
/**
- * \brief Generic all-in-one encryption/decryption
- * (for all ciphers except AEAD constructs).
- *
- * \param ctx generic cipher context
- * \param iv IV to use (or NONCE_COUNTER for CTR-mode ciphers)
- * \param iv_len IV length for ciphers with variable-size IV;
- * discarded by ciphers with fixed-size IV.
- * \param input buffer holding the input data
- * \param ilen length of the input data
- * \param output buffer for the output data. Should be able to hold at
- * least ilen + block_size. Cannot be the same buffer as
- * input!
- * \param olen length of the output data, will be filled with the
- * actual number of bytes written.
- *
- * \note Some ciphers don't use IVs nor NONCE. For these
- * ciphers, use iv = NULL and iv_len = 0.
- *
- * \returns 0 on success, or
- * MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or
- * MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED if decryption
+ * \brief The generic all-in-one encryption/decryption function,
+ * for all ciphers except AEAD constructs.
+ *
+ * \param ctx The generic cipher context.
+ * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers.
+ * \param iv_len The IV length for ciphers with variable-size IV.
+ * This parameter is discarded by ciphers with fixed-size
+ * IV.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ * \param output The buffer for the output data. Must be able to hold at
+ * least \p ilen + block_size. Must not be the same buffer
+ * as input.
+ * \param olen The length of the output data, to be updated with the
+ * actual number of Bytes written.
+ *
+ * \note Some ciphers do not use IVs nor nonce. For these
+ * ciphers, use \p iv = NULL and \p iv_len = 0.
+ *
+ * \returns \c 0 on success, or
+ * #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or
+ * #MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED if decryption
* expected a full block but was not provided one, or
- * MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding
- * while decrypting, or
- * a cipher specific error code.
+ * #MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding
+ * while decrypting, or a cipher-specific error code on
+ * failure for any other reason.
*/
int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx,
const unsigned char *iv, size_t iv_len,
#if defined(MBEDTLS_CIPHER_MODE_AEAD)
/**
- * \brief Generic autenticated encryption (AEAD ciphers).
- *
- * \param ctx generic cipher context
- * \param iv IV to use (or NONCE_COUNTER for CTR-mode ciphers)
- * \param iv_len IV length for ciphers with variable-size IV;
- * discarded by ciphers with fixed-size IV.
- * \param ad Additional data to authenticate.
- * \param ad_len Length of ad.
- * \param input buffer holding the input data
- * \param ilen length of the input data
- * \param output buffer for the output data.
- * Should be able to hold at least ilen.
- * \param olen length of the output data, will be filled with the
- * actual number of bytes written.
- * \param tag buffer for the authentication tag
- * \param tag_len desired tag length
- *
- * \returns 0 on success, or
- * MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or
- * a cipher specific error code.
+ * \brief The generic autenticated encryption (AEAD) function.
+ *
+ * \param ctx The generic cipher context.
+ * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers.
+ * \param iv_len The IV length for ciphers with variable-size IV.
+ * This parameter is discarded by ciphers with fixed-size IV.
+ * \param ad The additional data to authenticate.
+ * \param ad_len The length of \p ad.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ * \param output The buffer for the output data.
+ * Must be able to hold at least \p ilen.
+ * \param olen The length of the output data, to be updated with the
+ * actual number of Bytes written.
+ * \param tag The buffer for the authentication tag.
+ * \param tag_len The desired length of the authentication tag.
+ *
+ * \returns \c 0 on success, or
+ * #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or
+ * a cipher-specific error code.
*/
int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx,
const unsigned char *iv, size_t iv_len,
unsigned char *tag, size_t tag_len );
/**
- * \brief Generic autenticated decryption (AEAD ciphers).
- *
- * \param ctx generic cipher context
- * \param iv IV to use (or NONCE_COUNTER for CTR-mode ciphers)
- * \param iv_len IV length for ciphers with variable-size IV;
- * discarded by ciphers with fixed-size IV.
- * \param ad Additional data to be authenticated.
- * \param ad_len Length of ad.
- * \param input buffer holding the input data
- * \param ilen length of the input data
- * \param output buffer for the output data.
- * Should be able to hold at least ilen.
- * \param olen length of the output data, will be filled with the
- * actual number of bytes written.
- * \param tag buffer holding the authentication tag
- * \param tag_len length of the authentication tag
- *
- * \returns 0 on success, or
- * MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or
- * MBEDTLS_ERR_CIPHER_AUTH_FAILED if data isn't authentic,
- * or a cipher specific error code.
+ * \brief The generic autenticated decryption (AEAD) function.
+ *
+ * \param ctx The generic cipher context.
+ * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers.
+ * \param iv_len The IV length for ciphers with variable-size IV.
+ * This parameter is discarded by ciphers with fixed-size IV.
+ * \param ad The additional data to be authenticated.
+ * \param ad_len The length of \p ad.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ * \param output The buffer for the output data.
+ * Must be able to hold at least \p ilen.
+ * \param olen The length of the output data, to be updated with the
+ * actual number of Bytes written.
+ * \param tag The buffer holding the authentication tag.
+ * \param tag_len The length of the authentication tag.
+ *
+ * \returns \c 0 on success, or
+ * #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or
+ * #MBEDTLS_ERR_CIPHER_AUTH_FAILED if data is not authentic,
+ * or a cipher-specific error code on failure for any other reason.
*
* \note If the data is not authentic, then the output buffer
- * is zeroed out to prevent the unauthentic plaintext to
- * be used by mistake, making this interface safer.
+ * is zeroed out to prevent the unauthentic plaintext being
+ * used, making this interface safer.
*/
int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx,
const unsigned char *iv, size_t iv_len,
* \brief Cipher wrappers.
*
* \author Adriaan de Jong <dejong@fox-it.com>
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
/**
* \file cmac.h
*
- * \brief Cipher-based Message Authentication Code (CMAC) Mode for
- * Authentication
- *
- * Copyright (C) 2015-2016, ARM Limited, All Rights Reserved
+ * \brief The Cipher-based Message Authentication Code (CMAC) Mode for
+ * Authentication.
+ */
+/*
+ * Copyright (C) 2015-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
+
#ifndef MBEDTLS_CMAC_H
#define MBEDTLS_CMAC_H
extern "C" {
#endif
+#define MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED -0x007A /**< CMAC hardware accelerator failed. */
+
#define MBEDTLS_AES_BLOCK_SIZE 16
#define MBEDTLS_DES3_BLOCK_SIZE 8
#if defined(MBEDTLS_AES_C)
-#define MBEDTLS_CIPHER_BLKSIZE_MAX 16 /* longest used by CMAC is AES */
+#define MBEDTLS_CIPHER_BLKSIZE_MAX 16 /* The longest block used by CMAC is that of AES. */
#else
-#define MBEDTLS_CIPHER_BLKSIZE_MAX 8 /* longest used by CMAC is 3DES */
+#define MBEDTLS_CIPHER_BLKSIZE_MAX 8 /* The longest block used by CMAC is that of 3DES. */
#endif
+#if !defined(MBEDTLS_CMAC_ALT)
+
/**
- * CMAC context structure - Contains internal state information only
+ * The CMAC context structure.
*/
struct mbedtls_cmac_context_t
{
- /** Internal state of the CMAC algorithm */
+ /** The internal state of the CMAC algorithm. */
unsigned char state[MBEDTLS_CIPHER_BLKSIZE_MAX];
/** Unprocessed data - either data that was not block aligned and is still
- * pending to be processed, or the final block */
+ * pending processing, or the final block. */
unsigned char unprocessed_block[MBEDTLS_CIPHER_BLKSIZE_MAX];
- /** Length of data pending to be processed */
+ /** The length of data pending processing. */
size_t unprocessed_len;
};
/**
- * \brief Set the CMAC key and prepare to authenticate the input
- * data.
- * Should be called with an initialised cipher context.
- *
- * \param ctx Cipher context
- * \param key CMAC key
- * \param keybits length of the CMAC key in bits
- * (must be acceptable by the cipher)
- *
- * \return 0 if successful, or a cipher specific error code
+ * \brief This function sets the CMAC key, and prepares to authenticate
+ * the input data.
+ * Must be called with an initialized cipher context.
+ *
+ * \param ctx The cipher context used for the CMAC operation, initialized
+ * as one of the following types:<ul>
+ * <li>MBEDTLS_CIPHER_AES_128_ECB</li>
+ * <li>MBEDTLS_CIPHER_AES_192_ECB</li>
+ * <li>MBEDTLS_CIPHER_AES_256_ECB</li>
+ * <li>MBEDTLS_CIPHER_DES_EDE3_ECB</li></ul>
+ * \param key The CMAC key.
+ * \param keybits The length of the CMAC key in bits.
+ * Must be supported by the cipher.
+ *
+ * \return \c 0 on success, or a cipher-specific error code.
*/
int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx,
const unsigned char *key, size_t keybits );
/**
- * \brief Generic CMAC process buffer.
- * Called between mbedtls_cipher_cmac_starts() or
- * mbedtls_cipher_cmac_reset() and
- * mbedtls_cipher_cmac_finish().
- * May be called repeatedly.
- *
- * \param ctx CMAC context
- * \param input buffer holding the data
- * \param ilen length of the input data
- *
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \brief This function feeds an input buffer into an ongoing CMAC
+ * computation.
+ *
+ * It is called between mbedtls_cipher_cmac_starts() or
+ * mbedtls_cipher_cmac_reset(), and mbedtls_cipher_cmac_finish().
+ * Can be called repeatedly.
+ *
+ * \param ctx The cipher context used for the CMAC operation.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ *
+ * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA
+ * if parameter verification fails.
*/
int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx,
const unsigned char *input, size_t ilen );
/**
- * \brief Output CMAC.
- * Called after mbedtls_cipher_cmac_update().
- * Usually followed by mbedtls_cipher_cmac_reset(), then
- * mbedtls_cipher_cmac_starts(), or mbedtls_cipher_free().
+ * \brief This function finishes the CMAC operation, and writes
+ * the result to the output buffer.
*
- * \param ctx CMAC context
- * \param output Generic CMAC checksum result
+ * It is called after mbedtls_cipher_cmac_update().
+ * It can be followed by mbedtls_cipher_cmac_reset() and
+ * mbedtls_cipher_cmac_update(), or mbedtls_cipher_free().
*
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \param ctx The cipher context used for the CMAC operation.
+ * \param output The output buffer for the CMAC checksum result.
+ *
+ * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA
+ * if parameter verification fails.
*/
int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx,
unsigned char *output );
/**
- * \brief Prepare to authenticate a new message with the same key.
- * Called after mbedtls_cipher_cmac_finish() and before
- * mbedtls_cipher_cmac_update().
+ * \brief This function prepares the authentication of another
+ * message with the same key as the previous CMAC
+ * operation.
+ *
+ * It is called after mbedtls_cipher_cmac_finish()
+ * and before mbedtls_cipher_cmac_update().
*
- * \param ctx CMAC context to be reset
+ * \param ctx The cipher context used for the CMAC operation.
*
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA
+ * if parameter verification fails.
*/
int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx );
/**
- * \brief Output = Generic_CMAC( hmac key, input buffer )
+ * \brief This function calculates the full generic CMAC
+ * on the input buffer with the provided key.
+ *
+ * The function allocates the context, performs the
+ * calculation, and frees the context.
*
- * \param cipher_info message digest info
- * \param key CMAC key
- * \param keylen length of the CMAC key in bits
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output Generic CMAC-result
+ * The CMAC result is calculated as
+ * output = generic CMAC(cmac key, input buffer).
*
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ *
+ * \param cipher_info The cipher information.
+ * \param key The CMAC key.
+ * \param keylen The length of the CMAC key in bits.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ * \param output The buffer for the generic CMAC result.
+ *
+ * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA
+ * if parameter verification fails.
*/
int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info,
const unsigned char *key, size_t keylen,
#if defined(MBEDTLS_AES_C)
/**
- * \brief AES-CMAC-128-PRF
- * Implementation of (AES-CMAC-PRF-128), as defined in RFC 4615
- *
- * \param key PRF key
- * \param key_len PRF key length in bytes
- * \param input buffer holding the input data
- * \param in_len length of the input data in bytes
- * \param output buffer holding the generated pseudorandom output (16 bytes)
- *
- * \return 0 if successful
+ * \brief This function implements the AES-CMAC-PRF-128 pseudorandom
+ * function, as defined in
+ * <em>RFC-4615: The Advanced Encryption Standard-Cipher-based
+ * Message Authentication Code-Pseudo-Random Function-128
+ * (AES-CMAC-PRF-128) Algorithm for the Internet Key
+ * Exchange Protocol (IKE).</em>
+ *
+ * \param key The key to use.
+ * \param key_len The key length in Bytes.
+ * \param input The buffer holding the input data.
+ * \param in_len The length of the input data in Bytes.
+ * \param output The buffer holding the generated 16 Bytes of
+ * pseudorandom output.
+ *
+ * \return \c 0 on success.
*/
int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len,
const unsigned char *input, size_t in_len,
unsigned char output[16] );
#endif /* MBEDTLS_AES_C */
+#ifdef __cplusplus
+}
+#endif
+
+#else /* !MBEDTLS_CMAC_ALT */
+#include "cmac_alt.h"
+#endif /* !MBEDTLS_CMAC_ALT */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) )
/**
- * \brief Checkup routine
+ * \brief The CMAC checkup routine.
*
- * \return 0 if successful, or 1 if the test failed
+ * \return \c 0 on success, or \c 1 on failure.
*/
int mbedtls_cmac_self_test( int verbose );
#endif /* MBEDTLS_SELF_TEST && ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */
* for the PolarSSL naming conventions.
*
* \deprecated Use the new names directly instead
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#if defined MBEDTLS_ERROR_C
#define POLARSSL_ERROR_C MBEDTLS_ERROR_C
#endif
-#if defined MBEDTLS_ERROR_STRERROR_BC
-#define POLARSSL_ERROR_STRERROR_BC MBEDTLS_ERROR_STRERROR_BC
-#endif
#if defined MBEDTLS_ERROR_STRERROR_DUMMY
#define POLARSSL_ERROR_STRERROR_DUMMY MBEDTLS_ERROR_STRERROR_DUMMY
#endif
#if defined MBEDTLS_MEMORY_BUFFER_ALLOC_C
#define POLARSSL_MEMORY_BUFFER_ALLOC_C MBEDTLS_MEMORY_BUFFER_ALLOC_C
#endif
-#if defined MBEDTLS_MEMORY_C
-#define POLARSSL_MEMORY_C MBEDTLS_MEMORY_C
-#endif
#if defined MBEDTLS_MEMORY_DEBUG
#define POLARSSL_MEMORY_DEBUG MBEDTLS_MEMORY_DEBUG
#endif
#if defined MBEDTLS_PADLOCK_C
#define POLARSSL_PADLOCK_C MBEDTLS_PADLOCK_C
#endif
-#if defined MBEDTLS_PBKDF2_C
-#define POLARSSL_PBKDF2_C MBEDTLS_PBKDF2_C
-#endif
#if defined MBEDTLS_PEM_PARSE_C
#define POLARSSL_PEM_PARSE_C MBEDTLS_PEM_PARSE_C
#endif
#if defined MBEDTLS_PLATFORM_STD_FREE
#define POLARSSL_PLATFORM_STD_FREE MBEDTLS_PLATFORM_STD_FREE
#endif
-#if defined MBEDTLS_PLATFORM_STD_MALLOC
-#define POLARSSL_PLATFORM_STD_MALLOC MBEDTLS_PLATFORM_STD_MALLOC
-#endif
#if defined MBEDTLS_PLATFORM_STD_MEM_HDR
#define POLARSSL_PLATFORM_STD_MEM_HDR MBEDTLS_PLATFORM_STD_MEM_HDR
#endif
#if defined MBEDTLS_SHA512_PROCESS_ALT
#define POLARSSL_SHA512_PROCESS_ALT MBEDTLS_SHA512_PROCESS_ALT
#endif
-#if defined MBEDTLS_SSL_AEAD_RANDOM_IV
-#define POLARSSL_SSL_AEAD_RANDOM_IV MBEDTLS_SSL_AEAD_RANDOM_IV
-#endif
-#if defined MBEDTLS_SSL_ALERT_MESSAGES
-#define POLARSSL_SSL_ALERT_MESSAGES MBEDTLS_SSL_ALERT_MESSAGES
-#endif
#if defined MBEDTLS_SSL_ALL_ALERT_MESSAGES
#define POLARSSL_SSL_ALL_ALERT_MESSAGES MBEDTLS_SSL_ALL_ALERT_MESSAGES
#endif
#if defined MBEDTLS_SSL_DEBUG_ALL
#define POLARSSL_SSL_DEBUG_ALL MBEDTLS_SSL_DEBUG_ALL
#endif
-#if defined MBEDTLS_SSL_DISABLE_RENEGOTIATION
-#define POLARSSL_SSL_DISABLE_RENEGOTIATION MBEDTLS_SSL_DISABLE_RENEGOTIATION
-#endif
#if defined MBEDTLS_SSL_DTLS_ANTI_REPLAY
#define POLARSSL_SSL_DTLS_ANTI_REPLAY MBEDTLS_SSL_DTLS_ANTI_REPLAY
#endif
#define KU_KEY_ENCIPHERMENT MBEDTLS_X509_KU_KEY_ENCIPHERMENT
#define KU_NON_REPUDIATION MBEDTLS_X509_KU_NON_REPUDIATION
#define LN_2_DIV_LN_10_SCALE100 MBEDTLS_LN_2_DIV_LN_10_SCALE100
-#define MD_CONTEXT_T_INIT MBEDTLS_MD_CONTEXT_T_INIT
#define MEMORY_VERIFY_ALLOC MBEDTLS_MEMORY_VERIFY_ALLOC
#define MEMORY_VERIFY_ALWAYS MBEDTLS_MEMORY_VERIFY_ALWAYS
#define MEMORY_VERIFY_FREE MBEDTLS_MEMORY_VERIFY_FREE
#define POLARSSL_CONFIG_H MBEDTLS_CONFIG_H
#define POLARSSL_CTR_DRBG_H MBEDTLS_CTR_DRBG_H
#define POLARSSL_DEBUG_H MBEDTLS_DEBUG_H
-#define POLARSSL_DEBUG_LOG_FULL MBEDTLS_DEBUG_LOG_FULL
-#define POLARSSL_DEBUG_LOG_RAW MBEDTLS_DEBUG_LOG_RAW
#define POLARSSL_DECRYPT MBEDTLS_DECRYPT
#define POLARSSL_DES_H MBEDTLS_DES_H
#define POLARSSL_DHM_H MBEDTLS_DHM_H
-#define POLARSSL_DHM_RFC2409_MODP_1024_G MBEDTLS_DHM_RFC2409_MODP_1024_G
-#define POLARSSL_DHM_RFC2409_MODP_1024_P MBEDTLS_DHM_RFC2409_MODP_1024_P
#define POLARSSL_DHM_RFC3526_MODP_2048_G MBEDTLS_DHM_RFC3526_MODP_2048_G
#define POLARSSL_DHM_RFC3526_MODP_2048_P MBEDTLS_DHM_RFC3526_MODP_2048_P
#define POLARSSL_DHM_RFC3526_MODP_3072_G MBEDTLS_DHM_RFC3526_MODP_3072_G
#define POLARSSL_DHM_RFC3526_MODP_3072_P MBEDTLS_DHM_RFC3526_MODP_3072_P
-#define POLARSSL_DHM_RFC5114_MODP_1024_G MBEDTLS_DHM_RFC5114_MODP_1024_G
-#define POLARSSL_DHM_RFC5114_MODP_1024_P MBEDTLS_DHM_RFC5114_MODP_1024_P
#define POLARSSL_DHM_RFC5114_MODP_2048_G MBEDTLS_DHM_RFC5114_MODP_2048_G
#define POLARSSL_DHM_RFC5114_MODP_2048_P MBEDTLS_DHM_RFC5114_MODP_2048_P
#define POLARSSL_ECDH_H MBEDTLS_ECDH_H
#define POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR
#define POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG
#define POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG
-#define POLARSSL_ERR_MD2_FILE_IO_ERROR MBEDTLS_ERR_MD2_FILE_IO_ERROR
-#define POLARSSL_ERR_MD4_FILE_IO_ERROR MBEDTLS_ERR_MD4_FILE_IO_ERROR
-#define POLARSSL_ERR_MD5_FILE_IO_ERROR MBEDTLS_ERR_MD5_FILE_IO_ERROR
#define POLARSSL_ERR_MD_ALLOC_FAILED MBEDTLS_ERR_MD_ALLOC_FAILED
#define POLARSSL_ERR_MD_BAD_INPUT_DATA MBEDTLS_ERR_MD_BAD_INPUT_DATA
#define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE
#define POLARSSL_ERR_OID_BUF_TOO_SMALL MBEDTLS_ERR_OID_BUF_TOO_SMALL
#define POLARSSL_ERR_OID_NOT_FOUND MBEDTLS_ERR_OID_NOT_FOUND
#define POLARSSL_ERR_PADLOCK_DATA_MISALIGNED MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED
-#define POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA MBEDTLS_ERR_PBKDF2_BAD_INPUT_DATA
#define POLARSSL_ERR_PEM_BAD_INPUT_DATA MBEDTLS_ERR_PEM_BAD_INPUT_DATA
#define POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE
#define POLARSSL_ERR_PEM_INVALID_DATA MBEDTLS_ERR_PEM_INVALID_DATA
#define POLARSSL_ERR_PK_TYPE_MISMATCH MBEDTLS_ERR_PK_TYPE_MISMATCH
#define POLARSSL_ERR_PK_UNKNOWN_NAMED_CURVE MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE
#define POLARSSL_ERR_PK_UNKNOWN_PK_ALG MBEDTLS_ERR_PK_UNKNOWN_PK_ALG
-#define POLARSSL_ERR_RIPEMD160_FILE_IO_ERROR MBEDTLS_ERR_RIPEMD160_FILE_IO_ERROR
#define POLARSSL_ERR_RSA_BAD_INPUT_DATA MBEDTLS_ERR_RSA_BAD_INPUT_DATA
#define POLARSSL_ERR_RSA_INVALID_PADDING MBEDTLS_ERR_RSA_INVALID_PADDING
#define POLARSSL_ERR_RSA_KEY_CHECK_FAILED MBEDTLS_ERR_RSA_KEY_CHECK_FAILED
#define POLARSSL_ERR_RSA_PUBLIC_FAILED MBEDTLS_ERR_RSA_PUBLIC_FAILED
#define POLARSSL_ERR_RSA_RNG_FAILED MBEDTLS_ERR_RSA_RNG_FAILED
#define POLARSSL_ERR_RSA_VERIFY_FAILED MBEDTLS_ERR_RSA_VERIFY_FAILED
-#define POLARSSL_ERR_SHA1_FILE_IO_ERROR MBEDTLS_ERR_SHA1_FILE_IO_ERROR
-#define POLARSSL_ERR_SHA256_FILE_IO_ERROR MBEDTLS_ERR_SHA256_FILE_IO_ERROR
-#define POLARSSL_ERR_SHA512_FILE_IO_ERROR MBEDTLS_ERR_SHA512_FILE_IO_ERROR
#define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE
#define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST
#define POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY
#define POLARSSL_MD_SHA512 MBEDTLS_MD_SHA512
#define POLARSSL_MD_WRAP_H MBEDTLS_MD_WRAP_H
#define POLARSSL_MEMORY_BUFFER_ALLOC_H MBEDTLS_MEMORY_BUFFER_ALLOC_H
-#define POLARSSL_MEMORY_H MBEDTLS_MEMORY_H
#define POLARSSL_MODE_CBC MBEDTLS_MODE_CBC
#define POLARSSL_MODE_CCM MBEDTLS_MODE_CCM
#define POLARSSL_MODE_CFB MBEDTLS_MODE_CFB
#define POLARSSL_MPI_MAX_BITS_SCALE100 MBEDTLS_MPI_MAX_BITS_SCALE100
#define POLARSSL_MPI_MAX_LIMBS MBEDTLS_MPI_MAX_LIMBS
#define POLARSSL_MPI_RW_BUFFER_SIZE MBEDTLS_MPI_RW_BUFFER_SIZE
-#define POLARSSL_NET_H MBEDTLS_NET_H
+#define POLARSSL_NET_H MBEDTLS_NET_SOCKETS_H
#define POLARSSL_NET_LISTEN_BACKLOG MBEDTLS_NET_LISTEN_BACKLOG
#define POLARSSL_OID_H MBEDTLS_OID_H
#define POLARSSL_OPERATION_NONE MBEDTLS_OPERATION_NONE
#define POLARSSL_PADDING_ZEROS MBEDTLS_PADDING_ZEROS
#define POLARSSL_PADDING_ZEROS_AND_LEN MBEDTLS_PADDING_ZEROS_AND_LEN
#define POLARSSL_PADLOCK_H MBEDTLS_PADLOCK_H
-#define POLARSSL_PBKDF2_H MBEDTLS_PBKDF2_H
#define POLARSSL_PEM_H MBEDTLS_PEM_H
#define POLARSSL_PKCS11_H MBEDTLS_PKCS11_H
#define POLARSSL_PKCS12_H MBEDTLS_PKCS12_H
#define TLS_RSA_WITH_NULL_SHA256 MBEDTLS_TLS_RSA_WITH_NULL_SHA256
#define TLS_RSA_WITH_RC4_128_MD5 MBEDTLS_TLS_RSA_WITH_RC4_128_MD5
#define TLS_RSA_WITH_RC4_128_SHA MBEDTLS_TLS_RSA_WITH_RC4_128_SHA
-#define UL64 MBEDTLS_UL64
#define X509_CRT_VERSION_1 MBEDTLS_X509_CRT_VERSION_1
#define X509_CRT_VERSION_2 MBEDTLS_X509_CRT_VERSION_2
#define X509_CRT_VERSION_3 MBEDTLS_X509_CRT_VERSION_3
#define _ssl_key_cert mbedtls_ssl_key_cert
#define _ssl_premaster_secret mbedtls_ssl_premaster_secret
#define _ssl_session mbedtls_ssl_session
-#define _ssl_ticket_keys mbedtls_ssl_ticket_keys
#define _ssl_transform mbedtls_ssl_transform
#define _x509_crl mbedtls_x509_crl
#define _x509_crl_entry mbedtls_x509_crl_entry
#define cipher_definitions mbedtls_cipher_definitions
#define cipher_finish mbedtls_cipher_finish
#define cipher_free mbedtls_cipher_free
-#define cipher_free_ctx mbedtls_cipher_free_ctx
#define cipher_get_block_size mbedtls_cipher_get_block_size
#define cipher_get_cipher_mode mbedtls_cipher_get_cipher_mode
#define cipher_get_iv_size mbedtls_cipher_get_iv_size
#define cipher_mode_t mbedtls_cipher_mode_t
#define cipher_padding_t mbedtls_cipher_padding_t
#define cipher_reset mbedtls_cipher_reset
-#define cipher_self_test mbedtls_cipher_self_test
#define cipher_set_iv mbedtls_cipher_set_iv
#define cipher_set_padding_mode mbedtls_cipher_set_padding_mode
#define cipher_setkey mbedtls_cipher_setkey
#define ctr_drbg_context mbedtls_ctr_drbg_context
#define ctr_drbg_free mbedtls_ctr_drbg_free
#define ctr_drbg_init mbedtls_ctr_drbg_init
-#define ctr_drbg_init_entropy_len mbedtls_ctr_drbg_init_entropy_len
#define ctr_drbg_random mbedtls_ctr_drbg_random
#define ctr_drbg_random_with_add mbedtls_ctr_drbg_random_with_add
#define ctr_drbg_reseed mbedtls_ctr_drbg_reseed
#define ctr_drbg_update mbedtls_ctr_drbg_update
#define ctr_drbg_update_seed_file mbedtls_ctr_drbg_update_seed_file
#define ctr_drbg_write_seed_file mbedtls_ctr_drbg_write_seed_file
-#define debug_fmt mbedtls_debug_fmt
#define debug_print_buf mbedtls_debug_print_buf
#define debug_print_crt mbedtls_debug_print_crt
#define debug_print_ecp mbedtls_debug_print_ecp
#define debug_print_mpi mbedtls_debug_print_mpi
#define debug_print_msg mbedtls_debug_print_msg
#define debug_print_ret mbedtls_debug_print_ret
-#define debug_set_log_mode mbedtls_debug_set_log_mode
#define debug_set_threshold mbedtls_debug_set_threshold
#define des3_context mbedtls_des3_context
#define des3_crypt_cbc mbedtls_des3_crypt_cbc
#define ecdh_make_public mbedtls_ecdh_make_public
#define ecdh_read_params mbedtls_ecdh_read_params
#define ecdh_read_public mbedtls_ecdh_read_public
-#define ecdh_self_test mbedtls_ecdh_self_test
#define ecdh_side mbedtls_ecdh_side
#define ecdsa_context mbedtls_ecdsa_context
#define ecdsa_free mbedtls_ecdsa_free
#define ecdsa_info mbedtls_ecdsa_info
#define ecdsa_init mbedtls_ecdsa_init
#define ecdsa_read_signature mbedtls_ecdsa_read_signature
-#define ecdsa_self_test mbedtls_ecdsa_self_test
#define ecdsa_sign mbedtls_ecdsa_sign
#define ecdsa_sign_det mbedtls_ecdsa_sign_det
#define ecdsa_verify mbedtls_ecdsa_verify
#define ecdsa_write_signature_det mbedtls_ecdsa_write_signature_det
#define eckey_info mbedtls_eckey_info
#define eckeydh_info mbedtls_eckeydh_info
-#define ecp_add mbedtls_ecp_add
#define ecp_check_privkey mbedtls_ecp_check_privkey
#define ecp_check_pub_priv mbedtls_ecp_check_pub_priv
#define ecp_check_pubkey mbedtls_ecp_check_pubkey
#define ecp_group_free mbedtls_ecp_group_free
#define ecp_group_id mbedtls_ecp_group_id
#define ecp_group_init mbedtls_ecp_group_init
-#define ecp_group_read_string mbedtls_ecp_group_read_string
#define ecp_grp_id_list mbedtls_ecp_grp_id_list
#define ecp_is_zero mbedtls_ecp_is_zero
#define ecp_keypair mbedtls_ecp_keypair
#define ecp_point_write_binary mbedtls_ecp_point_write_binary
#define ecp_self_test mbedtls_ecp_self_test
#define ecp_set_zero mbedtls_ecp_set_zero
-#define ecp_sub mbedtls_ecp_sub
#define ecp_tls_read_group mbedtls_ecp_tls_read_group
#define ecp_tls_read_point mbedtls_ecp_tls_read_point
#define ecp_tls_write_group mbedtls_ecp_tls_write_group
#define hmac_drbg_context mbedtls_hmac_drbg_context
#define hmac_drbg_free mbedtls_hmac_drbg_free
#define hmac_drbg_init mbedtls_hmac_drbg_init
-#define hmac_drbg_init_buf mbedtls_hmac_drbg_init_buf
#define hmac_drbg_random mbedtls_hmac_drbg_random
#define hmac_drbg_random_with_add mbedtls_hmac_drbg_random_with_add
#define hmac_drbg_reseed mbedtls_hmac_drbg_reseed
#define md mbedtls_md
#define md2 mbedtls_md2
#define md2_context mbedtls_md2_context
-#define md2_file mbedtls_md2_file
#define md2_finish mbedtls_md2_finish
#define md2_free mbedtls_md2_free
-#define md2_hmac mbedtls_md2_hmac
-#define md2_hmac_finish mbedtls_md2_hmac_finish
-#define md2_hmac_reset mbedtls_md2_hmac_reset
-#define md2_hmac_starts mbedtls_md2_hmac_starts
-#define md2_hmac_update mbedtls_md2_hmac_update
#define md2_info mbedtls_md2_info
#define md2_init mbedtls_md2_init
#define md2_process mbedtls_md2_process
#define md2_update mbedtls_md2_update
#define md4 mbedtls_md4
#define md4_context mbedtls_md4_context
-#define md4_file mbedtls_md4_file
#define md4_finish mbedtls_md4_finish
#define md4_free mbedtls_md4_free
-#define md4_hmac mbedtls_md4_hmac
-#define md4_hmac_finish mbedtls_md4_hmac_finish
-#define md4_hmac_reset mbedtls_md4_hmac_reset
-#define md4_hmac_starts mbedtls_md4_hmac_starts
-#define md4_hmac_update mbedtls_md4_hmac_update
#define md4_info mbedtls_md4_info
#define md4_init mbedtls_md4_init
#define md4_process mbedtls_md4_process
#define md4_update mbedtls_md4_update
#define md5 mbedtls_md5
#define md5_context mbedtls_md5_context
-#define md5_file mbedtls_md5_file
#define md5_finish mbedtls_md5_finish
#define md5_free mbedtls_md5_free
-#define md5_hmac mbedtls_md5_hmac
-#define md5_hmac_finish mbedtls_md5_hmac_finish
-#define md5_hmac_reset mbedtls_md5_hmac_reset
-#define md5_hmac_starts mbedtls_md5_hmac_starts
-#define md5_hmac_update mbedtls_md5_hmac_update
#define md5_info mbedtls_md5_info
#define md5_init mbedtls_md5_init
#define md5_process mbedtls_md5_process
#define md_file mbedtls_md_file
#define md_finish mbedtls_md_finish
#define md_free mbedtls_md_free
-#define md_free_ctx mbedtls_md_free_ctx
#define md_get_name mbedtls_md_get_name
#define md_get_size mbedtls_md_get_size
#define md_get_type mbedtls_md_get_type
#define memory_buffer_alloc_status mbedtls_memory_buffer_alloc_status
#define memory_buffer_alloc_verify mbedtls_memory_buffer_alloc_verify
#define memory_buffer_set_verify mbedtls_memory_buffer_set_verify
-#define memory_set_own mbedtls_memory_set_own
#define mpi mbedtls_mpi
#define mpi_add_abs mbedtls_mpi_add_abs
#define mpi_add_int mbedtls_mpi_add_int
#define padlock_supports mbedtls_padlock_has_support
#define padlock_xcryptcbc mbedtls_padlock_xcryptcbc
#define padlock_xcryptecb mbedtls_padlock_xcryptecb
-#define pbkdf2_hmac mbedtls_pbkdf2_hmac
-#define pbkdf2_self_test mbedtls_pbkdf2_self_test
#define pem_context mbedtls_pem_context
#define pem_free mbedtls_pem_free
#define pem_init mbedtls_pem_init
#define platform_entropy_poll mbedtls_platform_entropy_poll
#define platform_set_exit mbedtls_platform_set_exit
#define platform_set_fprintf mbedtls_platform_set_fprintf
-#define platform_set_malloc_free mbedtls_platform_set_malloc_free
#define platform_set_printf mbedtls_platform_set_printf
#define platform_set_snprintf mbedtls_platform_set_snprintf
#define polarssl_exit mbedtls_exit
#define polarssl_fprintf mbedtls_fprintf
#define polarssl_free mbedtls_free
-#define polarssl_malloc mbedtls_malloc
#define polarssl_mutex_free mbedtls_mutex_free
#define polarssl_mutex_init mbedtls_mutex_init
#define polarssl_mutex_lock mbedtls_mutex_lock
#define polarssl_strerror mbedtls_strerror
#define ripemd160 mbedtls_ripemd160
#define ripemd160_context mbedtls_ripemd160_context
-#define ripemd160_file mbedtls_ripemd160_file
#define ripemd160_finish mbedtls_ripemd160_finish
#define ripemd160_free mbedtls_ripemd160_free
-#define ripemd160_hmac mbedtls_ripemd160_hmac
-#define ripemd160_hmac_finish mbedtls_ripemd160_hmac_finish
-#define ripemd160_hmac_reset mbedtls_ripemd160_hmac_reset
-#define ripemd160_hmac_starts mbedtls_ripemd160_hmac_starts
-#define ripemd160_hmac_update mbedtls_ripemd160_hmac_update
#define ripemd160_info mbedtls_ripemd160_info
#define ripemd160_init mbedtls_ripemd160_init
#define ripemd160_process mbedtls_ripemd160_process
#define rsa_check_pubkey mbedtls_rsa_check_pubkey
#define rsa_context mbedtls_rsa_context
#define rsa_copy mbedtls_rsa_copy
-#define rsa_decrypt_func mbedtls_rsa_decrypt_func
#define rsa_free mbedtls_rsa_free
#define rsa_gen_key mbedtls_rsa_gen_key
#define rsa_info mbedtls_rsa_info
#define rsa_init mbedtls_rsa_init
-#define rsa_key_len_func mbedtls_rsa_key_len_func
#define rsa_pkcs1_decrypt mbedtls_rsa_pkcs1_decrypt
#define rsa_pkcs1_encrypt mbedtls_rsa_pkcs1_encrypt
#define rsa_pkcs1_sign mbedtls_rsa_pkcs1_sign
#define rsa_rsassa_pss_verify_ext mbedtls_rsa_rsassa_pss_verify_ext
#define rsa_self_test mbedtls_rsa_self_test
#define rsa_set_padding mbedtls_rsa_set_padding
-#define rsa_sign_func mbedtls_rsa_sign_func
#define safer_memcmp mbedtls_ssl_safer_memcmp
#define set_alarm mbedtls_set_alarm
#define sha1 mbedtls_sha1
#define sha1_context mbedtls_sha1_context
-#define sha1_file mbedtls_sha1_file
#define sha1_finish mbedtls_sha1_finish
#define sha1_free mbedtls_sha1_free
-#define sha1_hmac mbedtls_sha1_hmac
-#define sha1_hmac_finish mbedtls_sha1_hmac_finish
-#define sha1_hmac_reset mbedtls_sha1_hmac_reset
-#define sha1_hmac_starts mbedtls_sha1_hmac_starts
-#define sha1_hmac_update mbedtls_sha1_hmac_update
#define sha1_info mbedtls_sha1_info
#define sha1_init mbedtls_sha1_init
#define sha1_process mbedtls_sha1_process
#define sha224_info mbedtls_sha224_info
#define sha256 mbedtls_sha256
#define sha256_context mbedtls_sha256_context
-#define sha256_file mbedtls_sha256_file
#define sha256_finish mbedtls_sha256_finish
#define sha256_free mbedtls_sha256_free
-#define sha256_hmac mbedtls_sha256_hmac
-#define sha256_hmac_finish mbedtls_sha256_hmac_finish
-#define sha256_hmac_reset mbedtls_sha256_hmac_reset
-#define sha256_hmac_starts mbedtls_sha256_hmac_starts
-#define sha256_hmac_update mbedtls_sha256_hmac_update
#define sha256_info mbedtls_sha256_info
#define sha256_init mbedtls_sha256_init
#define sha256_process mbedtls_sha256_process
#define sha384_info mbedtls_sha384_info
#define sha512 mbedtls_sha512
#define sha512_context mbedtls_sha512_context
-#define sha512_file mbedtls_sha512_file
#define sha512_finish mbedtls_sha512_finish
#define sha512_free mbedtls_sha512_free
-#define sha512_hmac mbedtls_sha512_hmac
-#define sha512_hmac_finish mbedtls_sha512_hmac_finish
-#define sha512_hmac_reset mbedtls_sha512_hmac_reset
-#define sha512_hmac_starts mbedtls_sha512_hmac_starts
-#define sha512_hmac_update mbedtls_sha512_hmac_update
#define sha512_info mbedtls_sha512_info
#define sha512_init mbedtls_sha512_init
#define sha512_process mbedtls_sha512_process
#define ssl_cookie_setup mbedtls_ssl_cookie_setup
#define ssl_cookie_write mbedtls_ssl_cookie_write
#define ssl_cookie_write_t mbedtls_ssl_cookie_write_t
-#define ssl_curve_is_acceptable mbedtls_ssl_curve_is_acceptable
#define ssl_derive_keys mbedtls_ssl_derive_keys
#define ssl_dtls_replay_check mbedtls_ssl_dtls_replay_check
#define ssl_dtls_replay_update mbedtls_ssl_dtls_replay_update
#define ssl_set_arc4_support mbedtls_ssl_conf_arc4_support
#define ssl_set_authmode mbedtls_ssl_conf_authmode
#define ssl_set_bio mbedtls_ssl_set_bio
-#define ssl_set_bio mbedtls_ssl_set_bio_timeout
#define ssl_set_ca_chain mbedtls_ssl_conf_ca_chain
#define ssl_set_cbc_record_splitting mbedtls_ssl_conf_cbc_record_splitting
#define ssl_set_ciphersuites mbedtls_ssl_conf_ciphersuites
#define ssl_set_max_version mbedtls_ssl_conf_max_version
#define ssl_set_min_version mbedtls_ssl_conf_min_version
#define ssl_set_own_cert mbedtls_ssl_conf_own_cert
-#define ssl_set_own_cert_alt mbedtls_ssl_set_own_cert_alt
-#define ssl_set_own_cert_rsa mbedtls_ssl_set_own_cert_rsa
#define ssl_set_psk mbedtls_ssl_conf_psk
#define ssl_set_psk_cb mbedtls_ssl_conf_psk_cb
#define ssl_set_renegotiation mbedtls_ssl_conf_renegotiation
#define ssl_set_rng mbedtls_ssl_conf_rng
#define ssl_set_session mbedtls_ssl_set_session
#define ssl_set_session_cache mbedtls_ssl_conf_session_cache
-#define ssl_set_session_ticket_lifetime mbedtls_ssl_conf_session_ticket_lifetime
#define ssl_set_session_tickets mbedtls_ssl_conf_session_tickets
#define ssl_set_sni mbedtls_ssl_conf_sni
#define ssl_set_transport mbedtls_ssl_conf_transport
#define ssl_set_verify mbedtls_ssl_conf_verify
#define ssl_sig_from_pk mbedtls_ssl_sig_from_pk
#define ssl_states mbedtls_ssl_states
-#define ssl_ticket_keys mbedtls_ssl_ticket_keys
#define ssl_transform mbedtls_ssl_transform
#define ssl_transform_free mbedtls_ssl_transform_free
#define ssl_write mbedtls_ssl_write
#define test_cli_key mbedtls_test_cli_key
#define test_cli_key_ec mbedtls_test_cli_key_ec
#define test_cli_key_rsa mbedtls_test_cli_key_rsa
-#define test_dhm_params mbedtls_test_dhm_params
#define test_srv_crt mbedtls_test_srv_crt
#define test_srv_crt_ec mbedtls_test_srv_crt_ec
#define test_srv_crt_rsa mbedtls_test_srv_crt_rsa
#define x509_get_time mbedtls_x509_get_time
#define x509_key_size_helper mbedtls_x509_key_size_helper
#define x509_name mbedtls_x509_name
-#define x509_oid_get_description mbedtls_x509_oid_get_description
-#define x509_oid_get_numeric_string mbedtls_x509_oid_get_numeric_string
#define x509_self_test mbedtls_x509_self_test
#define x509_sequence mbedtls_x509_sequence
#define x509_serial_gets mbedtls_x509_serial_gets
* This set of compile-time options may be used to enable
* or disable features selectively, and reduce the global
* memory footprint.
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#define MBEDTLS_HAVE_ASM
/**
+ * \def MBEDTLS_NO_UDBL_DIVISION
+ *
+ * The platform lacks support for double-width integer division (64-bit
+ * division on a 32-bit platform, 128-bit division on a 64-bit platform).
+ *
+ * Used in:
+ * include/mbedtls/bignum.h
+ * library/bignum.c
+ *
+ * The bignum code uses double-width division to speed up some operations.
+ * Double-width division is often implemented in software that needs to
+ * be linked with the program. The presence of a double-width integer
+ * type is usually detected automatically through preprocessor macros,
+ * but the automatic detection cannot know whether the code needs to
+ * and can be linked with an implementation of division for that type.
+ * By default division is assumed to be usable if the type is present.
+ * Uncomment this option to prevent the use of double-width division.
+ *
+ * Note that division for the native integer type is always required.
+ * Furthermore, a 64-bit type is always required even on a 32-bit
+ * platform, but it need not support multiplication or division. In some
+ * cases it is also desirable to disable some double-width operations. For
+ * example, if double-width division is implemented in software, disabling
+ * it can reduce code size in some embedded targets.
+ */
+//#define MBEDTLS_NO_UDBL_DIVISION
+
+/**
* \def MBEDTLS_HAVE_SSE2
*
* CPU supports SSE2 instruction set.
//#define MBEDTLS_PLATFORM_PRINTF_ALT
//#define MBEDTLS_PLATFORM_SNPRINTF_ALT
//#define MBEDTLS_PLATFORM_NV_SEED_ALT
+//#define MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT
/**
* \def MBEDTLS_DEPRECATED_WARNING
* \def MBEDTLS_AES_ALT
*
* MBEDTLS__MODULE_NAME__ALT: Uncomment a macro to let mbed TLS use your
- * alternate core implementation of a symmetric crypto or hash module (e.g.
- * platform specific assembly optimized implementations). Keep in mind that
- * the function prototypes should remain the same.
+ * alternate core implementation of a symmetric crypto, an arithmetic or hash
+ * module (e.g. platform specific assembly optimized implementations). Keep
+ * in mind that the function prototypes should remain the same.
*
* This replaces the whole module. If you only want to replace one of the
* functions, use one of the MBEDTLS__FUNCTION_NAME__ALT flags.
*
* Example: In case you uncomment MBEDTLS_AES_ALT, mbed TLS will no longer
- * provide the "struct mbedtls_aes_context" definition and omit the base function
- * declarations and implementations. "aes_alt.h" will be included from
+ * provide the "struct mbedtls_aes_context" definition and omit the base
+ * function declarations and implementations. "aes_alt.h" will be included from
* "aes.h" to include the new function definitions.
*
* Uncomment a macro to enable alternate implementation of the corresponding
* module.
+ *
+ * \warning MD2, MD4, MD5, ARC4, DES and SHA-1 are considered weak and their
+ * use constitutes a security risk. If possible, we recommend
+ * avoiding dependencies on them, and considering stronger message
+ * digests and ciphers instead.
+ *
*/
//#define MBEDTLS_AES_ALT
//#define MBEDTLS_ARC4_ALT
//#define MBEDTLS_BLOWFISH_ALT
//#define MBEDTLS_CAMELLIA_ALT
+//#define MBEDTLS_CCM_ALT
+//#define MBEDTLS_CMAC_ALT
//#define MBEDTLS_DES_ALT
-//#define MBEDTLS_XTEA_ALT
+//#define MBEDTLS_DHM_ALT
+//#define MBEDTLS_ECJPAKE_ALT
+//#define MBEDTLS_GCM_ALT
//#define MBEDTLS_MD2_ALT
//#define MBEDTLS_MD4_ALT
//#define MBEDTLS_MD5_ALT
//#define MBEDTLS_RIPEMD160_ALT
+//#define MBEDTLS_RSA_ALT
//#define MBEDTLS_SHA1_ALT
//#define MBEDTLS_SHA256_ALT
//#define MBEDTLS_SHA512_ALT
+//#define MBEDTLS_XTEA_ALT
+/*
+ * When replacing the elliptic curve module, pleace consider, that it is
+ * implemented with two .c files:
+ * - ecp.c
+ * - ecp_curves.c
+ * You can replace them very much like all the other MBEDTLS__MODULE_NAME__ALT
+ * macros as described above. The only difference is that you have to make sure
+ * that you provide functionality for both .c files.
+ */
+//#define MBEDTLS_ECP_ALT
/**
* \def MBEDTLS_MD2_PROCESS_ALT
* of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible
* with this definition.
*
- * Note: if you use the AES_xxx_ALT macros, then is is recommended to also set
- * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES
- * tables.
+ * \note Because of a signature change, the core AES encryption and decryption routines are
+ * currently named mbedtls_aes_internal_encrypt and mbedtls_aes_internal_decrypt,
+ * respectively. When setting up alternative implementations, these functions should
+ * be overriden, but the wrapper functions mbedtls_aes_decrypt and mbedtls_aes_encrypt
+ * must stay untouched.
+ *
+ * \note If you use the AES_xxx_ALT macros, then is is recommended to also set
+ * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES
+ * tables.
*
* Uncomment a macro to enable alternate implementation of the corresponding
* function.
+ *
+ * \warning MD2, MD4, MD5, DES and SHA-1 are considered weak and their use
+ * constitutes a security risk. If possible, we recommend avoiding
+ * dependencies on them, and considering stronger message digests
+ * and ciphers instead.
+ *
*/
//#define MBEDTLS_MD2_PROCESS_ALT
//#define MBEDTLS_MD4_PROCESS_ALT
//#define MBEDTLS_AES_SETKEY_DEC_ALT
//#define MBEDTLS_AES_ENCRYPT_ALT
//#define MBEDTLS_AES_DECRYPT_ALT
+//#define MBEDTLS_ECDH_GEN_PUBLIC_ALT
+//#define MBEDTLS_ECDH_COMPUTE_SHARED_ALT
+//#define MBEDTLS_ECDSA_VERIFY_ALT
+//#define MBEDTLS_ECDSA_SIGN_ALT
+//#define MBEDTLS_ECDSA_GENKEY_ALT
+
+/**
+ * \def MBEDTLS_ECP_INTERNAL_ALT
+ *
+ * Expose a part of the internal interface of the Elliptic Curve Point module.
+ *
+ * MBEDTLS_ECP__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use your
+ * alternative core implementation of elliptic curve arithmetic. Keep in mind
+ * that function prototypes should remain the same.
+ *
+ * This partially replaces one function. The header file from mbed TLS is still
+ * used, in contrast to the MBEDTLS_ECP_ALT flag. The original implementation
+ * is still present and it is used for group structures not supported by the
+ * alternative.
+ *
+ * Any of these options become available by defining MBEDTLS_ECP_INTERNAL_ALT
+ * and implementing the following functions:
+ * unsigned char mbedtls_internal_ecp_grp_capable(
+ * const mbedtls_ecp_group *grp )
+ * int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp )
+ * void mbedtls_internal_ecp_deinit( const mbedtls_ecp_group *grp )
+ * The mbedtls_internal_ecp_grp_capable function should return 1 if the
+ * replacement functions implement arithmetic for the given group and 0
+ * otherwise.
+ * The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_deinit are
+ * called before and after each point operation and provide an opportunity to
+ * implement optimized set up and tear down instructions.
+ *
+ * Example: In case you uncomment MBEDTLS_ECP_INTERNAL_ALT and
+ * MBEDTLS_ECP_DOUBLE_JAC_ALT, mbed TLS will still provide the ecp_double_jac
+ * function, but will use your mbedtls_internal_ecp_double_jac if the group is
+ * supported (your mbedtls_internal_ecp_grp_capable function returns 1 when
+ * receives it as an argument). If the group is not supported then the original
+ * implementation is used. The other functions and the definition of
+ * mbedtls_ecp_group and mbedtls_ecp_point will not change, so your
+ * implementation of mbedtls_internal_ecp_double_jac and
+ * mbedtls_internal_ecp_grp_capable must be compatible with this definition.
+ *
+ * Uncomment a macro to enable alternate implementation of the corresponding
+ * function.
+ */
+/* Required for all the functions in this section */
+//#define MBEDTLS_ECP_INTERNAL_ALT
+/* Support for Weierstrass curves with Jacobi representation */
+//#define MBEDTLS_ECP_RANDOMIZE_JAC_ALT
+//#define MBEDTLS_ECP_ADD_MIXED_ALT
+//#define MBEDTLS_ECP_DOUBLE_JAC_ALT
+//#define MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT
+//#define MBEDTLS_ECP_NORMALIZE_JAC_ALT
+/* Support for curves with Montgomery arithmetic */
+//#define MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT
+//#define MBEDTLS_ECP_RANDOMIZE_MXZ_ALT
+//#define MBEDTLS_ECP_NORMALIZE_MXZ_ALT
/**
* \def MBEDTLS_TEST_NULL_ENTROPY
* MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA
*
* Uncomment this macro to enable weak ciphersuites
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers instead.
*/
//#define MBEDTLS_ENABLE_WEAK_CIPHERSUITES
* MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256
* MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA
* MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA
+ *
+ * \warning Using DHE constitutes a security risk as it
+ * is not possible to validate custom DH parameters.
+ * If possible, it is recommended users should consider
+ * preferring other methods of key exchange.
+ * See dhm.h for more details.
+ *
*/
#define MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
* MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
* MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
* MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
+ *
+ * \warning Using DHE constitutes a security risk as it
+ * is not possible to validate custom DH parameters.
+ * If possible, it is recommended users should consider
+ * preferring other methods of key exchange.
+ * See dhm.h for more details.
+ *
*/
#define MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
/**
* \def MBEDTLS_RSA_NO_CRT
*
- * Do not use the Chinese Remainder Theorem for the RSA private operation.
+ * Do not use the Chinese Remainder Theorem
+ * for the RSA private operation.
*
* Uncomment this macro to disable the use of CRT in RSA.
*
* misuse/misunderstand.
*
* Comment this to disable support for renegotiation.
+ *
+ * \note Even if this option is disabled, both client and server are aware
+ * of the Renegotiation Indication Extension (RFC 5746) used to
+ * prevent the SSL renegotiation attack (see RFC 5746 Sect. 1).
+ * (See \c mbedtls_ssl_conf_legacy_renegotiation for the
+ * configuration of this extension).
+ *
*/
#define MBEDTLS_SSL_RENEGOTIATION
#define MBEDTLS_SSL_TRUNCATED_HMAC
/**
+ * \def MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT
+ *
+ * Fallback to old (pre-2.7), non-conforming implementation of the truncated
+ * HMAC extension which also truncates the HMAC key. Note that this option is
+ * only meant for a transitory upgrade period and is likely to be removed in
+ * a future version of the library.
+ *
+ * \warning The old implementation is non-compliant and has a security weakness
+ * (2^80 brute force attack on the HMAC key used for a single,
+ * uninterrupted connection). This should only be enabled temporarily
+ * when (1) the use of truncated HMAC is essential in order to save
+ * bandwidth, and (2) the peer is an Mbed TLS stack that doesn't use
+ * the fixed implementation yet (pre-2.7).
+ *
+ * \deprecated This option is deprecated and will likely be removed in a
+ * future version of Mbed TLS.
+ *
+ * Uncomment to fallback to old, non-compliant truncated HMAC implementation.
+ *
+ * Requires: MBEDTLS_SSL_TRUNCATED_HMAC
+ */
+//#define MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT
+
+/**
* \def MBEDTLS_THREADING_ALT
*
* Provide your own alternate threading implementation.
*
* \note Currently compression can't be used with DTLS.
*
+ * \deprecated This feature is deprecated and will be removed
+ * in the next major revision of the library.
+ *
* Used in: library/ssl_tls.c
* library/ssl_cli.c
* library/ssl_srv.c
* MBEDTLS_TLS_RSA_WITH_RC4_128_MD5
* MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA
* MBEDTLS_TLS_PSK_WITH_RC4_128_SHA
+ *
+ * \warning ARC4 is considered a weak cipher and its use constitutes a
+ * security risk. If possible, we recommend avoidng dependencies on
+ * it, and considering stronger ciphers instead.
+ *
*/
#define MBEDTLS_ARC4_C
* library/pkwrite.c
* library/x509_create.c
* library/x509write_crt.c
- * library/mbedtls_x509write_csr.c
+ * library/x509write_csr.c
*/
#define MBEDTLS_ASN1_WRITE_C
* library/ecp.c
* library/ecdsa.c
* library/rsa.c
+ * library/rsa_internal.c
* library/ssl_tls.c
*
* This module is required for RSA, DHM and ECC (ECDH, ECDSA) support.
* MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA
*
* PEM_PARSE uses DES/3DES for decrypting encrypted keys.
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers instead.
*/
#define MBEDTLS_DES_C
*
* This module is used by the following key exchanges:
* DHE-RSA, DHE-PSK
+ *
+ * \warning Using DHE constitutes a security risk as it
+ * is not possible to validate custom DH parameters.
+ * If possible, it is recommended users should consider
+ * preferring other methods of key exchange.
+ * See dhm.h for more details.
+ *
*/
#define MBEDTLS_DHM_C
*
* Enable the generic message digest layer.
*
- * Module: library/mbedtls_md.c
+ * Module: library/md.c
* Caller:
*
* Uncomment to enable generic message digest wrappers.
*
* Enable the MD2 hash algorithm.
*
- * Module: library/mbedtls_md2.c
+ * Module: library/md2.c
* Caller:
*
* Uncomment to enable support for (rare) MD2-signed X.509 certs.
+ *
+ * \warning MD2 is considered a weak message digest and its use constitutes a
+ * security risk. If possible, we recommend avoiding dependencies on
+ * it, and considering stronger message digests instead.
+ *
*/
//#define MBEDTLS_MD2_C
*
* Enable the MD4 hash algorithm.
*
- * Module: library/mbedtls_md4.c
+ * Module: library/md4.c
* Caller:
*
* Uncomment to enable support for (rare) MD4-signed X.509 certs.
+ *
+ * \warning MD4 is considered a weak message digest and its use constitutes a
+ * security risk. If possible, we recommend avoiding dependencies on
+ * it, and considering stronger message digests instead.
+ *
*/
//#define MBEDTLS_MD4_C
*
* Enable the MD5 hash algorithm.
*
- * Module: library/mbedtls_md5.c
- * Caller: library/mbedtls_md.c
+ * Module: library/md5.c
+ * Caller: library/md.c
* library/pem.c
* library/ssl_tls.c
*
- * This module is required for SSL/TLS and X.509.
- * PEM_PARSE uses MD5 for decrypting encrypted keys.
+ * This module is required for SSL/TLS up to version 1.1, and for TLS 1.2
+ * depending on the handshake parameters. Further, it is used for checking
+ * MD5-signed certificates, and for PBKDF1 when decrypting PEM-encoded
+ * encrypted keys.
+ *
+ * \warning MD5 is considered a weak message digest and its use constitutes a
+ * security risk. If possible, we recommend avoiding dependencies on
+ * it, and considering stronger message digests instead.
+ *
*/
#define MBEDTLS_MD5_C
* library/rsa.c
* library/x509.c
* library/x509_create.c
- * library/mbedtls_x509_crl.c
- * library/mbedtls_x509_crt.c
- * library/mbedtls_x509_csr.c
+ * library/x509_crl.c
+ * library/x509_crt.c
+ * library/x509_csr.c
* library/x509write_crt.c
- * library/mbedtls_x509write_csr.c
+ * library/x509write_csr.c
*
* This modules translates between OIDs and internal values.
*/
* Module: library/pem.c
* Caller: library/dhm.c
* library/pkparse.c
- * library/mbedtls_x509_crl.c
- * library/mbedtls_x509_crt.c
- * library/mbedtls_x509_csr.c
+ * library/x509_crl.c
+ * library/x509_crt.c
+ * library/x509_csr.c
*
* Requires: MBEDTLS_BASE64_C
*
* Module: library/pem.c
* Caller: library/pkwrite.c
* library/x509write_crt.c
- * library/mbedtls_x509write_csr.c
+ * library/x509write_csr.c
*
* Requires: MBEDTLS_BASE64_C
*
* Enable the generic public (asymetric) key parser.
*
* Module: library/pkparse.c
- * Caller: library/mbedtls_x509_crt.c
- * library/mbedtls_x509_csr.c
+ * Caller: library/x509_crt.c
+ * library/x509_csr.c
*
* Requires: MBEDTLS_PK_C
*
*
* Enable the RIPEMD-160 hash algorithm.
*
- * Module: library/mbedtls_ripemd160.c
- * Caller: library/mbedtls_md.c
+ * Module: library/ripemd160.c
+ * Caller: library/md.c
*
*/
#define MBEDTLS_RIPEMD160_C
* Enable the RSA public-key cryptosystem.
*
* Module: library/rsa.c
+ * library/rsa_internal.c
* Caller: library/ssl_cli.c
* library/ssl_srv.c
* library/ssl_tls.c
*
* Enable the SHA1 cryptographic hash algorithm.
*
- * Module: library/mbedtls_sha1.c
- * Caller: library/mbedtls_md.c
+ * Module: library/sha1.c
+ * Caller: library/md.c
* library/ssl_cli.c
* library/ssl_srv.c
* library/ssl_tls.c
* library/x509write_crt.c
*
- * This module is required for SSL/TLS and SHA1-signed certificates.
+ * This module is required for SSL/TLS up to version 1.1, for TLS 1.2
+ * depending on the handshake parameters, and for SHA1-signed certificates.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use constitutes
+ * a security risk. If possible, we recommend avoiding dependencies
+ * on it, and considering stronger message digests instead.
+ *
*/
#define MBEDTLS_SHA1_C
*
* Enable the SHA-224 and SHA-256 cryptographic hash algorithms.
*
- * Module: library/mbedtls_sha256.c
+ * Module: library/sha256.c
* Caller: library/entropy.c
- * library/mbedtls_md.c
+ * library/md.c
* library/ssl_cli.c
* library/ssl_srv.c
* library/ssl_tls.c
*
* Enable the SHA-384 and SHA-512 cryptographic hash algorithms.
*
- * Module: library/mbedtls_sha512.c
+ * Module: library/sha512.c
* Caller: library/entropy.c
- * library/mbedtls_md.c
+ * library/md.c
* library/ssl_cli.c
* library/ssl_srv.c
*
* Enable X.509 core for using certificates.
*
* Module: library/x509.c
- * Caller: library/mbedtls_x509_crl.c
- * library/mbedtls_x509_crt.c
- * library/mbedtls_x509_csr.c
+ * Caller: library/x509_crl.c
+ * library/x509_crt.c
+ * library/x509_csr.c
*
* Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_BIGNUM_C, MBEDTLS_OID_C,
* MBEDTLS_PK_PARSE_C
*
* Enable X.509 certificate parsing.
*
- * Module: library/mbedtls_x509_crt.c
+ * Module: library/x509_crt.c
* Caller: library/ssl_cli.c
* library/ssl_srv.c
* library/ssl_tls.c
*
* Enable X.509 CRL parsing.
*
- * Module: library/mbedtls_x509_crl.c
- * Caller: library/mbedtls_x509_crt.c
+ * Module: library/x509_crl.c
+ * Caller: library/x509_crt.c
*
* Requires: MBEDTLS_X509_USE_C
*
*
* Enable X.509 Certificate Signing Request (CSR) parsing.
*
- * Module: library/mbedtls_x509_csr.c
+ * Module: library/x509_csr.c
* Caller: library/x509_crt_write.c
*
* Requires: MBEDTLS_X509_USE_C
//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */
//#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the null terminator character ('\0'). */
+/**
+ * Allow SHA-1 in the default TLS configuration for certificate signing.
+ * Without this build-time option, SHA-1 support must be activated explicitly
+ * through mbedtls_ssl_conf_cert_profile. Turning on this option is not
+ * recommended because of it is possible to generate SHA-1 collisions, however
+ * this may be safe for legacy infrastructure where additional controls apply.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use constitutes
+ * a security risk. If possible, we recommend avoiding dependencies
+ * on it, and considering stronger message digests instead.
+ *
+ */
+// #define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
+
+/**
+ * Allow SHA-1 in the default TLS configuration for TLS 1.2 handshake
+ * signature and ciphersuite selection. Without this build-time option, SHA-1
+ * support must be activated explicitly through mbedtls_ssl_conf_sig_hashes.
+ * The use of SHA-1 in TLS <= 1.1 and in HMAC-SHA-1 is always allowed by
+ * default. At the time of writing, there is no practical attack on the use
+ * of SHA-1 in handshake signatures, hence this option is turned on by default
+ * to preserve compatibility with existing peers, but the general
+ * warning applies nonetheless:
+ *
+ * \warning SHA-1 is considered a weak message digest and its use constitutes
+ * a security risk. If possible, we recommend avoiding dependencies
+ * on it, and considering stronger message digests instead.
+ *
+ */
+#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE
+
/* \} name SECTION: Customisation configuration options */
/* Target and application specific configurations */
/**
* \file ctr_drbg.h
*
- * \brief CTR_DRBG based on AES-256 (NIST SP 800-90)
+ * \brief CTR_DRBG is based on AES-256, as defined in <em>NIST SP 800-90A:
+ * Recommendation for Random Number Generation Using Deterministic
+ * Random Bit Generators</em>.
*
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
+
#ifndef MBEDTLS_CTR_DRBG_H
#define MBEDTLS_CTR_DRBG_H
#endif
#define MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED -0x0034 /**< The entropy source failed. */
-#define MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG -0x0036 /**< Too many random requested in single call. */
-#define MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG -0x0038 /**< Input too large (Entropy + additional). */
-#define MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR -0x003A /**< Read/write error in file. */
+#define MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG -0x0036 /**< The requested random buffer length is too big. */
+#define MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG -0x0038 /**< The input (entropy + additional data) is too large. */
+#define MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR -0x003A /**< Read or write error in file. */
-#define MBEDTLS_CTR_DRBG_BLOCKSIZE 16 /**< Block size used by the cipher */
-#define MBEDTLS_CTR_DRBG_KEYSIZE 32 /**< Key size used by the cipher */
-#define MBEDTLS_CTR_DRBG_KEYBITS ( MBEDTLS_CTR_DRBG_KEYSIZE * 8 )
-#define MBEDTLS_CTR_DRBG_SEEDLEN ( MBEDTLS_CTR_DRBG_KEYSIZE + MBEDTLS_CTR_DRBG_BLOCKSIZE )
- /**< The seed length (counter + AES key) */
+#define MBEDTLS_CTR_DRBG_BLOCKSIZE 16 /**< The block size used by the cipher. */
+#define MBEDTLS_CTR_DRBG_KEYSIZE 32 /**< The key size used by the cipher. */
+#define MBEDTLS_CTR_DRBG_KEYBITS ( MBEDTLS_CTR_DRBG_KEYSIZE * 8 ) /**< The key size for the DRBG operation, in bits. */
+#define MBEDTLS_CTR_DRBG_SEEDLEN ( MBEDTLS_CTR_DRBG_KEYSIZE + MBEDTLS_CTR_DRBG_BLOCKSIZE ) /**< The seed length, calculated as (counter + AES key). */
/**
* \name SECTION: Module settings
*
* The configuration options you can set for this module are in this section.
- * Either change them in config.h or define them on the compiler command line.
+ * Either change them in config.h or define them using the compiler command
+ * line.
* \{
*/
#if !defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN)
#if defined(MBEDTLS_SHA512_C) && !defined(MBEDTLS_ENTROPY_FORCE_SHA256)
-#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */
+#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48
+/**< The amount of entropy used per seed by default:
+ * <ul><li>48 with SHA-512.</li>
+ * <li>32 with SHA-256.</li></ul>
+ */
#else
-#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 32 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with SHA-256) */
+#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 32
+/**< Amount of entropy used per seed by default:
+ * <ul><li>48 with SHA-512.</li>
+ * <li>32 with SHA-256.</li></ul>
+ */
#endif
#endif
#if !defined(MBEDTLS_CTR_DRBG_RESEED_INTERVAL)
-#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */
+#define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000
+/**< The interval before reseed is performed by default. */
#endif
#if !defined(MBEDTLS_CTR_DRBG_MAX_INPUT)
-#define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */
+#define MBEDTLS_CTR_DRBG_MAX_INPUT 256
+/**< The maximum number of additional input Bytes. */
#endif
#if !defined(MBEDTLS_CTR_DRBG_MAX_REQUEST)
-#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */
+#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024
+/**< The maximum number of requested Bytes per call. */
#endif
#if !defined(MBEDTLS_CTR_DRBG_MAX_SEED_INPUT)
-#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */
+#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384
+/**< The maximum size of seed or reseed buffer. */
#endif
/* \} name SECTION: Module settings */
-#define MBEDTLS_CTR_DRBG_PR_OFF 0 /**< No prediction resistance */
-#define MBEDTLS_CTR_DRBG_PR_ON 1 /**< Prediction resistance enabled */
+#define MBEDTLS_CTR_DRBG_PR_OFF 0
+/**< Prediction resistance is disabled. */
+#define MBEDTLS_CTR_DRBG_PR_ON 1
+/**< Prediction resistance is enabled. */
#ifdef __cplusplus
extern "C" {
#endif
/**
- * \brief CTR_DRBG context structure
+ * \brief The CTR_DRBG context structure.
*/
typedef struct
{
- unsigned char counter[16]; /*!< counter (V) */
- int reseed_counter; /*!< reseed counter */
- int prediction_resistance; /*!< enable prediction resistance (Automatic
- reseed before every random generation) */
- size_t entropy_len; /*!< amount of entropy grabbed on each
- (re)seed */
- int reseed_interval; /*!< reseed interval */
-
- mbedtls_aes_context aes_ctx; /*!< AES context */
+ unsigned char counter[16]; /*!< The counter (V). */
+ int reseed_counter; /*!< The reseed counter. */
+ int prediction_resistance; /*!< This determines whether prediction
+ resistance is enabled, that is
+ whether to systematically reseed before
+ each random generation. */
+ size_t entropy_len; /*!< The amount of entropy grabbed on each
+ seed or reseed operation. */
+ int reseed_interval; /*!< The reseed interval. */
+
+ mbedtls_aes_context aes_ctx; /*!< The AES context. */
/*
* Callbacks (Entropy)
*/
int (*f_entropy)(void *, unsigned char *, size_t);
+ /*!< The entropy callback function. */
- void *p_entropy; /*!< context for the entropy function */
+ void *p_entropy; /*!< The context for the entropy function. */
#if defined(MBEDTLS_THREADING_C)
mbedtls_threading_mutex_t mutex;
mbedtls_ctr_drbg_context;
/**
- * \brief CTR_DRBG context initialization
- * Makes the context ready for mbedtls_ctr_drbg_seed() or
- * mbedtls_ctr_drbg_free().
+ * \brief This function initializes the CTR_DRBG context,
+ * and prepares it for mbedtls_ctr_drbg_seed()
+ * or mbedtls_ctr_drbg_free().
*
- * \param ctx CTR_DRBG context to be initialized
+ * \param ctx The CTR_DRBG context to initialize.
*/
void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *ctx );
/**
- * \brief CTR_DRBG initial seeding
- * Seed and setup entropy source for future reseeds.
+ * \brief This function seeds and sets up the CTR_DRBG
+ * entropy source for future reseeds.
*
- * Note: Personalization data can be provided in addition to the more generic
- * entropy source to make this instantiation as unique as possible.
+ * \note Personalization data can be provided in addition to the more generic
+ * entropy source, to make this instantiation as unique as possible.
*
- * \param ctx CTR_DRBG context to be seeded
- * \param f_entropy Entropy callback (p_entropy, buffer to fill, buffer
- * length)
- * \param p_entropy Entropy context
- * \param custom Personalization data (Device specific identifiers)
- * (Can be NULL)
- * \param len Length of personalization data
+ * \param ctx The CTR_DRBG context to seed.
+ * \param f_entropy The entropy callback, taking as arguments the
+ * \p p_entropy context, the buffer to fill, and the
+ length of the buffer.
+ * \param p_entropy The entropy context.
+ * \param custom Personalization data, that is device-specific
+ identifiers. Can be NULL.
+ * \param len The length of the personalization data.
*
- * \return 0 if successful, or
- * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED
+ * \return \c 0 on success, or
+ * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure.
*/
int mbedtls_ctr_drbg_seed( mbedtls_ctr_drbg_context *ctx,
int (*f_entropy)(void *, unsigned char *, size_t),
size_t len );
/**
- * \brief Clear CTR_CRBG context data
+ * \brief This function clears CTR_CRBG context data.
*
- * \param ctx CTR_DRBG context to clear
+ * \param ctx The CTR_DRBG context to clear.
*/
void mbedtls_ctr_drbg_free( mbedtls_ctr_drbg_context *ctx );
/**
- * \brief Enable / disable prediction resistance (Default: Off)
+ * \brief This function turns prediction resistance on or off.
+ * The default value is off.
*
- * Note: If enabled, entropy is used for ctx->entropy_len before each call!
- * Only use this if you have ample supply of good entropy!
+ * \note If enabled, entropy is gathered at the beginning of
+ * every call to mbedtls_ctr_drbg_random_with_add().
+ * Only use this if your entropy source has sufficient
+ * throughput.
*
- * \param ctx CTR_DRBG context
- * \param resistance MBEDTLS_CTR_DRBG_PR_ON or MBEDTLS_CTR_DRBG_PR_OFF
+ * \param ctx The CTR_DRBG context.
+ * \param resistance #MBEDTLS_CTR_DRBG_PR_ON or #MBEDTLS_CTR_DRBG_PR_OFF.
*/
void mbedtls_ctr_drbg_set_prediction_resistance( mbedtls_ctr_drbg_context *ctx,
int resistance );
/**
- * \brief Set the amount of entropy grabbed on each (re)seed
- * (Default: MBEDTLS_CTR_DRBG_ENTROPY_LEN)
+ * \brief This function sets the amount of entropy grabbed on each
+ * seed or reseed. The default value is
+ * #MBEDTLS_CTR_DRBG_ENTROPY_LEN.
*
- * \param ctx CTR_DRBG context
- * \param len Amount of entropy to grab
+ * \param ctx The CTR_DRBG context.
+ * \param len The amount of entropy to grab.
*/
void mbedtls_ctr_drbg_set_entropy_len( mbedtls_ctr_drbg_context *ctx,
size_t len );
/**
- * \brief Set the reseed interval
- * (Default: MBEDTLS_CTR_DRBG_RESEED_INTERVAL)
+ * \brief This function sets the reseed interval.
+ * The default value is #MBEDTLS_CTR_DRBG_RESEED_INTERVAL.
*
- * \param ctx CTR_DRBG context
- * \param interval Reseed interval
+ * \param ctx The CTR_DRBG context.
+ * \param interval The reseed interval.
*/
void mbedtls_ctr_drbg_set_reseed_interval( mbedtls_ctr_drbg_context *ctx,
int interval );
/**
- * \brief CTR_DRBG reseeding (extracts data from entropy source)
+ * \brief This function reseeds the CTR_DRBG context, that is
+ * extracts data from the entropy source.
*
- * \param ctx CTR_DRBG context
- * \param additional Additional data to add to state (Can be NULL)
- * \param len Length of additional data
+ * \param ctx The CTR_DRBG context.
+ * \param additional Additional data to add to the state. Can be NULL.
+ * \param len The length of the additional data.
*
- * \return 0 if successful, or
- * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED
+ * \return \c 0 on success, or
+ * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure.
*/
int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx,
const unsigned char *additional, size_t len );
/**
- * \brief CTR_DRBG update state
+ * \brief This function updates the state of the CTR_DRBG context.
*
- * \param ctx CTR_DRBG context
- * \param additional Additional data to update state with
- * \param add_len Length of additional data
+ * \param ctx The CTR_DRBG context.
+ * \param additional The data to update the state with.
+ * \param add_len Length of \p additional data.
*
- * \note If add_len is greater than MBEDTLS_CTR_DRBG_MAX_SEED_INPUT,
- * only the first MBEDTLS_CTR_DRBG_MAX_SEED_INPUT bytes are used,
- * the remaining ones are silently discarded.
+ * \note If \p add_len is greater than #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT,
+ * only the first #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT Bytes are used.
+ * The remaining Bytes are silently discarded.
*/
void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx,
const unsigned char *additional, size_t add_len );
/**
- * \brief CTR_DRBG generate random with additional update input
+ * \brief This function updates a CTR_DRBG instance with additional
+ * data and uses it to generate random data.
*
- * Note: Automatically reseeds if reseed_counter is reached.
+ * \note The function automatically reseeds if the reseed counter is exceeded.
*
- * \param p_rng CTR_DRBG context
- * \param output Buffer to fill
- * \param output_len Length of the buffer
- * \param additional Additional data to update with (Can be NULL)
- * \param add_len Length of additional data
+ * \param p_rng The CTR_DRBG context. This must be a pointer to a
+ * #mbedtls_ctr_drbg_context structure.
+ * \param output The buffer to fill.
+ * \param output_len The length of the buffer.
+ * \param additional Additional data to update. Can be NULL.
+ * \param add_len The length of the additional data.
*
- * \return 0 if successful, or
- * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED, or
- * MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG
+ * \return \c 0 on success, or
+ * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or
+ * #MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG on failure.
*/
int mbedtls_ctr_drbg_random_with_add( void *p_rng,
unsigned char *output, size_t output_len,
const unsigned char *additional, size_t add_len );
/**
- * \brief CTR_DRBG generate random
+ * \brief This function uses CTR_DRBG to generate random data.
*
- * Note: Automatically reseeds if reseed_counter is reached.
+ * \note The function automatically reseeds if the reseed counter is exceeded.
*
- * \param p_rng CTR_DRBG context
- * \param output Buffer to fill
- * \param output_len Length of the buffer
+ * \param p_rng The CTR_DRBG context. This must be a pointer to a
+ * #mbedtls_ctr_drbg_context structure.
+ * \param output The buffer to fill.
+ * \param output_len The length of the buffer.
*
- * \return 0 if successful, or
- * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED, or
- * MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG
+ * \return \c 0 on success, or
+ * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or
+ * #MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG on failure.
*/
int mbedtls_ctr_drbg_random( void *p_rng,
unsigned char *output, size_t output_len );
#if defined(MBEDTLS_FS_IO)
/**
- * \brief Write a seed file
+ * \brief This function writes a seed file.
*
- * \param ctx CTR_DRBG context
- * \param path Name of the file
+ * \param ctx The CTR_DRBG context.
+ * \param path The name of the file.
*
- * \return 0 if successful,
- * MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error, or
- * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED
+ * \return \c 0 on success,
+ * #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error, or
+ * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on
+ * failure.
*/
int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path );
/**
- * \brief Read and update a seed file. Seed is added to this
- * instance
+ * \brief This function reads and updates a seed file. The seed
+ * is added to this instance.
*
- * \param ctx CTR_DRBG context
- * \param path Name of the file
+ * \param ctx The CTR_DRBG context.
+ * \param path The name of the file.
*
- * \return 0 if successful,
- * MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error,
- * MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or
- * MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG
+ * \return \c 0 on success,
+ * #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error,
+ * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or
+ * #MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG on failure.
*/
int mbedtls_ctr_drbg_update_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path );
#endif /* MBEDTLS_FS_IO */
/**
- * \brief Checkup routine
+ * \brief The CTR_DRBG checkup routine.
*
- * \return 0 if successful, or 1 if the test failed
+ * \return \c 0 on success, or \c 1 on failure.
*/
int mbedtls_ctr_drbg_self_test( int verbose );
* \file debug.h
*
* \brief Functions for controlling and providing debug output from the library.
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
*
* \brief DES block cipher
*
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
+ *
*/
#ifndef MBEDTLS_DES_H
#define MBEDTLS_DES_H
#define MBEDTLS_DES_DECRYPT 0
#define MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH -0x0032 /**< The data input has an invalid length. */
+#define MBEDTLS_ERR_DES_HW_ACCEL_FAILED -0x0033 /**< DES hardware accelerator failed. */
#define MBEDTLS_DES_KEY_SIZE 8
/**
* \brief DES context structure
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
*/
typedef struct
{
* \brief Initialize DES context
*
* \param ctx DES context to be initialized
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
*/
void mbedtls_des_init( mbedtls_des_context *ctx );
* \brief Clear DES context
*
* \param ctx DES context to be cleared
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
*/
void mbedtls_des_free( mbedtls_des_context *ctx );
* a parity bit to allow verification.
*
* \param key 8-byte secret key
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
*/
void mbedtls_des_key_set_parity( unsigned char key[MBEDTLS_DES_KEY_SIZE] );
* \param key 8-byte secret key
*
* \return 0 is parity was ok, 1 if parity was not correct.
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
*/
int mbedtls_des_key_check_key_parity( const unsigned char key[MBEDTLS_DES_KEY_SIZE] );
* \param key 8-byte secret key
*
* \return 0 if no weak key was found, 1 if a weak key was identified.
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
*/
int mbedtls_des_key_check_weak( const unsigned char key[MBEDTLS_DES_KEY_SIZE] );
* \param key 8-byte secret key
*
* \return 0
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
*/
int mbedtls_des_setkey_enc( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] );
* \param key 8-byte secret key
*
* \return 0
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
*/
int mbedtls_des_setkey_dec( mbedtls_des_context *ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE] );
* \param output 64-bit output block
*
* \return 0 if successful
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
*/
int mbedtls_des_crypt_ecb( mbedtls_des_context *ctx,
const unsigned char input[8],
* \param iv initialization vector (updated after use)
* \param input buffer holding the input data
* \param output buffer holding the output data
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
*/
int mbedtls_des_crypt_cbc( mbedtls_des_context *ctx,
int mode,
*
* \param SK Round keys
* \param key Base key
+ *
+ * \warning DES is considered a weak cipher and its use constitutes a
+ * security risk. We recommend considering stronger ciphers
+ * instead.
*/
void mbedtls_des_setkey( uint32_t SK[32],
const unsigned char key[MBEDTLS_DES_KEY_SIZE] );
/**
* \file dhm.h
*
- * \brief Diffie-Hellman-Merkle key exchange
+ * \brief Diffie-Hellman-Merkle key exchange.
*
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ * <em>RFC-3526: More Modular Exponential (MODP) Diffie-Hellman groups for
+ * Internet Key Exchange (IKE)</em> defines a number of standardized
+ * Diffie-Hellman groups for IKE.
+ *
+ * <em>RFC-5114: Additional Diffie-Hellman Groups for Use with IETF
+ * Standards</em> defines a number of standardized Diffie-Hellman
+ * groups that can be used.
+ *
+ * \warning The security of the DHM key exchange relies on the proper choice
+ * of prime modulus - optimally, it should be a safe prime. The usage
+ * of non-safe primes both decreases the difficulty of the underlying
+ * discrete logarithm problem and can lead to small subgroup attacks
+ * leaking private exponent bits when invalid public keys are used
+ * and not detected. This is especially relevant if the same DHM
+ * parameters are reused for multiple key exchanges as in static DHM,
+ * while the criticality of small-subgroup attacks is lower for
+ * ephemeral DHM.
+ *
+ * \warning For performance reasons, the code does neither perform primality
+ * nor safe primality tests, nor the expensive checks for invalid
+ * subgroups. Moreover, even if these were performed, non-standardized
+ * primes cannot be trusted because of the possibility of backdoors
+ * that can't be effectively checked for.
+ *
+ * \warning Diffie-Hellman-Merkle is therefore a security risk when not using
+ * standardized primes generated using a trustworthy ("nothing up
+ * my sleeve") method, such as the RFC 3526 / 7919 primes. In the TLS
+ * protocol, DH parameters need to be negotiated, so using the default
+ * primes systematically is not always an option. If possible, use
+ * Elliptic Curve Diffie-Hellman (ECDH), which has better performance,
+ * and for which the TLS protocol mandates the use of standard
+ * parameters.
+ *
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
+
#ifndef MBEDTLS_DHM_H
#define MBEDTLS_DHM_H
+#if !defined(MBEDTLS_CONFIG_FILE)
+#include "config.h"
+#else
+#include MBEDTLS_CONFIG_FILE
+#endif
#include "bignum.h"
+#if !defined(MBEDTLS_DHM_ALT)
/*
* DHM Error codes
*/
-#define MBEDTLS_ERR_DHM_BAD_INPUT_DATA -0x3080 /**< Bad input parameters to function. */
+#define MBEDTLS_ERR_DHM_BAD_INPUT_DATA -0x3080 /**< Bad input parameters. */
#define MBEDTLS_ERR_DHM_READ_PARAMS_FAILED -0x3100 /**< Reading of the DHM parameters failed. */
#define MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED -0x3180 /**< Making of the DHM parameters failed. */
#define MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED -0x3200 /**< Reading of the public values failed. */
#define MBEDTLS_ERR_DHM_CALC_SECRET_FAILED -0x3300 /**< Calculation of the DHM secret failed. */
#define MBEDTLS_ERR_DHM_INVALID_FORMAT -0x3380 /**< The ASN.1 data is not formatted correctly. */
#define MBEDTLS_ERR_DHM_ALLOC_FAILED -0x3400 /**< Allocation of memory failed. */
-#define MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480 /**< Read/write of file failed. */
-
-/**
- * RFC 3526 defines a number of standardized Diffie-Hellman groups
- * for IKE.
- * RFC 5114 defines a number of standardized Diffie-Hellman groups
- * that can be used.
- *
- * Some are included here for convenience.
- *
- * Included are:
- * RFC 3526 3. 2048-bit MODP Group
- * RFC 3526 4. 3072-bit MODP Group
- * RFC 3526 5. 4096-bit MODP Group
- * RFC 5114 2.2. 2048-bit MODP Group with 224-bit Prime Order Subgroup
- */
-#define MBEDTLS_DHM_RFC3526_MODP_2048_P \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
- "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
- "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
- "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
- "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
- "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
- "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
- "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
- "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
- "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
- "15728E5A8AACAA68FFFFFFFFFFFFFFFF"
-
-#define MBEDTLS_DHM_RFC3526_MODP_2048_G "02"
-
-#define MBEDTLS_DHM_RFC3526_MODP_3072_P \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
- "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
- "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
- "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
- "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
- "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
- "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
- "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
- "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
- "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
- "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
- "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
- "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
- "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
- "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
- "43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF"
-
-#define MBEDTLS_DHM_RFC3526_MODP_3072_G "02"
-
-#define MBEDTLS_DHM_RFC3526_MODP_4096_P \
- "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
- "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
- "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
- "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
- "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
- "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
- "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
- "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
- "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
- "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
- "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
- "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
- "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
- "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
- "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
- "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" \
- "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" \
- "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" \
- "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" \
- "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" \
- "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199" \
- "FFFFFFFFFFFFFFFF"
-
-#define MBEDTLS_DHM_RFC3526_MODP_4096_G "02"
-
-#define MBEDTLS_DHM_RFC5114_MODP_2048_P \
- "AD107E1E9123A9D0D660FAA79559C51FA20D64E5683B9FD1" \
- "B54B1597B61D0A75E6FA141DF95A56DBAF9A3C407BA1DF15" \
- "EB3D688A309C180E1DE6B85A1274A0A66D3F8152AD6AC212" \
- "9037C9EDEFDA4DF8D91E8FEF55B7394B7AD5B7D0B6C12207" \
- "C9F98D11ED34DBF6C6BA0B2C8BBC27BE6A00E0A0B9C49708" \
- "B3BF8A317091883681286130BC8985DB1602E714415D9330" \
- "278273C7DE31EFDC7310F7121FD5A07415987D9ADC0A486D" \
- "CDF93ACC44328387315D75E198C641A480CD86A1B9E587E8" \
- "BE60E69CC928B2B9C52172E413042E9B23F10B0E16E79763" \
- "C9B53DCF4BA80A29E3FB73C16B8E75B97EF363E2FFA31F71" \
- "CF9DE5384E71B81C0AC4DFFE0C10E64F"
-
-#define MBEDTLS_DHM_RFC5114_MODP_2048_G \
- "AC4032EF4F2D9AE39DF30B5C8FFDAC506CDEBE7B89998CAF"\
- "74866A08CFE4FFE3A6824A4E10B9A6F0DD921F01A70C4AFA"\
- "AB739D7700C29F52C57DB17C620A8652BE5E9001A8D66AD7"\
- "C17669101999024AF4D027275AC1348BB8A762D0521BC98A"\
- "E247150422EA1ED409939D54DA7460CDB5F6C6B250717CBE"\
- "F180EB34118E98D119529A45D6F834566E3025E316A330EF"\
- "BB77A86F0C1AB15B051AE3D428C8F8ACB70A8137150B8EEB"\
- "10E183EDD19963DDD9E263E4770589EF6AA21E7F5F2FF381"\
- "B539CCE3409D13CD566AFBB48D6C019181E1BCFE94B30269"\
- "EDFE72FE9B6AA4BD7B5A0F1C71CFFF4C19C418E1F6EC0179"\
- "81BC087F2A7065B384B890D3191F2BFA"
+#define MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480 /**< Read or write of file failed. */
+#define MBEDTLS_ERR_DHM_HW_ACCEL_FAILED -0x3500 /**< DHM hardware accelerator failed. */
+#define MBEDTLS_ERR_DHM_SET_GROUP_FAILED -0x3580 /**< Setting the modulus and generator failed. */
#ifdef __cplusplus
extern "C" {
#endif
/**
- * \brief DHM context structure
+ * \brief The DHM context structure.
*/
typedef struct
{
- size_t len; /*!< size(P) in chars */
- mbedtls_mpi P; /*!< prime modulus */
- mbedtls_mpi G; /*!< generator */
- mbedtls_mpi X; /*!< secret value */
- mbedtls_mpi GX; /*!< self = G^X mod P */
- mbedtls_mpi GY; /*!< peer = G^Y mod P */
- mbedtls_mpi K; /*!< key = GY^X mod P */
- mbedtls_mpi RP; /*!< cached R^2 mod P */
- mbedtls_mpi Vi; /*!< blinding value */
- mbedtls_mpi Vf; /*!< un-blinding value */
- mbedtls_mpi pX; /*!< previous X */
+ size_t len; /*!< The size of \p P in Bytes. */
+ mbedtls_mpi P; /*!< The prime modulus. */
+ mbedtls_mpi G; /*!< The generator. */
+ mbedtls_mpi X; /*!< Our secret value. */
+ mbedtls_mpi GX; /*!< Our public key = \c G^X mod \c P. */
+ mbedtls_mpi GY; /*!< The public key of the peer = \c G^Y mod \c P. */
+ mbedtls_mpi K; /*!< The shared secret = \c G^(XY) mod \c P. */
+ mbedtls_mpi RP; /*!< The cached value = \c R^2 mod \c P. */
+ mbedtls_mpi Vi; /*!< The blinding value. */
+ mbedtls_mpi Vf; /*!< The unblinding value. */
+ mbedtls_mpi pX; /*!< The previous \c X. */
}
mbedtls_dhm_context;
/**
- * \brief Initialize DHM context
+ * \brief This function initializes the DHM context.
*
- * \param ctx DHM context to be initialized
+ * \param ctx The DHM context to initialize.
*/
void mbedtls_dhm_init( mbedtls_dhm_context *ctx );
/**
- * \brief Parse the ServerKeyExchange parameters
+ * \brief This function parses the ServerKeyExchange parameters.
*
- * \param ctx DHM context
- * \param p &(start of input buffer)
- * \param end end of buffer
+ * \param ctx The DHM context.
+ * \param p On input, *p must be the start of the input buffer.
+ * On output, *p is updated to point to the end of the data
+ * that has been read. On success, this is the first byte
+ * past the end of the ServerKeyExchange parameters.
+ * On error, this is the point at which an error has been
+ * detected, which is usually not useful except to debug
+ * failures.
+ * \param end The end of the input buffer.
*
- * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code
+ * on failure.
*/
int mbedtls_dhm_read_params( mbedtls_dhm_context *ctx,
unsigned char **p,
const unsigned char *end );
/**
- * \brief Setup and write the ServerKeyExchange parameters
+ * \brief This function sets up and writes the ServerKeyExchange
+ * parameters.
*
- * \param ctx DHM context
- * \param x_size private value size in bytes
- * \param output destination buffer
- * \param olen number of chars written
- * \param f_rng RNG function
- * \param p_rng RNG parameter
+ * \param ctx The DHM context.
+ * \param x_size The private value size in Bytes.
+ * \param olen The number of characters written.
+ * \param output The destination buffer.
+ * \param f_rng The RNG function.
+ * \param p_rng The RNG parameter.
*
- * \note This function assumes that ctx->P and ctx->G
- * have already been properly set (for example
- * using mbedtls_mpi_read_string or mbedtls_mpi_read_binary).
+ * \note The destination buffer must be large enough to hold
+ * the reduced binary presentation of the modulus, the generator
+ * and the public key, each wrapped with a 2-byte length field.
+ * It is the responsibility of the caller to ensure that enough
+ * space is available. Refer to \c mbedtls_mpi_size to computing
+ * the byte-size of an MPI.
*
- * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
+ * \note This function assumes that \c ctx->P and \c ctx->G
+ * have already been properly set. For that, use
+ * mbedtls_dhm_set_group() below in conjunction with
+ * mbedtls_mpi_read_binary() and mbedtls_mpi_read_string().
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code
+ * on failure.
*/
int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size,
unsigned char *output, size_t *olen,
void *p_rng );
/**
- * \brief Import the peer's public value G^Y
+ * \brief Set prime modulus and generator
+ *
+ * \param ctx The DHM context.
+ * \param P The MPI holding DHM prime modulus.
+ * \param G The MPI holding DHM generator.
*
- * \param ctx DHM context
- * \param input input buffer
- * \param ilen size of buffer
+ * \note This function can be used to set P, G
+ * in preparation for \c mbedtls_dhm_make_params.
*
- * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
+ * \return \c 0 if successful, or an \c MBEDTLS_ERR_DHM_XXX error code
+ * on failure.
+ */
+int mbedtls_dhm_set_group( mbedtls_dhm_context *ctx,
+ const mbedtls_mpi *P,
+ const mbedtls_mpi *G );
+
+/**
+ * \brief This function imports the public value G^Y of the peer.
+ *
+ * \param ctx The DHM context.
+ * \param input The input buffer.
+ * \param ilen The size of the input buffer.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code
+ * on failure.
*/
int mbedtls_dhm_read_public( mbedtls_dhm_context *ctx,
const unsigned char *input, size_t ilen );
/**
- * \brief Create own private value X and export G^X
+ * \brief This function creates its own private value \c X and
+ * exports \c G^X.
+ *
+ * \param ctx The DHM context.
+ * \param x_size The private value size in Bytes.
+ * \param output The destination buffer.
+ * \param olen The length of the destination buffer. Must be at least
+ equal to ctx->len (the size of \c P).
+ * \param f_rng The RNG function.
+ * \param p_rng The RNG parameter.
*
- * \param ctx DHM context
- * \param x_size private value size in bytes
- * \param output destination buffer
- * \param olen must be at least equal to the size of P, ctx->len
- * \param f_rng RNG function
- * \param p_rng RNG parameter
+ * \note The destination buffer will always be fully written
+ * so as to contain a big-endian presentation of G^X mod P.
+ * If it is larger than ctx->len, it will accordingly be
+ * padded with zero-bytes in the beginning.
*
- * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code
+ * on failure.
*/
int mbedtls_dhm_make_public( mbedtls_dhm_context *ctx, int x_size,
unsigned char *output, size_t olen,
void *p_rng );
/**
- * \brief Derive and export the shared secret (G^Y)^X mod P
- *
- * \param ctx DHM context
- * \param output destination buffer
- * \param output_size size of the destination buffer
- * \param olen on exit, holds the actual number of bytes written
- * \param f_rng RNG function, for blinding purposes
- * \param p_rng RNG parameter
- *
- * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
- *
- * \note If non-NULL, f_rng is used to blind the input as
- * countermeasure against timing attacks. Blinding is
- * automatically used if and only if our secret value X is
- * re-used and costs nothing otherwise, so it is recommended
- * to always pass a non-NULL f_rng argument.
+ * \brief This function derives and exports the shared secret
+ * \c (G^Y)^X mod \c P.
+ *
+ * \param ctx The DHM context.
+ * \param output The destination buffer.
+ * \param output_size The size of the destination buffer. Must be at least
+ * the size of ctx->len.
+ * \param olen On exit, holds the actual number of Bytes written.
+ * \param f_rng The RNG function, for blinding purposes.
+ * \param p_rng The RNG parameter.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code
+ * on failure.
+ *
+ * \note If non-NULL, \p f_rng is used to blind the input as
+ * a countermeasure against timing attacks. Blinding is used
+ * only if our secret value \p X is re-used and omitted
+ * otherwise. Therefore, we recommend always passing a
+ * non-NULL \p f_rng argument.
*/
int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx,
unsigned char *output, size_t output_size, size_t *olen,
void *p_rng );
/**
- * \brief Free and clear the components of a DHM key
+ * \brief This function frees and clears the components of a DHM key.
*
- * \param ctx DHM context to free and clear
+ * \param ctx The DHM context to free and clear.
*/
void mbedtls_dhm_free( mbedtls_dhm_context *ctx );
#if defined(MBEDTLS_ASN1_PARSE_C)
/** \ingroup x509_module */
/**
- * \brief Parse DHM parameters in PEM or DER format
+ * \brief This function parses DHM parameters in PEM or DER format.
*
- * \param dhm DHM context to be initialized
- * \param dhmin input buffer
- * \param dhminlen size of the buffer
- * (including the terminating null byte for PEM data)
+ * \param dhm The DHM context to initialize.
+ * \param dhmin The input buffer.
+ * \param dhminlen The size of the buffer, including the terminating null
+ * Byte for PEM data.
*
- * \return 0 if successful, or a specific DHM or PEM error code
+ * \return \c 0 on success, or a specific DHM or PEM error code
+ * on failure.
*/
int mbedtls_dhm_parse_dhm( mbedtls_dhm_context *dhm, const unsigned char *dhmin,
size_t dhminlen );
#if defined(MBEDTLS_FS_IO)
/** \ingroup x509_module */
/**
- * \brief Load and parse DHM parameters
+ * \brief This function loads and parses DHM parameters from a file.
*
- * \param dhm DHM context to be initialized
- * \param path filename to read the DHM Parameters from
+ * \param dhm The DHM context to load the parameters to.
+ * \param path The filename to read the DHM parameters from.
*
- * \return 0 if successful, or a specific DHM or PEM error code
+ * \return \c 0 on success, or a specific DHM or PEM error code
+ * on failure.
*/
int mbedtls_dhm_parse_dhmfile( mbedtls_dhm_context *dhm, const char *path );
#endif /* MBEDTLS_FS_IO */
#endif /* MBEDTLS_ASN1_PARSE_C */
+#ifdef __cplusplus
+}
+#endif
+
+#else /* MBEDTLS_DHM_ALT */
+#include "dhm_alt.h"
+#endif /* MBEDTLS_DHM_ALT */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
- * \brief Checkup routine
+ * \brief The DMH checkup routine.
*
- * \return 0 if successful, or 1 if the test failed
+ * \return \c 0 on success, or \c 1 on failure.
*/
int mbedtls_dhm_self_test( int verbose );
}
#endif
+/**
+ * RFC 3526, RFC 5114 and RFC 7919 standardize a number of
+ * Diffie-Hellman groups, some of which are included here
+ * for use within the SSL/TLS module and the user's convenience
+ * when configuring the Diffie-Hellman parameters by hand
+ * through \c mbedtls_ssl_conf_dh_param.
+ *
+ * The following lists the source of the above groups in the standards:
+ * - RFC 5114 section 2.2: 2048-bit MODP Group with 224-bit Prime Order Subgroup
+ * - RFC 3526 section 3: 2048-bit MODP Group
+ * - RFC 3526 section 4: 3072-bit MODP Group
+ * - RFC 3526 section 5: 4096-bit MODP Group
+ * - RFC 7919 section A.1: ffdhe2048
+ * - RFC 7919 section A.2: ffdhe3072
+ * - RFC 7919 section A.3: ffdhe4096
+ * - RFC 7919 section A.4: ffdhe6144
+ * - RFC 7919 section A.5: ffdhe8192
+ *
+ * The constants with suffix "_p" denote the chosen prime moduli, while
+ * the constants with suffix "_g" denote the chosen generator
+ * of the associated prime field.
+ *
+ * The constants further suffixed with "_bin" are provided in binary format,
+ * while all other constants represent null-terminated strings holding the
+ * hexadecimal presentation of the respective numbers.
+ *
+ * The primes from RFC 3526 and RFC 7919 have been generating by the following
+ * trust-worthy procedure:
+ * - Fix N in { 2048, 3072, 4096, 6144, 8192 } and consider the N-bit number
+ * the first and last 64 bits are all 1, and the remaining N - 128 bits of
+ * which are 0x7ff...ff.
+ * - Add the smallest multiple of the first N - 129 bits of the binary expansion
+ * of pi (for RFC 5236) or e (for RFC 7919) to this intermediate bit-string
+ * such that the resulting integer is a safe-prime.
+ * - The result is the respective RFC 3526 / 7919 prime, and the corresponding
+ * generator is always chosen to be 2 (which is a square for these prime,
+ * hence the corresponding subgroup has order (p-1)/2 and avoids leaking a
+ * bit in the private exponent).
+ *
+ */
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+MBEDTLS_DEPRECATED typedef char const * mbedtls_deprecated_constant_t;
+#define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) \
+ ( (mbedtls_deprecated_constant_t) ( VAL ) )
+#else
+#define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) VAL
+#endif /* ! MBEDTLS_DEPRECATED_WARNING */
+
+/**
+ * \warning The origin of the primes in RFC 5114 is not documented and
+ * their use therefore constitutes a security risk!
+ *
+ * \deprecated The hex-encoded primes from RFC 5114 are deprecated and are
+ * likely to be removed in a future version of the library without
+ * replacement.
+ */
+
+/**
+ * The hexadecimal presentation of the prime underlying the
+ * 2048-bit MODP Group with 224-bit Prime Order Subgroup, as defined
+ * in <em>RFC-5114: Additional Diffie-Hellman Groups for Use with
+ * IETF Standards</em>.
+ */
+#define MBEDTLS_DHM_RFC5114_MODP_2048_P \
+ MBEDTLS_DEPRECATED_STRING_CONSTANT( \
+ "AD107E1E9123A9D0D660FAA79559C51FA20D64E5683B9FD1" \
+ "B54B1597B61D0A75E6FA141DF95A56DBAF9A3C407BA1DF15" \
+ "EB3D688A309C180E1DE6B85A1274A0A66D3F8152AD6AC212" \
+ "9037C9EDEFDA4DF8D91E8FEF55B7394B7AD5B7D0B6C12207" \
+ "C9F98D11ED34DBF6C6BA0B2C8BBC27BE6A00E0A0B9C49708" \
+ "B3BF8A317091883681286130BC8985DB1602E714415D9330" \
+ "278273C7DE31EFDC7310F7121FD5A07415987D9ADC0A486D" \
+ "CDF93ACC44328387315D75E198C641A480CD86A1B9E587E8" \
+ "BE60E69CC928B2B9C52172E413042E9B23F10B0E16E79763" \
+ "C9B53DCF4BA80A29E3FB73C16B8E75B97EF363E2FFA31F71" \
+ "CF9DE5384E71B81C0AC4DFFE0C10E64F" )
+
+/**
+ * The hexadecimal presentation of the chosen generator of the 2048-bit MODP
+ * Group with 224-bit Prime Order Subgroup, as defined in <em>RFC-5114:
+ * Additional Diffie-Hellman Groups for Use with IETF Standards</em>.
+ */
+#define MBEDTLS_DHM_RFC5114_MODP_2048_G \
+ MBEDTLS_DEPRECATED_STRING_CONSTANT( \
+ "AC4032EF4F2D9AE39DF30B5C8FFDAC506CDEBE7B89998CAF" \
+ "74866A08CFE4FFE3A6824A4E10B9A6F0DD921F01A70C4AFA" \
+ "AB739D7700C29F52C57DB17C620A8652BE5E9001A8D66AD7" \
+ "C17669101999024AF4D027275AC1348BB8A762D0521BC98A" \
+ "E247150422EA1ED409939D54DA7460CDB5F6C6B250717CBE" \
+ "F180EB34118E98D119529A45D6F834566E3025E316A330EF" \
+ "BB77A86F0C1AB15B051AE3D428C8F8ACB70A8137150B8EEB" \
+ "10E183EDD19963DDD9E263E4770589EF6AA21E7F5F2FF381" \
+ "B539CCE3409D13CD566AFBB48D6C019181E1BCFE94B30269" \
+ "EDFE72FE9B6AA4BD7B5A0F1C71CFFF4C19C418E1F6EC0179" \
+ "81BC087F2A7065B384B890D3191F2BFA" )
+
+/**
+ * The hexadecimal presentation of the prime underlying the 2048-bit MODP
+ * Group, as defined in <em>RFC-3526: More Modular Exponential (MODP)
+ * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
+ *
+ * \deprecated The hex-encoded primes from RFC 3625 are deprecated and
+ * superseded by the corresponding macros providing them as
+ * binary constants. Their hex-encoded constants are likely
+ * to be removed in a future version of the library.
+ *
+ */
+#define MBEDTLS_DHM_RFC3526_MODP_2048_P \
+ MBEDTLS_DEPRECATED_STRING_CONSTANT( \
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
+ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
+ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
+ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
+ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
+ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
+ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
+ "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
+ "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
+ "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
+ "15728E5A8AACAA68FFFFFFFFFFFFFFFF" )
+
+/**
+ * The hexadecimal presentation of the chosen generator of the 2048-bit MODP
+ * Group, as defined in <em>RFC-3526: More Modular Exponential (MODP)
+ * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
+ */
+#define MBEDTLS_DHM_RFC3526_MODP_2048_G \
+ MBEDTLS_DEPRECATED_STRING_CONSTANT( "02" )
+
+/**
+ * The hexadecimal presentation of the prime underlying the 3072-bit MODP
+ * Group, as defined in <em>RFC-3072: More Modular Exponential (MODP)
+ * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
+ */
+#define MBEDTLS_DHM_RFC3526_MODP_3072_P \
+ MBEDTLS_DEPRECATED_STRING_CONSTANT( \
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
+ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
+ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
+ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
+ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
+ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
+ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
+ "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
+ "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
+ "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
+ "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
+ "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
+ "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
+ "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
+ "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
+ "43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF" )
+
+/**
+ * The hexadecimal presentation of the chosen generator of the 3072-bit MODP
+ * Group, as defined in <em>RFC-3526: More Modular Exponential (MODP)
+ * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
+ */
+#define MBEDTLS_DHM_RFC3526_MODP_3072_G \
+ MBEDTLS_DEPRECATED_STRING_CONSTANT( "02" )
+
+/**
+ * The hexadecimal presentation of the prime underlying the 4096-bit MODP
+ * Group, as defined in <em>RFC-3526: More Modular Exponential (MODP)
+ * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
+ */
+#define MBEDTLS_DHM_RFC3526_MODP_4096_P \
+ MBEDTLS_DEPRECATED_STRING_CONSTANT( \
+ "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
+ "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
+ "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
+ "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
+ "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
+ "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
+ "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
+ "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
+ "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
+ "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
+ "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
+ "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
+ "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
+ "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
+ "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
+ "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" \
+ "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" \
+ "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" \
+ "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" \
+ "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" \
+ "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199" \
+ "FFFFFFFFFFFFFFFF" )
+
+/**
+ * The hexadecimal presentation of the chosen generator of the 4096-bit MODP
+ * Group, as defined in <em>RFC-3526: More Modular Exponential (MODP)
+ * Diffie-Hellman groups for Internet Key Exchange (IKE)</em>.
+ */
+#define MBEDTLS_DHM_RFC3526_MODP_4096_G \
+ MBEDTLS_DEPRECATED_STRING_CONSTANT( "02" )
+
+#endif /* MBEDTLS_DEPRECATED_REMOVED */
+
+/*
+ * Trustworthy DHM parameters in binary form
+ */
+
+#define MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN { \
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \
+ 0xC9, 0x0F, 0xDA, 0xA2, 0x21, 0x68, 0xC2, 0x34, \
+ 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1, \
+ 0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, \
+ 0x02, 0x0B, 0xBE, 0xA6, 0x3B, 0x13, 0x9B, 0x22, \
+ 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD, \
+ 0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, \
+ 0x30, 0x2B, 0x0A, 0x6D, 0xF2, 0x5F, 0x14, 0x37, \
+ 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45, \
+ 0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, \
+ 0xF4, 0x4C, 0x42, 0xE9, 0xA6, 0x37, 0xED, 0x6B, \
+ 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED, \
+ 0xE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1E, 0xFC, 0x8C, 0xE0, 0xBA, 0x8A, 0x4F, 0xE8, \
+ 0xB6, 0x85, 0x5D, 0xFE, 0x72, 0xB0, 0xA6, 0x6E, \
+ 0xDE, 0xD2, 0xFB, 0xAB, 0xFB, 0xE5, 0x8A, 0x30, \
+ 0xFA, 0xFA, 0xBE, 0x1C, 0x5D, 0x71, 0xA8, 0x7E, \
+ 0x2F, 0x74, 0x1E, 0xF8, 0xC1, 0xFE, 0x86, 0xFE, \
+ 0xA6, 0xBB, 0xFD, 0xE5, 0x30, 0x67, 0x7F, 0x0D, \
+ 0x97, 0xD1, 0x1D, 0x49, 0xF7, 0xA8, 0x44, 0x3D, \
+ 0x08, 0x22, 0xE5, 0x06, 0xA9, 0xF4, 0x61, 0x4E, \
+ 0x01, 0x1E, 0x2A, 0x94, 0x83, 0x8F, 0xF8, 0x8C, \
+ 0xD6, 0x8C, 0x8B, 0xB7, 0xC5, 0xC6, 0x42, 0x4C, \
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
+
+#define MBEDTLS_DHM_RFC7919_FFDHE8192_G_BIN { 0x02 }
+
#endif /* dhm.h */
/**
* \file ecdh.h
*
- * \brief Elliptic curve Diffie-Hellman
+ * \brief The Elliptic Curve Diffie-Hellman (ECDH) protocol APIs.
*
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ * ECDH is an anonymous key agreement protocol allowing two parties to
+ * establish a shared secret over an insecure channel. Each party must have an
+ * elliptic-curve public–private key pair.
+ *
+ * For more information, see <em>NIST SP 800-56A Rev. 2: Recommendation for
+ * Pair-Wise Key Establishment Schemes Using Discrete Logarithm
+ * Cryptography</em>.
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
+
#ifndef MBEDTLS_ECDH_H
#define MBEDTLS_ECDH_H
#endif
/**
- * When importing from an EC key, select if it is our key or the peer's key
+ * Defines the source of the imported EC key:
+ * <ul><li>Our key.</li>
+ * <li>The key of the peer.</li></ul>
*/
typedef enum
{
} mbedtls_ecdh_side;
/**
- * \brief ECDH context structure
+ * \brief The ECDH context structure.
*/
typedef struct
{
- mbedtls_ecp_group grp; /*!< elliptic curve used */
- mbedtls_mpi d; /*!< our secret value (private key) */
- mbedtls_ecp_point Q; /*!< our public value (public key) */
- mbedtls_ecp_point Qp; /*!< peer's public value (public key) */
- mbedtls_mpi z; /*!< shared secret */
- int point_format; /*!< format for point export in TLS messages */
- mbedtls_ecp_point Vi; /*!< blinding value (for later) */
- mbedtls_ecp_point Vf; /*!< un-blinding value (for later) */
- mbedtls_mpi _d; /*!< previous d (for later) */
+ mbedtls_ecp_group grp; /*!< The elliptic curve used. */
+ mbedtls_mpi d; /*!< The private key. */
+ mbedtls_ecp_point Q; /*!< The public key. */
+ mbedtls_ecp_point Qp; /*!< The value of the public key of the peer. */
+ mbedtls_mpi z; /*!< The shared secret. */
+ int point_format; /*!< The format of point export in TLS messages. */
+ mbedtls_ecp_point Vi; /*!< The blinding value. */
+ mbedtls_ecp_point Vf; /*!< The unblinding value. */
+ mbedtls_mpi _d; /*!< The previous \p d. */
}
mbedtls_ecdh_context;
/**
- * \brief Generate a public key.
- * Raw function that only does the core computation.
+ * \brief This function generates an ECDH keypair on an elliptic
+ * curve.
*
- * \param grp ECP group
- * \param d Destination MPI (secret exponent, aka private key)
- * \param Q Destination point (public key)
- * \param f_rng RNG function
- * \param p_rng RNG parameter
+ * This function performs the first of two core computations
+ * implemented during the ECDH key exchange. The second core
+ * computation is performed by mbedtls_ecdh_compute_shared().
*
- * \return 0 if successful,
- * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
+ * \param grp The ECP group.
+ * \param d The destination MPI (private key).
+ * \param Q The destination point (public key).
+ * \param f_rng The RNG function.
+ * \param p_rng The RNG parameter.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX or
+ * \c MBEDTLS_MPI_XXX error code on failure.
+ *
+ * \see ecp.h
*/
int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
/**
- * \brief Compute shared secret
- * Raw function that only does the core computation.
+ * \brief This function computes the shared secret.
+ *
+ * This function performs the second of two core computations
+ * implemented during the ECDH key exchange. The first core
+ * computation is performed by mbedtls_ecdh_gen_public().
*
- * \param grp ECP group
- * \param z Destination MPI (shared secret)
- * \param Q Public key from other party
- * \param d Our secret exponent (private key)
- * \param f_rng RNG function (see notes)
- * \param p_rng RNG parameter
+ * \param grp The ECP group.
+ * \param z The destination MPI (shared secret).
+ * \param Q The public key from another party.
+ * \param d Our secret exponent (private key).
+ * \param f_rng The RNG function.
+ * \param p_rng The RNG parameter.
*
- * \return 0 if successful,
- * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX or
+ * \c MBEDTLS_MPI_XXX error code on failure.
*
- * \note If f_rng is not NULL, it is used to implement
+ * \see ecp.h
+ *
+ * \note If \p f_rng is not NULL, it is used to implement
* countermeasures against potential elaborate timing
- * attacks, see \c mbedtls_ecp_mul() for details.
+ * attacks. For more information, see mbedtls_ecp_mul().
*/
int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z,
const mbedtls_ecp_point *Q, const mbedtls_mpi *d,
void *p_rng );
/**
- * \brief Initialize context
+ * \brief This function initializes an ECDH context.
*
- * \param ctx Context to initialize
+ * \param ctx The ECDH context to initialize.
*/
void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx );
/**
- * \brief Free context
+ * \brief This function frees a context.
*
- * \param ctx Context to free
+ * \param ctx The context to free.
*/
void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx );
/**
- * \brief Generate a public key and a TLS ServerKeyExchange payload.
- * (First function used by a TLS server for ECDHE.)
+ * \brief This function generates a public key and a TLS
+ * ServerKeyExchange payload.
+ *
+ * This is the first function used by a TLS server for ECDHE
+ * ciphersuites.
+ *
+ * \param ctx The ECDH context.
+ * \param olen The number of characters written.
+ * \param buf The destination buffer.
+ * \param blen The length of the destination buffer.
+ * \param f_rng The RNG function.
+ * \param p_rng The RNG parameter.
*
- * \param ctx ECDH context
- * \param olen number of chars written
- * \param buf destination buffer
- * \param blen length of buffer
- * \param f_rng RNG function
- * \param p_rng RNG parameter
+ * \note This function assumes that the ECP group (grp) of the
+ * \p ctx context has already been properly set,
+ * for example, using mbedtls_ecp_group_load().
*
- * \note This function assumes that ctx->grp has already been
- * properly set (for example using mbedtls_ecp_group_load).
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
+ * on failure.
*
- * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
+ * \see ecp.h
*/
int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen,
unsigned char *buf, size_t blen,
void *p_rng );
/**
- * \brief Parse and procress a TLS ServerKeyExhange payload.
- * (First function used by a TLS client for ECDHE.)
+ * \brief This function parses and processes a TLS ServerKeyExhange
+ * payload.
+ *
+ * This is the first function used by a TLS client for ECDHE
+ * ciphersuites.
+ *
+ * \param ctx The ECDH context.
+ * \param buf The pointer to the start of the input buffer.
+ * \param end The address for one Byte past the end of the buffer.
*
- * \param ctx ECDH context
- * \param buf pointer to start of input buffer
- * \param end one past end of buffer
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
+ * on failure.
*
- * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
+ * \see ecp.h
*/
int mbedtls_ecdh_read_params( mbedtls_ecdh_context *ctx,
const unsigned char **buf, const unsigned char *end );
/**
- * \brief Setup an ECDH context from an EC key.
- * (Used by clients and servers in place of the
- * ServerKeyEchange for static ECDH: import ECDH parameters
- * from a certificate's EC key information.)
+ * \brief This function sets up an ECDH context from an EC key.
*
- * \param ctx ECDH constext to set
- * \param key EC key to use
- * \param side Is it our key (1) or the peer's key (0) ?
+ * It is used by clients and servers in place of the
+ * ServerKeyEchange for static ECDH, and imports ECDH
+ * parameters from the EC key information of a certificate.
*
- * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
+ * \param ctx The ECDH context to set up.
+ * \param key The EC key to use.
+ * \param side Defines the source of the key:
+ * <ul><li>1: Our key.</li>
+ <li>0: The key of the peer.</li></ul>
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
+ * on failure.
+ *
+ * \see ecp.h
*/
int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypair *key,
mbedtls_ecdh_side side );
/**
- * \brief Generate a public key and a TLS ClientKeyExchange payload.
- * (Second function used by a TLS client for ECDH(E).)
+ * \brief This function generates a public key and a TLS
+ * ClientKeyExchange payload.
+ *
+ * This is the second function used by a TLS client for ECDH(E)
+ * ciphersuites.
*
- * \param ctx ECDH context
- * \param olen number of bytes actually written
- * \param buf destination buffer
- * \param blen size of destination buffer
- * \param f_rng RNG function
- * \param p_rng RNG parameter
+ * \param ctx The ECDH context.
+ * \param olen The number of Bytes written.
+ * \param buf The destination buffer.
+ * \param blen The size of the destination buffer.
+ * \param f_rng The RNG function.
+ * \param p_rng The RNG parameter.
*
- * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
+ * on failure.
+ *
+ * \see ecp.h
*/
int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen,
unsigned char *buf, size_t blen,
void *p_rng );
/**
- * \brief Parse and process a TLS ClientKeyExchange payload.
- * (Second function used by a TLS server for ECDH(E).)
+ * \brief This function parses and processes a TLS ClientKeyExchange
+ * payload.
+ *
+ * This is the second function used by a TLS server for ECDH(E)
+ * ciphersuites.
*
- * \param ctx ECDH context
- * \param buf start of input buffer
- * \param blen length of input buffer
+ * \param ctx The ECDH context.
+ * \param buf The start of the input buffer.
+ * \param blen The length of the input buffer.
*
- * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
+ * on failure.
+ *
+ * \see ecp.h
*/
int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx,
const unsigned char *buf, size_t blen );
/**
- * \brief Derive and export the shared secret.
- * (Last function used by both TLS client en servers.)
+ * \brief This function derives and exports the shared secret.
+ *
+ * This is the last function used by both TLS client
+ * and servers.
+ *
+ * \param ctx The ECDH context.
+ * \param olen The number of Bytes written.
+ * \param buf The destination buffer.
+ * \param blen The length of the destination buffer.
+ * \param f_rng The RNG function.
+ * \param p_rng The RNG parameter.
*
- * \param ctx ECDH context
- * \param olen number of bytes written
- * \param buf destination buffer
- * \param blen buffer length
- * \param f_rng RNG function, see notes for \c mbedtls_ecdh_compute_shared()
- * \param p_rng RNG parameter
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code
+ * on failure.
*
- * \return 0 if successful, or an MBEDTLS_ERR_ECP_XXX error code
+ * \see ecp.h
+ *
+ * \note If \p f_rng is not NULL, it is used to implement
+ * countermeasures against potential elaborate timing
+ * attacks. For more information, see mbedtls_ecp_mul().
*/
int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen,
unsigned char *buf, size_t blen,
/**
* \file ecdsa.h
*
- * \brief Elliptic curve DSA
+ * \brief The Elliptic Curve Digital Signature Algorithm (ECDSA).
*
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ * ECDSA is defined in <em>Standards for Efficient Cryptography Group (SECG):
+ * SEC1 Elliptic Curve Cryptography</em>.
+ * The use of ECDSA for TLS is defined in <em>RFC-4492: Elliptic Curve
+ * Cryptography (ECC) Cipher Suites for Transport Layer Security (TLS)</em>.
+ *
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
+
#ifndef MBEDTLS_ECDSA_H
#define MBEDTLS_ECDSA_H
#include "md.h"
/*
- * RFC 4492 page 20:
+ * RFC-4492 page 20:
*
* Ecdsa-Sig-Value ::= SEQUENCE {
* r INTEGER,
#if MBEDTLS_ECP_MAX_BYTES > 124
#error "MBEDTLS_ECP_MAX_BYTES bigger than expected, please fix MBEDTLS_ECDSA_MAX_LEN"
#endif
-/** Maximum size of an ECDSA signature in bytes */
+/** The maximal size of an ECDSA signature in Bytes. */
#define MBEDTLS_ECDSA_MAX_LEN ( 3 + 2 * ( 3 + MBEDTLS_ECP_MAX_BYTES ) )
/**
- * \brief ECDSA context structure
+ * \brief The ECDSA context structure.
*/
typedef mbedtls_ecp_keypair mbedtls_ecdsa_context;
#endif
/**
- * \brief Compute ECDSA signature of a previously hashed message
+ * \brief This function computes the ECDSA signature of a
+ * previously-hashed message.
*
- * \note The deterministic version is usually prefered.
+ * \note The deterministic version is usually preferred.
*
- * \param grp ECP group
- * \param r First output integer
- * \param s Second output integer
- * \param d Private signing key
- * \param buf Message hash
- * \param blen Length of buf
- * \param f_rng RNG function
- * \param p_rng RNG parameter
+ * \param grp The ECP group.
+ * \param r The first output integer.
+ * \param s The second output integer.
+ * \param d The private signing key.
+ * \param buf The message hash.
+ * \param blen The length of \p buf.
+ * \param f_rng The RNG function.
+ * \param p_rng The RNG parameter.
*
- * \return 0 if successful,
- * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
+ * \note If the bitlength of the message hash is larger than the
+ * bitlength of the group order, then the hash is truncated
+ * as defined in <em>Standards for Efficient Cryptography Group
+ * (SECG): SEC1 Elliptic Curve Cryptography</em>, section
+ * 4.1.3, step 5.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX
+ * or \c MBEDTLS_MPI_XXX error code on failure.
+ *
+ * \see ecp.h
*/
int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s,
const mbedtls_mpi *d, const unsigned char *buf, size_t blen,
#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
/**
- * \brief Compute ECDSA signature of a previously hashed message,
- * deterministic version (RFC 6979).
- *
- * \param grp ECP group
- * \param r First output integer
- * \param s Second output integer
- * \param d Private signing key
- * \param buf Message hash
- * \param blen Length of buf
- * \param md_alg MD algorithm used to hash the message
- *
- * \return 0 if successful,
- * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
+ * \brief This function computes the ECDSA signature of a
+ * previously-hashed message, deterministic version.
+ * For more information, see <em>RFC-6979: Deterministic
+ * Usage of the Digital Signature Algorithm (DSA) and Elliptic
+ * Curve Digital Signature Algorithm (ECDSA)</em>.
+ *
+ * \param grp The ECP group.
+ * \param r The first output integer.
+ * \param s The second output integer.
+ * \param d The private signing key.
+ * \param buf The message hash.
+ * \param blen The length of \p buf.
+ * \param md_alg The MD algorithm used to hash the message.
+ *
+ * \note If the bitlength of the message hash is larger than the
+ * bitlength of the group order, then the hash is truncated as
+ * defined in <em>Standards for Efficient Cryptography Group
+ * (SECG): SEC1 Elliptic Curve Cryptography</em>, section
+ * 4.1.3, step 5.
+ *
+ * \return \c 0 on success,
+ * or an \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX
+ * error code on failure.
+ *
+ * \see ecp.h
*/
int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s,
const mbedtls_mpi *d, const unsigned char *buf, size_t blen,
#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
/**
- * \brief Verify ECDSA signature of a previously hashed message
- *
- * \param grp ECP group
- * \param buf Message hash
- * \param blen Length of buf
- * \param Q Public key to use for verification
- * \param r First integer of the signature
- * \param s Second integer of the signature
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid
- * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code
+ * \brief This function verifies the ECDSA signature of a
+ * previously-hashed message.
+ *
+ * \param grp The ECP group.
+ * \param buf The message hash.
+ * \param blen The length of \p buf.
+ * \param Q The public key to use for verification.
+ * \param r The first integer of the signature.
+ * \param s The second integer of the signature.
+ *
+ * \note If the bitlength of the message hash is larger than the
+ * bitlength of the group order, then the hash is truncated as
+ * defined in <em>Standards for Efficient Cryptography Group
+ * (SECG): SEC1 Elliptic Curve Cryptography</em>, section
+ * 4.1.4, step 3.
+ *
+ * \return \c 0 on success,
+ * #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid,
+ * or an \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX
+ * error code on failure for any other reason.
+ *
+ * \see ecp.h
*/
int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp,
const unsigned char *buf, size_t blen,
const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s);
/**
- * \brief Compute ECDSA signature and write it to buffer,
- * serialized as defined in RFC 4492 page 20.
- * (Not thread-safe to use same context in multiple threads)
- *
- * \note The deterministice version (RFC 6979) is used if
- * MBEDTLS_ECDSA_DETERMINISTIC is defined.
- *
- * \param ctx ECDSA context
- * \param md_alg Algorithm that was used to hash the message
- * \param hash Message hash
- * \param hlen Length of hash
- * \param sig Buffer that will hold the signature
- * \param slen Length of the signature written
- * \param f_rng RNG function
- * \param p_rng RNG parameter
- *
- * \note The "sig" buffer must be at least as large as twice the
- * size of the curve used, plus 9 (eg. 73 bytes if a 256-bit
- * curve is used). MBEDTLS_ECDSA_MAX_LEN is always safe.
- *
- * \return 0 if successful,
- * or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or
- * MBEDTLS_ERR_ASN1_XXX error code
+ * \brief This function computes the ECDSA signature and writes it
+ * to a buffer, serialized as defined in <em>RFC-4492:
+ * Elliptic Curve Cryptography (ECC) Cipher Suites for
+ * Transport Layer Security (TLS)</em>.
+ *
+ * \warning It is not thread-safe to use the same context in
+ * multiple threads.
+ *
+ * \note The deterministic version is used if
+ * #MBEDTLS_ECDSA_DETERMINISTIC is defined. For more
+ * information, see <em>RFC-6979: Deterministic Usage
+ * of the Digital Signature Algorithm (DSA) and Elliptic
+ * Curve Digital Signature Algorithm (ECDSA)</em>.
+ *
+ * \param ctx The ECDSA context.
+ * \param md_alg The message digest that was used to hash the message.
+ * \param hash The message hash.
+ * \param hlen The length of the hash.
+ * \param sig The buffer that holds the signature.
+ * \param slen The length of the signature written.
+ * \param f_rng The RNG function.
+ * \param p_rng The RNG parameter.
+ *
+ * \note The \p sig buffer must be at least twice as large as the
+ * size of the curve used, plus 9. For example, 73 Bytes if
+ * a 256-bit curve is used. A buffer length of
+ * #MBEDTLS_ECDSA_MAX_LEN is always safe.
+ *
+ * \note If the bitlength of the message hash is larger than the
+ * bitlength of the group order, then the hash is truncated as
+ * defined in <em>Standards for Efficient Cryptography Group
+ * (SECG): SEC1 Elliptic Curve Cryptography</em>, section
+ * 4.1.3, step 5.
+ *
+ * \return \c 0 on success,
+ * or an \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or
+ * \c MBEDTLS_ERR_ASN1_XXX error code on failure.
+ *
+ * \see ecp.h
*/
int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t md_alg,
const unsigned char *hash, size_t hlen,
#define MBEDTLS_DEPRECATED
#endif
/**
- * \brief Compute ECDSA signature and write it to buffer,
- * serialized as defined in RFC 4492 page 20.
- * Deterministic version, RFC 6979.
- * (Not thread-safe to use same context in multiple threads)
+ * \brief This function computes an ECDSA signature and writes it to a buffer,
+ * serialized as defined in <em>RFC-4492: Elliptic Curve Cryptography
+ * (ECC) Cipher Suites for Transport Layer Security (TLS)</em>.
+ *
+ * The deterministic version is defined in <em>RFC-6979:
+ * Deterministic Usage of the Digital Signature Algorithm (DSA) and
+ * Elliptic Curve Digital Signature Algorithm (ECDSA)</em>.
+ *
+ * \warning It is not thread-safe to use the same context in
+ * multiple threads.
+
*
* \deprecated Superseded by mbedtls_ecdsa_write_signature() in 2.0.0
*
- * \param ctx ECDSA context
- * \param hash Message hash
- * \param hlen Length of hash
- * \param sig Buffer that will hold the signature
- * \param slen Length of the signature written
- * \param md_alg MD algorithm used to hash the message
+ * \param ctx The ECDSA context.
+ * \param hash The Message hash.
+ * \param hlen The length of the hash.
+ * \param sig The buffer that holds the signature.
+ * \param slen The length of the signature written.
+ * \param md_alg The MD algorithm used to hash the message.
*
- * \note The "sig" buffer must be at least as large as twice the
- * size of the curve used, plus 9 (eg. 73 bytes if a 256-bit
- * curve is used). MBEDTLS_ECDSA_MAX_LEN is always safe.
+ * \note The \p sig buffer must be at least twice as large as the
+ * size of the curve used, plus 9. For example, 73 Bytes if a
+ * 256-bit curve is used. A buffer length of
+ * #MBEDTLS_ECDSA_MAX_LEN is always safe.
*
- * \return 0 if successful,
- * or a MBEDTLS_ERR_ECP_XXX, MBEDTLS_ERR_MPI_XXX or
- * MBEDTLS_ERR_ASN1_XXX error code
+ * \note If the bitlength of the message hash is larger than the
+ * bitlength of the group order, then the hash is truncated as
+ * defined in <em>Standards for Efficient Cryptography Group
+ * (SECG): SEC1 Elliptic Curve Cryptography</em>, section
+ * 4.1.3, step 5.
+ *
+ * \return \c 0 on success,
+ * or an \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or
+ * \c MBEDTLS_ERR_ASN1_XXX error code on failure.
+ *
+ * \see ecp.h
*/
int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx,
const unsigned char *hash, size_t hlen,
#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
/**
- * \brief Read and verify an ECDSA signature
- *
- * \param ctx ECDSA context
- * \param hash Message hash
- * \param hlen Size of hash
- * \param sig Signature to read and verify
- * \param slen Size of sig
- *
- * \return 0 if successful,
- * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid,
- * MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if the signature is
- * valid but its actual length is less than siglen,
- * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_ERR_MPI_XXX error code
+ * \brief This function reads and verifies an ECDSA signature.
+ *
+ * \param ctx The ECDSA context.
+ * \param hash The message hash.
+ * \param hlen The size of the hash.
+ * \param sig The signature to read and verify.
+ * \param slen The size of \p sig.
+ *
+ * \note If the bitlength of the message hash is larger than the
+ * bitlength of the group order, then the hash is truncated as
+ * defined in <em>Standards for Efficient Cryptography Group
+ * (SECG): SEC1 Elliptic Curve Cryptography</em>, section
+ * 4.1.4, step 3.
+ *
+ * \return \c 0 on success,
+ * #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid,
+ * #MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if the signature is
+ * valid but its actual length is less than \p siglen,
+ * or an \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_ERR_MPI_XXX
+ * error code on failure for any other reason.
+ *
+ * \see ecp.h
*/
int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx,
const unsigned char *hash, size_t hlen,
const unsigned char *sig, size_t slen );
/**
- * \brief Generate an ECDSA keypair on the given curve
+ * \brief This function generates an ECDSA keypair on the given curve.
*
- * \param ctx ECDSA context in which the keypair should be stored
- * \param gid Group (elliptic curve) to use. One of the various
- * MBEDTLS_ECP_DP_XXX macros depending on configuration.
- * \param f_rng RNG function
- * \param p_rng RNG parameter
+ * \param ctx The ECDSA context to store the keypair in.
+ * \param gid The elliptic curve to use. One of the various
+ * \c MBEDTLS_ECP_DP_XXX macros depending on configuration.
+ * \param f_rng The RNG function.
+ * \param p_rng The RNG parameter.
*
- * \return 0 on success, or a MBEDTLS_ERR_ECP_XXX code.
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX code on
+ * failure.
+ *
+ * \see ecp.h
*/
int mbedtls_ecdsa_genkey( mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
/**
- * \brief Set an ECDSA context from an EC key pair
+ * \brief This function sets an ECDSA context from an EC key pair.
+ *
+ * \param ctx The ECDSA context to set.
+ * \param key The EC key to use.
*
- * \param ctx ECDSA context to set
- * \param key EC key to use
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX code on
+ * failure.
*
- * \return 0 on success, or a MBEDTLS_ERR_ECP_XXX code.
+ * \see ecp.h
*/
int mbedtls_ecdsa_from_keypair( mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key );
/**
- * \brief Initialize context
+ * \brief This function initializes an ECDSA context.
*
- * \param ctx Context to initialize
+ * \param ctx The ECDSA context to initialize.
*/
void mbedtls_ecdsa_init( mbedtls_ecdsa_context *ctx );
/**
- * \brief Free context
+ * \brief This function frees an ECDSA context.
*
- * \param ctx Context to free
+ * \param ctx The ECDSA context to free.
*/
void mbedtls_ecdsa_free( mbedtls_ecdsa_context *ctx );
* \file ecjpake.h
*
* \brief Elliptic curve J-PAKE
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#include "ecp.h"
#include "md.h"
+#if !defined(MBEDTLS_ECJPAKE_ALT)
+
#ifdef __cplusplus
extern "C" {
#endif
const unsigned char *secret,
size_t len );
-/*
+/**
* \brief Check if a context is ready for use
*
* \param ctx Context to check
*/
void mbedtls_ecjpake_free( mbedtls_ecjpake_context *ctx );
+#ifdef __cplusplus
+}
+#endif
+
+#else /* MBEDTLS_ECJPAKE_ALT */
+#include "ecjpake_alt.h"
+#endif /* MBEDTLS_ECJPAKE_ALT */
+
#if defined(MBEDTLS_SELF_TEST)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if a test failed
*/
int mbedtls_ecjpake_self_test( int verbose );
-#endif
#ifdef __cplusplus
}
#endif
+#endif /* MBEDTLS_SELF_TEST */
+
#endif /* ecjpake.h */
* \file ecp.h
*
* \brief Elliptic curves over GF(p)
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00 /**< Generation of random value, such as (ephemeral) key, failed. */
#define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80 /**< Invalid private or public key. */
#define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 /**< Signature is valid but shorter than the user-supplied length. */
+#define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED -0x4B80 /**< ECP hardware accelerator failed. */
+
+#if !defined(MBEDTLS_ECP_ALT)
+/*
+ * default mbed TLS elliptic curve arithmetic implementation
+ *
+ * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an
+ * alternative implementation for the whole module and it will replace this
+ * one.)
+ */
#ifdef __cplusplus
extern "C" {
* \brief Set a group using well-known domain parameters
*
* \param grp Destination group
- * \param index Index in the list of well-known domain parameters
+ * \param id Index in the list of well-known domain parameters
*
* \return 0 if successful,
* MBEDTLS_ERR_MPI_XXX if initialization failed
* \note Index should be a value of RFC 4492's enum NamedCurve,
* usually in the form of a MBEDTLS_ECP_DP_XXX macro.
*/
-int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id index );
+int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id id );
/**
* \brief Set a group from a TLS ECParameters record
int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv );
#if defined(MBEDTLS_SELF_TEST)
+
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if a test failed
*/
int mbedtls_ecp_self_test( int verbose );
-#endif
+
+#endif /* MBEDTLS_SELF_TEST */
#ifdef __cplusplus
}
#endif
+#else /* MBEDTLS_ECP_ALT */
+#include "ecp_alt.h"
+#endif /* MBEDTLS_ECP_ALT */
+
#endif /* ecp.h */
--- /dev/null
+/**
+ * \file ecp_internal.h
+ *
+ * \brief Function declarations for alternative implementation of elliptic curve
+ * point arithmetic.
+ */
+/*
+ * Copyright (C) 2016, ARM Limited, All Rights Reserved
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This file is part of mbed TLS (https://tls.mbed.org)
+ */
+
+/*
+ * References:
+ *
+ * [1] BERNSTEIN, Daniel J. Curve25519: new Diffie-Hellman speed records.
+ * <http://cr.yp.to/ecdh/curve25519-20060209.pdf>
+ *
+ * [2] CORON, Jean-S'ebastien. Resistance against differential power analysis
+ * for elliptic curve cryptosystems. In : Cryptographic Hardware and
+ * Embedded Systems. Springer Berlin Heidelberg, 1999. p. 292-302.
+ * <http://link.springer.com/chapter/10.1007/3-540-48059-5_25>
+ *
+ * [3] HEDABOU, Mustapha, PINEL, Pierre, et B'EN'ETEAU, Lucien. A comb method to
+ * render ECC resistant against Side Channel Attacks. IACR Cryptology
+ * ePrint Archive, 2004, vol. 2004, p. 342.
+ * <http://eprint.iacr.org/2004/342.pdf>
+ *
+ * [4] Certicom Research. SEC 2: Recommended Elliptic Curve Domain Parameters.
+ * <http://www.secg.org/sec2-v2.pdf>
+ *
+ * [5] HANKERSON, Darrel, MENEZES, Alfred J., VANSTONE, Scott. Guide to Elliptic
+ * Curve Cryptography.
+ *
+ * [6] Digital Signature Standard (DSS), FIPS 186-4.
+ * <http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf>
+ *
+ * [7] Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer
+ * Security (TLS), RFC 4492.
+ * <https://tools.ietf.org/search/rfc4492>
+ *
+ * [8] <http://www.hyperelliptic.org/EFD/g1p/auto-shortw-jacobian.html>
+ *
+ * [9] COHEN, Henri. A Course in Computational Algebraic Number Theory.
+ * Springer Science & Business Media, 1 Aug 2000
+ */
+
+#ifndef MBEDTLS_ECP_INTERNAL_H
+#define MBEDTLS_ECP_INTERNAL_H
+
+#if defined(MBEDTLS_ECP_INTERNAL_ALT)
+
+/**
+ * \brief Indicate if the Elliptic Curve Point module extension can
+ * handle the group.
+ *
+ * \param grp The pointer to the elliptic curve group that will be the
+ * basis of the cryptographic computations.
+ *
+ * \return Non-zero if successful.
+ */
+unsigned char mbedtls_internal_ecp_grp_capable( const mbedtls_ecp_group *grp );
+
+/**
+ * \brief Initialise the Elliptic Curve Point module extension.
+ *
+ * If mbedtls_internal_ecp_grp_capable returns true for a
+ * group, this function has to be able to initialise the
+ * module for it.
+ *
+ * This module can be a driver to a crypto hardware
+ * accelerator, for which this could be an initialise function.
+ *
+ * \param grp The pointer to the group the module needs to be
+ * initialised for.
+ *
+ * \return 0 if successful.
+ */
+int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp );
+
+/**
+ * \brief Frees and deallocates the Elliptic Curve Point module
+ * extension.
+ *
+ * \param grp The pointer to the group the module was initialised for.
+ */
+void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp );
+
+#if defined(ECP_SHORTWEIERSTRASS)
+
+#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT)
+/**
+ * \brief Randomize jacobian coordinates:
+ * (X, Y, Z) -> (l^2 X, l^3 Y, l Z) for random l.
+ *
+ * \param grp Pointer to the group representing the curve.
+ *
+ * \param pt The point on the curve to be randomised, given with Jacobian
+ * coordinates.
+ *
+ * \param f_rng A function pointer to the random number generator.
+ *
+ * \param p_rng A pointer to the random number generator state.
+ *
+ * \return 0 if successful.
+ */
+int mbedtls_internal_ecp_randomize_jac( const mbedtls_ecp_group *grp,
+ mbedtls_ecp_point *pt, int (*f_rng)(void *, unsigned char *, size_t),
+ void *p_rng );
+#endif
+
+#if defined(MBEDTLS_ECP_ADD_MIXED_ALT)
+/**
+ * \brief Addition: R = P + Q, mixed affine-Jacobian coordinates.
+ *
+ * The coordinates of Q must be normalized (= affine),
+ * but those of P don't need to. R is not normalized.
+ *
+ * This function is used only as a subrutine of
+ * ecp_mul_comb().
+ *
+ * Special cases: (1) P or Q is zero, (2) R is zero,
+ * (3) P == Q.
+ * None of these cases can happen as intermediate step in
+ * ecp_mul_comb():
+ * - at each step, P, Q and R are multiples of the base
+ * point, the factor being less than its order, so none of
+ * them is zero;
+ * - Q is an odd multiple of the base point, P an even
+ * multiple, due to the choice of precomputed points in the
+ * modified comb method.
+ * So branches for these cases do not leak secret information.
+ *
+ * We accept Q->Z being unset (saving memory in tables) as
+ * meaning 1.
+ *
+ * Cost in field operations if done by [5] 3.22:
+ * 1A := 8M + 3S
+ *
+ * \param grp Pointer to the group representing the curve.
+ *
+ * \param R Pointer to a point structure to hold the result.
+ *
+ * \param P Pointer to the first summand, given with Jacobian
+ * coordinates
+ *
+ * \param Q Pointer to the second summand, given with affine
+ * coordinates.
+ *
+ * \return 0 if successful.
+ */
+int mbedtls_internal_ecp_add_mixed( const mbedtls_ecp_group *grp,
+ mbedtls_ecp_point *R, const mbedtls_ecp_point *P,
+ const mbedtls_ecp_point *Q );
+#endif
+
+/**
+ * \brief Point doubling R = 2 P, Jacobian coordinates.
+ *
+ * Cost: 1D := 3M + 4S (A == 0)
+ * 4M + 4S (A == -3)
+ * 3M + 6S + 1a otherwise
+ * when the implementation is based on the "dbl-1998-cmo-2"
+ * doubling formulas in [8] and standard optimizations are
+ * applied when curve parameter A is one of { 0, -3 }.
+ *
+ * \param grp Pointer to the group representing the curve.
+ *
+ * \param R Pointer to a point structure to hold the result.
+ *
+ * \param P Pointer to the point that has to be doubled, given with
+ * Jacobian coordinates.
+ *
+ * \return 0 if successful.
+ */
+#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT)
+int mbedtls_internal_ecp_double_jac( const mbedtls_ecp_group *grp,
+ mbedtls_ecp_point *R, const mbedtls_ecp_point *P );
+#endif
+
+/**
+ * \brief Normalize jacobian coordinates of an array of (pointers to)
+ * points.
+ *
+ * Using Montgomery's trick to perform only one inversion mod P
+ * the cost is:
+ * 1N(t) := 1I + (6t - 3)M + 1S
+ * (See for example Algorithm 10.3.4. in [9])
+ *
+ * This function is used only as a subrutine of
+ * ecp_mul_comb().
+ *
+ * Warning: fails (returning an error) if one of the points is
+ * zero!
+ * This should never happen, see choice of w in ecp_mul_comb().
+ *
+ * \param grp Pointer to the group representing the curve.
+ *
+ * \param T Array of pointers to the points to normalise.
+ *
+ * \param t_len Number of elements in the array.
+ *
+ * \return 0 if successful,
+ * an error if one of the points is zero.
+ */
+#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT)
+int mbedtls_internal_ecp_normalize_jac_many( const mbedtls_ecp_group *grp,
+ mbedtls_ecp_point *T[], size_t t_len );
+#endif
+
+/**
+ * \brief Normalize jacobian coordinates so that Z == 0 || Z == 1.
+ *
+ * Cost in field operations if done by [5] 3.2.1:
+ * 1N := 1I + 3M + 1S
+ *
+ * \param grp Pointer to the group representing the curve.
+ *
+ * \param pt pointer to the point to be normalised. This is an
+ * input/output parameter.
+ *
+ * \return 0 if successful.
+ */
+#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT)
+int mbedtls_internal_ecp_normalize_jac( const mbedtls_ecp_group *grp,
+ mbedtls_ecp_point *pt );
+#endif
+
+#endif /* ECP_SHORTWEIERSTRASS */
+
+#if defined(ECP_MONTGOMERY)
+
+#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT)
+int mbedtls_internal_ecp_double_add_mxz( const mbedtls_ecp_group *grp,
+ mbedtls_ecp_point *R, mbedtls_ecp_point *S, const mbedtls_ecp_point *P,
+ const mbedtls_ecp_point *Q, const mbedtls_mpi *d );
+#endif
+
+/**
+ * \brief Randomize projective x/z coordinates:
+ * (X, Z) -> (l X, l Z) for random l
+ *
+ * \param grp pointer to the group representing the curve
+ *
+ * \param P the point on the curve to be randomised given with
+ * projective coordinates. This is an input/output parameter.
+ *
+ * \param f_rng a function pointer to the random number generator
+ *
+ * \param p_rng a pointer to the random number generator state
+ *
+ * \return 0 if successful
+ */
+#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT)
+int mbedtls_internal_ecp_randomize_mxz( const mbedtls_ecp_group *grp,
+ mbedtls_ecp_point *P, int (*f_rng)(void *, unsigned char *, size_t),
+ void *p_rng );
+#endif
+
+/**
+ * \brief Normalize Montgomery x/z coordinates: X = X/Z, Z = 1.
+ *
+ * \param grp pointer to the group representing the curve
+ *
+ * \param P pointer to the point to be normalised. This is an
+ * input/output parameter.
+ *
+ * \return 0 if successful
+ */
+#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT)
+int mbedtls_internal_ecp_normalize_mxz( const mbedtls_ecp_group *grp,
+ mbedtls_ecp_point *P );
+#endif
+
+#endif /* ECP_MONTGOMERY */
+
+#endif /* MBEDTLS_ECP_INTERNAL_ALT */
+
+#endif /* ecp_internal.h */
+
* \file entropy.h
*
* \brief Entropy accumulator implementation
- *
+ */
+/*
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
*/
typedef struct
{
+ int accumulator_started;
#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
mbedtls_sha512_context accumulator;
#else
* \file entropy_poll.h
*
* \brief Platform-specific and custom entropy polling functions
- *
+ */
+/*
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file error.h
*
* \brief Error to string translation
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
*
* Module Nr Codes assigned
* MPI 7 0x0002-0x0010
- * GCM 2 0x0012-0x0014
- * BLOWFISH 2 0x0016-0x0018
+ * GCM 3 0x0012-0x0014 0x0013-0x0013
+ * BLOWFISH 3 0x0016-0x0018 0x0017-0x0017
* THREADING 3 0x001A-0x001E
- * AES 2 0x0020-0x0022
- * CAMELLIA 2 0x0024-0x0026
- * XTEA 1 0x0028-0x0028
+ * AES 4 0x0020-0x0022 0x0023-0x0025
+ * CAMELLIA 3 0x0024-0x0026 0x0027-0x0027
+ * XTEA 2 0x0028-0x0028 0x0029-0x0029
* BASE64 2 0x002A-0x002C
* OID 1 0x002E-0x002E 0x000B-0x000B
* PADLOCK 1 0x0030-0x0030
- * DES 1 0x0032-0x0032
+ * DES 2 0x0032-0x0032 0x0033-0x0033
* CTR_DBRG 4 0x0034-0x003A
* ENTROPY 3 0x003C-0x0040 0x003D-0x003F
* NET 11 0x0042-0x0052 0x0043-0x0045
* ASN1 7 0x0060-0x006C
+ * CMAC 1 0x007A-0x007A
* PBKDF2 1 0x007C-0x007C
- * HMAC_DRBG 4 0x0003-0x0009
- * CCM 2 0x000D-0x000F
+ * HMAC_DRBG 4 0x0003-0x0009
+ * CCM 3 0x000D-0x0011
+ * ARC4 1 0x0019-0x0019
+ * MD2 1 0x002B-0x002B
+ * MD4 1 0x002D-0x002D
+ * MD5 1 0x002F-0x002F
+ * RIPEMD160 1 0x0031-0x0031
+ * SHA1 1 0x0035-0x0035
+ * SHA256 1 0x0037-0x0037
+ * SHA512 1 0x0039-0x0039
*
* High-level module nr (3 bits - 0x0...-0x7...)
* Name ID Nr of Errors
* PEM 1 9
* PKCS#12 1 4 (Started from top)
- * X509 2 19
+ * X509 2 20
* PKCS5 2 4 (Started from top)
- * DHM 3 9
- * PK 3 14 (Started from top)
- * RSA 4 9
- * ECP 4 8 (Started from top)
- * MD 5 4
- * CIPHER 6 6
+ * DHM 3 11
+ * PK 3 15 (Started from top)
+ * RSA 4 11
+ * ECP 4 9 (Started from top)
+ * MD 5 5
+ * CIPHER 6 8
* SSL 6 17 (Started from top)
* SSL 7 31
*
/**
* \file gcm.h
*
- * \brief Galois/Counter mode for 128-bit block ciphers
+ * \brief Galois/Counter Mode (GCM) for 128-bit block ciphers, as defined
+ * in <em>D. McGrew, J. Viega, The Galois/Counter Mode of Operation
+ * (GCM), Natl. Inst. Stand. Technol.</em>
*
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ * For more information on GCM, see <em>NIST SP 800-38D: Recommendation for
+ * Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC</em>.
+ *
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
+
#ifndef MBEDTLS_GCM_H
#define MBEDTLS_GCM_H
#define MBEDTLS_GCM_DECRYPT 0
#define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012 /**< Authenticated decryption failed. */
+#define MBEDTLS_ERR_GCM_HW_ACCEL_FAILED -0x0013 /**< GCM hardware accelerator failed. */
#define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014 /**< Bad input parameters to function. */
+#if !defined(MBEDTLS_GCM_ALT)
+
#ifdef __cplusplus
extern "C" {
#endif
/**
- * \brief GCM context structure
+ * \brief The GCM context structure.
*/
typedef struct {
- mbedtls_cipher_context_t cipher_ctx;/*!< cipher context used */
- uint64_t HL[16]; /*!< Precalculated HTable */
- uint64_t HH[16]; /*!< Precalculated HTable */
- uint64_t len; /*!< Total data length */
- uint64_t add_len; /*!< Total add length */
- unsigned char base_ectr[16];/*!< First ECTR for tag */
- unsigned char y[16]; /*!< Y working value */
- unsigned char buf[16]; /*!< buf working value */
- int mode; /*!< Encrypt or Decrypt */
+ mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */
+ uint64_t HL[16]; /*!< Precalculated HTable low. */
+ uint64_t HH[16]; /*!< Precalculated HTable high. */
+ uint64_t len; /*!< The total length of the encrypted data. */
+ uint64_t add_len; /*!< The total length of the additional data. */
+ unsigned char base_ectr[16]; /*!< The first ECTR for tag. */
+ unsigned char y[16]; /*!< The Y working value. */
+ unsigned char buf[16]; /*!< The buf working value. */
+ int mode; /*!< The operation to perform:
+ #MBEDTLS_GCM_ENCRYPT or
+ #MBEDTLS_GCM_DECRYPT. */
}
mbedtls_gcm_context;
/**
- * \brief Initialize GCM context (just makes references valid)
- * Makes the context ready for mbedtls_gcm_setkey() or
- * mbedtls_gcm_free().
+ * \brief This function initializes the specified GCM context,
+ * to make references valid, and prepares the context
+ * for mbedtls_gcm_setkey() or mbedtls_gcm_free().
+ *
+ * The function does not bind the GCM context to a particular
+ * cipher, nor set the key. For this purpose, use
+ * mbedtls_gcm_setkey().
*
- * \param ctx GCM context to initialize
+ * \param ctx The GCM context to initialize.
*/
void mbedtls_gcm_init( mbedtls_gcm_context *ctx );
/**
- * \brief GCM initialization (encryption)
+ * \brief This function associates a GCM context with a
+ * cipher algorithm and a key.
*
- * \param ctx GCM context to be initialized
- * \param cipher cipher to use (a 128-bit block cipher)
- * \param key encryption key
- * \param keybits must be 128, 192 or 256
+ * \param ctx The GCM context to initialize.
+ * \param cipher The 128-bit block cipher to use.
+ * \param key The encryption key.
+ * \param keybits The key size in bits. Valid options are:
+ * <ul><li>128 bits</li>
+ * <li>192 bits</li>
+ * <li>256 bits</li></ul>
*
- * \return 0 if successful, or a cipher specific error code
+ * \return \c 0 on success, or a cipher specific error code.
*/
int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx,
mbedtls_cipher_id_t cipher,
unsigned int keybits );
/**
- * \brief GCM buffer encryption/decryption using a block cipher
+ * \brief This function performs GCM encryption or decryption of a buffer.
*
- * \note On encryption, the output buffer can be the same as the input buffer.
- * On decryption, the output buffer cannot be the same as input buffer.
- * If buffers overlap, the output buffer must trail at least 8 bytes
+ * \note For encryption, the output buffer can be the same as the input buffer.
+ * For decryption, the output buffer cannot be the same as input buffer.
+ * If the buffers overlap, the output buffer must trail at least 8 Bytes
* behind the input buffer.
*
- * \param ctx GCM context
- * \param mode MBEDTLS_GCM_ENCRYPT or MBEDTLS_GCM_DECRYPT
- * \param length length of the input data
- * \param iv initialization vector
- * \param iv_len length of IV
- * \param add additional data
- * \param add_len length of additional data
- * \param input buffer holding the input data
- * \param output buffer for holding the output data
- * \param tag_len length of the tag to generate
- * \param tag buffer for holding the tag
- *
- * \return 0 if successful
+ * \param ctx The GCM context to use for encryption or decryption.
+ * \param mode The operation to perform: #MBEDTLS_GCM_ENCRYPT or
+ * #MBEDTLS_GCM_DECRYPT.
+ * \param length The length of the input data. This must be a multiple of 16 except in the last call before mbedtls_gcm_finish().
+ * \param iv The initialization vector.
+ * \param iv_len The length of the IV.
+ * \param add The buffer holding the additional data.
+ * \param add_len The length of the additional data.
+ * \param input The buffer holding the input data.
+ * \param output The buffer for holding the output data.
+ * \param tag_len The length of the tag to generate.
+ * \param tag The buffer for holding the tag.
+ *
+ * \return \c 0 on success.
*/
int mbedtls_gcm_crypt_and_tag( mbedtls_gcm_context *ctx,
int mode,
unsigned char *tag );
/**
- * \brief GCM buffer authenticated decryption using a block cipher
+ * \brief This function performs a GCM authenticated decryption of a
+ * buffer.
*
- * \note On decryption, the output buffer cannot be the same as input buffer.
- * If buffers overlap, the output buffer must trail at least 8 bytes
+ * \note For decryption, the output buffer cannot be the same as input buffer.
+ * If the buffers overlap, the output buffer must trail at least 8 Bytes
* behind the input buffer.
*
- * \param ctx GCM context
- * \param length length of the input data
- * \param iv initialization vector
- * \param iv_len length of IV
- * \param add additional data
- * \param add_len length of additional data
- * \param tag buffer holding the tag
- * \param tag_len length of the tag
- * \param input buffer holding the input data
- * \param output buffer for holding the output data
- *
- * \return 0 if successful and authenticated,
- * MBEDTLS_ERR_GCM_AUTH_FAILED if tag does not match
+ * \param ctx The GCM context.
+ * \param length The length of the input data. This must be a multiple of 16 except in the last call before mbedtls_gcm_finish().
+ * \param iv The initialization vector.
+ * \param iv_len The length of the IV.
+ * \param add The buffer holding the additional data.
+ * \param add_len The length of the additional data.
+ * \param tag The buffer holding the tag.
+ * \param tag_len The length of the tag.
+ * \param input The buffer holding the input data.
+ * \param output The buffer for holding the output data.
+ *
+ * \return 0 if successful and authenticated, or
+ * #MBEDTLS_ERR_GCM_AUTH_FAILED if tag does not match.
*/
int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx,
size_t length,
unsigned char *output );
/**
- * \brief Generic GCM stream start function
+ * \brief This function starts a GCM encryption or decryption
+ * operation.
*
- * \param ctx GCM context
- * \param mode MBEDTLS_GCM_ENCRYPT or MBEDTLS_GCM_DECRYPT
- * \param iv initialization vector
- * \param iv_len length of IV
- * \param add additional data (or NULL if length is 0)
- * \param add_len length of additional data
+ * \param ctx The GCM context.
+ * \param mode The operation to perform: #MBEDTLS_GCM_ENCRYPT or
+ * #MBEDTLS_GCM_DECRYPT.
+ * \param iv The initialization vector.
+ * \param iv_len The length of the IV.
+ * \param add The buffer holding the additional data, or NULL if \p add_len is 0.
+ * \param add_len The length of the additional data. If 0, \p add is NULL.
*
- * \return 0 if successful
+ * \return \c 0 on success.
*/
int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
int mode,
size_t add_len );
/**
- * \brief Generic GCM update function. Encrypts/decrypts using the
- * given GCM context. Expects input to be a multiple of 16
- * bytes! Only the last call before mbedtls_gcm_finish() can be less
- * than 16 bytes!
+ * \brief This function feeds an input buffer into an ongoing GCM
+ * encryption or decryption operation.
+ *
+ * ` The function expects input to be a multiple of 16
+ * Bytes. Only the last call before calling
+ * mbedtls_gcm_finish() can be less than 16 Bytes.
*
- * \note On decryption, the output buffer cannot be the same as input buffer.
- * If buffers overlap, the output buffer must trail at least 8 bytes
+ * \note For decryption, the output buffer cannot be the same as input buffer.
+ * If the buffers overlap, the output buffer must trail at least 8 Bytes
* behind the input buffer.
*
- * \param ctx GCM context
- * \param length length of the input data
- * \param input buffer holding the input data
- * \param output buffer for holding the output data
+ * \param ctx The GCM context.
+ * \param length The length of the input data. This must be a multiple of 16 except in the last call before mbedtls_gcm_finish().
+ * \param input The buffer holding the input data.
+ * \param output The buffer for holding the output data.
*
- * \return 0 if successful or MBEDTLS_ERR_GCM_BAD_INPUT
+ * \return \c 0 on success, or #MBEDTLS_ERR_GCM_BAD_INPUT on failure.
*/
int mbedtls_gcm_update( mbedtls_gcm_context *ctx,
size_t length,
unsigned char *output );
/**
- * \brief Generic GCM finalisation function. Wraps up the GCM stream
- * and generates the tag. The tag can have a maximum length of
- * 16 bytes.
+ * \brief This function finishes the GCM operation and generates
+ * the authentication tag.
*
- * \param ctx GCM context
- * \param tag buffer for holding the tag
- * \param tag_len length of the tag to generate (must be at least 4)
+ * It wraps up the GCM stream, and generates the
+ * tag. The tag can have a maximum length of 16 Bytes.
*
- * \return 0 if successful or MBEDTLS_ERR_GCM_BAD_INPUT
+ * \param ctx The GCM context.
+ * \param tag The buffer for holding the tag.
+ * \param tag_len The length of the tag to generate. Must be at least four.
+ *
+ * \return \c 0 on success, or #MBEDTLS_ERR_GCM_BAD_INPUT on failure.
*/
int mbedtls_gcm_finish( mbedtls_gcm_context *ctx,
unsigned char *tag,
size_t tag_len );
/**
- * \brief Free a GCM context and underlying cipher sub-context
+ * \brief This function clears a GCM context and the underlying
+ * cipher sub-context.
*
- * \param ctx GCM context to free
+ * \param ctx The GCM context to clear.
*/
void mbedtls_gcm_free( mbedtls_gcm_context *ctx );
+#ifdef __cplusplus
+}
+#endif
+
+#else /* !MBEDTLS_GCM_ALT */
+#include "gcm_alt.h"
+#endif /* !MBEDTLS_GCM_ALT */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
- * \brief Checkup routine
+ * \brief The GCM checkup routine.
*
- * \return 0 if successful, or 1 if the test failed
+ * \return \c 0 on success, or \c 1 on failure.
*/
int mbedtls_gcm_self_test( int verbose );
}
#endif
+
#endif /* gcm.h */
* \file havege.h
*
* \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file hmac_drbg.h
*
* \brief HMAC_DRBG (NIST SP 800-90A)
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
-/**
+ /**
* \file md.h
*
- * \brief Generic message digest wrapper
+ * \brief The generic message-digest wrapper.
*
* \author Adriaan de Jong <dejong@fox-it.com>
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
+
#ifndef MBEDTLS_MD_H
#define MBEDTLS_MD_H
#include <stddef.h>
+#if !defined(MBEDTLS_CONFIG_FILE)
+#include "config.h"
+#else
+#include MBEDTLS_CONFIG_FILE
+#endif
+
#define MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE -0x5080 /**< The selected feature is not available. */
#define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */
#define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180 /**< Failed to allocate memory. */
#define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200 /**< Opening or reading of file failed. */
+#define MBEDTLS_ERR_MD_HW_ACCEL_FAILED -0x5280 /**< MD hardware accelerator failed. */
#ifdef __cplusplus
extern "C" {
#endif
+/**
+ * \brief Enumeration of supported message digests
+ *
+ * \warning MD2, MD4, MD5 and SHA-1 are considered weak message digests and
+ * their use constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
typedef enum {
MBEDTLS_MD_NONE=0,
MBEDTLS_MD_MD2,
#endif
/**
- * Opaque struct defined in md_internal.h
+ * Opaque struct defined in md_internal.h.
*/
typedef struct mbedtls_md_info_t mbedtls_md_info_t;
/**
- * Generic message digest context.
+ * The generic message-digest context.
*/
typedef struct {
- /** Information about the associated message digest */
+ /** Information about the associated message digest. */
const mbedtls_md_info_t *md_info;
- /** Digest-specific context */
+ /** The digest-specific context. */
void *md_ctx;
- /** HMAC part of the context */
+ /** The HMAC part of the context. */
void *hmac_ctx;
} mbedtls_md_context_t;
/**
- * \brief Returns the list of digests supported by the generic digest module.
+ * \brief This function returns the list of digests supported by the
+ * generic digest module.
*
- * \return a statically allocated array of digests, the last entry
- * is 0.
+ * \return A statically allocated array of digests. Each element
+ * in the returned list is an integer belonging to the
+ * message-digest enumeration #mbedtls_md_type_t.
+ * The last entry is 0.
*/
const int *mbedtls_md_list( void );
/**
- * \brief Returns the message digest information associated with the
- * given digest name.
+ * \brief This function returns the message-digest information
+ * associated with the given digest name.
*
- * \param md_name Name of the digest to search for.
+ * \param md_name The name of the digest to search for.
*
- * \return The message digest information associated with md_name or
- * NULL if not found.
+ * \return The message-digest information associated with \p md_name,
+ * or NULL if not found.
*/
const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name );
/**
- * \brief Returns the message digest information associated with the
- * given digest type.
+ * \brief This function returns the message-digest information
+ * associated with the given digest type.
*
- * \param md_type type of digest to search for.
+ * \param md_type The type of digest to search for.
*
- * \return The message digest information associated with md_type or
- * NULL if not found.
+ * \return The message-digest information associated with \p md_type,
+ * or NULL if not found.
*/
const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type );
/**
- * \brief Initialize a md_context (as NONE)
- * This should always be called first.
- * Prepares the context for mbedtls_md_setup() or mbedtls_md_free().
+ * \brief This function initializes a message-digest context without
+ * binding it to a particular message-digest algorithm.
+ *
+ * This function should always be called first. It prepares the
+ * context for mbedtls_md_setup() for binding it to a
+ * message-digest algorithm.
*/
void mbedtls_md_init( mbedtls_md_context_t *ctx );
/**
- * \brief Free and clear the internal structures of ctx.
- * Can be called at any time after mbedtls_md_init().
- * Mandatory once mbedtls_md_setup() has been called.
+ * \brief This function clears the internal structure of \p ctx and
+ * frees any embedded internal structure, but does not free
+ * \p ctx itself.
+ *
+ * If you have called mbedtls_md_setup() on \p ctx, you must
+ * call mbedtls_md_free() when you are no longer using the
+ * context.
+ * Calling this function if you have previously
+ * called mbedtls_md_init() and nothing else is optional.
+ * You must not call this function if you have not called
+ * mbedtls_md_init().
*/
void mbedtls_md_free( mbedtls_md_context_t *ctx );
#define MBEDTLS_DEPRECATED
#endif
/**
- * \brief Select MD to use and allocate internal structures.
- * Should be called after mbedtls_md_init() or mbedtls_md_free().
+ * \brief This function selects the message digest algorithm to use,
+ * and allocates internal structures.
+ *
+ * It should be called after mbedtls_md_init() or mbedtls_md_free().
* Makes it necessary to call mbedtls_md_free() later.
*
* \deprecated Superseded by mbedtls_md_setup() in 2.0.0
*
- * \param ctx Context to set up.
- * \param md_info Message digest to use.
+ * \param ctx The context to set up.
+ * \param md_info The information structure of the message-digest algorithm
+ * to use.
*
* \returns \c 0 on success,
- * \c MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
- * \c MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
+ * #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
+ * #MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
*/
int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info ) MBEDTLS_DEPRECATED;
#undef MBEDTLS_DEPRECATED
#endif /* MBEDTLS_DEPRECATED_REMOVED */
/**
- * \brief Select MD to use and allocate internal structures.
- * Should be called after mbedtls_md_init() or mbedtls_md_free().
- * Makes it necessary to call mbedtls_md_free() later.
+ * \brief This function selects the message digest algorithm to use,
+ * and allocates internal structures.
*
- * \param ctx Context to set up.
- * \param md_info Message digest to use.
- * \param hmac 0 to save some memory if HMAC will not be used,
- * non-zero is HMAC is going to be used with this context.
+ * It should be called after mbedtls_md_init() or
+ * mbedtls_md_free(). Makes it necessary to call
+ * mbedtls_md_free() later.
+ *
+ * \param ctx The context to set up.
+ * \param md_info The information structure of the message-digest algorithm
+ * to use.
+ * \param hmac <ul><li>0: HMAC is not used. Saves some memory.</li>
+ * <li>non-zero: HMAC is used with this context.</li></ul>
*
* \returns \c 0 on success,
- * \c MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure,
- * \c MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure.
+ * #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure, or
+ * #MBEDTLS_ERR_MD_ALLOC_FAILED on memory allocation failure.
*/
int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac );
/**
- * \brief Clone the state of an MD context
+ * \brief This function clones the state of an message-digest
+ * context.
+ *
+ * \note You must call mbedtls_md_setup() on \c dst before calling
+ * this function.
*
- * \note The two contexts must have been setup to the same type
- * (cloning from SHA-256 to SHA-512 make no sense).
+ * \note The two contexts must have the same type,
+ * for example, both are SHA-256.
*
- * \warning Only clones the MD state, not the HMAC state! (for now)
+ * \warning This function clones the message-digest state, not the
+ * HMAC state.
*
- * \param dst The destination context
- * \param src The context to be cloned
+ * \param dst The destination context.
+ * \param src The context to be cloned.
*
* \return \c 0 on success,
- * \c MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure.
+ * #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure.
*/
int mbedtls_md_clone( mbedtls_md_context_t *dst,
const mbedtls_md_context_t *src );
/**
- * \brief Returns the size of the message digest output.
+ * \brief This function extracts the message-digest size from the
+ * message-digest information structure.
*
- * \param md_info message digest info
+ * \param md_info The information structure of the message-digest algorithm
+ * to use.
*
- * \return size of the message digest output in bytes.
+ * \return The size of the message-digest output in Bytes.
*/
unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info );
/**
- * \brief Returns the type of the message digest output.
+ * \brief This function extracts the message-digest type from the
+ * message-digest information structure.
*
- * \param md_info message digest info
+ * \param md_info The information structure of the message-digest algorithm
+ * to use.
*
- * \return type of the message digest output.
+ * \return The type of the message digest.
*/
mbedtls_md_type_t mbedtls_md_get_type( const mbedtls_md_info_t *md_info );
/**
- * \brief Returns the name of the message digest output.
+ * \brief This function extracts the message-digest name from the
+ * message-digest information structure.
*
- * \param md_info message digest info
+ * \param md_info The information structure of the message-digest algorithm
+ * to use.
*
- * \return name of the message digest output.
+ * \return The name of the message digest.
*/
const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info );
/**
- * \brief Prepare the context to digest a new message.
- * Generally called after mbedtls_md_setup() or mbedtls_md_finish().
- * Followed by mbedtls_md_update().
+ * \brief This function starts a message-digest computation.
*
- * \param ctx generic message digest context.
+ * You must call this function after setting up the context
+ * with mbedtls_md_setup(), and before passing data with
+ * mbedtls_md_update().
*
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \param ctx The generic message-digest context.
+ *
+ * \returns \c 0 on success, #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
+ * parameter verification fails.
*/
int mbedtls_md_starts( mbedtls_md_context_t *ctx );
/**
- * \brief Generic message digest process buffer
- * Called between mbedtls_md_starts() and mbedtls_md_finish().
- * May be called repeatedly.
+ * \brief This function feeds an input buffer into an ongoing
+ * message-digest computation.
+ *
+ * You must call mbedtls_md_starts() before calling this
+ * function. You may call this function multiple times.
+ * Afterwards, call mbedtls_md_finish().
*
- * \param ctx Generic message digest context
- * \param input buffer holding the datal
- * \param ilen length of the input data
+ * \param ctx The generic message-digest context.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
*
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \returns \c 0 on success, #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
+ * parameter verification fails.
*/
int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen );
/**
- * \brief Generic message digest final digest
- * Called after mbedtls_md_update().
- * Usually followed by mbedtls_md_free() or mbedtls_md_starts().
+ * \brief This function finishes the digest operation,
+ * and writes the result to the output buffer.
*
- * \param ctx Generic message digest context
- * \param output Generic message digest checksum result
+ * Call this function after a call to mbedtls_md_starts(),
+ * followed by any number of calls to mbedtls_md_update().
+ * Afterwards, you may either clear the context with
+ * mbedtls_md_free(), or call mbedtls_md_starts() to reuse
+ * the context for another digest operation with the same
+ * algorithm.
*
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \param ctx The generic message-digest context.
+ * \param output The buffer for the generic message-digest checksum result.
+ *
+ * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
+ * parameter verification fails.
*/
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output );
/**
- * \brief Output = message_digest( input buffer )
+ * \brief This function calculates the message-digest of a buffer,
+ * with respect to a configurable message-digest algorithm
+ * in a single call.
+ *
+ * The result is calculated as
+ * Output = message_digest(input buffer).
*
- * \param md_info message digest info
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output Generic message digest checksum result
+ * \param md_info The information structure of the message-digest algorithm
+ * to use.
+ * \param input The buffer holding the data.
+ * \param ilen The length of the input data.
+ * \param output The generic message-digest checksum result.
*
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
+ * parameter verification fails.
*/
int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
unsigned char *output );
#if defined(MBEDTLS_FS_IO)
/**
- * \brief Output = message_digest( file contents )
+ * \brief This function calculates the message-digest checksum
+ * result of the contents of the provided file.
+ *
+ * The result is calculated as
+ * Output = message_digest(file contents).
*
- * \param md_info message digest info
- * \param path input file name
- * \param output generic message digest checksum result
+ * \param md_info The information structure of the message-digest algorithm
+ * to use.
+ * \param path The input file name.
+ * \param output The generic message-digest checksum result.
*
- * \return 0 if successful,
- * MBEDTLS_ERR_MD_FILE_IO_ERROR if file input failed,
- * MBEDTLS_ERR_MD_BAD_INPUT_DATA if md_info was NULL.
+ * \return \c 0 on success,
+ * #MBEDTLS_ERR_MD_FILE_IO_ERROR if file input failed, or
+ * #MBEDTLS_ERR_MD_BAD_INPUT_DATA if \p md_info was NULL.
*/
int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path,
unsigned char *output );
#endif /* MBEDTLS_FS_IO */
/**
- * \brief Set HMAC key and prepare to authenticate a new message.
- * Usually called after mbedtls_md_setup() or mbedtls_md_hmac_finish().
+ * \brief This function sets the HMAC key and prepares to
+ * authenticate a new message.
*
- * \param ctx HMAC context
- * \param key HMAC secret key
- * \param keylen length of the HMAC key in bytes
+ * Call this function after mbedtls_md_setup(), to use
+ * the MD context for an HMAC calculation, then call
+ * mbedtls_md_hmac_update() to provide the input data, and
+ * mbedtls_md_hmac_finish() to get the HMAC value.
*
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \param ctx The message digest context containing an embedded HMAC
+ * context.
+ * \param key The HMAC secret key.
+ * \param keylen The length of the HMAC key in Bytes.
+ *
+ * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
+ * parameter verification fails.
*/
int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key,
size_t keylen );
/**
- * \brief Generic HMAC process buffer.
- * Called between mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset()
- * and mbedtls_md_hmac_finish().
- * May be called repeatedly.
- *
- * \param ctx HMAC context
- * \param input buffer holding the data
- * \param ilen length of the input data
- *
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \brief This function feeds an input buffer into an ongoing HMAC
+ * computation.
+ *
+ * Call mbedtls_md_hmac_starts() or mbedtls_md_hmac_reset()
+ * before calling this function.
+ * You may call this function multiple times to pass the
+ * input piecewise.
+ * Afterwards, call mbedtls_md_hmac_finish().
+ *
+ * \param ctx The message digest context containing an embedded HMAC
+ * context.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ *
+ * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
+ * parameter verification fails.
*/
int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input,
size_t ilen );
/**
- * \brief Output HMAC.
- * Called after mbedtls_md_hmac_update().
- * Usually followed by mbedtls_md_hmac_reset(),
- * mbedtls_md_hmac_starts(), or mbedtls_md_free().
+ * \brief This function finishes the HMAC operation, and writes
+ * the result to the output buffer.
+ *
+ * Call this function after mbedtls_md_hmac_starts() and
+ * mbedtls_md_hmac_update() to get the HMAC value. Afterwards
+ * you may either call mbedtls_md_free() to clear the context,
+ * or call mbedtls_md_hmac_reset() to reuse the context with
+ * the same HMAC key.
*
- * \param ctx HMAC context
- * \param output Generic HMAC checksum result
+ * \param ctx The message digest context containing an embedded HMAC
+ * context.
+ * \param output The generic HMAC checksum result.
*
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
+ * parameter verification fails.
*/
int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output);
/**
- * \brief Prepare to authenticate a new message with the same key.
- * Called after mbedtls_md_hmac_finish() and before
- * mbedtls_md_hmac_update().
+ * \brief This function prepares to authenticate a new message with
+ * the same key as the previous HMAC operation.
*
- * \param ctx HMAC context to be reset
+ * You may call this function after mbedtls_md_hmac_finish().
+ * Afterwards call mbedtls_md_hmac_update() to pass the new
+ * input.
*
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \param ctx The message digest context containing an embedded HMAC
+ * context.
+ *
+ * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
+ * parameter verification fails.
*/
int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx );
/**
- * \brief Output = Generic_HMAC( hmac key, input buffer )
+ * \brief This function calculates the full generic HMAC
+ * on the input buffer with the provided key.
+ *
+ * The function allocates the context, performs the
+ * calculation, and frees the context.
+ *
+ * The HMAC result is calculated as
+ * output = generic HMAC(hmac key, input buffer).
*
- * \param md_info message digest info
- * \param key HMAC secret key
- * \param keylen length of the HMAC key in bytes
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output Generic HMAC-result
+ * \param md_info The information structure of the message-digest algorithm
+ * to use.
+ * \param key The HMAC secret key.
+ * \param keylen The length of the HMAC secret key in Bytes.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ * \param output The generic HMAC result.
*
- * \returns 0 on success, MBEDTLS_ERR_MD_BAD_INPUT_DATA if parameter
- * verification fails.
+ * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if
+ * parameter verification fails.
*/
int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
*
* \brief MD2 message digest algorithm (hash function)
*
+ * \warning MD2 is considered a weak message digest and its use constitutes a
+ * security risk. We recommend considering stronger message digests
+ * instead.
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
+ *
*/
#ifndef MBEDTLS_MD2_H
#define MBEDTLS_MD2_H
#include <stddef.h>
+#define MBEDTLS_ERR_MD2_HW_ACCEL_FAILED -0x002B /**< MD2 hardware accelerator failed */
+
#if !defined(MBEDTLS_MD2_ALT)
// Regular implementation
//
/**
* \brief MD2 context structure
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
typedef struct
{
* \brief Initialize MD2 context
*
* \param ctx MD2 context to be initialized
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
void mbedtls_md2_init( mbedtls_md2_context *ctx );
* \brief Clear MD2 context
*
* \param ctx MD2 context to be cleared
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
void mbedtls_md2_free( mbedtls_md2_context *ctx );
*
* \param dst The destination context
* \param src The context to be cloned
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
void mbedtls_md2_clone( mbedtls_md2_context *dst,
const mbedtls_md2_context *src );
* \brief MD2 context setup
*
* \param ctx context to be initialized
+ *
+ * \return 0 if successful
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_md2_starts_ret( mbedtls_md2_context *ctx );
+
+/**
+ * \brief MD2 process buffer
+ *
+ * \param ctx MD2 context
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ *
+ * \return 0 if successful
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_md2_update_ret( mbedtls_md2_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
+
+/**
+ * \brief MD2 final digest
+ *
+ * \param ctx MD2 context
+ * \param output MD2 checksum result
+ *
+ * \return 0 if successful
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_md2_finish_ret( mbedtls_md2_context *ctx,
+ unsigned char output[16] );
+
+/**
+ * \brief MD2 process data block (internal use only)
+ *
+ * \param ctx MD2 context
+ *
+ * \return 0 if successful
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_internal_md2_process( mbedtls_md2_context *ctx );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
+ * \brief MD2 context setup
+ *
+ * \deprecated Superseded by mbedtls_md2_starts_ret() in 2.7.0
+ *
+ * \param ctx context to be initialized
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md2_starts( mbedtls_md2_context *ctx );
+MBEDTLS_DEPRECATED void mbedtls_md2_starts( mbedtls_md2_context *ctx );
/**
* \brief MD2 process buffer
*
+ * \deprecated Superseded by mbedtls_md2_update_ret() in 2.7.0
+ *
* \param ctx MD2 context
- * \param input buffer holding the data
+ * \param input buffer holding the data
* \param ilen length of the input data
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md2_update( mbedtls_md2_context *ctx, const unsigned char *input, size_t ilen );
+MBEDTLS_DEPRECATED void mbedtls_md2_update( mbedtls_md2_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
/**
* \brief MD2 final digest
*
+ * \deprecated Superseded by mbedtls_md2_finish_ret() in 2.7.0
+ *
* \param ctx MD2 context
* \param output MD2 checksum result
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md2_finish( mbedtls_md2_context *ctx, unsigned char output[16] );
+MBEDTLS_DEPRECATED void mbedtls_md2_finish( mbedtls_md2_context *ctx,
+ unsigned char output[16] );
+
+/**
+ * \brief MD2 process data block (internal use only)
+ *
+ * \deprecated Superseded by mbedtls_internal_md2_process() in 2.7.0
+ *
+ * \param ctx MD2 context
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+MBEDTLS_DEPRECATED void mbedtls_md2_process( mbedtls_md2_context *ctx );
+
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
/**
* \brief Output = MD2( input buffer )
*
- * \param input buffer holding the data
+ * \param input buffer holding the data
* \param ilen length of the input data
* \param output MD2 checksum result
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md2( const unsigned char *input, size_t ilen, unsigned char output[16] );
+int mbedtls_md2_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
+ * \brief Output = MD2( input buffer )
+ *
+ * \deprecated Superseded by mbedtls_md2_ret() in 2.7.0
+ *
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ * \param output MD2 checksum result
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+MBEDTLS_DEPRECATED void mbedtls_md2( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] );
+
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
+ *
+ * \warning MD2 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
int mbedtls_md2_self_test( int verbose );
-/* Internal use */
-void mbedtls_md2_process( mbedtls_md2_context *ctx );
-
#ifdef __cplusplus
}
#endif
*
* \brief MD4 message digest algorithm (hash function)
*
+ * \warning MD4 is considered a weak message digest and its use constitutes a
+ * security risk. We recommend considering stronger message digests
+ * instead.
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
+ *
*/
#ifndef MBEDTLS_MD4_H
#define MBEDTLS_MD4_H
#include <stddef.h>
#include <stdint.h>
+#define MBEDTLS_ERR_MD4_HW_ACCEL_FAILED -0x002D /**< MD4 hardware accelerator failed */
+
#if !defined(MBEDTLS_MD4_ALT)
// Regular implementation
//
/**
* \brief MD4 context structure
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
typedef struct
{
* \brief Initialize MD4 context
*
* \param ctx MD4 context to be initialized
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
void mbedtls_md4_init( mbedtls_md4_context *ctx );
* \brief Clear MD4 context
*
* \param ctx MD4 context to be cleared
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
void mbedtls_md4_free( mbedtls_md4_context *ctx );
*
* \param dst The destination context
* \param src The context to be cloned
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
void mbedtls_md4_clone( mbedtls_md4_context *dst,
const mbedtls_md4_context *src );
* \brief MD4 context setup
*
* \param ctx context to be initialized
+ *
+ * \return 0 if successful
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ */
+int mbedtls_md4_starts_ret( mbedtls_md4_context *ctx );
+
+/**
+ * \brief MD4 process buffer
+ *
+ * \param ctx MD4 context
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ *
+ * \return 0 if successful
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_md4_update_ret( mbedtls_md4_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
+
+/**
+ * \brief MD4 final digest
+ *
+ * \param ctx MD4 context
+ * \param output MD4 checksum result
+ *
+ * \return 0 if successful
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_md4_finish_ret( mbedtls_md4_context *ctx,
+ unsigned char output[16] );
+
+/**
+ * \brief MD4 process data block (internal use only)
+ *
+ * \param ctx MD4 context
+ * \param data buffer holding one block of data
+ *
+ * \return 0 if successful
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_internal_md4_process( mbedtls_md4_context *ctx,
+ const unsigned char data[64] );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
+ * \brief MD4 context setup
+ *
+ * \deprecated Superseded by mbedtls_md4_starts_ret() in 2.7.0
+ *
+ * \param ctx context to be initialized
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md4_starts( mbedtls_md4_context *ctx );
+MBEDTLS_DEPRECATED void mbedtls_md4_starts( mbedtls_md4_context *ctx );
/**
* \brief MD4 process buffer
*
+ * \deprecated Superseded by mbedtls_md4_update_ret() in 2.7.0
+ *
* \param ctx MD4 context
- * \param input buffer holding the data
+ * \param input buffer holding the data
* \param ilen length of the input data
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md4_update( mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen );
+MBEDTLS_DEPRECATED void mbedtls_md4_update( mbedtls_md4_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
/**
* \brief MD4 final digest
*
+ * \deprecated Superseded by mbedtls_md4_finish_ret() in 2.7.0
+ *
* \param ctx MD4 context
* \param output MD4 checksum result
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md4_finish( mbedtls_md4_context *ctx, unsigned char output[16] );
+MBEDTLS_DEPRECATED void mbedtls_md4_finish( mbedtls_md4_context *ctx,
+ unsigned char output[16] );
+
+/**
+ * \brief MD4 process data block (internal use only)
+ *
+ * \deprecated Superseded by mbedtls_internal_md4_process() in 2.7.0
+ *
+ * \param ctx MD4 context
+ * \param data buffer holding one block of data
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+MBEDTLS_DEPRECATED void mbedtls_md4_process( mbedtls_md4_context *ctx,
+ const unsigned char data[64] );
+
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
/**
* \brief Output = MD4( input buffer )
*
- * \param input buffer holding the data
+ * \param input buffer holding the data
* \param ilen length of the input data
* \param output MD4 checksum result
+ *
+ * \return 0 if successful
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md4( const unsigned char *input, size_t ilen, unsigned char output[16] );
+int mbedtls_md4_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
+ * \brief Output = MD4( input buffer )
+ *
+ * \deprecated Superseded by mbedtls_md4_ret() in 2.7.0
+ *
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ * \param output MD4 checksum result
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+MBEDTLS_DEPRECATED void mbedtls_md4( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] );
+
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
+ *
+ * \warning MD4 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
int mbedtls_md4_self_test( int verbose );
-/* Internal use */
-void mbedtls_md4_process( mbedtls_md4_context *ctx, const unsigned char data[64] );
-
#ifdef __cplusplus
}
#endif
*
* \brief MD5 message digest algorithm (hash function)
*
+ * \warning MD5 is considered a weak message digest and its use constitutes a
+ * security risk. We recommend considering stronger message
+ * digests instead.
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#include <stddef.h>
#include <stdint.h>
+#define MBEDTLS_ERR_MD5_HW_ACCEL_FAILED -0x002F /**< MD5 hardware accelerator failed */
+
#if !defined(MBEDTLS_MD5_ALT)
// Regular implementation
//
/**
* \brief MD5 context structure
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
typedef struct
{
* \brief Initialize MD5 context
*
* \param ctx MD5 context to be initialized
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
void mbedtls_md5_init( mbedtls_md5_context *ctx );
* \brief Clear MD5 context
*
* \param ctx MD5 context to be cleared
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
void mbedtls_md5_free( mbedtls_md5_context *ctx );
*
* \param dst The destination context
* \param src The context to be cloned
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
void mbedtls_md5_clone( mbedtls_md5_context *dst,
const mbedtls_md5_context *src );
* \brief MD5 context setup
*
* \param ctx context to be initialized
+ *
+ * \return 0 if successful
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_md5_starts_ret( mbedtls_md5_context *ctx );
+
+/**
+ * \brief MD5 process buffer
+ *
+ * \param ctx MD5 context
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ *
+ * \return 0 if successful
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_md5_update_ret( mbedtls_md5_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
+
+/**
+ * \brief MD5 final digest
+ *
+ * \param ctx MD5 context
+ * \param output MD5 checksum result
+ *
+ * \return 0 if successful
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_md5_finish_ret( mbedtls_md5_context *ctx,
+ unsigned char output[16] );
+
+/**
+ * \brief MD5 process data block (internal use only)
+ *
+ * \param ctx MD5 context
+ * \param data buffer holding one block of data
+ *
+ * \return 0 if successful
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_internal_md5_process( mbedtls_md5_context *ctx,
+ const unsigned char data[64] );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
+ * \brief MD5 context setup
+ *
+ * \deprecated Superseded by mbedtls_md5_starts_ret() in 2.7.0
+ *
+ * \param ctx context to be initialized
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md5_starts( mbedtls_md5_context *ctx );
+MBEDTLS_DEPRECATED void mbedtls_md5_starts( mbedtls_md5_context *ctx );
/**
* \brief MD5 process buffer
*
+ * \deprecated Superseded by mbedtls_md5_update_ret() in 2.7.0
+ *
* \param ctx MD5 context
- * \param input buffer holding the data
+ * \param input buffer holding the data
* \param ilen length of the input data
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen );
+MBEDTLS_DEPRECATED void mbedtls_md5_update( mbedtls_md5_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
/**
* \brief MD5 final digest
*
+ * \deprecated Superseded by mbedtls_md5_finish_ret() in 2.7.0
+ *
* \param ctx MD5 context
* \param output MD5 checksum result
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+MBEDTLS_DEPRECATED void mbedtls_md5_finish( mbedtls_md5_context *ctx,
+ unsigned char output[16] );
+
+/**
+ * \brief MD5 process data block (internal use only)
+ *
+ * \deprecated Superseded by mbedtls_internal_md5_process() in 2.7.0
+ *
+ * \param ctx MD5 context
+ * \param data buffer holding one block of data
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md5_finish( mbedtls_md5_context *ctx, unsigned char output[16] );
+MBEDTLS_DEPRECATED void mbedtls_md5_process( mbedtls_md5_context *ctx,
+ const unsigned char data[64] );
-/* Internal use */
-void mbedtls_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64] );
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
/**
* \brief Output = MD5( input buffer )
*
- * \param input buffer holding the data
+ * \param input buffer holding the data
* \param ilen length of the input data
* \param output MD5 checksum result
+ *
+ * \return 0 if successful
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_md5( const unsigned char *input, size_t ilen, unsigned char output[16] );
+int mbedtls_md5_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
+ * \brief Output = MD5( input buffer )
+ *
+ * \deprecated Superseded by mbedtls_md5_ret() in 2.7.0
+ *
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ * \param output MD5 checksum result
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+MBEDTLS_DEPRECATED void mbedtls_md5( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] );
+
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
+ *
+ * \warning MD5 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
int mbedtls_md5_self_test( int verbose );
* \warning This in an internal header. Do not include directly.
*
* \author Adriaan de Jong <dejong@fox-it.com>
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
int block_size;
/** Digest initialisation function */
- void (*starts_func)( void *ctx );
+ int (*starts_func)( void *ctx );
/** Digest update function */
- void (*update_func)( void *ctx, const unsigned char *input, size_t ilen );
+ int (*update_func)( void *ctx, const unsigned char *input, size_t ilen );
/** Digest finalisation function */
- void (*finish_func)( void *ctx, unsigned char *output );
+ int (*finish_func)( void *ctx, unsigned char *output );
/** Generic digest function */
- void (*digest_func)( const unsigned char *input, size_t ilen,
- unsigned char *output );
+ int (*digest_func)( const unsigned char *input, size_t ilen,
+ unsigned char *output );
/** Allocate a new context */
void * (*ctx_alloc_func)( void );
void (*clone_func)( void *dst, const void *src );
/** Internal use only */
- void (*process_func)( void *ctx, const unsigned char *input );
+ int (*process_func)( void *ctx, const unsigned char *input );
};
#if defined(MBEDTLS_MD2_C)
* \file memory_buffer_alloc.h
*
* \brief Buffer-based memory allocator
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
*
* \brief Deprecated header file that includes mbedtls/net_sockets.h
*
+ * \deprecated Superseded by mbedtls/net_sockets.h
+ */
+/*
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
- *
- * \deprecated Superseded by mbedtls/net_sockets.h
*/
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
* \file net_sockets.h
*
* \brief Network communication functions
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file oid.h
*
* \brief Object Identifier (OID) database
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#define MBEDTLS_OID_HMAC_SHA1 MBEDTLS_OID_RSA_COMPANY "\x02\x07" /**< id-hmacWithSHA1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 7 } */
+#define MBEDTLS_OID_HMAC_SHA224 MBEDTLS_OID_RSA_COMPANY "\x02\x08" /**< id-hmacWithSHA224 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 8 } */
+
+#define MBEDTLS_OID_HMAC_SHA256 MBEDTLS_OID_RSA_COMPANY "\x02\x09" /**< id-hmacWithSHA256 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 9 } */
+
+#define MBEDTLS_OID_HMAC_SHA384 MBEDTLS_OID_RSA_COMPANY "\x02\x0A" /**< id-hmacWithSHA384 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 10 } */
+
+#define MBEDTLS_OID_HMAC_SHA512 MBEDTLS_OID_RSA_COMPANY "\x02\x0B" /**< id-hmacWithSHA512 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 11 } */
+
/*
* Encryption algorithms
*/
* \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
*/
int mbedtls_oid_get_md_alg( const mbedtls_asn1_buf *oid, mbedtls_md_type_t *md_alg );
+
+/**
+ * \brief Translate hmac algorithm OID into md_type
+ *
+ * \param oid OID to use
+ * \param md_hmac place to store message hmac algorithm
+ *
+ * \return 0 if successful, or MBEDTLS_ERR_OID_NOT_FOUND
+ */
+int mbedtls_oid_get_md_hmac( const mbedtls_asn1_buf *oid, mbedtls_md_type_t *md_hmac );
#endif /* MBEDTLS_MD_C */
/**
*
* \brief VIA PadLock ACE for HW encryption/decryption supported by some
* processors
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file pem.h
*
* \brief Privacy Enhanced Mail (PEM) decoding
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file pk.h
*
* \brief Public Key abstraction layer
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00 /**< Elliptic curve is unsupported (only NIST curves are supported). */
#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980 /**< Unavailable feature, e.g. RSA disabled for RSA key. */
#define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900 /**< The signature is valid but its length is less than expected. */
+#define MBEDTLS_ERR_PK_HW_ACCEL_FAILED -0x3880 /**< PK hardware accelerator failed. */
#ifdef __cplusplus
extern "C" {
/**
- * \file pk.h
+ * \file pk_internal.h
*
* \brief Public Key abstraction layer: wrapper functions
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \brief Wrapper for PKCS#11 library libpkcs11-helper
*
* \author Adriaan de Jong <dejong@fox-it.com>
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file pkcs12.h
*
* \brief PKCS#12 Personal Information Exchange Syntax
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \brief PKCS#5 functions
*
* \author Mathias Olsson <mathias@kompetensum.com>
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
/**
* \file platform.h
*
- * \brief mbed TLS Platform abstraction layer
- *
- * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
+ * \brief The Mbed TLS platform abstraction layer.
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_PLATFORM_H
#define MBEDTLS_PLATFORM_H
#include <time.h>
#if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF)
#if defined(_WIN32)
-#define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf /**< Default snprintf to use */
+#define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf /**< The default \c snprintf function to use. */
#else
-#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use */
+#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< The default \c snprintf function to use. */
#endif
#endif
#if !defined(MBEDTLS_PLATFORM_STD_PRINTF)
-#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use */
+#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< The default \c printf function to use. */
#endif
#if !defined(MBEDTLS_PLATFORM_STD_FPRINTF)
-#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use */
+#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< The default \c fprintf function to use. */
#endif
#if !defined(MBEDTLS_PLATFORM_STD_CALLOC)
-#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use */
+#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< The default \c calloc function to use. */
#endif
#if !defined(MBEDTLS_PLATFORM_STD_FREE)
-#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use */
+#define MBEDTLS_PLATFORM_STD_FREE free /**< The default \c free function to use. */
#endif
#if !defined(MBEDTLS_PLATFORM_STD_EXIT)
-#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use */
+#define MBEDTLS_PLATFORM_STD_EXIT exit /**< The default \c exit function to use. */
#endif
#if !defined(MBEDTLS_PLATFORM_STD_TIME)
-#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use */
+#define MBEDTLS_PLATFORM_STD_TIME time /**< The default \c time function to use. */
#endif
#if !defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS)
-#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS /**< Default exit value to use */
+#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS EXIT_SUCCESS /**< The default exit value to use. */
#endif
#if !defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE)
-#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE /**< Default exit value to use */
+#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE EXIT_FAILURE /**< The default exit value to use. */
#endif
#if defined(MBEDTLS_FS_IO)
#if !defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ)
extern void (*mbedtls_free)( void *ptr );
/**
- * \brief Set your own memory implementation function pointers
+ * \brief This function allows configuring custom memory-management functions.
*
- * \param calloc_func the calloc function implementation
- * \param free_func the free function implementation
+ * \param calloc_func The \c calloc function implementation.
+ * \param free_func The \c free function implementation.
*
- * \return 0 if successful
+ * \return \c 0.
*/
int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ),
void (*free_func)( void * ) );
extern int (*mbedtls_fprintf)( FILE *stream, const char *format, ... );
/**
- * \brief Set your own fprintf function pointer
+ * \brief This function allows configuring a custom \p fprintf function pointer.
*
- * \param fprintf_func the fprintf function implementation
+ * \param fprintf_func The \c fprintf function implementation.
*
- * \return 0
+ * \return \c 0.
*/
int mbedtls_platform_set_fprintf( int (*fprintf_func)( FILE *stream, const char *,
... ) );
extern int (*mbedtls_printf)( const char *format, ... );
/**
- * \brief Set your own printf function pointer
+ * \brief This function allows configuring a custom \c printf function
+ * pointer.
*
- * \param printf_func the printf function implementation
+ * \param printf_func The \c printf function implementation.
*
- * \return 0
+ * \return \c 0 on success.
*/
int mbedtls_platform_set_printf( int (*printf_func)( const char *, ... ) );
#else /* !MBEDTLS_PLATFORM_PRINTF_ALT */
extern int (*mbedtls_snprintf)( char * s, size_t n, const char * format, ... );
/**
- * \brief Set your own snprintf function pointer
+ * \brief This function allows configuring a custom \c snprintf function
+ * pointer.
*
- * \param snprintf_func the snprintf function implementation
+ * \param snprintf_func The \c snprintf function implementation.
*
- * \return 0
+ * \return \c 0 on success.
*/
int mbedtls_platform_set_snprintf( int (*snprintf_func)( char * s, size_t n,
const char * format, ... ) );
extern void (*mbedtls_exit)( int status );
/**
- * \brief Set your own exit function pointer
+ * \brief This function allows configuring a custom \c exit function
+ * pointer.
*
- * \param exit_func the exit function implementation
+ * \param exit_func The \c exit function implementation.
*
- * \return 0
+ * \return \c 0 on success.
*/
int mbedtls_platform_set_exit( void (*exit_func)( int status ) );
#else
extern int (*mbedtls_nv_seed_write)( unsigned char *buf, size_t buf_len );
/**
- * \brief Set your own seed file writing/reading functions
+ * \brief This function allows configuring custom seed file writing and
+ * reading functions.
*
- * \param nv_seed_read_func the seed reading function implementation
- * \param nv_seed_write_func the seed writing function implementation
+ * \param nv_seed_read_func The seed reading function implementation.
+ * \param nv_seed_write_func The seed writing function implementation.
*
- * \return 0
+ * \return \c 0 on success.
*/
int mbedtls_platform_set_nv_seed(
int (*nv_seed_read_func)( unsigned char *buf, size_t buf_len ),
#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */
#endif /* MBEDTLS_ENTROPY_NV_SEED */
+#if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
+
+/**
+ * \brief The platform context structure.
+ *
+ * \note This structure may be used to assist platform-specific
+ * setup or teardown operations.
+ */
+typedef struct {
+ char dummy; /**< Placeholder member, as empty structs are not portable. */
+}
+mbedtls_platform_context;
+
+#else
+#include "platform_alt.h"
+#endif /* !MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */
+
+/**
+ * \brief This function performs any platform initialization operations.
+ *
+ * \param ctx The Mbed TLS context.
+ *
+ * \return \c 0 on success.
+ *
+ * \note This function is intended to allow platform-specific initialization,
+ * and should be called before any other library functions. Its
+ * implementation is platform-specific, and unless
+ * platform-specific code is provided, it does nothing.
+ *
+ * Its use and whether it is necessary to call it is dependent on the
+ * platform.
+ */
+int mbedtls_platform_setup( mbedtls_platform_context *ctx );
+/**
+ * \brief This function performs any platform teardown operations.
+ *
+ * \param ctx The Mbed TLS context.
+ *
+ * \note This function should be called after every other Mbed TLS module
+ * has been correctly freed using the appropriate free function.
+ * Its implementation is platform-specific, and unless
+ * platform-specific code is provided, it does nothing.
+ *
+ * Its use and whether it is necessary to call it is dependent on the
+ * platform.
+ */
+void mbedtls_platform_teardown( mbedtls_platform_context *ctx );
+
#ifdef __cplusplus
}
#endif
* \file platform_time.h
*
* \brief mbed TLS Platform time abstraction
- *
+ */
+/*
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file ripemd160.h
*
* \brief RIPE MD-160 message digest
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#include <stddef.h>
#include <stdint.h>
+#define MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED -0x0031 /**< RIPEMD160 hardware accelerator failed */
+
#if !defined(MBEDTLS_RIPEMD160_ALT)
// Regular implementation
//
* \brief RIPEMD-160 context setup
*
* \param ctx context to be initialized
+ *
+ * \return 0 if successful
*/
-void mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx );
+int mbedtls_ripemd160_starts_ret( mbedtls_ripemd160_context *ctx );
/**
* \brief RIPEMD-160 process buffer
*
* \param ctx RIPEMD-160 context
- * \param input buffer holding the data
+ * \param input buffer holding the data
* \param ilen length of the input data
+ *
+ * \return 0 if successful
*/
-void mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx,
- const unsigned char *input, size_t ilen );
+int mbedtls_ripemd160_update_ret( mbedtls_ripemd160_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
/**
* \brief RIPEMD-160 final digest
*
* \param ctx RIPEMD-160 context
* \param output RIPEMD-160 checksum result
+ *
+ * \return 0 if successful
+ */
+int mbedtls_ripemd160_finish_ret( mbedtls_ripemd160_context *ctx,
+ unsigned char output[20] );
+
+/**
+ * \brief RIPEMD-160 process data block (internal use only)
+ *
+ * \param ctx RIPEMD-160 context
+ * \param data buffer holding one block of data
+ *
+ * \return 0 if successful
+ */
+int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx,
+ const unsigned char data[64] );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
+ * \brief RIPEMD-160 context setup
+ *
+ * \deprecated Superseded by mbedtls_ripemd160_starts_ret() in 2.7.0
+ *
+ * \param ctx context to be initialized
*/
-void mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx, unsigned char output[20] );
+MBEDTLS_DEPRECATED void mbedtls_ripemd160_starts(
+ mbedtls_ripemd160_context *ctx );
-/* Internal use */
-void mbedtls_ripemd160_process( mbedtls_ripemd160_context *ctx, const unsigned char data[64] );
+/**
+ * \brief RIPEMD-160 process buffer
+ *
+ * \deprecated Superseded by mbedtls_ripemd160_update_ret() in 2.7.0
+ *
+ * \param ctx RIPEMD-160 context
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ */
+MBEDTLS_DEPRECATED void mbedtls_ripemd160_update(
+ mbedtls_ripemd160_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
+
+/**
+ * \brief RIPEMD-160 final digest
+ *
+ * \deprecated Superseded by mbedtls_ripemd160_finish_ret() in 2.7.0
+ *
+ * \param ctx RIPEMD-160 context
+ * \param output RIPEMD-160 checksum result
+ */
+MBEDTLS_DEPRECATED void mbedtls_ripemd160_finish(
+ mbedtls_ripemd160_context *ctx,
+ unsigned char output[20] );
+
+/**
+ * \brief RIPEMD-160 process data block (internal use only)
+ *
+ * \deprecated Superseded by mbedtls_internal_ripemd160_process() in 2.7.0
+ *
+ * \param ctx RIPEMD-160 context
+ * \param data buffer holding one block of data
+ */
+MBEDTLS_DEPRECATED void mbedtls_ripemd160_process(
+ mbedtls_ripemd160_context *ctx,
+ const unsigned char data[64] );
+
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
#endif
#else /* MBEDTLS_RIPEMD160_ALT */
-#include "ripemd160.h"
+#include "ripemd160_alt.h"
#endif /* MBEDTLS_RIPEMD160_ALT */
#ifdef __cplusplus
/**
* \brief Output = RIPEMD-160( input buffer )
*
- * \param input buffer holding the data
+ * \param input buffer holding the data
* \param ilen length of the input data
* \param output RIPEMD-160 checksum result
+ *
+ * \return 0 if successful
*/
-void mbedtls_ripemd160( const unsigned char *input, size_t ilen,
- unsigned char output[20] );
+int mbedtls_ripemd160_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[20] );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
+ * \brief Output = RIPEMD-160( input buffer )
+ *
+ * \deprecated Superseded by mbedtls_ripemd160_ret() in 2.7.0
+ *
+ * \param input buffer holding the data
+ * \param ilen length of the input data
+ * \param output RIPEMD-160 checksum result
+ */
+MBEDTLS_DEPRECATED void mbedtls_ripemd160( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[20] );
+
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
/**
* \brief Checkup routine
/**
* \file rsa.h
*
- * \brief The RSA public-key cryptosystem
+ * \brief The RSA public-key cryptosystem.
*
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ * For more information, see <em>Public-Key Cryptography Standards (PKCS)
+ * #1 v1.5: RSA Encryption</em> and <em>Public-Key Cryptography Standards
+ * (PKCS) #1 v2.1: RSA Cryptography Specifications</em>.
+ *
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_RSA_H
#define MBEDTLS_RSA_H
#define MBEDTLS_ERR_RSA_BAD_INPUT_DATA -0x4080 /**< Bad input parameters to function. */
#define MBEDTLS_ERR_RSA_INVALID_PADDING -0x4100 /**< Input data contains invalid padding and is rejected. */
#define MBEDTLS_ERR_RSA_KEY_GEN_FAILED -0x4180 /**< Something failed during generation of a key. */
-#define MBEDTLS_ERR_RSA_KEY_CHECK_FAILED -0x4200 /**< Key failed to pass the library's validity check. */
+#define MBEDTLS_ERR_RSA_KEY_CHECK_FAILED -0x4200 /**< Key failed to pass the validity check of the library. */
#define MBEDTLS_ERR_RSA_PUBLIC_FAILED -0x4280 /**< The public key operation failed. */
#define MBEDTLS_ERR_RSA_PRIVATE_FAILED -0x4300 /**< The private key operation failed. */
#define MBEDTLS_ERR_RSA_VERIFY_FAILED -0x4380 /**< The PKCS#1 verification failed. */
#define MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE -0x4400 /**< The output buffer for decryption is not large enough. */
#define MBEDTLS_ERR_RSA_RNG_FAILED -0x4480 /**< The random generator failed to generate non-zeros. */
+#define MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION -0x4500 /**< The implementation does not offer the requested operation, for example, because of security violations or lack of functionality. */
+#define MBEDTLS_ERR_RSA_HW_ACCEL_FAILED -0x4580 /**< RSA hardware accelerator failed. */
/*
* RSA constants
*/
-#define MBEDTLS_RSA_PUBLIC 0
-#define MBEDTLS_RSA_PRIVATE 1
+#define MBEDTLS_RSA_PUBLIC 0 /**< Request private key operation. */
+#define MBEDTLS_RSA_PRIVATE 1 /**< Request public key operation. */
-#define MBEDTLS_RSA_PKCS_V15 0
-#define MBEDTLS_RSA_PKCS_V21 1
+#define MBEDTLS_RSA_PKCS_V15 0 /**< Use PKCS-1 v1.5 encoding. */
+#define MBEDTLS_RSA_PKCS_V21 1 /**< Use PKCS-1 v2.1 encoding. */
-#define MBEDTLS_RSA_SIGN 1
-#define MBEDTLS_RSA_CRYPT 2
+#define MBEDTLS_RSA_SIGN 1 /**< Identifier for RSA signature operations. */
+#define MBEDTLS_RSA_CRYPT 2 /**< Identifier for RSA encryption and decryption operations. */
#define MBEDTLS_RSA_SALT_LEN_ANY -1
* The above constants may be used even if the RSA module is compile out,
* eg for alternative (PKCS#11) RSA implemenations in the PK layers.
*/
-#if defined(MBEDTLS_RSA_C)
+
+#if !defined(MBEDTLS_RSA_ALT)
+// Regular implementation
+//
#ifdef __cplusplus
extern "C" {
#endif
/**
- * \brief RSA context structure
+ * \brief The RSA context structure.
+ *
+ * \note Direct manipulation of the members of this structure
+ * is deprecated. All manipulation should instead be done through
+ * the public interface functions.
*/
typedef struct
{
- int ver; /*!< always 0 */
- size_t len; /*!< size(N) in chars */
+ int ver; /*!< Always 0.*/
+ size_t len; /*!< The size of \p N in Bytes. */
+
+ mbedtls_mpi N; /*!< The public modulus. */
+ mbedtls_mpi E; /*!< The public exponent. */
- mbedtls_mpi N; /*!< public modulus */
- mbedtls_mpi E; /*!< public exponent */
+ mbedtls_mpi D; /*!< The private exponent. */
+ mbedtls_mpi P; /*!< The first prime factor. */
+ mbedtls_mpi Q; /*!< The second prime factor. */
- mbedtls_mpi D; /*!< private exponent */
- mbedtls_mpi P; /*!< 1st prime factor */
- mbedtls_mpi Q; /*!< 2nd prime factor */
- mbedtls_mpi DP; /*!< D % (P - 1) */
- mbedtls_mpi DQ; /*!< D % (Q - 1) */
+ mbedtls_mpi DP; /*!< \p D % (P - 1) */
+ mbedtls_mpi DQ; /*!< \p D % (Q - 1) */
mbedtls_mpi QP; /*!< 1 / (Q % P) */
- mbedtls_mpi RN; /*!< cached R^2 mod N */
- mbedtls_mpi RP; /*!< cached R^2 mod P */
- mbedtls_mpi RQ; /*!< cached R^2 mod Q */
+ mbedtls_mpi RN; /*!< cached R^2 mod \p N */
- mbedtls_mpi Vi; /*!< cached blinding value */
- mbedtls_mpi Vf; /*!< cached un-blinding value */
+ mbedtls_mpi RP; /*!< cached R^2 mod \p P */
+ mbedtls_mpi RQ; /*!< cached R^2 mod \p Q */
- int padding; /*!< MBEDTLS_RSA_PKCS_V15 for 1.5 padding and
- MBEDTLS_RSA_PKCS_v21 for OAEP/PSS */
- int hash_id; /*!< Hash identifier of mbedtls_md_type_t as
- specified in the mbedtls_md.h header file
- for the EME-OAEP and EMSA-PSS
- encoding */
+ mbedtls_mpi Vi; /*!< The cached blinding value. */
+ mbedtls_mpi Vf; /*!< The cached un-blinding value. */
+
+ int padding; /*!< Selects padding mode:
+ #MBEDTLS_RSA_PKCS_V15 for 1.5 padding and
+ #MBEDTLS_RSA_PKCS_V21 for OAEP or PSS. */
+ int hash_id; /*!< Hash identifier of mbedtls_md_type_t type,
+ as specified in md.h for use in the MGF
+ mask generating function used in the
+ EME-OAEP and EMSA-PSS encodings. */
#if defined(MBEDTLS_THREADING_C)
- mbedtls_threading_mutex_t mutex; /*!< Thread-safety mutex */
+ mbedtls_threading_mutex_t mutex; /*!< Thread-safety mutex. */
#endif
}
mbedtls_rsa_context;
/**
- * \brief Initialize an RSA context
+ * \brief This function initializes an RSA context.
*
- * Note: Set padding to MBEDTLS_RSA_PKCS_V21 for the RSAES-OAEP
+ * \note Set padding to #MBEDTLS_RSA_PKCS_V21 for the RSAES-OAEP
* encryption scheme and the RSASSA-PSS signature scheme.
*
- * \param ctx RSA context to be initialized
- * \param padding MBEDTLS_RSA_PKCS_V15 or MBEDTLS_RSA_PKCS_V21
- * \param hash_id MBEDTLS_RSA_PKCS_V21 hash identifier
+ * \param ctx The RSA context to initialize.
+ * \param padding Selects padding mode: #MBEDTLS_RSA_PKCS_V15 or
+ * #MBEDTLS_RSA_PKCS_V21.
+ * \param hash_id The hash identifier of #mbedtls_md_type_t type, if
+ * \p padding is #MBEDTLS_RSA_PKCS_V21.
*
- * \note The hash_id parameter is actually ignored
- * when using MBEDTLS_RSA_PKCS_V15 padding.
+ * \note The \p hash_id parameter is ignored when using
+ * #MBEDTLS_RSA_PKCS_V15 padding.
*
- * \note Choice of padding mode is strictly enforced for private key
+ * \note The choice of padding mode is strictly enforced for private key
* operations, since there might be security concerns in
- * mixing padding modes. For public key operations it's merely
+ * mixing padding modes. For public key operations it is
* a default value, which can be overriden by calling specific
- * rsa_rsaes_xxx or rsa_rsassa_xxx functions.
+ * \c rsa_rsaes_xxx or \c rsa_rsassa_xxx functions.
*
- * \note The chosen hash is always used for OEAP encryption.
- * For PSS signatures, it's always used for making signatures,
- * but can be overriden (and always is, if set to
- * MBEDTLS_MD_NONE) for verifying them.
+ * \note The hash selected in \p hash_id is always used for OEAP
+ * encryption. For PSS signatures, it is always used for
+ * making signatures, but can be overriden for verifying them.
+ * If set to #MBEDTLS_MD_NONE, it is always overriden.
*/
void mbedtls_rsa_init( mbedtls_rsa_context *ctx,
- int padding,
- int hash_id);
+ int padding,
+ int hash_id);
/**
- * \brief Set padding for an already initialized RSA context
- * See \c mbedtls_rsa_init() for details.
+ * \brief This function imports a set of core parameters into an
+ * RSA context.
+ *
+ * \param ctx The initialized RSA context to store the parameters in.
+ * \param N The RSA modulus, or NULL.
+ * \param P The first prime factor of \p N, or NULL.
+ * \param Q The second prime factor of \p N, or NULL.
+ * \param D The private exponent, or NULL.
+ * \param E The public exponent, or NULL.
*
- * \param ctx RSA context to be set
- * \param padding MBEDTLS_RSA_PKCS_V15 or MBEDTLS_RSA_PKCS_V21
- * \param hash_id MBEDTLS_RSA_PKCS_V21 hash identifier
+ * \note This function can be called multiple times for successive
+ * imports, if the parameters are not simultaneously present.
+ *
+ * Any sequence of calls to this function should be followed
+ * by a call to mbedtls_rsa_complete(), which checks and
+ * completes the provided information to a ready-for-use
+ * public or private RSA key.
+ *
+ * \note See mbedtls_rsa_complete() for more information on which
+ * parameters are necessary to set up a private or public
+ * RSA key.
+ *
+ * \note The imported parameters are copied and need not be preserved
+ * for the lifetime of the RSA context being set up.
+ *
+ * \return \c 0 on success, or a non-zero error code on failure.
*/
-void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, int hash_id);
+int mbedtls_rsa_import( mbedtls_rsa_context *ctx,
+ const mbedtls_mpi *N,
+ const mbedtls_mpi *P, const mbedtls_mpi *Q,
+ const mbedtls_mpi *D, const mbedtls_mpi *E );
/**
- * \brief Generate an RSA keypair
+ * \brief This function imports core RSA parameters, in raw big-endian
+ * binary format, into an RSA context.
+ *
+ * \param ctx The initialized RSA context to store the parameters in.
+ * \param N The RSA modulus, or NULL.
+ * \param N_len The Byte length of \p N, ignored if \p N == NULL.
+ * \param P The first prime factor of \p N, or NULL.
+ * \param P_len The Byte length of \p P, ignored if \p P == NULL.
+ * \param Q The second prime factor of \p N, or NULL.
+ * \param Q_len The Byte length of \p Q, ignored if \p Q == NULL.
+ * \param D The private exponent, or NULL.
+ * \param D_len The Byte length of \p D, ignored if \p D == NULL.
+ * \param E The public exponent, or NULL.
+ * \param E_len The Byte length of \p E, ignored if \p E == NULL.
+ *
+ * \note This function can be called multiple times for successive
+ * imports, if the parameters are not simultaneously present.
+ *
+ * Any sequence of calls to this function should be followed
+ * by a call to mbedtls_rsa_complete(), which checks and
+ * completes the provided information to a ready-for-use
+ * public or private RSA key.
+ *
+ * \note See mbedtls_rsa_complete() for more information on which
+ * parameters are necessary to set up a private or public
+ * RSA key.
+ *
+ * \note The imported parameters are copied and need not be preserved
+ * for the lifetime of the RSA context being set up.
+ *
+ * \return \c 0 on success, or a non-zero error code on failure.
+ */
+int mbedtls_rsa_import_raw( mbedtls_rsa_context *ctx,
+ unsigned char const *N, size_t N_len,
+ unsigned char const *P, size_t P_len,
+ unsigned char const *Q, size_t Q_len,
+ unsigned char const *D, size_t D_len,
+ unsigned char const *E, size_t E_len );
+
+/**
+ * \brief This function completes an RSA context from
+ * a set of imported core parameters.
+ *
+ * To setup an RSA public key, precisely \p N and \p E
+ * must have been imported.
*
- * \param ctx RSA context that will hold the key
- * \param f_rng RNG function
- * \param p_rng RNG parameter
- * \param nbits size of the public key in bits
- * \param exponent public exponent (e.g., 65537)
+ * To setup an RSA private key, sufficient information must
+ * be present for the other parameters to be derivable.
*
- * \note mbedtls_rsa_init() must be called beforehand to setup
- * the RSA context.
+ * The default implementation supports the following:
+ * <ul><li>Derive \p P, \p Q from \p N, \p D, \p E.</li>
+ * <li>Derive \p N, \p D from \p P, \p Q, \p E.</li></ul>
+ * Alternative implementations need not support these.
+ *
+ * If this function runs successfully, it guarantees that
+ * the RSA context can be used for RSA operations without
+ * the risk of failure or crash.
+ *
+ * \param ctx The initialized RSA context holding imported parameters.
+ *
+ * \return \c 0 on success, or #MBEDTLS_ERR_RSA_BAD_INPUT_DATA if the
+ * attempted derivations failed.
+ *
+ * \warning This function need not perform consistency checks
+ * for the imported parameters. In particular, parameters that
+ * are not needed by the implementation might be silently
+ * discarded and left unchecked. To check the consistency
+ * of the key material, see mbedtls_rsa_check_privkey().
*
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
*/
-int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- unsigned int nbits, int exponent );
+int mbedtls_rsa_complete( mbedtls_rsa_context *ctx );
/**
- * \brief Check a public RSA key
+ * \brief This function exports the core parameters of an RSA key.
+ *
+ * If this function runs successfully, the non-NULL buffers
+ * pointed to by \p N, \p P, \p Q, \p D, and \p E are fully
+ * written, with additional unused space filled leading by
+ * zero Bytes.
+ *
+ * Possible reasons for returning
+ * #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION:<ul>
+ * <li>An alternative RSA implementation is in use, which
+ * stores the key externally, and either cannot or should
+ * not export it into RAM.</li>
+ * <li>A SW or HW implementation might not support a certain
+ * deduction. For example, \p P, \p Q from \p N, \p D,
+ * and \p E if the former are not part of the
+ * implementation.</li></ul>
+ *
+ * If the function fails due to an unsupported operation,
+ * the RSA context stays intact and remains usable.
+ *
+ * \param ctx The initialized RSA context.
+ * \param N The MPI to hold the RSA modulus, or NULL.
+ * \param P The MPI to hold the first prime factor of \p N, or NULL.
+ * \param Q The MPI to hold the second prime factor of \p N, or NULL.
+ * \param D The MPI to hold the private exponent, or NULL.
+ * \param E The MPI to hold the public exponent, or NULL.
+ *
+ * \return \c 0 on success,
+ * #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION if exporting the
+ * requested parameters cannot be done due to missing
+ * functionality or because of security policies,
+ * or a non-zero return code on any other failure.
+ *
+ */
+int mbedtls_rsa_export( const mbedtls_rsa_context *ctx,
+ mbedtls_mpi *N, mbedtls_mpi *P, mbedtls_mpi *Q,
+ mbedtls_mpi *D, mbedtls_mpi *E );
+
+/**
+ * \brief This function exports core parameters of an RSA key
+ * in raw big-endian binary format.
+ *
+ * If this function runs successfully, the non-NULL buffers
+ * pointed to by \p N, \p P, \p Q, \p D, and \p E are fully
+ * written, with additional unused space filled leading by
+ * zero Bytes.
+ *
+ * Possible reasons for returning
+ * #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION:<ul>
+ * <li>An alternative RSA implementation is in use, which
+ * stores the key externally, and either cannot or should
+ * not export it into RAM.</li>
+ * <li>A SW or HW implementation might not support a certain
+ * deduction. For example, \p P, \p Q from \p N, \p D,
+ * and \p E if the former are not part of the
+ * implementation.</li></ul>
+ * If the function fails due to an unsupported operation,
+ * the RSA context stays intact and remains usable.
+ *
+ * \param ctx The initialized RSA context.
+ * \param N The Byte array to store the RSA modulus, or NULL.
+ * \param N_len The size of the buffer for the modulus.
+ * \param P The Byte array to hold the first prime factor of \p N, or
+ * NULL.
+ * \param P_len The size of the buffer for the first prime factor.
+ * \param Q The Byte array to hold the second prime factor of \p N, or
+ NULL.
+ * \param Q_len The size of the buffer for the second prime factor.
+ * \param D The Byte array to hold the private exponent, or NULL.
+ * \param D_len The size of the buffer for the private exponent.
+ * \param E The Byte array to hold the public exponent, or NULL.
+ * \param E_len The size of the buffer for the public exponent.
+ *
+ * \note The length fields are ignored if the corresponding
+ * buffer pointers are NULL.
+ *
+ * \return \c 0 on success,
+ * #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION if exporting the
+ * requested parameters cannot be done due to missing
+ * functionality or because of security policies,
+ * or a non-zero return code on any other failure.
+ */
+int mbedtls_rsa_export_raw( const mbedtls_rsa_context *ctx,
+ unsigned char *N, size_t N_len,
+ unsigned char *P, size_t P_len,
+ unsigned char *Q, size_t Q_len,
+ unsigned char *D, size_t D_len,
+ unsigned char *E, size_t E_len );
+
+/**
+ * \brief This function exports CRT parameters of a private RSA key.
+ *
+ * \param ctx The initialized RSA context.
+ * \param DP The MPI to hold D modulo P-1, or NULL.
+ * \param DQ The MPI to hold D modulo Q-1, or NULL.
+ * \param QP The MPI to hold modular inverse of Q modulo P, or NULL.
*
- * \param ctx RSA context to be checked
+ * \return \c 0 on success, non-zero error code otherwise.
+ *
+ * \note Alternative RSA implementations not using CRT-parameters
+ * internally can implement this function based on
+ * mbedtls_rsa_deduce_opt().
*
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
*/
-int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx );
+int mbedtls_rsa_export_crt( const mbedtls_rsa_context *ctx,
+ mbedtls_mpi *DP, mbedtls_mpi *DQ, mbedtls_mpi *QP );
+
+/**
+ * \brief This function sets padding for an already initialized RSA
+ * context. See mbedtls_rsa_init() for details.
+ *
+ * \param ctx The RSA context to be set.
+ * \param padding Selects padding mode: #MBEDTLS_RSA_PKCS_V15 or
+ * #MBEDTLS_RSA_PKCS_V21.
+ * \param hash_id The #MBEDTLS_RSA_PKCS_V21 hash identifier.
+ */
+void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding,
+ int hash_id);
+
+/**
+ * \brief This function retrieves the length of RSA modulus in Bytes.
+ *
+ * \param ctx The initialized RSA context.
+ *
+ * \return The length of the RSA modulus in Bytes.
+ *
+ */
+size_t mbedtls_rsa_get_len( const mbedtls_rsa_context *ctx );
+
+/**
+ * \brief This function generates an RSA keypair.
+ *
+ * \param ctx The RSA context used to hold the key.
+ * \param f_rng The RNG function.
+ * \param p_rng The RNG parameter.
+ * \param nbits The size of the public key in bits.
+ * \param exponent The public exponent. For example, 65537.
+ *
+ * \note mbedtls_rsa_init() must be called before this function,
+ * to set up the RSA context.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code
+ on failure.
+ */
+int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx,
+ int (*f_rng)(void *, unsigned char *, size_t),
+ void *p_rng,
+ unsigned int nbits, int exponent );
/**
- * \brief Check a private RSA key
+ * \brief This function checks if a context contains at least an RSA
+ * public key.
+ *
+ * If the function runs successfully, it is guaranteed that
+ * enough information is present to perform an RSA public key
+ * operation using mbedtls_rsa_public().
+ *
+ * \param ctx The RSA context to check.
*
- * \param ctx RSA context to be checked
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
*
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
+ */
+int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx );
+
+/**
+ * \brief This function checks if a context contains an RSA private key
+ * and perform basic consistency checks.
+ *
+ * \param ctx The RSA context to check.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code on
+ * failure.
+ *
+ * \note The consistency checks performed by this function not only
+ * ensure that mbedtls_rsa_private() can be called successfully
+ * on the given context, but that the various parameters are
+ * mutually consistent with high probability, in the sense that
+ * mbedtls_rsa_public() and mbedtls_rsa_private() are inverses.
+ *
+ * \warning This function should catch accidental misconfigurations
+ * like swapping of parameters, but it cannot establish full
+ * trust in neither the quality nor the consistency of the key
+ * material that was used to setup the given RSA context:
+ * <ul><li>Consistency: Imported parameters that are irrelevant
+ * for the implementation might be silently dropped. If dropped,
+ * the current function does not have access to them,
+ * and therefore cannot check them. See mbedtls_rsa_complete().
+ * If you want to check the consistency of the entire
+ * content of an PKCS1-encoded RSA private key, for example, you
+ * should use mbedtls_rsa_validate_params() before setting
+ * up the RSA context.
+ * Additionally, if the implementation performs empirical checks,
+ * these checks substantiate but do not guarantee consistency.</li>
+ * <li>Quality: This function is not expected to perform
+ * extended quality assessments like checking that the prime
+ * factors are safe. Additionally, it is the responsibility of the
+ * user to ensure the trustworthiness of the source of his RSA
+ * parameters, which goes beyond what is effectively checkable
+ * by the library.</li></ul>
*/
int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx );
/**
- * \brief Check a public-private RSA key pair.
- * Check each of the contexts, and make sure they match.
+ * \brief This function checks a public-private RSA key pair.
*
- * \param pub RSA context holding the public key
- * \param prv RSA context holding the private key
+ * It checks each of the contexts, and makes sure they match.
*
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
+ * \param pub The RSA context holding the public key.
+ * \param prv The RSA context holding the private key.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
*/
-int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv );
+int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub,
+ const mbedtls_rsa_context *prv );
/**
- * \brief Do an RSA public key operation
+ * \brief This function performs an RSA public key operation.
+ *
+ * \param ctx The RSA context.
+ * \param input The input buffer.
+ * \param output The output buffer.
*
- * \param ctx RSA context
- * \param input input buffer
- * \param output output buffer
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
*
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
+ * \note This function does not handle message padding.
*
- * \note This function does NOT take care of message
- * padding. Also, be sure to set input[0] = 0 or assure that
- * input is smaller than N.
+ * \note Make sure to set \p input[0] = 0 or ensure that
+ * input is smaller than \p N.
*
* \note The input and output buffers must be large
- * enough (eg. 128 bytes if RSA-1024 is used).
+ * enough. For example, 128 Bytes if RSA-1024 is used.
*/
int mbedtls_rsa_public( mbedtls_rsa_context *ctx,
const unsigned char *input,
unsigned char *output );
/**
- * \brief Do an RSA private key operation
+ * \brief This function performs an RSA private key operation.
*
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for blinding)
- * \param p_rng RNG parameter
- * \param input input buffer
- * \param output output buffer
+ * \param ctx The RSA context.
+ * \param f_rng The RNG function. Needed for blinding.
+ * \param p_rng The RNG parameter.
+ * \param input The input buffer.
+ * \param output The output buffer.
*
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
*
* \note The input and output buffers must be large
- * enough (eg. 128 bytes if RSA-1024 is used).
+ * enough. For example, 128 Bytes if RSA-1024 is used.
+ *
+ * \note Blinding is used if and only if a PRNG is provided.
+ *
+ * \note If blinding is used, both the base of exponentation
+ * and the exponent are blinded, providing protection
+ * against some side-channel attacks.
+ *
+ * \warning It is deprecated and a security risk to not provide
+ * a PRNG here and thereby prevent the use of blinding.
+ * Future versions of the library may enforce the presence
+ * of a PRNG.
+ *
*/
int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
unsigned char *output );
/**
- * \brief Generic wrapper to perform a PKCS#1 encryption using the
- * mode from the context. Add the message padding, then do an
- * RSA operation.
+ * \brief This function adds the message padding, then performs an RSA
+ * operation.
*
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding
- * and MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param ilen contains the plaintext length
- * \param input buffer holding the data to be encrypted
- * \param output buffer that will hold the ciphertext
+ * It is the generic wrapper for performing a PKCS#1 encryption
+ * operation using the \p mode from the context.
*
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
*
- * \note The output buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
+ * \param ctx The RSA context.
+ * \param f_rng The RNG function. Needed for padding, PKCS#1 v2.1
+ * encoding, and #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param ilen The length of the plaintext.
+ * \param input The buffer holding the data to encrypt.
+ * \param output The buffer used to hold the ciphertext.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * implicitly set to #MBEDTLS_RSA_PUBLIC.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PRIVATE and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
+ *
+ * \note The input and output buffers must be as large as the size
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
*/
int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
unsigned char *output );
/**
- * \brief Perform a PKCS#1 v1.5 encryption (RSAES-PKCS1-v1_5-ENCRYPT)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for padding and MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param ilen contains the plaintext length
- * \param input buffer holding the data to be encrypted
- * \param output buffer that will hold the ciphertext
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
+ * \brief This function performs a PKCS#1 v1.5 encryption operation
+ * (RSAES-PKCS1-v1_5-ENCRYPT).
+ *
+ * \param ctx The RSA context.
+ * \param f_rng The RNG function. Needed for padding and
+ * #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param ilen The length of the plaintext.
+ * \param input The buffer holding the data to encrypt.
+ * \param output The buffer used to hold the ciphertext.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * implicitly set to #MBEDTLS_RSA_PUBLIC.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PRIVATE and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
*
* \note The output buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
*/
int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
unsigned char *output );
/**
- * \brief Perform a PKCS#1 v2.1 OAEP encryption (RSAES-OAEP-ENCRYPT)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for padding and PKCS#1 v2.1 encoding
- * and MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param label buffer holding the custom label to use
- * \param label_len contains the label length
- * \param ilen contains the plaintext length
- * \param input buffer holding the data to be encrypted
- * \param output buffer that will hold the ciphertext
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
+ * \brief This function performs a PKCS#1 v2.1 OAEP encryption
+ * operation (RSAES-OAEP-ENCRYPT).
+ *
+ * \param ctx The RSA context.
+ * \param f_rng The RNG function. Needed for padding and PKCS#1 v2.1
+ * encoding and #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param label The buffer holding the custom label to use.
+ * \param label_len The length of the label.
+ * \param ilen The length of the plaintext.
+ * \param input The buffer holding the data to encrypt.
+ * \param output The buffer used to hold the ciphertext.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * implicitly set to #MBEDTLS_RSA_PUBLIC.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PRIVATE and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
*
* \note The output buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
+ * of ctx->N. For example, 128 Bytes if RSA-1024 is used.
*/
int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
unsigned char *output );
/**
- * \brief Generic wrapper to perform a PKCS#1 decryption using the
- * mode from the context. Do an RSA operation, then remove
- * the message padding
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param olen will contain the plaintext length
- * \param input buffer holding the encrypted data
- * \param output buffer that will hold the plaintext
- * \param output_max_len maximum length of the output buffer
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The output buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
- * an error is thrown.
+ * \brief This function performs an RSA operation, then removes the
+ * message padding.
+ *
+ * It is the generic wrapper for performing a PKCS#1 decryption
+ * operation using the \p mode from the context.
+ *
+ * \param ctx The RSA context.
+ * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param olen The length of the plaintext.
+ * \param input The buffer holding the encrypted data.
+ * \param output The buffer used to hold the plaintext.
+ * \param output_max_len The maximum length of the output buffer.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * implicitly set to #MBEDTLS_RSA_PRIVATE.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PUBLIC and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
+ *
+ * \note The output buffer length \c output_max_len should be
+ * as large as the size \p ctx->len of \p ctx->N (for example,
+ * 128 Bytes if RSA-1024 is used) to be able to hold an
+ * arbitrary decrypted message. If it is not large enough to
+ * hold the decryption of the particular ciphertext provided,
+ * the function returns \c MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
+ *
+ * \note The input buffer must be as large as the size
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
*/
int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
size_t output_max_len );
/**
- * \brief Perform a PKCS#1 v1.5 decryption (RSAES-PKCS1-v1_5-DECRYPT)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param olen will contain the plaintext length
- * \param input buffer holding the encrypted data
- * \param output buffer that will hold the plaintext
- * \param output_max_len maximum length of the output buffer
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The output buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
- * an error is thrown.
+ * \brief This function performs a PKCS#1 v1.5 decryption
+ * operation (RSAES-PKCS1-v1_5-DECRYPT).
+ *
+ * \param ctx The RSA context.
+ * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param olen The length of the plaintext.
+ * \param input The buffer holding the encrypted data.
+ * \param output The buffer to hold the plaintext.
+ * \param output_max_len The maximum length of the output buffer.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * implicitly set to #MBEDTLS_RSA_PRIVATE.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PUBLIC and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
+ *
+ * \note The output buffer length \c output_max_len should be
+ * as large as the size \p ctx->len of \p ctx->N, for example,
+ * 128 Bytes if RSA-1024 is used, to be able to hold an
+ * arbitrary decrypted message. If it is not large enough to
+ * hold the decryption of the particular ciphertext provided,
+ * the function returns #MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
+ *
+ * \note The input buffer must be as large as the size
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
*/
int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
size_t output_max_len );
/**
- * \brief Perform a PKCS#1 v2.1 OAEP decryption (RSAES-OAEP-DECRYPT)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param label buffer holding the custom label to use
- * \param label_len contains the label length
- * \param olen will contain the plaintext length
- * \param input buffer holding the encrypted data
- * \param output buffer that will hold the plaintext
- * \param output_max_len maximum length of the output buffer
- *
- * \return 0 if successful, or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The output buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used) otherwise
- * an error is thrown.
+ * \brief This function performs a PKCS#1 v2.1 OAEP decryption
+ * operation (RSAES-OAEP-DECRYPT).
+ *
+ * \param ctx The RSA context.
+ * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param label The buffer holding the custom label to use.
+ * \param label_len The length of the label.
+ * \param olen The length of the plaintext.
+ * \param input The buffer holding the encrypted data.
+ * \param output The buffer to hold the plaintext.
+ * \param output_max_len The maximum length of the output buffer.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * implicitly set to #MBEDTLS_RSA_PRIVATE.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PUBLIC and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
+ *
+ * \note The output buffer length \c output_max_len should be
+ * as large as the size \p ctx->len of \p ctx->N, for
+ * example, 128 Bytes if RSA-1024 is used, to be able to
+ * hold an arbitrary decrypted message. If it is not
+ * large enough to hold the decryption of the particular
+ * ciphertext provided, the function returns
+ * #MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE.
+ *
+ * \note The input buffer must be as large as the size
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
*/
int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
size_t output_max_len );
/**
- * \brief Generic wrapper to perform a PKCS#1 signature using the
- * mode from the context. Do a private RSA operation to sign
- * a message digest
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for
- * MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer that will hold the ciphertext
- *
- * \return 0 if the signing operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- *
- * \note In case of PKCS#1 v2.1 encoding, see comments on
- * \note \c mbedtls_rsa_rsassa_pss_sign() for details on md_alg and hash_id.
+ * \brief This function performs a private RSA operation to sign
+ * a message digest using PKCS#1.
+ *
+ * It is the generic wrapper for performing a PKCS#1
+ * signature using the \p mode from the context.
+ *
+ * \param ctx The RSA context.
+ * \param f_rng The RNG function. Needed for PKCS#1 v2.1 encoding and for
+ * #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param md_alg The message-digest algorithm used to hash the original data.
+ * Use #MBEDTLS_MD_NONE for signing raw data.
+ * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE.
+ * \param hash The buffer holding the message digest.
+ * \param sig The buffer to hold the ciphertext.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * implicitly set to #MBEDTLS_RSA_PRIVATE.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PUBLIC and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 if the signing operation was successful,
+ * or an \c MBEDTLS_ERR_RSA_XXX error code on failure.
+ *
+ * \note The \p sig buffer must be as large as the size
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
+ *
+ * \note For PKCS#1 v2.1 encoding, see comments on
+ * mbedtls_rsa_rsassa_pss_sign() for details on
+ * \p md_alg and \p hash_id.
*/
int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
unsigned char *sig );
/**
- * \brief Perform a PKCS#1 v1.5 signature (RSASSA-PKCS1-v1_5-SIGN)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer that will hold the ciphertext
- *
- * \return 0 if the signing operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
+ * \brief This function performs a PKCS#1 v1.5 signature
+ * operation (RSASSA-PKCS1-v1_5-SIGN).
+ *
+ * \param ctx The RSA context.
+ * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param md_alg The message-digest algorithm used to hash the original data.
+ * Use #MBEDTLS_MD_NONE for signing raw data.
+ * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE.
+ * \param hash The buffer holding the message digest.
+ * \param sig The buffer to hold the ciphertext.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * implicitly set to #MBEDTLS_RSA_PRIVATE.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PUBLIC and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 if the signing operation was successful,
+ * or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
+ *
+ * \note The \p sig buffer must be as large as the size
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
*/
int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
unsigned char *sig );
/**
- * \brief Perform a PKCS#1 v2.1 PSS signature (RSASSA-PSS-SIGN)
- *
- * \param ctx RSA context
- * \param f_rng RNG function (Needed for PKCS#1 v2.1 encoding and for
- * MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer that will hold the ciphertext
- *
- * \return 0 if the signing operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- *
- * \note The hash_id in the RSA context is the one used for the
- * encoding. md_alg in the function call is the type of hash
- * that is encoded. According to RFC 3447 it is advised to
- * keep both hashes the same.
+ * \brief This function performs a PKCS#1 v2.1 PSS signature
+ * operation (RSASSA-PSS-SIGN).
+ *
+ * \param ctx The RSA context.
+ * \param f_rng The RNG function. Needed for PKCS#1 v2.1 encoding and for
+ * #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param md_alg The message-digest algorithm used to hash the original data.
+ * Use #MBEDTLS_MD_NONE for signing raw data.
+ * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE.
+ * \param hash The buffer holding the message digest.
+ * \param sig The buffer to hold the ciphertext.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * implicitly set to #MBEDTLS_RSA_PRIVATE.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PUBLIC and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 if the signing operation was successful,
+ * or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
+ *
+ * \note The \p sig buffer must be as large as the size
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
+ *
+ * \note The \p hash_id in the RSA context is the one used for the
+ * encoding. \p md_alg in the function call is the type of hash
+ * that is encoded. According to <em>RFC-3447: Public-Key
+ * Cryptography Standards (PKCS) #1 v2.1: RSA Cryptography
+ * Specifications</em> it is advised to keep both hashes the
+ * same.
*/
int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
unsigned char *sig );
/**
- * \brief Generic wrapper to perform a PKCS#1 verification using the
- * mode from the context. Do a public RSA operation and check
- * the message digest
- *
- * \param ctx points to an RSA public key
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer holding the ciphertext
- *
- * \return 0 if the verify operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- *
- * \note In case of PKCS#1 v2.1 encoding, see comments on
- * \c mbedtls_rsa_rsassa_pss_verify() about md_alg and hash_id.
+ * \brief This function performs a public RSA operation and checks
+ * the message digest.
+ *
+ * This is the generic wrapper for performing a PKCS#1
+ * verification using the mode from the context.
+ *
+ * \param ctx The RSA public key context.
+ * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param md_alg The message-digest algorithm used to hash the original data.
+ * Use #MBEDTLS_MD_NONE for signing raw data.
+ * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE.
+ * \param hash The buffer holding the message digest.
+ * \param sig The buffer holding the ciphertext.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * set to #MBEDTLS_RSA_PUBLIC.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PRIVATE and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 if the verify operation was successful,
+ * or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
+ *
+ * \note The \p sig buffer must be as large as the size
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
+ *
+ * \note For PKCS#1 v2.1 encoding, see comments on
+ * mbedtls_rsa_rsassa_pss_verify() about \p md_alg and
+ * \p hash_id.
*/
int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
const unsigned char *sig );
/**
- * \brief Perform a PKCS#1 v1.5 verification (RSASSA-PKCS1-v1_5-VERIFY)
- *
- * \param ctx points to an RSA public key
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer holding the ciphertext
- *
- * \return 0 if the verify operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
+ * \brief This function performs a PKCS#1 v1.5 verification
+ * operation (RSASSA-PKCS1-v1_5-VERIFY).
+ *
+ * \param ctx The RSA public key context.
+ * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param md_alg The message-digest algorithm used to hash the original data.
+ * Use #MBEDTLS_MD_NONE for signing raw data.
+ * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE.
+ * \param hash The buffer holding the message digest.
+ * \param sig The buffer holding the ciphertext.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * set to #MBEDTLS_RSA_PUBLIC.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PRIVATE and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 if the verify operation was successful,
+ * or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
+ *
+ * \note The \p sig buffer must be as large as the size
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
*/
int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
const unsigned char *sig );
/**
- * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY)
- * (This is the "simple" version.)
- *
- * \param ctx points to an RSA public key
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param sig buffer holding the ciphertext
- *
- * \return 0 if the verify operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- *
- * \note The hash_id in the RSA context is the one used for the
- * verification. md_alg in the function call is the type of
- * hash that is verified. According to RFC 3447 it is advised to
- * keep both hashes the same. If hash_id in the RSA context is
- * unset, the md_alg from the function call is used.
+ * \brief This function performs a PKCS#1 v2.1 PSS verification
+ * operation (RSASSA-PSS-VERIFY).
+ *
+ * The hash function for the MGF mask generating function
+ * is that specified in the RSA context.
+ *
+ * \param ctx The RSA public key context.
+ * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param md_alg The message-digest algorithm used to hash the original data.
+ * Use #MBEDTLS_MD_NONE for signing raw data.
+ * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE.
+ * \param hash The buffer holding the message digest.
+ * \param sig The buffer holding the ciphertext.
+ *
+ * \deprecated It is deprecated and discouraged to call this function
+ * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library
+ * are likely to remove the \p mode argument and have it
+ * implicitly set to #MBEDTLS_RSA_PUBLIC.
+ *
+ * \note Alternative implementations of RSA need not support
+ * mode being set to #MBEDTLS_RSA_PRIVATE and might instead
+ * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION.
+ *
+ * \return \c 0 if the verify operation was successful,
+ * or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
+ *
+ * \note The \p sig buffer must be as large as the size
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
+ *
+ * \note The \p hash_id in the RSA context is the one used for the
+ * verification. \p md_alg in the function call is the type of
+ * hash that is verified. According to <em>RFC-3447: Public-Key
+ * Cryptography Standards (PKCS) #1 v2.1: RSA Cryptography
+ * Specifications</em> it is advised to keep both hashes the
+ * same. If \p hash_id in the RSA context is unset,
+ * the \p md_alg from the function call is used.
*/
int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
const unsigned char *sig );
/**
- * \brief Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY)
- * (This is the version with "full" options.)
- *
- * \param ctx points to an RSA public key
- * \param f_rng RNG function (Only needed for MBEDTLS_RSA_PRIVATE)
- * \param p_rng RNG parameter
- * \param mode MBEDTLS_RSA_PUBLIC or MBEDTLS_RSA_PRIVATE
- * \param md_alg a MBEDTLS_MD_XXX (use MBEDTLS_MD_NONE for signing raw data)
- * \param hashlen message digest length (for MBEDTLS_MD_NONE only)
- * \param hash buffer holding the message digest
- * \param mgf1_hash_id message digest used for mask generation
- * \param expected_salt_len Length of the salt used in padding, use
- * MBEDTLS_RSA_SALT_LEN_ANY to accept any salt length
- * \param sig buffer holding the ciphertext
- *
- * \return 0 if the verify operation was successful,
- * or an MBEDTLS_ERR_RSA_XXX error code
- *
- * \note The "sig" buffer must be as large as the size
- * of ctx->N (eg. 128 bytes if RSA-1024 is used).
- *
- * \note The hash_id in the RSA context is ignored.
+ * \brief This function performs a PKCS#1 v2.1 PSS verification
+ * operation (RSASSA-PSS-VERIFY).
+ *
+ * The hash function for the MGF mask generating function
+ * is that specified in \p mgf1_hash_id.
+ *
+ * \param ctx The RSA public key context.
+ * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE.
+ * \param p_rng The RNG parameter.
+ * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE.
+ * \param md_alg The message-digest algorithm used to hash the original data.
+ * Use #MBEDTLS_MD_NONE for signing raw data.
+ * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE.
+ * \param hash The buffer holding the message digest.
+ * \param mgf1_hash_id The message digest used for mask generation.
+ * \param expected_salt_len The length of the salt used in padding. Use
+ * #MBEDTLS_RSA_SALT_LEN_ANY to accept any salt length.
+ * \param sig The buffer holding the ciphertext.
+ *
+ * \return \c 0 if the verify operation was successful,
+ * or an \c MBEDTLS_ERR_RSA_XXX error code
+ * on failure.
+ *
+ * \note The \p sig buffer must be as large as the size
+ * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used.
+ *
+ * \note The \p hash_id in the RSA context is ignored.
*/
int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx,
int (*f_rng)(void *, unsigned char *, size_t),
const unsigned char *sig );
/**
- * \brief Copy the components of an RSA context
+ * \brief This function copies the components of an RSA context.
*
- * \param dst Destination context
- * \param src Source context
+ * \param dst The destination context.
+ * \param src The source context.
*
- * \return 0 on success,
- * MBEDTLS_ERR_MPI_ALLOC_FAILED on memory allocation failure
+ * \return \c 0 on success,
+ * #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory allocation failure.
*/
int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src );
/**
- * \brief Free the components of an RSA key
+ * \brief This function frees the components of an RSA key.
*
- * \param ctx RSA Context to free
+ * \param ctx The RSA Context to free.
*/
void mbedtls_rsa_free( mbedtls_rsa_context *ctx );
+#ifdef __cplusplus
+}
+#endif
+
+#else /* MBEDTLS_RSA_ALT */
+#include "rsa_alt.h"
+#endif /* MBEDTLS_RSA_ALT */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
- * \brief Checkup routine
+ * \brief The RSA checkup routine.
*
- * \return 0 if successful, or 1 if the test failed
+ * \return \c 0 on success, or \c 1 on failure.
*/
int mbedtls_rsa_self_test( int verbose );
}
#endif
-#endif /* MBEDTLS_RSA_C */
-
#endif /* rsa.h */
--- /dev/null
+/**
+ * \file rsa_internal.h
+ *
+ * \brief Context-independent RSA helper functions
+ */
+/*
+ * Copyright (C) 2006-2017, ARM Limited, All Rights Reserved
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This file is part of mbed TLS (https://tls.mbed.org)
+ *
+ *
+ * This file declares some RSA-related helper functions useful when
+ * implementing the RSA interface. They are public and provided in a
+ * separate compilation unit in order to make it easy for designers of
+ * alternative RSA implementations to use them in their code, as it is
+ * conceived that the functionality they provide will be necessary
+ * for most complete implementations.
+ *
+ * End-users of Mbed TLS not intending to re-implement the RSA functionality
+ * are not expected to get into the need of making use of these functions directly,
+ * but instead should be able to use the functions declared in rsa.h.
+ *
+ * There are two classes of helper functions:
+ * (1) Parameter-generating helpers. These are:
+ * - mbedtls_rsa_deduce_primes
+ * - mbedtls_rsa_deduce_private_exponent
+ * - mbedtls_rsa_deduce_crt
+ * Each of these functions takes a set of core RSA parameters
+ * and generates some other, or CRT related parameters.
+ * (2) Parameter-checking helpers. These are:
+ * - mbedtls_rsa_validate_params
+ * - mbedtls_rsa_validate_crt
+ * They take a set of core or CRT related RSA parameters
+ * and check their validity.
+ *
+ */
+
+#ifndef MBEDTLS_RSA_INTERNAL_H
+#define MBEDTLS_RSA_INTERNAL_H
+
+#if !defined(MBEDTLS_CONFIG_FILE)
+#include "config.h"
+#else
+#include MBEDTLS_CONFIG_FILE
+#endif
+
+#include "bignum.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * \brief Compute RSA prime moduli P, Q from public modulus N=PQ
+ * and a pair of private and public key.
+ *
+ * \note This is a 'static' helper function not operating on
+ * an RSA context. Alternative implementations need not
+ * overwrite it.
+ *
+ * \param N RSA modulus N = PQ, with P, Q to be found
+ * \param E RSA public exponent
+ * \param D RSA private exponent
+ * \param P Pointer to MPI holding first prime factor of N on success
+ * \param Q Pointer to MPI holding second prime factor of N on success
+ *
+ * \return
+ * - 0 if successful. In this case, P and Q constitute a
+ * factorization of N.
+ * - A non-zero error code otherwise.
+ *
+ * \note It is neither checked that P, Q are prime nor that
+ * D, E are modular inverses wrt. P-1 and Q-1. For that,
+ * use the helper function \c mbedtls_rsa_validate_params.
+ *
+ */
+int mbedtls_rsa_deduce_primes( mbedtls_mpi const *N, mbedtls_mpi const *E,
+ mbedtls_mpi const *D,
+ mbedtls_mpi *P, mbedtls_mpi *Q );
+
+/**
+ * \brief Compute RSA private exponent from
+ * prime moduli and public key.
+ *
+ * \note This is a 'static' helper function not operating on
+ * an RSA context. Alternative implementations need not
+ * overwrite it.
+ *
+ * \param P First prime factor of RSA modulus
+ * \param Q Second prime factor of RSA modulus
+ * \param E RSA public exponent
+ * \param D Pointer to MPI holding the private exponent on success.
+ *
+ * \return
+ * - 0 if successful. In this case, D is set to a simultaneous
+ * modular inverse of E modulo both P-1 and Q-1.
+ * - A non-zero error code otherwise.
+ *
+ * \note This function does not check whether P and Q are primes.
+ *
+ */
+int mbedtls_rsa_deduce_private_exponent( mbedtls_mpi const *P,
+ mbedtls_mpi const *Q,
+ mbedtls_mpi const *E,
+ mbedtls_mpi *D );
+
+
+/**
+ * \brief Generate RSA-CRT parameters
+ *
+ * \note This is a 'static' helper function not operating on
+ * an RSA context. Alternative implementations need not
+ * overwrite it.
+ *
+ * \param P First prime factor of N
+ * \param Q Second prime factor of N
+ * \param D RSA private exponent
+ * \param DP Output variable for D modulo P-1
+ * \param DQ Output variable for D modulo Q-1
+ * \param QP Output variable for the modular inverse of Q modulo P.
+ *
+ * \return 0 on success, non-zero error code otherwise.
+ *
+ * \note This function does not check whether P, Q are
+ * prime and whether D is a valid private exponent.
+ *
+ */
+int mbedtls_rsa_deduce_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q,
+ const mbedtls_mpi *D, mbedtls_mpi *DP,
+ mbedtls_mpi *DQ, mbedtls_mpi *QP );
+
+
+/**
+ * \brief Check validity of core RSA parameters
+ *
+ * \note This is a 'static' helper function not operating on
+ * an RSA context. Alternative implementations need not
+ * overwrite it.
+ *
+ * \param N RSA modulus N = PQ
+ * \param P First prime factor of N
+ * \param Q Second prime factor of N
+ * \param D RSA private exponent
+ * \param E RSA public exponent
+ * \param f_rng PRNG to be used for primality check, or NULL
+ * \param p_rng PRNG context for f_rng, or NULL
+ *
+ * \return
+ * - 0 if the following conditions are satisfied
+ * if all relevant parameters are provided:
+ * - P prime if f_rng != NULL (%)
+ * - Q prime if f_rng != NULL (%)
+ * - 1 < N = P * Q
+ * - 1 < D, E < N
+ * - D and E are modular inverses modulo P-1 and Q-1
+ * (%) This is only done if MBEDTLS_GENPRIME is defined.
+ * - A non-zero error code otherwise.
+ *
+ * \note The function can be used with a restricted set of arguments
+ * to perform specific checks only. E.g., calling it with
+ * (-,P,-,-,-) and a PRNG amounts to a primality check for P.
+ */
+int mbedtls_rsa_validate_params( const mbedtls_mpi *N, const mbedtls_mpi *P,
+ const mbedtls_mpi *Q, const mbedtls_mpi *D,
+ const mbedtls_mpi *E,
+ int (*f_rng)(void *, unsigned char *, size_t),
+ void *p_rng );
+
+/**
+ * \brief Check validity of RSA CRT parameters
+ *
+ * \note This is a 'static' helper function not operating on
+ * an RSA context. Alternative implementations need not
+ * overwrite it.
+ *
+ * \param P First prime factor of RSA modulus
+ * \param Q Second prime factor of RSA modulus
+ * \param D RSA private exponent
+ * \param DP MPI to check for D modulo P-1
+ * \param DQ MPI to check for D modulo P-1
+ * \param QP MPI to check for the modular inverse of Q modulo P.
+ *
+ * \return
+ * - 0 if the following conditions are satisfied:
+ * - D = DP mod P-1 if P, D, DP != NULL
+ * - Q = DQ mod P-1 if P, D, DQ != NULL
+ * - QP = Q^-1 mod P if P, Q, QP != NULL
+ * - \c MBEDTLS_ERR_RSA_KEY_CHECK_FAILED if check failed,
+ * potentially including \c MBEDTLS_ERR_MPI_XXX if some
+ * MPI calculations failed.
+ * - \c MBEDTLS_ERR_RSA_BAD_INPUT_DATA if insufficient
+ * data was provided to check DP, DQ or QP.
+ *
+ * \note The function can be used with a restricted set of arguments
+ * to perform specific checks only. E.g., calling it with the
+ * parameters (P, -, D, DP, -, -) will check DP = D mod P-1.
+ */
+int mbedtls_rsa_validate_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q,
+ const mbedtls_mpi *D, const mbedtls_mpi *DP,
+ const mbedtls_mpi *DQ, const mbedtls_mpi *QP );
+
+#endif /* rsa_internal.h */
/**
* \file sha1.h
*
- * \brief SHA-1 cryptographic hash function
+ * \brief The SHA-1 cryptographic hash function.
*
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ * \warning SHA-1 is considered a weak message digest and its use constitutes
+ * a security risk. We recommend considering stronger message
+ * digests instead.
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_SHA1_H
#define MBEDTLS_SHA1_H
#include <stddef.h>
#include <stdint.h>
+#define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED -0x0035 /**< SHA-1 hardware accelerator failed */
+
#if !defined(MBEDTLS_SHA1_ALT)
// Regular implementation
//
#endif
/**
- * \brief SHA-1 context structure
+ * \brief The SHA-1 context structure.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
typedef struct
{
- uint32_t total[2]; /*!< number of bytes processed */
- uint32_t state[5]; /*!< intermediate digest state */
- unsigned char buffer[64]; /*!< data block being processed */
+ uint32_t total[2]; /*!< The number of Bytes processed. */
+ uint32_t state[5]; /*!< The intermediate digest state. */
+ unsigned char buffer[64]; /*!< The data block being processed. */
}
mbedtls_sha1_context;
/**
- * \brief Initialize SHA-1 context
+ * \brief This function initializes a SHA-1 context.
+ *
+ * \param ctx The SHA-1 context to initialize.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
*
- * \param ctx SHA-1 context to be initialized
*/
void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
/**
- * \brief Clear SHA-1 context
+ * \brief This function clears a SHA-1 context.
+ *
+ * \param ctx The SHA-1 context to clear.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
*
- * \param ctx SHA-1 context to be cleared
*/
void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
/**
- * \brief Clone (the state of) a SHA-1 context
+ * \brief This function clones the state of a SHA-1 context.
+ *
+ * \param dst The destination context.
+ * \param src The context to clone.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
*
- * \param dst The destination context
- * \param src The context to be cloned
*/
void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
const mbedtls_sha1_context *src );
/**
+ * \brief This function starts a SHA-1 checksum calculation.
+ *
+ * \param ctx The context to initialize.
+ *
+ * \return \c 0 if successful
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx );
+
+/**
+ * \brief This function feeds an input buffer into an ongoing SHA-1
+ * checksum calculation.
+ *
+ * \param ctx The SHA-1 context.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ *
+ * \return \c 0 if successful
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
+
+/**
+ * \brief This function finishes the SHA-1 operation, and writes
+ * the result to the output buffer.
+ *
+ * \param ctx The SHA-1 context.
+ * \param output The SHA-1 checksum result.
+ *
+ * \return \c 0 if successful
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
+ unsigned char output[20] );
+
+/**
+ * \brief SHA-1 process data block (internal use only)
+ *
+ * \param ctx SHA-1 context
+ * \param data The data block being processed.
+ *
+ * \return \c 0 if successful
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
+ const unsigned char data[64] );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
* \brief SHA-1 context setup
*
- * \param ctx context to be initialized
+ * \deprecated Superseded by mbedtls_sha1_starts_ret() in 2.7.0
+ *
+ * \param ctx The SHA-1 context to be initialized.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
+MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
/**
* \brief SHA-1 process buffer
*
- * \param ctx SHA-1 context
- * \param input buffer holding the data
- * \param ilen length of the input data
+ * \deprecated Superseded by mbedtls_sha1_update_ret() in 2.7.0
+ *
+ * \param ctx The SHA-1 context.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
+MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
/**
* \brief SHA-1 final digest
*
- * \param ctx SHA-1 context
- * \param output SHA-1 checksum result
+ * \deprecated Superseded by mbedtls_sha1_finish_ret() in 2.7.0
+ *
+ * \param ctx The SHA-1 context.
+ * \param output The SHA-1 checksum result.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx,
+ unsigned char output[20] );
+
+/**
+ * \brief SHA-1 process data block (internal use only)
+ *
+ * \deprecated Superseded by mbedtls_internal_sha1_process() in 2.7.0
+ *
+ * \param ctx The SHA-1 context.
+ * \param data The data block being processed.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] );
+MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx,
+ const unsigned char data[64] );
-/* Internal use */
-void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] );
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
#endif
/**
+ * \brief This function calculates the SHA-1 checksum of a buffer.
+ *
+ * The function allocates the context, performs the
+ * calculation, and frees the context.
+ *
+ * The SHA-1 result is calculated as
+ * output = SHA-1(input buffer).
+ *
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ * \param output The SHA-1 checksum result.
+ *
+ * \return \c 0 if successful
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
+ */
+int mbedtls_sha1_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[20] );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
* \brief Output = SHA-1( input buffer )
*
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output SHA-1 checksum result
+ * \deprecated Superseded by mbedtls_sha1_ret() in 2.7.0
+ *
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ * \param output The SHA-1 checksum result.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
+ *
*/
-void mbedtls_sha1( const unsigned char *input, size_t ilen, unsigned char output[20] );
+MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[20] );
+
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
/**
- * \brief Checkup routine
+ * \brief The SHA-1 checkup routine.
+ *
+ * \return \c 0 on success, or \c 1 on failure.
+ *
+ * \warning SHA-1 is considered a weak message digest and its use
+ * constitutes a security risk. We recommend considering
+ * stronger message digests instead.
*
- * \return 0 if successful, or 1 if the test failed
*/
int mbedtls_sha1_self_test( int verbose );
/**
* \file sha256.h
*
- * \brief SHA-224 and SHA-256 cryptographic hash function
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ * \brief The SHA-224 and SHA-256 cryptographic hash function.
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_SHA256_H
#define MBEDTLS_SHA256_H
#include <stddef.h>
#include <stdint.h>
+#define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037 /**< SHA-256 hardware accelerator failed */
+
#if !defined(MBEDTLS_SHA256_ALT)
// Regular implementation
//
#endif
/**
- * \brief SHA-256 context structure
+ * \brief The SHA-256 context structure.
+ *
+ * The structure is used both for SHA-256 and for SHA-224
+ * checksum calculations. The choice between these two is
+ * made in the call to mbedtls_sha256_starts_ret().
*/
typedef struct
{
- uint32_t total[2]; /*!< number of bytes processed */
- uint32_t state[8]; /*!< intermediate digest state */
- unsigned char buffer[64]; /*!< data block being processed */
- int is224; /*!< 0 => SHA-256, else SHA-224 */
+ uint32_t total[2]; /*!< The number of Bytes processed. */
+ uint32_t state[8]; /*!< The intermediate digest state. */
+ unsigned char buffer[64]; /*!< The data block being processed. */
+ int is224; /*!< Determines which function to use.
+ <ul><li>0: Use SHA-256.</li>
+ <li>1: Use SHA-224.</li></ul> */
}
mbedtls_sha256_context;
/**
- * \brief Initialize SHA-256 context
+ * \brief This function initializes a SHA-256 context.
*
- * \param ctx SHA-256 context to be initialized
+ * \param ctx The SHA-256 context to initialize.
*/
void mbedtls_sha256_init( mbedtls_sha256_context *ctx );
/**
- * \brief Clear SHA-256 context
+ * \brief This function clears a SHA-256 context.
*
- * \param ctx SHA-256 context to be cleared
+ * \param ctx The SHA-256 context to clear.
*/
void mbedtls_sha256_free( mbedtls_sha256_context *ctx );
/**
- * \brief Clone (the state of) a SHA-256 context
+ * \brief This function clones the state of a SHA-256 context.
*
- * \param dst The destination context
- * \param src The context to be cloned
+ * \param dst The destination context.
+ * \param src The context to clone.
*/
void mbedtls_sha256_clone( mbedtls_sha256_context *dst,
const mbedtls_sha256_context *src );
/**
- * \brief SHA-256 context setup
+ * \brief This function starts a SHA-224 or SHA-256 checksum
+ * calculation.
+ *
+ * \param ctx The context to initialize.
+ * \param is224 Determines which function to use.
+ * <ul><li>0: Use SHA-256.</li>
+ * <li>1: Use SHA-224.</li></ul>
*
- * \param ctx context to be initialized
- * \param is224 0 = use SHA256, 1 = use SHA224
+ * \return \c 0 on success.
*/
-void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 );
+int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 );
/**
- * \brief SHA-256 process buffer
+ * \brief This function feeds an input buffer into an ongoing
+ * SHA-256 checksum calculation.
*
* \param ctx SHA-256 context
- * \param input buffer holding the data
+ * \param input buffer holding the data
* \param ilen length of the input data
+ *
+ * \return \c 0 on success.
*/
-void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input,
- size_t ilen );
+int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
/**
- * \brief SHA-256 final digest
+ * \brief This function finishes the SHA-256 operation, and writes
+ * the result to the output buffer.
*
- * \param ctx SHA-256 context
- * \param output SHA-224/256 checksum result
+ * \param ctx The SHA-256 context.
+ * \param output The SHA-224 or SHA-256 checksum result.
+ *
+ * \return \c 0 on success.
+ */
+int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
+ unsigned char output[32] );
+
+/**
+ * \brief This function processes a single data block within
+ * the ongoing SHA-256 computation. This function is for
+ * internal use only.
+ *
+ * \param ctx The SHA-256 context.
+ * \param data The buffer holding one block of data.
+ *
+ * \return \c 0 on success.
+ */
+int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
+ const unsigned char data[64] );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
+ * \brief This function starts a SHA-256 checksum calculation.
+ *
+ * \deprecated Superseded by mbedtls_sha256_starts_ret() in 2.7.0.
+ *
+ * \param ctx The SHA-256 context to initialize.
+ * \param is224 Determines which function to use.
+ * <ul><li>0: Use SHA-256.</li>
+ * <li>1: Use SHA-224.</li></ul>
+ */
+MBEDTLS_DEPRECATED void mbedtls_sha256_starts( mbedtls_sha256_context *ctx,
+ int is224 );
+
+/**
+ * \brief This function feeds an input buffer into an ongoing
+ * SHA-256 checksum calculation.
+ *
+ * \deprecated Superseded by mbedtls_sha256_update_ret() in 2.7.0.
+ *
+ * \param ctx The SHA-256 context to initialize.
+ * \param input The buffer holding the data.
+ * \param ilen The length of the input data.
+ */
+MBEDTLS_DEPRECATED void mbedtls_sha256_update( mbedtls_sha256_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
+
+/**
+ * \brief This function finishes the SHA-256 operation, and writes
+ * the result to the output buffer.
+ *
+ * \deprecated Superseded by mbedtls_sha256_finish_ret() in 2.7.0.
+ *
+ * \param ctx The SHA-256 context.
+ * \param output The SHA-224or SHA-256 checksum result.
*/
-void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] );
+MBEDTLS_DEPRECATED void mbedtls_sha256_finish( mbedtls_sha256_context *ctx,
+ unsigned char output[32] );
-/* Internal use */
-void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] );
+/**
+ * \brief This function processes a single data block within
+ * the ongoing SHA-256 computation. This function is for
+ * internal use only.
+ *
+ * \deprecated Superseded by mbedtls_internal_sha256_process() in 2.7.0.
+ *
+ * \param ctx The SHA-256 context.
+ * \param data The buffer holding one block of data.
+ */
+MBEDTLS_DEPRECATED void mbedtls_sha256_process( mbedtls_sha256_context *ctx,
+ const unsigned char data[64] );
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
#endif
#endif
/**
- * \brief Output = SHA-256( input buffer )
+ * \brief This function calculates the SHA-224 or SHA-256
+ * checksum of a buffer.
*
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output SHA-224/256 checksum result
- * \param is224 0 = use SHA256, 1 = use SHA224
+ * The function allocates the context, performs the
+ * calculation, and frees the context.
+ *
+ * The SHA-256 result is calculated as
+ * output = SHA-256(input buffer).
+ *
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ * \param output The SHA-224 or SHA-256 checksum result.
+ * \param is224 Determines which function to use.
+ * <ul><li>0: Use SHA-256.</li>
+ * <li>1: Use SHA-224.</li></ul>
+ */
+int mbedtls_sha256_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[32],
+ int is224 );
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+
+/**
+ * \brief This function calculates the SHA-224 or SHA-256 checksum
+ * of a buffer.
+ *
+ * The function allocates the context, performs the
+ * calculation, and frees the context.
+ *
+ * The SHA-256 result is calculated as
+ * output = SHA-256(input buffer).
+ *
+ * \deprecated Superseded by mbedtls_sha256_ret() in 2.7.0.
+ *
+ * \param input The buffer holding the data.
+ * \param ilen The length of the input data.
+ * \param output The SHA-224 or SHA-256 checksum result.
+ * \param is224 Determines which function to use.
+ * <ul><li>0: Use SHA-256.</li>
+ * <li>1: Use SHA-224.</li></ul>
*/
-void mbedtls_sha256( const unsigned char *input, size_t ilen,
- unsigned char output[32], int is224 );
+MBEDTLS_DEPRECATED void mbedtls_sha256( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[32],
+ int is224 );
+
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
/**
- * \brief Checkup routine
+ * \brief The SHA-224 and SHA-256 checkup routine.
*
- * \return 0 if successful, or 1 if the test failed
+ * \return \c 0 on success, or \c 1 on failure.
*/
int mbedtls_sha256_self_test( int verbose );
/**
* \file sha512.h
*
- * \brief SHA-384 and SHA-512 cryptographic hash function
- *
- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
+ * \brief The SHA-384 and SHA-512 cryptographic hash function.
+ */
+/*
+ * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * This file is part of mbed TLS (https://tls.mbed.org)
+ * This file is part of Mbed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_SHA512_H
#define MBEDTLS_SHA512_H
#include <stddef.h>
#include <stdint.h>
+#define MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED -0x0039 /**< SHA-512 hardware accelerator failed */
+
#if !defined(MBEDTLS_SHA512_ALT)
// Regular implementation
//
#endif
/**
- * \brief SHA-512 context structure
+ * \brief The SHA-512 context structure.
+ *
+ * The structure is used both for SHA-384 and for SHA-512
+ * checksum calculations. The choice between these two is
+ * made in the call to mbedtls_sha512_starts_ret().
*/
typedef struct
{
- uint64_t total[2]; /*!< number of bytes processed */
- uint64_t state[8]; /*!< intermediate digest state */
- unsigned char buffer[128]; /*!< data block being processed */
- int is384; /*!< 0 => SHA-512, else SHA-384 */
+ uint64_t total[2]; /*!< The number of Bytes processed. */
+ uint64_t state[8]; /*!< The intermediate digest state. */
+ unsigned char buffer[128]; /*!< The data block being processed. */
+ int is384; /*!< Determines which function to use.
+ * <ul><li>0: Use SHA-512.</li>
+ * <li>1: Use SHA-384.</li></ul> */
}
mbedtls_sha512_context;
/**
- * \brief Initialize SHA-512 context
+ * \brief This function initializes a SHA-512 context.
*
- * \param ctx SHA-512 context to be initialized
+ * \param ctx The SHA-512 context to initialize.
*/
void mbedtls_sha512_init( mbedtls_sha512_context *ctx );
/**
- * \brief Clear SHA-512 context
+ * \brief This function clears a SHA-512 context.
*
- * \param ctx SHA-512 context to be cleared
+ * \param ctx The SHA-512 context to clear.
*/
void mbedtls_sha512_free( mbedtls_sha512_context *ctx );
/**
- * \brief Clone (the state of) a SHA-512 context
+ * \brief This function clones the state of a SHA-512 context.
*
- * \param dst The destination context
- * \param src The context to be cloned
+ * \param dst The destination context.
+ * \param src The context to clone.
*/
void mbedtls_sha512_clone( mbedtls_sha512_context *dst,
const mbedtls_sha512_context *src );
/**
- * \brief SHA-512 context setup
+ * \brief This function starts a SHA-384 or SHA-512 checksum
+ * calculation.
+ *
+ * \param ctx The SHA-512 context to initialize.
+ * \param is384 Determines which function to use.
+ * <ul><li>0: Use SHA-512.</li>
+ * <li>1: Use SHA-384.</li></ul>
*
- * \param ctx context to be initialized
- * \param is384 0 = use SHA512, 1 = use SHA384
+ * \return \c 0 on success.
*/
-void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 );
+int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 );
/**
- * \brief SHA-512 process buffer
+ * \brief This function feeds an input buffer into an ongoing
+ * SHA-512 checksum calculation.
+ *
+ * \param ctx The SHA-512 context.
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
*
- * \param ctx SHA-512 context
- * \param input buffer holding the data
- * \param ilen length of the input data
+ * \return \c 0 on success.
*/
-void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input,
+int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx,
+ const unsigned char *input,
size_t ilen );
/**
- * \brief SHA-512 final digest
+ * \brief This function finishes the SHA-512 operation, and writes
+ * the result to the output buffer. This function is for
+ * internal use only.
+ *
+ * \param ctx The SHA-512 context.
+ * \param output The SHA-384 or SHA-512 checksum result.
+ *
+ * \return \c 0 on success.
+ */
+int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx,
+ unsigned char output[64] );
+
+/**
+ * \brief This function processes a single data block within
+ * the ongoing SHA-512 computation.
+ *
+ * \param ctx The SHA-512 context.
+ * \param data The buffer holding one block of data.
+ *
+ * \return \c 0 on success.
+ */
+int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx,
+ const unsigned char data[128] );
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+/**
+ * \brief This function starts a SHA-384 or SHA-512 checksum
+ * calculation.
+ *
+ * \deprecated Superseded by mbedtls_sha512_starts_ret() in 2.7.0
+ *
+ * \param ctx The SHA-512 context to initialize.
+ * \param is384 Determines which function to use.
+ * <ul><li>0: Use SHA-512.</li>
+ * <li>1: Use SHA-384.</li></ul>
+ */
+MBEDTLS_DEPRECATED void mbedtls_sha512_starts( mbedtls_sha512_context *ctx,
+ int is384 );
+
+/**
+ * \brief This function feeds an input buffer into an ongoing
+ * SHA-512 checksum calculation.
+ *
+ * \deprecated Superseded by mbedtls_sha512_update_ret() in 2.7.0
+ *
+ * \param ctx The SHA-512 context.
+ * \param input The buffer holding the data.
+ * \param ilen The length of the input data.
+ */
+MBEDTLS_DEPRECATED void mbedtls_sha512_update( mbedtls_sha512_context *ctx,
+ const unsigned char *input,
+ size_t ilen );
+
+/**
+ * \brief This function finishes the SHA-512 operation, and writes
+ * the result to the output buffer.
+ *
+ * \deprecated Superseded by mbedtls_sha512_finish_ret() in 2.7.0
+ *
+ * \param ctx The SHA-512 context.
+ * \param output The SHA-384 or SHA-512 checksum result.
+ */
+MBEDTLS_DEPRECATED void mbedtls_sha512_finish( mbedtls_sha512_context *ctx,
+ unsigned char output[64] );
+
+/**
+ * \brief This function processes a single data block within
+ * the ongoing SHA-512 computation. This function is for
+ * internal use only.
*
- * \param ctx SHA-512 context
- * \param output SHA-384/512 checksum result
+ * \deprecated Superseded by mbedtls_internal_sha512_process() in 2.7.0
+ *
+ * \param ctx The SHA-512 context.
+ * \param data The buffer holding one block of data.
*/
-void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] );
+MBEDTLS_DEPRECATED void mbedtls_sha512_process(
+ mbedtls_sha512_context *ctx,
+ const unsigned char data[128] );
+
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
#endif
/**
- * \brief Output = SHA-512( input buffer )
+ * \brief This function calculates the SHA-512 or SHA-384
+ * checksum of a buffer.
+ *
+ * The function allocates the context, performs the
+ * calculation, and frees the context.
*
- * \param input buffer holding the data
- * \param ilen length of the input data
- * \param output SHA-384/512 checksum result
- * \param is384 0 = use SHA512, 1 = use SHA384
+ * The SHA-512 result is calculated as
+ * output = SHA-512(input buffer).
+ *
+ * \param input The buffer holding the input data.
+ * \param ilen The length of the input data.
+ * \param output The SHA-384 or SHA-512 checksum result.
+ * \param is384 Determines which function to use.
+ * <ul><li>0: Use SHA-512.</li>
+ * <li>1: Use SHA-384.</li></ul>
+ *
+ * \return \c 0 on success.
*/
-void mbedtls_sha512( const unsigned char *input, size_t ilen,
- unsigned char output[64], int is384 );
+int mbedtls_sha512_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[64],
+ int is384 );
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
/**
- * \brief Checkup routine
+ * \brief This function calculates the SHA-512 or SHA-384
+ * checksum of a buffer.
+ *
+ * The function allocates the context, performs the
+ * calculation, and frees the context.
+ *
+ * The SHA-512 result is calculated as
+ * output = SHA-512(input buffer).
*
- * \return 0 if successful, or 1 if the test failed
+ * \deprecated Superseded by mbedtls_sha512_ret() in 2.7.0
+ *
+ * \param input The buffer holding the data.
+ * \param ilen The length of the input data.
+ * \param output The SHA-384 or SHA-512 checksum result.
+ * \param is384 Determines which function to use.
+ * <ul><li>0: Use SHA-512.</li>
+ * <li>1: Use SHA-384.</li></ul>
*/
-int mbedtls_sha512_self_test( int verbose );
+MBEDTLS_DEPRECATED void mbedtls_sha512( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[64],
+ int is384 );
-/* Internal use */
-void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] );
+#undef MBEDTLS_DEPRECATED
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
+ /**
+ * \brief The SHA-384 or SHA-512 checkup routine.
+ *
+ * \return \c 0 on success, or \c 1 on failure.
+ */
+int mbedtls_sha512_self_test( int verbose );
#ifdef __cplusplus
}
* \file ssl.h
*
* \brief SSL/TLS functions.
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#endif
#if defined(MBEDTLS_ZLIB_SUPPORT)
+
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#warning "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and will be removed in the next major revision of the library"
+#endif
+
+#if defined(MBEDTLS_DEPRECATED_REMOVED)
+#error "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and cannot be used if MBEDTLS_DEPRECATED_REMOVED is set"
+#endif
+
#include "zlib.h"
#endif
#define MBEDTLS_SSL_PRESET_DEFAULT 0
#define MBEDTLS_SSL_PRESET_SUITEB 2
+#define MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED 1
+#define MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED 0
+
/*
* Default range for DTLS retransmission timer value, in milliseconds.
* RFC 6347 4.2.4.1 says from 1 second to 60 seconds.
/* Defined in ssl_internal.h */
typedef struct mbedtls_ssl_transform mbedtls_ssl_transform;
typedef struct mbedtls_ssl_handshake_params mbedtls_ssl_handshake_params;
+typedef struct mbedtls_ssl_sig_hash_set_t mbedtls_ssl_sig_hash_set_t;
#if defined(MBEDTLS_X509_CRT_PARSE_C)
typedef struct mbedtls_ssl_key_cert mbedtls_ssl_key_cert;
#endif
#if defined(MBEDTLS_SSL_FALLBACK_SCSV) && defined(MBEDTLS_SSL_CLI_C)
unsigned int fallback : 1; /*!< is this a fallback? */
#endif
+#if defined(MBEDTLS_SSL_SRV_C)
+ unsigned int cert_req_ca_list : 1; /*!< enable sending CA list in
+ Certificate Request messages? */
+#endif
};
size_t in_hslen; /*!< current handshake message length,
including the handshake header */
int nb_zero; /*!< # of 0-length encrypted messages */
- int record_read; /*!< record is already present */
+
+ int keep_current_message; /*!< drop or reuse current message
+ on next call to record layer? */
/*
* Record layer (outgoing data)
* \note No copy of the configuration context is made, it can be
* shared by many mbedtls_ssl_context structures.
*
- * \warning Modifying the conf structure after it has been used in this
- * function is unsupported!
+ * \warning The conf structure will be accessed during the session.
+ * It must not be modified or freed as long as the session
+ * is active.
+ *
+ * \warning This function must be called exactly once per context.
+ * Calling mbedtls_ssl_setup again is not supported, even
+ * if no session is active.
*
* \param ssl SSL context
* \param conf SSL configuration to use
*
* If set, the verify callback is called for each
* certificate in the chain. For implementation
- * information, please see \c x509parse_verify()
+ * information, please see \c mbedtls_x509_crt_verify()
*
* \param conf SSL configuration
* \param f_vrfy verification function
*
* \note See the documentation of \c mbedtls_ssl_set_timer_t and
* \c mbedtls_ssl_get_timer_t for the conventions this pair of
- * callbacks must fallow.
+ * callbacks must follow.
*
* \note On some platforms, timing.c provides
* \c mbedtls_timing_set_delay() and
#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+
+#if defined(MBEDTLS_DEPRECATED_WARNING)
+#define MBEDTLS_DEPRECATED __attribute__((deprecated))
+#else
+#define MBEDTLS_DEPRECATED
+#endif
+
/**
* \brief Set the Diffie-Hellman public P and G values,
* read as hexadecimal strings (server-side only)
- * (Default: MBEDTLS_DHM_RFC5114_MODP_2048_[PG])
+ * (Default values: MBEDTLS_DHM_RFC3526_MODP_2048_[PG])
*
* \param conf SSL configuration
* \param dhm_P Diffie-Hellman-Merkle modulus
* \param dhm_G Diffie-Hellman-Merkle generator
*
+ * \deprecated Superseded by \c mbedtls_ssl_conf_dh_param_bin.
+ *
* \return 0 if successful
*/
-int mbedtls_ssl_conf_dh_param( mbedtls_ssl_config *conf, const char *dhm_P, const char *dhm_G );
+MBEDTLS_DEPRECATED int mbedtls_ssl_conf_dh_param( mbedtls_ssl_config *conf,
+ const char *dhm_P,
+ const char *dhm_G );
+
+#endif /* MBEDTLS_DEPRECATED_REMOVED */
+
+/**
+ * \brief Set the Diffie-Hellman public P and G values
+ * from big-endian binary presentations.
+ * (Default values: MBEDTLS_DHM_RFC3526_MODP_2048_[PG]_BIN)
+ *
+ * \param conf SSL configuration
+ * \param dhm_P Diffie-Hellman-Merkle modulus in big-endian binary form
+ * \param P_len Length of DHM modulus
+ * \param dhm_G Diffie-Hellman-Merkle generator in big-endian binary form
+ * \param G_len Length of DHM generator
+ *
+ * \return 0 if successful
+ */
+int mbedtls_ssl_conf_dh_param_bin( mbedtls_ssl_config *conf,
+ const unsigned char *dhm_P, size_t P_len,
+ const unsigned char *dhm_G, size_t G_len );
/**
* \brief Set the Diffie-Hellman public P and G values,
#if defined(MBEDTLS_X509_CRT_PARSE_C)
/**
- * \brief Set the hostname to check against the received server
- * certificate. It sets the ServerName TLS extension too,
- * if the extension is enabled.
- * (client-side only)
+ * \brief Set or reset the hostname to check against the received
+ * server certificate. It sets the ServerName TLS extension,
+ * too, if that extension is enabled. (client-side only)
*
* \param ssl SSL context
- * \param hostname the server hostname
+ * \param hostname the server hostname, may be NULL to clear hostname
+
+ * \note Maximum hostname length MBEDTLS_SSL_MAX_HOST_NAME_LEN.
*
- * \return 0 if successful or MBEDTLS_ERR_SSL_ALLOC_FAILED
+ * \return 0 if successful, MBEDTLS_ERR_SSL_ALLOC_FAILED on
+ * allocation failure, MBEDTLS_ERR_SSL_BAD_INPUT_DATA on
+ * too long input hostname.
+ *
+ * Hostname set to the one provided on success (cleared
+ * when NULL). On allocation failure hostname is cleared.
+ * On too long input failure, old hostname is unchanged.
*/
int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname );
#endif /* MBEDTLS_X509_CRT_PARSE_C */
void mbedtls_ssl_conf_arc4_support( mbedtls_ssl_config *conf, char arc4 );
#endif /* MBEDTLS_ARC4_C */
+#if defined(MBEDTLS_SSL_SRV_C)
+/**
+ * \brief Whether to send a list of acceptable CAs in
+ * CertificateRequest messages.
+ * (Default: do send)
+ *
+ * \param conf SSL configuration
+ * \param cert_req_ca_list MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED or
+ * MBEDTLS_SSL_CERT_REQ_CA_LIST_DISABLED
+ */
+void mbedtls_ssl_conf_cert_req_ca_list( mbedtls_ssl_config *conf,
+ char cert_req_ca_list );
+#endif /* MBEDTLS_SSL_SRV_C */
+
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
/**
* \brief Set the maximum fragment length to emit and/or negotiate
/**
* \brief Set record counter threshold for periodic renegotiation.
- * (Default: 2^64 - 256.)
+ * (Default: 2^48 - 1)
*
* Renegotiation is automatically triggered when a record
* counter (outgoing or ingoing) crosses the defined
* Lower values can be used to enforce policies such as "keys
* must be refreshed every N packets with cipher X".
*
+ * The renegotiation period can be disabled by setting
+ * conf->disable_renegotiation to
+ * MBEDTLS_SSL_RENEGOTIATION_DISABLED.
+ *
+ * \note When the configured transport is
+ * MBEDTLS_SSL_TRANSPORT_DATAGRAM the maximum renegotiation
+ * period is 2^48 - 1, and for MBEDTLS_SSL_TRANSPORT_STREAM,
+ * the maximum renegotiation period is 2^64 - 1.
+ *
* \param conf SSL configuration
* \param period The threshold value: a big-endian 64-bit number.
- * Set to 2^64 - 1 to disable periodic renegotiation
*/
void mbedtls_ssl_conf_renegotiation_period( mbedtls_ssl_config *conf,
const unsigned char period[8] );
* \param len how many bytes must be written
*
* \return the number of bytes actually written (may be less than len),
- * or MBEDTLS_ERR_SSL_WANT_WRITE of MBEDTLS_ERR_SSL_WANT_READ,
+ * or MBEDTLS_ERR_SSL_WANT_WRITE or MBEDTLS_ERR_SSL_WANT_READ,
* or another negative error code.
*
* \note If this function returns something other than a positive
* \param transport MBEDTLS_SSL_TRANSPORT_STREAM for TLS, or
* MBEDTLS_SSL_TRANSPORT_DATAGRAM for DTLS
* \param preset a MBEDTLS_SSL_PRESET_XXX value
- * (currently unused).
*
* \note See \c mbedtls_ssl_conf_transport() for notes on DTLS.
*
* \file ssl_cache.h
*
* \brief SSL session cache implementation
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file ssl_ciphersuites.h
*
* \brief SSL Ciphersuites for mbed TLS
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#define MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED
#endif
+/* Key exchanges allowing client certificate requests */
+#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
+#define MBEDTLS_KEY_EXCHANGE__CERT_REQ_ALLOWED__ENABLED
+#endif
+
+/* Key exchanges involving server signature in ServerKeyExchange */
+#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
+#define MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED
+#endif
+
+/* Key exchanges using ECDH */
+#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
+#define MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED
+#endif
+
+/* Key exchanges that don't involve ephemeral keys */
+#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED)
+#define MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED
+#endif
+
+/* Key exchanges that involve ephemeral keys */
+#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
+#define MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED
+#endif
+
/* Key exchanges using a PSK */
#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \
defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) || \
#define MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED
#endif
-/* Key exchanges using a ECDHE */
+/* Key exchanges using DHE */
+#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
+ defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
+#define MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED
+#endif
+
+/* Key exchanges using ECDHE */
#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
#if defined(MBEDTLS_PK_C)
mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg( const mbedtls_ssl_ciphersuite_t *info );
+mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_alg( const mbedtls_ssl_ciphersuite_t *info );
#endif
int mbedtls_ssl_ciphersuite_uses_ec( const mbedtls_ssl_ciphersuite_t *info );
int mbedtls_ssl_ciphersuite_uses_psk( const mbedtls_ssl_ciphersuite_t *info );
+#if defined(MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED)
+static inline int mbedtls_ssl_ciphersuite_has_pfs( const mbedtls_ssl_ciphersuite_t *info )
+{
+ switch( info->key_exchange )
+ {
+ case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_DHE_PSK:
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK:
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
+ case MBEDTLS_KEY_EXCHANGE_ECJPAKE:
+ return( 1 );
+
+ default:
+ return( 0 );
+ }
+}
+#endif /* MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED */
+
+#if defined(MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED)
+static inline int mbedtls_ssl_ciphersuite_no_pfs( const mbedtls_ssl_ciphersuite_t *info )
+{
+ switch( info->key_exchange )
+ {
+ case MBEDTLS_KEY_EXCHANGE_ECDH_RSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA:
+ case MBEDTLS_KEY_EXCHANGE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_PSK:
+ case MBEDTLS_KEY_EXCHANGE_RSA_PSK:
+ return( 1 );
+
+ default:
+ return( 0 );
+ }
+}
+#endif /* MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED */
+
+#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED)
+static inline int mbedtls_ssl_ciphersuite_uses_ecdh( const mbedtls_ssl_ciphersuite_t *info )
+{
+ switch( info->key_exchange )
+ {
+ case MBEDTLS_KEY_EXCHANGE_ECDH_RSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA:
+ return( 1 );
+
+ default:
+ return( 0 );
+ }
+}
+#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED */
+
+static inline int mbedtls_ssl_ciphersuite_cert_req_allowed( const mbedtls_ssl_ciphersuite_t *info )
+{
+ switch( info->key_exchange )
+ {
+ case MBEDTLS_KEY_EXCHANGE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDH_RSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
+ return( 1 );
+
+ default:
+ return( 0 );
+ }
+}
+
+#if defined(MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED)
+static inline int mbedtls_ssl_ciphersuite_uses_dhe( const mbedtls_ssl_ciphersuite_t *info )
+{
+ switch( info->key_exchange )
+ {
+ case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_DHE_PSK:
+ return( 1 );
+
+ default:
+ return( 0 );
+ }
+}
+#endif /* MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED) */
+
+#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED)
+static inline int mbedtls_ssl_ciphersuite_uses_ecdhe( const mbedtls_ssl_ciphersuite_t *info )
+{
+ switch( info->key_exchange )
+ {
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK:
+ return( 1 );
+
+ default:
+ return( 0 );
+ }
+}
+#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED) */
+
+#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED)
+static inline int mbedtls_ssl_ciphersuite_uses_server_signature( const mbedtls_ssl_ciphersuite_t *info )
+{
+ switch( info->key_exchange )
+ {
+ case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
+ return( 1 );
+
+ default:
+ return( 0 );
+ }
+}
+#endif /* MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED */
+
#ifdef __cplusplus
}
#endif
* \file ssl_cookie.h
*
* \brief DTLS cookie callbacks implementation
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
/**
- * \file ssl_ticket.h
+ * \file ssl_internal.h
*
* \brief Internal functions shared by the SSL modules
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#define MBEDTLS_SSL_INTERNAL_H
#include "ssl.h"
+#include "cipher.h"
#if defined(MBEDTLS_MD5_C)
#include "md5.h"
#endif /* MBEDTLS_SSL_PROTO_TLS1 */
#endif /* MBEDTLS_SSL_PROTO_SSL3 */
+#define MBEDTLS_SSL_MIN_VALID_MINOR_VERSION MBEDTLS_SSL_MINOR_VERSION_1
+#define MBEDTLS_SSL_MIN_VALID_MAJOR_VERSION MBEDTLS_SSL_MAJOR_VERSION_3
+
/* Determine maximum supported version */
#define MBEDTLS_SSL_MAX_MAJOR_VERSION MBEDTLS_SSL_MAJOR_VERSION_3
#define MBEDTLS_SSL_PADDING_ADD 0
#endif
-#define MBEDTLS_SSL_BUFFER_LEN ( MBEDTLS_SSL_MAX_CONTENT_LEN \
- + MBEDTLS_SSL_COMPRESSION_ADD \
- + 29 /* counter + header + IV */ \
- + MBEDTLS_SSL_MAC_ADD \
- + MBEDTLS_SSL_PADDING_ADD \
+#define MBEDTLS_SSL_PAYLOAD_LEN ( MBEDTLS_SSL_MAX_CONTENT_LEN \
+ + MBEDTLS_SSL_COMPRESSION_ADD \
+ + MBEDTLS_MAX_IV_LENGTH \
+ + MBEDTLS_SSL_MAC_ADD \
+ + MBEDTLS_SSL_PADDING_ADD \
)
/*
+ * Check that we obey the standard's message size bounds
+ */
+
+#if MBEDTLS_SSL_MAX_CONTENT_LEN > 16384
+#error Bad configuration - record content too large.
+#endif
+
+#if MBEDTLS_SSL_PAYLOAD_LEN > 16384 + 2048
+#error Bad configuration - protected record payload too large.
+#endif
+
+/* Note: Even though the TLS record header is only 5 bytes
+ long, we're internally using 8 bytes to store the
+ implicit sequence number. */
+#define MBEDTLS_SSL_HEADER_LEN 13
+
+#define MBEDTLS_SSL_BUFFER_LEN \
+ ( ( MBEDTLS_SSL_HEADER_LEN ) + ( MBEDTLS_SSL_PAYLOAD_LEN ) )
+
+/*
* TLS extension flags (for extensions with outgoing ServerHello content
* that need it (e.g. for RENEGOTIATION_INFO the server already knows because
* of state of the renegotiation flag, so no indicator is required)
extern "C" {
#endif
+#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
+ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
+/*
+ * Abstraction for a grid of allowed signature-hash-algorithm pairs.
+ */
+struct mbedtls_ssl_sig_hash_set_t
+{
+ /* At the moment, we only need to remember a single suitable
+ * hash algorithm per signature algorithm. As long as that's
+ * the case - and we don't need a general lookup function -
+ * we can implement the sig-hash-set as a map from signatures
+ * to hash algorithms. */
+ mbedtls_md_type_t rsa;
+ mbedtls_md_type_t ecdsa;
+};
+#endif /* MBEDTLS_SSL_PROTO_TLS1_2 &&
+ MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
+
/*
* This structure contains the parameters only needed during handshake.
*/
/*
* Handshake specific crypto variables
*/
- int sig_alg; /*!< Hash algorithm for signature */
- int verify_sig_alg; /*!< Signature algorithm for verify */
+
+#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
+ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
+ mbedtls_ssl_sig_hash_set_t hash_algs; /*!< Set of suitable sig-hash pairs */
+#endif
#if defined(MBEDTLS_DHM_C)
mbedtls_dhm_context dhm_ctx; /*!< DHM key exchange */
#endif
unsigned char *ecjpake_cache; /*!< Cache for ClientHello ext */
size_t ecjpake_cache_len; /*!< Length of cached data */
#endif
-#endif
+#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C) || \
defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
const mbedtls_ecp_curve_info **curves; /*!< Supported elliptic curves */
mbedtls_ssl_key_cert *sni_key_cert; /*!< key/cert list from SNI */
mbedtls_x509_crt *sni_ca_chain; /*!< trusted CAs from SNI callback */
mbedtls_x509_crl *sni_ca_crl; /*!< trusted CAs CRLs from SNI */
-#endif
+#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */
#endif /* MBEDTLS_X509_CRT_PARSE_C */
#if defined(MBEDTLS_SSL_PROTO_DTLS)
unsigned int out_msg_seq; /*!< Outgoing handshake sequence number */
resending messages */
unsigned char alt_out_ctr[8]; /*!< Alternative record epoch/counter
for resending messages */
-#endif
+#endif /* MBEDTLS_SSL_PROTO_DTLS */
/*
* Checksum contexts
};
#endif /* MBEDTLS_SSL_PROTO_DTLS */
+#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
+ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
+
+/* Find an entry in a signature-hash set matching a given hash algorithm. */
+mbedtls_md_type_t mbedtls_ssl_sig_hash_set_find( mbedtls_ssl_sig_hash_set_t *set,
+ mbedtls_pk_type_t sig_alg );
+/* Add a signature-hash-pair to a signature-hash set */
+void mbedtls_ssl_sig_hash_set_add( mbedtls_ssl_sig_hash_set_t *set,
+ mbedtls_pk_type_t sig_alg,
+ mbedtls_md_type_t md_alg );
+/* Allow exactly one hash algorithm for each signature. */
+void mbedtls_ssl_sig_hash_set_const_hash( mbedtls_ssl_sig_hash_set_t *set,
+ mbedtls_md_type_t md_alg );
+
+/* Setup an empty signature-hash set */
+static inline void mbedtls_ssl_sig_hash_set_init( mbedtls_ssl_sig_hash_set_t *set )
+{
+ mbedtls_ssl_sig_hash_set_const_hash( set, MBEDTLS_MD_NONE );
+}
+
+#endif /* MBEDTLS_SSL_PROTO_TLS1_2) &&
+ MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
/**
* \brief Free referenced items in an SSL transform context and clear
int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl );
void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl );
+/**
+ * \brief Update record layer
+ *
+ * This function roughly separates the implementation
+ * of the logic of (D)TLS from the implementation
+ * of the secure transport.
+ *
+ * \param ssl SSL context to use
+ *
+ * \return 0 or non-zero error code.
+ *
+ * \note A clarification on what is called 'record layer' here
+ * is in order, as many sensible definitions are possible:
+ *
+ * The record layer takes as input an untrusted underlying
+ * transport (stream or datagram) and transforms it into
+ * a serially multiplexed, secure transport, which
+ * conceptually provides the following:
+ *
+ * (1) Three datagram based, content-agnostic transports
+ * for handshake, alert and CCS messages.
+ * (2) One stream- or datagram-based transport
+ * for application data.
+ * (3) Functionality for changing the underlying transform
+ * securing the contents.
+ *
+ * The interface to this functionality is given as follows:
+ *
+ * a Updating
+ * [Currently implemented by mbedtls_ssl_read_record]
+ *
+ * Check if and on which of the four 'ports' data is pending:
+ * Nothing, a controlling datagram of type (1), or application
+ * data (2). In any case data is present, internal buffers
+ * provide access to the data for the user to process it.
+ * Consumption of type (1) datagrams is done automatically
+ * on the next update, invalidating that the internal buffers
+ * for previous datagrams, while consumption of application
+ * data (2) is user-controlled.
+ *
+ * b Reading of application data
+ * [Currently manual adaption of ssl->in_offt pointer]
+ *
+ * As mentioned in the last paragraph, consumption of data
+ * is different from the automatic consumption of control
+ * datagrams (1) because application data is treated as a stream.
+ *
+ * c Tracking availability of application data
+ * [Currently manually through decreasing ssl->in_msglen]
+ *
+ * For efficiency and to retain datagram semantics for
+ * application data in case of DTLS, the record layer
+ * provides functionality for checking how much application
+ * data is still available in the internal buffer.
+ *
+ * d Changing the transformation securing the communication.
+ *
+ * Given an opaque implementation of the record layer in the
+ * above sense, it should be possible to implement the logic
+ * of (D)TLS on top of it without the need to know anything
+ * about the record layer's internals. This is done e.g.
+ * in all the handshake handling functions, and in the
+ * application data reading function mbedtls_ssl_read.
+ *
+ * \note The above tries to give a conceptual picture of the
+ * record layer, but the current implementation deviates
+ * from it in some places. For example, our implementation of
+ * the update functionality through mbedtls_ssl_read_record
+ * discards datagrams depending on the current state, which
+ * wouldn't fall under the record layer's responsibility
+ * following the above definition.
+ *
+ */
int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl );
int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want );
#if defined(MBEDTLS_PK_C)
unsigned char mbedtls_ssl_sig_from_pk( mbedtls_pk_context *pk );
+unsigned char mbedtls_ssl_sig_from_pk_alg( mbedtls_pk_type_t type );
mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig( unsigned char sig );
#endif
static inline int mbedtls_ssl_safer_memcmp( const void *a, const void *b, size_t n )
{
size_t i;
- const unsigned char *A = (const unsigned char *) a;
- const unsigned char *B = (const unsigned char *) b;
- unsigned char diff = 0;
+ volatile const unsigned char *A = (volatile const unsigned char *) a;
+ volatile const unsigned char *B = (volatile const unsigned char *) b;
+ volatile unsigned char diff = 0;
for( i = 0; i < n; i++ )
diff |= A[i] ^ B[i];
return( diff );
}
+#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \
+ defined(MBEDTLS_SSL_PROTO_TLS1_1)
+int mbedtls_ssl_get_key_exchange_md_ssl_tls( mbedtls_ssl_context *ssl,
+ unsigned char *output,
+ unsigned char *data, size_t data_len );
+#endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || \
+ MBEDTLS_SSL_PROTO_TLS1_1 */
+
+#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \
+ defined(MBEDTLS_SSL_PROTO_TLS1_2)
+int mbedtls_ssl_get_key_exchange_md_tls1_2( mbedtls_ssl_context *ssl,
+ unsigned char *output,
+ unsigned char *data, size_t data_len,
+ mbedtls_md_type_t md_alg );
+#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \
+ MBEDTLS_SSL_PROTO_TLS1_2 */
+
#ifdef __cplusplus
}
#endif
* \file ssl_ticket.h
*
* \brief TLS server ticket callbacks implementation
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file threading.h
*
* \brief Threading abstraction layer
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
/**
* \file timing.h
*
- * \brief Portable interface to the CPU cycle counter
- *
+ * \brief Portable interface to timeouts and to the CPU cycle counter
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \warning This is only a best effort! Do not rely on this!
* In particular, it is known to be unreliable on virtual
* machines.
+ *
+ * \note This value starts at an unspecified origin and
+ * may wrap around.
*/
unsigned long mbedtls_timing_hardclock( void );
* \brief Return the elapsed time in milliseconds
*
* \param val points to a timer structure
- * \param reset if set to 1, the timer is restarted
+ * \param reset If 0, query the elapsed time. Otherwise (re)start the timer.
+ *
+ * \return Elapsed time since the previous reset in ms. When
+ * restarting, this is always 0.
+ *
+ * \note To initialize a timer, call this function with reset=1.
+ *
+ * Determining the elapsed time and resetting the timer is not
+ * atomic on all platforms, so after the sequence
+ * `{ get_timer(1); ...; time1 = get_timer(1); ...; time2 =
+ * get_timer(0) }` the value time1+time2 is only approximately
+ * the delay since the first reset.
*/
unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset );
* \brief Setup an alarm clock
*
* \param seconds delay before the "mbedtls_timing_alarmed" flag is set
+ * (must be >=0)
*
* \warning Only one alarm at a time is supported. In a threaded
* context, this means one for the whole process, not one per
* \brief Set a pair of delays to watch
* (See \c mbedtls_timing_get_delay().)
*
- * \param data Pointer to timing data
+ * \param data Pointer to timing data.
* Must point to a valid \c mbedtls_timing_delay_context struct.
* \param int_ms First (intermediate) delay in milliseconds.
+ * The effect if int_ms > fin_ms is unspecified.
* \param fin_ms Second (final) delay in milliseconds.
* Pass 0 to cancel the current delay.
+ *
+ * \note To set a single delay, either use \c mbedtls_timing_set_timer
+ * directly or use this function with int_ms == fin_ms.
*/
void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms );
* \param data Pointer to timing data
* Must point to a valid \c mbedtls_timing_delay_context struct.
*
- * \return -1 if cancelled (fin_ms = 0)
+ * \return -1 if cancelled (fin_ms = 0),
* 0 if none of the delays are passed,
* 1 if only the intermediate delay is passed,
* 2 if the final delay is passed.
* \file version.h
*
* \brief Run-time version information
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Major, Minor, Patchlevel
*/
#define MBEDTLS_VERSION_MAJOR 2
-#define MBEDTLS_VERSION_MINOR 4
+#define MBEDTLS_VERSION_MINOR 8
#define MBEDTLS_VERSION_PATCH 0
/**
* MMNNPP00
* Major version | Minor version | Patch version
*/
-#define MBEDTLS_VERSION_NUMBER 0x02040000
-#define MBEDTLS_VERSION_STRING "2.4.0"
-#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.4.0"
+#define MBEDTLS_VERSION_NUMBER 0x02080000
+#define MBEDTLS_VERSION_STRING "2.8.0"
+#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.8.0"
#if defined(MBEDTLS_VERSION_C)
* \file x509.h
*
* \brief X.509 generic defines and structures
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#define MBEDTLS_ERR_X509_ALLOC_FAILED -0x2880 /**< Allocation of memory failed. */
#define MBEDTLS_ERR_X509_FILE_IO_ERROR -0x2900 /**< Read/write of file failed. */
#define MBEDTLS_ERR_X509_BUFFER_TOO_SMALL -0x2980 /**< Destination buffer is too small. */
+#define MBEDTLS_ERR_X509_FATAL_ERROR -0x3000 /**< A fatal error occured, eg the chain is too long or the vrfy callback failed. */
/* \} name */
/**
#define MBEDTLS_X509_EXT_INIHIBIT_ANYPOLICY (1 << 13)
#define MBEDTLS_X509_EXT_FRESHEST_CRL (1 << 14)
-#define MBEDTLS_X509_EXT_NS_CERT_TYPE (1 << 16) /* Parsed (and then ?) */
+#define MBEDTLS_X509_EXT_NS_CERT_TYPE (1 << 16)
/*
* Storage format identifiers
* \note Intended usage is "if( is_past( valid_to ) ) ERROR".
* Hence the return value of 1 if on internal errors.
*
- * \param time mbedtls_x509_time to check
+ * \param to mbedtls_x509_time to check
*
* \return 1 if the given time is in the past or an error occured,
* 0 otherwise.
*/
-int mbedtls_x509_time_is_past( const mbedtls_x509_time *time );
+int mbedtls_x509_time_is_past( const mbedtls_x509_time *to );
/**
* \brief Check a given mbedtls_x509_time against the system time
* \note Intended usage is "if( is_future( valid_from ) ) ERROR".
* Hence the return value of 1 if on internal errors.
*
- * \param time mbedtls_x509_time to check
+ * \param from mbedtls_x509_time to check
*
* \return 1 if the given time is in the future or an error occured,
* 0 otherwise.
*/
-int mbedtls_x509_time_is_future( const mbedtls_x509_time *time );
+int mbedtls_x509_time_is_future( const mbedtls_x509_time *from );
/**
* \brief Checkup routine
mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg,
void **sig_opts );
int mbedtls_x509_get_time( unsigned char **p, const unsigned char *end,
- mbedtls_x509_time *time );
+ mbedtls_x509_time *t );
int mbedtls_x509_get_serial( unsigned char **p, const unsigned char *end,
mbedtls_x509_buf *serial );
int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end,
* \file x509_crl.h
*
* \brief X.509 certificate revocation list parsing
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file x509_crt.h
*
* \brief X.509 certificate parsing and writing
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
*
* All flags left after returning from the callback
* are also returned to the application. The function should
- * return 0 for anything but a fatal error.
+ * return 0 for anything (including invalid certificates)
+ * other than fatal error, as a non-zero return code
+ * immediately aborts the verification process. For fatal
+ * errors, a specific error code should be used (different
+ * from MBEDTLS_ERR_X509_CERT_VERIFY_FAILED which should not
+ * be returned at this point), or MBEDTLS_ERR_X509_FATAL_ERROR
+ * can be used if no better code is available.
*
* \note In case verification failed, the results can be displayed
* using \c mbedtls_x509_crt_verify_info()
* \param f_vrfy verification function
* \param p_vrfy verification parameter
*
- * \return 0 if successful or MBEDTLS_ERR_X509_CERT_VERIFY_FAILED
- * in which case *flags will have one or more
- * MBEDTLS_X509_BADCERT_XXX or MBEDTLS_X509_BADCRL_XXX flags
- * set,
- * or another error in case of a fatal error encountered
- * during the verification process.
+ * \return 0 (and flags set to 0) if the chain was verified and valid,
+ * MBEDTLS_ERR_X509_CERT_VERIFY_FAILED if the chain was verified
+ * but found to be invalid, in which case *flags will have one
+ * or more MBEDTLS_X509_BADCERT_XXX or MBEDTLS_X509_BADCRL_XXX
+ * flags set, or another error (and flags set to 0xffffffff)
+ * in case of a fatal error encountered during the
+ * verification process.
*/
int mbedtls_x509_crt_verify( mbedtls_x509_crt *crt,
mbedtls_x509_crt *trust_ca,
#if defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE)
/**
- * \brief Check usage of certificate against extentedJeyUsage.
+ * \brief Check usage of certificate against extendedKeyUsage.
*
- * \param crt Leaf certificate used.
- * \param usage_oid Intended usage (eg MBEDTLS_OID_SERVER_AUTH or MBEDTLS_OID_CLIENT_AUTH).
+ * \param crt Leaf certificate used.
+ * \param usage_oid Intended usage (eg MBEDTLS_OID_SERVER_AUTH or
+ * MBEDTLS_OID_CLIENT_AUTH).
* \param usage_len Length of usage_oid (eg given by MBEDTLS_OID_SIZE()).
*
- * \return 0 if this use of the certificate is allowed,
- * MBEDTLS_ERR_X509_BAD_INPUT_DATA if not.
+ * \return 0 if this use of the certificate is allowed,
+ * MBEDTLS_ERR_X509_BAD_INPUT_DATA if not.
*
- * \note Usually only makes sense on leaf certificates.
+ * \note Usually only makes sense on leaf certificates.
*/
int mbedtls_x509_crt_check_extended_key_usage( const mbedtls_x509_crt *crt,
- const char *usage_oid,
- size_t usage_len );
-#endif /* MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE) */
+ const char *usage_oid,
+ size_t usage_len );
+#endif /* MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE */
#if defined(MBEDTLS_X509_CRL_PARSE_C)
/**
* \file x509_csr.h
*
* \brief X.509 certificate signing request parsing and writing
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* \file xtea.h
*
* \brief XTEA block cipher (32-bit)
- *
+ */
+/*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
#define MBEDTLS_XTEA_DECRYPT 0
#define MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH -0x0028 /**< The data input has an invalid length. */
+#define MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED -0x0029 /**< XTEA hardware accelerator failed. */
#if !defined(MBEDTLS_XTEA_ALT)
// Regular implementation
platform.c
ripemd160.c
rsa.c
+ rsa_internal.c
sha1.c
sha256.c
sha512.c
if(USE_SHARED_MBEDTLS_LIBRARY)
add_library(mbedcrypto SHARED ${src_crypto})
- set_target_properties(mbedcrypto PROPERTIES VERSION 2.4.0 SOVERSION 0)
+ set_target_properties(mbedcrypto PROPERTIES VERSION 2.8.0 SOVERSION 1)
target_link_libraries(mbedcrypto ${libs})
add_library(mbedx509 SHARED ${src_x509})
- set_target_properties(mbedx509 PROPERTIES VERSION 2.4.0 SOVERSION 0)
+ set_target_properties(mbedx509 PROPERTIES VERSION 2.8.0 SOVERSION 0)
target_link_libraries(mbedx509 ${libs} mbedcrypto)
add_library(mbedtls SHARED ${src_tls})
- set_target_properties(mbedtls PROPERTIES VERSION 2.4.0 SOVERSION 10)
+ set_target_properties(mbedtls PROPERTIES VERSION 2.8.0 SOVERSION 10)
target_link_libraries(mbedtls ${libs} mbedx509)
install(TARGETS mbedtls mbedx509 mbedcrypto
SOEXT_TLS=so.10
SOEXT_X509=so.0
-SOEXT_CRYPTO=so.0
+SOEXT_CRYPTO=so.1
DLEXT=so
# OSX shared library extension:
padlock.o pem.o pk.o \
pk_wrap.o pkcs12.o pkcs5.o \
pkparse.o pkwrite.o platform.o \
- ripemd160.o rsa.o sha1.o \
- sha256.o sha512.o threading.o \
- timing.o version.o \
+ ripemd160.o rsa_internal.o rsa.o \
+ sha1.o sha256.o sha512.o \
+ threading.o timing.o version.o \
version_features.o xtea.o
OBJS_X509= certs.o pkcs11.o x509.o \
* AES-ECB block encryption
*/
#if !defined(MBEDTLS_AES_ENCRYPT_ALT)
-void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
- const unsigned char input[16],
- unsigned char output[16] )
+int mbedtls_internal_aes_encrypt( mbedtls_aes_context *ctx,
+ const unsigned char input[16],
+ unsigned char output[16] )
{
int i;
uint32_t *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
PUT_UINT32_LE( X1, output, 4 );
PUT_UINT32_LE( X2, output, 8 );
PUT_UINT32_LE( X3, output, 12 );
+
+ return( 0 );
}
#endif /* !MBEDTLS_AES_ENCRYPT_ALT */
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
+ const unsigned char input[16],
+ unsigned char output[16] )
+{
+ mbedtls_internal_aes_encrypt( ctx, input, output );
+}
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
+
/*
* AES-ECB block decryption
*/
#if !defined(MBEDTLS_AES_DECRYPT_ALT)
-void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
- const unsigned char input[16],
- unsigned char output[16] )
+int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
+ const unsigned char input[16],
+ unsigned char output[16] )
{
int i;
uint32_t *RK, X0, X1, X2, X3, Y0, Y1, Y2, Y3;
PUT_UINT32_LE( X1, output, 4 );
PUT_UINT32_LE( X2, output, 8 );
PUT_UINT32_LE( X3, output, 12 );
+
+ return( 0 );
}
#endif /* !MBEDTLS_AES_DECRYPT_ALT */
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
+ const unsigned char input[16],
+ unsigned char output[16] )
+{
+ mbedtls_internal_aes_decrypt( ctx, input, output );
+}
+#endif /* !MBEDTLS_DEPRECATED_REMOVED */
+
/*
* AES-ECB block encryption/decryption
*/
#endif
if( mode == MBEDTLS_AES_ENCRYPT )
- mbedtls_aes_encrypt( ctx, input, output );
+ return( mbedtls_internal_aes_encrypt( ctx, input, output ) );
else
- mbedtls_aes_decrypt( ctx, input, output );
-
- return( 0 );
+ return( mbedtls_internal_aes_decrypt( ctx, input, output ) );
}
#if defined(MBEDTLS_CIPHER_MODE_CBC)
*/
int mbedtls_aes_self_test( int verbose )
{
- int ret = 0, i, j, u, v;
+ int ret = 0, i, j, u, mode;
+ unsigned int keybits;
unsigned char key[32];
unsigned char buf[64];
+ const unsigned char *aes_tests;
#if defined(MBEDTLS_CIPHER_MODE_CBC) || defined(MBEDTLS_CIPHER_MODE_CFB)
unsigned char iv[16];
#endif
for( i = 0; i < 6; i++ )
{
u = i >> 1;
- v = i & 1;
+ keybits = 128 + u * 64;
+ mode = i & 1;
if( verbose != 0 )
- mbedtls_printf( " AES-ECB-%3d (%s): ", 128 + u * 64,
- ( v == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
+ mbedtls_printf( " AES-ECB-%3d (%s): ", keybits,
+ ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
memset( buf, 0, 16 );
- if( v == MBEDTLS_AES_DECRYPT )
+ if( mode == MBEDTLS_AES_DECRYPT )
{
- mbedtls_aes_setkey_dec( &ctx, key, 128 + u * 64 );
-
- for( j = 0; j < 10000; j++ )
- mbedtls_aes_crypt_ecb( &ctx, v, buf, buf );
-
- if( memcmp( buf, aes_test_ecb_dec[u], 16 ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- ret = 1;
- goto exit;
- }
+ ret = mbedtls_aes_setkey_dec( &ctx, key, keybits );
+ aes_tests = aes_test_ecb_dec[u];
}
else
{
- mbedtls_aes_setkey_enc( &ctx, key, 128 + u * 64 );
-
- for( j = 0; j < 10000; j++ )
- mbedtls_aes_crypt_ecb( &ctx, v, buf, buf );
+ ret = mbedtls_aes_setkey_enc( &ctx, key, keybits );
+ aes_tests = aes_test_ecb_enc[u];
+ }
- if( memcmp( buf, aes_test_ecb_enc[u], 16 ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
+ /*
+ * AES-192 is an optional feature that may be unavailable when
+ * there is an alternative underlying implementation i.e. when
+ * MBEDTLS_AES_ALT is defined.
+ */
+ if( ret == MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE && keybits == 192 )
+ {
+ mbedtls_printf( "skipped\n" );
+ continue;
+ }
+ else if( ret != 0 )
+ {
+ goto exit;
+ }
- ret = 1;
+ for( j = 0; j < 10000; j++ )
+ {
+ ret = mbedtls_aes_crypt_ecb( &ctx, mode, buf, buf );
+ if( ret != 0 )
goto exit;
- }
+ }
+
+ if( memcmp( buf, aes_tests, 16 ) != 0 )
+ {
+ ret = 1;
+ goto exit;
}
if( verbose != 0 )
for( i = 0; i < 6; i++ )
{
u = i >> 1;
- v = i & 1;
+ keybits = 128 + u * 64;
+ mode = i & 1;
if( verbose != 0 )
- mbedtls_printf( " AES-CBC-%3d (%s): ", 128 + u * 64,
- ( v == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
+ mbedtls_printf( " AES-CBC-%3d (%s): ", keybits,
+ ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
memset( iv , 0, 16 );
memset( prv, 0, 16 );
memset( buf, 0, 16 );
- if( v == MBEDTLS_AES_DECRYPT )
+ if( mode == MBEDTLS_AES_DECRYPT )
{
- mbedtls_aes_setkey_dec( &ctx, key, 128 + u * 64 );
-
- for( j = 0; j < 10000; j++ )
- mbedtls_aes_crypt_cbc( &ctx, v, 16, iv, buf, buf );
-
- if( memcmp( buf, aes_test_cbc_dec[u], 16 ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- ret = 1;
- goto exit;
- }
+ ret = mbedtls_aes_setkey_dec( &ctx, key, keybits );
+ aes_tests = aes_test_cbc_dec[u];
}
else
{
- mbedtls_aes_setkey_enc( &ctx, key, 128 + u * 64 );
+ ret = mbedtls_aes_setkey_enc( &ctx, key, keybits );
+ aes_tests = aes_test_cbc_enc[u];
+ }
+
+ /*
+ * AES-192 is an optional feature that may be unavailable when
+ * there is an alternative underlying implementation i.e. when
+ * MBEDTLS_AES_ALT is defined.
+ */
+ if( ret == MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE && keybits == 192 )
+ {
+ mbedtls_printf( "skipped\n" );
+ continue;
+ }
+ else if( ret != 0 )
+ {
+ goto exit;
+ }
- for( j = 0; j < 10000; j++ )
+ for( j = 0; j < 10000; j++ )
+ {
+ if( mode == MBEDTLS_AES_ENCRYPT )
{
unsigned char tmp[16];
- mbedtls_aes_crypt_cbc( &ctx, v, 16, iv, buf, buf );
-
memcpy( tmp, prv, 16 );
memcpy( prv, buf, 16 );
memcpy( buf, tmp, 16 );
}
- if( memcmp( prv, aes_test_cbc_enc[u], 16 ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- ret = 1;
+ ret = mbedtls_aes_crypt_cbc( &ctx, mode, 16, iv, buf, buf );
+ if( ret != 0 )
goto exit;
- }
+
+ }
+
+ if( memcmp( buf, aes_tests, 16 ) != 0 )
+ {
+ ret = 1;
+ goto exit;
}
if( verbose != 0 )
for( i = 0; i < 6; i++ )
{
u = i >> 1;
- v = i & 1;
+ keybits = 128 + u * 64;
+ mode = i & 1;
if( verbose != 0 )
- mbedtls_printf( " AES-CFB128-%3d (%s): ", 128 + u * 64,
- ( v == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
+ mbedtls_printf( " AES-CFB128-%3d (%s): ", keybits,
+ ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
memcpy( iv, aes_test_cfb128_iv, 16 );
- memcpy( key, aes_test_cfb128_key[u], 16 + u * 8 );
+ memcpy( key, aes_test_cfb128_key[u], keybits / 8 );
offset = 0;
- mbedtls_aes_setkey_enc( &ctx, key, 128 + u * 64 );
+ ret = mbedtls_aes_setkey_enc( &ctx, key, keybits );
+ /*
+ * AES-192 is an optional feature that may be unavailable when
+ * there is an alternative underlying implementation i.e. when
+ * MBEDTLS_AES_ALT is defined.
+ */
+ if( ret == MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE && keybits == 192 )
+ {
+ mbedtls_printf( "skipped\n" );
+ continue;
+ }
+ else if( ret != 0 )
+ {
+ goto exit;
+ }
- if( v == MBEDTLS_AES_DECRYPT )
+ if( mode == MBEDTLS_AES_DECRYPT )
{
memcpy( buf, aes_test_cfb128_ct[u], 64 );
- mbedtls_aes_crypt_cfb128( &ctx, v, 64, &offset, iv, buf, buf );
-
- if( memcmp( buf, aes_test_cfb128_pt, 64 ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- ret = 1;
- goto exit;
- }
+ aes_tests = aes_test_cfb128_pt;
}
else
{
memcpy( buf, aes_test_cfb128_pt, 64 );
- mbedtls_aes_crypt_cfb128( &ctx, v, 64, &offset, iv, buf, buf );
+ aes_tests = aes_test_cfb128_ct[u];
+ }
- if( memcmp( buf, aes_test_cfb128_ct[u], 64 ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
+ ret = mbedtls_aes_crypt_cfb128( &ctx, mode, 64, &offset, iv, buf, buf );
+ if( ret != 0 )
+ goto exit;
- ret = 1;
- goto exit;
- }
+ if( memcmp( buf, aes_tests, 64 ) != 0 )
+ {
+ ret = 1;
+ goto exit;
}
if( verbose != 0 )
for( i = 0; i < 6; i++ )
{
u = i >> 1;
- v = i & 1;
+ mode = i & 1;
if( verbose != 0 )
mbedtls_printf( " AES-CTR-128 (%s): ",
- ( v == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
+ ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" );
memcpy( nonce_counter, aes_test_ctr_nonce_counter[u], 16 );
memcpy( key, aes_test_ctr_key[u], 16 );
offset = 0;
- mbedtls_aes_setkey_enc( &ctx, key, 128 );
+ if( ( ret = mbedtls_aes_setkey_enc( &ctx, key, 128 ) ) != 0 )
+ goto exit;
+
+ len = aes_test_ctr_len[u];
- if( v == MBEDTLS_AES_DECRYPT )
+ if( mode == MBEDTLS_AES_DECRYPT )
{
- len = aes_test_ctr_len[u];
memcpy( buf, aes_test_ctr_ct[u], len );
-
- mbedtls_aes_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block,
- buf, buf );
-
- if( memcmp( buf, aes_test_ctr_pt[u], len ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- ret = 1;
- goto exit;
- }
+ aes_tests = aes_test_ctr_pt[u];
}
else
{
- len = aes_test_ctr_len[u];
memcpy( buf, aes_test_ctr_pt[u], len );
+ aes_tests = aes_test_ctr_ct[u];
+ }
- mbedtls_aes_crypt_ctr( &ctx, len, &offset, nonce_counter, stream_block,
- buf, buf );
+ ret = mbedtls_aes_crypt_ctr( &ctx, len, &offset, nonce_counter,
+ stream_block, buf, buf );
+ if( ret != 0 )
+ goto exit;
- if( memcmp( buf, aes_test_ctr_ct[u], len ) != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- ret = 1;
- goto exit;
- }
+ if( memcmp( buf, aes_tests, len ) != 0 )
+ {
+ ret = 1;
+ goto exit;
}
if( verbose != 0 )
ret = 0;
exit:
+ if( ret != 0 && verbose != 0 )
+ mbedtls_printf( "failed\n" );
+
mbedtls_aes_free( &ctx );
return( ret );
return( 0 );
}
- n = ( ( n * 6 ) + 7 ) >> 3;
+ /* The following expression is to calculate the following formula without
+ * risk of integer overflow in n:
+ * n = ( ( n * 6 ) + 7 ) >> 3;
+ */
+ n = ( 6 * ( n >> 3 ) ) + ( ( 6 * ( n & 0x7 ) + 7 ) >> 3 );
n -= j;
if( dst == NULL || dlen < n )
volatile mbedtls_mpi_uint *p = v; while( n-- ) *p++ = 0;
}
+/* Implementation that should never be optimized out by the compiler */
+static void mbedtls_zeroize( void *v, size_t n ) {
+ volatile unsigned char *p = v; while( n-- ) *p++ = 0;
+}
+
#define ciL (sizeof(mbedtls_mpi_uint)) /* chars in limb */
#define biL (ciL << 3) /* bits in limb */
#define biH (ciL << 2) /* half limb size */
n = mbedtls_mpi_bitlen( X );
if( radix >= 4 ) n >>= 1;
if( radix >= 16 ) n >>= 1;
- n += 3;
+ /*
+ * Round up the buffer length to an even value to ensure that there is
+ * enough room for hexadecimal values that can be represented in an odd
+ * number of digits.
+ */
+ n += 3 + ( ( n + 1 ) & 1 );
if( buflen < n )
{
if( slen == sizeof( s ) - 2 )
return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL );
- if( s[slen - 1] == '\n' ) { slen--; s[slen] = '\0'; }
- if( s[slen - 1] == '\r' ) { slen--; s[slen] = '\0'; }
+ if( slen > 0 && s[slen - 1] == '\n' ) { slen--; s[slen] = '\0'; }
+ if( slen > 0 && s[slen - 1] == '\r' ) { slen--; s[slen] = '\0'; }
p = s + slen;
- while( --p >= s )
+ while( p-- > s )
if( mpi_get_digit( &d, radix, *p ) != 0 )
break;
int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t buflen )
{
int ret;
- size_t i, j, n;
+ size_t i, j;
+ size_t const limbs = CHARS_TO_LIMBS( buflen );
- for( n = 0; n < buflen; n++ )
- if( buf[n] != 0 )
- break;
+ /* Ensure that target MPI has exactly the necessary number of limbs */
+ if( X->n != limbs )
+ {
+ mbedtls_mpi_free( X );
+ mbedtls_mpi_init( X );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, limbs ) );
+ }
- MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, CHARS_TO_LIMBS( buflen - n ) ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) );
- for( i = buflen, j = 0; i > n; i--, j++ )
+ for( i = buflen, j = 0; i > 0; i--, j++ )
X->p[j / ciL] |= ((mbedtls_mpi_uint) buf[i - 1]) << ((j % ciL) << 3);
cleanup:
mbedtls_mpi RR, T, W[ 2 << MBEDTLS_MPI_WINDOW_SIZE ], Apos;
int neg;
- if( mbedtls_mpi_cmp_int( N, 0 ) < 0 || ( N->p[0] & 1 ) == 0 )
+ if( mbedtls_mpi_cmp_int( N, 0 ) <= 0 || ( N->p[0] & 1 ) == 0 )
return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
if( mbedtls_mpi_cmp_int( E, 0 ) < 0 )
*/
MBEDTLS_MPI_CHK( mpi_montred( X, N, mm, &T ) );
- if( neg )
+ if( neg && E->n != 0 && ( E->p[0] & 1 ) != 0 )
{
X->s = -1;
MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( X, N, X ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( X, buf, size ) );
cleanup:
+ mbedtls_zeroize( buf, sizeof( buf ) );
return( ret );
}
int ret;
mbedtls_mpi G, TA, TU, U1, U2, TB, TV, V1, V2;
- if( mbedtls_mpi_cmp_int( N, 0 ) <= 0 )
+ if( mbedtls_mpi_cmp_int( N, 1 ) <= 0 )
return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TU ); mbedtls_mpi_init( &U1 ); mbedtls_mpi_init( &U2 );
#endif /* MBEDTLS_PLATFORM_C */
#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
+#if !defined(MBEDTLS_CCM_ALT)
+
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0;
return( 0 );
}
+#endif /* !MBEDTLS_CCM_ALT */
#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
/*
"uCjn8pwUOkABXK8Mss90fzCfCEOtIA==\r\n" \
"-----END CERTIFICATE-----\r\n"
const char mbedtls_test_ca_crt_ec[] = TEST_CA_CRT_EC;
+const size_t mbedtls_test_ca_crt_ec_len = sizeof( mbedtls_test_ca_crt_ec );
const char mbedtls_test_ca_key_ec[] =
"-----BEGIN EC PRIVATE KEY-----\r\n"
"UsuWTITwJImcnlAs1gaRZ3sAWm7cOUidL0fo2G0fYUFNcYoCSLffCFTEHBuPnagb\r\n"
"a77x/sY1Bvii8S9/XhDTb6pTMx06wzrm\r\n"
"-----END EC PRIVATE KEY-----\r\n";
+const size_t mbedtls_test_ca_key_ec_len = sizeof( mbedtls_test_ca_key_ec );
const char mbedtls_test_ca_pwd_ec[] = "PolarSSLTest";
+const size_t mbedtls_test_ca_pwd_ec_len = sizeof( mbedtls_test_ca_pwd_ec ) - 1;
const char mbedtls_test_srv_crt_ec[] =
"-----BEGIN CERTIFICATE-----\r\n"
"C12r0Lz3ri/moSEpNZWqPjkCMCE2f53GXcYLqyfyJR078c/xNSUU5+Xxl7VZ414V\r\n"
"fGa5kHvHARBPc8YAIVIqDvHH1Q==\r\n"
"-----END CERTIFICATE-----\r\n";
+const size_t mbedtls_test_srv_crt_ec_len = sizeof( mbedtls_test_srv_crt_ec );
const char mbedtls_test_srv_key_ec[] =
"-----BEGIN EC PRIVATE KEY-----\r\n"
"AwEHoUQDQgAEN8xW2XYJHlpyPsdZLf8gbu58+QaRdNCtFLX3aCJZYpJO5QDYIxH/\r\n"
"6i/SNF1dFr2KiMJrdw1VzYoqDvoByLTt/w==\r\n"
"-----END EC PRIVATE KEY-----\r\n";
+const size_t mbedtls_test_srv_key_ec_len = sizeof( mbedtls_test_srv_key_ec );
const char mbedtls_test_cli_crt_ec[] =
"-----BEGIN CERTIFICATE-----\r\n"
"lgOsjnhw3fIOoLIWy2WOGsk/LGF++DzvrRzuNiACMQCd8iem1XS4JK7haj8xocpU\r\n"
"LwjQje5PDGHfd3h9tP38Qknu5bJqws0md2KOKHyeV0U=\r\n"
"-----END CERTIFICATE-----\r\n";
+const size_t mbedtls_test_cli_crt_ec_len = sizeof( mbedtls_test_cli_crt_ec );
const char mbedtls_test_cli_key_ec[] =
"-----BEGIN EC PRIVATE KEY-----\r\n"
"AwEHoUQDQgAEV+WusXPf06y7k7iB/xKu7uZTrM5VU/Y0Dswu42MlC9+Y4vNcYDaW\r\n"
"wNUYFHDlf5/VS0UY5bBs1Vz4lo+HcKPkxw==\r\n"
"-----END EC PRIVATE KEY-----\r\n";
-
-const size_t mbedtls_test_ca_crt_ec_len = sizeof( mbedtls_test_ca_crt_ec );
-const size_t mbedtls_test_ca_key_ec_len = sizeof( mbedtls_test_ca_key_ec );
-const size_t mbedtls_test_ca_pwd_ec_len = sizeof( mbedtls_test_ca_pwd_ec ) - 1;
-const size_t mbedtls_test_srv_crt_ec_len = sizeof( mbedtls_test_srv_crt_ec );
-const size_t mbedtls_test_srv_key_ec_len = sizeof( mbedtls_test_srv_key_ec );
-const size_t mbedtls_test_cli_crt_ec_len = sizeof( mbedtls_test_cli_crt_ec );
const size_t mbedtls_test_cli_key_ec_len = sizeof( mbedtls_test_cli_key_ec );
-#else
-#define TEST_CA_CRT_EC
#endif /* MBEDTLS_ECDSA_C */
#if defined(MBEDTLS_RSA_C)
-#define TEST_CA_CRT_RSA \
+
+#if defined(MBEDTLS_SHA256_C)
+#define TEST_CA_CRT_RSA_SHA256 \
+"-----BEGIN CERTIFICATE-----\r\n" \
+"MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER\r\n" \
+"MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" \
+"MTcwNTA0MTY1NzAxWhcNMjcwNTA1MTY1NzAxWjA7MQswCQYDVQQGEwJOTDERMA8G\r\n" \
+"A1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G\r\n" \
+"CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx\r\n" \
+"mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny\r\n" \
+"50BwFMtEonILwuVA+T7lpg6z+exKY8C4KQB0nFc7qKUEkHHxvYPZP9al4jwqj+8n\r\n" \
+"YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL\r\n" \
+"R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu\r\n" \
+"KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj\r\n" \
+"gZUwgZIwHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/MGMGA1UdIwRcMFqA\r\n" \
+"FLRa5KWz3tJS9rnVppUP6z68x/3/oT+kPTA7MQswCQYDVQQGEwJOTDERMA8GA1UE\r\n" \
+"CgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0GCAQAwDAYDVR0T\r\n" \
+"BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAHK/HHrTZMnnVMpde1io+voAtql7j\r\n" \
+"4sRhLrjD7o3THtwRbDa2diCvpq0Sq23Ng2LMYoXsOxoL/RQK3iN7UKxV3MKPEr0w\r\n" \
+"XQS+kKQqiT2bsfrjnWMVHZtUOMpm6FNqcdGm/Rss3vKda2lcKl8kUnq/ylc1+QbB\r\n" \
+"G6A6tUvQcr2ZyWfVg+mM5XkhTrOOXus2OLikb4WwEtJTJRNE0f+yPODSUz0/vT57\r\n" \
+"ApH0CnB80bYJshYHPHHymOtleAB8KSYtqm75g/YNobjnjB6cm4HkW3OZRVIl6fYY\r\n" \
+"n20NRVA1Vjs6GAROr4NqW4k/+LofY9y0LLDE+p0oIEKXIsIvhPr39swxSA==\r\n" \
+"-----END CERTIFICATE-----\r\n"
+
+const char mbedtls_test_ca_crt_rsa[] = TEST_CA_CRT_RSA_SHA256;
+const size_t mbedtls_test_ca_crt_rsa_len = sizeof( mbedtls_test_ca_crt_rsa );
+#define TEST_CA_CRT_RSA_SOME
+
+static const char mbedtls_test_ca_crt_rsa_sha256[] = TEST_CA_CRT_RSA_SHA256;
+
+#endif
+
+#if !defined(TEST_CA_CRT_RSA_SOME) || defined(MBEDTLS_SHA1_C)
+#define TEST_CA_CRT_RSA_SHA1 \
"-----BEGIN CERTIFICATE-----\r\n" \
"MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" \
"MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" \
"m/UTSLBNFNHesiTZeH31NcxYGdHSme9Nc/gfidRa0FLOCfWxRlFqAI47zG9jAQCZ\r\n" \
"7Z2mCGDNMhjQc+BYcdnl0lPXjdDK6V0qCg1dVewhUBcW5gZKzV7e9+DpVA==\r\n" \
"-----END CERTIFICATE-----\r\n"
-const char mbedtls_test_ca_crt_rsa[] = TEST_CA_CRT_RSA;
+
+#if !defined (TEST_CA_CRT_RSA_SOME)
+const char mbedtls_test_ca_crt_rsa[] = TEST_CA_CRT_RSA_SHA1;
+const size_t mbedtls_test_ca_crt_rsa_len = sizeof( mbedtls_test_ca_crt_rsa );
+#endif
+
+static const char mbedtls_test_ca_crt_rsa_sha1[] = TEST_CA_CRT_RSA_SHA1;
+
+#endif
const char mbedtls_test_ca_key_rsa[] =
"-----BEGIN RSA PRIVATE KEY-----\r\n"
"wN48lslbHnqqagr6Xm1nNOSVl8C/6kbJEsMpLhAezfRtGwvOucoaE+WbeUNolGde\r\n"
"P/eQiddSf0brnpiLJRh7qZrl9XuqYdpUqnoEdMAfotDOID8OtV7gt8a48ad8VPW2\r\n"
"-----END RSA PRIVATE KEY-----\r\n";
+const size_t mbedtls_test_ca_key_rsa_len = sizeof( mbedtls_test_ca_key_rsa );
const char mbedtls_test_ca_pwd_rsa[] = "PolarSSLTest";
+const size_t mbedtls_test_ca_pwd_rsa_len = sizeof( mbedtls_test_ca_pwd_rsa ) - 1;
const char mbedtls_test_srv_crt_rsa[] =
"-----BEGIN CERTIFICATE-----\r\n"
"RRQfaD8neM9c1S/iJ/amTVqJxA1KOdOS5780WhPfSArA+g4qAmSjelc3p4wWpha8\r\n"
"zhuYwjVuX6JHG0c=\r\n"
"-----END CERTIFICATE-----\r\n";
+const size_t mbedtls_test_srv_crt_rsa_len = sizeof( mbedtls_test_srv_crt_rsa );
const char mbedtls_test_srv_key_rsa[] =
"-----BEGIN RSA PRIVATE KEY-----\r\n"
"4AgahOxIxXx2gxJnq3yfkJfIjwf0s2DyP0kY2y6Ua1OeomPeY9mrIS4tCuDQ6LrE\r\n"
"TB6l9VGoxJL4fyHnZb8L5gGvnB1bbD8cL6YPaDiOhcRseC9vBiEuVg==\r\n"
"-----END RSA PRIVATE KEY-----\r\n";
+const size_t mbedtls_test_srv_key_rsa_len = sizeof( mbedtls_test_srv_key_rsa );
const char mbedtls_test_cli_crt_rsa[] =
"-----BEGIN CERTIFICATE-----\r\n"
-"MIIDPzCCAiegAwIBAgIBBDANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n"
-"MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n"
-"MTEwMjEyMTQ0NDA3WhcNMjEwMjEyMTQ0NDA3WjA8MQswCQYDVQQGEwJOTDERMA8G\r\n"
-"A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIENsaWVudCAyMIIBIjAN\r\n"
+"MIIDhTCCAm2gAwIBAgIBBDANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER\r\n"
+"MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n"
+"MTcwNTA1MTMwNzU5WhcNMjcwNTA2MTMwNzU5WjA8MQswCQYDVQQGEwJOTDERMA8G\r\n"
+"A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIENsaWVudCAyMIIBIjAN\r\n"
"BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6f\r\n"
"M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu\r\n"
"1C93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786NvcHpK8UovKIG9cB32oSQQom\r\n"
+"LoR0eHDRzdqEkoq7yGZufHFiRAAzbMqJfogRtxlrWAeB4y/jGaMBV25IbFOIcH2W\r\n"
+"iCEaMMbG+VQLKNvuC63kmw/Zewc9ThM6Pa1Hcy0axT0faf1B/U01j0FIcw/6mTfK\r\n"
+"D8w48OIwc1yr0JtutCVjig5DC0yznGMt32RyseOLcUe+lfq005v2PAiCozr5X8rE\r\n"
+"ofGZpiM2NqRPePgYy+Vc75Zk28xkRQq1ncprgQb3S4vTsZdScpM9hLf+eMlrgqlj\r\n"
+"c5PLSkXBeLE5+fedkyfTaLxxQlgCpuoOhKBm04/R1pWNzUHyqagjO9Q=\r\n"
"-----END CERTIFICATE-----\r\n";
+const size_t mbedtls_test_cli_crt_rsa_len = sizeof( mbedtls_test_cli_crt_rsa );
const char mbedtls_test_cli_key_rsa[] =
"-----BEGIN RSA PRIVATE KEY-----\r\n"
"bHFVW2r0dBTqegP2/KTOxKzaHfC1qf0RGDsUoJCNJrd1cwoCLG8P2EF4w3OBrKqv\r\n"
"8u4ytY0F+Vlanj5lm3TaoHSVF1+NWPyOTiwevIECGKwSxvlki4fDAA==\r\n"
"-----END RSA PRIVATE KEY-----\r\n";
-
-const size_t mbedtls_test_ca_crt_rsa_len = sizeof( mbedtls_test_ca_crt_rsa );
-const size_t mbedtls_test_ca_key_rsa_len = sizeof( mbedtls_test_ca_key_rsa );
-const size_t mbedtls_test_ca_pwd_rsa_len = sizeof( mbedtls_test_ca_pwd_rsa ) - 1;
-const size_t mbedtls_test_srv_crt_rsa_len = sizeof( mbedtls_test_srv_crt_rsa );
-const size_t mbedtls_test_srv_key_rsa_len = sizeof( mbedtls_test_srv_key_rsa );
-const size_t mbedtls_test_cli_crt_rsa_len = sizeof( mbedtls_test_cli_crt_rsa );
const size_t mbedtls_test_cli_key_rsa_len = sizeof( mbedtls_test_cli_key_rsa );
-#else
-#define TEST_CA_CRT_RSA
#endif /* MBEDTLS_RSA_C */
#if defined(MBEDTLS_PEM_PARSE_C)
/* Concatenation of all available CA certificates */
-const char mbedtls_test_cas_pem[] = TEST_CA_CRT_RSA TEST_CA_CRT_EC;
+const char mbedtls_test_cas_pem[] =
+#ifdef TEST_CA_CRT_RSA_SHA1
+ TEST_CA_CRT_RSA_SHA1
+#endif
+#ifdef TEST_CA_CRT_RSA_SHA256
+ TEST_CA_CRT_RSA_SHA256
+#endif
+#ifdef TEST_CA_CRT_EC
+ TEST_CA_CRT_EC
+#endif
+ "";
const size_t mbedtls_test_cas_pem_len = sizeof( mbedtls_test_cas_pem );
#endif
/* List of all available CA certificates */
const char * mbedtls_test_cas[] = {
-#if defined(MBEDTLS_RSA_C)
- mbedtls_test_ca_crt_rsa,
+#if defined(TEST_CA_CRT_RSA_SHA1)
+ mbedtls_test_ca_crt_rsa_sha1,
+#endif
+#if defined(TEST_CA_CRT_RSA_SHA256)
+ mbedtls_test_ca_crt_rsa_sha256,
#endif
#if defined(MBEDTLS_ECDSA_C)
mbedtls_test_ca_crt_ec,
NULL
};
const size_t mbedtls_test_cas_len[] = {
-#if defined(MBEDTLS_RSA_C)
- sizeof( mbedtls_test_ca_crt_rsa ),
+#if defined(TEST_CA_CRT_RSA_SHA1)
+ sizeof( mbedtls_test_ca_crt_rsa_sha1 ),
+#endif
+#if defined(TEST_CA_CRT_RSA_SHA256)
+ sizeof( mbedtls_test_ca_crt_rsa_sha256 ),
#endif
#if defined(MBEDTLS_ECDSA_C)
sizeof( mbedtls_test_ca_crt_ec ),
};
#if defined(MBEDTLS_RSA_C)
-const char *mbedtls_test_ca_crt = mbedtls_test_ca_crt_rsa;
+const char *mbedtls_test_ca_crt = mbedtls_test_ca_crt_rsa; /* SHA1 or SHA256 */
const char *mbedtls_test_ca_key = mbedtls_test_ca_key_rsa;
const char *mbedtls_test_ca_pwd = mbedtls_test_ca_pwd_rsa;
const char *mbedtls_test_srv_crt = mbedtls_test_srv_crt_rsa;
* If there is not enough data for a full block, cache it.
*/
if( ( ctx->operation == MBEDTLS_DECRYPT &&
- ilen + ctx->unprocessed_len <= block_size ) ||
+ ilen <= block_size - ctx->unprocessed_len ) ||
( ctx->operation == MBEDTLS_ENCRYPT &&
- ilen + ctx->unprocessed_len < block_size ) )
+ ilen < block_size - ctx->unprocessed_len ) )
{
memcpy( &( ctx->unprocessed_data[ctx->unprocessed_len] ), input,
ilen );
if( NULL == input || NULL == data_len )
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- bad = 0xFF;
+ bad = 0x80;
*data_len = 0;
for( i = input_len; i > 0; i-- )
{
prev_done = done;
- done |= ( input[i-1] != 0 );
+ done |= ( input[i - 1] != 0 );
*data_len |= ( i - 1 ) * ( done != prev_done );
- bad &= ( input[i-1] ^ 0x80 ) | ( done == prev_done );
+ bad ^= input[i - 1] * ( done != prev_done );
}
return( MBEDTLS_ERR_CIPHER_INVALID_PADDING * ( bad != 0 ) );
-/*
+/**
* \file cmac.c
*
* \brief NIST SP800-38B compliant CMAC implementation for AES and 3DES
*
* - NIST SP 800-38B Recommendation for Block Cipher Modes of Operation: The
* CMAC Mode for Authentication
- * http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38b.pdf
+ * http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38b.pdf
*
* - RFC 4493 - The AES-CMAC Algorithm
* https://tools.ietf.org/html/rfc4493
#if defined(MBEDTLS_SELF_TEST)
#include <stdio.h>
#define mbedtls_printf printf
-#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C || MBEDTLS_DES_C */
+#endif /* MBEDTLS_SELF_TEST */
#endif /* MBEDTLS_PLATFORM_C */
+#if !defined(MBEDTLS_CMAC_ALT) || defined(MBEDTLS_SELF_TEST)
+
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0;
* with R_64 = 0x1B and R_128 = 0x87
*
* Input and output MUST NOT point to the same buffer
- * Block size must be 8 byes or 16 bytes - the block sizes for DES and AES.
+ * Block size must be 8 bytes or 16 bytes - the block sizes for DES and AES.
*/
static int cmac_multiply_by_u( unsigned char *output,
const unsigned char *input,
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
}
- for( i = blocksize - 1; i >= 0; i-- )
+ for( i = (int)blocksize - 1; i >= 0; i-- )
{
output[i] = input[i] << 1 | overflow;
overflow = input[i] >> 7;
return( ret );
}
+#endif /* !defined(MBEDTLS_CMAC_ALT) || defined(MBEDTLS_SELF_TEST) */
+#if !defined(MBEDTLS_CMAC_ALT)
static void cmac_xor_block( unsigned char *output, const unsigned char *input1,
const unsigned char *input2,
const size_t block_size )
{
- size_t index;
+ size_t idx;
- for( index = 0; index < block_size; index++ )
- output[ index ] = input1[ index ] ^ input2[ index ];
+ for( idx = 0; idx < block_size; idx++ )
+ output[ idx ] = input1[ idx ] ^ input2[ idx ];
}
/*
if( ctx == NULL || ctx->cipher_info == NULL || key == NULL )
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
- if( ( retval = mbedtls_cipher_setkey( ctx, key, keybits,
+ if( ( retval = mbedtls_cipher_setkey( ctx, key, (int)keybits,
MBEDTLS_ENCRYPT ) ) != 0 )
return( retval );
{
mbedtls_cmac_context_t* cmac_ctx;
unsigned char *state;
- int n, j, ret = 0;
- size_t olen, block_size;
+ int ret = 0;
+ size_t n, j, olen, block_size;
if( ctx == NULL || ctx->cipher_info == NULL || input == NULL ||
ctx->cmac_ctx == NULL )
/* n is the number of blocks including any final partial block */
n = ( ilen + block_size - 1 ) / block_size;
- /* Iterate across the input data in block sized chunks */
- for( j = 0; j < n - 1; j++ )
+ /* Iterate across the input data in block sized chunks, excluding any
+ * final partial or complete block */
+ for( j = 1; j < n; j++ )
{
cmac_xor_block( state, input, state, block_size );
}
#endif /* MBEDTLS_AES_C */
+#endif /* !MBEDTLS_CMAC_ALT */
+
#if defined(MBEDTLS_SELF_TEST)
/*
- * CMAC test data from SP800-38B Appendix D.1 (corrected)
- * http://csrc.nist.gov/publications/nistpubs/800-38B/Updated_CMAC_Examples.pdf
+ * CMAC test data for SP800-38B
+ * http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/AES_CMAC.pdf
+ * http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/TDES_CMAC.pdf
*
* AES-CMAC-PRF-128 test data from RFC 4615
* https://tools.ietf.org/html/rfc4615#page-4
#if defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C)
/* All CMAC test inputs are truncated from the same 64 byte buffer. */
static const unsigned char test_message[] = {
- 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
- 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
- 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
- 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
- 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
- 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
- 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
- 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10
+ /* PT */
+ 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
+ 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a,
+ 0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
+ 0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51,
+ 0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
+ 0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef,
+ 0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
+ 0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10
};
#endif /* MBEDTLS_AES_C || MBEDTLS_DES_C */
#if defined(MBEDTLS_AES_C)
/* Truncation point of message for AES CMAC tests */
static const unsigned int aes_message_lengths[NB_CMAC_TESTS_PER_KEY] = {
+ /* Mlen */
0,
16,
- 40,
+ 20,
64
};
-/* AES 128 CMAC Test Data */
+/* CMAC-AES128 Test Data */
static const unsigned char aes_128_key[16] = {
- 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
- 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
+ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
+ 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
};
static const unsigned char aes_128_subkeys[2][MBEDTLS_AES_BLOCK_SIZE] = {
{
- 0xfb, 0xee, 0xd6, 0x18, 0x35, 0x71, 0x33, 0x66,
- 0x7c, 0x85, 0xe0, 0x8f, 0x72, 0x36, 0xa8, 0xde
+ /* K1 */
+ 0xfb, 0xee, 0xd6, 0x18, 0x35, 0x71, 0x33, 0x66,
+ 0x7c, 0x85, 0xe0, 0x8f, 0x72, 0x36, 0xa8, 0xde
},
{
- 0xf7, 0xdd, 0xac, 0x30, 0x6a, 0xe2, 0x66, 0xcc,
- 0xf9, 0x0b, 0xc1, 0x1e, 0xe4, 0x6d, 0x51, 0x3b
+ /* K2 */
+ 0xf7, 0xdd, 0xac, 0x30, 0x6a, 0xe2, 0x66, 0xcc,
+ 0xf9, 0x0b, 0xc1, 0x1e, 0xe4, 0x6d, 0x51, 0x3b
}
};
static const unsigned char aes_128_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_AES_BLOCK_SIZE] = {
{
- 0xbb, 0x1d, 0x69, 0x29, 0xe9, 0x59, 0x37, 0x28,
- 0x7f, 0xa3, 0x7d, 0x12, 0x9b, 0x75, 0x67, 0x46
+ /* Example #1 */
+ 0xbb, 0x1d, 0x69, 0x29, 0xe9, 0x59, 0x37, 0x28,
+ 0x7f, 0xa3, 0x7d, 0x12, 0x9b, 0x75, 0x67, 0x46
},
{
- 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44,
- 0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c
+ /* Example #2 */
+ 0x07, 0x0a, 0x16, 0xb4, 0x6b, 0x4d, 0x41, 0x44,
+ 0xf7, 0x9b, 0xdd, 0x9d, 0xd0, 0x4a, 0x28, 0x7c
},
{
- 0xdf, 0xa6, 0x67, 0x47, 0xde, 0x9a, 0xe6, 0x30,
- 0x30, 0xca, 0x32, 0x61, 0x14, 0x97, 0xc8, 0x27
+ /* Example #3 */
+ 0x7d, 0x85, 0x44, 0x9e, 0xa6, 0xea, 0x19, 0xc8,
+ 0x23, 0xa7, 0xbf, 0x78, 0x83, 0x7d, 0xfa, 0xde
},
{
- 0x51, 0xf0, 0xbe, 0xbf, 0x7e, 0x3b, 0x9d, 0x92,
- 0xfc, 0x49, 0x74, 0x17, 0x79, 0x36, 0x3c, 0xfe
+ /* Example #4 */
+ 0x51, 0xf0, 0xbe, 0xbf, 0x7e, 0x3b, 0x9d, 0x92,
+ 0xfc, 0x49, 0x74, 0x17, 0x79, 0x36, 0x3c, 0xfe
}
};
-/* AES 192 CMAC Test Data */
+/* CMAC-AES192 Test Data */
static const unsigned char aes_192_key[24] = {
- 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
- 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
- 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b
+ 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52,
+ 0xc8, 0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5,
+ 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b
};
static const unsigned char aes_192_subkeys[2][MBEDTLS_AES_BLOCK_SIZE] = {
{
- 0x44, 0x8a, 0x5b, 0x1c, 0x93, 0x51, 0x4b, 0x27,
- 0x3e, 0xe6, 0x43, 0x9d, 0xd4, 0xda, 0xa2, 0x96
+ /* K1 */
+ 0x44, 0x8a, 0x5b, 0x1c, 0x93, 0x51, 0x4b, 0x27,
+ 0x3e, 0xe6, 0x43, 0x9d, 0xd4, 0xda, 0xa2, 0x96
},
{
- 0x89, 0x14, 0xb6, 0x39, 0x26, 0xa2, 0x96, 0x4e,
- 0x7d, 0xcc, 0x87, 0x3b, 0xa9, 0xb5, 0x45, 0x2c
+ /* K2 */
+ 0x89, 0x14, 0xb6, 0x39, 0x26, 0xa2, 0x96, 0x4e,
+ 0x7d, 0xcc, 0x87, 0x3b, 0xa9, 0xb5, 0x45, 0x2c
}
};
static const unsigned char aes_192_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_AES_BLOCK_SIZE] = {
{
- 0xd1, 0x7d, 0xdf, 0x46, 0xad, 0xaa, 0xcd, 0xe5,
- 0x31, 0xca, 0xc4, 0x83, 0xde, 0x7a, 0x93, 0x67
+ /* Example #1 */
+ 0xd1, 0x7d, 0xdf, 0x46, 0xad, 0xaa, 0xcd, 0xe5,
+ 0x31, 0xca, 0xc4, 0x83, 0xde, 0x7a, 0x93, 0x67
},
{
- 0x9e, 0x99, 0xa7, 0xbf, 0x31, 0xe7, 0x10, 0x90,
- 0x06, 0x62, 0xf6, 0x5e, 0x61, 0x7c, 0x51, 0x84
+ /* Example #2 */
+ 0x9e, 0x99, 0xa7, 0xbf, 0x31, 0xe7, 0x10, 0x90,
+ 0x06, 0x62, 0xf6, 0x5e, 0x61, 0x7c, 0x51, 0x84
},
{
- 0x8a, 0x1d, 0xe5, 0xbe, 0x2e, 0xb3, 0x1a, 0xad,
- 0x08, 0x9a, 0x82, 0xe6, 0xee, 0x90, 0x8b, 0x0e
+ /* Example #3 */
+ 0x3d, 0x75, 0xc1, 0x94, 0xed, 0x96, 0x07, 0x04,
+ 0x44, 0xa9, 0xfa, 0x7e, 0xc7, 0x40, 0xec, 0xf8
},
{
- 0xa1, 0xd5, 0xdf, 0x0e, 0xed, 0x79, 0x0f, 0x79,
- 0x4d, 0x77, 0x58, 0x96, 0x59, 0xf3, 0x9a, 0x11
+ /* Example #4 */
+ 0xa1, 0xd5, 0xdf, 0x0e, 0xed, 0x79, 0x0f, 0x79,
+ 0x4d, 0x77, 0x58, 0x96, 0x59, 0xf3, 0x9a, 0x11
}
};
-/* AES 256 CMAC Test Data */
+/* CMAC-AES256 Test Data */
static const unsigned char aes_256_key[32] = {
- 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
- 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
- 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
- 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4
+ 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
+ 0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
+ 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
+ 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4
};
static const unsigned char aes_256_subkeys[2][MBEDTLS_AES_BLOCK_SIZE] = {
{
- 0xca, 0xd1, 0xed, 0x03, 0x29, 0x9e, 0xed, 0xac,
- 0x2e, 0x9a, 0x99, 0x80, 0x86, 0x21, 0x50, 0x2f
+ /* K1 */
+ 0xca, 0xd1, 0xed, 0x03, 0x29, 0x9e, 0xed, 0xac,
+ 0x2e, 0x9a, 0x99, 0x80, 0x86, 0x21, 0x50, 0x2f
},
{
- 0x95, 0xa3, 0xda, 0x06, 0x53, 0x3d, 0xdb, 0x58,
- 0x5d, 0x35, 0x33, 0x01, 0x0c, 0x42, 0xa0, 0xd9
+ /* K2 */
+ 0x95, 0xa3, 0xda, 0x06, 0x53, 0x3d, 0xdb, 0x58,
+ 0x5d, 0x35, 0x33, 0x01, 0x0c, 0x42, 0xa0, 0xd9
}
};
static const unsigned char aes_256_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_AES_BLOCK_SIZE] = {
{
- 0x02, 0x89, 0x62, 0xf6, 0x1b, 0x7b, 0xf8, 0x9e,
- 0xfc, 0x6b, 0x55, 0x1f, 0x46, 0x67, 0xd9, 0x83
+ /* Example #1 */
+ 0x02, 0x89, 0x62, 0xf6, 0x1b, 0x7b, 0xf8, 0x9e,
+ 0xfc, 0x6b, 0x55, 0x1f, 0x46, 0x67, 0xd9, 0x83
},
{
- 0x28, 0xa7, 0x02, 0x3f, 0x45, 0x2e, 0x8f, 0x82,
- 0xbd, 0x4b, 0xf2, 0x8d, 0x8c, 0x37, 0xc3, 0x5c
+ /* Example #2 */
+ 0x28, 0xa7, 0x02, 0x3f, 0x45, 0x2e, 0x8f, 0x82,
+ 0xbd, 0x4b, 0xf2, 0x8d, 0x8c, 0x37, 0xc3, 0x5c
},
{
- 0xaa, 0xf3, 0xd8, 0xf1, 0xde, 0x56, 0x40, 0xc2,
- 0x32, 0xf5, 0xb1, 0x69, 0xb9, 0xc9, 0x11, 0xe6
+ /* Example #3 */
+ 0x15, 0x67, 0x27, 0xdc, 0x08, 0x78, 0x94, 0x4a,
+ 0x02, 0x3c, 0x1f, 0xe0, 0x3b, 0xad, 0x6d, 0x93
},
{
- 0xe1, 0x99, 0x21, 0x90, 0x54, 0x9f, 0x6e, 0xd5,
- 0x69, 0x6a, 0x2c, 0x05, 0x6c, 0x31, 0x54, 0x10
+ /* Example #4 */
+ 0xe1, 0x99, 0x21, 0x90, 0x54, 0x9f, 0x6e, 0xd5,
+ 0x69, 0x6a, 0x2c, 0x05, 0x6c, 0x31, 0x54, 0x10
}
};
#endif /* MBEDTLS_AES_C */
/* Truncation point of message for 3DES CMAC tests */
static const unsigned int des3_message_lengths[NB_CMAC_TESTS_PER_KEY] = {
0,
- 8,
+ 16,
20,
32
};
-/* 3DES 2 Key CMAC Test Data */
+/* CMAC-TDES (Generation) - 2 Key Test Data */
static const unsigned char des3_2key_key[24] = {
- 0x4c, 0xf1, 0x51, 0x34, 0xa2, 0x85, 0x0d, 0xd5,
- 0x8a, 0x3d, 0x10, 0xba, 0x80, 0x57, 0x0d, 0x38,
- 0x4c, 0xf1, 0x51, 0x34, 0xa2, 0x85, 0x0d, 0xd5
+ /* Key1 */
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
+ /* Key2 */
+ 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xEF, 0x01,
+ /* Key3 */
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef
};
static const unsigned char des3_2key_subkeys[2][8] = {
{
- 0x8e, 0xcf, 0x37, 0x3e, 0xd7, 0x1a, 0xfa, 0xef
+ /* K1 */
+ 0x0d, 0xd2, 0xcb, 0x7a, 0x3d, 0x88, 0x88, 0xd9
},
{
- 0x1d, 0x9e, 0x6e, 0x7d, 0xae, 0x35, 0xf5, 0xc5
+ /* K2 */
+ 0x1b, 0xa5, 0x96, 0xf4, 0x7b, 0x11, 0x11, 0xb2
}
};
static const unsigned char des3_2key_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_DES3_BLOCK_SIZE] = {
{
- 0xbd, 0x2e, 0xbf, 0x9a, 0x3b, 0xa0, 0x03, 0x61
+ /* Sample #1 */
+ 0x79, 0xce, 0x52, 0xa7, 0xf7, 0x86, 0xa9, 0x60
},
{
- 0x4f, 0xf2, 0xab, 0x81, 0x3c, 0x53, 0xce, 0x83
+ /* Sample #2 */
+ 0xcc, 0x18, 0xa0, 0xb7, 0x9a, 0xf2, 0x41, 0x3b
},
{
- 0x62, 0xdd, 0x1b, 0x47, 0x19, 0x02, 0xbd, 0x4e
+ /* Sample #3 */
+ 0xc0, 0x6d, 0x37, 0x7e, 0xcd, 0x10, 0x19, 0x69
},
{
- 0x31, 0xb1, 0xe4, 0x31, 0xda, 0xbc, 0x4e, 0xb8
+ /* Sample #4 */
+ 0x9c, 0xd3, 0x35, 0x80, 0xf9, 0xb6, 0x4d, 0xfb
}
};
-/* 3DES 3 Key CMAC Test Data */
+/* CMAC-TDES (Generation) - 3 Key Test Data */
static const unsigned char des3_3key_key[24] = {
- 0x8a, 0xa8, 0x3b, 0xf8, 0xcb, 0xda, 0x10, 0x62,
- 0x0b, 0xc1, 0xbf, 0x19, 0xfb, 0xb6, 0xcd, 0x58,
- 0xbc, 0x31, 0x3d, 0x4a, 0x37, 0x1c, 0xa8, 0xb5
+ /* Key1 */
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xaa, 0xcd, 0xef,
+ /* Key2 */
+ 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01,
+ /* Key3 */
+ 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23
};
static const unsigned char des3_3key_subkeys[2][8] = {
{
- 0x91, 0x98, 0xe9, 0xd3, 0x14, 0xe6, 0x53, 0x5f
+ /* K1 */
+ 0x9d, 0x74, 0xe7, 0x39, 0x33, 0x17, 0x96, 0xc0
},
{
- 0x23, 0x31, 0xd3, 0xa6, 0x29, 0xcc, 0xa6, 0xa5
+ /* K2 */
+ 0x3a, 0xe9, 0xce, 0x72, 0x66, 0x2f, 0x2d, 0x9b
}
};
static const unsigned char des3_3key_expected_result[NB_CMAC_TESTS_PER_KEY][MBEDTLS_DES3_BLOCK_SIZE] = {
{
- 0xb7, 0xa6, 0x88, 0xe1, 0x22, 0xff, 0xaf, 0x95
+ /* Sample #1 */
+ 0x7d, 0xb0, 0xd3, 0x7d, 0xf9, 0x36, 0xc5, 0x50
},
{
- 0x8e, 0x8f, 0x29, 0x31, 0x36, 0x28, 0x37, 0x97
+ /* Sample #2 */
+ 0x30, 0x23, 0x9c, 0xf1, 0xf5, 0x2e, 0x66, 0x09
},
{
- 0x74, 0x3d, 0xdb, 0xe0, 0xce, 0x2d, 0xc2, 0xed
+ /* Sample #3 */
+ 0x6c, 0x9f, 0x3e, 0xe4, 0x92, 0x3f, 0x6b, 0xe2
},
{
- 0x33, 0xe6, 0xb1, 0x09, 0x24, 0x00, 0xea, 0xe5
+ /* Sample #4 */
+ 0x99, 0x42, 0x9b, 0xd0, 0xbF, 0x79, 0x04, 0xe5
}
};
#if defined(MBEDTLS_AES_C)
/* AES AES-CMAC-PRF-128 Test Data */
static const unsigned char PRFK[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ /* Key */
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0xed, 0xcb
};
10
};
-/* PRF M */
+/* Message */
static const unsigned char PRFM[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13
};
static const unsigned char PRFT[NB_PRF_TESTS][16] = {
{
- 0x84, 0xa3, 0x48, 0xa4, 0xa4, 0x5d, 0x23, 0x5b,
- 0xab, 0xff, 0xfc, 0x0d, 0x2b, 0x4d, 0xa0, 0x9a
+ 0x84, 0xa3, 0x48, 0xa4, 0xa4, 0x5d, 0x23, 0x5b,
+ 0xab, 0xff, 0xfc, 0x0d, 0x2b, 0x4d, 0xa0, 0x9a
},
{
- 0x98, 0x0a, 0xe8, 0x7b, 0x5f, 0x4c, 0x9c, 0x52,
- 0x14, 0xf5, 0xb6, 0xa8, 0x45, 0x5e, 0x4c, 0x2d
+ 0x98, 0x0a, 0xe8, 0x7b, 0x5f, 0x4c, 0x9c, 0x52,
+ 0x14, 0xf5, 0xb6, 0xa8, 0x45, 0x5e, 0x4c, 0x2d
},
{
- 0x29, 0x0d, 0x9e, 0x11, 0x2e, 0xdb, 0x09, 0xee,
- 0x14, 0x1f, 0xcf, 0x64, 0xc0, 0xb7, 0x2f, 0x3d
+ 0x29, 0x0d, 0x9e, 0x11, 0x2e, 0xdb, 0x09, 0xee,
+ 0x14, 0x1f, 0xcf, 0x64, 0xc0, 0xb7, 0x2f, 0x3d
}
};
#endif /* MBEDTLS_AES_C */
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
- * The NIST SP 800-90 DRBGs are described in the following publucation.
+ * The NIST SP 800-90 DRBGs are described in the following publication.
*
* http://csrc.nist.gov/publications/nistpubs/800-90/SP800-90revised_March2007.pdf
*/
/*
* Initialize with an empty key
*/
- mbedtls_aes_setkey_enc( &ctx->aes_ctx, key, MBEDTLS_CTR_DRBG_KEYBITS );
+ if( ( ret = mbedtls_aes_setkey_enc( &ctx->aes_ctx, key, MBEDTLS_CTR_DRBG_KEYBITS ) ) != 0 )
+ {
+ return( ret );
+ }
if( ( ret = mbedtls_ctr_drbg_reseed( ctx, custom, len ) ) != 0 )
+ {
return( ret );
-
+ }
return( 0 );
}
unsigned char chain[MBEDTLS_CTR_DRBG_BLOCKSIZE];
unsigned char *p, *iv;
mbedtls_aes_context aes_ctx;
+ int ret = 0;
int i, j;
size_t buf_len, use_len;
for( i = 0; i < MBEDTLS_CTR_DRBG_KEYSIZE; i++ )
key[i] = i;
- mbedtls_aes_setkey_enc( &aes_ctx, key, MBEDTLS_CTR_DRBG_KEYBITS );
+ if( ( ret = mbedtls_aes_setkey_enc( &aes_ctx, key, MBEDTLS_CTR_DRBG_KEYBITS ) ) != 0 )
+ {
+ goto exit;
+ }
/*
* Reduce data to MBEDTLS_CTR_DRBG_SEEDLEN bytes of data
use_len -= ( use_len >= MBEDTLS_CTR_DRBG_BLOCKSIZE ) ?
MBEDTLS_CTR_DRBG_BLOCKSIZE : use_len;
- mbedtls_aes_crypt_ecb( &aes_ctx, MBEDTLS_AES_ENCRYPT, chain, chain );
+ if( ( ret = mbedtls_aes_crypt_ecb( &aes_ctx, MBEDTLS_AES_ENCRYPT, chain, chain ) ) != 0 )
+ {
+ goto exit;
+ }
}
memcpy( tmp + j, chain, MBEDTLS_CTR_DRBG_BLOCKSIZE );
/*
* Do final encryption with reduced data
*/
- mbedtls_aes_setkey_enc( &aes_ctx, tmp, MBEDTLS_CTR_DRBG_KEYBITS );
+ if( ( ret = mbedtls_aes_setkey_enc( &aes_ctx, tmp, MBEDTLS_CTR_DRBG_KEYBITS ) ) != 0 )
+ {
+ goto exit;
+ }
iv = tmp + MBEDTLS_CTR_DRBG_KEYSIZE;
p = output;
for( j = 0; j < MBEDTLS_CTR_DRBG_SEEDLEN; j += MBEDTLS_CTR_DRBG_BLOCKSIZE )
{
- mbedtls_aes_crypt_ecb( &aes_ctx, MBEDTLS_AES_ENCRYPT, iv, iv );
+ if( ( ret = mbedtls_aes_crypt_ecb( &aes_ctx, MBEDTLS_AES_ENCRYPT, iv, iv ) ) != 0 )
+ {
+ goto exit;
+ }
memcpy( p, iv, MBEDTLS_CTR_DRBG_BLOCKSIZE );
p += MBEDTLS_CTR_DRBG_BLOCKSIZE;
}
-
+exit:
mbedtls_aes_free( &aes_ctx );
+ /*
+ * tidy up the stack
+ */
+ mbedtls_zeroize( buf, sizeof( buf ) );
+ mbedtls_zeroize( tmp, sizeof( tmp ) );
+ mbedtls_zeroize( key, sizeof( key ) );
+ mbedtls_zeroize( chain, sizeof( chain ) );
+ if( 0 != ret )
+ {
+ /*
+ * wipe partial seed from memory
+ */
+ mbedtls_zeroize( output, MBEDTLS_CTR_DRBG_SEEDLEN );
+ }
- return( 0 );
+ return( ret );
}
static int ctr_drbg_update_internal( mbedtls_ctr_drbg_context *ctx,
unsigned char tmp[MBEDTLS_CTR_DRBG_SEEDLEN];
unsigned char *p = tmp;
int i, j;
+ int ret = 0;
memset( tmp, 0, MBEDTLS_CTR_DRBG_SEEDLEN );
/*
* Crypt counter block
*/
- mbedtls_aes_crypt_ecb( &ctx->aes_ctx, MBEDTLS_AES_ENCRYPT, ctx->counter, p );
+ if( ( ret = mbedtls_aes_crypt_ecb( &ctx->aes_ctx, MBEDTLS_AES_ENCRYPT, ctx->counter, p ) ) != 0 )
+ {
+ return( ret );
+ }
p += MBEDTLS_CTR_DRBG_BLOCKSIZE;
}
/*
* Update key and counter
*/
- mbedtls_aes_setkey_enc( &ctx->aes_ctx, tmp, MBEDTLS_CTR_DRBG_KEYBITS );
+ if( ( ret = mbedtls_aes_setkey_enc( &ctx->aes_ctx, tmp, MBEDTLS_CTR_DRBG_KEYBITS ) ) != 0 )
+ {
+ return( ret );
+ }
memcpy( ctx->counter, tmp + MBEDTLS_CTR_DRBG_KEYSIZE, MBEDTLS_CTR_DRBG_BLOCKSIZE );
return( 0 );
{
unsigned char seed[MBEDTLS_CTR_DRBG_MAX_SEED_INPUT];
size_t seedlen = 0;
+ int ret;
- if( ctx->entropy_len + len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT )
+ if( ctx->entropy_len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT ||
+ len > MBEDTLS_CTR_DRBG_MAX_SEED_INPUT - ctx->entropy_len )
return( MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG );
memset( seed, 0, MBEDTLS_CTR_DRBG_MAX_SEED_INPUT );
/*
* Reduce to 384 bits
*/
- block_cipher_df( seed, seed, seedlen );
+ if( ( ret = block_cipher_df( seed, seed, seedlen ) ) != 0 )
+ {
+ return( ret );
+ }
/*
* Update state
*/
- ctr_drbg_update_internal( ctx, seed );
+ if( ( ret = ctr_drbg_update_internal( ctx, seed ) ) != 0 )
+ {
+ return( ret );
+ }
ctx->reseed_counter = 1;
return( 0 );
ctx->prediction_resistance )
{
if( ( ret = mbedtls_ctr_drbg_reseed( ctx, additional, add_len ) ) != 0 )
+ {
return( ret );
-
+ }
add_len = 0;
}
if( add_len > 0 )
{
- block_cipher_df( add_input, additional, add_len );
- ctr_drbg_update_internal( ctx, add_input );
+ if( ( ret = block_cipher_df( add_input, additional, add_len ) ) != 0 )
+ {
+ return( ret );
+ }
+ if( ( ret = ctr_drbg_update_internal( ctx, add_input ) ) != 0 )
+ {
+ return( ret );
+ }
}
while( output_len > 0 )
/*
* Crypt counter block
*/
- mbedtls_aes_crypt_ecb( &ctx->aes_ctx, MBEDTLS_AES_ENCRYPT, ctx->counter, tmp );
+ if( ( ret = mbedtls_aes_crypt_ecb( &ctx->aes_ctx, MBEDTLS_AES_ENCRYPT, ctx->counter, tmp ) ) != 0 )
+ {
+ return( ret );
+ }
use_len = ( output_len > MBEDTLS_CTR_DRBG_BLOCKSIZE ) ? MBEDTLS_CTR_DRBG_BLOCKSIZE :
output_len;
output_len -= use_len;
}
- ctr_drbg_update_internal( ctx, add_input );
+ if( ( ret = ctr_drbg_update_internal( ctx, add_input ) ) != 0 )
+ {
+ return( ret );
+ }
ctx->reseed_counter++;
goto exit;
if( fwrite( buf, 1, MBEDTLS_CTR_DRBG_MAX_INPUT, f ) != MBEDTLS_CTR_DRBG_MAX_INPUT )
- {
ret = MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR;
- goto exit;
- }
-
- ret = 0;
+ else
+ ret = 0;
exit:
+ mbedtls_zeroize( buf, sizeof( buf ) );
+
fclose( f );
return( ret );
}
int mbedtls_ctr_drbg_update_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path )
{
+ int ret = 0;
FILE *f;
size_t n;
unsigned char buf[ MBEDTLS_CTR_DRBG_MAX_INPUT ];
}
if( fread( buf, 1, n, f ) != n )
- {
- fclose( f );
- return( MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR );
- }
+ ret = MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR;
+ else
+ mbedtls_ctr_drbg_update( ctx, buf, n );
fclose( f );
- mbedtls_ctr_drbg_update( ctx, buf, n );
+ mbedtls_zeroize( buf, sizeof( buf ) );
+
+ if( ret != 0 )
+ return( ret );
return( mbedtls_ctr_drbg_write_seed_file( ctx, path ) );
}
*/
#if defined(MBEDTLS_THREADING_C)
char idstr[20 + DEBUG_BUF_SIZE]; /* 0x + 16 nibbles + ': ' */
- mbedtls_snprintf( idstr, sizeof( idstr ), "%p: %s", ssl, str );
+ mbedtls_snprintf( idstr, sizeof( idstr ), "%p: %s", (void*)ssl, str );
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, idstr );
#else
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
va_start( argp, format );
#if defined(_WIN32)
-#if defined(_TRUNCATE)
+#if defined(_TRUNCATE) && !defined(__MINGW32__)
ret = _vsnprintf_s( str, DEBUG_BUF_SIZE, _TRUNCATE, format, argp );
#else
ret = _vsnprintf( str, DEBUG_BUF_SIZE, format, argp );
#define mbedtls_free free
#endif
+#if !defined(MBEDTLS_DHM_ALT)
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
*
* Parameter should be: 2 <= public_param <= P - 2
*
+ * This means that we need to return an error if
+ * public_param < 2 or public_param > P-2
+ *
* For more information on the attack, see:
* http://www.cl.cam.ac.uk/~rja14/Papers/psandqs.pdf
* http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-2643
static int dhm_check_range( const mbedtls_mpi *param, const mbedtls_mpi *P )
{
mbedtls_mpi L, U;
- int ret = MBEDTLS_ERR_DHM_BAD_INPUT_DATA;
+ int ret = 0;
mbedtls_mpi_init( &L ); mbedtls_mpi_init( &U );
MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &L, 2 ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &U, P, 2 ) );
- if( mbedtls_mpi_cmp_mpi( param, &L ) >= 0 &&
- mbedtls_mpi_cmp_mpi( param, &U ) <= 0 )
+ if( mbedtls_mpi_cmp_mpi( param, &L ) < 0 ||
+ mbedtls_mpi_cmp_mpi( param, &U ) > 0 )
{
- ret = 0;
+ ret = MBEDTLS_ERR_DHM_BAD_INPUT_DATA;
}
cleanup:
*/
do
{
- mbedtls_mpi_fill_random( &ctx->X, x_size, f_rng, p_rng );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &ctx->X, x_size, f_rng, p_rng ) );
while( mbedtls_mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 )
MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &ctx->X, 1 ) );
/*
* export P, G, GX
*/
-#define DHM_MPI_EXPORT(X,n) \
- MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( X, p + 2, n ) ); \
- *p++ = (unsigned char)( n >> 8 ); \
- *p++ = (unsigned char)( n ); p += n;
+#define DHM_MPI_EXPORT( X, n ) \
+ do { \
+ MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( ( X ), \
+ p + 2, \
+ ( n ) ) ); \
+ *p++ = (unsigned char)( ( n ) >> 8 ); \
+ *p++ = (unsigned char)( ( n ) ); \
+ p += ( n ); \
+ } while( 0 )
n1 = mbedtls_mpi_size( &ctx->P );
n2 = mbedtls_mpi_size( &ctx->G );
DHM_MPI_EXPORT( &ctx->G , n2 );
DHM_MPI_EXPORT( &ctx->GX, n3 );
- *olen = p - output;
+ *olen = p - output;
ctx->len = n1;
}
/*
+ * Set prime modulus and generator
+ */
+int mbedtls_dhm_set_group( mbedtls_dhm_context *ctx,
+ const mbedtls_mpi *P,
+ const mbedtls_mpi *G )
+{
+ int ret;
+
+ if( ctx == NULL || P == NULL || G == NULL )
+ return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA );
+
+ if( ( ret = mbedtls_mpi_copy( &ctx->P, P ) ) != 0 ||
+ ( ret = mbedtls_mpi_copy( &ctx->G, G ) ) != 0 )
+ {
+ return( MBEDTLS_ERR_DHM_SET_GROUP_FAILED + ret );
+ }
+
+ ctx->len = mbedtls_mpi_size( &ctx->P );
+ return( 0 );
+}
+
+/*
* Import the peer's public value G^Y
*/
int mbedtls_dhm_read_public( mbedtls_dhm_context *ctx,
*/
do
{
- mbedtls_mpi_fill_random( &ctx->X, x_size, f_rng, p_rng );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &ctx->X, x_size, f_rng, p_rng ) );
while( mbedtls_mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 )
MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &ctx->X, 1 ) );
count = 0;
do
{
- mbedtls_mpi_fill_random( &ctx->Vi, mbedtls_mpi_size( &ctx->P ), f_rng, p_rng );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &ctx->Vi, mbedtls_mpi_size( &ctx->P ), f_rng, p_rng ) );
while( mbedtls_mpi_cmp_mpi( &ctx->Vi, &ctx->P ) >= 0 )
MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &ctx->Vi, 1 ) );
*/
void mbedtls_dhm_free( mbedtls_dhm_context *ctx )
{
- mbedtls_mpi_free( &ctx->pX); mbedtls_mpi_free( &ctx->Vf ); mbedtls_mpi_free( &ctx->Vi );
- mbedtls_mpi_free( &ctx->RP ); mbedtls_mpi_free( &ctx->K ); mbedtls_mpi_free( &ctx->GY );
- mbedtls_mpi_free( &ctx->GX ); mbedtls_mpi_free( &ctx->X ); mbedtls_mpi_free( &ctx->G );
- mbedtls_mpi_free( &ctx->P );
+ mbedtls_mpi_free( &ctx->pX ); mbedtls_mpi_free( &ctx->Vf );
+ mbedtls_mpi_free( &ctx->Vi ); mbedtls_mpi_free( &ctx->RP );
+ mbedtls_mpi_free( &ctx->K ); mbedtls_mpi_free( &ctx->GY );
+ mbedtls_mpi_free( &ctx->GX ); mbedtls_mpi_free( &ctx->X );
+ mbedtls_mpi_free( &ctx->G ); mbedtls_mpi_free( &ctx->P );
mbedtls_zeroize( ctx, sizeof( mbedtls_dhm_context ) );
}
if( fread( *buf, 1, *n, f ) != *n )
{
fclose( f );
+
+ mbedtls_zeroize( *buf, *n + 1 );
mbedtls_free( *buf );
+
return( MBEDTLS_ERR_DHM_FILE_IO_ERROR );
}
}
#endif /* MBEDTLS_FS_IO */
#endif /* MBEDTLS_ASN1_PARSE_C */
+#endif /* MBEDTLS_DHM_ALT */
#if defined(MBEDTLS_SELF_TEST)
#include <string.h>
+#if !defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT)
/*
* Generate public key: simple wrapper around mbedtls_ecp_gen_keypair
*/
{
return mbedtls_ecp_gen_keypair( grp, d, Q, f_rng, p_rng );
}
+#endif /* MBEDTLS_ECDH_GEN_PUBLIC_ALT */
+#if !defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT)
/*
* Compute shared secret (SEC1 3.3.1)
*/
return( ret );
}
+#endif /* MBEDTLS_ECDH_COMPUTE_SHARED_ALT */
/*
* Initialize context
return( ret );
}
+#if !defined(MBEDTLS_ECDSA_SIGN_ALT)
/*
* Compute ECDSA signature of a hashed message (SEC1 4.1.3)
* Obviously, compared to SEC1 4.1.3, we skip step 4 (hash message)
if( grp->N.p == NULL )
return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
+ /* Make sure d is in range 1..n-1 */
+ if( mbedtls_mpi_cmp_int( d, 1 ) < 0 || mbedtls_mpi_cmp_mpi( d, &grp->N ) >= 0 )
+ return( MBEDTLS_ERR_ECP_INVALID_KEY );
+
mbedtls_ecp_point_init( &R );
mbedtls_mpi_init( &k ); mbedtls_mpi_init( &e ); mbedtls_mpi_init( &t );
return( ret );
}
+#endif /* MBEDTLS_ECDSA_SIGN_ALT */
#if defined(MBEDTLS_ECDSA_DETERMINISTIC)
/*
}
#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
+#if !defined(MBEDTLS_ECDSA_VERIFY_ALT)
/*
* Verify ECDSA signature of hashed message (SEC1 4.1.4)
* Obviously, compared to SEC1 4.1.3, we skip step 2 (hash message)
return( ret );
}
+#endif /* MBEDTLS_ECDSA_VERIFY_ALT */
/*
* Convert a signature (given by context) to ASN.1
return( ret );
}
+#if !defined(MBEDTLS_ECDSA_GENKEY_ALT)
/*
* Generate key pair
*/
return( mbedtls_ecp_group_load( &ctx->grp, gid ) ||
mbedtls_ecp_gen_keypair( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) );
}
+#endif /* MBEDTLS_ECDSA_GENKEY_ALT */
/*
* Set context from an mbedtls_ecp_keypair
#include <string.h>
+#if !defined(MBEDTLS_ECJPAKE_ALT)
+
/*
* Convert a mbedtls_ecjpake_role to identifier string
*/
#undef ID_MINE
#undef ID_PEER
+#endif /* ! MBEDTLS_ECJPAKE_ALT */
#if defined(MBEDTLS_SELF_TEST)
#if defined(MBEDTLS_ECP_C)
#include "mbedtls/ecp.h"
+#include "mbedtls/threading.h"
#include <string.h>
+#if !defined(MBEDTLS_ECP_ALT)
+
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#define mbedtls_free free
#endif
+#include "mbedtls/ecp_internal.h"
+
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
!defined(inline) && !defined(__cplusplus)
#define inline __inline
if( mbedtls_mpi_cmp_int( &pt->Z, 0 ) == 0 )
return( 0 );
+#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT)
+ if ( mbedtls_internal_ecp_grp_capable( grp ) )
+ {
+ return mbedtls_internal_ecp_normalize_jac( grp, pt );
+ }
+#endif /* MBEDTLS_ECP_NORMALIZE_JAC_ALT */
mbedtls_mpi_init( &Zi ); mbedtls_mpi_init( &ZZi );
/*
if( t_len < 2 )
return( ecp_normalize_jac( grp, *T ) );
+#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT)
+ if ( mbedtls_internal_ecp_grp_capable( grp ) )
+ {
+ return mbedtls_internal_ecp_normalize_jac_many(grp, T, t_len);
+ }
+#endif
+
if( ( c = mbedtls_calloc( t_len, sizeof( mbedtls_mpi ) ) ) == NULL )
return( MBEDTLS_ERR_ECP_ALLOC_FAILED );
dbl_count++;
#endif
+#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT)
+ if ( mbedtls_internal_ecp_grp_capable( grp ) )
+ {
+ return mbedtls_internal_ecp_double_jac( grp, R, P );
+ }
+#endif /* MBEDTLS_ECP_DOUBLE_JAC_ALT */
+
mbedtls_mpi_init( &M ); mbedtls_mpi_init( &S ); mbedtls_mpi_init( &T ); mbedtls_mpi_init( &U );
/* Special case for A = -3 */
add_count++;
#endif
+#if defined(MBEDTLS_ECP_ADD_MIXED_ALT)
+ if ( mbedtls_internal_ecp_grp_capable( grp ) )
+ {
+ return mbedtls_internal_ecp_add_mixed( grp, R, P, Q );
+ }
+#endif /* MBEDTLS_ECP_ADD_MIXED_ALT */
+
/*
* Trivial cases: P == 0 or Q == 0 (case 1)
*/
{
int ret;
mbedtls_mpi l, ll;
- size_t p_size = ( grp->pbits + 7 ) / 8;
+ size_t p_size;
int count = 0;
+#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT)
+ if ( mbedtls_internal_ecp_grp_capable( grp ) )
+ {
+ return mbedtls_internal_ecp_randomize_jac( grp, pt, f_rng, p_rng );
+ }
+#endif /* MBEDTLS_ECP_RANDOMIZE_JAC_ALT */
+
+ p_size = ( grp->pbits + 7 ) / 8;
mbedtls_mpi_init( &l ); mbedtls_mpi_init( &ll );
/* Generate l such that 1 < l < p */
do
{
- mbedtls_mpi_fill_random( &l, p_size, f_rng, p_rng );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &l, p_size, f_rng, p_rng ) );
while( mbedtls_mpi_cmp_mpi( &l, &grp->P ) >= 0 )
MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &l, 1 ) );
MBEDTLS_MPI_CHK( ecp_normalize_jac_many( grp, TT, k ) );
cleanup:
+
return( ret );
}
}
cleanup:
+
mbedtls_ecp_point_free( &Txi );
return( ret );
{
int ret;
+#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT)
+ if ( mbedtls_internal_ecp_grp_capable( grp ) )
+ {
+ return mbedtls_internal_ecp_normalize_mxz( grp, P );
+ }
+#endif /* MBEDTLS_ECP_NORMALIZE_MXZ_ALT */
+
MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &P->Z, &P->Z, &grp->P ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &P->X, &P->X, &P->Z ) ); MOD_MUL( P->X );
MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &P->Z, 1 ) );
{
int ret;
mbedtls_mpi l;
- size_t p_size = ( grp->pbits + 7 ) / 8;
+ size_t p_size;
int count = 0;
+#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT)
+ if ( mbedtls_internal_ecp_grp_capable( grp ) )
+ {
+ return mbedtls_internal_ecp_randomize_mxz( grp, P, f_rng, p_rng );
+ }
+#endif /* MBEDTLS_ECP_RANDOMIZE_MXZ_ALT */
+
+ p_size = ( grp->pbits + 7 ) / 8;
mbedtls_mpi_init( &l );
/* Generate l such that 1 < l < p */
do
{
- mbedtls_mpi_fill_random( &l, p_size, f_rng, p_rng );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &l, p_size, f_rng, p_rng ) );
while( mbedtls_mpi_cmp_mpi( &l, &grp->P ) >= 0 )
MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &l, 1 ) );
int ret;
mbedtls_mpi A, AA, B, BB, E, C, D, DA, CB;
+#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT)
+ if ( mbedtls_internal_ecp_grp_capable( grp ) )
+ {
+ return mbedtls_internal_ecp_double_add_mxz( grp, R, S, P, Q, d );
+ }
+#endif /* MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT */
+
mbedtls_mpi_init( &A ); mbedtls_mpi_init( &AA ); mbedtls_mpi_init( &B );
mbedtls_mpi_init( &BB ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &C );
mbedtls_mpi_init( &D ); mbedtls_mpi_init( &DA ); mbedtls_mpi_init( &CB );
const mbedtls_mpi *m, const mbedtls_ecp_point *P,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
- int ret;
+ int ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
+#if defined(MBEDTLS_ECP_INTERNAL_ALT)
+ char is_grp_capable = 0;
+#endif
/* Common sanity checks */
if( mbedtls_mpi_cmp_int( &P->Z, 1 ) != 0 )
( ret = mbedtls_ecp_check_pubkey( grp, P ) ) != 0 )
return( ret );
+#if defined(MBEDTLS_ECP_INTERNAL_ALT)
+ if ( is_grp_capable = mbedtls_internal_ecp_grp_capable( grp ) )
+ {
+ MBEDTLS_MPI_CHK( mbedtls_internal_ecp_init( grp ) );
+ }
+
+#endif /* MBEDTLS_ECP_INTERNAL_ALT */
#if defined(ECP_MONTGOMERY)
if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY )
- return( ecp_mul_mxz( grp, R, m, P, f_rng, p_rng ) );
+ ret = ecp_mul_mxz( grp, R, m, P, f_rng, p_rng );
+
#endif
#if defined(ECP_SHORTWEIERSTRASS)
if( ecp_get_type( grp ) == ECP_TYPE_SHORT_WEIERSTRASS )
- return( ecp_mul_comb( grp, R, m, P, f_rng, p_rng ) );
+ ret = ecp_mul_comb( grp, R, m, P, f_rng, p_rng );
+
#endif
- return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
+#if defined(MBEDTLS_ECP_INTERNAL_ALT)
+cleanup:
+
+ if ( is_grp_capable )
+ {
+ mbedtls_internal_ecp_free( grp );
+ }
+
+#endif /* MBEDTLS_ECP_INTERNAL_ALT */
+ return( ret );
}
#if defined(ECP_SHORTWEIERSTRASS)
{
int ret;
mbedtls_ecp_point mP;
+#if defined(MBEDTLS_ECP_INTERNAL_ALT)
+ char is_grp_capable = 0;
+#endif
if( ecp_get_type( grp ) != ECP_TYPE_SHORT_WEIERSTRASS )
return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE );
MBEDTLS_MPI_CHK( mbedtls_ecp_mul_shortcuts( grp, &mP, m, P ) );
MBEDTLS_MPI_CHK( mbedtls_ecp_mul_shortcuts( grp, R, n, Q ) );
+#if defined(MBEDTLS_ECP_INTERNAL_ALT)
+ if ( is_grp_capable = mbedtls_internal_ecp_grp_capable( grp ) )
+ {
+ MBEDTLS_MPI_CHK( mbedtls_internal_ecp_init( grp ) );
+ }
+
+#endif /* MBEDTLS_ECP_INTERNAL_ALT */
MBEDTLS_MPI_CHK( ecp_add_mixed( grp, R, &mP, R ) );
MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) );
cleanup:
+
+#if defined(MBEDTLS_ECP_INTERNAL_ALT)
+ if ( is_grp_capable )
+ {
+ mbedtls_internal_ecp_free( grp );
+ }
+
+#endif /* MBEDTLS_ECP_INTERNAL_ALT */
mbedtls_ecp_point_free( &mP );
return( ret );
{
/* SEC1 3.2.1: Generate d such that 1 <= n < N */
int count = 0;
- unsigned char rnd[MBEDTLS_ECP_MAX_BYTES];
/*
* Match the procedure given in RFC 6979 (deterministic ECDSA):
*/
do
{
- MBEDTLS_MPI_CHK( f_rng( p_rng, rnd, n_size ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( d, rnd, n_size ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( d, n_size, f_rng, p_rng ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( d, 8 * n_size - grp->nbits ) );
/*
#endif /* MBEDTLS_SELF_TEST */
+#endif /* !MBEDTLS_ECP_ALT */
+
#endif /* MBEDTLS_ECP_C */
#include <string.h>
+#if !defined(MBEDTLS_ECP_ALT)
+
#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
!defined(inline) && !defined(__cplusplus)
#define inline __inline
int ret;
size_t i;
mbedtls_mpi M, R;
- mbedtls_mpi_uint Mp[P_KOBLITZ_MAX + P_KOBLITZ_R];
+ mbedtls_mpi_uint Mp[P_KOBLITZ_MAX + P_KOBLITZ_R + 1];
if( N->n < p_limbs )
return( 0 );
memcpy( Mp, N->p + p_limbs - adjust, M.n * sizeof( mbedtls_mpi_uint ) );
if( shift != 0 )
MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &M, shift ) );
- M.n += R.n - adjust; /* Make room for multiplication by R */
+ M.n += R.n; /* Make room for multiplication by R */
/* N = A0 */
if( mask != 0 )
memcpy( Mp, N->p + p_limbs - adjust, M.n * sizeof( mbedtls_mpi_uint ) );
if( shift != 0 )
MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &M, shift ) );
- M.n += R.n - adjust; /* Make room for multiplication by R */
+ M.n += R.n; /* Make room for multiplication by R */
/* N = A0 */
if( mask != 0 )
}
#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */
+#endif /* !MBEDTLS_ECP_ALT */
+
#endif /* MBEDTLS_ECP_C */
void mbedtls_entropy_init( mbedtls_entropy_context *ctx )
{
- memset( ctx, 0, sizeof(mbedtls_entropy_context) );
+ ctx->source_count = 0;
+ memset( ctx->source, 0, sizeof( ctx->source ) );
#if defined(MBEDTLS_THREADING_C)
mbedtls_mutex_init( &ctx->mutex );
#endif
+ ctx->accumulator_started = 0;
#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
- mbedtls_sha512_starts( &ctx->accumulator, 0 );
+ mbedtls_sha512_init( &ctx->accumulator );
#else
- mbedtls_sha256_starts( &ctx->accumulator, 0 );
+ mbedtls_sha256_init( &ctx->accumulator );
#endif
#if defined(MBEDTLS_HAVEGE_C)
mbedtls_havege_init( &ctx->havege_data );
#endif
+ /* Reminder: Update ENTROPY_HAVE_STRONG in the test files
+ * when adding more strong entropy sources here. */
+
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
mbedtls_entropy_add_source( ctx, mbedtls_null_entropy_poll, NULL,
1, MBEDTLS_ENTROPY_SOURCE_STRONG );
mbedtls_entropy_add_source( ctx, mbedtls_nv_seed_poll, NULL,
MBEDTLS_ENTROPY_BLOCK_SIZE,
MBEDTLS_ENTROPY_SOURCE_STRONG );
+ ctx->initial_entropy_run = 0;
#endif
#endif /* MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES */
}
#if defined(MBEDTLS_THREADING_C)
mbedtls_mutex_free( &ctx->mutex );
#endif
- mbedtls_zeroize( ctx, sizeof( mbedtls_entropy_context ) );
+#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
+ mbedtls_sha512_free( &ctx->accumulator );
+#else
+ mbedtls_sha256_free( &ctx->accumulator );
+#endif
+#if defined(MBEDTLS_ENTROPY_NV_SEED)
+ ctx->initial_entropy_run = 0;
+#endif
+ ctx->source_count = 0;
+ mbedtls_zeroize( ctx->source, sizeof( ctx->source ) );
+ ctx->accumulator_started = 0;
}
int mbedtls_entropy_add_source( mbedtls_entropy_context *ctx,
mbedtls_entropy_f_source_ptr f_source, void *p_source,
size_t threshold, int strong )
{
- int index, ret = 0;
+ int idx, ret = 0;
#if defined(MBEDTLS_THREADING_C)
if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
return( ret );
#endif
- index = ctx->source_count;
- if( index >= MBEDTLS_ENTROPY_MAX_SOURCES )
+ idx = ctx->source_count;
+ if( idx >= MBEDTLS_ENTROPY_MAX_SOURCES )
{
ret = MBEDTLS_ERR_ENTROPY_MAX_SOURCES;
goto exit;
}
- ctx->source[index].f_source = f_source;
- ctx->source[index].p_source = p_source;
- ctx->source[index].threshold = threshold;
- ctx->source[index].strong = strong;
+ ctx->source[idx].f_source = f_source;
+ ctx->source[idx].p_source = p_source;
+ ctx->source[idx].threshold = threshold;
+ ctx->source[idx].strong = strong;
ctx->source_count++;
unsigned char tmp[MBEDTLS_ENTROPY_BLOCK_SIZE];
size_t use_len = len;
const unsigned char *p = data;
+ int ret = 0;
if( use_len > MBEDTLS_ENTROPY_BLOCK_SIZE )
{
#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
- mbedtls_sha512( data, len, tmp, 0 );
+ if( ( ret = mbedtls_sha512_ret( data, len, tmp, 0 ) ) != 0 )
+ goto cleanup;
#else
- mbedtls_sha256( data, len, tmp, 0 );
+ if( ( ret = mbedtls_sha256_ret( data, len, tmp, 0 ) ) != 0 )
+ goto cleanup;
#endif
p = tmp;
use_len = MBEDTLS_ENTROPY_BLOCK_SIZE;
header[0] = source_id;
header[1] = use_len & 0xFF;
+ /*
+ * Start the accumulator if this has not already happened. Note that
+ * it is sufficient to start the accumulator here only because all calls to
+ * gather entropy eventually execute this code.
+ */
#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
- mbedtls_sha512_update( &ctx->accumulator, header, 2 );
- mbedtls_sha512_update( &ctx->accumulator, p, use_len );
+ if( ctx->accumulator_started == 0 &&
+ ( ret = mbedtls_sha512_starts_ret( &ctx->accumulator, 0 ) ) != 0 )
+ goto cleanup;
+ else
+ ctx->accumulator_started = 1;
+ if( ( ret = mbedtls_sha512_update_ret( &ctx->accumulator, header, 2 ) ) != 0 )
+ goto cleanup;
+ ret = mbedtls_sha512_update_ret( &ctx->accumulator, p, use_len );
#else
- mbedtls_sha256_update( &ctx->accumulator, header, 2 );
- mbedtls_sha256_update( &ctx->accumulator, p, use_len );
+ if( ctx->accumulator_started == 0 &&
+ ( ret = mbedtls_sha256_starts_ret( &ctx->accumulator, 0 ) ) != 0 )
+ goto cleanup;
+ else
+ ctx->accumulator_started = 1;
+ if( ( ret = mbedtls_sha256_update_ret( &ctx->accumulator, header, 2 ) ) != 0 )
+ goto cleanup;
+ ret = mbedtls_sha256_update_ret( &ctx->accumulator, p, use_len );
#endif
- return( 0 );
+cleanup:
+ mbedtls_zeroize( tmp, sizeof( tmp ) );
+
+ return( ret );
}
int mbedtls_entropy_update_manual( mbedtls_entropy_context *ctx,
if( ( ret = ctx->source[i].f_source( ctx->source[i].p_source,
buf, MBEDTLS_ENTROPY_MAX_GATHER, &olen ) ) != 0 )
{
- return( ret );
+ goto cleanup;
}
/*
*/
if( olen > 0 )
{
- entropy_update( ctx, (unsigned char) i, buf, olen );
+ if( ( ret = entropy_update( ctx, (unsigned char) i,
+ buf, olen ) ) != 0 )
+ return( ret );
ctx->source[i].size += olen;
}
}
if( have_one_strong == 0 )
- return( MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE );
+ ret = MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE;
- return( 0 );
+cleanup:
+ mbedtls_zeroize( buf, sizeof( buf ) );
+
+ return( ret );
}
/*
memset( buf, 0, MBEDTLS_ENTROPY_BLOCK_SIZE );
#if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
- mbedtls_sha512_finish( &ctx->accumulator, buf );
+ /*
+ * Note that at this stage it is assumed that the accumulator was started
+ * in a previous call to entropy_update(). If this is not guaranteed, the
+ * code below will fail.
+ */
+ if( ( ret = mbedtls_sha512_finish_ret( &ctx->accumulator, buf ) ) != 0 )
+ goto exit;
/*
* Reset accumulator and counters and recycle existing entropy
*/
- memset( &ctx->accumulator, 0, sizeof( mbedtls_sha512_context ) );
- mbedtls_sha512_starts( &ctx->accumulator, 0 );
- mbedtls_sha512_update( &ctx->accumulator, buf, MBEDTLS_ENTROPY_BLOCK_SIZE );
+ mbedtls_sha512_free( &ctx->accumulator );
+ mbedtls_sha512_init( &ctx->accumulator );
+ if( ( ret = mbedtls_sha512_starts_ret( &ctx->accumulator, 0 ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_sha512_update_ret( &ctx->accumulator, buf,
+ MBEDTLS_ENTROPY_BLOCK_SIZE ) ) != 0 )
+ goto exit;
/*
* Perform second SHA-512 on entropy
*/
- mbedtls_sha512( buf, MBEDTLS_ENTROPY_BLOCK_SIZE, buf, 0 );
+ if( ( ret = mbedtls_sha512_ret( buf, MBEDTLS_ENTROPY_BLOCK_SIZE,
+ buf, 0 ) ) != 0 )
+ goto exit;
#else /* MBEDTLS_ENTROPY_SHA512_ACCUMULATOR */
- mbedtls_sha256_finish( &ctx->accumulator, buf );
+ if( ( ret = mbedtls_sha256_finish_ret( &ctx->accumulator, buf ) ) != 0 )
+ goto exit;
/*
* Reset accumulator and counters and recycle existing entropy
*/
- memset( &ctx->accumulator, 0, sizeof( mbedtls_sha256_context ) );
- mbedtls_sha256_starts( &ctx->accumulator, 0 );
- mbedtls_sha256_update( &ctx->accumulator, buf, MBEDTLS_ENTROPY_BLOCK_SIZE );
+ mbedtls_sha256_free( &ctx->accumulator );
+ mbedtls_sha256_init( &ctx->accumulator );
+ if( ( ret = mbedtls_sha256_starts_ret( &ctx->accumulator, 0 ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_sha256_update_ret( &ctx->accumulator, buf,
+ MBEDTLS_ENTROPY_BLOCK_SIZE ) ) != 0 )
+ goto exit;
/*
* Perform second SHA-256 on entropy
*/
- mbedtls_sha256( buf, MBEDTLS_ENTROPY_BLOCK_SIZE, buf, 0 );
+ if( ( ret = mbedtls_sha256_ret( buf, MBEDTLS_ENTROPY_BLOCK_SIZE,
+ buf, 0 ) ) != 0 )
+ goto exit;
#endif /* MBEDTLS_ENTROPY_SHA512_ACCUMULATOR */
for( i = 0; i < ctx->source_count; i++ )
ret = 0;
exit:
+ mbedtls_zeroize( buf, sizeof( buf ) );
+
#if defined(MBEDTLS_THREADING_C)
if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
return( MBEDTLS_ERR_THREADING_MUTEX_ERROR );
int mbedtls_entropy_update_nv_seed( mbedtls_entropy_context *ctx )
{
int ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR;
- unsigned char buf[ MBEDTLS_ENTROPY_MAX_SEED_SIZE ];
+ unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE];
/* Read new seed and write it to NV */
if( ( ret = mbedtls_entropy_func( ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE ) ) != 0 )
/* Manually update the remaining stream with a separator value to diverge */
memset( buf, 0, MBEDTLS_ENTROPY_BLOCK_SIZE );
- mbedtls_entropy_update_manual( ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE );
+ ret = mbedtls_entropy_update_manual( ctx, buf, MBEDTLS_ENTROPY_BLOCK_SIZE );
- return( 0 );
+ return( ret );
}
#endif /* MBEDTLS_ENTROPY_NV_SEED */
ret = 0;
exit:
+ mbedtls_zeroize( buf, sizeof( buf ) );
+
fclose( f );
return( ret );
}
int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *path )
{
+ int ret = 0;
FILE *f;
size_t n;
unsigned char buf[ MBEDTLS_ENTROPY_MAX_SEED_SIZE ];
n = MBEDTLS_ENTROPY_MAX_SEED_SIZE;
if( fread( buf, 1, n, f ) != n )
- {
- fclose( f );
- return( MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR );
- }
+ ret = MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR;
+ else
+ ret = mbedtls_entropy_update_manual( ctx, buf, n );
fclose( f );
- mbedtls_entropy_update_manual( ctx, buf, n );
+ mbedtls_zeroize( buf, sizeof( buf ) );
+
+ if( ret != 0 )
+ return( ret );
return( mbedtls_entropy_write_seed_file( ctx, path ) );
}
#include "mbedtls/aes.h"
#endif
+#if defined(MBEDTLS_ARC4_C)
+#include "mbedtls/arc4.h"
+#endif
+
#if defined(MBEDTLS_BASE64_C)
#include "mbedtls/base64.h"
#endif
#include "mbedtls/cipher.h"
#endif
+#if defined(MBEDTLS_CMAC_C)
+#include "mbedtls/cmac.h"
+#endif
+
#if defined(MBEDTLS_CTR_DRBG_C)
#include "mbedtls/ctr_drbg.h"
#endif
#include "mbedtls/md.h"
#endif
+#if defined(MBEDTLS_MD2_C)
+#include "mbedtls/md2.h"
+#endif
+
+#if defined(MBEDTLS_MD4_C)
+#include "mbedtls/md4.h"
+#endif
+
+#if defined(MBEDTLS_MD5_C)
+#include "mbedtls/md5.h"
+#endif
+
#if defined(MBEDTLS_NET_C)
#include "mbedtls/net_sockets.h"
#endif
#include "mbedtls/pkcs5.h"
#endif
+#if defined(MBEDTLS_RIPEMD160_C)
+#include "mbedtls/ripemd160.h"
+#endif
+
#if defined(MBEDTLS_RSA_C)
#include "mbedtls/rsa.h"
#endif
+#if defined(MBEDTLS_SHA1_C)
+#include "mbedtls/sha1.h"
+#endif
+
+#if defined(MBEDTLS_SHA256_C)
+#include "mbedtls/sha256.h"
+#endif
+
+#if defined(MBEDTLS_SHA512_C)
+#include "mbedtls/sha512.h"
+#endif
+
#if defined(MBEDTLS_SSL_TLS_C)
#include "mbedtls/ssl.h"
#endif
if( use_ret == -(MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE) )
mbedtls_snprintf( buf, buflen, "CIPHER - The selected feature is not available" );
if( use_ret == -(MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA) )
- mbedtls_snprintf( buf, buflen, "CIPHER - Bad input parameters to function" );
+ mbedtls_snprintf( buf, buflen, "CIPHER - Bad input parameters" );
if( use_ret == -(MBEDTLS_ERR_CIPHER_ALLOC_FAILED) )
mbedtls_snprintf( buf, buflen, "CIPHER - Failed to allocate memory" );
if( use_ret == -(MBEDTLS_ERR_CIPHER_INVALID_PADDING) )
if( use_ret == -(MBEDTLS_ERR_CIPHER_AUTH_FAILED) )
mbedtls_snprintf( buf, buflen, "CIPHER - Authentication failed (for AEAD modes)" );
if( use_ret == -(MBEDTLS_ERR_CIPHER_INVALID_CONTEXT) )
- mbedtls_snprintf( buf, buflen, "CIPHER - The context is invalid, eg because it was free()ed" );
+ mbedtls_snprintf( buf, buflen, "CIPHER - The context is invalid. For example, because it was freed" );
+ if( use_ret == -(MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "CIPHER - Cipher hardware accelerator failed" );
#endif /* MBEDTLS_CIPHER_C */
#if defined(MBEDTLS_DHM_C)
if( use_ret == -(MBEDTLS_ERR_DHM_BAD_INPUT_DATA) )
- mbedtls_snprintf( buf, buflen, "DHM - Bad input parameters to function" );
+ mbedtls_snprintf( buf, buflen, "DHM - Bad input parameters" );
if( use_ret == -(MBEDTLS_ERR_DHM_READ_PARAMS_FAILED) )
mbedtls_snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" );
if( use_ret == -(MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED) )
if( use_ret == -(MBEDTLS_ERR_DHM_ALLOC_FAILED) )
mbedtls_snprintf( buf, buflen, "DHM - Allocation of memory failed" );
if( use_ret == -(MBEDTLS_ERR_DHM_FILE_IO_ERROR) )
- mbedtls_snprintf( buf, buflen, "DHM - Read/write of file failed" );
+ mbedtls_snprintf( buf, buflen, "DHM - Read or write of file failed" );
+ if( use_ret == -(MBEDTLS_ERR_DHM_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "DHM - DHM hardware accelerator failed" );
+ if( use_ret == -(MBEDTLS_ERR_DHM_SET_GROUP_FAILED) )
+ mbedtls_snprintf( buf, buflen, "DHM - Setting the modulus and generator failed" );
#endif /* MBEDTLS_DHM_C */
#if defined(MBEDTLS_ECP_C)
mbedtls_snprintf( buf, buflen, "ECP - Invalid private or public key" );
if( use_ret == -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH) )
mbedtls_snprintf( buf, buflen, "ECP - Signature is valid but shorter than the user-supplied length" );
+ if( use_ret == -(MBEDTLS_ERR_ECP_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "ECP - ECP hardware accelerator failed" );
#endif /* MBEDTLS_ECP_C */
#if defined(MBEDTLS_MD_C)
mbedtls_snprintf( buf, buflen, "MD - Failed to allocate memory" );
if( use_ret == -(MBEDTLS_ERR_MD_FILE_IO_ERROR) )
mbedtls_snprintf( buf, buflen, "MD - Opening or reading of file failed" );
+ if( use_ret == -(MBEDTLS_ERR_MD_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "MD - MD hardware accelerator failed" );
#endif /* MBEDTLS_MD_C */
#if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C)
mbedtls_snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" );
if( use_ret == -(MBEDTLS_ERR_PK_SIG_LEN_MISMATCH) )
mbedtls_snprintf( buf, buflen, "PK - The signature is valid but its length is less than expected" );
+ if( use_ret == -(MBEDTLS_ERR_PK_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "PK - PK hardware accelerator failed" );
#endif /* MBEDTLS_PK_C */
#if defined(MBEDTLS_PKCS12_C)
if( use_ret == -(MBEDTLS_ERR_RSA_KEY_GEN_FAILED) )
mbedtls_snprintf( buf, buflen, "RSA - Something failed during generation of a key" );
if( use_ret == -(MBEDTLS_ERR_RSA_KEY_CHECK_FAILED) )
- mbedtls_snprintf( buf, buflen, "RSA - Key failed to pass the library's validity check" );
+ mbedtls_snprintf( buf, buflen, "RSA - Key failed to pass the validity check of the library" );
if( use_ret == -(MBEDTLS_ERR_RSA_PUBLIC_FAILED) )
mbedtls_snprintf( buf, buflen, "RSA - The public key operation failed" );
if( use_ret == -(MBEDTLS_ERR_RSA_PRIVATE_FAILED) )
mbedtls_snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" );
if( use_ret == -(MBEDTLS_ERR_RSA_RNG_FAILED) )
mbedtls_snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" );
+ if( use_ret == -(MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION) )
+ mbedtls_snprintf( buf, buflen, "RSA - The implementation does not offer the requested operation, for example, because of security violations or lack of functionality" );
+ if( use_ret == -(MBEDTLS_ERR_RSA_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "RSA - RSA hardware accelerator failed" );
#endif /* MBEDTLS_RSA_C */
#if defined(MBEDTLS_SSL_TLS_C)
mbedtls_snprintf( buf, buflen, "X509 - Read/write of file failed" );
if( use_ret == -(MBEDTLS_ERR_X509_BUFFER_TOO_SMALL) )
mbedtls_snprintf( buf, buflen, "X509 - Destination buffer is too small" );
+ if( use_ret == -(MBEDTLS_ERR_X509_FATAL_ERROR) )
+ mbedtls_snprintf( buf, buflen, "X509 - A fatal error occured, eg the chain is too long or the vrfy callback failed" );
#endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */
// END generated code
mbedtls_snprintf( buf, buflen, "AES - Invalid key length" );
if( use_ret == -(MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH) )
mbedtls_snprintf( buf, buflen, "AES - Invalid data input length" );
+ if( use_ret == -(MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE) )
+ mbedtls_snprintf( buf, buflen, "AES - Feature not available. For example, an unsupported AES key size" );
+ if( use_ret == -(MBEDTLS_ERR_AES_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "AES - AES hardware accelerator failed" );
#endif /* MBEDTLS_AES_C */
+#if defined(MBEDTLS_ARC4_C)
+ if( use_ret == -(MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "ARC4 - ARC4 hardware accelerator failed" );
+#endif /* MBEDTLS_ARC4_C */
+
#if defined(MBEDTLS_ASN1_PARSE_C)
if( use_ret == -(MBEDTLS_ERR_ASN1_OUT_OF_DATA) )
mbedtls_snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" );
#if defined(MBEDTLS_BLOWFISH_C)
if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH) )
mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid key length" );
+ if( use_ret == -(MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "BLOWFISH - Blowfish hardware accelerator failed" );
if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH) )
mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid data input length" );
#endif /* MBEDTLS_BLOWFISH_C */
mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid key length" );
if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH) )
mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid data input length" );
+ if( use_ret == -(MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "CAMELLIA - Camellia hardware accelerator failed" );
#endif /* MBEDTLS_CAMELLIA_C */
#if defined(MBEDTLS_CCM_C)
if( use_ret == -(MBEDTLS_ERR_CCM_BAD_INPUT) )
- mbedtls_snprintf( buf, buflen, "CCM - Bad input parameters to function" );
+ mbedtls_snprintf( buf, buflen, "CCM - Bad input parameters to the function" );
if( use_ret == -(MBEDTLS_ERR_CCM_AUTH_FAILED) )
mbedtls_snprintf( buf, buflen, "CCM - Authenticated decryption failed" );
+ if( use_ret == -(MBEDTLS_ERR_CCM_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "CCM - CCM hardware accelerator failed" );
#endif /* MBEDTLS_CCM_C */
+#if defined(MBEDTLS_CMAC_C)
+ if( use_ret == -(MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "CMAC - CMAC hardware accelerator failed" );
+#endif /* MBEDTLS_CMAC_C */
+
#if defined(MBEDTLS_CTR_DRBG_C)
if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) )
mbedtls_snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" );
if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG) )
- mbedtls_snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" );
+ mbedtls_snprintf( buf, buflen, "CTR_DRBG - The requested random buffer length is too big" );
if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG) )
- mbedtls_snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" );
+ mbedtls_snprintf( buf, buflen, "CTR_DRBG - The input (entropy + additional data) is too large" );
if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR) )
- mbedtls_snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" );
+ mbedtls_snprintf( buf, buflen, "CTR_DRBG - Read or write error in file" );
#endif /* MBEDTLS_CTR_DRBG_C */
#if defined(MBEDTLS_DES_C)
if( use_ret == -(MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH) )
mbedtls_snprintf( buf, buflen, "DES - The data input has an invalid length" );
+ if( use_ret == -(MBEDTLS_ERR_DES_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "DES - DES hardware accelerator failed" );
#endif /* MBEDTLS_DES_C */
#if defined(MBEDTLS_ENTROPY_C)
#if defined(MBEDTLS_GCM_C)
if( use_ret == -(MBEDTLS_ERR_GCM_AUTH_FAILED) )
mbedtls_snprintf( buf, buflen, "GCM - Authenticated decryption failed" );
+ if( use_ret == -(MBEDTLS_ERR_GCM_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "GCM - GCM hardware accelerator failed" );
if( use_ret == -(MBEDTLS_ERR_GCM_BAD_INPUT) )
mbedtls_snprintf( buf, buflen, "GCM - Bad input parameters to function" );
#endif /* MBEDTLS_GCM_C */
mbedtls_snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" );
#endif /* MBEDTLS_HMAC_DRBG_C */
+#if defined(MBEDTLS_MD2_C)
+ if( use_ret == -(MBEDTLS_ERR_MD2_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "MD2 - MD2 hardware accelerator failed" );
+#endif /* MBEDTLS_MD2_C */
+
+#if defined(MBEDTLS_MD4_C)
+ if( use_ret == -(MBEDTLS_ERR_MD4_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "MD4 - MD4 hardware accelerator failed" );
+#endif /* MBEDTLS_MD4_C */
+
+#if defined(MBEDTLS_MD5_C)
+ if( use_ret == -(MBEDTLS_ERR_MD5_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "MD5 - MD5 hardware accelerator failed" );
+#endif /* MBEDTLS_MD5_C */
+
#if defined(MBEDTLS_NET_C)
if( use_ret == -(MBEDTLS_ERR_NET_SOCKET_FAILED) )
mbedtls_snprintf( buf, buflen, "NET - Failed to open a socket" );
mbedtls_snprintf( buf, buflen, "PADLOCK - Input data should be aligned" );
#endif /* MBEDTLS_PADLOCK_C */
+#if defined(MBEDTLS_RIPEMD160_C)
+ if( use_ret == -(MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "RIPEMD160 - RIPEMD160 hardware accelerator failed" );
+#endif /* MBEDTLS_RIPEMD160_C */
+
+#if defined(MBEDTLS_SHA1_C)
+ if( use_ret == -(MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "SHA1 - SHA-1 hardware accelerator failed" );
+#endif /* MBEDTLS_SHA1_C */
+
+#if defined(MBEDTLS_SHA256_C)
+ if( use_ret == -(MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "SHA256 - SHA-256 hardware accelerator failed" );
+#endif /* MBEDTLS_SHA256_C */
+
+#if defined(MBEDTLS_SHA512_C)
+ if( use_ret == -(MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "SHA512 - SHA-512 hardware accelerator failed" );
+#endif /* MBEDTLS_SHA512_C */
+
#if defined(MBEDTLS_THREADING_C)
if( use_ret == -(MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE) )
mbedtls_snprintf( buf, buflen, "THREADING - The selected feature is not available" );
#if defined(MBEDTLS_XTEA_C)
if( use_ret == -(MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH) )
mbedtls_snprintf( buf, buflen, "XTEA - The data input has an invalid length" );
+ if( use_ret == -(MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED) )
+ mbedtls_snprintf( buf, buflen, "XTEA - XTEA hardware accelerator failed" );
#endif /* MBEDTLS_XTEA_C */
// END generated code
#endif
#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
+#include "mbedtls/aes.h"
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#endif /* MBEDTLS_PLATFORM_C */
#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
+#if !defined(MBEDTLS_GCM_ALT)
+
/*
* 32-bit integer manipulation macros (big endian)
*/
size_t use_len, olen = 0;
/* IV and AD are limited to 2^64 bits, so 2^61 bytes */
- if( ( (uint64_t) iv_len ) >> 61 != 0 ||
- ( (uint64_t) add_len ) >> 61 != 0 )
+ /* IV is not allowed to be zero length */
+ if( iv_len == 0 ||
+ ( (uint64_t) iv_len ) >> 61 != 0 ||
+ ( (uint64_t) add_len ) >> 61 != 0 )
{
return( MBEDTLS_ERR_GCM_BAD_INPUT );
}
mbedtls_zeroize( ctx, sizeof( mbedtls_gcm_context ) );
}
+#endif /* !MBEDTLS_GCM_ALT */
+
#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C)
/*
* AES-GCM test vectors from:
int i, j, ret;
mbedtls_cipher_id_t cipher = MBEDTLS_CIPHER_ID_AES;
- mbedtls_gcm_init( &ctx );
-
for( j = 0; j < 3; j++ )
{
int key_len = 128 + 64 * j;
for( i = 0; i < MAX_TESTS; i++ )
{
+ mbedtls_gcm_init( &ctx );
+
if( verbose != 0 )
mbedtls_printf( " AES-GCM-%3d #%d (%s): ",
- key_len, i, "enc" );
-
- mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]], key_len );
+ key_len, i, "enc" );
+
+ ret = mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]],
+ key_len );
+ /*
+ * AES-192 is an optional feature that may be unavailable when
+ * there is an alternative underlying implementation i.e. when
+ * MBEDTLS_AES_ALT is defined.
+ */
+ if( ret == MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE && key_len == 192 )
+ {
+ mbedtls_printf( "skipped\n" );
+ break;
+ }
+ else if( ret != 0 )
+ {
+ goto exit;
+ }
ret = mbedtls_gcm_crypt_and_tag( &ctx, MBEDTLS_GCM_ENCRYPT,
- pt_len[i],
- iv[iv_index[i]], iv_len[i],
- additional[add_index[i]], add_len[i],
- pt[pt_index[i]], buf, 16, tag_buf );
+ pt_len[i],
+ iv[iv_index[i]], iv_len[i],
+ additional[add_index[i]], add_len[i],
+ pt[pt_index[i]], buf, 16, tag_buf );
+ if( ret != 0 )
+ goto exit;
- if( ret != 0 ||
- memcmp( buf, ct[j * 6 + i], pt_len[i] ) != 0 ||
- memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
+ if ( memcmp( buf, ct[j * 6 + i], pt_len[i] ) != 0 ||
+ memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
{
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
+ ret = 1;
+ goto exit;
}
mbedtls_gcm_free( &ctx );
if( verbose != 0 )
mbedtls_printf( "passed\n" );
+ mbedtls_gcm_init( &ctx );
+
if( verbose != 0 )
mbedtls_printf( " AES-GCM-%3d #%d (%s): ",
- key_len, i, "dec" );
+ key_len, i, "dec" );
- mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]], key_len );
+ ret = mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]],
+ key_len );
+ if( ret != 0 )
+ goto exit;
ret = mbedtls_gcm_crypt_and_tag( &ctx, MBEDTLS_GCM_DECRYPT,
- pt_len[i],
- iv[iv_index[i]], iv_len[i],
- additional[add_index[i]], add_len[i],
- ct[j * 6 + i], buf, 16, tag_buf );
+ pt_len[i],
+ iv[iv_index[i]], iv_len[i],
+ additional[add_index[i]], add_len[i],
+ ct[j * 6 + i], buf, 16, tag_buf );
+
+ if( ret != 0 )
+ goto exit;
- if( ret != 0 ||
- memcmp( buf, pt[pt_index[i]], pt_len[i] ) != 0 ||
+ if( memcmp( buf, pt[pt_index[i]], pt_len[i] ) != 0 ||
memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
{
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
+ ret = 1;
+ goto exit;
}
mbedtls_gcm_free( &ctx );
if( verbose != 0 )
mbedtls_printf( "passed\n" );
+ mbedtls_gcm_init( &ctx );
+
if( verbose != 0 )
mbedtls_printf( " AES-GCM-%3d #%d split (%s): ",
- key_len, i, "enc" );
+ key_len, i, "enc" );
- mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]], key_len );
+ ret = mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]],
+ key_len );
+ if( ret != 0 )
+ goto exit;
ret = mbedtls_gcm_starts( &ctx, MBEDTLS_GCM_ENCRYPT,
- iv[iv_index[i]], iv_len[i],
- additional[add_index[i]], add_len[i] );
+ iv[iv_index[i]], iv_len[i],
+ additional[add_index[i]], add_len[i] );
if( ret != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
+ goto exit;
if( pt_len[i] > 32 )
{
size_t rest_len = pt_len[i] - 32;
ret = mbedtls_gcm_update( &ctx, 32, pt[pt_index[i]], buf );
if( ret != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
+ goto exit;
ret = mbedtls_gcm_update( &ctx, rest_len, pt[pt_index[i]] + 32,
buf + 32 );
if( ret != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
+ goto exit;
}
else
{
ret = mbedtls_gcm_update( &ctx, pt_len[i], pt[pt_index[i]], buf );
if( ret != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
+ goto exit;
}
ret = mbedtls_gcm_finish( &ctx, tag_buf, 16 );
- if( ret != 0 ||
- memcmp( buf, ct[j * 6 + i], pt_len[i] ) != 0 ||
+ if( ret != 0 )
+ goto exit;
+
+ if( memcmp( buf, ct[j * 6 + i], pt_len[i] ) != 0 ||
memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
{
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
+ ret = 1;
+ goto exit;
}
mbedtls_gcm_free( &ctx );
if( verbose != 0 )
mbedtls_printf( "passed\n" );
+ mbedtls_gcm_init( &ctx );
+
if( verbose != 0 )
mbedtls_printf( " AES-GCM-%3d #%d split (%s): ",
- key_len, i, "dec" );
+ key_len, i, "dec" );
- mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]], key_len );
+ ret = mbedtls_gcm_setkey( &ctx, cipher, key[key_index[i]],
+ key_len );
+ if( ret != 0 )
+ goto exit;
ret = mbedtls_gcm_starts( &ctx, MBEDTLS_GCM_DECRYPT,
iv[iv_index[i]], iv_len[i],
additional[add_index[i]], add_len[i] );
if( ret != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
+ goto exit;
if( pt_len[i] > 32 )
{
size_t rest_len = pt_len[i] - 32;
ret = mbedtls_gcm_update( &ctx, 32, ct[j * 6 + i], buf );
if( ret != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
+ goto exit;
ret = mbedtls_gcm_update( &ctx, rest_len, ct[j * 6 + i] + 32,
- buf + 32 );
+ buf + 32 );
if( ret != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
+ goto exit;
}
else
{
- ret = mbedtls_gcm_update( &ctx, pt_len[i], ct[j * 6 + i], buf );
+ ret = mbedtls_gcm_update( &ctx, pt_len[i], ct[j * 6 + i],
+ buf );
if( ret != 0 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
+ goto exit;
}
ret = mbedtls_gcm_finish( &ctx, tag_buf, 16 );
- if( ret != 0 ||
- memcmp( buf, pt[pt_index[i]], pt_len[i] ) != 0 ||
+ if( ret != 0 )
+ goto exit;
+
+ if( memcmp( buf, pt[pt_index[i]], pt_len[i] ) != 0 ||
memcmp( tag_buf, tag[j * 6 + i], 16 ) != 0 )
{
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
+ ret = 1;
+ goto exit;
}
mbedtls_gcm_free( &ctx );
if( verbose != 0 )
mbedtls_printf( "passed\n" );
-
}
}
if( verbose != 0 )
mbedtls_printf( "\n" );
- return( 0 );
+ ret = 0;
+
+exit:
+ if( ret != 0 )
+ {
+ if( verbose != 0 )
+ mbedtls_printf( "failed\n" );
+ mbedtls_gcm_free( &ctx );
+ }
+
+ return( ret );
}
#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */
exit:
fclose( f );
+ mbedtls_zeroize( buf, sizeof( buf ) );
+
return( ret );
}
int mbedtls_hmac_drbg_update_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path )
{
+ int ret = 0;
FILE *f;
size_t n;
unsigned char buf[ MBEDTLS_HMAC_DRBG_MAX_INPUT ];
}
if( fread( buf, 1, n, f ) != n )
- {
- fclose( f );
- return( MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR );
- }
+ ret = MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR;
+ else
+ mbedtls_hmac_drbg_update( ctx, buf, n );
fclose( f );
- mbedtls_hmac_drbg_update( ctx, buf, n );
+ mbedtls_zeroize( buf, sizeof( buf ) );
+
+ if( ret != 0 )
+ return( ret );
return( mbedtls_hmac_drbg_write_seed_file( ctx, path ) );
}
if( ctx == NULL || ctx->md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
- ctx->md_info->starts_func( ctx->md_ctx );
-
- return( 0 );
+ return( ctx->md_info->starts_func( ctx->md_ctx ) );
}
int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen )
if( ctx == NULL || ctx->md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
- ctx->md_info->update_func( ctx->md_ctx, input, ilen );
-
- return( 0 );
+ return( ctx->md_info->update_func( ctx->md_ctx, input, ilen ) );
}
int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output )
if( ctx == NULL || ctx->md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
- ctx->md_info->finish_func( ctx->md_ctx, output );
-
- return( 0 );
+ return( ctx->md_info->finish_func( ctx->md_ctx, output ) );
}
int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen,
if( md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
- md_info->digest_func( input, ilen, output );
-
- return( 0 );
+ return( md_info->digest_func( input, ilen, output ) );
}
#if defined(MBEDTLS_FS_IO)
if( ( ret = mbedtls_md_setup( &ctx, md_info, 0 ) ) != 0 )
goto cleanup;
- md_info->starts_func( ctx.md_ctx );
+ if( ( ret = md_info->starts_func( ctx.md_ctx ) ) != 0 )
+ goto cleanup;
while( ( n = fread( buf, 1, sizeof( buf ), f ) ) > 0 )
- md_info->update_func( ctx.md_ctx, buf, n );
+ if( ( ret = md_info->update_func( ctx.md_ctx, buf, n ) ) != 0 )
+ goto cleanup;
if( ferror( f ) != 0 )
- {
ret = MBEDTLS_ERR_MD_FILE_IO_ERROR;
- goto cleanup;
- }
-
- md_info->finish_func( ctx.md_ctx, output );
+ else
+ ret = md_info->finish_func( ctx.md_ctx, output );
cleanup:
+ mbedtls_zeroize( buf, sizeof( buf ) );
fclose( f );
mbedtls_md_free( &ctx );
int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, size_t keylen )
{
+ int ret;
unsigned char sum[MBEDTLS_MD_MAX_SIZE];
unsigned char *ipad, *opad;
size_t i;
if( keylen > (size_t) ctx->md_info->block_size )
{
- ctx->md_info->starts_func( ctx->md_ctx );
- ctx->md_info->update_func( ctx->md_ctx, key, keylen );
- ctx->md_info->finish_func( ctx->md_ctx, sum );
+ if( ( ret = ctx->md_info->starts_func( ctx->md_ctx ) ) != 0 )
+ goto cleanup;
+ if( ( ret = ctx->md_info->update_func( ctx->md_ctx, key, keylen ) ) != 0 )
+ goto cleanup;
+ if( ( ret = ctx->md_info->finish_func( ctx->md_ctx, sum ) ) != 0 )
+ goto cleanup;
keylen = ctx->md_info->size;
key = sum;
opad[i] = (unsigned char)( opad[i] ^ key[i] );
}
- mbedtls_zeroize( sum, sizeof( sum ) );
+ if( ( ret = ctx->md_info->starts_func( ctx->md_ctx ) ) != 0 )
+ goto cleanup;
+ if( ( ret = ctx->md_info->update_func( ctx->md_ctx, ipad,
+ ctx->md_info->block_size ) ) != 0 )
+ goto cleanup;
- ctx->md_info->starts_func( ctx->md_ctx );
- ctx->md_info->update_func( ctx->md_ctx, ipad, ctx->md_info->block_size );
+cleanup:
+ mbedtls_zeroize( sum, sizeof( sum ) );
- return( 0 );
+ return( ret );
}
int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen )
if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
- ctx->md_info->update_func( ctx->md_ctx, input, ilen );
-
- return( 0 );
+ return( ctx->md_info->update_func( ctx->md_ctx, input, ilen ) );
}
int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output )
{
+ int ret;
unsigned char tmp[MBEDTLS_MD_MAX_SIZE];
unsigned char *opad;
opad = (unsigned char *) ctx->hmac_ctx + ctx->md_info->block_size;
- ctx->md_info->finish_func( ctx->md_ctx, tmp );
- ctx->md_info->starts_func( ctx->md_ctx );
- ctx->md_info->update_func( ctx->md_ctx, opad, ctx->md_info->block_size );
- ctx->md_info->update_func( ctx->md_ctx, tmp, ctx->md_info->size );
- ctx->md_info->finish_func( ctx->md_ctx, output );
-
- return( 0 );
+ if( ( ret = ctx->md_info->finish_func( ctx->md_ctx, tmp ) ) != 0 )
+ return( ret );
+ if( ( ret = ctx->md_info->starts_func( ctx->md_ctx ) ) != 0 )
+ return( ret );
+ if( ( ret = ctx->md_info->update_func( ctx->md_ctx, opad,
+ ctx->md_info->block_size ) ) != 0 )
+ return( ret );
+ if( ( ret = ctx->md_info->update_func( ctx->md_ctx, tmp,
+ ctx->md_info->size ) ) != 0 )
+ return( ret );
+ return( ctx->md_info->finish_func( ctx->md_ctx, output ) );
}
int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx )
{
+ int ret;
unsigned char *ipad;
if( ctx == NULL || ctx->md_info == NULL || ctx->hmac_ctx == NULL )
ipad = (unsigned char *) ctx->hmac_ctx;
- ctx->md_info->starts_func( ctx->md_ctx );
- ctx->md_info->update_func( ctx->md_ctx, ipad, ctx->md_info->block_size );
-
- return( 0 );
+ if( ( ret = ctx->md_info->starts_func( ctx->md_ctx ) ) != 0 )
+ return( ret );
+ return( ctx->md_info->update_func( ctx->md_ctx, ipad,
+ ctx->md_info->block_size ) );
}
-int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen,
- const unsigned char *input, size_t ilen,
- unsigned char *output )
+int mbedtls_md_hmac( const mbedtls_md_info_t *md_info,
+ const unsigned char *key, size_t keylen,
+ const unsigned char *input, size_t ilen,
+ unsigned char *output )
{
mbedtls_md_context_t ctx;
int ret;
mbedtls_md_init( &ctx );
if( ( ret = mbedtls_md_setup( &ctx, md_info, 1 ) ) != 0 )
- return( ret );
+ goto cleanup;
- mbedtls_md_hmac_starts( &ctx, key, keylen );
- mbedtls_md_hmac_update( &ctx, input, ilen );
- mbedtls_md_hmac_finish( &ctx, output );
+ if( ( ret = mbedtls_md_hmac_starts( &ctx, key, keylen ) ) != 0 )
+ goto cleanup;
+ if( ( ret = mbedtls_md_hmac_update( &ctx, input, ilen ) ) != 0 )
+ goto cleanup;
+ if( ( ret = mbedtls_md_hmac_finish( &ctx, output ) ) != 0 )
+ goto cleanup;
+cleanup:
mbedtls_md_free( &ctx );
- return( 0 );
+ return( ret );
}
int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data )
if( ctx == NULL || ctx->md_info == NULL )
return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
- ctx->md_info->process_func( ctx->md_ctx, data );
-
- return( 0 );
+ return( ctx->md_info->process_func( ctx->md_ctx, data ) );
}
unsigned char mbedtls_md_get_size( const mbedtls_md_info_t *md_info )
/*
* MD2 context setup
*/
-void mbedtls_md2_starts( mbedtls_md2_context *ctx )
+int mbedtls_md2_starts_ret( mbedtls_md2_context *ctx )
{
memset( ctx->cksum, 0, 16 );
memset( ctx->state, 0, 46 );
memset( ctx->buffer, 0, 16 );
ctx->left = 0;
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md2_starts( mbedtls_md2_context *ctx )
+{
+ mbedtls_md2_starts_ret( ctx );
+}
+#endif
+
#if !defined(MBEDTLS_MD2_PROCESS_ALT)
-void mbedtls_md2_process( mbedtls_md2_context *ctx )
+int mbedtls_internal_md2_process( mbedtls_md2_context *ctx )
{
int i, j;
unsigned char t = 0;
( ctx->cksum[i] ^ PI_SUBST[ctx->buffer[i] ^ t] );
t = ctx->cksum[i];
}
+
+ return( 0 );
}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md2_process( mbedtls_md2_context *ctx )
+{
+ mbedtls_internal_md2_process( ctx );
+}
+#endif
#endif /* !MBEDTLS_MD2_PROCESS_ALT */
/*
* MD2 process buffer
*/
-void mbedtls_md2_update( mbedtls_md2_context *ctx, const unsigned char *input, size_t ilen )
+int mbedtls_md2_update_ret( mbedtls_md2_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
{
+ int ret;
size_t fill;
while( ilen > 0 )
{
- if( ctx->left + ilen > 16 )
+ if( ilen > 16 - ctx->left )
fill = 16 - ctx->left;
else
fill = ilen;
if( ctx->left == 16 )
{
ctx->left = 0;
- mbedtls_md2_process( ctx );
+ if( ( ret = mbedtls_internal_md2_process( ctx ) ) != 0 )
+ return( ret );
}
}
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md2_update( mbedtls_md2_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
+{
+ mbedtls_md2_update_ret( ctx, input, ilen );
+}
+#endif
+
/*
* MD2 final digest
*/
-void mbedtls_md2_finish( mbedtls_md2_context *ctx, unsigned char output[16] )
+int mbedtls_md2_finish_ret( mbedtls_md2_context *ctx,
+ unsigned char output[16] )
{
+ int ret;
size_t i;
unsigned char x;
for( i = ctx->left; i < 16; i++ )
ctx->buffer[i] = x;
- mbedtls_md2_process( ctx );
+ if( ( ret = mbedtls_internal_md2_process( ctx ) ) != 0 )
+ return( ret );
memcpy( ctx->buffer, ctx->cksum, 16 );
- mbedtls_md2_process( ctx );
+ if( ( ret = mbedtls_internal_md2_process( ctx ) ) != 0 )
+ return( ret );
memcpy( output, ctx->state, 16 );
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md2_finish( mbedtls_md2_context *ctx,
+ unsigned char output[16] )
+{
+ mbedtls_md2_finish_ret( ctx, output );
}
+#endif
#endif /* !MBEDTLS_MD2_ALT */
/*
* output = MD2( input buffer )
*/
-void mbedtls_md2( const unsigned char *input, size_t ilen, unsigned char output[16] )
+int mbedtls_md2_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] )
{
+ int ret;
mbedtls_md2_context ctx;
mbedtls_md2_init( &ctx );
- mbedtls_md2_starts( &ctx );
- mbedtls_md2_update( &ctx, input, ilen );
- mbedtls_md2_finish( &ctx, output );
+
+ if( ( ret = mbedtls_md2_starts_ret( &ctx ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_md2_update_ret( &ctx, input, ilen ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_md2_finish_ret( &ctx, output ) ) != 0 )
+ goto exit;
+
+exit:
mbedtls_md2_free( &ctx );
+
+ return( ret );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md2( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] )
+{
+ mbedtls_md2_ret( input, ilen, output );
+}
+#endif
+
#if defined(MBEDTLS_SELF_TEST)
/*
* RFC 1319 test vectors
*/
-static const char md2_test_str[7][81] =
+static const unsigned char md2_test_str[7][81] =
{
{ "" },
{ "a" },
{ "message digest" },
{ "abcdefghijklmnopqrstuvwxyz" },
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" },
- { "12345678901234567890123456789012345678901234567890123456789012" \
+ { "12345678901234567890123456789012345678901234567890123456789012"
"345678901234567890" }
};
+static const size_t md2_test_strlen[7] =
+{
+ 0, 1, 3, 14, 26, 62, 80
+};
+
static const unsigned char md2_test_sum[7][16] =
{
{ 0x83, 0x50, 0xE5, 0xA3, 0xE2, 0x4C, 0x15, 0x3D,
*/
int mbedtls_md2_self_test( int verbose )
{
- int i;
+ int i, ret = 0;
unsigned char md2sum[16];
for( i = 0; i < 7; i++ )
if( verbose != 0 )
mbedtls_printf( " MD2 test #%d: ", i + 1 );
- mbedtls_md2( (unsigned char *) md2_test_str[i],
- strlen( md2_test_str[i] ), md2sum );
+ ret = mbedtls_md2_ret( md2_test_str[i], md2_test_strlen[i], md2sum );
+ if( ret != 0 )
+ goto fail;
if( memcmp( md2sum, md2_test_sum[i], 16 ) != 0 )
{
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
+ ret = 1;
+ goto fail;
}
if( verbose != 0 )
mbedtls_printf( "\n" );
return( 0 );
+
+fail:
+ if( verbose != 0 )
+ mbedtls_printf( "failed\n" );
+
+ return( ret );
}
#endif /* MBEDTLS_SELF_TEST */
/*
* MD4 context setup
*/
-void mbedtls_md4_starts( mbedtls_md4_context *ctx )
+int mbedtls_md4_starts_ret( mbedtls_md4_context *ctx )
{
ctx->total[0] = 0;
ctx->total[1] = 0;
ctx->state[1] = 0xEFCDAB89;
ctx->state[2] = 0x98BADCFE;
ctx->state[3] = 0x10325476;
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md4_starts( mbedtls_md4_context *ctx )
+{
+ mbedtls_md4_starts_ret( ctx );
}
+#endif
#if !defined(MBEDTLS_MD4_PROCESS_ALT)
-void mbedtls_md4_process( mbedtls_md4_context *ctx, const unsigned char data[64] )
+int mbedtls_internal_md4_process( mbedtls_md4_context *ctx,
+ const unsigned char data[64] )
{
uint32_t X[16], A, B, C, D;
ctx->state[1] += B;
ctx->state[2] += C;
ctx->state[3] += D;
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md4_process( mbedtls_md4_context *ctx,
+ const unsigned char data[64] )
+{
+ mbedtls_internal_md4_process( ctx, data );
}
+#endif
#endif /* !MBEDTLS_MD4_PROCESS_ALT */
/*
* MD4 process buffer
*/
-void mbedtls_md4_update( mbedtls_md4_context *ctx, const unsigned char *input, size_t ilen )
+int mbedtls_md4_update_ret( mbedtls_md4_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
{
+ int ret;
size_t fill;
uint32_t left;
if( ilen == 0 )
- return;
+ return( 0 );
left = ctx->total[0] & 0x3F;
fill = 64 - left;
{
memcpy( (void *) (ctx->buffer + left),
(void *) input, fill );
- mbedtls_md4_process( ctx, ctx->buffer );
+
+ if( ( ret = mbedtls_internal_md4_process( ctx, ctx->buffer ) ) != 0 )
+ return( ret );
+
input += fill;
ilen -= fill;
left = 0;
while( ilen >= 64 )
{
- mbedtls_md4_process( ctx, input );
+ if( ( ret = mbedtls_internal_md4_process( ctx, input ) ) != 0 )
+ return( ret );
+
input += 64;
ilen -= 64;
}
memcpy( (void *) (ctx->buffer + left),
(void *) input, ilen );
}
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md4_update( mbedtls_md4_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
+{
+ mbedtls_md4_update_ret( ctx, input, ilen );
}
+#endif
static const unsigned char md4_padding[64] =
{
/*
* MD4 final digest
*/
-void mbedtls_md4_finish( mbedtls_md4_context *ctx, unsigned char output[16] )
+int mbedtls_md4_finish_ret( mbedtls_md4_context *ctx,
+ unsigned char output[16] )
{
+ int ret;
uint32_t last, padn;
uint32_t high, low;
unsigned char msglen[8];
last = ctx->total[0] & 0x3F;
padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
- mbedtls_md4_update( ctx, (unsigned char *) md4_padding, padn );
- mbedtls_md4_update( ctx, msglen, 8 );
+ ret = mbedtls_md4_update_ret( ctx, (unsigned char *)md4_padding, padn );
+ if( ret != 0 )
+ return( ret );
+
+ if( ( ret = mbedtls_md4_update_ret( ctx, msglen, 8 ) ) != 0 )
+ return( ret );
+
PUT_UINT32_LE( ctx->state[0], output, 0 );
PUT_UINT32_LE( ctx->state[1], output, 4 );
PUT_UINT32_LE( ctx->state[2], output, 8 );
PUT_UINT32_LE( ctx->state[3], output, 12 );
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md4_finish( mbedtls_md4_context *ctx,
+ unsigned char output[16] )
+{
+ mbedtls_md4_finish_ret( ctx, output );
}
+#endif
#endif /* !MBEDTLS_MD4_ALT */
/*
* output = MD4( input buffer )
*/
-void mbedtls_md4( const unsigned char *input, size_t ilen, unsigned char output[16] )
+int mbedtls_md4_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] )
{
+ int ret;
mbedtls_md4_context ctx;
mbedtls_md4_init( &ctx );
- mbedtls_md4_starts( &ctx );
- mbedtls_md4_update( &ctx, input, ilen );
- mbedtls_md4_finish( &ctx, output );
+
+ if( ( ret = mbedtls_md4_starts_ret( &ctx ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_md4_update_ret( &ctx, input, ilen ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_md4_finish_ret( &ctx, output ) ) != 0 )
+ goto exit;
+
+exit:
mbedtls_md4_free( &ctx );
+
+ return( ret );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md4( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] )
+{
+ mbedtls_md4_ret( input, ilen, output );
}
+#endif
#if defined(MBEDTLS_SELF_TEST)
/*
* RFC 1320 test vectors
*/
-static const char md4_test_str[7][81] =
+static const unsigned char md4_test_str[7][81] =
{
{ "" },
{ "a" },
{ "message digest" },
{ "abcdefghijklmnopqrstuvwxyz" },
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" },
- { "12345678901234567890123456789012345678901234567890123456789012" \
+ { "12345678901234567890123456789012345678901234567890123456789012"
"345678901234567890" }
};
+static const size_t md4_test_strlen[7] =
+{
+ 0, 1, 3, 14, 26, 62, 80
+};
+
static const unsigned char md4_test_sum[7][16] =
{
{ 0x31, 0xD6, 0xCF, 0xE0, 0xD1, 0x6A, 0xE9, 0x31,
*/
int mbedtls_md4_self_test( int verbose )
{
- int i;
+ int i, ret = 0;
unsigned char md4sum[16];
for( i = 0; i < 7; i++ )
if( verbose != 0 )
mbedtls_printf( " MD4 test #%d: ", i + 1 );
- mbedtls_md4( (unsigned char *) md4_test_str[i],
- strlen( md4_test_str[i] ), md4sum );
+ ret = mbedtls_md4_ret( md4_test_str[i], md4_test_strlen[i], md4sum );
+ if( ret != 0 )
+ goto fail;
if( memcmp( md4sum, md4_test_sum[i], 16 ) != 0 )
{
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
+ ret = 1;
+ goto fail;
}
if( verbose != 0 )
mbedtls_printf( "\n" );
return( 0 );
+
+fail:
+ if( verbose != 0 )
+ mbedtls_printf( "failed\n" );
+
+ return( ret );
}
#endif /* MBEDTLS_SELF_TEST */
/*
* MD5 context setup
*/
-void mbedtls_md5_starts( mbedtls_md5_context *ctx )
+int mbedtls_md5_starts_ret( mbedtls_md5_context *ctx )
{
ctx->total[0] = 0;
ctx->total[1] = 0;
ctx->state[1] = 0xEFCDAB89;
ctx->state[2] = 0x98BADCFE;
ctx->state[3] = 0x10325476;
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md5_starts( mbedtls_md5_context *ctx )
+{
+ mbedtls_md5_starts_ret( ctx );
+}
+#endif
+
#if !defined(MBEDTLS_MD5_PROCESS_ALT)
-void mbedtls_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64] )
+int mbedtls_internal_md5_process( mbedtls_md5_context *ctx,
+ const unsigned char data[64] )
{
uint32_t X[16], A, B, C, D;
ctx->state[1] += B;
ctx->state[2] += C;
ctx->state[3] += D;
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md5_process( mbedtls_md5_context *ctx,
+ const unsigned char data[64] )
+{
+ mbedtls_internal_md5_process( ctx, data );
}
+#endif
#endif /* !MBEDTLS_MD5_PROCESS_ALT */
/*
* MD5 process buffer
*/
-void mbedtls_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen )
+int mbedtls_md5_update_ret( mbedtls_md5_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
{
+ int ret;
size_t fill;
uint32_t left;
if( ilen == 0 )
- return;
+ return( 0 );
left = ctx->total[0] & 0x3F;
fill = 64 - left;
if( left && ilen >= fill )
{
memcpy( (void *) (ctx->buffer + left), input, fill );
- mbedtls_md5_process( ctx, ctx->buffer );
+ if( ( ret = mbedtls_internal_md5_process( ctx, ctx->buffer ) ) != 0 )
+ return( ret );
+
input += fill;
ilen -= fill;
left = 0;
while( ilen >= 64 )
{
- mbedtls_md5_process( ctx, input );
+ if( ( ret = mbedtls_internal_md5_process( ctx, input ) ) != 0 )
+ return( ret );
+
input += 64;
ilen -= 64;
}
{
memcpy( (void *) (ctx->buffer + left), input, ilen );
}
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md5_update( mbedtls_md5_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
+{
+ mbedtls_md5_update_ret( ctx, input, ilen );
+}
+#endif
+
static const unsigned char md5_padding[64] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*
* MD5 final digest
*/
-void mbedtls_md5_finish( mbedtls_md5_context *ctx, unsigned char output[16] )
+int mbedtls_md5_finish_ret( mbedtls_md5_context *ctx,
+ unsigned char output[16] )
{
+ int ret;
uint32_t last, padn;
uint32_t high, low;
unsigned char msglen[8];
last = ctx->total[0] & 0x3F;
padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
- mbedtls_md5_update( ctx, md5_padding, padn );
- mbedtls_md5_update( ctx, msglen, 8 );
+ if( ( ret = mbedtls_md5_update_ret( ctx, md5_padding, padn ) ) != 0 )
+ return( ret );
+
+ if( ( ret = mbedtls_md5_update_ret( ctx, msglen, 8 ) ) != 0 )
+ return( ret );
PUT_UINT32_LE( ctx->state[0], output, 0 );
PUT_UINT32_LE( ctx->state[1], output, 4 );
PUT_UINT32_LE( ctx->state[2], output, 8 );
PUT_UINT32_LE( ctx->state[3], output, 12 );
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md5_finish( mbedtls_md5_context *ctx,
+ unsigned char output[16] )
+{
+ mbedtls_md5_finish_ret( ctx, output );
+}
+#endif
+
#endif /* !MBEDTLS_MD5_ALT */
/*
* output = MD5( input buffer )
*/
-void mbedtls_md5( const unsigned char *input, size_t ilen, unsigned char output[16] )
+int mbedtls_md5_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] )
{
+ int ret;
mbedtls_md5_context ctx;
mbedtls_md5_init( &ctx );
- mbedtls_md5_starts( &ctx );
- mbedtls_md5_update( &ctx, input, ilen );
- mbedtls_md5_finish( &ctx, output );
+
+ if( ( ret = mbedtls_md5_starts_ret( &ctx ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_md5_update_ret( &ctx, input, ilen ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_md5_finish_ret( &ctx, output ) ) != 0 )
+ goto exit;
+
+exit:
mbedtls_md5_free( &ctx );
+
+ return( ret );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_md5( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[16] )
+{
+ mbedtls_md5_ret( input, ilen, output );
}
+#endif
#if defined(MBEDTLS_SELF_TEST)
/*
{ "message digest" },
{ "abcdefghijklmnopqrstuvwxyz" },
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" },
- { "12345678901234567890123456789012345678901234567890123456789012" \
+ { "12345678901234567890123456789012345678901234567890123456789012"
"345678901234567890" }
};
-static const int md5_test_buflen[7] =
+static const size_t md5_test_buflen[7] =
{
0, 1, 3, 14, 26, 62, 80
};
*/
int mbedtls_md5_self_test( int verbose )
{
- int i;
+ int i, ret = 0;
unsigned char md5sum[16];
for( i = 0; i < 7; i++ )
if( verbose != 0 )
mbedtls_printf( " MD5 test #%d: ", i + 1 );
- mbedtls_md5( md5_test_buf[i], md5_test_buflen[i], md5sum );
+ ret = mbedtls_md5_ret( md5_test_buf[i], md5_test_buflen[i], md5sum );
+ if( ret != 0 )
+ goto fail;
if( memcmp( md5sum, md5_test_sum[i], 16 ) != 0 )
{
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
+ ret = 1;
+ goto fail;
}
if( verbose != 0 )
mbedtls_printf( "\n" );
return( 0 );
+
+fail:
+ if( verbose != 0 )
+ mbedtls_printf( "failed\n" );
+
+ return( ret );
}
#endif /* MBEDTLS_SELF_TEST */
#if defined(MBEDTLS_MD2_C)
-static void md2_starts_wrap( void *ctx )
+static int md2_starts_wrap( void *ctx )
{
- mbedtls_md2_starts( (mbedtls_md2_context *) ctx );
+ return( mbedtls_md2_starts_ret( (mbedtls_md2_context *) ctx ) );
}
-static void md2_update_wrap( void *ctx, const unsigned char *input,
+static int md2_update_wrap( void *ctx, const unsigned char *input,
size_t ilen )
{
- mbedtls_md2_update( (mbedtls_md2_context *) ctx, input, ilen );
+ return( mbedtls_md2_update_ret( (mbedtls_md2_context *) ctx, input, ilen ) );
}
-static void md2_finish_wrap( void *ctx, unsigned char *output )
+static int md2_finish_wrap( void *ctx, unsigned char *output )
{
- mbedtls_md2_finish( (mbedtls_md2_context *) ctx, output );
+ return( mbedtls_md2_finish_ret( (mbedtls_md2_context *) ctx, output ) );
}
static void *md2_ctx_alloc( void )
(const mbedtls_md2_context *) src );
}
-static void md2_process_wrap( void *ctx, const unsigned char *data )
+static int md2_process_wrap( void *ctx, const unsigned char *data )
{
((void) data);
- mbedtls_md2_process( (mbedtls_md2_context *) ctx );
+ return( mbedtls_internal_md2_process( (mbedtls_md2_context *) ctx ) );
}
const mbedtls_md_info_t mbedtls_md2_info = {
md2_starts_wrap,
md2_update_wrap,
md2_finish_wrap,
- mbedtls_md2,
+ mbedtls_md2_ret,
md2_ctx_alloc,
md2_ctx_free,
md2_clone_wrap,
#if defined(MBEDTLS_MD4_C)
-static void md4_starts_wrap( void *ctx )
+static int md4_starts_wrap( void *ctx )
{
- mbedtls_md4_starts( (mbedtls_md4_context *) ctx );
+ return( mbedtls_md4_starts_ret( (mbedtls_md4_context *) ctx ) );
}
-static void md4_update_wrap( void *ctx, const unsigned char *input,
+static int md4_update_wrap( void *ctx, const unsigned char *input,
size_t ilen )
{
- mbedtls_md4_update( (mbedtls_md4_context *) ctx, input, ilen );
+ return( mbedtls_md4_update_ret( (mbedtls_md4_context *) ctx, input, ilen ) );
}
-static void md4_finish_wrap( void *ctx, unsigned char *output )
+static int md4_finish_wrap( void *ctx, unsigned char *output )
{
- mbedtls_md4_finish( (mbedtls_md4_context *) ctx, output );
+ return( mbedtls_md4_finish_ret( (mbedtls_md4_context *) ctx, output ) );
}
static void *md4_ctx_alloc( void )
static void md4_clone_wrap( void *dst, const void *src )
{
mbedtls_md4_clone( (mbedtls_md4_context *) dst,
- (const mbedtls_md4_context *) src );
+ (const mbedtls_md4_context *) src );
}
-static void md4_process_wrap( void *ctx, const unsigned char *data )
+static int md4_process_wrap( void *ctx, const unsigned char *data )
{
- mbedtls_md4_process( (mbedtls_md4_context *) ctx, data );
+ return( mbedtls_internal_md4_process( (mbedtls_md4_context *) ctx, data ) );
}
const mbedtls_md_info_t mbedtls_md4_info = {
md4_starts_wrap,
md4_update_wrap,
md4_finish_wrap,
- mbedtls_md4,
+ mbedtls_md4_ret,
md4_ctx_alloc,
md4_ctx_free,
md4_clone_wrap,
#if defined(MBEDTLS_MD5_C)
-static void md5_starts_wrap( void *ctx )
+static int md5_starts_wrap( void *ctx )
{
- mbedtls_md5_starts( (mbedtls_md5_context *) ctx );
+ return( mbedtls_md5_starts_ret( (mbedtls_md5_context *) ctx ) );
}
-static void md5_update_wrap( void *ctx, const unsigned char *input,
+static int md5_update_wrap( void *ctx, const unsigned char *input,
size_t ilen )
{
- mbedtls_md5_update( (mbedtls_md5_context *) ctx, input, ilen );
+ return( mbedtls_md5_update_ret( (mbedtls_md5_context *) ctx, input, ilen ) );
}
-static void md5_finish_wrap( void *ctx, unsigned char *output )
+static int md5_finish_wrap( void *ctx, unsigned char *output )
{
- mbedtls_md5_finish( (mbedtls_md5_context *) ctx, output );
+ return( mbedtls_md5_finish_ret( (mbedtls_md5_context *) ctx, output ) );
}
static void *md5_ctx_alloc( void )
static void md5_clone_wrap( void *dst, const void *src )
{
mbedtls_md5_clone( (mbedtls_md5_context *) dst,
- (const mbedtls_md5_context *) src );
+ (const mbedtls_md5_context *) src );
}
-static void md5_process_wrap( void *ctx, const unsigned char *data )
+static int md5_process_wrap( void *ctx, const unsigned char *data )
{
- mbedtls_md5_process( (mbedtls_md5_context *) ctx, data );
+ return( mbedtls_internal_md5_process( (mbedtls_md5_context *) ctx, data ) );
}
const mbedtls_md_info_t mbedtls_md5_info = {
md5_starts_wrap,
md5_update_wrap,
md5_finish_wrap,
- mbedtls_md5,
+ mbedtls_md5_ret,
md5_ctx_alloc,
md5_ctx_free,
md5_clone_wrap,
#if defined(MBEDTLS_RIPEMD160_C)
-static void ripemd160_starts_wrap( void *ctx )
+static int ripemd160_starts_wrap( void *ctx )
{
- mbedtls_ripemd160_starts( (mbedtls_ripemd160_context *) ctx );
+ return( mbedtls_ripemd160_starts_ret( (mbedtls_ripemd160_context *) ctx ) );
}
-static void ripemd160_update_wrap( void *ctx, const unsigned char *input,
+static int ripemd160_update_wrap( void *ctx, const unsigned char *input,
size_t ilen )
{
- mbedtls_ripemd160_update( (mbedtls_ripemd160_context *) ctx, input, ilen );
+ return( mbedtls_ripemd160_update_ret( (mbedtls_ripemd160_context *) ctx,
+ input, ilen ) );
}
-static void ripemd160_finish_wrap( void *ctx, unsigned char *output )
+static int ripemd160_finish_wrap( void *ctx, unsigned char *output )
{
- mbedtls_ripemd160_finish( (mbedtls_ripemd160_context *) ctx, output );
+ return( mbedtls_ripemd160_finish_ret( (mbedtls_ripemd160_context *) ctx,
+ output ) );
}
static void *ripemd160_ctx_alloc( void )
(const mbedtls_ripemd160_context *) src );
}
-static void ripemd160_process_wrap( void *ctx, const unsigned char *data )
+static int ripemd160_process_wrap( void *ctx, const unsigned char *data )
{
- mbedtls_ripemd160_process( (mbedtls_ripemd160_context *) ctx, data );
+ return( mbedtls_internal_ripemd160_process(
+ (mbedtls_ripemd160_context *) ctx, data ) );
}
const mbedtls_md_info_t mbedtls_ripemd160_info = {
ripemd160_starts_wrap,
ripemd160_update_wrap,
ripemd160_finish_wrap,
- mbedtls_ripemd160,
+ mbedtls_ripemd160_ret,
ripemd160_ctx_alloc,
ripemd160_ctx_free,
ripemd160_clone_wrap,
#if defined(MBEDTLS_SHA1_C)
-static void sha1_starts_wrap( void *ctx )
+static int sha1_starts_wrap( void *ctx )
{
- mbedtls_sha1_starts( (mbedtls_sha1_context *) ctx );
+ return( mbedtls_sha1_starts_ret( (mbedtls_sha1_context *) ctx ) );
}
-static void sha1_update_wrap( void *ctx, const unsigned char *input,
+static int sha1_update_wrap( void *ctx, const unsigned char *input,
size_t ilen )
{
- mbedtls_sha1_update( (mbedtls_sha1_context *) ctx, input, ilen );
+ return( mbedtls_sha1_update_ret( (mbedtls_sha1_context *) ctx,
+ input, ilen ) );
}
-static void sha1_finish_wrap( void *ctx, unsigned char *output )
+static int sha1_finish_wrap( void *ctx, unsigned char *output )
{
- mbedtls_sha1_finish( (mbedtls_sha1_context *) ctx, output );
+ return( mbedtls_sha1_finish_ret( (mbedtls_sha1_context *) ctx, output ) );
}
static void *sha1_ctx_alloc( void )
mbedtls_free( ctx );
}
-static void sha1_process_wrap( void *ctx, const unsigned char *data )
+static int sha1_process_wrap( void *ctx, const unsigned char *data )
{
- mbedtls_sha1_process( (mbedtls_sha1_context *) ctx, data );
+ return( mbedtls_internal_sha1_process( (mbedtls_sha1_context *) ctx,
+ data ) );
}
const mbedtls_md_info_t mbedtls_sha1_info = {
sha1_starts_wrap,
sha1_update_wrap,
sha1_finish_wrap,
- mbedtls_sha1,
+ mbedtls_sha1_ret,
sha1_ctx_alloc,
sha1_ctx_free,
sha1_clone_wrap,
*/
#if defined(MBEDTLS_SHA256_C)
-static void sha224_starts_wrap( void *ctx )
+static int sha224_starts_wrap( void *ctx )
{
- mbedtls_sha256_starts( (mbedtls_sha256_context *) ctx, 1 );
+ return( mbedtls_sha256_starts_ret( (mbedtls_sha256_context *) ctx, 1 ) );
}
-static void sha224_update_wrap( void *ctx, const unsigned char *input,
+static int sha224_update_wrap( void *ctx, const unsigned char *input,
size_t ilen )
{
- mbedtls_sha256_update( (mbedtls_sha256_context *) ctx, input, ilen );
+ return( mbedtls_sha256_update_ret( (mbedtls_sha256_context *) ctx,
+ input, ilen ) );
}
-static void sha224_finish_wrap( void *ctx, unsigned char *output )
+static int sha224_finish_wrap( void *ctx, unsigned char *output )
{
- mbedtls_sha256_finish( (mbedtls_sha256_context *) ctx, output );
+ return( mbedtls_sha256_finish_ret( (mbedtls_sha256_context *) ctx,
+ output ) );
}
-static void sha224_wrap( const unsigned char *input, size_t ilen,
- unsigned char *output )
+static int sha224_wrap( const unsigned char *input, size_t ilen,
+ unsigned char *output )
{
- mbedtls_sha256( input, ilen, output, 1 );
+ return( mbedtls_sha256_ret( input, ilen, output, 1 ) );
}
static void *sha224_ctx_alloc( void )
(const mbedtls_sha256_context *) src );
}
-static void sha224_process_wrap( void *ctx, const unsigned char *data )
+static int sha224_process_wrap( void *ctx, const unsigned char *data )
{
- mbedtls_sha256_process( (mbedtls_sha256_context *) ctx, data );
+ return( mbedtls_internal_sha256_process( (mbedtls_sha256_context *) ctx,
+ data ) );
}
const mbedtls_md_info_t mbedtls_sha224_info = {
sha224_process_wrap,
};
-static void sha256_starts_wrap( void *ctx )
+static int sha256_starts_wrap( void *ctx )
{
- mbedtls_sha256_starts( (mbedtls_sha256_context *) ctx, 0 );
+ return( mbedtls_sha256_starts_ret( (mbedtls_sha256_context *) ctx, 0 ) );
}
-static void sha256_wrap( const unsigned char *input, size_t ilen,
- unsigned char *output )
+static int sha256_wrap( const unsigned char *input, size_t ilen,
+ unsigned char *output )
{
- mbedtls_sha256( input, ilen, output, 0 );
+ return( mbedtls_sha256_ret( input, ilen, output, 0 ) );
}
const mbedtls_md_info_t mbedtls_sha256_info = {
#if defined(MBEDTLS_SHA512_C)
-static void sha384_starts_wrap( void *ctx )
+static int sha384_starts_wrap( void *ctx )
{
- mbedtls_sha512_starts( (mbedtls_sha512_context *) ctx, 1 );
+ return( mbedtls_sha512_starts_ret( (mbedtls_sha512_context *) ctx, 1 ) );
}
-static void sha384_update_wrap( void *ctx, const unsigned char *input,
- size_t ilen )
+static int sha384_update_wrap( void *ctx, const unsigned char *input,
+ size_t ilen )
{
- mbedtls_sha512_update( (mbedtls_sha512_context *) ctx, input, ilen );
+ return( mbedtls_sha512_update_ret( (mbedtls_sha512_context *) ctx,
+ input, ilen ) );
}
-static void sha384_finish_wrap( void *ctx, unsigned char *output )
+static int sha384_finish_wrap( void *ctx, unsigned char *output )
{
- mbedtls_sha512_finish( (mbedtls_sha512_context *) ctx, output );
+ return( mbedtls_sha512_finish_ret( (mbedtls_sha512_context *) ctx,
+ output ) );
}
-static void sha384_wrap( const unsigned char *input, size_t ilen,
- unsigned char *output )
+static int sha384_wrap( const unsigned char *input, size_t ilen,
+ unsigned char *output )
{
- mbedtls_sha512( input, ilen, output, 1 );
+ return( mbedtls_sha512_ret( input, ilen, output, 1 ) );
}
static void *sha384_ctx_alloc( void )
(const mbedtls_sha512_context *) src );
}
-static void sha384_process_wrap( void *ctx, const unsigned char *data )
+static int sha384_process_wrap( void *ctx, const unsigned char *data )
{
- mbedtls_sha512_process( (mbedtls_sha512_context *) ctx, data );
+ return( mbedtls_internal_sha512_process( (mbedtls_sha512_context *) ctx,
+ data ) );
}
const mbedtls_md_info_t mbedtls_sha384_info = {
sha384_process_wrap,
};
-static void sha512_starts_wrap( void *ctx )
+static int sha512_starts_wrap( void *ctx )
{
- mbedtls_sha512_starts( (mbedtls_sha512_context *) ctx, 0 );
+ return( mbedtls_sha512_starts_ret( (mbedtls_sha512_context *) ctx, 0 ) );
}
-static void sha512_wrap( const unsigned char *input, size_t ilen,
- unsigned char *output )
+static int sha512_wrap( const unsigned char *input, size_t ilen,
+ unsigned char *output )
{
- mbedtls_sha512( input, ilen, output, 0 );
+ return( mbedtls_sha512_ret( input, ilen, output, 0 ) );
}
const mbedtls_md_info_t mbedtls_sha512_info = {
#endif
}
-static void debug_chain()
+static void debug_chain( void )
{
memory_header *cur = heap.first;
return( 0 );
}
-static int verify_chain()
+static int verify_chain( void )
{
- memory_header *prv = heap.first, *cur = heap.first->next;
+ memory_header *prv = heap.first, *cur;
- if( verify_header( heap.first ) != 0 )
+ if( prv == NULL || verify_header( prv ) != 0 )
{
#if defined(MBEDTLS_MEMORY_DEBUG)
mbedtls_fprintf( stderr, "FATAL: verification of first header "
return( 1 );
}
+ cur = heap.first->next;
+
while( cur != NULL )
{
if( verify_header( cur ) != 0 )
original_len = len = n * size;
- if( n != 0 && len / n != size )
+ if( n == 0 || size == 0 || len / n != size )
+ return( NULL );
+ else if( len > (size_t)-MBEDTLS_MEMORY_ALIGN_MULTIPLE )
return( NULL );
if( len % MBEDTLS_MEMORY_ALIGN_MULTIPLE )
if( ptr == NULL || heap.buf == NULL || heap.first == NULL )
return;
- if( p < heap.buf || p > heap.buf + heap.len )
+ if( p < heap.buf || p >= heap.buf + heap.len )
{
#if defined(MBEDTLS_MEMORY_DEBUG)
mbedtls_fprintf( stderr, "FATAL: mbedtls_free() outside of managed "
heap.verify = verify;
}
-int mbedtls_memory_buffer_alloc_verify()
+int mbedtls_memory_buffer_alloc_verify( void )
{
return verify_chain();
}
#if defined(MBEDTLS_MEMORY_DEBUG)
-void mbedtls_memory_buffer_alloc_status()
+void mbedtls_memory_buffer_alloc_status( void )
{
mbedtls_fprintf( stderr,
"Current use: %zu blocks / %zu bytes, max: %zu blocks / "
void mbedtls_memory_buffer_alloc_init( unsigned char *buf, size_t len )
{
- memset( &heap, 0, sizeof(buffer_alloc_ctx) );
- memset( buf, 0, len );
+ memset( &heap, 0, sizeof( buffer_alloc_ctx ) );
#if defined(MBEDTLS_THREADING_C)
mbedtls_mutex_init( &heap.mutex );
mbedtls_platform_set_calloc_free( buffer_alloc_calloc, buffer_alloc_free );
#endif
- if( (size_t) buf % MBEDTLS_MEMORY_ALIGN_MULTIPLE )
+ if( len < sizeof( memory_header ) + MBEDTLS_MEMORY_ALIGN_MULTIPLE )
+ return;
+ else if( (size_t)buf % MBEDTLS_MEMORY_ALIGN_MULTIPLE )
{
/* Adjust len first since buf is used in the computation */
len -= MBEDTLS_MEMORY_ALIGN_MULTIPLE
- - (size_t) buf % MBEDTLS_MEMORY_ALIGN_MULTIPLE;
+ - (size_t)buf % MBEDTLS_MEMORY_ALIGN_MULTIPLE;
buf += MBEDTLS_MEMORY_ALIGN_MULTIPLE
- - (size_t) buf % MBEDTLS_MEMORY_ALIGN_MULTIPLE;
+ - (size_t)buf % MBEDTLS_MEMORY_ALIGN_MULTIPLE;
}
+ memset( buf, 0, len );
+
heap.buf = buf;
heap.len = len;
- heap.first = (memory_header *) buf;
- heap.first->size = len - sizeof(memory_header);
+ heap.first = (memory_header *)buf;
+ heap.first->size = len - sizeof( memory_header );
heap.first->magic1 = MAGIC1;
heap.first->magic2 = MAGIC2;
heap.first_free = heap.first;
}
-void mbedtls_memory_buffer_alloc_free()
+void mbedtls_memory_buffer_alloc_free( void )
{
#if defined(MBEDTLS_THREADING_C)
mbedtls_mutex_free( &heap.mutex );
return( 0 );
}
-static int check_all_free( )
+static int check_all_free( void )
{
if(
#if defined(MBEDTLS_MEMORY_DEBUG)
#endif
#endif /* _MSC_VER */
-#define read(fd,buf,len) recv(fd,(char*)buf,(int) len,0)
-#define write(fd,buf,len) send(fd,(char*)buf,(int) len,0)
+#define read(fd,buf,len) recv( fd, (char*)( buf ), (int)( len ), 0 )
+#define write(fd,buf,len) send( fd, (char*)( buf ), (int)( len ), 0 )
#define close(fd) closesocket(fd)
static int wsa_init_done = 0;
#endif /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */
/* Some MS functions want int and MSVC warns if we pass size_t,
- * but the standard fucntions use socklen_t, so cast only for MSVC */
+ * but the standard functions use socklen_t, so cast only for MSVC */
#if defined(_MSC_VER)
#define MSVC_INT_CAST (int)
#else
/*
* Initiate a TCP connection with host:port and the given protocol
*/
-int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto )
+int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host,
+ const char *port, int proto )
{
int ret;
struct addrinfo hints, *addr_list, *cur;
}
}
- /* I we ever get there, it's a success */
+ /* Bind was successful */
ret = 0;
break;
}
*/
static int net_would_block( const mbedtls_net_context *ctx )
{
+ int err = errno;
+
/*
* Never return 'WOULD BLOCK' on a non-blocking socket
*/
if( ( fcntl( ctx->fd, F_GETFL ) & O_NONBLOCK ) != O_NONBLOCK )
+ {
+ errno = err;
return( 0 );
+ }
- switch( errno )
+ switch( errno = err )
{
#if defined EAGAIN
case EAGAIN:
{
/* TCP: actual accept() */
ret = client_ctx->fd = (int) accept( bind_ctx->fd,
- (struct sockaddr *) &client_addr, &n );
+ (struct sockaddr *) &client_addr, &n );
}
else
{
FN_OID_TYPED_FROM_ASN1(oid_md_alg_t, md_alg, oid_md_alg)
FN_OID_GET_ATTR1(mbedtls_oid_get_md_alg, oid_md_alg_t, md_alg, mbedtls_md_type_t, md_alg)
FN_OID_GET_OID_BY_ATTR1(mbedtls_oid_get_oid_by_md, oid_md_alg_t, oid_md_alg, mbedtls_md_type_t, md_alg)
+
+/*
+ * For HMAC digestAlgorithm
+ */
+typedef struct {
+ mbedtls_oid_descriptor_t descriptor;
+ mbedtls_md_type_t md_hmac;
+} oid_md_hmac_t;
+
+static const oid_md_hmac_t oid_md_hmac[] =
+{
+#if defined(MBEDTLS_SHA1_C)
+ {
+ { ADD_LEN( MBEDTLS_OID_HMAC_SHA1 ), "hmacSHA1", "HMAC-SHA-1" },
+ MBEDTLS_MD_SHA1,
+ },
+#endif /* MBEDTLS_SHA1_C */
+#if defined(MBEDTLS_SHA256_C)
+ {
+ { ADD_LEN( MBEDTLS_OID_HMAC_SHA224 ), "hmacSHA224", "HMAC-SHA-224" },
+ MBEDTLS_MD_SHA224,
+ },
+ {
+ { ADD_LEN( MBEDTLS_OID_HMAC_SHA256 ), "hmacSHA256", "HMAC-SHA-256" },
+ MBEDTLS_MD_SHA256,
+ },
+#endif /* MBEDTLS_SHA256_C */
+#if defined(MBEDTLS_SHA512_C)
+ {
+ { ADD_LEN( MBEDTLS_OID_HMAC_SHA384 ), "hmacSHA384", "HMAC-SHA-384" },
+ MBEDTLS_MD_SHA384,
+ },
+ {
+ { ADD_LEN( MBEDTLS_OID_HMAC_SHA512 ), "hmacSHA512", "HMAC-SHA-512" },
+ MBEDTLS_MD_SHA512,
+ },
+#endif /* MBEDTLS_SHA512_C */
+ {
+ { NULL, 0, NULL, NULL },
+ MBEDTLS_MD_NONE,
+ },
+};
+
+FN_OID_TYPED_FROM_ASN1(oid_md_hmac_t, md_hmac, oid_md_hmac)
+FN_OID_GET_ATTR1(mbedtls_oid_get_md_hmac, oid_md_hmac_t, md_hmac, mbedtls_md_type_t, md_hmac)
#endif /* MBEDTLS_MD_C */
#if defined(MBEDTLS_PKCS12_C)
#define mbedtls_free free
#endif
+#if defined(MBEDTLS_PEM_PARSE_C)
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
}
-#if defined(MBEDTLS_PEM_PARSE_C)
void mbedtls_pem_init( mbedtls_pem_context *ctx )
{
memset( ctx, 0, sizeof( mbedtls_pem_context ) );
return( 0 );
}
-static void pem_pbkdf1( unsigned char *key, size_t keylen,
- unsigned char *iv,
- const unsigned char *pwd, size_t pwdlen )
+static int pem_pbkdf1( unsigned char *key, size_t keylen,
+ unsigned char *iv,
+ const unsigned char *pwd, size_t pwdlen )
{
mbedtls_md5_context md5_ctx;
unsigned char md5sum[16];
size_t use_len;
+ int ret;
mbedtls_md5_init( &md5_ctx );
/*
* key[ 0..15] = MD5(pwd || IV)
*/
- mbedtls_md5_starts( &md5_ctx );
- mbedtls_md5_update( &md5_ctx, pwd, pwdlen );
- mbedtls_md5_update( &md5_ctx, iv, 8 );
- mbedtls_md5_finish( &md5_ctx, md5sum );
+ if( ( ret = mbedtls_md5_starts_ret( &md5_ctx ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md5_update_ret( &md5_ctx, pwd, pwdlen ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md5_update_ret( &md5_ctx, iv, 8 ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md5_finish_ret( &md5_ctx, md5sum ) ) != 0 )
+ goto exit;
if( keylen <= 16 )
{
memcpy( key, md5sum, keylen );
-
- mbedtls_md5_free( &md5_ctx );
- mbedtls_zeroize( md5sum, 16 );
- return;
+ goto exit;
}
memcpy( key, md5sum, 16 );
/*
* key[16..23] = MD5(key[ 0..15] || pwd || IV])
*/
- mbedtls_md5_starts( &md5_ctx );
- mbedtls_md5_update( &md5_ctx, md5sum, 16 );
- mbedtls_md5_update( &md5_ctx, pwd, pwdlen );
- mbedtls_md5_update( &md5_ctx, iv, 8 );
- mbedtls_md5_finish( &md5_ctx, md5sum );
+ if( ( ret = mbedtls_md5_starts_ret( &md5_ctx ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md5_update_ret( &md5_ctx, md5sum, 16 ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md5_update_ret( &md5_ctx, pwd, pwdlen ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md5_update_ret( &md5_ctx, iv, 8 ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md5_finish_ret( &md5_ctx, md5sum ) ) != 0 )
+ goto exit;
use_len = 16;
if( keylen < 32 )
memcpy( key + 16, md5sum, use_len );
+exit:
mbedtls_md5_free( &md5_ctx );
mbedtls_zeroize( md5sum, 16 );
+
+ return( ret );
}
#if defined(MBEDTLS_DES_C)
/*
* Decrypt with DES-CBC, using PBKDF1 for key derivation
*/
-static void pem_des_decrypt( unsigned char des_iv[8],
- unsigned char *buf, size_t buflen,
- const unsigned char *pwd, size_t pwdlen )
+static int pem_des_decrypt( unsigned char des_iv[8],
+ unsigned char *buf, size_t buflen,
+ const unsigned char *pwd, size_t pwdlen )
{
mbedtls_des_context des_ctx;
unsigned char des_key[8];
+ int ret;
mbedtls_des_init( &des_ctx );
- pem_pbkdf1( des_key, 8, des_iv, pwd, pwdlen );
+ if( ( ret = pem_pbkdf1( des_key, 8, des_iv, pwd, pwdlen ) ) != 0 )
+ goto exit;
- mbedtls_des_setkey_dec( &des_ctx, des_key );
- mbedtls_des_crypt_cbc( &des_ctx, MBEDTLS_DES_DECRYPT, buflen,
+ if( ( ret = mbedtls_des_setkey_dec( &des_ctx, des_key ) ) != 0 )
+ goto exit;
+ ret = mbedtls_des_crypt_cbc( &des_ctx, MBEDTLS_DES_DECRYPT, buflen,
des_iv, buf, buf );
+exit:
mbedtls_des_free( &des_ctx );
mbedtls_zeroize( des_key, 8 );
+
+ return( ret );
}
/*
* Decrypt with 3DES-CBC, using PBKDF1 for key derivation
*/
-static void pem_des3_decrypt( unsigned char des3_iv[8],
- unsigned char *buf, size_t buflen,
- const unsigned char *pwd, size_t pwdlen )
+static int pem_des3_decrypt( unsigned char des3_iv[8],
+ unsigned char *buf, size_t buflen,
+ const unsigned char *pwd, size_t pwdlen )
{
mbedtls_des3_context des3_ctx;
unsigned char des3_key[24];
+ int ret;
mbedtls_des3_init( &des3_ctx );
- pem_pbkdf1( des3_key, 24, des3_iv, pwd, pwdlen );
+ if( ( ret = pem_pbkdf1( des3_key, 24, des3_iv, pwd, pwdlen ) ) != 0 )
+ goto exit;
- mbedtls_des3_set3key_dec( &des3_ctx, des3_key );
- mbedtls_des3_crypt_cbc( &des3_ctx, MBEDTLS_DES_DECRYPT, buflen,
+ if( ( ret = mbedtls_des3_set3key_dec( &des3_ctx, des3_key ) ) != 0 )
+ goto exit;
+ ret = mbedtls_des3_crypt_cbc( &des3_ctx, MBEDTLS_DES_DECRYPT, buflen,
des3_iv, buf, buf );
+exit:
mbedtls_des3_free( &des3_ctx );
mbedtls_zeroize( des3_key, 24 );
+
+ return( ret );
}
#endif /* MBEDTLS_DES_C */
/*
* Decrypt with AES-XXX-CBC, using PBKDF1 for key derivation
*/
-static void pem_aes_decrypt( unsigned char aes_iv[16], unsigned int keylen,
- unsigned char *buf, size_t buflen,
- const unsigned char *pwd, size_t pwdlen )
+static int pem_aes_decrypt( unsigned char aes_iv[16], unsigned int keylen,
+ unsigned char *buf, size_t buflen,
+ const unsigned char *pwd, size_t pwdlen )
{
mbedtls_aes_context aes_ctx;
unsigned char aes_key[32];
+ int ret;
mbedtls_aes_init( &aes_ctx );
- pem_pbkdf1( aes_key, keylen, aes_iv, pwd, pwdlen );
+ if( ( ret = pem_pbkdf1( aes_key, keylen, aes_iv, pwd, pwdlen ) ) != 0 )
+ goto exit;
- mbedtls_aes_setkey_dec( &aes_ctx, aes_key, keylen * 8 );
- mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_DECRYPT, buflen,
+ if( ( ret = mbedtls_aes_setkey_dec( &aes_ctx, aes_key, keylen * 8 ) ) != 0 )
+ goto exit;
+ ret = mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_DECRYPT, buflen,
aes_iv, buf, buf );
+exit:
mbedtls_aes_free( &aes_ctx );
mbedtls_zeroize( aes_key, keylen );
+
+ return( ret );
}
#endif /* MBEDTLS_AES_C */
enc = 0;
- if( memcmp( s1, "Proc-Type: 4,ENCRYPTED", 22 ) == 0 )
+ if( s2 - s1 >= 22 && memcmp( s1, "Proc-Type: 4,ENCRYPTED", 22 ) == 0 )
{
#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \
( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) )
#if defined(MBEDTLS_DES_C)
- if( memcmp( s1, "DEK-Info: DES-EDE3-CBC,", 23 ) == 0 )
+ if( s2 - s1 >= 23 && memcmp( s1, "DEK-Info: DES-EDE3-CBC,", 23 ) == 0 )
{
enc_alg = MBEDTLS_CIPHER_DES_EDE3_CBC;
s1 += 23;
- if( pem_get_iv( s1, pem_iv, 8 ) != 0 )
+ if( s2 - s1 < 16 || pem_get_iv( s1, pem_iv, 8 ) != 0 )
return( MBEDTLS_ERR_PEM_INVALID_ENC_IV );
s1 += 16;
}
- else if( memcmp( s1, "DEK-Info: DES-CBC,", 18 ) == 0 )
+ else if( s2 - s1 >= 18 && memcmp( s1, "DEK-Info: DES-CBC,", 18 ) == 0 )
{
enc_alg = MBEDTLS_CIPHER_DES_CBC;
s1 += 18;
- if( pem_get_iv( s1, pem_iv, 8) != 0 )
+ if( s2 - s1 < 16 || pem_get_iv( s1, pem_iv, 8) != 0 )
return( MBEDTLS_ERR_PEM_INVALID_ENC_IV );
s1 += 16;
#endif /* MBEDTLS_DES_C */
#if defined(MBEDTLS_AES_C)
- if( memcmp( s1, "DEK-Info: AES-", 14 ) == 0 )
+ if( s2 - s1 >= 14 && memcmp( s1, "DEK-Info: AES-", 14 ) == 0 )
{
- if( memcmp( s1, "DEK-Info: AES-128-CBC,", 22 ) == 0 )
+ if( s2 - s1 < 22 )
+ return( MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG );
+ else if( memcmp( s1, "DEK-Info: AES-128-CBC,", 22 ) == 0 )
enc_alg = MBEDTLS_CIPHER_AES_128_CBC;
else if( memcmp( s1, "DEK-Info: AES-192-CBC,", 22 ) == 0 )
enc_alg = MBEDTLS_CIPHER_AES_192_CBC;
return( MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG );
s1 += 22;
- if( pem_get_iv( s1, pem_iv, 16 ) != 0 )
+ if( s2 - s1 < 32 || pem_get_iv( s1, pem_iv, 16 ) != 0 )
return( MBEDTLS_ERR_PEM_INVALID_ENC_IV );
s1 += 32;
( MBEDTLS_AES_C || MBEDTLS_DES_C ) */
}
- if( s1 == s2 )
+ if( s1 >= s2 )
return( MBEDTLS_ERR_PEM_INVALID_DATA );
ret = mbedtls_base64_decode( NULL, 0, &len, s1, s2 - s1 );
if( ( ret = mbedtls_base64_decode( buf, len, &len, s1, s2 - s1 ) ) != 0 )
{
+ mbedtls_zeroize( buf, len );
mbedtls_free( buf );
return( MBEDTLS_ERR_PEM_INVALID_DATA + ret );
}
( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) )
if( pwd == NULL )
{
+ mbedtls_zeroize( buf, len );
mbedtls_free( buf );
return( MBEDTLS_ERR_PEM_PASSWORD_REQUIRED );
}
+ ret = 0;
+
#if defined(MBEDTLS_DES_C)
if( enc_alg == MBEDTLS_CIPHER_DES_EDE3_CBC )
- pem_des3_decrypt( pem_iv, buf, len, pwd, pwdlen );
+ ret = pem_des3_decrypt( pem_iv, buf, len, pwd, pwdlen );
else if( enc_alg == MBEDTLS_CIPHER_DES_CBC )
- pem_des_decrypt( pem_iv, buf, len, pwd, pwdlen );
+ ret = pem_des_decrypt( pem_iv, buf, len, pwd, pwdlen );
#endif /* MBEDTLS_DES_C */
#if defined(MBEDTLS_AES_C)
if( enc_alg == MBEDTLS_CIPHER_AES_128_CBC )
- pem_aes_decrypt( pem_iv, 16, buf, len, pwd, pwdlen );
+ ret = pem_aes_decrypt( pem_iv, 16, buf, len, pwd, pwdlen );
else if( enc_alg == MBEDTLS_CIPHER_AES_192_CBC )
- pem_aes_decrypt( pem_iv, 24, buf, len, pwd, pwdlen );
+ ret = pem_aes_decrypt( pem_iv, 24, buf, len, pwd, pwdlen );
else if( enc_alg == MBEDTLS_CIPHER_AES_256_CBC )
- pem_aes_decrypt( pem_iv, 32, buf, len, pwd, pwdlen );
+ ret = pem_aes_decrypt( pem_iv, 32, buf, len, pwd, pwdlen );
#endif /* MBEDTLS_AES_C */
+ if( ret != 0 )
+ {
+ mbedtls_free( buf );
+ return( ret );
+ }
+
/*
* The result will be ASN.1 starting with a SEQUENCE tag, with 1 to 3
* length bytes (allow 4 to be sure) in all known use cases.
*/
if( len <= 2 || buf[0] != 0x30 || buf[1] > 0x83 )
{
+ mbedtls_zeroize( buf, len );
mbedtls_free( buf );
return( MBEDTLS_ERR_PEM_PASSWORD_MISMATCH );
}
#else
+ mbedtls_zeroize( buf, len );
mbedtls_free( buf );
return( MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE );
#endif /* MBEDTLS_MD5_C && MBEDTLS_CIPHER_MODE_CBC &&
void mbedtls_pem_free( mbedtls_pem_context *ctx )
{
+ if( ctx->buf != NULL )
+ mbedtls_zeroize( ctx->buf, ctx->buflen );
mbedtls_free( ctx->buf );
mbedtls_free( ctx->info );
unsigned char *buf, size_t buf_len, size_t *olen )
{
int ret;
- unsigned char *encode_buf, *c, *p = buf;
+ unsigned char *encode_buf = NULL, *c, *p = buf;
size_t len = 0, use_len, add_len = 0;
mbedtls_base64_encode( NULL, 0, &use_len, der_data, der_len );
return( MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL );
}
- if( ( encode_buf = mbedtls_calloc( 1, use_len ) ) == NULL )
+ if( use_len != 0 &&
+ ( ( encode_buf = mbedtls_calloc( 1, use_len ) ) == NULL ) )
return( MBEDTLS_ERR_PEM_ALLOC_FAILED );
if( ( ret = mbedtls_base64_encode( encode_buf, use_len, &use_len, der_data,
#include "mbedtls/ecdsa.h"
#endif
+#include <limits.h>
+#include <stdint.h>
+
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
int ret;
const mbedtls_pk_rsassa_pss_options *pss_opts;
+#if SIZE_MAX > UINT_MAX
+ if( md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len )
+ return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
+#endif /* SIZE_MAX > UINT_MAX */
+
if( options == NULL )
return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
return( 0 );
#else
return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
-#endif
+#endif /* MBEDTLS_RSA_C && MBEDTLS_PKCS1_V21 */
}
/* General case: no options */
#define mbedtls_free free
#endif
+#include <limits.h>
+#include <stdint.h>
+
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
static size_t rsa_get_bitlen( const void *ctx )
{
- return( 8 * ((const mbedtls_rsa_context *) ctx)->len );
+ const mbedtls_rsa_context * rsa = (const mbedtls_rsa_context *) ctx;
+ return( 8 * mbedtls_rsa_get_len( rsa ) );
}
static int rsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg,
const unsigned char *sig, size_t sig_len )
{
int ret;
+ mbedtls_rsa_context * rsa = (mbedtls_rsa_context *) ctx;
+ size_t rsa_len = mbedtls_rsa_get_len( rsa );
+
+#if SIZE_MAX > UINT_MAX
+ if( md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len )
+ return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
+#endif /* SIZE_MAX > UINT_MAX */
- if( sig_len < ((mbedtls_rsa_context *) ctx)->len )
+ if( sig_len < rsa_len )
return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
- if( ( ret = mbedtls_rsa_pkcs1_verify( (mbedtls_rsa_context *) ctx, NULL, NULL,
+ if( ( ret = mbedtls_rsa_pkcs1_verify( rsa, NULL, NULL,
MBEDTLS_RSA_PUBLIC, md_alg,
(unsigned int) hash_len, hash, sig ) ) != 0 )
return( ret );
- if( sig_len > ((mbedtls_rsa_context *) ctx)->len )
+ if( sig_len > rsa_len )
return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH );
return( 0 );
unsigned char *sig, size_t *sig_len,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
- *sig_len = ((mbedtls_rsa_context *) ctx)->len;
+ mbedtls_rsa_context * rsa = (mbedtls_rsa_context *) ctx;
+
+#if SIZE_MAX > UINT_MAX
+ if( md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len )
+ return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
+#endif /* SIZE_MAX > UINT_MAX */
- return( mbedtls_rsa_pkcs1_sign( (mbedtls_rsa_context *) ctx, f_rng, p_rng, MBEDTLS_RSA_PRIVATE,
+ *sig_len = mbedtls_rsa_get_len( rsa );
+
+ return( mbedtls_rsa_pkcs1_sign( rsa, f_rng, p_rng, MBEDTLS_RSA_PRIVATE,
md_alg, (unsigned int) hash_len, hash, sig ) );
}
unsigned char *output, size_t *olen, size_t osize,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
- if( ilen != ((mbedtls_rsa_context *) ctx)->len )
+ mbedtls_rsa_context * rsa = (mbedtls_rsa_context *) ctx;
+
+ if( ilen != mbedtls_rsa_get_len( rsa ) )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
- return( mbedtls_rsa_pkcs1_decrypt( (mbedtls_rsa_context *) ctx, f_rng, p_rng,
+ return( mbedtls_rsa_pkcs1_decrypt( rsa, f_rng, p_rng,
MBEDTLS_RSA_PRIVATE, olen, input, output, osize ) );
}
unsigned char *output, size_t *olen, size_t osize,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
{
- *olen = ((mbedtls_rsa_context *) ctx)->len;
+ mbedtls_rsa_context * rsa = (mbedtls_rsa_context *) ctx;
+ *olen = mbedtls_rsa_get_len( rsa );
if( *olen > osize )
return( MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE );
- return( mbedtls_rsa_pkcs1_encrypt( (mbedtls_rsa_context *) ctx,
- f_rng, p_rng, MBEDTLS_RSA_PUBLIC, ilen, input, output ) );
+ return( mbedtls_rsa_pkcs1_encrypt( rsa, f_rng, p_rng, MBEDTLS_RSA_PUBLIC,
+ ilen, input, output ) );
}
static int rsa_check_pair_wrap( const void *pub, const void *prv )
{
mbedtls_rsa_alt_context *rsa_alt = (mbedtls_rsa_alt_context *) ctx;
+#if SIZE_MAX > UINT_MAX
+ if( UINT_MAX < hash_len )
+ return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
+#endif /* SIZE_MAX > UINT_MAX */
+
*sig_len = rsa_alt->key_len_func( rsa_alt->key );
return( rsa_alt->sign_func( rsa_alt->key, f_rng, p_rng, MBEDTLS_RSA_PRIVATE,
if( ( ret = mbedtls_asn1_get_alg_null( &p, end, &prf_alg_oid ) ) != 0 )
return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT + ret );
- if( MBEDTLS_OID_CMP( MBEDTLS_OID_HMAC_SHA1, &prf_alg_oid ) != 0 )
+ if( mbedtls_oid_get_md_hmac( &prf_alg_oid, md_type ) != 0 )
return( MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE );
- *md_type = MBEDTLS_MD_SHA1;
-
if( p != end )
return( MBEDTLS_ERR_PKCS5_INVALID_FORMAT +
MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
#define mbedtls_free free
#endif
-#if defined(MBEDTLS_FS_IO)
+#if defined(MBEDTLS_FS_IO) || \
+ defined(MBEDTLS_PKCS12_C) || defined(MBEDTLS_PKCS5_C)
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
}
+#endif
+#if defined(MBEDTLS_FS_IO)
/*
* Load all data from a file into a given buffer.
*
if( fread( *buf, 1, *n, f ) != *n )
{
fclose( f );
+
+ mbedtls_zeroize( *buf, *n );
mbedtls_free( *buf );
+
return( MBEDTLS_ERR_PK_FILE_IO_ERROR );
}
{
int ret;
+ if ( end - *p < 1 )
+ return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT +
+ MBEDTLS_ERR_ASN1_OUT_OF_DATA );
+
/* Tag may be either OID or SEQUENCE */
params->tag = **p;
if( params->tag != MBEDTLS_ASN1_OID
return( MBEDTLS_ERR_PK_INVALID_PUBKEY +
MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
- if( ( ret = mbedtls_asn1_get_mpi( p, end, &rsa->N ) ) != 0 ||
- ( ret = mbedtls_asn1_get_mpi( p, end, &rsa->E ) ) != 0 )
+ /* Import N */
+ if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_INTEGER ) ) != 0 )
return( MBEDTLS_ERR_PK_INVALID_PUBKEY + ret );
- if( *p != end )
- return( MBEDTLS_ERR_PK_INVALID_PUBKEY +
- MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
+ if( ( ret = mbedtls_rsa_import_raw( rsa, *p, len, NULL, 0, NULL, 0,
+ NULL, 0, NULL, 0 ) ) != 0 )
+ return( MBEDTLS_ERR_PK_INVALID_PUBKEY );
+
+ *p += len;
+
+ /* Import E */
+ if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_INTEGER ) ) != 0 )
+ return( MBEDTLS_ERR_PK_INVALID_PUBKEY + ret );
- if( ( ret = mbedtls_rsa_check_pubkey( rsa ) ) != 0 )
+ if( ( ret = mbedtls_rsa_import_raw( rsa, NULL, 0, NULL, 0, NULL, 0,
+ NULL, 0, *p, len ) ) != 0 )
return( MBEDTLS_ERR_PK_INVALID_PUBKEY );
- rsa->len = mbedtls_mpi_size( &rsa->N );
+ *p += len;
+
+ if( mbedtls_rsa_complete( rsa ) != 0 ||
+ mbedtls_rsa_check_pubkey( rsa ) != 0 )
+ {
+ return( MBEDTLS_ERR_PK_INVALID_PUBKEY );
+ }
+
+ if( *p != end )
+ return( MBEDTLS_ERR_PK_INVALID_PUBKEY +
+ MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
return( 0 );
}
const unsigned char *key,
size_t keylen )
{
- int ret;
+ int ret, version;
size_t len;
unsigned char *p, *end;
+ mbedtls_mpi T;
+ mbedtls_mpi_init( &T );
+
p = (unsigned char *) key;
end = p + keylen;
end = p + len;
- if( ( ret = mbedtls_asn1_get_int( &p, end, &rsa->ver ) ) != 0 )
+ if( ( ret = mbedtls_asn1_get_int( &p, end, &version ) ) != 0 )
{
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret );
}
- if( rsa->ver != 0 )
+ if( version != 0 )
{
return( MBEDTLS_ERR_PK_KEY_INVALID_VERSION );
}
- if( ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->N ) ) != 0 ||
- ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->E ) ) != 0 ||
- ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->D ) ) != 0 ||
- ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->P ) ) != 0 ||
- ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->Q ) ) != 0 ||
- ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->DP ) ) != 0 ||
- ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->DQ ) ) != 0 ||
- ( ret = mbedtls_asn1_get_mpi( &p, end, &rsa->QP ) ) != 0 )
- {
- mbedtls_rsa_free( rsa );
- return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret );
- }
+ /* Import N */
+ if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
+ MBEDTLS_ASN1_INTEGER ) ) != 0 ||
+ ( ret = mbedtls_rsa_import_raw( rsa, p, len, NULL, 0, NULL, 0,
+ NULL, 0, NULL, 0 ) ) != 0 )
+ goto cleanup;
+ p += len;
+
+ /* Import E */
+ if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
+ MBEDTLS_ASN1_INTEGER ) ) != 0 ||
+ ( ret = mbedtls_rsa_import_raw( rsa, NULL, 0, NULL, 0, NULL, 0,
+ NULL, 0, p, len ) ) != 0 )
+ goto cleanup;
+ p += len;
- rsa->len = mbedtls_mpi_size( &rsa->N );
+ /* Import D */
+ if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
+ MBEDTLS_ASN1_INTEGER ) ) != 0 ||
+ ( ret = mbedtls_rsa_import_raw( rsa, NULL, 0, NULL, 0, NULL, 0,
+ p, len, NULL, 0 ) ) != 0 )
+ goto cleanup;
+ p += len;
+
+ /* Import P */
+ if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
+ MBEDTLS_ASN1_INTEGER ) ) != 0 ||
+ ( ret = mbedtls_rsa_import_raw( rsa, NULL, 0, p, len, NULL, 0,
+ NULL, 0, NULL, 0 ) ) != 0 )
+ goto cleanup;
+ p += len;
+
+ /* Import Q */
+ if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
+ MBEDTLS_ASN1_INTEGER ) ) != 0 ||
+ ( ret = mbedtls_rsa_import_raw( rsa, NULL, 0, NULL, 0, p, len,
+ NULL, 0, NULL, 0 ) ) != 0 )
+ goto cleanup;
+ p += len;
+
+ /* Complete the RSA private key */
+ if( ( ret = mbedtls_rsa_complete( rsa ) ) != 0 )
+ goto cleanup;
+
+ /* Check optional parameters */
+ if( ( ret = mbedtls_asn1_get_mpi( &p, end, &T ) ) != 0 ||
+ ( ret = mbedtls_asn1_get_mpi( &p, end, &T ) ) != 0 ||
+ ( ret = mbedtls_asn1_get_mpi( &p, end, &T ) ) != 0 )
+ goto cleanup;
if( p != end )
{
- mbedtls_rsa_free( rsa );
- return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT +
- MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
+ ret = MBEDTLS_ERR_PK_KEY_INVALID_FORMAT +
+ MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ;
}
- if( ( ret = mbedtls_rsa_check_privkey( rsa ) ) != 0 )
+cleanup:
+
+ mbedtls_mpi_free( &T );
+
+ if( ret != 0 )
{
+ /* Wrap error code if it's coming from a lower level */
+ if( ( ret & 0xff80 ) == 0 )
+ ret = MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret;
+ else
+ ret = MBEDTLS_ERR_PK_KEY_INVALID_FORMAT;
+
mbedtls_rsa_free( rsa );
- return( ret );
}
- return( 0 );
+ return( ret );
}
#endif /* MBEDTLS_RSA_C */
/*
* Parse an unencrypted PKCS#8 encoded private key
+ *
+ * Notes:
+ *
+ * - This function does not own the key buffer. It is the
+ * responsibility of the caller to take care of zeroizing
+ * and freeing it after use.
+ *
+ * - The function is responsible for freeing the provided
+ * PK context on failure.
+ *
*/
static int pk_parse_key_pkcs8_unencrypted_der(
mbedtls_pk_context *pk,
const mbedtls_pk_info_t *pk_info;
/*
- * This function parses the PrivatKeyInfo object (PKCS#8 v1.2 = RFC 5208)
+ * This function parses the PrivateKeyInfo object (PKCS#8 v1.2 = RFC 5208)
*
* PrivateKeyInfo ::= SEQUENCE {
* version Version,
/*
* Parse an encrypted PKCS#8 encoded private key
+ *
+ * To save space, the decryption happens in-place on the given key buffer.
+ * Also, while this function may modify the keybuffer, it doesn't own it,
+ * and instead it is the responsibility of the caller to zeroize and properly
+ * free it after use.
+ *
*/
#if defined(MBEDTLS_PKCS12_C) || defined(MBEDTLS_PKCS5_C)
static int pk_parse_key_pkcs8_encrypted_der(
mbedtls_pk_context *pk,
- const unsigned char *key, size_t keylen,
+ unsigned char *key, size_t keylen,
const unsigned char *pwd, size_t pwdlen )
{
int ret, decrypted = 0;
size_t len;
- unsigned char buf[2048];
+ unsigned char *buf;
unsigned char *p, *end;
mbedtls_asn1_buf pbe_alg_oid, pbe_params;
#if defined(MBEDTLS_PKCS12_C)
mbedtls_md_type_t md_alg;
#endif
- memset( buf, 0, sizeof( buf ) );
-
- p = (unsigned char *) key;
+ p = key;
end = p + keylen;
if( pwdlen == 0 )
return( MBEDTLS_ERR_PK_PASSWORD_REQUIRED );
/*
- * This function parses the EncryptedPrivatKeyInfo object (PKCS#8)
+ * This function parses the EncryptedPrivateKeyInfo object (PKCS#8)
*
* EncryptedPrivateKeyInfo ::= SEQUENCE {
* encryptionAlgorithm EncryptionAlgorithmIdentifier,
* EncryptedData ::= OCTET STRING
*
* The EncryptedData OCTET STRING is a PKCS#8 PrivateKeyInfo
+ *
*/
if( ( ret = mbedtls_asn1_get_tag( &p, end, &len,
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 )
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret );
- if( len > sizeof( buf ) )
- return( MBEDTLS_ERR_PK_BAD_INPUT_DATA );
+ buf = p;
/*
- * Decrypt EncryptedData with appropriate PDE
+ * Decrypt EncryptedData with appropriate PBE
*/
#if defined(MBEDTLS_PKCS12_C)
if( mbedtls_oid_get_pkcs12_pbe_alg( &pbe_alg_oid, &md_alg, &cipher_alg ) == 0 )
if( ret == 0 )
{
- if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL )
- return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG );
-
- if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 ||
+ pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA );
+ if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 ||
( ret = pk_parse_key_pkcs1_der( mbedtls_pk_rsa( *pk ),
pem.buf, pem.buflen ) ) != 0 )
{
key, pwd, pwdlen, &len );
if( ret == 0 )
{
- if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_ECKEY ) ) == NULL )
- return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG );
+ pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_ECKEY );
- if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 ||
+ if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 ||
( ret = pk_parse_key_sec1_der( mbedtls_pk_ec( *pk ),
pem.buf, pem.buflen ) ) != 0 )
{
#endif /* MBEDTLS_PEM_PARSE_C */
/*
- * At this point we only know it's not a PEM formatted key. Could be any
- * of the known DER encoded private key formats
- *
- * We try the different DER format parsers to see if one passes without
- * error
- */
+ * At this point we only know it's not a PEM formatted key. Could be any
+ * of the known DER encoded private key formats
+ *
+ * We try the different DER format parsers to see if one passes without
+ * error
+ */
#if defined(MBEDTLS_PKCS12_C) || defined(MBEDTLS_PKCS5_C)
- if( ( ret = pk_parse_key_pkcs8_encrypted_der( pk, key, keylen,
- pwd, pwdlen ) ) == 0 )
{
- return( 0 );
+ unsigned char *key_copy;
+
+ if( keylen == 0 )
+ return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT );
+
+ if( ( key_copy = mbedtls_calloc( 1, keylen ) ) == NULL )
+ return( MBEDTLS_ERR_PK_ALLOC_FAILED );
+
+ memcpy( key_copy, key, keylen );
+
+ ret = pk_parse_key_pkcs8_encrypted_der( pk, key_copy, keylen,
+ pwd, pwdlen );
+
+ mbedtls_zeroize( key_copy, keylen );
+ mbedtls_free( key_copy );
}
+ if( ret == 0 )
+ return( 0 );
+
mbedtls_pk_free( pk );
if( ret == MBEDTLS_ERR_PK_PASSWORD_MISMATCH )
mbedtls_pk_free( pk );
#if defined(MBEDTLS_RSA_C)
- if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL )
- return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG );
- if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 ||
- ( ret = pk_parse_key_pkcs1_der( mbedtls_pk_rsa( *pk ), key, keylen ) ) == 0 )
+ pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA );
+ if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 ||
+ ( ret = pk_parse_key_pkcs1_der( mbedtls_pk_rsa( *pk ),
+ key, keylen ) ) != 0 )
+ {
+ mbedtls_pk_free( pk );
+ }
+ else
{
return( 0 );
}
- mbedtls_pk_free( pk );
#endif /* MBEDTLS_RSA_C */
#if defined(MBEDTLS_ECP_C)
- if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_ECKEY ) ) == NULL )
- return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG );
- if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 ||
- ( ret = pk_parse_key_sec1_der( mbedtls_pk_ec( *pk ), key, keylen ) ) == 0 )
+ pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_ECKEY );
+ if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 ||
+ ( ret = pk_parse_key_sec1_der( mbedtls_pk_ec( *pk ),
+ key, keylen ) ) != 0 )
+ {
+ mbedtls_pk_free( pk );
+ }
+ else
{
return( 0 );
}
- mbedtls_pk_free( pk );
#endif /* MBEDTLS_ECP_C */
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT );
{
int ret;
unsigned char *p;
+#if defined(MBEDTLS_RSA_C)
+ const mbedtls_pk_info_t *pk_info;
+#endif
#if defined(MBEDTLS_PEM_PARSE_C)
size_t len;
mbedtls_pem_context pem;
mbedtls_pem_init( &pem );
+#if defined(MBEDTLS_RSA_C)
+ /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */
+ if( keylen == 0 || key[keylen - 1] != '\0' )
+ ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT;
+ else
+ ret = mbedtls_pem_read_buffer( &pem,
+ "-----BEGIN RSA PUBLIC KEY-----",
+ "-----END RSA PUBLIC KEY-----",
+ key, NULL, 0, &len );
+
+ if( ret == 0 )
+ {
+ p = pem.buf;
+ if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL )
+ return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG );
+
+ if( ( ret = mbedtls_pk_setup( ctx, pk_info ) ) != 0 )
+ return( ret );
+
+ if ( ( ret = pk_get_rsapubkey( &p, p + pem.buflen, mbedtls_pk_rsa( *ctx ) ) ) != 0 )
+ mbedtls_pk_free( ctx );
+
+ mbedtls_pem_free( &pem );
+ return( ret );
+ }
+ else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT )
+ {
+ mbedtls_pem_free( &pem );
+ return( ret );
+ }
+#endif /* MBEDTLS_RSA_C */
/* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */
if( keylen == 0 || key[keylen - 1] != '\0' )
/*
* Was PEM encoded
*/
- key = pem.buf;
- keylen = pem.buflen;
+ p = pem.buf;
+
+ ret = mbedtls_pk_parse_subpubkey( &p, p + pem.buflen, ctx );
+ mbedtls_pem_free( &pem );
+ return( ret );
}
else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT )
{
mbedtls_pem_free( &pem );
return( ret );
}
+ mbedtls_pem_free( &pem );
#endif /* MBEDTLS_PEM_PARSE_C */
+
+#if defined(MBEDTLS_RSA_C)
+ if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL )
+ return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG );
+
+ if( ( ret = mbedtls_pk_setup( ctx, pk_info ) ) != 0 )
+ return( ret );
+
+ p = (unsigned char *)key;
+ ret = pk_get_rsapubkey( &p, p + keylen, mbedtls_pk_rsa( *ctx ) );
+ if( ret == 0 )
+ {
+ return( ret );
+ }
+ mbedtls_pk_free( ctx );
+ if( ret != ( MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) )
+ {
+ return( ret );
+ }
+#endif /* MBEDTLS_RSA_C */
p = (unsigned char *) key;
ret = mbedtls_pk_parse_subpubkey( &p, p + keylen, ctx );
-#if defined(MBEDTLS_PEM_PARSE_C)
- mbedtls_pem_free( &pem );
-#endif
-
return( ret );
}
* }
*/
static int pk_write_rsa_pubkey( unsigned char **p, unsigned char *start,
- mbedtls_rsa_context *rsa )
+ mbedtls_rsa_context *rsa )
{
int ret;
size_t len = 0;
+ mbedtls_mpi T;
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( p, start, &rsa->E ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( p, start, &rsa->N ) );
+ mbedtls_mpi_init( &T );
+
+ /* Export E */
+ if ( ( ret = mbedtls_rsa_export( rsa, NULL, NULL, NULL, NULL, &T ) ) != 0 ||
+ ( ret = mbedtls_asn1_write_mpi( p, start, &T ) ) < 0 )
+ goto end_of_export;
+ len += ret;
+
+ /* Export N */
+ if ( ( ret = mbedtls_rsa_export( rsa, &T, NULL, NULL, NULL, NULL ) ) != 0 ||
+ ( ret = mbedtls_asn1_write_mpi( p, start, &T ) ) < 0 )
+ goto end_of_export;
+ len += ret;
+
+end_of_export:
+
+ mbedtls_mpi_free( &T );
+ if( ret < 0 )
+ return( ret );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_CONSTRUCTED |
* EC public key is an EC point
*/
static int pk_write_ec_pubkey( unsigned char **p, unsigned char *start,
- mbedtls_ecp_keypair *ec )
+ mbedtls_ecp_keypair *ec )
{
int ret;
size_t len = 0;
* }
*/
static int pk_write_ec_param( unsigned char **p, unsigned char *start,
- mbedtls_ecp_keypair *ec )
+ mbedtls_ecp_keypair *ec )
{
int ret;
size_t len = 0;
#endif /* MBEDTLS_ECP_C */
int mbedtls_pk_write_pubkey( unsigned char **p, unsigned char *start,
- const mbedtls_pk_context *key )
+ const mbedtls_pk_context *key )
{
int ret;
size_t len = 0;
#if defined(MBEDTLS_RSA_C)
if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_RSA )
{
+ mbedtls_mpi T; /* Temporary holding the exported parameters */
mbedtls_rsa_context *rsa = mbedtls_pk_rsa( *key );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->QP ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->DQ ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->DP ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->Q ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->P ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->D ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->E ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, &rsa->N ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_int( &c, buf, 0 ) );
+ /*
+ * Export the parameters one after another to avoid simultaneous copies.
+ */
+
+ mbedtls_mpi_init( &T );
+
+ /* Export QP */
+ if( ( ret = mbedtls_rsa_export_crt( rsa, NULL, NULL, &T ) ) != 0 ||
+ ( ret = mbedtls_asn1_write_mpi( &c, buf, &T ) ) < 0 )
+ goto end_of_export;
+ len += ret;
+
+ /* Export DQ */
+ if( ( ret = mbedtls_rsa_export_crt( rsa, NULL, &T, NULL ) ) != 0 ||
+ ( ret = mbedtls_asn1_write_mpi( &c, buf, &T ) ) < 0 )
+ goto end_of_export;
+ len += ret;
+
+ /* Export DP */
+ if( ( ret = mbedtls_rsa_export_crt( rsa, &T, NULL, NULL ) ) != 0 ||
+ ( ret = mbedtls_asn1_write_mpi( &c, buf, &T ) ) < 0 )
+ goto end_of_export;
+ len += ret;
+
+ /* Export Q */
+ if ( ( ret = mbedtls_rsa_export( rsa, NULL, NULL,
+ &T, NULL, NULL ) ) != 0 ||
+ ( ret = mbedtls_asn1_write_mpi( &c, buf, &T ) ) < 0 )
+ goto end_of_export;
+ len += ret;
+
+ /* Export P */
+ if ( ( ret = mbedtls_rsa_export( rsa, NULL, &T,
+ NULL, NULL, NULL ) ) != 0 ||
+ ( ret = mbedtls_asn1_write_mpi( &c, buf, &T ) ) < 0 )
+ goto end_of_export;
+ len += ret;
+
+ /* Export D */
+ if ( ( ret = mbedtls_rsa_export( rsa, NULL, NULL,
+ NULL, &T, NULL ) ) != 0 ||
+ ( ret = mbedtls_asn1_write_mpi( &c, buf, &T ) ) < 0 )
+ goto end_of_export;
+ len += ret;
+
+ /* Export E */
+ if ( ( ret = mbedtls_rsa_export( rsa, NULL, NULL,
+ NULL, NULL, &T ) ) != 0 ||
+ ( ret = mbedtls_asn1_write_mpi( &c, buf, &T ) ) < 0 )
+ goto end_of_export;
+ len += ret;
+
+ /* Export N */
+ if ( ( ret = mbedtls_rsa_export( rsa, &T, NULL,
+ NULL, NULL, NULL ) ) != 0 ||
+ ( ret = mbedtls_asn1_write_mpi( &c, buf, &T ) ) < 0 )
+ goto end_of_export;
+ len += ret;
+
+ end_of_export:
+
+ mbedtls_mpi_free( &T );
+ if( ret < 0 )
+ return( ret );
+ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_int( &c, buf, 0 ) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, buf, MBEDTLS_ASN1_CONSTRUCTED |
- MBEDTLS_ASN1_SEQUENCE ) );
+ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c,
+ buf, MBEDTLS_ASN1_CONSTRUCTED |
+ MBEDTLS_ASN1_SEQUENCE ) );
}
else
#endif /* MBEDTLS_RSA_C */
#include "mbedtls/platform.h"
+#if defined(MBEDTLS_ENTROPY_NV_SEED) && \
+ !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO)
+/* Implementation that should never be optimized out by the compiler */
+static void mbedtls_zeroize( void *v, size_t n ) {
+ volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0;
+}
+#endif
+
#if defined(MBEDTLS_PLATFORM_MEMORY)
#if !defined(MBEDTLS_PLATFORM_STD_CALLOC)
static void *platform_calloc_uninit( size_t n, size_t size )
return( -1 );
va_start( argp, fmt );
-#if defined(_TRUNCATE)
+#if defined(_TRUNCATE) && !defined(__MINGW32__)
ret = _vsnprintf_s( s, n, _TRUNCATE, fmt, argp );
#else
ret = _vsnprintf( s, n, fmt, argp );
size_t n;
if( ( file = fopen( MBEDTLS_PLATFORM_STD_NV_SEED_FILE, "rb" ) ) == NULL )
- return -1;
+ return( -1 );
if( ( n = fread( buf, 1, buf_len, file ) ) != buf_len )
{
fclose( file );
- return -1;
+ mbedtls_zeroize( buf, buf_len );
+ return( -1 );
}
fclose( file );
- return( n );
+ return( (int)n );
}
int mbedtls_platform_std_nv_seed_write( unsigned char *buf, size_t buf_len )
}
fclose( file );
- return( n );
+ return( (int)n );
}
#endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */
#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */
#endif /* MBEDTLS_ENTROPY_NV_SEED */
+#if !defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
+/*
+ * Placeholder platform setup that does nothing by default
+ */
+int mbedtls_platform_setup( mbedtls_platform_context *ctx )
+{
+ (void)ctx;
+
+ return( 0 );
+}
+
+/*
+ * Placeholder platform teardown that does nothing by default
+ */
+void mbedtls_platform_teardown( mbedtls_platform_context *ctx )
+{
+ (void)ctx;
+}
+#endif /* MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */
+
#endif /* MBEDTLS_PLATFORM_C */
#endif /* MBEDTLS_PLATFORM_C */
#endif /* MBEDTLS_SELF_TEST */
+#if !defined(MBEDTLS_RIPEMD160_ALT)
+
/*
* 32-bit integer manipulation macros (little endian)
*/
/*
* RIPEMD-160 context setup
*/
-void mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx )
+int mbedtls_ripemd160_starts_ret( mbedtls_ripemd160_context *ctx )
{
ctx->total[0] = 0;
ctx->total[1] = 0;
ctx->state[2] = 0x98BADCFE;
ctx->state[3] = 0x10325476;
ctx->state[4] = 0xC3D2E1F0;
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_ripemd160_starts( mbedtls_ripemd160_context *ctx )
+{
+ mbedtls_ripemd160_starts_ret( ctx );
+}
+#endif
+
#if !defined(MBEDTLS_RIPEMD160_PROCESS_ALT)
/*
* Process one block
*/
-void mbedtls_ripemd160_process( mbedtls_ripemd160_context *ctx, const unsigned char data[64] )
+int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx,
+ const unsigned char data[64] )
{
uint32_t A, B, C, D, E, Ap, Bp, Cp, Dp, Ep, X[16];
ctx->state[3] = ctx->state[4] + A + Bp;
ctx->state[4] = ctx->state[0] + B + Cp;
ctx->state[0] = C;
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_ripemd160_process( mbedtls_ripemd160_context *ctx,
+ const unsigned char data[64] )
+{
+ mbedtls_internal_ripemd160_process( ctx, data );
}
+#endif
#endif /* !MBEDTLS_RIPEMD160_PROCESS_ALT */
/*
* RIPEMD-160 process buffer
*/
-void mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx,
- const unsigned char *input, size_t ilen )
+int mbedtls_ripemd160_update_ret( mbedtls_ripemd160_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
{
+ int ret;
size_t fill;
uint32_t left;
if( ilen == 0 )
- return;
+ return( 0 );
left = ctx->total[0] & 0x3F;
fill = 64 - left;
if( left && ilen >= fill )
{
memcpy( (void *) (ctx->buffer + left), input, fill );
- mbedtls_ripemd160_process( ctx, ctx->buffer );
+
+ if( ( ret = mbedtls_internal_ripemd160_process( ctx, ctx->buffer ) ) != 0 )
+ return( ret );
+
input += fill;
ilen -= fill;
left = 0;
while( ilen >= 64 )
{
- mbedtls_ripemd160_process( ctx, input );
+ if( ( ret = mbedtls_internal_ripemd160_process( ctx, input ) ) != 0 )
+ return( ret );
+
input += 64;
ilen -= 64;
}
{
memcpy( (void *) (ctx->buffer + left), input, ilen );
}
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_ripemd160_update( mbedtls_ripemd160_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
+{
+ mbedtls_ripemd160_update_ret( ctx, input, ilen );
+}
+#endif
+
static const unsigned char ripemd160_padding[64] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*
* RIPEMD-160 final digest
*/
-void mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx, unsigned char output[20] )
+int mbedtls_ripemd160_finish_ret( mbedtls_ripemd160_context *ctx,
+ unsigned char output[20] )
{
+ int ret;
uint32_t last, padn;
uint32_t high, low;
unsigned char msglen[8];
last = ctx->total[0] & 0x3F;
padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
- mbedtls_ripemd160_update( ctx, ripemd160_padding, padn );
- mbedtls_ripemd160_update( ctx, msglen, 8 );
+ ret = mbedtls_ripemd160_update_ret( ctx, ripemd160_padding, padn );
+ if( ret != 0 )
+ return( ret );
+
+ ret = mbedtls_ripemd160_update_ret( ctx, msglen, 8 );
+ if( ret != 0 )
+ return( ret );
PUT_UINT32_LE( ctx->state[0], output, 0 );
PUT_UINT32_LE( ctx->state[1], output, 4 );
PUT_UINT32_LE( ctx->state[2], output, 8 );
PUT_UINT32_LE( ctx->state[3], output, 12 );
PUT_UINT32_LE( ctx->state[4], output, 16 );
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_ripemd160_finish( mbedtls_ripemd160_context *ctx,
+ unsigned char output[20] )
+{
+ mbedtls_ripemd160_finish_ret( ctx, output );
+}
+#endif
+
+#endif /* ! MBEDTLS_RIPEMD160_ALT */
+
/*
* output = RIPEMD-160( input buffer )
*/
-void mbedtls_ripemd160( const unsigned char *input, size_t ilen,
- unsigned char output[20] )
+int mbedtls_ripemd160_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[20] )
{
+ int ret;
mbedtls_ripemd160_context ctx;
mbedtls_ripemd160_init( &ctx );
- mbedtls_ripemd160_starts( &ctx );
- mbedtls_ripemd160_update( &ctx, input, ilen );
- mbedtls_ripemd160_finish( &ctx, output );
+
+ if( ( ret = mbedtls_ripemd160_starts_ret( &ctx ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_ripemd160_update_ret( &ctx, input, ilen ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_ripemd160_finish_ret( &ctx, output ) ) != 0 )
+ goto exit;
+
+exit:
mbedtls_ripemd160_free( &ctx );
+
+ return( ret );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_ripemd160( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[20] )
+{
+ mbedtls_ripemd160_ret( input, ilen, output );
}
+#endif
#if defined(MBEDTLS_SELF_TEST)
/*
* http://homes.esat.kuleuven.be/~bosselae/mbedtls_ripemd160.html#HMAC
*/
#define TESTS 8
-#define KEYS 2
-static const char *ripemd160_test_input[TESTS] =
+static const unsigned char ripemd160_test_str[TESTS][81] =
+{
+ { "" },
+ { "a" },
+ { "abc" },
+ { "message digest" },
+ { "abcdefghijklmnopqrstuvwxyz" },
+ { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" },
+ { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" },
+ { "12345678901234567890123456789012345678901234567890123456789012"
+ "345678901234567890" },
+};
+
+static const size_t ripemd160_test_strlen[TESTS] =
{
- "",
- "a",
- "abc",
- "message digest",
- "abcdefghijklmnopqrstuvwxyz",
- "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- "1234567890123456789012345678901234567890"
- "1234567890123456789012345678901234567890",
+ 0, 1, 3, 14, 26, 56, 62, 80
};
static const unsigned char ripemd160_test_md[TESTS][20] =
*/
int mbedtls_ripemd160_self_test( int verbose )
{
- int i;
+ int i, ret = 0;
unsigned char output[20];
memset( output, 0, sizeof output );
if( verbose != 0 )
mbedtls_printf( " RIPEMD-160 test #%d: ", i + 1 );
- mbedtls_ripemd160( (const unsigned char *) ripemd160_test_input[i],
- strlen( ripemd160_test_input[i] ),
- output );
+ ret = mbedtls_ripemd160_ret( ripemd160_test_str[i],
+ ripemd160_test_strlen[i], output );
+ if( ret != 0 )
+ goto fail;
if( memcmp( output, ripemd160_test_md[i], 20 ) != 0 )
{
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
+ ret = 1;
+ goto fail;
}
if( verbose != 0 )
mbedtls_printf( "\n" );
return( 0 );
+
+fail:
+ if( verbose != 0 )
+ mbedtls_printf( "failed\n" );
+
+ return( ret );
}
#endif /* MBEDTLS_SELF_TEST */
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
+
/*
* The following sources were referenced in the design of this implementation
* of the RSA algorithm:
* [2] Handbook of Applied Cryptography - 1997, Chapter 8
* Menezes, van Oorschot and Vanstone
*
+ * [3] Malware Guard Extension: Using SGX to Conceal Cache Attacks
+ * Michael Schwarz, Samuel Weiser, Daniel Gruss, Clémentine Maurice and
+ * Stefan Mangard
+ * https://arxiv.org/abs/1702.08719v2
+ *
*/
#if !defined(MBEDTLS_CONFIG_FILE)
#if defined(MBEDTLS_RSA_C)
#include "mbedtls/rsa.h"
+#include "mbedtls/rsa_internal.h"
#include "mbedtls/oid.h"
#include <string.h>
#define mbedtls_free free
#endif
+#if !defined(MBEDTLS_RSA_ALT)
+
+/* Implementation that should never be optimized out by the compiler */
+static void mbedtls_zeroize( void *v, size_t n ) {
+ volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0;
+}
+
+/* constant-time buffer comparison */
+static inline int mbedtls_safer_memcmp( const void *a, const void *b, size_t n )
+{
+ size_t i;
+ const unsigned char *A = (const unsigned char *) a;
+ const unsigned char *B = (const unsigned char *) b;
+ unsigned char diff = 0;
+
+ for( i = 0; i < n; i++ )
+ diff |= A[i] ^ B[i];
+
+ return( diff );
+}
+
+int mbedtls_rsa_import( mbedtls_rsa_context *ctx,
+ const mbedtls_mpi *N,
+ const mbedtls_mpi *P, const mbedtls_mpi *Q,
+ const mbedtls_mpi *D, const mbedtls_mpi *E )
+{
+ int ret;
+
+ if( ( N != NULL && ( ret = mbedtls_mpi_copy( &ctx->N, N ) ) != 0 ) ||
+ ( P != NULL && ( ret = mbedtls_mpi_copy( &ctx->P, P ) ) != 0 ) ||
+ ( Q != NULL && ( ret = mbedtls_mpi_copy( &ctx->Q, Q ) ) != 0 ) ||
+ ( D != NULL && ( ret = mbedtls_mpi_copy( &ctx->D, D ) ) != 0 ) ||
+ ( E != NULL && ( ret = mbedtls_mpi_copy( &ctx->E, E ) ) != 0 ) )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
+ }
+
+ if( N != NULL )
+ ctx->len = mbedtls_mpi_size( &ctx->N );
+
+ return( 0 );
+}
+
+int mbedtls_rsa_import_raw( mbedtls_rsa_context *ctx,
+ unsigned char const *N, size_t N_len,
+ unsigned char const *P, size_t P_len,
+ unsigned char const *Q, size_t Q_len,
+ unsigned char const *D, size_t D_len,
+ unsigned char const *E, size_t E_len )
+{
+ int ret = 0;
+
+ if( N != NULL )
+ {
+ MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &ctx->N, N, N_len ) );
+ ctx->len = mbedtls_mpi_size( &ctx->N );
+ }
+
+ if( P != NULL )
+ MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &ctx->P, P, P_len ) );
+
+ if( Q != NULL )
+ MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &ctx->Q, Q, Q_len ) );
+
+ if( D != NULL )
+ MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &ctx->D, D, D_len ) );
+
+ if( E != NULL )
+ MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &ctx->E, E, E_len ) );
+
+cleanup:
+
+ if( ret != 0 )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
+
+ return( 0 );
+}
+
+/*
+ * Checks whether the context fields are set in such a way
+ * that the RSA primitives will be able to execute without error.
+ * It does *not* make guarantees for consistency of the parameters.
+ */
+static int rsa_check_context( mbedtls_rsa_context const *ctx, int is_priv,
+ int blinding_needed )
+{
+#if !defined(MBEDTLS_RSA_NO_CRT)
+ /* blinding_needed is only used for NO_CRT to decide whether
+ * P,Q need to be present or not. */
+ ((void) blinding_needed);
+#endif
+
+ if( ctx->len != mbedtls_mpi_size( &ctx->N ) ||
+ ctx->len > MBEDTLS_MPI_MAX_SIZE )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+ }
+
+ /*
+ * 1. Modular exponentiation needs positive, odd moduli.
+ */
+
+ /* Modular exponentiation wrt. N is always used for
+ * RSA public key operations. */
+ if( mbedtls_mpi_cmp_int( &ctx->N, 0 ) <= 0 ||
+ mbedtls_mpi_get_bit( &ctx->N, 0 ) == 0 )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+ }
+
+#if !defined(MBEDTLS_RSA_NO_CRT)
+ /* Modular exponentiation for P and Q is only
+ * used for private key operations and if CRT
+ * is used. */
+ if( is_priv &&
+ ( mbedtls_mpi_cmp_int( &ctx->P, 0 ) <= 0 ||
+ mbedtls_mpi_get_bit( &ctx->P, 0 ) == 0 ||
+ mbedtls_mpi_cmp_int( &ctx->Q, 0 ) <= 0 ||
+ mbedtls_mpi_get_bit( &ctx->Q, 0 ) == 0 ) )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+ }
+#endif /* !MBEDTLS_RSA_NO_CRT */
+
+ /*
+ * 2. Exponents must be positive
+ */
+
+ /* Always need E for public key operations */
+ if( mbedtls_mpi_cmp_int( &ctx->E, 0 ) <= 0 )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+
+#if defined(MBEDTLS_RSA_NO_CRT)
+ /* For private key operations, use D or DP & DQ
+ * as (unblinded) exponents. */
+ if( is_priv && mbedtls_mpi_cmp_int( &ctx->D, 0 ) <= 0 )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+#else
+ if( is_priv &&
+ ( mbedtls_mpi_cmp_int( &ctx->DP, 0 ) <= 0 ||
+ mbedtls_mpi_cmp_int( &ctx->DQ, 0 ) <= 0 ) )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+ }
+#endif /* MBEDTLS_RSA_NO_CRT */
+
+ /* Blinding shouldn't make exponents negative either,
+ * so check that P, Q >= 1 if that hasn't yet been
+ * done as part of 1. */
+#if defined(MBEDTLS_RSA_NO_CRT)
+ if( is_priv && blinding_needed &&
+ ( mbedtls_mpi_cmp_int( &ctx->P, 0 ) <= 0 ||
+ mbedtls_mpi_cmp_int( &ctx->Q, 0 ) <= 0 ) )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+ }
+#endif
+
+ /* It wouldn't lead to an error if it wasn't satisfied,
+ * but check for QP >= 1 nonetheless. */
+#if !defined(MBEDTLS_RSA_NO_CRT)
+ if( is_priv &&
+ mbedtls_mpi_cmp_int( &ctx->QP, 0 ) <= 0 )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+ }
+#endif
+
+ return( 0 );
+}
+
+int mbedtls_rsa_complete( mbedtls_rsa_context *ctx )
+{
+ int ret = 0;
+
+ const int have_N = ( mbedtls_mpi_cmp_int( &ctx->N, 0 ) != 0 );
+ const int have_P = ( mbedtls_mpi_cmp_int( &ctx->P, 0 ) != 0 );
+ const int have_Q = ( mbedtls_mpi_cmp_int( &ctx->Q, 0 ) != 0 );
+ const int have_D = ( mbedtls_mpi_cmp_int( &ctx->D, 0 ) != 0 );
+ const int have_E = ( mbedtls_mpi_cmp_int( &ctx->E, 0 ) != 0 );
+
+ /*
+ * Check whether provided parameters are enough
+ * to deduce all others. The following incomplete
+ * parameter sets for private keys are supported:
+ *
+ * (1) P, Q missing.
+ * (2) D and potentially N missing.
+ *
+ */
+
+ const int n_missing = have_P && have_Q && have_D && have_E;
+ const int pq_missing = have_N && !have_P && !have_Q && have_D && have_E;
+ const int d_missing = have_P && have_Q && !have_D && have_E;
+ const int is_pub = have_N && !have_P && !have_Q && !have_D && have_E;
+
+ /* These three alternatives are mutually exclusive */
+ const int is_priv = n_missing || pq_missing || d_missing;
+
+ if( !is_priv && !is_pub )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+
+ /*
+ * Step 1: Deduce N if P, Q are provided.
+ */
+
+ if( !have_N && have_P && have_Q )
+ {
+ if( ( ret = mbedtls_mpi_mul_mpi( &ctx->N, &ctx->P,
+ &ctx->Q ) ) != 0 )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
+ }
+
+ ctx->len = mbedtls_mpi_size( &ctx->N );
+ }
+
+ /*
+ * Step 2: Deduce and verify all remaining core parameters.
+ */
+
+ if( pq_missing )
+ {
+ ret = mbedtls_rsa_deduce_primes( &ctx->N, &ctx->E, &ctx->D,
+ &ctx->P, &ctx->Q );
+ if( ret != 0 )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
+
+ }
+ else if( d_missing )
+ {
+ if( ( ret = mbedtls_rsa_deduce_private_exponent( &ctx->P,
+ &ctx->Q,
+ &ctx->E,
+ &ctx->D ) ) != 0 )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
+ }
+ }
+
+ /*
+ * Step 3: Deduce all additional parameters specific
+ * to our current RSA implementation.
+ */
+
+#if !defined(MBEDTLS_RSA_NO_CRT)
+ if( is_priv )
+ {
+ ret = mbedtls_rsa_deduce_crt( &ctx->P, &ctx->Q, &ctx->D,
+ &ctx->DP, &ctx->DQ, &ctx->QP );
+ if( ret != 0 )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
+ }
+#endif /* MBEDTLS_RSA_NO_CRT */
+
+ /*
+ * Step 3: Basic sanity checks
+ */
+
+ return( rsa_check_context( ctx, is_priv, 1 ) );
+}
+
+int mbedtls_rsa_export_raw( const mbedtls_rsa_context *ctx,
+ unsigned char *N, size_t N_len,
+ unsigned char *P, size_t P_len,
+ unsigned char *Q, size_t Q_len,
+ unsigned char *D, size_t D_len,
+ unsigned char *E, size_t E_len )
+{
+ int ret = 0;
+
+ /* Check if key is private or public */
+ const int is_priv =
+ mbedtls_mpi_cmp_int( &ctx->N, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->P, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->Q, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->D, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->E, 0 ) != 0;
+
+ if( !is_priv )
+ {
+ /* If we're trying to export private parameters for a public key,
+ * something must be wrong. */
+ if( P != NULL || Q != NULL || D != NULL )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+
+ }
+
+ if( N != NULL )
+ MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &ctx->N, N, N_len ) );
+
+ if( P != NULL )
+ MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &ctx->P, P, P_len ) );
+
+ if( Q != NULL )
+ MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &ctx->Q, Q, Q_len ) );
+
+ if( D != NULL )
+ MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &ctx->D, D, D_len ) );
+
+ if( E != NULL )
+ MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &ctx->E, E, E_len ) );
+
+cleanup:
+
+ return( ret );
+}
+
+int mbedtls_rsa_export( const mbedtls_rsa_context *ctx,
+ mbedtls_mpi *N, mbedtls_mpi *P, mbedtls_mpi *Q,
+ mbedtls_mpi *D, mbedtls_mpi *E )
+{
+ int ret;
+
+ /* Check if key is private or public */
+ int is_priv =
+ mbedtls_mpi_cmp_int( &ctx->N, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->P, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->Q, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->D, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->E, 0 ) != 0;
+
+ if( !is_priv )
+ {
+ /* If we're trying to export private parameters for a public key,
+ * something must be wrong. */
+ if( P != NULL || Q != NULL || D != NULL )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+
+ }
+
+ /* Export all requested core parameters. */
+
+ if( ( N != NULL && ( ret = mbedtls_mpi_copy( N, &ctx->N ) ) != 0 ) ||
+ ( P != NULL && ( ret = mbedtls_mpi_copy( P, &ctx->P ) ) != 0 ) ||
+ ( Q != NULL && ( ret = mbedtls_mpi_copy( Q, &ctx->Q ) ) != 0 ) ||
+ ( D != NULL && ( ret = mbedtls_mpi_copy( D, &ctx->D ) ) != 0 ) ||
+ ( E != NULL && ( ret = mbedtls_mpi_copy( E, &ctx->E ) ) != 0 ) )
+ {
+ return( ret );
+ }
+
+ return( 0 );
+}
+
+/*
+ * Export CRT parameters
+ * This must also be implemented if CRT is not used, for being able to
+ * write DER encoded RSA keys. The helper function mbedtls_rsa_deduce_crt
+ * can be used in this case.
+ */
+int mbedtls_rsa_export_crt( const mbedtls_rsa_context *ctx,
+ mbedtls_mpi *DP, mbedtls_mpi *DQ, mbedtls_mpi *QP )
+{
+ int ret;
+
+ /* Check if key is private or public */
+ int is_priv =
+ mbedtls_mpi_cmp_int( &ctx->N, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->P, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->Q, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->D, 0 ) != 0 &&
+ mbedtls_mpi_cmp_int( &ctx->E, 0 ) != 0;
+
+ if( !is_priv )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+
+#if !defined(MBEDTLS_RSA_NO_CRT)
+ /* Export all requested blinding parameters. */
+ if( ( DP != NULL && ( ret = mbedtls_mpi_copy( DP, &ctx->DP ) ) != 0 ) ||
+ ( DQ != NULL && ( ret = mbedtls_mpi_copy( DQ, &ctx->DQ ) ) != 0 ) ||
+ ( QP != NULL && ( ret = mbedtls_mpi_copy( QP, &ctx->QP ) ) != 0 ) )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
+ }
+#else
+ if( ( ret = mbedtls_rsa_deduce_crt( &ctx->P, &ctx->Q, &ctx->D,
+ DP, DQ, QP ) ) != 0 )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
+ }
+#endif
+
+ return( 0 );
+}
+
/*
* Initialize an RSA context
*/
ctx->hash_id = hash_id;
}
+/*
+ * Get length in bytes of RSA modulus
+ */
+
+size_t mbedtls_rsa_get_len( const mbedtls_rsa_context *ctx )
+{
+ return( ctx->len );
+}
+
+
#if defined(MBEDTLS_GENPRIME)
/*
unsigned int nbits, int exponent )
{
int ret;
- mbedtls_mpi P1, Q1, H, G;
+ mbedtls_mpi H, G;
if( f_rng == NULL || nbits < 128 || exponent < 3 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
if( nbits % 2 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 );
- mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
+ mbedtls_mpi_init( &H );
+ mbedtls_mpi_init( &G );
/*
* find primes P and Q with Q < P so that:
do
{
MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->P, nbits >> 1, 0,
- f_rng, p_rng ) );
+ f_rng, p_rng ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->Q, nbits >> 1, 0,
- f_rng, p_rng ) );
+ f_rng, p_rng ) );
if( mbedtls_mpi_cmp_mpi( &ctx->P, &ctx->Q ) == 0 )
continue;
continue;
if( mbedtls_mpi_cmp_mpi( &ctx->P, &ctx->Q ) < 0 )
- mbedtls_mpi_swap( &ctx->P, &ctx->Q );
+ mbedtls_mpi_swap( &ctx->P, &ctx->Q );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &P1, &ctx->P, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &Q1, &ctx->Q, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) );
+ /* Temporarily replace P,Q by P-1, Q-1 */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &ctx->P, &ctx->P, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &ctx->Q, &ctx->Q, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &H, &ctx->P, &ctx->Q ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, &ctx->E, &H ) );
}
while( mbedtls_mpi_cmp_int( &G, 1 ) != 0 );
+ /* Restore P,Q */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &ctx->P, &ctx->P, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &ctx->Q, &ctx->Q, 1 ) );
+
+ ctx->len = mbedtls_mpi_size( &ctx->N );
+
/*
* D = E^-1 mod ((P-1)*(Q-1))
* DP = D mod (P - 1)
* DQ = D mod (Q - 1)
* QP = Q^-1 mod P
*/
- MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->D , &ctx->E, &H ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->DP, &ctx->D, &P1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &ctx->DQ, &ctx->D, &Q1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->QP, &ctx->Q, &ctx->P ) );
- ctx->len = ( mbedtls_mpi_bitlen( &ctx->N ) + 7 ) >> 3;
+ MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->D, &ctx->E, &H ) );
+
+#if !defined(MBEDTLS_RSA_NO_CRT)
+ MBEDTLS_MPI_CHK( mbedtls_rsa_deduce_crt( &ctx->P, &ctx->Q, &ctx->D,
+ &ctx->DP, &ctx->DQ, &ctx->QP ) );
+#endif /* MBEDTLS_RSA_NO_CRT */
+
+ /* Double-check */
+ MBEDTLS_MPI_CHK( mbedtls_rsa_check_privkey( ctx ) );
cleanup:
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G );
+ mbedtls_mpi_free( &H );
+ mbedtls_mpi_free( &G );
if( ret != 0 )
{
*/
int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx )
{
- if( !ctx->N.p || !ctx->E.p )
+ if( rsa_check_context( ctx, 0 /* public */, 0 /* no blinding */ ) != 0 )
return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
- if( ( ctx->N.p[0] & 1 ) == 0 ||
- ( ctx->E.p[0] & 1 ) == 0 )
- return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
-
- if( mbedtls_mpi_bitlen( &ctx->N ) < 128 ||
- mbedtls_mpi_bitlen( &ctx->N ) > MBEDTLS_MPI_MAX_BITS )
+ if( mbedtls_mpi_bitlen( &ctx->N ) < 128 )
+ {
return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
+ }
- if( mbedtls_mpi_bitlen( &ctx->E ) < 2 ||
+ if( mbedtls_mpi_get_bit( &ctx->E, 0 ) == 0 ||
+ mbedtls_mpi_bitlen( &ctx->E ) < 2 ||
mbedtls_mpi_cmp_mpi( &ctx->E, &ctx->N ) >= 0 )
+ {
return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
+ }
return( 0 );
}
/*
- * Check a private RSA key
+ * Check for the consistency of all fields in an RSA private key context
*/
int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx )
{
- int ret;
- mbedtls_mpi PQ, DE, P1, Q1, H, I, G, G2, L1, L2, DP, DQ, QP;
-
- if( ( ret = mbedtls_rsa_check_pubkey( ctx ) ) != 0 )
- return( ret );
-
- if( !ctx->P.p || !ctx->Q.p || !ctx->D.p )
+ if( mbedtls_rsa_check_pubkey( ctx ) != 0 ||
+ rsa_check_context( ctx, 1 /* private */, 1 /* blinding */ ) != 0 )
+ {
return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
+ }
- mbedtls_mpi_init( &PQ ); mbedtls_mpi_init( &DE ); mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 );
- mbedtls_mpi_init( &H ); mbedtls_mpi_init( &I ); mbedtls_mpi_init( &G ); mbedtls_mpi_init( &G2 );
- mbedtls_mpi_init( &L1 ); mbedtls_mpi_init( &L2 ); mbedtls_mpi_init( &DP ); mbedtls_mpi_init( &DQ );
- mbedtls_mpi_init( &QP );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &PQ, &ctx->P, &ctx->Q ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &DE, &ctx->D, &ctx->E ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &P1, &ctx->P, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &Q1, &ctx->Q, 1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, &ctx->E, &H ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G2, &P1, &Q1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( &L1, &L2, &H, &G2 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &I, &DE, &L1 ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &DP, &ctx->D, &P1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &DQ, &ctx->D, &Q1 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &QP, &ctx->Q, &ctx->P ) );
- /*
- * Check for a valid PKCS1v2 private key
- */
- if( mbedtls_mpi_cmp_mpi( &PQ, &ctx->N ) != 0 ||
- mbedtls_mpi_cmp_mpi( &DP, &ctx->DP ) != 0 ||
- mbedtls_mpi_cmp_mpi( &DQ, &ctx->DQ ) != 0 ||
- mbedtls_mpi_cmp_mpi( &QP, &ctx->QP ) != 0 ||
- mbedtls_mpi_cmp_int( &L2, 0 ) != 0 ||
- mbedtls_mpi_cmp_int( &I, 1 ) != 0 ||
- mbedtls_mpi_cmp_int( &G, 1 ) != 0 )
+ if( mbedtls_rsa_validate_params( &ctx->N, &ctx->P, &ctx->Q,
+ &ctx->D, &ctx->E, NULL, NULL ) != 0 )
{
- ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
}
-cleanup:
- mbedtls_mpi_free( &PQ ); mbedtls_mpi_free( &DE ); mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 );
- mbedtls_mpi_free( &H ); mbedtls_mpi_free( &I ); mbedtls_mpi_free( &G ); mbedtls_mpi_free( &G2 );
- mbedtls_mpi_free( &L1 ); mbedtls_mpi_free( &L2 ); mbedtls_mpi_free( &DP ); mbedtls_mpi_free( &DQ );
- mbedtls_mpi_free( &QP );
-
- if( ret == MBEDTLS_ERR_RSA_KEY_CHECK_FAILED )
- return( ret );
-
- if( ret != 0 )
- return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED + ret );
+#if !defined(MBEDTLS_RSA_NO_CRT)
+ else if( mbedtls_rsa_validate_crt( &ctx->P, &ctx->Q, &ctx->D,
+ &ctx->DP, &ctx->DQ, &ctx->QP ) != 0 )
+ {
+ return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
+ }
+#endif
return( 0 );
}
/*
* Check if contexts holding a public and private key match
*/
-int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv )
+int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub,
+ const mbedtls_rsa_context *prv )
{
- if( mbedtls_rsa_check_pubkey( pub ) != 0 ||
+ if( mbedtls_rsa_check_pubkey( pub ) != 0 ||
mbedtls_rsa_check_privkey( prv ) != 0 )
{
return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED );
size_t olen;
mbedtls_mpi T;
+ if( rsa_check_context( ctx, 0 /* public */, 0 /* no blinding */ ) )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+
mbedtls_mpi_init( &T );
#if defined(MBEDTLS_THREADING_C)
}
/*
+ * Exponent blinding supposed to prevent side-channel attacks using multiple
+ * traces of measurements to recover the RSA key. The more collisions are there,
+ * the more bits of the key can be recovered. See [3].
+ *
+ * Collecting n collisions with m bit long blinding value requires 2^(m-m/n)
+ * observations on avarage.
+ *
+ * For example with 28 byte blinding to achieve 2 collisions the adversary has
+ * to make 2^112 observations on avarage.
+ *
+ * (With the currently (as of 2017 April) known best algorithms breaking 2048
+ * bit RSA requires approximately as much time as trying out 2^112 random keys.
+ * Thus in this sense with 28 byte blinding the security is not reduced by
+ * side-channel attacks like the one in [3])
+ *
+ * This countermeasure does not help if the key recovery is possible with a
+ * single trace.
+ */
+#define RSA_EXPONENT_BLINDING 28
+
+/*
* Do an RSA private key operation
*/
int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
{
int ret;
size_t olen;
- mbedtls_mpi T, T1, T2;
- /* Make sure we have private key info, prevent possible misuse */
- if( ctx->P.p == NULL || ctx->Q.p == NULL || ctx->D.p == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+ /* Temporary holding the result */
+ mbedtls_mpi T;
- mbedtls_mpi_init( &T ); mbedtls_mpi_init( &T1 ); mbedtls_mpi_init( &T2 );
+ /* Temporaries holding P-1, Q-1 and the
+ * exponent blinding factor, respectively. */
+ mbedtls_mpi P1, Q1, R;
+
+#if !defined(MBEDTLS_RSA_NO_CRT)
+ /* Temporaries holding the results mod p resp. mod q. */
+ mbedtls_mpi TP, TQ;
+
+ /* Temporaries holding the blinded exponents for
+ * the mod p resp. mod q computation (if used). */
+ mbedtls_mpi DP_blind, DQ_blind;
+
+ /* Pointers to actual exponents to be used - either the unblinded
+ * or the blinded ones, depending on the presence of a PRNG. */
+ mbedtls_mpi *DP = &ctx->DP;
+ mbedtls_mpi *DQ = &ctx->DQ;
+#else
+ /* Temporary holding the blinded exponent (if used). */
+ mbedtls_mpi D_blind;
+
+ /* Pointer to actual exponent to be used - either the unblinded
+ * or the blinded one, depending on the presence of a PRNG. */
+ mbedtls_mpi *D = &ctx->D;
+#endif /* MBEDTLS_RSA_NO_CRT */
+
+ /* Temporaries holding the initial input and the double
+ * checked result; should be the same in the end. */
+ mbedtls_mpi I, C;
+
+ if( rsa_check_context( ctx, 1 /* private key checks */,
+ f_rng != NULL /* blinding y/n */ ) != 0 )
+ {
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+ }
#if defined(MBEDTLS_THREADING_C)
if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
return( ret );
#endif
+ /* MPI Initialization */
+ mbedtls_mpi_init( &T );
+
+ mbedtls_mpi_init( &P1 );
+ mbedtls_mpi_init( &Q1 );
+ mbedtls_mpi_init( &R );
+
+ if( f_rng != NULL )
+ {
+#if defined(MBEDTLS_RSA_NO_CRT)
+ mbedtls_mpi_init( &D_blind );
+#else
+ mbedtls_mpi_init( &DP_blind );
+ mbedtls_mpi_init( &DQ_blind );
+#endif
+ }
+
+#if !defined(MBEDTLS_RSA_NO_CRT)
+ mbedtls_mpi_init( &TP ); mbedtls_mpi_init( &TQ );
+#endif
+
+ mbedtls_mpi_init( &I );
+ mbedtls_mpi_init( &C );
+
+ /* End of MPI initialization */
+
MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( &T, input, ctx->len ) );
if( mbedtls_mpi_cmp_mpi( &T, &ctx->N ) >= 0 )
{
goto cleanup;
}
+ MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &I, &T ) );
+
if( f_rng != NULL )
{
/*
MBEDTLS_MPI_CHK( rsa_prepare_blinding( ctx, f_rng, p_rng ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, &T, &ctx->Vi ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &T, &T, &ctx->N ) );
+
+ /*
+ * Exponent blinding
+ */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &P1, &ctx->P, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &Q1, &ctx->Q, 1 ) );
+
+#if defined(MBEDTLS_RSA_NO_CRT)
+ /*
+ * D_blind = ( P - 1 ) * ( Q - 1 ) * R + D
+ */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &R, RSA_EXPONENT_BLINDING,
+ f_rng, p_rng ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &D_blind, &P1, &Q1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &D_blind, &D_blind, &R ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &D_blind, &D_blind, &ctx->D ) );
+
+ D = &D_blind;
+#else
+ /*
+ * DP_blind = ( P - 1 ) * R + DP
+ */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &R, RSA_EXPONENT_BLINDING,
+ f_rng, p_rng ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &DP_blind, &P1, &R ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &DP_blind, &DP_blind,
+ &ctx->DP ) );
+
+ DP = &DP_blind;
+
+ /*
+ * DQ_blind = ( Q - 1 ) * R + DQ
+ */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &R, RSA_EXPONENT_BLINDING,
+ f_rng, p_rng ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &DQ_blind, &Q1, &R ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &DQ_blind, &DQ_blind,
+ &ctx->DQ ) );
+
+ DQ = &DQ_blind;
+#endif /* MBEDTLS_RSA_NO_CRT */
}
#if defined(MBEDTLS_RSA_NO_CRT)
- MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T, &T, &ctx->D, &ctx->N, &ctx->RN ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T, &T, D, &ctx->N, &ctx->RN ) );
#else
/*
- * faster decryption using the CRT
+ * Faster decryption using the CRT
*
- * T1 = input ^ dP mod P
- * T2 = input ^ dQ mod Q
+ * TP = input ^ dP mod P
+ * TQ = input ^ dQ mod Q
*/
- MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T1, &T, &ctx->DP, &ctx->P, &ctx->RP ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &T2, &T, &ctx->DQ, &ctx->Q, &ctx->RQ ) );
+
+ MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &TP, &T, DP, &ctx->P, &ctx->RP ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &TQ, &T, DQ, &ctx->Q, &ctx->RQ ) );
/*
- * T = (T1 - T2) * (Q^-1 mod P) mod P
+ * T = (TP - TQ) * (Q^-1 mod P) mod P
*/
- MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &T, &T1, &T2 ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T1, &T, &ctx->QP ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &T, &T1, &ctx->P ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &T, &TP, &TQ ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &TP, &T, &ctx->QP ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &T, &TP, &ctx->P ) );
/*
- * T = T2 + T * Q
+ * T = TQ + T * Q
*/
- MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T1, &T, &ctx->Q ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &T, &T2, &T1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &TP, &T, &ctx->Q ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &T, &TQ, &TP ) );
#endif /* MBEDTLS_RSA_NO_CRT */
if( f_rng != NULL )
MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &T, &T, &ctx->N ) );
}
+ /* Verify the result to prevent glitching attacks. */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &C, &T, &ctx->E,
+ &ctx->N, &ctx->RN ) );
+ if( mbedtls_mpi_cmp_mpi( &C, &I ) != 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_VERIFY_FAILED;
+ goto cleanup;
+ }
+
olen = ctx->len;
MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &T, output, olen ) );
-cleanup:
-#if defined(MBEDTLS_THREADING_C)
- if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
- return( MBEDTLS_ERR_THREADING_MUTEX_ERROR );
+cleanup:
+#if defined(MBEDTLS_THREADING_C)
+ if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 )
+ return( MBEDTLS_ERR_THREADING_MUTEX_ERROR );
+#endif
+
+ mbedtls_mpi_free( &P1 );
+ mbedtls_mpi_free( &Q1 );
+ mbedtls_mpi_free( &R );
+
+ if( f_rng != NULL )
+ {
+#if defined(MBEDTLS_RSA_NO_CRT)
+ mbedtls_mpi_free( &D_blind );
+#else
+ mbedtls_mpi_free( &DP_blind );
+ mbedtls_mpi_free( &DQ_blind );
+#endif
+ }
+
+ mbedtls_mpi_free( &T );
+
+#if !defined(MBEDTLS_RSA_NO_CRT)
+ mbedtls_mpi_free( &TP ); mbedtls_mpi_free( &TQ );
#endif
- mbedtls_mpi_free( &T ); mbedtls_mpi_free( &T1 ); mbedtls_mpi_free( &T2 );
+ mbedtls_mpi_free( &C );
+ mbedtls_mpi_free( &I );
if( ret != 0 )
return( MBEDTLS_ERR_RSA_PRIVATE_FAILED + ret );
* \param slen length of the source buffer
* \param md_ctx message digest context to use
*/
-static void mgf_mask( unsigned char *dst, size_t dlen, unsigned char *src,
+static int mgf_mask( unsigned char *dst, size_t dlen, unsigned char *src,
size_t slen, mbedtls_md_context_t *md_ctx )
{
unsigned char mask[MBEDTLS_MD_MAX_SIZE];
unsigned char *p;
unsigned int hlen;
size_t i, use_len;
+ int ret = 0;
memset( mask, 0, MBEDTLS_MD_MAX_SIZE );
memset( counter, 0, 4 );
if( dlen < hlen )
use_len = dlen;
- mbedtls_md_starts( md_ctx );
- mbedtls_md_update( md_ctx, src, slen );
- mbedtls_md_update( md_ctx, counter, 4 );
- mbedtls_md_finish( md_ctx, mask );
+ if( ( ret = mbedtls_md_starts( md_ctx ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md_update( md_ctx, src, slen ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md_update( md_ctx, counter, 4 ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md_finish( md_ctx, mask ) ) != 0 )
+ goto exit;
for( i = 0; i < use_len; ++i )
*p++ ^= mask[i];
dlen -= use_len;
}
+
+exit:
+ mbedtls_zeroize( mask, sizeof( mask ) );
+
+ return( ret );
}
#endif /* MBEDTLS_PKCS1_V21 */
p += hlen;
/* Construct DB */
- mbedtls_md( md_info, label, label_len, p );
+ if( ( ret = mbedtls_md( md_info, label, label_len, p ) ) != 0 )
+ return( ret );
p += hlen;
p += olen - 2 * hlen - 2 - ilen;
*p++ = 1;
mbedtls_md_init( &md_ctx );
if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
- {
- mbedtls_md_free( &md_ctx );
- return( ret );
- }
+ goto exit;
/* maskedDB: Apply dbMask to DB */
- mgf_mask( output + hlen + 1, olen - hlen - 1, output + 1, hlen,
- &md_ctx );
+ if( ( ret = mgf_mask( output + hlen + 1, olen - hlen - 1, output + 1, hlen,
+ &md_ctx ) ) != 0 )
+ goto exit;
/* maskedSeed: Apply seedMask to seed */
- mgf_mask( output + 1, hlen, output + hlen + 1, olen - hlen - 1,
- &md_ctx );
+ if( ( ret = mgf_mask( output + 1, hlen, output + hlen + 1, olen - hlen - 1,
+ &md_ctx ) ) != 0 )
+ goto exit;
+exit:
mbedtls_md_free( &md_ctx );
+ if( ret != 0 )
+ return( ret );
+
return( ( mode == MBEDTLS_RSA_PUBLIC )
? mbedtls_rsa_public( ctx, output, output )
: mbedtls_rsa_private( ctx, f_rng, p_rng, output, output ) );
: mbedtls_rsa_private( ctx, f_rng, p_rng, input, buf );
if( ret != 0 )
- return( ret );
+ goto cleanup;
/*
* Unmask data and generate lHash
if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
{
mbedtls_md_free( &md_ctx );
- return( ret );
+ goto cleanup;
}
-
- /* Generate lHash */
- mbedtls_md( md_info, label, label_len, lhash );
-
/* seed: Apply seedMask to maskedSeed */
- mgf_mask( buf + 1, hlen, buf + hlen + 1, ilen - hlen - 1,
- &md_ctx );
-
+ if( ( ret = mgf_mask( buf + 1, hlen, buf + hlen + 1, ilen - hlen - 1,
+ &md_ctx ) ) != 0 ||
/* DB: Apply dbMask to maskedDB */
- mgf_mask( buf + hlen + 1, ilen - hlen - 1, buf + 1, hlen,
- &md_ctx );
+ ( ret = mgf_mask( buf + hlen + 1, ilen - hlen - 1, buf + 1, hlen,
+ &md_ctx ) ) != 0 )
+ {
+ mbedtls_md_free( &md_ctx );
+ goto cleanup;
+ }
mbedtls_md_free( &md_ctx );
+ /* Generate lHash */
+ if( ( ret = mbedtls_md( md_info, label, label_len, lhash ) ) != 0 )
+ goto cleanup;
+
/*
* Check contents, in "constant-time"
*/
* the different error conditions.
*/
if( bad != 0 )
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
+ {
+ ret = MBEDTLS_ERR_RSA_INVALID_PADDING;
+ goto cleanup;
+ }
if( ilen - ( p - buf ) > output_max_len )
- return( MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE );
+ {
+ ret = MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE;
+ goto cleanup;
+ }
*olen = ilen - (p - buf);
memcpy( output, p, *olen );
+ ret = 0;
- return( 0 );
+cleanup:
+ mbedtls_zeroize( buf, sizeof( buf ) );
+ mbedtls_zeroize( lhash, sizeof( lhash ) );
+
+ return( ret );
}
#endif /* MBEDTLS_PKCS1_V21 */
: mbedtls_rsa_private( ctx, f_rng, p_rng, input, buf );
if( ret != 0 )
- return( ret );
+ goto cleanup;
p = buf;
bad = 0;
bad |= ( pad_count < 8 );
if( bad )
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
+ {
+ ret = MBEDTLS_ERR_RSA_INVALID_PADDING;
+ goto cleanup;
+ }
if( ilen - ( p - buf ) > output_max_len )
- return( MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE );
+ {
+ ret = MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE;
+ goto cleanup;
+ }
*olen = ilen - (p - buf);
memcpy( output, p, *olen );
+ ret = 0;
- return( 0 );
+cleanup:
+ mbedtls_zeroize( buf, sizeof( buf ) );
+
+ return( ret );
}
#endif /* MBEDTLS_PKCS1_V15 */
mbedtls_md_init( &md_ctx );
if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
- {
- mbedtls_md_free( &md_ctx );
- return( ret );
- }
+ goto exit;
/* Generate H = Hash( M' ) */
- mbedtls_md_starts( &md_ctx );
- mbedtls_md_update( &md_ctx, p, 8 );
- mbedtls_md_update( &md_ctx, hash, hashlen );
- mbedtls_md_update( &md_ctx, salt, slen );
- mbedtls_md_finish( &md_ctx, p );
+ if( ( ret = mbedtls_md_starts( &md_ctx ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md_update( &md_ctx, p, 8 ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md_update( &md_ctx, hash, hashlen ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md_update( &md_ctx, salt, slen ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md_finish( &md_ctx, p ) ) != 0 )
+ goto exit;
/* Compensate for boundary condition when applying mask */
if( msb % 8 == 0 )
offset = 1;
/* maskedDB: Apply dbMask to DB */
- mgf_mask( sig + offset, olen - hlen - 1 - offset, p, hlen, &md_ctx );
-
- mbedtls_md_free( &md_ctx );
+ if( ( ret = mgf_mask( sig + offset, olen - hlen - 1 - offset, p, hlen,
+ &md_ctx ) ) != 0 )
+ goto exit;
msb = mbedtls_mpi_bitlen( &ctx->N ) - 1;
sig[0] &= 0xFF >> ( olen * 8 - msb );
p += hlen;
*p++ = 0xBC;
+ mbedtls_zeroize( salt, sizeof( salt ) );
+
+exit:
+ mbedtls_md_free( &md_ctx );
+
+ if( ret != 0 )
+ return( ret );
+
return( ( mode == MBEDTLS_RSA_PUBLIC )
? mbedtls_rsa_public( ctx, sig, sig )
: mbedtls_rsa_private( ctx, f_rng, p_rng, sig, sig ) );
/*
* Implementation of the PKCS#1 v2.1 RSASSA-PKCS1-V1_5-SIGN function
*/
-/*
- * Do an RSA operation to sign the message digest
+
+/* Construct a PKCS v1.5 encoding of a hashed message
+ *
+ * This is used both for signature generation and verification.
+ *
+ * Parameters:
+ * - md_alg: Identifies the hash algorithm used to generate the given hash;
+ * MBEDTLS_MD_NONE if raw data is signed.
+ * - hashlen: Length of hash in case hashlen is MBEDTLS_MD_NONE.
+ * - hash: Buffer containing the hashed message or the raw data.
+ * - dst_len: Length of the encoded message.
+ * - dst: Buffer to hold the encoded message.
+ *
+ * Assumptions:
+ * - hash has size hashlen if md_alg == MBEDTLS_MD_NONE.
+ * - hash has size corresponding to md_alg if md_alg != MBEDTLS_MD_NONE.
+ * - dst points to a buffer of size at least dst_len.
+ *
*/
-int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng,
- int mode,
- mbedtls_md_type_t md_alg,
- unsigned int hashlen,
- const unsigned char *hash,
- unsigned char *sig )
+static int rsa_rsassa_pkcs1_v15_encode( mbedtls_md_type_t md_alg,
+ unsigned int hashlen,
+ const unsigned char *hash,
+ size_t dst_len,
+ unsigned char *dst )
{
- size_t nb_pad, olen, oid_size = 0;
- unsigned char *p = sig;
- const char *oid = NULL;
- unsigned char *sig_try = NULL, *verif = NULL;
- size_t i;
- unsigned char diff;
- volatile unsigned char diff_no_optimize;
- int ret;
-
- if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- olen = ctx->len;
- nb_pad = olen - 3;
+ size_t oid_size = 0;
+ size_t nb_pad = dst_len;
+ unsigned char *p = dst;
+ const char *oid = NULL;
+ /* Are we signing hashed or raw data? */
if( md_alg != MBEDTLS_MD_NONE )
{
const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_alg );
if( mbedtls_oid_get_oid_by_md( md_alg, &oid, &oid_size ) != 0 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
- nb_pad -= 10 + oid_size;
-
hashlen = mbedtls_md_get_size( md_info );
+
+ /* Double-check that 8 + hashlen + oid_size can be used as a
+ * 1-byte ASN.1 length encoding and that there's no overflow. */
+ if( 8 + hashlen + oid_size >= 0x80 ||
+ 10 + hashlen < hashlen ||
+ 10 + hashlen + oid_size < 10 + hashlen )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+
+ /*
+ * Static bounds check:
+ * - Need 10 bytes for five tag-length pairs.
+ * (Insist on 1-byte length encodings to protect against variants of
+ * Bleichenbacher's forgery attack against lax PKCS#1v1.5 verification)
+ * - Need hashlen bytes for hash
+ * - Need oid_size bytes for hash alg OID.
+ */
+ if( nb_pad < 10 + hashlen + oid_size )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+ nb_pad -= 10 + hashlen + oid_size;
}
+ else
+ {
+ if( nb_pad < hashlen )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
- nb_pad -= hashlen;
+ nb_pad -= hashlen;
+ }
- if( ( nb_pad < 8 ) || ( nb_pad > olen ) )
+ /* Need space for signature header and padding delimiter (3 bytes),
+ * and 8 bytes for the minimal padding */
+ if( nb_pad < 3 + 8 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+ nb_pad -= 3;
+ /* Now nb_pad is the amount of memory to be filled
+ * with padding, and at least 8 bytes long. */
+
+ /* Write signature header and padding */
*p++ = 0;
*p++ = MBEDTLS_RSA_SIGN;
memset( p, 0xFF, nb_pad );
p += nb_pad;
*p++ = 0;
+ /* Are we signing raw data? */
if( md_alg == MBEDTLS_MD_NONE )
{
memcpy( p, hash, hashlen );
+ return( 0 );
}
- else
+
+ /* Signing hashed data, add corresponding ASN.1 structure
+ *
+ * DigestInfo ::= SEQUENCE {
+ * digestAlgorithm DigestAlgorithmIdentifier,
+ * digest Digest }
+ * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
+ * Digest ::= OCTET STRING
+ *
+ * Schematic:
+ * TAG-SEQ + LEN [ TAG-SEQ + LEN [ TAG-OID + LEN [ OID ]
+ * TAG-NULL + LEN [ NULL ] ]
+ * TAG-OCTET + LEN [ HASH ] ]
+ */
+ *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED;
+ *p++ = (unsigned char)( 0x08 + oid_size + hashlen );
+ *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED;
+ *p++ = (unsigned char)( 0x04 + oid_size );
+ *p++ = MBEDTLS_ASN1_OID;
+ *p++ = (unsigned char) oid_size;
+ memcpy( p, oid, oid_size );
+ p += oid_size;
+ *p++ = MBEDTLS_ASN1_NULL;
+ *p++ = 0x00;
+ *p++ = MBEDTLS_ASN1_OCTET_STRING;
+ *p++ = (unsigned char) hashlen;
+ memcpy( p, hash, hashlen );
+ p += hashlen;
+
+ /* Just a sanity-check, should be automatic
+ * after the initial bounds check. */
+ if( p != dst + dst_len )
{
- /*
- * DigestInfo ::= SEQUENCE {
- * digestAlgorithm DigestAlgorithmIdentifier,
- * digest Digest }
- *
- * DigestAlgorithmIdentifier ::= AlgorithmIdentifier
- *
- * Digest ::= OCTET STRING
- */
- *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED;
- *p++ = (unsigned char) ( 0x08 + oid_size + hashlen );
- *p++ = MBEDTLS_ASN1_SEQUENCE | MBEDTLS_ASN1_CONSTRUCTED;
- *p++ = (unsigned char) ( 0x04 + oid_size );
- *p++ = MBEDTLS_ASN1_OID;
- *p++ = oid_size & 0xFF;
- memcpy( p, oid, oid_size );
- p += oid_size;
- *p++ = MBEDTLS_ASN1_NULL;
- *p++ = 0x00;
- *p++ = MBEDTLS_ASN1_OCTET_STRING;
- *p++ = hashlen;
- memcpy( p, hash, hashlen );
+ mbedtls_zeroize( dst, dst_len );
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
}
- if( mode == MBEDTLS_RSA_PUBLIC )
- return( mbedtls_rsa_public( ctx, sig, sig ) );
+ return( 0 );
+}
+
+/*
+ * Do an RSA operation to sign the message digest
+ */
+int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx,
+ int (*f_rng)(void *, unsigned char *, size_t),
+ void *p_rng,
+ int mode,
+ mbedtls_md_type_t md_alg,
+ unsigned int hashlen,
+ const unsigned char *hash,
+ unsigned char *sig )
+{
+ int ret;
+ unsigned char *sig_try = NULL, *verif = NULL;
+
+ if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+
+ /*
+ * Prepare PKCS1-v1.5 encoding (padding and hash identifier)
+ */
+
+ if( ( ret = rsa_rsassa_pkcs1_v15_encode( md_alg, hashlen, hash,
+ ctx->len, sig ) ) != 0 )
+ return( ret );
/*
+ * Call respective RSA primitive
+ */
+
+ if( mode == MBEDTLS_RSA_PUBLIC )
+ {
+ /* Skip verification on a public key operation */
+ return( mbedtls_rsa_public( ctx, sig, sig ) );
+ }
+
+ /* Private key operation
+ *
* In order to prevent Lenstra's attack, make the signature in a
* temporary buffer and check it before returning it.
*/
+
sig_try = mbedtls_calloc( 1, ctx->len );
if( sig_try == NULL )
return( MBEDTLS_ERR_MPI_ALLOC_FAILED );
- verif = mbedtls_calloc( 1, ctx->len );
+ verif = mbedtls_calloc( 1, ctx->len );
if( verif == NULL )
{
mbedtls_free( sig_try );
MBEDTLS_MPI_CHK( mbedtls_rsa_private( ctx, f_rng, p_rng, sig, sig_try ) );
MBEDTLS_MPI_CHK( mbedtls_rsa_public( ctx, sig_try, verif ) );
- /* Compare in constant time just in case */
- for( diff = 0, i = 0; i < ctx->len; i++ )
- diff |= verif[i] ^ sig[i];
- diff_no_optimize = diff;
-
- if( diff_no_optimize != 0 )
+ if( mbedtls_safer_memcmp( verif, sig, ctx->len ) != 0 )
{
ret = MBEDTLS_ERR_RSA_PRIVATE_FAILED;
goto cleanup;
int ret;
size_t siglen;
unsigned char *p;
+ unsigned char *hash_start;
unsigned char result[MBEDTLS_MD_MAX_SIZE];
unsigned char zeros[8];
unsigned int hlen;
- size_t slen, msb;
+ size_t observed_salt_len, msb;
const mbedtls_md_info_t *md_info;
mbedtls_md_context_t md_ctx;
unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
hlen = mbedtls_md_get_size( md_info );
- slen = siglen - hlen - 1; /* Currently length of salt + padding */
memset( zeros, 0, 8 );
*/
msb = mbedtls_mpi_bitlen( &ctx->N ) - 1;
+ if( buf[0] >> ( 8 - siglen * 8 + msb ) )
+ return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+
/* Compensate for boundary condition when applying mask */
if( msb % 8 == 0 )
{
p++;
siglen -= 1;
}
- if( buf[0] >> ( 8 - siglen * 8 + msb ) )
+
+ if( siglen < hlen + 2 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
+ hash_start = p + siglen - hlen - 1;
mbedtls_md_init( &md_ctx );
if( ( ret = mbedtls_md_setup( &md_ctx, md_info, 0 ) ) != 0 )
- {
- mbedtls_md_free( &md_ctx );
- return( ret );
- }
+ goto exit;
- mgf_mask( p, siglen - hlen - 1, p + siglen - hlen - 1, hlen, &md_ctx );
+ ret = mgf_mask( p, siglen - hlen - 1, hash_start, hlen, &md_ctx );
+ if( ret != 0 )
+ goto exit;
buf[0] &= 0xFF >> ( siglen * 8 - msb );
- while( p < buf + siglen && *p == 0 )
+ while( p < hash_start - 1 && *p == 0 )
p++;
- if( p == buf + siglen ||
- *p++ != 0x01 )
+ if( *p++ != 0x01 )
{
- mbedtls_md_free( &md_ctx );
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
+ ret = MBEDTLS_ERR_RSA_INVALID_PADDING;
+ goto exit;
}
- /* Actual salt len */
- slen -= p - buf;
+ observed_salt_len = hash_start - p;
if( expected_salt_len != MBEDTLS_RSA_SALT_LEN_ANY &&
- slen != (size_t) expected_salt_len )
+ observed_salt_len != (size_t) expected_salt_len )
{
- mbedtls_md_free( &md_ctx );
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
+ ret = MBEDTLS_ERR_RSA_INVALID_PADDING;
+ goto exit;
}
/*
* Generate H = Hash( M' )
*/
- mbedtls_md_starts( &md_ctx );
- mbedtls_md_update( &md_ctx, zeros, 8 );
- mbedtls_md_update( &md_ctx, hash, hashlen );
- mbedtls_md_update( &md_ctx, p, slen );
- mbedtls_md_finish( &md_ctx, result );
+ ret = mbedtls_md_starts( &md_ctx );
+ if ( ret != 0 )
+ goto exit;
+ ret = mbedtls_md_update( &md_ctx, zeros, 8 );
+ if ( ret != 0 )
+ goto exit;
+ ret = mbedtls_md_update( &md_ctx, hash, hashlen );
+ if ( ret != 0 )
+ goto exit;
+ ret = mbedtls_md_update( &md_ctx, p, observed_salt_len );
+ if ( ret != 0 )
+ goto exit;
+ ret = mbedtls_md_finish( &md_ctx, result );
+ if ( ret != 0 )
+ goto exit;
+
+ if( memcmp( hash_start, result, hlen ) != 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_VERIFY_FAILED;
+ goto exit;
+ }
+exit:
mbedtls_md_free( &md_ctx );
- if( memcmp( p + slen, result, hlen ) == 0 )
- return( 0 );
- else
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
+ return( ret );
}
/*
const unsigned char *hash,
const unsigned char *sig )
{
- int ret;
- size_t len, siglen, asn1_len;
- unsigned char *p, *end;
- mbedtls_md_type_t msg_md_alg;
- const mbedtls_md_info_t *md_info;
- mbedtls_asn1_buf oid;
- unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
+ int ret = 0;
+ const size_t sig_len = ctx->len;
+ unsigned char *encoded = NULL, *encoded_expected = NULL;
if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
- siglen = ctx->len;
-
- if( siglen < 16 || siglen > sizeof( buf ) )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
-
- ret = ( mode == MBEDTLS_RSA_PUBLIC )
- ? mbedtls_rsa_public( ctx, sig, buf )
- : mbedtls_rsa_private( ctx, f_rng, p_rng, sig, buf );
-
- if( ret != 0 )
- return( ret );
-
- p = buf;
-
- if( *p++ != 0 || *p++ != MBEDTLS_RSA_SIGN )
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
-
- while( *p != 0 )
- {
- if( p >= buf + siglen - 1 || *p != 0xFF )
- return( MBEDTLS_ERR_RSA_INVALID_PADDING );
- p++;
- }
- p++;
-
- len = siglen - ( p - buf );
+ /*
+ * Prepare expected PKCS1 v1.5 encoding of hash.
+ */
- if( len == hashlen && md_alg == MBEDTLS_MD_NONE )
+ if( ( encoded = mbedtls_calloc( 1, sig_len ) ) == NULL ||
+ ( encoded_expected = mbedtls_calloc( 1, sig_len ) ) == NULL )
{
- if( memcmp( p, hash, hashlen ) == 0 )
- return( 0 );
- else
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
+ ret = MBEDTLS_ERR_MPI_ALLOC_FAILED;
+ goto cleanup;
}
- md_info = mbedtls_md_info_from_type( md_alg );
- if( md_info == NULL )
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA );
- hashlen = mbedtls_md_get_size( md_info );
-
- end = p + len;
+ if( ( ret = rsa_rsassa_pkcs1_v15_encode( md_alg, hashlen, hash, sig_len,
+ encoded_expected ) ) != 0 )
+ goto cleanup;
/*
- * Parse the ASN.1 structure inside the PKCS#1 v1.5 structure
+ * Apply RSA primitive to get what should be PKCS1 encoded hash.
*/
- if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len,
- MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- if( asn1_len + 2 != len )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len,
- MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- if( asn1_len + 6 + hashlen != len )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- if( ( ret = mbedtls_asn1_get_tag( &p, end, &oid.len, MBEDTLS_ASN1_OID ) ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- oid.p = p;
- p += oid.len;
- if( mbedtls_oid_get_md_alg( &oid, &msg_md_alg ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- if( md_alg != msg_md_alg )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
+ ret = ( mode == MBEDTLS_RSA_PUBLIC )
+ ? mbedtls_rsa_public( ctx, sig, encoded )
+ : mbedtls_rsa_private( ctx, f_rng, p_rng, sig, encoded );
+ if( ret != 0 )
+ goto cleanup;
/*
- * assume the algorithm parameters must be NULL
+ * Compare
*/
- if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_NULL ) ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
- if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
-
- if( asn1_len != hashlen )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
+ if( ( ret = mbedtls_safer_memcmp( encoded, encoded_expected,
+ sig_len ) ) != 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_VERIFY_FAILED;
+ goto cleanup;
+ }
- if( memcmp( p, hash, hashlen ) != 0 )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
+cleanup:
- p += hashlen;
+ if( encoded != NULL )
+ {
+ mbedtls_zeroize( encoded, sig_len );
+ mbedtls_free( encoded );
+ }
- if( p != end )
- return( MBEDTLS_ERR_RSA_VERIFY_FAILED );
+ if( encoded_expected != NULL )
+ {
+ mbedtls_zeroize( encoded_expected, sig_len );
+ mbedtls_free( encoded_expected );
+ }
- return( 0 );
+ return( ret );
}
#endif /* MBEDTLS_PKCS1_V15 */
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->D, &src->D ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->P, &src->P ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->Q, &src->Q ) );
+
+#if !defined(MBEDTLS_RSA_NO_CRT)
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->DP, &src->DP ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->DQ, &src->DQ ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->QP, &src->QP ) );
-
- MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->RN, &src->RN ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->RP, &src->RP ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->RQ, &src->RQ ) );
+#endif
+
+ MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->RN, &src->RN ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->Vi, &src->Vi ) );
MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &dst->Vf, &src->Vf ) );
void mbedtls_rsa_free( mbedtls_rsa_context *ctx )
{
mbedtls_mpi_free( &ctx->Vi ); mbedtls_mpi_free( &ctx->Vf );
- mbedtls_mpi_free( &ctx->RQ ); mbedtls_mpi_free( &ctx->RP ); mbedtls_mpi_free( &ctx->RN );
- mbedtls_mpi_free( &ctx->QP ); mbedtls_mpi_free( &ctx->DQ ); mbedtls_mpi_free( &ctx->DP );
- mbedtls_mpi_free( &ctx->Q ); mbedtls_mpi_free( &ctx->P ); mbedtls_mpi_free( &ctx->D );
+ mbedtls_mpi_free( &ctx->RN ); mbedtls_mpi_free( &ctx->D );
+ mbedtls_mpi_free( &ctx->Q ); mbedtls_mpi_free( &ctx->P );
mbedtls_mpi_free( &ctx->E ); mbedtls_mpi_free( &ctx->N );
+#if !defined(MBEDTLS_RSA_NO_CRT)
+ mbedtls_mpi_free( &ctx->RQ ); mbedtls_mpi_free( &ctx->RP );
+ mbedtls_mpi_free( &ctx->QP ); mbedtls_mpi_free( &ctx->DQ );
+ mbedtls_mpi_free( &ctx->DP );
+#endif /* MBEDTLS_RSA_NO_CRT */
+
#if defined(MBEDTLS_THREADING_C)
mbedtls_mutex_free( &ctx->mutex );
#endif
}
+#endif /* !MBEDTLS_RSA_ALT */
+
#if defined(MBEDTLS_SELF_TEST)
#include "mbedtls/sha1.h"
"910E4168387E3C30AA1E00C339A79508" \
"8452DD96A9A5EA5D9DCA68DA636032AF"
-#define RSA_DP "C1ACF567564274FB07A0BBAD5D26E298" \
- "3C94D22288ACD763FD8E5600ED4A702D" \
- "F84198A5F06C2E72236AE490C93F07F8" \
- "3CC559CD27BC2D1CA488811730BB5725"
-
-#define RSA_DQ "4959CBF6F8FEF750AEE6977C155579C7" \
- "D8AAEA56749EA28623272E4F7D0592AF" \
- "7C1F1313CAC9471B5C523BFE592F517B" \
- "407A1BD76C164B93DA2D32A383E58357"
-
-#define RSA_QP "9AE7FBC99546432DF71896FC239EADAE" \
- "F38D18D2B2F0E2DD275AA977E2BF4411" \
- "F5A3B2A5D33605AEBBCCBA7FEB9F2D2F" \
- "A74206CEC169D74BF5A8C50D6F48EA08"
-
#define PT_LEN 24
#define RSA_PT "\xAA\xBB\xCC\x03\x02\x01\x00\xFF\xFF\xFF\xFF\xFF" \
"\x11\x22\x33\x0A\x0B\x0C\xCC\xDD\xDD\xDD\xDD\xDD"
unsigned char sha1sum[20];
#endif
+ mbedtls_mpi K;
+
+ mbedtls_mpi_init( &K );
mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
- rsa.len = KEY_LEN;
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.N , 16, RSA_N ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.E , 16, RSA_E ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.D , 16, RSA_D ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.P , 16, RSA_P ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.Q , 16, RSA_Q ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.DP, 16, RSA_DP ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.DQ, 16, RSA_DQ ) );
- MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &rsa.QP, 16, RSA_QP ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &K, 16, RSA_N ) );
+ MBEDTLS_MPI_CHK( mbedtls_rsa_import( &rsa, &K, NULL, NULL, NULL, NULL ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &K, 16, RSA_P ) );
+ MBEDTLS_MPI_CHK( mbedtls_rsa_import( &rsa, NULL, &K, NULL, NULL, NULL ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &K, 16, RSA_Q ) );
+ MBEDTLS_MPI_CHK( mbedtls_rsa_import( &rsa, NULL, NULL, &K, NULL, NULL ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &K, 16, RSA_D ) );
+ MBEDTLS_MPI_CHK( mbedtls_rsa_import( &rsa, NULL, NULL, NULL, &K, NULL ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &K, 16, RSA_E ) );
+ MBEDTLS_MPI_CHK( mbedtls_rsa_import( &rsa, NULL, NULL, NULL, NULL, &K ) );
+
+ MBEDTLS_MPI_CHK( mbedtls_rsa_complete( &rsa ) );
if( verbose != 0 )
mbedtls_printf( " RSA key validation: " );
if( verbose != 0 )
mbedtls_printf( "failed\n" );
- return( 1 );
+ ret = 1;
+ goto cleanup;
}
if( verbose != 0 )
memcpy( rsa_plaintext, RSA_PT, PT_LEN );
- if( mbedtls_rsa_pkcs1_encrypt( &rsa, myrand, NULL, MBEDTLS_RSA_PUBLIC, PT_LEN,
- rsa_plaintext, rsa_ciphertext ) != 0 )
+ if( mbedtls_rsa_pkcs1_encrypt( &rsa, myrand, NULL, MBEDTLS_RSA_PUBLIC,
+ PT_LEN, rsa_plaintext,
+ rsa_ciphertext ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
- return( 1 );
+ ret = 1;
+ goto cleanup;
}
if( verbose != 0 )
mbedtls_printf( "passed\n PKCS#1 decryption : " );
- if( mbedtls_rsa_pkcs1_decrypt( &rsa, myrand, NULL, MBEDTLS_RSA_PRIVATE, &len,
- rsa_ciphertext, rsa_decrypted,
- sizeof(rsa_decrypted) ) != 0 )
+ if( mbedtls_rsa_pkcs1_decrypt( &rsa, myrand, NULL, MBEDTLS_RSA_PRIVATE,
+ &len, rsa_ciphertext, rsa_decrypted,
+ sizeof(rsa_decrypted) ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
- return( 1 );
+ ret = 1;
+ goto cleanup;
}
if( memcmp( rsa_decrypted, rsa_plaintext, len ) != 0 )
if( verbose != 0 )
mbedtls_printf( "failed\n" );
- return( 1 );
+ ret = 1;
+ goto cleanup;
}
if( verbose != 0 )
if( verbose != 0 )
mbedtls_printf( " PKCS#1 data sign : " );
- mbedtls_sha1( rsa_plaintext, PT_LEN, sha1sum );
-
- if( mbedtls_rsa_pkcs1_sign( &rsa, myrand, NULL, MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_SHA1, 0,
- sha1sum, rsa_ciphertext ) != 0 )
+ if( mbedtls_sha1_ret( rsa_plaintext, PT_LEN, sha1sum ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
return( 1 );
}
+ if( mbedtls_rsa_pkcs1_sign( &rsa, myrand, NULL,
+ MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_SHA1, 0,
+ sha1sum, rsa_ciphertext ) != 0 )
+ {
+ if( verbose != 0 )
+ mbedtls_printf( "failed\n" );
+
+ ret = 1;
+ goto cleanup;
+ }
+
if( verbose != 0 )
mbedtls_printf( "passed\n PKCS#1 sig. verify: " );
- if( mbedtls_rsa_pkcs1_verify( &rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_SHA1, 0,
- sha1sum, rsa_ciphertext ) != 0 )
+ if( mbedtls_rsa_pkcs1_verify( &rsa, NULL, NULL,
+ MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_SHA1, 0,
+ sha1sum, rsa_ciphertext ) != 0 )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
- return( 1 );
+ ret = 1;
+ goto cleanup;
}
if( verbose != 0 )
mbedtls_printf( "\n" );
cleanup:
+ mbedtls_mpi_free( &K );
mbedtls_rsa_free( &rsa );
#else /* MBEDTLS_PKCS1_V15 */
((void) verbose);
--- /dev/null
+/*
+ * Helper functions for the RSA module
+ *
+ * Copyright (C) 2006-2017, ARM Limited, All Rights Reserved
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This file is part of mbed TLS (https://tls.mbed.org)
+ *
+ */
+
+#if !defined(MBEDTLS_CONFIG_FILE)
+#include "mbedtls/config.h"
+#else
+#include MBEDTLS_CONFIG_FILE
+#endif
+
+#if defined(MBEDTLS_RSA_C)
+
+#include "mbedtls/rsa.h"
+#include "mbedtls/bignum.h"
+#include "mbedtls/rsa_internal.h"
+
+/*
+ * Compute RSA prime factors from public and private exponents
+ *
+ * Summary of algorithm:
+ * Setting F := lcm(P-1,Q-1), the idea is as follows:
+ *
+ * (a) For any 1 <= X < N with gcd(X,N)=1, we have X^F = 1 modulo N, so X^(F/2)
+ * is a square root of 1 in Z/NZ. Since Z/NZ ~= Z/PZ x Z/QZ by CRT and the
+ * square roots of 1 in Z/PZ and Z/QZ are +1 and -1, this leaves the four
+ * possibilities X^(F/2) = (+-1, +-1). If it happens that X^(F/2) = (-1,+1)
+ * or (+1,-1), then gcd(X^(F/2) + 1, N) will be equal to one of the prime
+ * factors of N.
+ *
+ * (b) If we don't know F/2 but (F/2) * K for some odd (!) K, then the same
+ * construction still applies since (-)^K is the identity on the set of
+ * roots of 1 in Z/NZ.
+ *
+ * The public and private key primitives (-)^E and (-)^D are mutually inverse
+ * bijections on Z/NZ if and only if (-)^(DE) is the identity on Z/NZ, i.e.
+ * if and only if DE - 1 is a multiple of F, say DE - 1 = F * L.
+ * Splitting L = 2^t * K with K odd, we have
+ *
+ * DE - 1 = FL = (F/2) * (2^(t+1)) * K,
+ *
+ * so (F / 2) * K is among the numbers
+ *
+ * (DE - 1) >> 1, (DE - 1) >> 2, ..., (DE - 1) >> ord
+ *
+ * where ord is the order of 2 in (DE - 1).
+ * We can therefore iterate through these numbers apply the construction
+ * of (a) and (b) above to attempt to factor N.
+ *
+ */
+int mbedtls_rsa_deduce_primes( mbedtls_mpi const *N,
+ mbedtls_mpi const *E, mbedtls_mpi const *D,
+ mbedtls_mpi *P, mbedtls_mpi *Q )
+{
+ int ret = 0;
+
+ uint16_t attempt; /* Number of current attempt */
+ uint16_t iter; /* Number of squares computed in the current attempt */
+
+ uint16_t order; /* Order of 2 in DE - 1 */
+
+ mbedtls_mpi T; /* Holds largest odd divisor of DE - 1 */
+ mbedtls_mpi K; /* Temporary holding the current candidate */
+
+ const unsigned char primes[] = { 2,
+ 3, 5, 7, 11, 13, 17, 19, 23,
+ 29, 31, 37, 41, 43, 47, 53, 59,
+ 61, 67, 71, 73, 79, 83, 89, 97,
+ 101, 103, 107, 109, 113, 127, 131, 137,
+ 139, 149, 151, 157, 163, 167, 173, 179,
+ 181, 191, 193, 197, 199, 211, 223, 227,
+ 229, 233, 239, 241, 251
+ };
+
+ const size_t num_primes = sizeof( primes ) / sizeof( *primes );
+
+ if( P == NULL || Q == NULL || P->p != NULL || Q->p != NULL )
+ return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
+
+ if( mbedtls_mpi_cmp_int( N, 0 ) <= 0 ||
+ mbedtls_mpi_cmp_int( D, 1 ) <= 0 ||
+ mbedtls_mpi_cmp_mpi( D, N ) >= 0 ||
+ mbedtls_mpi_cmp_int( E, 1 ) <= 0 ||
+ mbedtls_mpi_cmp_mpi( E, N ) >= 0 )
+ {
+ return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
+ }
+
+ /*
+ * Initializations and temporary changes
+ */
+
+ mbedtls_mpi_init( &K );
+ mbedtls_mpi_init( &T );
+
+ /* T := DE - 1 */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, D, E ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &T, &T, 1 ) );
+
+ if( ( order = (uint16_t) mbedtls_mpi_lsb( &T ) ) == 0 )
+ {
+ ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
+ goto cleanup;
+ }
+
+ /* After this operation, T holds the largest odd divisor of DE - 1. */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &T, order ) );
+
+ /*
+ * Actual work
+ */
+
+ /* Skip trying 2 if N == 1 mod 8 */
+ attempt = 0;
+ if( N->p[0] % 8 == 1 )
+ attempt = 1;
+
+ for( ; attempt < num_primes; ++attempt )
+ {
+ mbedtls_mpi_lset( &K, primes[attempt] );
+
+ /* Check if gcd(K,N) = 1 */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( P, &K, N ) );
+ if( mbedtls_mpi_cmp_int( P, 1 ) != 0 )
+ continue;
+
+ /* Go through K^T + 1, K^(2T) + 1, K^(4T) + 1, ...
+ * and check whether they have nontrivial GCD with N. */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &K, &K, &T, N,
+ Q /* temporarily use Q for storing Montgomery
+ * multiplication helper values */ ) );
+
+ for( iter = 1; iter <= order; ++iter )
+ {
+ /* If we reach 1 prematurely, there's no point
+ * in continuing to square K */
+ if( mbedtls_mpi_cmp_int( &K, 1 ) == 0 )
+ break;
+
+ MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &K, &K, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( P, &K, N ) );
+
+ if( mbedtls_mpi_cmp_int( P, 1 ) == 1 &&
+ mbedtls_mpi_cmp_mpi( P, N ) == -1 )
+ {
+ /*
+ * Have found a nontrivial divisor P of N.
+ * Set Q := N / P.
+ */
+
+ MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( Q, NULL, N, P ) );
+ goto cleanup;
+ }
+
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, &K, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &K, &K, &K ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &K, &K, N ) );
+ }
+
+ /*
+ * If we get here, then either we prematurely aborted the loop because
+ * we reached 1, or K holds primes[attempt]^(DE - 1) mod N, which must
+ * be 1 if D,E,N were consistent.
+ * Check if that's the case and abort if not, to avoid very long,
+ * yet eventually failing, computations if N,D,E were not sane.
+ */
+ if( mbedtls_mpi_cmp_int( &K, 1 ) != 0 )
+ {
+ break;
+ }
+ }
+
+ ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA;
+
+cleanup:
+
+ mbedtls_mpi_free( &K );
+ mbedtls_mpi_free( &T );
+ return( ret );
+}
+
+/*
+ * Given P, Q and the public exponent E, deduce D.
+ * This is essentially a modular inversion.
+ */
+int mbedtls_rsa_deduce_private_exponent( mbedtls_mpi const *P,
+ mbedtls_mpi const *Q,
+ mbedtls_mpi const *E,
+ mbedtls_mpi *D )
+{
+ int ret = 0;
+ mbedtls_mpi K, L;
+
+ if( D == NULL || mbedtls_mpi_cmp_int( D, 0 ) != 0 )
+ return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
+
+ if( mbedtls_mpi_cmp_int( P, 1 ) <= 0 ||
+ mbedtls_mpi_cmp_int( Q, 1 ) <= 0 ||
+ mbedtls_mpi_cmp_int( E, 0 ) == 0 )
+ {
+ return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
+ }
+
+ mbedtls_mpi_init( &K );
+ mbedtls_mpi_init( &L );
+
+ /* Temporarily put K := P-1 and L := Q-1 */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, P, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &L, Q, 1 ) );
+
+ /* Temporarily put D := gcd(P-1, Q-1) */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( D, &K, &L ) );
+
+ /* K := LCM(P-1, Q-1) */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &K, &K, &L ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( &K, NULL, &K, D ) );
+
+ /* Compute modular inverse of E in LCM(P-1, Q-1) */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( D, E, &K ) );
+
+cleanup:
+
+ mbedtls_mpi_free( &K );
+ mbedtls_mpi_free( &L );
+
+ return( ret );
+}
+
+/*
+ * Check that RSA CRT parameters are in accordance with core parameters.
+ */
+int mbedtls_rsa_validate_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q,
+ const mbedtls_mpi *D, const mbedtls_mpi *DP,
+ const mbedtls_mpi *DQ, const mbedtls_mpi *QP )
+{
+ int ret = 0;
+
+ mbedtls_mpi K, L;
+ mbedtls_mpi_init( &K );
+ mbedtls_mpi_init( &L );
+
+ /* Check that DP - D == 0 mod P - 1 */
+ if( DP != NULL )
+ {
+ if( P == NULL )
+ {
+ ret = MBEDTLS_ERR_RSA_BAD_INPUT_DATA;
+ goto cleanup;
+ }
+
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, P, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &L, DP, D ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &L, &L, &K ) );
+
+ if( mbedtls_mpi_cmp_int( &L, 0 ) != 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ goto cleanup;
+ }
+ }
+
+ /* Check that DQ - D == 0 mod Q - 1 */
+ if( DQ != NULL )
+ {
+ if( Q == NULL )
+ {
+ ret = MBEDTLS_ERR_RSA_BAD_INPUT_DATA;
+ goto cleanup;
+ }
+
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, Q, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &L, DQ, D ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &L, &L, &K ) );
+
+ if( mbedtls_mpi_cmp_int( &L, 0 ) != 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ goto cleanup;
+ }
+ }
+
+ /* Check that QP * Q - 1 == 0 mod P */
+ if( QP != NULL )
+ {
+ if( P == NULL || Q == NULL )
+ {
+ ret = MBEDTLS_ERR_RSA_BAD_INPUT_DATA;
+ goto cleanup;
+ }
+
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &K, QP, Q ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, &K, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &K, &K, P ) );
+ if( mbedtls_mpi_cmp_int( &K, 0 ) != 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ goto cleanup;
+ }
+ }
+
+cleanup:
+
+ /* Wrap MPI error codes by RSA check failure error code */
+ if( ret != 0 &&
+ ret != MBEDTLS_ERR_RSA_KEY_CHECK_FAILED &&
+ ret != MBEDTLS_ERR_RSA_BAD_INPUT_DATA )
+ {
+ ret += MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ }
+
+ mbedtls_mpi_free( &K );
+ mbedtls_mpi_free( &L );
+
+ return( ret );
+}
+
+/*
+ * Check that core RSA parameters are sane.
+ */
+int mbedtls_rsa_validate_params( const mbedtls_mpi *N, const mbedtls_mpi *P,
+ const mbedtls_mpi *Q, const mbedtls_mpi *D,
+ const mbedtls_mpi *E,
+ int (*f_rng)(void *, unsigned char *, size_t),
+ void *p_rng )
+{
+ int ret = 0;
+ mbedtls_mpi K, L;
+
+ mbedtls_mpi_init( &K );
+ mbedtls_mpi_init( &L );
+
+ /*
+ * Step 1: If PRNG provided, check that P and Q are prime
+ */
+
+#if defined(MBEDTLS_GENPRIME)
+ if( f_rng != NULL && P != NULL &&
+ ( ret = mbedtls_mpi_is_prime( P, f_rng, p_rng ) ) != 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ goto cleanup;
+ }
+
+ if( f_rng != NULL && Q != NULL &&
+ ( ret = mbedtls_mpi_is_prime( Q, f_rng, p_rng ) ) != 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ goto cleanup;
+ }
+#else
+ ((void) f_rng);
+ ((void) p_rng);
+#endif /* MBEDTLS_GENPRIME */
+
+ /*
+ * Step 2: Check that 1 < N = P * Q
+ */
+
+ if( P != NULL && Q != NULL && N != NULL )
+ {
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &K, P, Q ) );
+ if( mbedtls_mpi_cmp_int( N, 1 ) <= 0 ||
+ mbedtls_mpi_cmp_mpi( &K, N ) != 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ goto cleanup;
+ }
+ }
+
+ /*
+ * Step 3: Check and 1 < D, E < N if present.
+ */
+
+ if( N != NULL && D != NULL && E != NULL )
+ {
+ if ( mbedtls_mpi_cmp_int( D, 1 ) <= 0 ||
+ mbedtls_mpi_cmp_int( E, 1 ) <= 0 ||
+ mbedtls_mpi_cmp_mpi( D, N ) >= 0 ||
+ mbedtls_mpi_cmp_mpi( E, N ) >= 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ goto cleanup;
+ }
+ }
+
+ /*
+ * Step 4: Check that D, E are inverse modulo P-1 and Q-1
+ */
+
+ if( P != NULL && Q != NULL && D != NULL && E != NULL )
+ {
+ if( mbedtls_mpi_cmp_int( P, 1 ) <= 0 ||
+ mbedtls_mpi_cmp_int( Q, 1 ) <= 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ goto cleanup;
+ }
+
+ /* Compute DE-1 mod P-1 */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &K, D, E ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, &K, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &L, P, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &K, &K, &L ) );
+ if( mbedtls_mpi_cmp_int( &K, 0 ) != 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ goto cleanup;
+ }
+
+ /* Compute DE-1 mod Q-1 */
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &K, D, E ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, &K, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &L, Q, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &K, &K, &L ) );
+ if( mbedtls_mpi_cmp_int( &K, 0 ) != 0 )
+ {
+ ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ goto cleanup;
+ }
+ }
+
+cleanup:
+
+ mbedtls_mpi_free( &K );
+ mbedtls_mpi_free( &L );
+
+ /* Wrap MPI error codes by RSA check failure error code */
+ if( ret != 0 && ret != MBEDTLS_ERR_RSA_KEY_CHECK_FAILED )
+ {
+ ret += MBEDTLS_ERR_RSA_KEY_CHECK_FAILED;
+ }
+
+ return( ret );
+}
+
+int mbedtls_rsa_deduce_crt( const mbedtls_mpi *P, const mbedtls_mpi *Q,
+ const mbedtls_mpi *D, mbedtls_mpi *DP,
+ mbedtls_mpi *DQ, mbedtls_mpi *QP )
+{
+ int ret = 0;
+ mbedtls_mpi K;
+ mbedtls_mpi_init( &K );
+
+ /* DP = D mod P-1 */
+ if( DP != NULL )
+ {
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, P, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( DP, D, &K ) );
+ }
+
+ /* DQ = D mod Q-1 */
+ if( DQ != NULL )
+ {
+ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &K, Q, 1 ) );
+ MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( DQ, D, &K ) );
+ }
+
+ /* QP = Q^{-1} mod P */
+ if( QP != NULL )
+ {
+ MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( QP, Q, P ) );
+ }
+
+cleanup:
+ mbedtls_mpi_free( &K );
+
+ return( ret );
+}
+
+#endif /* MBEDTLS_RSA_C */
/*
* SHA-1 context setup
*/
-void mbedtls_sha1_starts( mbedtls_sha1_context *ctx )
+int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx )
{
ctx->total[0] = 0;
ctx->total[1] = 0;
ctx->state[2] = 0x98BADCFE;
ctx->state[3] = 0x10325476;
ctx->state[4] = 0xC3D2E1F0;
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha1_starts( mbedtls_sha1_context *ctx )
+{
+ mbedtls_sha1_starts_ret( ctx );
+}
+#endif
+
#if !defined(MBEDTLS_SHA1_PROCESS_ALT)
-void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] )
+int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx,
+ const unsigned char data[64] )
{
uint32_t temp, W[16], A, B, C, D, E;
ctx->state[2] += C;
ctx->state[3] += D;
ctx->state[4] += E;
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha1_process( mbedtls_sha1_context *ctx,
+ const unsigned char data[64] )
+{
+ mbedtls_internal_sha1_process( ctx, data );
}
+#endif
#endif /* !MBEDTLS_SHA1_PROCESS_ALT */
/*
* SHA-1 process buffer
*/
-void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen )
+int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
{
+ int ret;
size_t fill;
uint32_t left;
if( ilen == 0 )
- return;
+ return( 0 );
left = ctx->total[0] & 0x3F;
fill = 64 - left;
if( left && ilen >= fill )
{
memcpy( (void *) (ctx->buffer + left), input, fill );
- mbedtls_sha1_process( ctx, ctx->buffer );
+
+ if( ( ret = mbedtls_internal_sha1_process( ctx, ctx->buffer ) ) != 0 )
+ return( ret );
+
input += fill;
ilen -= fill;
left = 0;
while( ilen >= 64 )
{
- mbedtls_sha1_process( ctx, input );
+ if( ( ret = mbedtls_internal_sha1_process( ctx, input ) ) != 0 )
+ return( ret );
+
input += 64;
ilen -= 64;
}
if( ilen > 0 )
memcpy( (void *) (ctx->buffer + left), input, ilen );
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha1_update( mbedtls_sha1_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
+{
+ mbedtls_sha1_update_ret( ctx, input, ilen );
+}
+#endif
+
static const unsigned char sha1_padding[64] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*
* SHA-1 final digest
*/
-void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] )
+int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx,
+ unsigned char output[20] )
{
+ int ret;
uint32_t last, padn;
uint32_t high, low;
unsigned char msglen[8];
last = ctx->total[0] & 0x3F;
padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
- mbedtls_sha1_update( ctx, sha1_padding, padn );
- mbedtls_sha1_update( ctx, msglen, 8 );
+ if( ( ret = mbedtls_sha1_update_ret( ctx, sha1_padding, padn ) ) != 0 )
+ return( ret );
+ if( ( ret = mbedtls_sha1_update_ret( ctx, msglen, 8 ) ) != 0 )
+ return( ret );
PUT_UINT32_BE( ctx->state[0], output, 0 );
PUT_UINT32_BE( ctx->state[1], output, 4 );
PUT_UINT32_BE( ctx->state[2], output, 8 );
PUT_UINT32_BE( ctx->state[3], output, 12 );
PUT_UINT32_BE( ctx->state[4], output, 16 );
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha1_finish( mbedtls_sha1_context *ctx,
+ unsigned char output[20] )
+{
+ mbedtls_sha1_finish_ret( ctx, output );
+}
+#endif
+
#endif /* !MBEDTLS_SHA1_ALT */
/*
* output = SHA-1( input buffer )
*/
-void mbedtls_sha1( const unsigned char *input, size_t ilen, unsigned char output[20] )
+int mbedtls_sha1_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[20] )
{
+ int ret;
mbedtls_sha1_context ctx;
mbedtls_sha1_init( &ctx );
- mbedtls_sha1_starts( &ctx );
- mbedtls_sha1_update( &ctx, input, ilen );
- mbedtls_sha1_finish( &ctx, output );
+
+ if( ( ret = mbedtls_sha1_starts_ret( &ctx ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_sha1_update_ret( &ctx, input, ilen ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_sha1_finish_ret( &ctx, output ) ) != 0 )
+ goto exit;
+
+exit:
mbedtls_sha1_free( &ctx );
+
+ return( ret );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha1( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[20] )
+{
+ mbedtls_sha1_ret( input, ilen, output );
+}
+#endif
+
#if defined(MBEDTLS_SELF_TEST)
/*
* FIPS-180-1 test vectors
{ "" }
};
-static const int sha1_test_buflen[3] =
+static const size_t sha1_test_buflen[3] =
{
3, 56, 1000
};
if( verbose != 0 )
mbedtls_printf( " SHA-1 test #%d: ", i + 1 );
- mbedtls_sha1_starts( &ctx );
+ if( ( ret = mbedtls_sha1_starts_ret( &ctx ) ) != 0 )
+ goto fail;
if( i == 2 )
{
memset( buf, 'a', buflen = 1000 );
for( j = 0; j < 1000; j++ )
- mbedtls_sha1_update( &ctx, buf, buflen );
+ {
+ ret = mbedtls_sha1_update_ret( &ctx, buf, buflen );
+ if( ret != 0 )
+ goto fail;
+ }
}
else
- mbedtls_sha1_update( &ctx, sha1_test_buf[i],
- sha1_test_buflen[i] );
+ {
+ ret = mbedtls_sha1_update_ret( &ctx, sha1_test_buf[i],
+ sha1_test_buflen[i] );
+ if( ret != 0 )
+ goto fail;
+ }
- mbedtls_sha1_finish( &ctx, sha1sum );
+ if( ( ret = mbedtls_sha1_finish_ret( &ctx, sha1sum ) ) != 0 )
+ goto fail;
if( memcmp( sha1sum, sha1_test_sum[i], 20 ) != 0 )
{
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
ret = 1;
- goto exit;
+ goto fail;
}
if( verbose != 0 )
if( verbose != 0 )
mbedtls_printf( "\n" );
+ goto exit;
+
+fail:
+ if( verbose != 0 )
+ mbedtls_printf( "failed\n" );
+
exit:
mbedtls_sha1_free( &ctx );
/*
* SHA-256 context setup
*/
-void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 )
+int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 )
{
ctx->total[0] = 0;
ctx->total[1] = 0;
}
ctx->is224 = is224;
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha256_starts( mbedtls_sha256_context *ctx,
+ int is224 )
+{
+ mbedtls_sha256_starts_ret( ctx, is224 );
}
+#endif
#if !defined(MBEDTLS_SHA256_PROCESS_ALT)
static const uint32_t K[] =
d += temp1; h = temp1 + temp2; \
}
-void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] )
+int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx,
+ const unsigned char data[64] )
{
uint32_t temp1, temp2, W[64];
uint32_t A[8];
for( i = 0; i < 8; i++ )
ctx->state[i] += A[i];
+
+ return( 0 );
}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha256_process( mbedtls_sha256_context *ctx,
+ const unsigned char data[64] )
+{
+ mbedtls_internal_sha256_process( ctx, data );
+}
+#endif
#endif /* !MBEDTLS_SHA256_PROCESS_ALT */
/*
* SHA-256 process buffer
*/
-void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input,
- size_t ilen )
+int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
{
+ int ret;
size_t fill;
uint32_t left;
if( ilen == 0 )
- return;
+ return( 0 );
left = ctx->total[0] & 0x3F;
fill = 64 - left;
if( left && ilen >= fill )
{
memcpy( (void *) (ctx->buffer + left), input, fill );
- mbedtls_sha256_process( ctx, ctx->buffer );
+
+ if( ( ret = mbedtls_internal_sha256_process( ctx, ctx->buffer ) ) != 0 )
+ return( ret );
+
input += fill;
ilen -= fill;
left = 0;
while( ilen >= 64 )
{
- mbedtls_sha256_process( ctx, input );
+ if( ( ret = mbedtls_internal_sha256_process( ctx, input ) ) != 0 )
+ return( ret );
+
input += 64;
ilen -= 64;
}
if( ilen > 0 )
memcpy( (void *) (ctx->buffer + left), input, ilen );
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha256_update( mbedtls_sha256_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
+{
+ mbedtls_sha256_update_ret( ctx, input, ilen );
+}
+#endif
+
static const unsigned char sha256_padding[64] =
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/*
* SHA-256 final digest
*/
-void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] )
+int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx,
+ unsigned char output[32] )
{
+ int ret;
uint32_t last, padn;
uint32_t high, low;
unsigned char msglen[8];
last = ctx->total[0] & 0x3F;
padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );
- mbedtls_sha256_update( ctx, sha256_padding, padn );
- mbedtls_sha256_update( ctx, msglen, 8 );
+ if( ( ret = mbedtls_sha256_update_ret( ctx, sha256_padding, padn ) ) != 0 )
+ return( ret );
+
+ if( ( ret = mbedtls_sha256_update_ret( ctx, msglen, 8 ) ) != 0 )
+ return( ret );
PUT_UINT32_BE( ctx->state[0], output, 0 );
PUT_UINT32_BE( ctx->state[1], output, 4 );
if( ctx->is224 == 0 )
PUT_UINT32_BE( ctx->state[7], output, 28 );
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha256_finish( mbedtls_sha256_context *ctx,
+ unsigned char output[32] )
+{
+ mbedtls_sha256_finish_ret( ctx, output );
}
+#endif
#endif /* !MBEDTLS_SHA256_ALT */
/*
* output = SHA-256( input buffer )
*/
-void mbedtls_sha256( const unsigned char *input, size_t ilen,
- unsigned char output[32], int is224 )
+int mbedtls_sha256_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[32],
+ int is224 )
{
+ int ret;
mbedtls_sha256_context ctx;
mbedtls_sha256_init( &ctx );
- mbedtls_sha256_starts( &ctx, is224 );
- mbedtls_sha256_update( &ctx, input, ilen );
- mbedtls_sha256_finish( &ctx, output );
+
+ if( ( ret = mbedtls_sha256_starts_ret( &ctx, is224 ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_sha256_update_ret( &ctx, input, ilen ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_sha256_finish_ret( &ctx, output ) ) != 0 )
+ goto exit;
+
+exit:
mbedtls_sha256_free( &ctx );
+
+ return( ret );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha256( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[32],
+ int is224 )
+{
+ mbedtls_sha256_ret( input, ilen, output, is224 );
}
+#endif
#if defined(MBEDTLS_SELF_TEST)
/*
{ "" }
};
-static const int sha256_test_buflen[3] =
+static const size_t sha256_test_buflen[3] =
{
3, 56, 1000
};
if( verbose != 0 )
mbedtls_printf( " SHA-%d test #%d: ", 256 - k * 32, j + 1 );
- mbedtls_sha256_starts( &ctx, k );
+ if( ( ret = mbedtls_sha256_starts_ret( &ctx, k ) ) != 0 )
+ goto fail;
if( j == 2 )
{
memset( buf, 'a', buflen = 1000 );
for( j = 0; j < 1000; j++ )
- mbedtls_sha256_update( &ctx, buf, buflen );
+ {
+ ret = mbedtls_sha256_update_ret( &ctx, buf, buflen );
+ if( ret != 0 )
+ goto fail;
+ }
+
}
else
- mbedtls_sha256_update( &ctx, sha256_test_buf[j],
- sha256_test_buflen[j] );
+ {
+ ret = mbedtls_sha256_update_ret( &ctx, sha256_test_buf[j],
+ sha256_test_buflen[j] );
+ if( ret != 0 )
+ goto fail;
+ }
+
+ if( ( ret = mbedtls_sha256_finish_ret( &ctx, sha256sum ) ) != 0 )
+ goto fail;
- mbedtls_sha256_finish( &ctx, sha256sum );
if( memcmp( sha256sum, sha256_test_sum[i], 32 - k * 4 ) != 0 )
{
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
ret = 1;
- goto exit;
+ goto fail;
}
if( verbose != 0 )
if( verbose != 0 )
mbedtls_printf( "\n" );
+ goto exit;
+
+fail:
+ if( verbose != 0 )
+ mbedtls_printf( "failed\n" );
+
exit:
mbedtls_sha256_free( &ctx );
mbedtls_free( buf );
/*
* SHA-512 context setup
*/
-void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 )
+int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 )
{
ctx->total[0] = 0;
ctx->total[1] = 0;
}
ctx->is384 = is384;
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha512_starts( mbedtls_sha512_context *ctx,
+ int is384 )
+{
+ mbedtls_sha512_starts_ret( ctx, is384 );
}
+#endif
#if !defined(MBEDTLS_SHA512_PROCESS_ALT)
UL64(0x5FCB6FAB3AD6FAEC), UL64(0x6C44198C4A475817)
};
-void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] )
+int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx,
+ const unsigned char data[128] )
{
int i;
uint64_t temp1, temp2, W[80];
ctx->state[5] += F;
ctx->state[6] += G;
ctx->state[7] += H;
+
+ return( 0 );
}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha512_process( mbedtls_sha512_context *ctx,
+ const unsigned char data[128] )
+{
+ mbedtls_internal_sha512_process( ctx, data );
+}
+#endif
#endif /* !MBEDTLS_SHA512_PROCESS_ALT */
/*
* SHA-512 process buffer
*/
-void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input,
- size_t ilen )
+int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
{
+ int ret;
size_t fill;
unsigned int left;
if( ilen == 0 )
- return;
+ return( 0 );
left = (unsigned int) (ctx->total[0] & 0x7F);
fill = 128 - left;
if( left && ilen >= fill )
{
memcpy( (void *) (ctx->buffer + left), input, fill );
- mbedtls_sha512_process( ctx, ctx->buffer );
+
+ if( ( ret = mbedtls_internal_sha512_process( ctx, ctx->buffer ) ) != 0 )
+ return( ret );
+
input += fill;
ilen -= fill;
left = 0;
while( ilen >= 128 )
{
- mbedtls_sha512_process( ctx, input );
+ if( ( ret = mbedtls_internal_sha512_process( ctx, input ) ) != 0 )
+ return( ret );
+
input += 128;
ilen -= 128;
}
if( ilen > 0 )
memcpy( (void *) (ctx->buffer + left), input, ilen );
+
+ return( 0 );
+}
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha512_update( mbedtls_sha512_context *ctx,
+ const unsigned char *input,
+ size_t ilen )
+{
+ mbedtls_sha512_update_ret( ctx, input, ilen );
}
+#endif
static const unsigned char sha512_padding[128] =
{
/*
* SHA-512 final digest
*/
-void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] )
+int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx,
+ unsigned char output[64] )
{
+ int ret;
size_t last, padn;
uint64_t high, low;
unsigned char msglen[16];
last = (size_t)( ctx->total[0] & 0x7F );
padn = ( last < 112 ) ? ( 112 - last ) : ( 240 - last );
- mbedtls_sha512_update( ctx, sha512_padding, padn );
- mbedtls_sha512_update( ctx, msglen, 16 );
+ if( ( ret = mbedtls_sha512_update_ret( ctx, sha512_padding, padn ) ) != 0 )
+ return( ret );
+
+ if( ( ret = mbedtls_sha512_update_ret( ctx, msglen, 16 ) ) != 0 )
+ return( ret );
PUT_UINT64_BE( ctx->state[0], output, 0 );
PUT_UINT64_BE( ctx->state[1], output, 8 );
PUT_UINT64_BE( ctx->state[6], output, 48 );
PUT_UINT64_BE( ctx->state[7], output, 56 );
}
+
+ return( 0 );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha512_finish( mbedtls_sha512_context *ctx,
+ unsigned char output[64] )
+{
+ mbedtls_sha512_finish_ret( ctx, output );
+}
+#endif
+
#endif /* !MBEDTLS_SHA512_ALT */
/*
* output = SHA-512( input buffer )
*/
-void mbedtls_sha512( const unsigned char *input, size_t ilen,
- unsigned char output[64], int is384 )
+int mbedtls_sha512_ret( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[64],
+ int is384 )
{
+ int ret;
mbedtls_sha512_context ctx;
mbedtls_sha512_init( &ctx );
- mbedtls_sha512_starts( &ctx, is384 );
- mbedtls_sha512_update( &ctx, input, ilen );
- mbedtls_sha512_finish( &ctx, output );
+
+ if( ( ret = mbedtls_sha512_starts_ret( &ctx, is384 ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_sha512_update_ret( &ctx, input, ilen ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_sha512_finish_ret( &ctx, output ) ) != 0 )
+ goto exit;
+
+exit:
mbedtls_sha512_free( &ctx );
+
+ return( ret );
}
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
+void mbedtls_sha512( const unsigned char *input,
+ size_t ilen,
+ unsigned char output[64],
+ int is384 )
+{
+ mbedtls_sha512_ret( input, ilen, output, is384 );
+}
+#endif
+
#if defined(MBEDTLS_SELF_TEST)
/*
{ "" }
};
-static const int sha512_test_buflen[3] =
+static const size_t sha512_test_buflen[3] =
{
3, 112, 1000
};
if( verbose != 0 )
mbedtls_printf( " SHA-%d test #%d: ", 512 - k * 128, j + 1 );
- mbedtls_sha512_starts( &ctx, k );
+ if( ( ret = mbedtls_sha512_starts_ret( &ctx, k ) ) != 0 )
+ goto fail;
if( j == 2 )
{
memset( buf, 'a', buflen = 1000 );
for( j = 0; j < 1000; j++ )
- mbedtls_sha512_update( &ctx, buf, buflen );
+ {
+ ret = mbedtls_sha512_update_ret( &ctx, buf, buflen );
+ if( ret != 0 )
+ goto fail;
+ }
}
else
- mbedtls_sha512_update( &ctx, sha512_test_buf[j],
- sha512_test_buflen[j] );
+ {
+ ret = mbedtls_sha512_update_ret( &ctx, sha512_test_buf[j],
+ sha512_test_buflen[j] );
+ if( ret != 0 )
+ goto fail;
+ }
- mbedtls_sha512_finish( &ctx, sha512sum );
+ if( ( ret = mbedtls_sha512_finish_ret( &ctx, sha512sum ) ) != 0 )
+ goto fail;
if( memcmp( sha512sum, sha512_test_sum[i], 64 - k * 16 ) != 0 )
{
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
ret = 1;
- goto exit;
+ goto fail;
}
if( verbose != 0 )
if( verbose != 0 )
mbedtls_printf( "\n" );
+ goto exit;
+
+fail:
+ if( verbose != 0 )
+ mbedtls_printf( "failed\n" );
+
exit:
mbedtls_sha512_free( &ctx );
mbedtls_free( buf );
{
int ret = 1;
#if defined(MBEDTLS_HAVE_TIME)
- mbedtls_time_t t = time( NULL ), oldest = 0;
+ mbedtls_time_t t = mbedtls_time( NULL ), oldest = 0;
mbedtls_ssl_cache_entry *old = NULL;
#endif
mbedtls_ssl_cache_context *cache = (mbedtls_ssl_cache_context *) data;
#if defined(MBEDTLS_THREADING_C)
mbedtls_mutex_free( &cache->mutex );
#endif
+ cache->chain = NULL;
}
#endif /* MBEDTLS_SSL_CACHE_C */
return( MBEDTLS_PK_NONE );
}
}
+
+mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_alg( const mbedtls_ssl_ciphersuite_t *info )
+{
+ switch( info->key_exchange )
+ {
+ case MBEDTLS_KEY_EXCHANGE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
+ return( MBEDTLS_PK_RSA );
+
+ case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
+ return( MBEDTLS_PK_ECDSA );
+
+ default:
+ return( MBEDTLS_PK_NONE );
+ }
+}
+
#endif /* MBEDTLS_PK_C */
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)
}
/*
+ * Sect. 3, RFC 6066 (TLS Extensions Definitions)
+ *
+ * In order to provide any of the server names, clients MAY include an
+ * extension of type "server_name" in the (extended) client hello. The
+ * "extension_data" field of this extension SHALL contain
+ * "ServerNameList" where:
+ *
* struct {
* NameType name_type;
* select (name_type) {
* struct {
* ServerName server_name_list<1..2^16-1>
* } ServerNameList;
+ *
*/
*p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SERVERNAME >> 8 ) & 0xFF );
*p++ = (unsigned char)( ( MBEDTLS_TLS_EXT_SERVERNAME ) & 0xFF );
*olen = 0;
+ /* We're always including an TLS_EMPTY_RENEGOTIATION_INFO_SCSV in the
+ * initial ClientHello, in which case also adding the renegotiation
+ * info extension is NOT RECOMMENDED as per RFC 5746 Section 3.4. */
if( ssl->renego_status != MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS )
return;
#if defined(MBEDTLS_ECP_C)
for( grp_id = ssl->conf->curve_list; *grp_id != MBEDTLS_ECP_DP_NONE; grp_id++ )
- {
- info = mbedtls_ecp_curve_info_from_grp_id( *grp_id );
#else
for( info = mbedtls_ecp_curve_list(); info->grp_id != MBEDTLS_ECP_DP_NONE; info++ )
+#endif
{
+#if defined(MBEDTLS_ECP_C)
+ info = mbedtls_ecp_curve_info_from_grp_id( *grp_id );
#endif
if( info == NULL )
{
#if defined(MBEDTLS_ECP_C)
for( grp_id = ssl->conf->curve_list; *grp_id != MBEDTLS_ECP_DP_NONE; grp_id++ )
- {
- info = mbedtls_ecp_curve_info_from_grp_id( *grp_id );
#else
for( info = mbedtls_ecp_curve_list(); info->grp_id != MBEDTLS_ECP_DP_NONE; info++ )
+#endif
{
+#if defined(MBEDTLS_ECP_C)
+ info = mbedtls_ecp_curve_info_from_grp_id( *grp_id );
#endif
elliptic_curve_list[elliptic_curve_len++] = info->tls_id >> 8;
elliptic_curve_list[elliptic_curve_len++] = info->tls_id & 0xFF;
*p++ = (unsigned char)( ciphersuites[i] );
}
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, got %d ciphersuites (excluding SCSVs)", n ) );
+
/*
* Add TLS_EMPTY_RENEGOTIATION_INFO_SCSV
*/
if( ssl->renego_status == MBEDTLS_SSL_INITIAL_HANDSHAKE )
#endif
{
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "adding EMPTY_RENEGOTIATION_INFO_SCSV" ) );
*p++ = (unsigned char)( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO >> 8 );
*p++ = (unsigned char)( MBEDTLS_SSL_EMPTY_RENEGOTIATION_INFO );
n++;
*q++ = (unsigned char)( n >> 7 );
*q++ = (unsigned char)( n << 1 );
- MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, got %d ciphersuites", n ) );
-
#if defined(MBEDTLS_ZLIB_SUPPORT)
offer_compress = 1;
#else
ext_len += olen;
#endif
+ /* Note that TLS_EMPTY_RENEGOTIATION_INFO_SCSV is always added
+ * even if MBEDTLS_SSL_RENEGOTIATION is not defined. */
#if defined(MBEDTLS_SSL_RENEGOTIATION)
ssl_write_renegotiation_ext( ssl, p + 2 + ext_len, &olen );
ext_len += olen;
const unsigned char *buf,
size_t len )
{
- int ret;
-
#if defined(MBEDTLS_SSL_RENEGOTIATION)
if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE )
{
ssl->peer_verify_data, ssl->verify_data_len ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-matching renegotiation info" ) );
-
- if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 )
- return( ret );
-
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
}
if( len != 1 || buf[0] != 0x00 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-zero length renegotiation info" ) );
-
- if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 )
- return( ret );
-
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
len != 1 ||
buf[0] != ssl->conf->mfl_code )
{
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-matching max fragment length extension" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
if( ssl->conf->trunc_hmac == MBEDTLS_SSL_TRUNC_HMAC_DISABLED ||
len != 0 )
{
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-matching truncated HMAC extension" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ||
len != 0 )
{
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-matching encrypt-then-MAC extension" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ||
len != 0 )
{
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-matching extended master secret extension" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
if( ssl->conf->session_tickets == MBEDTLS_SSL_SESSION_TICKETS_DISABLED ||
len != 0 )
{
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-matching session ticket extension" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
if( list_size + 1 != len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
{
#if defined(MBEDTLS_ECDH_C) || defined(MBEDTLS_ECDSA_C)
ssl->handshake->ecdh_ctx.point_format = p[0];
-#endif
+#endif
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
ssl->handshake->ecjpake_ctx.point_format = p[0];
#endif
}
MBEDTLS_SSL_DEBUG_MSG( 1, ( "no point format in common" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C ||
buf, len ) ) != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_read_round_one", ret );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( ret );
}
/* If we didn't send it, the server shouldn't send it */
if( ssl->conf->alpn_list == NULL )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-matching ALPN extension" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
+ }
/*
* opaque ProtocolName<1..2^8-1>;
/* Min length is 2 (list_len) + 1 (name_len) + 1 (name) */
if( len < 4 )
+ {
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
+ }
list_len = ( buf[0] << 8 ) | buf[1];
if( list_len != len - 2 )
+ {
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
+ }
name_len = buf[2];
if( name_len != list_len - 1 )
+ {
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
+ }
/* Check that the server chosen protocol was in our list and save it */
for( p = ssl->conf->alpn_list; *p != NULL; p++ )
}
}
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "ALPN extension: no matching protocol" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
#endif /* MBEDTLS_SSL_ALPN */
#endif
int handshake_failure = 0;
const mbedtls_ssl_ciphersuite_t *suite_info;
-#if defined(MBEDTLS_DEBUG_C)
- uint32_t t;
-#endif
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server hello" ) );
if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 )
{
+ /* No alert on a read error. */
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret );
return( ret );
}
}
MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-handshake message during renego" ) );
+
+ ssl->keep_current_message = 1;
return( MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO );
}
#endif /* MBEDTLS_SSL_RENEGOTIATION */
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
buf[0] != MBEDTLS_SSL_HS_SERVER_HELLO )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION );
}
-#if defined(MBEDTLS_DEBUG_C)
- t = ( (uint32_t) buf[2] << 24 )
- | ( (uint32_t) buf[3] << 16 )
- | ( (uint32_t) buf[4] << 8 )
- | ( (uint32_t) buf[5] );
- MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, current time: %lu", t ) );
-#endif
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, current time: %lu",
+ ( (uint32_t) buf[2] << 24 ) |
+ ( (uint32_t) buf[3] << 16 ) |
+ ( (uint32_t) buf[4] << 8 ) |
+ ( (uint32_t) buf[5] ) ) );
memcpy( ssl->handshake->randbytes + 32, buf + 2, 32 );
if( n > 32 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) + 40 + n + ext_len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
}
else
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
#endif/* MBEDTLS_ZLIB_SUPPORT */
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "server hello, bad compression: %d", comp ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE );
}
if( ssl->transform_negotiate->ciphersuite_info == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "ciphersuite info for %04x not found", i ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR );
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
}
if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR );
return( ret );
}
}
)
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
if( ssl->conf->ciphersuite_list[ssl->minor_ver][i] == 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
)
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
ssl->session_negotiate->compression = comp;
if( ext_size + 4 > ext_len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
if( handshake_failure == 1 )
{
- if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 )
- return( ret );
-
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO );
}
*
* opaque psk_identity_hint<0..2^16-1>;
*/
+ if( (*p) > end - 2 )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message "
+ "(psk_identity_hint length)" ) );
+ return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
+ }
len = (*p)[0] << 8 | (*p)[1];
*p += 2;
- if( (*p) + len > end )
+ if( (*p) > end - len )
{
- MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message (psk_identity_hint length)" ) );
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message "
+ "(psk_identity_hint length)" ) );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
}
*/
if( mbedtls_ssl_check_sig_hash( ssl, *md_alg ) != 0 )
{
- MBEDTLS_SSL_DEBUG_MSG( 1, ( "server used HashAlgorithm "
- "that was not offered" ) );
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "server used HashAlgorithm %d that was not offered",
+ *(p)[0] ) );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
}
static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl )
{
int ret;
- const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
- unsigned char *p, *end;
+ const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
+ ssl->transform_negotiate->ciphersuite_info;
+ unsigned char *p = NULL, *end = NULL;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server key exchange" ) );
if( ( ret = ssl_get_ecdh_params_from_cert( ssl ) ) != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "ssl_get_ecdh_params_from_cert", ret );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( ret );
}
if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK ||
ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK )
{
- ssl->record_read = 1;
+ /* Current message is probably either
+ * CertificateRequest or ServerHelloDone */
+ ssl->keep_current_message = 1;
goto exit;
}
- MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "server key exchange message must "
+ "not be skipped" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );
+
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
if( ssl_parse_server_psk_hint( ssl, &p, end ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
}
} /* FALLTROUGH */
if( ssl_parse_server_dh_params( ssl, &p, end ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
}
}
if( ssl_parse_server_ecdh_params( ssl, &p, end ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
}
}
if( ret != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_read_round_two", ret );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
}
}
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
}
-#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
- if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA )
+#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED)
+ if( mbedtls_ssl_ciphersuite_uses_server_signature( ciphersuite_info ) )
{
size_t sig_len, hashlen;
unsigned char hash[64];
&md_alg, &pk_alg ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
}
if( pk_alg != mbedtls_ssl_get_ciphersuite_sig_pk_alg( ciphersuite_info ) )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
}
}
/*
* Read signature
*/
+
+ if( p > end - 2 )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
+ return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
+ }
sig_len = ( p[0] << 8 ) | p[1];
p += 2;
- if( end != p + sig_len )
+ if( p != end - sig_len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE );
}
defined(MBEDTLS_SSL_PROTO_TLS1_1)
if( md_alg == MBEDTLS_MD_NONE )
{
- mbedtls_md5_context mbedtls_md5;
- mbedtls_sha1_context mbedtls_sha1;
-
- mbedtls_md5_init( &mbedtls_md5 );
- mbedtls_sha1_init( &mbedtls_sha1 );
-
hashlen = 36;
-
- /*
- * digitally-signed struct {
- * opaque md5_hash[16];
- * opaque sha_hash[20];
- * };
- *
- * md5_hash
- * MD5(ClientHello.random + ServerHello.random
- * + ServerParams);
- * sha_hash
- * SHA(ClientHello.random + ServerHello.random
- * + ServerParams);
- */
- mbedtls_md5_starts( &mbedtls_md5 );
- mbedtls_md5_update( &mbedtls_md5, ssl->handshake->randbytes, 64 );
- mbedtls_md5_update( &mbedtls_md5, params, params_len );
- mbedtls_md5_finish( &mbedtls_md5, hash );
-
- mbedtls_sha1_starts( &mbedtls_sha1 );
- mbedtls_sha1_update( &mbedtls_sha1, ssl->handshake->randbytes, 64 );
- mbedtls_sha1_update( &mbedtls_sha1, params, params_len );
- mbedtls_sha1_finish( &mbedtls_sha1, hash + 16 );
-
- mbedtls_md5_free( &mbedtls_md5 );
- mbedtls_sha1_free( &mbedtls_sha1 );
+ ret = mbedtls_ssl_get_key_exchange_md_ssl_tls( ssl, hash, params,
+ params_len );
+ if( ret != 0 )
+ return( ret );
}
else
#endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || \
defined(MBEDTLS_SSL_PROTO_TLS1_2)
if( md_alg != MBEDTLS_MD_NONE )
{
- mbedtls_md_context_t ctx;
-
- mbedtls_md_init( &ctx );
-
/* Info from md_alg will be used instead */
hashlen = 0;
-
- /*
- * digitally-signed struct {
- * opaque client_random[32];
- * opaque server_random[32];
- * ServerDHParams params;
- * };
- */
- if( ( ret = mbedtls_md_setup( &ctx,
- mbedtls_md_info_from_type( md_alg ), 0 ) ) != 0 )
- {
- MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_setup", ret );
+ ret = mbedtls_ssl_get_key_exchange_md_tls1_2( ssl, hash, params,
+ params_len, md_alg );
+ if( ret != 0 )
return( ret );
- }
-
- mbedtls_md_starts( &ctx );
- mbedtls_md_update( &ctx, ssl->handshake->randbytes, 64 );
- mbedtls_md_update( &ctx, params, params_len );
- mbedtls_md_finish( &ctx, hash );
- mbedtls_md_free( &ctx );
}
else
#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \
if( ssl->session_negotiate->peer_cert == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 2, ( "certificate required" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
if( ! mbedtls_pk_can_do( &ssl->session_negotiate->peer_cert->pk, pk_alg ) )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH );
}
if( ( ret = mbedtls_pk_verify( &ssl->session_negotiate->peer_cert->pk,
md_alg, hash, hashlen, p, sig_len ) ) != 0 )
{
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR );
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_verify", ret );
return( ret );
}
}
-#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED ||
- MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED ||
- MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
+#endif /* MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED */
exit:
ssl->state++;
return( 0 );
}
-#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \
- !defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
- !defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \
- !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
- !defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)&& \
- !defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
+#if ! defined(MBEDTLS_KEY_EXCHANGE__CERT_REQ_ALLOWED__ENABLED)
static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
{
- const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
+ const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
+ ssl->transform_negotiate->ciphersuite_info;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate request" ) );
- if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE )
+ if( ! mbedtls_ssl_ciphersuite_cert_req_allowed( ciphersuite_info ) )
{
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate request" ) );
ssl->state++;
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
}
-#else
+#else /* MBEDTLS_KEY_EXCHANGE__CERT_REQ_ALLOWED__ENABLED */
static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
{
int ret;
unsigned char *buf;
size_t n = 0;
size_t cert_type_len = 0, dn_len = 0;
- const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
+ const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
+ ssl->transform_negotiate->ciphersuite_info;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate request" ) );
- if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE )
+ if( ! mbedtls_ssl_ciphersuite_cert_req_allowed( ciphersuite_info ) )
{
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate request" ) );
ssl->state++;
return( 0 );
}
- if( ssl->record_read == 0 )
+ if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 )
{
- if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 )
- {
- MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret );
- return( ret );
- }
-
- if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE )
- {
- MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate request message" ) );
- return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
- }
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret );
+ return( ret );
+ }
- ssl->record_read = 1;
+ if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate request message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );
+ return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
- ssl->client_auth = 0;
ssl->state++;
-
- if( ssl->in_msg[0] == MBEDTLS_SSL_HS_CERTIFICATE_REQUEST )
- ssl->client_auth++;
+ ssl->client_auth = ( ssl->in_msg[0] == MBEDTLS_SSL_HS_CERTIFICATE_REQUEST );
MBEDTLS_SSL_DEBUG_MSG( 3, ( "got %s certificate request",
ssl->client_auth ? "a" : "no" ) );
if( ssl->client_auth == 0 )
+ {
+ /* Current message is probably the ServerHelloDone */
+ ssl->keep_current_message = 1;
goto exit;
-
- ssl->record_read = 0;
+ }
/*
* struct {
if( ssl->in_hslen < mbedtls_ssl_hs_hdr_len( ssl ) + 2 + n )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate request message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST );
}
for( i = 0; i < sig_alg_len; i += 2 )
{
- MBEDTLS_SSL_DEBUG_MSG( 3, ( "Supported Signature Algorithm found: %d,%d", sig_alg[i], sig_alg[i + 1] ) );
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "Supported Signature Algorithm found: %d"
+ ",%d", sig_alg[i], sig_alg[i + 1] ) );
}
#endif
if( ssl->in_hslen < mbedtls_ssl_hs_hdr_len( ssl ) + 2 + n )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate request message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST );
}
}
if( ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) + 3 + n )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate request message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST );
}
return( 0 );
}
-#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED &&
- !MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED &&
- !MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED &&
- !MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED &&
- !MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED &&
- !MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
+#endif /* MBEDTLS_KEY_EXCHANGE__CERT_REQ_ALLOWED__ENABLED */
static int ssl_parse_server_hello_done( mbedtls_ssl_context *ssl )
{
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server hello done" ) );
- if( ssl->record_read == 0 )
+ if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 )
{
- if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 )
- {
- MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret );
- return( ret );
- }
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret );
+ return( ret );
+ }
- if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE )
- {
- MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello done message" ) );
- return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
- }
+ if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello done message" ) );
+ return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
- ssl->record_read = 0;
if( ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) ||
ssl->in_msg[0] != MBEDTLS_SSL_HS_SERVER_HELLO_DONE )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server hello done message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE );
}
{
int ret;
size_t i, n;
- const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
+ const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
+ ssl->transform_negotiate->ciphersuite_info;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write client key exchange" ) );
MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED ||
MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
- if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK )
+ if( mbedtls_ssl_ciphersuite_uses_psk( ciphersuite_info ) )
{
/*
* opaque psk_identity<0..2^16-1>;
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
{
- const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
+ const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
+ ssl->transform_negotiate->ciphersuite_info;
int ret;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate verify" ) );
static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
{
int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE;
- const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
+ const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
+ ssl->transform_negotiate->ciphersuite_info;
size_t n = 0, offset = 0;
unsigned char hash[48];
unsigned char *hash_start = hash;
if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad new session ticket message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
ssl->in_hslen < 6 + mbedtls_ssl_hs_hdr_len( ssl ) )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad new session ticket message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET );
}
if( ticket_len + 6 + mbedtls_ssl_hs_hdr_len( ssl ) != ssl->in_hslen )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad new session ticket message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET );
}
if( ( ticket = mbedtls_calloc( 1, ticket_len ) ) == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "ticket alloc failed" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR );
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
mbedtls_md_free( &ctx->hmac_ctx );
#if defined(MBEDTLS_THREADING_C)
- mbedtls_mutex_init( &ctx->mutex );
+ mbedtls_mutex_free( &ctx->mutex );
#endif
mbedtls_zeroize( ctx, sizeof( mbedtls_ssl_cookie_ctx ) );
if( servername_list_size + 2 != len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
if( hostname_len + 3 > servername_list_size )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
if( servername_list_size != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
const unsigned char *buf,
size_t len )
{
- int ret;
-
#if defined(MBEDTLS_SSL_RENEGOTIATION)
if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE )
{
ssl->verify_data_len ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-matching renegotiation info" ) );
-
- if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 )
- return( ret );
-
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
}
if( len != 1 || buf[0] != 0x0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "non-zero length renegotiation info" ) );
-
- if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 )
- return( ret );
-
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
+
+/*
+ * Status of the implementation of signature-algorithms extension:
+ *
+ * Currently, we are only considering the signature-algorithm extension
+ * to pick a ciphersuite which allows us to send the ServerKeyExchange
+ * message with a signature-hash combination that the user allows.
+ *
+ * We do *not* check whether all certificates in our certificate
+ * chain are signed with an allowed signature-hash pair.
+ * This needs to be done at a later stage.
+ *
+ */
static int ssl_parse_signature_algorithms_ext( mbedtls_ssl_context *ssl,
const unsigned char *buf,
size_t len )
{
size_t sig_alg_list_size;
+
const unsigned char *p;
const unsigned char *end = buf + len;
- const int *md_cur;
+ mbedtls_md_type_t md_cur;
+ mbedtls_pk_type_t sig_cur;
sig_alg_list_size = ( ( buf[0] << 8 ) | ( buf[1] ) );
if( sig_alg_list_size + 2 != len ||
sig_alg_list_size % 2 != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
- /*
- * For now, ignore the SignatureAlgorithm part and rely on offered
- * ciphersuites only for that part. To be fixed later.
+ /* Currently we only guarantee signing the ServerKeyExchange message according
+ * to the constraints specified in this extension (see above), so it suffices
+ * to remember only one suitable hash for each possible signature algorithm.
*
- * So, just look at the HashAlgorithm part.
+ * This will change when we also consider certificate signatures,
+ * in which case we will need to remember the whole signature-hash
+ * pair list from the extension.
*/
- for( md_cur = ssl->conf->sig_hashes; *md_cur != MBEDTLS_MD_NONE; md_cur++ ) {
- for( p = buf + 2; p < end; p += 2 ) {
- if( *md_cur == (int) mbedtls_ssl_md_alg_from_hash( p[0] ) ) {
- ssl->handshake->sig_alg = p[0];
- goto have_sig_alg;
- }
+
+ for( p = buf + 2; p < end; p += 2 )
+ {
+ /* Silently ignore unknown signature or hash algorithms. */
+
+ if( ( sig_cur = mbedtls_ssl_pk_alg_from_sig( p[1] ) ) == MBEDTLS_PK_NONE )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, signature_algorithm ext"
+ " unknown sig alg encoding %d", p[1] ) );
+ continue;
}
- }
- /* Some key echanges do not need signatures at all */
- MBEDTLS_SSL_DEBUG_MSG( 3, ( "no signature_algorithm in common" ) );
- return( 0 );
+ /* Check if we support the hash the user proposes */
+ md_cur = mbedtls_ssl_md_alg_from_hash( p[0] );
+ if( md_cur == MBEDTLS_MD_NONE )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, signature_algorithm ext:"
+ " unknown hash alg encoding %d", p[0] ) );
+ continue;
+ }
-have_sig_alg:
- MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, signature_algorithm ext: %d",
- ssl->handshake->sig_alg ) );
+ if( mbedtls_ssl_check_sig_hash( ssl, md_cur ) == 0 )
+ {
+ mbedtls_ssl_sig_hash_set_add( &ssl->handshake->hash_algs, sig_cur, md_cur );
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, signature_algorithm ext:"
+ " match sig %d and hash %d",
+ sig_cur, md_cur ) );
+ }
+ else
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, signature_algorithm ext: "
+ "hash alg %d not supported", md_cur ) );
+ }
+ }
return( 0 );
}
list_size % 2 != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
if( ssl->handshake->curves != NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
our_size = MBEDTLS_ECP_DP_MAX;
if( ( curves = mbedtls_calloc( our_size, sizeof( *curves ) ) ) == NULL )
+ {
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR );
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
+ }
ssl->handshake->curves = curves;
if( list_size + 1 != len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
buf, len ) ) != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_read_round_one", ret );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( ret );
}
if( len != 1 || buf[0] >= MBEDTLS_SSL_MAX_FRAG_LEN_INVALID )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
if( len != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
if( len != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
if( len != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
/* Min length is 2 (list_len) + 1 (name_len) + 1 (name) */
if( len < 4 )
+ {
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
+ }
list_len = ( buf[0] << 8 ) | buf[1];
if( list_len != len - 2 )
+ {
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
+ }
/*
- * Use our order of preference
+ * Validate peer's list (lengths)
*/
start = buf + 2;
end = buf + len;
+ for( theirs = start; theirs != end; theirs += cur_len )
+ {
+ cur_len = *theirs++;
+
+ /* Current identifier must fit in list */
+ if( cur_len > (size_t)( end - theirs ) )
+ {
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
+ return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
+ }
+
+ /* Empty strings MUST NOT be included */
+ if( cur_len == 0 )
+ {
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER );
+ return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
+ }
+ }
+
+ /*
+ * Use our order of preference
+ */
for( ours = ssl->conf->alpn_list; *ours != NULL; ours++ )
{
ours_len = strlen( *ours );
for( theirs = start; theirs != end; theirs += cur_len )
{
- /* If the list is well formed, we should get equality first */
- if( theirs > end )
- return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
-
cur_len = *theirs++;
- /* Empty strings MUST NOT be included */
- if( cur_len == 0 )
- return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
-
if( cur_len == ours_len &&
memcmp( theirs, *ours, cur_len ) == 0 )
{
const mbedtls_ssl_ciphersuite_t * ciphersuite_info )
{
mbedtls_ssl_key_cert *cur, *list, *fallback = NULL;
- mbedtls_pk_type_t pk_alg = mbedtls_ssl_get_ciphersuite_sig_pk_alg( ciphersuite_info );
+ mbedtls_pk_type_t pk_alg =
+ mbedtls_ssl_get_ciphersuite_sig_pk_alg( ciphersuite_info );
uint32_t flags;
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
{
const mbedtls_ssl_ciphersuite_t *suite_info;
+#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
+ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
+ mbedtls_pk_type_t sig_type;
+#endif
+
suite_info = mbedtls_ssl_ciphersuite_from_id( suite_id );
if( suite_info == NULL )
{
}
#endif
+#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
+ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
+ /* If the ciphersuite requires signing, check whether
+ * a suitable hash algorithm is present. */
+ if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )
+ {
+ sig_type = mbedtls_ssl_get_ciphersuite_sig_alg( suite_info );
+ if( sig_type != MBEDTLS_PK_NONE &&
+ mbedtls_ssl_sig_hash_set_find( &ssl->handshake->hash_algs, sig_type ) == MBEDTLS_MD_NONE )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "ciphersuite mismatch: no suitable hash algorithm "
+ "for signature algorithm %d", sig_type ) );
+ return( 0 );
+ }
+ }
+
+#endif /* MBEDTLS_SSL_PROTO_TLS1_2 &&
+ MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
+
#if defined(MBEDTLS_X509_CRT_PARSE_C)
/*
* Final check: if ciphersuite requires us to have a
if( ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "client hello v2 illegal for renegotiation" ) );
-
- if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 )
- return( ret );
-
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
#endif /* MBEDTLS_SSL_RENEGOTIATION */
MBEDTLS_SSL_DEBUG_MSG( 1, ( "received RENEGOTIATION SCSV "
"during renegotiation" ) );
- if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 )
- return( ret );
-
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
#endif /* MBEDTLS_SSL_RENEGOTIATION */
ciphersuite_info = NULL;
#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE)
for( j = 0, p = buf + 6; j < ciph_len; j += 3, p += 3 )
- {
for( i = 0; ciphersuites[i] != 0; i++ )
#else
for( i = 0; ciphersuites[i] != 0; i++ )
- {
for( j = 0, p = buf + 6; j < ciph_len; j += 3, p += 3 )
#endif
{
if( ciphersuite_info != NULL )
goto have_ciphersuite_v2;
}
- }
if( got_common_suite )
{
ssl->conf->allow_legacy_renegotiation == MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "legacy renegotiation, breaking off handshake" ) );
-
- if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 )
- return( ret );
-
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
}
#endif /* MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO */
+/* This function doesn't alert on errors that happen early during
+ ClientHello parsing because they might indicate that the client is
+ not talking SSL/TLS at all and would not understand our alert. */
static int ssl_parse_client_hello( mbedtls_ssl_context *ssl )
{
int ret, got_common_suite;
const mbedtls_ssl_ciphersuite_t *ciphersuite_info;
int major, minor;
+ /* If there is no signature-algorithm extension present,
+ * we need to fall back to the default values for allowed
+ * signature-hash pairs. */
+#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
+ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
+ int sig_hash_alg_ext_present = 0;
+#endif /* MBEDTLS_SSL_PROTO_TLS1_2 &&
+ MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
+
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse client hello" ) );
#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)
{
if( ( ret = mbedtls_ssl_fetch_input( ssl, 5 ) ) != 0 )
{
+ /* No alert on a read error. */
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret );
return( ret );
}
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_STREAM )
#endif
if( ( buf[0] & 0x80 ) != 0 )
- return ssl_parse_client_hello_v2( ssl );
+ return( ssl_parse_client_hello_v2( ssl ) );
#endif
MBEDTLS_SSL_DEBUG_BUF( 4, "record header", buf, mbedtls_ssl_hdr_len( ssl ) );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
- if( ( ret = mbedtls_ssl_fetch_input( ssl, mbedtls_ssl_hdr_len( ssl ) + msg_len ) ) != 0 )
+ if( ( ret = mbedtls_ssl_fetch_input( ssl,
+ mbedtls_ssl_hdr_len( ssl ) + msg_len ) ) != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret );
return( ret );
" [%d:%d] < [%d:%d]",
ssl->major_ver, ssl->minor_ver,
ssl->conf->min_major_ver, ssl->conf->min_minor_ver ) );
-
mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION );
-
return( MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION );
}
sess_len + 34 + 2 > msg_len ) /* 2 for cipherlist length field */
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
if( cookie_offset + 1 + cookie_len + 2 > msg_len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_PROTOCOL_VERSION );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
/* We know we didn't send a cookie, so it should be empty */
if( cookie_len != 0 )
{
+ /* This may be an attacker's probe, so don't send an alert */
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
( ciph_len % 2 ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
comp_len + comp_offset + 1 > msg_len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
if( msg_len < ext_offset + 2 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
msg_len != ext_offset + 2 + ext_len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
}
if( ext_size + 4 > ext_len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
switch( ext_id )
#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
case MBEDTLS_TLS_EXT_SIG_ALG:
- MBEDTLS_SSL_DEBUG_MSG( 3, ( "found signature_algorithms extension" ) );
-#if defined(MBEDTLS_SSL_RENEGOTIATION)
- if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS )
- break;
-#endif
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "found signature_algorithms extension" ) );
ret = ssl_parse_signature_algorithms_ext( ssl, ext + 4, ext_size );
if( ret != 0 )
return( ret );
+
+ sig_hash_alg_ext_present = 1;
break;
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 &&
MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
if( ext_len > 0 && ext_len < 4 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
}
#endif
#if defined(MBEDTLS_SSL_FALLBACK_SCSV)
- for( i = 0, p = buf + 41 + sess_len; i < ciph_len; i += 2, p += 2 )
+ for( i = 0, p = buf + ciph_offset + 2; i < ciph_len; i += 2, p += 2 )
{
if( p[0] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE >> 8 ) & 0xff ) &&
p[1] == (unsigned char)( ( MBEDTLS_SSL_FALLBACK_SCSV_VALUE ) & 0xff ) )
}
#endif /* MBEDTLS_SSL_FALLBACK_SCSV */
+#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
+ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
+
+ /*
+ * Try to fall back to default hash SHA1 if the client
+ * hasn't provided any preferred signature-hash combinations.
+ */
+ if( sig_hash_alg_ext_present == 0 )
+ {
+ mbedtls_md_type_t md_default = MBEDTLS_MD_SHA1;
+
+ if( mbedtls_ssl_check_sig_hash( ssl, md_default ) != 0 )
+ md_default = MBEDTLS_MD_NONE;
+
+ mbedtls_ssl_sig_hash_set_const_hash( &ssl->handshake->hash_algs, md_default );
+ }
+
+#endif /* MBEDTLS_SSL_PROTO_TLS1_2 &&
+ MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
+
/*
* Check for TLS_EMPTY_RENEGOTIATION_INFO_SCSV
*/
#if defined(MBEDTLS_SSL_RENEGOTIATION)
if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS )
{
- MBEDTLS_SSL_DEBUG_MSG( 1, ( "received RENEGOTIATION SCSV during renegotiation" ) );
-
- if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 )
- return( ret );
-
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "received RENEGOTIATION SCSV "
+ "during renegotiation" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
#endif
if( handshake_failure == 1 )
{
- if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 )
- return( ret );
-
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO );
}
ciphersuite_info = NULL;
#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE)
for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 )
- {
for( i = 0; ciphersuites[i] != 0; i++ )
#else
for( i = 0; ciphersuites[i] != 0; i++ )
- {
for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 )
#endif
{
if( ciphersuite_info != NULL )
goto have_ciphersuite;
}
- }
if( got_common_suite )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "got ciphersuites in common, "
"but none of them usable" ) );
- mbedtls_ssl_send_fatal_handshake_failure( ssl );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE );
}
else
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no ciphersuites in common" ) );
- mbedtls_ssl_send_fatal_handshake_failure( ssl );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE );
return( MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN );
}
mbedtls_ssl_recv_flight_completed( ssl );
#endif
+ /* Debugging-only output for testsuite */
+#if defined(MBEDTLS_DEBUG_C) && \
+ defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
+ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
+ if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )
+ {
+ mbedtls_pk_type_t sig_alg = mbedtls_ssl_get_ciphersuite_sig_alg( ciphersuite_info );
+ if( sig_alg != MBEDTLS_PK_NONE )
+ {
+ mbedtls_md_type_t md_alg = mbedtls_ssl_sig_hash_set_find( &ssl->handshake->hash_algs,
+ sig_alg );
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello v3, signature_algorithm ext: %d",
+ mbedtls_ssl_hash_from_md_alg( md_alg ) ) );
+ }
+ else
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "no hash algorithm for signature algorithm "
+ "%d - should not happen", sig_alg ) );
+ }
+ }
+#endif
+
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse client hello" ) );
return( 0 );
const mbedtls_ssl_ciphersuite_t *suite = NULL;
const mbedtls_cipher_info_t *cipher = NULL;
- if( ssl->session_negotiate->encrypt_then_mac == MBEDTLS_SSL_EXTENDED_MS_DISABLED ||
+ if( ssl->session_negotiate->encrypt_then_mac == MBEDTLS_SSL_ETM_DISABLED ||
ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 )
{
*olen = 0;
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
static int ssl_write_certificate_request( mbedtls_ssl_context *ssl )
{
- const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
+ const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
+ ssl->transform_negotiate->ciphersuite_info;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate request" ) );
static int ssl_write_certificate_request( mbedtls_ssl_context *ssl )
{
int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE;
- const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
+ const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
+ ssl->transform_negotiate->ciphersuite_info;
size_t dn_size, total_dn_size; /* excluding length bytes */
size_t ct_len, sa_len; /* including length bytes */
unsigned char *buf, *p;
* opaque DistinguishedName<1..2^16-1>;
*/
p += 2;
-#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
- if( ssl->handshake->sni_ca_chain != NULL )
- crt = ssl->handshake->sni_ca_chain;
- else
-#endif
- crt = ssl->conf->ca_chain;
total_dn_size = 0;
- while( crt != NULL && crt->version != 0 )
+
+ if( ssl->conf->cert_req_ca_list == MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED )
{
- dn_size = crt->subject_raw.len;
+#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
+ if( ssl->handshake->sni_ca_chain != NULL )
+ crt = ssl->handshake->sni_ca_chain;
+ else
+#endif
+ crt = ssl->conf->ca_chain;
- if( end < p ||
- (size_t)( end - p ) < dn_size ||
- (size_t)( end - p ) < 2 + dn_size )
+ while( crt != NULL && crt->version != 0 )
{
- MBEDTLS_SSL_DEBUG_MSG( 1, ( "skipping CAs: buffer too short" ) );
- break;
- }
+ dn_size = crt->subject_raw.len;
- *p++ = (unsigned char)( dn_size >> 8 );
- *p++ = (unsigned char)( dn_size );
- memcpy( p, crt->subject_raw.p, dn_size );
- p += dn_size;
+ if( end < p ||
+ (size_t)( end - p ) < dn_size ||
+ (size_t)( end - p ) < 2 + dn_size )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "skipping CAs: buffer too short" ) );
+ break;
+ }
- MBEDTLS_SSL_DEBUG_BUF( 3, "requested DN", p - dn_size, dn_size );
+ *p++ = (unsigned char)( dn_size >> 8 );
+ *p++ = (unsigned char)( dn_size );
+ memcpy( p, crt->subject_raw.p, dn_size );
+ p += dn_size;
- total_dn_size += 2 + dn_size;
- crt = crt->next;
+ MBEDTLS_SSL_DEBUG_BUF( 3, "requested DN", p - dn_size, dn_size );
+
+ total_dn_size += 2 + dn_size;
+ crt = crt->next;
+ }
}
ssl->out_msglen = p - buf;
const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
ssl->transform_negotiate->ciphersuite_info;
-#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
+#if defined(MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED)
unsigned char *p = ssl->out_msg + 4;
+ size_t len;
+#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED)
unsigned char *dig_signed = p;
- size_t dig_signed_len = 0, len;
- ((void) dig_signed);
- ((void) dig_signed_len);
- ((void) len);
-#endif
+ size_t dig_signed_len = 0;
+#endif /* MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED */
+#endif /* MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED */
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write server key exchange" ) );
-#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)
- if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK )
- {
- MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write server key exchange" ) );
- ssl->state++;
- return( 0 );
- }
-#endif
+ /*
+ *
+ * Part 1: Extract static ECDH parameters and abort
+ * if ServerKeyExchange not needed.
+ *
+ */
-#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
- if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_RSA ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA )
+ /* For suites involving ECDH, extract DH parameters
+ * from certificate at this point. */
+#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED)
+ if( mbedtls_ssl_ciphersuite_uses_ecdh( ciphersuite_info ) )
{
ssl_get_ecdh_params_from_cert( ssl );
+ }
+#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED */
+ /* Key exchanges not involving ephemeral keys don't use
+ * ServerKeyExchange, so end here. */
+#if defined(MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED)
+ if( mbedtls_ssl_ciphersuite_no_pfs( ciphersuite_info ) )
+ {
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write server key exchange" ) );
ssl->state++;
return( 0 );
}
-#endif
+#endif /* MBEDTLS_KEY_EXCHANGE__NON_PFS__ENABLED */
+
+ /*
+ *
+ * Part 2: Provide key exchange parameters for chosen ciphersuite.
+ *
+ */
+ /*
+ * - ECJPAKE key exchanges
+ */
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE )
{
- size_t jlen;
const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN;
ret = mbedtls_ecjpake_write_round_two( &ssl->handshake->ecjpake_ctx,
- p, end - p, &jlen, ssl->conf->f_rng, ssl->conf->p_rng );
+ p, end - p, &len, ssl->conf->f_rng, ssl->conf->p_rng );
if( ret != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_write_round_two", ret );
return( ret );
}
- p += jlen;
- n += jlen;
+ p += len;
+ n += len;
}
#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
+ /*
+ * For (EC)DHE key exchanges with PSK, parameters are prefixed by support
+ * identity hint (RFC 4279, Sec. 3). Until someone needs this feature,
+ * we use empty support identity hints here.
+ **/
+#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK ||
ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK )
{
- /* Note: we don't support identity hints, until someone asks
- * for them. */
*(p++) = 0x00;
*(p++) = 0x00;
#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED ||
MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
- if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK )
+ /*
+ * - DHE key exchanges
+ */
+#if defined(MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED)
+ if( mbedtls_ssl_ciphersuite_uses_dhe( ciphersuite_info ) )
{
if( ssl->conf->dhm_P.p == NULL || ssl->conf->dhm_G.p == NULL )
{
* opaque dh_Ys<1..2^16-1>;
* } ServerDHParams;
*/
- if( ( ret = mbedtls_mpi_copy( &ssl->handshake->dhm_ctx.P, &ssl->conf->dhm_P ) ) != 0 ||
- ( ret = mbedtls_mpi_copy( &ssl->handshake->dhm_ctx.G, &ssl->conf->dhm_G ) ) != 0 )
+ if( ( ret = mbedtls_dhm_set_group( &ssl->handshake->dhm_ctx,
+ &ssl->conf->dhm_P,
+ &ssl->conf->dhm_G ) ) != 0 )
{
- MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_mpi_copy", ret );
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_set_group", ret );
return( ret );
}
return( ret );
}
+#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED)
dig_signed = p;
dig_signed_len = len;
+#endif
p += len;
n += len;
MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: G ", &ssl->handshake->dhm_ctx.G );
MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: GX", &ssl->handshake->dhm_ctx.GX );
}
-#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED ||
- MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */
+#endif /* MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED */
+ /*
+ * - ECDHE key exchanges
+ */
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED)
- if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK )
+ if( mbedtls_ssl_ciphersuite_uses_ecdhe( ciphersuite_info ) )
{
/*
* Ephemeral ECDH parameters:
return( ret );
}
- dig_signed = p;
+#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED)
+ dig_signed = p;
dig_signed_len = len;
+#endif
p += len;
n += len;
}
#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED */
-#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
- defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
- if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_RSA ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_RSA ||
- ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA )
+ /*
+ *
+ * Part 3: For key exchanges involving the server signing the
+ * exchange parameters, compute and add the signature here.
+ *
+ */
+#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED)
+ if( mbedtls_ssl_ciphersuite_uses_server_signature( ciphersuite_info ) )
{
size_t signature_len = 0;
unsigned int hashlen = 0;
unsigned char hash[64];
- mbedtls_md_type_t md_alg = MBEDTLS_MD_NONE;
/*
- * Choose hash algorithm. NONE means MD5 + SHA1 here.
+ * 3.1: Choose hash algorithm:
+ * A: For TLS 1.2, obey signature-hash-algorithm extension
+ * to choose appropriate hash.
+ * B: For SSL3, TLS1.0, TLS1.1 and ECDHE_ECDSA, use SHA1
+ * (RFC 4492, Sec. 5.4)
+ * C: Otherwise, use MD5 + SHA1 (RFC 4346, Sec. 7.4.3)
*/
+
+ mbedtls_md_type_t md_alg;
+
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
+ mbedtls_pk_type_t sig_alg =
+ mbedtls_ssl_get_ciphersuite_sig_pk_alg( ciphersuite_info );
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )
{
- md_alg = mbedtls_ssl_md_alg_from_hash( ssl->handshake->sig_alg );
-
- if( md_alg == MBEDTLS_MD_NONE )
+ /* A: For TLS 1.2, obey signature-hash-algorithm extension
+ * (RFC 5246, Sec. 7.4.1.4.1). */
+ if( sig_alg == MBEDTLS_PK_NONE ||
+ ( md_alg = mbedtls_ssl_sig_hash_set_find( &ssl->handshake->hash_algs,
+ sig_alg ) ) == MBEDTLS_MD_NONE )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
+ /* (... because we choose a cipher suite
+ * only if there is a matching hash.) */
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
}
}
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \
defined(MBEDTLS_SSL_PROTO_TLS1_1)
- if( ciphersuite_info->key_exchange ==
- MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA )
+ if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA )
{
+ /* B: Default hash SHA1 */
md_alg = MBEDTLS_MD_SHA1;
}
else
-#endif
+#endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || \
+ MBEDTLS_SSL_PROTO_TLS1_1 */
{
+ /* C: MD5 + SHA1 */
md_alg = MBEDTLS_MD_NONE;
}
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "pick hash algorithm %d for signing", md_alg ) );
+
/*
- * Compute the hash to be signed
+ * 3.2: Compute the hash to be signed
*/
#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \
defined(MBEDTLS_SSL_PROTO_TLS1_1)
if( md_alg == MBEDTLS_MD_NONE )
{
- mbedtls_md5_context mbedtls_md5;
- mbedtls_sha1_context mbedtls_sha1;
-
- mbedtls_md5_init( &mbedtls_md5 );
- mbedtls_sha1_init( &mbedtls_sha1 );
-
- /*
- * digitally-signed struct {
- * opaque md5_hash[16];
- * opaque sha_hash[20];
- * };
- *
- * md5_hash
- * MD5(ClientHello.random + ServerHello.random
- * + ServerParams);
- * sha_hash
- * SHA(ClientHello.random + ServerHello.random
- * + ServerParams);
- */
- mbedtls_md5_starts( &mbedtls_md5 );
- mbedtls_md5_update( &mbedtls_md5, ssl->handshake->randbytes, 64 );
- mbedtls_md5_update( &mbedtls_md5, dig_signed, dig_signed_len );
- mbedtls_md5_finish( &mbedtls_md5, hash );
-
- mbedtls_sha1_starts( &mbedtls_sha1 );
- mbedtls_sha1_update( &mbedtls_sha1, ssl->handshake->randbytes, 64 );
- mbedtls_sha1_update( &mbedtls_sha1, dig_signed, dig_signed_len );
- mbedtls_sha1_finish( &mbedtls_sha1, hash + 16 );
-
hashlen = 36;
-
- mbedtls_md5_free( &mbedtls_md5 );
- mbedtls_sha1_free( &mbedtls_sha1 );
+ ret = mbedtls_ssl_get_key_exchange_md_ssl_tls( ssl, hash,
+ dig_signed,
+ dig_signed_len );
+ if( ret != 0 )
+ return( ret );
}
else
#endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || \
defined(MBEDTLS_SSL_PROTO_TLS1_2)
if( md_alg != MBEDTLS_MD_NONE )
{
- mbedtls_md_context_t ctx;
- const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_alg );
-
- mbedtls_md_init( &ctx );
-
/* Info from md_alg will be used instead */
hashlen = 0;
-
- /*
- * digitally-signed struct {
- * opaque client_random[32];
- * opaque server_random[32];
- * ServerDHParams params;
- * };
- */
- if( ( ret = mbedtls_md_setup( &ctx, md_info, 0 ) ) != 0 )
- {
- MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_setup", ret );
+ ret = mbedtls_ssl_get_key_exchange_md_tls1_2( ssl, hash,
+ dig_signed,
+ dig_signed_len,
+ md_alg );
+ if( ret != 0 )
return( ret );
- }
-
- mbedtls_md_starts( &ctx );
- mbedtls_md_update( &ctx, ssl->handshake->randbytes, 64 );
- mbedtls_md_update( &ctx, dig_signed, dig_signed_len );
- mbedtls_md_finish( &ctx, hash );
- mbedtls_md_free( &ctx );
}
else
#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \
(unsigned int) ( mbedtls_md_get_size( mbedtls_md_info_from_type( md_alg ) ) ) );
/*
- * Make the signature
+ * 3.3: Compute and add the signature
*/
if( mbedtls_ssl_own_key( ssl ) == NULL )
{
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 )
{
- *(p++) = ssl->handshake->sig_alg;
- *(p++) = mbedtls_ssl_sig_from_pk( mbedtls_ssl_own_key( ssl ) );
+ /*
+ * For TLS 1.2, we need to specify signature and hash algorithm
+ * explicitly through a prefix to the signature.
+ *
+ * struct {
+ * HashAlgorithm hash;
+ * SignatureAlgorithm signature;
+ * } SignatureAndHashAlgorithm;
+ *
+ * struct {
+ * SignatureAndHashAlgorithm algorithm;
+ * opaque signature<0..2^16-1>;
+ * } DigitallySigned;
+ *
+ */
+
+ *(p++) = mbedtls_ssl_hash_from_md_alg( md_alg );
+ *(p++) = mbedtls_ssl_sig_from_pk_alg( sig_alg );
n += 2;
}
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
if( ( ret = mbedtls_pk_sign( mbedtls_ssl_own_key( ssl ), md_alg, hash, hashlen,
- p + 2 , &signature_len,
- ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 )
+ p + 2 , &signature_len, ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_sign", ret );
return( ret );
n += signature_len;
}
-#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) ||
- MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED ||
- MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
+#endif /* MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED */
+
+ /* Done with actual work; add header and send. */
ssl->out_msglen = 4 + n;
ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE;
/*
* Receive client pre-shared key identity name
*/
- if( *p + 2 > end )
+ if( end - *p < 2 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE );
n = ( (*p)[0] << 8 ) | (*p)[1];
*p += 2;
- if( n < 1 || n > 65535 || *p + n > end )
+ if( n < 1 || n > 65535 || n > (size_t) ( end - *p ) )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client key exchange message" ) );
return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE );
if( ret == MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY )
{
MBEDTLS_SSL_DEBUG_BUF( 3, "Unknown PSK identity", *p, n );
- if( ( ret = mbedtls_ssl_send_alert_message( ssl,
- MBEDTLS_SSL_ALERT_LEVEL_FATAL,
- MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY ) ) != 0 )
- {
- return( ret );
- }
-
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_UNKNOWN_PSK_IDENTITY );
return( MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY );
}
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl )
{
- const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
+ const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
+ ssl->transform_negotiate->ciphersuite_info;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate verify" ) );
mbedtls_pk_type_t pk_alg;
#endif
mbedtls_md_type_t md_alg;
- const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
+ const mbedtls_ssl_ciphersuite_t *ciphersuite_info =
+ ssl->transform_negotiate->ciphersuite_info;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate verify" ) );
const unsigned char *random, size_t rlen,
unsigned char *dstbuf, size_t dlen )
{
+ int ret = 0;
size_t i;
mbedtls_md5_context md5;
mbedtls_sha1_context sha1;
{
memset( padding, (unsigned char) ('A' + i), 1 + i );
- mbedtls_sha1_starts( &sha1 );
- mbedtls_sha1_update( &sha1, padding, 1 + i );
- mbedtls_sha1_update( &sha1, secret, slen );
- mbedtls_sha1_update( &sha1, random, rlen );
- mbedtls_sha1_finish( &sha1, sha1sum );
-
- mbedtls_md5_starts( &md5 );
- mbedtls_md5_update( &md5, secret, slen );
- mbedtls_md5_update( &md5, sha1sum, 20 );
- mbedtls_md5_finish( &md5, dstbuf + i * 16 );
- }
-
+ if( ( ret = mbedtls_sha1_starts_ret( &sha1 ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_sha1_update_ret( &sha1, padding, 1 + i ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_sha1_update_ret( &sha1, secret, slen ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_sha1_update_ret( &sha1, random, rlen ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_sha1_finish_ret( &sha1, sha1sum ) ) != 0 )
+ goto exit;
+
+ if( ( ret = mbedtls_md5_starts_ret( &md5 ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md5_update_ret( &md5, secret, slen ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md5_update_ret( &md5, sha1sum, 20 ) ) != 0 )
+ goto exit;
+ if( ( ret = mbedtls_md5_finish_ret( &md5, dstbuf + i * 16 ) ) != 0 )
+ goto exit;
+ }
+
+exit:
mbedtls_md5_free( &md5 );
mbedtls_sha1_free( &sha1 );
mbedtls_zeroize( padding, sizeof( padding ) );
mbedtls_zeroize( sha1sum, sizeof( sha1sum ) );
- return( 0 );
+ return( ret );
}
#endif /* MBEDTLS_SSL_PROTO_SSL3 */
unsigned char *key2;
unsigned char *mac_enc;
unsigned char *mac_dec;
+ size_t mac_key_len;
size_t iv_copy_len;
const mbedtls_cipher_info_t *cipher_info;
const mbedtls_md_info_t *md_info;
cipher_info->mode == MBEDTLS_MODE_CCM )
{
transform->maclen = 0;
+ mac_key_len = 0;
transform->ivlen = 12;
transform->fixed_ivlen = 4;
}
/* Get MAC length */
- transform->maclen = mbedtls_md_get_size( md_info );
+ mac_key_len = mbedtls_md_get_size( md_info );
+ transform->maclen = mac_key_len;
#if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
/*
* so we only need to adjust the length here.
*/
if( session->trunc_hmac == MBEDTLS_SSL_TRUNC_HMAC_ENABLED )
+ {
transform->maclen = MBEDTLS_SSL_TRUNCATED_HMAC_LEN;
+
+#if defined(MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT)
+ /* Fall back to old, non-compliant version of the truncated
+ * HMAC implementation which also truncates the key
+ * (Mbed TLS versions from 1.3 to 2.6.0) */
+ mac_key_len = transform->maclen;
+#endif
+ }
#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
/* IV length */
#if defined(MBEDTLS_SSL_CLI_C)
if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT )
{
- key1 = keyblk + transform->maclen * 2;
- key2 = keyblk + transform->maclen * 2 + transform->keylen;
+ key1 = keyblk + mac_key_len * 2;
+ key2 = keyblk + mac_key_len * 2 + transform->keylen;
mac_enc = keyblk;
- mac_dec = keyblk + transform->maclen;
+ mac_dec = keyblk + mac_key_len;
/*
* This is not used in TLS v1.1.
#if defined(MBEDTLS_SSL_SRV_C)
if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER )
{
- key1 = keyblk + transform->maclen * 2 + transform->keylen;
- key2 = keyblk + transform->maclen * 2;
+ key1 = keyblk + mac_key_len * 2 + transform->keylen;
+ key2 = keyblk + mac_key_len * 2;
- mac_enc = keyblk + transform->maclen;
+ mac_enc = keyblk + mac_key_len;
mac_dec = keyblk;
/*
#if defined(MBEDTLS_SSL_PROTO_SSL3)
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 )
{
- if( transform->maclen > sizeof transform->mac_enc )
+ if( mac_key_len > sizeof transform->mac_enc )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
}
- memcpy( transform->mac_enc, mac_enc, transform->maclen );
- memcpy( transform->mac_dec, mac_dec, transform->maclen );
+ memcpy( transform->mac_enc, mac_enc, mac_key_len );
+ memcpy( transform->mac_dec, mac_dec, mac_key_len );
}
else
#endif /* MBEDTLS_SSL_PROTO_SSL3 */
defined(MBEDTLS_SSL_PROTO_TLS1_2)
if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_1 )
{
- mbedtls_md_hmac_starts( &transform->md_ctx_enc, mac_enc, transform->maclen );
- mbedtls_md_hmac_starts( &transform->md_ctx_dec, mac_dec, transform->maclen );
+ mbedtls_md_hmac_starts( &transform->md_ctx_enc, mac_enc, mac_key_len );
+ mbedtls_md_hmac_starts( &transform->md_ctx_dec, mac_dec, mac_key_len );
}
else
#endif
transform->iv_enc, transform->iv_dec,
iv_copy_len,
mac_enc, mac_dec,
- transform->maclen ) ) != 0 )
+ mac_key_len ) ) != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_hw_record_init", ret );
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
{
ssl->conf->f_export_keys( ssl->conf->p_export_keys,
session->master, keyblk,
- transform->maclen, transform->keylen,
+ mac_key_len, transform->keylen,
iv_copy_len );
}
#endif
memset( pad_1, 0x36, 48 );
memset( pad_2, 0x5C, 48 );
- mbedtls_md5_update( &md5, ssl->session_negotiate->master, 48 );
- mbedtls_md5_update( &md5, pad_1, 48 );
- mbedtls_md5_finish( &md5, hash );
+ mbedtls_md5_update_ret( &md5, ssl->session_negotiate->master, 48 );
+ mbedtls_md5_update_ret( &md5, pad_1, 48 );
+ mbedtls_md5_finish_ret( &md5, hash );
- mbedtls_md5_starts( &md5 );
- mbedtls_md5_update( &md5, ssl->session_negotiate->master, 48 );
- mbedtls_md5_update( &md5, pad_2, 48 );
- mbedtls_md5_update( &md5, hash, 16 );
- mbedtls_md5_finish( &md5, hash );
+ mbedtls_md5_starts_ret( &md5 );
+ mbedtls_md5_update_ret( &md5, ssl->session_negotiate->master, 48 );
+ mbedtls_md5_update_ret( &md5, pad_2, 48 );
+ mbedtls_md5_update_ret( &md5, hash, 16 );
+ mbedtls_md5_finish_ret( &md5, hash );
- mbedtls_sha1_update( &sha1, ssl->session_negotiate->master, 48 );
- mbedtls_sha1_update( &sha1, pad_1, 40 );
- mbedtls_sha1_finish( &sha1, hash + 16 );
+ mbedtls_sha1_update_ret( &sha1, ssl->session_negotiate->master, 48 );
+ mbedtls_sha1_update_ret( &sha1, pad_1, 40 );
+ mbedtls_sha1_finish_ret( &sha1, hash + 16 );
- mbedtls_sha1_starts( &sha1 );
- mbedtls_sha1_update( &sha1, ssl->session_negotiate->master, 48 );
- mbedtls_sha1_update( &sha1, pad_2, 40 );
- mbedtls_sha1_update( &sha1, hash + 16, 20 );
- mbedtls_sha1_finish( &sha1, hash + 16 );
+ mbedtls_sha1_starts_ret( &sha1 );
+ mbedtls_sha1_update_ret( &sha1, ssl->session_negotiate->master, 48 );
+ mbedtls_sha1_update_ret( &sha1, pad_2, 40 );
+ mbedtls_sha1_update_ret( &sha1, hash + 16, 20 );
+ mbedtls_sha1_finish_ret( &sha1, hash + 16 );
MBEDTLS_SSL_DEBUG_BUF( 3, "calculated verify result", hash, 36 );
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc verify" ) );
mbedtls_md5_clone( &md5, &ssl->handshake->fin_md5 );
mbedtls_sha1_clone( &sha1, &ssl->handshake->fin_sha1 );
- mbedtls_md5_finish( &md5, hash );
- mbedtls_sha1_finish( &sha1, hash + 16 );
+ mbedtls_md5_finish_ret( &md5, hash );
+ mbedtls_sha1_finish_ret( &sha1, hash + 16 );
MBEDTLS_SSL_DEBUG_BUF( 3, "calculated verify result", hash, 36 );
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc verify" ) );
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> calc verify sha256" ) );
mbedtls_sha256_clone( &sha256, &ssl->handshake->fin_sha256 );
- mbedtls_sha256_finish( &sha256, hash );
+ mbedtls_sha256_finish_ret( &sha256, hash );
MBEDTLS_SSL_DEBUG_BUF( 3, "calculated verify result", hash, 32 );
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc verify" ) );
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> calc verify sha384" ) );
mbedtls_sha512_clone( &sha512, &ssl->handshake->fin_sha512 );
- mbedtls_sha512_finish( &sha512, hash );
+ mbedtls_sha512_finish_ret( &sha512, hash );
MBEDTLS_SSL_DEBUG_BUF( 3, "calculated verify result", hash, 48 );
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc verify" ) );
/*
* SSLv3.0 MAC functions
*/
-static void ssl_mac( mbedtls_md_context_t *md_ctx, unsigned char *secret,
- unsigned char *buf, size_t len,
- unsigned char *ctr, int type )
+#define SSL_MAC_MAX_BYTES 20 /* MD-5 or SHA-1 */
+static void ssl_mac( mbedtls_md_context_t *md_ctx,
+ const unsigned char *secret,
+ const unsigned char *buf, size_t len,
+ const unsigned char *ctr, int type,
+ unsigned char out[SSL_MAC_MAX_BYTES] )
{
unsigned char header[11];
unsigned char padding[48];
mbedtls_md_update( md_ctx, padding, padlen );
mbedtls_md_update( md_ctx, header, 11 );
mbedtls_md_update( md_ctx, buf, len );
- mbedtls_md_finish( md_ctx, buf + len );
+ mbedtls_md_finish( md_ctx, out );
memset( padding, 0x5C, padlen );
mbedtls_md_starts( md_ctx );
mbedtls_md_update( md_ctx, secret, md_size );
mbedtls_md_update( md_ctx, padding, padlen );
- mbedtls_md_update( md_ctx, buf + len, md_size );
- mbedtls_md_finish( md_ctx, buf + len );
+ mbedtls_md_update( md_ctx, out, md_size );
+ mbedtls_md_finish( md_ctx, out );
}
#endif /* MBEDTLS_SSL_PROTO_SSL3 */
MBEDTLS_SSL_DEBUG_BUF( 4, "before encrypt: output payload",
ssl->out_msg, ssl->out_msglen );
+ if( ssl->out_msglen > MBEDTLS_SSL_MAX_CONTENT_LEN )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "Record content %u too large, maximum %d",
+ (unsigned) ssl->out_msglen,
+ MBEDTLS_SSL_MAX_CONTENT_LEN ) );
+ return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
+ }
+
/*
* Add MAC before if needed
*/
#if defined(MBEDTLS_SSL_PROTO_SSL3)
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 )
{
+ unsigned char mac[SSL_MAC_MAX_BYTES];
+
ssl_mac( &ssl->transform_out->md_ctx_enc,
ssl->transform_out->mac_enc,
ssl->out_msg, ssl->out_msglen,
- ssl->out_ctr, ssl->out_msgtype );
+ ssl->out_ctr, ssl->out_msgtype,
+ mac );
+
+ memcpy( ssl->out_msg + ssl->out_msglen, mac, ssl->transform_out->maclen );
}
else
#endif
defined(MBEDTLS_SSL_PROTO_TLS1_2)
if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_1 )
{
+ unsigned char mac[MBEDTLS_SSL_MAC_ADD];
+
mbedtls_md_hmac_update( &ssl->transform_out->md_ctx_enc, ssl->out_ctr, 8 );
mbedtls_md_hmac_update( &ssl->transform_out->md_ctx_enc, ssl->out_hdr, 3 );
mbedtls_md_hmac_update( &ssl->transform_out->md_ctx_enc, ssl->out_len, 2 );
mbedtls_md_hmac_update( &ssl->transform_out->md_ctx_enc,
ssl->out_msg, ssl->out_msglen );
- mbedtls_md_hmac_finish( &ssl->transform_out->md_ctx_enc,
- ssl->out_msg + ssl->out_msglen );
+ mbedtls_md_hmac_finish( &ssl->transform_out->md_ctx_enc, mac );
mbedtls_md_hmac_reset( &ssl->transform_out->md_ctx_enc );
+
+ memcpy( ssl->out_msg + ssl->out_msglen, mac, ssl->transform_out->maclen );
}
else
#endif
return( 0 );
}
-#define SSL_MAX_MAC_SIZE 48
-
static int ssl_decrypt_buf( mbedtls_ssl_context *ssl )
{
size_t i;
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
if( ssl->session_in->encrypt_then_mac == MBEDTLS_SSL_ETM_ENABLED )
{
- unsigned char computed_mac[SSL_MAX_MAC_SIZE];
+ unsigned char mac_expect[MBEDTLS_SSL_MAC_ADD];
unsigned char pseudo_hdr[13];
MBEDTLS_SSL_DEBUG_MSG( 3, ( "using encrypt then mac" ) );
mbedtls_md_hmac_update( &ssl->transform_in->md_ctx_dec, pseudo_hdr, 13 );
mbedtls_md_hmac_update( &ssl->transform_in->md_ctx_dec,
ssl->in_iv, ssl->in_msglen );
- mbedtls_md_hmac_finish( &ssl->transform_in->md_ctx_dec, computed_mac );
+ mbedtls_md_hmac_finish( &ssl->transform_in->md_ctx_dec, mac_expect );
mbedtls_md_hmac_reset( &ssl->transform_in->md_ctx_dec );
MBEDTLS_SSL_DEBUG_BUF( 4, "message mac", ssl->in_iv + ssl->in_msglen,
ssl->transform_in->maclen );
- MBEDTLS_SSL_DEBUG_BUF( 4, "computed mac", computed_mac,
+ MBEDTLS_SSL_DEBUG_BUF( 4, "expected mac", mac_expect,
ssl->transform_in->maclen );
- if( mbedtls_ssl_safer_memcmp( ssl->in_iv + ssl->in_msglen, computed_mac,
- ssl->transform_in->maclen ) != 0 )
+ if( mbedtls_ssl_safer_memcmp( ssl->in_iv + ssl->in_msglen, mac_expect,
+ ssl->transform_in->maclen ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "message mac does not match" ) );
#if defined(SSL_SOME_MODES_USE_MAC)
if( auth_done == 0 )
{
- unsigned char tmp[SSL_MAX_MAC_SIZE];
+ unsigned char mac_expect[MBEDTLS_SSL_MAC_ADD];
ssl->in_msglen -= ssl->transform_in->maclen;
ssl->in_len[0] = (unsigned char)( ssl->in_msglen >> 8 );
ssl->in_len[1] = (unsigned char)( ssl->in_msglen );
- memcpy( tmp, ssl->in_msg + ssl->in_msglen, ssl->transform_in->maclen );
-
#if defined(MBEDTLS_SSL_PROTO_SSL3)
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 )
{
ssl_mac( &ssl->transform_in->md_ctx_dec,
ssl->transform_in->mac_dec,
ssl->in_msg, ssl->in_msglen,
- ssl->in_ctr, ssl->in_msgtype );
+ ssl->in_ctr, ssl->in_msgtype,
+ mac_expect );
}
else
#endif /* MBEDTLS_SSL_PROTO_SSL3 */
mbedtls_md_hmac_update( &ssl->transform_in->md_ctx_dec, ssl->in_len, 2 );
mbedtls_md_hmac_update( &ssl->transform_in->md_ctx_dec, ssl->in_msg,
ssl->in_msglen );
- mbedtls_md_hmac_finish( &ssl->transform_in->md_ctx_dec,
- ssl->in_msg + ssl->in_msglen );
+ mbedtls_md_hmac_finish( &ssl->transform_in->md_ctx_dec, mac_expect );
/* Call mbedtls_md_process at least once due to cache attacks */
for( j = 0; j < extra_run + 1; j++ )
mbedtls_md_process( &ssl->transform_in->md_ctx_dec, ssl->in_msg );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
}
- MBEDTLS_SSL_DEBUG_BUF( 4, "message mac", tmp, ssl->transform_in->maclen );
- MBEDTLS_SSL_DEBUG_BUF( 4, "computed mac", ssl->in_msg + ssl->in_msglen,
- ssl->transform_in->maclen );
+ MBEDTLS_SSL_DEBUG_BUF( 4, "expected mac", mac_expect, ssl->transform_in->maclen );
+ MBEDTLS_SSL_DEBUG_BUF( 4, "message mac", ssl->in_msg + ssl->in_msglen,
+ ssl->transform_in->maclen );
- if( mbedtls_ssl_safer_memcmp( tmp, ssl->in_msg + ssl->in_msglen,
- ssl->transform_in->maclen ) != 0 )
+ if( mbedtls_ssl_safer_memcmp( ssl->in_msg + ssl->in_msglen, mac_expect,
+ ssl->transform_in->maclen ) != 0 )
{
#if defined(MBEDTLS_SSL_DEBUG_ALL)
MBEDTLS_SSL_DEBUG_MSG( 1, ( "message mac does not match" ) );
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
{
/* Make room for the additional DTLS fields */
+ if( MBEDTLS_SSL_MAX_CONTENT_LEN - ssl->out_msglen < 8 )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "DTLS handshake message too large: "
+ "size %u, maximum %u",
+ (unsigned) ( ssl->in_hslen - 4 ),
+ (unsigned) ( MBEDTLS_SSL_MAX_CONTENT_LEN - 12 ) ) );
+ return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
+ }
+
memmove( ssl->out_msg + 12, ssl->out_msg + 4, len - 4 );
ssl->out_msglen += 8;
len += 8;
if( ret == MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED )
{
- /* Dont check write errors as we can't do anything here.
+ /* Don't check write errors as we can't do anything here.
* If the error is permanent we'll catch it later,
* if it's not, then hopefully it'll work next time. */
(void) ssl->f_send( ssl->p_bio, ssl->out_buf, len );
*/
static int ssl_parse_record_header( mbedtls_ssl_context *ssl )
{
- int ret;
int major_ver, minor_ver;
MBEDTLS_SSL_DEBUG_BUF( 4, "input record header", ssl->in_hdr, mbedtls_ssl_hdr_len( ssl ) );
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "unknown record type" ) );
- if( ( ret = mbedtls_ssl_send_alert_message( ssl,
- MBEDTLS_SSL_ALERT_LEVEL_FATAL,
- MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE ) ) != 0 )
- {
- return( ret );
- }
+#if defined(MBEDTLS_SSL_PROTO_DTLS)
+ /* Silently ignore invalid DTLS records as recommended by RFC 6347
+ * Section 4.1.2.7 */
+ if( ssl->conf->transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM )
+#endif /* MBEDTLS_SSL_PROTO_DTLS */
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );
return( MBEDTLS_ERR_SSL_INVALID_RECORD );
}
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> read record" ) );
- do {
+ if( ssl->keep_current_message == 0 )
+ {
+ do {
- if( ( ret = mbedtls_ssl_read_record_layer( ssl ) ) != 0 )
+ if( ( ret = mbedtls_ssl_read_record_layer( ssl ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_read_record_layer" ), ret );
+ return( ret );
+ }
+
+ ret = mbedtls_ssl_handle_message_type( ssl );
+
+ } while( MBEDTLS_ERR_SSL_NON_FATAL == ret );
+
+ if( 0 != ret )
{
MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_read_record_layer" ), ret );
return( ret );
}
- ret = mbedtls_ssl_handle_message_type( ssl );
-
- } while( MBEDTLS_ERR_SSL_NON_FATAL == ret );
-
- if( 0 != ret )
- {
- MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_handle_message_type" ), ret );
- return( ret );
+ if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE )
+ {
+ mbedtls_ssl_update_handshake_status( ssl );
+ }
}
-
- if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE )
+ else
{
- mbedtls_ssl_update_handshake_status( ssl );
+ MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= reuse previously read message" ) );
+ ssl->keep_current_message = 0;
}
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= read record" ) );
{
int ret;
- if( ssl->in_hslen != 0 && ssl->in_hslen < ssl->in_msglen )
+ /*
+ * Step A
+ *
+ * Consume last content-layer message and potentially
+ * update in_msglen which keeps track of the contents'
+ * consumption state.
+ *
+ * (1) Handshake messages:
+ * Remove last handshake message, move content
+ * and adapt in_msglen.
+ *
+ * (2) Alert messages:
+ * Consume whole record content, in_msglen = 0.
+ *
+ * NOTE: This needs to be fixed, since like for
+ * handshake messages it is allowed to have
+ * multiple alerts witin a single record.
+ * Internal reference IOTSSL-1321.
+ *
+ * (3) Change cipher spec:
+ * Consume whole record content, in_msglen = 0.
+ *
+ * (4) Application data:
+ * Don't do anything - the record layer provides
+ * the application data as a stream transport
+ * and consumes through mbedtls_ssl_read only.
+ *
+ */
+
+ /* Case (1): Handshake messages */
+ if( ssl->in_hslen != 0 )
{
+ /* Hard assertion to be sure that no application data
+ * is in flight, as corrupting ssl->in_msglen during
+ * ssl->in_offt != NULL is fatal. */
+ if( ssl->in_offt != NULL )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
+ return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
+ }
+
/*
* Get next Handshake message in the current record
*/
- ssl->in_msglen -= ssl->in_hslen;
- memmove( ssl->in_msg, ssl->in_msg + ssl->in_hslen,
- ssl->in_msglen );
+ /* Notes:
+ * (1) in_hslen is *NOT* necessarily the size of the
+ * current handshake content: If DTLS handshake
+ * fragmentation is used, that's the fragment
+ * size instead. Using the total handshake message
+ * size here is FAULTY and should be changed at
+ * some point. Internal reference IOTSSL-1414.
+ * (2) While it doesn't seem to cause problems, one
+ * has to be very careful not to assume that in_hslen
+ * is always <= in_msglen in a sensible communication.
+ * Again, it's wrong for DTLS handshake fragmentation.
+ * The following check is therefore mandatory, and
+ * should not be treated as a silently corrected assertion.
+ * Additionally, ssl->in_hslen might be arbitrarily out of
+ * bounds after handling a DTLS message with an unexpected
+ * sequence number, see mbedtls_ssl_prepare_handshake_record.
+ */
+ if( ssl->in_hslen < ssl->in_msglen )
+ {
+ ssl->in_msglen -= ssl->in_hslen;
+ memmove( ssl->in_msg, ssl->in_msg + ssl->in_hslen,
+ ssl->in_msglen );
- MBEDTLS_SSL_DEBUG_BUF( 4, "remaining content in record",
- ssl->in_msg, ssl->in_msglen );
+ MBEDTLS_SSL_DEBUG_BUF( 4, "remaining content in record",
+ ssl->in_msg, ssl->in_msglen );
+ }
+ else
+ {
+ ssl->in_msglen = 0;
+ }
+ ssl->in_hslen = 0;
+ }
+ /* Case (4): Application data */
+ else if( ssl->in_offt != NULL )
+ {
return( 0 );
}
-
- ssl->in_hslen = 0;
+ /* Everything else (CCS & Alerts) */
+ else
+ {
+ ssl->in_msglen = 0;
+ }
/*
- * Read the record header and parse it
+ * Step B
+ *
+ * Fetch and decode new record if current one is fully consumed.
+ *
*/
+
+ if( ssl->in_msglen > 0 )
+ {
+ /* There's something left to be processed in the current record. */
+ return( 0 );
+ }
+
+ /* Need to fetch a new record */
+
#if defined(MBEDTLS_SSL_PROTO_DTLS)
read_record_header:
#endif
+ /* Current record either fully processed or to be discarded. */
+
if( ( ret = mbedtls_ssl_fetch_input( ssl, mbedtls_ssl_hdr_len( ssl ) ) ) != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret );
}
#endif
+ /* As above, invalid records cause
+ * dismissal of the whole datagram. */
+
+ ssl->next_record_offset = 0;
+ ssl->in_left = 0;
+
MBEDTLS_SSL_DEBUG_MSG( 1, ( "discarding invalid record (mac)" ) );
goto read_record_header;
}
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> send alert message" ) );
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "send alert level=%u message=%u", level, message ));
ssl->out_msgtype = MBEDTLS_SSL_MSG_ALERT;
ssl->out_msglen = 2;
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret );
return( ret );
}
-
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= send alert message" ) );
return( 0 );
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \
!defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \
!defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
+/* No certificate support -> dummy functions */
int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl )
{
const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) );
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
}
+
#else
+/* Some certificate support -> implement write and parse */
+
int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl )
{
int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE;
size_t i, n;
const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
int authmode = ssl->conf->authmode;
+ uint8_t alert;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate" ) );
if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 )
{
+ /* mbedtls_ssl_read_record may have sent an alert already. We
+ let it decide whether to alert. */
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret );
return( ret );
}
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "SSLv3 client has no certificate" ) );
+ /* The client was asked for a certificate but didn't send
+ one. The client should know what's going on, so we
+ don't send an alert. */
ssl->session_negotiate->verify_result = MBEDTLS_X509_BADCERT_MISSING;
if( authmode == MBEDTLS_SSL_VERIFY_OPTIONAL )
return( 0 );
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "TLSv1 client has no certificate" ) );
+ /* The client was asked for a certificate but didn't send
+ one. The client should know what's going on, so we
+ don't send an alert. */
ssl->session_negotiate->verify_result = MBEDTLS_X509_BADCERT_MISSING;
if( authmode == MBEDTLS_SSL_VERIFY_OPTIONAL )
return( 0 );
if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
ssl->in_hslen < mbedtls_ssl_hs_hdr_len( ssl ) + 3 + 3 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE );
}
ssl->in_hslen != n + 3 + mbedtls_ssl_hs_hdr_len( ssl ) )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE );
}
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed",
sizeof( mbedtls_x509_crt ) ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR );
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
if( ssl->in_msg[i] != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE );
}
if( n < 128 || i + n > ssl->in_hslen )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE );
}
ret = mbedtls_x509_crt_parse_der( ssl->session_negotiate->peer_cert,
ssl->in_msg + i, n );
- if( 0 != ret && ( MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG + MBEDTLS_ERR_OID_NOT_FOUND ) != ret )
+ switch( ret )
{
+ case 0: /*ok*/
+ case MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG + MBEDTLS_ERR_OID_NOT_FOUND:
+ /* Ignore certificate with an unknown algorithm: maybe a
+ prior certificate was already trusted. */
+ break;
+
+ case MBEDTLS_ERR_X509_ALLOC_FAILED:
+ alert = MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR;
+ goto crt_parse_der_failed;
+
+ case MBEDTLS_ERR_X509_UNKNOWN_VERSION:
+ alert = MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT;
+ goto crt_parse_der_failed;
+
+ default:
+ alert = MBEDTLS_SSL_ALERT_MSG_BAD_CERT;
+ crt_parse_der_failed:
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, alert );
MBEDTLS_SSL_DEBUG_RET( 1, " mbedtls_x509_crt_parse_der", ret );
return( ret );
}
if( ssl->session->peer_cert == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "new server cert during renegotiation" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED );
return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE );
}
ssl->session->peer_cert->raw.len ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "server cert changed during renegotiation" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED );
return( MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE );
}
}
ca_crl = ssl->conf->ca_crl;
}
- if( ca_chain == NULL )
- {
- MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no CA chain" ) );
- return( MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED );
- }
-
/*
* Main check: verify certificate
*/
if( mbedtls_pk_can_do( pk, MBEDTLS_PK_ECKEY ) &&
mbedtls_ssl_check_curve( ssl, mbedtls_pk_ec( *pk )->grp.id ) != 0 )
{
+ ssl->session_negotiate->verify_result |= MBEDTLS_X509_BADCERT_BAD_KEY;
+
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate (EC key curve)" ) );
if( ret == 0 )
ret = MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE;
#endif /* MBEDTLS_ECP_C */
if( mbedtls_ssl_check_cert_usage( ssl->session_negotiate->peer_cert,
- ciphersuite_info,
- ! ssl->conf->endpoint,
+ ciphersuite_info,
+ ! ssl->conf->endpoint,
&ssl->session_negotiate->verify_result ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad certificate (usage extensions)" ) );
ret = MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE;
}
- if( authmode == MBEDTLS_SSL_VERIFY_OPTIONAL )
+ /* mbedtls_x509_crt_verify_with_profile is supposed to report a
+ * verification failure through MBEDTLS_ERR_X509_CERT_VERIFY_FAILED,
+ * with details encoded in the verification flags. All other kinds
+ * of error codes, including those from the user provided f_vrfy
+ * functions, are treated as fatal and lead to a failure of
+ * ssl_parse_certificate even if verification was optional. */
+ if( authmode == MBEDTLS_SSL_VERIFY_OPTIONAL &&
+ ( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED ||
+ ret == MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE ) )
+ {
ret = 0;
+ }
+
+ if( ca_chain == NULL && authmode == MBEDTLS_SSL_VERIFY_REQUIRED )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no CA chain" ) );
+ ret = MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED;
+ }
+
+ if( ret != 0 )
+ {
+ /* The certificate may have been rejected for several reasons.
+ Pick one and send the corresponding alert. Which alert to send
+ may be a subject of debate in some cases. */
+ if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_OTHER )
+ alert = MBEDTLS_SSL_ALERT_MSG_ACCESS_DENIED;
+ else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_CN_MISMATCH )
+ alert = MBEDTLS_SSL_ALERT_MSG_BAD_CERT;
+ else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_KEY_USAGE )
+ alert = MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT;
+ else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_EXT_KEY_USAGE )
+ alert = MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT;
+ else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_NS_CERT_TYPE )
+ alert = MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT;
+ else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_BAD_PK )
+ alert = MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT;
+ else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_BAD_KEY )
+ alert = MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_CERT;
+ else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_EXPIRED )
+ alert = MBEDTLS_SSL_ALERT_MSG_CERT_EXPIRED;
+ else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_REVOKED )
+ alert = MBEDTLS_SSL_ALERT_MSG_CERT_REVOKED;
+ else if( ssl->session_negotiate->verify_result & MBEDTLS_X509_BADCERT_NOT_TRUSTED )
+ alert = MBEDTLS_SSL_ALERT_MSG_UNKNOWN_CA;
+ else
+ alert = MBEDTLS_SSL_ALERT_MSG_CERT_UNKNOWN;
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ alert );
+ }
+
+#if defined(MBEDTLS_DEBUG_C)
+ if( ssl->session_negotiate->verify_result != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "! Certificate verification flags %x",
+ ssl->session_negotiate->verify_result ) );
+ }
+ else
+ {
+ MBEDTLS_SSL_DEBUG_MSG( 3, ( "Certificate verification flags clear" ) );
+ }
+#endif /* MBEDTLS_DEBUG_C */
}
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate" ) );
if( ssl->in_msgtype != MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad change cipher spec message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
if( ssl->in_msglen != 1 || ssl->in_msg[0] != 1 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad change cipher spec message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC );
}
if( ++ssl->in_epoch == 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "DTLS epoch would wrap" ) );
+ /* This is highly unlikely to happen for legitimate reasons, so
+ treat it as an attack and don't send an alert. */
return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING );
}
}
if( ( ret = mbedtls_ssl_hw_record_activate( ssl, MBEDTLS_SSL_CHANNEL_INBOUND ) ) != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_hw_record_activate", ret );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR );
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
}
}
{
#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \
defined(MBEDTLS_SSL_PROTO_TLS1_1)
- mbedtls_md5_starts( &ssl->handshake->fin_md5 );
- mbedtls_sha1_starts( &ssl->handshake->fin_sha1 );
+ mbedtls_md5_starts_ret( &ssl->handshake->fin_md5 );
+ mbedtls_sha1_starts_ret( &ssl->handshake->fin_sha1 );
#endif
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
#if defined(MBEDTLS_SHA256_C)
- mbedtls_sha256_starts( &ssl->handshake->fin_sha256, 0 );
+ mbedtls_sha256_starts_ret( &ssl->handshake->fin_sha256, 0 );
#endif
#if defined(MBEDTLS_SHA512_C)
- mbedtls_sha512_starts( &ssl->handshake->fin_sha512, 1 );
+ mbedtls_sha512_starts_ret( &ssl->handshake->fin_sha512, 1 );
#endif
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
}
{
#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \
defined(MBEDTLS_SSL_PROTO_TLS1_1)
- mbedtls_md5_update( &ssl->handshake->fin_md5 , buf, len );
- mbedtls_sha1_update( &ssl->handshake->fin_sha1, buf, len );
+ mbedtls_md5_update_ret( &ssl->handshake->fin_md5 , buf, len );
+ mbedtls_sha1_update_ret( &ssl->handshake->fin_sha1, buf, len );
#endif
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
#if defined(MBEDTLS_SHA256_C)
- mbedtls_sha256_update( &ssl->handshake->fin_sha256, buf, len );
+ mbedtls_sha256_update_ret( &ssl->handshake->fin_sha256, buf, len );
#endif
#if defined(MBEDTLS_SHA512_C)
- mbedtls_sha512_update( &ssl->handshake->fin_sha512, buf, len );
+ mbedtls_sha512_update_ret( &ssl->handshake->fin_sha512, buf, len );
#endif
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
}
static void ssl_update_checksum_md5sha1( mbedtls_ssl_context *ssl,
const unsigned char *buf, size_t len )
{
- mbedtls_md5_update( &ssl->handshake->fin_md5 , buf, len );
- mbedtls_sha1_update( &ssl->handshake->fin_sha1, buf, len );
+ mbedtls_md5_update_ret( &ssl->handshake->fin_md5 , buf, len );
+ mbedtls_sha1_update_ret( &ssl->handshake->fin_sha1, buf, len );
}
#endif
static void ssl_update_checksum_sha256( mbedtls_ssl_context *ssl,
const unsigned char *buf, size_t len )
{
- mbedtls_sha256_update( &ssl->handshake->fin_sha256, buf, len );
+ mbedtls_sha256_update_ret( &ssl->handshake->fin_sha256, buf, len );
}
#endif
static void ssl_update_checksum_sha384( mbedtls_ssl_context *ssl,
const unsigned char *buf, size_t len )
{
- mbedtls_sha512_update( &ssl->handshake->fin_sha512, buf, len );
+ mbedtls_sha512_update_ret( &ssl->handshake->fin_sha512, buf, len );
}
#endif
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
memset( padbuf, 0x36, 48 );
- mbedtls_md5_update( &md5, (const unsigned char *) sender, 4 );
- mbedtls_md5_update( &md5, session->master, 48 );
- mbedtls_md5_update( &md5, padbuf, 48 );
- mbedtls_md5_finish( &md5, md5sum );
+ mbedtls_md5_update_ret( &md5, (const unsigned char *) sender, 4 );
+ mbedtls_md5_update_ret( &md5, session->master, 48 );
+ mbedtls_md5_update_ret( &md5, padbuf, 48 );
+ mbedtls_md5_finish_ret( &md5, md5sum );
- mbedtls_sha1_update( &sha1, (const unsigned char *) sender, 4 );
- mbedtls_sha1_update( &sha1, session->master, 48 );
- mbedtls_sha1_update( &sha1, padbuf, 40 );
- mbedtls_sha1_finish( &sha1, sha1sum );
+ mbedtls_sha1_update_ret( &sha1, (const unsigned char *) sender, 4 );
+ mbedtls_sha1_update_ret( &sha1, session->master, 48 );
+ mbedtls_sha1_update_ret( &sha1, padbuf, 40 );
+ mbedtls_sha1_finish_ret( &sha1, sha1sum );
memset( padbuf, 0x5C, 48 );
- mbedtls_md5_starts( &md5 );
- mbedtls_md5_update( &md5, session->master, 48 );
- mbedtls_md5_update( &md5, padbuf, 48 );
- mbedtls_md5_update( &md5, md5sum, 16 );
- mbedtls_md5_finish( &md5, buf );
+ mbedtls_md5_starts_ret( &md5 );
+ mbedtls_md5_update_ret( &md5, session->master, 48 );
+ mbedtls_md5_update_ret( &md5, padbuf, 48 );
+ mbedtls_md5_update_ret( &md5, md5sum, 16 );
+ mbedtls_md5_finish_ret( &md5, buf );
- mbedtls_sha1_starts( &sha1 );
- mbedtls_sha1_update( &sha1, session->master, 48 );
- mbedtls_sha1_update( &sha1, padbuf , 40 );
- mbedtls_sha1_update( &sha1, sha1sum, 20 );
- mbedtls_sha1_finish( &sha1, buf + 16 );
+ mbedtls_sha1_starts_ret( &sha1 );
+ mbedtls_sha1_update_ret( &sha1, session->master, 48 );
+ mbedtls_sha1_update_ret( &sha1, padbuf , 40 );
+ mbedtls_sha1_update_ret( &sha1, sha1sum, 20 );
+ mbedtls_sha1_finish_ret( &sha1, buf + 16 );
MBEDTLS_SSL_DEBUG_BUF( 3, "calc finished result", buf, 36 );
? "client finished"
: "server finished";
- mbedtls_md5_finish( &md5, padbuf );
- mbedtls_sha1_finish( &sha1, padbuf + 16 );
+ mbedtls_md5_finish_ret( &md5, padbuf );
+ mbedtls_sha1_finish_ret( &sha1, padbuf + 16 );
ssl->handshake->tls_prf( session->master, 48, sender,
padbuf, 36, buf, len );
? "client finished"
: "server finished";
- mbedtls_sha256_finish( &sha256, padbuf );
+ mbedtls_sha256_finish_ret( &sha256, padbuf );
ssl->handshake->tls_prf( session->master, 48, sender,
padbuf, 32, buf, len );
? "client finished"
: "server finished";
- mbedtls_sha512_finish( &sha512, padbuf );
+ mbedtls_sha512_finish_ret( &sha512, padbuf );
ssl->handshake->tls_prf( session->master, 48, sender,
padbuf, 48, buf, len );
if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) + hash_len )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_FINISHED );
}
buf, hash_len ) != 0 )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad finished message" ) );
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR );
return( MBEDTLS_ERR_SSL_BAD_HS_FINISHED );
}
defined(MBEDTLS_SSL_PROTO_TLS1_1)
mbedtls_md5_init( &handshake->fin_md5 );
mbedtls_sha1_init( &handshake->fin_sha1 );
- mbedtls_md5_starts( &handshake->fin_md5 );
- mbedtls_sha1_starts( &handshake->fin_sha1 );
+ mbedtls_md5_starts_ret( &handshake->fin_md5 );
+ mbedtls_sha1_starts_ret( &handshake->fin_sha1 );
#endif
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
#if defined(MBEDTLS_SHA256_C)
mbedtls_sha256_init( &handshake->fin_sha256 );
- mbedtls_sha256_starts( &handshake->fin_sha256, 0 );
+ mbedtls_sha256_starts_ret( &handshake->fin_sha256, 0 );
#endif
#if defined(MBEDTLS_SHA512_C)
mbedtls_sha512_init( &handshake->fin_sha512 );
- mbedtls_sha512_starts( &handshake->fin_sha512, 1 );
+ mbedtls_sha512_starts_ret( &handshake->fin_sha512, 1 );
#endif
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
handshake->update_checksum = ssl_update_checksum_start;
- handshake->sig_alg = MBEDTLS_SSL_HASH_SHA1;
+
+#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
+ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
+ mbedtls_ssl_sig_hash_set_init( &handshake->hash_algs );
+#endif
#if defined(MBEDTLS_DHM_C)
mbedtls_dhm_init( &handshake->dhm_ctx );
ssl->in_hslen = 0;
ssl->nb_zero = 0;
- ssl->record_read = 0;
+
+ ssl->keep_current_message = 0;
ssl->out_msg = ssl->out_buf + 13;
ssl->out_msgtype = 0;
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
}
- if( conf->psk != NULL || conf->psk_identity != NULL )
+ if( conf->psk != NULL )
{
+ mbedtls_zeroize( conf->psk, conf->psk_len );
+
mbedtls_free( conf->psk );
- mbedtls_free( conf->psk_identity );
conf->psk = NULL;
+ conf->psk_len = 0;
+ }
+ if( conf->psk_identity != NULL )
+ {
+ mbedtls_free( conf->psk_identity );
conf->psk_identity = NULL;
+ conf->psk_identity_len = 0;
}
if( ( conf->psk = mbedtls_calloc( 1, psk_len ) ) == NULL ||
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
if( ssl->handshake->psk != NULL )
+ {
+ mbedtls_zeroize( ssl->handshake->psk, ssl->handshake->psk_len );
mbedtls_free( ssl->handshake->psk );
+ ssl->handshake->psk_len = 0;
+ }
if( ( ssl->handshake->psk = mbedtls_calloc( 1, psk_len ) ) == NULL )
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
+
+#if !defined(MBEDTLS_DEPRECATED_REMOVED)
int mbedtls_ssl_conf_dh_param( mbedtls_ssl_config *conf, const char *dhm_P, const char *dhm_G )
{
int ret;
return( 0 );
}
+#endif /* MBEDTLS_DEPRECATED_REMOVED */
+
+int mbedtls_ssl_conf_dh_param_bin( mbedtls_ssl_config *conf,
+ const unsigned char *dhm_P, size_t P_len,
+ const unsigned char *dhm_G, size_t G_len )
+{
+ int ret;
+
+ if( ( ret = mbedtls_mpi_read_binary( &conf->dhm_P, dhm_P, P_len ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_binary( &conf->dhm_G, dhm_G, G_len ) ) != 0 )
+ {
+ mbedtls_mpi_free( &conf->dhm_P );
+ mbedtls_mpi_free( &conf->dhm_G );
+ return( ret );
+ }
+
+ return( 0 );
+}
int mbedtls_ssl_conf_dh_param_ctx( mbedtls_ssl_config *conf, mbedtls_dhm_context *dhm_ctx )
{
{
conf->sig_hashes = hashes;
}
-#endif
+#endif /* MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
#if defined(MBEDTLS_ECP_C)
/*
{
conf->curve_list = curve_list;
}
-#endif
+#endif /* MBEDTLS_ECP_C */
#if defined(MBEDTLS_X509_CRT_PARSE_C)
int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname )
{
- size_t hostname_len;
+ /* Initialize to suppress unnecessary compiler warning */
+ size_t hostname_len = 0;
- if( hostname == NULL )
- return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
+ /* Check if new hostname is valid before
+ * making any change to current one */
+ if( hostname != NULL )
+ {
+ hostname_len = strlen( hostname );
- hostname_len = strlen( hostname );
+ if( hostname_len > MBEDTLS_SSL_MAX_HOST_NAME_LEN )
+ return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
+ }
- if( hostname_len + 1 == 0 )
- return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
+ /* Now it's clear that we will overwrite the old hostname,
+ * so we can free it safely */
- if( hostname_len > MBEDTLS_SSL_MAX_HOST_NAME_LEN )
- return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
+ if( ssl->hostname != NULL )
+ {
+ mbedtls_zeroize( ssl->hostname, strlen( ssl->hostname ) );
+ mbedtls_free( ssl->hostname );
+ }
- ssl->hostname = mbedtls_calloc( 1, hostname_len + 1 );
+ /* Passing NULL as hostname shall clear the old one */
- if( ssl->hostname == NULL )
- return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
+ if( hostname == NULL )
+ {
+ ssl->hostname = NULL;
+ }
+ else
+ {
+ ssl->hostname = mbedtls_calloc( 1, hostname_len + 1 );
+ if( ssl->hostname == NULL )
+ return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
- memcpy( ssl->hostname, hostname, hostname_len );
+ memcpy( ssl->hostname, hostname, hostname_len );
- ssl->hostname[hostname_len] = '\0';
+ ssl->hostname[hostname_len] = '\0';
+ }
return( 0 );
}
-#endif
+#endif /* MBEDTLS_X509_CRT_PARSE_C */
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
void mbedtls_ssl_conf_sni( mbedtls_ssl_config *conf,
const char **p;
/*
- * "Empty strings MUST NOT be included and byte strings MUST NOT be
- * truncated". Check lengths now rather than later.
+ * RFC 7301 3.1: "Empty strings MUST NOT be included and byte strings
+ * MUST NOT be truncated."
+ * We check lengths now rather than later.
*/
tot_len = 0;
for( p = protos; *p != NULL; p++ )
}
#endif
+#if defined(MBEDTLS_SSL_SRV_C)
+void mbedtls_ssl_conf_cert_req_ca_list( mbedtls_ssl_config *conf,
+ char cert_req_ca_list )
+{
+ conf->cert_req_ca_list = cert_req_ca_list;
+}
+#endif
+
#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC)
void mbedtls_ssl_conf_encrypt_then_mac( mbedtls_ssl_config *conf, char etm )
{
*/
static int ssl_check_ctr_renegotiate( mbedtls_ssl_context *ssl )
{
+ size_t ep_len = ssl_ep_len( ssl );
+ int in_ctr_cmp;
+ int out_ctr_cmp;
+
if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER ||
ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING ||
ssl->conf->disable_renegotiation == MBEDTLS_SSL_RENEGOTIATION_DISABLED )
return( 0 );
}
- if( memcmp( ssl->in_ctr, ssl->conf->renego_period, 8 ) <= 0 &&
- memcmp( ssl->out_ctr, ssl->conf->renego_period, 8 ) <= 0 )
+ in_ctr_cmp = memcmp( ssl->in_ctr + ep_len,
+ ssl->conf->renego_period + ep_len, 8 - ep_len );
+ out_ctr_cmp = memcmp( ssl->out_ctr + ep_len,
+ ssl->conf->renego_period + ep_len, 8 - ep_len );
+
+ if( in_ctr_cmp <= 0 && out_ctr_cmp <= 0 )
{
return( 0 );
}
*/
int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len )
{
- int ret, record_read = 0;
+ int ret;
size_t n;
if( ssl == NULL || ssl->conf == NULL )
}
#endif
+ /*
+ * Check if renegotiation is necessary and/or handshake is
+ * in process. If yes, perform/continue, and fall through
+ * if an unexpected packet is received while the client
+ * is waiting for the ServerHello.
+ *
+ * (There is no equivalent to the last condition on
+ * the server-side as it is not treated as within
+ * a handshake while waiting for the ClientHello
+ * after a renegotiation request.)
+ */
+
#if defined(MBEDTLS_SSL_RENEGOTIATION)
- if( ( ret = ssl_check_ctr_renegotiate( ssl ) ) != 0 )
+ ret = ssl_check_ctr_renegotiate( ssl );
+ if( ret != MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO &&
+ ret != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "ssl_check_ctr_renegotiate", ret );
return( ret );
if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER )
{
ret = mbedtls_ssl_handshake( ssl );
- if( ret == MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO )
- {
- record_read = 1;
- }
- else if( ret != 0 )
+ if( ret != MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO &&
+ ret != 0 )
{
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_handshake", ret );
return( ret );
}
}
+ /*
+ * TODO
+ *
+ * The logic should be streamlined here:
+ *
+ * Instead of
+ *
+ * - Manually checking whether ssl->in_offt is NULL
+ * - Fetching a new record if yes
+ * - Setting ssl->in_offt if one finds an application record
+ * - Resetting keep_current_message after handling the application data
+ *
+ * one should
+ *
+ * - Adapt read_record to set ssl->in_offt automatically
+ * when a new application data record is processed.
+ * - Always call mbedtls_ssl_read_record here.
+ *
+ * This way, the logic of ssl_read would be much clearer:
+ *
+ * (1) Always call record layer and see what kind of record is on
+ * and have it ready for consumption (in particular, in_offt
+ * properly set for application data records).
+ * (2) If it's application data (either freshly fetched
+ * or something already being partially processed),
+ * serve the read request from it.
+ * (3) If it's something different from application data,
+ * handle it accordingly, e.g. potentially start a
+ * renegotiation.
+ *
+ * This will also remove the need to manually reset
+ * ssl->keep_current_message = 0 below.
+ *
+ */
+
if( ssl->in_offt == NULL )
{
/* Start timer if not already running */
ssl_set_timer( ssl, ssl->conf->read_timeout );
}
- if( ! record_read )
+ if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 )
{
- if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 )
- {
- if( ret == MBEDTLS_ERR_SSL_CONN_EOF )
- return( 0 );
+ if( ret == MBEDTLS_ERR_SSL_CONN_EOF )
+ return( 0 );
- MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret );
- return( ret );
- }
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret );
+ return( ret );
}
if( ssl->in_msglen == 0 &&
}
}
-#if defined(MBEDTLS_SSL_RENEGOTIATION)
if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "received handshake message" ) );
+ /*
+ * - For client-side, expect SERVER_HELLO_REQUEST.
+ * - For server-side, expect CLIENT_HELLO.
+ * - Fail (TLS) or silently drop record (DTLS) in other cases.
+ */
+
#if defined(MBEDTLS_SSL_CLI_C)
if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT &&
( ssl->in_msg[0] != MBEDTLS_SSL_HS_HELLO_REQUEST ||
- ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) ) )
+ ssl->in_hslen != mbedtls_ssl_hs_hdr_len( ssl ) ) )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "handshake received (not HelloRequest)" ) );
#endif
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
+#endif /* MBEDTLS_SSL_CLI_C */
+#if defined(MBEDTLS_SSL_SRV_C)
if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER &&
ssl->in_msg[0] != MBEDTLS_SSL_HS_CLIENT_HELLO )
{
#endif
return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
-#endif
+#endif /* MBEDTLS_SSL_SRV_C */
- if( ssl->conf->disable_renegotiation == MBEDTLS_SSL_RENEGOTIATION_DISABLED ||
- ( ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION &&
- ssl->conf->allow_legacy_renegotiation ==
- MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION ) )
+#if defined(MBEDTLS_SSL_RENEGOTIATION)
+ /* Determine whether renegotiation attempt should be accepted */
+ if( ! ( ssl->conf->disable_renegotiation == MBEDTLS_SSL_RENEGOTIATION_DISABLED ||
+ ( ssl->secure_renegotiation == MBEDTLS_SSL_LEGACY_RENEGOTIATION &&
+ ssl->conf->allow_legacy_renegotiation ==
+ MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION ) ) )
{
+ /*
+ * Accept renegotiation request
+ */
+
+ /* DTLS clients need to know renego is server-initiated */
+#if defined(MBEDTLS_SSL_PROTO_DTLS)
+ if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM &&
+ ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT )
+ {
+ ssl->renego_status = MBEDTLS_SSL_RENEGOTIATION_PENDING;
+ }
+#endif
+ ret = ssl_start_renegotiation( ssl );
+ if( ret != MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO &&
+ ret != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "ssl_start_renegotiation", ret );
+ return( ret );
+ }
+ }
+ else
+#endif /* MBEDTLS_SSL_RENEGOTIATION */
+ {
+ /*
+ * Refuse renegotiation
+ */
+
MBEDTLS_SSL_DEBUG_MSG( 3, ( "refusing renegotiation, sending alert" ) );
#if defined(MBEDTLS_SSL_PROTO_SSL3)
if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 )
{
- /*
- * SSLv3 does not have a "no_renegotiation" alert
- */
- if( ( ret = mbedtls_ssl_send_fatal_handshake_failure( ssl ) ) != 0 )
- return( ret );
+ /* SSLv3 does not have a "no_renegotiation" warning, so
+ we send a fatal alert and abort the connection. */
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_UNEXPECTED_MESSAGE );
+ return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE );
}
else
#endif /* MBEDTLS_SSL_PROTO_SSL3 */
return( MBEDTLS_ERR_SSL_INTERNAL_ERROR );
}
}
- else
- {
- /* DTLS clients need to know renego is server-initiated */
-#if defined(MBEDTLS_SSL_PROTO_DTLS)
- if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM &&
- ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT )
- {
- ssl->renego_status = MBEDTLS_SSL_RENEGOTIATION_PENDING;
- }
-#endif
- ret = ssl_start_renegotiation( ssl );
- if( ret == MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO )
- {
- record_read = 1;
- }
- else if( ret != 0 )
- {
- MBEDTLS_SSL_DEBUG_RET( 1, "ssl_start_renegotiation", ret );
- return( ret );
- }
- }
- /* If a non-handshake record was read during renego, fallthrough,
- * else tell the user they should call mbedtls_ssl_read() again */
- if( ! record_read )
- return( MBEDTLS_ERR_SSL_WANT_READ );
+ return( MBEDTLS_ERR_SSL_WANT_READ );
}
+#if defined(MBEDTLS_SSL_RENEGOTIATION)
else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING )
{
-
if( ssl->conf->renego_max_records >= 0 )
{
if( ++ssl->renego_records_seen > ssl->conf->renego_max_records )
}
}
#endif /* MBEDTLS_SSL_SRV_C && MBEDTLS_SSL_RENEGOTIATION */
-#endif
+#endif /* MBEDTLS_SSL_PROTO_DTLS */
}
n = ( len < ssl->in_msglen )
ssl->in_msglen -= n;
if( ssl->in_msglen == 0 )
- /* all bytes consumed */
+ {
+ /* all bytes consumed */
ssl->in_offt = NULL;
+ ssl->keep_current_message = 0;
+ }
else
+ {
/* more data available */
ssl->in_offt += n;
+ }
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= read" ) );
int ret;
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
size_t max_len = mbedtls_ssl_get_max_frag_len( ssl );
-
+#else
+ size_t max_len = MBEDTLS_SSL_MAX_CONTENT_LEN;
+#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
if( len > max_len )
{
#if defined(MBEDTLS_SSL_PROTO_DTLS)
#endif
len = max_len;
}
-#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */
if( ssl->out_left != 0 )
{
*
* With non-blocking I/O, ssl_write_real() may return WANT_WRITE,
* then the caller will call us again with the same arguments, so
- * remember wether we already did the split or not.
+ * remember whether we already did the split or not.
*/
#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING)
static int ssl_write_split( mbedtls_ssl_context *ssl,
MBEDTLS_MD_SHA256,
MBEDTLS_MD_SHA224,
#endif
-#if defined(MBEDTLS_SHA1_C)
+#if defined(MBEDTLS_SHA1_C) && defined(MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE)
MBEDTLS_MD_SHA1,
#endif
MBEDTLS_MD_NONE
conf->anti_replay = MBEDTLS_SSL_ANTI_REPLAY_ENABLED;
#endif
+#if defined(MBEDTLS_SSL_SRV_C)
+ conf->cert_req_ca_list = MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED;
+#endif
+
#if defined(MBEDTLS_SSL_PROTO_DTLS)
conf->hs_timeout_min = MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MIN;
conf->hs_timeout_max = MBEDTLS_SSL_DTLS_TIMEOUT_DFL_MAX;
#if defined(MBEDTLS_SSL_RENEGOTIATION)
conf->renego_max_records = MBEDTLS_SSL_RENEGO_MAX_RECORDS_DEFAULT;
- memset( conf->renego_period, 0xFF, 7 );
- conf->renego_period[7] = 0x00;
+ memset( conf->renego_period, 0x00, 2 );
+ memset( conf->renego_period + 2, 0xFF, 6 );
#endif
#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_SSL_SRV_C)
if( endpoint == MBEDTLS_SSL_IS_SERVER )
{
- if( ( ret = mbedtls_ssl_conf_dh_param( conf,
- MBEDTLS_DHM_RFC5114_MODP_2048_P,
- MBEDTLS_DHM_RFC5114_MODP_2048_G ) ) != 0 )
+ const unsigned char dhm_p[] =
+ MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN;
+ const unsigned char dhm_g[] =
+ MBEDTLS_DHM_RFC3526_MODP_2048_G_BIN;
+
+ if ( ( ret = mbedtls_ssl_conf_dh_param_bin( conf,
+ dhm_p, sizeof( dhm_p ),
+ dhm_g, sizeof( dhm_g ) ) ) != 0 )
{
return( ret );
}
* Default
*/
default:
- conf->min_major_ver = MBEDTLS_SSL_MAJOR_VERSION_3;
- conf->min_minor_ver = MBEDTLS_SSL_MINOR_VERSION_1; /* TLS 1.0 */
+ conf->min_major_ver = ( MBEDTLS_SSL_MIN_MAJOR_VERSION >
+ MBEDTLS_SSL_MIN_VALID_MAJOR_VERSION ) ?
+ MBEDTLS_SSL_MIN_MAJOR_VERSION :
+ MBEDTLS_SSL_MIN_VALID_MAJOR_VERSION;
+ conf->min_minor_ver = ( MBEDTLS_SSL_MIN_MINOR_VERSION >
+ MBEDTLS_SSL_MIN_VALID_MINOR_VERSION ) ?
+ MBEDTLS_SSL_MIN_MINOR_VERSION :
+ MBEDTLS_SSL_MIN_VALID_MINOR_VERSION;
conf->max_major_ver = MBEDTLS_SSL_MAX_MAJOR_VERSION;
conf->max_minor_ver = MBEDTLS_SSL_MAX_MINOR_VERSION;
return( MBEDTLS_SSL_SIG_ANON );
}
+unsigned char mbedtls_ssl_sig_from_pk_alg( mbedtls_pk_type_t type )
+{
+ switch( type ) {
+ case MBEDTLS_PK_RSA:
+ return( MBEDTLS_SSL_SIG_RSA );
+ case MBEDTLS_PK_ECDSA:
+ case MBEDTLS_PK_ECKEY:
+ return( MBEDTLS_SSL_SIG_ECDSA );
+ default:
+ return( MBEDTLS_SSL_SIG_ANON );
+ }
+}
+
mbedtls_pk_type_t mbedtls_ssl_pk_alg_from_sig( unsigned char sig )
{
switch( sig )
}
#endif /* MBEDTLS_PK_C && ( MBEDTLS_RSA_C || MBEDTLS_ECDSA_C ) */
+#if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \
+ defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED)
+
+/* Find an entry in a signature-hash set matching a given hash algorithm. */
+mbedtls_md_type_t mbedtls_ssl_sig_hash_set_find( mbedtls_ssl_sig_hash_set_t *set,
+ mbedtls_pk_type_t sig_alg )
+{
+ switch( sig_alg )
+ {
+ case MBEDTLS_PK_RSA:
+ return( set->rsa );
+ case MBEDTLS_PK_ECDSA:
+ return( set->ecdsa );
+ default:
+ return( MBEDTLS_MD_NONE );
+ }
+}
+
+/* Add a signature-hash-pair to a signature-hash set */
+void mbedtls_ssl_sig_hash_set_add( mbedtls_ssl_sig_hash_set_t *set,
+ mbedtls_pk_type_t sig_alg,
+ mbedtls_md_type_t md_alg )
+{
+ switch( sig_alg )
+ {
+ case MBEDTLS_PK_RSA:
+ if( set->rsa == MBEDTLS_MD_NONE )
+ set->rsa = md_alg;
+ break;
+
+ case MBEDTLS_PK_ECDSA:
+ if( set->ecdsa == MBEDTLS_MD_NONE )
+ set->ecdsa = md_alg;
+ break;
+
+ default:
+ break;
+ }
+}
+
+/* Allow exactly one hash algorithm for each signature. */
+void mbedtls_ssl_sig_hash_set_const_hash( mbedtls_ssl_sig_hash_set_t *set,
+ mbedtls_md_type_t md_alg )
+{
+ set->rsa = md_alg;
+ set->ecdsa = md_alg;
+}
+
+#endif /* MBEDTLS_SSL_PROTO_TLS1_2) &&
+ MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED */
+
/*
* Convert from MBEDTLS_SSL_HASH_XXX to MBEDTLS_MD_XXX
*/
* and, for DTLS, to/from TLS equivalent.
*
* For TLS this is the identity.
- * For DTLS, use one complement (v -> 255 - v, and then map as follows:
+ * For DTLS, use 1's complement (v -> 255 - v, and then map as follows:
* 1.0 <-> 3.2 (DTLS 1.0 is based on TLS 1.1)
* 1.x <-> 3.x+1 for x != 0 (DTLS 1.2 based on TLS 1.2)
*/
#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1)
#if defined(MBEDTLS_MD5_C)
case MBEDTLS_SSL_HASH_MD5:
- ssl->handshake->calc_verify = ssl_calc_verify_tls;
- break;
+ return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH;
#endif
#if defined(MBEDTLS_SHA1_C)
case MBEDTLS_SSL_HASH_SHA1:
#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */
}
+#if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \
+ defined(MBEDTLS_SSL_PROTO_TLS1_1)
+int mbedtls_ssl_get_key_exchange_md_ssl_tls( mbedtls_ssl_context *ssl,
+ unsigned char *output,
+ unsigned char *data, size_t data_len )
+{
+ int ret = 0;
+ mbedtls_md5_context mbedtls_md5;
+ mbedtls_sha1_context mbedtls_sha1;
+
+ mbedtls_md5_init( &mbedtls_md5 );
+ mbedtls_sha1_init( &mbedtls_sha1 );
+
+ /*
+ * digitally-signed struct {
+ * opaque md5_hash[16];
+ * opaque sha_hash[20];
+ * };
+ *
+ * md5_hash
+ * MD5(ClientHello.random + ServerHello.random
+ * + ServerParams);
+ * sha_hash
+ * SHA(ClientHello.random + ServerHello.random
+ * + ServerParams);
+ */
+ if( ( ret = mbedtls_md5_starts_ret( &mbedtls_md5 ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md5_starts_ret", ret );
+ goto exit;
+ }
+ if( ( ret = mbedtls_md5_update_ret( &mbedtls_md5,
+ ssl->handshake->randbytes, 64 ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md5_update_ret", ret );
+ goto exit;
+ }
+ if( ( ret = mbedtls_md5_update_ret( &mbedtls_md5, data, data_len ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md5_update_ret", ret );
+ goto exit;
+ }
+ if( ( ret = mbedtls_md5_finish_ret( &mbedtls_md5, output ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md5_finish_ret", ret );
+ goto exit;
+ }
+
+ if( ( ret = mbedtls_sha1_starts_ret( &mbedtls_sha1 ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha1_starts_ret", ret );
+ goto exit;
+ }
+ if( ( ret = mbedtls_sha1_update_ret( &mbedtls_sha1,
+ ssl->handshake->randbytes, 64 ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha1_update_ret", ret );
+ goto exit;
+ }
+ if( ( ret = mbedtls_sha1_update_ret( &mbedtls_sha1, data,
+ data_len ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha1_update_ret", ret );
+ goto exit;
+ }
+ if( ( ret = mbedtls_sha1_finish_ret( &mbedtls_sha1,
+ output + 16 ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_sha1_finish_ret", ret );
+ goto exit;
+ }
+
+exit:
+ mbedtls_md5_free( &mbedtls_md5 );
+ mbedtls_sha1_free( &mbedtls_sha1 );
+
+ if( ret != 0 )
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR );
+
+ return( ret );
+
+}
+#endif /* MBEDTLS_SSL_PROTO_SSL3 || MBEDTLS_SSL_PROTO_TLS1 || \
+ MBEDTLS_SSL_PROTO_TLS1_1 */
+
+#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \
+ defined(MBEDTLS_SSL_PROTO_TLS1_2)
+int mbedtls_ssl_get_key_exchange_md_tls1_2( mbedtls_ssl_context *ssl,
+ unsigned char *output,
+ unsigned char *data, size_t data_len,
+ mbedtls_md_type_t md_alg )
+{
+ int ret = 0;
+ mbedtls_md_context_t ctx;
+ const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_alg );
+
+ mbedtls_md_init( &ctx );
+
+ /*
+ * digitally-signed struct {
+ * opaque client_random[32];
+ * opaque server_random[32];
+ * ServerDHParams params;
+ * };
+ */
+ if( ( ret = mbedtls_md_setup( &ctx, md_info, 0 ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_setup", ret );
+ goto exit;
+ }
+ if( ( ret = mbedtls_md_starts( &ctx ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_starts", ret );
+ goto exit;
+ }
+ if( ( ret = mbedtls_md_update( &ctx, ssl->handshake->randbytes, 64 ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_update", ret );
+ goto exit;
+ }
+ if( ( ret = mbedtls_md_update( &ctx, data, data_len ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_update", ret );
+ goto exit;
+ }
+ if( ( ret = mbedtls_md_finish( &ctx, output ) ) != 0 )
+ {
+ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_finish", ret );
+ goto exit;
+ }
+
+exit:
+ mbedtls_md_free( &ctx );
+
+ if( ret != 0 )
+ mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL,
+ MBEDTLS_SSL_ALERT_MSG_INTERNAL_ERROR );
+
+ return( ret );
+}
+#endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \
+ MBEDTLS_SSL_PROTO_TLS1_2 */
+
#endif /* MBEDTLS_SSL_TLS_C */
#if defined(MBEDTLS_THREADING_PTHREAD)
static void threading_mutex_init_pthread( mbedtls_threading_mutex_t *mutex )
{
- if( mutex == NULL || mutex->is_valid )
+ if( mutex == NULL )
return;
mutex->is_valid = pthread_mutex_init( &mutex->mutex, NULL ) == 0;
unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset )
{
- unsigned long delta;
- LARGE_INTEGER offset, hfreq;
struct _hr_time *t = (struct _hr_time *) val;
- QueryPerformanceCounter( &offset );
- QueryPerformanceFrequency( &hfreq );
-
- delta = (unsigned long)( ( 1000 *
- ( offset.QuadPart - t->start.QuadPart ) ) /
- hfreq.QuadPart );
-
if( reset )
+ {
QueryPerformanceCounter( &t->start );
-
- return( delta );
+ return( 0 );
+ }
+ else
+ {
+ unsigned long delta;
+ LARGE_INTEGER now, hfreq;
+ QueryPerformanceCounter( &now );
+ QueryPerformanceFrequency( &hfreq );
+ delta = (unsigned long)( ( now.QuadPart - t->start.QuadPart ) * 1000ul
+ / hfreq.QuadPart );
+ return( delta );
+ }
}
/* It's OK to use a global because alarm() is supposed to be global anyway */
{
DWORD ThreadId;
+ if( seconds == 0 )
+ {
+ /* No need to create a thread for this simple case.
+ * Also, this shorcut is more reliable at least on MinGW32 */
+ mbedtls_timing_alarmed = 1;
+ return;
+ }
+
mbedtls_timing_alarmed = 0;
alarmMs = seconds * 1000;
CloseHandle( CreateThread( NULL, 0, TimerProc, NULL, 0, &ThreadId ) );
unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset )
{
- unsigned long delta;
- struct timeval offset;
struct _hr_time *t = (struct _hr_time *) val;
- gettimeofday( &offset, NULL );
-
if( reset )
{
- t->start.tv_sec = offset.tv_sec;
- t->start.tv_usec = offset.tv_usec;
+ gettimeofday( &t->start, NULL );
return( 0 );
}
-
- delta = ( offset.tv_sec - t->start.tv_sec ) * 1000
- + ( offset.tv_usec - t->start.tv_usec ) / 1000;
-
- return( delta );
+ else
+ {
+ unsigned long delta;
+ struct timeval now;
+ gettimeofday( &now, NULL );
+ delta = ( now.tv_sec - t->start.tv_sec ) * 1000ul
+ + ( now.tv_usec - t->start.tv_usec ) / 1000;
+ return( delta );
+ }
}
static void sighandler( int signum )
mbedtls_timing_alarmed = 0;
signal( SIGALRM, sighandler );
alarm( seconds );
+ if( seconds == 0 )
+ {
+ /* alarm(0) cancelled any previous pending alarm, but the
+ handler won't fire, so raise the flag straight away. */
+ mbedtls_timing_alarmed = 1;
+ }
}
#endif /* _WIN32 && !EFIX64 && !EFI32 */
(void) j;
}
-#define FAIL do \
-{ \
- if( verbose != 0 ) \
- mbedtls_printf( "failed\n" ); \
- \
- return( 1 ); \
-} while( 0 )
+#define FAIL do \
+ { \
+ if( verbose != 0 ) \
+ { \
+ mbedtls_printf( "failed at line %d\n", __LINE__ ); \
+ mbedtls_printf( " cycles=%lu ratio=%lu millisecs=%lu secs=%lu hardfail=%d a=%lu b=%lu\n", \
+ cycles, ratio, millisecs, secs, hardfail, \
+ (unsigned long) a, (unsigned long) b ); \
+ mbedtls_printf( " elapsed(hires)=%lu elapsed(ctx)=%lu status(ctx)=%d\n", \
+ mbedtls_timing_get_timer( &hires, 0 ), \
+ mbedtls_timing_get_timer( &ctx.timer, 0 ), \
+ mbedtls_timing_get_delay( &ctx ) ); \
+ } \
+ return( 1 ); \
+ } while( 0 )
/*
* Checkup routine
*/
int mbedtls_timing_self_test( int verbose )
{
- unsigned long cycles, ratio;
- unsigned long millisecs, secs;
- int hardfail;
+ unsigned long cycles = 0, ratio = 0;
+ unsigned long millisecs = 0, secs = 0;
+ int hardfail = 0;
struct mbedtls_timing_hr_time hires;
- uint32_t a, b;
+ uint32_t a = 0, b = 0;
mbedtls_timing_delay_context ctx;
if( verbose != 0 )
mbedtls_printf( " TIMING tests note: will take some time!\n" );
-
if( verbose != 0 )
mbedtls_printf( " TIMING test #1 (set_alarm / get_timer): " );
- for( secs = 1; secs <= 3; secs++ )
{
+ secs = 1;
+
(void) mbedtls_timing_get_timer( &hires, 1 );
mbedtls_set_alarm( (int) secs );
/* For some reason on Windows it looks like alarm has an extra delay
* (maybe related to creating a new thread). Allow some room here. */
if( millisecs < 800 * secs || millisecs > 1200 * secs + 300 )
- {
- if( verbose != 0 )
- mbedtls_printf( "failed\n" );
-
- return( 1 );
- }
+ FAIL;
}
if( verbose != 0 )
if( verbose != 0 )
mbedtls_printf( " TIMING test #2 (set/get_delay ): " );
- for( a = 200; a <= 400; a += 200 )
{
- for( b = 200; b <= 400; b += 200 )
- {
- mbedtls_timing_set_delay( &ctx, a, a + b );
-
- busy_msleep( a - a / 8 );
- if( mbedtls_timing_get_delay( &ctx ) != 0 )
- FAIL;
+ a = 800;
+ b = 400;
+ mbedtls_timing_set_delay( &ctx, a, a + b ); /* T = 0 */
- busy_msleep( a / 4 );
- if( mbedtls_timing_get_delay( &ctx ) != 1 )
- FAIL;
+ busy_msleep( a - a / 4 ); /* T = a - a/4 */
+ if( mbedtls_timing_get_delay( &ctx ) != 0 )
+ FAIL;
- busy_msleep( b - a / 8 - b / 8 );
- if( mbedtls_timing_get_delay( &ctx ) != 1 )
- FAIL;
+ busy_msleep( a / 4 + b / 4 ); /* T = a + b/4 */
+ if( mbedtls_timing_get_delay( &ctx ) != 1 )
+ FAIL;
- busy_msleep( b / 4 );
- if( mbedtls_timing_get_delay( &ctx ) != 2 )
- FAIL;
- }
+ busy_msleep( b ); /* T = a + b + b/4 */
+ if( mbedtls_timing_get_delay( &ctx ) != 2 )
+ FAIL;
}
mbedtls_timing_set_delay( &ctx, 0, 0 );
* On a 4Ghz 32-bit machine the cycle counter wraps about once per second;
* since the whole test is about 10ms, it shouldn't happen twice in a row.
*/
- hardfail = 0;
hard_test:
if( hardfail > 1 )
#include "mbedtls/version.h"
#include <string.h>
-unsigned int mbedtls_version_get_number()
+unsigned int mbedtls_version_get_number( void )
{
return( MBEDTLS_VERSION_NUMBER );
}
#if defined(MBEDTLS_HAVE_ASM)
"MBEDTLS_HAVE_ASM",
#endif /* MBEDTLS_HAVE_ASM */
+#if defined(MBEDTLS_NO_UDBL_DIVISION)
+ "MBEDTLS_NO_UDBL_DIVISION",
+#endif /* MBEDTLS_NO_UDBL_DIVISION */
#if defined(MBEDTLS_HAVE_SSE2)
"MBEDTLS_HAVE_SSE2",
#endif /* MBEDTLS_HAVE_SSE2 */
#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT)
"MBEDTLS_PLATFORM_NV_SEED_ALT",
#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */
+#if defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT)
+ "MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT",
+#endif /* MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */
#if defined(MBEDTLS_DEPRECATED_WARNING)
"MBEDTLS_DEPRECATED_WARNING",
#endif /* MBEDTLS_DEPRECATED_WARNING */
#if defined(MBEDTLS_CAMELLIA_ALT)
"MBEDTLS_CAMELLIA_ALT",
#endif /* MBEDTLS_CAMELLIA_ALT */
+#if defined(MBEDTLS_CCM_ALT)
+ "MBEDTLS_CCM_ALT",
+#endif /* MBEDTLS_CCM_ALT */
+#if defined(MBEDTLS_CMAC_ALT)
+ "MBEDTLS_CMAC_ALT",
+#endif /* MBEDTLS_CMAC_ALT */
#if defined(MBEDTLS_DES_ALT)
"MBEDTLS_DES_ALT",
#endif /* MBEDTLS_DES_ALT */
-#if defined(MBEDTLS_XTEA_ALT)
- "MBEDTLS_XTEA_ALT",
-#endif /* MBEDTLS_XTEA_ALT */
+#if defined(MBEDTLS_DHM_ALT)
+ "MBEDTLS_DHM_ALT",
+#endif /* MBEDTLS_DHM_ALT */
+#if defined(MBEDTLS_ECJPAKE_ALT)
+ "MBEDTLS_ECJPAKE_ALT",
+#endif /* MBEDTLS_ECJPAKE_ALT */
+#if defined(MBEDTLS_GCM_ALT)
+ "MBEDTLS_GCM_ALT",
+#endif /* MBEDTLS_GCM_ALT */
#if defined(MBEDTLS_MD2_ALT)
"MBEDTLS_MD2_ALT",
#endif /* MBEDTLS_MD2_ALT */
#if defined(MBEDTLS_RIPEMD160_ALT)
"MBEDTLS_RIPEMD160_ALT",
#endif /* MBEDTLS_RIPEMD160_ALT */
+#if defined(MBEDTLS_RSA_ALT)
+ "MBEDTLS_RSA_ALT",
+#endif /* MBEDTLS_RSA_ALT */
#if defined(MBEDTLS_SHA1_ALT)
"MBEDTLS_SHA1_ALT",
#endif /* MBEDTLS_SHA1_ALT */
#if defined(MBEDTLS_SHA512_ALT)
"MBEDTLS_SHA512_ALT",
#endif /* MBEDTLS_SHA512_ALT */
+#if defined(MBEDTLS_XTEA_ALT)
+ "MBEDTLS_XTEA_ALT",
+#endif /* MBEDTLS_XTEA_ALT */
+#if defined(MBEDTLS_ECP_ALT)
+ "MBEDTLS_ECP_ALT",
+#endif /* MBEDTLS_ECP_ALT */
#if defined(MBEDTLS_MD2_PROCESS_ALT)
"MBEDTLS_MD2_PROCESS_ALT",
#endif /* MBEDTLS_MD2_PROCESS_ALT */
#if defined(MBEDTLS_AES_DECRYPT_ALT)
"MBEDTLS_AES_DECRYPT_ALT",
#endif /* MBEDTLS_AES_DECRYPT_ALT */
+#if defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT)
+ "MBEDTLS_ECDH_GEN_PUBLIC_ALT",
+#endif /* MBEDTLS_ECDH_GEN_PUBLIC_ALT */
+#if defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT)
+ "MBEDTLS_ECDH_COMPUTE_SHARED_ALT",
+#endif /* MBEDTLS_ECDH_COMPUTE_SHARED_ALT */
+#if defined(MBEDTLS_ECDSA_VERIFY_ALT)
+ "MBEDTLS_ECDSA_VERIFY_ALT",
+#endif /* MBEDTLS_ECDSA_VERIFY_ALT */
+#if defined(MBEDTLS_ECDSA_SIGN_ALT)
+ "MBEDTLS_ECDSA_SIGN_ALT",
+#endif /* MBEDTLS_ECDSA_SIGN_ALT */
+#if defined(MBEDTLS_ECDSA_GENKEY_ALT)
+ "MBEDTLS_ECDSA_GENKEY_ALT",
+#endif /* MBEDTLS_ECDSA_GENKEY_ALT */
+#if defined(MBEDTLS_ECP_INTERNAL_ALT)
+ "MBEDTLS_ECP_INTERNAL_ALT",
+#endif /* MBEDTLS_ECP_INTERNAL_ALT */
+#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT)
+ "MBEDTLS_ECP_RANDOMIZE_JAC_ALT",
+#endif /* MBEDTLS_ECP_RANDOMIZE_JAC_ALT */
+#if defined(MBEDTLS_ECP_ADD_MIXED_ALT)
+ "MBEDTLS_ECP_ADD_MIXED_ALT",
+#endif /* MBEDTLS_ECP_ADD_MIXED_ALT */
+#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT)
+ "MBEDTLS_ECP_DOUBLE_JAC_ALT",
+#endif /* MBEDTLS_ECP_DOUBLE_JAC_ALT */
+#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT)
+ "MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT",
+#endif /* MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT */
+#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT)
+ "MBEDTLS_ECP_NORMALIZE_JAC_ALT",
+#endif /* MBEDTLS_ECP_NORMALIZE_JAC_ALT */
+#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT)
+ "MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT",
+#endif /* MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT */
+#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT)
+ "MBEDTLS_ECP_RANDOMIZE_MXZ_ALT",
+#endif /* MBEDTLS_ECP_RANDOMIZE_MXZ_ALT */
+#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT)
+ "MBEDTLS_ECP_NORMALIZE_MXZ_ALT",
+#endif /* MBEDTLS_ECP_NORMALIZE_MXZ_ALT */
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
"MBEDTLS_TEST_NULL_ENTROPY",
#endif /* MBEDTLS_TEST_NULL_ENTROPY */
#if defined(MBEDTLS_SSL_TRUNCATED_HMAC)
"MBEDTLS_SSL_TRUNCATED_HMAC",
#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */
+#if defined(MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT)
+ "MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT",
+#endif /* MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT */
#if defined(MBEDTLS_THREADING_ALT)
"MBEDTLS_THREADING_ALT",
#endif /* MBEDTLS_THREADING_ALT */
}
}
-static int x509_parse_int(unsigned char **p, unsigned n, int *res){
+static int x509_parse_int( unsigned char **p, size_t n, int *res )
+{
*res = 0;
- for( ; n > 0; --n ){
- if( ( **p < '0') || ( **p > '9' ) ) return MBEDTLS_ERR_X509_INVALID_DATE;
+
+ for( ; n > 0; --n )
+ {
+ if( ( **p < '0') || ( **p > '9' ) )
+ return ( MBEDTLS_ERR_X509_INVALID_DATE );
+
*res *= 10;
- *res += (*(*p)++ - '0');
+ *res += ( *(*p)++ - '0' );
}
- return 0;
+
+ return( 0 );
}
-static int x509_date_is_valid(const mbedtls_x509_time *time)
+static int x509_date_is_valid(const mbedtls_x509_time *t )
{
int ret = MBEDTLS_ERR_X509_INVALID_DATE;
+ int month_len;
- CHECK_RANGE( 0, 9999, time->year );
- CHECK_RANGE( 0, 23, time->hour );
- CHECK_RANGE( 0, 59, time->min );
- CHECK_RANGE( 0, 59, time->sec );
+ CHECK_RANGE( 0, 9999, t->year );
+ CHECK_RANGE( 0, 23, t->hour );
+ CHECK_RANGE( 0, 59, t->min );
+ CHECK_RANGE( 0, 59, t->sec );
- switch( time->mon )
+ switch( t->mon )
{
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
- CHECK_RANGE( 1, 31, time->day );
+ month_len = 31;
break;
case 4: case 6: case 9: case 11:
- CHECK_RANGE( 1, 30, time->day );
+ month_len = 30;
break;
case 2:
- CHECK_RANGE( 1, 28 + (time->year % 4 == 0), time->day );
+ if( ( !( t->year % 4 ) && t->year % 100 ) ||
+ !( t->year % 400 ) )
+ month_len = 29;
+ else
+ month_len = 28;
break;
default:
return( ret );
}
+ CHECK_RANGE( 1, month_len, t->day );
return( 0 );
}
/*
+ * Parse an ASN1_UTC_TIME (yearlen=2) or ASN1_GENERALIZED_TIME (yearlen=4)
+ * field.
+ */
+static int x509_parse_time( unsigned char **p, size_t len, size_t yearlen,
+ mbedtls_x509_time *tm )
+{
+ int ret;
+
+ /*
+ * Minimum length is 10 or 12 depending on yearlen
+ */
+ if ( len < yearlen + 8 )
+ return ( MBEDTLS_ERR_X509_INVALID_DATE );
+ len -= yearlen + 8;
+
+ /*
+ * Parse year, month, day, hour, minute
+ */
+ CHECK( x509_parse_int( p, yearlen, &tm->year ) );
+ if ( 2 == yearlen )
+ {
+ if ( tm->year < 50 )
+ tm->year += 100;
+
+ tm->year += 1900;
+ }
+
+ CHECK( x509_parse_int( p, 2, &tm->mon ) );
+ CHECK( x509_parse_int( p, 2, &tm->day ) );
+ CHECK( x509_parse_int( p, 2, &tm->hour ) );
+ CHECK( x509_parse_int( p, 2, &tm->min ) );
+
+ /*
+ * Parse seconds if present
+ */
+ if ( len >= 2 )
+ {
+ CHECK( x509_parse_int( p, 2, &tm->sec ) );
+ len -= 2;
+ }
+ else
+ return ( MBEDTLS_ERR_X509_INVALID_DATE );
+
+ /*
+ * Parse trailing 'Z' if present
+ */
+ if ( 1 == len && 'Z' == **p )
+ {
+ (*p)++;
+ len--;
+ }
+
+ /*
+ * We should have parsed all characters at this point
+ */
+ if ( 0 != len )
+ return ( MBEDTLS_ERR_X509_INVALID_DATE );
+
+ CHECK( x509_date_is_valid( tm ) );
+
+ return ( 0 );
+}
+
+/*
* Time ::= CHOICE {
* utcTime UTCTime,
* generalTime GeneralizedTime }
*/
int mbedtls_x509_get_time( unsigned char **p, const unsigned char *end,
- mbedtls_x509_time *time )
+ mbedtls_x509_time *tm )
{
int ret;
- size_t len;
+ size_t len, year_len;
unsigned char tag;
if( ( end - *p ) < 1 )
tag = **p;
if( tag == MBEDTLS_ASN1_UTC_TIME )
- {
- (*p)++;
- ret = mbedtls_asn1_get_len( p, end, &len );
-
- if( ret != 0 )
- return( MBEDTLS_ERR_X509_INVALID_DATE + ret );
-
- CHECK( x509_parse_int( p, 2, &time->year ) );
- CHECK( x509_parse_int( p, 2, &time->mon ) );
- CHECK( x509_parse_int( p, 2, &time->day ) );
- CHECK( x509_parse_int( p, 2, &time->hour ) );
- CHECK( x509_parse_int( p, 2, &time->min ) );
- if( len > 10 )
- CHECK( x509_parse_int( p, 2, &time->sec ) );
- if( len > 12 && *(*p)++ != 'Z' )
- return( MBEDTLS_ERR_X509_INVALID_DATE );
-
- time->year += 100 * ( time->year < 50 );
- time->year += 1900;
-
- CHECK( x509_date_is_valid( time ) );
-
- return( 0 );
- }
+ year_len = 2;
else if( tag == MBEDTLS_ASN1_GENERALIZED_TIME )
- {
- (*p)++;
- ret = mbedtls_asn1_get_len( p, end, &len );
-
- if( ret != 0 )
- return( MBEDTLS_ERR_X509_INVALID_DATE + ret );
-
- CHECK( x509_parse_int( p, 4, &time->year ) );
- CHECK( x509_parse_int( p, 2, &time->mon ) );
- CHECK( x509_parse_int( p, 2, &time->day ) );
- CHECK( x509_parse_int( p, 2, &time->hour ) );
- CHECK( x509_parse_int( p, 2, &time->min ) );
- if( len > 12 )
- CHECK( x509_parse_int( p, 2, &time->sec ) );
- if( len > 14 && *(*p)++ != 'Z' )
- return( MBEDTLS_ERR_X509_INVALID_DATE );
-
- CHECK( x509_date_is_valid( time ) );
-
- return( 0 );
- }
+ year_len = 4;
else
return( MBEDTLS_ERR_X509_INVALID_DATE +
MBEDTLS_ERR_ASN1_UNEXPECTED_TAG );
+
+ (*p)++;
+ ret = mbedtls_asn1_get_len( p, end, &len );
+
+ if( ret != 0 )
+ return( MBEDTLS_ERR_X509_INVALID_DATE + ret );
+
+ return x509_parse_time( p, len, year_len, tm );
}
int mbedtls_x509_get_sig( unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig )
/*
* X.509 Extensions (No parsing of extensions, pointer should
- * be either manually updated or extensions should be parsed!
+ * be either manually updated or extensions should be parsed!)
*/
int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end,
mbedtls_x509_buf *ext, int tag )
*/
int mbedtls_x509_self_test( int verbose )
{
-#if defined(MBEDTLS_CERTS_C) && defined(MBEDTLS_SHA1_C)
+#if defined(MBEDTLS_CERTS_C) && defined(MBEDTLS_SHA256_C)
int ret;
uint32_t flags;
mbedtls_x509_crt cacert;
}
/*
- * X.509 CRL v2 extensions (no extensions parsed yet.)
+ * X.509 CRL v2 extensions
+ *
+ * We currently don't parse any extension's content, but we do check that the
+ * list of extensions is well-formed and abort on critical extensions (that
+ * are unsupported as we don't support any extension so far)
*/
static int x509_get_crl_ext( unsigned char **p,
const unsigned char *end,
mbedtls_x509_buf *ext )
{
int ret;
- size_t len = 0;
- /* Get explicit tag */
- if( ( ret = mbedtls_x509_get_ext( p, end, ext, 0) ) != 0 )
+ /*
+ * crlExtensions [0] EXPLICIT Extensions OPTIONAL
+ * -- if present, version MUST be v2
+ */
+ if( ( ret = mbedtls_x509_get_ext( p, end, ext, 0 ) ) != 0 )
{
if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG )
return( 0 );
while( *p < end )
{
+ /*
+ * Extension ::= SEQUENCE {
+ * extnID OBJECT IDENTIFIER,
+ * critical BOOLEAN DEFAULT FALSE,
+ * extnValue OCTET STRING }
+ */
+ int is_critical = 0;
+ const unsigned char *end_ext_data;
+ size_t len;
+
+ /* Get enclosing sequence tag */
if( ( ret = mbedtls_asn1_get_tag( p, end, &len,
MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 )
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret );
+ end_ext_data = *p + len;
+
+ /* Get OID (currently ignored) */
+ if( ( ret = mbedtls_asn1_get_tag( p, end_ext_data, &len,
+ MBEDTLS_ASN1_OID ) ) != 0 )
+ {
+ return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret );
+ }
*p += len;
+
+ /* Get optional critical */
+ if( ( ret = mbedtls_asn1_get_bool( p, end_ext_data,
+ &is_critical ) ) != 0 &&
+ ( ret != MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) )
+ {
+ return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret );
+ }
+
+ /* Data should be octet string type */
+ if( ( ret = mbedtls_asn1_get_tag( p, end_ext_data, &len,
+ MBEDTLS_ASN1_OCTET_STRING ) ) != 0 )
+ return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret );
+
+ /* Ignore data so far and just check its length */
+ *p += len;
+ if( *p != end_ext_data )
+ return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS +
+ MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
+
+ /* Abort on (unsupported) critical extensions */
+ if( is_critical )
+ return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS +
+ MBEDTLS_ERR_ASN1_UNEXPECTED_TAG );
}
if( *p != end )
{
int ret;
size_t len;
- unsigned char *p, *end;
+ unsigned char *p = NULL, *end = NULL;
mbedtls_x509_buf sig_params1, sig_params2, sig_oid2;
mbedtls_x509_crl *crl = chain;
/*
* Copy raw DER-encoded CRL
*/
- if( ( p = mbedtls_calloc( 1, buflen ) ) == NULL )
+ if( buflen == 0 )
+ return( MBEDTLS_ERR_X509_INVALID_FORMAT );
+
+ p = mbedtls_calloc( 1, buflen );
+ if( p == NULL )
return( MBEDTLS_ERR_X509_ALLOC_FAILED );
memcpy( p, buf, buflen );
return( ret );
}
- crl->version++;
-
- if( crl->version > 2 )
+ if( crl->version < 0 || crl->version > 1 )
{
mbedtls_x509_crl_free( crl );
return( MBEDTLS_ERR_X509_UNKNOWN_VERSION );
}
+ crl->version++;
+
if( ( ret = mbedtls_x509_get_sig_alg( &crl->sig_oid, &sig_params1,
&crl->sig_md, &crl->sig_pk,
&crl->sig_opts ) ) != 0 )
if( ( ret = mbedtls_x509_crl_parse_der( chain,
pem.buf, pem.buflen ) ) != 0 )
{
+ mbedtls_pem_free( &pem );
return( ret );
}
-
- mbedtls_pem_free( &pem );
}
- else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT )
+ else if( is_pem )
{
mbedtls_pem_free( &pem );
return( ret );
}
+
+ mbedtls_pem_free( &pem );
}
/* In the PEM case, buflen is 1 at the end, for the terminated NULL byte.
* And a valid CRL cannot be less than 1 byte anyway. */
*/
const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_default =
{
- /* Hashes from SHA-1 and above */
+#if defined(MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES)
+ /* Allow SHA-1 (weak, but still safe in controlled environments) */
MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA1 ) |
- MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_RIPEMD160 ) |
+#endif
+ /* Only SHA-2 hashes */
MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA224 ) |
MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA256 ) |
MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA384 ) |
MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA256 ) |
MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA384 ),
/* Only ECDSA */
- MBEDTLS_X509_ID_FLAG( MBEDTLS_PK_ECDSA ),
+ MBEDTLS_X509_ID_FLAG( MBEDTLS_PK_ECDSA ) |
+ MBEDTLS_X509_ID_FLAG( MBEDTLS_PK_ECKEY ),
#if defined(MBEDTLS_ECP_C)
/* Only NIST P-256 and P-384 */
MBEDTLS_X509_ID_FLAG( MBEDTLS_ECP_DP_SECP256R1 ) |
if( ( ret = mbedtls_asn1_get_len( p, end, &tag_len ) ) != 0 )
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret );
- if( ( tag & MBEDTLS_ASN1_CONTEXT_SPECIFIC ) != MBEDTLS_ASN1_CONTEXT_SPECIFIC )
+ if( ( tag & MBEDTLS_ASN1_TAG_CLASS_MASK ) !=
+ MBEDTLS_ASN1_CONTEXT_SPECIFIC )
+ {
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS +
MBEDTLS_ERR_ASN1_UNEXPECTED_TAG );
+ }
/* Skip everything but DNS name */
if( tag != ( MBEDTLS_ASN1_CONTEXT_SPECIFIC | 2 ) )
return( ret );
}
- crt->version++;
-
- if( crt->version > 3 )
+ if( crt->version < 0 || crt->version > 2 )
{
mbedtls_x509_crt_free( crt );
return( MBEDTLS_ERR_X509_UNKNOWN_VERSION );
}
+ crt->version++;
+
if( ( ret = mbedtls_x509_get_sig_alg( &crt->sig_oid, &sig_params1,
&crt->sig_md, &crt->sig_pk,
&crt->sig_opts ) ) != 0 )
*/
int mbedtls_x509_crt_parse( mbedtls_x509_crt *chain, const unsigned char *buf, size_t buflen )
{
- int success = 0, first_error = 0, total_failed = 0;
#if defined(MBEDTLS_PEM_PARSE_C)
+ int success = 0, first_error = 0, total_failed = 0;
int buf_format = MBEDTLS_X509_FORMAT_DER;
#endif
p = filename + len;
filename[len++] = '*';
- w_ret = MultiByteToWideChar( CP_ACP, 0, filename, len, szDir,
+ w_ret = MultiByteToWideChar( CP_ACP, 0, filename, (int)len, szDir,
MAX_PATH - 3 );
if( w_ret == 0 )
return( MBEDTLS_ERR_X509_BAD_INPUT_DATA );
p, (int) len - 1,
NULL, NULL );
if( w_ret == 0 )
- return( MBEDTLS_ERR_X509_FILE_IO_ERROR );
+ {
+ ret = MBEDTLS_ERR_X509_FILE_IO_ERROR;
+ goto cleanup;
+ }
w_ret = mbedtls_x509_crt_parse_file( chain, filename );
if( w_ret < 0 )
if( GetLastError() != ERROR_NO_MORE_FILES )
ret = MBEDTLS_ERR_X509_FILE_IO_ERROR;
+cleanup:
FindClose( hFind );
#else /* _WIN32 */
int t_ret;
if( dir == NULL )
return( MBEDTLS_ERR_X509_FILE_IO_ERROR );
-#if defined(MBEDTLS_THREADING_PTHREAD)
+#if defined(MBEDTLS_THREADING_C)
if( ( ret = mbedtls_mutex_lock( &mbedtls_threading_readdir_mutex ) ) != 0 )
{
closedir( dir );
return( ret );
}
-#endif
+#endif /* MBEDTLS_THREADING_C */
while( ( entry = readdir( dir ) ) != NULL )
{
cleanup:
closedir( dir );
-#if defined(MBEDTLS_THREADING_PTHREAD)
+#if defined(MBEDTLS_THREADING_C)
if( mbedtls_mutex_unlock( &mbedtls_threading_readdir_mutex ) != 0 )
ret = MBEDTLS_ERR_THREADING_MUTEX_ERROR;
-#endif
+#endif /* MBEDTLS_THREADING_C */
#endif /* _WIN32 */
int check_path_cnt;
unsigned char hash[MBEDTLS_MD_MAX_SIZE];
const mbedtls_md_info_t *md_info;
+ mbedtls_x509_crt *future_past_ca = NULL;
if( mbedtls_x509_time_is_past( &child->valid_to ) )
*flags |= MBEDTLS_X509_BADCERT_EXPIRED;
continue;
}
- if( mbedtls_x509_time_is_past( &trust_ca->valid_to ) )
+ if( mbedtls_pk_verify_ext( child->sig_pk, child->sig_opts, &trust_ca->pk,
+ child->sig_md, hash, mbedtls_md_get_size( md_info ),
+ child->sig.p, child->sig.len ) != 0 )
{
continue;
}
- if( mbedtls_x509_time_is_future( &trust_ca->valid_from ) )
+ if( mbedtls_x509_time_is_past( &trust_ca->valid_to ) ||
+ mbedtls_x509_time_is_future( &trust_ca->valid_from ) )
{
- continue;
- }
+ if ( future_past_ca == NULL )
+ future_past_ca = trust_ca;
- if( mbedtls_pk_verify_ext( child->sig_pk, child->sig_opts, &trust_ca->pk,
- child->sig_md, hash, mbedtls_md_get_size( md_info ),
- child->sig.p, child->sig.len ) != 0 )
- {
continue;
}
+ break;
+ }
+
+ if( trust_ca != NULL || ( trust_ca = future_past_ca ) != NULL )
+ {
/*
* Top of chain is signed by a trusted CA
*/
if( x509_profile_check_key( profile, child->sig_pk, &trust_ca->pk ) != 0 )
*flags |= MBEDTLS_X509_BADCERT_BAD_KEY;
-
- break;
}
/*
((void) ca_crl);
#endif
+ if( mbedtls_x509_time_is_past( &trust_ca->valid_to ) )
+ ca_flags |= MBEDTLS_X509_BADCERT_EXPIRED;
+
+ if( mbedtls_x509_time_is_future( &trust_ca->valid_from ) )
+ ca_flags |= MBEDTLS_X509_BADCERT_FUTURE;
+
if( NULL != f_vrfy )
{
if( ( ret = f_vrfy( p_vrfy, trust_ca, path_cnt + 1,
/* path_cnt is 0 for the first intermediate CA */
if( 1 + path_cnt > MBEDTLS_X509_MAX_INTERMEDIATE_CA )
{
- *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED;
- return( MBEDTLS_ERR_X509_CERT_VERIFY_FAILED );
+ /* return immediately as the goal is to avoid unbounded recursion */
+ return( MBEDTLS_ERR_X509_FATAL_ERROR );
}
if( mbedtls_x509_time_is_past( &child->valid_to ) )
mbedtls_x509_sequence *cur = NULL;
mbedtls_pk_type_t pk_type;
- if( profile == NULL )
- return( MBEDTLS_ERR_X509_BAD_INPUT_DATA );
-
*flags = 0;
+ if( profile == NULL )
+ {
+ ret = MBEDTLS_ERR_X509_BAD_INPUT_DATA;
+ goto exit;
+ }
+
if( cn != NULL )
{
name = &crt->subject;
ret = x509_crt_verify_top( crt, parent, ca_crl, profile,
pathlen, selfsigned, flags, f_vrfy, p_vrfy );
if( ret != 0 )
- return( ret );
+ goto exit;
}
else
{
ret = x509_crt_verify_child( crt, parent, trust_ca, ca_crl, profile,
pathlen, selfsigned, flags, f_vrfy, p_vrfy );
if( ret != 0 )
- return( ret );
+ goto exit;
}
else
{
ret = x509_crt_verify_top( crt, trust_ca, ca_crl, profile,
pathlen, selfsigned, flags, f_vrfy, p_vrfy );
if( ret != 0 )
- return( ret );
+ goto exit;
}
}
+exit:
+ /* prevent misuse of the vrfy callback - VERIFY_FAILED would be ignored by
+ * the SSL module for authmode optional, but non-zero return from the
+ * callback means a fatal error so it shouldn't be ignored */
+ if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED )
+ ret = MBEDTLS_ERR_X509_FATAL_ERROR;
+
+ if( ret != 0 )
+ {
+ *flags = (uint32_t) -1;
+ return( ret );
+ }
+
if( *flags != 0 )
return( MBEDTLS_ERR_X509_CERT_VERIFY_FAILED );
return( ret );
}
- csr->version++;
-
- if( csr->version != 1 )
+ if( csr->version != 0 )
{
mbedtls_x509_csr_free( csr );
return( MBEDTLS_ERR_X509_UNKNOWN_VERSION );
}
+ csr->version++;
+
/*
* subject Name
*/
*/
int mbedtls_x509_csr_parse( mbedtls_x509_csr *csr, const unsigned char *buf, size_t buflen )
{
- int ret;
#if defined(MBEDTLS_PEM_PARSE_C)
+ int ret;
size_t use_len;
mbedtls_pem_context pem;
#endif
void mbedtls_x509write_crt_init( mbedtls_x509write_cert *ctx )
{
- memset( ctx, 0, sizeof(mbedtls_x509write_cert) );
+ memset( ctx, 0, sizeof( mbedtls_x509write_cert ) );
mbedtls_mpi_init( &ctx->serial );
ctx->version = MBEDTLS_X509_CRT_VERSION_3;
mbedtls_asn1_free_named_data_list( &ctx->issuer );
mbedtls_asn1_free_named_data_list( &ctx->extensions );
- mbedtls_zeroize( ctx, sizeof(mbedtls_x509write_cert) );
+ mbedtls_zeroize( ctx, sizeof( mbedtls_x509write_cert ) );
}
void mbedtls_x509write_crt_set_version( mbedtls_x509write_cert *ctx, int version )
memset( buf, 0, sizeof(buf) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_pk_write_pubkey( &c, buf, ctx->subject_key ) );
- mbedtls_sha1( buf + sizeof(buf) - len, len, buf + sizeof(buf) - 20 );
- c = buf + sizeof(buf) - 20;
+ ret = mbedtls_sha1_ret( buf + sizeof( buf ) - len, len,
+ buf + sizeof( buf ) - 20 );
+ if( ret != 0 )
+ return( ret );
+ c = buf + sizeof( buf ) - 20;
len = 20;
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) );
{
int ret;
unsigned char buf[MBEDTLS_MPI_MAX_SIZE * 2 + 20]; /* tag, length + 2xMPI */
- unsigned char *c = buf + sizeof(buf);
+ unsigned char *c = buf + sizeof( buf );
size_t len = 0;
memset( buf, 0, sizeof(buf) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_pk_write_pubkey( &c, buf, ctx->issuer_key ) );
- mbedtls_sha1( buf + sizeof(buf) - len, len, buf + sizeof(buf) - 20 );
- c = buf + sizeof(buf) - 20;
+ ret = mbedtls_sha1_ret( buf + sizeof( buf ) - len, len,
+ buf + sizeof( buf ) - 20 );
+ if( ret != 0 )
+ return( ret );
+ c = buf + sizeof( buf ) - 20;
len = 20;
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) );
return mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_AUTHORITY_KEY_IDENTIFIER,
MBEDTLS_OID_SIZE( MBEDTLS_OID_AUTHORITY_KEY_IDENTIFIER ),
- 0, buf + sizeof(buf) - len, len );
+ 0, buf + sizeof( buf ) - len, len );
}
#endif /* MBEDTLS_SHA1_C */
}
static int x509_write_time( unsigned char **p, unsigned char *start,
- const char *time, size_t size )
+ const char *t, size_t size )
{
int ret;
size_t len = 0;
/*
* write MBEDTLS_ASN1_UTC_TIME if year < 2050 (2 bytes shorter)
*/
- if( time[0] == '2' && time[1] == '0' && time [2] < '5' )
+ if( t[0] == '2' && t[1] == '0' && t[2] < '5' )
{
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start,
- (const unsigned char *) time + 2,
+ (const unsigned char *) t + 2,
size - 2 ) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_UTC_TIME ) );
else
{
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start,
- (const unsigned char *) time,
+ (const unsigned char *) t,
size ) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_GENERALIZED_TIME ) );
c = tmp_buf + sizeof( tmp_buf );
/* Signature algorithm needed in TBS, and later for actual signature */
- pk_alg = mbedtls_pk_get_type( ctx->issuer_key );
- if( pk_alg == MBEDTLS_PK_ECKEY )
+
+ /* There's no direct way of extracting a signature algorithm
+ * (represented as an element of mbedtls_pk_type_t) from a PK instance. */
+ if( mbedtls_pk_can_do( ctx->issuer_key, MBEDTLS_PK_RSA ) )
+ pk_alg = MBEDTLS_PK_RSA;
+ else if( mbedtls_pk_can_do( ctx->issuer_key, MBEDTLS_PK_ECDSA ) )
pk_alg = MBEDTLS_PK_ECDSA;
+ else
+ return( MBEDTLS_ERR_X509_INVALID_ALG );
if( ( ret = mbedtls_oid_get_oid_by_sig_alg( pk_alg, ctx->md_alg,
- &sig_oid, &sig_oid_len ) ) != 0 )
+ &sig_oid, &sig_oid_len ) ) != 0 )
{
return( ret );
}
/*
* Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension
*/
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_extensions( &c, tmp_buf, ctx->extensions ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED |
- MBEDTLS_ASN1_SEQUENCE ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONTEXT_SPECIFIC |
- MBEDTLS_ASN1_CONSTRUCTED | 3 ) );
+
+ /* Only for v3 */
+ if( ctx->version == MBEDTLS_X509_CRT_VERSION_3 )
+ {
+ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_extensions( &c, tmp_buf, ctx->extensions ) );
+ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) );
+ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED |
+ MBEDTLS_ASN1_SEQUENCE ) );
+ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) );
+ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONTEXT_SPECIFIC |
+ MBEDTLS_ASN1_CONSTRUCTED | 3 ) );
+ }
/*
* SubjectPublicKeyInfo
/*
* Version ::= INTEGER { v1(0), v2(1), v3(2) }
*/
- sub_len = 0;
- MBEDTLS_ASN1_CHK_ADD( sub_len, mbedtls_asn1_write_int( &c, tmp_buf, ctx->version ) );
- len += sub_len;
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, sub_len ) );
- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONTEXT_SPECIFIC |
- MBEDTLS_ASN1_CONSTRUCTED | 0 ) );
+
+ /* Can be omitted for v1 */
+ if( ctx->version != MBEDTLS_X509_CRT_VERSION_1 )
+ {
+ sub_len = 0;
+ MBEDTLS_ASN1_CHK_ADD( sub_len, mbedtls_asn1_write_int( &c, tmp_buf, ctx->version ) );
+ len += sub_len;
+ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, sub_len ) );
+ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONTEXT_SPECIFIC |
+ MBEDTLS_ASN1_CONSTRUCTED | 0 ) );
+ }
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) );
MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED |
- MBEDTLS_ASN1_SEQUENCE ) );
+ MBEDTLS_ASN1_SEQUENCE ) );
/*
* Make signature
*/
- mbedtls_md( mbedtls_md_info_from_type( ctx->md_alg ), c, len, hash );
+ if( ( ret = mbedtls_md( mbedtls_md_info_from_type( ctx->md_alg ), c,
+ len, hash ) ) != 0 )
+ {
+ return( ret );
+ }
if( ( ret = mbedtls_pk_sign( ctx->issuer_key, ctx->md_alg, hash, 0, sig, &sig_len,
f_rng, p_rng ) ) != 0 )
void mbedtls_x509write_csr_init( mbedtls_x509write_csr *ctx )
{
- memset( ctx, 0, sizeof(mbedtls_x509write_csr) );
+ memset( ctx, 0, sizeof( mbedtls_x509write_csr ) );
}
void mbedtls_x509write_csr_free( mbedtls_x509write_csr *ctx )
mbedtls_asn1_free_named_data_list( &ctx->subject );
mbedtls_asn1_free_named_data_list( &ctx->extensions );
- mbedtls_zeroize( ctx, sizeof(mbedtls_x509write_csr) );
+ mbedtls_zeroize( ctx, sizeof( mbedtls_x509write_csr ) );
}
void mbedtls_x509write_csr_set_md_alg( mbedtls_x509write_csr *ctx, mbedtls_md_type_t md_alg )
*/
mbedtls_md( mbedtls_md_info_from_type( ctx->md_alg ), c, len, hash );
- pk_alg = mbedtls_pk_get_type( ctx->key );
- if( pk_alg == MBEDTLS_PK_ECKEY )
+ if( ( ret = mbedtls_pk_sign( ctx->key, ctx->md_alg, hash, 0, sig, &sig_len,
+ f_rng, p_rng ) ) != 0 )
+ {
+ return( ret );
+ }
+
+ if( mbedtls_pk_can_do( ctx->key, MBEDTLS_PK_RSA ) )
+ pk_alg = MBEDTLS_PK_RSA;
+ else if( mbedtls_pk_can_do( ctx->key, MBEDTLS_PK_ECDSA ) )
pk_alg = MBEDTLS_PK_ECDSA;
+ else
+ return( MBEDTLS_ERR_X509_INVALID_ALG );
- if( ( ret = mbedtls_pk_sign( ctx->key, ctx->md_alg, hash, 0, sig, &sig_len,
- f_rng, p_rng ) ) != 0 ||
- ( ret = mbedtls_oid_get_oid_by_sig_alg( pk_alg, ctx->md_alg,
- &sig_oid, &sig_oid_len ) ) != 0 )
+ if( ( ret = mbedtls_oid_get_oid_by_sig_alg( pk_alg, ctx->md_alg,
+ &sig_oid, &sig_oid_len ) ) != 0 )
{
return( ret );
}
FILE *fkey, *fin = NULL, *fout = NULL;
char *p;
+
unsigned char IV[16];
+ unsigned char tmp[16];
unsigned char key[512];
unsigned char digest[32];
unsigned char buffer[1024];
}
mode = atoi( argv[1] );
- memset(IV, 0, sizeof(IV));
- memset(key, 0, sizeof(key));
- memset(digest, 0, sizeof(digest));
- memset(buffer, 0, sizeof(buffer));
+ memset( IV, 0, sizeof( IV ) );
+ memset( key, 0, sizeof( key ) );
+ memset( digest, 0, sizeof( digest ) );
+ memset( buffer, 0, sizeof( buffer ) );
if( mode != MODE_ENCRYPT && mode != MODE_DECRYPT )
{
}
/*
- * Read the secret key and clean the command line.
+ * Read the secret key from file or command line
*/
if( ( fkey = fopen( argv[4], "rb" ) ) != NULL )
{
}
}
- memset( argv[4], 0, strlen( argv[4] ) );
-
#if defined(_WIN32_WCE)
filesize = fseek( fin, 0L, SEEK_END );
#else
mbedtls_md_finish( &sha_ctx, digest );
}
- memset( key, 0, sizeof( key ) );
mbedtls_aes_setkey_enc( &aes_ctx, digest, 256 );
mbedtls_md_hmac_starts( &sha_ctx, digest, 32 );
if( mode == MODE_DECRYPT )
{
- unsigned char tmp[16];
-
/*
* The encrypted file must be structured as follows:
*
mbedtls_md_finish( &sha_ctx, digest );
}
- memset( key, 0, sizeof( key ) );
mbedtls_aes_setkey_dec( &aes_ctx, digest, 256 );
mbedtls_md_hmac_starts( &sha_ctx, digest, 32 );
if( fout )
fclose( fout );
+ /* Zeroize all command line arguments to also cover
+ the case when the user has missed or reordered some,
+ in which case the key might not be in argv[4]. */
+ for( i = 0; i < (unsigned int) argc; i++ )
+ memset( argv[i], 0, strlen( argv[i] ) );
+
+ memset( IV, 0, sizeof( IV ) );
+ memset( key, 0, sizeof( key ) );
+ memset( tmp, 0, sizeof( tmp ) );
memset( buffer, 0, sizeof( buffer ) );
memset( digest, 0, sizeof( digest ) );
}
/*
- * Read the secret key and clean the command line.
+ * Read the secret key from file or command line
*/
if( ( fkey = fopen( argv[6], "rb" ) ) != NULL )
{
}
}
- memset( argv[6], 0, strlen( argv[6] ) );
-
#if defined(_WIN32_WCE)
filesize = fseek( fin, 0L, SEEK_END );
#else
}
- memset( key, 0, sizeof( key ) );
-
if( mbedtls_cipher_setkey( &cipher_ctx, digest, cipher_info->key_bitlen,
MBEDTLS_ENCRYPT ) != 0 )
{
mbedtls_md_finish( &md_ctx, digest );
}
- memset( key, 0, sizeof( key ) );
-
if( mbedtls_cipher_setkey( &cipher_ctx, digest, cipher_info->key_bitlen,
MBEDTLS_DECRYPT ) != 0 )
{
if( fout )
fclose( fout );
+ /* Zeroize all command line arguments to also cover
+ the case when the user has missed or reordered some,
+ in which case the key might not be in argv[6]. */
+ for( i = 0; i < argc; i++ )
+ memset( argv[i], 0, strlen( argv[i] ) );
+
+ memset( IV, 0, sizeof( IV ) );
+ memset( key, 0, sizeof( key ) );
memset( buffer, 0, sizeof( buffer ) );
+ memset( output, 0, sizeof( output ) );
memset( digest, 0, sizeof( digest ) );
mbedtls_cipher_free( &cipher_ctx );
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
+#include <stdlib.h>
#include <stdio.h>
-#define mbedtls_printf printf
+#define mbedtls_printf printf
+#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
+#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif
#if defined(MBEDTLS_MD5_C)
#else
int main( void )
{
- int i;
+ int i, ret;
unsigned char digest[16];
char str[] = "Hello, world!";
mbedtls_printf( "\n MD5('%s') = ", str );
- mbedtls_md5( (unsigned char *) str, 13, digest );
+ if( ( ret = mbedtls_md5_ret( (unsigned char *) str, 13, digest ) ) != 0 )
+ return( MBEDTLS_EXIT_FAILURE );
for( i = 0; i < 16; i++ )
mbedtls_printf( "%02x", digest[i] );
fflush( stdout ); getchar();
#endif
- return( 0 );
+ return( MBEDTLS_EXIT_SUCCESS );
}
#endif /* MBEDTLS_MD5_C */
goto exit;
}
- mbedtls_sha1( buf, (int)( p - 2 - buf ), hash );
+ if( ( ret = mbedtls_sha1_ret( buf, (int)( p - 2 - buf ), hash ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! mbedtls_sha1_ret returned %d\n\n", ret );
+ goto exit;
+ }
if( ( ret = mbedtls_rsa_pkcs1_verify( &rsa, NULL, NULL, MBEDTLS_RSA_PUBLIC,
MBEDTLS_MD_SHA256, 0, hash, p ) ) != 0 )
mbedtls_dhm_context dhm;
mbedtls_aes_context aes;
+ mbedtls_mpi N, P, Q, D, E;
+
mbedtls_net_init( &listen_fd );
mbedtls_net_init( &client_fd );
mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_SHA256 );
mbedtls_aes_init( &aes );
mbedtls_ctr_drbg_init( &ctr_drbg );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E );
+
/*
* 1. Setup the RNG
*/
mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
- if( ( ret = mbedtls_mpi_read_file( &rsa.N , 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.E , 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.D , 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.P , 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.Q , 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.DP, 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.DQ, 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.QP, 16, f ) ) != 0 )
+ if( ( ret = mbedtls_mpi_read_file( &N , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &E , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &D , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &P , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &Q , 16, f ) ) != 0 )
{
- mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n", ret );
+ mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n",
+ ret );
fclose( f );
goto exit;
}
+ fclose( f );
- rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3;
+ if( ( ret = mbedtls_rsa_import( &rsa, &N, &P, &Q, &D, &E ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! mbedtls_rsa_import returned %d\n\n",
+ ret );
+ goto exit;
+ }
- fclose( f );
+ if( ( ret = mbedtls_rsa_complete( &rsa ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! mbedtls_rsa_complete returned %d\n\n",
+ ret );
+ goto exit;
+ }
/*
* 2b. Get the DHM modulus and generator
/*
* 5. Sign the parameters and send them
*/
- mbedtls_sha1( buf, n, hash );
+ if( ( ret = mbedtls_sha1_ret( buf, n, hash ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! mbedtls_sha1_ret returned %d\n\n", ret );
+ goto exit;
+ }
buf[n ] = (unsigned char)( rsa.len >> 8 );
buf[n + 1] = (unsigned char)( rsa.len );
memset( buf, 0, sizeof( buf ) );
+ n = dhm.len;
if( ( ret = mbedtls_net_recv( &client_fd, buf, n ) ) != (int) n )
{
mbedtls_printf( " failed\n ! mbedtls_net_recv returned %d\n\n", ret );
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E );
+
mbedtls_net_free( &client_fd );
mbedtls_net_free( &listen_fd );
mbedtls_printf( " ok\n" );
/*
- * Verification: are the computed secret equal?
+ * Verification: are the computed secrets equal?
*/
mbedtls_printf( " . Checking if both computed secrets are equal..." );
fflush( stdout );
#include "mbedtls/entropy.h"
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/ecdsa.h"
+#include "mbedtls/sha256.h"
#include <string.h>
#endif
mbedtls_ecdsa_context ctx_sign, ctx_verify;
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
- unsigned char hash[] = "This should be the hash of a message.";
- unsigned char sig[512];
+ unsigned char message[100];
+ unsigned char hash[32];
+ unsigned char sig[MBEDTLS_ECDSA_MAX_LEN];
size_t sig_len;
const char *pers = "ecdsa";
((void) argv);
mbedtls_ecdsa_init( &ctx_verify );
mbedtls_ctr_drbg_init( &ctr_drbg );
- memset(sig, 0, sizeof( sig ) );
+ memset( sig, 0, sizeof( sig ) );
+ memset( message, 0x25, sizeof( message ) );
ret = 1;
if( argc != 1 )
dump_pubkey( " + Public key: ", &ctx_sign );
/*
- * Sign some message hash
+ * Compute message hash
*/
- mbedtls_printf( " . Signing message..." );
+ mbedtls_printf( " . Computing message hash..." );
+ fflush( stdout );
+
+ if( ( ret = mbedtls_sha256_ret( message, sizeof( message ), hash, 0 ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! mbedtls_sha256_ret returned %d\n", ret );
+ goto exit;
+ }
+
+ mbedtls_printf( " ok\n" );
+
+ dump_buf( " + Hash: ", hash, sizeof( hash ) );
+
+ /*
+ * Sign message hash
+ */
+ mbedtls_printf( " . Signing message hash..." );
fflush( stdout );
if( ( ret = mbedtls_ecdsa_write_signature( &ctx_sign, MBEDTLS_MD_SHA256,
}
mbedtls_printf( " ok (signature length = %u)\n", (unsigned int) sig_len );
- dump_buf( " + Hash: ", hash, sizeof hash );
dump_buf( " + Signature: ", sig, sig_len );
/*
char buf[1024];
int i;
char *p, *q;
+ mbedtls_mpi N, P, Q, D, E, DP, DQ, QP;
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
const char *pers = "gen_key";
/*
* Set to sane values
*/
+
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP );
+ mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );
+
mbedtls_pk_init( &key );
mbedtls_ctr_drbg_init( &ctr_drbg );
memset( buf, 0, sizeof( buf ) );
if( opt.type == MBEDTLS_PK_RSA )
{
ret = mbedtls_rsa_gen_key( mbedtls_pk_rsa( key ), mbedtls_ctr_drbg_random, &ctr_drbg,
- opt.rsa_keysize, 65537 );
+ opt.rsa_keysize, 65537 );
if( ret != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_rsa_gen_key returned -0x%04x", -ret );
if( opt.type == MBEDTLS_PK_ECKEY )
{
ret = mbedtls_ecp_gen_key( opt.ec_curve, mbedtls_pk_ec( key ),
- mbedtls_ctr_drbg_random, &ctr_drbg );
+ mbedtls_ctr_drbg_random, &ctr_drbg );
if( ret != 0 )
{
- mbedtls_printf( " failed\n ! mbedtls_rsa_gen_key returned -0x%04x", -ret );
+ mbedtls_printf( " failed\n ! mbedtls_ecp_gen_key returned -0x%04x", -ret );
goto exit;
}
}
if( mbedtls_pk_get_type( &key ) == MBEDTLS_PK_RSA )
{
mbedtls_rsa_context *rsa = mbedtls_pk_rsa( key );
- mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL );
- mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL );
- mbedtls_mpi_write_file( "D: ", &rsa->D, 16, NULL );
- mbedtls_mpi_write_file( "P: ", &rsa->P, 16, NULL );
- mbedtls_mpi_write_file( "Q: ", &rsa->Q, 16, NULL );
- mbedtls_mpi_write_file( "DP: ", &rsa->DP, 16, NULL );
- mbedtls_mpi_write_file( "DQ: ", &rsa->DQ, 16, NULL );
- mbedtls_mpi_write_file( "QP: ", &rsa->QP, 16, NULL );
+
+ if( ( ret = mbedtls_rsa_export ( rsa, &N, &P, &Q, &D, &E ) ) != 0 ||
+ ( ret = mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
+ goto exit;
+ }
+
+ mbedtls_mpi_write_file( "N: ", &N, 16, NULL );
+ mbedtls_mpi_write_file( "E: ", &E, 16, NULL );
+ mbedtls_mpi_write_file( "D: ", &D, 16, NULL );
+ mbedtls_mpi_write_file( "P: ", &P, 16, NULL );
+ mbedtls_mpi_write_file( "Q: ", &Q, 16, NULL );
+ mbedtls_mpi_write_file( "DP: ", &DP, 16, NULL );
+ mbedtls_mpi_write_file( "DQ: ", &DQ, 16, NULL );
+ mbedtls_mpi_write_file( "QP: ", &QP, 16, NULL );
}
else
#endif
#endif
}
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
+ mbedtls_mpi_free( &DQ ); mbedtls_mpi_free( &QP );
+
mbedtls_pk_free( &key );
mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy );
}
#endif /* MBEDTLS_PK_WRITE_C && MBEDTLS_PEM_WRITE_C && MBEDTLS_FS_IO &&
* MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */
-
int main( int argc, char *argv[] )
{
int ret = 0;
- mbedtls_pk_context pk;
char buf[1024];
int i;
char *p, *q;
+ mbedtls_pk_context pk;
+ mbedtls_mpi N, P, Q, D, E, DP, DQ, QP;
+
/*
* Set to sane values
*/
mbedtls_pk_init( &pk );
memset( buf, 0, sizeof(buf) );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP );
+ mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );
+
if( argc == 0 )
{
usage:
if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_RSA )
{
mbedtls_rsa_context *rsa = mbedtls_pk_rsa( pk );
- mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL );
- mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL );
- mbedtls_mpi_write_file( "D: ", &rsa->D, 16, NULL );
- mbedtls_mpi_write_file( "P: ", &rsa->P, 16, NULL );
- mbedtls_mpi_write_file( "Q: ", &rsa->Q, 16, NULL );
- mbedtls_mpi_write_file( "DP: ", &rsa->DP, 16, NULL );
- mbedtls_mpi_write_file( "DQ: ", &rsa->DQ, 16, NULL );
- mbedtls_mpi_write_file( "QP: ", &rsa->QP, 16, NULL );
+
+ if( ( ret = mbedtls_rsa_export ( rsa, &N, &P, &Q, &D, &E ) ) != 0 ||
+ ( ret = mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
+ goto exit;
+ }
+
+ mbedtls_mpi_write_file( "N: ", &N, 16, NULL );
+ mbedtls_mpi_write_file( "E: ", &E, 16, NULL );
+ mbedtls_mpi_write_file( "D: ", &D, 16, NULL );
+ mbedtls_mpi_write_file( "P: ", &P, 16, NULL );
+ mbedtls_mpi_write_file( "Q: ", &Q, 16, NULL );
+ mbedtls_mpi_write_file( "DP: ", &DP, 16, NULL );
+ mbedtls_mpi_write_file( "DQ: ", &DQ, 16, NULL );
+ mbedtls_mpi_write_file( "QP: ", &QP, 16, NULL );
}
else
#endif
if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_RSA )
{
mbedtls_rsa_context *rsa = mbedtls_pk_rsa( pk );
- mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL );
- mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL );
+
+ if( ( ret = mbedtls_rsa_export( rsa, &N, NULL, NULL,
+ NULL, &E ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
+ goto exit;
+ }
+ mbedtls_mpi_write_file( "N: ", &N, 16, NULL );
+ mbedtls_mpi_write_file( "E: ", &E, 16, NULL );
}
else
#endif
exit:
#if defined(MBEDTLS_ERROR_C)
- mbedtls_strerror( ret, buf, sizeof(buf) );
- mbedtls_printf( " ! Last error was: %s\n", buf );
+ if( ret != 0 )
+ {
+ mbedtls_strerror( ret, buf, sizeof(buf) );
+ mbedtls_printf( " ! Last error was: %s\n", buf );
+ }
#endif
mbedtls_pk_free( &pk );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
+ mbedtls_mpi_free( &DQ ); mbedtls_mpi_free( &QP );
#if defined(_WIN32)
mbedtls_printf( " + Press Enter to exit this program.\n" );
#define OUTPUT_FORMAT_DER 1
#define USAGE \
- "\n usage: key_app param=<>...\n" \
+ "\n usage: key_app_writer param=<>...\n" \
"\n acceptable parameters:\n" \
" mode=private|public default: none\n" \
" filename=%%s default: keyfile.key\n" \
int main( int argc, char *argv[] )
{
int ret = 0;
- mbedtls_pk_context key;
char buf[1024];
int i;
char *p, *q;
+ mbedtls_pk_context key;
+ mbedtls_mpi N, P, Q, D, E, DP, DQ, QP;
+
/*
* Set to sane values
*/
mbedtls_pk_init( &key );
memset( buf, 0, sizeof( buf ) );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP );
+ mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );
+
if( argc == 0 )
{
usage:
if( mbedtls_pk_get_type( &key ) == MBEDTLS_PK_RSA )
{
mbedtls_rsa_context *rsa = mbedtls_pk_rsa( key );
- mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL );
- mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL );
- mbedtls_mpi_write_file( "D: ", &rsa->D, 16, NULL );
- mbedtls_mpi_write_file( "P: ", &rsa->P, 16, NULL );
- mbedtls_mpi_write_file( "Q: ", &rsa->Q, 16, NULL );
- mbedtls_mpi_write_file( "DP: ", &rsa->DP, 16, NULL );
- mbedtls_mpi_write_file( "DQ: ", &rsa->DQ, 16, NULL );
- mbedtls_mpi_write_file( "QP: ", &rsa->QP, 16, NULL );
+
+ if( ( ret = mbedtls_rsa_export ( rsa, &N, &P, &Q, &D, &E ) ) != 0 ||
+ ( ret = mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
+ goto exit;
+ }
+
+ mbedtls_mpi_write_file( "N: ", &N, 16, NULL );
+ mbedtls_mpi_write_file( "E: ", &E, 16, NULL );
+ mbedtls_mpi_write_file( "D: ", &D, 16, NULL );
+ mbedtls_mpi_write_file( "P: ", &P, 16, NULL );
+ mbedtls_mpi_write_file( "Q: ", &Q, 16, NULL );
+ mbedtls_mpi_write_file( "DP: ", &DP, 16, NULL );
+ mbedtls_mpi_write_file( "DQ: ", &DQ, 16, NULL );
+ mbedtls_mpi_write_file( "QP: ", &QP, 16, NULL );
}
else
#endif
if( mbedtls_pk_get_type( &key ) == MBEDTLS_PK_RSA )
{
mbedtls_rsa_context *rsa = mbedtls_pk_rsa( key );
- mbedtls_mpi_write_file( "N: ", &rsa->N, 16, NULL );
- mbedtls_mpi_write_file( "E: ", &rsa->E, 16, NULL );
+
+ if( ( ret = mbedtls_rsa_export( rsa, &N, NULL, NULL,
+ NULL, &E ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
+ goto exit;
+ }
+ mbedtls_mpi_write_file( "N: ", &N, 16, NULL );
+ mbedtls_mpi_write_file( "E: ", &E, 16, NULL );
}
else
#endif
#endif
}
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
+ mbedtls_mpi_free( &DQ ); mbedtls_mpi_free( &QP );
+
mbedtls_pk_free( &key );
#if defined(_WIN32)
int return_val, exit_val, c;
size_t i;
mbedtls_rsa_context rsa;
+ mbedtls_mpi N, P, Q, D, E, DP, DQ, QP;
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
unsigned char result[1024];
mbedtls_printf( "\n . Seeding the random number generator..." );
fflush( stdout );
+ mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
mbedtls_ctr_drbg_init( &ctr_drbg );
mbedtls_entropy_init( &entropy );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP );
+ mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );
return_val = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func,
&entropy, (const unsigned char *) pers,
goto exit;
}
- if( ( return_val = mbedtls_mpi_read_file( &rsa.N , 16, f ) ) != 0 ||
- ( return_val = mbedtls_mpi_read_file( &rsa.E , 16, f ) ) != 0 ||
- ( return_val = mbedtls_mpi_read_file( &rsa.D , 16, f ) ) != 0 ||
- ( return_val = mbedtls_mpi_read_file( &rsa.P , 16, f ) ) != 0 ||
- ( return_val = mbedtls_mpi_read_file( &rsa.Q , 16, f ) ) != 0 ||
- ( return_val = mbedtls_mpi_read_file( &rsa.DP, 16, f ) ) != 0 ||
- ( return_val = mbedtls_mpi_read_file( &rsa.DQ, 16, f ) ) != 0 ||
- ( return_val = mbedtls_mpi_read_file( &rsa.QP, 16, f ) ) != 0 )
+ if( ( return_val = mbedtls_mpi_read_file( &N , 16, f ) ) != 0 ||
+ ( return_val = mbedtls_mpi_read_file( &E , 16, f ) ) != 0 ||
+ ( return_val = mbedtls_mpi_read_file( &D , 16, f ) ) != 0 ||
+ ( return_val = mbedtls_mpi_read_file( &P , 16, f ) ) != 0 ||
+ ( return_val = mbedtls_mpi_read_file( &Q , 16, f ) ) != 0 ||
+ ( return_val = mbedtls_mpi_read_file( &DP , 16, f ) ) != 0 ||
+ ( return_val = mbedtls_mpi_read_file( &DQ , 16, f ) ) != 0 ||
+ ( return_val = mbedtls_mpi_read_file( &QP , 16, f ) ) != 0 )
{
exit_val = MBEDTLS_EXIT_FAILURE;
mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n",
fclose( f );
goto exit;
}
+ fclose( f );
- rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3;
+ if( ( return_val = mbedtls_rsa_import( &rsa, &N, &P, &Q, &D, &E ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! mbedtls_rsa_import returned %d\n\n",
+ return_val );
+ goto exit;
+ }
- fclose( f );
+ if( ( return_val = mbedtls_rsa_complete( &rsa ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! mbedtls_rsa_complete returned %d\n\n",
+ return_val );
+ goto exit;
+ }
/*
* Extract the RSA encrypted value from the text file
mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy );
mbedtls_rsa_free( &rsa );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
+ mbedtls_mpi_free( &DQ ); mbedtls_mpi_free( &QP );
#if defined(_WIN32)
mbedtls_printf( " + Press Enter to exit this program.\n" );
return( exit_val );
}
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_RSA_C && MBEDTLS_FS_IO */
-
unsigned char input[1024];
unsigned char buf[512];
const char *pers = "rsa_encrypt";
+ mbedtls_mpi N, E;
exit_val = MBEDTLS_EXIT_SUCCESS;
mbedtls_printf( "\n . Seeding the random number generator..." );
fflush( stdout );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
mbedtls_ctr_drbg_init( &ctr_drbg );
mbedtls_entropy_init( &entropy );
goto exit;
}
- if( ( return_val = mbedtls_mpi_read_file( &rsa.N, 16, f ) ) != 0 ||
- ( return_val = mbedtls_mpi_read_file( &rsa.E, 16, f ) ) != 0 )
+ if( ( return_val = mbedtls_mpi_read_file( &N, 16, f ) ) != 0 ||
+ ( return_val = mbedtls_mpi_read_file( &E, 16, f ) ) != 0 )
{
exit_val = MBEDTLS_EXIT_FAILURE;
mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n",
fclose( f );
goto exit;
}
-
- rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3;
-
fclose( f );
+ if( ( return_val = mbedtls_rsa_import( &rsa, &N, NULL,
+ NULL, NULL, &E ) ) != 0 )
+ {
+ exit_val = MBEDTLS_EXIT_FAILURE;
+ mbedtls_printf( " failed\n ! mbedtls_rsa_import returned %d\n\n",
+ return_val );
+ goto exit;
+ }
+
if( strlen( argv[1] ) > 100 )
{
exit_val = MBEDTLS_EXIT_FAILURE;
mbedtls_printf( "\n . Done (created \"%s\")\n\n", "result-enc.txt" );
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy );
mbedtls_rsa_free( &rsa );
mbedtls_rsa_context rsa;
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
+ mbedtls_mpi N, P, Q, D, E, DP, DQ, QP;
FILE *fpub = NULL;
FILE *fpriv = NULL;
const char *pers = "rsa_genkey";
mbedtls_ctr_drbg_init( &ctr_drbg );
+ mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP );
+ mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );
mbedtls_printf( "\n . Seeding the random number generator..." );
fflush( stdout );
mbedtls_printf( " ok\n . Generating the RSA key [ %d-bit ]...", KEY_SIZE );
fflush( stdout );
- mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
-
if( ( ret = mbedtls_rsa_gen_key( &rsa, mbedtls_ctr_drbg_random, &ctr_drbg, KEY_SIZE,
- EXPONENT ) ) != 0 )
+ EXPONENT ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_rsa_gen_key returned %d\n\n", ret );
goto exit;
mbedtls_printf( " ok\n . Exporting the public key in rsa_pub.txt...." );
fflush( stdout );
+ if( ( ret = mbedtls_rsa_export ( &rsa, &N, &P, &Q, &D, &E ) ) != 0 ||
+ ( ret = mbedtls_rsa_export_crt( &rsa, &DP, &DQ, &QP ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
+ ret = 1;
+ goto exit;
+ }
+
if( ( fpub = fopen( "rsa_pub.txt", "wb+" ) ) == NULL )
{
mbedtls_printf( " failed\n ! could not open rsa_pub.txt for writing\n\n" );
goto exit;
}
- if( ( ret = mbedtls_mpi_write_file( "N = ", &rsa.N, 16, fpub ) ) != 0 ||
- ( ret = mbedtls_mpi_write_file( "E = ", &rsa.E, 16, fpub ) ) != 0 )
+ if( ( ret = mbedtls_mpi_write_file( "N = ", &N, 16, fpub ) ) != 0 ||
+ ( ret = mbedtls_mpi_write_file( "E = ", &E, 16, fpub ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_mpi_write_file returned %d\n\n", ret );
goto exit;
goto exit;
}
- if( ( ret = mbedtls_mpi_write_file( "N = " , &rsa.N , 16, fpriv ) ) != 0 ||
- ( ret = mbedtls_mpi_write_file( "E = " , &rsa.E , 16, fpriv ) ) != 0 ||
- ( ret = mbedtls_mpi_write_file( "D = " , &rsa.D , 16, fpriv ) ) != 0 ||
- ( ret = mbedtls_mpi_write_file( "P = " , &rsa.P , 16, fpriv ) ) != 0 ||
- ( ret = mbedtls_mpi_write_file( "Q = " , &rsa.Q , 16, fpriv ) ) != 0 ||
- ( ret = mbedtls_mpi_write_file( "DP = ", &rsa.DP, 16, fpriv ) ) != 0 ||
- ( ret = mbedtls_mpi_write_file( "DQ = ", &rsa.DQ, 16, fpriv ) ) != 0 ||
- ( ret = mbedtls_mpi_write_file( "QP = ", &rsa.QP, 16, fpriv ) ) != 0 )
+ if( ( ret = mbedtls_mpi_write_file( "N = " , &N , 16, fpriv ) ) != 0 ||
+ ( ret = mbedtls_mpi_write_file( "E = " , &E , 16, fpriv ) ) != 0 ||
+ ( ret = mbedtls_mpi_write_file( "D = " , &D , 16, fpriv ) ) != 0 ||
+ ( ret = mbedtls_mpi_write_file( "P = " , &P , 16, fpriv ) ) != 0 ||
+ ( ret = mbedtls_mpi_write_file( "Q = " , &Q , 16, fpriv ) ) != 0 ||
+ ( ret = mbedtls_mpi_write_file( "DP = ", &DP, 16, fpriv ) ) != 0 ||
+ ( ret = mbedtls_mpi_write_file( "DQ = ", &DQ, 16, fpriv ) ) != 0 ||
+ ( ret = mbedtls_mpi_write_file( "QP = ", &QP, 16, fpriv ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_mpi_write_file returned %d\n\n", ret );
goto exit;
if( fpriv != NULL )
fclose( fpriv );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
+ mbedtls_mpi_free( &DQ ); mbedtls_mpi_free( &QP );
mbedtls_rsa_free( &rsa );
mbedtls_ctr_drbg_free( &ctr_drbg );
mbedtls_entropy_free( &entropy );
unsigned char hash[32];
unsigned char buf[MBEDTLS_MPI_MAX_SIZE];
char filename[512];
+ mbedtls_mpi N, P, Q, D, E, DP, DQ, QP;
mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
+
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP );
+ mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );
+
ret = 1;
if( argc != 2 )
goto exit;
}
- if( ( ret = mbedtls_mpi_read_file( &rsa.N , 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.E , 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.D , 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.P , 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.Q , 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.DP, 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.DQ, 16, f ) ) != 0 ||
- ( ret = mbedtls_mpi_read_file( &rsa.QP, 16, f ) ) != 0 )
+ if( ( ret = mbedtls_mpi_read_file( &N , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &E , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &D , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &P , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &Q , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &DP , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &DQ , 16, f ) ) != 0 ||
+ ( ret = mbedtls_mpi_read_file( &QP , 16, f ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n", ret );
fclose( f );
goto exit;
}
+ fclose( f );
- rsa.len = ( mbedtls_mpi_bitlen( &rsa.N ) + 7 ) >> 3;
+ if( ( ret = mbedtls_rsa_import( &rsa, &N, &P, &Q, &D, &E ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! mbedtls_rsa_import returned %d\n\n",
+ ret );
+ goto exit;
+ }
- fclose( f );
+ if( ( ret = mbedtls_rsa_complete( &rsa ) ) != 0 )
+ {
+ mbedtls_printf( " failed\n ! mbedtls_rsa_complete returned %d\n\n",
+ ret );
+ goto exit;
+ }
mbedtls_printf( "\n . Checking the private key" );
fflush( stdout );
exit:
mbedtls_rsa_free( &rsa );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
+ mbedtls_mpi_free( &DQ ); mbedtls_mpi_free( &QP );
#if defined(_WIN32)
mbedtls_printf( " + Press Enter to exit this program.\n" );
!defined(MBEDTLS_NET_C) || !defined(MBEDTLS_TIMING_C) || \
!defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_CTR_DRBG_C) || \
!defined(MBEDTLS_X509_CRT_PARSE_C) || !defined(MBEDTLS_RSA_C) || \
- !defined(MBEDTLS_CERTS_C)
+ !defined(MBEDTLS_CERTS_C) || !defined(MBEDTLS_PEM_PARSE_C)
int main( void )
{
mbedtls_printf( "MBEDTLS_SSL_CLI_C and/or MBEDTLS_SSL_PROTO_DTLS and/or "
/*
* 4. Handshake
*/
- mbedtls_printf( " . Performing the SSL/TLS handshake..." );
+ mbedtls_printf( " . Performing the DTLS handshake..." );
fflush( stdout );
do ret = mbedtls_ssl_handshake( &ssl );
goto exit;
}
- if( ( ret = mbedtls_ssl_set_hostname( &ssl, "mbed TLS Server 1" ) ) != 0 )
+ if( ( ret = mbedtls_ssl_set_hostname( &ssl, SERVER_NAME ) ) != 0 )
{
mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n", ret );
goto exit;
#include <stdlib.h>
#include <string.h>
+#define MAX_REQUEST_SIZE 20000
+#define MAX_REQUEST_SIZE_STR "20000"
+
#define DFL_SERVER_NAME "localhost"
#define DFL_SERVER_ADDR NULL
#define DFL_SERVER_PORT "4433"
#define DFL_MIN_VERSION -1
#define DFL_MAX_VERSION -1
#define DFL_ARC4 -1
+#define DFL_SHA1 -1
#define DFL_AUTH_MODE -1
#define DFL_MFL_CODE MBEDTLS_SSL_MAX_FRAG_LEN_NONE
#define DFL_TRUNC_HMAC -1
#define DFL_RECONNECT_HARD 0
#define DFL_TICKETS MBEDTLS_SSL_SESSION_TICKETS_ENABLED
#define DFL_ALPN_STRING NULL
+#define DFL_CURVES NULL
#define DFL_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM
#define DFL_HS_TO_MIN 0
#define DFL_HS_TO_MAX 0
#define USAGE_ALPN ""
#endif /* MBEDTLS_SSL_ALPN */
+#if defined(MBEDTLS_ECP_C)
+#define USAGE_CURVES \
+ " curves=a,b,c,d default: \"default\" (library default)\n" \
+ " example: \"secp521r1,brainpoolP512r1\"\n" \
+ " - use \"none\" for empty list\n" \
+ " - see mbedtls_ecp_curve_list()\n" \
+ " for acceptable curve names\n"
+#else
+#define USAGE_CURVES ""
+#endif
+
#if defined(MBEDTLS_SSL_PROTO_DTLS)
#define USAGE_DTLS \
" dtls=%%d default: 0 (TLS)\n" \
" server_addr=%%s default: given by name\n" \
" server_port=%%d default: 4433\n" \
" request_page=%%s default: \".\"\n" \
- " request_size=%%d default: about 34 (basic request)\n" \
- " (minimum: 0, max: 16384)\n" \
+ " request_size=%%d default: about 34 (basic request)\n" \
+ " (minimum: 0, max: " MAX_REQUEST_SIZE_STR " )\n" \
" debug_level=%%d default: 0 (disabled)\n" \
" nbio=%%d default: 0 (blocking I/O)\n" \
" options: 1 (non-blocking), 2 (added delays)\n" \
USAGE_FALLBACK \
USAGE_EMS \
USAGE_ETM \
+ USAGE_CURVES \
USAGE_RECSPLIT \
USAGE_DHMLEN \
"\n" \
" arc4=%%d default: (library default: 0)\n" \
+ " allow_sha1=%%d default: 0\n" \
" min_version=%%s default: (library default: tls1)\n" \
" max_version=%%s default: (library default: tls1_2)\n" \
" force_version=%%s default: \"\" (none)\n" \
" force_ciphersuite=<name> default: all enabled\n"\
" acceptable ciphersuite names:\n"
+#define ALPN_LIST_SIZE 10
+#define CURVE_LIST_SIZE 20
+
/*
* global options
*/
int min_version; /* minimum protocol version accepted */
int max_version; /* maximum protocol version accepted */
int arc4; /* flag for arc4 suites support */
+ int allow_sha1; /* flag for SHA-1 support */
int auth_mode; /* verify mode for connection */
unsigned char mfl_code; /* code for maximum fragment length */
int trunc_hmac; /* negotiate truncated hmac or not */
int reco_delay; /* delay in seconds before resuming session */
int reconnect_hard; /* unexpectedly reconnect from the same port */
int tickets; /* enable / disable session tickets */
+ const char *curves; /* list of supported elliptic curves */
const char *alpn_string; /* ALPN supported protocols */
int transport; /* TLS or DTLS? */
uint32_t hs_to_min; /* Initial value of DTLS handshake timer */
return( 0 );
}
+
+static int ssl_sig_hashes_for_test[] = {
+#if defined(MBEDTLS_SHA512_C)
+ MBEDTLS_MD_SHA512,
+ MBEDTLS_MD_SHA384,
+#endif
+#if defined(MBEDTLS_SHA256_C)
+ MBEDTLS_MD_SHA256,
+ MBEDTLS_MD_SHA224,
+#endif
+#if defined(MBEDTLS_SHA1_C)
+ /* Allow SHA-1 as we use it extensively in tests. */
+ MBEDTLS_MD_SHA1,
+#endif
+ MBEDTLS_MD_NONE
+};
#endif /* MBEDTLS_X509_CRT_PARSE_C */
int main( int argc, char *argv[] )
{
int ret = 0, len, tail_len, i, written, frags, retry_left;
mbedtls_net_context server_fd;
- unsigned char buf[MBEDTLS_SSL_MAX_CONTENT_LEN + 1];
+
+ unsigned char buf[MAX_REQUEST_SIZE + 1];
+
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
unsigned char psk[MBEDTLS_PSK_MAX_LEN];
size_t psk_len = 0;
#endif
#if defined(MBEDTLS_SSL_ALPN)
- const char *alpn_list[10];
+ const char *alpn_list[ALPN_LIST_SIZE];
+#endif
+#if defined(MBEDTLS_ECP_C)
+ mbedtls_ecp_group_id curve_list[CURVE_LIST_SIZE];
+ const mbedtls_ecp_curve_info *curve_cur;
#endif
+
const char *pers = "ssl_client2";
+#if defined(MBEDTLS_X509_CRT_PARSE_C)
+ mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
+#endif
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_ssl_context ssl;
opt.min_version = DFL_MIN_VERSION;
opt.max_version = DFL_MAX_VERSION;
opt.arc4 = DFL_ARC4;
+ opt.allow_sha1 = DFL_SHA1;
opt.auth_mode = DFL_AUTH_MODE;
opt.mfl_code = DFL_MFL_CODE;
opt.trunc_hmac = DFL_TRUNC_HMAC;
opt.reconnect_hard = DFL_RECONNECT_HARD;
opt.tickets = DFL_TICKETS;
opt.alpn_string = DFL_ALPN_STRING;
+ opt.curves = DFL_CURVES;
opt.transport = DFL_TRANSPORT;
opt.hs_to_min = DFL_HS_TO_MIN;
opt.hs_to_max = DFL_HS_TO_MAX;
else if( strcmp( p, "request_size" ) == 0 )
{
opt.request_size = atoi( q );
- if( opt.request_size < 0 || opt.request_size > MBEDTLS_SSL_MAX_CONTENT_LEN )
+ if( opt.request_size < 0 ||
+ opt.request_size > MAX_REQUEST_SIZE )
goto usage;
}
else if( strcmp( p, "ca_file" ) == 0 )
default: goto usage;
}
}
+ else if( strcmp( p, "curves" ) == 0 )
+ opt.curves = q;
else if( strcmp( p, "etm" ) == 0 )
{
switch( atoi( q ) )
default: goto usage;
}
}
+ else if( strcmp( p, "allow_sha1" ) == 0 )
+ {
+ switch( atoi( q ) )
+ {
+ case 0: opt.allow_sha1 = 0; break;
+ case 1: opt.allow_sha1 = 1; break;
+ default: goto usage;
+ }
+ }
else if( strcmp( p, "force_version" ) == 0 )
{
if( strcmp( q, "ssl3" ) == 0 )
}
#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */
+#if defined(MBEDTLS_ECP_C)
+ if( opt.curves != NULL )
+ {
+ p = (char *) opt.curves;
+ i = 0;
+
+ if( strcmp( p, "none" ) == 0 )
+ {
+ curve_list[0] = MBEDTLS_ECP_DP_NONE;
+ }
+ else if( strcmp( p, "default" ) != 0 )
+ {
+ /* Leave room for a final NULL in curve list */
+ while( i < CURVE_LIST_SIZE - 1 && *p != '\0' )
+ {
+ q = p;
+
+ /* Terminate the current string */
+ while( *p != ',' && *p != '\0' )
+ p++;
+ if( *p == ',' )
+ *p++ = '\0';
+
+ if( ( curve_cur = mbedtls_ecp_curve_info_from_name( q ) ) != NULL )
+ {
+ curve_list[i++] = curve_cur->grp_id;
+ }
+ else
+ {
+ mbedtls_printf( "unknown curve %s\n", q );
+ mbedtls_printf( "supported curves: " );
+ for( curve_cur = mbedtls_ecp_curve_list();
+ curve_cur->grp_id != MBEDTLS_ECP_DP_NONE;
+ curve_cur++ )
+ {
+ mbedtls_printf( "%s ", curve_cur->name );
+ }
+ mbedtls_printf( "\n" );
+ goto exit;
+ }
+ }
+
+ mbedtls_printf("Number of curves: %d\n", i );
+
+ if( i == CURVE_LIST_SIZE - 1 && *p != '\0' )
+ {
+ mbedtls_printf( "curves list too long, maximum %d",
+ CURVE_LIST_SIZE - 1 );
+ goto exit;
+ }
+
+ curve_list[i] = MBEDTLS_ECP_DP_NONE;
+ }
+ }
+#endif /* MBEDTLS_ECP_C */
+
#if defined(MBEDTLS_SSL_ALPN)
if( opt.alpn_string != NULL )
{
i = 0;
/* Leave room for a final NULL in alpn_list */
- while( i < (int) sizeof alpn_list - 1 && *p != '\0' )
+ while( i < ALPN_LIST_SIZE - 1 && *p != '\0' )
{
alpn_list[i++] = p;
}
#if defined(MBEDTLS_X509_CRT_PARSE_C)
+ /* The default algorithms profile disables SHA-1, but our tests still
+ rely on it heavily. */
+ if( opt.allow_sha1 > 0 )
+ {
+ crt_profile_for_test.allowed_mds |= MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA1 );
+ mbedtls_ssl_conf_cert_profile( &conf, &crt_profile_for_test );
+ mbedtls_ssl_conf_sig_hashes( &conf, ssl_sig_hashes_for_test );
+ }
+
if( opt.debug_level > 0 )
mbedtls_ssl_conf_verify( &conf, my_verify, NULL );
-#endif
+#endif /* MBEDTLS_X509_CRT_PARSE_C */
if( opt.auth_mode != DFL_AUTH_MODE )
mbedtls_ssl_conf_authmode( &conf, opt.auth_mode );
}
#endif
+#if defined(MBEDTLS_ECP_C)
+ if( opt.curves != NULL &&
+ strcmp( opt.curves, "default" ) != 0 )
+ {
+ mbedtls_ssl_conf_curves( &conf, curve_list );
+ }
+#endif
+
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
if( ( ret = mbedtls_ssl_conf_psk( &conf, psk, psk_len,
(const unsigned char *) opt.psk_identity,
mbedtls_printf( " > Write to server:" );
fflush( stdout );
- len = mbedtls_snprintf( (char *) buf, sizeof(buf) - 1, GET_REQUEST,
- opt.request_page );
+ len = mbedtls_snprintf( (char *) buf, sizeof( buf ) - 1, GET_REQUEST,
+ opt.request_page );
tail_len = (int) strlen( GET_REQUEST_END );
/* Add padding to GET request to reach opt.request_size in length */
len += opt.request_size - len - tail_len;
}
- strncpy( (char *) buf + len, GET_REQUEST_END, sizeof(buf) - len - 1 );
+ strncpy( (char *) buf + len, GET_REQUEST_END, sizeof( buf ) - len - 1 );
len += tail_len;
/* Truncate if request size is smaller than the "natural" size */
frags = 1;
written = ret;
+
+ if( written < len )
+ {
+ mbedtls_printf( " warning\n ! request didn't fit into single datagram and "
+ "was truncated to size %u", (unsigned) written );
+ }
}
buf[written] = '\0';
ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file );
else
#endif
-#if defined(MBEDTLS_CERTS_C)
+#if defined(MBEDTLS_CERTS_C) && defined(MBEDTLS_PEM_PARSE_C)
ret = mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_cas_pem,
mbedtls_test_cas_pem_len );
#else
{
ret = 1;
- mbedtls_printf("MBEDTLS_CERTS_C not defined.");
+ mbedtls_printf("MBEDTLS_CERTS_C and/or MBEDTLS_PEM_PARSE_C not defined.");
}
#endif
if( ret < 0 )
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
+
+#if !defined(_MSC_VER)
+#include <inttypes.h>
+#endif
#if !defined(_WIN32)
#include <signal.h>
#define DFL_ALLOW_LEGACY -2
#define DFL_RENEGOTIATE 0
#define DFL_RENEGO_DELAY -2
-#define DFL_RENEGO_PERIOD -1
+#define DFL_RENEGO_PERIOD ( (uint64_t)-1 )
#define DFL_EXCHANGES 1
#define DFL_MIN_VERSION -1
#define DFL_MAX_VERSION -1
#define DFL_ARC4 -1
+#define DFL_SHA1 -1
#define DFL_AUTH_MODE -1
+#define DFL_CERT_REQ_CA_LIST MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED
#define DFL_MFL_CODE MBEDTLS_SSL_MAX_FRAG_LEN_NONE
#define DFL_TRUNC_HMAC -1
#define DFL_TICKETS MBEDTLS_SSL_SESSION_TICKETS_ENABLED
#define DFL_CACHE_TIMEOUT -1
#define DFL_SNI NULL
#define DFL_ALPN_STRING NULL
+#define DFL_CURVES NULL
#define DFL_DHM_FILE NULL
#define DFL_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM
#define DFL_COOKIES 1
" renegotiation=%%d default: 0 (disabled)\n" \
" renegotiate=%%d default: 0 (disabled)\n" \
" renego_delay=%%d default: -2 (library default)\n" \
- " renego_period=%%d default: (library default)\n"
+ " renego_period=%%d default: (2^64 - 1 for TLS, 2^48 - 1 for DTLS)\n"
#else
#define USAGE_RENEGO ""
#endif
#define USAGE_ECJPAKE ""
#endif
+#if defined(MBEDTLS_ECP_C)
+#define USAGE_CURVES \
+ " curves=a,b,c,d default: \"default\" (library default)\n" \
+ " example: \"secp521r1,brainpoolP512r1\"\n" \
+ " - use \"none\" for empty list\n" \
+ " - see mbedtls_ecp_curve_list()\n" \
+ " for acceptable curve names\n"
+#else
+#define USAGE_CURVES ""
+#endif
+
#define USAGE \
"\n usage: ssl_server2 param=<>...\n" \
"\n acceptable parameters:\n" \
- " server_addr=%%d default: (all interfaces)\n" \
+ " server_addr=%%s default: (all interfaces)\n" \
" server_port=%%d default: 4433\n" \
" debug_level=%%d default: 0 (disabled)\n" \
" nbio=%%d default: 0 (blocking I/O)\n" \
"\n" \
" auth_mode=%%s default: (library default: none)\n" \
" options: none, optional, required\n" \
+ " cert_req_ca_list=%%d default: 1 (send ca list)\n" \
+ " options: 1 (send ca list), 0 (don't send)\n" \
USAGE_IO \
USAGE_SNI \
"\n" \
USAGE_ALPN \
USAGE_EMS \
USAGE_ETM \
+ USAGE_CURVES \
"\n" \
" arc4=%%d default: (library default: 0)\n" \
+ " allow_sha1=%%d default: 0\n" \
" min_version=%%s default: (library default: tls1)\n" \
" max_version=%%s default: (library default: tls1_2)\n" \
" force_version=%%s default: \"\" (none)\n" \
" force_ciphersuite=<name> default: all enabled\n" \
" acceptable ciphersuite names:\n"
+
+#define ALPN_LIST_SIZE 10
+#define CURVE_LIST_SIZE 20
+
+#define PUT_UINT64_BE(out_be,in_le,i) \
+{ \
+ (out_be)[(i) + 0] = (unsigned char)( ( (in_le) >> 56 ) & 0xFF ); \
+ (out_be)[(i) + 1] = (unsigned char)( ( (in_le) >> 48 ) & 0xFF ); \
+ (out_be)[(i) + 2] = (unsigned char)( ( (in_le) >> 40 ) & 0xFF ); \
+ (out_be)[(i) + 3] = (unsigned char)( ( (in_le) >> 32 ) & 0xFF ); \
+ (out_be)[(i) + 4] = (unsigned char)( ( (in_le) >> 24 ) & 0xFF ); \
+ (out_be)[(i) + 5] = (unsigned char)( ( (in_le) >> 16 ) & 0xFF ); \
+ (out_be)[(i) + 6] = (unsigned char)( ( (in_le) >> 8 ) & 0xFF ); \
+ (out_be)[(i) + 7] = (unsigned char)( ( (in_le) >> 0 ) & 0xFF ); \
+}
+
/*
* global options
*/
int allow_legacy; /* allow legacy renegotiation */
int renegotiate; /* attempt renegotiation? */
int renego_delay; /* delay before enforcing renegotiation */
- int renego_period; /* period for automatic renegotiation */
+ uint64_t renego_period; /* period for automatic renegotiation */
int exchanges; /* number of data exchanges */
int min_version; /* minimum protocol version accepted */
int max_version; /* maximum protocol version accepted */
int arc4; /* flag for arc4 suites support */
+ int allow_sha1; /* flag for SHA-1 support */
int auth_mode; /* verify mode for connection */
+ int cert_req_ca_list; /* should we send the CA list? */
unsigned char mfl_code; /* code for maximum fragment length */
int trunc_hmac; /* accept truncated hmac? */
int tickets; /* enable / disable session tickets */
int cache_max; /* max number of session cache entries */
int cache_timeout; /* expiration delay of session cache entries */
char *sni; /* string describing sni information */
+ const char *curves; /* list of supported elliptic curves */
const char *alpn_string; /* ALPN supported protocols */
const char *dhm_file; /* the file with the DH parameters */
int extended_ms; /* allow negotiation of extended MS? */
}
#endif
+#if defined(MBEDTLS_X509_CRT_PARSE_C)
+static int ssl_sig_hashes_for_test[] = {
+#if defined(MBEDTLS_SHA512_C)
+ MBEDTLS_MD_SHA512,
+ MBEDTLS_MD_SHA384,
+#endif
+#if defined(MBEDTLS_SHA256_C)
+ MBEDTLS_MD_SHA256,
+ MBEDTLS_MD_SHA224,
+#endif
+#if defined(MBEDTLS_SHA1_C)
+ /* Allow SHA-1 as we use it extensively in tests. */
+ MBEDTLS_MD_SHA1,
+#endif
+ MBEDTLS_MD_NONE
+};
+#endif /* MBEDTLS_X509_CRT_PARSE_C */
+
int main( int argc, char *argv[] )
{
int ret = 0, len, written, frags, exchanges_left;
mbedtls_ssl_cookie_ctx cookie_ctx;
#endif
+#if defined(MBEDTLS_X509_CRT_PARSE_C)
+ mbedtls_x509_crt_profile crt_profile_for_test = mbedtls_x509_crt_profile_default;
+#endif
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
mbedtls_ssl_context ssl;
#if defined(SNI_OPTION)
sni_entry *sni_info = NULL;
#endif
+#if defined(MBEDTLS_ECP_C)
+ mbedtls_ecp_group_id curve_list[CURVE_LIST_SIZE];
+ const mbedtls_ecp_curve_info * curve_cur;
+#endif
#if defined(MBEDTLS_SSL_ALPN)
- const char *alpn_list[10];
+ const char *alpn_list[ALPN_LIST_SIZE];
#endif
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
unsigned char alloc_buf[100000];
opt.min_version = DFL_MIN_VERSION;
opt.max_version = DFL_MAX_VERSION;
opt.arc4 = DFL_ARC4;
+ opt.allow_sha1 = DFL_SHA1;
opt.auth_mode = DFL_AUTH_MODE;
+ opt.cert_req_ca_list = DFL_CERT_REQ_CA_LIST;
opt.mfl_code = DFL_MFL_CODE;
opt.trunc_hmac = DFL_TRUNC_HMAC;
opt.tickets = DFL_TICKETS;
opt.cache_timeout = DFL_CACHE_TIMEOUT;
opt.sni = DFL_SNI;
opt.alpn_string = DFL_ALPN_STRING;
+ opt.curves = DFL_CURVES;
opt.dhm_file = DFL_DHM_FILE;
opt.transport = DFL_TRANSPORT;
opt.cookies = DFL_COOKIES;
}
opt.force_ciphersuite[1] = 0;
}
+ else if( strcmp( p, "curves" ) == 0 )
+ opt.curves = q;
else if( strcmp( p, "version_suites" ) == 0 )
opt.version_suites = q;
else if( strcmp( p, "renegotiation" ) == 0 )
}
else if( strcmp( p, "renego_period" ) == 0 )
{
- opt.renego_period = atoi( q );
- if( opt.renego_period < 2 || opt.renego_period > 255 )
+#if defined(_MSC_VER)
+ opt.renego_period = _strtoui64( q, NULL, 10 );
+#else
+ if( sscanf( q, "%" SCNu64, &opt.renego_period ) != 1 )
+ goto usage;
+#endif /* _MSC_VER */
+ if( opt.renego_period < 2 )
goto usage;
}
else if( strcmp( p, "exchanges" ) == 0 )
default: goto usage;
}
}
+ else if( strcmp( p, "allow_sha1" ) == 0 )
+ {
+ switch( atoi( q ) )
+ {
+ case 0: opt.allow_sha1 = 0; break;
+ case 1: opt.allow_sha1 = 1; break;
+ default: goto usage;
+ }
+ }
else if( strcmp( p, "force_version" ) == 0 )
{
if( strcmp( q, "ssl3" ) == 0 )
if( ( opt.auth_mode = get_auth_mode( q ) ) < 0 )
goto usage;
}
+ else if( strcmp( p, "cert_req_ca_list" ) == 0 )
+ {
+ opt.cert_req_ca_list = atoi( q );
+ if( opt.cert_req_ca_list < 0 || opt.cert_req_ca_list > 1 )
+ goto usage;
+ }
else if( strcmp( p, "max_frag_len" ) == 0 )
{
if( strcmp( q, "512" ) == 0 )
}
#endif /* MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED */
+#if defined(MBEDTLS_ECP_C)
+ if( opt.curves != NULL )
+ {
+ p = (char *) opt.curves;
+ i = 0;
+
+ if( strcmp( p, "none" ) == 0 )
+ {
+ curve_list[0] = MBEDTLS_ECP_DP_NONE;
+ }
+ else if( strcmp( p, "default" ) != 0 )
+ {
+ /* Leave room for a final NULL in curve list */
+ while( i < CURVE_LIST_SIZE - 1 && *p != '\0' )
+ {
+ q = p;
+
+ /* Terminate the current string */
+ while( *p != ',' && *p != '\0' )
+ p++;
+ if( *p == ',' )
+ *p++ = '\0';
+
+ if( ( curve_cur = mbedtls_ecp_curve_info_from_name( q ) ) != NULL )
+ {
+ curve_list[i++] = curve_cur->grp_id;
+ }
+ else
+ {
+ mbedtls_printf( "unknown curve %s\n", q );
+ mbedtls_printf( "supported curves: " );
+ for( curve_cur = mbedtls_ecp_curve_list();
+ curve_cur->grp_id != MBEDTLS_ECP_DP_NONE;
+ curve_cur++ )
+ {
+ mbedtls_printf( "%s ", curve_cur->name );
+ }
+ mbedtls_printf( "\n" );
+ goto exit;
+ }
+ }
+
+ mbedtls_printf("Number of curves: %d\n", i );
+
+ if( i == CURVE_LIST_SIZE - 1 && *p != '\0' )
+ {
+ mbedtls_printf( "curves list too long, maximum %d",
+ CURVE_LIST_SIZE - 1 );
+ goto exit;
+ }
+
+ curve_list[i] = MBEDTLS_ECP_DP_NONE;
+ }
+ }
+#endif /* MBEDTLS_ECP_C */
+
#if defined(MBEDTLS_SSL_ALPN)
if( opt.alpn_string != NULL )
{
i = 0;
/* Leave room for a final NULL in alpn_list */
- while( i < (int) sizeof alpn_list - 1 && *p != '\0' )
+ while( i < ALPN_LIST_SIZE - 1 && *p != '\0' )
{
alpn_list[i++] = p;
goto exit;
}
+#if defined(MBEDTLS_X509_CRT_PARSE_C)
+ /* The default algorithms profile disables SHA-1, but our tests still
+ rely on it heavily. Hence we allow it here. A real-world server
+ should use the default profile unless there is a good reason not to. */
+ if( opt.allow_sha1 > 0 )
+ {
+ crt_profile_for_test.allowed_mds |= MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA1 );
+ mbedtls_ssl_conf_cert_profile( &conf, &crt_profile_for_test );
+ mbedtls_ssl_conf_sig_hashes( &conf, ssl_sig_hashes_for_test );
+ }
+#endif /* MBEDTLS_X509_CRT_PARSE_C */
+
if( opt.auth_mode != DFL_AUTH_MODE )
mbedtls_ssl_conf_authmode( &conf, opt.auth_mode );
+ if( opt.cert_req_ca_list != DFL_CERT_REQ_CA_LIST )
+ mbedtls_ssl_conf_cert_req_ca_list( &conf, opt.cert_req_ca_list );
+
#if defined(MBEDTLS_SSL_PROTO_DTLS)
if( opt.hs_to_min != DFL_HS_TO_MIN || opt.hs_to_max != DFL_HS_TO_MAX )
mbedtls_ssl_conf_handshake_timeout( &conf, opt.hs_to_min, opt.hs_to_max );
if( opt.renego_period != DFL_RENEGO_PERIOD )
{
- renego_period[7] = opt.renego_period;
+ PUT_UINT64_BE( renego_period, opt.renego_period, 0 );
mbedtls_ssl_conf_renegotiation_period( &conf, renego_period );
}
#endif
mbedtls_ssl_conf_sni( &conf, sni_callback, sni_info );
#endif
+#if defined(MBEDTLS_ECP_C)
+ if( opt.curves != NULL &&
+ strcmp( opt.curves, "default" ) != 0 )
+ {
+ mbedtls_ssl_conf_curves( &conf, curve_list );
+ }
+#endif
+
#if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED)
if( strlen( opt.psk ) != 0 && strlen( opt.psk_identity ) != 0 )
{
#if !defined(_WIN32)
if( received_sigterm )
{
- mbedtls_printf( " interrupted by SIGTERM\n" );
- ret = 0;
+ mbedtls_printf( " interrupted by SIGTERM (not in net_accept())\n" );
+ if( ret == MBEDTLS_ERR_NET_INVALID_CONTEXT )
+ ret = 0;
+
goto exit;
}
#endif
#if !defined(_WIN32)
if( received_sigterm )
{
- mbedtls_printf( " interrupted by signal\n" );
- ret = 0;
+ mbedtls_printf( " interrupted by SIGTERM (in net_accept())\n" );
+ if( ret == MBEDTLS_ERR_NET_ACCEPT_FAILED )
+ ret = 0;
+
goto exit;
}
#endif
#if defined(MBEDTLS_X509_CRT_PARSE_C)
/*
- * 5. Verify the server certificate
+ * 5. Verify the client certificate
*/
mbedtls_printf( " . Verifying peer X.509 certificate..." );
CODE; \
} \
\
- mbedtls_printf( "%9lu Kb/s, %9lu cycles/byte\n", \
+ mbedtls_printf( "%9lu KiB/s, %9lu cycles/byte\n", \
ii * BUFSIZE / 1024, \
( mbedtls_timing_hardclock() - tsc ) / ( jj * BUFSIZE ) ); \
} while( 0 )
-#if defined(MBEDTLS_ERROR_C)
-#define PRINT_ERROR \
- mbedtls_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \
- mbedtls_printf( "FAILED: %s\n", tmp );
-#else
-#define PRINT_ERROR \
- mbedtls_printf( "FAILED: -0x%04x\n", -ret );
-#endif
-
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG)
#define MEMORY_MEASURE_INIT \
#if defined(MBEDTLS_MD4_C)
if( todo.md4 )
- TIME_AND_TSC( "MD4", mbedtls_md4( buf, BUFSIZE, tmp ) );
+ TIME_AND_TSC( "MD4", mbedtls_md4_ret( buf, BUFSIZE, tmp ) );
#endif
#if defined(MBEDTLS_MD5_C)
if( todo.md5 )
- TIME_AND_TSC( "MD5", mbedtls_md5( buf, BUFSIZE, tmp ) );
+ TIME_AND_TSC( "MD5", mbedtls_md5_ret( buf, BUFSIZE, tmp ) );
#endif
#if defined(MBEDTLS_RIPEMD160_C)
if( todo.ripemd160 )
- TIME_AND_TSC( "RIPEMD160", mbedtls_ripemd160( buf, BUFSIZE, tmp ) );
+ TIME_AND_TSC( "RIPEMD160", mbedtls_ripemd160_ret( buf, BUFSIZE, tmp ) );
#endif
#if defined(MBEDTLS_SHA1_C)
if( todo.sha1 )
- TIME_AND_TSC( "SHA-1", mbedtls_sha1( buf, BUFSIZE, tmp ) );
+ TIME_AND_TSC( "SHA-1", mbedtls_sha1_ret( buf, BUFSIZE, tmp ) );
#endif
#if defined(MBEDTLS_SHA256_C)
if( todo.sha256 )
- TIME_AND_TSC( "SHA-256", mbedtls_sha256( buf, BUFSIZE, tmp, 0 ) );
+ TIME_AND_TSC( "SHA-256", mbedtls_sha256_ret( buf, BUFSIZE, tmp, 0 ) );
#endif
#if defined(MBEDTLS_SHA512_C)
if( todo.sha512 )
- TIME_AND_TSC( "SHA-512", mbedtls_sha512( buf, BUFSIZE, tmp, 0 ) );
+ TIME_AND_TSC( "SHA-512", mbedtls_sha512_ret( buf, BUFSIZE, tmp, 0 ) );
#endif
#if defined(MBEDTLS_ARC4_C)
if( todo.dhm )
{
int dhm_sizes[] = { 2048, 3072 };
- const char *dhm_P[] = {
- MBEDTLS_DHM_RFC3526_MODP_2048_P,
- MBEDTLS_DHM_RFC3526_MODP_3072_P,
- };
- const char *dhm_G[] = {
- MBEDTLS_DHM_RFC3526_MODP_2048_G,
- MBEDTLS_DHM_RFC3526_MODP_3072_G,
- };
+ const unsigned char dhm_P_2048[] =
+ MBEDTLS_DHM_RFC3526_MODP_2048_P_BIN;
+ const unsigned char dhm_P_3072[] =
+ MBEDTLS_DHM_RFC3526_MODP_3072_P_BIN;
+ const unsigned char dhm_G_2048[] =
+ MBEDTLS_DHM_RFC3526_MODP_2048_G_BIN;
+ const unsigned char dhm_G_3072[] =
+ MBEDTLS_DHM_RFC3526_MODP_3072_G_BIN;
+
+ const unsigned char *dhm_P[] = { dhm_P_2048, dhm_P_3072 };
+ const size_t dhm_P_size[] = { sizeof( dhm_P_2048 ),
+ sizeof( dhm_P_3072 ) };
+
+ const unsigned char *dhm_G[] = { dhm_G_2048, dhm_G_3072 };
+ const size_t dhm_G_size[] = { sizeof( dhm_G_2048 ),
+ sizeof( dhm_G_3072 ) };
mbedtls_dhm_context dhm;
size_t olen;
{
mbedtls_dhm_init( &dhm );
- if( mbedtls_mpi_read_string( &dhm.P, 16, dhm_P[i] ) != 0 ||
- mbedtls_mpi_read_string( &dhm.G, 16, dhm_G[i] ) != 0 )
+ if( mbedtls_mpi_read_binary( &dhm.P, dhm_P[i],
+ dhm_P_size[i] ) != 0 ||
+ mbedtls_mpi_read_binary( &dhm.G, dhm_G[i],
+ dhm_G_size[i] ) != 0 )
{
mbedtls_exit( 1 );
}
* self-test. If this fails, we attempt the test anyway, so no error is passed
* back.
*/
-#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_ENTROPY_C) && \
- defined(MBEDTLS_ENTROPY_NV_SEED) && !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
+#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_ENTROPY_C)
+#if defined(MBEDTLS_ENTROPY_NV_SEED) && !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
static void create_entropy_seed_file( void )
{
int result;
}
#endif
-int main( int argc, char *argv[] )
+int mbedtls_entropy_self_test_wrapper( int verbose )
{
- int v, suites_tested = 0, suites_failed = 0;
-#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_SELF_TEST)
- unsigned char buf[1000000];
+#if defined(MBEDTLS_ENTROPY_NV_SEED) && !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
+ create_entropy_seed_file( );
+#endif
+ return( mbedtls_entropy_self_test( verbose ) );
+}
#endif
- void *pointer;
-
- /*
- * The C standard doesn't guarantee that all-bits-0 is the representation
- * of a NULL pointer. We do however use that in our code for initializing
- * structures, which should work on every modern platform. Let's be sure.
- */
- memset( &pointer, 0, sizeof( void * ) );
- if( pointer != NULL )
- {
- mbedtls_printf( "all-bits-zero is not a NULL pointer\n" );
- mbedtls_exit( MBEDTLS_EXIT_FAILURE );
- }
-
- /*
- * Make sure we have a snprintf that correctly zero-terminates
- */
- if( run_test_snprintf() != 0 )
- {
- mbedtls_printf( "the snprintf implementation is broken\n" );
- mbedtls_exit( MBEDTLS_EXIT_FAILURE );
- }
-
- if( argc == 2 && ( strcmp( argv[1], "--quiet" ) == 0 ||
- strcmp( argv[1], "-q" ) == 0 ) )
- {
- v = 0;
- }
- else
- {
- v = 1;
- mbedtls_printf( "\n" );
- }
#if defined(MBEDTLS_SELF_TEST)
-
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
- mbedtls_memory_buffer_alloc_init( buf, sizeof(buf) );
-#endif
-
-#if defined(MBEDTLS_MD2_C)
- if( mbedtls_md2_self_test( v ) != 0 )
+int mbedtls_memory_buffer_alloc_free_and_self_test( int verbose )
+{
+ if( verbose != 0 )
{
- suites_failed++;
+#if defined(MBEDTLS_MEMORY_DEBUG)
+ mbedtls_memory_buffer_alloc_status( );
+#endif
}
- suites_tested++;
+ mbedtls_memory_buffer_alloc_free( );
+ return( mbedtls_memory_buffer_alloc_self_test( verbose ) );
+}
#endif
+typedef struct
+{
+ const char *name;
+ int ( *function )( int );
+} selftest_t;
+
+const selftest_t selftests[] =
+{
+#if defined(MBEDTLS_MD2_C)
+ {"md2", mbedtls_md2_self_test},
+#endif
#if defined(MBEDTLS_MD4_C)
- if( mbedtls_md4_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"md4", mbedtls_md4_self_test},
#endif
-
#if defined(MBEDTLS_MD5_C)
- if( mbedtls_md5_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"md5", mbedtls_md5_self_test},
#endif
-
#if defined(MBEDTLS_RIPEMD160_C)
- if( mbedtls_ripemd160_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"ripemd160", mbedtls_ripemd160_self_test},
#endif
-
#if defined(MBEDTLS_SHA1_C)
- if( mbedtls_sha1_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"sha1", mbedtls_sha1_self_test},
#endif
-
#if defined(MBEDTLS_SHA256_C)
- if( mbedtls_sha256_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"sha256", mbedtls_sha256_self_test},
#endif
-
#if defined(MBEDTLS_SHA512_C)
- if( mbedtls_sha512_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"sha512", mbedtls_sha512_self_test},
#endif
-
#if defined(MBEDTLS_ARC4_C)
- if( mbedtls_arc4_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"arc4", mbedtls_arc4_self_test},
#endif
-
#if defined(MBEDTLS_DES_C)
- if( mbedtls_des_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"des", mbedtls_des_self_test},
#endif
-
#if defined(MBEDTLS_AES_C)
- if( mbedtls_aes_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"aes", mbedtls_aes_self_test},
#endif
-
#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C)
- if( mbedtls_gcm_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"gcm", mbedtls_gcm_self_test},
#endif
-
#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C)
- if( mbedtls_ccm_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"ccm", mbedtls_ccm_self_test},
#endif
-
#if defined(MBEDTLS_CMAC_C)
- if( ( mbedtls_cmac_self_test( v ) ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"cmac", mbedtls_cmac_self_test},
#endif
-
#if defined(MBEDTLS_BASE64_C)
- if( mbedtls_base64_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"base64", mbedtls_base64_self_test},
#endif
-
#if defined(MBEDTLS_BIGNUM_C)
- if( mbedtls_mpi_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"mpi", mbedtls_mpi_self_test},
#endif
-
#if defined(MBEDTLS_RSA_C)
- if( mbedtls_rsa_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"rsa", mbedtls_rsa_self_test},
#endif
-
#if defined(MBEDTLS_X509_USE_C)
- if( mbedtls_x509_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"x509", mbedtls_x509_self_test},
#endif
-
#if defined(MBEDTLS_XTEA_C)
- if( mbedtls_xtea_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"xtea", mbedtls_xtea_self_test},
#endif
-
#if defined(MBEDTLS_CAMELLIA_C)
- if( mbedtls_camellia_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"camellia", mbedtls_camellia_self_test},
#endif
-
#if defined(MBEDTLS_CTR_DRBG_C)
- if( mbedtls_ctr_drbg_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"ctr_drbg", mbedtls_ctr_drbg_self_test},
#endif
-
#if defined(MBEDTLS_HMAC_DRBG_C)
- if( mbedtls_hmac_drbg_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"hmac_drbg", mbedtls_hmac_drbg_self_test},
#endif
-
#if defined(MBEDTLS_ECP_C)
- if( mbedtls_ecp_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"ecp", mbedtls_ecp_self_test},
#endif
-
#if defined(MBEDTLS_ECJPAKE_C)
- if( mbedtls_ecjpake_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"ecjpake", mbedtls_ecjpake_self_test},
#endif
-
#if defined(MBEDTLS_DHM_C)
- if( mbedtls_dhm_self_test( v ) != 0 )
- {
- suites_failed++;
- }
- suites_tested++;
+ {"dhm", mbedtls_dhm_self_test},
#endif
-
#if defined(MBEDTLS_ENTROPY_C)
+ {"entropy", mbedtls_entropy_self_test_wrapper},
+#endif
+#if defined(MBEDTLS_PKCS5_C)
+ {"pkcs5", mbedtls_pkcs5_self_test},
+#endif
+/* Slower test after the faster ones */
+#if defined(MBEDTLS_TIMING_C)
+ {"timing", mbedtls_timing_self_test},
+#endif
+/* Heap test comes last */
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
+ {"memory_buffer_alloc", mbedtls_memory_buffer_alloc_free_and_self_test},
+#endif
+ {NULL, NULL}
+};
+#endif /* MBEDTLS_SELF_TEST */
-#if defined(MBEDTLS_ENTROPY_NV_SEED) && !defined(MBEDTLS_NO_PLATFORM_ENTROPY)
- create_entropy_seed_file();
+int main( int argc, char *argv[] )
+{
+#if defined(MBEDTLS_SELF_TEST)
+ const selftest_t *test;
+#endif /* MBEDTLS_SELF_TEST */
+ char **argp;
+ int v = 1; /* v=1 for verbose mode */
+ int exclude_mode = 0;
+ int suites_tested = 0, suites_failed = 0;
+#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_SELF_TEST)
+ unsigned char buf[1000000];
#endif
+ void *pointer;
- if( mbedtls_entropy_self_test( v ) != 0 )
+ /*
+ * The C standard doesn't guarantee that all-bits-0 is the representation
+ * of a NULL pointer. We do however use that in our code for initializing
+ * structures, which should work on every modern platform. Let's be sure.
+ */
+ memset( &pointer, 0, sizeof( void * ) );
+ if( pointer != NULL )
{
- suites_failed++;
+ mbedtls_printf( "all-bits-zero is not a NULL pointer\n" );
+ mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
- suites_tested++;
-#endif
-#if defined(MBEDTLS_PKCS5_C)
- if( mbedtls_pkcs5_self_test( v ) != 0 )
+ /*
+ * Make sure we have a snprintf that correctly zero-terminates
+ */
+ if( run_test_snprintf() != 0 )
{
- suites_failed++;
+ mbedtls_printf( "the snprintf implementation is broken\n" );
+ mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
- suites_tested++;
-#endif
-
-/* Slow tests last */
-#if defined(MBEDTLS_TIMING_C)
- if( mbedtls_timing_self_test( v ) != 0 )
+ for( argp = argv + ( argc >= 1 ? 1 : argc ); *argp != NULL; ++argp )
{
- suites_failed++;
+ if( strcmp( *argp, "--quiet" ) == 0 ||
+ strcmp( *argp, "-q" ) == 0 )
+ {
+ v = 0;
+ }
+ else if( strcmp( *argp, "--exclude" ) == 0 ||
+ strcmp( *argp, "-x" ) == 0 )
+ {
+ exclude_mode = 1;
+ }
+ else
+ break;
}
- suites_tested++;
-#endif
if( v != 0 )
- {
-#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG)
- mbedtls_memory_buffer_alloc_status();
-#endif
- }
+ mbedtls_printf( "\n" );
+
+#if defined(MBEDTLS_SELF_TEST)
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
- mbedtls_memory_buffer_alloc_free();
- if( mbedtls_memory_buffer_alloc_self_test( v ) != 0 )
+ mbedtls_memory_buffer_alloc_init( buf, sizeof(buf) );
+#endif
+
+ if( *argp != NULL && exclude_mode == 0 )
{
- suites_failed++;
+ /* Run the specified tests */
+ for( ; *argp != NULL; argp++ )
+ {
+ for( test = selftests; test->name != NULL; test++ )
+ {
+ if( !strcmp( *argp, test->name ) )
+ {
+ if( test->function( v ) != 0 )
+ {
+ suites_failed++;
+ }
+ suites_tested++;
+ break;
+ }
+ }
+ if( test->name == NULL )
+ {
+ mbedtls_printf( " Test suite %s not available -> failed\n\n", *argp );
+ suites_failed++;
+ }
+ }
+ }
+ else
+ {
+ /* Run all the tests except excluded ones */
+ for( test = selftests; test->name != NULL; test++ )
+ {
+ if( exclude_mode )
+ {
+ char **excluded;
+ for( excluded = argp; *excluded != NULL; ++excluded )
+ {
+ if( !strcmp( *excluded, test->name ) )
+ break;
+ }
+ if( *excluded )
+ {
+ if( v )
+ mbedtls_printf( " Skip: %s\n", test->name );
+ continue;
+ }
+ }
+ if( test->function( v ) != 0 )
+ {
+ suites_failed++;
+ }
+ suites_tested++;
+ }
}
- suites_tested++;
-#endif
#else
+ (void) exclude_mode;
mbedtls_printf( " MBEDTLS_SELF_TEST not defined.\n" );
#endif
#include "mbedtls/x509_csr.h"
#include "mbedtls/entropy.h"
#include "mbedtls/ctr_drbg.h"
+#include "mbedtls/md.h"
#include "mbedtls/error.h"
#include <stdio.h>
#if defined(MBEDTLS_X509_CSR_PARSE_C)
#define USAGE_CSR \
- " request_file=%%s default: (empty)\n" \
- " If request_file is specified, subject_key,\n" \
- " subject_pwd and subject_name are ignored!\n"
+ " request_file=%%s default: (empty)\n" \
+ " If request_file is specified, subject_key,\n" \
+ " subject_pwd and subject_name are ignored!\n"
#else
#define USAGE_CSR ""
#endif /* MBEDTLS_X509_CSR_PARSE_C */
#define DFL_MAX_PATHLEN -1
#define DFL_KEY_USAGE 0
#define DFL_NS_CERT_TYPE 0
+#define DFL_VERSION 3
+#define DFL_AUTH_IDENT 1
+#define DFL_SUBJ_IDENT 1
+#define DFL_CONSTRAINTS 1
+#define DFL_DIGEST MBEDTLS_MD_SHA256
#define USAGE \
"\n usage: cert_write param=<>...\n" \
"\n acceptable parameters:\n" \
USAGE_CSR \
- " subject_key=%%s default: subject.key\n" \
- " subject_pwd=%%s default: (empty)\n" \
- " subject_name=%%s default: CN=Cert,O=mbed TLS,C=UK\n" \
+ " subject_key=%%s default: subject.key\n" \
+ " subject_pwd=%%s default: (empty)\n" \
+ " subject_name=%%s default: CN=Cert,O=mbed TLS,C=UK\n" \
"\n" \
- " issuer_crt=%%s default: (empty)\n" \
- " If issuer_crt is specified, issuer_name is\n" \
- " ignored!\n" \
- " issuer_name=%%s default: CN=CA,O=mbed TLS,C=UK\n" \
+ " issuer_crt=%%s default: (empty)\n" \
+ " If issuer_crt is specified, issuer_name is\n" \
+ " ignored!\n" \
+ " issuer_name=%%s default: CN=CA,O=mbed TLS,C=UK\n" \
"\n" \
- " selfsign=%%d default: 0 (false)\n" \
- " If selfsign is enabled, issuer_name and\n" \
- " issuer_key are required (issuer_crt and\n" \
- " subject_* are ignored\n" \
- " issuer_key=%%s default: ca.key\n" \
- " issuer_pwd=%%s default: (empty)\n" \
- " output_file=%%s default: cert.crt\n" \
- " serial=%%s default: 1\n" \
- " not_before=%%s default: 20010101000000\n"\
- " not_after=%%s default: 20301231235959\n"\
- " is_ca=%%d default: 0 (disabled)\n" \
- " max_pathlen=%%d default: -1 (none)\n" \
- " key_usage=%%s default: (empty)\n" \
- " Comma-separated-list of values:\n" \
- " digital_signature\n" \
- " non_repudiation\n" \
- " key_encipherment\n" \
- " data_encipherment\n" \
- " key_agreement\n" \
- " key_cert_sign\n" \
- " crl_sign\n" \
- " ns_cert_type=%%s default: (empty)\n" \
- " Comma-separated-list of values:\n" \
- " ssl_client\n" \
- " ssl_server\n" \
- " email\n" \
- " object_signing\n" \
- " ssl_ca\n" \
- " email_ca\n" \
- " object_signing_ca\n" \
+ " selfsign=%%d default: 0 (false)\n" \
+ " If selfsign is enabled, issuer_name and\n" \
+ " issuer_key are required (issuer_crt and\n" \
+ " subject_* are ignored\n" \
+ " issuer_key=%%s default: ca.key\n" \
+ " issuer_pwd=%%s default: (empty)\n" \
+ " output_file=%%s default: cert.crt\n" \
+ " serial=%%s default: 1\n" \
+ " not_before=%%s default: 20010101000000\n"\
+ " not_after=%%s default: 20301231235959\n"\
+ " is_ca=%%d default: 0 (disabled)\n" \
+ " max_pathlen=%%d default: -1 (none)\n" \
+ " md=%%s default: SHA256\n" \
+ " Supported values:\n" \
+ " MD5, SHA1, SHA256, SHA512\n"\
+ " version=%%d default: 3\n" \
+ " Possible values: 1, 2, 3\n"\
+ " subject_identifier=%%s default: 1\n" \
+ " Possible values: 0, 1\n" \
+ " (Considered for v3 only)\n"\
+ " authority_identifier=%%s default: 1\n" \
+ " Possible values: 0, 1\n" \
+ " (Considered for v3 only)\n"\
+ " basic_constraints=%%d default: 1\n" \
+ " Possible values: 0, 1\n" \
+ " (Considered for v3 only)\n"\
+ " key_usage=%%s default: (empty)\n" \
+ " Comma-separated-list of values:\n" \
+ " digital_signature\n" \
+ " non_repudiation\n" \
+ " key_encipherment\n" \
+ " data_encipherment\n" \
+ " key_agreement\n" \
+ " key_cert_sign\n" \
+ " crl_sign\n" \
+ " (Considered for v3 only)\n"\
+ " ns_cert_type=%%s default: (empty)\n" \
+ " Comma-separated-list of values:\n" \
+ " ssl_client\n" \
+ " ssl_server\n" \
+ " email\n" \
+ " object_signing\n" \
+ " ssl_ca\n" \
+ " email_ca\n" \
+ " object_signing_ca\n" \
"\n"
/*
int selfsign; /* selfsign the certificate */
int is_ca; /* is a CA certificate */
int max_pathlen; /* maximum CA path length */
+ int authority_identifier; /* add authority identifier to CRT */
+ int subject_identifier; /* add subject identifier to CRT */
+ int basic_constraints; /* add basic constraints ext to CRT */
+ int version; /* CRT version */
+ mbedtls_md_type_t md; /* Hash used for signing */
unsigned char key_usage; /* key usage flags */
unsigned char ns_cert_type; /* NS cert type */
} opt;
size_t len = 0;
memset( output_buf, 0, 4096 );
- if( ( ret = mbedtls_x509write_crt_pem( crt, output_buf, 4096, f_rng, p_rng ) ) < 0 )
+ if( ( ret = mbedtls_x509write_crt_pem( crt, output_buf, 4096,
+ f_rng, p_rng ) ) < 0 )
return( ret );
len = strlen( (char *) output_buf );
* Set to sane values
*/
mbedtls_x509write_crt_init( &crt );
- mbedtls_x509write_crt_set_md_alg( &crt, MBEDTLS_MD_SHA256 );
mbedtls_pk_init( &loaded_issuer_key );
mbedtls_pk_init( &loaded_subject_key );
mbedtls_mpi_init( &serial );
opt.max_pathlen = DFL_MAX_PATHLEN;
opt.key_usage = DFL_KEY_USAGE;
opt.ns_cert_type = DFL_NS_CERT_TYPE;
+ opt.version = DFL_VERSION - 1;
+ opt.md = DFL_DIGEST;
+ opt.subject_identifier = DFL_SUBJ_IDENT;
+ opt.authority_identifier = DFL_AUTH_IDENT;
+ opt.basic_constraints = DFL_CONSTRAINTS;
for( i = 1; i < argc; i++ )
{
{
opt.serial = q;
}
+ else if( strcmp( p, "authority_identifier" ) == 0 )
+ {
+ opt.authority_identifier = atoi( q );
+ if( opt.authority_identifier != 0 &&
+ opt.authority_identifier != 1 )
+ {
+ mbedtls_printf( "Invalid argument for option %s\n", p );
+ goto usage;
+ }
+ }
+ else if( strcmp( p, "subject_identifier" ) == 0 )
+ {
+ opt.subject_identifier = atoi( q );
+ if( opt.subject_identifier != 0 &&
+ opt.subject_identifier != 1 )
+ {
+ mbedtls_printf( "Invalid argument for option %s\n", p );
+ goto usage;
+ }
+ }
+ else if( strcmp( p, "basic_constraints" ) == 0 )
+ {
+ opt.basic_constraints = atoi( q );
+ if( opt.basic_constraints != 0 &&
+ opt.basic_constraints != 1 )
+ {
+ mbedtls_printf( "Invalid argument for option %s\n", p );
+ goto usage;
+ }
+ }
+ else if( strcmp( p, "md" ) == 0 )
+ {
+ if( strcmp( q, "SHA1" ) == 0 )
+ opt.md = MBEDTLS_MD_SHA1;
+ else if( strcmp( q, "SHA256" ) == 0 )
+ opt.md = MBEDTLS_MD_SHA256;
+ else if( strcmp( q, "SHA512" ) == 0 )
+ opt.md = MBEDTLS_MD_SHA512;
+ else if( strcmp( q, "MD5" ) == 0 )
+ opt.md = MBEDTLS_MD_MD5;
+ else
+ {
+ mbedtls_printf( "Invalid argument for option %s\n", p );
+ goto usage;
+ }
+ }
+ else if( strcmp( p, "version" ) == 0 )
+ {
+ opt.version = atoi( q );
+ if( opt.version < 1 || opt.version > 3 )
+ {
+ mbedtls_printf( "Invalid argument for option %s\n", p );
+ goto usage;
+ }
+ opt.version--;
+ }
else if( strcmp( p, "selfsign" ) == 0 )
{
opt.selfsign = atoi( q );
if( opt.selfsign < 0 || opt.selfsign > 1 )
+ {
+ mbedtls_printf( "Invalid argument for option %s\n", p );
goto usage;
+ }
}
else if( strcmp( p, "is_ca" ) == 0 )
{
opt.is_ca = atoi( q );
if( opt.is_ca < 0 || opt.is_ca > 1 )
+ {
+ mbedtls_printf( "Invalid argument for option %s\n", p );
goto usage;
+ }
}
else if( strcmp( p, "max_pathlen" ) == 0 )
{
opt.max_pathlen = atoi( q );
if( opt.max_pathlen < -1 || opt.max_pathlen > 127 )
+ {
+ mbedtls_printf( "Invalid argument for option %s\n", p );
goto usage;
+ }
}
else if( strcmp( p, "key_usage" ) == 0 )
{
else if( strcmp( q, "crl_sign" ) == 0 )
opt.key_usage |= MBEDTLS_X509_KU_CRL_SIGN;
else
+ {
+ mbedtls_printf( "Invalid argument for option %s\n", p );
goto usage;
+ }
q = r;
}
else if( strcmp( q, "object_signing_ca" ) == 0 )
opt.ns_cert_type |= MBEDTLS_X509_NS_CERT_TYPE_OBJECT_SIGNING_CA;
else
+ {
+ mbedtls_printf( "Invalid argument for option %s\n", p );
goto usage;
+ }
q = r;
}
strlen( pers ) ) ) != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d - %s\n", ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d - %s\n",
+ ret, buf );
goto exit;
}
if( ( ret = mbedtls_mpi_read_string( &serial, 10, opt.serial ) ) != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_mpi_read_string returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_mpi_read_string "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
if( ( ret = mbedtls_x509_crt_parse_file( &issuer_crt, opt.issuer_crt ) ) != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
if( ret < 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
if( ( ret = mbedtls_x509_csr_parse_file( &csr, opt.request_file ) ) != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509_csr_parse_file returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_x509_csr_parse_file "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
if( ret < 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_x509_dn_gets "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
if( ret != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
if( ret != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile "
+ "returned -x%02x - %s\n\n", -ret, buf );
goto exit;
}
mbedtls_mpi_cmp_mpi( &mbedtls_pk_rsa( issuer_crt.pk )->E,
&mbedtls_pk_rsa( *issuer_key )->E ) != 0 )
{
- mbedtls_printf( " failed\n ! issuer_key does not match issuer certificate\n\n" );
+ mbedtls_printf( " failed\n ! issuer_key does not match "
+ "issuer certificate\n\n" );
ret = -1;
goto exit;
}
if( ( ret = mbedtls_x509write_crt_set_subject_name( &crt, opt.subject_name ) ) != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject_name returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject_name "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
if( ( ret = mbedtls_x509write_crt_set_issuer_name( &crt, opt.issuer_name ) ) != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_issuer_name returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_issuer_name "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
mbedtls_printf( " . Setting certificate values ..." );
fflush( stdout );
+ mbedtls_x509write_crt_set_version( &crt, opt.version );
+ mbedtls_x509write_crt_set_md_alg( &crt, opt.md );
+
ret = mbedtls_x509write_crt_set_serial( &crt, &serial );
if( ret != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_serial returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_serial "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
if( ret != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_validity returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_validity "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
mbedtls_printf( " ok\n" );
- mbedtls_printf( " . Adding the Basic Constraints extension ..." );
- fflush( stdout );
-
- ret = mbedtls_x509write_crt_set_basic_constraints( &crt, opt.is_ca,
- opt.max_pathlen );
- if( ret != 0 )
+ if( opt.version == MBEDTLS_X509_CRT_VERSION_3 &&
+ opt.basic_constraints != 0 )
{
- mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! x509write_crt_set_basic_contraints returned -0x%02x - %s\n\n", -ret, buf );
- goto exit;
- }
+ mbedtls_printf( " . Adding the Basic Constraints extension ..." );
+ fflush( stdout );
- mbedtls_printf( " ok\n" );
+ ret = mbedtls_x509write_crt_set_basic_constraints( &crt, opt.is_ca,
+ opt.max_pathlen );
+ if( ret != 0 )
+ {
+ mbedtls_strerror( ret, buf, 1024 );
+ mbedtls_printf( " failed\n ! x509write_crt_set_basic_contraints "
+ "returned -0x%04x - %s\n\n", -ret, buf );
+ goto exit;
+ }
-#if defined(MBEDTLS_SHA1_C)
- mbedtls_printf( " . Adding the Subject Key Identifier ..." );
- fflush( stdout );
+ mbedtls_printf( " ok\n" );
+ }
- ret = mbedtls_x509write_crt_set_subject_key_identifier( &crt );
- if( ret != 0 )
+#if defined(MBEDTLS_SHA1_C)
+ if( opt.version == MBEDTLS_X509_CRT_VERSION_3 &&
+ opt.subject_identifier != 0 )
{
- mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject_key_identifier returned -0x%02x - %s\n\n", -ret, buf );
- goto exit;
- }
+ mbedtls_printf( " . Adding the Subject Key Identifier ..." );
+ fflush( stdout );
- mbedtls_printf( " ok\n" );
+ ret = mbedtls_x509write_crt_set_subject_key_identifier( &crt );
+ if( ret != 0 )
+ {
+ mbedtls_strerror( ret, buf, 1024 );
+ mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_subject"
+ "_key_identifier returned -0x%04x - %s\n\n",
+ -ret, buf );
+ goto exit;
+ }
- mbedtls_printf( " . Adding the Authority Key Identifier ..." );
- fflush( stdout );
+ mbedtls_printf( " ok\n" );
+ }
- ret = mbedtls_x509write_crt_set_authority_key_identifier( &crt );
- if( ret != 0 )
+ if( opt.version == MBEDTLS_X509_CRT_VERSION_3 &&
+ opt.authority_identifier != 0 )
{
- mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_authority_key_identifier returned -0x%02x - %s\n\n", -ret, buf );
- goto exit;
- }
+ mbedtls_printf( " . Adding the Authority Key Identifier ..." );
+ fflush( stdout );
- mbedtls_printf( " ok\n" );
+ ret = mbedtls_x509write_crt_set_authority_key_identifier( &crt );
+ if( ret != 0 )
+ {
+ mbedtls_strerror( ret, buf, 1024 );
+ mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_authority_"
+ "key_identifier returned -0x%04x - %s\n\n",
+ -ret, buf );
+ goto exit;
+ }
+
+ mbedtls_printf( " ok\n" );
+ }
#endif /* MBEDTLS_SHA1_C */
- if( opt.key_usage )
+ if( opt.version == MBEDTLS_X509_CRT_VERSION_3 &&
+ opt.key_usage != 0 )
{
mbedtls_printf( " . Adding the Key Usage extension ..." );
fflush( stdout );
if( ret != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_key_usage returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_key_usage "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
mbedtls_printf( " ok\n" );
}
- if( opt.ns_cert_type )
+ if( opt.version == MBEDTLS_X509_CRT_VERSION_3 &&
+ opt.ns_cert_type != 0 )
{
mbedtls_printf( " . Adding the NS Cert Type extension ..." );
fflush( stdout );
if( ret != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_ns_cert_type returned -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! mbedtls_x509write_crt_set_ns_cert_type "
+ "returned -0x%04x - %s\n\n", -ret, buf );
goto exit;
}
mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
{
mbedtls_strerror( ret, buf, 1024 );
- mbedtls_printf( " failed\n ! write_certifcate -0x%02x - %s\n\n", -ret, buf );
+ mbedtls_printf( " failed\n ! write_certificate -0x%04x - %s\n\n",
+ -ret, buf );
goto exit;
}
#
# Full usage description provided below.
#
-# Things that shouldn't be enabled with "full".
+# The following options are disabled instead of enabled with "full".
#
# MBEDTLS_TEST_NULL_ENTROPY
# MBEDTLS_DEPRECATED_REMOVED
# MBEDTLS_NO_PLATFORM_ENTROPY
# MBEDTLS_REMOVE_ARC4_CIPHERSUITES
# MBEDTLS_SSL_HW_RECORD_ACCEL
+# MBEDTLS_RSA_NO_CRT
# MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3
# MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
# - this could be enabled if the respective tests were adapted
my $usage = <<EOU;
$0 [-f <file> | --file <file>] [-o | --force]
[set <symbol> <value> | unset <symbol> | get <symbol> |
- full | realfull]
+ full | realfull | baremetal]
Commands
set <symbol> [<value>] - Uncomments or adds a #define for the <symbol> to
unset <symbol> - Comments out the #define for the given symbol if
present in the configuration file.
get <symbol> - Finds the #define for the given symbol, returning
- an exitcode of 0 if the symbol is found, and -1 if
+ an exitcode of 0 if the symbol is found, and 1 if
not. The value of the symbol is output if one is
specified in the configuration file.
full - Uncomments all #define's in the configuration file
excluding some reserved symbols, until the
'Module configuration options' section
realfull - Uncomments all #define's with no exclusions
+ baremetal - Sets full configuration suitable for baremetal build.
Options
-f | --file <filename> - The file or file path for the configuration file
used:
$config_file
-o | --force - If the symbol isn't present in the configuration
- file when setting it's value, a #define is
+ file when setting its value, a #define is
appended to the end of the file.
EOU
MBEDTLS_ECP_DP_M511_ENABLED
MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
MBEDTLS_NO_PLATFORM_ENTROPY
+MBEDTLS_RSA_NO_CRT
MBEDTLS_REMOVE_ARC4_CIPHERSUITES
MBEDTLS_SSL_HW_RECORD_ACCEL
MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3
MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION
MBEDTLS_ZLIB_SUPPORT
MBEDTLS_PKCS11_C
+MBEDTLS_NO_UDBL_DIVISION
_ALT\s*$
);
+# Things that should be disabled in "baremetal"
+my @excluded_baremetal = qw(
+MBEDTLS_NET_C
+MBEDTLS_TIMING_C
+MBEDTLS_FS_IO
+MBEDTLS_ENTROPY_NV_SEED
+MBEDTLS_HAVE_TIME
+MBEDTLS_HAVE_TIME_DATE
+MBEDTLS_DEPRECATED_WARNING
+MBEDTLS_HAVEGE_C
+MBEDTLS_THREADING_C
+MBEDTLS_THREADING_PTHREAD
+MBEDTLS_MEMORY_BACKTRACE
+MBEDTLS_MEMORY_BUFFER_ALLOC_C
+MBEDTLS_PLATFORM_TIME_ALT
+MBEDTLS_PLATFORM_FPRINTF_ALT
+);
+
# Things that should be enabled in "full" even if they match @excluded
my @non_excluded = qw(
PLATFORM_[A-Z0-9]+_ALT
);
+# Things that should be enabled in "baremetal"
+my @non_excluded_baremetal = qw(
+MBEDTLS_NO_PLATFORM_ENTROPY
+);
+
# Process the command line arguments
my $force_option = 0;
# ...else assume it's a command
$action = $arg;
- if ($action eq "full" || $action eq "realfull") {
+ if ($action eq "full" || $action eq "realfull" || $action eq "baremetal" ) {
# No additional parameters
die $usage if @ARGV;
my @config_lines = <$config_read>;
close $config_read;
-my ($exclude_re, $no_exclude_re);
+# Add required baremetal symbols to the list that is included.
+if ( $action eq "baremetal" ) {
+ @non_excluded = ( @non_excluded, @non_excluded_baremetal );
+}
+
+my ($exclude_re, $no_exclude_re, $exclude_baremetal_re);
if ($action eq "realfull") {
$exclude_re = qr/^$/;
$no_exclude_re = qr/./;
$exclude_re = join '|', @excluded;
$no_exclude_re = join '|', @non_excluded;
}
+if ( $action eq "baremetal" ) {
+ $exclude_baremetal_re = join '|', @excluded_baremetal;
+}
-open my $config_write, '>', $config_file or die "write $config_file: $!\n";
+my $config_write = undef;
+if ($action ne "get") {
+ open $config_write, '>', $config_file or die "write $config_file: $!\n";
+}
my $done;
for my $line (@config_lines) {
- if ($action eq "full" || $action eq "realfull") {
+ if ($action eq "full" || $action eq "realfull" || $action eq "baremetal" ) {
if ($line =~ /name SECTION: Module configuration options/) {
$done = 1;
}
if (!$done && $line =~ m!^//\s?#define! &&
- ( $line !~ /$exclude_re/ || $line =~ /$no_exclude_re/ ) ) {
+ ( $line !~ /$exclude_re/ || $line =~ /$no_exclude_re/ ) &&
+ ( $action ne "baremetal" || ( $line !~ /$exclude_baremetal_re/ ) ) ) {
$line =~ s!^//\s?!!;
}
if (!$done && $line =~ m!^\s?#define! &&
- ! ( $line !~ /$exclude_re/ || $line =~ /$no_exclude_re/ ) ) {
+ ! ( ( $line !~ /$exclude_re/ || $line =~ /$no_exclude_re/ ) &&
+ ( $action ne "baremetal" || ( $line !~ /$exclude_baremetal_re/ ) ) ) ) {
$line =~ s!^!//!;
}
} elsif ($action eq "unset") {
$done = 1;
}
} elsif (!$done && $action eq "get") {
- if ($line =~ /^\s*#define\s*$name\s*(.*)\s*\b/) {
+ if ($line =~ /^\s*#define\s*$name(?:\s+(.*?))\s*(?:$|\/\*|\/\/)/) {
$value = $1;
$done = 1;
}
}
- print $config_write $line;
+ if (defined $config_write) {
+ print $config_write $line or die "write $config_file: $!\n";
+ }
}
# Did the set command work?
-if ($action eq "set"&& $force_option && !$done) {
+if ($action eq "set" && $force_option && !$done) {
# If the force option was set, append the symbol to the end of the file
my $line = "#define $name";
$line .= "\n";
$done = 1;
- print $config_write $line;
+ print $config_write $line or die "write $config_file: $!\n";
}
-close $config_write;
+if (defined $config_write) {
+ close $config_write or die "close $config_file: $!\n";
+}
if ($action eq "get") {
- if($done) {
+ if ($done) {
if ($value ne '') {
- print $value;
+ print "$value\n";
}
exit 0;
} else {
# If the symbol was not found, return an error
- exit -1;
+ exit 1;
}
}
ssl_set_arc4_support mbedtls_ssl_conf_arc4_support
ssl_set_authmode mbedtls_ssl_conf_authmode
ssl_set_bio mbedtls_ssl_set_bio
-ssl_set_bio_timeout mbedtls_ssl_set_bio_timeout
ssl_set_ca_chain mbedtls_ssl_conf_ca_chain
ssl_set_cbc_record_splitting mbedtls_ssl_conf_cbc_record_splitting
ssl_set_ciphersuites mbedtls_ssl_conf_ciphersuites
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<PropertyGroup Label="UserMacros" />\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<LinkIncremental>true</LinkIncremental>\r
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>\r
</PropertyGroup>\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
<LinkIncremental>true</LinkIncremental>\r
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>\r
</PropertyGroup>\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
<LinkIncremental>false</LinkIncremental>\r
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>\r
</PropertyGroup>\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<LinkIncremental>false</LinkIncremental>\r
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>\r
</PropertyGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
expression x, y;
statement S;
@@
- x = mbedtls_malloc(...);
- y = mbedtls_malloc(...);
+ x = mbedtls_calloc(...);
+ y = mbedtls_calloc(...);
...
* if (x == NULL || y == NULL)
S
statement S;
@@
if (
-* (x = mbedtls_malloc(...)) == NULL
+* (x = mbedtls_calloc(...)) == NULL
||
-* (y = mbedtls_malloc(...)) == NULL
+* (y = mbedtls_calloc(...)) == NULL
)
S
#
# Configurations included:
# default include/mbedtls/config.h
-# yotta yotta/module/mbedtls/config.h
# thread configs/config-thread.h
# suite-b configs/config-suite-b.h
# psk configs/config-ccm-psk-tls1_2.h
log "$( arm-none-eabi-gcc --version | head -n1 )"
log "CFLAGS=$ARMGCC_FLAGS"
-# creates the yotta config
-yotta/create-module.sh >/dev/null
-
doit default include/mbedtls/config.h
-doit yotta yotta/module/mbedtls/config.h
doit thread configs/config-thread.h
doit suite-b configs/config-suite-b.h
doit psk configs/config-ccm-psk-tls1_2.h
my $error_format_file = $data_dir.'/error.fmt';
-my @low_level_modules = ( "AES", "ASN1", "BLOWFISH", "CAMELLIA", "BIGNUM",
- "BASE64", "XTEA", "PBKDF2", "OID",
- "PADLOCK", "DES", "NET", "CTR_DRBG", "ENTROPY",
- "HMAC_DRBG", "MD2", "MD4", "MD5", "RIPEMD160",
- "SHA1", "SHA256", "SHA512", "GCM", "THREADING", "CCM" );
-my @high_level_modules = ( "PEM", "X509", "DHM", "RSA", "ECP", "MD", "CIPHER", "SSL",
- "PK", "PKCS12", "PKCS5" );
+my @low_level_modules = qw( AES ARC4 ASN1 BASE64 BIGNUM BLOWFISH
+ CAMELLIA CCM CMAC CTR_DRBG DES
+ ENTROPY GCM HMAC_DRBG MD2 MD4 MD5
+ NET OID PADLOCK PBKDF2 RIPEMD160
+ SHA1 SHA256 SHA512 THREADING XTEA );
+my @high_level_modules = qw( CIPHER DHM ECP MD
+ PEM PK PKCS12 PKCS5
+ RSA SSL X509 );
my $line_separator = $/;
undef $/;
+++ /dev/null
-#!/usr/bin/perl
-
-# Check for malloc calls not shortly followed by initialisation.
-#
-# Known limitations:
-# - false negative: can't see allocations spanning more than one line
-# - possible false negatives, see patterns
-# - false positive: malloc-malloc-init-init is not accepted
-# - false positives: "non-standard" init functions (eg, the things being
-# initialised is not the first arg, or initialise struct members)
-#
-# Since false positives are expected, the results must be manually reviewed.
-#
-# Typical usage: scripts/malloc-init.pl library/*.c
-
-use warnings;
-use strict;
-
-use utf8;
-use open qw(:std utf8);
-
-my $limit = 7;
-my $inits = qr/memset|memcpy|_init|fread|base64_..code/;
-
-# cases to bear in mind:
-#
-# 0. foo = malloc(...); memset( foo, ... );
-# 1. *foo = malloc(...); memset( *foo, ... );
-# 2. type *foo = malloc(...); memset( foo, ...);
-# 3. foo = malloc(...); foo_init( (type *) foo );
-# 4. foo = malloc(...); for(i=0..n) { init( &foo[i] ); }
-#
-# The chosen patterns are a bit relaxed, but unlikely to cause false positives
-# in real code (initialising *foo or &foo instead of foo will likely be caught
-# by functional tests).
-#
-my $id = qr/([a-zA-Z-0-9_\->\.]*)/;
-my $prefix = qr/\s(?:\*?|\&?|\([a-z_]* \*\))\s*/;
-
-my $name;
-my $line;
-my @bad;
-
-die "Usage: $0 file.c [...]\n" unless @ARGV;
-
-while (my $file = shift @ARGV)
-{
- open my $fh, "<", $file or die "read $file failed: $!\n";
- while (<$fh>)
- {
- if( /mbedtls_malloc\(/ ) {
- if( /$id\s*=.*mbedtls_malloc\(/ ) {
- push @bad, "$file:$line:$name" if $name;
- $name = $1;
- $line = $.;
- } else {
- push @bad, "$file:$.:???" unless /return mbedtls_malloc/;
- }
- } elsif( $name && /(?:$inits)\($prefix\Q$name\E\b/ ) {
- undef $name;
- } elsif( $name && $. - $line > $limit ) {
- push @bad, "$file:$line:$name";
- undef $name;
- undef $line;
- }
- }
- close $fh or die;
-}
-
-print "$_\n" for @bad;
-#!/bin/sh
-#
+#! /usr/bin/env sh
+
# output_env.sh
#
# This file is part of mbed TLS (https://tls.mbed.org)
# - version of libc, clang, asan and valgrind if installed
# - version of gnuTLS and OpenSSL
+print_version()
+{
+ BIN="$1"
+ shift
+ ARGS="$1"
+ shift
+ FAIL_MSG="$1"
+ shift
+
+ if ! `type "$BIN" > /dev/null 2>&1`; then
+ echo "* $FAIL_MSG"
+ return 0
+ fi
+
+ BIN=`which "$BIN"`
+ VERSION_STR=`$BIN $ARGS 2>&1`
+
+ # Apply all filters
+ while [ $# -gt 0 ]; do
+ FILTER="$1"
+ shift
+ VERSION_STR=`echo "$VERSION_STR" | $FILTER`
+ done
+
+ echo "* ${BIN##*/}: $BIN: $VERSION_STR"
+}
+
+print_version "uname" "-a" ""
echo
-echo "* Operating system and architecture:"
-uname -a
+: ${ARMC5_CC:=armcc}
+print_version "$ARMC5_CC" "--vsn" "armcc not found!" "head -n 2"
echo
-if `hash armcc > /dev/null 2>&1`; then
- echo "* armcc:"
- armcc --vsn | head -n 2
-else
- echo "* armcc not found!"
-fi
+: ${ARMC6_CC:=armclang}
+print_version "$ARMC6_CC" "--vsn" "armclang not found!" "head -n 2"
echo
-if `hash arm-none-eabi-gcc > /dev/null 2>&1`; then
- echo "* gcc-arm:"
- arm-none-eabi-gcc --version | head -n 1
-else
- echo "* gcc-arm not found!"
-fi
+print_version "arm-none-eabi-gcc" "--version" "gcc-arm not found!" "head -n 1"
echo
-if `hash gcc > /dev/null 2>&1`; then
- echo "* gcc:"
- gcc --version | head -n 1
-else
- echo "* gcc not found!"
-fi
+print_version "gcc" "--version" "gcc not found!" "head -n 1"
echo
-if `hash clang > /dev/null 2>&1`; then
- echo "* clang:"
- clang --version | head -n 2
- clang -v 2>&1 | grep Selected
-else
- echo "* clang not found!"
-fi
+print_version "clang" "--version" "clang not found" "head -n 2"
echo
-if `hash ldd > /dev/null 2>&1`; then
- echo "* libc:"
- ldd --version | head -n 1
-else
- echo "* No ldd present: can't determine libc version!"
-fi
+print_version "ldd" "--version" \
+ "No ldd present: can't determine libc version!" \
+ "head -n 1"
echo
-if `hash valgrind > /dev/null 2>&1`; then
- echo "* valgrind:"
- valgrind --version
-else
- echo "* valgrind not found!"
-fi
+print_version "valgrind" "--version" "valgrind not found!"
echo
-if `hash openssl > /dev/null 2>&1`; then
- echo "* openssl:"
- openssl version
-else
- echo "* openssl not found!"
-fi
-if [ -n "${OPENSSL+set}" ]; then
- echo
- if `hash "$OPENSSL" > /dev/null 2>&1`; then
- echo "* $OPENSSL at environment variable 'OPENSSL':"
- $OPENSSL version
- else
- echo "* $OPENSSL at environment variable 'OPENSSL' not found!"
- fi
-fi
+: ${OPENSSL:=openssl}
+print_version "$OPENSSL" "version" "openssl not found!"
+echo
if [ -n "${OPENSSL_LEGACY+set}" ]; then
+ print_version "$OPENSSL_LEGACY" "version" "openssl legacy version not found!"
echo
- if `hash "$OPENSSL_LEGACY" > /dev/null 2>&1`; then
- echo "* $OPENSSL_LEGACY at environment variable 'OPENSSL_LEGACY':"
- $OPENSSL_LEGACY version
- else
- echo "* $OPENSSL_LEGACY at environment variable 'OPENSSL_LEGACY' not found!"
- fi
fi
+: ${GNUTLS_CLI:=gnutls-cli}
+print_version "$GNUTLS_CLI" "--version" "gnuTLS client not found!" "head -n 1"
echo
-if `hash gnutls-cli > /dev/null 2>&1`; then
- echo "* gnuTLS client:"
- gnutls-cli --version | head -n 1
-else
- echo "* gnuTLS client not found!"
-fi
+: ${GNUTLS_SERV:=gnutls-serv}
+print_version "$GNUTLS_SERV" "--version" "gnuTLS server not found!" "head -n 1"
echo
-if `hash gnutls-serv > /dev/null 2>&1`; then
- echo "* gnuTLS server:"
- gnutls-serv --version | head -n 1
-else
- echo "* gnuTLS server not found!"
-fi
-
-if [ -n "${GNUTLS_CLI+set}" ]; then
- echo
- if `hash "$GNUTLS_CLI" > /dev/null 2>&1`; then
- echo "* $GNUTLS_CLI at environment variable 'GNUTLS_CLI':"
- $GNUTLS_CLI --version | head -n 1
- else
- echo "* $GNUTLS_CLI at environment variable 'GNUTLS_CLI' not found!"
- fi
-fi
-
-if [ -n "${GNUTLS_SERV+set}" ]; then
- echo
- if `hash "$GNUTLS_SERV" > /dev/null 2>&1`; then
- echo "* $GNUTLS_SERV at environment variable 'GNUTLS_SERV':"
- $GNUTLS_SERV --version | head -n 1
- else
- echo "* $GNUTLS_SERV at environment variable 'GNUTLS_SERV' not found!"
- fi
-fi
if [ -n "${GNUTLS_LEGACY_CLI+set}" ]; then
+ print_version "$GNUTLS_LEGACY_CLI" "--version" \
+ "gnuTLS client legacy version not found!" \
+ "head -n 1"
echo
- if `hash "$GNUTLS_LEGACY_CLI" > /dev/null 2>&1`; then
- echo "* $GNUTLS_LEGACY_CLI at environment variable 'GNUTLS_LEGACY_CLI':"
- $GNUTLS_LEGACY_CLI --version | head -n 1
- else
- echo "* $GNUTLS_LEGACY_CLI at environment variable 'GNUTLS_LEGACY_CLI' not found!"
- fi
fi
if [ -n "${GNUTLS_LEGACY_SERV+set}" ]; then
+ print_version "$GNUTLS_LEGACY_SERV" "--version" \
+ "gnuTLS server legacy version not found!" \
+ "head -n 1"
echo
- if `hash "$GNUTLS_LEGACY_SERV" > /dev/null 2>&1`; then
- echo "* $GNUTLS_LEGACY_SERV at environment variable 'GNUTLS_LEGACY_SERV':"
- $GNUTLS_LEGACY_SERV --version | head -n 1
- else
- echo "* $GNUTLS_LEGACY_SERV at environment variable 'GNUTLS_LEGACY_SERV' not found!"
- fi
fi
-echo
if `hash dpkg > /dev/null 2>&1`; then
echo "* asan:"
dpkg -s libasan2 2> /dev/null | grep -i version
else
echo "* No dpkg present: can't determine asan version!"
fi
-
echo
-
--- /dev/null
+@rm_calloc_cast@
+expression x, n, m;
+type T;
+@@
+ x =
+- (T *)
+ mbedtls_calloc(n, m)
+++ /dev/null
-@rm_malloc_cast@
-expression x, n;
-type T;
-@@
- x =
-- (T *)
- mbedtls_malloc(n)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_executable(test_suite_${data_name} test_suite_${data_name}.c)
target_link_libraries(test_suite_${data_name} ${libs})
- add_test(${data_name}-suite test_suite_${data_name})
+ add_test(${data_name}-suite test_suite_${data_name} --verbose)
endfunction(add_test_suite)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
if(MSVC)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w") # no warnings here
+ # If a warning level has been defined, suppress all warnings for test code
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX-")
endif(MSVC)
add_test_suite(aes aes.ecb)
if (CMAKE_HOST_UNIX)
set(command ln -s ${target} ${link})
else()
- set(command cmd.exe /c mklink /d ${link} ${target})
+ set(command cmd.exe /c mklink /j ${link} ${target})
endif()
execute_process(COMMAND ${command}
else
M_CLIENT_ARGS="$M_CLIENT_ARGS crt_file=none key_file=none"
fi
+
+ # Allow SHA-1. It's disabled by default for security reasons but
+ # our tests still use certificates signed with it.
+ M_SERVER_ARGS="$M_SERVER_ARGS allow_sha1=1"
+ M_CLIENT_ARGS="$M_CLIENT_ARGS allow_sha1=1"
;;
"PSK")
M_CLIENT_ARGS="$M_CLIENT_ARGS psk=6162636465666768696a6b6c6d6e6f70 crt_file=none key_file=none"
O_CLIENT_ARGS="$O_CLIENT_ARGS -psk 6162636465666768696a6b6c6d6e6f70"
G_CLIENT_ARGS="$G_CLIENT_ARGS --pskusername Client_identity --pskkey=6162636465666768696a6b6c6d6e6f70"
+
+ # Allow SHA-1. It's disabled by default for security reasons but
+ # our tests still use certificates signed with it.
+ M_SERVER_ARGS="$M_SERVER_ARGS allow_sha1=1"
+ M_CLIENT_ARGS="$M_CLIENT_ARGS allow_sha1=1"
;;
esac
}
fi
}
+# Wait for process $2 to be listening on port $1
+if type lsof >/dev/null 2>/dev/null; then
+ wait_server_start() {
+ START_TIME=$(date +%s)
+ if is_dtls "$MODE"; then
+ proto=UDP
+ else
+ proto=TCP
+ fi
+ while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
+ if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
+ echo "SERVERSTART TIMEOUT"
+ echo "SERVERSTART TIMEOUT" >> $SRV_OUT
+ break
+ fi
+ # Linux and *BSD support decimal arguments to sleep. On other
+ # OSes this may be a tight loop.
+ sleep 0.1 2>/dev/null || true
+ done
+ }
+else
+ echo "Warning: lsof not available, wait_server_start = sleep"
+ wait_server_start() {
+ sleep 2
+ }
+fi
+
+
# start_server <name>
# also saves name and command
start_server() {
while :; do echo bla; sleep 1; done | $SERVER_CMD >> $SRV_OUT 2>&1 &
PROCESS_ID=$!
- sleep 1
+ wait_server_start "$PORT" "$PROCESS_ID"
}
# terminate the running server
--- /dev/null
+cli-rsa.csr
+server2-rsa.csr
+test-ca.csr
--- /dev/null
+## This file contains a record of how some of the test data was
+## generated. The final build products are committed to the repository
+## as well to make sure that the test data is identical. You do not
+## need to use this makefile unless you're extending mbed TLS's tests.
+
+## Many data files were generated prior to the existence of this
+## makefile, so the method of their generation was not recorded.
+
+## Note that in addition to depending on the version of the data
+## generation tool, many of the build outputs are randomized, so
+## running this makefile twice would not produce the same results.
+
+## Tools
+OPENSSL ?= openssl
+MBEDTLS_CERT_WRITE ?= $(PWD)/../../programs/x509/cert_write
+
+## Build the generated test data. Note that since the final outputs
+## are committed to the repository, this target should do nothing on a
+## fresh checkout. Furthermore, since the generation is randomized,
+## re-running the same targets may result in differing files. The goal
+## of this makefile is primarily to serve as a record of how the
+## targets were generated in the first place.
+default: all_final
+
+all_intermediate := # temporary files
+all_final := # files used by tests
+
+
+
+################################################################
+#### Generate certificates from existing keys
+################################################################
+
+test_ca_crt = test-ca.crt
+test_ca_key_file_rsa = test-ca.key
+test_ca_pwd_rsa = PolarSSLTest
+test_ca_config_file = test-ca.opensslconf
+
+test-ca.csr: $(test_ca_key_file_rsa) $(test_ca_config_file)
+ $(OPENSSL) req -new -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=PolarSSL Test CA" -out $@
+all_intermediate += test-ca.csr
+test-ca-sha1.crt: $(test_ca_key_file_rsa) $(test_ca_config_file) test-ca.csr
+ $(OPENSSL) req -x509 -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 0 -days 3653 -sha1 -in test-ca.csr -out $@
+all_final += test-ca-sha1.crt
+test-ca-sha256.crt: $(test_ca_key_file_rsa) $(test_ca_config_file) test-ca.csr
+ $(OPENSSL) req -x509 -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 0 -days 3653 -sha256 -in test-ca.csr -out $@
+all_final += test-ca-sha256.crt
+
+crl-idp.pem: $(test_ca_crt) $(test_ca_key_file_rsa) $(test_ca_config_file)
+ $(OPENSSL) ca -gencrl -batch -cert $(test_ca_crt) -keyfile $(test_ca_key_file_rsa) -key $(test_ca_pwd_rsa) -config $(test_ca_config_file) -name test_ca -md sha256 -crldays 3653 -crlexts crl_ext_idp -out $@
+all_final += crl-idp.pem
+crl-idpnc.pem: $(test_ca_crt) $(test_ca_key_file_rsa) $(test_ca_config_file)
+ $(OPENSSL) ca -gencrl -batch -cert $(test_ca_crt) -keyfile $(test_ca_key_file_rsa) -key $(test_ca_pwd_rsa) -config $(test_ca_config_file) -name test_ca -md sha256 -crldays 3653 -crlexts crl_ext_idp_nc -out $@
+all_final += crl-idpnc.pem
+
+cli_crt_key_file_rsa = cli-rsa.key
+cli_crt_extensions_file = cli.opensslconf
+
+cli-rsa.csr: $(cli_crt_key_file_rsa)
+ $(OPENSSL) req -new -key $(cli_crt_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=PolarSSL Client 2" -out $@
+all_intermediate += cli-rsa.csr
+cli-rsa-sha1.crt: $(cli_crt_key_file_rsa) test-ca-sha1.crt cli-rsa.csr
+ $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha1.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha1 -in cli-rsa.csr -out $@
+all_final += cli-rsa-sha1.crt
+cli-rsa-sha256.crt: $(cli_crt_key_file_rsa) test-ca-sha256.crt cli-rsa.csr
+ $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha256.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha256 -in cli-rsa.csr -out $@
+all_final += cli-rsa-sha256.crt
+
+server2-rsa.csr: server2.key
+ $(OPENSSL) req -new -key server2.key -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=localhost" -out $@
+all_intermediate += server2-rsa.csr
+server2-sha256.crt: server2-rsa.csr
+ $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha256.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha256 -in server2-rsa.csr -out $@
+all_final += server2-sha256.crt
+
+rsa_pkcs1_2048_public.pem: server8.key
+ $(OPENSSL) rsa -in $< -outform PEM -RSAPublicKey_out -out $@
+all_final += rsa_pkcs1_2048_public.pem
+
+rsa_pkcs1_2048_public.der: rsa_pkcs1_2048_public.pem
+ $(OPENSSL) rsa -RSAPublicKey_in -in $< -outform DER -RSAPublicKey_out -out $@
+all_final += rsa_pkcs1_2048_public.der
+
+rsa_pkcs8_2048_public.pem: server8.key
+ $(OPENSSL) rsa -in $< -outform PEM -pubout -out $@
+all_final += rsa_pkcs8_2048_public.pem
+
+rsa_pkcs8_2048_public.der: rsa_pkcs8_2048_public.pem
+ $(OPENSSL) rsa -pubin -in $< -outform DER -pubout -out $@
+all_final += rsa_pkcs8_2048_public.der
+
+################################################################
+#### Generate various RSA keys
+################################################################
+
+### Password used for PKCS1-encoded encrypted RSA keys
+keys_rsa_basic_pwd = testkey
+
+### Password used for PKCS8-encoded encrypted RSA keys
+keys_rsa_pkcs8_pwd = PolarSSLTest
+
+### Basic 1024-, 2048- and 4096-bit unencrypted RSA keys from which
+### all other encrypted RSA keys are derived.
+rsa_pkcs1_1024_clear.pem:
+ $(OPENSSL) genrsa -out $@ 1024
+all_final += rsa_pkcs1_1024_clear.pem
+rsa_pkcs1_2048_clear.pem:
+ $(OPENSSL) genrsa -out $@ 2048
+all_final += rsa_pkcs1_2048_clear.pem
+rsa_pkcs1_4096_clear.pem:
+ $(OPENSSL) genrsa -out $@ 4096
+all_final += rsa_pkcs1_4096_clear.pem
+
+###
+### PKCS1-encoded, encrypted RSA keys
+###
+
+### 1024-bit
+rsa_pkcs1_1024_des.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) rsa -des -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_1024_des.pem
+rsa_pkcs1_1024_3des.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) rsa -des3 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_1024_3des.pem
+rsa_pkcs1_1024_aes128.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) rsa -aes128 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_1024_aes128.pem
+rsa_pkcs1_1024_aes192.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) rsa -aes192 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_1024_aes192.pem
+rsa_pkcs1_1024_aes256.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) rsa -aes256 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_1024_aes256.pem
+keys_rsa_enc_basic_1024: rsa_pkcs1_1024_des.pem rsa_pkcs1_1024_3des.pem rsa_pkcs1_1024_aes128.pem rsa_pkcs1_1024_aes192.pem rsa_pkcs1_1024_aes256.pem
+
+# 2048-bit
+rsa_pkcs1_2048_des.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) rsa -des -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_2048_des.pem
+rsa_pkcs1_2048_3des.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) rsa -des3 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_2048_3des.pem
+rsa_pkcs1_2048_aes128.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) rsa -aes128 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_2048_aes128.pem
+rsa_pkcs1_2048_aes192.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) rsa -aes192 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_2048_aes192.pem
+rsa_pkcs1_2048_aes256.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) rsa -aes256 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_2048_aes256.pem
+keys_rsa_enc_basic_2048: rsa_pkcs1_2048_des.pem rsa_pkcs1_2048_3des.pem rsa_pkcs1_2048_aes128.pem rsa_pkcs1_2048_aes192.pem rsa_pkcs1_2048_aes256.pem
+
+# 4096-bit
+rsa_pkcs1_4096_des.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) rsa -des -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_4096_des.pem
+rsa_pkcs1_4096_3des.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) rsa -des3 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_4096_3des.pem
+rsa_pkcs1_4096_aes128.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) rsa -aes128 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_4096_aes128.pem
+rsa_pkcs1_4096_aes192.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) rsa -aes192 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_4096_aes192.pem
+rsa_pkcs1_4096_aes256.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) rsa -aes256 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
+all_final += rsa_pkcs1_4096_aes256.pem
+keys_rsa_enc_basic_4096: rsa_pkcs1_4096_des.pem rsa_pkcs1_4096_3des.pem rsa_pkcs1_4096_aes128.pem rsa_pkcs1_4096_aes192.pem rsa_pkcs1_4096_aes256.pem
+
+###
+### PKCS8-v1 encoded, encrypted RSA keys
+###
+
+### 1024-bit
+rsa_pkcs8_pbe_sha1_1024_3des.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
+all_final += rsa_pkcs8_pbe_sha1_1024_3des.der
+rsa_pkcs8_pbe_sha1_1024_3des.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
+all_final += rsa_pkcs8_pbe_sha1_1024_3des.pem
+keys_rsa_enc_pkcs8_v1_1024_3des: rsa_pkcs8_pbe_sha1_1024_3des.pem rsa_pkcs8_pbe_sha1_1024_3des.der
+
+rsa_pkcs8_pbe_sha1_1024_2des.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
+all_final += rsa_pkcs8_pbe_sha1_1024_2des.der
+rsa_pkcs8_pbe_sha1_1024_2des.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
+all_final += rsa_pkcs8_pbe_sha1_1024_2des.pem
+keys_rsa_enc_pkcs8_v1_1024_2des: rsa_pkcs8_pbe_sha1_1024_2des.pem rsa_pkcs8_pbe_sha1_1024_2des.der
+
+rsa_pkcs8_pbe_sha1_1024_rc4_128.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
+all_final += rsa_pkcs8_pbe_sha1_1024_rc4_128.der
+rsa_pkcs8_pbe_sha1_1024_rc4_128.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
+all_final += rsa_pkcs8_pbe_sha1_1024_rc4_128.pem
+keys_rsa_enc_pkcs8_v1_1024_rc4_128: rsa_pkcs8_pbe_sha1_1024_rc4_128.pem rsa_pkcs8_pbe_sha1_1024_rc4_128.der
+
+keys_rsa_enc_pkcs8_v1_1024: keys_rsa_enc_pkcs8_v1_1024_3des keys_rsa_enc_pkcs8_v1_1024_2des keys_rsa_enc_pkcs8_v1_1024_rc4_128
+
+### 2048-bit
+rsa_pkcs8_pbe_sha1_2048_3des.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
+all_final += rsa_pkcs8_pbe_sha1_2048_3des.der
+rsa_pkcs8_pbe_sha1_2048_3des.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
+all_final += rsa_pkcs8_pbe_sha1_2048_3des.pem
+keys_rsa_enc_pkcs8_v1_2048_3des: rsa_pkcs8_pbe_sha1_2048_3des.pem rsa_pkcs8_pbe_sha1_2048_3des.der
+
+rsa_pkcs8_pbe_sha1_2048_2des.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
+all_final += rsa_pkcs8_pbe_sha1_2048_2des.der
+rsa_pkcs8_pbe_sha1_2048_2des.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
+all_final += rsa_pkcs8_pbe_sha1_2048_2des.pem
+keys_rsa_enc_pkcs8_v1_2048_2des: rsa_pkcs8_pbe_sha1_2048_2des.pem rsa_pkcs8_pbe_sha1_2048_2des.der
+
+rsa_pkcs8_pbe_sha1_2048_rc4_128.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
+all_final += rsa_pkcs8_pbe_sha1_2048_rc4_128.der
+rsa_pkcs8_pbe_sha1_2048_rc4_128.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
+all_final += rsa_pkcs8_pbe_sha1_2048_rc4_128.pem
+keys_rsa_enc_pkcs8_v1_2048_rc4_128: rsa_pkcs8_pbe_sha1_2048_rc4_128.pem rsa_pkcs8_pbe_sha1_2048_rc4_128.der
+
+keys_rsa_enc_pkcs8_v1_2048: keys_rsa_enc_pkcs8_v1_2048_3des keys_rsa_enc_pkcs8_v1_2048_2des keys_rsa_enc_pkcs8_v1_2048_rc4_128
+
+### 4096-bit
+rsa_pkcs8_pbe_sha1_4096_3des.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
+all_final += rsa_pkcs8_pbe_sha1_4096_3des.der
+rsa_pkcs8_pbe_sha1_4096_3des.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
+all_final += rsa_pkcs8_pbe_sha1_4096_3des.pem
+keys_rsa_enc_pkcs8_v1_4096_3des: rsa_pkcs8_pbe_sha1_4096_3des.pem rsa_pkcs8_pbe_sha1_4096_3des.der
+
+rsa_pkcs8_pbe_sha1_4096_2des.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
+all_final += rsa_pkcs8_pbe_sha1_4096_2des.der
+rsa_pkcs8_pbe_sha1_4096_2des.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
+all_final += rsa_pkcs8_pbe_sha1_4096_2des.pem
+keys_rsa_enc_pkcs8_v1_4096_2des: rsa_pkcs8_pbe_sha1_4096_2des.pem rsa_pkcs8_pbe_sha1_4096_2des.der
+
+rsa_pkcs8_pbe_sha1_4096_rc4_128.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
+all_final += rsa_pkcs8_pbe_sha1_4096_rc4_128.der
+rsa_pkcs8_pbe_sha1_4096_rc4_128.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
+all_final += rsa_pkcs8_pbe_sha1_4096_rc4_128.pem
+keys_rsa_enc_pkcs8_v1_4096_rc4_128: rsa_pkcs8_pbe_sha1_4096_rc4_128.pem rsa_pkcs8_pbe_sha1_4096_rc4_128.der
+
+keys_rsa_enc_pkcs8_v1_4096: keys_rsa_enc_pkcs8_v1_4096_3des keys_rsa_enc_pkcs8_v1_4096_2des keys_rsa_enc_pkcs8_v1_4096_rc4_128
+
+###
+### PKCS8-v2 encoded, encrypted RSA keys, no PRF specified (default for OpenSSL1.0: hmacWithSHA1)
+###
+
+### 1024-bit
+rsa_pkcs8_pbes2_pbkdf2_1024_3des.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_3des.der
+rsa_pkcs8_pbes2_pbkdf2_1024_3des.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_3des.pem
+keys_rsa_enc_pkcs8_v2_1024_3des: rsa_pkcs8_pbes2_pbkdf2_1024_3des.der rsa_pkcs8_pbes2_pbkdf2_1024_3des.pem
+
+rsa_pkcs8_pbes2_pbkdf2_1024_des.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_des.der
+rsa_pkcs8_pbes2_pbkdf2_1024_des.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_des.pem
+keys_rsa_enc_pkcs8_v2_1024_des: rsa_pkcs8_pbes2_pbkdf2_1024_des.der rsa_pkcs8_pbes2_pbkdf2_1024_des.pem
+
+keys_rsa_enc_pkcs8_v2_1024: keys_rsa_enc_pkcs8_v2_1024_3des keys_rsa_enc_pkcs8_v2_1024_des
+
+### 2048-bit
+rsa_pkcs8_pbes2_pbkdf2_2048_3des.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_3des.der
+rsa_pkcs8_pbes2_pbkdf2_2048_3des.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_3des.pem
+keys_rsa_enc_pkcs8_v2_2048_3des: rsa_pkcs8_pbes2_pbkdf2_2048_3des.der rsa_pkcs8_pbes2_pbkdf2_2048_3des.pem
+
+rsa_pkcs8_pbes2_pbkdf2_2048_des.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_des.der
+rsa_pkcs8_pbes2_pbkdf2_2048_des.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_des.pem
+keys_rsa_enc_pkcs8_v2_2048_des: rsa_pkcs8_pbes2_pbkdf2_2048_des.der rsa_pkcs8_pbes2_pbkdf2_2048_des.pem
+
+keys_rsa_enc_pkcs8_v2_2048: keys_rsa_enc_pkcs8_v2_2048_3des keys_rsa_enc_pkcs8_v2_2048_des
+
+### 4096-bit
+rsa_pkcs8_pbes2_pbkdf2_4096_3des.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_3des.der
+rsa_pkcs8_pbes2_pbkdf2_4096_3des.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_3des.pem
+keys_rsa_enc_pkcs8_v2_4096_3des: rsa_pkcs8_pbes2_pbkdf2_4096_3des.der rsa_pkcs8_pbes2_pbkdf2_4096_3des.pem
+
+rsa_pkcs8_pbes2_pbkdf2_4096_des.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_des.der
+rsa_pkcs8_pbes2_pbkdf2_4096_des.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_des.pem
+keys_rsa_enc_pkcs8_v2_4096_des: rsa_pkcs8_pbes2_pbkdf2_4096_des.der rsa_pkcs8_pbes2_pbkdf2_4096_des.pem
+
+keys_rsa_enc_pkcs8_v2_4096: keys_rsa_enc_pkcs8_v2_4096_3des keys_rsa_enc_pkcs8_v2_4096_des
+
+###
+### PKCS8-v2 encoded, encrypted RSA keys, PRF hmacWithSHA224
+###
+
+### 1024-bit
+rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA224 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.der
+rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA224 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.pem
+keys_rsa_enc_pkcs8_v2_1024_3des_sha224: rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.der rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.pem
+
+rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA224 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.der
+rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA224 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.pem
+keys_rsa_enc_pkcs8_v2_1024_des_sha224: rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.der rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.pem
+
+keys_rsa_enc_pkcs8_v2_1024_sha224: keys_rsa_enc_pkcs8_v2_1024_3des_sha224 keys_rsa_enc_pkcs8_v2_1024_des_sha224
+
+### 2048-bit
+rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA224 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.der
+rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA224 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.pem
+keys_rsa_enc_pkcs8_v2_2048_3des_sha224: rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.der rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.pem
+
+rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA224 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.der
+rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA224 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.pem
+keys_rsa_enc_pkcs8_v2_2048_des_sha224: rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.der rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.pem
+
+keys_rsa_enc_pkcs8_v2_2048_sha224: keys_rsa_enc_pkcs8_v2_2048_3des_sha224 keys_rsa_enc_pkcs8_v2_2048_des_sha224
+
+### 4096-bit
+rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA224 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.der
+rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA224 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.pem
+keys_rsa_enc_pkcs8_v2_4096_3des_sha224: rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.der rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.pem
+
+rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA224 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.der
+rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA224 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.pem
+keys_rsa_enc_pkcs8_v2_4096_des_sha224: rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.der rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.pem
+
+keys_rsa_enc_pkcs8_v2_4096_sha224: keys_rsa_enc_pkcs8_v2_4096_3des_sha224 keys_rsa_enc_pkcs8_v2_4096_des_sha224
+
+###
+### PKCS8-v2 encoded, encrypted RSA keys, PRF hmacWithSHA256
+###
+
+### 1024-bit
+rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA256 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.der
+rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA256 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.pem
+keys_rsa_enc_pkcs8_v2_1024_3des_sha256: rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.der rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.pem
+
+rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA256 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.der
+rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA256 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.pem
+keys_rsa_enc_pkcs8_v2_1024_des_sha256: rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.der rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.pem
+
+keys_rsa_enc_pkcs8_v2_1024_sha256: keys_rsa_enc_pkcs8_v2_1024_3des_sha256 keys_rsa_enc_pkcs8_v2_1024_des_sha256
+
+### 2048-bit
+rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA256 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.der
+rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA256 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.pem
+keys_rsa_enc_pkcs8_v2_2048_3des_sha256: rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.der rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.pem
+
+rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA256 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.der
+rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA256 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.pem
+keys_rsa_enc_pkcs8_v2_2048_des_sha256: rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.der rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.pem
+
+keys_rsa_enc_pkcs8_v2_2048_sha256: keys_rsa_enc_pkcs8_v2_2048_3des_sha256 keys_rsa_enc_pkcs8_v2_2048_des_sha256
+
+### 4096-bit
+rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA256 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.der
+rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA256 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.pem
+keys_rsa_enc_pkcs8_v2_4096_3des_sha256: rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.der rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.pem
+
+rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA256 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.der
+rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA256 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.pem
+keys_rsa_enc_pkcs8_v2_4096_des_sha256: rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.der rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.pem
+
+keys_rsa_enc_pkcs8_v2_4096_sha256: keys_rsa_enc_pkcs8_v2_4096_3des_sha256 keys_rsa_enc_pkcs8_v2_4096_des_sha256
+
+###
+### PKCS8-v2 encoded, encrypted RSA keys, PRF hmacWithSHA384
+###
+
+### 1024-bit
+rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA384 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.der
+rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA384 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.pem
+keys_rsa_enc_pkcs8_v2_1024_3des_sha384: rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.der rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.pem
+
+rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA384 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.der
+rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA384 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.pem
+keys_rsa_enc_pkcs8_v2_1024_des_sha384: rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.der rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.pem
+
+keys_rsa_enc_pkcs8_v2_1024_sha384: keys_rsa_enc_pkcs8_v2_1024_3des_sha384 keys_rsa_enc_pkcs8_v2_1024_des_sha384
+
+### 2048-bit
+rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA384 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.der
+rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA384 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.pem
+keys_rsa_enc_pkcs8_v2_2048_3des_sha384: rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.der rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.pem
+
+rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA384 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.der
+rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA384 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.pem
+keys_rsa_enc_pkcs8_v2_2048_des_sha384: rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.der rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.pem
+
+keys_rsa_enc_pkcs8_v2_2048_sha384: keys_rsa_enc_pkcs8_v2_2048_3des_sha384 keys_rsa_enc_pkcs8_v2_2048_des_sha384
+
+### 4096-bit
+rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA384 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.der
+rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA384 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.pem
+keys_rsa_enc_pkcs8_v2_4096_3des_sha384: rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.der rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.pem
+
+rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA384 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.der
+rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA384 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.pem
+keys_rsa_enc_pkcs8_v2_4096_des_sha384: rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.der rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.pem
+
+keys_rsa_enc_pkcs8_v2_4096_sha384: keys_rsa_enc_pkcs8_v2_4096_3des_sha384 keys_rsa_enc_pkcs8_v2_4096_des_sha384
+
+###
+### PKCS8-v2 encoded, encrypted RSA keys, PRF hmacWithSHA512
+###
+
+### 1024-bit
+rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA512 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.der
+rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA512 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.pem
+keys_rsa_enc_pkcs8_v2_1024_3des_sha512: rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.der rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.pem
+
+rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.der: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA512 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.der
+rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.pem: rsa_pkcs1_1024_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA512 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.pem
+keys_rsa_enc_pkcs8_v2_1024_des_sha512: rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.der rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.pem
+
+keys_rsa_enc_pkcs8_v2_1024_sha512: keys_rsa_enc_pkcs8_v2_1024_3des_sha512 keys_rsa_enc_pkcs8_v2_1024_des_sha512
+
+### 2048-bit
+rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA512 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.der
+rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA512 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.pem
+keys_rsa_enc_pkcs8_v2_2048_3des_sha512: rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.der rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.pem
+
+rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.der: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA512 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.der
+rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.pem: rsa_pkcs1_2048_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA512 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.pem
+keys_rsa_enc_pkcs8_v2_2048_des_sha512: rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.der rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.pem
+
+keys_rsa_enc_pkcs8_v2_2048_sha512: keys_rsa_enc_pkcs8_v2_2048_3des_sha512 keys_rsa_enc_pkcs8_v2_2048_des_sha512
+
+### 4096-bit
+rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA512 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.der
+rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des3 -v2prf hmacWithSHA512 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.pem
+keys_rsa_enc_pkcs8_v2_4096_3des_sha512: rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.der rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.pem
+
+rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.der: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA512 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.der
+rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.pem: rsa_pkcs1_4096_clear.pem
+ $(OPENSSL) pkcs8 -topk8 -v2 des -v2prf hmacWithSHA512 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
+all_final += rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.pem
+keys_rsa_enc_pkcs8_v2_4096_des_sha512: rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.der rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.pem
+
+keys_rsa_enc_pkcs8_v2_4096_sha512: keys_rsa_enc_pkcs8_v2_4096_3des_sha512 keys_rsa_enc_pkcs8_v2_4096_des_sha512
+
+###
+### Rules to generate all RSA keys from a particular class
+###
+
+### Generate basic unencrypted RSA keys
+keys_rsa_unenc: rsa_pkcs1_1024_clear.pem rsa_pkcs1_2048_clear.pem rsa_pkcs1_4096_clear.pem
+
+### Generate PKCS1-encoded encrypted RSA keys
+keys_rsa_enc_basic: keys_rsa_enc_basic_1024 keys_rsa_enc_basic_2048 keys_rsa_enc_basic_4096
+
+### Generate PKCS8-v1 encrypted RSA keys
+keys_rsa_enc_pkcs8_v1: keys_rsa_enc_pkcs8_v1_1024 keys_rsa_enc_pkcs8_v1_2048 keys_rsa_enc_pkcs8_v1_4096
+
+### Generate PKCS8-v2 encrypted RSA keys
+keys_rsa_enc_pkcs8_v2: keys_rsa_enc_pkcs8_v2_1024 keys_rsa_enc_pkcs8_v2_2048 keys_rsa_enc_pkcs8_v2_4096 keys_rsa_enc_pkcs8_v2_1024_sha224 keys_rsa_enc_pkcs8_v2_2048_sha224 keys_rsa_enc_pkcs8_v2_4096_sha224 keys_rsa_enc_pkcs8_v2_1024_sha256 keys_rsa_enc_pkcs8_v2_2048_sha256 keys_rsa_enc_pkcs8_v2_4096_sha256 keys_rsa_enc_pkcs8_v2_1024_sha384 keys_rsa_enc_pkcs8_v2_2048_sha384 keys_rsa_enc_pkcs8_v2_4096_sha384 keys_rsa_enc_pkcs8_v2_1024_sha512 keys_rsa_enc_pkcs8_v2_2048_sha512 keys_rsa_enc_pkcs8_v2_4096_sha512
+
+### Generate all RSA keys
+keys_rsa_all: keys_rsa_unenc keys_rsa_enc_basic keys_rsa_enc_pkcs8_v1 keys_rsa_enc_pkcs8_v2
+
+
+
+################################################################
+### Generate certificates for CRT write check tests
+################################################################
+
+### The test files use the Mbed TLS generated certificates server1*.crt,
+### but for comparison with OpenSSL also rules for OpenSSL-generated
+### certificates server1*.crt.openssl are offered.
+###
+### Known differences:
+### * OpenSSL encodes trailing zero-bits in bit-strings occurring in X.509 extension
+### as unused bits, while Mbed TLS doesn't.
+
+test_ca_server1_db = test-ca.server1.db
+test_ca_server1_serial = test-ca.server1.serial
+test_ca_server1_config_file = test-ca.server1.opensslconf
+
+server1.csr: server1.key server1_csr.opensslconf
+ $(OPENSSL) req -keyform PEM -key server1.key -config server1_csr.opensslconf -out $@ -new
+all_final += server1.csr
+
+server1.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa)
+ $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 version=3 output_file=$@
+server1.noauthid.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa)
+ $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144406 not_after=20210212144406 md=SHA1 authority_identifier=0 version=3 output_file=$@
+server1.der: server1.crt
+ $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
+all_final += server1.crt server1.noauthid.crt server1.der
+
+server1.key_usage.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa)
+ $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 key_usage=digital_signature,non_repudiation,key_encipherment version=3 output_file=$@
+server1.key_usage_noauthid.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa)
+ $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 key_usage=digital_signature,non_repudiation,key_encipherment authority_identifier=0 version=3 output_file=$@
+server1.key_usage.der: server1.key_usage.crt
+ $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
+all_final += server1.key_usage.crt server1.key_usage_noauthid.crt server1.key_usage.der
+
+server1.cert_type.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa)
+ $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 ns_cert_type=ssl_server version=3 output_file=$@
+server1.cert_type_noauthid.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa)
+ $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 ns_cert_type=ssl_server authority_identifier=0 version=3 output_file=$@
+server1.cert_type.der: server1.cert_type.crt
+ $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
+all_final += server1.cert_type.crt server1.cert_type_noauthid.crt server1.cert_type.der
+
+server1.v1.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa)
+ $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 version=1 output_file=$@
+server1.v1.der: server1.v1.crt
+ $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
+all_final += server1.v1.crt server1.v1.der
+
+# OpenSSL-generated certificates for comparison
+# Also provide certificates in DER format to allow
+# direct binary comparison using e.g. dumpasn1
+server1.crt.openssl server1.key_usage.crt.openssl server1.cert_type.crt.openssl: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa) $(test_ca_server1_config_file)
+ echo "01" > $(test_ca_server1_serial)
+ rm -f $(test_ca_server1_db)
+ touch $(test_ca_server1_db)
+ $(OPENSSL) ca -batch -passin "pass:$(test_ca_pwd_rsa)" -config $(test_ca_server1_config_file) -in server1.csr -extensions v3_ext -extfile $@.v3_ext -out $@
+server1.der.openssl: server1.crt.openssl
+ $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
+server1.key_usage.der.openssl: server1.key_usage.crt.openssl
+ $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
+server1.cert_type.der.openssl: server1.cert_type.crt.openssl
+ $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
+
+server1.v1.crt.openssl: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa) $(test_ca_server1_config_file)
+ echo "01" > $(test_ca_server1_serial)
+ rm -f $(test_ca_server1_db)
+ touch $(test_ca_server1_db)
+ $(OPENSSL) ca -batch -passin "pass:$(test_ca_pwd_rsa)" -config $(test_ca_server1_config_file) -in server1.csr -out $@
+server1.v1.der.openssl: server1.v1.crt.openssl
+ $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@
+
+server1_all: server1.csr server1.crt server1.noauthid.crt server1.crt.openssl server1.v1.crt server1.v1.crt.openssl server1.key_usage.crt server1.key_usage_noauthid.crt server1.key_usage.crt.openssl server1.cert_type.crt server1.cert_type_noauthid.crt server1.cert_type.crt.openssl server1.der server1.der.openssl server1.v1.der server1.v1.der.openssl server1.key_usage.der server1.key_usage.der.openssl server1.cert_type.der server1.cert_type.der.openssl
+
+
+
+################################################################
+#### Meta targets
+################################################################
+
+all_final: $(all_final)
+all: $(all_intermediate) $(all_final)
+
+.PHONY: default all_final all
+.PHONY: keys_rsa_all
+.PHONY: keys_rsa_unenc keys_rsa_enc_basic
+.PHONY: keys_rsa_enc_pkcs8_v1 keys_rsa_enc_pkcs8_v2
+.PHONY: keys_rsa_enc_basic_1024 keys_rsa_enc_basic_2048 keys_rsa_enc_basic_4096
+.PHONY: keys_rsa_enc_pkcs8_v1_1024 keys_rsa_enc_pkcs8_v2_1024
+.PHONY: keys_rsa_enc_pkcs8_v1_2048 keys_rsa_enc_pkcs8_v2_2048
+.PHONY: keys_rsa_enc_pkcs8_v1_4096 keys_rsa_enc_pkcs8_v2_4096
+.PHONY: server1_all
+
+# These files should not be committed to the repository.
+list_intermediate:
+ @printf '%s\n' $(all_intermediate) | sort
+# These files should be committed to the repository so that the test data is
+# available upon checkout without running a randomized process depending on
+# third-party tools.
+list_final:
+ @printf '%s\n' $(all_final) | sort
+.PHONY: list_intermediate list_final
+
+## Remove intermediate files
+clean:
+ rm -f $(all_intermediate)
+## Remove all build products, even the ones that are committed
+neat: clean
+ rm -f $(all_final)
+.PHONY: clean neat
There are two main CAs for use as trusted roots:
- test-ca.crt aka "C=NL, O=PolarSSL, CN=PolarSSL Test CA"
uses a RSA-2048 key
+ test-ca-sha1.crt and test-ca-sha256.crt use the same key, signed with
+ different hashes.
- test-ca2*.crt aka "C=NL, O=PolarSSL, CN=Polarssl Test EC CA"
uses an EC key with NIST P-384 (aka secp384r1)
variants used to test the keyUsage extension
- cert_md*.crt, cert_sha*.crt: 1 R: signature hash
- cert_v1_with_ext.crt: 1 R: v1 with extensions (illegal)
- cli2.crt: 2 E: basic
+- cli-rsa.key, cli-rsa-*.crt: RSA key used for test clients, signed by
+ the RSA test CA.
- enco-cert-utf8str.pem: see enco-ca-prstr.pem above
- server1*.crt: 1* R C* P1*: misc *(server1-v1 see test-ca-v1.crt above)
*CRL for: .cert_type.crt, .crt, .key_usage.crt, .v1.crt
Note: crl_future would revoke server9 and cert_sha384.crt if signed by CA 1
crl-rsa-pss* would revoke server6.crt if signed by CA 2
+
+Generation
+----------
+
+Newer test files have been generated through commands in the Makefile. The
+resulting files are committed to the repository so that the tests can
+run without having to re-do the generation and so that the output is the
+same for everyone (the generation process is randomized).
+
+The origin of older certificates has not been recorded.
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIDhTCCAm2gAwIBAgIBBDANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER
+MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN
+MTcwNTA1MTMwNzEwWhcNMjcwNTA2MTMwNzEwWjA8MQswCQYDVQQGEwJOTDERMA8G
+A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIENsaWVudCAyMIIBIjAN
+BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6f
+M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu
+1C93KYRhTYJQj6eVSHD1bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEw
+MjDV0/YI0FZPRo7yX/k9Z5GIMC5Cst99++UMd//sMcB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60
+ZcxFp3rtDpkp0JxhFLhiizFrujMtZSjYNm5U7KkgPVHhLELEUvCmOnKTt4ap/vZ0
+BxJNe1GZH3pW6SAvGDQpl9sG7uu/vTFP+lCxukmzxB0DrrDcvorEkKMom7ZCCRvW
+KZsZ6YeH2Z81BauRj218kQKBgQCUV/DgKP2985xDTT79N08jUo3hTP5MVYCCuj/+
+UeEw1TvZcx3LJby7P6Xad6a1/BqveaGyFKIfEFIaBUBItk801sDDpDaYc4gL00Xc
+7lFuBHOZkxJYlss5QrGpuOEl9ZwUt5IrFLBdYaKqNHzNVC1pCPfb/JyH6Dr2HUxq
+gxUwAQKBgQCcU6G2L8AG9d9c0UpOyL1tMvFe5Ttw0KjlQVdsh1MP6yigYo9DYuwu
+bHFVW2r0dBTqegP2/KTOxKzaHfC1qf0RGDsUoJCNJrd1cwoCLG8P2EF4w3OBrKqv
+8u4ytY0F+Vlanj5lm3TaoHSVF1+NWPyOTiwevIECGKwSxvlki4fDAA==
+-----END RSA PRIVATE KEY-----
\ No newline at end of file
--- /dev/null
+[cli-rsa]
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid:always,issuer:always
+basicConstraints = CA:false
--- /dev/null
+-----BEGIN X509 CRL-----
+MIIBszCBnAIBATANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDERMA8GA1UE
+ChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EXDTE4MDMxNDA3
+MzE0OFoXDTI4MDMxNDA3MzE0OFqgLTArMCkGA1UdHAEB/wQfMB2gG6AZhhdodHRw
+Oi8vcGtpLmV4YW1wbGUuY29tLzANBgkqhkiG9w0BAQsFAAOCAQEAs/vp1Ybq9Lj/
+YM+O2uBqhRNdt494GYSYcZcltbQDwLgDwsFQ9S+q5zBtanhxiF3C6dyDoWS6xyY3
+dkdO9kK2YAQLNaFBCsKRrI9vGKuF5/1uIr0a8cQcqVzyRI9uK0KgGEk9/APGtqob
+nj/nt2ry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+MTUwMzJaFw0yNzA2MjMxMTUwMzJaMC8xCzAJBgNVBAYTAlVLMREwDwYDVQQKDAht
+YmVkIFRMUzENMAsGA1UEAwwEQ0EwMDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA
+BFW41/qAwAPpy+Txdc7PKmzZsq9CPiujKU4vpF1ekXnGx2HP420QobwBVVWhkzRm
+LwdboH2j65dcCKjQ7mv/dxKjUDBOMB0GA1UdDgQWBBQlFYvU5WboI4fcdPoiQs8/
+fPHZrTAfBgNVHSMEGDAWgBQlFYvU5WboI4fcdPoiQs8/fPHZrTAMBgNVHRMEBTAD
+AQH/MAoGCCqGSM49BAMCA0gAMEUCIQC7iRcVzwMyfVK5imirJ7MqJQ04euH4CLOt
+IZ+SNfaERAIgSU0MWFDosVEIpg8YMqIHeF7Mg4ZyH6+fGazJgVLttUY=
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIARPaEIfROHkE9Y0ZgHh7Mc3ZU6LR9lCOIw1ksYTHp5EoAoGCCqGSM49
+AwEHoUQDQgAEVbjX+oDAA+nL5PF1zs8qbNmyr0I+K6MpTi+kXV6RecbHYc/jbRCh
+vAFVVaGTNGYvB1ugfaPrl1wIqNDua/93Eg==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB3jCCAYWgAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMDAwHhcNMTcwNjIyMTE1MDMyWhcN
+MjcwNjIzMTE1MDMyWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMDEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQznn9zHHwL
+GO8VR4W9V7vMlxCdoojzEOiX5Y6JtPtFOz866ueHY6zoN0/mJ6DnqnSXilJIUUeW
+6eGfqmka7nxko4GRMIGOMB0GA1UdDgQWBBSh3uHkX5nj86yFEFwjscSWM40P+jBf
+BgNVHSMEWDBWgBQlFYvU5WboI4fcdPoiQs8/fPHZraEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTAwggkA/KCWhcqToHAw
+DAYDVR0TBAUwAwEB/zAKBggqhkjOPQQDAgNHADBEAiBasbuinP+pJTU4oDCVD8zQ
+1rJBDSOKIEyWu84/D6Hj6wIgVMPUoO01bPhzllAa/gW8Xk/daey09SBgN3AT9pWU
+TDA=
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEINSnxPqUNMba8F2KWNxU88heSs7vgas5BOzjRwQsQe6IoAoGCCqGSM49
+AwEHoUQDQgAEM55/cxx8CxjvFUeFvVe7zJcQnaKI8xDol+WOibT7RTs/Ournh2Os
+6DdP5ieg56p0l4pSSFFHlunhn6ppGu58ZA==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1zCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMDEwHhcNMTcwNjIyMTE1MDMyWhcN
+MjcwNjIzMTE1MDMyWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMDIwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQWHpv1i6lf
+wvNPOP5ka6S0n55EvzoaYK6pbTXP6yMOW/4XZSPKx5Zoq4FMe0cKzGIIFL1rzj1V
+2czYB+qvLhyio4GJMIGGMB0GA1UdDgQWBBT5RCgQ0AlZTQbfFB2+6+w0XRvydTBX
+BgNVHSMEUDBOgBSh3uHkX5nj86yFEFwjscSWM40P+qEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTAwggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSAAwRQIhAI7unGW/gr9tOc3i+dF5N815srgh+FrX
+oj9Et74EcSpTAiBubv+vOH0DE0gmYI11HeAIgutWqqMIC72dZlwTF/Vi3g==
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIPW9zE8cjiZ8w17jTAebb4xAmEg6heEEnEaG4lGCd38joAoGCCqGSM49
+AwEHoUQDQgAEFh6b9YupX8LzTzj+ZGuktJ+eRL86GmCuqW01z+sjDlv+F2UjyseW
+aKuBTHtHCsxiCBS9a849VdnM2Afqry4cog==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB2DCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMDIwHhcNMTcwNjIyMTE1MDMyWhcN
+MjcwNjIzMTE1MDMyWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMDMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQRDXDNIi1p
+ereudhqwa2LslXgsxnB63Hu5y5lg+1WPruIYPzD/Ho0APveVdzFLVji19+bE4+tF
+PYL1SpsN1WfWo4GJMIGGMB0GA1UdDgQWBBQApzZdtBdD3dLxouQpr/aDiVttdzBX
+BgNVHSMEUDBOgBT5RCgQ0AlZTQbfFB2+6+w0XRvydaEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTAxggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhAOnd+7bAofkHVa4KFNjv3TCegw1lrhuM
+8Of8wgvrTEGoAiEAsS8iKMpSfXH4D0egg4gLamE6akde965rDtySU+ve9lg=
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIBx2xwapGbHTy79IbpJkc/w9LJXPKNG7gGRLPOGPQFI6oAoGCCqGSM49
+AwEHoUQDQgAEEQ1wzSItaXq3rnYasGti7JV4LMZwetx7ucuZYPtVj67iGD8w/x6N
+AD73lXcxS1Y4tffmxOPrRT2C9UqbDdVn1g==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1jCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMDMwHhcNMTcwNjIyMTE1MDMyWhcN
+MjcwNjIzMTE1MDMyWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMDQwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQUXDgcUVNT
+9hovbZE5HL6rjOb7C55wEuWKThV/CcZ4rWrXx7VXHYdD/R3aDA7JSvYpm2sTok4i
+sblDzhZM/GDNo4GJMIGGMB0GA1UdDgQWBBQox4F1NsZunlsduoGvzIgRSYfB3zBX
+BgNVHSMEUDBOgBQApzZdtBdD3dLxouQpr/aDiVttd6EzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTAyggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgAkiNhqFAZXSUWEDK91OZvQGdeZOtd6mC
++Wv3fGk3t28CIEKOwidkUTUaiPdZ4efmAr+CEeGzdq27ob2S+nqqHqgV
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIDQvTm0wfEAKoymv8ePBv7cRxrnM4g6LREnSll5ghQsXoAoGCCqGSM49
+AwEHoUQDQgAEFFw4HFFTU/YaL22RORy+q4zm+wuecBLlik4VfwnGeK1q18e1Vx2H
+Q/0d2gwOyUr2KZtrE6JOIrG5Q84WTPxgzQ==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1zCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMDQwHhcNMTcwNjIyMTE1MDMyWhcN
+MjcwNjIzMTE1MDMyWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMDUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQEdT0OFf5G
+UcrgX2XllCyJzP94NZ464GsgB6psNLsDeL+j7AU+oJy7VLvW/lHh3ODgl08Z9bhq
+LFBmNjnHbm8Qo4GJMIGGMB0GA1UdDgQWBBTXh06MAV9S4l4lG1TKOrKRBh4qnzBX
+BgNVHSMEUDBOgBQox4F1NsZunlsduoGvzIgRSYfB36EzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTAzggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSAAwRQIhAIW++zqDZlLLUk/emePohdNOp5JO3wS9
+XvkBJ6Wua7GBAiAdx+EKmdjVrwnzrQltTgnmSfGMXhKNYifK3uD83W3pcQ==
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIP3MTs0m9ssAAXQ94O6GYC3pckfpMUxQiPTG8hQYgA0WoAoGCCqGSM49
+AwEHoUQDQgAEBHU9DhX+RlHK4F9l5ZQsicz/eDWeOuBrIAeqbDS7A3i/o+wFPqCc
+u1S71v5R4dzg4JdPGfW4aixQZjY5x25vEA==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1jCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMDUwHhcNMTcwNjIyMTE1MDMyWhcN
+MjcwNjIzMTE1MDMyWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMDYwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASA9qWoAUHr
+nn+3kxyNrjPJk82WDLimW21RN51uxpobadv8YgGEDRdP+Ok+uRqQSUsA6ZXfF3iG
+r2GjfQ3wMDH8o4GJMIGGMB0GA1UdDgQWBBSjovYaC/m6Li9Tp0V9iZRs9267QzBX
+BgNVHSMEUDBOgBTXh06MAV9S4l4lG1TKOrKRBh4qn6EzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTA0ggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgcjZNFWJtlDmoPZbAxqsGczRYK0lfPgu6
+g1H7pp0ce+wCIDj9BRZM2OB9EF0e+MDKGjyZGfvfrL6Ir47x/KrM6H8T
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIESUhQgXWd8cVQnitNEpOD2JNMqH9ug/wYaY1xW3SaSGoAoGCCqGSM49
+AwEHoUQDQgAEgPalqAFB655/t5Mcja4zyZPNlgy4plttUTedbsaaG2nb/GIBhA0X
+T/jpPrkakElLAOmV3xd4hq9ho30N8DAx/A==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB2DCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMDYwHhcNMTcwNjIyMTE1MDMyWhcN
+MjcwNjIzMTE1MDMyWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMDcwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASNOj4d4MEA
+7p/3miijqG4ToE4opKPAm+3BTIGrJTYT14++TSiUICl0ASXj+xeUcLMIaXTN042s
+LsHxpShzQaL0o4GJMIGGMB0GA1UdDgQWBBREq5J3toJPxZ3O+ssJ5vkkU0RJEzBX
+BgNVHSMEUDBOgBSjovYaC/m6Li9Tp0V9iZRs9267Q6EzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTA1ggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhAKGcf+c442c/XiwubbaiQvsoZ7EoVxuM
+oKmia0gPyBNkAiEA83asjJ5FDXQuLyZpczviXrbmqgCPOfYadtvkc0cxMis=
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIEi1oKInPLbiINj8OxdActVTgI+YQVSefdQfCu1ihbLRoAoGCCqGSM49
+AwEHoUQDQgAEjTo+HeDBAO6f95ooo6huE6BOKKSjwJvtwUyBqyU2E9ePvk0olCAp
+dAEl4/sXlHCzCGl0zdONrC7B8aUoc0Gi9A==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB2DCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMDcwHhcNMTcwNjIyMTE1MDMyWhcN
+MjcwNjIzMTE1MDMyWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMDgwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARpQeQ/YGQj
+nl7Szo6WStJ1u7xunTL5jBkXH8aAVSm0qiX4AD/7YPxa5EnGzZdLTn25vQVnfQAG
+pMx8P1lYiGYCo4GJMIGGMB0GA1UdDgQWBBS40mLt93U8Sh8ZGiDVAhRSiBPcXjBX
+BgNVHSMEUDBOgBREq5J3toJPxZ3O+ssJ5vkkU0RJE6EzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTA2ggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhANwGf+F4a+kmXWz8UjSpRkaToTV6EFWw
+/Tjzj0tQhDoAAiEA19RxeWOVBBpM6LOHg6v5Lf54YN1snkLf+sEXyZCuWQQ=
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIC8M2G7XcqeagYgt8SZJbuTh4tYchGvX3yDZJKTuBgFUoAoGCCqGSM49
+AwEHoUQDQgAEaUHkP2BkI55e0s6OlkrSdbu8bp0y+YwZFx/GgFUptKol+AA/+2D8
+WuRJxs2XS059ub0FZ30ABqTMfD9ZWIhmAg==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1jCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMDgwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMDkwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAR7ZB16+t6E
+sfahGyKUGJW5mezkzjdaYvc4lbJaKNRwFRfc3F/fmNOSsUFSg/F0N+vUE+doKiPC
+8wRwLzvm4s+5o4GJMIGGMB0GA1UdDgQWBBT6gyXHzPIPYc1Vr1aGiLLeMh4HpjBX
+BgNVHSMEUDBOgBS40mLt93U8Sh8ZGiDVAhRSiBPcXqEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTA3ggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgO4el1ZPhlIli/qNR2SIEiuvs5Mmy868i
+N2Rv5X/VxIECIA/8rUALQxW38XSdBVX3e/jzu7ju47n1YwEqD9K9WdVv
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIKkdxegP5yN840sBDxIPpiMftZss14uLaH7zoxOqrePDoAoGCCqGSM49
+AwEHoUQDQgAEe2QdevrehLH2oRsilBiVuZns5M43WmL3OJWyWijUcBUX3Nxf35jT
+krFBUoPxdDfr1BPnaCojwvMEcC875uLPuQ==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1zCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMDkwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMTAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAR6jlGKbJd5
+hiDxN789gkOcwpyHI9wRwCrADAOwOkMePBPRlwGdm7mw7Z/EAmu26zRm/hcyrs4M
+qk2LabDjPI9Xo4GJMIGGMB0GA1UdDgQWBBQtxZSLJAkEz+2RKMQexM6EtsfgcjBX
+BgNVHSMEUDBOgBT6gyXHzPIPYc1Vr1aGiLLeMh4HpqEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTA4ggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSAAwRQIgP7S8vFstfUBdNe6ym5GYG5Q+aBVEKqRs
+fVW7HNUktSYCIQDo6Jua6o/DJbrpq4qYWq5gv4yGyzPTN+3IaKrEICdaaw==
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIPuPPMxo5e2doI7YfDp60qmEn4YwYs2sb5QlOpFQ3BIJoAoGCCqGSM49
+AwEHoUQDQgAEeo5RimyXeYYg8Te/PYJDnMKchyPcEcAqwAwDsDpDHjwT0ZcBnZu5
+sO2fxAJrtus0Zv4XMq7ODKpNi2mw4zyPVw==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1jCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMTAwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMTEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATZwR+WK6NB
+F/7riFdN63c8hjYddZRR4lrzVNPwiBQxnnxwpPyrD9A6aPPmLc6SqGOJW4ZGVCco
+IBze9RJVeiB9o4GJMIGGMB0GA1UdDgQWBBSOSt6ePyMRT6PGMaIi7FqNX9MKtDBX
+BgNVHSMEUDBOgBQtxZSLJAkEz+2RKMQexM6EtsfgcqEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTA5ggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgN//NqM0FrkrMjmxoeCY9DgxkH2R6sQ4d
+NgtwCZAIqEICIBs4vupaVcuvni9tltbP26wi7c0FR+blZuo5DPIA3SVe
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIHaMieH2/wn6lnsFUGzww43ymhN16Z0nhG5TyvNeY8U2oAoGCCqGSM49
+AwEHoUQDQgAE2cEfliujQRf+64hXTet3PIY2HXWUUeJa81TT8IgUMZ58cKT8qw/Q
+Omjz5i3OkqhjiVuGRlQnKCAc3vUSVXogfQ==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1jCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMTEwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMTIwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATDE9LPlLPc
+gZ3b0BchR/AkhNEP9HAavwYadJIyzoPo5edCVnboQH786jsZwZNZoC0gHDAhCmGc
+IfRenISAoVuPo4GJMIGGMB0GA1UdDgQWBBTZTtbi+j0Sm/Zs/+gTkWdASpQzfjBX
+BgNVHSMEUDBOgBSOSt6ePyMRT6PGMaIi7FqNX9MKtKEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTEwggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgYYF5AnRV7eh2hLD5Dz//pceMTKz9Ls46
+E6DxvbfDHikCIFttlGrOCZVyS4ocsjuKIELVUX5qfygI0sn4kU3qCTs2
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIAzhAcc1Yb2u4bsQDaYeRaRW8kJ/HzFTTfINV1k+TxZ/oAoGCCqGSM49
+AwEHoUQDQgAEwxPSz5Sz3IGd29AXIUfwJITRD/RwGr8GGnSSMs6D6OXnQlZ26EB+
+/Oo7GcGTWaAtIBwwIQphnCH0XpyEgKFbjw==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1zCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMTIwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMTMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATrkzCJLznh
+lhnsv1RXB9kfeaD+cIruPQ0cItBDGpdvD8xbBVvQci4+RG2RVUCSWRhkFYjSsUSM
+0QHMQnBFlhw2o4GJMIGGMB0GA1UdDgQWBBTmVnUSF2MYwws/nCMv7b1wJVkDmjBX
+BgNVHSMEUDBOgBTZTtbi+j0Sm/Zs/+gTkWdASpQzfqEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTExggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSAAwRQIgWsm+rHJgwUEyNm8EKbEds5yurpp5/3y5
+PsvXJVDqxogCIQDUP0Jcl3A907CE2tPVXSgD6LQ6CPu19mixemPw60yijA==
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIKb966FXMh8cFQt3sVpmcrh2/3yaGiLMwz+/XGKGMJ+2oAoGCCqGSM49
+AwEHoUQDQgAE65MwiS854ZYZ7L9UVwfZH3mg/nCK7j0NHCLQQxqXbw/MWwVb0HIu
+PkRtkVVAklkYZBWI0rFEjNEBzEJwRZYcNg==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1zCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMTMwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMTQwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATRMZN0RHzP
+donNmZuq9XPhzvQ52TaokxT39qpQtlFyvUuEGKrLoNvdcpARaA0rGput6RLAQOVU
+iNVlJ3Ipj789o4GJMIGGMB0GA1UdDgQWBBRNsJB++ccSBmbCCKBxi4CjXROBkzBX
+BgNVHSMEUDBOgBTmVnUSF2MYwws/nCMv7b1wJVkDmqEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTEyggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSAAwRQIgVfuLpjp08AaxKWf6cuZUUCRd7CojSS1I
+71hzeUyFS+sCIQDNJI6P/pBbiHgTaGlBAgfcEfmxmbY0n4xZndtxIkmyVA==
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIKEycJNLyYJ5JgECpCuZiFeXZIMC+XsMEKoMhRTx6xD+oAoGCCqGSM49
+AwEHoUQDQgAE0TGTdER8z3aJzZmbqvVz4c70Odk2qJMU9/aqULZRcr1LhBiqy6Db
+3XKQEWgNKxqbrekSwEDlVIjVZSdyKY+/PQ==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1zCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMTQwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMTUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQlKUiMoSss
+/hsTasedqdB2BCOGJhTt0hgUGeUnWNZ1svO4yn0GkFHZ08++fl2MKqjpj+VXq0JS
+FFyGUOgmgi3Ho4GJMIGGMB0GA1UdDgQWBBR1mXlrdW5rx1VnqMMnUBXo0WWGWjBX
+BgNVHSMEUDBOgBRNsJB++ccSBmbCCKBxi4CjXROBk6EzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTEzggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSAAwRQIhAKYOIo+fdCQRqpH4LN8qUK1aKzKmWGxS
+fGzEEkg/29bMAiAl95cmucoCDMq2Ab8Coc0dEqyJ6+rAPMLBCbGawyiW6A==
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIL1c0zvh4Fx8aylrlHsOsK5Pcam7BWVHM2lDxGO26QIUoAoGCCqGSM49
+AwEHoUQDQgAEJSlIjKErLP4bE2rHnanQdgQjhiYU7dIYFBnlJ1jWdbLzuMp9BpBR
+2dPPvn5djCqo6Y/lV6tCUhRchlDoJoItxw==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB2DCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMTUwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMTYwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQ7Vsp7JmDN
+kgPh/+zmIPkd7o0xot/WPMFn3uAsGtsU385MF0fmhfFLhRbbH9h4JjYHj8y0spU3
+buUXhftvAZVbo4GJMIGGMB0GA1UdDgQWBBRTw3K0Psy3u/6+3KKSoaQqJnPvPjBX
+BgNVHSMEUDBOgBR1mXlrdW5rx1VnqMMnUBXo0WWGWqEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTE0ggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhAMJnGjE9v3SjuGfi0jNByrwyNfhlTHMh
+FhPQidNrDpXwAiEAqYtNiV8t9RrAa9GC6FWDuJpvIiU6FsE+lFq6uIq/J2E=
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIM0YCnGkEG/TjBxrytP9Ztslm1yoQaWptBxegRzzBRDVoAoGCCqGSM49
+AwEHoUQDQgAEO1bKeyZgzZID4f/s5iD5He6NMaLf1jzBZ97gLBrbFN/OTBdH5oXx
+S4UW2x/YeCY2B4/MtLKVN27lF4X7bwGVWw==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1zCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMTYwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMTcwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARrISq2zO9m
+D29YCLHB56FdU/RINtRhfeLtM+u5o3HaAnopy0S98RzuEGELjpzr8ZI6kkMMZsj8
+nFZQF8HfuE0go4GJMIGGMB0GA1UdDgQWBBSnjWvpWxZcFnfQ2KGtCg/u6fT/DzBX
+BgNVHSMEUDBOgBRTw3K0Psy3u/6+3KKSoaQqJnPvPqEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTE1ggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSAAwRQIgDgXjoc6FfMF5W0NziV6vx2BOPNWav01Z
+ynEP4h9ULnUCIQC1rU4sEId3UdjzTKhpSGTKtaOuPG+b0YdEMPimI4jmVw==
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIAiUS1dM3qrcOun8PjKe+rw40L2HG/Y8Dfxl0AfzyIVeoAoGCCqGSM49
+AwEHoUQDQgAEayEqtszvZg9vWAixweehXVP0SDbUYX3i7TPruaNx2gJ6KctEvfEc
+7hBhC46c6/GSOpJDDGbI/JxWUBfB37hNIA==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB2DCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMTcwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMTgwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAASsc/JkNcYf
+bMgpOfrL5kKOGxOJaGS6SQIeNO33UeBpToe1bU2acN652xjvcGo0fJEtxg2fcPHR
+hTnGMBD1u1N2o4GJMIGGMB0GA1UdDgQWBBSDbIpYntlhJ0GgIsyd75XRhlC18jBX
+BgNVHSMEUDBOgBSnjWvpWxZcFnfQ2KGtCg/u6fT/D6EzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTE2ggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhAJo2NXfJU1sK6SVTu4OV21FKITlXntMi
+oenYMsBjzO8oAiEAidSELcLjjAHi3mfBARvCgKlRhmbNEMCHQT7Ha7ZQoRw=
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIJETLWqIZtnejCGzESDgMnknxqEx5evMGZfzBVPKMwKKoAoGCCqGSM49
+AwEHoUQDQgAErHPyZDXGH2zIKTn6y+ZCjhsTiWhkukkCHjTt91HgaU6HtW1NmnDe
+udsY73BqNHyRLcYNn3Dx0YU5xjAQ9btTdg==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1jCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMTgwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMTkwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQJyRCHND78
+KxZHoHHdOTjPuD6HjHPnEKX8apblUpETDJuLW7YR3V8Q0dTac+JHiR6e2l4DlDbf
+5bTiyFoAzw9yo4GJMIGGMB0GA1UdDgQWBBRQMc94kTqW+zQO3lo2WMI/81k3czBX
+BgNVHSMEUDBOgBSDbIpYntlhJ0GgIsyd75XRhlC18qEzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTE3ggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgIzGOZqJRmvygzvLm8zxZFyoNpcT7e26H
+nZd5xFIzEakCIHGYcUXzt+owSVlLmrlW8gQcB81ErQbxuBTAsvpaaKSS
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIDJyHSKbXEZVfkNftQF4eHeJVuXhGdaboa7w4RejL5uYoAoGCCqGSM49
+AwEHoUQDQgAECckQhzQ+/CsWR6Bx3Tk4z7g+h4xz5xCl/GqW5VKREwybi1u2Ed1f
+ENHU2nPiR4kentpeA5Q23+W04shaAM8Pcg==
+-----END EC PRIVATE KEY-----
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIB1jCCAX2gAwIBAgIBATAKBggqhkjOPQQDAjAvMQswCQYDVQQGEwJVSzERMA8G
+A1UECgwIbWJlZCBUTFMxDTALBgNVBAMMBENBMTkwHhcNMTcwNjIyMTE1MDMzWhcN
+MjcwNjIzMTE1MDMzWjAvMQswCQYDVQQGEwJVSzERMA8GA1UECgwIbWJlZCBUTFMx
+DTALBgNVBAMMBENBMjAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATGebrN8JxE
+heOdCxD+mhnQ4zMUxF1WUkmAAHIUw089BYiH9SAwYS/M5tnl+R8fbjvoGqSpR6Tk
+V9EU3CQyIoxwo4GJMIGGMB0GA1UdDgQWBBTZs6oChL1c2CSZXY2YFQkkqg+lzDBX
+BgNVHSMEUDBOgBRQMc94kTqW+zQO3lo2WMI/81k3c6EzpDEwLzELMAkGA1UEBhMC
+VUsxETAPBgNVBAoMCG1iZWQgVExTMQ0wCwYDVQQDDARDQTE4ggEBMAwGA1UdEwQF
+MAMBAf8wCgYIKoZIzj0EAwIDRwAwRAIgRVGZReXKvdMHhwLbPvbrTVLeAGDqmqMH
+/WqD4u23QBgCID/QtFaiawjviNFEdtU7JK6v4ZY0PQ0a0+HLZIHLi9ah
+-----END CERTIFICATE-----
--- /dev/null
+-----BEGIN EC PARAMETERS-----
+BggqhkjOPQMBBw==
+-----END EC PARAMETERS-----
+-----BEGIN EC PRIVATE KEY-----
+MHcCAQEEIJHLciDhJcnlE5MhTrOfFlnRbpJQLOf4h72E6VDXxMM0oAoGCCqGSM49
+AwEHoUQDQgAExnm6zfCcRIXjnQsQ/poZ0OMzFMRdVlJJgAByFMNPPQWIh/UgMGEv
+zObZ5fkfH2476BqkqUek5FfRFNwkMiKMcA==
+-----END EC PRIVATE KEY-----
--- /dev/null
+These certificates form a very long chain, used to test the
+MBEDTLS_X509_MAX_INT_CA limit.
+
+NN.key is the private key of certificate NN.crt.
+
+The root is 00.crt and N+1.crt is a child of N.crt.
+
+File cNN.pem contains the chain NN.crt to 00.crt.
+
+Those certificates were generated by tests/data_files/dir-maxpath/long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IgVMPUoO01bPhzllAa/gW8Xk/daey09SBgN3AT9pWU
+TDA=
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIBpTCCAUugAwIBAgIJAPygloXKk6BwMAoGCCqGSM49BAMCMC8xCzAJBgNVBAYT
+AlVLMREwDwYDVQQKDAhtYmVkIFRMUzENMAsGA1UEAwwEQ0EwMDAeFw0xNzA2MjIx
+MTUwMzJaFw0yNzA2MjMxMTUwMzJaMC8xCzAJBgNVBAYTAlVLMREwDwYDVQQKDAht
+YmVkIFRMUzENMAsGA1UEAwwEQ0EwMDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA
+BFW41/qAwAPpy+Txdc7PKmzZsq9CPiujKU4vpF1ekXnGx2HP420QobwBVVWhkzRm
+LwdboH2j65dcCKjQ7mv/dxKjUDBOMB0GA1UdDgQWBBQlFYvU5WboI4fcdPoiQs8/
+fPHZrTAfBgNVHSMEGDAWgBQlFYvU5WboI4fcdPoiQs8/fPHZrTAMBgNVHRMEBTAD
+AQH/MAoGCCqGSM49BAMCA0gAMEUCIQC7iRcVzwMyfVK5imirJ7MqJQ04euH4CLOt
+IZ+SNfaERAIgSU0MWFDosVEIpg8YMqIHeF7Mg4ZyH6+fGazJgVLttUY=
+-----END CERTIFICATE-----
--- /dev/null
+[int]
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid:always,issuer:always
+basicConstraints = CA:true
--- /dev/null
+#!/bin/sh
+
+set -eu
+
+: ${OPENSSL:=openssl}
+NB=20
+
+OPT="-days 3653 -sha256"
+
+# generate self-signed root
+$OPENSSL ecparam -name prime256v1 -genkey -out 00.key
+$OPENSSL req -new -x509 -subj "/C=UK/O=mbed TLS/CN=CA00" $OPT \
+ -key 00.key -out 00.crt
+
+# cXX.pem is the chain starting at XX
+cp 00.crt c00.pem
+
+# generate long chain
+i=1
+while [ $i -le $NB ]; do
+ UP=$( printf "%02d" $((i-1)) )
+ ME=$( printf "%02d" $i )
+
+ $OPENSSL ecparam -name prime256v1 -genkey -out ${ME}.key
+ $OPENSSL req -new -subj "/C=UK/O=mbed TLS/CN=CA${ME}" \
+ -key ${ME}.key -out ${ME}.csr
+ $OPENSSL x509 -req -CA ${UP}.crt -CAkey ${UP}.key -set_serial 1 $OPT \
+ -extfile int.opensslconf -extensions int \
+ -in ${ME}.csr -out ${ME}.crt
+
+ cat ${ME}.crt c${UP}.pem > c${ME}.pem
+
+ rm ${ME}.csr
+ i=$((i+1))
+done
+++ /dev/null
------BEGIN RSA PRIVATE KEY-----
-MIICXgIBAAKBgQDMYfnvWtC8Id5bPKae5yXSxQTt+Zpul6AnnZWfI2TtIarvjHBF
-UtXRo96y7hoL4VWOPKGCsRqMFDkrbeUjRrx8iL914/srnyf6sh9c8Zk04xEOpK1y
-pvBz+Ks4uZObtjnnitf0NBGdjMKxveTq+VE7BWUIyQjtQ8mbDOsiLLvh7wIDAQAB
-AoGAefPIT8MPpAJNjIE/JrfkAMTgsSLrvCurO5gzDBbxhPE+7tsMrsDDpuix3HBo
-iEg3ZbzV3obQwV7b0gcr34W4t0CMuJf5b5irHRG8JcZuncmofDy6z7S5Vs75O85z
-fVzTIuVUyuHy1rM6rSBYKfsMLVyImUb4wtIXEMHPzdCL9LECQQD3ZfgGqudMWq8v
-3BlKhsQ4fsR0vxzNlMZfoRrZzcvBT339Bp1UQ8aUo8xBtHiRwuW1NaPNgYKX6XQ6
-ppuWuTiJAkEA030i493KnFPLRwWypqF/s6ZNlVye+euFN5NF/IeJcvb/GUDRYv9O
-pRozRS1jNx4ZB1K2xT7N9MwsPHD6j6K4twJBALdfHTfT9RzjGnae7SAQQ+CcFYFz
-JiY6386B2yUVJLFj+j5RaMvMcKQ7xGnvGm7vxtNJrt/j3qg6oavXUfulzgECQQDP
-CEVLhCd/+ZeZoz5MWPTGTRrOCKmoRqNW0FlG6PfpD1qSwh04KG44uflO0yu5HUGr
-JZG+bcj4x5bWZFMkoUrpAkEAyEgQzesKFqcbt1cqv3pLXJYQBBw6leFXgHk11a7k
-+AkexhrPYyq/4tXFO2TLk2hs7tpYgNDOqZCvEu7jtN3RuA==
------END RSA PRIVATE KEY-----
+++ /dev/null
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: DES-EDE3-CBC,BE8274D6692AF2A7
-
-9ZXjoF55A9XgJpdaWmF/ZL1sJfbnE1M42N7HHRDwpq1/K+afC9poM0/AdCUbRL7w
-uvQERievbAYpNeLdah1EftM6033e1oTxUMivdL4orDKcbb3qDpSQ0o0UbjavbT+d
-aruilW8zVP4dz3mYMvGbkgoujgzdT+4wM0T1mTTuYcRKQsHlg7QDy2QrBILNuXA4
-Hmye4GlSXVUSON8vPXT12V4oeubEIZVlnkLTRFGRVA4qz5tby9GBymkeNCBu+LCw
-JwJLTbQwMFqozHvioq/2YBaHDcySpTD4X5AwrCjifUNO9BnLWLAmt8dOWr0z+48E
-P/yWr5xZl3DrKh9r9EGb9xbTxhum3yHV7bvXLoUH+t9gowmd4Lq3Qjjf8jQXle0P
-zoCOVxwN1E1IMhleEUPV7L8mbt26b0JyvrSS5ByrXahGu9vGQyy7qqx9ZANkzgXF
-3hPMDuzQXMJiUeG92VsMEdGdA1/8V5ro+ceB5c7Zca5MjMzvx2tihda7BUjj6dSE
-cA8Vvksy/NX/nqHSt0aSgphvBmZP8dN6GMcZ+hT7p0fhCq4mSFEykQqueKXiFUfz
-0xCUVZC6WzOoEkc8k7xiLWQDlsZZ13Z4yxU1IxJp7llZXpZ8GkwS+678/Nx8h54A
-mv5ZlSFWWQrvN5JPQJka7aU2ITu1LUK6mXBu+DoSDOfQuqR4vQytkjOqHK185iHs
-JQtBGkFFdElkWgubPX/S8/xxoT8MoQY/c+dr6iwcswyUnSJXh32KLPGNBoqWCCbY
-jp/VYmeb117gNpEJKJhcNbrP7DoQrC3/D7JFXnOvTA/z6FOtUmz0rQ==
------END RSA PRIVATE KEY-----
+++ /dev/null
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: AES-128-CBC,B5FA3F70C2AF79EB9D3DD2C40E7AE61A
-
-iyfOvvyTPPR7on4XPFxu6CoCgTqh88ROlslM+RLJhwM/qGexbgDOzeI2CPf4XfzI
-tyevKD/pqCaCMesYJh/HDQCILdW2tGbwzPajg72xkfCD6+1NHOGoDbdQN8ahGVmg
-flAYU0iXDMvqs/jnucM7nlTGp8Istn7+zd9ARyrkQy+I8nvMh3chGKWzx/XtJR+z
-Iv8p+n/o+fCHzGvtj+LWYeUc4d0OTIjnF6QPTtPOexX28z0gXRODT/indgifNXv3
-j45KO2NYOaVTaCuiWIHj7wWBokoL4bCMFcFTJbdJx5BgfLmDkTEmB/6DEXu6UOsQ
-3lPzyJhIRxn7hNq2I47TzSAFvmcXwm84txpxtSwHTcl9LgsyIiEMmHv3lPPE1G94
-F5VrCzzFHyU7nFRdUC0mqLrCHcjDn5O4SQWfH7J/7G4OArU6lA4Z2NC03IPxEmsQ
-66Fu8GdMbmtFORdlZQtOjLi3zZwN9+NwhiUrNNdVvGNJIjIcZ4FZRZysbt7++hfQ
-/JOAKhVNC8dNROJUleEYIiqx23e5lze6wqcIosziq3tb6/SQ6fH533D8+PpcZKsC
-IlWKAQzsNV+nJvt7CI1ppWc6CtV7TKn0scZm2oOC4339gdR5xzxXe9EJDsMBpcg9
-drIdBr+3UxeC6Lc/rWM7IjSQ2YULBra3toEF6UYevngXdUD2YafrpoY5rK9IH90G
-Hjbf65IaHLTS0jA7lAvJsQEBuULQQoWENOjhp8v+UfkNM2ccyOuUk3xZJNeX19YP
-1Z09UMEKbf6ucoRCc01SBl206OAsq1NZEaodszT+mDg990I/9ACVi3LEU6XB5ZVs
------END RSA PRIVATE KEY-----
+++ /dev/null
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: AES-192-CBC,72F869F41B989D71730B2983448251B8
-
-R6ST6H9oUyFWBavUO++azbn9ga87lgeuqNMVVScOcXjguqQZdnuZq9AzwQQETEv+
-ZbVPL9w2isuXKoavaPxYyCXbZ+l6JRfWiXi6CmnfNhx4MgYpbH9BEqGbIVxA3fvu
-zFutqi+Ru6QeERshDNke6HfFjJ91WkBjNjrXcfDmt0uRGqFSWd5DSEniyaPmxCYs
-mpRwr9XESFiBkCHL+/iSkW0EZBjwHW0//RNsZKtuqVJGW/dZhDxerOGRl0a1oWkb
-IvfED7afrXMlpHokMwtUduk2TBE1AoczZ6Dv7RZGipaBR4yb9kYgIkiqFk53lg5h
-7b3WQt6TYECI7X3Q2rDgPQtUChVud0uUQYmQ5328HRE8zhlWxHGmTQMWVBW6X+FM
-ikFLRUeYBeq0UJu20DmvklZV6iDxsULLu+Rb0b8NkT+V2feSXbrP976oCSUznvT6
-3e2EOH+KAqMy5JZhTsjM7HtkleMwYQ9v+Wnbnn1OsB9drYWUJuhQeXt6v8dkm/eD
-9m6dZzivc/h1UThIuuZPo+6S7FoluIlt5uv2UcnYYdYOgKSd1Vm0wztGaJn3CSGw
-JEbebucr+5ptOHxflV5Txgnfj63sJyVd/wy0T8sMRO2znk5uVLWxf855fNXev9M3
-gA3+MXC2eGaR9DYOxfakFRwL+Z30RlIktaqDK76BZRD4sWB6dIVw5JdCXpNMCuDH
-dxlTKcP59uPAEB2VyhDvm5CN3T+bM2K6WDZFO95hKKfEk5ea/UB7DA2ucfovdayE
-Hd46EUKC4/cdUFiSycgD01ztdda7hU7hFvOkHTK7O3G1yvEwH0+jxKNsudNfbbxc
------END RSA PRIVATE KEY-----
+++ /dev/null
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: AES-256-CBC,53572EEEE794948AC48CB0E077CE075A
-
-p0YobpQmzHb3NgGlojpYoH+G5f1XX9snYv2GQe2tGTBQpoHh+ivHcOt85EZu9pC1
-1KRdALEwp7Cb4RYeQncV9Bfp5rItupS1TwfgKAlp7Plmb4vDcDVw+KL3PaYn52Bd
-qq5USLxCvKcl91hZXzitttH072lEj2MzW2QpX2/1hCRPgMD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dev/null
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+if (!@ARGV || $ARGV[0] == '--help') {
+ print <<EOF;
+Usage: $0 mbedtls_test_foo <file.pem
+ $0 TEST_FOO mbedtls_test_foo <file.pem
+Print out a PEM file as C code defining a string constant.
+
+Used to include some of the test data in /library/certs.c for
+self-tests and sample programs.
+EOF
+ exit;
+}
+
+my $pp_name = @ARGV > 1 ? shift @ARGV : undef;
+my $name = shift @ARGV;
+
+my @lines = map {chomp; s/([\\"])/\\$1/g; "\"$_\\r\\n\""} <STDIN>;
+
+if (defined $pp_name) {
+ foreach ("#define $pp_name", @lines[0..@lines-2]) {
+ printf "%-72s\\\n", $_;
+ }
+ print "$lines[@lines-1]\n";
+ print "const char $name\[\] = $pp_name;\n";
+} else {
+ print "const char $name\[\] =";
+ foreach (@lines) {
+ print "\n$_";
+ }
+ print ";\n";
+}
--- /dev/null
+-----BEGIN RSA PRIVATE KEY-----
+MIIBOwIBAAJBALB20jJQgW+aqwIwfkUrl/DK51mDabQWJOivx5caWaE4kvZLB+qm
+7JKMFgstbsj50N1bY8izrAdntPZciS9WwQ8CAwEAAQJAKYfNcIoB7II6PQmsrhrU
+Z5dZW3fSKNANX7X/A1DwR0DlF8uZnpWsWbYcRoXX7QjvepZqc54wryhW55Wlm6yI
+AQIhAOJIaLjSpbHjzzcJQ7mylxn2WGIlbJPPzJ9OaFZCZQvxAiEAx6OEAvl6JKa6
+6a+N2Wvhtcgb4qqR6UHQGJQYGJz5nP8CIAvgoR6ScAAWZRoOcm+c4DGMrLb6H+ji
+T2tNQkzEz2kBAiEAmw34GStU36STpa6RGJ4+tyZN6jWakDVqf7x+HpfFE1cCIQDc
+KzXIxec2taye4OeIa1v4W/MigMmYE9w93Uw/Qi3azA==
+-----END RSA PRIVATE KEY-----
--- /dev/null
+-----BEGIN RSA PRIVATE KEY-----
+MIIBPQIBAAJCATG2mGDzy5v4XqNY/fK9KZDxt3qA1qT9+BekPdiWvffdJq+KwCN/
+Um4NM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5XaBSwcT9eztiLUXGivzc
+-----END RSA PRIVATE KEY-----
--- /dev/null
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: AES-256-CBC,28A56EB102CAFF494BF4AFB55C4ED52A
+
+5yOXbxDDgomJtRFC9iBL819dU/vCOe0JlwdyQOQbagd1Efj7oErrMuVZJOl18d/o
+2G6OtjqlynzoeqkTwE0yJEyRMLz6CIZp0wHGoDMyT4Oe86uGh3ki9ZqIWlgxt+mA
+7e1RApFnZOCzmHCGZNCqdSNUV5G/cs7or6Gd9HvdKSCdxffPptE6FaaY8OX4737P
+pr7svylp569Secz6MO1Rds7eOPEjAZBJyDSah2AMIiEMJxGrZ662iFo/3S1MuDOY
+/xoDHtP/Vo3ep6D8Fp24PeJ4/iocu6hmhAIO4j+zLN6uow/Wu+D8kBKMhtrUtnHO
+AoP6sjkNOsMg7fbTEqTrXHkOw92PbZSBbwsgB5z6kKeTCYVDBHUaDDlOTbCxw+t8
+PH6IOrQXUIPl7dt2ilfLjqgzpw4T+RCYp1xgM1ZIsoCspUpizmMTPwtn7fuIjUHb
+copBjLOT4tUx7itVi2tTAMvtiW9mrHVI8xgpqSiTz2Hg4uMCFlxkglrwp1yIUClY
+BtMGL7qA/l/gmhHRYDpkzf+ewuTeOImyyfEnAawVT3+G6p3tf/Cs9RVgUCnCrFHa
+/BuYhGTtTV+R6F7+3yRk/XORp9R3K4BbgWHHma2dB0zYIFDXYtlrODUyQ362Tv1q
+JNFis2PbtNB7DRKrB/KtteWtg32mSaTL446a0HCF0VpFB/nq0wEPCvghed5KYHSR
+PzoegmnjkDikgid4O/RhcOC5+qEykNalddhQOY6CxJEwVTAviHbQAyW3eP1AnIa+
++Ifc2o67i57bkLLlg0pqHITlz1+g7SWDj7Aix2Y68zWZVL3n+e/wzqbdYqMVxiGz
+-----END RSA PRIVATE KEY-----
--- /dev/null
+-----BEGIN RSA PRIVATE KEY-----
+MIICXgIBAAKBgQCvBX05buhPt1/bt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LsptiUBu2gNyy6FC+Bwov36H51y+f3tJIl51ImWnGQ
+R1HMDtLuzHTb31CmWvXCYf14IT3gowxvpO8smaqoYOIw4XeSzprBKMgqXL69/qjk
++et4W4/zG0p5R4WlKBaReXJ2C57xvSTmbaqbCjIYroshlPo9csPAwFtRrWi4Aqv5
+j9OELmZzgK745QnL3IkqsjQuS+Luqg8s4OFifcwBLSVpo2pWhdJnKk40cai8QLpr
+St8e3BHGZPdxacC04cTc8zN8Xr7r76lZ7h+ppksx0uoTV2U0+3caMqyyByuF5If+
+RUYXOJ0Y2jUMUYdid3k+C0bn5VbChFCxniv10LpJZ24Nt4RKEYy+2VhIQ+FuAbQ/
+dSMJdqBP4TTBu0DzCmqaGvgjjKLTFF635hzP+cFvaFWhVOY2v4tkV+4zkvBUKzss
+Ef3ZwhDses56/KTI54GUJqWxNK+a1ekor3tr1IUMPzeaApzUSRXusT62QMBOW0q9
+8lSNcAywvWrlcZ127J2zZMrk0SKo1jNNzYKWt0e9XpqMWAq07SlUL0MJCt/KYw6J
+1eXT+xE9H5FEZvQkBFCHYyAyq54P3yrWV9y01xi0y3ruBf50i7k/IrAtE9c1FZda
+2h5qh0GNAEiGRr8bbh3A3wugidwAVoHQeuMnAsShf+5gj8Np7W9kEQ==
+-----END RSA PRIVATE KEY-----
--- /dev/null
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,3F3828FEA9BF197C
+
+30fgMPEIKER2VH64TsY5lk8ICdP0prc+UiW/tjbQL+2APptirB5SDRAtuwTvbFRc
+Da97zrRwrhhGxNVobJhhffQlyB6vhM6h5aq9dKwD3auOVFosOm0xdiAC/tv+DqAx
+DIZIhYUB5IeleQ5rlDJWoReUeOcnB+d7VP+Zlc1l7zDMx/3FgOyOhlq7dufNUGnY
+n0tZWKItiV7rOYWTjbDu79BpG52VyHf217v+DeDSugom4FIWQS+XwIKg7xvEnxn/
+vX9pgiaVfXlfZLfUMhKIP+az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g56Zb8gEoBU
+nrzTkLICntwdZqFpITklGfF3tZDIWWgbYZMqEOVk+u6WQWv+rBlXfgyW1UbmcgOP
+yoiJRSvqtsVwY5cSyuiZcm4Py6VM33ad4/fd4E9W3HQL/axHfdUzN3YMGOsd/PfO
+AdgGl81+uIgttDOjj+X+HF17gq3jZA409MZEyyBXEI1QXOJE8EKOVnzjHd+nO3OZ
+GmXYWveeyMUrZba/VVoVB5S/wZntL64GHd+GqaXSuEgjmqYFTPgsehCUYoHHxxeA
+-----END RSA PRIVATE KEY-----
--- /dev/null
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: AES-128-CBC,4D279F635142BFE952A71E8EE6D14B0D
+
+6+qW0XUu06eXe0jjSsmRGySu1KXnEjg+682sUbxOk//2YitaMx8wMQqRQvT9Uusp
+lW7tYOz47wiz2UrJXKo8Rxow3B38wW7vwjh/Xaw4m6DlcID8Ho3ubN1n9Or9goi9
+Kg3NYtrIWac5njywFzf17TIlxmbHg3wF98c0bKRInBGZxVcEtbcdRiM0ZSst4IAm
+xi7vEwHHyo7d3cBJoItJ/1kELqHmwFoWZj2wlXCVEHUU5pFfK5WY7uq5P9FQFBmI
+et0IeCCdysZyRmS8Y6BY5cWv2u9mccIvvazQev8H3W8hQ/LS418yYenqd8CAuvct
+N0tTpVhV+jXxPwV1+F29kpkburnHrbDN+ZUIVaAdea/yNMC+bcoEypnpT6D1m2ig
+ouV7jecJSOxhaDh4h1JccR6Pu2DOWTDpn6pxUrCIo4+2lVbLXOeDS8ClhFf5VzX0
+D+5ZOAdm/LSQIOBXBtqOJ2qDBJINZgpQlRDvo8wDHchslDChTNKdvzjgr/hxdPeE
+tAf33lXR0TgqX2vhwbpjqMX2Zi+7VL8ylcjWITdderiNDueDpy7UN45f+0DVhNfT
+JIleuqNl09tL34unugpM+QSzgJ0odHpZ1VXkr7zgSFOYau6/drlexS61KXsqk6x0
+rs+n9ssgVqS3HCne0l8I4VOejutBLAVGOXoz7EC9PtS+iYavetnEcqf4SBPHikrn
+j67x/wz7jlEsSCyYA8SfPJY1wcKgfKaSU+w2XxAo5bMBjb3QiBYRSvb67q+DtO8K
+hUnZMqdbvzFIyXfP4/5WGhBe7ho0dQrtVT+PcCxknMMQ+kyQp+f+jbddLCvcKQFa
+Dlvw4XpMR4Ee2ukkaWpXAc6ES301NnXoAwlvKAkThfRDHwGckGfiEIunEZN5l1TK
+0X1tp21gUZYE+o7SZNI98Sh2CjxIQSKdA212hI3A+2mOwqBNoZcoDBqrvd2cCoNR
+xDA65eV8l5HrDAtMHHt5wTHzcfMik1CTHwL0/O8izQH+fTHKw8xR+VEoGbbQRkAY
+PJzMvehkVkc7e4K22nXAs38LARUW0D77ppR78VV2d/D5FCIXrDn58pi4RjjnQOO4
+yoGv4snLhnMq8bYQ5En9403cbMCJBYp4gvC09xeNNkL6EKoBjpupSMrZNn19VsrO
+VkACjifittw08/g5ncuAAO98YHQKmNPTM6py707dMs4L5jTOcLHCqo+fo+Wnx9Nx
+v7JmWNuFwfG+gIBIYIKmW0om+pcxfYMsry8byIUGNj5SnaGtl5kLD67Lr+LLJwBJ
+TNbGd8auBVtroIjdGVnvwtS1oM6eNXogL++sD7NBY5GdJvOMVP9X0VjyfHd+byjL
+SfTAJq986dSO+5262mRY3fLsKCeQ/quIvxGsJ2sdRoTFXyKFUu5etuOH+40Yhivx
+SnyUd+mVH3MF2sWpuBRE3Ny87mmE8CzFBh+pDdVpdvb1I387wwhpcSfW/6ila16R
+1NSvAFwXMeZkxpZZ6hn1Avyc1VQi0fICjKCR0WYY7+Fl3Uv9uXznzuv9COHe2nmu
+Giom0TSsOhNeMq0N9AbnUEPAhhIEsaMSZAOODsrvtbRijCcrCkY31EI0O2pT0Vgg
+-----END RSA PRIVATE KEY-----
--- /dev/null
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: AES-192-CBC,9253446D0CFFFA0AA50C251F129E6148
+
+CrtEJsyM72x0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8XGjqYeApHd0das7w8FdDZtNJ
+MK7Oqa2HEq3ChaV8OaiyHul34gR+NttskcQkgRfJX+LJ2j3IxVAqmUdid8LFJL28
+Rpx/pONcGJHjdubbZZ67Cldb/nUs0ST+HQ+BJbYZNqTeDDBSCIsye+MUKnqBIOl/
+30zEUz5WMe2w+c5BWw65aVL7F6gtKao+W93CQ4yZGbNRfiglX193BQYwR1+7QAWT
+78jf5WyYzFj3VU8iwZ/PQ3njCR9Fumm75xtIlAhHqliKg8C3Jfb8uZvSjvntkjWn
+ksgsLRF+/P1PdulaRYNcZAoYKTz9vYpVaWlSyOm3HnKpl2wSoJXrp/cHzd37FyqW
+z8CeXtMSvio2wXmadhBEEoc8QSY5s3/J6jDJaWUxkQNPdWZkDmVgDC0DUlfEdSqh
+-----END RSA PRIVATE KEY-----
--- /dev/null
+-----BEGIN RSA PUBLIC KEY-----
+MIIBCgKCAQEA2xx/LgvNv87RdRCgorjOfariBeB62ERjj7W9wLAZuTe4GUoO8V10
+gGdGhwbeW38GA73BjV4HFdRb9Nzlzz35wREsrmq5ir0dZ2YX6k692xWagofk8HjD
+o4WHsP2fqZlf4zPszOoLtWFe8Ul+P6Mt6gEMzEKadpvE0DfTsRcBYQEWWX4cF8NT
+/dFyy0xgFdp94uqtUO+O4ovUandV1nDZa7vx7jkEOKO94tHgZmvinEeZ6Sjmtvwu
+ymdDhOjVg9admGsBPoHcPHrK+fOc99YoGyd4fMPQ1WOngTSJrSVqvfLq7fpX/OU0
+xsEPcS3SCBAbrURB4P55oGOTirFd6bDubwIDAQAB
+-----END RSA PUBLIC KEY-----
--- /dev/null
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,08A2EE4A627B9219
+
+BZXLuKYuOupeUZGJPIIiGd1dFXaBiFNmczkwjADQeQPb5rzf89n2d7N1442YkJ5q
+nIvyHoezi2er4bhxUX6ToftGdd9X/WeAbuW3QfzlLccf69RgLpKjWasKRlws27W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kZJKCs5zNn9RV/S
+ypllyB3DT9fBCWed8rxAH0PQ5iYc9UNeSkfmWapfJT4YCUmzNYU0C/f7blYet3xL
+1gOXpiISdTh7ilzFe/i5d1I1UegmtTSj/MmVtT8mw1gqc6NIaFIFY+VKU6am0z07
++aD5llI0Ok3/J2YMJKrW14u8VU6oAKfSqhZRdWnEemBJiAgKre9r+3qwg3pGgBCt
+sRYpXZaRLbzmtFjI5Mfy0uB2zhB0XuqVCCgqT7WqzfWilgLRPW1PLJoMxOykg9FW
+3EofQFJZ1/jHCm0Mxcy2a5edwgjIHevRQGGAWHaOnjiHXKBhpnRRTlxsv+ct13kH
+c8cT7E1vQ614hRluDfTeQmyHXerlkSwgZDsEaJpOJ2nWnes2k6u6hRLNEPMoQy5F
+dUdCwLvXxNEnClgx8IizMJmxzhvmAHF+9//WgJS+KxB002MnP4wX8ejpnCgM1/oe
+-----END RSA PRIVATE KEY-----
--- /dev/null
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2xx/LgvNv87RdRCgorjO
+fariBeB62ERjj7W9wLAZuTe4GUoO8V10gGdGhwbeW38GA73BjV4HFdRb9Nzlzz35
+wREsrmq5ir0dZ2YX6k692xWagofk8HjDo4WHsP2fqZlf4zPszOoLtWFe8Ul+P6Mt
+6gEMzEKadpvE0DfTsRcBYQEWWX4cF8NT/dFyy0xgFdp94uqtUO+O4ovUandV1nDZ
+a7vx7jkEOKO94tHgZmvinEeZ6SjmtvwuymdDhOjVg9admGsBPoHcPHrK+fOc99Yo
+Gyd4fMPQ1WOngTSJrSVqvfLq7fpX/OU0xsEPcS3SCBAbrURB4P55oGOTirFd6bDu
+bwIDAQAB
+-----END PUBLIC KEY-----
--- /dev/null
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIICojAcBgoqhkiG9w0BDAEEMA4ECAvRaVQoz78HAgIIAASCAoBiIDDzD49HEwvC
+COrRrODVgYMJ4+jy08j0yQoy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Q=
+-----END ENCRYPTED PRIVATE KEY-----
--- /dev/null
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIC0TBLBgkqhkiG9w0BBQ0wPjApBgkqhkiG9w0BBQwwHAQIEfr61PLRSswCAggA
+MAwGCCqGSIb3DQILBQAwEQYFKw4DAgcECIis3kdV3MqyBIICgN8cVWWhMwix1YF1
+5atoT1U1EWGOUokVtb+oTlqJfMvnZeCHc6kYMwbWvTqga88AUhSssFL9WaXPb67a
+BlhYYkijNdOcu7m0V331RWdzxGAYHHv6Zb+43+/a3fx0hYwWsAKBLKnYXbxAckA1
+NSuItKnyrWCprvhelNLJRBY3aJG9EeqjIeh0MLFMbIhFJosnB7oMliYVu4DxnMNq
+JzWoiBHllgidjZm/vTTmfH9gL0ya6TwBgmj4gOvRu30P9wdBPxS7IZi0xj618SMm
+eOSVdRpuxvX4gzQ0TuWTzFIRdhCFx5fL366tVca/YZ+9qRO5oOqAucVKWZ5zcMVp
+yD1SOjMDP7x+3LBzIYAYb74kHol8ejIQM3IrO0nzANer5M/KWIRbXoDuyLzeiqrG
+FbzpL/kAQ37L7o+GS6gyYgN0lQoZxlgTt4t1+DCNAMWh4xmFTNJgXB6a846u6c41
+K4GQrwOXGAr0pYdNg44fB5fqw+594VKxHEa+7MpMvzos4wsISkrCjbFRVCuO78HY
+rwsD6pWtac02fg+8+a8cTmUXGkzoEKE80hTC0r1SO2w0RabyjTHxRQyZtcCgavkr
+E6Avbabq3GDdxT4IpTI6LiDKFaRUpxMnTyToTlGzsi7sjELHDqgOw4/PbTeNeyJH
+PPqoB71p9Djitpw0plUoO9MWQQPWB7ro3W0g+2lS1782wTk+9jWBDVdgDV8+FYJG
+cr4GxoADHFOt2viKf+7cq5ZP8HxvLfHF4kULslea2AM+3yTQ5TTAahCbGOPVJgaA
+tcqOZIGpIxk+aRceZRrKPerXRmZvRItbgZ+QUCw3kRxgzanOHB671jp+VORMFzJR
+jhpl0rs=
+-----END ENCRYPTED PRIVATE KEY-----
--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8okQjxRiGe+GQLheQpsL/ZW
+HsljSq73o9v/F7xNE9xqIxEGnUDYIAQCX47CiQOTTR9Lz6N/t36Eew1+KjiI4Xda
+VCu207ipFQPpNkvc13z2NWC/4NeRQg82LCYep4y+ZblcyqLqvMwOhJro2Kxoe1e1
+rv1Mwzd0ShUosb/2CChCRdirLJFXaXzm+PzBZoCyJEWcSxi56By58jh6H+XeUxCj
+0fl7eXLHb4sv8kf7P0KJGCxNY7ik3TLJjncsA9gLmFAeRcYWKq5SuSEW3DmfDSXZ
+CC1pSsvFBvV60ZFm2r96xqFHKFHOb15qm9DBXphr870nZQB7+QgRwp+jd+xdXUDS
+PelVGau5uoRN2tFPNvoeGyww9lkuNAJWK4U+LdLwHsQOUIKTf1rgwz5C077omOh4
+3u+3zMTCMRDNhiJb3g==
+-----END ENCRYPTED PRIVATE KEY-----
--- /dev/null
+[v3_ext]
+basicConstraints = CA:false
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid
+nsCertType=server
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIDMTCCAhmgAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER
+MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN
+MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G
+A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN
+BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqQIfPUBq1VVTi/027oJlLhVhXom/
+uOhFkNvuiBZS0/FDUEeWEllkh2v9K+BG+XO+3c+S4ZFb7Wagb4kpeUWA0INq1UFD
+d185fAkER4KwVzlw7aPsFRkeqDMIR8EFQqn9TMO0390GH00QUUBncxMPQPhtgSVf
+CrFTxjB+FTms+Vruf5KepgVb5xOXhbUjktnUJAbVCSWJdQfdphqPPwkZvq1lLGTr
+lZvc/kFeF6babFtpzAK6FCwWJJxK3M3Q91Jnc/EtoCP9fvQxyi1wyokLBNsupk9w
+bp7OvViJ4lNZnm5akmXiiD8MlBmj3eXonZUT7Snbq3AS3FrKaxerUoJUsQIDAQAB
+oz8wPTAJBgNVHRMEAjAAMB0GA1UdDgQWBBQfdNY/KcF0dEU7BRIsPai9Q1kCpjAR
+BglghkgBhvhCAQEEBAMCAEAwDQYJKoZIhvcNAQEFBQADggEBABNT+r+6vvlpjtyz
+mewrGOKPt5iwb8w2aReJ0AWuyQzTiduN26MhXq93cXHV0pHj2rD7MfiBEwBSWnf9
+FcxkE0g77GVyM9Vs9Uy/MspIqOce7JD0c36G4EI8lYce2TYwQLE9CGNl+LDxqkLy
+prijXBl/FaD+IO/SNMr3VVnfFEZqPUxg+BSTaGgD+52Z7B4nPP0xGPjlW367RGDv
+9dIkr1thve2WOeC9ixxl9K/864I7/0GdbgKSf77xl3/5vnQUOY7kugRvkvxWIgHS
+HNVnmEN2I2Nb0M8lQNF1sFDbpFwVbh9CkBF5LJNesy0VWd67Ho6EntPEb7vBFF/x
+jz0b2l4=
+-----END CERTIFICATE-----
--- /dev/null
+[v3_ext]
+basicConstraints = CA:false
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid
--- /dev/null
+-----BEGIN CERTIFICATE REQUEST-----
+MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow
+GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP
+ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ
+ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ
+HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF
+W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs
+FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/
+DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAAMA0GCSqGSIb3DQEBCwUA
+A4IBAQBY/1nnYQ3ThVyeZb1Z2wLYoHZ5rfeJCedyP7N/gjJZjhrMbwioUft2uHpb
++OZQfxRXJTbtj/1wpRMCoUMLWzapS7/xGx3IjoPtl42aM4M+xVYvbLjExL13kUAr
+eE4JWcMIbTEPol2zSdX/LuB+m27jEp5VsvM2ty9qOw/T4iKwjFSe6pcYZ2spks19
+3ltgjnaamwqKcN9zUA3IERTsWjr5exKYgfXm2OeeuSP0tHr7Dh+w/2XA9dGcLhrm
+TA4P8QjIgSDlyzmhYYmsrioFPuCfdi1uzs8bxmbLXbiCGZ8TDMy5oLqLo1K+j2pF
+ox+ATHKxQ/XpRQP+2OTb9sw1kM59
+-----END CERTIFICATE REQUEST-----
--- /dev/null
+[v3_ext]
+basicConstraints = CA:false
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid
+keyUsage=critical, digitalSignature, nonRepudiation, keyEncipherment
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIDLjCCAhagAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER
+MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN
+MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G
+A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN
+BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqQIfPUBq1VVTi/027oJlLhVhXom/
+uOhFkNvuiBZS0/FDUEe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GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZI
+hvcNAQEBBQADggEPADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb
+7ogWUtPxQ1BHlhJZZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJ
+BEeCsFc5cO2j7BUZHqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8Yw
+fhU5rPla7n+SnqYFW+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5B
+Xhem2mxbacwCuhQsFiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1Y
+ieJTWZ5uWpJl4og/DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAATANBgkq
+hkiG9w0BAQUFAAOCAQEAPMRfR9ql7b06b5DdNyJhD96lBzuVSUOW2MgVHT2Vs7NB
+tk5L1htpA5N4uaIeyt6YM0xU0nHdHUKaywNcDiXcnzvRoctGWiWdpcEvdA0rYRF5
+T4MGPpjEuLJcG3aTU8mV8wUEbrY6IEnSpC1G9iasjhkwAF7pb/Ic8+/riwmPD/Fh
+zBrRfBCgi5VXbX9IvY+yQHRVRal8y+n4eh9/hFxBKDbvuidFropGzcuparEwCIRi
+U7L/7aZ3A5wsQp9GPDliSjpeYCf5tok/bvjG4xU041pGQ7yVNpu2mEIoqDz9v+Ay
+IKqsWradEnFG/1ov78a2RB+2+iIPE4iCDtmKUkgPjQ==
-----END CERTIFICATE-----
--- /dev/null
+[ req ]
+distinguished_name = req_distinguished_name
+prompt = no
+# Restrict to non-UTF8 PrintableStrings.
+string_mask = nombstr
+
+[ req_distinguished_name ]
+C = NL
+O = PolarSSL
+CN = PolarSSL Server 1
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIDfTCCAmWgAwIBAgIBBDANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER
+MA8GA1UECg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/3/MGMGA1UdIwRcMFqA
+FLRa5KWz3tJS9rnVppUP6z68x/3/oT+kPTA7MQswCQYDVQQGEwJOTDERMA8GA1UE
+CgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0GCAQAwDAYDVR0T
+BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAHK/HHrTZMnnVMpde1io+voAtql7j
+4sRhLrjD7o3THtwRbDa2diCvpq0Sq23Ng2LMYoXsOxoL/RQK3iN7UKxV3MKPEr0w
+XQS+kKQqiT2bsfrjnWMVHZtUOMpm6FNqcdGm/Rss3vKda2lcKl8kUnq/ylc1+QbB
+G6A6tUvQcr2ZyWfVg+mM5XkhTrOOXus2OLikb4WwEtJTJRNE0f+yPODSUz0/vT57
+ApH0CnB80bYJshYHPHHymOtleAB8KSYtqm75g/YNobjnjB6cm4HkW3OZRVIl6fYY
+n20NRVA1Vjs6GAROr4NqW4k/+LofY9y0LLDE+p0oIEKXIsIvhPr39swxSA==
+-----END CERTIFICATE-----
--- /dev/null
+[req]
+x509_extensions = v3_ca
+distinguished_name = req_dn
+
+[req_dn]
+countryName = NL
+organizationalUnitName = PolarSSL
+commonName = PolarSSL Test CA
+
+[v3_ca]
+subjectKeyIdentifier=hash
+authorityKeyIdentifier=keyid:always,issuer:always
+basicConstraints = CA:true
+
+[test_ca]
+database = /dev/null
+
+[crl_ext_idp]
+issuingDistributionPoint=critical, @idpdata
+
+[crl_ext_idp_nc]
+issuingDistributionPoint=@idpdata
+
+[idpdata]
+fullname=URI:http://pki.example.com/
--- /dev/null
+ [ ca ]
+ default_ca = test-ca
+
+ [ test-ca ]
+ certificate = test-ca.crt
+ private_key = test-ca.key
+ serial = test-ca.server1.serial
+ default_md = sha1
+ default_startdate = 110212144406Z
+ default_enddate = 210212144406Z
+ new_certs_dir = ./
+ database = ./test-ca.server1.db
+ policy = policy_match
+
+ [policy_match]
+ countryName = supplied
+ organizationName = supplied
+ commonName = supplied
--- /dev/null
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j0EAwIFAANpADBmAjEAvQ/49lXXrLYdOIGtTaYWjpZP
+tRBXQiGPMzUvmKBk7gM7bF4iFPsdJikyXHmuwv3RAjEA8vtUX8fAAB3fbh5dEXRm
+l7tz0Sw/RW6AHFtaIauGkhHqeKIaKIi6WSgHu6x97uyg
+-----END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIICIDCCAaWgAwIBAgIBCjAKBggqhkjOPQQDAjA+MQswCQYDVQQGEwJOTDERMA8G
+A1UEChMIUG9sYXJTU0wxHDAaBgNVBAMTE1BvbGFyc3NsIFRlc3QgRUMgQ0EwHhcN
+MTMwOTI0MTU1MjA0WhcNMjMwOTIyMTU1MjA0WjA0MQswCQYDVQQGEwJOTDERMA8G
+A1UEChMIUG9sYXJTU0wxEjAQBgNVBAMTCWxvY2FsaG9zdDBZMBMGByqGSM49AgEG
+CCqGSM49AwEHA0IABIFZMXZJJPoVraugMW4O7TMR+pElVcGwwZwDcj6Yui2kcjeJ
+H0M3jR+OOtjwV+gvT8kApPfbcw+yxgSU0UA7OOOjgZ0wgZowCQYDVR0TBAIwADAd
+BgNVHQ4EFgQUfmWPPjMDFOXhvmCy4IV/jOdgK3swbgYDVR0jBGcwZYAUnW0gJEkB
+PyvLeLUZvH4kydv7NnyhQqRAMD4xCzAJBgNVBAYTAk5MMREwDwYDVQQKEwhQb2xh
+clNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBFQyBDQYIJAMFD4n5iQ8zoMAoG
+CCqGSM49BAMCA2kAMGYCMQCsYTyleBFuI4nizuxo/ie5dxJnD0ynwCnRJ+84PZP4
+AQA3HdUz0qNYs4CZ2am9Gz0CMQDr2TNLFA3C3S3pmgXMT0eKzR1Ca1/Nulf0llQZ
+Xj09kLboxuemP40IIqhQnpYptMg=
+-----END CERTIFICATE-----
--- /dev/null
+README for git hooks script
+===========================
+git has a way to run scripts, which are invoked by specific git commands.
+The git hooks are located in `<mbed TLS root>/.git/hooks`, and as such are not under version control
+for more information, see the [git documentation](https://git-scm.com/docs/githooks).
+
+The mbed TLS git hooks are located in `<mbed TLS root>/tests/git-scripts` directory, and one must create a soft link from `<mbed TLS root>/.git/hooks` to `<mbed TLS root>/tesst/git-scripts`, in order to make the hook scripts successfully work.
+
+Example:
+
+Execute the following command to create a link on linux from the mbed TLS `.git/hooks` directory:
+`ln -s ../../tests/git-scripts/pre-push.sh pre-push`
+
+**Note: Currently the mbed TLS git hooks work only on a GNU platform. If using a non-GNU platform, don't enable these hooks!**
+
+These scripts can also be used independently.
--- /dev/null
+#!/bin/sh
+# pre-push.sh
+#
+# This file is part of mbed TLS (https://tls.mbed.org)
+#
+# Copyright (c) 2017, ARM Limited, All Rights Reserved
+#
+# Purpose
+#
+# Called by "git push" after it has checked the remote status, but before anything has been
+# pushed. If this script exits with a non-zero status nothing will be pushed.
+# This script can also be used independently, not using git.
+#
+# This hook is called with the following parameters:
+#
+# $1 -- Name of the remote to which the push is being done
+# $2 -- URL to which the push is being done
+#
+# If pushing without using a named remote those arguments will be equal.
+#
+# Information about the commits which are being pushed is supplied as lines to
+# the standard input in the form:
+#
+# <local ref> <local sha1> <remote ref> <remote sha1>
+#
+
+REMOTE="$1"
+URL="$2"
+
+echo "REMOTE is $REMOTE"
+echo "URL is $URL"
+
+set -eu
+
+run_test()
+{
+ TEST=$1
+ echo "running '$TEST'"
+ if ! `$TEST > /dev/null 2>&1`; then
+ echo "test '$TEST' failed"
+ return 1
+ fi
+}
+
+run_test ./tests/scripts/check-doxy-blocks.pl
+run_test ./tests/scripts/check-names.sh
+run_test ./tests/scripts/check-generated-files.sh
-#!/bin/sh
+#! /usr/bin/env sh
# all.sh
#
# This file is part of mbed TLS (https://tls.mbed.org)
#
-# Copyright (c) 2014-2016, ARM Limited, All Rights Reserved
-#
+# Copyright (c) 2014-2017, ARM Limited, All Rights Reserved
+
+
+
+################################################################
+#### Documentation
+################################################################
+
# Purpose
+# -------
#
# To run all tests possible or available on the platform.
#
+# Notes for users
+# ---------------
+#
# Warning: the test is destructive. It includes various build modes and
# configurations, and can and will arbitrarily change the current CMake
-# configuration. After this script has been run, the CMake cache will be lost
-# and CMake will no longer be initialised.
+# configuration. The following files must be committed into git:
+# * include/mbedtls/config.h
+# * Makefile, library/Makefile, programs/Makefile, tests/Makefile
+# After running this script, the CMake cache will be lost and CMake
+# will no longer be initialised.
+#
+# The script assumes the presence of a number of tools:
+# * Basic Unix tools (Windows users note: a Unix-style find must be before
+# the Windows find in the PATH)
+# * Perl
+# * GNU Make
+# * CMake
+# * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind)
+# * arm-gcc and mingw-gcc
+# * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc
+# * Yotta build dependencies, unless invoked with --no-yotta
+# * OpenSSL and GnuTLS command line tools, recent enough for the
+# interoperability tests. If they don't support SSLv3 then a legacy
+# version of these tools must be present as well (search for LEGACY
+# below).
+# See the invocation of check_tools below for details.
+#
+# This script must be invoked from the toplevel directory of a git
+# working copy of Mbed TLS.
+#
+# Note that the output is not saved. You may want to run
+# script -c tests/scripts/all.sh
+# or
+# tests/scripts/all.sh >all.log 2>&1
+#
+# Notes for maintainers
+# ---------------------
+#
+# The tests are roughly in order from fastest to slowest. This doesn't
+# have to be exact, but in general you should add slower tests towards
+# the end and fast checks near the beginning.
+#
+# Sanity checks have the following form:
+# 1. msg "short description of what is about to be done"
+# 2. run sanity check (failure stops the script)
#
-# The script assumes the presence of gcc and clang (recent enough for using
-# ASan with gcc and MemSan with clang, or valgrind) are available, as well as
-# cmake and a "good" find.
+# Build or build-and-test steps have the following form:
+# 1. msg "short description of what is about to be done"
+# 2. cleanup
+# 3. preparation (config.pl, cmake, ...) (failure stops the script)
+# 4. make
+# 5. Run tests if relevant. All tests must be prefixed with
+# if_build_successful for the sake of --keep-going.
+
+
+
+################################################################
+#### Initialization and command line parsing
+################################################################
# Abort on errors (and uninitialised variables)
set -eu
-if [ -d library -a -d include -a -d tests ]; then :; else
- err_msg "Must be run from mbed TLS root"
+if [ "$( uname )" != "Linux" ]; then
+ echo "This script only works in Linux" >&2
+ exit 1
+elif [ -d library -a -d include -a -d tests ]; then :; else
+ echo "Must be run from mbed TLS root" >&2
exit 1
fi
MEMORY=0
FORCE=0
+KEEP_GOING=0
RELEASE=0
+RUN_ARMCC=1
+YOTTA=1
# Default commands, can be overriden by the environment
: ${OPENSSL:="openssl"}
: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build}
+: ${ARMC5_BIN_DIR:=/usr/bin}
+: ${ARMC6_BIN_DIR:=/usr/bin}
+
+# if MAKEFLAGS is not set add the -j option to speed up invocations of make
+if [ -n "${MAKEFLAGS+set}" ]; then
+ export MAKEFLAGS="-j"
+fi
usage()
{
- printf "Usage: $0\n"
- printf " -h|--help\t\tPrint this help.\n"
- printf " -m|--memory\t\tAdditional optional memory tests.\n"
- printf " -f|--force\t\tForce the tests to overwrite any modified files.\n"
- printf " -s|--seed\t\tInteger seed value to use for this test run.\n"
- printf " -r|--release-test\t\tRun this script in release mode. This fixes the seed value to 1.\n"
- printf " --out-of-source-dir=<path>\t\tDirectory used for CMake out-of-source build tests."
- printf " --openssl=<OpenSSL_path>\t\tPath to OpenSSL executable to use for most tests.\n"
- printf " --openssl-legacy=<OpenSSL_path>\t\tPath to OpenSSL executable to use for legacy tests e.g. SSLv3.\n"
- printf " --gnutls-cli=<GnuTLS_cli_path>\t\tPath to GnuTLS client executable to use for most tests.\n"
- printf " --gnutls-serv=<GnuTLS_serv_path>\t\tPath to GnuTLS server executable to use for most tests.\n"
- printf " --gnutls-legacy-cli=<GnuTLS_cli_path>\t\tPath to GnuTLS client executable to use for legacy tests.\n"
- printf " --gnutls-legacy-serv=<GnuTLS_serv_path>\t\tPath to GnuTLS server executable to use for legacy tests.\n"
+ cat <<EOF
+Usage: $0 [OPTION]...
+ -h|--help Print this help.
+
+General options:
+ -f|--force Force the tests to overwrite any modified files.
+ -k|--keep-going Run all tests and report errors at the end.
+ -m|--memory Additional optional memory tests.
+ --armcc Run ARM Compiler builds (on by default).
+ --no-armcc Skip ARM Compiler builds.
+ --no-yotta Skip yotta module build.
+ --out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
+ -r|--release-test Run this script in release mode. This fixes the seed value to 1.
+ -s|--seed Integer seed value to use for this test run.
+ --yotta Build yotta module (on by default).
+
+Tool path options:
+ --armc5-bin-dir=<ARMC5_bin_dir_path> ARM Compiler 5 bin directory.
+ --armc6-bin-dir=<ARMC6_bin_dir_path> ARM Compiler 6 bin directory.
+ --gnutls-cli=<GnuTLS_cli_path> GnuTLS client executable to use for most tests.
+ --gnutls-serv=<GnuTLS_serv_path> GnuTLS server executable to use for most tests.
+ --gnutls-legacy-cli=<GnuTLS_cli_path> GnuTLS client executable to use for legacy tests.
+ --gnutls-legacy-serv=<GnuTLS_serv_path> GnuTLS server executable to use for legacy tests.
+ --openssl=<OpenSSL_path> OpenSSL executable to use for most tests.
+ --openssl-legacy=<OpenSSL_path> OpenSSL executable to use for legacy tests e.g. SSLv3.
+EOF
}
# remove built files as well as the cmake cache/config
cleanup()
{
- make clean
+ command make clean
find . -name yotta -prune -o -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} \+
rm -f include/Makefile include/mbedtls/Makefile programs/*/Makefile
fi
}
-trap cleanup INT TERM HUP
+# Executed on exit. May be redefined depending on command line options.
+final_report () {
+ :
+}
+
+fatal_signal () {
+ cleanup
+ final_report $1
+ trap - $1
+ kill -$1 $$
+}
+
+trap 'fatal_signal HUP' HUP
+trap 'fatal_signal INT' INT
+trap 'fatal_signal TERM' TERM
msg()
{
echo "* $1 "
printf "* "; date
echo "******************************************************************"
+ current_section=$1
}
+if [ $RUN_ARMCC -ne 0 ]; then
+ armc6_build_test()
+ {
+ FLAGS="$1"
+
+ msg "build: ARM Compiler 6 ($FLAGS), make"
+ ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \
+ WARNING_CFLAGS='-xc -std=c99' make lib
+ make clean
+ }
+fi
+
err_msg()
{
echo "$1" >&2
while [ $# -gt 0 ]; do
case "$1" in
- --memory|-m*)
- MEMORY=${1#-m}
+ --armcc)
+ RUN_ARMCC=1
+ ;;
+ --armc5-bin-dir)
+ shift
+ ARMC5_BIN_DIR="$1"
+ ;;
+ --armc6-bin-dir)
+ shift
+ ARMC6_BIN_DIR="$1"
;;
--force|-f)
FORCE=1
;;
- --seed|-s)
+ --gnutls-cli)
shift
- SEED="$1"
+ GNUTLS_CLI="$1"
;;
- --release-test|-r)
- RELEASE=1
+ --gnutls-legacy-cli)
+ shift
+ GNUTLS_LEGACY_CLI="$1"
;;
- --out-of-source-dir)
+ --gnutls-legacy-serv)
shift
- OUT_OF_SOURCE_DIR="$1"
+ GNUTLS_LEGACY_SERV="$1"
+ ;;
+ --gnutls-serv)
+ shift
+ GNUTLS_SERV="$1"
+ ;;
+ --help|-h)
+ usage
+ exit
+ ;;
+ --keep-going|-k)
+ KEEP_GOING=1
+ ;;
+ --memory|-m)
+ MEMORY=1
+ ;;
+ --no-armcc)
+ RUN_ARMCC=0
+ ;;
+ --no-yotta)
+ YOTTA=0
;;
--openssl)
shift
shift
OPENSSL_LEGACY="$1"
;;
- --gnutls-cli)
+ --out-of-source-dir)
shift
- GNUTLS_CLI="$1"
+ OUT_OF_SOURCE_DIR="$1"
;;
- --gnutls-serv)
- shift
- GNUTLS_SERV="$1"
+ --release-test|-r)
+ RELEASE=1
;;
- --gnutls-legacy-cli)
+ --seed|-s)
shift
- GNUTLS_LEGACY_CLI="$1"
+ SEED="$1"
;;
- --gnutls-legacy-serv)
- shift
- GNUTLS_LEGACY_SERV="$1"
+ --yotta)
+ YOTTA=1
;;
- --help|-h|*)
- usage
- exit 1
+ *)
+ echo >&2 "Unknown option: $1"
+ echo >&2 "Run $0 --help for usage."
+ exit 120
;;
esac
shift
done
if [ $FORCE -eq 1 ]; then
- rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
+ if [ $YOTTA -eq 1 ]; then
+ rm -rf yotta/module "$OUT_OF_SOURCE_DIR"
+ fi
git checkout-index -f -q $CONFIG_H
cleanup
else
- if [ -d yotta/module ]; then
+ if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then
err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'"
echo "You can either delete your work and retry, or force the test to overwrite the"
echo "test by rerunning the script as: $0 --force"
fi
if ! git diff-files --quiet include/mbedtls/config.h; then
- echo $?
err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. "
echo "You can either delete or preserve your work, or force the test by rerunning the"
echo "script as: $0 --force"
fi
fi
+build_status=0
+if [ $KEEP_GOING -eq 1 ]; then
+ failure_summary=
+ failure_count=0
+ start_red=
+ end_color=
+ if [ -t 1 ]; then
+ case "${TERM:-}" in
+ *color*|cygwin|linux|rxvt*|screen|[Eex]term*)
+ start_red=$(printf '\033[31m')
+ end_color=$(printf '\033[0m')
+ ;;
+ esac
+ fi
+ record_status () {
+ if "$@"; then
+ last_status=0
+ else
+ last_status=$?
+ text="$current_section: $* -> $last_status"
+ failure_summary="$failure_summary
+$text"
+ failure_count=$((failure_count + 1))
+ echo "${start_red}^^^^$text^^^^${end_color}"
+ fi
+ }
+ make () {
+ case "$*" in
+ *test|*check)
+ if [ $build_status -eq 0 ]; then
+ record_status command make "$@"
+ else
+ echo "(skipped because the build failed)"
+ fi
+ ;;
+ *)
+ record_status command make "$@"
+ build_status=$last_status
+ ;;
+ esac
+ }
+ final_report () {
+ if [ $failure_count -gt 0 ]; then
+ echo
+ echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ echo "${start_red}FAILED: $failure_count${end_color}$failure_summary"
+ echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+ elif [ -z "${1-}" ]; then
+ echo "SUCCESS :)"
+ fi
+ if [ -n "${1-}" ]; then
+ echo "Killed by SIG$1."
+ fi
+ }
+else
+ record_status () {
+ "$@"
+ }
+fi
+if_build_succeeded () {
+ if [ $build_status -eq 0 ]; then
+ record_status "$@"
+ fi
+}
+
if [ $RELEASE -eq 1 ]; then
# Fix the seed value to 1 to ensure that the tests are deterministic.
SEED=1
echo "GNUTLS_SERV: $GNUTLS_SERV"
echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI"
echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV"
+echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR"
+echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR"
+
+ARMC5_CC="$ARMC5_BIN_DIR/armcc"
+ARMC5_AR="$ARMC5_BIN_DIR/armar"
+ARMC6_CC="$ARMC6_BIN_DIR/armclang"
+ARMC6_AR="$ARMC6_BIN_DIR/armar"
# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
# we just export the variables they require
# Make sure the tools we need are available.
check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \
- "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
- "arm-none-eabi-gcc" "armcc"
+ "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \
+ "arm-none-eabi-gcc" "i686-w64-mingw32-gcc"
+if [ $RUN_ARMCC -ne 0 ]; then
+ check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR"
+fi
+
+
+
+################################################################
+#### Basic checks
+################################################################
#
# Test Suites to be executed
msg "info: output_env.sh"
OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \
GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \
- GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" scripts/output_env.sh
+ GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \
+ ARMC6_CC="$ARMC6_CC" scripts/output_env.sh
msg "test: recursion.pl" # < 1s
tests/scripts/recursion.pl library/*.c
cleanup
tests/scripts/doxygen.sh
-msg "build: create and build yotta module" # ~ 30s
-cleanup
-tests/scripts/yotta-build.sh
+
+
+################################################################
+#### Build and test many configurations and targets
+################################################################
+
+if [ $RUN_ARMCC -ne 0 ] && [ $YOTTA -ne 0 ]; then
+ # Note - use of yotta is deprecated, and yotta also requires armcc to be on the
+ # path, and uses whatever version of armcc it finds there.
+ msg "build: create and build yotta module" # ~ 30s
+ cleanup
+ record_status tests/scripts/yotta-build.sh
+fi
msg "build: cmake, gcc, ASan" # ~ 1 min 50s
cleanup
make test
msg "test: ssl-opt.sh (ASan build)" # ~ 1 min
-tests/ssl-opt.sh
+if_build_succeeded tests/ssl-opt.sh
msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s
-tests/scripts/test-ref-configs.pl
+if_build_succeeded tests/scripts/test-ref-configs.pl
msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min
make
msg "test: compat.sh (ASan build)" # ~ 6 min
-tests/compat.sh
+if_build_succeeded tests/compat.sh
msg "build: Default + SSLv3 (ASan build)" # ~ 6 min
cleanup
make test
msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min
-tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
-OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
+if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2'
+if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3'
msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min
-tests/ssl-opt.sh
+if_build_succeeded tests/ssl-opt.sh
-msg "build: cmake, full config, clang" # ~ 50s
+msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min
+cleanup
+cp "$CONFIG_H" "$CONFIG_BAK"
+scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION
+CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
+make
+
+msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s
+make test
+
+msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min
+if_build_succeeded tests/ssl-opt.sh
+
+msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min
+cleanup
+cp "$CONFIG_H" "$CONFIG_BAK"
+scripts/config.pl set MBEDTLS_RSA_NO_CRT
+CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
+make
+
+msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s
+make test
+
+msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s
+tests/ssl-opt.sh -f RSA
+
+msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min
+tests/compat.sh -t RSA
+
+msg "build: cmake, full config, clang, C99" # ~ 50s
cleanup
cp "$CONFIG_H" "$CONFIG_BAK"
scripts/config.pl full
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests
-CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check .
-make
+CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On .
+make CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic'
msg "test: main suites (full config)" # ~ 5s
-make test
+make CFLAGS='-Werror -Wall -Wextra' test
msg "test: ssl-opt.sh default (full config)" # ~ 1s
-tests/ssl-opt.sh -f Default
+if_build_succeeded tests/ssl-opt.sh -f Default
msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min
-OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR'
+if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR'
msg "test/build: curves.pl (gcc)" # ~ 4 min
cleanup
cmake -D CMAKE_BUILD_TYPE:String=Debug .
-tests/scripts/curves.pl
+if_build_succeeded tests/scripts/curves.pl
msg "test/build: key-exchanges (gcc)" # ~ 1 min
cleanup
cmake -D CMAKE_BUILD_TYPE:String=Check .
-tests/scripts/key-exchanges.pl
+if_build_succeeded tests/scripts/key-exchanges.pl
msg "build: Unix make, -Os (gcc)" # ~ 30s
cleanup
-CC=gcc CFLAGS='-Werror -Os' make
+make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os'
-# this is meant to cath missing #define mbedtls_printf etc
-# disable fsio to catch some more missing #include <stdio.h>
-msg "build: full config except platform/fsio, make, gcc" # ~ 30s
+# Full configuration build, without platform support, file IO and net sockets.
+# This should catch missing mbedtls_printf definitions, and by disabling file
+# IO, it should catch missing '#include <stdio.h>'
+msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s
cleanup
cp "$CONFIG_H" "$CONFIG_BAK"
scripts/config.pl full
scripts/config.pl unset MBEDTLS_PLATFORM_C
+scripts/config.pl unset MBEDTLS_NET_C
scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY
scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT
scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT
scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
scripts/config.pl unset MBEDTLS_FS_IO
-CC=gcc CFLAGS='-Werror -O0' make
+# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19,
+# to re-enable platform integration features otherwise disabled in C99 builds
+make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs
+make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test
# catch compile bugs in _uninit functions
msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s
scripts/config.pl full
scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
-CC=gcc CFLAGS='-Werror -O0' make
+make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s
cleanup
cp "$CONFIG_H" "$CONFIG_BAK"
scripts/config.pl full
scripts/config.pl unset MBEDTLS_SSL_SRV_C
-CC=gcc CFLAGS='-Werror -O0' make
+make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s
cleanup
cp "$CONFIG_H" "$CONFIG_BAK"
scripts/config.pl full
scripts/config.pl unset MBEDTLS_SSL_CLI_C
-CC=gcc CFLAGS='-Werror -O0' make
+make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0'
+# Note, C99 compliance can also be tested with the sockets support disabled,
+# as that requires a POSIX platform (which isn't the same as C99).
msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s
cleanup
cp "$CONFIG_H" "$CONFIG_BAK"
scripts/config.pl full
scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc.
scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux
-CC=gcc CFLAGS='-Werror -O0 -std=c99 -pedantic' make lib
+make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib
+
+msg "build: default config except MFL extension (ASan build)" # ~ 30s
+cleanup
+cp "$CONFIG_H" "$CONFIG_BAK"
+scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
+CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
+make
+
+msg "test: ssl-opt.sh, MFL-related tests"
+if_build_succeeded tests/ssl-opt.sh -f "Max fragment length"
msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)"
cleanup
make test
if uname -a | grep -F Linux >/dev/null; then
-msg "build/test: make shared" # ~ 40s
-cleanup
-make SHARED=1 all check
+ msg "build/test: make shared" # ~ 40s
+ cleanup
+ make SHARED=1 all check
fi
if uname -a | grep -F x86_64 >/dev/null; then
-msg "build: i386, make, gcc" # ~ 30s
-cleanup
-CC=gcc CFLAGS='-Werror -m32' make
+ msg "build: i386, make, gcc" # ~ 30s
+ cleanup
+ make CC=gcc CFLAGS='-Werror -Wall -Wextra -m32'
+
+ msg "test: i386, make, gcc"
+ make test
+
+ msg "build: 64-bit ILP32, make, gcc" # ~ 30s
+ cleanup
+ make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32'
+
+ msg "test: 64-bit ILP32, make, gcc"
+ make test
fi # x86_64
+msg "build: gcc, force 32-bit bignum limbs"
+cleanup
+cp "$CONFIG_H" "$CONFIG_BAK"
+scripts/config.pl unset MBEDTLS_HAVE_ASM
+scripts/config.pl unset MBEDTLS_AESNI_C
+scripts/config.pl unset MBEDTLS_PADLOCK_C
+make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32'
+
+msg "test: gcc, force 32-bit bignum limbs"
+make test
+
+msg "build: gcc, force 64-bit bignum limbs"
+cleanup
+cp "$CONFIG_H" "$CONFIG_BAK"
+scripts/config.pl unset MBEDTLS_HAVE_ASM
+scripts/config.pl unset MBEDTLS_AESNI_C
+scripts/config.pl unset MBEDTLS_PADLOCK_C
+make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64'
+
+msg "test: gcc, force 64-bit bignum limbs"
+make test
+
msg "build: arm-none-eabi-gcc, make" # ~ 10s
cleanup
cp "$CONFIG_H" "$CONFIG_BAK"
scripts/config.pl unset MBEDTLS_THREADING_C
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
-CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS=-Werror make lib
+make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
-msg "build: armcc, make"
+msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s
+cleanup
+cp "$CONFIG_H" "$CONFIG_BAK"
+scripts/config.pl full
+scripts/config.pl unset MBEDTLS_NET_C
+scripts/config.pl unset MBEDTLS_TIMING_C
+scripts/config.pl unset MBEDTLS_FS_IO
+scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED
+scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY
+# following things are not in the default config
+scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c
+scripts/config.pl unset MBEDTLS_THREADING_PTHREAD
+scripts/config.pl unset MBEDTLS_THREADING_C
+scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
+scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
+scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION
+make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib
+echo "Checking that software 64-bit division is not required"
+! grep __aeabi_uldiv library/*.o
+
+msg "build: ARM Compiler 5, make"
cleanup
cp "$CONFIG_H" "$CONFIG_BAK"
scripts/config.pl full
scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit
scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME
-CC=armcc AR=armar WARNING_CFLAGS= make lib
-if which i686-w64-mingw32-gcc >/dev/null; then
-msg "build: cross-mingw64, make" # ~ 30s
-cleanup
-CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 make
-WINDOWS_BUILD=1 make clean
-CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS=-Werror WINDOWS_BUILD=1 SHARED=1 make
-WINDOWS_BUILD=1 make clean
+if [ $RUN_ARMCC -ne 0 ]; then
+ make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib
+ make clean
+
+ # ARM Compiler 6 - Target ARMv7-A
+ armc6_build_test "--target=arm-arm-none-eabi -march=armv7-a"
+
+ # ARM Compiler 6 - Target ARMv7-M
+ armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m"
+
+ # ARM Compiler 6 - Target ARMv8-A - AArch32
+ armc6_build_test "--target=arm-arm-none-eabi -march=armv8.2-a"
+
+ # ARM Compiler 6 - Target ARMv8-M
+ armc6_build_test "--target=arm-arm-none-eabi -march=armv8-m.main"
+
+ # ARM Compiler 6 - Target ARMv8-A - AArch64
+ armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a"
fi
-# MemSan currently only available on Linux 64 bits
-if uname -a | grep 'Linux.*x86_64' >/dev/null; then
+msg "build: allow SHA1 in certificates by default"
+cleanup
+cp "$CONFIG_H" "$CONFIG_BAK"
+scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
+make CFLAGS='-Werror -Wall -Wextra'
+msg "test: allow SHA1 in certificates by default"
+make test
+if_build_succeeded tests/ssl-opt.sh -f SHA-1
-msg "build: MSan (clang)" # ~ 1 min 20s
+msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min
cleanup
cp "$CONFIG_H" "$CONFIG_BAK"
-scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
-CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
+scripts/config.pl set MBEDTLS_RSA_NO_CRT
+CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
make
-msg "test: main suites (MSan)" # ~ 10s
+msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)"
make test
-msg "test: ssl-opt.sh (MSan)" # ~ 1 min
-tests/ssl-opt.sh
+msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
+cleanup
+make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs
-# Optional part(s)
+# note Make tests only builds the tests, but doesn't run them
+make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests
+make WINDOWS_BUILD=1 clean
-if [ "$MEMORY" -gt 0 ]; then
- msg "test: compat.sh (MSan)" # ~ 6 min 20s
- tests/compat.sh
-fi
+msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s
+make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs
+make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 tests
+make WINDOWS_BUILD=1 clean
+
+# MemSan currently only available on Linux 64 bits
+if uname -a | grep 'Linux.*x86_64' >/dev/null; then
+
+ msg "build: MSan (clang)" # ~ 1 min 20s
+ cleanup
+ cp "$CONFIG_H" "$CONFIG_BAK"
+ scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm
+ CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan .
+ make
+
+ msg "test: main suites (MSan)" # ~ 10s
+ make test
+
+ msg "test: ssl-opt.sh (MSan)" # ~ 1 min
+ if_build_succeeded tests/ssl-opt.sh
+
+ # Optional part(s)
+
+ if [ "$MEMORY" -gt 0 ]; then
+ msg "test: compat.sh (MSan)" # ~ 6 min 20s
+ if_build_succeeded tests/compat.sh
+ fi
else # no MemSan
-msg "build: Release (clang)"
-cleanup
-CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
-make
+ msg "build: Release (clang)"
+ cleanup
+ CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release .
+ make
-msg "test: main suites valgrind (Release)"
-make memcheck
+ msg "test: main suites valgrind (Release)"
+ make memcheck
-# Optional part(s)
-# Currently broken, programs don't seem to receive signals
-# under valgrind on OS X
+ # Optional part(s)
+ # Currently broken, programs don't seem to receive signals
+ # under valgrind on OS X
-if [ "$MEMORY" -gt 0 ]; then
- msg "test: ssl-opt.sh --memcheck (Release)"
- tests/ssl-opt.sh --memcheck
-fi
+ if [ "$MEMORY" -gt 0 ]; then
+ msg "test: ssl-opt.sh --memcheck (Release)"
+ if_build_succeeded tests/ssl-opt.sh --memcheck
+ fi
-if [ "$MEMORY" -gt 1 ]; then
- msg "test: compat.sh --memcheck (Release)"
- tests/compat.sh --memcheck
-fi
+ if [ "$MEMORY" -gt 1 ]; then
+ msg "test: compat.sh --memcheck (Release)"
+ if_build_succeeded tests/compat.sh --memcheck
+ fi
fi # MemSan
cd "$MBEDTLS_ROOT_DIR"
rm -rf "$OUT_OF_SOURCE_DIR"
+
+
+################################################################
+#### Termination
+################################################################
+
msg "Done, cleaning up"
cleanup
+final_report
# everything with a backslach except '\0' and backslash at EOL
my $doxy_re = qr/\\(?!0|\n)/;
+# Return an error code to the environment if a potential error in the
+# source code is found.
+my $exit_code = 0;
+
sub check_file {
my ($fname) = @_;
open my $fh, '<', $fname or die "Failed to open '$fname': $!\n";
if ($block_start and $line =~ m/$doxy_re/) {
print "$fname:$block_start: directive on line $.\n";
$block_start = 0; # report only one directive per block
+ $exit_code = 1;
}
}
}
}
-# locate root directory based on invocation name
-my $root = dirname($0) . '/..';
-chdir $root or die "Can't chdir to '$root': $!\n";
-
-# just do it
+# Check that the script is being run from the project's root directory.
for my $dir (@directories) {
- check_dir($dir)
+ if (! -d $dir) {
+ die "This script must be run from the mbed TLS root directory";
+ } else {
+ check_dir($dir)
+ }
}
+exit $exit_code;
+
__END__
set -eu
if grep --version|head -n1|grep GNU >/dev/null; then :; else
- echo "This script requires GNU grep."
+ echo "This script requires GNU grep.">&2
exit 1
fi
system( "scripts/config.pl unset $curve" )
and abort "Failed to disable $curve\n";
- system( "make lib" ) and abort "Failed to build lib: $curve\n";
+ system( "CFLAGS='-Werror -Wall -Wextra' make lib" )
+ and abort "Failed to build lib: $curve\n";
system( "cd tests && make" ) and abort "Failed to build tests: $curve\n";
system( "make test" ) and abort "Failed test suite: $curve\n";
# file name is used to replace the symbol 'TESTCASE_FILENAME' in the main
# code file above.
#
+# A test data file consists of a sequence of paragraphs separated by
+# a single empty line. Line breaks may be in Unix (LF) or Windows (CRLF)
+# format. Lines starting with the character '#' are ignored
+# (the parser behaves as if they were not present).
+#
+# Each paragraph describes one test case and must consist of: (1) one
+# line which is the test case name; (2) an optional line starting with
+# the 11-character prefix "depends_on:"; (3) a line containing the test
+# function to execute and its parameters.
+#
+# A depends_on: line consists of a list of compile-time options
+# separated by the character ':', with no whitespace. The test case
+# is executed only if this compilation option is enabled in config.h.
+#
+# The last line of each paragraph contains a test function name and
+# a list of parameters separated by the character ':'. Running the
+# test case calls this function with the specified parameters. Each
+# parameter may either be an integer written in decimal or hexadecimal,
+# or a string surrounded by double quotes which may not contain the
+# ':' character.
+#
use strict;
$param_defs .= " char *param$i = params[$i];\n";
$param_checks .= " if( verify_string( ¶m$i ) != 0 ) return( DISPATCH_INVALID_TEST_DATA );\n";
push @dispatch_params, "param$i";
- $mapping_regex .= ":[^:\n]+";
+ $mapping_regex .= ":(?:\\\\.|[^:\n])+";
}
else
{
# and make check code
my $dep_check_code;
-my @res = $test_data =~ /^depends_on:([\w:]+)/msg;
+my @res = $test_data =~ /^depends_on:([!:\w]+)/msg;
my %case_deps;
foreach my $deps (@res)
{
}
while( my ($key, $value) = each(%case_deps) )
{
- $dep_check_code .= << "END";
+ if( substr($key, 0, 1) eq "!" )
+ {
+ my $key = substr($key, 1);
+ $dep_check_code .= << "END";
+ if( strcmp( str, "!$key" ) == 0 )
+ {
+#if !defined($key)
+ return( DEPENDENCY_SUPPORTED );
+#else
+ return( DEPENDENCY_NOT_SUPPORTED );
+#endif
+ }
+END
+ }
+ else
+ {
+ $dep_check_code .= << "END";
if( strcmp( str, "$key" ) == 0 )
{
#if defined($key)
#endif
}
END
+ }
}
# Make mapping code
$verbose = TRUE;
}
-my @suites = grep { ! /\.(?:c|gcno|gcda|dSYM)$/ } glob 'test_suite_*';
+# All test suites = executable files, excluding source files, debug
+# and profiling information, etc. We can't just grep {! /\./} because
+#some of our test cases' base names contain a dot.
+my @suites = grep { -x $_ || /\.exe$/ } glob 'test_suite_*';
die "$0: no test suite found\n" unless @suites;
# in case test suites are linked dynamically
--- /dev/null
+#!/usr/bin/env perl
+
+# A simple TCP client that sends some data and expects a response.
+# Usage: tcp_client.pl HOSTNAME PORT DATA1 RESPONSE1
+# DATA: hex-encoded data to send to the server
+# RESPONSE: regexp that must match the server's response
+
+use warnings;
+use strict;
+use IO::Socket::INET;
+
+# Pack hex digits into a binary string, ignoring whitespace.
+sub parse_hex {
+ my ($hex) = @_;
+ $hex =~ s/\s+//g;
+ return pack('H*', $hex);
+}
+
+## Open a TCP connection to the specified host and port.
+sub open_connection {
+ my ($host, $port) = @_;
+ my $socket = IO::Socket::INET->new(PeerAddr => $host,
+ PeerPort => $port,
+ Proto => 'tcp',
+ Timeout => 1);
+ die "Cannot connect to $host:$port: $!" unless $socket;
+ return $socket;
+}
+
+## Close the TCP connection.
+sub close_connection {
+ my ($connection) = @_;
+ $connection->shutdown(2);
+ # Ignore shutdown failures (at least for now)
+ return 1;
+}
+
+## Write the given data, expressed as hexadecimal
+sub write_data {
+ my ($connection, $hexdata) = @_;
+ my $data = parse_hex($hexdata);
+ my $total_sent = 0;
+ while ($total_sent < length($data)) {
+ my $sent = $connection->send($data, 0);
+ if (!defined $sent) {
+ die "Unable to send data: $!";
+ }
+ $total_sent += $sent;
+ }
+ return 1;
+}
+
+## Read a response and check it against an expected prefix
+sub read_response {
+ my ($connection, $expected_hex) = @_;
+ my $expected_data = parse_hex($expected_hex);
+ my $start_offset = 0;
+ while ($start_offset < length($expected_data)) {
+ my $actual_data;
+ my $ok = $connection->recv($actual_data, length($expected_data));
+ if (!defined $ok) {
+ die "Unable to receive data: $!";
+ }
+ if (($actual_data ^ substr($expected_data, $start_offset)) =~ /[^\000]/) {
+ printf STDERR ("Received \\x%02x instead of \\x%02x at offset %d\n",
+ ord(substr($actual_data, $-[0], 1)),
+ ord(substr($expected_data, $start_offset + $-[0], 1)),
+ $start_offset + $-[0]);
+ return 0;
+ }
+ $start_offset += length($actual_data);
+ }
+ return 1;
+}
+
+if (@ARGV != 4) {
+ print STDERR "Usage: $0 HOSTNAME PORT DATA1 RESPONSE1\n";
+ exit(3);
+}
+my ($host, $port, $data1, $response1) = @ARGV;
+my $connection = open_connection($host, $port);
+write_data($connection, $data1);
+if (!read_response($connection, $response1)) {
+ exit(1);
+}
+close_connection($connection);
#!/usr/bin/perl
-# test standard configurations:
-# - build
-# - run test suite
-# - run compat.sh
+# test-ref-configs.pl
+#
+# This file is part of mbed TLS (https://tls.mbed.org)
+#
+# Copyright (c) 2013-2016, ARM Limited, All Rights Reserved
+#
+# Purpose
+#
+# For each reference configuration file in the configs directory, build the
+# configuration, run the test suites and compat.sh
#
# Usage: tests/scripts/test-ref-configs.pl [config-name [...]]
'config-suite-b.h' => {
'compat' => "-m tls1_2 -f 'ECDHE-ECDSA.*AES.*GCM' -p mbedTLS",
},
- 'config-picocoin.h' => {
- },
'config-ccm-psk-tls1_2.h' => {
'compat' => '-m tls1_2 -f \'^TLS-PSK-WITH-AES-...-CCM-8\'',
},
system( "cp configs/$conf $config_h" )
and abort "Failed to activate $conf\n";
- system( "make CFLAGS='-Os -Werror'" ) and abort "Failed to build: $conf\n";
+ system( "CFLAGS='-Os -Werror -Wall -Wextra' make" ) and abort "Failed to build: $conf\n";
system( "make test" ) and abort "Failed test suite: $conf\n";
my $compat = $data->{'compat'};
: ${OPENSSL_CMD:=openssl} # OPENSSL would conflict with the build system
: ${GNUTLS_CLI:=gnutls-cli}
: ${GNUTLS_SERV:=gnutls-serv}
+: ${PERL:=perl}
O_SRV="$OPENSSL_CMD s_server -www -cert data_files/server5.crt -key data_files/server5.key"
O_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_CMD s_client"
G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key"
G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt"
+TCP_CLIENT="$PERL scripts/tcp_client.pl"
TESTS=0
FAILS=0
PRESERVE_LOGS=0
+# Pick a "unique" server port in the range 10000-19999, and a proxy
+# port which is this plus 10000. Each port number may be independently
+# overridden by a command line option.
+SRV_PORT=$(($$ % 10000 + 10000))
+PXY_PORT=$((SRV_PORT + 10000))
+
print_usage() {
echo "Usage: $0 [options]"
printf " -h|--help\tPrint this help.\n"
printf " -m|--memcheck\tCheck memory leaks and errors.\n"
- printf " -f|--filter\tOnly matching tests are executed (default: '$FILTER')\n"
- printf " -e|--exclude\tMatching tests are excluded (default: '$EXCLUDE')\n"
+ printf " -f|--filter\tOnly matching tests are executed (BRE; default: '$FILTER')\n"
+ printf " -e|--exclude\tMatching tests are excluded (BRE; default: '$EXCLUDE')\n"
printf " -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
printf " -s|--show-numbers\tShow test numbers in front of test names\n"
printf " -p|--preserve-logs\tPreserve logs of successful tests as well\n"
+ printf " --port\tTCP/UDP port (default: randomish 1xxxx)\n"
+ printf " --proxy-port\tTCP/UDP proxy port (default: randomish 2xxxx)\n"
printf " --seed\tInteger seed value to use for this test run\n"
}
-p|--preserve-logs)
PRESERVE_LOGS=1
;;
+ --port)
+ shift; SRV_PORT=$1
+ ;;
+ --proxy-port)
+ shift; PXY_PORT=$1
+ ;;
--seed)
shift; SEED="$1"
;;
fi
}
+# skip next test if the flag is enabled in config.h
+requires_config_disabled() {
+ if grep "^#define $1" $CONFIG_H > /dev/null; then
+ SKIP_NEXT="YES"
+ fi
+}
+
# skip next test if OpenSSL doesn't support FALLBACK_SCSV
requires_openssl_with_fallback_scsv() {
if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
fi
}
-# wait for server to start: two versions depending on lsof availability
-wait_server_start() {
- if which lsof >/dev/null 2>&1; then
- START_TIME=$( date +%s )
- DONE=0
-
- # make a tight loop, server usually takes less than 1 sec to start
+# Wait for process $2 to be listening on port $1
+if type lsof >/dev/null 2>/dev/null; then
+ wait_server_start() {
+ START_TIME=$(date +%s)
if [ "$DTLS" -eq 1 ]; then
- while [ $DONE -eq 0 ]; do
- if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
- then
- DONE=1
- elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
- echo "SERVERSTART TIMEOUT"
- echo "SERVERSTART TIMEOUT" >> $SRV_OUT
- DONE=1
- fi
- done
+ proto=UDP
else
- while [ $DONE -eq 0 ]; do
- if lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null
- then
- DONE=1
- elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
- echo "SERVERSTART TIMEOUT"
- echo "SERVERSTART TIMEOUT" >> $SRV_OUT
- DONE=1
- fi
- done
+ proto=TCP
fi
- else
+ # Make a tight loop, server normally takes less than 1s to start.
+ while ! lsof -a -n -b -i "$proto:$1" -p "$2" >/dev/null 2>/dev/null; do
+ if [ $(( $(date +%s) - $START_TIME )) -gt $DOG_DELAY ]; then
+ echo "SERVERSTART TIMEOUT"
+ echo "SERVERSTART TIMEOUT" >> $SRV_OUT
+ break
+ fi
+ # Linux and *BSD support decimal arguments to sleep. On other
+ # OSes this may be a tight loop.
+ sleep 0.1 2>/dev/null || true
+ done
+ }
+else
+ echo "Warning: lsof not available, wait_server_start = sleep $START_DELAY"
+ wait_server_start() {
sleep "$START_DELAY"
+ }
+fi
+
+# Given the client or server debug output, parse the unix timestamp that is
+# included in the first 4 bytes of the random bytes and check that it's within
+# acceptable bounds
+check_server_hello_time() {
+ # Extract the time from the debug (lvl 3) output of the client
+ SERVER_HELLO_TIME="$(sed -n 's/.*server hello, current time: //p' < "$1")"
+ # Get the Unix timestamp for now
+ CUR_TIME=$(date +'%s')
+ THRESHOLD_IN_SECS=300
+
+ # Check if the ServerHello time was printed
+ if [ -z "$SERVER_HELLO_TIME" ]; then
+ return 1
+ fi
+
+ # Check the time in ServerHello is within acceptable bounds
+ if [ $SERVER_HELLO_TIME -lt $(( $CUR_TIME - $THRESHOLD_IN_SECS )) ]; then
+ # The time in ServerHello is at least 5 minutes before now
+ return 1
+ elif [ $SERVER_HELLO_TIME -gt $(( $CUR_TIME + $THRESHOLD_IN_SECS )) ]; then
+ # The time in ServerHello is at least 5 minutes later than now
+ return 1
+ else
+ return 0
fi
}
# Options: -s pattern pattern that must be present in server output
# -c pattern pattern that must be present in client output
# -u pattern lines after pattern must be unique in client output
+# -f call shell function on client output
# -S pattern pattern that must be absent in server output
# -C pattern pattern that must be absent in client output
# -U pattern lines after pattern must be unique in server output
+# -F call shell function on server output
run_test() {
NAME="$1"
shift 1
echo "$SRV_CMD" > $SRV_OUT
provide_input | $SRV_CMD >> $SRV_OUT 2>&1 &
SRV_PID=$!
- wait_server_start
+ wait_server_start "$SRV_PORT" "$SRV_PID"
echo "$CLI_CMD" > $CLI_OUT
eval "$CLI_CMD" >> $CLI_OUT 2>&1 &
return
fi
;;
+ "-F")
+ if ! $2 "$SRV_OUT"; then
+ fail "function call to '$2' failed on Server output"
+ return
+ fi
+ ;;
+ "-f")
+ if ! $2 "$CLI_OUT"; then
+ fail "function call to '$2' failed on Client output"
+ return
+ fi
+ ;;
*)
echo "Unknown test: $1" >&2
# used by watchdog
MAIN_PID="$$"
-# be more patient with valgrind
+# We use somewhat arbitrary delays for tests:
+# - how long do we wait for the server to start (when lsof not available)?
+# - how long do we allow for the client to finish?
+# (not to check performance, just to avoid waiting indefinitely)
+# Things are slower with valgrind, so give extra time here.
+#
+# Note: without lsof, there is a trade-off between the running time of this
+# script and the risk of spurious errors because we didn't wait long enough.
+# The watchdog delay on the other hand doesn't affect normal running time of
+# the script, only the case where a client or server gets stuck.
if [ "$MEMCHECK" -gt 0 ]; then
- START_DELAY=3
- DOG_DELAY=30
+ START_DELAY=6
+ DOG_DELAY=60
else
- START_DELAY=1
- DOG_DELAY=10
+ START_DELAY=2
+ DOG_DELAY=20
fi
+
+# some particular tests need more time:
+# - for the client, we multiply the usual watchdog limit by a factor
+# - for the server, we sleep for a number of seconds after the client exits
+# see client_need_more_time() and server_needs_more_time()
CLI_DELAY_FACTOR=1
SRV_DELAY_SECONDS=0
-# Pick a "unique" server port in the range 10000-19999, and a proxy port
-PORT_BASE="0000$$"
-PORT_BASE="$( printf $PORT_BASE | tail -c 4 )"
-SRV_PORT="1$PORT_BASE"
-PXY_PORT="2$PORT_BASE"
-unset PORT_BASE
-
# fix commands to use this port, force IPv4 while at it
# +SRV_PORT will be replaced by either $SRV_PORT or $PXY_PORT later
P_SRV="$P_SRV server_addr=127.0.0.1 server_port=$SRV_PORT"
G_SRV="$G_SRV -p $SRV_PORT"
G_CLI="$G_CLI -p +SRV_PORT localhost"
+# Allow SHA-1, because many of our test certificates use it
+P_SRV="$P_SRV allow_sha1=1"
+P_CLI="$P_CLI allow_sha1=1"
+
# Also pick a unique name for intermediate files
SRV_OUT="srv_out.$$"
CLI_OUT="cli_out.$$"
-s "Protocol is DTLSv1.2" \
-s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384"
+# Test current time in ServerHello
+requires_config_enabled MBEDTLS_HAVE_TIME
+run_test "Default, ServerHello contains gmt_unix_time" \
+ "$P_SRV debug_level=3" \
+ "$P_CLI debug_level=3" \
+ 0 \
+ -s "Protocol is TLSv1.2" \
+ -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \
+ -s "client hello v3, signature_algorithm ext: 6" \
+ -s "ECDHE curve: secp521r1" \
+ -S "error" \
+ -C "error" \
+ -f "check_server_hello_time" \
+ -F "check_server_hello_time"
+
# Test for uniqueness of IVs in AEAD ciphersuites
run_test "Unique IV in GCM" \
"$P_SRV exchanges=20 debug_level=4" \
-S "SSL - None of the common ciphersuites is usable" \
-S "SSL - The server has no ciphersuites in common"
+# Tests for SHA-1 support
+
+requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
+run_test "SHA-1 forbidden by default in server certificate" \
+ "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
+ "$P_CLI debug_level=2 allow_sha1=0" \
+ 1 \
+ -c "The certificate is signed with an unacceptable hash"
+
+requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
+run_test "SHA-1 forbidden by default in server certificate" \
+ "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
+ "$P_CLI debug_level=2 allow_sha1=0" \
+ 0
+
+run_test "SHA-1 explicitly allowed in server certificate" \
+ "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt" \
+ "$P_CLI allow_sha1=1" \
+ 0
+
+run_test "SHA-256 allowed by default in server certificate" \
+ "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2-sha256.crt" \
+ "$P_CLI allow_sha1=0" \
+ 0
+
+requires_config_disabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
+run_test "SHA-1 forbidden by default in client certificate" \
+ "$P_SRV auth_mode=required allow_sha1=0" \
+ "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
+ 1 \
+ -s "The certificate is signed with an unacceptable hash"
+
+requires_config_enabled MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
+run_test "SHA-1 forbidden by default in client certificate" \
+ "$P_SRV auth_mode=required allow_sha1=0" \
+ "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
+ 0
+
+run_test "SHA-1 explicitly allowed in client certificate" \
+ "$P_SRV auth_mode=required allow_sha1=1" \
+ "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha1.crt" \
+ 0
+
+run_test "SHA-256 allowed by default in client certificate" \
+ "$P_SRV auth_mode=required allow_sha1=0" \
+ "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \
+ 0
+
# Tests for Truncated HMAC extension
run_test "Truncated HMAC: client default, server default" \
"$P_SRV debug_level=4" \
"$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
0 \
- -s "dumping 'computed mac' (20 bytes)" \
- -S "dumping 'computed mac' (10 bytes)"
+ -s "dumping 'expected mac' (20 bytes)" \
+ -S "dumping 'expected mac' (10 bytes)"
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
run_test "Truncated HMAC: client disabled, server default" \
"$P_SRV debug_level=4" \
- "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
- trunc_hmac=0" \
+ "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
0 \
- -s "dumping 'computed mac' (20 bytes)" \
- -S "dumping 'computed mac' (10 bytes)"
+ -s "dumping 'expected mac' (20 bytes)" \
+ -S "dumping 'expected mac' (10 bytes)"
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
run_test "Truncated HMAC: client enabled, server default" \
"$P_SRV debug_level=4" \
- "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
- trunc_hmac=1" \
+ "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
0 \
- -s "dumping 'computed mac' (20 bytes)" \
- -S "dumping 'computed mac' (10 bytes)"
+ -s "dumping 'expected mac' (20 bytes)" \
+ -S "dumping 'expected mac' (10 bytes)"
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
run_test "Truncated HMAC: client enabled, server disabled" \
"$P_SRV debug_level=4 trunc_hmac=0" \
- "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
- trunc_hmac=1" \
+ "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
0 \
- -s "dumping 'computed mac' (20 bytes)" \
- -S "dumping 'computed mac' (10 bytes)"
+ -s "dumping 'expected mac' (20 bytes)" \
+ -S "dumping 'expected mac' (10 bytes)"
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Truncated HMAC: client disabled, server enabled" \
+ "$P_SRV debug_level=4 trunc_hmac=1" \
+ "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
+ 0 \
+ -s "dumping 'expected mac' (20 bytes)" \
+ -S "dumping 'expected mac' (10 bytes)"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
run_test "Truncated HMAC: client enabled, server enabled" \
"$P_SRV debug_level=4 trunc_hmac=1" \
- "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA \
- trunc_hmac=1" \
+ "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
+ 0 \
+ -S "dumping 'expected mac' (20 bytes)" \
+ -s "dumping 'expected mac' (10 bytes)"
+
+run_test "Truncated HMAC, DTLS: client default, server default" \
+ "$P_SRV dtls=1 debug_level=4" \
+ "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \
0 \
- -S "dumping 'computed mac' (20 bytes)" \
- -s "dumping 'computed mac' (10 bytes)"
+ -s "dumping 'expected mac' (20 bytes)" \
+ -S "dumping 'expected mac' (10 bytes)"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Truncated HMAC, DTLS: client disabled, server default" \
+ "$P_SRV dtls=1 debug_level=4" \
+ "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
+ 0 \
+ -s "dumping 'expected mac' (20 bytes)" \
+ -S "dumping 'expected mac' (10 bytes)"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Truncated HMAC, DTLS: client enabled, server default" \
+ "$P_SRV dtls=1 debug_level=4" \
+ "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
+ 0 \
+ -s "dumping 'expected mac' (20 bytes)" \
+ -S "dumping 'expected mac' (10 bytes)"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Truncated HMAC, DTLS: client enabled, server disabled" \
+ "$P_SRV dtls=1 debug_level=4 trunc_hmac=0" \
+ "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
+ 0 \
+ -s "dumping 'expected mac' (20 bytes)" \
+ -S "dumping 'expected mac' (10 bytes)"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Truncated HMAC, DTLS: client disabled, server enabled" \
+ "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
+ "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=0" \
+ 0 \
+ -s "dumping 'expected mac' (20 bytes)" \
+ -S "dumping 'expected mac' (10 bytes)"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Truncated HMAC, DTLS: client enabled, server enabled" \
+ "$P_SRV dtls=1 debug_level=4 trunc_hmac=1" \
+ "$P_CLI dtls=1 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA trunc_hmac=1" \
+ 0 \
+ -S "dumping 'expected mac' (20 bytes)" \
+ -s "dumping 'expected mac' (10 bytes)"
# Tests for Encrypt-then-MAC extension
-s "received FALLBACK_SCSV" \
-S "inapropriate fallback"
+## ClientHello generated with
+## "openssl s_client -CAfile tests/data_files/test-ca.crt -tls1_1 -connect localhost:4433 -cipher ..."
+## then manually twiddling the ciphersuite list.
+## The ClientHello content is spelled out below as a hex string as
+## "prefix ciphersuite1 ciphersuite2 ciphersuite3 ciphersuite4 suffix".
+## The expected response is an inappropriate_fallback alert.
+requires_openssl_with_fallback_scsv
+run_test "Fallback SCSV: beginning of list" \
+ "$P_SRV debug_level=2" \
+ "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 5600 0031 0032 0033 0100000900230000000f000101' '15030200020256'" \
+ 0 \
+ -s "received FALLBACK_SCSV" \
+ -s "inapropriate fallback"
+
+requires_openssl_with_fallback_scsv
+run_test "Fallback SCSV: end of list" \
+ "$P_SRV debug_level=2" \
+ "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0031 0032 0033 5600 0100000900230000000f000101' '15030200020256'" \
+ 0 \
+ -s "received FALLBACK_SCSV" \
+ -s "inapropriate fallback"
+
+## Here the expected response is a valid ServerHello prefix, up to the random.
+requires_openssl_with_fallback_scsv
+run_test "Fallback SCSV: not in list" \
+ "$P_SRV debug_level=2" \
+ "$TCP_CLIENT localhost $SRV_PORT '160301003e0100003a03022aafb94308dc22ca1086c65acc00e414384d76b61ecab37df1633b1ae1034dbe000008 0056 0031 0032 0033 0100000900230000000f000101' '16030200300200002c0302'" \
+ 0 \
+ -S "received FALLBACK_SCSV" \
+ -S "inapropriate fallback"
+
# Tests for CBC 1/n-1 record splitting
run_test "CBC Record splitting: TLS 1.2, no splitting" \
# Tests for Max Fragment Length extension
-run_test "Max fragment length: not used, reference" \
+MAX_CONTENT_LEN_EXPECT='16384'
+MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN)
+
+if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then
+ printf "The ${CONFIG_H} file contains a value for the configuration of\n"
+ printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n"
+ printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n"
+ printf "\n"
+ printf "The tests assume this value and if it changes, the tests in this\n"
+ printf "script should also be adjusted.\n"
+ printf "\n"
+
+ exit 1
+fi
+
+requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
+run_test "Max fragment length: enabled, default" \
"$P_SRV debug_level=3" \
"$P_CLI debug_level=3" \
0 \
-S "server hello, max_fragment_length extension" \
-C "found max_fragment_length extension"
+requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
+run_test "Max fragment length: enabled, default, larger message" \
+ "$P_SRV debug_level=3" \
+ "$P_CLI debug_level=3 request_size=16385" \
+ 0 \
+ -c "Maximum fragment length is 16384" \
+ -s "Maximum fragment length is 16384" \
+ -C "client hello, adding max_fragment_length extension" \
+ -S "found max fragment length extension" \
+ -S "server hello, max_fragment_length extension" \
+ -C "found max_fragment_length extension" \
+ -c "16385 bytes written in 2 fragments" \
+ -s "16384 bytes read" \
+ -s "1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
+run_test "Max fragment length, DTLS: enabled, default, larger message" \
+ "$P_SRV debug_level=3 dtls=1" \
+ "$P_CLI debug_level=3 dtls=1 request_size=16385" \
+ 1 \
+ -c "Maximum fragment length is 16384" \
+ -s "Maximum fragment length is 16384" \
+ -C "client hello, adding max_fragment_length extension" \
+ -S "found max fragment length extension" \
+ -S "server hello, max_fragment_length extension" \
+ -C "found max_fragment_length extension" \
+ -c "fragment larger than.*maximum "
+
+requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
+run_test "Max fragment length: disabled, larger message" \
+ "$P_SRV debug_level=3" \
+ "$P_CLI debug_level=3 request_size=16385" \
+ 0 \
+ -C "Maximum fragment length is 16384" \
+ -S "Maximum fragment length is 16384" \
+ -c "16385 bytes written in 2 fragments" \
+ -s "16384 bytes read" \
+ -s "1 bytes read"
+
+requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
+run_test "Max fragment length DTLS: disabled, larger message" \
+ "$P_SRV debug_level=3 dtls=1" \
+ "$P_CLI debug_level=3 dtls=1 request_size=16385" \
+ 1 \
+ -C "Maximum fragment length is 16384" \
+ -S "Maximum fragment length is 16384" \
+ -c "fragment larger than.*maximum "
+
+requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
run_test "Max fragment length: used by client" \
"$P_SRV debug_level=3" \
"$P_CLI debug_level=3 max_frag_len=4096" \
-s "server hello, max_fragment_length extension" \
-c "found max_fragment_length extension"
+requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
run_test "Max fragment length: used by server" \
"$P_SRV debug_level=3 max_frag_len=4096" \
"$P_CLI debug_level=3" \
-S "server hello, max_fragment_length extension" \
-C "found max_fragment_length extension"
+requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
requires_gnutls
run_test "Max fragment length: gnutls server" \
"$G_SRV" \
-c "client hello, adding max_fragment_length extension" \
-c "found max_fragment_length extension"
+requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
run_test "Max fragment length: client, message just fits" \
"$P_SRV debug_level=3" \
"$P_CLI debug_level=3 max_frag_len=2048 request_size=2048" \
-c "2048 bytes written in 1 fragments" \
-s "2048 bytes read"
+requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
run_test "Max fragment length: client, larger message" \
"$P_SRV debug_level=3" \
"$P_CLI debug_level=3 max_frag_len=2048 request_size=2345" \
-s "2048 bytes read" \
-s "297 bytes read"
+requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
run_test "Max fragment length: DTLS client, larger message" \
"$P_SRV debug_level=3 dtls=1" \
"$P_CLI debug_level=3 dtls=1 max_frag_len=2048 request_size=2345" \
# Tests for renegotiation
+# Renegotiation SCSV always added, regardless of SSL_RENEGOTIATION
run_test "Renegotiation: none, for reference" \
"$P_SRV debug_level=3 exchanges=2 auth_mode=optional" \
"$P_CLI debug_level=3 exchanges=2" \
-S "=> renegotiate" \
-S "write hello request"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: client-initiated" \
"$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
"$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
-s "=> renegotiate" \
-S "write hello request"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: server-initiated" \
"$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
"$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
-s "=> renegotiate" \
-s "write hello request"
+# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
+# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
+# algorithm stronger than SHA-1 is enabled in config.h
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
+run_test "Renegotiation: Signature Algorithms parsing, client-initiated" \
+ "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional" \
+ "$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
+ 0 \
+ -c "client hello, adding renegotiation extension" \
+ -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
+ -s "found renegotiation extension" \
+ -s "server hello, secure renegotiation extension" \
+ -c "found renegotiation extension" \
+ -c "=> renegotiate" \
+ -s "=> renegotiate" \
+ -S "write hello request" \
+ -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
+
+# Checks that no Signature Algorithm with SHA-1 gets negotiated. Negotiating SHA-1 would mean that
+# the server did not parse the Signature Algorithm extension. This test is valid only if an MD
+# algorithm stronger than SHA-1 is enabled in config.h
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
+run_test "Renegotiation: Signature Algorithms parsing, server-initiated" \
+ "$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
+ "$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
+ 0 \
+ -c "client hello, adding renegotiation extension" \
+ -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
+ -s "found renegotiation extension" \
+ -s "server hello, secure renegotiation extension" \
+ -c "found renegotiation extension" \
+ -c "=> renegotiate" \
+ -s "=> renegotiate" \
+ -s "write hello request" \
+ -S "client hello v3, signature_algorithm ext: 2" # Is SHA-1 negotiated?
+
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: double" \
"$P_SRV debug_level=3 exchanges=2 renegotiation=1 auth_mode=optional renegotiate=1" \
"$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
-s "=> renegotiate" \
-s "write hello request"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: client-initiated, server-rejected" \
"$P_SRV debug_level=3 exchanges=2 renegotiation=0 auth_mode=optional" \
"$P_CLI debug_level=3 exchanges=2 renegotiation=1 renegotiate=1" \
-c "SSL - Unexpected message at ServerHello in renegotiation" \
-c "failed"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: server-initiated, client-rejected, default" \
"$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
"$P_CLI debug_level=3 exchanges=2 renegotiation=0" \
-S "SSL - An unexpected message was received from our peer" \
-S "failed"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: server-initiated, client-rejected, not enforced" \
"$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
renego_delay=-1 auth_mode=optional" \
-S "failed"
# delay 2 for 1 alert record + 1 application data record
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: server-initiated, client-rejected, delay 2" \
"$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
renego_delay=2 auth_mode=optional" \
-S "SSL - An unexpected message was received from our peer" \
-S "failed"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: server-initiated, client-rejected, delay 0" \
"$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
renego_delay=0 auth_mode=optional" \
-s "write hello request" \
-s "SSL - An unexpected message was received from our peer"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: server-initiated, client-accepted, delay 0" \
"$P_SRV debug_level=3 exchanges=2 renegotiation=1 renegotiate=1 \
renego_delay=0 auth_mode=optional" \
-S "SSL - An unexpected message was received from our peer" \
-S "failed"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: periodic, just below period" \
"$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
"$P_CLI debug_level=3 exchanges=2 renegotiation=1" \
-S "failed"
# one extra exchange to be able to complete renego
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: periodic, just above period" \
"$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
"$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
-S "SSL - An unexpected message was received from our peer" \
-S "failed"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: periodic, two times period" \
"$P_SRV debug_level=3 exchanges=9 renegotiation=1 renego_period=3 auth_mode=optional" \
"$P_CLI debug_level=3 exchanges=7 renegotiation=1" \
-S "SSL - An unexpected message was received from our peer" \
-S "failed"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: periodic, above period, disabled" \
"$P_SRV debug_level=3 exchanges=9 renegotiation=0 renego_period=3 auth_mode=optional" \
"$P_CLI debug_level=3 exchanges=4 renegotiation=1" \
-S "SSL - An unexpected message was received from our peer" \
-S "failed"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: nbio, client-initiated" \
"$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 auth_mode=optional" \
"$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1" \
-s "=> renegotiate" \
-S "write hello request"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: nbio, server-initiated" \
"$P_SRV debug_level=3 nbio=2 exchanges=2 renegotiation=1 renegotiate=1 auth_mode=optional" \
"$P_CLI debug_level=3 nbio=2 exchanges=2 renegotiation=1" \
-s "=> renegotiate" \
-s "write hello request"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: openssl server, client-initiated" \
"$O_SRV -www" \
"$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
-c "HTTP/1.0 200 [Oo][Kk]"
requires_gnutls
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: gnutls server strict, client-initiated" \
"$G_SRV --priority=NORMAL:%SAFE_RENEGOTIATION" \
"$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
-c "HTTP/1.0 200 [Oo][Kk]"
requires_gnutls
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: gnutls server unsafe, client-initiated default" \
"$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
"$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1" \
-C "HTTP/1.0 200 [Oo][Kk]"
requires_gnutls
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: gnutls server unsafe, client-inititated no legacy" \
"$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
"$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
-C "HTTP/1.0 200 [Oo][Kk]"
requires_gnutls
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: gnutls server unsafe, client-inititated legacy" \
"$G_SRV --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \
"$P_CLI debug_level=3 exchanges=1 renegotiation=1 renegotiate=1 \
-C "error" \
-c "HTTP/1.0 200 [Oo][Kk]"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: DTLS, client-initiated" \
"$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1" \
"$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
-s "=> renegotiate" \
-S "write hello request"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: DTLS, server-initiated" \
"$P_SRV debug_level=3 dtls=1 exchanges=2 renegotiation=1 renegotiate=1" \
"$P_CLI debug_level=3 dtls=1 exchanges=2 renegotiation=1 \
-s "=> renegotiate" \
-s "write hello request"
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
+run_test "Renegotiation: DTLS, renego_period overflow" \
+ "$P_SRV debug_level=3 dtls=1 exchanges=4 renegotiation=1 renego_period=18446462598732840962 auth_mode=optional" \
+ "$P_CLI debug_level=3 dtls=1 exchanges=4 renegotiation=1" \
+ 0 \
+ -c "client hello, adding renegotiation extension" \
+ -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
+ -s "found renegotiation extension" \
+ -s "server hello, secure renegotiation extension" \
+ -s "record counter limit reached: renegotiate" \
+ -c "=> renegotiate" \
+ -s "=> renegotiate" \
+ -s "write hello request"
+
requires_gnutls
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "Renegotiation: DTLS, gnutls server, client-initiated" \
"$G_SRV -u --mtu 4096" \
"$P_CLI debug_level=3 dtls=1 exchanges=1 renegotiation=1 renegotiate=1" \
-C "! mbedtls_ssl_handshake returned" \
-C "X509 - Certificate verification failed"
+run_test "Authentication: server goodcert, client optional, no trusted CA" \
+ "$P_SRV" \
+ "$P_CLI debug_level=3 auth_mode=optional ca_file=none ca_path=none" \
+ 0 \
+ -c "x509_verify_cert() returned" \
+ -c "! The certificate is not correctly signed by the trusted CA" \
+ -c "! Certificate verification flags"\
+ -C "! mbedtls_ssl_handshake returned" \
+ -C "X509 - Certificate verification failed" \
+ -C "SSL - No CA Chain is set, but required to operate"
+
+run_test "Authentication: server goodcert, client required, no trusted CA" \
+ "$P_SRV" \
+ "$P_CLI debug_level=3 auth_mode=required ca_file=none ca_path=none" \
+ 1 \
+ -c "x509_verify_cert() returned" \
+ -c "! The certificate is not correctly signed by the trusted CA" \
+ -c "! Certificate verification flags"\
+ -c "! mbedtls_ssl_handshake returned" \
+ -c "SSL - No CA Chain is set, but required to operate"
+
+# The purpose of the next two tests is to test the client's behaviour when receiving a server
+# certificate with an unsupported elliptic curve. This should usually not happen because
+# the client informs the server about the supported curves - it does, though, in the
+# corner case of a static ECDH suite, because the server doesn't check the curve on that
+# occasion (to be fixed). If that bug's fixed, the test needs to be altered to use a
+# different means to have the server ignoring the client's supported curve list.
+
+requires_config_enabled MBEDTLS_ECP_C
+run_test "Authentication: server ECDH p256v1, client required, p256v1 unsupported" \
+ "$P_SRV debug_level=1 key_file=data_files/server5.key \
+ crt_file=data_files/server5.ku-ka.crt" \
+ "$P_CLI debug_level=3 auth_mode=required curves=secp521r1" \
+ 1 \
+ -c "bad certificate (EC key curve)"\
+ -c "! Certificate verification flags"\
+ -C "bad server certificate (ECDH curve)" # Expect failure at earlier verification stage
+
+requires_config_enabled MBEDTLS_ECP_C
+run_test "Authentication: server ECDH p256v1, client optional, p256v1 unsupported" \
+ "$P_SRV debug_level=1 key_file=data_files/server5.key \
+ crt_file=data_files/server5.ku-ka.crt" \
+ "$P_CLI debug_level=3 auth_mode=optional curves=secp521r1" \
+ 1 \
+ -c "bad certificate (EC key curve)"\
+ -c "! Certificate verification flags"\
+ -c "bad server certificate (ECDH curve)" # Expect failure only at ECDH params check
+
run_test "Authentication: server badcert, client none" \
"$P_SRV crt_file=data_files/server5-badsign.crt \
key_file=data_files/server5.key" \
-c "Supported Signature Algorithm found: 4," \
-c "Supported Signature Algorithm found: 5,"
+requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
+run_test "Authentication: client has no cert, server required (SSLv3)" \
+ "$P_SRV debug_level=3 min_version=ssl3 auth_mode=required" \
+ "$P_CLI debug_level=3 force_version=ssl3 crt_file=none \
+ key_file=data_files/server5.key" \
+ 1 \
+ -S "skip write certificate request" \
+ -C "skip parse certificate request" \
+ -c "got a certificate request" \
+ -c "got no certificate to send" \
+ -S "x509_verify_cert() returned" \
+ -s "client has no certificate" \
+ -s "! mbedtls_ssl_handshake returned" \
+ -c "! mbedtls_ssl_handshake returned" \
+ -s "No client certification received from the client, but required by the authentication mode"
+
+run_test "Authentication: client has no cert, server required (TLS)" \
+ "$P_SRV debug_level=3 auth_mode=required" \
+ "$P_CLI debug_level=3 crt_file=none \
+ key_file=data_files/server5.key" \
+ 1 \
+ -S "skip write certificate request" \
+ -C "skip parse certificate request" \
+ -c "got a certificate request" \
+ -c "= write certificate$" \
+ -C "skip write certificate$" \
+ -S "x509_verify_cert() returned" \
+ -s "client has no certificate" \
+ -s "! mbedtls_ssl_handshake returned" \
+ -c "! mbedtls_ssl_handshake returned" \
+ -s "No client certification received from the client, but required by the authentication mode"
+
run_test "Authentication: client badcert, server required" \
"$P_SRV debug_level=3 auth_mode=required" \
"$P_CLI debug_level=3 crt_file=data_files/server5-badsign.crt \
-s "x509_verify_cert() returned" \
-s "! The certificate is not correctly signed by the trusted CA" \
-s "! mbedtls_ssl_handshake returned" \
+ -s "send alert level=2 message=48" \
+ -c "! mbedtls_ssl_handshake returned" \
+ -s "X509 - Certificate verification failed"
+# We don't check that the client receives the alert because it might
+# detect that its write end of the connection is closed and abort
+# before reading the alert message.
+
+run_test "Authentication: client cert not trusted, server required" \
+ "$P_SRV debug_level=3 auth_mode=required" \
+ "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
+ key_file=data_files/server5.key" \
+ 1 \
+ -S "skip write certificate request" \
+ -C "skip parse certificate request" \
+ -c "got a certificate request" \
+ -C "skip write certificate" \
+ -C "skip write certificate verify" \
+ -S "skip parse certificate verify" \
+ -s "x509_verify_cert() returned" \
+ -s "! The certificate is not correctly signed by the trusted CA" \
+ -s "! mbedtls_ssl_handshake returned" \
-c "! mbedtls_ssl_handshake returned" \
-s "X509 - Certificate verification failed"
-c "skip write certificate verify" \
-C "! mbedtls_ssl_handshake returned"
+run_test "Authentication: client no cert, openssl server required" \
+ "$O_SRV -Verify 10" \
+ "$P_CLI debug_level=3 crt_file=none key_file=none" \
+ 1 \
+ -C "skip parse certificate request" \
+ -c "got a certificate request" \
+ -C "skip write certificate$" \
+ -c "skip write certificate verify" \
+ -c "! mbedtls_ssl_handshake returned"
+
requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
run_test "Authentication: client no cert, ssl3" \
"$P_SRV debug_level=3 auth_mode=optional force_version=ssl3" \
-C "! mbedtls_ssl_handshake returned" \
-S "X509 - Certificate verification failed"
+# The "max_int chain" tests assume that MAX_INTERMEDIATE_CA is set to its
+# default value (8)
+
+MAX_IM_CA='8'
+MAX_IM_CA_CONFIG=$( ../scripts/config.pl get MBEDTLS_X509_MAX_INTERMEDIATE_CA)
+
+if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then
+ printf "The ${CONFIG_H} file contains a value for the configuration of\n"
+ printf "MBEDTLS_X509_MAX_INTERMEDIATE_CA that is different from the script’s\n"
+ printf "test value of ${MAX_IM_CA}. \n"
+ printf "\n"
+ printf "The tests assume this value and if it changes, the tests in this\n"
+ printf "script should also be adjusted.\n"
+ printf "\n"
+
+ exit 1
+fi
+
+run_test "Authentication: server max_int chain, client default" \
+ "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \
+ key_file=data_files/dir-maxpath/09.key" \
+ "$P_CLI server_name=CA09 ca_file=data_files/dir-maxpath/00.crt" \
+ 0 \
+ -C "X509 - A fatal error occured"
+
+run_test "Authentication: server max_int+1 chain, client default" \
+ "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
+ key_file=data_files/dir-maxpath/10.key" \
+ "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt" \
+ 1 \
+ -c "X509 - A fatal error occured"
+
+run_test "Authentication: server max_int+1 chain, client optional" \
+ "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
+ key_file=data_files/dir-maxpath/10.key" \
+ "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
+ auth_mode=optional" \
+ 1 \
+ -c "X509 - A fatal error occured"
+
+run_test "Authentication: server max_int+1 chain, client none" \
+ "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \
+ key_file=data_files/dir-maxpath/10.key" \
+ "$P_CLI server_name=CA10 ca_file=data_files/dir-maxpath/00.crt \
+ auth_mode=none" \
+ 0 \
+ -C "X509 - A fatal error occured"
+
+run_test "Authentication: client max_int+1 chain, server default" \
+ "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \
+ "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
+ key_file=data_files/dir-maxpath/10.key" \
+ 0 \
+ -S "X509 - A fatal error occured"
+
+run_test "Authentication: client max_int+1 chain, server optional" \
+ "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \
+ "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
+ key_file=data_files/dir-maxpath/10.key" \
+ 1 \
+ -s "X509 - A fatal error occured"
+
+run_test "Authentication: client max_int+1 chain, server required" \
+ "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
+ "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \
+ key_file=data_files/dir-maxpath/10.key" \
+ 1 \
+ -s "X509 - A fatal error occured"
+
+run_test "Authentication: client max_int chain, server required" \
+ "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \
+ "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \
+ key_file=data_files/dir-maxpath/09.key" \
+ 0 \
+ -S "X509 - A fatal error occured"
+
+# Tests for CA list in CertificateRequest messages
+
+run_test "Authentication: send CA list in CertificateRequest (default)" \
+ "$P_SRV debug_level=3 auth_mode=required" \
+ "$P_CLI crt_file=data_files/server6.crt \
+ key_file=data_files/server6.key" \
+ 0 \
+ -s "requested DN"
+
+run_test "Authentication: do not send CA list in CertificateRequest" \
+ "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
+ "$P_CLI crt_file=data_files/server6.crt \
+ key_file=data_files/server6.key" \
+ 0 \
+ -S "requested DN"
+
+run_test "Authentication: send CA list in CertificateRequest, client self signed" \
+ "$P_SRV debug_level=3 auth_mode=required cert_req_ca_list=0" \
+ "$P_CLI debug_level=3 crt_file=data_files/server5-selfsigned.crt \
+ key_file=data_files/server5.key" \
+ 1 \
+ -S "requested DN" \
+ -s "x509_verify_cert() returned" \
+ -s "! The certificate is not correctly signed by the trusted CA" \
+ -s "! mbedtls_ssl_handshake returned" \
+ -c "! mbedtls_ssl_handshake returned" \
+ -s "X509 - Certificate verification failed"
+
# Tests for certificate selection based on SHA verson
run_test "Certificate hash: client TLS 1.2 -> SHA-2" \
debug_level=3" \
0 \
-c "value of 'DHM: P ' (2048 bits)" \
- -c "value of 'DHM: G ' (2048 bits)"
+ -c "value of 'DHM: G ' (2 bits)"
run_test "DHM parameters: other parameters" \
"$P_SRV dhm_file=data_files/dhparams.pem" \
# Test for ClientHello without extensions
requires_gnutls
-run_test "ClientHello without extensions" \
+run_test "ClientHello without extensions, SHA-1 allowed" \
"$P_SRV debug_level=3" \
"$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
0 \
-s "dumping 'client hello extensions' (0 bytes)"
+requires_gnutls
+run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \
+ "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \
+ "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \
+ 0 \
+ -s "dumping 'client hello extensions' (0 bytes)"
+
# Tests for mbedtls_ssl_get_bytes_avail()
run_test "mbedtls_ssl_get_bytes_avail: no extra data" \
0 \
-s "Read from client: 1 bytes read"
-run_test "Small packet TLS 1.0 BlockCipher without EtM" \
+run_test "Small packet TLS 1.0 BlockCipher, without EtM" \
"$P_SRV" \
"$P_CLI request_size=1 force_version=tls1 etm=0 \
force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
0 \
-s "Read from client: 1 bytes read"
-run_test "Small packet TLS 1.0 BlockCipher truncated MAC" \
- "$P_SRV" \
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.0 BlockCipher, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
+ "$P_CLI request_size=1 force_version=tls1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
"$P_CLI request_size=1 force_version=tls1 \
- force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
0 \
-s "Read from client: 1 bytes read"
-run_test "Small packet TLS 1.0 StreamCipher truncated MAC" \
+run_test "Small packet TLS 1.0 StreamCipher" \
"$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
"$P_CLI request_size=1 force_version=tls1 \
- force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+run_test "Small packet TLS 1.0 StreamCipher, without EtM" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
+ "$P_CLI request_size=1 force_version=tls1 \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.0 StreamCipher, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ "$P_CLI request_size=1 force_version=tls1 \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ "$P_CLI request_size=1 force_version=tls1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
+ trunc_hmac=1 etm=0" \
0 \
-s "Read from client: 1 bytes read"
0 \
-s "Read from client: 1 bytes read"
-run_test "Small packet TLS 1.1 BlockCipher without EtM" \
+run_test "Small packet TLS 1.1 BlockCipher, without EtM" \
"$P_SRV" \
- "$P_CLI request_size=1 force_version=tls1_1 etm=0 \
- force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ "$P_CLI request_size=1 force_version=tls1_1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.1 BlockCipher, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
+ "$P_CLI request_size=1 force_version=tls1_1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
+ "$P_CLI request_size=1 force_version=tls1_1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
0 \
-s "Read from client: 1 bytes read"
0 \
-s "Read from client: 1 bytes read"
-run_test "Small packet TLS 1.1 BlockCipher truncated MAC" \
- "$P_SRV" \
+run_test "Small packet TLS 1.1 StreamCipher, without EtM" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
"$P_CLI request_size=1 force_version=tls1_1 \
- force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
0 \
-s "Read from client: 1 bytes read"
-run_test "Small packet TLS 1.1 StreamCipher truncated MAC" \
- "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.1 StreamCipher, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ "$P_CLI request_size=1 force_version=tls1_1 \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
"$P_CLI request_size=1 force_version=tls1_1 \
- force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
0 \
-s "Read from client: 1 bytes read"
0 \
-s "Read from client: 1 bytes read"
-run_test "Small packet TLS 1.2 BlockCipher without EtM" \
+run_test "Small packet TLS 1.2 BlockCipher, without EtM" \
"$P_SRV" \
- "$P_CLI request_size=1 force_version=tls1_2 etm=0 \
- force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ "$P_CLI request_size=1 force_version=tls1_2 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA etm=0" \
0 \
-s "Read from client: 1 bytes read"
0 \
-s "Read from client: 1 bytes read"
-run_test "Small packet TLS 1.2 BlockCipher truncated MAC" \
- "$P_SRV" \
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.2 BlockCipher, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
"$P_CLI request_size=1 force_version=tls1_2 \
- force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
+ "$P_CLI request_size=1 force_version=tls1_2 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
0 \
-s "Read from client: 1 bytes read"
0 \
-s "Read from client: 1 bytes read"
-run_test "Small packet TLS 1.2 StreamCipher truncated MAC" \
+run_test "Small packet TLS 1.2 StreamCipher, without EtM" \
"$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
"$P_CLI request_size=1 force_version=tls1_2 \
- force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.2 StreamCipher, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ "$P_CLI request_size=1 force_version=tls1_2 \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ "$P_CLI request_size=1 force_version=tls1_2 \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
0 \
-s "Read from client: 1 bytes read"
0 \
-s "Read from client: 1 bytes read"
+# Tests for small packets in DTLS
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+run_test "Small packet DTLS 1.0" \
+ "$P_SRV dtls=1 force_version=dtls1" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+run_test "Small packet DTLS 1.0, without EtM" \
+ "$P_SRV dtls=1 force_version=dtls1 etm=0" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet DTLS 1.0, truncated hmac" \
+ "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1" \
+ "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
+ "$P_SRV dtls=1 force_version=dtls1 trunc_hmac=1 etm=0" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+run_test "Small packet DTLS 1.2" \
+ "$P_SRV dtls=1 force_version=dtls1_2" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+run_test "Small packet DTLS 1.2, without EtM" \
+ "$P_SRV dtls=1 force_version=dtls1_2 etm=0" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet DTLS 1.2, truncated hmac" \
+ "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
+ "$P_SRV dtls=1 force_version=dtls1_2 trunc_hmac=1 etm=0" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1"\
+ 0 \
+ -s "Read from client: 1 bytes read"
+
# A test for extensions in SSLv3
requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
"$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \
force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
0 \
+ -c "16384 bytes written in 1 fragments" \
-s "Read from client: 16384 bytes read"
requires_config_enabled MBEDTLS_SSL_PROTO_SSL3
"$P_CLI request_size=16384 force_version=ssl3 \
force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
0 \
+ -c "16384 bytes written in 1 fragments" \
-s "Read from client: 16384 bytes read"
run_test "Large packet TLS 1.0 BlockCipher" \
"$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
0 \
+ -c "16384 bytes written in 1 fragments" \
-s "Read from client: 16384 bytes read"
-run_test "Large packet TLS 1.0 BlockCipher truncated MAC" \
+run_test "Large packet TLS 1.0 BlockCipher, without EtM" \
"$P_SRV" \
+ "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 16384 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.0 BlockCipher, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
"$P_CLI request_size=16384 force_version=tls1 recsplit=0 \
- force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
+ 0 \
+ -c "16384 bytes written in 1 fragments" \
+ -s "Read from client: 16384 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
+ "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 16384 bytes read"
+
+run_test "Large packet TLS 1.0 StreamCipher" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
+ "$P_CLI request_size=16384 force_version=tls1 \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
0 \
-s "Read from client: 16384 bytes read"
-run_test "Large packet TLS 1.0 StreamCipher truncated MAC" \
+run_test "Large packet TLS 1.0 StreamCipher, without EtM" \
"$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
"$P_CLI request_size=16384 force_version=tls1 \
- force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
+ 0 \
+ -s "Read from client: 16384 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.0 StreamCipher, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ "$P_CLI request_size=16384 force_version=tls1 \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
0 \
-s "Read from client: 16384 bytes read"
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ "$P_CLI request_size=16384 force_version=tls1 \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
+ 0 \
+ -c "16384 bytes written in 1 fragments" \
+ -s "Read from client: 16384 bytes read"
+
run_test "Large packet TLS 1.1 BlockCipher" \
"$P_SRV" \
"$P_CLI request_size=16384 force_version=tls1_1 \
force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
0 \
+ -c "16384 bytes written in 1 fragments" \
+ -s "Read from client: 16384 bytes read"
+
+run_test "Large packet TLS 1.1 BlockCipher, without EtM" \
+ "$P_SRV" \
+ "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 16384 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.1 BlockCipher, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
+ "$P_CLI request_size=16384 force_version=tls1_1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 16384 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
+ "$P_CLI request_size=16384 force_version=tls1_1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
+ 0 \
-s "Read from client: 16384 bytes read"
run_test "Large packet TLS 1.1 StreamCipher" \
"$P_CLI request_size=16384 force_version=tls1_1 \
force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
0 \
+ -c "16384 bytes written in 1 fragments" \
-s "Read from client: 16384 bytes read"
-run_test "Large packet TLS 1.1 BlockCipher truncated MAC" \
- "$P_SRV" \
+run_test "Large packet TLS 1.1 StreamCipher, without EtM" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
"$P_CLI request_size=16384 force_version=tls1_1 \
- force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
0 \
+ -c "16384 bytes written in 1 fragments" \
-s "Read from client: 16384 bytes read"
-run_test "Large packet TLS 1.1 StreamCipher truncated MAC" \
- "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.1 StreamCipher, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ "$P_CLI request_size=16384 force_version=tls1_1 \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 16384 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
"$P_CLI request_size=16384 force_version=tls1_1 \
- force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
0 \
+ -c "16384 bytes written in 1 fragments" \
-s "Read from client: 16384 bytes read"
run_test "Large packet TLS 1.2 BlockCipher" \
"$P_CLI request_size=16384 force_version=tls1_2 \
force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
0 \
+ -c "16384 bytes written in 1 fragments" \
+ -s "Read from client: 16384 bytes read"
+
+run_test "Large packet TLS 1.2 BlockCipher, without EtM" \
+ "$P_SRV" \
+ "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
-s "Read from client: 16384 bytes read"
run_test "Large packet TLS 1.2 BlockCipher larger MAC" \
"$P_CLI request_size=16384 force_version=tls1_2 \
force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \
0 \
+ -c "16384 bytes written in 1 fragments" \
-s "Read from client: 16384 bytes read"
-run_test "Large packet TLS 1.2 BlockCipher truncated MAC" \
- "$P_SRV" \
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.2 BlockCipher, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
"$P_CLI request_size=16384 force_version=tls1_2 \
- force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \
0 \
-s "Read from client: 16384 bytes read"
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \
+ "$P_SRV trunc_hmac=1" \
+ "$P_CLI request_size=16384 force_version=tls1_2 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \
+ 0 \
+ -c "16384 bytes written in 1 fragments" \
+ -s "Read from client: 16384 bytes read"
+
run_test "Large packet TLS 1.2 StreamCipher" \
"$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
"$P_CLI request_size=16384 force_version=tls1_2 \
force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
0 \
+ -c "16384 bytes written in 1 fragments" \
-s "Read from client: 16384 bytes read"
-run_test "Large packet TLS 1.2 StreamCipher truncated MAC" \
+run_test "Large packet TLS 1.2 StreamCipher, without EtM" \
"$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \
"$P_CLI request_size=16384 force_version=tls1_2 \
- force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA \
- trunc_hmac=1" \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \
+ 0 \
+ -s "Read from client: 16384 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.2 StreamCipher, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ "$P_CLI request_size=16384 force_version=tls1_2 \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 16384 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Large packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \
+ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \
+ "$P_CLI request_size=16384 force_version=tls1_2 \
+ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \
0 \
+ -c "16384 bytes written in 1 fragments" \
-s "Read from client: 16384 bytes read"
run_test "Large packet TLS 1.2 AEAD" \
"$P_CLI request_size=16384 force_version=tls1_2 \
force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \
0 \
+ -c "16384 bytes written in 1 fragments" \
-s "Read from client: 16384 bytes read"
run_test "Large packet TLS 1.2 AEAD shorter tag" \
"$P_CLI request_size=16384 force_version=tls1_2 \
force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \
0 \
+ -c "16384 bytes written in 1 fragments" \
-s "Read from client: 16384 bytes read"
# Tests for DTLS HelloVerifyRequest
-C "error"
requires_gnutls
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "DTLS reassembly: fragmentation, renego (gnutls server)" \
"$G_SRV -u --mtu 256" \
"$P_CLI debug_level=3 dtls=1 renegotiation=1 renegotiate=1" \
-s "Extra-header:"
requires_gnutls
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "DTLS reassembly: fragmentation, nbio, renego (gnutls server)" \
"$G_SRV -u --mtu 256" \
"$P_CLI debug_level=3 nbio=2 dtls=1 renegotiation=1 renegotiate=1" \
-c "HTTP/1.0 200 OK"
client_needs_more_time 4
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \
-p "$P_PXY drop=5 delay=5 duplicate=5" \
"$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
-c "HTTP/1.0 200 OK"
client_needs_more_time 4
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \
-p "$P_PXY drop=5 delay=5 duplicate=5" \
"$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
-c "HTTP/1.0 200 OK"
client_needs_more_time 4
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \
-p "$P_PXY drop=5 delay=5 duplicate=5" \
"$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
-c "HTTP/1.0 200 OK"
client_needs_more_time 4
+requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \
-p "$P_PXY drop=5 delay=5 duplicate=5" \
"$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \
/*----------------------------------------------------------------------------*/
/* Global variables */
-static int test_errors = 0;
+
+static struct
+{
+ int failed;
+ const char *test;
+ const char *filename;
+ int line_no;
+}
+test_info;
+
+
+/*----------------------------------------------------------------------------*/
+/* Helper flags for complex dependencies */
+
+/* Indicates whether we expect mbedtls_entropy_init
+ * to initialize some strong entropy source. */
+#if defined(MBEDTLS_TEST_NULL_ENTROPY) || \
+ ( !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) && \
+ ( !defined(MBEDTLS_NO_PLATFORM_ENTROPY) || \
+ defined(MBEDTLS_HAVEGE_C) || \
+ defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \
+ defined(ENTROPY_NV_SEED) ) )
+#define ENTROPY_HAVE_STRONG
+#endif
/*----------------------------------------------------------------------------*/
static void test_fail( const char *test, int line_no, const char* filename )
{
- test_errors++;
- if( test_errors == 1 )
- mbedtls_fprintf( stdout, "FAILED\n" );
- mbedtls_fprintf( stdout, " %s\n at line %d, %s\n", test, line_no,
- filename );
+ test_info.failed = 1;
+ test_info.test = test;
+ test_info.line_no = line_no;
+ test_info.filename = filename;
}
-
"TESTCASE_FILENAME"
+/** Retrieve one input line into buf, which must have room for len
+ * bytes. The trailing line break (if any) is stripped from the result.
+ * Lines beginning with the character '#' are skipped. Lines that are
+ * more than len-1 bytes long including the trailing line break are
+ * truncated; note that the following bytes remain in the input stream.
+ *
+ * \return 0 on success, -1 on error or end of file
+ */
int get_line( FILE *f, char *buf, size_t len )
{
char *ret;
- ret = fgets( buf, len, f );
- if( ret == NULL )
- return( -1 );
+ do
+ {
+ ret = fgets( buf, len, f );
+ if( ret == NULL )
+ return( -1 );
+ }
+ while( buf[0] == '#' );
- if( strlen( buf ) && buf[strlen(buf) - 1] == '\n' )
- buf[strlen(buf) - 1] = '\0';
- if( strlen( buf ) && buf[strlen(buf) - 1] == '\r' )
- buf[strlen(buf) - 1] = '\0';
+ ret = buf + strlen( buf );
+ if( ret-- > buf && *ret == '\n' )
+ *ret = '\0';
+ if( ret-- > buf && *ret == '\r' )
+ *ret = '\0';
return( 0 );
}
char buf[5000];
char *params[50];
void *pointer;
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
int stdout_fd = -1;
+#endif /* __unix__ || __APPLE__ __MACH__ */
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
!defined(TEST_SUITE_MEMORY_BUFFER_ALLOC)
testfile_count = 1;
}
+ /* Initialize the struct that holds information about the last test */
+ memset( &test_info, 0, sizeof( test_info ) );
+
/* Now begin to execute the tests in the testfiles */
for ( testfile_index = 0;
testfile_index < testfile_count;
if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
break;
- mbedtls_fprintf( stdout, "%s%.66s", test_errors ? "\n" : "", buf );
+ mbedtls_fprintf( stdout, "%s%.66s", test_info.failed ? "\n" : "", buf );
mbedtls_fprintf( stdout, " " );
for( i = strlen( buf ) + 1; i < 67; i++ )
mbedtls_fprintf( stdout, "." );
break;
cnt = parse_arguments( buf, strlen(buf), params );
}
-
+
// If there are no unmet dependencies execute the test
if( unmet_dep_count == 0 )
{
- test_errors = 0;
+ test_info.failed = 0;
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
/* Suppress all output from the library unless we're verbose
if( unmet_dep_count > 0 || ret == DISPATCH_UNSUPPORTED_SUITE )
{
total_skipped++;
- mbedtls_fprintf( stdout, "----\n" );
+ mbedtls_fprintf( stdout, "----" );
if( 1 == option_verbose && ret == DISPATCH_UNSUPPORTED_SUITE )
{
- mbedtls_fprintf( stdout, " Test Suite not enabled" );
+ mbedtls_fprintf( stdout, "\n Test Suite not enabled" );
}
if( 1 == option_verbose && unmet_dep_count > 0 )
{
- mbedtls_fprintf( stdout, " Unmet dependencies: " );
+ mbedtls_fprintf( stdout, "\n Unmet dependencies: " );
for( i = 0; i < unmet_dep_count; i++ )
{
mbedtls_fprintf(stdout, "%s ",
unmet_dependencies[i]);
free(unmet_dependencies[i]);
}
- mbedtls_fprintf( stdout, "\n" );
}
+ mbedtls_fprintf( stdout, "\n" );
fflush( stdout );
unmet_dep_count = 0;
}
- else if( ret == DISPATCH_TEST_SUCCESS && test_errors == 0 )
+ else if( ret == DISPATCH_TEST_SUCCESS )
{
- mbedtls_fprintf( stdout, "PASS\n" );
+ if( test_info.failed == 0 )
+ {
+ mbedtls_fprintf( stdout, "PASS\n" );
+ }
+ else
+ {
+ total_errors++;
+ mbedtls_fprintf( stdout, "FAILED\n" );
+ mbedtls_fprintf( stdout, " %s\n at line %d, %s\n",
+ test_info.test, test_info.line_no,
+ test_info.filename );
+ }
fflush( stdout );
}
else if( ret == DISPATCH_INVALID_TEST_DATA )
{
mbedtls_fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" );
- fclose(file);
+ fclose( file );
mbedtls_exit( 2 );
}
else
total_errors++;
- if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
+ if( ( ret = get_line( file, buf, sizeof( buf ) ) ) != 0 )
break;
- if( strlen(buf) != 0 )
+ if( strlen( buf ) != 0 )
{
mbedtls_fprintf( stderr, "Should be empty %d\n",
- (int) strlen(buf) );
+ (int) strlen( buf ) );
return( 1 );
}
}
- fclose(file);
+ fclose( file );
/* In case we encounter early end of file */
for( i = 0; i < unmet_dep_count; i++ )
return( total_errors != 0 );
}
-
depends_on:MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS
check_padding:MBEDTLS_PADDING_ONE_AND_ZEROS:"0000000000":MBEDTLS_ERR_CIPHER_INVALID_PADDING:4
+Check one and zeros padding #8 (last byte 0x80 | x)
+depends_on:MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS
+check_padding:MBEDTLS_PADDING_ONE_AND_ZEROS:"0000000082":MBEDTLS_ERR_CIPHER_INVALID_PADDING:4
+
Check zeros and len padding #1 (correct)
depends_on:MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN
check_padding:MBEDTLS_PADDING_ZEROS_AND_LEN:"DABBAD0001":0:4
/* BEGIN_HEADER */
#include "mbedtls/ctr_drbg.h"
-int test_offset_idx;
-int mbedtls_entropy_func( void *data, unsigned char *buf, size_t len )
+static int test_offset_idx;
+static int mbedtls_test_entropy_func( void *data, unsigned char *buf, size_t len )
{
const unsigned char *p = (unsigned char *) data;
memcpy( buf, p + test_offset_idx, len );
TEST_ASSERT( mbedtls_ctr_drbg_reseed( &ctx, additional,
MBEDTLS_CTR_DRBG_MAX_SEED_INPUT + 1 ) ==
MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG );
+
+ mbedtls_ctr_drbg_set_entropy_len( &ctx, ~0 );
+ TEST_ASSERT( mbedtls_ctr_drbg_reseed( &ctx, additional,
+ MBEDTLS_CTR_DRBG_MAX_SEED_INPUT ) ==
+ MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG );
exit:
mbedtls_ctr_drbg_free( &ctx );
}
add2_len = unhexify( add2, add2_string );
test_offset_idx = 0;
- TEST_ASSERT( mbedtls_ctr_drbg_seed_entropy_len( &ctx, mbedtls_entropy_func, entropy, add_init, add_init_len, 32 ) == 0 );
+ TEST_ASSERT( mbedtls_ctr_drbg_seed_entropy_len( &ctx, mbedtls_test_entropy_func, entropy, add_init, add_init_len, 32 ) == 0 );
mbedtls_ctr_drbg_set_prediction_resistance( &ctx, MBEDTLS_CTR_DRBG_PR_ON );
TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, buf, 16, add1, add1_len ) == 0 );
add2_len = unhexify( add2, add2_string );
test_offset_idx = 0;
- TEST_ASSERT( mbedtls_ctr_drbg_seed_entropy_len( &ctx, mbedtls_entropy_func, entropy, add_init, add_init_len, 32 ) == 0 );
+ TEST_ASSERT( mbedtls_ctr_drbg_seed_entropy_len( &ctx, mbedtls_test_entropy_func, entropy, add_init, add_init_len, 32 ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, buf, 16, add1, add1_len ) == 0 );
TEST_ASSERT( mbedtls_ctr_drbg_reseed( &ctx, add_reseed, add_reseed_len ) == 0 );
/* Init must use entropy */
last_idx = test_offset_idx;
- TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctx, mbedtls_entropy_func, entropy, NULL, 0 ) == 0 );
+ TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctx, mbedtls_test_entropy_func, entropy, NULL, 0 ) == 0 );
TEST_ASSERT( last_idx < test_offset_idx );
/* By default, PR is off and reseed_interval is large,
Diffie-Hellman full exchange #1
-dhm_do_dhm:10:"23":10:"5"
+dhm_do_dhm:10:"23":10:"5":0
Diffie-Hellman full exchange #2
-dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622"
+dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622":0
Diffie-Hellman full exchange #3
-dhm_do_dhm:10:"93450983094850938450983409623982317398171298719873918739182739712938719287391879381271":10:"9345098309485093845098340962223981329819812792137312973297123912791271"
+dhm_do_dhm:10:"93450983094850938450983409623982317398171298719873918739182739712938719287391879381271":10:"9345098309485093845098340962223981329819812792137312973297123912791271":0
+
+Diffie-Hellman trivial subgroup #1
+dhm_do_dhm:10:"23":10:"1":MBEDTLS_ERR_DHM_BAD_INPUT_DATA
+
+Diffie-Hellman trivial subgroup #2
+dhm_do_dhm:10:"23":10:"-1":MBEDTLS_ERR_DHM_BAD_INPUT_DATA
+
+Diffie-Hellman small modulus
+dhm_do_dhm:10:"3":10:"5":MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED
+
+Diffie-Hellman zero modulus
+dhm_do_dhm:10:"0":10:"5":MBEDTLS_ERR_DHM_BAD_INPUT_DATA
Diffie-Hallman load parameters from file
dhm_file:"data_files/dhparams.pem":"9e35f430443a09904f3a39a979797d070df53378e79c2438bef4e761f3c714553328589b041c809be1d6c6b5f1fc9f47d3a25443188253a992a56818b37ba9de5a40d362e56eff0be5417474c125c199272c8fe41dea733df6f662c92ae76556e755d10c64e6a50968f67fc6ea73d0dca8569be2ba204e23580d8bca2f4975b3":"02":128
/* BEGIN_CASE */
void dhm_do_dhm( int radix_P, char *input_P,
- int radix_G, char *input_G )
+ int radix_G, char *input_G, int result )
{
mbedtls_dhm_context ctx_srv;
mbedtls_dhm_context ctx_cli;
/*
* First key exchange
*/
- TEST_ASSERT( mbedtls_dhm_make_params( &ctx_srv, x_size, ske, &ske_len, &rnd_pseudo_rand, &rnd_info ) == 0 );
+ TEST_ASSERT( mbedtls_dhm_make_params( &ctx_srv, x_size, ske, &ske_len, &rnd_pseudo_rand, &rnd_info ) == result );
+ if ( result != 0 )
+ goto exit;
+
ske[ske_len++] = 0;
ske[ske_len++] = 0;
TEST_ASSERT( mbedtls_dhm_read_params( &ctx_cli, &p, ske + ske_len ) == 0 );
ECDSA primitive rfc 4754 p256
depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED
-ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"DC51D3866A15BACDE33D96F992FCA99DA7E6EF0934E7097559C27F1614C88A7F":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085E0822CB04235E970":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945CDDFE7D509BBFD7D":"9E56F509196784D963D1C0A401510EE7ADA3DCC5DEE04B154BF61AF1D5A6DECE":"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD":"CB28E0999B9C7715FD0A80D8E47A77079716CBBF917DD72E97566EA1C066957C":"86FA3BB4E26CAD5BF90B7F81899256CE7594BB1EA0C89212748BFF3B3D5B0315"
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"DC51D3866A15BACDE33D96F992FCA99DA7E6EF0934E7097559C27F1614C88A7F":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085E0822CB04235E970":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945CDDFE7D509BBFD7D":"9E56F509196784D963D1C0A401510EE7ADA3DCC5DEE04B154BF61AF1D5A6DECE":"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD":"CB28E0999B9C7715FD0A80D8E47A77079716CBBF917DD72E97566EA1C066957C":"86FA3BB4E26CAD5BF90B7F81899256CE7594BB1EA0C89212748BFF3B3D5B0315":0
ECDSA primitive rfc 4754 p384
depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED
-ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"0BEB646634BA87735D77AE4809A0EBEA865535DE4C1E1DCB692E84708E81A5AF62E528C38B2A81B35309668D73524D9F":"96281BF8DD5E0525CA049C048D345D3082968D10FEDF5C5ACA0C64E6465A97EA5CE10C9DFEC21797415710721F437922":"447688BA94708EB6E2E4D59F6AB6D7EDFF9301D249FE49C33096655F5D502FAD3D383B91C5E7EDAA2B714CC99D5743CA":"B4B74E44D71A13D568003D7489908D564C7761E229C58CBFA18950096EB7463B854D7FA992F934D927376285E63414FA":"CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7":"FB017B914E29149432D8BAC29A514640B46F53DDAB2C69948084E2930F1C8F7E08E07C9C63F2D21A07DCB56A6AF56EB3":"B263A1305E057F984D38726A1B46874109F417BCA112674C528262A40A629AF1CBB9F516CE0FA7D2FF630863A00E8B9F"
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"0BEB646634BA87735D77AE4809A0EBEA865535DE4C1E1DCB692E84708E81A5AF62E528C38B2A81B35309668D73524D9F":"96281BF8DD5E0525CA049C048D345D3082968D10FEDF5C5ACA0C64E6465A97EA5CE10C9DFEC21797415710721F437922":"447688BA94708EB6E2E4D59F6AB6D7EDFF9301D249FE49C33096655F5D502FAD3D383B91C5E7EDAA2B714CC99D5743CA":"B4B74E44D71A13D568003D7489908D564C7761E229C58CBFA18950096EB7463B854D7FA992F934D927376285E63414FA":"CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7":"FB017B914E29149432D8BAC29A514640B46F53DDAB2C69948084E2930F1C8F7E08E07C9C63F2D21A07DCB56A6AF56EB3":"B263A1305E057F984D38726A1B46874109F417BCA112674C528262A40A629AF1CBB9F516CE0FA7D2FF630863A00E8B9F":0
ECDSA primitive rfc 4754 p521
depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED
-ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0065FDA3409451DCAB0A0EAD45495112A3D813C17BFD34BDF8C1209D7DF5849120597779060A7FF9D704ADF78B570FFAD6F062E95C7E0C5D5481C5B153B48B375FA1":"0151518F1AF0F563517EDD5485190DF95A4BF57B5CBA4CF2A9A3F6474725A35F7AFE0A6DDEB8BEDBCD6A197E592D40188901CECD650699C9B5E456AEA5ADD19052A8":"006F3B142EA1BFFF7E2837AD44C9E4FF6D2D34C73184BBAD90026DD5E6E85317D9DF45CAD7803C6C20035B2F3FF63AFF4E1BA64D1C077577DA3F4286C58F0AEAE643":"00C1C2B305419F5A41344D7E4359933D734096F556197A9B244342B8B62F46F9373778F9DE6B6497B1EF825FF24F42F9B4A4BD7382CFC3378A540B1B7F0C1B956C2F":"DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F":"0154FD3836AF92D0DCA57DD5341D3053988534FDE8318FC6AAAAB68E2E6F4339B19F2F281A7E0B22C269D93CF8794A9278880ED7DBB8D9362CAEACEE544320552251":"017705A7030290D1CEB605A9A1BB03FF9CDD521E87A696EC926C8C10C8362DF4975367101F67D1CF9BCCBF2F3D239534FA509E70AAC851AE01AAC68D62F866472660"
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0065FDA3409451DCAB0A0EAD45495112A3D813C17BFD34BDF8C1209D7DF5849120597779060A7FF9D704ADF78B570FFAD6F062E95C7E0C5D5481C5B153B48B375FA1":"0151518F1AF0F563517EDD5485190DF95A4BF57B5CBA4CF2A9A3F6474725A35F7AFE0A6DDEB8BEDBCD6A197E592D40188901CECD650699C9B5E456AEA5ADD19052A8":"006F3B142EA1BFFF7E2837AD44C9E4FF6D2D34C73184BBAD90026DD5E6E85317D9DF45CAD7803C6C20035B2F3FF63AFF4E1BA64D1C077577DA3F4286C58F0AEAE643":"00C1C2B305419F5A41344D7E4359933D734096F556197A9B244342B8B62F46F9373778F9DE6B6497B1EF825FF24F42F9B4A4BD7382CFC3378A540B1B7F0C1B956C2F":"DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F":"0154FD3836AF92D0DCA57DD5341D3053988534FDE8318FC6AAAAB68E2E6F4339B19F2F281A7E0B22C269D93CF8794A9278880ED7DBB8D9362CAEACEE544320552251":"017705A7030290D1CEB605A9A1BB03FF9CDD521E87A696EC926C8C10C8362DF4975367101F67D1CF9BCCBF2F3D239534FA509E70AAC851AE01AAC68D62F866472660":0
ECDSA write-read random #1
depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED
depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED:MBEDTLS_SHA512_C
ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538":MBEDTLS_MD_SHA512:"test":"13E99020ABF5CEE7525D16B69B229652AB6BDF2AFFCAEF38773B4B7D08725F10CDB93482FDCC54EDCEE91ECA4166B2A7C6265EF0CE2BD7051B7CEF945BABD47EE6D":"1FBD0013C674AA79CB39849527916CE301C66EA7CE8B80682786AD60F98F7E78A19CA69EFF5C57400E3B3A0AD66CE0978214D13BAF4E9AC60752F7B155E2DE4DCE3"
+ECDSA zero private parameter p192
+depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"0":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945":"9E56F509196784D963D1C0A401510EE7ADA3DCC5DEE04B15":"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9C":"98C6BD12B23EAF5E2A2045132086BE3EB8EBD62ABF6698FF":"57A22B07DEA9530F8DE9471B1DC6624472E8E2844BC25B64":MBEDTLS_ERR_ECP_INVALID_KEY
+
+ECDSA private parameter greater than n p192
+depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD41":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945":"9E56F509196784D963D1C0A401510EE7ADA3DCC5DEE04B15":"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61":"98C6BD12B23EAF5E2A2045132086BE3EB8EBD62ABF6698FF":"57A22B07DEA9530F8DE9471B1DC6624472E8E2844BC25B64":MBEDTLS_ERR_ECP_INVALID_KEY
+
+ECDSA zero private parameter p224
+depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"0":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085E0822CB04235E970":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945CDDFE7D5":"9E56F509196784D963D1C0A401510EE7ADA3DCC5DEE04B154BF61AF1":"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61":"22226F9D40A96E19C4A301CE5B74B115303C0F3A4FD30FC257FB57AC":"66D1CDD83E3AF75605DD6E2FEFF196D30AA7ED7A2EDF7AF475403D69":MBEDTLS_ERR_ECP_INVALID_KEY
+
+ECDSA private parameter greater than n p224
+depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C11":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085E0822CB04235E970":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945CDDFE7D5":"9E56F509196784D963D1C0A401510EE7ADA3DCC5DEE04B154BF61AF1":"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD":"22226F9D40A96E19C4A301CE5B74B115303C0F3A4FD30FC257FB57AC":"66D1CDD83E3AF75605DD6E2FEFF196D30AA7ED7A2EDF7AF475403D69":MBEDTLS_ERR_ECP_INVALID_KEY
+
+ECDSA zero private parameter p256
+depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"0":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085E0822CB04235E970":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945CDDFE7D509BBFD7D":"9E56F509196784D963D1C0A401510EE7ADA3DCC5DEE04B154BF61AF1D5A6DECE":"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD":"CB28E0999B9C7715FD0A80D8E47A77079716CBBF917DD72E97566EA1C066957C":"86FA3BB4E26CAD5BF90B7F81899256CE7594BB1EA0C89212748BFF3B3D5B0315":MBEDTLS_ERR_ECP_INVALID_KEY
+
+ECDSA private parameter greater than n p256
+depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"DC51D3866A15BACDE33D96F992FCA99DA7E6EF0934E7097559C27F1614C88A7F1":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085E0822CB04235E970":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945CDDFE7D509BBFD7D":"9E56F509196784D963D1C0A401510EE7ADA3DCC5DEE04B154BF61AF1D5A6DECE":"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD":"CB28E0999B9C7715FD0A80D8E47A77079716CBBF917DD72E97566EA1C066957C":"86FA3BB4E26CAD5BF90B7F81899256CE7594BB1EA0C89212748BFF3B3D5B0315":MBEDTLS_ERR_ECP_INVALID_KEY
+
+ECDSA zero private parameter p384
+depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"0":"96281BF8DD5E0525CA049C048D345D3082968D10FEDF5C5ACA0C64E6465A97EA5CE10C9DFEC21797415710721F437922":"447688BA94708EB6E2E4D59F6AB6D7EDFF9301D249FE49C33096655F5D502FAD3D383B91C5E7EDAA2B714CC99D5743CA":"B4B74E44D71A13D568003D7489908D564C7761E229C58CBFA18950096EB7463B854D7FA992F934D927376285E63414FA":"CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7":"FB017B914E29149432D8BAC29A514640B46F53DDAB2C69948084E2930F1C8F7E08E07C9C63F2D21A07DCB56A6AF56EB3":"B263A1305E057F984D38726A1B46874109F417BCA112674C528262A40A629AF1CBB9F516CE0FA7D2FF630863A00E8B9F":MBEDTLS_ERR_ECP_INVALID_KEY
+
+ECDSA private parameter greater than n p384
+depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"10BEB646634BA87735D77AE4809A0EBEA865535DE4C1E1DCB692E84708E81A5AF62E528C38B2A81B35309668D73524D9F":"96281BF8DD5E0525CA049C048D345D3082968D10FEDF5C5ACA0C64E6465A97EA5CE10C9DFEC21797415710721F437922":"447688BA94708EB6E2E4D59F6AB6D7EDFF9301D249FE49C33096655F5D502FAD3D383B91C5E7EDAA2B714CC99D5743CA":"B4B74E44D71A13D568003D7489908D564C7761E229C58CBFA18950096EB7463B854D7FA992F934D927376285E63414FA":"CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7":"FB017B914E29149432D8BAC29A514640B46F53DDAB2C69948084E2930F1C8F7E08E07C9C63F2D21A07DCB56A6AF56EB3":"B263A1305E057F984D38726A1B46874109F417BCA112674C528262A40A629AF1CBB9F516CE0FA7D2FF630863A00E8B9F":MBEDTLS_ERR_ECP_INVALID_KEY
+
+ECDSA zero private parameter p521
+depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0":"0151518F1AF0F563517EDD5485190DF95A4BF57B5CBA4CF2A9A3F6474725A35F7AFE0A6DDEB8BEDBCD6A197E592D40188901CECD650699C9B5E456AEA5ADD19052A8":"006F3B142EA1BFFF7E2837AD44C9E4FF6D2D34C73184BBAD90026DD5E6E85317D9DF45CAD7803C6C20035B2F3FF63AFF4E1BA64D1C077577DA3F4286C58F0AEAE643":"00C1C2B305419F5A41344D7E4359933D734096F556197A9B244342B8B62F46F9373778F9DE6B6497B1EF825FF24F42F9B4A4BD7382CFC3378A540B1B7F0C1B956C2F":"DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F":"0154FD3836AF92D0DCA57DD5341D3053988534FDE8318FC6AAAAB68E2E6F4339B19F2F281A7E0B22C269D93CF8794A9278880ED7DBB8D9362CAEACEE544320552251":"017705A7030290D1CEB605A9A1BB03FF9CDD521E87A696EC926C8C10C8362DF4975367101F67D1CF9BCCBF2F3D239534FA509E70AAC851AE01AAC68D62F866472660":MBEDTLS_ERR_ECP_INVALID_KEY
+
+ECDSA private parameter greater than n p521
+depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED
+ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0065FDA3409451DCAB0A0EAD45495112A3D813C17BFD34BDF8C1209D7DF5849120597779060A7FF9D704ADF78B570FFAD6F062E95C7E0C5D5481C5B153B48B375FA11":"0151518F1AF0F563517EDD5485190DF95A4BF57B5CBA4CF2A9A3F6474725A35F7AFE0A6DDEB8BEDBCD6A197E592D40188901CECD650699C9B5E456AEA5ADD19052A8":"006F3B142EA1BFFF7E2837AD44C9E4FF6D2D34C73184BBAD90026DD5E6E85317D9DF45CAD7803C6C20035B2F3FF63AFF4E1BA64D1C077577DA3F4286C58F0AEAE643":"00C1C2B305419F5A41344D7E4359933D734096F556197A9B244342B8B62F46F9373778F9DE6B6497B1EF825FF24F42F9B4A4BD7382CFC3378A540B1B7F0C1B956C2F":"DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F":"0154FD3836AF92D0DCA57DD5341D3053988534FDE8318FC6AAAAB68E2E6F4339B19F2F281A7E0B22C269D93CF8794A9278880ED7DBB8D9362CAEACEE544320552251":"017705A7030290D1CEB605A9A1BB03FF9CDD521E87A696EC926C8C10C8362DF4975367101F67D1CF9BCCBF2F3D239534FA509E70AAC851AE01AAC68D62F866472660":MBEDTLS_ERR_ECP_INVALID_KEY
/* BEGIN_CASE */
void ecdsa_prim_test_vectors( int id, char *d_str, char *xQ_str, char *yQ_str,
char *k_str, char *hash_str, char *r_str,
- char *s_str )
+ char *s_str, int result )
{
mbedtls_ecp_group grp;
mbedtls_ecp_point Q;
}
TEST_ASSERT( mbedtls_ecdsa_sign( &grp, &r, &s, &d, hash, hlen,
- rnd_buffer_rand, &rnd_info ) == 0 );
+ rnd_buffer_rand, &rnd_info ) == result );
- TEST_ASSERT( mbedtls_mpi_cmp_mpi( &r, &r_check ) == 0 );
- TEST_ASSERT( mbedtls_mpi_cmp_mpi( &s, &s_check ) == 0 );
+ if ( result == 0)
+ {
+ TEST_ASSERT( mbedtls_mpi_cmp_mpi( &r, &r_check ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_cmp_mpi( &s, &s_check ) == 0 );
- TEST_ASSERT( mbedtls_ecdsa_verify( &grp, hash, hlen, &Q, &r_check, &s_check ) == 0 );
+ TEST_ASSERT( mbedtls_ecdsa_verify( &grp, hash, hlen, &Q, &r_check, &s_check ) == 0 );
+ }
exit:
mbedtls_ecp_group_free( &grp );
void read_round_one( int role, char *data, int ref_ret )
{
mbedtls_ecjpake_context ctx;
- const unsigned char pw[] = {};
+
+ const unsigned char * pw = NULL;
+ const size_t pw_len = 0;
+
unsigned char *msg;
size_t len;
TEST_ASSERT( msg != NULL );
TEST_ASSERT( mbedtls_ecjpake_setup( &ctx, role,
- MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, 0 ) == 0 );
+ MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, pw_len ) == 0 );
TEST_ASSERT( mbedtls_ecjpake_read_round_one( &ctx, msg, len ) == ref_ret );
void read_round_two_cli( char *data, int ref_ret )
{
mbedtls_ecjpake_context ctx;
- const unsigned char pw[] = {};
+
+ const unsigned char * pw = NULL;
+ const size_t pw_len = 0;
+
unsigned char *msg;
size_t len;
TEST_ASSERT( msg != NULL );
TEST_ASSERT( mbedtls_ecjpake_setup( &ctx, MBEDTLS_ECJPAKE_CLIENT,
- MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, 0 ) == 0 );
+ MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, pw_len ) == 0 );
TEST_ASSERT( ecjpake_test_load( &ctx,
ADD_SIZE( ecjpake_test_x1 ), ADD_SIZE( ecjpake_test_x2 ),
void read_round_two_srv( char *data, int ref_ret )
{
mbedtls_ecjpake_context ctx;
- const unsigned char pw[] = {};
+
+ const unsigned char * pw = NULL;
+ const size_t pw_len = 0;
+
unsigned char *msg;
size_t len;
TEST_ASSERT( msg != NULL );
TEST_ASSERT( mbedtls_ecjpake_setup( &ctx, MBEDTLS_ECJPAKE_SERVER,
- MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, 0 ) == 0 );
+ MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, pw_len ) == 0 );
TEST_ASSERT( ecjpake_test_load( &ctx,
ADD_SIZE( ecjpake_test_x3 ), ADD_SIZE( ecjpake_test_x4 ),
ECP check pubkey Montgomery #1 (too big)
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
-ecp_check_pub_mx:MBEDTLS_ECP_DP_CURVE25519:"010000000000000000000000000000000000000000000000000000000000000000":MBEDTLS_ERR_ECP_INVALID_KEY
+ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"010000000000000000000000000000000000000000000000000000000000000000":"0":"1":MBEDTLS_ERR_ECP_INVALID_KEY
ECP check pubkey Montgomery #2 (biggest)
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
-ecp_check_pub_mx:MBEDTLS_ECP_DP_CURVE25519:"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":0
+ecp_check_pub:MBEDTLS_ECP_DP_CURVE25519:"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF":"0":"1":0
+
+ECP check pubkey Koblitz #1 (point not on curve)
+depends_on:MBEDTLS_ECP_DP_SECP224K1_ENABLED
+ecp_check_pub:MBEDTLS_ECP_DP_SECP224K1:"E2000000000000BB3A13D43B323337383935321F0603551D":"100101FF040830060101FF02010A30220603551D0E041B04636FC0C0":"1":MBEDTLS_ERR_ECP_INVALID_KEY
+
+ECP check pubkey Koblitz #2 (coordinate not affine)
+depends_on:MBEDTLS_ECP_DP_SECP224K1_ENABLED
+ecp_check_pub:MBEDTLS_ECP_DP_SECP224K1:"E2000000000000BB3A13D43B323337383935321F0603551D":"100101FF040830060101FF02010A30220603551D0E041B04636FC0C0":"101":MBEDTLS_ERR_ECP_INVALID_KEY
ECP write binary #0 (zero, bad format)
depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED
/* END_CASE */
/* BEGIN_CASE */
-void ecp_check_pub_mx( int grp_id, char *key_hex, int ret )
+void ecp_check_pub( int grp_id, char *x_hex, char *y_hex, char *z_hex, int ret )
{
mbedtls_ecp_group grp;
mbedtls_ecp_point P;
TEST_ASSERT( mbedtls_ecp_group_load( &grp, grp_id ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &P.X, 16, key_hex ) == 0 );
- TEST_ASSERT( mbedtls_mpi_lset( &P.Z, 1 ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P.X, 16, x_hex ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P.Y, 16, y_hex ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P.Z, 16, z_hex ) == 0 );
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &P ) == ret );
Entropy threshold #2
entropy_threshold:32:1:32
-Entropy thershold #3
+Entropy threshold #3
entropy_threshold:16:0:MBEDTLS_ERR_ENTROPY_SOURCE_FAILED
-Entropy thershold #4
+Entropy threshold #4
entropy_threshold:1024:1:MBEDTLS_ERR_ENTROPY_SOURCE_FAILED
Check NV seed standard IO
}
/* END_CASE */
-/* BEGIN_CASE */
+/* BEGIN_CASE depends_on:ENTROPY_HAVE_STRONG */
void entropy_func_len( int len, int ret )
{
mbedtls_entropy_context ctx;
}
/* END_CASE */
-/* BEGIN_CASE */
+/* BEGIN_CASE depends_on:ENTROPY_HAVE_STRONG */
void entropy_threshold( int threshold, int chunk_size, int result )
{
mbedtls_entropy_context ctx;
}
/* END_CASE */
-/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
+/* BEGIN_CASE depends_on:ENTROPY_HAVE_STRONG:MBEDTLS_SELF_TEST */
void entropy_selftest( int result )
{
TEST_ASSERT( mbedtls_entropy_self_test( 1 ) == result );
depends_on:MBEDTLS_AES_C
gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"659b9e729d12f68b73fdc2f7260ab114":"fd0732a38224c3f16f58de3a7f333da2ecdb6eec92b469544a891966dd4f8fb64a711a793f1ef6a90e49765eacaccdd8cc438c2b57c51902d27a82ee4f24925a864a9513a74e734ddbf77204a99a3c0060fcfbaccae48fe509bc95c3d6e1b1592889c489801265715e6e4355a45357ce467c1caa2f1c3071bd3a9168a7d223e3":"459df18e2dfbd66d6ad04978432a6d97":"ee0b0b52a729c45b899cc924f46eb1908e55aaaeeaa0c4cdaacf57948a7993a6debd7b6cd7aa426dc3b3b6f56522ba3d5700a820b1697b8170bad9ca7caf1050f13d54fb1ddeb111086cb650e1c5f4a14b6a927205a83bf49f357576fd0f884a83b068154352076a6e36a5369436d2c8351f3e6bfec65b4816e3eb3f144ed7f9":32:"8e5a6a79":"FAIL":0
+AES-GCM Bad IV (AES-128,128,0,0,32) #0
+depends_on:MBEDTLS_AES_C
+gcm_bad_parameters:MBEDTLS_CIPHER_ID_AES:MBEDTLS_GCM_DECRYPT:"d0194b6ee68f0ed8adc4b22ed15dbf14":"":"":"":32:MBEDTLS_ERR_GCM_BAD_INPUT
+
AES-GCM Selftest
depends_on:MBEDTLS_AES_C
gcm_selftest:
depends_on:MBEDTLS_AES_C
gcm_encrypt_and_tag:MBEDTLS_CIPHER_ID_AES:"fe481476fce76efcfc78ed144b0756f1":"246e1f2babab8da98b17cc928bd49504d7d87ea2cc174f9ffb7dbafe5969ff824a0bcb52f35441d22f3edcd10fab0ec04c0bde5abd3624ca25cbb4541b5d62a3deb52c00b75d68aaf0504d51f95b8dcbebdd8433f4966c584ac7f8c19407ca927a79fa4ead2688c4a7baafb4c31ef83c05e8848ec2b4f657aab84c109c91c277":"1a2c18c6bf13b3b2785610c71ccd98ca":"b0ab3cb5256575774b8242b89badfbe0dfdfd04f5dd75a8e5f218b28d3f6bc085a013defa5f5b15dfb46132db58ed7a9ddb812d28ee2f962796ad988561a381c02d1cf37dca5fd33e081d61cc7b3ab0b477947524a4ca4cb48c36f48b302c440be6f5777518a60585a8a16cea510dbfc5580b0daac49a2b1242ff55e91a8eae8":"5587620bbb77f70afdf3cdb7ae390edd0473286d86d3f862ad70902d90ff1d315947c959f016257a8fe1f52cc22a54f21de8cb60b74808ac7b22ea7a15945371e18b77c9571aad631aa080c60c1e472019fa85625fc80ed32a51d05e397a8987c8fece197a566689d24d05361b6f3a75616c89db6123bf5902960b21a18bc03a":32:"bd4265a8":0
+AES-GCM Bad IV (AES-128,128,0,0,32) #0
+depends_on:MBEDTLS_AES_C
+gcm_bad_parameters:MBEDTLS_CIPHER_ID_AES:MBEDTLS_GCM_ENCRYPT:"d0194b6ee68f0ed8adc4b22ed15dbf14":"":"":"":32:MBEDTLS_ERR_GCM_BAD_INPUT
+
AES-GCM Selftest
depends_on:MBEDTLS_AES_C
gcm_selftest:
depends_on:MBEDTLS_AES_C
gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b10979797fb8f418a126120d45106e1779b4538751a19bf6":"e3dc64e3c02731fe6e6ec0e899183018da347bf8bd476aa7746d7a7729d83a95f64bb732ba987468d0cede154e28169f7bafa36559200795037ee38279e0e4ca40f9cfa85aa0c8035df9649345c8fdffd1c31528b485dfe443c1923180cc8fae5196d16f822be4ad07e3f1234e1d218e7c8fb37a0e4480dc6717c9c09ff5c45f":"ca362e615024a1fe11286668646cc1de":"237d95d86a5ad46035870f576a1757eded636c7234d5ed0f8039f6f59f1333cc31cb893170d1baa98bd4e79576de920120ead0fdecfb343edbc2fcc556540a91607388a05d43bdb8b55f1327552feed3b620614dfcccb2b342083896cbc81dc9670b761add998913ca813163708a45974e6d7b56dfd0511a72eb879f239d6a6d":32:"28d730ea":"dafde27aa8b3076bfa16ab1d89207d339c4997f8a756cc3eb62c0b023976de808ab640ba4467f2b2ea83d238861229c73387594cd43770386512ea595a70888b4c38863472279e06b923e7cf32438199b3e054ac4bc21baa8df39ddaa207ebb17fa4cad6e83ea58c3a92ec74e6e01b0a8979af145dd31d5df29750bb91b42d45":0
+AES-GCM Bad IV (AES-192,128,0,0,32) #0
+depends_on:MBEDTLS_AES_C
+gcm_bad_parameters:MBEDTLS_CIPHER_ID_AES:MBEDTLS_GCM_DECRYPT:"b10979797fb8f418a126120d45106e1779b4538751a19bf6":"":"":"":32:MBEDTLS_ERR_GCM_BAD_INPUT
+
AES-GCM Selftest
depends_on:MBEDTLS_AES_C
gcm_selftest:
depends_on:MBEDTLS_AES_C
gcm_encrypt_and_tag:MBEDTLS_CIPHER_ID_AES:"713358e746dd84ab27b8adb3b17ea59cd75fa6cb0c13d1a8":"35b8b655efdf2d09f5ed0233c9eeb0b6f85e513834848cd594dba3c6e64f78e7af4a7a6d53bba7b43764334d6373360ae3b73b1e765978dffa7dbd805fda7825b8e317e8d3f1314aa97f877be815439c5da845028d1686283735aefac79cdb9e02ec3590091cb507089b9174cd9a6111f446feead91f19b80fd222fc6299fd1c":"26ed909f5851961dd57fa950b437e17c":"c9469ad408764cb7d417f800d3d84f03080cee9bbd53f652763accde5fba13a53a12d990094d587345da2cdc99357b9afd63945ca07b760a2c2d4948dbadb1312670ccde87655a6a68edb5982d2fcf733bb4101d38cdb1a4942a5d410f4c45f5ddf00889bc1fe5ec69b40ae8aaee60ee97bea096eeef0ea71736efdb0d8a5ec9":"cc3f9983e1d673ec2c86ae4c1e1b04e30f9f395f67c36838e15ce825b05d37e9cd40041470224da345aa2da5dfb3e0c561dd05ba7984a1332541d58e8f9160e7e8457e717bab203de3161a72b7aedfa53616b16ca77fd28d566fbf7431be559caa1a129b2f29b9c5bbf3eaba594d6650c62907eb28e176f27c3be7a3aa24cef6":32:"5be7611b":0
+AES-GCM Bad IV (AES-192,128,0,0,32) #0
+depends_on:MBEDTLS_AES_C
+gcm_bad_parameters:MBEDTLS_CIPHER_ID_AES:MBEDTLS_GCM_ENCRYPT:"b10979797fb8f418a126120d45106e1779b4538751a19bf6":"":"":"":32:MBEDTLS_ERR_GCM_BAD_INPUT
+
AES-GCM Selftest
depends_on:MBEDTLS_AES_C
gcm_selftest:
depends_on:MBEDTLS_AES_C
gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ca264e7caecad56ee31c8bf8dde9592f753a6299e76c60ac1e93cff3b3de8ce9":"8d03cf6fac31182ad3e6f32e4c823e3b421aef786d5651afafbf70ef14c00524ab814bc421b1d4181b4d3d82d6ae4e8032e43a6c4e0691184425b37320798f865c88b9b306466311d79e3e42076837474c37c9f6336ed777f05f70b0c7d72bd4348a4cd754d0f0c3e4587f9a18313ea2d2bace502a24ea417d3041b709a0471f":"4763a4e37b806a5f4510f69fd8c63571":"07daeba37a66ebe15f3d6451d1176f3a7107a302da6966680c425377e621fd71610d1fc9c95122da5bf85f83b24c4b783b1dcd6b508d41e22c09b5c43693d072869601fc7e3f5a51dbd3bc6508e8d095b9130fb6a7f2a043f3a432e7ce68b7de06c1379e6bab5a1a48823b76762051b4e707ddc3201eb36456e3862425cb011a":32:"3105dddb":"FAIL":0
+AES-GCM Bad IV (AES-256,128,0,0,32) #0
+depends_on:MBEDTLS_AES_C
+gcm_bad_parameters:MBEDTLS_CIPHER_ID_AES:MBEDTLS_GCM_DECRYPT:"ca264e7caecad56ee31c8bf8dde9592f753a6299e76c60ac1e93cff3b3de8ce9":"":"":"":32:MBEDTLS_ERR_GCM_BAD_INPUT
+
AES-GCM Selftest
depends_on:MBEDTLS_AES_C
gcm_selftest:
depends_on:MBEDTLS_AES_C
gcm_encrypt_and_tag:MBEDTLS_CIPHER_ID_AES:"1477e189fb3546efac5cc144f25e132ffd0081be76e912e25cbce7ad63f1c2c4":"7bd3ea956f4b938ebe83ef9a75ddbda16717e924dd4e45202560bf5f0cffbffcdd23be3ae08ff30503d698ed08568ff6b3f6b9fdc9ea79c8e53a838cc8566a8b52ce7c21b2b067e778925a066c970a6c37b8a6cfc53145f24bf698c352078a7f0409b53196e00c619237454c190b970842bb6629c0def7f166d19565127cbce0":"c109f35893aff139db8ed51c85fee237":"8f7f9f71a4b2bb0aaf55fced4eb43c57415526162070919b5f8c08904942181820d5847dfd54d9ba707c5e893a888d5a38d0130f7f52c1f638b0119cf7bc5f2b68f51ff5168802e561dff2cf9c5310011c809eba002b2fa348718e8a5cb732056273cc7d01cce5f5837ab0b09b6c4c5321a7f30a3a3cd21f29da79fce3f3728b":"7841e3d78746f07e5614233df7175931e3c257e09ebd7b78545fae484d835ffe3db3825d3aa1e5cc1541fe6cac90769dc5aaeded0c148b5b4f397990eb34b39ee7881804e5a66ccc8d4afe907948780c4e646cc26479e1da874394cb3537a8f303e0aa13bd3cc36f6cc40438bcd41ef8b6a1cdee425175dcd17ee62611d09b02":32:"cb13ce59":0
+AES-GCM Bad IV (AES-256,128,0,0,32) #0
+depends_on:MBEDTLS_AES_C
+gcm_bad_parameters:MBEDTLS_CIPHER_ID_AES:MBEDTLS_GCM_DECRYPT:"ca264e7caecad56ee31c8bf8dde9592f753a6299e76c60ac1e93cff3b3de8ce9":"":"":"":32:MBEDTLS_ERR_GCM_BAD_INPUT
+
AES-GCM Selftest
depends_on:MBEDTLS_AES_C
gcm_selftest:
*/
/* BEGIN_CASE */
+void gcm_bad_parameters( int cipher_id, int direction,
+ char *hex_key_string, char *hex_src_string,
+ char *hex_iv_string, char *hex_add_string,
+ int tag_len_bits, int gcm_result )
+{
+ unsigned char key_str[128];
+ unsigned char src_str[128];
+ unsigned char dst_str[257];
+ unsigned char iv_str[128];
+ unsigned char add_str[128];
+ unsigned char tag_str[128];
+ unsigned char output[128];
+ unsigned char tag_output[16];
+ mbedtls_gcm_context ctx;
+ unsigned int key_len;
+ size_t pt_len, iv_len, add_len, tag_len = tag_len_bits / 8;
+
+ mbedtls_gcm_init( &ctx );
+
+ memset( key_str, 0x00, sizeof( key_str ) );
+ memset( src_str, 0x00, sizeof( src_str ) );
+ memset( dst_str, 0x00, sizeof( dst_str ) );
+ memset( iv_str, 0x00, sizeof( iv_str ) );
+ memset( add_str, 0x00, sizeof( add_str ) );
+ memset( tag_str, 0x00, sizeof( tag_str ) );
+ memset( output, 0x00, sizeof( output ) );
+ memset( tag_output, 0x00, sizeof( tag_output ) );
+
+ key_len = unhexify( key_str, hex_key_string );
+ pt_len = unhexify( src_str, hex_src_string );
+ iv_len = unhexify( iv_str, hex_iv_string );
+ add_len = unhexify( add_str, hex_add_string );
+
+ TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str, key_len * 8 ) == 0 );
+ TEST_ASSERT( mbedtls_gcm_crypt_and_tag( &ctx, direction, pt_len, iv_str, iv_len,
+ add_str, add_len, src_str, output, tag_len, tag_output ) == gcm_result );
+
+exit:
+ mbedtls_gcm_free( &ctx );
+}
+/* END_CASE */
+
+/* BEGIN_CASE */
void gcm_encrypt_and_tag( int cipher_id,
char *hex_key_string, char *hex_src_string,
char *hex_iv_string, char *hex_add_string,
size_t len;
} entropy_ctx;
-int mbedtls_entropy_func( void *data, unsigned char *buf, size_t len )
+static int mbedtls_test_entropy_func( void *data, unsigned char *buf, size_t len )
{
entropy_ctx *ctx = (entropy_ctx *) data;
/* Init must use entropy */
last_len = entropy.len;
- TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_entropy_func, &entropy,
+ TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &entropy,
NULL, 0 ) == 0 );
TEST_ASSERT( entropy.len < last_len );
TEST_ASSERT( memcmp( my_output, output, out_len ) == 0 );
/* And now the normal entropy-based variant */
- TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_entropy_func, &p_entropy,
+ TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy,
custom, custom_len ) == 0 );
TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, out_len,
add1, add1_len ) == 0 );
md_info = mbedtls_md_info_from_type( md_alg );
TEST_ASSERT( md_info != NULL );
- TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_entropy_func, &p_entropy,
+ TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy,
custom, custom_len ) == 0 );
TEST_ASSERT( mbedtls_hmac_drbg_reseed( &ctx, add1, add1_len ) == 0 );
TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, out_len,
md_info = mbedtls_md_info_from_type( md_alg );
TEST_ASSERT( md_info != NULL );
- TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_entropy_func, &p_entropy,
+ TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy,
custom, custom_len ) == 0 );
mbedtls_hmac_drbg_set_prediction_resistance( &ctx, MBEDTLS_HMAC_DRBG_PR_ON );
TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, out_len,
+# Tests of the generic message digest interface
MD process
mbedtls_md_process:
+# Test MD2, MD4, MD5 and RIPEMD160
mbedtls_md2 Test vector RFC1319 #1
md2_text:"":"8350e5a3e24c153df2275c9f80692773"
/* BEGIN_CASE depends_on:MBEDTLS_MD2_C */
void md2_text( char *text_src_string, char *hex_hash_string )
{
+ int ret;
unsigned char src_str[100];
unsigned char hash_str[33];
unsigned char output[16];
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
- mbedtls_md2( src_str, strlen( (char *) src_str ), output );
+ ret = mbedtls_md2_ret( src_str, strlen( (char *) src_str ), output );
+ TEST_ASSERT( ret == 0 ) ;
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
/* BEGIN_CASE depends_on:MBEDTLS_MD4_C */
void md4_text( char *text_src_string, char *hex_hash_string )
{
+ int ret;
unsigned char src_str[100];
unsigned char hash_str[33];
unsigned char output[16];
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
- mbedtls_md4( src_str, strlen( (char *) src_str ), output );
+ ret = mbedtls_md4_ret( src_str, strlen( (char *) src_str ), output );
+ TEST_ASSERT( ret == 0 );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
/* BEGIN_CASE depends_on:MBEDTLS_MD5_C */
void md5_text( char *text_src_string, char *hex_hash_string )
{
+ int ret;
unsigned char src_str[100];
unsigned char hash_str[33];
unsigned char output[16];
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
- mbedtls_md5( src_str, strlen( (char *) src_str ), output );
+ ret = mbedtls_md5_ret( src_str, strlen( (char *) src_str ), output );
+ TEST_ASSERT( ret == 0 );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
/* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C */
void ripemd160_text( char *text_src_string, char *hex_hash_string )
{
+ int ret;
unsigned char src_str[100];
unsigned char hash_str[41];
unsigned char output[20];
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
- mbedtls_ripemd160( src_str, strlen( (char *) src_str ), output );
+ ret = mbedtls_ripemd160_ret( src_str, strlen( (char *) src_str ), output );
+ TEST_ASSERT( ret == 0 );
hexify( hash_str, output, sizeof output );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
Memory buffer alloc - Out of Memory test
memory_buffer_alloc_oom_test:
+Memory buffer small buffer
+memory_buffer_small_buffer:
+
+Memory buffer underalloc
+memory_buffer_underalloc:
}
/* END_CASE */
+/* BEGIN_CASE depends_on:MBEDTLS_MEMORY_DEBUG */
+void memory_buffer_small_buffer( )
+{
+ unsigned char buf[1];
+
+ mbedtls_memory_buffer_alloc_init( buf, sizeof( buf ) );
+ TEST_ASSERT( mbedtls_memory_buffer_alloc_verify() != 0 );
+}
+/* END_CASE */
+
+/* BEGIN_CASE depends_on:MBEDTLS_MEMORY_DEBUG */
+void memory_buffer_underalloc( )
+{
+ unsigned char buf[100];
+ size_t i;
+
+ mbedtls_memory_buffer_alloc_init( buf, sizeof( buf ) );
+ for( i = 1; i < MBEDTLS_MEMORY_ALIGN_MULTIPLE; i++ )
+ {
+ TEST_ASSERT( mbedtls_calloc( 1,
+ (size_t)-( MBEDTLS_MEMORY_ALIGN_MULTIPLE - i ) ) == NULL );
+ TEST_ASSERT( mbedtls_memory_buffer_alloc_verify() == 0 );
+ }
+
+exit:
+ mbedtls_memory_buffer_alloc_free();
+}
+/* END_CASE */
Test mpi_read_write_string #9 (Empty MPI -> dec)
mpi_read_write_string:16:"":10:"0":4:0:0
+Test mpi_write_string #10 (Negative hex with odd number of digits)
+mpi_read_write_string:16:"-1":16:"":3:0:MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL
+
Base test mbedtls_mpi_read_binary #1
mbedtls_mpi_read_binary:"0941379d00fed1491fe15df284dfde4a142f68aa8d412023195cee66883e6290ffe703f4ea5963bf212713cee46b107c09182b5edcd955adac418bf4918e2889af48e1099d513830cec85c26ac1e158b52620e33ba8692f893efbb2f958b4424":10:"56125680981752282334141896320372489490613963693556392520816017892111350604111697682705498319512049040516698827829292076808006940873974979584527073481012636016353913462376755556720019831187364993587901952757307830896531678727717924"
mbedtls_mpi_exp_mod:10:"433019240910377478217373572959560109819648647016096560523769010881172869083338285573756574557395862965095016483867813043663981946477698466501451832407592327356331263124555137732393938242285782144928753919588632679050799198937132922145084847":10:"5781538327977828897150909166778407659250458379645823062042492461576758526757490910073628008613977550546382774775570888130029763571528699574717583228939535960234464230882573615930384979100379102915657483866755371559811718767760594919456971354184113721":10:"583137007797276923956891216216022144052044091311388601652961409557516421612874571554415606746479105795833145583959622117418531166391184939066520869800857530421873250114773204354963864729386957427276448683092491947566992077136553066273207777134303397724679138833126700957":10:"":10:"114597449276684355144920670007147953232659436380163461553186940113929777196018164149703566472936578890991049344459204199888254907113495794730452699842273939581048142004834330369483813876618772578869083248061616444392091693787039636316845512292127097865026290173004860736":0
Test mbedtls_mpi_exp_mod (Negative base)
-mbedtls_mpi_exp_mod:10:"-10000000000":10:"10000000000":10:"99999":10:"":10:"99998":0
+mbedtls_mpi_exp_mod:10:"-10000000000":10:"10000000000":10:"99999":10:"":10:"1":0
Test mbedtls_mpi_exp_mod (Negative base)
mbedtls_mpi_exp_mod:16:"-9f13012cd92aa72fb86ac8879d2fde4f7fd661aaae43a00971f081cc60ca277059d5c37e89652e2af2585d281d66ef6a9d38a117e9608e9e7574cd142dc55278838a2161dd56db9470d4c1da2d5df15a908ee2eb886aaa890f23be16de59386663a12f1afbb325431a3e835e3fd89b98b96a6f77382f458ef9a37e1f84a03045c8676ab55291a94c2228ea15448ee96b626b998":16:"40a54d1b9e86789f06d9607fb158672d64867665c73ee9abb545fc7a785634b354c7bae5b962ce8040cf45f2c1f3d3659b2ee5ede17534c8fc2ec85c815e8df1fe7048d12c90ee31b88a68a081f17f0d8ce5f4030521e9400083bcea73a429031d4ca7949c2000d597088e0c39a6014d8bf962b73bb2e8083bd0390a4e00b9b3":16:"eeaf0ab9adb38dd69c33f80afa8fc5e86072618775ff3c0b9ea2314c9c256576d674df7496ea81d3383b4813d692c6e0e0d5d8e250b98be48e495c1d6089dad15dc7d7b46154d6b6ce8ef4ad69b15d4982559b297bcf1885c529f566660e57ec68edbc3c05726cc02fd4cbf4976eaa9afd5138fe8376435b9fc61d2fc0eb06e3":16:"":16:"21acc7199e1b90f9b4844ffe12c19f00ec548c5d32b21c647d48b6015d8eb9ec9db05b4f3d44db4227a2b5659c1a7cceb9d5fa8fa60376047953ce7397d90aaeb7465e14e820734f84aa52ad0fc66701bcbb991d57715806a11531268e1e83dd48288c72b424a6287e9ce4e5cc4db0dd67614aecc23b0124a5776d36e5c89483":0
Base test mbedtls_mpi_inv_mod #4
mbedtls_mpi_inv_mod:10:"2":10:"4":10:"0":MBEDTLS_ERR_MPI_NOT_ACCEPTABLE
+Base test mbedtls_mpi_inv_mod #5
+mbedtls_mpi_inv_mod:10:"3":10:"1":10:"0":MBEDTLS_ERR_MPI_BAD_INPUT_DATA
+
Test mbedtls_mpi_inv_mod #1
mbedtls_mpi_inv_mod:16:"aa4df5cb14b4c31237f98bd1faf527c283c2d0f3eec89718664ba33f9762907c":16:"fffbbd660b94412ae61ead9c2906a344116e316a256fd387874c6c675b1d587d":16:"8d6a5c1d7adeae3e94b9bcd2c47e0d46e778bc8804a2cc25c02d775dc3d05b0c":0
TEST_ASSERT( mbedtls_mpi_is_prime( &X, rnd_std_rand, NULL ) == 0 );
if( safe )
{
- mbedtls_mpi_shift_r( &X, 1 ); /* X = ( X - 1 ) / 2 */
+ /* X = ( X - 1 ) / 2 */
+ TEST_ASSERT( mbedtls_mpi_shift_r( &X, 1 ) == 0 );
TEST_ASSERT( mbedtls_mpi_is_prime( &X, rnd_std_rand, NULL ) == 0 );
}
}
PEM write (exactly two lines + 1)
mbedtls_pem_write_buffer:"-----START TEST-----\n":"-----END TEST-----\n":"000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F00":"-----START TEST-----\nAAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8AAQIDBAUGBwgJCgsMDQ4P\nAAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8AAQIDBAUGBwgJCgsMDQ4P\nAA==\n-----END TEST-----\n"
+
+PEM read (DES-EDE3-CBC + invalid iv)
+mbedtls_pem_read_buffer:"^":"$":"^\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: DES-EDE3-CBC,00$":"pwd":MBEDTLS_ERR_PEM_INVALID_ENC_IV
+
+PEM read (DES-CBC + invalid iv)
+mbedtls_pem_read_buffer:"^":"$":"^\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: DES-CBC,00$":"pwd":MBEDTLS_ERR_PEM_INVALID_ENC_IV
+
+PEM read (unknown encryption algorithm)
+mbedtls_pem_read_buffer:"^":"$":"^\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: AES-,00$":"pwd":MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG
+
+PEM read (malformed PEM DES-CBC)
+depends_on:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC
+mbedtls_pem_read_buffer:"-----BEGIN EC PRIVATE KEY-----":"-----END EC PRIVATE KEY-----":"-----BEGIN EC PRIVATE KEY-----\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: DES-CBC,AA94892A169FA426\n\nMAAA\n-----END EC PRIVATE KEY-----":"pwd":MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH
+
+PEM read (malformed PEM DES-EDE3-CBC)
+depends_on:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC
+mbedtls_pem_read_buffer:"-----BEGIN EC PRIVATE KEY-----":"-----END EC PRIVATE KEY-----":"-----BEGIN EC PRIVATE KEY-----\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: DES-EDE3-CBC,AA94892A169FA426\n\nMAAA\n-----END EC PRIVATE KEY-----":"pwd":MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH
+
+PEM read (malformed PEM AES-128-CBC)
+depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC
+mbedtls_pem_read_buffer:"-----BEGIN EC PRIVATE KEY-----":"-----END EC PRIVATE KEY-----":"-----BEGIN EC PRIVATE KEY-----\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: AES-128-CBC,AA94892A169FA426AA94892A169FA426\n\nMAAA\n-----END EC PRIVATE KEY-----":"pwd":MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
/* BEGIN_HEADER */
#include "mbedtls/base64.h"
#include "mbedtls/pem.h"
+#include "mbedtls/des.h"
+#include "mbedtls/aes.h"
/* END_HEADER */
-/* BEGIN_DEPENDENCIES
- * depends_on:MBEDTLS_PEM_WRITE_C
- * END_DEPENDENCIES
- */
-
-/* BEGIN_CASE */
+/* BEGIN_CASE depends_on:MBEDTLS_PEM_WRITE_C */
void mbedtls_pem_write_buffer( char *start, char *end, char *buf_str, char *result_str )
{
unsigned char buf[5000];
mbedtls_free( check_buf );
}
/* END_CASE */
+
+/* BEGIN_CASE depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_AES_C:MBEDTLS_DES_C:MBEDTLS_MD5_C:MBEDTLS_CIPHER_MODE_CBC */
+void mbedtls_pem_read_buffer( char *header, char *footer, char *data,
+ char *pwd, int res )
+{
+ mbedtls_pem_context ctx;
+ int ret;
+ size_t use_len = 0;
+ size_t pwd_len = strlen( pwd );
+
+ mbedtls_pem_init( &ctx );
+
+ ret = mbedtls_pem_read_buffer( &ctx, header, footer, (unsigned char *)data,
+ (unsigned char *)pwd, pwd_len, &use_len );
+ TEST_ASSERT( ret == res );
+
+exit:
+ mbedtls_pem_free( &ctx );
+}
+/* END_CASE */
depends_on:MBEDTLS_PKCS1_V21:MBEDTLS_SHA256_C
pk_rsa_verify_ext_test_vec:"54657374206d657373616765":MBEDTLS_MD_SHA256:1024:16:"00dd118a9f99bab068ca2aea3b6a6d5997ed4ec954e40deecea07da01eaae80ec2bb1340db8a128e891324a5c5f5fad8f590d7c8cacbc5fe931dafda1223735279461abaa0572b761631b3a8afe7389b088b63993a0a25ee45d21858bab9931aedd4589a631b37fcf714089f856549f359326dd1e0e86dde52ed66b4a90bda4095":16:"010001":"0d2bdb0456a3d651d5bd48a4204493898f72cf1aaddd71387cc058bc3f4c235ea6be4010fd61b28e1fbb275462b53775c04be9022d38b6a2e0387dddba86a3f8554d2858044a59fddbd594753fc056fe33c8daddb85dc70d164690b1182209ff84824e0be10e35c379f2f378bf176a9f7cb94d95e44d90276a298c8810f741c9":MBEDTLS_PK_RSASSA_PSS:-1:MBEDTLS_RSA_SALT_LEN_ANY:MBEDTLS_ERR_PK_BAD_INPUT_DATA
-Verify ext RSA #9 (PKCS1 v2.1, RSA with options)
+Verify ext RSA #9 (PKCS1 v1.5, RSA with options)
depends_on:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C
pk_rsa_verify_ext_test_vec:"54657374206d657373616765":MBEDTLS_MD_SHA256:1024:16:"00dd118a9f99bab068ca2aea3b6a6d5997ed4ec954e40deecea07da01eaae80ec2bb1340db8a128e891324a5c5f5fad8f590d7c8cacbc5fe931dafda1223735279461abaa0572b761631b3a8afe7389b088b63993a0a25ee45d21858bab9931aedd4589a631b37fcf714089f856549f359326dd1e0e86dde52ed66b4a90bda4095":16:"010001":"0d2bdb0456a3d651d5bd48a4204493898f72cf1aaddd71387cc058bc3f4c235ea6be4010fd61b28e1fbb275462b53775c04be9022d38b6a2e0387dddba86a3f8554d2858044a59fddbd594753fc056fe33c8daddb85dc70d164690b1182209ff84824e0be10e35c379f2f378bf176a9f7cb94d95e44d90276a298c8810f741c9":MBEDTLS_PK_RSA:MBEDTLS_MD_SHA256:MBEDTLS_RSA_SALT_LEN_ANY:MBEDTLS_ERR_PK_BAD_INPUT_DATA
-Verify ext RSA #10 (PKCS1 v2.1, RSA without options)
+Verify ext RSA #10 (PKCS1 v1.5, RSA without options)
depends_on:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C
-pk_rsa_verify_ext_test_vec:"54657374206d657373616765":MBEDTLS_MD_SHA256:1024:16:"00dd118a9f99bab068ca2aea3b6a6d5997ed4ec954e40deecea07da01eaae80ec2bb1340db8a128e891324a5c5f5fad8f590d7c8cacbc5fe931dafda1223735279461abaa0572b761631b3a8afe7389b088b63993a0a25ee45d21858bab9931aedd4589a631b37fcf714089f856549f359326dd1e0e86dde52ed66b4a90bda4095":16:"010001":"0d2bdb0456a3d651d5bd48a4204493898f72cf1aaddd71387cc058bc3f4c235ea6be4010fd61b28e1fbb275462b53775c04be9022d38b6a2e0387dddba86a3f8554d2858044a59fddbd594753fc056fe33c8daddb85dc70d164690b1182209ff84824e0be10e35c379f2f378bf176a9f7cb94d95e44d90276a298c8810f741c9":MBEDTLS_PK_RSA:-1:MBEDTLS_RSA_SALT_LEN_ANY:MBEDTLS_ERR_RSA_INVALID_PADDING
+pk_rsa_verify_ext_test_vec:"54657374206d657373616765":MBEDTLS_MD_SHA256:1024:16:"00dd118a9f99bab068ca2aea3b6a6d5997ed4ec954e40deecea07da01eaae80ec2bb1340db8a128e891324a5c5f5fad8f590d7c8cacbc5fe931dafda1223735279461abaa0572b761631b3a8afe7389b088b63993a0a25ee45d21858bab9931aedd4589a631b37fcf714089f856549f359326dd1e0e86dde52ed66b4a90bda4095":16:"010001":"0d2bdb0456a3d651d5bd48a4204493898f72cf1aaddd71387cc058bc3f4c235ea6be4010fd61b28e1fbb275462b53775c04be9022d38b6a2e0387dddba86a3f8554d2858044a59fddbd594753fc056fe33c8daddb85dc70d164690b1182209ff84824e0be10e35c379f2f378bf176a9f7cb94d95e44d90276a298c8810f741c9":MBEDTLS_PK_RSA:-1:MBEDTLS_RSA_SALT_LEN_ANY:MBEDTLS_ERR_RSA_VERIFY_FAILED
Verify ext RSA #11 (PKCS1 v2.1, asking for ECDSA)
depends_on:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C
depends_on:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_RSA_C
mbedtls_pk_check_pair:"data_files/ec_256_pub.pem":"data_files/server1.key":MBEDTLS_ERR_PK_TYPE_MISMATCH
+RSA hash_len overflow (size_t vs unsigned int)
+depends_on:MBEDTLS_RSA_C:MBEDTLS_HAVE_INT64
+pk_rsa_overflow:
#include "mbedtls/ecp.h"
#include "mbedtls/rsa.h"
+#include <limits.h>
+#include <stdint.h>
+
static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len );
#define RSA_KEY_SIZE 512
const unsigned char *input, unsigned char *output,
size_t output_max_len )
{
- return( mbedtls_rsa_pkcs1_decrypt( (mbedtls_rsa_context *) ctx, NULL, NULL, mode, olen,
- input, output, output_max_len ) );
+ return( mbedtls_rsa_pkcs1_decrypt( (mbedtls_rsa_context *) ctx,
+ rnd_std_rand, NULL, mode, olen,
+ input, output, output_max_len ) );
}
int mbedtls_rsa_sign_func( void *ctx,
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
int mode, mbedtls_md_type_t md_alg, unsigned int hashlen,
const unsigned char *hash, unsigned char *sig )
{
- return( mbedtls_rsa_pkcs1_sign( (mbedtls_rsa_context *) ctx, f_rng, p_rng, mode,
+ ((void) f_rng);
+ ((void) p_rng);
+ return( mbedtls_rsa_pkcs1_sign( (mbedtls_rsa_context *) ctx, rnd_std_rand, NULL, mode,
md_alg, hashlen, hash, sig ) );
}
size_t mbedtls_rsa_key_len_func( void *ctx )
if( mbedtls_pk_get_type( &prv ) == MBEDTLS_PK_RSA )
{
TEST_ASSERT( mbedtls_pk_setup_rsa_alt( &alt, mbedtls_pk_rsa( prv ),
- mbedtls_rsa_decrypt_func, mbedtls_rsa_sign_func, mbedtls_rsa_key_len_func ) == 0 );
+ mbedtls_rsa_decrypt_func, mbedtls_rsa_sign_func,
+ mbedtls_rsa_key_len_func ) == 0 );
TEST_ASSERT( mbedtls_pk_check_pair( &pub, &alt ) == ret );
}
#endif
unsigned char cipher[1000];
size_t clear_len, olen, cipher_len;
rnd_pseudo_info rnd_info;
- mbedtls_mpi P1, Q1, H, G;
+ mbedtls_mpi N, P, Q, E;
mbedtls_rsa_context *rsa;
mbedtls_pk_context pk;
mbedtls_pk_init( &pk );
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P );
+ mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E );
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
memset( clear, 0, sizeof( clear ) );
memset( cipher, 0, sizeof( cipher ) );
- clear_len = unhexify( clear, clear_hex );
+ clear_len = unhexify( clear, clear_hex );
cipher_len = unhexify( cipher, cipher_hex );
/* init pk-rsa context */
rsa = mbedtls_pk_rsa( pk );
/* load public key */
- rsa->len = mod / 8;
- TEST_ASSERT( mbedtls_mpi_read_string( &rsa->N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &rsa->E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
/* load private key */
- TEST_ASSERT( mbedtls_mpi_read_string( &rsa->P, radix_P, input_P ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &rsa->Q, radix_Q, input_Q ) == 0 );
- TEST_ASSERT( mbedtls_mpi_sub_int( &P1, &rsa->P, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_sub_int( &Q1, &rsa->Q, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_gcd( &G, &rsa->E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &rsa->D , &rsa->E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &rsa->DP, &rsa->D, &P1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &rsa->DQ, &rsa->D, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &rsa->QP, &rsa->Q, &rsa->P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( rsa, &N, &P, &Q, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( rsa ) == (size_t) ( mod / 8 ) );
+ TEST_ASSERT( mbedtls_rsa_complete( rsa ) == 0 );
/* decryption test */
memset( output, 0, sizeof( output ) );
}
exit:
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P );
+ mbedtls_mpi_free( &Q ); mbedtls_mpi_free( &E );
mbedtls_pk_free( &pk );
}
/* END_CASE */
}
/* END_CASE */
+/* BEGIN_CASE depends_on:MBEDTLS_RSA_C */
+void pk_rsa_overflow( )
+{
+ mbedtls_pk_context pk;
+ size_t hash_len = SIZE_MAX, sig_len = SIZE_MAX;
+ unsigned char hash[50], sig[100];
+
+ if( SIZE_MAX <= UINT_MAX )
+ return;
+
+ memset( hash, 0x2a, sizeof hash );
+ memset( sig, 0, sizeof sig );
+
+ mbedtls_pk_init( &pk );
+
+ TEST_ASSERT( mbedtls_pk_setup( &pk,
+ mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == 0 );
+
+#if defined(MBEDTLS_PKCS1_V21)
+ TEST_ASSERT( mbedtls_pk_verify_ext( MBEDTLS_PK_RSASSA_PSS, NULL, &pk,
+ MBEDTLS_MD_NONE, hash, hash_len, sig, sig_len ) ==
+ MBEDTLS_ERR_PK_BAD_INPUT_DATA );
+#endif /* MBEDTLS_PKCS1_V21 */
+
+ TEST_ASSERT( mbedtls_pk_verify( &pk, MBEDTLS_MD_NONE, hash, hash_len,
+ sig, sig_len ) == MBEDTLS_ERR_PK_BAD_INPUT_DATA );
+
+ TEST_ASSERT( mbedtls_pk_sign( &pk, MBEDTLS_MD_NONE, hash, hash_len, sig, &sig_len,
+ rnd_std_rand, NULL ) == MBEDTLS_ERR_PK_BAD_INPUT_DATA );
+
+exit:
+ mbedtls_pk_free( &pk );
+}
+/* END_CASE */
+
/* BEGIN_CASE depends_on:MBEDTLS_RSA_C:MBEDTLS_PK_RSA_ALT_SUPPORT */
void pk_rsa_alt( )
{
TEST_ASSERT( strcmp( mbedtls_pk_get_name( &alt ), "RSA-alt" ) == 0 );
/* Test signature */
+#if SIZE_MAX > UINT_MAX
+ TEST_ASSERT( mbedtls_pk_sign( &alt, MBEDTLS_MD_NONE, hash, SIZE_MAX,
+ sig, &sig_len, rnd_std_rand, NULL ) ==
+ MBEDTLS_ERR_PK_BAD_INPUT_DATA );
+#endif /* SIZE_MAX > UINT_MAX */
TEST_ASSERT( mbedtls_pk_sign( &alt, MBEDTLS_MD_NONE, hash, sizeof hash,
- sig, &sig_len, rnd_std_rand, NULL ) == 0 );
+ sig, &sig_len, rnd_std_rand, NULL ) == 0 );
TEST_ASSERT( sig_len == RSA_KEY_LEN );
TEST_ASSERT( mbedtls_pk_verify( &rsa, MBEDTLS_MD_NONE,
hash, sizeof hash, sig, sig_len ) == 0 );
mbedtls_rsa_context ctx;
size_t msg_len;
rnd_buf_info info;
+ mbedtls_mpi N, E;
info.length = unhexify( rnd_buf, seed );
info.buf = rnd_buf;
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, hash );
memset( message_str, 0x00, 1000 );
memset( output, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
- ctx.len = mod / 8 + ( ( mod % 8 ) ? 1 : 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
msg_len = unhexify( message_str, message_hex_string );
}
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
unsigned char output[1000];
unsigned char output_str[1000];
mbedtls_rsa_context ctx;
- mbedtls_mpi P1, Q1, H, G;
size_t output_len;
rnd_pseudo_info rnd_info;
+ mbedtls_mpi N, P, Q, E;
((void) seed);
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P );
+ mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, hash );
memset( message_str, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
- ctx.len = mod / 8 + ( ( mod % 8 ) ? 1 : 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.P, radix_P, input_P ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.Q, radix_Q, input_Q ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
- TEST_ASSERT( mbedtls_mpi_sub_int( &P1, &ctx.P, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_sub_int( &Q1, &ctx.Q, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_gcd( &G, &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.D , &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DP, &ctx.D, &P1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DQ, &ctx.D, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.QP, &ctx.Q, &ctx.P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
unhexify( message_str, message_hex_string );
}
exit:
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P );
+ mbedtls_mpi_free( &Q ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
unsigned char output_str[1000];
unsigned char rnd_buf[1000];
mbedtls_rsa_context ctx;
- mbedtls_mpi P1, Q1, H, G;
+ mbedtls_mpi N, P, Q, E;
size_t msg_len;
rnd_buf_info info;
info.length = unhexify( rnd_buf, salt );
info.buf = rnd_buf;
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P );
+ mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, hash );
memset( message_str, 0x00, 1000 );
memset( output, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
- ctx.len = mod / 8 + ( ( mod % 8 ) ? 1 : 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.P, radix_P, input_P ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.Q, radix_Q, input_Q ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
- TEST_ASSERT( mbedtls_mpi_sub_int( &P1, &ctx.P, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_sub_int( &Q1, &ctx.Q, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_gcd( &G, &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.D , &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DP, &ctx.D, &P1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DQ, &ctx.D, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.QP, &ctx.Q, &ctx.P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
msg_len = unhexify( message_str, message_hex_string );
}
exit:
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P );
+ mbedtls_mpi_free( &Q ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
unsigned char result_str[1000];
mbedtls_rsa_context ctx;
size_t msg_len;
+ mbedtls_mpi N, E;
((void) salt);
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, hash );
memset( message_str, 0x00, 1000 );
memset( hash_result, 0x00, 1000 );
memset( result_str, 0x00, 1000 );
- ctx.len = mod / 8 + ( ( mod % 8 ) ? 1 : 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
msg_len = unhexify( message_str, message_hex_string );
unhexify( result_str, result_hex_str );
if( mbedtls_md_info_from_type( digest ) != NULL )
- TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str, msg_len, hash_result ) == 0 );
+ TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ),
+ message_str, msg_len, hash_result ) == 0 );
- TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, digest, 0, hash_result, result_str ) == result );
+ TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC,
+ digest, 0, hash_result,
+ result_str ) == result );
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
depends_on:MBEDTLS_SHA256_C
pkcs1_rsassa_pss_verify_ext:1024:16:"00dd118a9f99bab068ca2aea3b6a6d5997ed4ec954e40deecea07da01eaae80ec2bb1340db8a128e891324a5c5f5fad8f590d7c8cacbc5fe931dafda1223735279461abaa0572b761631b3a8afe7389b088b63993a0a25ee45d21858bab9931aedd4589a631b37fcf714089f856549f359326dd1e0e86dde52ed66b4a90bda4095":16:"010001":MBEDTLS_MD_NONE:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA1:MBEDTLS_RSA_SALT_LEN_ANY:"c0719e9a8d5d838d861dc6f675c899d2b309a3a65bb9fe6b11e5afcbf9a2c0b1":"7fc506d26ca3b22922a1ce39faaedd273161b82d9443c56f1a034f131ae4a18cae1474271cb4b66a17d9707ca58b0bdbd3c406b7e65bbcc9bbbce94dc45de807b4989b23b3e4db74ca29298137837eb90cc83d3219249bc7d480fceaf075203a86e54c4ecfa4e312e39f8f69d76534089a36ed9049ca9cfd5ab1db1fa75fe5c8":0:MBEDTLS_ERR_RSA_INVALID_PADDING
+RSASSA-PSS verify ext, 512-bit key, empty salt, good signature
+depends_on:MBEDTLS_SHA256_C
+pkcs1_rsassa_pss_verify_ext:512:16:"00b076d23250816f9aab02307e452b97f0cae7598369b41624e8afc7971a59a13892f64b07eaa6ec928c160b2d6ec8f9d0dd5b63c8b3ac0767b4f65c892f56c10f":16:"010001":MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA256:0:"":"ace8b03347da1b9a7a5e94a0d76359bb39c819bb170bef38ea84995ed653446c0ae87ede434cdf9d0cb2d7bf164cf427892363e6855a1d24d0ce5dd72acaf246":0:0
+
+RSASSA-PSS verify ext, 512-bit key, empty salt, bad signature
+depends_on:MBEDTLS_SHA256_C
+pkcs1_rsassa_pss_verify_ext:512:16:"00b076d23250816f9aab02307e452b97f0cae7598369b41624e8afc7971a59a13892f64b07eaa6ec928c160b2d6ec8f9d0dd5b63c8b3ac0767b4f65c892f56c10f":16:"010001":MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA256:0:"":"ace8b03347da1b9a7a5e94a0d76359bb39c819bb170bef38ea84995ed653446c0ae87ede434cdf9d0cb2d7bf164cf427892363e6855a1d24d0ce5dd72acaf247":MBEDTLS_ERR_RSA_INVALID_PADDING:MBEDTLS_ERR_RSA_INVALID_PADDING
+
+RSASSA-PSS verify ext, 522-bit key, SHA-512, empty salt, good signature
+depends_on:MBEDTLS_SHA512_C
+pkcs1_rsassa_pss_verify_ext:522:16:"02d302753e3dda28f42f4d9f92c8647420ea6fbc97c10f8498b966a953f357698d6581060dfe32c8ab98db4bc5ce2acdf0c1e6e404a75a13282550c1aa37d3cdc8bf":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:0:"":"016752ae0b5dfbade6bbd3dd37868d48c8d741f92dca41c360aeda553204c2212a117b1a3d77e0d3f48723503c46e16c8a64de00f1dee3e37e478417452630859486":0:0
+
+RSASSA-PSS verify ext, 528-bit key, SHA-512, saltlen=64, good signature with saltlen=0
+depends_on:MBEDTLS_SHA512_C
+pkcs1_rsassa_pss_verify_ext:528:16:"00e31c246d46485984261fd174cab3d4357344602ecd793c47dbe54252d37bb350bc634359b19515542080e4724a4b672291be57c7648f51629eaef234e847d99cc65f":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:64:"":"a9ad7994ba3a1071124153486924448cc67a5af3a5d34e9261d53770782cc85f58e2edde5f7004652a645e3e9606530eb57de41df7298ae2be9dec69cc0d613ab629":0:MBEDTLS_ERR_RSA_INVALID_PADDING
+
+RSASSA-PSS verify ext, 528-bit key, SHA-512, empty salt, good signature
+depends_on:MBEDTLS_SHA512_C
+pkcs1_rsassa_pss_verify_ext:528:16:"00e31c246d46485984261fd174cab3d4357344602ecd793c47dbe54252d37bb350bc634359b19515542080e4724a4b672291be57c7648f51629eaef234e847d99cc65f":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:0:"":"a9ad7994ba3a1071124153486924448cc67a5af3a5d34e9261d53770782cc85f58e2edde5f7004652a645e3e9606530eb57de41df7298ae2be9dec69cc0d613ab629":0:0
+
+RSASSA-PSS verify ext, 528-bit key, SHA-512, saltlen=64, good signature with saltlen=0
+depends_on:MBEDTLS_SHA512_C
+pkcs1_rsassa_pss_verify_ext:528:16:"00e31c246d46485984261fd174cab3d4357344602ecd793c47dbe54252d37bb350bc634359b19515542080e4724a4b672291be57c7648f51629eaef234e847d99cc65f":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:64:"":"a9ad7994ba3a1071124153486924448cc67a5af3a5d34e9261d53770782cc85f58e2edde5f7004652a645e3e9606530eb57de41df7298ae2be9dec69cc0d613ab629":0:MBEDTLS_ERR_RSA_INVALID_PADDING
+
+RSASSA-PSS verify ext, 512-bit key, SHA-512 (hash too large)
+depends_on:MBEDTLS_SHA512_C
+pkcs1_rsassa_pss_verify_ext:512:16:"00b076d23250816f9aab02307e452b97f0cae7598369b41624e8afc7971a59a13892f64b07eaa6ec928c160b2d6ec8f9d0dd5b63c8b3ac0767b4f65c892f56c10f":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:0:"":"ace8b03347da1b9a7a5e94a0d76359bb39c819bb170bef38ea84995ed653446c0ae87ede434cdf9d0cb2d7bf164cf427892363e6855a1d24d0ce5dd72acaf246":MBEDTLS_ERR_RSA_BAD_INPUT_DATA:MBEDTLS_ERR_RSA_BAD_INPUT_DATA
+
+RSASSA-PSS verify ext, 521-bit key, SHA-512, empty salt, bad signature
+depends_on:MBEDTLS_SHA512_C
+pkcs1_rsassa_pss_verify_ext:521:16:"0131b69860f3cb9bf85ea358fdf2bd2990f1b77a80d6a4fdf817a43dd896bdf7dd26af8ac0237f526e0d33b105c971fdbd4ffa9ece99fc469f31ecf429e8f562c1c3":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:0:"":"00471794655837da498cbf27242807b40593a353c707eb22fd2cc5a3259e728ac4f1df676043eeec8e16c1175b3d9ac8cae72ec1d5772dd69de71c5677f19031568e":MBEDTLS_ERR_RSA_BAD_INPUT_DATA:MBEDTLS_ERR_RSA_BAD_INPUT_DATA
+
+RSASSA-PSS verify ext, 521-bit key, SHA-256, empty salt, good signature
+depends_on:MBEDTLS_SHA256_C
+pkcs1_rsassa_pss_verify_ext:521:16:"0131b69860f3cb9bf85ea358fdf2bd2990f1b77a80d6a4fdf817a43dd896bdf7dd26af8ac0237f526e0d33b105c971fdbd4ffa9ece99fc469f31ecf429e8f562c1c3":16:"010001":MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA256:0:"41":"009c4941157fa36288e467310b198ab0c615c40963d611ffeef03000549ded809235955ecc57adba44782e9497c004f480ba2b3d58db8335fe0b391075c02c843a6d":0:0
+
+RSASSA-PSS verify ext, 521-bit key, SHA-256, empty salt, flipped-highest-bit signature
+depends_on:MBEDTLS_SHA256_C
+pkcs1_rsassa_pss_verify_ext:521:16:"0131b69860f3cb9bf85ea358fdf2bd2990f1b77a80d6a4fdf817a43dd896bdf7dd26af8ac0237f526e0d33b105c971fdbd4ffa9ece99fc469f31ecf429e8f562c1c3":16:"010001":MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA256:0:"41":"00e11a2403df681c44a1f73f014b6c9ad17847d0b673f7c2a801cee208d10ab5792c10cd0cd495a4b331aaa521409fca7cb1b0d978b3a84cd67e28078b98753e9466":MBEDTLS_ERR_RSA_BAD_INPUT_DATA:MBEDTLS_ERR_RSA_BAD_INPUT_DATA
+
+RSASSA-PSS verify ext, all-zero padding, automatic salt length
+depends_on:MBEDTLS_SHA256_C
+pkcs1_rsassa_pss_verify_ext:512:16:"00b076d23250816f9aab02307e452b97f0cae7598369b41624e8afc7971a59a13892f64b07eaa6ec928c160b2d6ec8f9d0dd5b63c8b3ac0767b4f65c892f56c10f":16:"010001":MBEDTLS_MD_NONE:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA256:MBEDTLS_RSA_SALT_LEN_ANY:"":"63a35294577c7e593170378175b7df27c293dae583ec2a971426eb2d66f2af483e897bfae5dc20300a9d61a3644e08c3aee61a463690a3498901563c46041056":MBEDTLS_ERR_RSA_INVALID_PADDING:MBEDTLS_ERR_RSA_INVALID_PADDING
+
mbedtls_rsa_context ctx;
size_t msg_len;
rnd_buf_info info;
+ mbedtls_mpi N, E;
info.length = unhexify( rnd_buf, seed );
info.buf = rnd_buf;
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V21, hash );
memset( message_str, 0x00, 1000 );
memset( output, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
- ctx.len = mod / 8 + ( ( mod % 8 ) ? 1 : 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
msg_len = unhexify( message_str, message_hex_string );
}
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
unsigned char output[1000];
unsigned char output_str[1000];
mbedtls_rsa_context ctx;
- mbedtls_mpi P1, Q1, H, G;
size_t output_len;
rnd_pseudo_info rnd_info;
+ mbedtls_mpi N, P, Q, E;
((void) seed);
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P );
+ mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E );
+
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V21, hash );
memset( message_str, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
- ctx.len = mod / 8 + ( ( mod % 8 ) ? 1 : 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.P, radix_P, input_P ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.Q, radix_Q, input_Q ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
- TEST_ASSERT( mbedtls_mpi_sub_int( &P1, &ctx.P, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_sub_int( &Q1, &ctx.Q, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_gcd( &G, &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.D , &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DP, &ctx.D, &P1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DQ, &ctx.D, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.QP, &ctx.Q, &ctx.P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
unhexify( message_str, message_hex_string );
}
exit:
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P );
+ mbedtls_mpi_free( &Q ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
unsigned char output_str[1000];
unsigned char rnd_buf[1000];
mbedtls_rsa_context ctx;
- mbedtls_mpi P1, Q1, H, G;
size_t msg_len;
rnd_buf_info info;
+ mbedtls_mpi N, P, Q, E;
info.length = unhexify( rnd_buf, salt );
info.buf = rnd_buf;
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P );
+ mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V21, hash );
memset( message_str, 0x00, 1000 );
memset( output, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
- ctx.len = mod / 8 + ( ( mod % 8 ) ? 1 : 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.P, radix_P, input_P ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.Q, radix_Q, input_Q ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
- TEST_ASSERT( mbedtls_mpi_sub_int( &P1, &ctx.P, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_sub_int( &Q1, &ctx.Q, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_gcd( &G, &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.D , &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DP, &ctx.D, &P1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DQ, &ctx.D, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.QP, &ctx.Q, &ctx.P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
msg_len = unhexify( message_str, message_hex_string );
if( mbedtls_md_info_from_type( digest ) != NULL )
- TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str, msg_len, hash_result ) == 0 );
+ TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str,
+ msg_len, hash_result ) == 0 );
- TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PRIVATE, digest, 0, hash_result, output ) == result );
+ TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PRIVATE,
+ digest, 0, hash_result, output ) == result );
if( result == 0 )
{
hexify( output_str, output, ctx.len);
}
exit:
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P );
+ mbedtls_mpi_free( &Q ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
unsigned char result_str[1000];
mbedtls_rsa_context ctx;
size_t msg_len;
+ mbedtls_mpi N, E;
((void) salt);
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V21, hash );
memset( message_str, 0x00, 1000 );
memset( hash_result, 0x00, 1000 );
memset( result_str, 0x00, 1000 );
- ctx.len = mod / 8 + ( ( mod % 8 ) ? 1 : 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
msg_len = unhexify( message_str, message_hex_string );
unhexify( result_str, result_hex_str );
if( mbedtls_md_info_from_type( digest ) != NULL )
- TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str, msg_len, hash_result ) == 0 );
+ TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str,
+ msg_len, hash_result ) == 0 );
- TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, digest, 0, hash_result, result_str ) == result );
+ TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC,
+ digest, 0, hash_result, result_str ) == result );
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
unsigned char result_str[1000];
mbedtls_rsa_context ctx;
size_t msg_len, hash_len;
+ mbedtls_mpi N, E;
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V21, ctx_hash );
memset( message_str, 0x00, 1000 );
memset( hash_result, 0x00, 1000 );
memset( result_str, 0x00, 1000 );
- ctx.len = mod / 8 + ( ( mod % 8 ) ? 1 : 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
msg_len = unhexify( message_str, message_hex_string );
result_str ) == result_full );
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
depends_on:MBEDTLS_SHA1_C
pbkdf2_hmac:MBEDTLS_MD_SHA1:"7061737300776f7264":"7361006c74":4096:16:"56fa6aa75548099dcc37d7f03425e0c3"
+PBKDF2 Python hashlib Test Vector #1 (SHA224)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA224:"70617373776f7264":"73616c74":1:20:"3c198cbdb9464b7857966bd05b7bc92bc1cc4e6e"
+
+PBKDF2 Python hashlib Test Vector #2 (SHA224)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA224:"70617373776f7264":"73616c74":2:20:"93200ffa96c5776d38fa10abdf8f5bfc0054b971"
+
+PBKDF2 Python hashlib Test Vector #3 (SHA224)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA224:"70617373776f7264":"73616c74":4096:20:"218c453bf90635bd0a21a75d172703ff6108ef60"
+
+PBKDF2 Python hashlib Test Vector #5 (SHA224)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA224:"70617373776f726450415353574f524470617373776f7264":"73616c7453414c5473616c7453414c5473616c7453414c5473616c7453414c5473616c74":4096:25:"056c4ba438ded91fc14e0594e6f52b87e1f3690c0dc0fbc057"
+
+PBKDF2 Python hashlib Test Vector #6 (SHA224)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA224:"7061737300776f7264":"7361006c74":4096:16:"9b4011b641f40a2a500a31d4a392d15c"
+
+PBKDF2 RFC 7914 Sec 11 Test Vector #1 (SHA256)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA256:"706173737764":"73616c74":1:64:"55ac046e56e3089fec1691c22544b605f94185216dde0465e68b9d57c20dacbc49ca9cccf179b645991664b39d77ef317c71b845b1e30bd509112041d3a19783"
+
+PBKDF2 RFC 7914 Sec 11 Test Vector #2 (SHA256)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA256:"50617373776f7264":"4e61436c":80000:64:"4ddcd8f60b98be21830cee5ef22701f9641a4418d04c0414aeff08876b34ab56a1d425a1225833549adb841b51c9b3176a272bdebba1d078478f62b397f33c8d"
+
+PBKDF2 Python hashlib Test Vector #1 (SHA256)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA256:"70617373776f7264":"73616c74":1:20:"120fb6cffcf8b32c43e7225256c4f837a86548c9"
+
+PBKDF2 Python hashlib Test Vector #2 (SHA256)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA256:"70617373776f7264":"73616c74":2:20:"ae4d0c95af6b46d32d0adff928f06dd02a303f8e"
+
+PBKDF2 Python hashlib Test Vector #3 (SHA256)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA256:"70617373776f7264":"73616c74":4096:20:"c5e478d59288c841aa530db6845c4c8d962893a0"
+
+PBKDF2 Python hashlib Test Vector #5 (SHA256)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA256:"70617373776f726450415353574f524470617373776f7264":"73616c7453414c5473616c7453414c5473616c7453414c5473616c7453414c5473616c74":4096:25:"348c89dbcbd32b2f32d814b8116e84cf2b17347ebc1800181c"
+
+PBKDF2 Python hashlib Test Vector #6 (SHA256)
+depends_on:MBEDTLS_SHA256_C
+pbkdf2_hmac:MBEDTLS_MD_SHA256:"7061737300776f7264":"7361006c74":4096:16:"89b69d0516f829893c696226650a8687"
+
+PBKDF2 Python hashlib Test Vector #1 (SHA384)
+depends_on:MBEDTLS_SHA512_C
+pbkdf2_hmac:MBEDTLS_MD_SHA384:"70617373776f7264":"73616c74":1:20:"c0e14f06e49e32d73f9f52ddf1d0c5c719160923"
+
+PBKDF2 Python hashlib Test Vector #2 (SHA384)
+depends_on:MBEDTLS_SHA512_C
+pbkdf2_hmac:MBEDTLS_MD_SHA384:"70617373776f7264":"73616c74":2:20:"54f775c6d790f21930459162fc535dbf04a93918"
+
+PBKDF2 Python hashlib Test Vector #3 (SHA384)
+depends_on:MBEDTLS_SHA512_C
+pbkdf2_hmac:MBEDTLS_MD_SHA384:"70617373776f7264":"73616c74":4096:20:"559726be38db125bc85ed7895f6e3cf574c7a01c"
+
+PBKDF2 Python hashlib Test Vector #5 (SHA384)
+depends_on:MBEDTLS_SHA512_C
+pbkdf2_hmac:MBEDTLS_MD_SHA384:"70617373776f726450415353574f524470617373776f7264":"73616c7453414c5473616c7453414c5473616c7453414c5473616c7453414c5473616c74":4096:25:"819143ad66df9a552559b9e131c52ae6c5c1b0eed18f4d283b"
+
+PBKDF2 Python hashlib Test Vector #6 (SHA384)
+depends_on:MBEDTLS_SHA512_C
+pbkdf2_hmac:MBEDTLS_MD_SHA384:"7061737300776f7264":"7361006c74":4096:16:"a3f00ac8657e095f8e0823d232fc60b3"
+
+PBKDF2 Python hashlib Test Vector #1 (SHA512)
+depends_on:MBEDTLS_SHA512_C
+pbkdf2_hmac:MBEDTLS_MD_SHA512:"70617373776f7264":"73616c74":1:20:"867f70cf1ade02cff3752599a3a53dc4af34c7a6"
+
+PBKDF2 Python hashlib Test Vector #2 (SHA512)
+depends_on:MBEDTLS_SHA512_C
+pbkdf2_hmac:MBEDTLS_MD_SHA512:"70617373776f7264":"73616c74":2:20:"e1d9c16aa681708a45f5c7c4e215ceb66e011a2e"
+
+PBKDF2 Python hashlib Test Vector #3 (SHA512)
+depends_on:MBEDTLS_SHA512_C
+pbkdf2_hmac:MBEDTLS_MD_SHA512:"70617373776f7264":"73616c74":4096:20:"d197b1b33db0143e018b12f3d1d1479e6cdebdcc"
+
+PBKDF2 Python hashlib Test Vector #5 (SHA512)
+depends_on:MBEDTLS_SHA512_C
+pbkdf2_hmac:MBEDTLS_MD_SHA512:"70617373776f726450415353574f524470617373776f7264":"73616c7453414c5473616c7453414c5473616c7453414c5473616c7453414c5473616c74":4096:25:"8c0511f4c6e597c6ac6315d8f0362e225f3c501495ba23b868"
+
+PBKDF2 Python hashlib Test Vector #6 (SHA512)
+depends_on:MBEDTLS_SHA512_C
+pbkdf2_hmac:MBEDTLS_MD_SHA512:"7061737300776f7264":"7361006c74":4096:16:"9d9e9c4cd21fe4be24d5b8244c759665"
+
PBES2 Decrypt (OK)
depends_on:MBEDTLS_SHA1_C:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC
mbedtls_pkcs5_pbes2:MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:"301B06092A864886F70D01050C300E04082ED7F24A1D516DD702020800301406082A864886F70D030704088A4FCC9DCC394910":"70617373776f7264":"1B60098D4834CA752D37B430E70B7A085CFF86E21F4849F969DD1DF623342662443F8BD1252BF83CEF6917551B08EF55A69C8F2BFFC93BCB2DFE2E354DA28F896D1BD1BFB972A1251219A6EC7183B0A4CF2C4998449ED786CAE2138437289EB2203974000C38619DA57A4E685D29649284602BD1806131772DA11A682674DC22B2CF109128DDB7FD980E1C5741FC0DB7":0:"308187020100301306072A8648CE3D020106082A8648CE3D030107046D306B0201010420F12A1320760270A83CBFFD53F6031EF76A5D86C8A204F2C30CA9EBF51F0F0EA7A1440342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFF060606060606"
depends_on:MBEDTLS_SHA1_C:MBEDTLS_DES_C
mbedtls_pkcs5_pbes2:MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:"301D06092A864886F70D01050C301004082ED7F24A1D516DD7020208003001":"":"":MBEDTLS_ERR_PKCS5_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA:""
-PBES2 Decrypt (bad, PBKDF2 params explicit prf_alg != HMAC-SHA1)
+PBES2 Decrypt (bad, PBKDF2 params explicit prf_alg != HMAC-SHA*)
depends_on:MBEDTLS_SHA1_C:MBEDTLS_DES_C
-mbedtls_pkcs5_pbes2:MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:"302706092A864886F70D01050C301A04082ED7F24A1D516DD702020800300A06082A864886F70D0208":"":"":MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE:""
+mbedtls_pkcs5_pbes2:MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:"302706092A864886F70D01050C301A04082ED7F24A1D516DD702020800300A06082A864886F70D0206":"":"":MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE:""
PBES2 Decrypt (bad, PBKDF2 params extra data)
depends_on:MBEDTLS_SHA1_C:MBEDTLS_DES_C
{
unsigned char pw_str[100];
unsigned char salt_str[100];
- unsigned char dst_str[100];
+ unsigned char dst_str[200];
mbedtls_md_context_t ctx;
const mbedtls_md_info_t *info;
mbedtls_md_init( &ctx );
- memset(pw_str, 0x00, 100);
- memset(salt_str, 0x00, 100);
- memset(dst_str, 0x00, 100);
+ memset(pw_str, 0x00, sizeof(pw_str));
+ memset(salt_str, 0x00, sizeof(salt_str));
+ memset(dst_str, 0x00, sizeof(dst_str));
pw_len = unhexify( pw_str, hex_password_string );
salt_len = unhexify( salt_str, hex_salt_string );
Parse RSA Key #1 (No password when required)
-depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_DES_C
pk_parse_keyfile_rsa:"data_files/test-ca.key":"NULL":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
Parse RSA Key #2 (Correct password)
-depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_DES_C
pk_parse_keyfile_rsa:"data_files/test-ca.key":"PolarSSLTest":0
Parse RSA Key #3 (Wrong password)
-depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_DES_C
pk_parse_keyfile_rsa:"data_files/test-ca.key":"PolarSSLWRONG":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
Parse RSA Key #4 (DES Encrypted)
depends_on:MBEDTLS_MD5_C:MBEDTLS_DES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
-pk_parse_keyfile_rsa:"data_files/keyfile.des":"testkey":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_1024_des.pem":"testkey":0
Parse RSA Key #5 (3DES Encrypted)
depends_on:MBEDTLS_MD5_C:MBEDTLS_DES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
-pk_parse_keyfile_rsa:"data_files/keyfile.3des":"testkey":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_1024_3des.pem":"testkey":0
Parse RSA Key #6 (AES-128 Encrypted)
depends_on:MBEDTLS_MD5_C:MBEDTLS_AES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
-pk_parse_keyfile_rsa:"data_files/keyfile.aes128":"testkey":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_1024_aes128.pem":"testkey":0
Parse RSA Key #7 (AES-192 Encrypted)
depends_on:MBEDTLS_MD5_C:MBEDTLS_AES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
-pk_parse_keyfile_rsa:"data_files/keyfile.aes192":"testkey":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_1024_aes192.pem":"testkey":0
Parse RSA Key #8 (AES-256 Encrypted)
depends_on:MBEDTLS_MD5_C:MBEDTLS_AES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
-pk_parse_keyfile_rsa:"data_files/keyfile.aes256":"testkey":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_1024_aes256.pem":"testkey":0
-Parse RSA Key #9 (PKCS#8 wrapped)
+Parse RSA Key #9 (2048-bit, DES Encrypted)
+depends_on:MBEDTLS_MD5_C:MBEDTLS_DES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_2048_des.pem":"testkey":0
+
+Parse RSA Key #10 (2048-bit, 3DES Encrypted)
+depends_on:MBEDTLS_MD5_C:MBEDTLS_DES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_2048_3des.pem":"testkey":0
+
+Parse RSA Key #11 (2048-bit, AES-128 Encrypted)
+depends_on:MBEDTLS_MD5_C:MBEDTLS_AES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_2048_aes128.pem":"testkey":0
+
+Parse RSA Key #12 (2048-bit, AES-192 Encrypted)
+depends_on:MBEDTLS_MD5_C:MBEDTLS_AES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_2048_aes192.pem":"testkey":0
+
+Parse RSA Key #13 (2048-bit, AES-256 Encrypted)
+depends_on:MBEDTLS_MD5_C:MBEDTLS_AES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_2048_aes256.pem":"testkey":0
+
+Parse RSA Key #14 (4096-bit, DES Encrypted)
+depends_on:MBEDTLS_MD5_C:MBEDTLS_DES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_4096_des.pem":"testkey":0
+
+Parse RSA Key #15 (4096-bit, 3DES Encrypted)
+depends_on:MBEDTLS_MD5_C:MBEDTLS_DES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_4096_3des.pem":"testkey":0
+
+Parse RSA Key #16 (4096-bit, AES-128 Encrypted)
+depends_on:MBEDTLS_MD5_C:MBEDTLS_AES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_4096_aes128.pem":"testkey":0
+
+Parse RSA Key #17 (4096-bit, AES-192 Encrypted)
+depends_on:MBEDTLS_MD5_C:MBEDTLS_AES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_4096_aes192.pem":"testkey":0
+
+Parse RSA Key #18 (4096-bit, AES-256 Encrypted)
+depends_on:MBEDTLS_MD5_C:MBEDTLS_AES_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs1_4096_aes256.pem":"testkey":0
+
+Parse RSA Key #19 (PKCS#8 wrapped)
depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C
pk_parse_keyfile_rsa:"data_files/format_gen.key":"":0
-Parse RSA Key #10 (PKCS#8 encrypted SHA1-3DES)
+Parse RSA Key #20 (PKCS#8 encrypted SHA1-3DES)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbe_sha1_3des.key":"PolarSSLTest":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_3des.pem":"PolarSSLTest":0
-Parse RSA Key #10.1 (PKCS#8 encrypted SHA1-3DES, wrong PW)
+Parse RSA Key #20.1 (PKCS#8 encrypted SHA1-3DES, wrong PW)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbe_sha1_3des.key":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_3des.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
-Parse RSA Key #10.2 (PKCS#8 encrypted SHA1-3DES, no PW)
+Parse RSA Key #20.2 (PKCS#8 encrypted SHA1-3DES, no PW)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbe_sha1_3des.key":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_3des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #21 (PKCS#8 encrypted SHA1-3DES, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_3des.pem":"PolarSSLTest":0
+
+Parse RSA Key #21.1 (PKCS#8 encrypted SHA1-3DES, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_3des.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #21.2 (PKCS#8 encrypted SHA1-3DES, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_3des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #22 (PKCS#8 encrypted SHA1-3DES, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_3des.pem":"PolarSSLTest":0
+
+Parse RSA Key #22.1 (PKCS#8 encrypted SHA1-3DES, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_3des.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #22.2 (PKCS#8 encrypted SHA1-3DES, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_3des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #23 (PKCS#8 encrypted SHA1-3DES DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_3des.der":"PolarSSLTest":0
+
+Parse RSA Key #24 (PKCS#8 encrypted SHA1-3DES DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_3des.der":"PolarSSLTest":0
-Parse RSA Key #11 (PKCS#8 encrypted SHA1-3DES DER)
+Parse RSA Key #25 (PKCS#8 encrypted SHA1-3DES DER, 4096-bit)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbe_sha1_3des.der":"PolarSSLTest":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_3des.der":"PolarSSLTest":0
+
+Parse RSA Key #26 (PKCS#8 encrypted SHA1-2DES)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_2des.pem":"PolarSSLTest":0
+
+Parse RSA Key #26.1 (PKCS#8 encrypted SHA1-2DES, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_2des.pem":"PolarSLTest":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #26.2 (PKCS#8 encrypted SHA1-2DES, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_2des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #27 (PKCS#8 encrypted SHA1-2DES, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_2des.pem":"PolarSSLTest":0
-Parse RSA Key #12 (PKCS#8 encrypted SHA1-2DES)
+Parse RSA Key #27.1 (PKCS#8 encrypted SHA1-2DES, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_2des.pem":"PolarSLTest":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #27.2 (PKCS#8 encrypted SHA1-2DES, 2048-bit no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_2des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #28 (PKCS#8 encrypted SHA1-2DES, 4096-bit)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbe_sha1_2des.key":"PolarSSLTest":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_2des.pem":"PolarSSLTest":0
-Parse RSA Key #12.1 (PKCS#8 encrypted SHA1-2DES, wrong PW)
+Parse RSA Key #28.1 (PKCS#8 encrypted SHA1-2DES, 4096-bit, wrong PW)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbe_sha1_2des.key":"PolarSLTest":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_2des.pem":"PolarSLTest":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
-Parse RSA Key #12.2 (PKCS#8 encrypted SHA1-2DES, no PW)
+Parse RSA Key #28.2 (PKCS#8 encrypted SHA1-2DES, 4096-bit, no PW)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbe_sha1_2des.key":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_2des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
-Parse RSA Key #13 (PKCS#8 encrypted SHA1-RC4-128)
+Parse RSA Key #29 (PKCS#8 encrypted SHA1-2DES DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_2des.der":"PolarSSLTest":0
+
+Parse RSA Key #30 (PKCS#8 encrypted SHA1-2DES DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_2des.der":"PolarSSLTest":0
+
+Parse RSA Key #31 (PKCS#8 encrypted SHA1-2DES DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_2des.der":"PolarSSLTest":0
+
+Parse RSA Key #32 (PKCS#8 encrypted SHA1-RC4-128)
+depends_on:MBEDTLS_ARC4_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_rc4_128.pem":"PolarSSLTest":0
+
+Parse RSA Key #32.1 (PKCS#8 encrypted SHA1-RC4-128, wrong PW)
+depends_on:MBEDTLS_ARC4_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_rc4_128.pem":"PolarSSLTe":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #32.2 (PKCS#8 encrypted SHA1-RC4-128, no PW)
+depends_on:MBEDTLS_ARC4_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_rc4_128.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #33 (PKCS#8 encrypted SHA1-RC4-128, 2048-bit)
+depends_on:MBEDTLS_ARC4_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_rc4_128.pem":"PolarSSLTest":0
+
+Parse RSA Key #33.1 (PKCS#8 encrypted SHA1-RC4-128, 2048-bit, wrong PW)
depends_on:MBEDTLS_ARC4_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbe_sha1_rc4_128.key":"PolarSSLTest":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_rc4_128.pem":"PolarSSLTe":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
-Parse RSA Key #13.1 (PKCS#8 encrypted SHA1-RC4-128, wrong PW)
+Parse RSA Key #33.2 (PKCS#8 encrypted SHA1-RC4-128, 2048-bit, no PW)
depends_on:MBEDTLS_ARC4_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbe_sha1_rc4_128.key":"PolarSSLTe":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_rc4_128.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
-Parse RSA Key #13.2 (PKCS#8 encrypted SHA1-RC4-128, no PW)
+Parse RSA Key #34 (PKCS#8 encrypted SHA1-RC4-128, 4096-bit)
depends_on:MBEDTLS_ARC4_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbe_sha1_rc4_128.key":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_rc4_128.pem":"PolarSSLTest":0
+
+Parse RSA Key #34.1 (PKCS#8 encrypted SHA1-RC4-128, 4096-bit, wrong PW)
+depends_on:MBEDTLS_ARC4_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_rc4_128.pem":"PolarSSLTe":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #34.2 (PKCS#8 encrypted SHA1-RC4-128, 4096-bit, no PW)
+depends_on:MBEDTLS_ARC4_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS12_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_rc4_128.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #35 (PKCS#8 encrypted SHA1-RC4-128 DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_1024_rc4_128.der":"PolarSSLTest":0
+
+Parse RSA Key #36 (PKCS#8 encrypted SHA1-RC4-128 DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_2048_rc4_128.der":"PolarSSLTest":0
-Parse RSA Key #14 (PKCS#8 encrypted v2 PBDFK2 3DES)
+Parse RSA Key #37 (PKCS#8 encrypted SHA1-RC4-128 DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS12_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbe_sha1_4096_rc4_128.der":"PolarSSLTest":0
+
+Parse RSA Key #38 (PKCS#8 encrypted v2 PBKDF2 3DES)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des.pem":"PolarSSLTest":0
+
+Parse RSA Key #38.1 (PKCS#8 encrypted v2 PBKDF2 3DES, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #38.2 (PKCS#8 encrypted v2 PBKDF2 3DES, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #39 (PKCS#8 encrypted v2 PBKDF2 3DES, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des.pem":"PolarSSLTest":0
+
+Parse RSA Key #39.1 (PKCS#8 encrypted v2 PBKDF2 3DES, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #39.2 (PKCS#8 encrypted v2 PBKDF2 3DES, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #40 (PKCS#8 encrypted v2 PBKDF2 3DES, 4096-bit)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbes2_pbkdf2_3des.key":"PolarSSLTest":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des.pem":"PolarSSLTest":0
-Parse RSA Key #15 (PKCS#8 encrypted v2 PBDFK2 3DES, wrong PW)
+Parse RSA Key #40.1 (PKCS#8 encrypted v2 PBKDF2 3DES, 4096-bit, wrong PW)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbes2_pbkdf2_3des.key":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
-Parse RSA Key #16 (PKCS#8 encrypted v2 PBDFK2 3DES, no PW)
+Parse RSA Key #40.2 (PKCS#8 encrypted v2 PBKDF2 3DES, 4096-bit, no PW)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbes2_pbkdf2_3des.key":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
-Parse RSA Key #17 (PKCS#8 encrypted v2 PBDFK2 3DES DER)
+Parse RSA Key #41 (PKCS#8 encrypted v2 PBKDF2 3DES DER)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbes2_pbkdf2_3des.der":"PolarSSLTest":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des.der":"PolarSSLTest":0
-Parse RSA Key #18 (PKCS#8 encrypted v2 PBDFK2 3DES DER, wrong PW)
+Parse RSA Key #41.1 (PKCS#8 encrypted v2 PBKDF2 3DES DER, wrong PW)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbes2_pbkdf2_3des.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
-Parse RSA Key #19 (PKCS#8 encrypted v2 PBDFK2 3DES DER, no PW)
+Parse RSA Key #41.2 (PKCS#8 encrypted v2 PBKDF2 3DES DER, no PW)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbes2_pbkdf2_3des.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #42 (PKCS#8 encrypted v2 PBKDF2 3DES DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des.der":"PolarSSLTest":0
+
+Parse RSA Key #42.1 (PKCS#8 encrypted v2 PBKDF2 3DES DER, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #42.2 (PKCS#8 encrypted v2 PBKDF2 3DES DER, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #43 (PKCS#8 encrypted v2 PBKDF2 3DES DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des.der":"PolarSSLTest":0
+
+Parse RSA Key #43.1 (PKCS#8 encrypted v2 PBKDF2 3DES DER, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #43.2 (PKCS#8 encrypted v2 PBKDF2 3DES DER, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #44 (PKCS#8 encrypted v2 PBKDF2 DES)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des.pem":"PolarSSLTest":0
+
+Parse RSA Key #44.1 (PKCS#8 encrypted v2 PBKDF2 DES, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #44.2 (PKCS#8 encrypted v2 PBKDF2 DES, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #45 (PKCS#8 encrypted v2 PBKDF2 DES, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des.pem":"PolarSSLTest":0
+
+Parse RSA Key #45.1 (PKCS#8 encrypted v2 PBKDF2 DES, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #45.2 (PKCS#8 encrypted v2 PBKDF2 DES, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
-Parse RSA Key #20 (PKCS#8 encrypted v2 PBDFK2 DES)
+Parse RSA Key #46 (PKCS#8 encrypted v2 PBKDF2 DES, 4096-bit)
depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
-pk_parse_keyfile_rsa:"data_files/pkcs8_pbes2_pbkdf2_des.key":"PolarSSLTest":0
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des.pem":"PolarSSLTest":0
+
+Parse RSA Key #46.1 (PKCS#8 encrypted v2 PBKDF2 DES, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #46.2 (PKCS#8 encrypted v2 PBKDF2 DES, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #47 (PKCS#8 encrypted v2 PBKDF2 DES DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des.der":"PolarSSLTest":0
+
+Parse RSA Key #47.1 (PKCS#8 encrypted v2 PBKDF2 DES DER, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #47.2 (PKCS#8 encrypted v2 PBKDF2 DES DER, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #48 (PKCS#8 encrypted v2 PBKDF2 DES DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des.der":"PolarSSLTest":0
+
+Parse RSA Key #48.1 (PKCS#8 encrypted v2 PBKDF2 DES DER, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #48.2 (PKCS#8 encrypted v2 PBKDF2 DES DER, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #49 (PKCS#8 encrypted v2 PBKDF2 DES DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des.der":"PolarSSLTest":0
+
+Parse RSA Key #49.1 (PKCS#8 encrypted v2 PBKDF2 DES DER, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #49.2 (PKCS#8 encrypted v2 PBKDF2 DES DER, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA1_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #50 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.pem":"PolarSSLTest":0
+
+Parse RSA Key #50.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #50.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #51 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.pem":"PolarSSLTest":0
+
+Parse RSA Key #51.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #51.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #52 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.pem":"PolarSSLTest":0
+
+Parse RSA Key #52.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #52.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #53 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224 DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.der":"PolarSSLTest":0
+
+Parse RSA Key #53.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224 DER, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #53.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224 DER, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha224.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #54 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224 DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.der":"PolarSSLTest":0
+
+Parse RSA Key #54.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224 DER, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #54.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224 DER, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha224.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #55 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224 DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.der":"PolarSSLTest":0
+
+Parse RSA Key #55.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224 DER, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #55.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA224 DER, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha224.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #56 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.pem":"PolarSSLTest":0
+
+Parse RSA Key #56.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #56.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #57 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.pem":"PolarSSLTest":0
+
+Parse RSA Key #57.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #57.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #58 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.pem":"PolarSSLTest":0
+
+Parse RSA Key #58.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #58.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #59 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224 DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.der":"PolarSSLTest":0
+
+Parse RSA Key #59.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224 DER, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #59.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224 DER, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha224.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #60 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224 DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.der":"PolarSSLTest":0
+
+Parse RSA Key #60.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224 DER, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #60.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224 DER, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha224.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #61 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224 DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.der":"PolarSSLTest":0
+
+Parse RSA Key #61.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224 DER, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #61.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA224 DER, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha224.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #62 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.pem":"PolarSSLTest":0
+
+Parse RSA Key #62.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #62.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #63 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.pem":"PolarSSLTest":0
+
+Parse RSA Key #63.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #63.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #64 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.pem":"PolarSSLTest":0
+
+Parse RSA Key #64.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #64.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #65 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256 DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.der":"PolarSSLTest":0
+
+Parse RSA Key #65.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256 DER, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #65.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256 DER, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha256.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #66 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256 DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.der":"PolarSSLTest":0
+
+Parse RSA Key #66.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256 DER, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #66.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256 DER, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha256.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #67 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256 DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.der":"PolarSSLTest":0
+
+Parse RSA Key #68.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256 DER, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #68.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA256 DER, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha256.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #69 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.pem":"PolarSSLTest":0
+
+Parse RSA Key #69.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #69.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #70 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.pem":"PolarSSLTest":0
+
+Parse RSA Key #70.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #70.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #71 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.pem":"PolarSSLTest":0
+
+Parse RSA Key #71.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #71.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #72 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256 DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.der":"PolarSSLTest":0
+
+Parse RSA Key #72.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256 DER, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #72.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256 DER, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha256.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #73 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256 DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.der":"PolarSSLTest":0
+
+Parse RSA Key #73.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256 DER, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #73.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256 DER, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha256.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #74 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256 DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.der":"PolarSSLTest":0
+
+Parse RSA Key #74.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256 DER, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #74.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA256 DER, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA256_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha256.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #75 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.pem":"PolarSSLTest":0
+
+Parse RSA Key #75.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #75.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #76 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.pem":"PolarSSLTest":0
+
+Parse RSA Key #76.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #76.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #77 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.pem":"PolarSSLTest":0
+
+Parse RSA Key #77.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #77.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #78 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384 DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.der":"PolarSSLTest":0
+
+Parse RSA Key #78.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384 DER, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #78.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384 DER, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha384.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #79 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384 DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.der":"PolarSSLTest":0
+
+Parse RSA Key #79.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384 DER, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #79.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384 DER, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha384.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #80 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384 DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.der":"PolarSSLTest":0
+
+Parse RSA Key #80.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384 DER, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #80.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA384 DER, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha384.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #81 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.pem":"PolarSSLTest":0
+
+Parse RSA Key #81.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #81.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #82 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.pem":"PolarSSLTest":0
+
+Parse RSA Key #82.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #82.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #83 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.pem":"PolarSSLTest":0
+
+Parse RSA Key #83.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #83.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #84 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384 DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.der":"PolarSSLTest":0
+
+Parse RSA Key #84.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384 DER, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #85.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384 DER, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha384.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #86 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384 DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.der":"PolarSSLTest":0
+
+Parse RSA Key #86.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384 DER, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #86.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384 DER, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha384.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #87 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384 DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.der":"PolarSSLTest":0
+
+Parse RSA Key #87.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384 DER, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #87.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA384 DER, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha384.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #88 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.pem":"PolarSSLTest":0
+
+Parse RSA Key #88.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #88.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #89 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.pem":"PolarSSLTest":0
+
+Parse RSA Key #89.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #89.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #90 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.pem":"PolarSSLTest":0
+
+Parse RSA Key #90.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #90.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #91 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512 DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.der":"PolarSSLTest":0
+
+Parse RSA Key #91.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512 DER, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #91.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512 DER, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_3des_sha512.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #92 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512 DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.der":"PolarSSLTest":0
+
+Parse RSA Key #92.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512 DER, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #92.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512 DER, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_3des_sha512.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #93 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512 DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.der":"PolarSSLTest":0
+
+Parse RSA Key #93.1 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512 DER, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #93.2 (PKCS#8 encrypted v2 PBKDF2 3DES hmacWithSHA512 DER, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_3des_sha512.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #94 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.pem":"PolarSSLTest":0
+
+Parse RSA Key #94.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #94.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #95 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.pem":"PolarSSLTest":0
+
+Parse RSA Key #95.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #95.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #96 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.pem":"PolarSSLTest":0
+
+Parse RSA Key #96.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.pem":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #96.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.pem":"":MBEDTLS_ERR_PK_PASSWORD_REQUIRED
+
+Parse RSA Key #97 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512 DER)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.der":"PolarSSLTest":0
+
+Parse RSA Key #97.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512 DER, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #97.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512 DER, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_1024_des_sha512.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #98 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512 DER, 2048-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.der":"PolarSSLTest":0
+
+Parse RSA Key #98.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512 DER, 2048-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #98.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512 DER, 2048-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_2048_des_sha512.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Parse RSA Key #99 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512 DER, 4096-bit)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.der":"PolarSSLTest":0
+
+Parse RSA Key #99.1 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512 DER, 4096-bit, wrong PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.der":"PolarSSLTes":MBEDTLS_ERR_PK_PASSWORD_MISMATCH
+
+Parse RSA Key #99.2 (PKCS#8 encrypted v2 PBKDF2 DES hmacWithSHA512 DER, 4096-bit, no PW)
+depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C
+pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
Parse Public RSA Key #1 (PKCS#8 wrapped)
-depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C
-pk_parse_public_keyfile_rsa:"data_files/format_gen.pub":0
+depends_on:MBEDTLS_PEM_PARSE_C
+pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs8_2048_public.pem":0
+
+Parse Public RSA Key #1 (PKCS#8 wrapped, DER)
+pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs8_2048_public.der":0
+
+Parse Public RSA Key #3 (PKCS#1 wrapped)
+depends_on:MBEDTLS_PEM_PARSE_C
+pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs1_2048_public.pem":0
+
+Parse Public RSA Key #4 (PKCS#1 wrapped, DER)
+pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs1_2048_public.der":0
Parse Public EC Key #1 (RFC 5480, DER)
depends_on:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED
pk_parse_keyfile_ec:"data_files/ec_prv.specdom.der":"NULL":0
Key ASN1 (Incorrect first tag)
-pk_parse_key_rsa:"":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+pk_parse_key:"":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
Key ASN1 (RSAPrivateKey, incorrect version tag)
-pk_parse_key_rsa:"300100":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+depends_on:MBEDTLS_RSA_C
+pk_parse_key:"300100":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
Key ASN1 (RSAPrivateKey, version tag missing)
-pk_parse_key_rsa:"3000":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+depends_on:MBEDTLS_RSA_C
+pk_parse_key:"3000":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
Key ASN1 (RSAPrivateKey, invalid version)
-pk_parse_key_rsa:"3003020101":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+depends_on:MBEDTLS_RSA_C
+pk_parse_key:"3003020101":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
Key ASN1 (RSAPrivateKey, correct version, incorrect tag)
-pk_parse_key_rsa:"300402010000":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+depends_on:MBEDTLS_RSA_C
+pk_parse_key:"300402010000":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
Key ASN1 (RSAPrivateKey, values present, length mismatch)
-pk_parse_key_rsa:"301c02010002010102010102010102010102010102010102010102010100":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+depends_on:MBEDTLS_RSA_C
+pk_parse_key:"301c02010002010102010102010102010102010102010102010102010100":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
Key ASN1 (RSAPrivateKey, values present, check_privkey fails)
-pk_parse_key_rsa:"301b020100020101020101020101020101020101020101020101020101":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+depends_on:MBEDTLS_RSA_C
+pk_parse_key:"301b020100020102020101020101020101020101020101020101020101":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
+
+Key ASN1 (ECPrivateKey, empty parameters)
+depends_on:MBEDTLS_ECP_C
+pk_parse_key:"30070201010400a000":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT
}
/* END_CASE */
-/* BEGIN_CASE depends_on:MBEDTLS_RSA_C */
-void pk_parse_key_rsa( char *key_data, char *result_str, int result )
+/* BEGIN_CASE */
+void pk_parse_key( char *key_data, char *result_str, int result )
{
mbedtls_pk_context pk;
unsigned char buf[2000];
RSA PKCS1 Verify v1.5 CAVS #1
depends_on:MBEDTLS_SHA1_C:MBEDTLS_PKCS1_V15
+# Good padding but wrong hash
mbedtls_rsa_pkcs1_verify:"d6248c3e96b1a7e5fea978870fcc4c9786b4e5156e16b7faef4557d667f730b8bc4c784ef00c624df5309513c3a5de8ca94c2152e0459618666d3148092562ebc256ffca45b27fd2d63c68bd5e0a0aefbe496e9e63838a361b1db6fc272464f191490bf9c029643c49d2d9cd08833b8a70b4b3431f56fb1eb55ccd39e77a9c92":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA1:1024:16:"e28a13548525e5f36dccb24ecb7cc332cc689dfd64012604c9c7816d72a16c3f5fcdc0e86e7c03280b1c69b586ce0cd8aec722cc73a5d3b730310bf7dfebdc77ce5d94bbc369dc18a2f7b07bd505ab0f82224aef09fdc1e5063234255e0b3c40a52e9e8ae60898eb88a766bdd788fe9493d8fd86bcdd2884d5c06216c65469e5":16:"3":"3203b7647fb7e345aa457681e5131777f1adc371f2fba8534928c4e52ef6206a856425d6269352ecbf64db2f6ad82397768cafdd8cd272e512d617ad67992226da6bc291c31404c17fd4b7e2beb20eff284a44f4d7af47fd6629e2c95809fa7f2241a04f70ac70d3271bb13258af1ed5c5988c95df7fa26603515791075feccd":MBEDTLS_ERR_RSA_VERIFY_FAILED
RSA PKCS1 Verify v1.5 CAVS #2
RSA PKCS1 Verify v1.5 CAVS #7
depends_on:MBEDTLS_SHA512_C:MBEDTLS_PKCS1_V15
-mbedtls_rsa_pkcs1_verify:"d03f12276f6ba7545b8fce719471bd253791878809694e8754f3b389f26c9253a758ed28b4c62535a8d5702d7a778731d5759ff2b3b39b192db680e791632918b6093c0e8ca25c2bf756a07fde4144a37f769fe4054455a45cb8cefe4462e7a9a45ce71f2189b4fef01b47aee8585d44dc9d6fa627a3e5f08801871731f234cd":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA384:1024:16:"e28a13548525e5f36dccb24ecb7cc332cc689dfd64012604c9c7816d72a16c3f5fcdc0e86e7c03280b1c69b586ce0cd8aec722cc73a5d3b730310bf7dfebdc77ce5d94bbc369dc18a2f7b07bd505ab0f82224aef09fdc1e5063234255e0b3c40a52e9e8ae60898eb88a766bdd788fe9493d8fd86bcdd2884d5c06216c65469e5":16:"3":"d93a878c1ce86571590b0e43794b3edb23552797c4b8c9e3da4fe1cc4ac0566acd3b10541fe9a7a79f5ea4892d3069ca6903efb5c40c47eb8a9c781eb4249281d40c3d96aae16da1bb4daaece6a26eca5f41c062b4124a64fc9d340cba5ab0d1f5affff6515a87f0933774fd4322d2fa497cd6f708a429ca56dcb1fd3db623d0":MBEDTLS_ERR_RSA_INVALID_PADDING
+# Bad padding after performing the public key operation
+mbedtls_rsa_pkcs1_verify:"d03f12276f6ba7545b8fce719471bd253791878809694e8754f3b389f26c9253a758ed28b4c62535a8d5702d7a778731d5759ff2b3b39b192db680e791632918b6093c0e8ca25c2bf756a07fde4144a37f769fe4054455a45cb8cefe4462e7a9a45ce71f2189b4fef01b47aee8585d44dc9d6fa627a3e5f08801871731f234cd":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA384:1024:16:"e28a13548525e5f36dccb24ecb7cc332cc689dfd64012604c9c7816d72a16c3f5fcdc0e86e7c03280b1c69b586ce0cd8aec722cc73a5d3b730310bf7dfebdc77ce5d94bbc369dc18a2f7b07bd505ab0f82224aef09fdc1e5063234255e0b3c40a52e9e8ae60898eb88a766bdd788fe9493d8fd86bcdd2884d5c06216c65469e5":16:"3":"d93a878c1ce86571590b0e43794b3edb23552797c4b8c9e3da4fe1cc4ac0566acd3b10541fe9a7a79f5ea4892d3069ca6903efb5c40c47eb8a9c781eb4249281d40c3d96aae16da1bb4daaece6a26eca5f41c062b4124a64fc9d340cba5ab0d1f5affff6515a87f0933774fd4322d2fa497cd6f708a429ca56dcb1fd3db623d0":MBEDTLS_ERR_RSA_VERIFY_FAILED
RSA PKCS1 Verify v1.5 CAVS #8
depends_on:MBEDTLS_SHA512_C:MBEDTLS_PKCS1_V15
RSA PKCS1 Verify v1.5 CAVS #10
depends_on:MBEDTLS_SHA1_C:MBEDTLS_PKCS1_V15
-mbedtls_rsa_pkcs1_verify:"55013a489e09b6553262aab59fb041b49437b86d52876f8e5d5e405b77ca0ff6ce8ea2dd75c7b3b411cf4445d56233c5b0ff0e58c49128d81b4fedd295e172d225c451e13defb34b87b7aea6d6f0d20f5c55feb71d2a789fa31f3d9ff47896adc16bec5ce0c9dda3fde190e08ca2451c01ff3091449887695f96dac97ad6a30e":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA1:1024:16:"e28a13548525e5f36dccb24ecb7cc332cc689dfd64012604c9c7816d72a16c3f5fcdc0e86e7c03280b1c69b586ce0cd8aec722cc73a5d3b730310bf7dfebdc77ce5d94bbc369dc18a2f7b07bd505ab0f82224aef09fdc1e5063234255e0b3c40a52e9e8ae60898eb88a766bdd788fe9493d8fd86bcdd2884d5c06216c65469e5":16:"10001":"dd82b7be791c454fbbf6f1de47cbe585a687e4e8bbae0b6e2a77f8ca4efd06d71498f9a74b931bd59c377e71daf708a624c51303f377006c676487bad57f7067b09b7bb94a6189119ab8cf7321c321b2dc7df565bfbec833a28b86625fb5fd6a035d4ed79ff0f9aee9fa78935eec65069439ee449d7f5249cdae6fdd6d8c2a63":MBEDTLS_ERR_RSA_INVALID_PADDING
+mbedtls_rsa_pkcs1_verify:"55013a489e09b6553262aab59fb041b49437b86d52876f8e5d5e405b77ca0ff6ce8ea2dd75c7b3b411cf4445d56233c5b0ff0e58c49128d81b4fedd295e172d225c451e13defb34b87b7aea6d6f0d20f5c55feb71d2a789fa31f3d9ff47896adc16bec5ce0c9dda3fde190e08ca2451c01ff3091449887695f96dac97ad6a30e":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA1:1024:16:"e28a13548525e5f36dccb24ecb7cc332cc689dfd64012604c9c7816d72a16c3f5fcdc0e86e7c03280b1c69b586ce0cd8aec722cc73a5d3b730310bf7dfebdc77ce5d94bbc369dc18a2f7b07bd505ab0f82224aef09fdc1e5063234255e0b3c40a52e9e8ae60898eb88a766bdd788fe9493d8fd86bcdd2884d5c06216c65469e5":16:"10001":"dd82b7be791c454fbbf6f1de47cbe585a687e4e8bbae0b6e2a77f8ca4efd06d71498f9a74b931bd59c377e71daf708a624c51303f377006c676487bad57f7067b09b7bb94a6189119ab8cf7321c321b2dc7df565bfbec833a28b86625fb5fd6a035d4ed79ff0f9aee9fa78935eec65069439ee449d7f5249cdae6fdd6d8c2a63":MBEDTLS_ERR_RSA_VERIFY_FAILED
RSA PKCS1 Verify v1.5 CAVS #11
depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
RSA PKCS1 Verify v1.5 CAVS #21
depends_on:MBEDTLS_SHA1_C:MBEDTLS_PKCS1_V15
-mbedtls_rsa_pkcs1_verify:"ac58fd024208d7f045d81a56cd55aad40ab86b0d216ab55136c7027aca23ea13480a52c0dacce0d98139b25965aa4ff76a41dd92037195d24bc0750d52cb3467b48b7b3e71d852c5f82bd9ee85a8388ead5cd8bc38c3d4792e8daa9734a137d31963e245ad3217fad235f7dfd5584de0fe91c4526568588e08b60bdf1badd99f":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA1:1536:16:"a59d9b7269b102b7be684ec5e28db79992e6d3231e77c90b78960c2638b35ef6dbdac1ac59e7249d96d426e7f99397eabc6b8903fe1942da580322b98bafacd81bb911c29666f83886a2a2864f3552044300e60cedd5a8c321c43e280413dc41673c39a11b98a885486f8187a70f270185c4c12bc48a1968305269776c070ef69d4913589a887c4d0f5e7dd58bd806d0d49a14a1762c38665cef4646ff13a0cd29c3a60460703c3d051d5b28c660bffb5f8bd43d495ffa64175f72b8abe5fddd":16:"10001":"a142b0d9456f8f4772675265a08613a66c416bd1ae712975c69d9ca5fb8c1be9c24359a04fd15460bf6136a8a11f13e3ce2de2171524f10cb715f0d71e3db15281ab99eadbe86cf8c5c518162c638ef27a4f7bfb4a1a3873f3c384a5b1c3b4966c837b9d8d192ac34e03943b7ae191355aa1ff3b9cd041bb2668f1f81cf0d015b3d3608cd9ac79398212c0f132f1bd45d47768b999fcf3c05fe2069593ceecedc851a7fc465abcfef0fabba9b9460153f6ba8723a5c6e766c83a446aef3ee327":MBEDTLS_ERR_RSA_INVALID_PADDING
+mbedtls_rsa_pkcs1_verify:"ac58fd024208d7f045d81a56cd55aad40ab86b0d216ab55136c7027aca23ea13480a52c0dacce0d98139b25965aa4ff76a41dd92037195d24bc0750d52cb3467b48b7b3e71d852c5f82bd9ee85a8388ead5cd8bc38c3d4792e8daa9734a137d31963e245ad3217fad235f7dfd5584de0fe91c4526568588e08b60bdf1badd99f":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA1:1536:16:"a59d9b7269b102b7be684ec5e28db79992e6d3231e77c90b78960c2638b35ef6dbdac1ac59e7249d96d426e7f99397eabc6b8903fe1942da580322b98bafacd81bb911c29666f83886a2a2864f3552044300e60cedd5a8c321c43e280413dc41673c39a11b98a885486f8187a70f270185c4c12bc48a1968305269776c070ef69d4913589a887c4d0f5e7dd58bd806d0d49a14a1762c38665cef4646ff13a0cd29c3a60460703c3d051d5b28c660bffb5f8bd43d495ffa64175f72b8abe5fddd":16:"10001":"a142b0d9456f8f4772675265a08613a66c416bd1ae712975c69d9ca5fb8c1be9c24359a04fd15460bf6136a8a11f13e3ce2de2171524f10cb715f0d71e3db15281ab99eadbe86cf8c5c518162c638ef27a4f7bfb4a1a3873f3c384a5b1c3b4966c837b9d8d192ac34e03943b7ae191355aa1ff3b9cd041bb2668f1f81cf0d015b3d3608cd9ac79398212c0f132f1bd45d47768b999fcf3c05fe2069593ceecedc851a7fc465abcfef0fabba9b9460153f6ba8723a5c6e766c83a446aef3ee327":MBEDTLS_ERR_RSA_VERIFY_FAILED
RSA PKCS1 Verify v1.5 CAVS #22
depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
-mbedtls_rsa_pkcs1_verify:"027f767928a5821e2723d6f36c43e6b498b6f0b381852571794a096bd49f1c36a4d7bacec7ec402c24b970163169173bb930ec7fdc39bc9457dfc4ca051f5f28a64de1bbe007c22e8368ff9b117dbda17efd2fb73434bbbf5a4158df56813b8c904bb2e779de504dcd974a291568210d6f85810291606a1c0cd88d51ceadf98a":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA224:1536:16:"a59d9b7269b102b7be684ec5e28db79992e6d3231e77c90b78960c2638b35ef6dbdac1ac59e7249d96d426e7f99397eabc6b8903fe1942da580322b98bafacd81bb911c29666f83886a2a2864f3552044300e60cedd5a8c321c43e280413dc41673c39a11b98a885486f8187a70f270185c4c12bc48a1968305269776c070ef69d4913589a887c4d0f5e7dd58bd806d0d49a14a1762c38665cef4646ff13a0cd29c3a60460703c3d051d5b28c660bffb5f8bd43d495ffa64175f72b8abe5fddd":16:"10001":"0676e64daaa18f4af46e9dfbe234db389b8a527b0fe1db97eb7f404e3155226cba70d318800f83160fa1aa19916e5c09f079331079f18cb8ab1a4b884cb28501824974f683ed2b9babae9f8c15bea30802805c6b2152119764811bbf5f3994d2e97fa2fe8c5ab15a23c14d7ae56be00eaa8bc26678481ff5ba59b0acfb0e43341bff9fc638e5625480a73dbc5d8d13bd2b9e64037c6b79df0c60869980c6a22ec46f80fb859cb4ee5d2032ac1fe538cfd85c70a7f33b4af50a93395917c2cfb6":MBEDTLS_ERR_RSA_INVALID_PADDING
+mbedtls_rsa_pkcs1_verify:"027f767928a5821e2723d6f36c43e6b498b6f0b381852571794a096bd49f1c36a4d7bacec7ec402c24b970163169173bb930ec7fdc39bc9457dfc4ca051f5f28a64de1bbe007c22e8368ff9b117dbda17efd2fb73434bbbf5a4158df56813b8c904bb2e779de504dcd974a291568210d6f85810291606a1c0cd88d51ceadf98a":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA224:1536:16:"a59d9b7269b102b7be684ec5e28db79992e6d3231e77c90b78960c2638b35ef6dbdac1ac59e7249d96d426e7f99397eabc6b8903fe1942da580322b98bafacd81bb911c29666f83886a2a2864f3552044300e60cedd5a8c321c43e280413dc41673c39a11b98a885486f8187a70f270185c4c12bc48a1968305269776c070ef69d4913589a887c4d0f5e7dd58bd806d0d49a14a1762c38665cef4646ff13a0cd29c3a60460703c3d051d5b28c660bffb5f8bd43d495ffa64175f72b8abe5fddd":16:"10001":"0676e64daaa18f4af46e9dfbe234db389b8a527b0fe1db97eb7f404e3155226cba70d318800f83160fa1aa19916e5c09f079331079f18cb8ab1a4b884cb28501824974f683ed2b9babae9f8c15bea30802805c6b2152119764811bbf5f3994d2e97fa2fe8c5ab15a23c14d7ae56be00eaa8bc26678481ff5ba59b0acfb0e43341bff9fc638e5625480a73dbc5d8d13bd2b9e64037c6b79df0c60869980c6a22ec46f80fb859cb4ee5d2032ac1fe538cfd85c70a7f33b4af50a93395917c2cfb6":MBEDTLS_ERR_RSA_VERIFY_FAILED
RSA PKCS1 Verify v1.5 CAVS #23
depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
RSA PKCS1 Verify v1.5 CAVS #30
depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
-mbedtls_rsa_pkcs1_verify:"ca312774f2756ac2019f213a01a63c9a0b4a49ccafecf25e97a4c632668e3c77e664f4d7635241f25205e50c37061b02c546db8346fa597c3da8cfd44a827c5a4ff4ecfcd1797b39a1b215d9bbb93fdb6eb35bafbda427a5068888a6e19f86224b0897490491207e35ce39085668b10b4fb851b7dd9465c03869790ef38a61b5":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA256:1536:16:"a59d9b7269b102b7be684ec5e28db79992e6d3231e77c90b78960c2638b35ef6dbdac1ac59e7249d96d426e7f99397eabc6b8903fe1942da580322b98bafacd81bb911c29666f83886a2a2864f3552044300e60cedd5a8c321c43e280413dc41673c39a11b98a885486f8187a70f270185c4c12bc48a1968305269776c070ef69d4913589a887c4d0f5e7dd58bd806d0d49a14a1762c38665cef4646ff13a0cd29c3a60460703c3d051d5b28c660bffb5f8bd43d495ffa64175f72b8abe5fddd":16:"3":"a202c33eb831b9d8e818b6c3bcdb42818e1d9c22a06ddd73a17a21e49d18cda44df349a066477cae068e1a5d2b518b0885e889ef796ca9e6f42a69ac755b8a6405fbaef93fe0130d98de35d689addfee3eecd26658903f774bda481c3f40ee0e9569a3c3e2da7ad576c7de82159d933e36fa29cfef99367005e34ab5082d80f48276d37dabc88dbb023bd01585329d2ccf417f78ec508aaa29751007d31f1669296b981d44c8fa99130c5df7a071725b496859314aaf9baf0ebc780355914249":MBEDTLS_ERR_RSA_INVALID_PADDING
+mbedtls_rsa_pkcs1_verify:"ca312774f2756ac2019f213a01a63c9a0b4a49ccafecf25e97a4c632668e3c77e664f4d7635241f25205e50c37061b02c546db8346fa597c3da8cfd44a827c5a4ff4ecfcd1797b39a1b215d9bbb93fdb6eb35bafbda427a5068888a6e19f86224b0897490491207e35ce39085668b10b4fb851b7dd9465c03869790ef38a61b5":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA256:1536:16:"a59d9b7269b102b7be684ec5e28db79992e6d3231e77c90b78960c2638b35ef6dbdac1ac59e7249d96d426e7f99397eabc6b8903fe1942da580322b98bafacd81bb911c29666f83886a2a2864f3552044300e60cedd5a8c321c43e280413dc41673c39a11b98a885486f8187a70f270185c4c12bc48a1968305269776c070ef69d4913589a887c4d0f5e7dd58bd806d0d49a14a1762c38665cef4646ff13a0cd29c3a60460703c3d051d5b28c660bffb5f8bd43d495ffa64175f72b8abe5fddd":16:"3":"a202c33eb831b9d8e818b6c3bcdb42818e1d9c22a06ddd73a17a21e49d18cda44df349a066477cae068e1a5d2b518b0885e889ef796ca9e6f42a69ac755b8a6405fbaef93fe0130d98de35d689addfee3eecd26658903f774bda481c3f40ee0e9569a3c3e2da7ad576c7de82159d933e36fa29cfef99367005e34ab5082d80f48276d37dabc88dbb023bd01585329d2ccf417f78ec508aaa29751007d31f1669296b981d44c8fa99130c5df7a071725b496859314aaf9baf0ebc780355914249":MBEDTLS_ERR_RSA_VERIFY_FAILED
RSA PKCS1 Verify v1.5 CAVS #31
depends_on:MBEDTLS_SHA512_C:MBEDTLS_PKCS1_V15
-mbedtls_rsa_pkcs1_verify:"2abe079077290ceb6c80ac5c61062ce8da814b1fb99a1a9fb2860ed900e6541856ec64bf19c0d9d1cc2280b7cc50af3e3d2ad8e044945d44761ca60891dd72bd6aa26a33274ffcf7ae7d661b5e651135fcff21aaf06b4a2db18fe5827e0243884f2841760b9f1c65fbda870f7f0cfbd6ff484f0825e688614928f2d12d1e7080":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA384:1536:16:"a59d9b7269b102b7be684ec5e28db79992e6d3231e77c90b78960c2638b35ef6dbdac1ac59e7249d96d426e7f99397eabc6b8903fe1942da580322b98bafacd81bb911c29666f83886a2a2864f3552044300e60cedd5a8c321c43e280413dc41673c39a11b98a885486f8187a70f270185c4c12bc48a1968305269776c070ef69d4913589a887c4d0f5e7dd58bd806d0d49a14a1762c38665cef4646ff13a0cd29c3a60460703c3d051d5b28c660bffb5f8bd43d495ffa64175f72b8abe5fddd":16:"10001":"402631f3cddfb02cc4d9cb58ef1ab6726bd787a50e12e98567c9702bfdf47af85904aec5a2f6c5df9a10f08f90f93728eb090ae2ac21ded9f38faecd8195f3eb3d4107521b1cee956e7a214245b038adae912fa35ec97cb3bdc41352e8aaff80173561284cb740f999a3cd6653a6c3d5a3f911a416f41e2155083982c99eb5998a0a74d77f1ae999d901ee24a7f2c424179a3f92b07dc0b3498c1884e60677bee0175e810b426c4ad008d2743cd19b00b33177bf8be3fed7f7406e1bce0c2ea3":MBEDTLS_ERR_RSA_INVALID_PADDING
+mbedtls_rsa_pkcs1_verify:"2abe079077290ceb6c80ac5c61062ce8da814b1fb99a1a9fb2860ed900e6541856ec64bf19c0d9d1cc2280b7cc50af3e3d2ad8e044945d44761ca60891dd72bd6aa26a33274ffcf7ae7d661b5e651135fcff21aaf06b4a2db18fe5827e0243884f2841760b9f1c65fbda870f7f0cfbd6ff484f0825e688614928f2d12d1e7080":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA384:1536:16:"a59d9b7269b102b7be684ec5e28db79992e6d3231e77c90b78960c2638b35ef6dbdac1ac59e7249d96d426e7f99397eabc6b8903fe1942da580322b98bafacd81bb911c29666f83886a2a2864f3552044300e60cedd5a8c321c43e280413dc41673c39a11b98a885486f8187a70f270185c4c12bc48a1968305269776c070ef69d4913589a887c4d0f5e7dd58bd806d0d49a14a1762c38665cef4646ff13a0cd29c3a60460703c3d051d5b28c660bffb5f8bd43d495ffa64175f72b8abe5fddd":16:"10001":"402631f3cddfb02cc4d9cb58ef1ab6726bd787a50e12e98567c9702bfdf47af85904aec5a2f6c5df9a10f08f90f93728eb090ae2ac21ded9f38faecd8195f3eb3d4107521b1cee956e7a214245b038adae912fa35ec97cb3bdc41352e8aaff80173561284cb740f999a3cd6653a6c3d5a3f911a416f41e2155083982c99eb5998a0a74d77f1ae999d901ee24a7f2c424179a3f92b07dc0b3498c1884e60677bee0175e810b426c4ad008d2743cd19b00b33177bf8be3fed7f7406e1bce0c2ea3":MBEDTLS_ERR_RSA_VERIFY_FAILED
RSA PKCS1 Verify v1.5 CAVS #32
depends_on:MBEDTLS_SHA512_C:MBEDTLS_PKCS1_V15
RSA PKCS1 Verify v1.5 CAVS #33
depends_on:MBEDTLS_SHA512_C:MBEDTLS_PKCS1_V15
-mbedtls_rsa_pkcs1_verify:"d0cd038c65b3acca45822eaf91ea5176e82043268876dec0b62e2abd619023b7023abc67c6b823cfef5447b8772f985ff7910d6cc87e6c23688ac6de1fee40bbe2da1a92770de92adaa427ace02fee571a0a0176fceb0c8f3eb72dde839ab201395625f5c0db8641ce19d7711212dec61733262c6ce4476c025e67a3d5bc01f3":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA512:1536:16:"a59d9b7269b102b7be684ec5e28db79992e6d3231e77c90b78960c2638b35ef6dbdac1ac59e7249d96d426e7f99397eabc6b8903fe1942da580322b98bafacd81bb911c29666f83886a2a2864f3552044300e60cedd5a8c321c43e280413dc41673c39a11b98a885486f8187a70f270185c4c12bc48a1968305269776c070ef69d4913589a887c4d0f5e7dd58bd806d0d49a14a1762c38665cef4646ff13a0cd29c3a60460703c3d051d5b28c660bffb5f8bd43d495ffa64175f72b8abe5fddd":16:"11":"2f30629c1117d013bb36e6099dee931dcaf0a1032b07ec23e2b262898a8945e569c9573d81e22bb0a5f8a28b0d7b8ff01367dd7f089c68ed1daa11cf53a96ee91b38e6b839b6e90bea34d14b78f5d2c7629b68c5b4f2ecfff66b483b2233cb14f95df533c867a2b610aebcdbb7ea3109aaf2f5762ab3edc2571deccc7da0c9a5b443ca2b924c0f18de7bbb736a08fed3916795018a436a3ae62c85d554a53a6d48623908e06e7d275f4251d3b3bd530bd11e155dcf2b5c2adf030cdf931ae749":MBEDTLS_ERR_RSA_INVALID_PADDING
+mbedtls_rsa_pkcs1_verify:"d0cd038c65b3acca45822eaf91ea5176e82043268876dec0b62e2abd619023b7023abc67c6b823cfef5447b8772f985ff7910d6cc87e6c23688ac6de1fee40bbe2da1a92770de92adaa427ace02fee571a0a0176fceb0c8f3eb72dde839ab201395625f5c0db8641ce19d7711212dec61733262c6ce4476c025e67a3d5bc01f3":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA512:1536:16:"a59d9b7269b102b7be684ec5e28db79992e6d3231e77c90b78960c2638b35ef6dbdac1ac59e7249d96d426e7f99397eabc6b8903fe1942da580322b98bafacd81bb911c29666f83886a2a2864f3552044300e60cedd5a8c321c43e280413dc41673c39a11b98a885486f8187a70f270185c4c12bc48a1968305269776c070ef69d4913589a887c4d0f5e7dd58bd806d0d49a14a1762c38665cef4646ff13a0cd29c3a60460703c3d051d5b28c660bffb5f8bd43d495ffa64175f72b8abe5fddd":16:"11":"2f30629c1117d013bb36e6099dee931dcaf0a1032b07ec23e2b262898a8945e569c9573d81e22bb0a5f8a28b0d7b8ff01367dd7f089c68ed1daa11cf53a96ee91b38e6b839b6e90bea34d14b78f5d2c7629b68c5b4f2ecfff66b483b2233cb14f95df533c867a2b610aebcdbb7ea3109aaf2f5762ab3edc2571deccc7da0c9a5b443ca2b924c0f18de7bbb736a08fed3916795018a436a3ae62c85d554a53a6d48623908e06e7d275f4251d3b3bd530bd11e155dcf2b5c2adf030cdf931ae749":MBEDTLS_ERR_RSA_VERIFY_FAILED
RSA PKCS1 Verify v1.5 CAVS #34
depends_on:MBEDTLS_SHA512_C:MBEDTLS_PKCS1_V15
mbedtls_rsa_pkcs1_verify:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA512:1536:16:"a59d9b7269b102b7be684ec5e28db79992e6d3231e77c90b78960c2638b35ef6dbdac1ac59e7249d96d426e7f99397eabc6b8903fe1942da580322b98bafacd81bb911c29666f83886a2a2864f3552044300e60cedd5a8c321c43e280413dc41673c39a11b98a885486f8187a70f270185c4c12bc48a1968305269776c070ef69d4913589a887c4d0f5e7dd58bd806d0d49a14a1762c38665cef4646ff13a0cd29c3a60460703c3d051d5b28c660bffb5f8bd43d495ffa64175f72b8abe5fddd":16:"11":"0b4d96f411c727a262d6d0ade34195b78603551061917d060f89add47b09dfe8715f4f9147d327dc25e91fe457e5d1a2f22cd8fe6fe8e29d2060658307c87a40640650fef3d4b289a6c3febc5a100b29a8b56623afb29fd3c13ea372bf3c638c1db25f8bd8c74c821beec7b5affcace1d05d056a6c2d3035926c7a268df4751a54bc20a6b8cfd729a7cba309ae817daccbef9950a482cf23950a8ca1d3a13ddb7d8d0f87ad5587d4d9ebe19fe93457597a7bdd056c2fd4cea7d31e4a0e595a7b":0
+RSA PKCS1 Verify v1.5 padding too short
+depends_on:MBEDTLS_SHA1_C:MBEDTLS_PKCS1_V15
+mbedtls_rsa_pkcs1_verify:"AABBCC03020100FFFFFFFFFF1122330A0B0CCCDDDDDDDDDD":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA1:1024:16:"9292758453063D803DD603D5E777D7888ED1D5BF35786190FA2F23EBC0848AEADDA92CA6C3D80B32C4D109BE0F36D6AE7130B9CED7ACDF54CFC7555AC14EEBAB93A89813FBF3C4F8066D2D800F7C38A81AE31942917403FF4946B0A83D3D3E05EE57C6F5F5606FB5D4BC6CD34EE0801A5E94BB77B07507233A0BC7BAC8F90F79":16:"10001":"6edd56f397d9bc6d176bbe3d80946fc352ad6127b85b1d67d849c0a38cbde7222c5fafbb18dcef791178a8e15f5c8cd91869f8ca4b758c46ce3e229bf666d2e3e296544351bcb5db7e0004f6c0800f76a432071297e405759d4324d1cf1c412758be93a39f834e03dee59e28ac571ce2b0b3c8fe639979f516223b54027340a5":MBEDTLS_ERR_RSA_VERIFY_FAILED
+
+# The following tests check whether the use of reduced length encodings (as mandated for DER in contrast to BER) is enforced in
+# the verification of PKCS1 v1.5 signatures - this is relevant to prevent Bleichenbacher signature forgery attacks.
+# The test data has been generated by signing a test file using `programs/pkey/rsa_sign` after making modifications
+# to `mbedtls_rsa_rsassa_pkcs1_v15_encode` to force the use of non-reduced encodings in different places as indicated in the respective tests.
+# See the documentation of `mbedtls_rsa_rsassa_pkcs1_v15_encode` for the layout of the relevant ASN.1 structure.
+# Correct signature with DER-compliant reduced length encodings
+RSA PKCS1 Verify v1.5 reduced length encoding
+depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
+mbedtls_rsa_pkcs1_verify:"7369676e617475726520746573740a":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA256:1024:16:"A1D46FBA2318F8DCEF16C280948B1CF27966B9B47225ED2989F8D74B45BD36049C0AAB5AD0FF003553BA843C8E12782FC5873BB89A3DC84B883D25666CD22BF3ACD5B675969F8BEBFBCAC93FDD927C7442B178B10D1DFF9398E52316AAE0AF74E594650BDC3C670241D418684593CDA1A7B9DC4F20D2FDC6F66344074003E211":16:"10001":"5B56096ECADA4DAC299FD3D6091C1BE4D7C4210086E61ADA6FFC267A690034DAFB3734035880B9E71CEB0331C32C8DE1A254D777DFE3C848AC7764907602452EC16FD8EB3664E2E682DB3AA8979059BFADFE6192D9029844C8CAF310552717DD5B5B36A9910CFABE5C54AC16F3A3461DEE730060981BD9B47EE8D6644963B7CA":0
+
+# Non-reduced 1-byte length encoding in `DigestInfo` ASN.1 element
+RSA PKCS1 Verify v1.5 non-reduced length encoding #1
+depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
+mbedtls_rsa_pkcs1_verify:"7369676e617475726520746573740a":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA256:1024:16:"A1D46FBA2318F8DCEF16C280948B1CF27966B9B47225ED2989F8D74B45BD36049C0AAB5AD0FF003553BA843C8E12782FC5873BB89A3DC84B883D25666CD22BF3ACD5B675969F8BEBFBCAC93FDD927C7442B178B10D1DFF9398E52316AAE0AF74E594650BDC3C670241D418684593CDA1A7B9DC4F20D2FDC6F66344074003E211":16:"10001":"2FCF7FC1B60B3C083872B1BD9C666745921951A8A9E099FD629675F620B670713519C4A97B870591B97FE5C5DB2FC2A0A3FCB0016536D1205AA32BA8BFCF54ABD542C02F7FCEA3C3531D7A87C82ED5B151A9599F1BDB070A905F5B721DE3C22F8AC35034C607920CE0699D7F79E5913915F3A01856B5D30F9E68F0CD7856D40F":MBEDTLS_ERR_RSA_VERIFY_FAILED
+
+# Non-reduced 2-byte length encoding for `digestAlgorithm` ASN.1 element
+RSA PKCS1 Verify v1.5 non-reduced length encoding #2
+depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
+mbedtls_rsa_pkcs1_verify:"7369676e617475726520746573740a":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA256:1024:16:"A1D46FBA2318F8DCEF16C280948B1CF27966B9B47225ED2989F8D74B45BD36049C0AAB5AD0FF003553BA843C8E12782FC5873BB89A3DC84B883D25666CD22BF3ACD5B675969F8BEBFBCAC93FDD927C7442B178B10D1DFF9398E52316AAE0AF74E594650BDC3C670241D418684593CDA1A7B9DC4F20D2FDC6F66344074003E211":16:"10001":"3C27512A8FDC973D856C0F288BE27D00D54FC0B359C520DA73A05156D98CDD6A83E6657BFA81D7B9716EEDFD98C08CD82F399298782782AE341D9AABCBB6B5F9C6552DE1D8B93047E1135032653F4F65A8937352E903864E008429E049680E3AA80F5DE1C7408C403011CEF4A3ECA549C027C8954BFBCA21F2A41C3EB0278029":MBEDTLS_ERR_RSA_VERIFY_FAILED
+
+# Non-reduced 3-byte length encoding for optional parameters in `digestAlgorithm` ASN.1 element
+RSA PKCS1 Verify v1.5 non-reduced length encoding #3
+depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
+mbedtls_rsa_pkcs1_verify:"7369676e617475726520746573740a":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA256:1024:16:"A1D46FBA2318F8DCEF16C280948B1CF27966B9B47225ED2989F8D74B45BD36049C0AAB5AD0FF003553BA843C8E12782FC5873BB89A3DC84B883D25666CD22BF3ACD5B675969F8BEBFBCAC93FDD927C7442B178B10D1DFF9398E52316AAE0AF74E594650BDC3C670241D418684593CDA1A7B9DC4F20D2FDC6F66344074003E211":16:"10001":"24BEB8502F24E0D11D9C10CEE4435EA972CEC93C23936E815ED2DF41BECEDDE889AF85BBEAF1B8C6928913AC523EA1D6653832E9D4E74F55B76771EA84F5A607342C341A14AB258019F38DBAEE4B967C8C8D26D6AF2583D32988471BA38751B6A67BA3D1147619C266A9AAC34244740BB59CD9DB3AFF19438B04C619AB719123":MBEDTLS_ERR_RSA_VERIFY_FAILED
+
+# Non-reduced 4-byte length encoding in `digest` ASN.1 element
+RSA PKCS1 Verify v1.5 non-reduced length encoding #4
+depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
+mbedtls_rsa_pkcs1_verify:"7369676e617475726520746573740a":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA256:1024:16:"A1D46FBA2318F8DCEF16C280948B1CF27966B9B47225ED2989F8D74B45BD36049C0AAB5AD0FF003553BA843C8E12782FC5873BB89A3DC84B883D25666CD22BF3ACD5B675969F8BEBFBCAC93FDD927C7442B178B10D1DFF9398E52316AAE0AF74E594650BDC3C670241D418684593CDA1A7B9DC4F20D2FDC6F66344074003E211":16:"10001":"13172EF7362CF421103FE1893429FAE85F83636BA8AF545252599A39892E62CEC317DC47C1D6B19328B63CDFD02FA0B49CE7980504635251FF08C0A1308C64D6466DFBF1EF2BA49EFDD6C2C888A30870EC2DC0FA4D67FDE6631C85ED2CEF8EEBF5578C974CBA4A04034D9B579B420D6CA93E4BFC09E014542A0EFB902AF90C5E":MBEDTLS_ERR_RSA_VERIFY_FAILED
+
+# Non-reduced 3-byte length encoding for OID in `digestAlgorithm` ASN.1 element
+RSA PKCS1 Verify v1.5 non-reduced length encoding #5
+depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
+mbedtls_rsa_pkcs1_verify:"7369676e617475726520746573740a":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA256:1024:16:"A1D46FBA2318F8DCEF16C280948B1CF27966B9B47225ED2989F8D74B45BD36049C0AAB5AD0FF003553BA843C8E12782FC5873BB89A3DC84B883D25666CD22BF3ACD5B675969F8BEBFBCAC93FDD927C7442B178B10D1DFF9398E52316AAE0AF74E594650BDC3C670241D418684593CDA1A7B9DC4F20D2FDC6F66344074003E211":16:"10001":"65DD518F63A2E289C035E9F2A9927BF5A6A74FF6FEFFF61AFCC52ED4A8A5B93534A3AD1709136306EE1379B47A4863BC6ED879E92CD6F99AA5B5F106102BDAE8DAFB15CF6EF00CB5FA63967706528DEE8876F3D04E8D75533009C73DA4C5744D20FFDB18EA78EE4D5D9D6F7BD3AFC2AD9A0EDDD56AA40AAEF789E6FB12AB6DE7":MBEDTLS_ERR_RSA_VERIFY_FAILED
+
RSA PKCS1 Sign #1 (SHA512, 1536 bits RSA)
depends_on:MBEDTLS_SHA512_C:MBEDTLS_PKCS1_V15
mbedtls_rsa_pkcs1_sign:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA512:1536:16:"c8c67df894c882045ede26a9008ab09ea0672077d7bc71d412511cd93981ddde8f91b967da404056c39f105f7f239abdaff92923859920f6299e82b95bd5b8c959948f4a035cbd693ad83014294d349813d1ad57911a6355d0731fe3a034e9db":16:"f15147d0e7c04a1e3f37adde802cdc610999bf7ab0088434aaeda0c0ab3910b14d2ce56cb66bffd97552195fae8b061077e03920814d8b9cfb5a3958b3a82c2a7fc97e55db5978b47a922156eb8a3e55c06a54a45d1670abdfb995489c4d0051":16:"bd429bb7c3b00bbea19ba664c0f8172d1a73c3cfa05e2ed656d570c1590918bb7e372ed25e2cd71395ba0a9b1a30f3ee012ffb0546cab8e3581fe3e23f44ab57a8aee9717e71a936a580fa8572d450fb00339a6f6704b717df0c149a465bab768c61500cd93b61113ff3e4389167f7b2c8e3c0da2d4765286bee555b0bcb4998f59b14fad03180a17c8b4f69bcd1234f4ae85950137665ac2ba80b55cc9b1aafb454b83771aa755acd2a00e93ddb65e696dbed8bdca69fb5e0c5c2097b9cfe4b":16:"3":"93b6fa99485c116ca6efdd4202ea1cf49f4c6345fae692584413743ce5b65510e8e4690aee9a19ea1ff10d57f22aa3548d839f28a8525a34354e9e58e0f3947e056ce2554e21bf287e220b98db3b551258cd42b495e5d1a3bbc83c9d1a02f2a300ef6d866ea75108e44ebb3e16b47df2f6de28feb2be3874dbbf21599451082d86e9f2f462575a8185c69aa1f1fcb6a363c5d71aeba2103449eaf3845285291148d5f78d1646b8dc95cbcc4082f987d948b0e7d4e80b60595f8a7517584e1643":0
RSA PKCS1 Sign #2 Verify (Fail)
depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
-mbedtls_rsa_pkcs1_verify:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA256:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"5aee2b9dbc02a6a2d87ff64a64165dc0b9ce70c79bab2d287939e2601c3223e0493988d5468731ae4edc7d5f5d449335c204fdb0e192c1915c9d694d3a61c3be14df79c4b34d6ac73707829024d263c94f9107fa93f3783de3965522336e18d1e01a142b5103451bb97839eaf2f44703a63050a36b78aef4072ea1a8daaaf1a2918fc03ee957a9c09efdc6287bcb4d6aec4723290294b249b3e3dc63157b560ad9c867323a73ebeb360cc9e482111643b0d86c4e33dcf170155590f0eba7d170789e84de336b7fe2f6cf485ddca94607a4ff379fc49d375c730249dd1a210e7dccd763d1c23c7532e769c6aa88e38e8654ff90f7b34df4c07ba90e89099ec1ed":MBEDTLS_ERR_RSA_INVALID_PADDING
+mbedtls_rsa_pkcs1_verify:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":MBEDTLS_RSA_PKCS_V15:MBEDTLS_MD_SHA256:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"5aee2b9dbc02a6a2d87ff64a64165dc0b9ce70c79bab2d287939e2601c3223e0493988d5468731ae4edc7d5f5d449335c204fdb0e192c1915c9d694d3a61c3be14df79c4b34d6ac73707829024d263c94f9107fa93f3783de3965522336e18d1e01a142b5103451bb97839eaf2f44703a63050a36b78aef4072ea1a8daaaf1a2918fc03ee957a9c09efdc6287bcb4d6aec4723290294b249b3e3dc63157b560ad9c867323a73ebeb360cc9e482111643b0d86c4e33dcf170155590f0eba7d170789e84de336b7fe2f6cf485ddca94607a4ff379fc49d375c730249dd1a210e7dccd763d1c23c7532e769c6aa88e38e8654ff90f7b34df4c07ba90e89099ec1ed":MBEDTLS_ERR_RSA_VERIFY_FAILED
RSA PKCS1 Sign #3 (SHA224, 2048 bits RSA)
depends_on:MBEDTLS_SHA256_C:MBEDTLS_PKCS1_V15
mbedtls_rsa_check_privkey:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":16:"":16:"9A66CF76572A71A17475794FA1C8C70D987E581E990D772BB27C77C53FF1ECBB31260E9EDAFAEBC79991807E48918EAB8C3A5F03A600F30C69511546AE788EDF53168E2D035D300EDCD5E4BF3AA2A6D603EA0A7BD11E1C1089657306DF8A64E7F1BC6B266B825C1A6C5F0FC85775F4CF7ACD63367E42EAFE46511D58AD6DFE0F":16:"844DBDD20925D9164F9A1E2F707076C261CCA8337D0241392B38AE3C12342F3AC14F8FD6DF4A1C36839662BD0D227344CD55A32AE5DBD2309A9A2B8A2C82BE6DDDDCE81D1B694775D9047AA765CA0C6E1BB8E61C8B7BE27ED711E8EE2FEAD87F3491F76A6D2262C14189EACDFD4CEFE0BF9D0A5B49857E0ED22CBEB98DC8D45B":16:"4951A7B174DF972C37BADCC38457B5EDD1F078BC613E75CE25E08814E12461C7A1C189A70EB8138294298D141244C7A9DE31AB4F6D38B40B04D6353CD30F77ADBF66BBDE41C7BE463C5E30AAA3F7BAD6CEE99506DEAAFA2F335C1B1C5C88B8ABB0D0387EE0D1B4E7027F7F085A025CEDB5CCE18B88C0462F1C3C910D47C0D4AB":MBEDTLS_ERR_RSA_KEY_CHECK_FAILED
RSA Check Private key #7 (No DP)
+depends_on:!MBEDTLS_RSA_NO_CRT
mbedtls_rsa_check_privkey:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"":16:"844DBDD20925D9164F9A1E2F707076C261CCA8337D0241392B38AE3C12342F3AC14F8FD6DF4A1C36839662BD0D227344CD55A32AE5DBD2309A9A2B8A2C82BE6DDDDCE81D1B694775D9047AA765CA0C6E1BB8E61C8B7BE27ED711E8EE2FEAD87F3491F76A6D2262C14189EACDFD4CEFE0BF9D0A5B49857E0ED22CBEB98DC8D45B":16:"4951A7B174DF972C37BADCC38457B5EDD1F078BC613E75CE25E08814E12461C7A1C189A70EB8138294298D141244C7A9DE31AB4F6D38B40B04D6353CD30F77ADBF66BBDE41C7BE463C5E30AAA3F7BAD6CEE99506DEAAFA2F335C1B1C5C88B8ABB0D0387EE0D1B4E7027F7F085A025CEDB5CCE18B88C0462F1C3C910D47C0D4AB":MBEDTLS_ERR_RSA_KEY_CHECK_FAILED
RSA Check Private key #8 (No DQ)
+depends_on:!MBEDTLS_RSA_NO_CRT
mbedtls_rsa_check_privkey:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"9A66CF76572A71A17475794FA1C8C70D987E581E990D772BB27C77C53FF1ECBB31260E9EDAFAEBC79991807E48918EAB8C3A5F03A600F30C69511546AE788EDF53168E2D035D300EDCD5E4BF3AA2A6D603EA0A7BD11E1C1089657306DF8A64E7F1BC6B266B825C1A6C5F0FC85775F4CF7ACD63367E42EAFE46511D58AD6DFE0F":16:"":16:"4951A7B174DF972C37BADCC38457B5EDD1F078BC613E75CE25E08814E12461C7A1C189A70EB8138294298D141244C7A9DE31AB4F6D38B40B04D6353CD30F77ADBF66BBDE41C7BE463C5E30AAA3F7BAD6CEE99506DEAAFA2F335C1B1C5C88B8ABB0D0387EE0D1B4E7027F7F085A025CEDB5CCE18B88C0462F1C3C910D47C0D4AB":MBEDTLS_ERR_RSA_KEY_CHECK_FAILED
RSA Check Private key #9 (No QP)
+depends_on:!MBEDTLS_RSA_NO_CRT
mbedtls_rsa_check_privkey:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"9A66CF76572A71A17475794FA1C8C70D987E581E990D772BB27C77C53FF1ECBB31260E9EDAFAEBC79991807E48918EAB8C3A5F03A600F30C69511546AE788EDF53168E2D035D300EDCD5E4BF3AA2A6D603EA0A7BD11E1C1089657306DF8A64E7F1BC6B266B825C1A6C5F0FC85775F4CF7ACD63367E42EAFE46511D58AD6DFE0F":16:"844DBDD20925D9164F9A1E2F707076C261CCA8337D0241392B38AE3C12342F3AC14F8FD6DF4A1C36839662BD0D227344CD55A32AE5DBD2309A9A2B8A2C82BE6DDDDCE81D1B694775D9047AA765CA0C6E1BB8E61C8B7BE27ED711E8EE2FEAD87F3491F76A6D2262C14189EACDFD4CEFE0BF9D0A5B49857E0ED22CBEB98DC8D45B":16:"":MBEDTLS_ERR_RSA_KEY_CHECK_FAILED
RSA Check Private key #10 (Incorrect)
mbedtls_rsa_gen_key:2048:3:0
RSA Generate Key - 1025 bit key
+# mbedtls_rsa_gen_key only supports even-sized keys
mbedtls_rsa_gen_key:1025:3:MBEDTLS_ERR_RSA_BAD_INPUT_DATA
+RSA Validate Params, toy example
+mbedtls_rsa_validate_params:10:"15":10:"3":10:"5":10:"3":10:"3":0:0
+
+RSA Validate Params, toy example, N missing
+mbedtls_rsa_validate_params:10:"":10:"3":10:"5":10:"3":10:"3":0:0
+
+RSA Validate Params, toy example, E missing
+mbedtls_rsa_validate_params:10:"15":10:"3":10:"5":10:"3":10:"":0:0
+
+RSA Validate Params, toy example, corrupted
+mbedtls_rsa_validate_params:10:"16":10:"3":10:"5":10:"3":10:"3":0:MBEDTLS_ERR_RSA_KEY_CHECK_FAILED
+
+RSA Validate Params, toy example, non-primes, no PRNG
+mbedtls_rsa_validate_params:10:"45":10:"9":10:"5":10:"7":10:"23":0:0
+
+RSA Validate Params, toy example, non-primes, PRNG
+mbedtls_rsa_validate_params:10:"45":10:"9":10:"5":10:"7":10:"23":1:MBEDTLS_ERR_RSA_KEY_CHECK_FAILED
+
+RSA Validate Params
+mbedtls_rsa_validate_params:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":0:0
+
+RSA Validate Params, N missing
+mbedtls_rsa_validate_params:16:"":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":0:0
+
+RSA Validate Params, bad N
+mbedtls_rsa_validate_params:16:"b38bc65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":0:MBEDTLS_ERR_RSA_KEY_CHECK_FAILED
+
+RSA Validate Params, non-prime, no PRNG
+mbedtls_rsa_validate_params:16:"":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd18":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"":16:"":0:0
+
+RSA Validate Params, non-prime, PRNG
+mbedtls_rsa_validate_params:16:"":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd18":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"":16:"":1:MBEDTLS_ERR_RSA_KEY_CHECK_FAILED
+
+RSA Deduce Private, toy example
+mbedtls_rsa_deduce_private_exponent:10:"7":10:"11":10:"7":10:"13":0:0
+
+RSA Deduce Private, toy example, corrupted
+mbedtls_rsa_deduce_private_exponent:10:"3":10:"5":10:"3":10:"3":1:MBEDTLS_ERR_MPI_NOT_ACCEPTABLE
+
+RSA Deduce Private
+mbedtls_rsa_deduce_private_exponent:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"3":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":0:0
+
+RSA Deduce Private, corrupted
+mbedtls_rsa_deduce_private_exponent:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"3":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":1:MBEDTLS_ERR_MPI_NOT_ACCEPTABLE
+
+RSA Deduce Primes, toy example
+mbedtls_rsa_deduce_primes:10:"35":10:"5":10:"5":10:"5":10:"7":0:0
+
+RSA Deduce Primes, toy example, corrupted
+mbedtls_rsa_deduce_primes:10:"35":10:"5":10:"5":10:"5":10:"7":1:MBEDTLS_ERR_MPI_BAD_INPUT_DATA
+
+RSA Deduce Moduli
+mbedtls_rsa_deduce_primes:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":0:0
+
+RSA Deduce Moduli, corrupted
+mbedtls_rsa_deduce_primes:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":1:MBEDTLS_ERR_MPI_BAD_INPUT_DATA
+
+RSA Import (N,P,Q,D,E)
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":0:1:0:0
+
+RSA Import (N,P,Q,D,E), inconsistent
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC3672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":0:1:MBEDTLS_ERR_RSA_KEY_CHECK_FAILED:0
+
+RSA Import (N,P,Q,D,E), successive
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":1:1:0:0
+
+RSA Import (N,P,Q,D,E), successive, inconsistent
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC3672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":1:1:MBEDTLS_ERR_RSA_KEY_CHECK_FAILED:0
+
+RSA Import (-,P,Q,D,E)
+mbedtls_rsa_import:16:"":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":0:1:0:0
+
+RSA Import (-,P,Q,D,E), successive
+mbedtls_rsa_import:16:"":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":1:1:0:0
+
+RSA Import (N,-,-,D,E)
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"":16:"":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":0:1:0:0
+
+RSA Import (N,-,-,D,E), succesive
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"":16:"":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":1:1:0:0
+
+RSA Import (N,P,Q,-,E)
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"":16:"3":0:1:0:0
+
+RSA Import (N,P,Q,-,E), successive
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"":16:"3":1:1:0:0
+
+RSA Import (-,P,Q,-,E)
+mbedtls_rsa_import:16:"":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"":16:"3":0:1:0:0
+
+RSA Import (-,P,Q,-,E), successive
+mbedtls_rsa_import:16:"":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"":16:"3":1:1:0:0
+
+RSA Import (N,-,Q,-,E)
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"":16:"3":0:1:0:MBEDTLS_ERR_RSA_BAD_INPUT_DATA
+
+RSA Import (N,-,Q,-,E), successive
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"":16:"3":1:1:0:MBEDTLS_ERR_RSA_BAD_INPUT_DATA
+
+RSA Import (N,-,-,-,E), complete public key
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"":16:"":16:"":16:"3":0:0:0:0
+
+RSA Import (N,-,-,-,E), complete public key, successive
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"":16:"":16:"":16:"3":1:0:0:0
+
+RSA Import (N,-,-,-,E), complete public key, corrupted
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"":16:"":16:"":16:"4":0:0:MBEDTLS_ERR_RSA_KEY_CHECK_FAILED:0
+
+RSA Import (N,-,-,-,E), complete public key, successive, corrupted
+mbedtls_rsa_import:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"":16:"":16:"":16:"4":1:0:MBEDTLS_ERR_RSA_KEY_CHECK_FAILED:0
+
+RSA Import Raw (N,P,Q,D,E), complete private key
+mbedtls_rsa_import_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":"03":0:1:0:0
+
+RSA Import Raw (N,P,Q,D,E), successive
+mbedtls_rsa_import_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":"03":1:1:0:0
+
+RSA Import Raw (-,P,Q,D,E)
+mbedtls_rsa_import_raw:"":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":"03":0:1:0:0
+
+RSA Import Raw (-,P,Q,D,E), successive
+mbedtls_rsa_import_raw:"":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":"03":1:1:0:0
+
+RSA Import Raw (N,-,-,D,E)
+mbedtls_rsa_import_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"":"":"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":"03":0:1:0:0
+
+RSA Import Raw (N,-,-,D,E), successive
+mbedtls_rsa_import_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"":"":"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":"03":1:1:0:0
+
+RSA Import Raw (N,P,Q,-,E)
+mbedtls_rsa_import_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"":"03":0:1:0:0
+
+RSA Import Raw (N,P,Q,-,E), successive
+mbedtls_rsa_import_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"":"03":1:1:0:0
+
+RSA Import Raw (-,P,Q,-,E)
+mbedtls_rsa_import_raw:"":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"":"03":0:1:0:0
+
+RSA Import Raw (-,P,Q,-,E), successive
+mbedtls_rsa_import_raw:"":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"":"03":1:1:0:0
+
+RSA Import Raw (N,-,Q,-,E)
+mbedtls_rsa_import_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"":"03":0:1:0:MBEDTLS_ERR_RSA_BAD_INPUT_DATA
+
+RSA Import Raw (N,-,Q,-,E), successive
+mbedtls_rsa_import_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"":"03":1:1:0:MBEDTLS_ERR_RSA_BAD_INPUT_DATA
+
+RSA Import Raw (N,-,-,-,E)
+mbedtls_rsa_import_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"":"":"":"03":0:0:0:0
+
+RSA Import Raw (N,-,-,-,E), successive
+mbedtls_rsa_import_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"":"":"":"03":1:0:0:0
+
+RSA Import Raw (-,-,-,-,-)
+mbedtls_rsa_import_raw:"":"":"":"":"":0:0:0:MBEDTLS_ERR_RSA_BAD_INPUT_DATA
+
+RSA Export (N,P,Q,D,E)
+mbedtls_rsa_export:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":1:0
+
+RSA Export (N,P,Q,D,E), successive
+mbedtls_rsa_export:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":1:1
+
+RSA Export (N,-,-,D,E)
+mbedtls_rsa_export:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"":16:"":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":1:0
+
+RSA Export (N,-,-,D,E), succesive
+mbedtls_rsa_export:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"":16:"":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"3":1:1
+
+RSA Export (N,P,Q,-,E)
+mbedtls_rsa_export:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"":16:"3":1:0
+
+RSA Export (N,P,Q,-,E), successive
+mbedtls_rsa_export:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"":16:"3":1:1
+
+RSA Export (N,-,-,-,E)
+mbedtls_rsa_export:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"":16:"":16:"":16:"3":0:0
+
+RSA Export Raw (N,P,Q,D,E)
+mbedtls_rsa_export_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":"03":1:0
+
+RSA Export Raw (N,P,Q,D,E), successive
+mbedtls_rsa_export_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":"03":1:1
+
+RSA Export Raw (N,-,-,D,E)
+mbedtls_rsa_export_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"":"":"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":"03":1:0
+
+RSA Export Raw (N,-,-,D,E), succesive
+mbedtls_rsa_export_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"":"":"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":"03":1:1
+
+RSA Export Raw (N,P,Q,-,E)
+mbedtls_rsa_export_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"":"03":1:0
+
+RSA Export Raw (N,P,Q,-,E), successive
+mbedtls_rsa_export_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":"":"03":1:1
+
+RSA Export Raw (N,-,-,-,E)
+mbedtls_rsa_export_raw:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":"":"":"":"03":0:0
+
RSA PKCS1 Encrypt Bad RNG
depends_on:MBEDTLS_PKCS1_V15
rsa_pkcs1_encrypt_bad_rng:"4E636AF98E40F3ADCFCCB698F4E80B9F":MBEDTLS_RSA_PKCS_V15:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"a42eda41e56235e666e7faaa77100197f657288a1bf183e4820f0c37ce2c456b960278d6003e0bbcd4be4a969f8e8fd9231e1f492414f00ed09844994c86ec32db7cde3bec7f0c3dbf6ae55baeb2712fa609f5fc3207a824eb3dace31849cd6a6084318523912bccb84cf42e3c6d6d1685131d69bb545acec827d2b0dfdd5568b7dcc4f5a11d6916583fefa689d367f8c9e1d95dcd2240895a9470b0c1730f97cd6e8546860bd254801769f54be96e16362ddcbf34d56035028890199e0f48db38642cb66a4181e028a6443a404fea284ce02b4614b683367d40874e505611d23142d49f06feea831d52d347b13610b413c4efc43a6de9f0b08d2a951dc503b6":MBEDTLS_ERR_RSA_RNG_FAILED
/* BEGIN_HEADER */
#include "mbedtls/rsa.h"
+#include "mbedtls/rsa_internal.h"
#include "mbedtls/md2.h"
#include "mbedtls/md4.h"
#include "mbedtls/md5.h"
#include "mbedtls/sha512.h"
#include "mbedtls/entropy.h"
#include "mbedtls/ctr_drbg.h"
+
/* END_HEADER */
/* BEGIN_DEPENDENCIES
unsigned char output[1000];
unsigned char output_str[1000];
mbedtls_rsa_context ctx;
- mbedtls_mpi P1, Q1, H, G;
+ mbedtls_mpi N, P, Q, E;
int msg_len;
rnd_pseudo_info rnd_info;
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P );
+ mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, padding_mode, 0 );
memset( message_str, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
- ctx.len = mod / 8;
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.P, radix_P, input_P ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.Q, radix_Q, input_Q ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
- TEST_ASSERT( mbedtls_mpi_sub_int( &P1, &ctx.P, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_sub_int( &Q1, &ctx.Q, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_gcd( &G, &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.D , &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DP, &ctx.D, &P1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DQ, &ctx.D, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.QP, &ctx.Q, &ctx.P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
msg_len = unhexify( message_str, message_hex_string );
if( mbedtls_md_info_from_type( digest ) != NULL )
- TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str, msg_len, hash_result ) == 0 );
+ TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ),
+ message_str, msg_len, hash_result ) == 0 );
- TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, digest, 0, hash_result, output ) == result );
+ TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &rnd_pseudo_rand, &rnd_info,
+ MBEDTLS_RSA_PRIVATE, digest, 0,
+ hash_result, output ) == result );
if( result == 0 )
{
hexify( output_str, output, ctx.len );
}
exit:
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P );
+ mbedtls_mpi_free( &Q ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
mbedtls_rsa_context ctx;
int msg_len;
+ mbedtls_mpi N, E;
+
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, padding_mode, 0 );
memset( message_str, 0x00, 1000 );
memset( hash_result, 0x00, 1000 );
memset( result_str, 0x00, 1000 );
- ctx.len = mod / 8;
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
msg_len = unhexify( message_str, message_hex_string );
TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, digest, 0, hash_result, result_str ) == result );
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
char *input_N, int radix_E, char *input_E,
char *result_hex_str )
{
+ int res;
unsigned char message_str[1000];
unsigned char hash_result[1000];
unsigned char output[1000];
unsigned char output_str[1000];
mbedtls_rsa_context ctx;
- mbedtls_mpi P1, Q1, H, G;
+ mbedtls_mpi N, P, Q, E;
int hash_len;
rnd_pseudo_info rnd_info;
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
mbedtls_rsa_init( &ctx, padding_mode, 0 );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P );
+ mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E );
memset( message_str, 0x00, 1000 );
memset( hash_result, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
- ctx.len = mod / 8;
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.P, radix_P, input_P ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.Q, radix_Q, input_Q ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
- TEST_ASSERT( mbedtls_mpi_sub_int( &P1, &ctx.P, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_sub_int( &Q1, &ctx.Q, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_gcd( &G, &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.D , &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DP, &ctx.D, &P1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DQ, &ctx.D, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.QP, &ctx.Q, &ctx.P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
unhexify( message_str, message_hex_string );
hash_len = unhexify( hash_result, hash_result_string );
- TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_NONE, hash_len, hash_result, output ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &rnd_pseudo_rand, &rnd_info,
+ MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_NONE,
+ hash_len, hash_result, output ) == 0 );
hexify( output_str, output, ctx.len );
memset( output, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
- TEST_ASSERT( mbedtls_rsa_rsaes_pkcs1_v15_encrypt( &ctx,
+ res = mbedtls_rsa_rsaes_pkcs1_v15_encrypt( &ctx,
&rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE,
- hash_len, hash_result, output ) == 0 );
+ hash_len, hash_result, output );
- hexify( output_str, output, ctx.len );
+#if !defined(MBEDTLS_RSA_ALT)
+ TEST_ASSERT( res == 0 );
+#else
+ TEST_ASSERT( ( res == 0 ) ||
+ ( res == MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION ) );
+#endif
- TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 );
+ if( res == 0 )
+ {
+ hexify( output_str, output, ctx.len );
+ TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 );
+ }
}
exit:
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P );
+ mbedtls_mpi_free( &Q ); mbedtls_mpi_free( &E );
+
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
char *input_N, int radix_E, char *input_E,
char *result_hex_str, int correct )
{
+ int res;
unsigned char message_str[1000];
unsigned char hash_result[1000];
unsigned char result_str[1000];
mbedtls_rsa_context ctx;
size_t hash_len, olen;
+ mbedtls_mpi N, E;
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
+
mbedtls_rsa_init( &ctx, padding_mode, 0 );
memset( message_str, 0x00, 1000 );
memset( hash_result, 0x00, 1000 );
memset( result_str, 0x00, 1000 );
memset( output, 0x00, sizeof( output ) );
- ctx.len = mod / 8;
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
unhexify( message_str, message_hex_string );
hash_len = unhexify( hash_result, hash_result_string );
unhexify( result_str, result_hex_str );
- TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_NONE, hash_len, hash_result, result_str ) == correct );
+ TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL,
+ MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_NONE,
+ hash_len, hash_result,
+ result_str ) == correct );
/* For PKCS#1 v1.5, there is an alternative way to verify signatures */
if( padding_mode == MBEDTLS_RSA_PKCS_V15 )
{
int ok;
- TEST_ASSERT( mbedtls_rsa_rsaes_pkcs1_v15_decrypt( &ctx,
+ res = mbedtls_rsa_rsaes_pkcs1_v15_decrypt( &ctx,
NULL, NULL, MBEDTLS_RSA_PUBLIC,
- &olen, result_str, output, sizeof( output ) ) == 0 );
+ &olen, result_str, output, sizeof( output ) );
- ok = olen == hash_len && memcmp( output, hash_result, olen ) == 0;
- if( correct == 0 )
- TEST_ASSERT( ok == 1 );
- else
- TEST_ASSERT( ok == 0 );
+#if !defined(MBEDTLS_RSA_ALT)
+ TEST_ASSERT( res == 0 );
+#else
+ TEST_ASSERT( ( res == 0 ) ||
+ ( res == MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION ) );
+#endif
+
+ if( res == 0 )
+ {
+ ok = olen == hash_len && memcmp( output, hash_result, olen ) == 0;
+ if( correct == 0 )
+ TEST_ASSERT( ok == 1 );
+ else
+ TEST_ASSERT( ok == 0 );
+ }
}
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
size_t msg_len;
rnd_pseudo_info rnd_info;
+ mbedtls_mpi N, E;
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
+
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
mbedtls_rsa_init( &ctx, padding_mode, 0 );
memset( output, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
- ctx.len = mod / 8;
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
msg_len = unhexify( message_str, message_hex_string );
- TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PUBLIC, msg_len, message_str, output ) == result );
+ TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_pseudo_rand, &rnd_info,
+ MBEDTLS_RSA_PUBLIC, msg_len,
+ message_str, output ) == result );
if( result == 0 )
{
hexify( output_str, output, ctx.len );
}
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
mbedtls_rsa_context ctx;
size_t msg_len;
+ mbedtls_mpi N, E;
+
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, padding_mode, 0 );
memset( message_str, 0x00, 1000 );
memset( output, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
- ctx.len = mod / 8;
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
msg_len = unhexify( message_str, message_hex_string );
- TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_zero_rand, NULL, MBEDTLS_RSA_PUBLIC, msg_len, message_str, output ) == result );
+ TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_zero_rand, NULL,
+ MBEDTLS_RSA_PUBLIC, msg_len,
+ message_str, output ) == result );
if( result == 0 )
{
hexify( output_str, output, ctx.len );
}
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
unsigned char output[1000];
unsigned char output_str[1000];
mbedtls_rsa_context ctx;
- mbedtls_mpi P1, Q1, H, G;
size_t output_len;
rnd_pseudo_info rnd_info;
+ mbedtls_mpi N, P, Q, E;
+
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P );
+ mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E );
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
mbedtls_rsa_init( &ctx, padding_mode, 0 );
memset( message_str, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
- ctx.len = mod / 8;
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.P, radix_P, input_P ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.Q, radix_Q, input_Q ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
- TEST_ASSERT( mbedtls_mpi_sub_int( &P1, &ctx.P, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_sub_int( &Q1, &ctx.Q, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_gcd( &G, &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.D , &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DP, &ctx.D, &P1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DQ, &ctx.D, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.QP, &ctx.Q, &ctx.P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
unhexify( message_str, message_hex_string );
}
exit:
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P );
+ mbedtls_mpi_free( &Q ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
unsigned char output_str[1000];
mbedtls_rsa_context ctx, ctx2; /* Also test mbedtls_rsa_copy() while at it */
+ mbedtls_mpi N, E;
+
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, 0 );
mbedtls_rsa_init( &ctx2, MBEDTLS_RSA_PKCS_V15, 0 );
memset( message_str, 0x00, 1000 );
memset( output, 0x00, 1000 );
memset( output_str, 0x00, 1000 );
- ctx.len = mod / 8;
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
unhexify( message_str, message_hex_string );
}
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
mbedtls_rsa_free( &ctx2 );
}
unsigned char output[1000];
unsigned char output_str[1000];
mbedtls_rsa_context ctx, ctx2; /* Also test mbedtls_rsa_copy() while at it */
- mbedtls_mpi P1, Q1, H, G;
+ mbedtls_mpi N, P, Q, E;
rnd_pseudo_info rnd_info;
int i;
- mbedtls_mpi_init( &P1 ); mbedtls_mpi_init( &Q1 ); mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G );
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P );
+ mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, 0 );
mbedtls_rsa_init( &ctx2, MBEDTLS_RSA_PKCS_V15, 0 );
memset( message_str, 0x00, 1000 );
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
- ctx.len = mod / 8;
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.P, radix_P, input_P ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.Q, radix_Q, input_Q ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
-
- TEST_ASSERT( mbedtls_mpi_sub_int( &P1, &ctx.P, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_sub_int( &Q1, &ctx.Q, 1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mul_mpi( &H, &P1, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_gcd( &G, &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.D , &ctx.E, &H ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DP, &ctx.D, &P1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_mod_mpi( &ctx.DQ, &ctx.D, &Q1 ) == 0 );
- TEST_ASSERT( mbedtls_mpi_inv_mod( &ctx.QP, &ctx.Q, &ctx.P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
unhexify( message_str, message_hex_string );
}
exit:
- mbedtls_mpi_free( &P1 ); mbedtls_mpi_free( &Q1 ); mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G );
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P );
+ mbedtls_mpi_free( &Q ); mbedtls_mpi_free( &E );
+
mbedtls_rsa_free( &ctx ); mbedtls_rsa_free( &ctx2 );
}
/* END_CASE */
int result )
{
mbedtls_rsa_context ctx;
+ mbedtls_mpi N, E;
+ mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E );
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, 0 );
if( strlen( input_N ) )
{
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
}
if( strlen( input_E ) )
{
- TEST_ASSERT( mbedtls_mpi_read_string( &ctx.E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
}
+ TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == result );
exit:
+ mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E );
mbedtls_rsa_free( &ctx );
}
/* END_CASE */
{
TEST_ASSERT( mbedtls_mpi_read_string( &ctx.D, radix_D, input_D ) == 0 );
}
+#if !defined(MBEDTLS_RSA_NO_CRT)
if( strlen( input_DP ) )
{
TEST_ASSERT( mbedtls_mpi_read_string( &ctx.DP, radix_DP, input_DP ) == 0 );
{
TEST_ASSERT( mbedtls_mpi_read_string( &ctx.QP, radix_QP, input_QP ) == 0 );
}
+#else
+ ((void) radix_DP); ((void) input_DP);
+ ((void) radix_DQ); ((void) input_DQ);
+ ((void) radix_QP); ((void) input_QP);
+#endif
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == result );
{
TEST_ASSERT( mbedtls_mpi_read_string( &prv.D, radix_D, input_D ) == 0 );
}
+#if !defined(MBEDTLS_RSA_NO_CRT)
if( strlen( input_DP ) )
{
TEST_ASSERT( mbedtls_mpi_read_string( &prv.DP, radix_DP, input_DP ) == 0 );
{
TEST_ASSERT( mbedtls_mpi_read_string( &prv.QP, radix_QP, input_QP ) == 0 );
}
+#else
+ ((void) radix_DP); ((void) input_DP);
+ ((void) radix_DQ); ((void) input_DQ);
+ ((void) radix_QP); ((void) input_QP);
+#endif
TEST_ASSERT( mbedtls_rsa_check_pub_priv( &pub, &prv ) == result );
}
/* END_CASE */
-/* BEGIN_CASE depends_on:MBEDTLS_CTR_DRBG_C:MBEDTLS_ENTROPY_C */
+/* BEGIN_CASE depends_on:MBEDTLS_CTR_DRBG_C:MBEDTLS_ENTROPY_C:ENTROPY_HAVE_STRONG */
void mbedtls_rsa_gen_key( int nrbits, int exponent, int result)
{
mbedtls_rsa_context ctx;
const char *pers = "test_suite_rsa";
mbedtls_ctr_drbg_init( &ctr_drbg );
-
mbedtls_entropy_init( &entropy );
- TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
- (const unsigned char *) pers, strlen( pers ) ) == 0 );
+ mbedtls_rsa_init ( &ctx, 0, 0 );
- mbedtls_rsa_init( &ctx, 0, 0 );
+ TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func,
+ &entropy, (const unsigned char *) pers,
+ strlen( pers ) ) == 0 );
TEST_ASSERT( mbedtls_rsa_gen_key( &ctx, mbedtls_ctr_drbg_random, &ctr_drbg, nrbits, exponent ) == result );
if( result == 0 )
}
/* END_CASE */
+/* BEGIN_CASE depends_on:MBEDTLS_CTR_DRBG_C:MBEDTLS_ENTROPY_C */
+void mbedtls_rsa_deduce_primes( int radix_N, char *input_N,
+ int radix_D, char *input_D,
+ int radix_E, char *input_E,
+ int radix_P, char *output_P,
+ int radix_Q, char *output_Q,
+ int corrupt, int result )
+{
+ mbedtls_mpi N, P, Pp, Q, Qp, D, E;
+
+ mbedtls_mpi_init( &N );
+ mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &Pp ); mbedtls_mpi_init( &Qp );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E );
+
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &D, radix_D, input_D ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Qp, radix_P, output_P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Pp, radix_Q, output_Q ) == 0 );
+
+ if( corrupt )
+ TEST_ASSERT( mbedtls_mpi_add_int( &D, &D, 2 ) == 0 );
+
+ /* Try to deduce P, Q from N, D, E only. */
+ TEST_ASSERT( mbedtls_rsa_deduce_primes( &N, &D, &E, &P, &Q ) == result );
+
+ if( !corrupt )
+ {
+ /* Check if (P,Q) = (Pp, Qp) or (P,Q) = (Qp, Pp) */
+ TEST_ASSERT( ( mbedtls_mpi_cmp_mpi( &P, &Pp ) == 0 && mbedtls_mpi_cmp_mpi( &Q, &Qp ) == 0 ) ||
+ ( mbedtls_mpi_cmp_mpi( &P, &Qp ) == 0 && mbedtls_mpi_cmp_mpi( &Q, &Pp ) == 0 ) );
+ }
+
+exit:
+ mbedtls_mpi_free( &N );
+ mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &Pp ); mbedtls_mpi_free( &Qp );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E );
+}
+/* END_CASE */
+
+/* BEGIN_CASE */
+void mbedtls_rsa_deduce_private_exponent( int radix_P, char *input_P,
+ int radix_Q, char *input_Q,
+ int radix_E, char *input_E,
+ int radix_D, char *output_D,
+ int corrupt, int result )
+{
+ mbedtls_mpi P, Q, D, Dp, E, R, Rp;
+
+ mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &Dp );
+ mbedtls_mpi_init( &E );
+ mbedtls_mpi_init( &R ); mbedtls_mpi_init( &Rp );
+
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_read_string( &Dp, radix_D, output_D ) == 0 );
+
+ if( corrupt )
+ {
+ /* Make E even */
+ TEST_ASSERT( mbedtls_mpi_set_bit( &E, 0, 0 ) == 0 );
+ }
+
+ /* Try to deduce D from N, P, Q, E. */
+ TEST_ASSERT( mbedtls_rsa_deduce_private_exponent( &P, &Q,
+ &E, &D ) == result );
+
+ if( !corrupt )
+ {
+ /*
+ * Check that D and Dp agree modulo LCM(P-1, Q-1).
+ */
+
+ /* Replace P,Q by P-1, Q-1 */
+ TEST_ASSERT( mbedtls_mpi_sub_int( &P, &P, 1 ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_sub_int( &Q, &Q, 1 ) == 0 );
+
+ /* Check D == Dp modulo P-1 */
+ TEST_ASSERT( mbedtls_mpi_mod_mpi( &R, &D, &P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_mod_mpi( &Rp, &Dp, &P ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R, &Rp ) == 0 );
+
+ /* Check D == Dp modulo Q-1 */
+ TEST_ASSERT( mbedtls_mpi_mod_mpi( &R, &D, &Q ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_mod_mpi( &Rp, &Dp, &Q ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R, &Rp ) == 0 );
+ }
+
+exit:
+
+ mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &Dp );
+ mbedtls_mpi_free( &E );
+ mbedtls_mpi_free( &R ); mbedtls_mpi_free( &Rp );
+}
+/* END_CASE */
+
+/* BEGIN_CASE depends_on:MBEDTLS_CTR_DRBG_C:MBEDTLS_ENTROPY_C:ENTROPY_HAVE_STRONG */
+void mbedtls_rsa_import( int radix_N, char *input_N,
+ int radix_P, char *input_P,
+ int radix_Q, char *input_Q,
+ int radix_D, char *input_D,
+ int radix_E, char *input_E,
+ int successive,
+ int is_priv,
+ int res_check,
+ int res_complete )
+{
+ mbedtls_mpi N, P, Q, D, E;
+ mbedtls_rsa_context ctx;
+
+ /* Buffers used for encryption-decryption test */
+ unsigned char *buf_orig = NULL;
+ unsigned char *buf_enc = NULL;
+ unsigned char *buf_dec = NULL;
+
+ mbedtls_entropy_context entropy;
+ mbedtls_ctr_drbg_context ctr_drbg;
+ const char *pers = "test_suite_rsa";
+
+ const int have_N = ( strlen( input_N ) > 0 );
+ const int have_P = ( strlen( input_P ) > 0 );
+ const int have_Q = ( strlen( input_Q ) > 0 );
+ const int have_D = ( strlen( input_D ) > 0 );
+ const int have_E = ( strlen( input_E ) > 0 );
+
+ mbedtls_ctr_drbg_init( &ctr_drbg );
+ mbedtls_entropy_init( &entropy );
+ mbedtls_rsa_init( &ctx, 0, 0 );
+
+ mbedtls_mpi_init( &N );
+ mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E );
+
+ TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
+ (const unsigned char *) pers, strlen( pers ) ) == 0 );
+
+ if( have_N )
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+
+ if( have_P )
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+
+ if( have_Q )
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+
+ if( have_D )
+ TEST_ASSERT( mbedtls_mpi_read_string( &D, radix_D, input_D ) == 0 );
+
+ if( have_E )
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+
+ if( !successive )
+ {
+ TEST_ASSERT( mbedtls_rsa_import( &ctx,
+ have_N ? &N : NULL,
+ have_P ? &P : NULL,
+ have_Q ? &Q : NULL,
+ have_D ? &D : NULL,
+ have_E ? &E : NULL ) == 0 );
+ }
+ else
+ {
+ /* Import N, P, Q, D, E separately.
+ * This should make no functional difference. */
+
+ TEST_ASSERT( mbedtls_rsa_import( &ctx,
+ have_N ? &N : NULL,
+ NULL, NULL, NULL, NULL ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_import( &ctx,
+ NULL,
+ have_P ? &P : NULL,
+ NULL, NULL, NULL ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_import( &ctx,
+ NULL, NULL,
+ have_Q ? &Q : NULL,
+ NULL, NULL ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_import( &ctx,
+ NULL, NULL, NULL,
+ have_D ? &D : NULL,
+ NULL ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_import( &ctx,
+ NULL, NULL, NULL, NULL,
+ have_E ? &E : NULL ) == 0 );
+ }
+
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == res_complete );
+
+ /* On expected success, perform some public and private
+ * key operations to check if the key is working properly. */
+ if( res_complete == 0 )
+ {
+ if( is_priv )
+ TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == res_check );
+ else
+ TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == res_check );
+
+ if( res_check != 0 )
+ goto exit;
+
+ buf_orig = mbedtls_calloc( 1, mbedtls_rsa_get_len( &ctx ) );
+ buf_enc = mbedtls_calloc( 1, mbedtls_rsa_get_len( &ctx ) );
+ buf_dec = mbedtls_calloc( 1, mbedtls_rsa_get_len( &ctx ) );
+ if( buf_orig == NULL || buf_enc == NULL || buf_dec == NULL )
+ goto exit;
+
+ TEST_ASSERT( mbedtls_ctr_drbg_random( &ctr_drbg,
+ buf_orig, mbedtls_rsa_get_len( &ctx ) ) == 0 );
+
+ /* Make sure the number we're generating is smaller than the modulus */
+ buf_orig[0] = 0x00;
+
+ TEST_ASSERT( mbedtls_rsa_public( &ctx, buf_orig, buf_enc ) == 0 );
+
+ if( is_priv )
+ {
+ TEST_ASSERT( mbedtls_rsa_private( &ctx, mbedtls_ctr_drbg_random,
+ &ctr_drbg, buf_enc,
+ buf_dec ) == 0 );
+
+ TEST_ASSERT( memcmp( buf_orig, buf_dec,
+ mbedtls_rsa_get_len( &ctx ) ) == 0 );
+ }
+ }
+
+exit:
+
+ mbedtls_free( buf_orig );
+ mbedtls_free( buf_enc );
+ mbedtls_free( buf_dec );
+
+ mbedtls_rsa_free( &ctx );
+
+ mbedtls_ctr_drbg_free( &ctr_drbg );
+ mbedtls_entropy_free( &entropy );
+
+ mbedtls_mpi_free( &N );
+ mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E );
+}
+/* END_CASE */
+
+/* BEGIN_CASE */
+void mbedtls_rsa_export( int radix_N, char *input_N,
+ int radix_P, char *input_P,
+ int radix_Q, char *input_Q,
+ int radix_D, char *input_D,
+ int radix_E, char *input_E,
+ int is_priv,
+ int successive )
+{
+ /* Original MPI's with which we set up the RSA context */
+ mbedtls_mpi N, P, Q, D, E;
+
+ /* Exported MPI's */
+ mbedtls_mpi Ne, Pe, Qe, De, Ee;
+
+ const int have_N = ( strlen( input_N ) > 0 );
+ const int have_P = ( strlen( input_P ) > 0 );
+ const int have_Q = ( strlen( input_Q ) > 0 );
+ const int have_D = ( strlen( input_D ) > 0 );
+ const int have_E = ( strlen( input_E ) > 0 );
+
+ mbedtls_rsa_context ctx;
+
+ mbedtls_rsa_init( &ctx, 0, 0 );
+
+ mbedtls_mpi_init( &N );
+ mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E );
+
+ mbedtls_mpi_init( &Ne );
+ mbedtls_mpi_init( &Pe ); mbedtls_mpi_init( &Qe );
+ mbedtls_mpi_init( &De ); mbedtls_mpi_init( &Ee );
+
+ /* Setup RSA context */
+
+ if( have_N )
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+
+ if( have_P )
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+
+ if( have_Q )
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+
+ if( have_D )
+ TEST_ASSERT( mbedtls_mpi_read_string( &D, radix_D, input_D ) == 0 );
+
+ if( have_E )
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_import( &ctx,
+ strlen( input_N ) ? &N : NULL,
+ strlen( input_P ) ? &P : NULL,
+ strlen( input_Q ) ? &Q : NULL,
+ strlen( input_D ) ? &D : NULL,
+ strlen( input_E ) ? &E : NULL ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
+
+ /*
+ * Export parameters and compare to original ones.
+ */
+
+ /* N and E must always be present. */
+ if( !successive )
+ {
+ TEST_ASSERT( mbedtls_rsa_export( &ctx, &Ne, NULL, NULL, NULL, &Ee ) == 0 );
+ }
+ else
+ {
+ TEST_ASSERT( mbedtls_rsa_export( &ctx, &Ne, NULL, NULL, NULL, NULL ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_export( &ctx, NULL, NULL, NULL, NULL, &Ee ) == 0 );
+ }
+ TEST_ASSERT( mbedtls_mpi_cmp_mpi( &N, &Ne ) == 0 );
+ TEST_ASSERT( mbedtls_mpi_cmp_mpi( &E, &Ee ) == 0 );
+
+ /* If we were providing enough information to setup a complete private context,
+ * we expect to be able to export all core parameters. */
+
+ if( is_priv )
+ {
+ if( !successive )
+ {
+ TEST_ASSERT( mbedtls_rsa_export( &ctx, NULL, &Pe, &Qe,
+ &De, NULL ) == 0 );
+ }
+ else
+ {
+ TEST_ASSERT( mbedtls_rsa_export( &ctx, NULL, &Pe, NULL,
+ NULL, NULL ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_export( &ctx, NULL, NULL, &Qe,
+ NULL, NULL ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_export( &ctx, NULL, NULL, NULL,
+ &De, NULL ) == 0 );
+ }
+
+ if( have_P )
+ TEST_ASSERT( mbedtls_mpi_cmp_mpi( &P, &Pe ) == 0 );
+
+ if( have_Q )
+ TEST_ASSERT( mbedtls_mpi_cmp_mpi( &Q, &Qe ) == 0 );
+
+ if( have_D )
+ TEST_ASSERT( mbedtls_mpi_cmp_mpi( &D, &De ) == 0 );
+
+ /* While at it, perform a sanity check */
+ TEST_ASSERT( mbedtls_rsa_validate_params( &Ne, &Pe, &Qe, &De, &Ee,
+ NULL, NULL ) == 0 );
+ }
+
+exit:
+
+ mbedtls_rsa_free( &ctx );
+
+ mbedtls_mpi_free( &N );
+ mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E );
+
+ mbedtls_mpi_free( &Ne );
+ mbedtls_mpi_free( &Pe ); mbedtls_mpi_free( &Qe );
+ mbedtls_mpi_free( &De ); mbedtls_mpi_free( &Ee );
+}
+/* END_CASE */
+
+/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_C:ENTROPY_HAVE_STRONG */
+void mbedtls_rsa_validate_params( int radix_N, char *input_N,
+ int radix_P, char *input_P,
+ int radix_Q, char *input_Q,
+ int radix_D, char *input_D,
+ int radix_E, char *input_E,
+ int prng, int result )
+{
+ /* Original MPI's with which we set up the RSA context */
+ mbedtls_mpi N, P, Q, D, E;
+
+ const int have_N = ( strlen( input_N ) > 0 );
+ const int have_P = ( strlen( input_P ) > 0 );
+ const int have_Q = ( strlen( input_Q ) > 0 );
+ const int have_D = ( strlen( input_D ) > 0 );
+ const int have_E = ( strlen( input_E ) > 0 );
+
+ mbedtls_entropy_context entropy;
+ mbedtls_ctr_drbg_context ctr_drbg;
+ const char *pers = "test_suite_rsa";
+
+ mbedtls_mpi_init( &N );
+ mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
+ mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E );
+
+ mbedtls_ctr_drbg_init( &ctr_drbg );
+ mbedtls_entropy_init( &entropy );
+ TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func,
+ &entropy, (const unsigned char *) pers,
+ strlen( pers ) ) == 0 );
+
+ if( have_N )
+ TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
+
+ if( have_P )
+ TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
+
+ if( have_Q )
+ TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
+
+ if( have_D )
+ TEST_ASSERT( mbedtls_mpi_read_string( &D, radix_D, input_D ) == 0 );
+
+ if( have_E )
+ TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_validate_params( have_N ? &N : NULL,
+ have_P ? &P : NULL,
+ have_Q ? &Q : NULL,
+ have_D ? &D : NULL,
+ have_E ? &E : NULL,
+ prng ? mbedtls_ctr_drbg_random : NULL,
+ prng ? &ctr_drbg : NULL ) == result );
+exit:
+
+ mbedtls_ctr_drbg_free( &ctr_drbg );
+ mbedtls_entropy_free( &entropy );
+
+ mbedtls_mpi_free( &N );
+ mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
+ mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E );
+}
+/* END_CASE */
+
+/* BEGIN_CASE depends_on:MBEDTLS_CTR_DRBG_C:MBEDTLS_ENTROPY_C */
+void mbedtls_rsa_export_raw( char *input_N, char *input_P,
+ char *input_Q, char *input_D,
+ char *input_E, int is_priv,
+ int successive )
+{
+ /* Original raw buffers with which we set up the RSA context */
+ unsigned char bufN[1000];
+ unsigned char bufP[1000];
+ unsigned char bufQ[1000];
+ unsigned char bufD[1000];
+ unsigned char bufE[1000];
+
+ size_t lenN = 0;
+ size_t lenP = 0;
+ size_t lenQ = 0;
+ size_t lenD = 0;
+ size_t lenE = 0;
+
+ /* Exported buffers */
+ unsigned char bufNe[ sizeof( bufN ) ];
+ unsigned char bufPe[ sizeof( bufP ) ];
+ unsigned char bufQe[ sizeof( bufQ ) ];
+ unsigned char bufDe[ sizeof( bufD ) ];
+ unsigned char bufEe[ sizeof( bufE ) ];
+
+ const int have_N = ( strlen( input_N ) > 0 );
+ const int have_P = ( strlen( input_P ) > 0 );
+ const int have_Q = ( strlen( input_Q ) > 0 );
+ const int have_D = ( strlen( input_D ) > 0 );
+ const int have_E = ( strlen( input_E ) > 0 );
+
+ mbedtls_rsa_context ctx;
+
+ mbedtls_rsa_init( &ctx, 0, 0 );
+
+ /* Setup RSA context */
+
+ if( have_N )
+ lenN = unhexify( bufN, input_N );
+
+ if( have_P )
+ lenP = unhexify( bufP, input_P );
+
+ if( have_Q )
+ lenQ = unhexify( bufQ, input_Q );
+
+ if( have_D )
+ lenD = unhexify( bufD, input_D );
+
+ if( have_E )
+ lenE = unhexify( bufE, input_E );
+
+ TEST_ASSERT( mbedtls_rsa_import_raw( &ctx,
+ have_N ? bufN : NULL, lenN,
+ have_P ? bufP : NULL, lenP,
+ have_Q ? bufQ : NULL, lenQ,
+ have_D ? bufD : NULL, lenD,
+ have_E ? bufE : NULL, lenE ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 );
+
+ /*
+ * Export parameters and compare to original ones.
+ */
+
+ /* N and E must always be present. */
+ if( !successive )
+ {
+ TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, bufNe, lenN,
+ NULL, 0, NULL, 0, NULL, 0,
+ bufEe, lenE ) == 0 );
+ }
+ else
+ {
+ TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, bufNe, lenN,
+ NULL, 0, NULL, 0, NULL, 0,
+ NULL, 0 ) == 0 );
+ TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, NULL, 0,
+ NULL, 0, NULL, 0, NULL, 0,
+ bufEe, lenE ) == 0 );
+ }
+ TEST_ASSERT( memcmp( bufN, bufNe, lenN ) == 0 );
+ TEST_ASSERT( memcmp( bufE, bufEe, lenE ) == 0 );
+
+ /* If we were providing enough information to setup a complete private context,
+ * we expect to be able to export all core parameters. */
+
+ if( is_priv )
+ {
+ if( !successive )
+ {
+ TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, NULL, 0,
+ bufPe, lenP ? lenP : sizeof( bufPe ),
+ bufQe, lenQ ? lenQ : sizeof( bufQe ),
+ bufDe, lenD ? lenD : sizeof( bufDe ),
+ NULL, 0 ) == 0 );
+ }
+ else
+ {
+ TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, NULL, 0,
+ bufPe, lenP ? lenP : sizeof( bufPe ),
+ NULL, 0, NULL, 0,
+ NULL, 0 ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, NULL, 0, NULL, 0,
+ bufQe, lenQ ? lenQ : sizeof( bufQe ),
+ NULL, 0, NULL, 0 ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, NULL, 0, NULL, 0,
+ NULL, 0, bufDe, lenD ? lenD : sizeof( bufDe ),
+ NULL, 0 ) == 0 );
+ }
+
+ if( have_P )
+ TEST_ASSERT( memcmp( bufP, bufPe, lenP ) == 0 );
+
+ if( have_Q )
+ TEST_ASSERT( memcmp( bufQ, bufQe, lenQ ) == 0 );
+
+ if( have_D )
+ TEST_ASSERT( memcmp( bufD, bufDe, lenD ) == 0 );
+
+ }
+
+exit:
+ mbedtls_rsa_free( &ctx );
+}
+/* END_CASE */
+
+/* BEGIN_CASE depends_on:MBEDTLS_CTR_DRBG_C:MBEDTLS_ENTROPY_C:ENTROPY_HAVE_STRONG */
+void mbedtls_rsa_import_raw( char *input_N,
+ char *input_P, char *input_Q,
+ char *input_D, char *input_E,
+ int successive,
+ int is_priv,
+ int res_check,
+ int res_complete )
+{
+ unsigned char bufN[1000];
+ unsigned char bufP[1000];
+ unsigned char bufQ[1000];
+ unsigned char bufD[1000];
+ unsigned char bufE[1000];
+
+ /* Buffers used for encryption-decryption test */
+ unsigned char *buf_orig = NULL;
+ unsigned char *buf_enc = NULL;
+ unsigned char *buf_dec = NULL;
+
+ size_t lenN = 0;
+ size_t lenP = 0;
+ size_t lenQ = 0;
+ size_t lenD = 0;
+ size_t lenE = 0;
+
+ mbedtls_rsa_context ctx;
+ mbedtls_entropy_context entropy;
+ mbedtls_ctr_drbg_context ctr_drbg;
+
+ const char *pers = "test_suite_rsa";
+
+ mbedtls_ctr_drbg_init( &ctr_drbg );
+ mbedtls_entropy_init( &entropy );
+ mbedtls_rsa_init( &ctx, 0, 0 );
+
+ TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func,
+ &entropy, (const unsigned char *) pers,
+ strlen( pers ) ) == 0 );
+
+ if( strlen( input_N ) )
+ lenN = unhexify( bufN, input_N );
+
+ if( strlen( input_P ) )
+ lenP = unhexify( bufP, input_P );
+
+ if( strlen( input_Q ) )
+ lenQ = unhexify( bufQ, input_Q );
+
+ if( strlen( input_D ) )
+ lenD = unhexify( bufD, input_D );
+
+ if( strlen( input_E ) )
+ lenE = unhexify( bufE, input_E );
+
+ if( !successive )
+ {
+ TEST_ASSERT( mbedtls_rsa_import_raw( &ctx,
+ ( lenN > 0 ) ? bufN : NULL, lenN,
+ ( lenP > 0 ) ? bufP : NULL, lenP,
+ ( lenQ > 0 ) ? bufQ : NULL, lenQ,
+ ( lenD > 0 ) ? bufD : NULL, lenD,
+ ( lenE > 0 ) ? bufE : NULL, lenE ) == 0 );
+ }
+ else
+ {
+ /* Import N, P, Q, D, E separately.
+ * This should make no functional difference. */
+
+ TEST_ASSERT( mbedtls_rsa_import_raw( &ctx,
+ ( lenN > 0 ) ? bufN : NULL, lenN,
+ NULL, 0, NULL, 0, NULL, 0, NULL, 0 ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_import_raw( &ctx,
+ NULL, 0,
+ ( lenP > 0 ) ? bufP : NULL, lenP,
+ NULL, 0, NULL, 0, NULL, 0 ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_import_raw( &ctx,
+ NULL, 0, NULL, 0,
+ ( lenQ > 0 ) ? bufQ : NULL, lenQ,
+ NULL, 0, NULL, 0 ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_import_raw( &ctx,
+ NULL, 0, NULL, 0, NULL, 0,
+ ( lenD > 0 ) ? bufD : NULL, lenD,
+ NULL, 0 ) == 0 );
+
+ TEST_ASSERT( mbedtls_rsa_import_raw( &ctx,
+ NULL, 0, NULL, 0, NULL, 0, NULL, 0,
+ ( lenE > 0 ) ? bufE : NULL, lenE ) == 0 );
+ }
+
+ TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == res_complete );
+
+ /* On expected success, perform some public and private
+ * key operations to check if the key is working properly. */
+ if( res_complete == 0 )
+ {
+ if( is_priv )
+ TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == res_check );
+ else
+ TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == res_check );
+
+ if( res_check != 0 )
+ goto exit;
+
+ buf_orig = mbedtls_calloc( 1, mbedtls_rsa_get_len( &ctx ) );
+ buf_enc = mbedtls_calloc( 1, mbedtls_rsa_get_len( &ctx ) );
+ buf_dec = mbedtls_calloc( 1, mbedtls_rsa_get_len( &ctx ) );
+ if( buf_orig == NULL || buf_enc == NULL || buf_dec == NULL )
+ goto exit;
+
+ TEST_ASSERT( mbedtls_ctr_drbg_random( &ctr_drbg,
+ buf_orig, mbedtls_rsa_get_len( &ctx ) ) == 0 );
+
+ /* Make sure the number we're generating is smaller than the modulus */
+ buf_orig[0] = 0x00;
+
+ TEST_ASSERT( mbedtls_rsa_public( &ctx, buf_orig, buf_enc ) == 0 );
+
+ if( is_priv )
+ {
+ TEST_ASSERT( mbedtls_rsa_private( &ctx, mbedtls_ctr_drbg_random,
+ &ctr_drbg, buf_enc,
+ buf_dec ) == 0 );
+
+ TEST_ASSERT( memcmp( buf_orig, buf_dec,
+ mbedtls_rsa_get_len( &ctx ) ) == 0 );
+ }
+ }
+
+exit:
+
+ mbedtls_free( buf_orig );
+ mbedtls_free( buf_enc );
+ mbedtls_free( buf_dec );
+
+ mbedtls_rsa_free( &ctx );
+
+ mbedtls_ctr_drbg_free( &ctr_drbg );
+ mbedtls_entropy_free( &entropy );
+
+}
+/* END_CASE */
+
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
void rsa_selftest()
{
+# Test the operation of SHA-1 and SHA-2
SHA-1 Test Vector NIST CAVS #1
depends_on:MBEDTLS_SHA1_C
mbedtls_sha1:"":"da39a3ee5e6b4b0d3255bfef95601890afd80709"
src_len = unhexify( src_str, hex_src_string );
- mbedtls_sha1( src_str, src_len, output );
+ TEST_ASSERT( mbedtls_sha1_ret( src_str, src_len, output ) == 0 );
hexify( hash_str, output, 20 );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
src_len = unhexify( src_str, hex_src_string );
- mbedtls_sha256( src_str, src_len, output, 1 );
+ TEST_ASSERT( mbedtls_sha256_ret( src_str, src_len, output, 1 ) == 0 );
hexify( hash_str, output, 28 );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
src_len = unhexify( src_str, hex_src_string );
- mbedtls_sha256( src_str, src_len, output, 0 );
+ TEST_ASSERT( mbedtls_sha256_ret( src_str, src_len, output, 0 ) == 0 );
hexify( hash_str, output, 32 );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
src_len = unhexify( src_str, hex_src_string );
- mbedtls_sha512( src_str, src_len, output, 1 );
+ TEST_ASSERT( mbedtls_sha512_ret( src_str, src_len, output, 1 ) == 0 );
hexify( hash_str, output, 48 );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
src_len = unhexify( src_str, hex_src_string );
- mbedtls_sha512( src_str, src_len, output, 0);
+ TEST_ASSERT( mbedtls_sha512_ret( src_str, src_len, output, 0 ) == 0 );
hexify( hash_str, output, 64 );
TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 );
SSL DTLS replay: big jump then just delayed
ssl_dtls_replay:"abcd12340000,abcd12340100":"abcd123400ff":0
+
+SSL SET_HOSTNAME memory leak: call ssl_set_hostname twice
+ssl_set_hostname_twice:"server0":"server1"
mbedtls_ssl_config_free( &conf );
}
/* END_CASE */
+
+/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C */
+void ssl_set_hostname_twice( char *hostname0, char *hostname1 )
+{
+ mbedtls_ssl_context ssl;
+ mbedtls_ssl_init( &ssl );
+
+ TEST_ASSERT( mbedtls_ssl_set_hostname( &ssl, hostname0 ) == 0 );
+ TEST_ASSERT( mbedtls_ssl_set_hostname( &ssl, hostname1 ) == 0 );
+
+ mbedtls_ssl_free( &ssl );
+}
+/* END_CASE */
\ No newline at end of file
-Timing selftest
-timing_selftest:
+Timing: basic timer operation
+timing_timer_simple:
+
+Timing: timer reset
+timing_timer_reset:
+
+Timing: two parallel timers, delay 0
+timing_two_timers:0:
+
+Timing: two parallel timers, delay 100
+timing_two_timers:100:
+
+Timing: two parallel timers, delay 1000
+timing_two_timers:1000:
+
+Timing: two parallel timers, delay 10000
+timing_two_timers:10000:
+
+Timing: delay 0ms, 0ms
+timing_delay:0:0:
+
+Timing: delay 0ms, 50ms
+timing_delay:0:50:
+
+Timing: delay 50ms, 50ms
+timing_delay:50:50:
+
+Timing: delay 50ms, 100ms
+timing_delay:50:100:
+
+Timing: delay 50ms, 200ms
+timing_delay:50:200:
+
+Timing: alarm in 0 second
+timing_alarm:0:
+
+Timing: alarm in 1 second
+timing_alarm:1:
+
+Timing: hardclock
+timing_hardclock:
/* BEGIN_HEADER */
+
+/* This test module exercises the timing module. One of the expected failure
+ modes is for timers to never expire, which could lead to an infinite loop.
+ The function timing_timer_simple is protected against this failure mode and
+ checks that timers do expire. Other functions will terminate if their
+ timers do expire. Therefore it is recommended to run timing_timer_simple
+ first and run other test functions only if that timing_timer_simple
+ succeeded. */
+
+#include <limits.h>
+
#include "mbedtls/timing.h"
+
+/* Wait this many milliseconds for a short timing test. This duration
+ should be large enough that, in practice, if you read the timer
+ value twice in a row, it won't have jumped by that much. */
+#define TIMING_SHORT_TEST_MS 100
+
+/* A loop that waits TIMING_SHORT_TEST_MS must not take more than this many
+ iterations. This value needs to be large enough to accommodate fast
+ platforms (e.g. at 4GHz and 10 cycles/iteration a CPU can run through 20
+ million iterations in 50ms). The only motivation to keep this value low is
+ to avoid having an infinite loop if the timer functions are not implemented
+ correctly. Ideally this value should be based on the processor speed but we
+ don't have this information! */
+#define TIMING_SHORT_TEST_ITERATIONS_MAX 1e8
+
+/* alarm(0) must fire in no longer than this amount of time. */
+#define TIMING_ALARM_0_DELAY_MS TIMING_SHORT_TEST_MS
+
+static int expected_delay_status( uint32_t int_ms, uint32_t fin_ms,
+ unsigned long actual_ms )
+{
+ return( fin_ms == 0 ? -1 :
+ actual_ms >= fin_ms ? 2 :
+ actual_ms >= int_ms ? 1 :
+ 0 );
+}
+
+/* Some conditions in timing_timer_simple suggest that timers are unreliable.
+ Most other test cases rely on timers to terminate, and could loop
+ indefinitely if timers are too broken. So if timing_timer_simple detected a
+ timer that risks not terminating (going backwards, or not reaching the
+ desired count in the alloted clock cycles), set this flag to immediately
+ fail those other tests without running any timers. */
+static int timers_are_badly_broken = 0;
+
/* END_HEADER */
/* BEGIN_DEPENDENCIES
* END_DEPENDENCIES
*/
-/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
-void timing_selftest()
+/* BEGIN_CASE */
+void timing_timer_simple( )
+{
+ struct mbedtls_timing_hr_time timer;
+ unsigned long millis = 0;
+ unsigned long new_millis = 0;
+ unsigned long iterations = 0;
+ /* Start the timer. */
+ (void) mbedtls_timing_get_timer( &timer, 1 );
+ /* Busy-wait loop for a few milliseconds. */
+ do
+ {
+ new_millis = mbedtls_timing_get_timer( &timer, 0 );
+ ++iterations;
+ /* Check that the timer didn't go backwards */
+ TEST_ASSERT( new_millis >= millis );
+ millis = new_millis;
+ }
+ while( millis < TIMING_SHORT_TEST_MS &&
+ iterations <= TIMING_SHORT_TEST_ITERATIONS_MAX );
+ /* The wait duration should have been large enough for at least a
+ few runs through the loop, even on the slowest realistic platform. */
+ TEST_ASSERT( iterations >= 2 );
+ /* The wait duration shouldn't have overflowed the iteration count. */
+ TEST_ASSERT( iterations < TIMING_SHORT_TEST_ITERATIONS_MAX );
+ return;
+
+exit:
+ if( iterations >= TIMING_SHORT_TEST_ITERATIONS_MAX ||
+ new_millis < millis )
+ {
+ /* The timer was very unreliable: it didn't increment and the loop ran
+ out, or it went backwards. Other tests that use timers might go
+ into an infinite loop, so we'll skip them. */
+ timers_are_badly_broken = 1;
+ }
+
+ /* No cleanup needed, but show some diagnostic iterations, because timing
+ problems can be hard to reproduce. */
+ mbedtls_fprintf( stdout, " Finished with millis=%lu new_millis=%lu get(timer)<=%lu iterations=%lu\n",
+ millis, new_millis, mbedtls_timing_get_timer( &timer, 0 ),
+ iterations );
+}
+/* END_CASE */
+
+/* BEGIN_CASE */
+void timing_timer_reset( )
{
- TEST_ASSERT( mbedtls_timing_self_test( 1 ) == 0 );
+ struct mbedtls_timing_hr_time timer;
+ unsigned long millis = 0;
+ unsigned long iterations = 0;
+
+ /* Skip this test if it looks like timers don't work at all, to avoid an
+ infinite loop below. */
+ TEST_ASSERT( !timers_are_badly_broken );
+
+ /* Start the timer. Timers are always reset to 0. */
+ TEST_ASSERT( mbedtls_timing_get_timer( &timer, 1 ) == 0 );
+ /* Busy-wait loop for a few milliseconds */
+ do
+ {
+ ++iterations;
+ millis = mbedtls_timing_get_timer( &timer, 0 );
+ }
+ while( millis < TIMING_SHORT_TEST_MS );
+
+ /* Reset the timer and check that it has restarted. */
+ TEST_ASSERT( mbedtls_timing_get_timer( &timer, 1 ) == 0 );
+ /* Read the timer immediately after reset. It should be 0 or close
+ to it. */
+ TEST_ASSERT( mbedtls_timing_get_timer( &timer, 0 ) < TIMING_SHORT_TEST_MS );
+ return;
+
+exit:
+ /* No cleanup needed, but show some diagnostic information, because timing
+ problems can be hard to reproduce. */
+ if( !timers_are_badly_broken )
+ mbedtls_fprintf( stdout, " Finished with millis=%lu get(timer)<=%lu iterations=%lu\n",
+ millis, mbedtls_timing_get_timer( &timer, 0 ),
+ iterations );
+}
+/* END_CASE */
+
+/* BEGIN_CASE */
+void timing_two_timers( int delta )
+{
+ struct mbedtls_timing_hr_time timer1, timer2;
+ unsigned long millis1 = 0, millis2 = 0;
+
+ /* Skip this test if it looks like timers don't work at all, to avoid an
+ infinite loop below. */
+ TEST_ASSERT( !timers_are_badly_broken );
+
+ /* Start the first timer and wait for a short time. */
+ (void) mbedtls_timing_get_timer( &timer1, 1 );
+ do
+ {
+ millis1 = mbedtls_timing_get_timer( &timer1, 0 );
+ }
+ while( millis1 < TIMING_SHORT_TEST_MS );
+
+ /* Do a short busy-wait, so that the difference between timer1 and timer2
+ doesn't practically always end up being very close to a whole number of
+ milliseconds. */
+ while( delta > 0 )
+ --delta;
+
+ /* Start the second timer and compare it with the first. */
+ mbedtls_timing_get_timer( &timer2, 1 );
+ do
+ {
+ millis1 = mbedtls_timing_get_timer( &timer1, 0 );
+ millis2 = mbedtls_timing_get_timer( &timer2, 0 );
+ /* The first timer should always be ahead of the first. */
+ TEST_ASSERT( millis1 > millis2 );
+ /* The timers shouldn't drift apart, i.e. millis2-millis1 should stay
+ roughly constant, but this is hard to test reliably, especially in
+ a busy environment such as an overloaded continuous integration
+ system, so we don't test it it. */
+ }
+ while( millis2 < TIMING_SHORT_TEST_MS );
+
+ return;
+
+exit:
+ /* No cleanup needed, but show some diagnostic iterations, because timing
+ problems can be hard to reproduce. */
+ if( !timers_are_badly_broken )
+ mbedtls_fprintf( stdout, " Finished with millis1=%lu get(timer1)<=%lu millis2=%lu get(timer2)<=%lu\n",
+ millis1, mbedtls_timing_get_timer( &timer1, 0 ),
+ millis2, mbedtls_timing_get_timer( &timer2, 0 ) );
+}
+/* END_CASE */
+
+/* BEGIN_CASE */
+void timing_alarm( int seconds )
+{
+ struct mbedtls_timing_hr_time timer;
+ unsigned long millis = 0;
+ /* We check that about the desired number of seconds has elapsed. Be
+ slightly liberal with the lower bound, so as to allow platforms where
+ the alarm (with second resolution) and the timer (with millisecond
+ resolution) are based on different clocks. Be very liberal with the
+ upper bound, because the platform might be busy. */
+ unsigned long millis_min = ( seconds > 0 ?
+ seconds * 900 :
+ 0 );
+ unsigned long millis_max = ( seconds > 0 ?
+ seconds * 1100 + 400 :
+ TIMING_ALARM_0_DELAY_MS );
+ unsigned long iterations = 0;
+
+ /* Skip this test if it looks like timers don't work at all, to avoid an
+ infinite loop below. */
+ TEST_ASSERT( !timers_are_badly_broken );
+
+ /* Set an alarm and count how long it takes with a timer. */
+ (void) mbedtls_timing_get_timer( &timer, 1 );
+ mbedtls_set_alarm( seconds );
+
+ if( seconds > 0 )
+ {
+ /* We set the alarm for at least 1 second. It should not have fired
+ immediately, even on a slow and busy platform. */
+ TEST_ASSERT( !mbedtls_timing_alarmed );
+ }
+ /* A 0-second alarm should fire quickly, but we don't guarantee that it
+ fires immediately, so mbedtls_timing_alarmed may or may not be set at
+ this point. */
+
+ /* Busy-wait until the alarm rings */
+ do
+ {
+ ++iterations;
+ millis = mbedtls_timing_get_timer( &timer, 0 );
+ }
+ while( !mbedtls_timing_alarmed && millis <= millis_max );
+
+ TEST_ASSERT( mbedtls_timing_alarmed );
+ TEST_ASSERT( millis >= millis_min );
+ TEST_ASSERT( millis <= millis_max );
+
+ mbedtls_timing_alarmed = 0;
+ return;
+
+exit:
+ /* Show some diagnostic iterations, because timing
+ problems can be hard to reproduce. */
+ if( !timers_are_badly_broken )
+ mbedtls_fprintf( stdout, " Finished with alarmed=%d millis=%lu get(timer)<=%lu iterations=%lu\n",
+ mbedtls_timing_alarmed,
+ millis, mbedtls_timing_get_timer( &timer, 0 ),
+ iterations );
+ /* Cleanup */
+ mbedtls_timing_alarmed = 0;
+}
+/* END_CASE */
+
+/* BEGIN_CASE */
+void timing_delay( int int_ms, int fin_ms )
+{
+ /* This function assumes that if int_ms is nonzero then it is large
+ enough that we have time to read all timers at least once in an
+ interval of time lasting int_ms milliseconds, and likewise for (fin_ms
+ - int_ms). So don't call it with arguments that are too small. */
+
+ mbedtls_timing_delay_context delay;
+ struct mbedtls_timing_hr_time timer;
+ unsigned long delta = 0; /* delay started between timer=0 and timer=delta */
+ unsigned long before = 0, after = 0;
+ unsigned long iterations = 0;
+ int status = -2;
+ int saw_status_1 = 0;
+ int warn_inconclusive = 0;
+
+ assert( int_ms >= 0 );
+ assert( fin_ms >= 0 );
+
+ /* Skip this test if it looks like timers don't work at all, to avoid an
+ infinite loop below. */
+ TEST_ASSERT( !timers_are_badly_broken );
+
+ /* Start a reference timer. Program a delay, and verify that the status of
+ the delay is consistent with the time given by the reference timer. */
+ (void) mbedtls_timing_get_timer( &timer, 1 );
+ mbedtls_timing_set_delay( &delay, int_ms, fin_ms );
+ /* Set delta to an upper bound for the interval between the start of timer
+ and the start of delay. Reading timer after starting delay gives us an
+ upper bound for the interval, rounded to a 1ms precision. Since this
+ might have been rounded down, but we need an upper bound, we add 1. */
+ delta = mbedtls_timing_get_timer( &timer, 0 ) + 1;
+
+ status = mbedtls_timing_get_delay( &delay );
+ if( fin_ms == 0 )
+ {
+ /* Cancelled timer. Just check the correct status for this case. */
+ TEST_ASSERT( status == -1 );
+ return;
+ }
+
+ /* Initially, none of the delays must be passed yet if they're nonzero.
+ This could fail for very small values of int_ms and fin_ms, where "very
+ small" depends how fast and how busy the platform is. */
+ if( int_ms > 0 )
+ {
+ TEST_ASSERT( status == 0 );
+ }
+ else
+ {
+ TEST_ASSERT( status == 1 );
+ }
+
+ do
+ {
+ unsigned long delay_min, delay_max;
+ int status_min, status_max;
+ ++iterations;
+ before = mbedtls_timing_get_timer( &timer, 0 );
+ status = mbedtls_timing_get_delay( &delay );
+ after = mbedtls_timing_get_timer( &timer, 0 );
+ /* At a time between before and after, the delay's status was status.
+ Check that this is consistent given that the delay was started
+ between times 0 and delta. */
+ delay_min = ( before > delta ? before - delta : 0 );
+ status_min = expected_delay_status( int_ms, fin_ms, delay_min );
+ delay_max = after;
+ status_max = expected_delay_status( int_ms, fin_ms, delay_max );
+ TEST_ASSERT( status >= status_min );
+ TEST_ASSERT( status <= status_max );
+ if( status == 1 )
+ saw_status_1 = 1;
+ }
+ while ( before <= fin_ms + delta && status != 2 );
+
+ /* Since we've waited at least fin_ms, the delay must have fully
+ expired. */
+ TEST_ASSERT( status == 2 );
+
+ /* If the second delay is more than the first, then there must have been a
+ point in time when the first delay was passed but not the second delay.
+ This could fail for very small values of (fin_ms - int_ms), where "very
+ small" depends how fast and how busy the platform is. In practice, this
+ is the test that's most likely to fail on a heavily loaded machine. */
+ if( fin_ms > int_ms )
+ {
+ warn_inconclusive = 1;
+ TEST_ASSERT( saw_status_1 );
+ }
+
+ return;
+
+exit:
+ /* No cleanup needed, but show some diagnostic iterations, because timing
+ problems can be hard to reproduce. */
+ if( !timers_are_badly_broken )
+ mbedtls_fprintf( stdout, " Finished with delta=%lu before=%lu after=%lu status=%d iterations=%lu\n",
+ delta, before, after, status, iterations );
+ if( warn_inconclusive )
+ mbedtls_fprintf( stdout, " Inconclusive test, try running it on a less heavily loaded machine.\n" );
+ }
+/* END_CASE */
+
+/* BEGIN_CASE */
+void timing_hardclock( )
+{
+ /* We make very few guarantees about mbedtls_timing_hardclock: its rate is
+ platform-dependent, it can wrap around. So there isn't much we can
+ test. But we do at least test that it doesn't crash, stall or return
+ completely nonsensical values. */
+
+ struct mbedtls_timing_hr_time timer;
+ unsigned long hardclock0 = -1, hardclock1 = -1, delta1 = -1;
+
+ /* Skip this test if it looks like timers don't work at all, to avoid an
+ infinite loop below. */
+ TEST_ASSERT( !timers_are_badly_broken );
+
+ hardclock0 = mbedtls_timing_hardclock( );
+ /* Wait 2ms to ensure a nonzero delay. Since the timer interface has 1ms
+ resolution and unspecified precision, waiting 1ms might be a very small
+ delay that's rounded up. */
+ (void) mbedtls_timing_get_timer( &timer, 1 );
+ while( mbedtls_timing_get_timer( &timer, 0 ) < 2 )
+ /*busy-wait loop*/;
+ hardclock1 = mbedtls_timing_hardclock( );
+
+ /* Although the hardclock counter can wrap around, the difference
+ (hardclock1 - hardclock0) is taken modulo the type size, so it is
+ correct as long as the counter only wrapped around at most once. We
+ further require the difference to be nonzero (after a wait of more than
+ 1ms, the counter must have changed), and not to be overly large (after
+ a wait of less than 3ms, plus time lost because other processes were
+ scheduled on the CPU). If the hardclock counter runs at 4GHz, then
+ 1000000000 (which is 1/4 of the counter wraparound on a 32-bit machine)
+ allows 250ms. */
+ delta1 = hardclock1 - hardclock0;
+ TEST_ASSERT( delta1 > 0 );
+ TEST_ASSERT( delta1 < 1000000000 );
+ return;
+
+exit:
+ /* No cleanup needed, but show some diagnostic iterations, because timing
+ problems can be hard to reproduce. */
+ if( !timers_are_badly_broken )
+ mbedtls_fprintf( stdout, " Finished with hardclock=%lu,%lu\n",
+ hardclock0, hardclock1 );
}
/* END_CASE */
Check compiletime library version
-check_compiletime_version:"2.4.0"
+check_compiletime_version:"2.8.0"
Check runtime library version
-check_runtime_version:"2.4.0"
+check_runtime_version:"2.8.0"
Check for MBEDTLS_VERSION_C
check_feature:"MBEDTLS_VERSION_C":0
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA512_C
mbedtls_x509_crl_info:"data_files/crl-ec-sha512.pem":"CRL version \: 2\nissuer name \: C=NL, O=PolarSSL, CN=Polarssl Test EC CA\nthis update \: 2013-09-24 16\:31\:08\nnext update \: 2023-09-22 16\:31\:08\nRevoked certificates\:\nserial number\: 0A revocation date\: 2013-09-24 16\:28\:38\nsigned using \: ECDSA with SHA512\n"
+X509 CRL Malformed Input (trailing spaces at end of file)
+depends_on:MBEDTLS_PEM_PARSE_C
+mbedtls_x509_crl_parse:"data_files/crl-malformed-trailing-spaces.pem":MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT
+
+X509 CRL Unsupported critical extension (issuingDistributionPoint)
+depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_SHA256_C
+mbedtls_x509_crl_parse:"data_files/crl-idp.pem":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG
+
+X509 CRL Unsupported non-critical extension (issuingDistributionPoint)
+depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_SHA256_C
+mbedtls_x509_crl_parse:"data_files/crl-idpnc.pem":0
+
X509 CSR Information RSA with MD4
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_MD4_C
mbedtls_x509_csr_info:"data_files/server1.req.md4":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nsigned using \: RSA with MD4\nRSA key size \: 2048 bits\n"
X509 Certificate verification #1 (Revoked Cert, Expired CRL, no CN)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl_expired.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_EXPIRED:"NULL"
+x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl_expired.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_EXPIRED:"compat":"NULL"
X509 Certificate verification #1a (Revoked Cert, Future CRL, no CN)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C
-x509_verify:"data_files/server6.crt":"data_files/test-ca2.crt":"data_files/crl-future.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_FUTURE:"NULL"
+x509_verify:"data_files/server6.crt":"data_files/test-ca2.crt":"data_files/crl-future.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_FUTURE:"compat":"NULL"
X509 Certificate verification #2 (Revoked Cert, Expired CRL)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl_expired.pem":"PolarSSL Server 1":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_EXPIRED:"NULL"
+x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl_expired.pem":"PolarSSL Server 1":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_EXPIRED:"compat":"NULL"
X509 Certificate verification #2a (Revoked Cert, Future CRL)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C
-x509_verify:"data_files/server6.crt":"data_files/test-ca2.crt":"data_files/crl-future.pem":"localhost":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_FUTURE:"NULL"
+x509_verify:"data_files/server6.crt":"data_files/test-ca2.crt":"data_files/crl-future.pem":"localhost":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_FUTURE:"compat":"NULL"
X509 Certificate verification #3 (Revoked Cert, Future CRL, CN Mismatch)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl_expired.pem":"PolarSSL Wrong CN":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_EXPIRED | MBEDTLS_X509_BADCERT_CN_MISMATCH:"NULL"
+x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl_expired.pem":"PolarSSL Wrong CN":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_EXPIRED | MBEDTLS_X509_BADCERT_CN_MISMATCH:"compat":"NULL"
X509 Certificate verification #3a (Revoked Cert, Expired CRL, CN Mismatch)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C
-x509_verify:"data_files/server6.crt":"data_files/test-ca2.crt":"data_files/crl-future.pem":"Wrong CN":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_FUTURE | MBEDTLS_X509_BADCERT_CN_MISMATCH:"NULL"
+x509_verify:"data_files/server6.crt":"data_files/test-ca2.crt":"data_files/crl-future.pem":"Wrong CN":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCRL_FUTURE | MBEDTLS_X509_BADCERT_CN_MISMATCH:"compat":"NULL"
X509 Certificate verification #4 (Valid Cert, Expired CRL)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/server2.crt":"data_files/test-ca.crt":"data_files/crl_expired.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCRL_EXPIRED:"NULL"
+x509_verify:"data_files/server2.crt":"data_files/test-ca.crt":"data_files/crl_expired.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCRL_EXPIRED:"compat":"NULL"
X509 Certificate verification #4a (Revoked Cert, Future CRL)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C
-x509_verify:"data_files/server5.crt":"data_files/test-ca2.crt":"data_files/crl-future.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCRL_FUTURE:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2.crt":"data_files/crl-future.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCRL_FUTURE:"compat":"NULL"
X509 Certificate verification #5 (Revoked Cert)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"NULL"
+x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"compat":"NULL"
X509 Certificate verification #6 (Revoked Cert)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"PolarSSL Server 1":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"NULL"
+x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"PolarSSL Server 1":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"compat":"NULL"
X509 Certificate verification #7 (Revoked Cert, CN Mismatch)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"PolarSSL Wrong CN":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCERT_CN_MISMATCH:"NULL"
+x509_verify:"data_files/server1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"PolarSSL Wrong CN":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED | MBEDTLS_X509_BADCERT_CN_MISMATCH:"compat":"NULL"
X509 Certificate verification #8 (Valid Cert)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C
-x509_verify:"data_files/server5.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha1.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha1.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #8a (Expired Cert)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C
-x509_verify:"data_files/server5-expired.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha1.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_EXPIRED:"NULL"
+x509_verify:"data_files/server5-expired.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha1.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_EXPIRED:"compat":"NULL"
X509 Certificate verification #8b (Future Cert)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C
-x509_verify:"data_files/server5-future.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha1.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_FUTURE:"NULL"
+x509_verify:"data_files/server5-future.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha1.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_FUTURE:"compat":"NULL"
X509 Certificate verification #9 (Not trusted Cert)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/server2.crt":"data_files/server1.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server2.crt":"data_files/server1.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #10 (Not trusted Cert, Expired CRL)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA1_C
-x509_verify:"data_files/server2.crt":"data_files/server1.crt":"data_files/crl_expired.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server2.crt":"data_files/server1.crt":"data_files/crl_expired.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #12 (Valid Cert MD4 Digest)
depends_on:MBEDTLS_MD4_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_md4.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_BAD_MD:"NULL"
+x509_verify:"data_files/cert_md4.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_BAD_MD:"compat":"NULL"
X509 Certificate verification #13 (Valid Cert MD5 Digest)
depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_md5.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_BAD_MD:"NULL"
+x509_verify:"data_files/cert_md5.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_BAD_MD:"compat":"NULL"
-X509 Certificate verification #14 (Valid Cert SHA1 Digest)
+X509 Certificate verification #14 (Valid Cert SHA1 Digest explicitly allowed in profile)
depends_on:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_sha1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/cert_sha1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
+
+X509 Certificate verification #14 (Valid Cert SHA1 Digest allowed in compile-time default profile)
+depends_on:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
+x509_verify:"data_files/cert_sha1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"default":"NULL"
+
+X509 Certificate verification #14 (Valid Cert SHA1 Digest forbidden in default profile)
+depends_on:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:!MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES
+x509_verify:"data_files/cert_sha1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCRL_BAD_MD | MBEDTLS_X509_BADCERT_BAD_MD:"default":"NULL"
X509 Certificate verification #15 (Valid Cert SHA224 Digest)
depends_on:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_sha224.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/cert_sha224.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #16 (Valid Cert SHA256 Digest)
depends_on:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_sha256.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/cert_sha256.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #17 (Valid Cert SHA384 Digest)
depends_on:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_sha384.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/cert_sha384.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #18 (Valid Cert SHA512 Digest)
depends_on:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_sha512.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/cert_sha512.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #19 (Valid Cert, denying callback)
depends_on:MBEDTLS_SHA512_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_sha512.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_OTHER:"verify_none"
+x509_verify:"data_files/cert_sha512.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_OTHER:"compat":"verify_none"
X509 Certificate verification #19 (Not trusted Cert, allowing callback)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA1_C
-x509_verify:"data_files/server2.crt":"data_files/server1.crt":"data_files/crl_expired.pem":"NULL":0:0:"verify_all"
+x509_verify:"data_files/server2.crt":"data_files/server1.crt":"data_files/crl_expired.pem":"NULL":0:0:"compat":"verify_all"
X509 Certificate verification #21 (domain matching wildcard certificate, case insensitive)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_wildcard.crt":"data_files/test-ca.crt":"data_files/crl.pem":"mail.ExAmPlE.com":0:0:"NULL"
+x509_verify:"data_files/cert_example_wildcard.crt":"data_files/test-ca.crt":"data_files/crl.pem":"mail.ExAmPlE.com":0:0:"compat":"NULL"
X509 Certificate verification #22 (domain not matching wildcard certificate)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_wildcard.crt":"data_files/test-ca.crt":"data_files/crl.pem":"mail.example.net":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"NULL"
+x509_verify:"data_files/cert_example_wildcard.crt":"data_files/test-ca.crt":"data_files/crl.pem":"mail.example.net":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"compat":"NULL"
X509 Certificate verification #23 (domain not matching wildcard certificate)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_wildcard.crt":"data_files/test-ca.crt":"data_files/crl.pem":"example.com":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"NULL"
+x509_verify:"data_files/cert_example_wildcard.crt":"data_files/test-ca.crt":"data_files/crl.pem":"example.com":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"compat":"NULL"
X509 Certificate verification #24 (domain matching CN of multi certificate)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"www.example.com":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"NULL"
+x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"www.example.com":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"compat":"NULL"
X509 Certificate verification #25 (domain matching multi certificate)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"example.net":0:0:"NULL"
+x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"example.net":0:0:"compat":"NULL"
X509 Certificate verification #26 (domain not matching multi certificate)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"www.example.net":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"NULL"
+x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"www.example.net":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"compat":"NULL"
X509 Certificate verification #27 (domain not matching multi certificate)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"xample.net":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"NULL"
+x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"xample.net":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"compat":"NULL"
X509 Certificate verification #27 (domain not matching multi certificate)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"bexample.net":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"NULL"
+x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"bexample.net":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"compat":"NULL"
X509 Certificate verification #28 (domain not matching wildcard in multi certificate)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"example.org":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"NULL"
+x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"example.org":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH:"compat":"NULL"
X509 Certificate verification #29 (domain matching wildcard in multi certificate)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"mail.example.org":0:0:"NULL"
+x509_verify:"data_files/cert_example_multi.crt":"data_files/test-ca.crt":"data_files/crl.pem":"mail.example.org":0:0:"compat":"NULL"
X509 Certificate verification #30 (domain matching multi certificate without CN)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_multi_nocn.crt":"data_files/test-ca.crt":"data_files/crl.pem":"www.shotokan-braunschweig.de":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/cert_example_multi_nocn.crt":"data_files/test-ca.crt":"data_files/crl.pem":"www.shotokan-braunschweig.de":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #31 (domain not matching multi certificate without CN)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
-x509_verify:"data_files/cert_example_multi_nocn.crt":"data_files/test-ca.crt":"data_files/crl.pem":"www.example.net":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH + MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/cert_example_multi_nocn.crt":"data_files/test-ca.crt":"data_files/crl.pem":"www.example.net":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_CN_MISMATCH + MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #32 (Valid, EC cert, RSA CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_PKCS1_V15:MBEDTLS_SHA1_C
-x509_verify:"data_files/server3.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server3.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #33 (Valid, RSA cert, EC CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_ECP_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_PKCS1_V15:MBEDTLS_ECP_DP_SECP384R1_ENABLED
-x509_verify:"data_files/server4.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server4.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #34 (Valid, EC cert, EC CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED
-x509_verify:"data_files/server5.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #35 (Revoked, EC CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED
-x509_verify:"data_files/server6.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"NULL"
+x509_verify:"data_files/server6.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"compat":"NULL"
X509 Certificate verification #36 (Valid, EC CA, SHA1 Digest)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C
-x509_verify:"data_files/server5-sha1.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5-sha1.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #37 (Valid, EC CA, SHA224 Digest)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED
-x509_verify:"data_files/server5-sha224.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5-sha224.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #38 (Valid, EC CA, SHA384 Digest)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_SHA256_C:MBEDTLS_SHA512_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED
-x509_verify:"data_files/server5-sha384.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5-sha384.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #39 (Valid, EC CA, SHA512 Digest)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_SHA256_C:MBEDTLS_SHA512_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED
-x509_verify:"data_files/server5-sha512.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5-sha512.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #40 (Valid, depth 0, RSA, CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/test-ca.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/test-ca.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #41 (Valid, depth 0, EC, CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA256_C
-x509_verify:"data_files/test-ca2.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/test-ca2.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #42 (Depth 0, not CA, RSA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA1_C
-x509_verify:"data_files/server2.crt":"data_files/server2.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server2.crt":"data_files/server2.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #43 (Depth 0, not CA, EC)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C
-x509_verify:"data_files/server5.crt":"data_files/server5.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/server5.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #44 (Corrupted signature, EC)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA256_C
-x509_verify:"data_files/server5-badsign.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server5-badsign.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #45 (Corrupted signature, RSA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA1_C
-x509_verify:"data_files/server2-badsign.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server2-badsign.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #46 (Valid, depth 2, EC-RSA-EC)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_RSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C
-x509_verify:"data_files/server7_int-ca.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server7_int-ca.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #47 (Untrusted, depth 2, EC-RSA-EC)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_RSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_PKCS1_V15:MBEDTLS_SHA1_C:MBEDTLS_SHA256_C
-x509_verify:"data_files/server7_int-ca.crt":"data_files/test-ca.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server7_int-ca.crt":"data_files/test-ca.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #48 (Missing intermediate CA, EC-RSA-EC)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_RSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_PKCS1_V15:MBEDTLS_SHA1_C:MBEDTLS_SHA256_C
-x509_verify:"data_files/server7.crt":"data_files/test-ca.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server7.crt":"data_files/test-ca.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #49 (Valid, depth 2, RSA-EC-RSA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_RSA_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server8_int-ca2.crt":"data_files/test-ca.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server8_int-ca2.crt":"data_files/test-ca.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #50 (Valid, multiple CAs)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C:MBEDTLS_SHA256_C
-x509_verify:"data_files/server2.crt":"data_files/test-ca_cat12.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server2.crt":"data_files/test-ca_cat12.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #51 (Valid, multiple CAs, reverse order)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C:MBEDTLS_SHA256_C
-x509_verify:"data_files/server2.crt":"data_files/test-ca_cat21.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server2.crt":"data_files/test-ca_cat21.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #52 (CA keyUsage valid)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED
-x509_verify:"data_files/server5.crt":"data_files/test-ca2.ku-crt_crl.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2.ku-crt_crl.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #53 (CA keyUsage missing cRLSign)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_X509_CHECK_KEY_USAGE:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED
-x509_verify:"data_files/server5.crt":"data_files/test-ca2.ku-crt.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCRL_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2.ku-crt.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCRL_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #54 (CA keyUsage missing cRLSign, no CRL)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C
-x509_verify:"data_files/server5.crt":"data_files/test-ca2.ku-crt.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2.ku-crt.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #55 (CA keyUsage missing keyCertSign)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_X509_CHECK_KEY_USAGE:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED
-x509_verify:"data_files/server5.crt":"data_files/test-ca2.ku-crl.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2.ku-crl.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #56 (CA keyUsage plain wrong)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_X509_CHECK_KEY_USAGE:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED
-x509_verify:"data_files/server5.crt":"data_files/test-ca2.ku-ds.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2.ku-ds.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #57 (Valid, RSASSA-PSS, SHA-1)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server9.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #58 (Valid, RSASSA-PSS, SHA-224)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9-sha224.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha224.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server9-sha224.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha224.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #59 (Valid, RSASSA-PSS, SHA-256)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9-sha256.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha256.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server9-sha256.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha256.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #60 (Valid, RSASSA-PSS, SHA-384)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA512_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9-sha384.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha384.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server9-sha384.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha384.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #61 (Valid, RSASSA-PSS, SHA-512)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA512_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9-sha512.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha512.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server9-sha512.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha512.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #62 (Revoked, RSASSA-PSS, SHA-1)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha1.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"NULL"
+x509_verify:"data_files/server9.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha1.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"compat":"NULL"
X509 Certificate verification #63 (Revoked, RSASSA-PSS, SHA-1, CRL badsign)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha1-badsign.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCRL_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server9.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha1-badsign.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCRL_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #64 (Valid, RSASSA-PSS, SHA-1, not top)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9-with-ca.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server9-with-ca.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #65 (RSASSA-PSS, SHA1, bad cert signature)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9-badsign.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server9-badsign.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #66 (RSASSA-PSS, SHA1, no RSA CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA1_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA256_C
-x509_verify:"data_files/server9.crt":"data_files/test-ca2.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server9.crt":"data_files/test-ca2.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #67 (Valid, RSASSA-PSS, all defaults)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9-defaults.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha1.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server9-defaults.crt":"data_files/test-ca.crt":"data_files/crl-rsa-pss-sha1.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #68 (RSASSA-PSS, wrong salt_len)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9-bad-saltlen.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server9-bad-saltlen.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #69 (RSASSA-PSS, wrong mgf_hash)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server9-bad-mgfhash.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server9-bad-mgfhash.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #70 (v1 trusted CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server1-v1.crt":"data_files/test-ca-v1.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server1-v1.crt":"data_files/test-ca-v1.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #71 (v1 trusted CA, other)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server2-v1.crt":"data_files/server1-v1.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server2-v1.crt":"data_files/server1-v1.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #72 (v1 chain)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server2-v1-chain.crt":"data_files/test-ca-v1.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server2-v1-chain.crt":"data_files/test-ca-v1.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #73 (selfsigned trusted without CA bit)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C
-x509_verify:"data_files/server5-selfsigned.crt":"data_files/server5-selfsigned.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5-selfsigned.crt":"data_files/server5-selfsigned.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #74 (signed by selfsigned trusted without CA bit)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C
-x509_verify:"data_files/server6-ss-child.crt":"data_files/server5-selfsigned.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"NULL"
+x509_verify:"data_files/server6-ss-child.crt":"data_files/server5-selfsigned.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL"
X509 Certificate verification #75 (encoding mismatch)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/enco-cert-utf8str.pem":"data_files/enco-ca-prstr.pem":"data_files/crl.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/enco-cert-utf8str.pem":"data_files/enco-ca-prstr.pem":"data_files/crl.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #76 (multiple CRLs, not revoked)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C:MBEDTLS_RSA_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server5.crt":"data_files/test-ca_cat12.crt":"data_files/crl_cat_ec-rsa.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca_cat12.crt":"data_files/crl_cat_ec-rsa.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #77 (multiple CRLs, revoked)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C:MBEDTLS_RSA_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server6.crt":"data_files/test-ca_cat12.crt":"data_files/crl_cat_ec-rsa.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"NULL"
+x509_verify:"data_files/server6.crt":"data_files/test-ca_cat12.crt":"data_files/crl_cat_ec-rsa.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"compat":"NULL"
X509 Certificate verification #78 (multiple CRLs, revoked by second)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C:MBEDTLS_RSA_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server6.crt":"data_files/test-ca_cat12.crt":"data_files/crl_cat_rsa-ec.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"NULL"
+x509_verify:"data_files/server6.crt":"data_files/test-ca_cat12.crt":"data_files/crl_cat_rsa-ec.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"compat":"NULL"
X509 Certificate verification #79 (multiple CRLs, revoked by future)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C:MBEDTLS_RSA_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server6.crt":"data_files/test-ca_cat12.crt":"data_files/crl_cat_ecfut-rsa.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED|MBEDTLS_X509_BADCRL_FUTURE:"NULL"
+x509_verify:"data_files/server6.crt":"data_files/test-ca_cat12.crt":"data_files/crl_cat_ecfut-rsa.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED|MBEDTLS_X509_BADCRL_FUTURE:"compat":"NULL"
X509 Certificate verification #80 (multiple CRLs, first future, revoked by second)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C:MBEDTLS_RSA_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/server1.crt":"data_files/test-ca_cat12.crt":"data_files/crl_cat_ecfut-rsa.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"NULL"
+x509_verify:"data_files/server1.crt":"data_files/test-ca_cat12.crt":"data_files/crl_cat_ecfut-rsa.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_REVOKED:"compat":"NULL"
X509 Certificate verification #81 (multiple CRLs, none relevant)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C:MBEDTLS_RSA_C:MBEDTLS_SHA1_C
-x509_verify:"data_files/enco-cert-utf8str.pem":"data_files/enco-ca-prstr.pem":"data_files/crl_cat_rsa-ec.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/enco-cert-utf8str.pem":"data_files/enco-ca-prstr.pem":"data_files/crl_cat_rsa-ec.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #82 (Not yet valid CA and valid CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C:MBEDTLS_SHA256_C
-x509_verify:"data_files/server5.crt":"data_files/test-ca2_cat-future-present.crt":"data_files/crl-ec-sha1.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2_cat-future-present.crt":"data_files/crl-ec-sha1.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #83 (valid CA and Not yet valid CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C:MBEDTLS_SHA256_C
-x509_verify:"data_files/server5.crt":"data_files/test-ca2_cat-present-future.crt":"data_files/crl-ec-sha1.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2_cat-present-future.crt":"data_files/crl-ec-sha1.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #84 (valid CA and Not yet valid CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C:MBEDTLS_SHA256_C
-x509_verify:"data_files/server5.crt":"data_files/test-ca2_cat-present-past.crt":"data_files/crl-ec-sha1.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2_cat-present-past.crt":"data_files/crl-ec-sha1.pem":"NULL":0:0:"compat":"NULL"
X509 Certificate verification #85 (Not yet valid CA and valid CA)
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C:MBEDTLS_SHA256_C
-x509_verify:"data_files/server5.crt":"data_files/test-ca2_cat-past-present.crt":"data_files/crl-ec-sha1.pem":"NULL":0:0:"NULL"
+x509_verify:"data_files/server5.crt":"data_files/test-ca2_cat-past-present.crt":"data_files/crl-ec-sha1.pem":"NULL":0:0:"compat":"NULL"
+
+X509 Certificate verification #86 (Not yet valid CA and invalid CA)
+depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C:MBEDTLS_SHA256_C
+x509_verify:"data_files/server5.crt":"data_files/test-ca2_cat-future-invalid.crt":"data_files/crl-ec-sha1.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_FUTURE:"compat":"NULL"
+
+X509 Certificate verification #87 (Expired CA and invalid CA)
+depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C:MBEDTLS_SHA256_C
+x509_verify:"data_files/server5.crt":"data_files/test-ca2_cat-past-invalid.crt":"data_files/crl-ec-sha1.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_EXPIRED:"compat":"NULL"
+
+X509 Certificate verification #88 (Suite B invalid, EC cert, RSA CA)
+depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_PKCS1_V15:MBEDTLS_SHA1_C
+x509_verify:"data_files/server3.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_BAD_MD|MBEDTLS_X509_BADCERT_BAD_PK|MBEDTLS_X509_BADCERT_BAD_KEY|MBEDTLS_X509_BADCRL_BAD_MD|MBEDTLS_X509_BADCRL_BAD_PK:"suite_b":"NULL"
+
+X509 Certificate verification #89 (Suite B invalid, RSA cert, EC CA)
+depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_ECP_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_PKCS1_V15:MBEDTLS_ECP_DP_SECP384R1_ENABLED
+x509_verify:"data_files/server4.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_BAD_PK:"suite_b":"NULL"
+
+X509 Certificate verification #90 (Suite B Valid, EC cert, EC CA)
+depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECP_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED
+x509_verify:"data_files/server5.crt":"data_files/test-ca2.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"suite_b":"NULL"
+
+X509 Certificate verification #91 (next profile Invalid Cert SHA224 Digest)
+depends_on:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
+x509_verify:"data_files/cert_sha224.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_BAD_MD|MBEDTLS_X509_BADCRL_BAD_MD:"next":"NULL"
+
+X509 Certificate verification #92 (next profile Valid Cert SHA256 Digest)
+depends_on:MBEDTLS_SHA256_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15
+x509_verify:"data_files/cert_sha256.crt":"data_files/test-ca.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"next":"NULL"
X509 Certificate verification callback: trusted EE cert
depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED
depends_on:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA1_C
x509parse_crt:"3081E430819F020104300D06092A864886F70D0101050500300F310D300B0603550403130454657374301E170D3133303731303135303233375A170D3233303730383135303233375A300F310D300B06035504031304546573743049301306072A8648CE3D020106082A8648CE3D03010103320004E962551A325B21B50CF6B990E33D4318FD16677130726357A196E3EFE7107BCB6BDC6D9DB2A4DF7C964ACFE81798433D300D06092A864886F70D01010505000331001A6C18CD1E457474B2D3912743F44B571341A7859A0122774A8E19A671680878936949F904C9255BDD6FFFDB33A7E6D8":"cert. version \: 1\nserial number \: 04\nissuer name \: CN=Test\nsubject name \: CN=Test\nissued on \: 2013-07-10 15\:02\:37\nexpires on \: 2023-07-08 15\:02\:37\nsigned using \: RSA with SHA1\nEC key size \: 192 bits\n":0
+X509 Certificate ASN1 (invalid version 3)
+x509parse_crt:"30173015a0030201038204deadbeef30080604cafed00d0500":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION
+
+X509 Certificate ASN1 (invalid version overflow)
+x509parse_crt:"301A3018a00602047FFFFFFF8204deadbeef30080604cafed00d0500":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION
+
+X509 Certificate ASN1 (invalid SubjectAltNames tag)
+depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA1_C
+x509parse_crt:"308203723082025AA003020102020111300D06092A864886F70D0101050500303B310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C3119301706035504031310506F6C617253534C2054657374204341301E170D3132303531303133323334315A170D3232303531313133323334315A303A310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C311830160603550403130F7777772E6578616D706C652E636F6D30820122300D06092A864886F70D01010105000382010F003082010A0282010100B93C4AC5C8A38E9017A49E52AA7175266180E7C7B56D8CFFAAB64126B7BE11AD5C73160C64114804FFD6E13B05DB89BBB39709D51C14DD688739B03D71CBE276D01AD8182D801B54F6E5449AF1CBAF612EDF490D9D09B7EDB1FD3CFD3CFA24CF5DBF7CE453E725B5EA4422E926D3EA20949EE66167BA2E07670B032FA209EDF0338F0BCE10EF67A4C608DAC1EDC23FD74ADD153DF95E1C8160463EB5B33D2FA6DE471CBC92AEEBDF276B1656B7DCECD15557A56EEC7525F5B77BDFABD23A5A91987D97170B130AA76B4A8BC14730FB3AF84104D5C1DFB81DBF7B01A565A2E01E36B7A65CCC305AF8CD6FCDF1196225CA01E3357FFA20F5DCFD69B26A007D17F70203010001A38181307F30090603551D1304023000301D0603551D0E041604147DE49C6BE6F9717D46D2123DAD6B1DFDC2AA784C301F0603551D23041830168014B45AE4A5B3DED252F6B9D5A6950FEB3EBCC7FDFF30320603551D11042B3029C20B6578616D706C652E636F6D820B6578616D706C652E6E6574820D2A2E6578616D706C652E6F7267300D06092A864886F70D010105050003820101004F09CB7AD5EEF5EF620DDC7BA285D68CCA95B46BDA115B92007513B9CA0BCEEAFBC31FE23F7F217479E2E6BCDA06E52F6FF655C67339CF48BC0D2F0CD27A06C34A4CD9485DA0D07389E4D4851D969A0E5799C66F1D21271F8D0529E840AE823968C39707CF3C934C1ADF2FA6A455487F7C8C1AC922DA24CD9239C68AECB08DF5698267CB04EEDE534196C127DC2FFE33FAD30EB8D432A9842853A5F0D189D5A298E71691BB9CC0418E8C58ACFFE3DD2E7AABB0B97176AD0F2733F7A929D3C076C0BF06407C0ED5A47C8AE2326E16AEDA641FB0557CDBDDF1A4BA447CB39958D2346E00EA976C143AF2101E0AA249107601F4F2C818FDCC6346128B091BF194E6":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG
+
X509 CRL ASN1 (Incorrect first tag)
x509parse_crl:"":"":MBEDTLS_ERR_X509_INVALID_FORMAT
depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C
x509parse_crl:"30463031020100300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030300d06092a864886f70d01010e050003020001":"CRL version \: 1\nissuer name \: CN=ABCD\nthis update \: 2009-01-01 00\:00\:00\nnext update \: 0000-00-00 00\:00\:00\nRevoked certificates\:\nsigned using \: RSA with SHA-224\n":0
+X509 CRL ASN1 (invalid version 2)
+x509parse_crl:"30463031020102300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030300d06092a864886f70d01010e050003020001":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION
+
+X509 CRL ASN1 (invalid version overflow)
+x509parse_crl:"3049303102047FFFFFFF300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030300d06092a864886f70d01010e050003020001":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION
+
+X509 CRL ASN1 (extension seq too long, crl-idp.pem byte 121)
+x509parse_crl:"308201b330819c020101300d06092a864886f70d01010b0500303b310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c3119301706035504031310506f6c617253534c2054657374204341170d3138303331343037333134385a170d3238303331343037333134385aa02d302b30300603551d1c0101ff041f301da01ba0198617687474703a2f2f706b692e6578616d706c652e636f6d2f300d06092a864886f70d01010b05000382010100b3fbe9d586eaf4b8ff60cf8edae06a85135db78f78198498719725b5b403c0b803c2c150f52faae7306d6a7871885dc2e9dc83a164bac7263776474ef642b660040b35a1410ac291ac8f6f18ab85e7fd6e22bd1af1c41ca95cf2448f6e2b42a018493dfc03c6b6aa1b9e3fe7b76af2182fb2121db4166bf0167d6f379c5a58adee5082423434d97be2909f5e7488053f996646db10dd49782626da53ad8eada01813c031b2bacdb0203bc017aac1735951a11d013ee4d1d5f7143ccbebf2371e66a1bec6e1febe69148f50784eef8adbb66664c96196d7e0c0bcdc807f447b54e058f37642a3337995bfbcd332208bd6016936705c82263eabd7affdba92fae3":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA
+
+X509 CRL ASN1 (extension oid too long, crl-idp.pem byte 123)
+x509parse_crl:"308201b330819c020101300d06092a864886f70d01010b0500303b310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c3119301706035504031310506f6c617253534c2054657374204341170d3138303331343037333134385a170d3238303331343037333134385aa02d302b30290628551d1c0101ff041f301da01ba0198617687474703a2f2f706b692e6578616d706c652e636f6d2f300d06092a864886f70d01010b05000382010100b3fbe9d586eaf4b8ff60cf8edae06a85135db78f78198498719725b5b403c0b803c2c150f52faae7306d6a7871885dc2e9dc83a164bac7263776474ef642b660040b35a1410ac291ac8f6f18ab85e7fd6e22bd1af1c41ca95cf2448f6e2b42a018493dfc03c6b6aa1b9e3fe7b76af2182fb2121db4166bf0167d6f379c5a58adee5082423434d97be2909f5e7488053f996646db10dd49782626da53ad8eada01813c031b2bacdb0203bc017aac1735951a11d013ee4d1d5f7143ccbebf2371e66a1bec6e1febe69148f50784eef8adbb66664c96196d7e0c0bcdc807f447b54e058f37642a3337995bfbcd332208bd6016936705c82263eabd7affdba92fae3":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA
+
+X509 CRL ASN1 (extension critical invalid length, crl-idp.pem byte 128)
+x509parse_crl:"308201b330819c020101300d06092a864886f70d01010b0500303b310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c3119301706035504031310506f6c617253534c2054657374204341170d3138303331343037333134385a170d3238303331343037333134385aa02d302b30290603551d1c0102ff041f301da01ba0198617687474703a2f2f706b692e6578616d706c652e636f6d2f300d06092a864886f70d01010b05000382010100b3fbe9d586eaf4b8ff60cf8edae06a85135db78f78198498719725b5b403c0b803c2c150f52faae7306d6a7871885dc2e9dc83a164bac7263776474ef642b660040b35a1410ac291ac8f6f18ab85e7fd6e22bd1af1c41ca95cf2448f6e2b42a018493dfc03c6b6aa1b9e3fe7b76af2182fb2121db4166bf0167d6f379c5a58adee5082423434d97be2909f5e7488053f996646db10dd49782626da53ad8eada01813c031b2bacdb0203bc017aac1735951a11d013ee4d1d5f7143ccbebf2371e66a1bec6e1febe69148f50784eef8adbb66664c96196d7e0c0bcdc807f447b54e058f37642a3337995bfbcd332208bd6016936705c82263eabd7affdba92fae3":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_INVALID_LENGTH
+
+X509 CRL ASN1 (extension data too long, crl-idp.pem byte 131)
+x509parse_crl:"308201b330819c020101300d06092a864886f70d01010b0500303b310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c3119301706035504031310506f6c617253534c2054657374204341170d3138303331343037333134385a170d3238303331343037333134385aa02d302b30290603551d1c0101ff0420301da01ba0198617687474703a2f2f706b692e6578616d706c652e636f6d2f300d06092a864886f70d01010b05000382010100b3fbe9d586eaf4b8ff60cf8edae06a85135db78f78198498719725b5b403c0b803c2c150f52faae7306d6a7871885dc2e9dc83a164bac7263776474ef642b660040b35a1410ac291ac8f6f18ab85e7fd6e22bd1af1c41ca95cf2448f6e2b42a018493dfc03c6b6aa1b9e3fe7b76af2182fb2121db4166bf0167d6f379c5a58adee5082423434d97be2909f5e7488053f996646db10dd49782626da53ad8eada01813c031b2bacdb0203bc017aac1735951a11d013ee4d1d5f7143ccbebf2371e66a1bec6e1febe69148f50784eef8adbb66664c96196d7e0c0bcdc807f447b54e058f37642a3337995bfbcd332208bd6016936705c82263eabd7affdba92fae3":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA
+
+X509 CRL ASN1 (extension data too short, crl-idp.pem byte 131)
+x509parse_crl:"308201b330819c020101300d06092a864886f70d01010b0500303b310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c3119301706035504031310506f6c617253534c2054657374204341170d3138303331343037333134385a170d3238303331343037333134385aa02d302b30290603551d1c0101ff041e301da01ba0198617687474703a2f2f706b692e6578616d706c652e636f6d2f300d06092a864886f70d01010b05000382010100b3fbe9d586eaf4b8ff60cf8edae06a85135db78f78198498719725b5b403c0b803c2c150f52faae7306d6a7871885dc2e9dc83a164bac7263776474ef642b660040b35a1410ac291ac8f6f18ab85e7fd6e22bd1af1c41ca95cf2448f6e2b42a018493dfc03c6b6aa1b9e3fe7b76af2182fb2121db4166bf0167d6f379c5a58adee5082423434d97be2909f5e7488053f996646db10dd49782626da53ad8eada01813c031b2bacdb0203bc017aac1735951a11d013ee4d1d5f7143ccbebf2371e66a1bec6e1febe69148f50784eef8adbb66664c96196d7e0c0bcdc807f447b54e058f37642a3337995bfbcd332208bd6016936705c82263eabd7affdba92fae3":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH
+
+X509 CRL ASN1 (extension not critical explicit, crl-idp.pem byte 129)
+x509parse_crl:"308201b330819c020101300d06092a864886f70d01010b0500303b310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c3119301706035504031310506f6c617253534c2054657374204341170d3138303331343037333134385a170d3238303331343037333134385aa02d302b30290603551d1c010100041f301da01ba0198617687474703a2f2f706b692e6578616d706c652e636f6d2f300d06092a864886f70d01010b05000382010100b3fbe9d586eaf4b8ff60cf8edae06a85135db78f78198498719725b5b403c0b803c2c150f52faae7306d6a7871885dc2e9dc83a164bac7263776474ef642b660040b35a1410ac291ac8f6f18ab85e7fd6e22bd1af1c41ca95cf2448f6e2b42a018493dfc03c6b6aa1b9e3fe7b76af2182fb2121db4166bf0167d6f379c5a58adee5082423434d97be2909f5e7488053f996646db10dd49782626da53ad8eada01813c031b2bacdb0203bc017aac1735951a11d013ee4d1d5f7143ccbebf2371e66a1bec6e1febe69148f50784eef8adbb66664c96196d7e0c0bcdc807f447b54e058f37642a3337995bfbcd332208bd6016936705c82263eabd7affdba92fae3":"CRL version \: 2\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nthis update \: 2018-03-14 07\:31\:48\nnext update \: 2028-03-14 07\:31\:48\nRevoked certificates\:\nsigned using \: RSA with SHA-256\n":0
+
X509 CRT parse path #2 (one cert)
depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C
mbedtls_x509_crt_parse_path:"data_files/dir1":0:1
depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED
mbedtls_x509_crt_parse_path:"data_files/dir3":1:2
+X509 CRT verify long chain (max intermediate CA, trusted)
+depends_on:MBEDTLS_SHA256_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED
+mbedtls_x509_crt_verify_max:"data_files/dir-maxpath/00.crt":"data_files/dir-maxpath":MBEDTLS_X509_MAX_INTERMEDIATE_CA:0:0
+
+X509 CRT verify long chain (max intermediate CA, untrusted)
+depends_on:MBEDTLS_SHA256_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED
+mbedtls_x509_crt_verify_max:"data_files/test-ca2.crt":"data_files/dir-maxpath":MBEDTLS_X509_MAX_INTERMEDIATE_CA-1:MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED
+
+X509 CRT verify long chain (max intermediate CA + 1)
+depends_on:MBEDTLS_SHA256_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED
+mbedtls_x509_crt_verify_max:"data_files/dir-maxpath/00.crt":"data_files/dir-maxpath":MBEDTLS_X509_MAX_INTERMEDIATE_CA+1:MBEDTLS_ERR_X509_FATAL_ERROR:-1
+
X509 CRT verify chain #1 (zero pathlen intermediate)
depends_on:MBEDTLS_SHA256_C:MBEDTLS_RSA_C
mbedtls_x509_crt_verify_chain:"data_files/dir4/cert14.crt data_files/dir4/cert13.crt data_files/dir4/cert12.crt":"data_files/dir4/cert11.crt":MBEDTLS_X509_BADCERT_NOT_TRUSTED
depends_on:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C
mbedtls_x509_csr_parse:"308201193081BF0201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFFA029302706092A864886F70D01090E311A301830090603551D1304023000300B0603551D0F0404030205E0300906072A8648CE3D04010349003046022100B49FD8C8F77ABFA871908DFBE684A08A793D0F490A43D86FCF2086E4F24BB0C2022100F829D5CCD3742369299E6294394717C4B723A0F68B44E831B6E6C3BCABF9724300":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH
+X509 CSR ASN.1 (invalid version overflow)
+mbedtls_x509_csr_parse:"3008300602047FFFFFFF":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION
+
X509 File parse (no issues)
depends_on:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C
x509parse_crt_file:"data_files/server7_int-ca.crt":0
X509 Get time (UTC invalid sec)
depends_on:MBEDTLS_X509_USE_C
x509_get_time:MBEDTLS_ASN1_UTC_TIME:"001130235960Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (UTC without time zone)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"000229121212":0:2000:2:29:12:12:12
+
+X509 Get time (UTC with invalid time zone #1)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"000229121212J":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (UTC with invalid time zone #2)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"000229121212+0300":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (Date with invalid tag)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_CONTEXT_SPECIFIC:"000229121212":MBEDTLS_ERR_X509_INVALID_DATE+MBEDTLS_ERR_ASN1_UNEXPECTED_TAG:0:0:0:0:0:0
+
+X509 Get time (UTC, truncated)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"000229121":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (Generalized Time, truncated)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_GENERALIZED_TIME:"20000229121":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (UTC without seconds)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0002291212":MBEDTLS_ERR_X509_INVALID_DATE:2000:2:29:12:12:0
+
+X509 Get time (UTC without seconds and with invalid time zone #1)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0002291212J":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (UTC without second and with invalid time zone #2)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0002291212+0300":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (UTC invalid character in year)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0\1130231212Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (UTC invalid character in month)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"001%30231212Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (UTC invalid character in day)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0011`0231212Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (UTC invalid character in hour)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0011302h1212Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (UTC invalid character in min)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"00113023u012Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (UTC invalid character in sec)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_UTC_TIME:"0011302359n0Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (Generalized Time, year multiple of 100 but not 400 is not a leap year)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_GENERALIZED_TIME:"19000229000000Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
+
+X509 Get time (Generalized Time, year multiple of 4 but not 100 is a leap year)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_GENERALIZED_TIME:"19920229000000Z":0:1992:2:29:0:0:0
+
+X509 Get time (Generalized Time, year multiple of 400 is a leap year)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_GENERALIZED_TIME:"20000229000000Z":0:2000:2:29:0:0:0
+
+X509 Get time (Generalized Time invalid leap year not multiple of 4, 100 or 400)
+depends_on:MBEDTLS_X509_USE_C
+x509_get_time:MBEDTLS_ASN1_GENERALIZED_TIME:"19910229000000Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0
#include "mbedtls/oid.h"
#include "mbedtls/base64.h"
+#if MBEDTLS_X509_MAX_INTERMEDIATE_CA > 19
+#error "The value of MBEDTLS_X509_MAX_INTERMEDIATE_C is larger \
+than the current threshold 19. To test larger values, please \
+adapt the script tests/data_files/dir-max/long.sh."
+#endif
+
+/* Profile for backward compatibility. Allows SHA-1, unlike the default
+ profile. */
const mbedtls_x509_crt_profile compat_profile =
{
MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA1 ) |
}
/* END_CASE */
+/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRL_PARSE_C */
+void mbedtls_x509_crl_parse( char *crl_file, int result )
+{
+ mbedtls_x509_crl crl;
+ char buf[2000];
+
+ mbedtls_x509_crl_init( &crl );
+ memset( buf, 0, 2000 );
+
+ TEST_ASSERT( mbedtls_x509_crl_parse_file( &crl, crl_file ) == result );
+
+exit:
+ mbedtls_x509_crl_free( &crl );
+}
+/* END_CASE */
+
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CSR_PARSE_C */
void mbedtls_x509_csr_info( char *csr_file, char *result_str )
{
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_CRL_PARSE_C */
void x509_verify( char *crt_file, char *ca_file, char *crl_file,
char *cn_name_str, int result, int flags_result,
+ char *profile_str,
char *verify_callback )
{
mbedtls_x509_crt crt;
int res;
int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *) = NULL;
char * cn_name = NULL;
+ const mbedtls_x509_crt_profile *profile;
mbedtls_x509_crt_init( &crt );
mbedtls_x509_crt_init( &ca );
if( strcmp( cn_name_str, "NULL" ) != 0 )
cn_name = cn_name_str;
+ if( strcmp( profile_str, "default" ) == 0 )
+ profile = &mbedtls_x509_crt_profile_default;
+ else if( strcmp( profile_str, "next" ) == 0 )
+ profile = &mbedtls_x509_crt_profile_next;
+ else if( strcmp( profile_str, "suite_b" ) == 0 )
+ profile = &mbedtls_x509_crt_profile_suiteb;
+ else if( strcmp( profile_str, "compat" ) == 0 )
+ profile = &compat_profile;
+ else
+ TEST_ASSERT( "Unknown algorithm profile" == 0 );
+
if( strcmp( verify_callback, "NULL" ) == 0 )
f_vrfy = NULL;
else if( strcmp( verify_callback, "verify_none" ) == 0 )
TEST_ASSERT( mbedtls_x509_crt_parse_file( &ca, ca_file ) == 0 );
TEST_ASSERT( mbedtls_x509_crl_parse_file( &crl, crl_file ) == 0 );
- res = mbedtls_x509_crt_verify_with_profile( &crt, &ca, &crl, &compat_profile, cn_name, &flags, f_vrfy, NULL );
+ res = mbedtls_x509_crt_verify_with_profile( &crt, &ca, &crl, profile, cn_name, &flags, f_vrfy, NULL );
TEST_ASSERT( res == ( result ) );
TEST_ASSERT( flags == (uint32_t)( flags_result ) );
TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 );
TEST_ASSERT( mbedtls_x509_crt_parse_file( &ca, ca_file ) == 0 );
- ret = mbedtls_x509_crt_verify( &crt, &ca, NULL, NULL, &flags,
- verify_print, &vrfy_ctx );
+ ret = mbedtls_x509_crt_verify_with_profile( &crt, &ca, NULL,
+ &compat_profile,
+ NULL, &flags,
+ verify_print, &vrfy_ctx );
TEST_ASSERT( ret == exp_ret );
TEST_ASSERT( strcmp( vrfy_ctx.buf, exp_vrfy_out ) == 0 );
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
+void mbedtls_x509_crt_verify_max( char *ca_file, char *chain_dir, int nb_int,
+ int ret_chk, int flags_chk )
+{
+ char file_buf[128];
+ int ret;
+ uint32_t flags;
+ mbedtls_x509_crt trusted, chain;
+
+ /*
+ * We expect chain_dir to contain certificates 00.crt, 01.crt, etc.
+ * with NN.crt signed by NN-1.crt
+ */
+
+ mbedtls_x509_crt_init( &trusted );
+ mbedtls_x509_crt_init( &chain );
+
+ /* Load trusted root */
+ TEST_ASSERT( mbedtls_x509_crt_parse_file( &trusted, ca_file ) == 0 );
+
+ /* Load a chain with nb_int intermediates (from 01 to nb_int),
+ * plus one "end-entity" cert (nb_int + 1) */
+ ret = mbedtls_snprintf( file_buf, sizeof file_buf, "%s/c%02d.pem", chain_dir,
+ nb_int + 1 );
+ TEST_ASSERT( ret > 0 && (size_t) ret < sizeof file_buf );
+ TEST_ASSERT( mbedtls_x509_crt_parse_file( &chain, file_buf ) == 0 );
+
+ /* Try to verify that chain */
+ ret = mbedtls_x509_crt_verify( &chain, &trusted, NULL, NULL, &flags,
+ NULL, NULL );
+ TEST_ASSERT( ret == ret_chk );
+ TEST_ASSERT( flags == (uint32_t) flags_chk );
+
+exit:
+ mbedtls_x509_crt_free( &chain );
+ mbedtls_x509_crt_free( &trusted );
+}
+/* END_CASE */
+
+/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */
void mbedtls_x509_crt_verify_chain( char *chain_paths, char *trusted_ca, int flags_result )
{
char* act;
int hour, int min, int sec )
{
mbedtls_x509_time time;
- unsigned char buf[17];
+ unsigned char buf[21];
unsigned char* start = buf;
unsigned char* end = buf;
memset( &time, 0x00, sizeof( time ) );
*end = (unsigned char)tag; end++;
- if( tag == MBEDTLS_ASN1_UTC_TIME )
- *end = 13;
- else
- *end = 15;
+ *end = strlen( time_str );
+ TEST_ASSERT( *end < 20 );
end++;
memcpy( end, time_str, (size_t)*(end - 1) );
end += *(end - 1);
Certificate write check Server1 SHA1
depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C
-x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:-1:"data_files/server1.crt"
+x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:1:-1:"data_files/server1.crt":0
Certificate write check Server1 SHA1, key_usage
depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C
-x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION | MBEDTLS_X509_KU_KEY_ENCIPHERMENT:0:-1:"data_files/server1.key_usage.crt"
+x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION | MBEDTLS_X509_KU_KEY_ENCIPHERMENT:0:1:-1:"data_files/server1.key_usage.crt":0
Certificate write check Server1 SHA1, ns_cert_type
depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C
-x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER:-1:"data_files/server1.cert_type.crt"
+x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER:1:-1:"data_files/server1.cert_type.crt":0
Certificate write check Server1 SHA1, version 1
depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C
-x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:MBEDTLS_X509_CRT_VERSION_1:"data_files/server1.v1.crt"
+x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:1:MBEDTLS_X509_CRT_VERSION_1:"data_files/server1.v1.crt":0
+
+Certificate write check Server1 SHA1, RSA_ALT
+depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C
+x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:0:-1:"data_files/server1.noauthid.crt":1
+
+Certificate write check Server1 SHA1, RSA_ALT, key_usage
+depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C
+x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION | MBEDTLS_X509_KU_KEY_ENCIPHERMENT:0:0:-1:"data_files/server1.key_usage_noauthid.crt":1
+
+Certificate write check Server1 SHA1, RSA_ALT, ns_cert_type
+depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C
+x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER:0:-1:"data_files/server1.cert_type_noauthid.crt":1
+
+Certificate write check Server1 SHA1, RSA_ALT, version 1
+depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C
+x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:0:MBEDTLS_X509_CRT_VERSION_1:"data_files/server1.v1.crt":1
X509 String to Names #1
mbedtls_x509_string_to_names:"C=NL,O=Offspark\, Inc., OU=PolarSSL":"C=NL, O=Offspark, Inc., OU=PolarSSL":0
#include "mbedtls/x509_csr.h"
#include "mbedtls/pem.h"
#include "mbedtls/oid.h"
+#include "mbedtls/rsa.h"
+
+#if defined(MBEDTLS_RSA_C)
+int mbedtls_rsa_decrypt_func( void *ctx, int mode, size_t *olen,
+ const unsigned char *input, unsigned char *output,
+ size_t output_max_len )
+{
+ return( mbedtls_rsa_pkcs1_decrypt( (mbedtls_rsa_context *) ctx, NULL, NULL, mode, olen,
+ input, output, output_max_len ) );
+}
+int mbedtls_rsa_sign_func( void *ctx,
+ int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
+ int mode, mbedtls_md_type_t md_alg, unsigned int hashlen,
+ const unsigned char *hash, unsigned char *sig )
+{
+ return( mbedtls_rsa_pkcs1_sign( (mbedtls_rsa_context *) ctx, f_rng, p_rng, mode,
+ md_alg, hashlen, hash, sig ) );
+}
+size_t mbedtls_rsa_key_len_func( void *ctx )
+{
+ return( ((const mbedtls_rsa_context *) ctx)->len );
+}
+#endif /* MBEDTLS_RSA_C */
+
/* END_HEADER */
/* BEGIN_DEPENDENCIES
if( cert_type != 0 )
TEST_ASSERT( mbedtls_x509write_csr_set_ns_cert_type( &req, cert_type ) == 0 );
- ret = mbedtls_x509write_csr_pem( &req, buf, sizeof(buf),
+ ret = mbedtls_x509write_csr_pem( &req, buf, sizeof( buf ),
rnd_pseudo_rand, &rnd_info );
TEST_ASSERT( ret == 0 );
char *subject_name, char *issuer_key_file,
char *issuer_pwd, char *issuer_name,
char *serial_str, char *not_before, char *not_after,
- int md_type, int key_usage, int cert_type, int ver,
- char *cert_check_file )
+ int md_type, int key_usage, int cert_type, int auth_ident,
+ int ver, char *cert_check_file, int rsa_alt )
{
- mbedtls_pk_context subject_key, issuer_key;
+ mbedtls_pk_context subject_key, issuer_key, issuer_key_alt;
+ mbedtls_pk_context *key = &issuer_key;
+
mbedtls_x509write_cert crt;
unsigned char buf[4096];
unsigned char check_buf[5000];
memset( &rnd_info, 0x2a, sizeof( rnd_pseudo_info ) );
mbedtls_mpi_init( &serial );
+
mbedtls_pk_init( &subject_key );
- mbedtls_pk_init( &issuer_key );
+ mbedtls_pk_init( &issuer_key );
+ mbedtls_pk_init( &issuer_key_alt );
+
+ mbedtls_x509write_crt_init( &crt );
TEST_ASSERT( mbedtls_pk_parse_keyfile( &subject_key, subject_key_file,
subject_pwd ) == 0 );
+
TEST_ASSERT( mbedtls_pk_parse_keyfile( &issuer_key, issuer_key_file,
issuer_pwd ) == 0 );
+
+ /* For RSA PK contexts, create a copy as an alternative RSA context. */
+ if( rsa_alt == 1 && mbedtls_pk_get_type( &issuer_key ) == MBEDTLS_PK_RSA )
+ {
+ TEST_ASSERT( mbedtls_pk_setup_rsa_alt( &issuer_key_alt,
+ mbedtls_pk_rsa( issuer_key ),
+ mbedtls_rsa_decrypt_func,
+ mbedtls_rsa_sign_func,
+ mbedtls_rsa_key_len_func ) == 0 );
+
+ key = &issuer_key_alt;
+ }
+
TEST_ASSERT( mbedtls_mpi_read_string( &serial, 10, serial_str ) == 0 );
- mbedtls_x509write_crt_init( &crt );
if( ver != -1 )
mbedtls_x509write_crt_set_version( &crt, ver );
+
TEST_ASSERT( mbedtls_x509write_crt_set_serial( &crt, &serial ) == 0 );
TEST_ASSERT( mbedtls_x509write_crt_set_validity( &crt, not_before,
- not_after ) == 0 );
+ not_after ) == 0 );
mbedtls_x509write_crt_set_md_alg( &crt, md_type );
TEST_ASSERT( mbedtls_x509write_crt_set_issuer_name( &crt, issuer_name ) == 0 );
TEST_ASSERT( mbedtls_x509write_crt_set_subject_name( &crt, subject_name ) == 0 );
mbedtls_x509write_crt_set_subject_key( &crt, &subject_key );
- mbedtls_x509write_crt_set_issuer_key( &crt, &issuer_key );
+
+ mbedtls_x509write_crt_set_issuer_key( &crt, key );
if( crt.version >= MBEDTLS_X509_CRT_VERSION_3 )
{
TEST_ASSERT( mbedtls_x509write_crt_set_basic_constraints( &crt, 0, 0 ) == 0 );
TEST_ASSERT( mbedtls_x509write_crt_set_subject_key_identifier( &crt ) == 0 );
- TEST_ASSERT( mbedtls_x509write_crt_set_authority_key_identifier( &crt ) == 0 );
+ if( auth_ident )
+ TEST_ASSERT( mbedtls_x509write_crt_set_authority_key_identifier( &crt ) == 0 );
if( key_usage != 0 )
TEST_ASSERT( mbedtls_x509write_crt_set_key_usage( &crt, key_usage ) == 0 );
if( cert_type != 0 )
TEST_ASSERT( mbedtls_x509write_crt_set_ns_cert_type( &crt, cert_type ) == 0 );
}
- ret = mbedtls_x509write_crt_pem( &crt, buf, sizeof(buf),
- rnd_pseudo_rand, &rnd_info );
+ ret = mbedtls_x509write_crt_pem( &crt, buf, sizeof( buf ),
+ rnd_pseudo_rand, &rnd_info );
TEST_ASSERT( ret == 0 );
pem_len = strlen( (char *) buf );
f = fopen( cert_check_file, "r" );
TEST_ASSERT( f != NULL );
- olen = fread( check_buf, 1, sizeof(check_buf), f );
+ olen = fread( check_buf, 1, sizeof( check_buf ), f );
fclose( f );
- TEST_ASSERT( olen < sizeof(check_buf) );
+ TEST_ASSERT( olen < sizeof( check_buf ) );
TEST_ASSERT( olen >= pem_len - 1 );
TEST_ASSERT( memcmp( buf, check_buf, pem_len - 1 ) == 0 );
der_len = mbedtls_x509write_crt_der( &crt, buf, sizeof( buf ),
- rnd_pseudo_rand, &rnd_info );
+ rnd_pseudo_rand, &rnd_info );
TEST_ASSERT( der_len >= 0 );
if( der_len == 0 )
goto exit;
ret = mbedtls_x509write_crt_der( &crt, buf, (size_t)( der_len - 1 ),
- rnd_pseudo_rand, &rnd_info );
+ rnd_pseudo_rand, &rnd_info );
TEST_ASSERT( ret == MBEDTLS_ERR_ASN1_BUF_TOO_SMALL );
exit:
mbedtls_x509write_crt_free( &crt );
- mbedtls_pk_free( &issuer_key );
+ mbedtls_pk_free( &issuer_key_alt );
mbedtls_pk_free( &subject_key );
+ mbedtls_pk_free( &issuer_key );
mbedtls_mpi_free( &serial );
}
/* END_CASE */
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <ItemGroup Label="ProjectConfigurations">\r
+ <ProjectConfiguration Include="Debug|Win32">\r
+ <Configuration>Debug</Configuration>\r
+ <Platform>Win32</Platform>\r
+ </ProjectConfiguration>\r
+ <ProjectConfiguration Include="Debug|x64">\r
+ <Configuration>Debug</Configuration>\r
+ <Platform>x64</Platform>\r
+ </ProjectConfiguration>\r
+ <ProjectConfiguration Include="Release|Win32">\r
+ <Configuration>Release</Configuration>\r
+ <Platform>Win32</Platform>\r
+ </ProjectConfiguration>\r
+ <ProjectConfiguration Include="Release|x64">\r
+ <Configuration>Release</Configuration>\r
+ <Platform>x64</Platform>\r
+ </ProjectConfiguration>\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ClCompile Include="..\..\programs\pkey\ecdh_curve25519.c" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ProjectReference Include="mbedTLS.vcxproj">
+ <Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
+ </ProjectReference>\r
+ </ItemGroup>\r
+ <PropertyGroup Label="Globals">\r
+ <ProjectGuid>{82EE497E-12CC-7C5B-A072-665678ACB43E}</ProjectGuid>\r
+ <Keyword>Win32Proj</Keyword>\r
+ <RootNamespace>ecdh_curve25519</RootNamespace>\r
+ </PropertyGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+ <ConfigurationType>Application</ConfigurationType>\r
+ <UseDebugLibraries>true</UseDebugLibraries>\r
+ <CharacterSet>Unicode</CharacterSet>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
+ <ConfigurationType>Application</ConfigurationType>\r
+ <UseDebugLibraries>true</UseDebugLibraries>\r
+ <CharacterSet>Unicode</CharacterSet>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+ <ConfigurationType>Application</ConfigurationType>\r
+ <UseDebugLibraries>false</UseDebugLibraries>\r
+ <WholeProgramOptimization>true</WholeProgramOptimization>\r
+ <CharacterSet>Unicode</CharacterSet>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
+ <ConfigurationType>Application</ConfigurationType>\r
+ <UseDebugLibraries>false</UseDebugLibraries>\r
+ <WholeProgramOptimization>true</WholeProgramOptimization>\r
+ <CharacterSet>Unicode</CharacterSet>\r
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>\r
+ </PropertyGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+ <ImportGroup Label="ExtensionSettings">\r
+ </ImportGroup>\r
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+ </ImportGroup>\r
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">\r
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+ </ImportGroup>\r
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+ </ImportGroup>\r
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">\r
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+ </ImportGroup>\r
+ <PropertyGroup Label="UserMacros" />\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+ <ClCompile>\r
+ <PrecompiledHeader>\r
+ </PrecompiledHeader>\r
+ <WarningLevel>Level3</WarningLevel>\r
+ <Optimization>Disabled</Optimization>\r
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ <AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories>\r
+ </ClCompile>\r
+ <Link>\r
+ <SubSystem>Console</SubSystem>\r
+ <GenerateDebugInformation>true</GenerateDebugInformation>\r
+ <ShowProgress>NotSet</ShowProgress>\r
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
+ </Link>\r
+ <ProjectReference>\r
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>\r
+ </ProjectReference>\r
+ </ItemDefinitionGroup>\r
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+ <ClCompile>\r
+ <PrecompiledHeader>\r
+ </PrecompiledHeader>\r
+ <WarningLevel>Level3</WarningLevel>\r
+ <Optimization>Disabled</Optimization>\r
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ <AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories>\r
+ </ClCompile>\r
+ <Link>\r
+ <SubSystem>Console</SubSystem>\r
+ <GenerateDebugInformation>true</GenerateDebugInformation>\r
+ <ShowProgress>NotSet</ShowProgress>\r
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
+ </Link>\r
+ <ProjectReference>\r
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>\r
+ </ProjectReference>\r
+ </ItemDefinitionGroup>\r
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+ <ClCompile>\r
+ <WarningLevel>Level3</WarningLevel>\r
+ <PrecompiledHeader>\r
+ </PrecompiledHeader>\r
+ <Optimization>MaxSpeed</Optimization>\r
+ <FunctionLevelLinking>true</FunctionLevelLinking>\r
+ <IntrinsicFunctions>true</IntrinsicFunctions>\r
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ <AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories>\r
+ </ClCompile>\r
+ <Link>\r
+ <SubSystem>Console</SubSystem>\r
+ <GenerateDebugInformation>true</GenerateDebugInformation>\r
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+ <OptimizeReferences>true</OptimizeReferences>\r
+ <AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>\r
+ </ItemDefinitionGroup>\r
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+ <ClCompile>\r
+ <WarningLevel>Level3</WarningLevel>\r
+ <PrecompiledHeader>\r
+ </PrecompiledHeader>\r
+ <Optimization>MaxSpeed</Optimization>\r
+ <FunctionLevelLinking>true</FunctionLevelLinking>\r
+ <IntrinsicFunctions>true</IntrinsicFunctions>\r
+ <PreprocessorDefinitions>WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
+ <AdditionalIncludeDirectories>../../include</AdditionalIncludeDirectories>\r
+ </ClCompile>\r
+ <Link>\r
+ <SubSystem>Console</SubSystem>\r
+ <GenerateDebugInformation>true</GenerateDebugInformation>\r
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>\r
+ <OptimizeReferences>true</OptimizeReferences>\r
+ <AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
+ <AdditionalDependencies>%(AdditionalDependencies);</AdditionalDependencies>\r
+ </Link>\r
+ </ItemDefinitionGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+ <ImportGroup Label="ExtensionTargets">\r
+ </ImportGroup>\r
+</Project>\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<PropertyGroup Label="UserMacros" />\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<LinkIncremental>true</LinkIncremental>\r
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>\r
</PropertyGroup>\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
<LinkIncremental>true</LinkIncremental>\r
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>\r
</PropertyGroup>\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
<LinkIncremental>false</LinkIncremental>\r
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>\r
</PropertyGroup>\r
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<LinkIncremental>false</LinkIncremental>\r
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>\r
</PropertyGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<ClInclude Include="..\..\include\mbedtls\ecdsa.h" />\r
<ClInclude Include="..\..\include\mbedtls\ecjpake.h" />\r
<ClInclude Include="..\..\include\mbedtls\ecp.h" />\r
+ <ClInclude Include="..\..\include\mbedtls\ecp_internal.h" />\r
<ClInclude Include="..\..\include\mbedtls\entropy.h" />\r
<ClInclude Include="..\..\include\mbedtls\entropy_poll.h" />\r
<ClInclude Include="..\..\include\mbedtls\error.h" />\r
<ClInclude Include="..\..\include\mbedtls\platform_time.h" />\r
<ClInclude Include="..\..\include\mbedtls\ripemd160.h" />\r
<ClInclude Include="..\..\include\mbedtls\rsa.h" />\r
+ <ClInclude Include="..\..\include\mbedtls\rsa_internal.h" />\r
<ClInclude Include="..\..\include\mbedtls\sha1.h" />\r
<ClInclude Include="..\..\include\mbedtls\sha256.h" />\r
<ClInclude Include="..\..\include\mbedtls\sha512.h" />\r
<ClCompile Include="..\..\library\platform.c" />\r
<ClCompile Include="..\..\library\ripemd160.c" />\r
<ClCompile Include="..\..\library\rsa.c" />\r
+ <ClCompile Include="..\..\library\rsa_internal.c" />\r
<ClCompile Include="..\..\library\sha1.c" />\r
<ClCompile Include="..\..\library\sha256.c" />\r
<ClCompile Include="..\..\library\sha512.c" />\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
<ItemGroup>\r
<ProjectReference Include="mbedTLS.vcxproj">
<Project>{46cf2d25-6a36-4189-b59c-e4815388e554}</Project>\r
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>\r
</ProjectReference>\r
</ItemGroup>\r
<PropertyGroup Label="Globals">\r
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
</ImportGroup>\r
<PropertyGroup Label="UserMacros" />\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
- <LinkIncremental>true</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
- <LinkIncremental>false</LinkIncremental>\r
- </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(Configuration)\$(TargetName)\</IntDir>
+ </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
<ClCompile>\r
<PrecompiledHeader>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<SubSystem>Console</SubSystem>\r
<GenerateDebugInformation>true</GenerateDebugInformation>\r
<ShowProgress>NotSet</ShowProgress>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>Debug</AdditionalLibraryDirectories>\r
</Link>\r
<ProjectReference>\r
<EnableCOMDATFolding>true</EnableCOMDATFolding>\r
<OptimizeReferences>true</OptimizeReferences>\r
<AdditionalLibraryDirectories>Release</AdditionalLibraryDirectories>\r
- <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);mbedTLS.lib</AdditionalDependencies>
+ <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
{{start}}
- SHA-1 : 3644 Kb/s, 32 cycles/byte
- SHA-256 : 1957 Kb/s, 59 cycles/byte
- SHA-512 : 587 Kb/s, 200 cycles/byte
- AES-CBC-128 : 1359 Kb/s, 86 cycles/byte
- AES-CBC-192 : 1183 Kb/s, 99 cycles/byte
- AES-CBC-256 : 1048 Kb/s, 111 cycles/byte
- AES-GCM-128 : 421 Kb/s, 279 cycles/byte
- AES-GCM-192 : 403 Kb/s, 292 cycles/byte
- AES-GCM-256 : 385 Kb/s, 305 cycles/byte
- AES-CCM-128 : 542 Kb/s, 216 cycles/byte
- AES-CCM-192 : 484 Kb/s, 242 cycles/byte
- AES-CCM-256 : 437 Kb/s, 268 cycles/byte
- CTR_DRBG (NOPR) : 1002 Kb/s, 117 cycles/byte
- CTR_DRBG (PR) : 705 Kb/s, 166 cycles/byte
- HMAC_DRBG SHA-1 (NOPR) : 228 Kb/s, 517 cycles/byte
- HMAC_DRBG SHA-1 (PR) : 210 Kb/s, 561 cycles/byte
- HMAC_DRBG SHA-256 (NOPR) : 212 Kb/s, 557 cycles/byte
- HMAC_DRBG SHA-256 (PR) : 185 Kb/s, 637 cycles/byte
+ SHA-1 : 3644 KiB/s, 32 cycles/byte
+ SHA-256 : 1957 KiB/s, 59 cycles/byte
+ SHA-512 : 587 KiB/s, 200 cycles/byte
+ AES-CBC-128 : 1359 KiB/s, 86 cycles/byte
+ AES-CBC-192 : 1183 KiB/s, 99 cycles/byte
+ AES-CBC-256 : 1048 KiB/s, 111 cycles/byte
+ AES-GCM-128 : 421 KiB/s, 279 cycles/byte
+ AES-GCM-192 : 403 KiB/s, 292 cycles/byte
+ AES-GCM-256 : 385 KiB/s, 305 cycles/byte
+ AES-CCM-128 : 542 KiB/s, 216 cycles/byte
+ AES-CCM-192 : 484 KiB/s, 242 cycles/byte
+ AES-CCM-256 : 437 KiB/s, 268 cycles/byte
+ CTR_DRBG (NOPR) : 1002 KiB/s, 117 cycles/byte
+ CTR_DRBG (PR) : 705 KiB/s, 166 cycles/byte
+ HMAC_DRBG SHA-1 (NOPR) : 228 KiB/s, 517 cycles/byte
+ HMAC_DRBG SHA-1 (PR) : 210 KiB/s, 561 cycles/byte
+ HMAC_DRBG SHA-256 (NOPR) : 212 KiB/s, 557 cycles/byte
+ HMAC_DRBG SHA-256 (PR) : 185 KiB/s, 637 cycles/byte
RSA-2048 : 41 ms/ public
RSA-2048 : 1349 ms/private
RSA-4096 : 134 ms/ public
CODE; \
} \
\
- mbedtls_printf( "%9lu Kb/s, %9lu cycles/byte\r\n", \
+ mbedtls_printf( "%9lu KiB/s, %9lu cycles/byte\r\n", \
i * BUFSIZE / 1024, \
( mbedtls_timing_hardclock() - tsc ) / ( j * BUFSIZE ) ); \
} while( 0 )
OSX 10.10 as development host
* [Build for x86 / Linux](build/Build-for-x86-Linux.md): Ubuntu 14.04 is used as a base platform.
+* [Build for Raspberry Pi 3 / Tizen](build/Build-for-RPi3-Tizen.md)
* [Build for Stm32f4 / NuttX](build/Build-for-STM32F4-NuttX.md)
* [Build for Raspberry Pi 2 / Linux](build/Build-for-RPi2-Linux.md)
-* [Build for Artik053 / TizenRT](build/Build-for-ARTIK053-TizenRT)
+* [Build for ARTIK053 / TizenRT](build/Build-for-ARTIK053-TizenRT.md)
#### H/W boards
* Current supporting
* STM32F4-Discovery + BB
* Raspberry Pi 2
-* Plan to support
- * Samsung Artik 053
- * Samsung Artik 10
- * (and your contributions including above plans)
+ * Raspberry Pi 3
+ * Samsung ARTIK 053
We will support the correct behavior of APIs for above environments. However, since IoT.js is targeting various kind IoT devices and platforms, single implementation cannot be the best practice for every environments. Therefore embedders should be in charge of optimization for their own environments. For more details on optimization, see the [Optimization Tips](devs/Optimization-Tips.md) page.
**[Getting Started](Getting-Started.md)**
- [x86 / Linux](build/Build-for-x86-Linux.md)
- [Raspberry Pi 2 / Linux](build/Build-for-RPi2-Linux.md)
+- [Raspberry Pi 3 / Tizen](build/Build-for-RPi3-Tizen.md)
- [Stm32f4 / NuttX](build/Build-for-STM32F4-NuttX.md)
+- [ARTIK053 / TizenRT](build/Build-for-ARTIK053-TizenRT.md)
**[Developer Guide](Developer's-Guide.md)**
- [Development Process](devs/Development-Process.md)
The following table shows ADC module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| adc.open | O | X | O | O |
-| adc.openSync | O | X | O | O |
-| adcpin.read | O | X | O | O |
-| adcpin.readSync | O | X | O | O |
-| adcpin.close | O | X | O | O |
-| adcpin.closeSync | O | X | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| adc.open | X | X | X | O | O |
+| adc.openSync | X | X | X | O | O |
+| adcpin.read | X | X | X | O | O |
+| adcpin.readSync | X | X | X | O | O |
+| adcpin.close | X | X | X | O | O |
+| adcpin.closeSync | X | X | X | O | O |
# ADC
The following shows Assert module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| assert.assert | O | O | O | O |
-| assert.doesNotThrow | O | O | O | O |
-| assert.equal | O | O | O | O |
-| assert.fail | O | O | O | O |
-| assert.notEqual | O | O | O | O |
-| assert.notStrictEqual | O | O | O | O |
-| assert.strictEqual | O | O | O | O |
-| assert.throws | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| assert.assert | O | O | O | O | O |
+| assert.doesNotThrow | O | O | O | O | O |
+| assert.equal | O | O | O | O | O |
+| assert.fail | O | O | O | O | O |
+| assert.notEqual | O | O | O | O | O |
+| assert.notStrictEqual | O | O | O | O | O |
+| assert.strictEqual | O | O | O | O | O |
+| assert.throws | O | O | O | O | O |
# Assert
The following shows BLE module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| ble.startAdvertising | O | O | X | X |
-| ble.stopAdvertising | O | O | X | X |
-| ble.setServices | O | O | X | X |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| ble.startAdvertising | O | X | O | X | X |
+| ble.stopAdvertising | O | X | O | X | X |
+| ble.setServices | O | X | O | X | X |
# BLE - Bluetooth Low Energy
The following shows Buffer module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| buf.compare | O | O | O | O |
-| buf.copy | O | O | O | O |
-| buf.equals | O | O | O | O |
-| buf.fill | O | O | O | O |
-| buf.slice | O | O | O | O |
-| buf.toString | O | O | O | O |
-| buf.write | O | O | O | O |
-| buf.writeUInt8 | O | O | O | O |
-| buf.writeUInt16LE | O | O | O | O |
-| buf.writeUInt32LE | O | O | O | O |
-| buf.readInt8 | O | O | O | O |
-| buf.readUInt8 | O | O | O | O |
-| buf.readUInt16LE | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| buf.compare | O | O | O | O | O |
+| buf.copy | O | O | O | O | O |
+| buf.equals | O | O | O | O | O |
+| buf.fill | O | O | O | O | O |
+| buf.slice | O | O | O | O | O |
+| buf.toString | O | O | O | O | O |
+| buf.write | O | O | O | O | O |
+| buf.writeUInt8 | O | O | O | O | O |
+| buf.writeUInt16LE | O | O | O | O | O |
+| buf.writeUInt32LE | O | O | O | O | O |
+| buf.readInt8 | O | O | O | O | O |
+| buf.readUInt8 | O | O | O | O | O |
+| buf.readUInt16LE | O | O | O | O | O |
# Buffer
The following shows dgram module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| dgram.createSocket | O | O | △ ¹ | △ ¹ |
-| dgram.Socket.addMembership | O | O | X | O |
-| dgram.Socket.address | O | O | X | O |
-| dgram.Socket.bind | O | O | △ ¹ | △ ¹ |
-| dgram.Socket.close | O | O | △ ² | O |
-| dgram.Socket.dropMembership | O | O | X | O |
-| dgram.Socket.send | O | O | △ ¹ | △ ¹ |
-| dgram.Socket.setBroadcast | O | O | X | X |
-| dgram.Socket.setMulticastLoopback | O | O | X | O |
-| dgram.Socket.setMulticastTTL | X | X | X | O |
-| dgram.Socket.setTTL | O | O | X | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| dgram.createSocket | O | O | O | △ ¹ | △ ¹ |
+| dgram.Socket.addMembership | O | X | O | X | O |
+| dgram.Socket.address | O | O | O | X | O |
+| dgram.Socket.bind | O | O | O | △ ¹ | △ ¹ |
+| dgram.Socket.close | O | O | O | △ ² | O |
+| dgram.Socket.dropMembership | O | X | O | X | O |
+| dgram.Socket.send | O | O | O | △ ¹ | △ ¹ |
+| dgram.Socket.setBroadcast | O | X | O | X | X |
+| dgram.Socket.setMulticastLoopback | O | O | O | X | O |
+| dgram.Socket.setMulticastTTL | X | X | X | X | O |
+| dgram.Socket.setTTL | O | X | O | X | O |
1. On NuttX/STM32F4-Discovery and TizenRT/Artik053, even a couple of sockets/server/requests might not work properly.
The following shows dns module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| dns.lookup | O | O | X | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| dns.lookup | O | O | O | X | O |
※ dns.lookup currently only returns IPv4 addresses. Support for IPv6 addresses are on the roadmap.
The following shows Event module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| emitter.addListener | O | O | O | O |
-| emitter.on | O | O | O | O |
-| emitter.emit | O | O | O | O |
-| emitter.once | O | O | O | O |
-| emitter.removeListener | O | O | O | O |
-| emitter.removeAllListeners | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| emitter.addListener | O | O | O | O | O |
+| emitter.on | O | O | O | O | O |
+| emitter.emit | O | O | O | O | O |
+| emitter.once | O | O | O | O | O |
+| emitter.removeListener | O | O | O | O | O |
+| emitter.removeAllListeners | O | O | O | O | O |
# Events
The following shows fs module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| fs.close | O | O | O | O |
-| fs.closeSync | O | O | O | O |
-| fs.exists | O | O | O | O |
-| fs.existsSync | O | O | O | O |
-| fs.fstat | O | O | X | X |
-| fs.fstatSync | O | O | X | X |
-| fs.mkdir | O | O | O | O |
-| fs.mkdirSync | O | O | O | O |
-| fs.open | O | O | O | O |
-| fs.openSync | O | O | O | O |
-| fs.read | O | O | O | O |
-| fs.readSync | O | O | O | O |
-| fs.readdir | O | O | O | O |
-| fs.readdirSync | O | O | O | O |
-| fs.readFile | O | O | O | O |
-| fs.readFileSync | O | O | O | O |
-| fs.rename | O | O | O | O |
-| fs.renameSync | O | O | O | O |
-| fs.rmdir | O | O | O | O |
-| fs.rmdirSync | O | O | O | O |
-| fs.stat | O | O | O | O |
-| fs.statSync | O | O | O | O |
-| fs.unlink | O | O | O | O |
-| fs.unlinkSync | O | O | O | O |
-| fs.write | O | O | O | O |
-| fs.writeSync | O | O | O | O |
-| fs.writeFile | O | O | O | O |
-| fs.writeFileSync | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| fs.close | O | O | O | O | O |
+| fs.closeSync | O | O | O | O | O |
+| fs.exists | O | O | O | O | O |
+| fs.existsSync | O | O | O | O | O |
+| fs.fstat | O | O | O | X | X |
+| fs.fstatSync | O | O | O | X | X |
+| fs.mkdir | O | O | O | O | O |
+| fs.mkdirSync | O | O | O | O | O |
+| fs.open | O | O | O | O | O |
+| fs.openSync | O | O | O | O | O |
+| fs.read | O | O | O | O | O |
+| fs.readSync | O | O | O | O | O |
+| fs.readdir | O | O | O | O | O |
+| fs.readdirSync | O | O | O | O | O |
+| fs.readFile | O | O | O | O | O |
+| fs.readFileSync | O | O | O | O | O |
+| fs.rename | O | O | O | O | O |
+| fs.renameSync | O | O | O | O | O |
+| fs.rmdir | O | O | O | O | O |
+| fs.rmdirSync | O | O | O | O | O |
+| fs.stat | O | O | O | O | O |
+| fs.statSync | O | O | O | O | O |
+| fs.unlink | O | O | O | O | O |
+| fs.unlinkSync | O | O | O | O | O |
+| fs.write | O | O | O | O | O |
+| fs.writeSync | O | O | O | O | O |
+| fs.writeFile | O | O | O | O | O |
+| fs.writeFileSync | O | O | O | O | O |
※ On NuttX path should be passed with a form of **absolute path**.
The following shows GPIO module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| gpio.open | O | O | O | O |
-| gpio.openSync | O | O | O | O |
-| gpiopin.write | O | O | O | O |
-| gpiopin.writeSync | O | O | O | O |
-| gpiopin.read | â–³ | â–³ | O | O |
-| gpiopin.readSync | O | O | O | O |
-| gpiopin.close | O | O | O | O |
-| gpiopin.closeSync | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| gpio.open | X | O | O | O | O |
+| gpio.openSync | X | O | O | O | O |
+| gpiopin.write | X | O | O | O | O |
+| gpiopin.writeSync | X | O | O | O | O |
+| gpiopin.read | X | O | â–³ | O | O |
+| gpiopin.readSync | X | O | O | O | O |
+| gpiopin.close | X | O | O | O | O |
+| gpiopin.closeSync | X | O | O | O | O |
# GPIO
The following shows Http module APIs available for each platform.
- | | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
- | :---: | :---: | :---: | :---: | :---: |
- | http.createServer | O | O | △ ¹ | △ ¹ |
- | http.request | O | O | △ ¹ | △ ¹ |
- | http.get | O | O | △ ¹ | △ ¹ |
+ | | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+ | :---: | :---: | :---: | :---: | :---: | :---: |
+ | http.createServer | O | O | O | △ ¹ | △ ¹ |
+ | http.request | O | O | O | △ ¹ | △ ¹ |
+ | http.get | O | O | O | △ ¹ | △ ¹ |
1. On NuttX/STM32F4-Discovery and TizenRT/Artik053, even a couple of sockets/server/requests might not work properly.
After response header is parsed, this event will be fired.
+### request.abort()
+Will abort the outgoing request, dropping any data to be sent/received and destroying the underlying socket.
+
### request.end([data][, callback])
* `data` {Buffer | string}
* `callback` {Function}
## Class: http.IncomingMessage
-http.IncomingMessage inherits `Stream.readable`.
+This object is created internally and returned to the callback in http.request(). It represents the response sent by a server to a request.
+
+http.IncomingMessage inherits [`Stream.readable`](IoT.js-API-Stream.md). See it's documentation to read incoming data from an HTTP request. Notable events are `'data'` (fired when there is data to read), `'close'`, `'end'` (Request has ended) and the method `readable.read()`.
+
### Event: 'close'
When underlying connection is closed, 'close' event is emitted.
The following shows Https module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | Nuttx<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) | Tizen<br/>(Artik 10) |
-| :---: | :---: | :---: | :---: | :---: | :---: |
-| https.request | X | X | X | X | O |
-| https.get | X | X | X | X | O |
+ | | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+ | :---: | :---: | :---: | :---: | :---: | :---: |
+ | https.createServer | O | O | O | △ ¹ | △ ¹ |
+ | https.request | O | O | O | △ ¹ | △ ¹ |
+ | https.get | O | O | O | △ ¹ | △ ¹ |
+
+1. On NuttX/STM32F4-Discovery and TizenRT/Artik053, even a couple of sockets/server/requests might not work properly.
# Https
var https = require('https');
https.get({
- port: 80,
+ port: 443,
}, function(res) {
...
});
### https.METHODS
-A list of HTTPS methods supported by the parser as `string` properties of an `Object`. Currently supported methods are `'DELETE'`, `'GET'`, `'HEAD'`, `'POST'`, `'PUT'`, `'CONNECT'`, `'OPTIONS'`, `'TRACE'`.
+A list of HTTPS methods supported by the parser as `string` properties of an `Object`.
## Class: https.ClientRequest
This object is created internally and returned from https.request(). It represents an in-progress request whose header has already been queued.
-https.ClientRequest inherits [`Stream.writable`](IoT.js-API-Stream.md). See it's documentation to write data to an outgoing HTTP request. Notable methods are `'writable.write()'` (to send data as request body), `'writable.end()'` (to signal an end and flush remaining request body), and the event `'finish'`.
-
-### Event: 'close'
-This event is fired when the underlying socket is closed.
-
-### Event: 'response'
-* `response` {https.IncomingMessage}
-
-This event is emitted when server's response header is parsed. ` https.IncomingMessage` object is passed as argument to handler.
-
-### Event: 'socket'
-This event is emitted when a socket is assigned to this request.
-
-### request.abort()
-Will abort the outgoing request, dropping any data to be sent/received and destroying the underlying socket.
-
-### request.aborted
-If the request has been aborted, this contains the time at which the request was aborted in milliseconds since epoch as `Number`.
-
-### request.setTimeout(ms, cb)
-* `ms` {number}
-* `cb` {Function}
-
-Registers cb for 'timeout' event and set socket's timeout value to ms. This event will be triggered by the underlying socket's 'timeout' event.
-
-If cb is not provided, the socket will be destroyed automatically after timeout.
-If you provides cb, you should handle the socket's timeout.
-
+See also: [http.ClientRequest](IoT.js-API-HTTP.md#class-httpclientrequest)
## Class: https.IncomingMessage
This object is created internally and returned to the callback in https.request(). It represents the response sent by a server to a request.
-https.IncomingMessage inherits [`Stream.readable`](IoT.js-API-Stream.md). See it's documentation to read incoming data from an HTTP request. Notable events are `'data'` (fired when there is data to read), `'close'`, `'end'` (Request has ended) and the method `readable.read()`.
-
-### message.headers
-HTTPS header object.
-
-### message.method
-Request's method as `string`
-
-### message.statusCode
-HTTPS response status code as `number` of 3-digit.
-
-### message.statusMessage
-HTTPS response status message as `string`
-
-### message.url
-Requests URL as `string`
-
-### message.setTimeout(ms, cb)
-* `ms` {number}
-* `cb` {Function}
-
-Registers cb for 'timeout' event set socket's timeout value to ms. This event will be triggered by the underlying socket's 'timeout' event.
-
-If cb is not provided, the socket will be destroyed automatically after timeout.
-If you provides cb, you should handle the socket's timeout.
+See also: [http.IncomingMessage](IoT.js-API-HTTP.md#class-httpincomingmessage)
The following shows I2C module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| i2c.open | O | O | O | O |
-| i2c.openSync | O | O | O | O |
-| i2cbus.read | O | O | O | O |
-| i2cbus.readSync | O | O | O | O |
-| i2cbus.write | O | O | O | O |
-| i2cbus.writeSync | O | O | O | O |
-| i2cbus.close | O | O | O | O |
-| i2cbus.closeSync | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| i2c.open | X | O | O | O | O |
+| i2c.openSync | X | O | O | O | O |
+| i2cbus.read | X | O | O | O | O |
+| i2cbus.readSync | X | O | O | O | O |
+| i2cbus.write | X | O | O | O | O |
+| i2cbus.writeSync | X | O | O | O | O |
+| i2cbus.close | X | O | O | O | O |
+| i2cbus.closeSync | X | O | O | O | O |
# I2C
### i2c.open(configuration, callback)
* `configuration` {Object} Configuration for open I2CBus.
* `device` {string} Device path. (only on Linux)
- * `bus` {number} The specified bus number. (NuttX and TizenRT only)
+ * `bus` {number} The specified bus number. (Tizen, TizenRT and NuttX only)
* `address` {number} Device address.
* `callback` {Function}
* `err` {Error|null}
### i2c.openSync(configuration)
* `configuration` {Object} Configuration for open I2CBus.
* `device` {string} Device path. (only on Linux)
- * `bus` {number} The specified bus number. (NuttX and TizenRT only)
+ * `bus` {number} The specified bus number. (Tizen, TizenRT and NuttX only)
* `address` {number} Device address.
* Returns: {Object} An instance of I2CBus.
The following shows module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| require | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| require | O | O | O | O | O |
# Module
The `require` function is always available there is no need to import `module` explicitly.
2. `iotjs_modules` folder under current working directory.
3. `$HOME/iotjs_modules`
4. `$IOTJS_PATH/iotjs_modules`
+5. `$IOTJS_EXTRA_MODULE_PATH`
For each directory in search paths above:
- If a directory `id` exists, module system consider the directory as a package:
- If `id/package.json` contains **main** property, load the file named **main** property.
- If `id/package.json` exists, but neither the **main** property nor the file named **main** property exist, load `index.js`.
+- Extra step for Linux/Tizen targets:
+ - If a file with `id.iotjs` exists, try to load it as an IoT.js dynamic module and return.
+
+**Adding extra paths for module loading**
+
+In order to add more directories to look for modules, you can set `IOTJS_EXTRA_MODULE_PATH` as an environment variable of your system. For instance, `./node_modules` and `./my_modules` will be referred if they're declared as follows.
+
+`IOTJS_EXTRA_MODULE_PATH=./node_modules:./my_modules`
The following shows net module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| net.createServer | O | O | △ ¹ | △ ¹ |
-| net.connect | O | O | △ ¹ | △ ¹ |
-| net.createConnection | O | O | △ ¹ | △ ¹ |
-| net.Server.listen | O | O | △ ¹ | △ ¹ |
-| net.Server.close | O | O | △ ²| O |
-| net.Socket.connect | O | O | △ ¹ | △ ¹ |
-| net.Socket.write | O | O | △ ¹ | △ ¹ |
-| net.Socket.end | O | O | △ ¹ ³ | △ ¹ ³ |
-| net.Socket.destroy | O | O | △ ¹ ³ | △ ¹ ³ |
-| net.Socket.pause | O | O | △ ¹ | △ ¹ |
-| net.Socket.resume | O | O | △ ¹ | △ ¹ |
-| net.Socket.setTimeout | O | O | △ ¹ | △ ¹ |
-| net.Socket.setKeepAlive | X | X | X | X |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| net.createServer | O | O | O | △ ¹ | △ ¹ |
+| net.connect | O | O | O | △ ¹ | △ ¹ |
+| net.createConnection | O | O | O | △ ¹ | △ ¹ |
+| net.Server.listen | O | O | O | △ ¹ | △ ¹ |
+| net.Server.close | O | O | O | △ ²| O |
+| net.Socket.connect | O | O | O | △ ¹ | △ ¹ |
+| net.Socket.write | O | O | O | △ ¹ | △ ¹ |
+| net.Socket.end | O | O | O | △ ¹ ³ | △ ¹ ³ |
+| net.Socket.destroy | O | O | O | △ ¹ ³ | △ ¹ ³ |
+| net.Socket.pause | O | O | O | △ ¹ | △ ¹ |
+| net.Socket.resume | O | O | O | △ ¹ | △ ¹ |
+| net.Socket.setTimeout | O | O | O | △ ¹ | △ ¹ |
+| net.Socket.setKeepAlive | X | X | X | X | X |
1. On NuttX/STM32F4-Discovery and TizenRT/Artik053, even a couple of sockets/server/requests might not work properly.
The following shows PWM module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| pwm.open | O | O | O | O |
-| pwm.openSync | O | O | O | O |
-| pwmpin.setPeriod | O | O | O | O |
-| pwmpin.setPeriodSync | O | O | O | O |
-| pwmpin.setFrequency | O | O | O | O |
-| pwmpin.setFrequencySync | O | O | O | O |
-| pwmpin.setDutyCycle | O | O | O | O |
-| pwmpin.setDutyCycleSync | O | O | O | O |
-| pwmpin.setEnable | O | O | O | O |
-| pwmpin.setEnableSync | O | O | O | O |
-| pwmpin.close | O | O | O | O |
-| pwmpin.closeSync | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(ARTIK530) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(ARTIK053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| pwm.open | X | O | O | O | O |
+| pwm.openSync | X | O | O | O | O |
+| pwmpin.setPeriod | X | O | O | O | O |
+| pwmpin.setPeriodSync | X | O | O | O | O |
+| pwmpin.setFrequency | X | O | O | O | O |
+| pwmpin.setFrequencySync | X | O | O | O | O |
+| pwmpin.setDutyCycle | X | O | O | O | O |
+| pwmpin.setDutyCycleSync | X | O | O | O | O |
+| pwmpin.setEnable | X | O | O | O | O |
+| pwmpin.setEnableSync | X | O | O | O | O |
+| pwmpin.close | X | O | O | O | O |
+| pwmpin.closeSync | X | O | O | O | O |
## Class: PWM
* `pin` {number} The pin number to use with this PWM object (mandatory configuration).
* `chip` {number} The PWM chip number (only on Linux). **Default:** `0`.
* `period` {number} The period of the PWM signal, in seconds (positive number).
- * `frequency` {integer} In Hz (positive integer).
* `dutyCycle` {number} The active time of the PWM signal, must be within the `0.0` and `1.0` range.
* `callback` {Function} Callback function.
* `err` {Error|null} The error object or `null` if there were no error.
To correctly open a PWM pin one must know the correct pin number:
* On Linux, `pin` is a number which is `0` or `1`.
+* On Tizen, `pin` is a number which is `2`. (Only ARTIK530 board support PWM.)
* On NuttX, you have to know pin name. The pin name is defined in target board module. For more module information, please see below list.
* [STM32F4-discovery](../targets/nuttx/stm32f4dis/IoT.js-API-Stm32f4dis.md#pwm-pin)
* `pin` {number} The pin number to use with this PWM object (mandatory configuration).
* `chip` {number} The PWM chip number (only on Linux). **Default:** `0`.
* `period` {number} The period of the PWM signal, in seconds (positive number).
- * `frequency` {integer} In Hz (positive integer).
* `dutyCycle` {number} The active time of the PWM signal, must be within the `0.0` and `1.0` range.
* Returns: {Object} An instance of PWMPin.
The following shows process module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| process.nextTick | O | O | O | O |
-| process.exit | O | O | O | O |
-| process.cwd | O | O | O | O |
-| process.chdir | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| process.nextTick | O | O | O | O | O |
+| process.exit | O | O | O | O | O |
+| process.cwd | O | O | O | O | O |
+| process.chdir | O | O | O | O | O |
※ On NuttX, you should pass absolute path to `process.chdir`.
The following environment elements can be accessed:
* `HOME`
* `IOTJS_PATH` which is set to `/mnt/sdcard` on NuttX by default.
+* `IOTJS_EXTRA_MODULE_PATH` contains the paths to be additionally referenced to load any module.
* `env` contains `'experimental'` if the IoT.js was build with experimental support.
**Example**
The following shows spi module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| spi.open | O | O | O | O |
-| spi.openSync | O | O | O | O |
-| spibus.transfer | O | O | O | O |
-| spibus.transferSync | O | O | O | O |
-| spibus.close | O | O | O | O |
-| spibus.closeSync | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| spi.open | X | O | O | O | O |
+| spi.openSync | X | O | O | O | O |
+| spibus.transfer | X | O | O | O | O |
+| spibus.transferSync | X | O | O | O | O |
+| spibus.close | X | O | O | O | O |
+| spibus.closeSync | X | O | O | O | O |
## Class: SPI
### spi.open(configuration, callback)
* `configuration` {Object}
* `device` {string} The specified path for `spidev`. (only on Linux)
- * `bus` {number} The specified bus number. (NuttX and TizenRT only)
+ * `bus` {number} The specified bus number. (Tizen, TizenRT and NuttX only)
* `mode` {SPI.MODE} The combinations of the polarity and phase. **Default:** `SPI.MODE[0]`.
* `chipSelect` {SPI.CHIPSELECT} Chip select state. **Default:** `SPI.CHIPSELECT.NONE`.
* `maxSpeed` {number} Maximum transfer speed. **Default:** `500000`.
### spi.openSync(configuration)
* `configuration` {Object}
* `device` {string} The specified path for `spidev`. (only on Linux)
- * `bus` {number} The specified bus number. (NuttX and TizenRT only)
+ * `bus` {number} The specified bus number. (Tizen, TizenRT and NuttX only)
* `mode` {SPI.MODE} The combinations of the polarity and phase. **Default:** `SPI.MODE[0]`.
* `chipSelect` {SPI.CHIPSELECT} Chip select state. **Default:** `SPI.CHIPSELECT.NONE`.
* `maxSpeed` {number} Maximum transfer speed. **Default:** `500000`.
The following shows stream module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| readable.isPaused | O | O | O | O |
-| readable.pause | O | O | O | O |
-| readable.read | O | O | O | O |
-| readable.resume | O | O | O | O |
-| writable.end | O | O | O | O |
-| writable.write | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| readable.isPaused | O | O | O | O | O |
+| readable.pause | O | O | O | O | O |
+| readable.read | O | O | O | O | O |
+| readable.resume | O | O | O | O | O |
+| writable.end | O | O | O | O | O |
+| writable.write | O | O | O | O | O |
# Stream
--- /dev/null
+### Platform Support
+
+The following chart shows the availability of each TLS module API function on each platform.
+
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | Nuttx<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| tls.connect | X | O | O | O | O | O |
+| tls.write | X | O | O | O | O | O |
+| tls.pause | X | O | O | O | O | O |
+| tls.end | X | O | O | O | O | O |
+| tls.resume | X | O | O | O | O | O |
+| tls.pause | X | O | O | O | O | O |
+
+# TLS
+
+Transport Layer Security makes secure communication over sockets possible.
+
+## Class: tls.TLSSocket
+The `TLSSocket` is responsible for all TLS negotiations and data encryption on a `net.Socket`.
+
+Just like `net.Socket` it uses a `Stream.duplex` interface.
+
+### new tls.TLSSocket(socket[,options])
+- `socket` {net.Socket | stream.Duplex}
+- `options` {Object}
+ - `session` {Buffer} Optional, `Buffer` instance containing a TLS session.
+
+Note: `tls.connect()` must be used to create the socket.
+
+### tls.connect(options[,callback])
+- `options` {Object}
+ - `host` {string} Host the client should connect to, defaults to 'localhost'.
+ - `port` {number} Port the client should connect to.
+ - `socket` {stream.Duplex} Optional, typically an instance of `net.Socket`. If this options is specified, host and port are ignored. The user passing the options is responsible for it connecting to the server. `tls.connect` won't call `net.connect` on it.
+ - `rejectUnauthorized` {boolean} Whether the server certificate should be verified against the list of supplied CAs. An `error` event is emitted if verifications fails; `err.code` contains the MbedTLS error code. Defaults to `false`. NOT READY
+ - `servername` {string} Server name for the SNI (Server name Indication) TLS extension. NOT READY
+ - `session` {Buffer} A `Buffer` containing a TLS session. NOT READY
+ - `minDHSize` {number} The minimum size of the DH parameter in bits to accept a TLS connection. If a server offers a DH parameter with a size less than specified, the TLS connection is destroyed and an error is thrown. Defaults to `1024`.
+ - `lookup` {Function} Custom lookup. Defaults to `dns.lookup()`.
+- `callback` {Function} The callback function will be added as a listener for the `secureConnect` event.
+
+Returns a `tls.TLSSocket` object.
+
+**Example**
+```js
+var tls = require('tls');
+
+var opts = {
+ host: '127.0.0.1',
+ port: 443,
+ rejectUnauthorized: true
+}
+
+var socket = tls.connect(opts, function() {
+ socket.write('Hello IoT.js');
+ socket.end();
+});
+```
+
+### tls.connect(port[,host][,options][,callback])
+- `port` {number} Port the client should connect to.
+- `host` {string} Host the client should connect to, defaults to 'localhost'.
+- `options` {Object} See `tls.connect()`.
+- `callback` {Function} See `tls.connect()`.
+
+Same as tls.connect() except that port and host can be provided as arguments instead of options.
+A port or host option, if specified, will take precedence over any port or host argument.
+
+**Example**
+```js
+var tls = require('tls');
+
+var socket = tls.connect(443, 'localhost', function() {
+ socket.write('Hello IoT.js');
+ socket.end();
+});
+```
+
+### tlsSocket.address()
+Returns an object containing the bound address, family name, and port of the socket.`{port: 443, family: 'IPv4', address: '127.0.0.1'}`
+
+### tlsSocket.authorizationError
+Returns the reason why the peer's certificate has not been verified.
+
+### tlsSocket.authorized
+Returns `true` if the peer certificate was signed by one of the CAs specified when creating the `tls.TLSSocket` instance, otherwise false.
+
+### tlsSocket.encrypted
+Always returns `true`, can be used to distinguish TLS sockets from regular `net.Socket`s.
+
+### tlsSocket.getProtocol()
+Returns a string containing the negotiated SSL/TLS protocol version of the connection. If the handshaking has not been complete, `unknown` will be returned. The value `null` will be returned for server sockets or disconnected client sockets.
+
+### tlsSocket.localAddress
+Returns a string representing the local IP address.
+
+### tlsSocket.localPort
+Returns a number representing the local port.
+
+### tlsSocket.remoteAddress
+Returns a string representing the remote IP address.
+
+### tlsSocket.remoteFamily
+Returns a string representing the remote IP family.
+
+### tlsSocket.remotePort
+Returns a number representing the remote port.
The following shows timer module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| setTimeout | O | O | O | O |
-| clearTimeout | O | O | O | O |
-| setInterval | O | O | O | O |
-| clearInterval | O | O | O | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| setTimeout | O | O | O | O | O |
+| clearTimeout | O | O | O | O | O |
+| setInterval | O | O | O | O | O |
+| clearInterval | O | O | O | O | O |
# Timers
The following shows uart module APIs available for each platform.
-| | Linux<br/>(Ubuntu) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
-| :---: | :---: | :---: | :---: | :---: |
-| uart.open | O | O | O | O |
-| uart.openSync | O | O | O | O |
-| uartport.write | O | O | O | O |
-| uartport.writeSync | O | O | O | O |
-| uartport.close | O | O | X | O |
-| uartport.closeSync | O | O | X | O |
+| | Linux<br/>(Ubuntu) | Tizen<br/>(Raspberry Pi) | Raspbian<br/>(Raspberry Pi) | NuttX<br/>(STM32F4-Discovery) | TizenRT<br/>(Artik053) |
+| :---: | :---: | :---: | :---: | :---: | :---: |
+| uart.open | O | O | O | O | O |
+| uart.openSync | O | O | O | O | O |
+| uartport.write | O | O | O | O | O |
+| uartport.writeSync | O | O | O | O | O |
+| uartport.close | O | O | O | O | O |
+| uartport.closeSync | O | O | O | O | O |
## Class: UART
### uart.open(configuration, callback)
* `configuration` {Object}
- * `device` {string} Mandatory configuration.
+ * `device` {string} Mandatory configuration. The specified device path.(Linux, Nuttx and TizenRT only)
+ * `port` {number} Mandatory configuration. The specified port number. (Tizen only)
* `baudRate` {number} Specifies how fast data is sent over a serial line. **Default:** `9600`.
* `dataBits` {number} Number of data bits that are being transmitted. **Default:** `8`.
* `callback` {Function}.
Opens an UARTPort object with the specified configuration.
-The `baudRate` must be equal to one of these values: [50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400].
+The `baudRate` must be equal to one of these values: [0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400].
The `dataBits` must be equal to one of these values: [5, 6, 7, 8].
### uart.openSync(configuration)
* `configuration` {Object}
- * `device` {string} Mandatory configuration.
+ * `device` {string} Mandatory configuration. The specified device path. (Linux, Nuttx and TizenRT only)
+ * `port` {number} Mandatory configuration. The specified port number. (Tizen only)
* `baudRate` {number} Specifies how fast data is sent over a serial line. **Default:** `9600`.
* `dataBits` {number} Number of data bits that are being transmitted. **Default:** `8`.
* Returns: {UARTPort}.
Closes the UART device asynchronously.
-On NuttX/STM32F4Discovery, Uart.close() blocks after close().
-It seems that poll() does not work properly on NuttX for some cases.
-
### uartport.closeSync()
Closes the UART device synchronously.
-On NuttX/STM32F4Discovery, Uart.close() blocks after close().
-It seems that poll() does not work properly on NuttX for some cases.
-
### Event: 'data'
* `callback` {Function}
* `data` {string} A string from the sender.
* [(ADC)](IoT.js-API-ADC.md)
* [(BLE)](IoT.js-API-BLE.md)
* [(GPIO)](IoT.js-API-GPIO.md)
+* [HTTPS](IoT.js-API-HTTPS.md)
* [(I2C)](IoT.js-API-I2C.md)
* [(PWM)](IoT.js-API-PWM.md)
* [(SPI)](IoT.js-API-SPI.md)
+* [TLS](IoT.js-API-TLS.md)
* [(UART)](IoT.js-API-UART.md)
* [UDP/Datagram](IoT.js-API-DGRAM.md)
--- /dev/null
+# IoT.js for OpenWrt build guide
+
+> :exclamation: This document describes an experimental feature and considerations.
+Please be aware that every experimental feature may change, be broken,
+or be removed in the future without any notice.
+
+
+The document presents the steps required to compile the IoT.js
+for OpenWrt. For target device, the TP-Link WR1043ND v1.x router is
+used. Please be advised, that if you have a different one, minor
+modifications to this document could be required.
+
+
+IMPORTANT!
+
+As the TP-Link WR1043ND is a mips based device and mips is a big-endian
+architecture. A JerryScipt snapshot which was built on an little-endian
+system will not work correctly. Thus the IoT.js must be
+built with disabled snaphost mode.
+
+## OpenWrt notes
+
+Since January 2018 the OpenWrt and LEDE project have merged into one
+and thus the old OpenWrt parts are now usable only from
+an archived repository: https://github.com/openwrt/archive
+
+## OpenWrt toolchain setup
+
+To build the IoT.js for OpenWrt, a toolchain is required for
+the target router/device. The toolchain setup in this document was
+tested on an Ubuntu 16.04.3 LTS Linux.
+
+Steps required for toolchain creation:
+
+### 0. Install OpenWrt build requirements
+```sh
+$ sudo apt-get install git-core build-essential libssl-dev libncurses5-dev unzip gawk zlib1g-dev subversion mercurial
+```
+
+### 1. Clone OpenWrt (Chaos Calmer version)
+
+```sh
+$ git clone https://github.com/openwrt/archive openwrt -b chaos_calmer
+$ cd openwrt
+```
+
+### 2. Run Menuconfig and configure the OpenWrt
+
+```sh
+$ make menuconfig
+```
+
+Options which should be set:
+* Set "Target System" to "Atheros AR7xxx/AR9xxx".
+* Set "Target Profile" to "TP-LINK TL-WR1043N/ND".
+
+Save the configuration (as .config) and exit from the menuconfig.
+
+### 3. Configure the environment variables
+
+```sh
+$ export BUILDROOT=$(pwd) # where the openwrt root dir is
+$ export STAGING_DIR=${BUILDROOT}/staging_dir/ # required by the compiler
+$ export PATH=$PATH:${STAGING_DIR}/host/bin:${STAGING_DIR}/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin/
+```
+
+The name `toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2` is created based on the menuconfig.
+This changes depending on the target device!
+
+### 4. Build the OpenWrt
+
+```sh
+$ make
+```
+
+### 5. Check if the compiler was built
+
+```sh
+$ mips-openwrt-linux-gcc --version # running this should print out the version information
+```
+
+At this point we have the required compiler for OpenWrt.
+
+
+## Build IoT.js for OpenWrt
+
+### 0. Check environment
+
+Please check if the `STAGING_DIR` is configured correctly and that the toolchain binary is on the `PATH`.
+
+### 1. Run the build with the OpenWrt toolchain file
+
+```sh
+$ ./tools/build.py --experimental --target-os openwrt --target-arch mips --no-snapshot --buildtype=release
+```
+
+It is advised to use release build as it is smaller than the debug build and can fit on the
+target router device.
+
+### 2. Copy the binary
+
+After a successful build, the `build/mips-openwrt/release/bin/iotjs`
+binary file can be copied to the target device.
+On how to copy a binary file to an OpenWrt target device, please see the OpenWrt manual(s).
### Setting Raspberry Pi
-IoT.js officially supports Raspbian. For more information, please visit [the official site](https://www.raspberrypi.org/downloads/raspbian/).
+IoT.js officially supports Raspbian.
+This setting guide is based on the image below.
+
+|Raspbian Image |
+|----------|
+| [2017-11-29-raspbian](http://downloads.raspberrypi.org/raspbian/images/raspbian-2017-12-01/) |
#### Enable the I2C interface
sudo raspi-config
```
This will launch raspi-config utility.
- * Select "9 Advanced Options"
- * Select "A6 I2C"
+ * Select "5 Interfacing Options"
+ * Select "P5 I2C"
The screen will ask you to enable I2C interface.
* Select "Yes"
To use UART module, the UART interface must be enabled.
-In `/boot/config.txt` file, change the value of enable_uart from 0 to 1.
-```
-enable_uart=1
+From the command line type:
+```bash
+sudo raspi-config
```
+This will launch raspi-config utility.
+ * Select "5 Interfacing Options"
+ * Select "P6 Serial"
+
+The screen will ask you to enable Serial interface.
+ * Select "Yes"
+ * Select "Ok"
+ * Select "Finish" to return to the command line.
+
+Reboot your Raspberry Pi.
To disable the serial console, edit the file `/boot/cmdline.txt`.
remove the word phase ```"console=serial0,115200"``` or ```"console=ttyAMA0,115200"```
* Note for Raspberry Pi 3 : You should use /dev/ttyS0 instead of /dev/ttyAMA0 in RPI3.
+#### Enable the SPI interface
+
+To use SPI module, the SPI interface must be enabled.
+
+From the command line type:
+```bash
+sudo raspi-config
+```
+This will launch raspi-config utility.
+ * Select "5 Interfacing Options"
+ * Select "P4 SPI"
+
+The screen will ask you to enable SPI interface.
+ * Select "Yes"
+ * Select "Ok"
+ * Select "Finish" to return to the command line.
+
+Reboot your Raspberry Pi.
+
### Build IoT.js on your desktop.
#### Prerequisite
./config/tizen/gbsbuild.sh
```
+The following options are provided.
+```
+--debug: Build output is 'debug'. If this option is not specified, it is 'release'.
+--clean: Make a clean gbs build by deleting the old build root.
+```
+
### 2. Bring up RPi3 with Tizen
Please see the following guide to bring up your RPI3 target with Tizen.
You can refer "Raspberry Pi 3" section of command-line-flash part.
#### Install
Transfer iotjs binary and test file to the device:
``` bash
-(ubuntu)$ sdb push ~/GBS-ROOT/local/repos/tizen_unified_preview1/armv7l/RPMS/iotjs-1.0.0-0.armv7l.rpm /tmp
+(ubuntu)$ sdb push ~/GBS-ROOT/local/repos/tizen_unified_preview2/armv7l/RPMS/iotjs-1.0.0-0.armv7l.rpm /tmp
(ubuntu)$ sdb push ./test/run_pass/test_console.js /home/owner/iotjs/
(ubuntu)$ sdb root on
(ubuntu)$ sdb shell
- [Inside IoT.js](Inside-IoT.js.md)
- [Experimental Features](Experimental-Features.md)
- - [Inside Validated Struct](Inside-IoT.js-Validated-Struct.md)
- [Logging Execution](Logging-IoT.js-execution.md)
- [Memory saving with libtuv](Memory-savings-with-libtuv.md)
- [Optimization Tips](Optimization-Tips.md)
- [JerryScript Debugger](Use-JerryScript-Debugger.md)
- [Writing New Builtin Module](Writing-New-Builtin-Module.md)
- - [Extended API Guidelines](Extended-API-Guidelines.md)
\ No newline at end of file
+ - [Extended API Guidelines](Extended-API-Guidelines.md)
* [Coding Style Guideline for C](#coding-style-guideline-for-c)
- * Validated Struct
* Header Files
* Formatting
* Naming
* Naming
* Formatting
* [Coding Style Guideline for Python](#coding-style-guideline-for-python)
-
+* [Coding Style Check Tool](#coding-style-check-tool)
# Coding Style Guideline for C
Our coding style guideline is based on [google c++ coding standard](https://google.github.io/styleguide/cppguide.html),
but modified due to some difference between C and C++.
-When this guideline is ambiguous, just follow the result of running `./tools/check_tidy.py`.
-
-Here are `./tools/check_tidy.py` options:
-```
---autoedit: Automatically edit the detected clang format errors. No diffs will be displayed.
-```
-## Validated Struct
-Use [Validated Struct](../devs/Inside-IoT.js-Validated-Struct.md) whenever possible, for encapsulation and validity check.
## Header Files
### Function names
Use lower cases and underscore for function names.
-For constructors, destructor, and methods of validated struct `iotjs_mystruct_t`, use names starting with `iotjs_mystruct_*`.
+For constructors and destructor, use names starting with `iotjs_mystruct_*`.
Constructor function name should be either `iotjs_mystruct_create` or `iotjs_mystruct_initialize`,
depending on whether the constructor returns the instance as return value, or the constructor just initializes the instance passed by parameter.
```c
typedef struct {
-} IOTJS_VALIDATED_STRUCT(iotjs_mystruct_t);
+} iotjs_mystruct_t;
iotjs_mystruct_t iotjs_mystruct_create(); // Ok
iotjs_mystruct_t* iotjs_mystruct_create(); // Ok
# Coding Style Guideline For Python
The coding conventions for Python code follows [PEP 8 - Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/)
+
+
+# Coding Style Check Tool
+
+When this guideline is ambiguous, just follow the result of running `./tools/check_tidy.py`.
+This tool helps you check your code style. You have to install `clang` and `eslint` to use this tool. And [`node.js`](https://nodejs.org/en/download/) should be installed before installing `eslint`.
+
+```bash
+$ sudo apt-get update
+$ sudo apt-get install clang-format-3.8
+$ cd iotjs
+$ npm install
+```
+
+Here are `./tools/check_tidy.py` options:
+```
+--autoedit: Automatically edit the detected clang format and eslint errors. No diffs will be displayed.
+```
+++ /dev/null
-Validated struct is C struct wrapper for encapsulation and validity check.
-
-* Validated Struct Declaration
-* Constructors, Destructor, Methods
-* Ownership of validated struct instance
- * Case 1: Validated struct instance as local variable
- * Case 2: Validated struct instance as parameter & return
- * Case 3: Validated struct instance as member variable of other struct
- * Case 4: Validated struct instance as data of asynchronous execution
-
-# Validated Struct Declaration
-
-```c
-typedef struct {
- int a;
- void* b;
-} IOTJS_VALIDATED_STRUCT(iotjs_myclass_t);
-```
-
-Above struct will make the member variable encapsulated by wrapping real members with wrapper like below.
-
-```c
-typedef struct {
- int a;
- void* b;
-} iotjs_myclass_t_impl_t;
-
-typedef struct {
- iotjs_myclass_impl_t unsafe;
- /* More members for struct validity check exist in debug mode */
-} iotjs_myclass_t;
-
-int main() {
- iotjs_myclass_t x;
-}
-```
-
-Only wizards will access the members directly by using `x.unsafe.a`, `x.unafe.b`, ... . Otherwize the members are only accessible with its accessor function.
-
-See `src/iotjs_def.h` for more details on real implementation.
-
-# Constructors, Destructor, Methods
-
-You should create C++-like constructors, destructor and methods with provided accessor. Then you can access the encapsulated member variables using `_this` variable, which has almost same role with C++ `this` keyword.
-You must call `destroy` for every validated structs you've created.
-
-```c
-/* Constructor */
-iotjs_myclass_t iotjs_myclass_create(int a) {
- iotjs_myclass_t instance;
- IOTJS_VALIDATED_STRUCT_CONSTRUCTOR(iotjs_myclass_t, &instance);
-
- _this->a = a;
- _this->b = malloc(a);
-
- return instance;
-}
-
-/* Destructor */
-void iotjs_myclass_destroy(iotjs_myclass_t* instance) {
- IOTJS_VALIDATED_STRUCT_DESTRUCTOR(iotjs_myclass_t, instance);
- free(_this->b);
-}
-
-/* Method */
-int iotjs_myclass_get_a(iotjs_myclass_t* instance) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_myclass_t, instance);
- return _this->a;
-}
-
-int main() {
- /* Validated struct as local variable */
- iotjs_myclass_t local_instance = iotjs_myclass_create(3);
- printf("%d\n", iotjs_myclass_get_a(&local_instance));
- iotjs_myclass_destroy(&local_instance);
- return 0;
-}
-```
-
-# Ownership of validated struct instance
-
-The ground rule is:
-
-* Use `iotjs_classname_t` typed variable if the variable *is* responsible for destruction of instance.
-* Use `iotjs_classname_t*` typed variable if the variable *is not* responsible for destruction of instance.
-
-Below Case 1 ~ Case 4 shows the case-by-case example of the ownership rule.
-
-## Case 1: Validated struct instance as local variable
-The `local_instance` variable in previous example was the local instance of validated struct.
-Since `local_instance` should be destructed inside the function scope, `iotjs_myclass_t` type was used.
-
-## Case 2: Validated struct instance as parameter & return
-Previous example also included the example of validated struct instance as parameter and return.
-When accessing member variable `a` by calling `iotjs_myclass_get_a()`,
-`iotjs_myclass_t*` type was used as the parameter type, since it *does not* move the responsibility to destruct the instance.
-
-And when returning the newly created instance by calling `iotjs_myclass_create()`,
-`iotjs_myclass_t` type was used as return type, since it *does* move the responsibility to destruct the instance.
-
-## Case 3: Validated struct instance as member variable of other struct
-
-```c
-/* Validated struct as member variable of other struct */
-
-typedef struct {
- iotjs_myclass_t member_instance;
-} IOTJS_VALIDATED_STRUCT(iotjs_otherclass_t)
-
-iotjs_otherclass_t iotjs_otherclass_create() {
- /* Initialization steps for iotjs_otherclass_t */
- _this->member_instance = iotjs_myclass_create(3);
-}
-
-void iotjs_otherclass_destroy() {
- /* Finalization steps for iotjs_otherclass_t */
- iotjs_myclass_destroy(&_this->member_instance);
-}
-```
-
-In the case above, `iotjs_myclass_t` instance is used as member variable of other class.
-Since `iotjs_otherclass_t` is responsible for finalizing the `member_instance`,
-it owns the variable as `iotjs_myclass_t` type, not pointer type.
-
-## Case 4: Validated struct instance as data of asynchronous execution
-Another usecase would be using validated struct as callback data.
-Currently, our all asynchronous datas are wrapped with `iotjs_*wrap_t` type,
-and they are destructed automatically.
-
-```c
-/*
- * Public APIs in iotjs_module_fs.h
- */
-
-typedef struct {
- iotjs_reqwrap_t reqwrap;
- uv_fs_t req;
-} IOTJS_VALIDATED_STRUCT(iotjs_fsreqwrap_t);
-
-iotjs_fsreqwrap_t* iotjs_fsreqwrap_create(const jerry_value_t* jcallback);
-void iotjs_fsreqwrap_dispatched(iotjs_fsreqwrap_t* fsreqwrap);
-```
-
-As you can see, constructor returns the `iotjs_fsreqwrap_t*` type,
-because it does not pass the responsibility to destruct the return value.
-It is destructed when request is dispatched, which can be informed by calling `iotjs_fsreqwrap_dispatched()`.
-The destructor `iotjs_fsreqwrap_destroy()` is hidden in c file.
-
-```c
-/*
- * Implementation in iotjs_module_fs.c
- */
-
-iotjs_fsreqwrap_t* iotjs_fsreqwrap_create(const jerry_value_t* jcallback) {
- iotjs_fsreqwrap_t* fsreqwrap = IOTJS_ALLOC(iotjs_fsreqwrap_t);
- IOTJS_VALIDATED_STRUCT_CONSTRUCTOR(iotjs_fsreqwrap_t, fsreqwrap);
- iotjs_reqwrap_initialize(&_this->reqwrap, jcallback, (uv_req_t*)&_this->req);
- return fsreqwrap;
-}
-
-static void iotjs_fsreqwrap_destroy(iotjs_fsreqwrap_t* fsreqwrap) { // private function
- IOTJS_VALIDATED_STRUCT_DESTRUCTOR(iotjs_fsreqwrap_t, fsreqwrap);
- uv_fs_req_cleanup(&_this->req);
- iotjs_reqwrap_destroy(&_this->reqwrap);
- IOTJS_RELEASE(fsreqwrap);
-}
-
-void iotjs_fsreqwrap_dispatched(iotjs_fsreqwrap_t* fsreqwrap) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_fsreqwrap_t, fsreqwrap);
- iotjs_fsreqwrap_destroy(fsreqwrap);
-}
-
-/*
- * Use of iotjs_fsreqwrap_t
- */
-
-void callback(uv_fs_t* req) {
- do_something(req);
- iotjs_fsreqwrap_dispatched(req); /* Call iotjs_*reqwrap_dispatched() when callback called */
-}
-
-void request(jerry_value_t* jcallback) {
- iotjs_fsreqwrap_t* wrap = iotjs_fsreqwrap_create(jcallback);
- uv_fs_request(loop, wrap->req, callback);
-}
-```
-
-In the case of tuv request wrapper, `iotjs_*reqwrap_dispatched()` should be called when the request has been dispatched.
-In the case of tuv handle wrapper, `iotjs_handlewrap_close()` should be called when the handle has been closed.
-in the case of JavaScript object wrapper, you don't have to do anything because JavaScript engine will call the destructor when the object becomes inaccessible.
-
-
jerry_value_t* jobject = (jerry_value_t*)malloc(sizeof(jerry_value_t)); // Not allowed
```
-Unfortunately, we strongly do not recommend that kind of pattern. We treat pointer-types variables in special way. (See [Validated Struct](Inside-IoT.js-Validated-Struct.md) for more details.)
-
To achieve your wish, we recommend using `iotjs_jobjectwrap_t` for that purpose.
`iotjs_jobjectwrap_t` is kind of weak pointer to a Javascript Object.
It refers a Javascript object but never increase reference count so that Javascript engine can collect the object when it turns into garbage.
### How to Test
-When you build ``iotjs`` binary successfully, you can run test driver with this binary.
+When you build ``iotjs`` binary successfully, you can run test runner with this binary.
```bash
-/path/to/iotjs tools/check_test.js
+tools/testrunner.py /path/to/iotjs
```
#### Set test options
To start the debugger-server: `<iotjs binary> --start-debug-server test.js`
It is important to note that optional parameters (such as `--debugger-wait-source` or
-`--jerry-debugger-port=...`) should be specified after `--start-debug-server` in order to work properly.
+`--debugger-port <PORT>`) should be specified after `--start-debug-server` in order to work properly.
#### Sending source to the debugger remotely
#### Setting the debugger port
If you want to specify the port number of the debugger-server (default: 5001),
-you can do so with the `--jerry-debugger-port=<PORT>` option:
-`<iotjs binary> --start-debug-server --jerry-debugger-port=8080 test.js`
+you can do so with the `--debugger-port <PORT>` option:
+`<iotjs binary> --start-debug-server --debugger-port 8080 test.js`
Two clients are included, a [python](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-debugger/jerry-client-ws.py)
and an [HTML](https://github.com/jerryscript-project/jerryscript/blob/master/jerry-debugger/jerry-client-ws.html) variant, they can be found under `deps/jerry/jerry-debugger/`.
* Callback
* Writing "Mixed" Module
* Using native module in JavaScript module
+* Advanced usage
+ * Module specific CMake file
+ * Writing Dynamically loadable modules
+* Module structure generator
See also:
* [Inside IoT.js](Inside-IoT.js.md)
* Use `./tools/build.py --external-modules=my-module` when building
* Enable your module in a profile or as an additional CMake parameter
+**Important:** the name of the module must be in lowercase. It is not allowed to use uppercase characters.
+
Your new module will look like below:
my-module/js/mymodule.js:
Where `native` is the JS object returned by the native `InitConsole` function in `iotjs_module_console.c`.
**Note**: `native` is undefined if there is no native part of the module.
+
+
+### Using bridge module to communicate between C and JavaScript module
+Bridge module provides two interfaces for sending synchronous and asynchronous message from Javascript to the native module. The Native module simply rersponds back to the requst using a simple inteface that can create return message. Of course you can use the IoT.js and JerryScript APIs to respond directly to the request of JavaScript module, but sometimes using a simpliffied method is more efficient in providing simple functionality in a short time.
+
+For example, JavaScript module can request resource path synchronously,
+and native module can simply return a resource path by just calling a function.
+
+in the bridge_sample.js of bridge_sample module
+```javascript
+bridge_sample.prototype.getResPath = function(){
+ return this.bridge.sendSync("getResPath", "");
+};
+```
+
+in the iotjs_bridge_sample.c of bridge_sample module
+```c
+if (strncmp(command, "getResPath", strlen("getResPath")) == 0) {
+ iotjs_bridge_set_return(return_message, "res/");
+ return 0;
+}
+```
+For the complete sample code, please see the bridge_sample in samples/bridge_sample folder.
+
+## Advanced usage
+
+### Module specific CMake file
+
+For each module, it is possible to define one extra cmake file.
+This can be done by specifying the `cmakefile` key file for
+a module in the related `modules.json` file.
+
+For example:
+
+```json
+{
+ "modules": {
+ "demomod": {
+ ...
+ "cmakefile": "module.cmake"
+ }
+ }
+}
+```
+
+This `module.cmake` is a module-specific CMake file
+which will be searchd for in the module's base directory.
+In this file it is possible to specify additonal dependecies,
+build targets, and other things.
+
+However, there are a few important rules which must be followed in
+the CMake file:
+
+* The `MODULE_DIR` and `MODULE_BINARY_DIR` will be set by
+ the IoT.js build system. Do NOT overwrite them in the CMake file!
+
+* The `MODULE_NAME` CMake variable must be set.
+ Example: `set(MODULE_NAME "demomod")`
+
+* The `add_subdirectory` call must specify the output binary dir.
+ Please use this template:
+`add_subdirectory(${MODULE_DIR}/lib/ ${MODULE_BASE_BINARY_DIR}/${MODULE_NAME})`
+ where `lib/` is a subdirectory of the module directory.
+
+* If there is an extra library which should be used during linking, the
+ following template should be used:
+ `list(APPEND MODULE_LIBS demo)`
+ where `demo` is the extra module which must be linked.
+ Any number of modules can be appended to the `MODULE_LIBS` list variable.
+
+* The source files which are specified in the `modules.json` file must NOT
+ be specified in the CMake file.
+
+
+An example module CMake file:
+```
+set(MODULE_NAME "mymodule")
+
+add_subdirectory(${MODULE_DIR}/myLib/ ${MODULE_BASE_BINARY_DIR}/${MODULE_NAME})
+
+list(APPEND MODULE_LIBS myLib)
+```
+
+To ease creation of modules which contains extra CMake files
+there is a module generator as described below.
+
+
+## Writing Dynamically loadable modules
+
+IoT.js support loading specially crafted shared libraries.
+To create such modules the source files must be compiled into a
+shared object - preferably using the `.iotjs` extension - and
+must have a special entry point defined using the `IOTJS_MODULE` macro.
+
+The `IOTJS_MODULE` macro has the following four parameters:
+
+* `iotjs_module_version`: target IoT.js target module version as `uint32_t`
+ value. The `IOTJS_CURRENT_MODULE_VERSION` can be used to get the current IoT.js
+ module version when the module is compiling.
+* `module_version`: the module version as a `uint32_t` value.
+* `initializer`: the entry point of module which should return an initialized
+ module object. Note: the macro will automaticall prefix the specified name
+ with `init_`.
+
+For example, in the `testmodule.c` file:
+
+```c
+
+#include <iotjs_binding.h>
+
+jerry_value_t init_testmodule(void) {
+ jerry_value_t object = jerry_create_object();
+ /* add properties to 'object' */
+ return object;
+}
+
+IOTJS_MODULE(IOTJS_CURRENT_MODULE_VERSION, 1, testmodule);
+```
+
+Should be compiled with the following command:
+
+```sh
+$ gcc -Wall -I<path/to/IoT.js headers> -I<path/to/JerryScript headers> -shared -o testmodule.iotjs testmodule.c
+```
+
+After the shared module is created it can be loaded via `require` call.
+Example JS code:
+
+```c
+var test = require('testmodule.iotjs');
+/* access the properties of the test module. */
+```
+
+During the dynamic module loading if the `iotsj_module_version`
+returned by the module does not match the `IOTJS_CURRENT_MODULE_VERSION`
+value of the running IoT.js instance, the module loading will fail.
+
+Please note that the dynamically loadable module differs from modules
+mentioned before in the following points:
+
+* The entry point must be specified with the `IOTJS_MODULE` macro.
+* The shared module is not compiled with the IoT.js binary.
+* There is no need for the `modules.json` file.
+
+
+## Module structure generator
+
+As previously shown, there are a few files required to create a module.
+These files can be createad manually or by the `tools/iotjs-create-module.py`
+script.
+
+The module generator can generate two types of modules:
+* basic built-in module which is compiled into the IoT.js binary.
+* shared module which can be dynamically loaded via the `require` call.
+
+To generate a module with the IoT.js module generator
+the module template should be specified and the name of the new module.
+
+**Important note:** The module name must be in lowercase.
+
+The `template` paramter for the module creator is optional, if it is
+not specified basic modules are created.
+
+The generated module(s) have simple examples in it which can be used
+to bootstrap ones own module(s). On how to use them please see the
+previous parts of this document.
+
+### Basic module generation
+
+Example basic module generation:
+```
+$ python ./iotjs/tools/iotjs-create-module.py --template basic demomod
+Creating module in ./demomod
+loading template file: ./iotjs/tools/module_template/module.cmake
+loading template file: ./iotjs/tools/module_template/modules.json
+loading template file: ./iotjs/tools/module_template/js/module.js
+loading template file: ./iotjs/tools/module_template/src/module.c
+Module created in: /mnt/work/demomod
+```
+
+By default the following structure will be created by the tool:
+
+```
+demomod/
+ |-- js
+ |-- module.js
+ |-- module.cmake
+ |-- modules.json
+ |-- src
+ |-- module.c
+```
+
+### Shared module generation
+
+Example shared module generation:
+```
+$ python ./iotjs/tools/iotjs-create-module.py --template shared demomod
+Creating module in ./demomod
+loading template file: ./iotjs/tools/module_templates/shared_module_template/CMakeLists.txt
+loading template file: ./iotjs/tools/module_templates/shared_module_template/README.md
+loading template file: ./iotjs/tools/module_templates/shared_module_template/js/test.js
+loading template file: ./iotjs/tools/module_templates/shared_module_template/src/module_entry.c
+Module created in: /mnt/work/demomod
+```
+
+The generated `demomod` will have a `CMakeLists.txt` file which contains
+path variables to the IoT.js headers and JerryScript headers. These path
+variables are absolute paths and required to the module compilation.
+Please adapt the paths if required.
+
+Additionnally the `README.md` file contains basic instructions on
+how to build and test the new module.
"name": "IoT.js",
"description": "Platform for Internet of Things with JavaScript",
"scripts": {
- "lint": "eslint src ./*.js -f table --ext .js > eslint.log",
- "lint-autofix": "eslint src ./*.js -f table --ext .js --fix > eslint.log",
- "lint-server": "nodemon --watch .eslintrc.js --watch ./src --ext js --exec \"npm run lint\""
+ "lint": "eslint src -f codeframe || true",
+ "lint-autofix": "eslint src -f codeframe --fix || true"
},
"author": "Samsung Electronics Co., Ltd.",
"license": "Apache-2.0",
"devDependencies": {
- "eslint": "^4.7.2",
- "nodemon": "^1.12.1"
+ "eslint": "^4.7.2"
}
}
Name: iotjs
Description: Platform for Internet of Things with JavaScript
Version: 1.0.0
-Libs:
-Cflags: -I${includedir}
+Libs: -L${libdir} -liotjs -lcapi-system-peripheral-io -lpthread -lcurl -ldlog -lappcore-agent
+Cflags: -I${includedir}/iotjs
BuildRequires: cmake
BuildRequires: glibc-static
#BuildRequires: aul
-#BuildRequires: pkgconfig(appcore-agent)
-#BuildRequires: pkgconfig(capi-appfw-service-application)
-#BuildRequires: pkgconfig(capi-appfw-app-common)
+BuildRequires: pkgconfig(appcore-agent)
+BuildRequires: pkgconfig(capi-appfw-service-application)
+BuildRequires: pkgconfig(capi-appfw-app-common)
#BuildRequires: pkgconfig(capi-appfw-package-manager)
-#BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(capi-system-peripheral-io)
BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(capi-appfw-app-control)
+BuildRequires: pkgconfig(bundle)
#BuildRequires: pkgconfig(st_things_sdkapi)
#for https
%description
Platform for Internet of Things with JavaScript
-# default is RELEASE mode.
-# If DEBUG mode is needed, please use tizen_build_devel_mode
-%define RELEASE False
-# For Example
-%if %{RELEASE} == "True"
-%define build_mode release
-%else
-%define build_mode debug
-%endif
-
-# Default values to be eventually overiden BEFORE or as gbs params:
-%{!?RELEASE: %define RELEASE 0}
+# Initialize the variables
+%{!?build_mode: %define build_mode release}
+%{!?external_build_options: %define external_build_options %{nil}}
%package service
Summary: Development files for %{name}
cp %{SOURCE1001} .
%build
-./tools/build.py --clean --buildtype=%{build_mode} --target-arch=noarch \
- --target-os=tizen --target-board=rpi3 \
- --external-lib=capi-system-peripheral-io \
- --compile-flag=-D__TIZEN__ \
- --cmake-param=-DENABLE_MODULE_DGRAM=ON \
- --cmake-param=-DENABLE_MODULE_GPIO=ON \
- --no-init-submodule --no-parallel-build
+./tools/build.py \
+ --clean \
+ --buildtype=%{build_mode} \
+ --profile=test/profiles/tizen.profile \
+ --target-arch=noarch \
+ --target-os=tizen \
+ --target-board=rpi3 \
+ --external-lib=capi-system-peripheral-io \
+ --external-lib=capi-appfw-app-common \
+ --external-lib=dlog \
+ --external-lib=bundle \
+ --external-lib=capi-appfw-app-control \
+ --external-include-dir=/usr/include/dlog/ \
+ --external-include-dir=/usr/include/appcore-agent/ \
+ --external-include-dir=/usr/include/appfw/ \
+ --external-include-dir=/usr/include/glib-2.0/ \
+ --external-include-dir=/usr/lib/glib-2.0/include/ \
+ --compile-flag=-D__TIZEN__ \
+ --compile-flag=-fPIC \
+ --jerry-cmake-param=-DENABLE_STATIC_LINK=OFF \
+ --no-init-submodule \
+ --no-parallel-build \
+ %{external_build_options}
# --external-lib=sdkapi \
+# Create shared library
+%define iotjs_target_lib libjerry-core.a libjerry-port-default.a libhttpparser.a libtuv.a \\\
+ libmbedx509.a libmbedtls.a libmbedcrypto.a libiotjs.a
+%define iotjs_lib_flag -lcapi-system-peripheral-io -lpthread -lcurl -ldlog -lappcore-agent -lcapi-appfw-app-common -lbundle -lcapi-appfw-app-control
+cd ./build/noarch-tizen/%{build_mode}/lib/
+gcc -shared -o libiotjs.so -Wl,--whole-archive %{iotjs_target_lib} -Wl,--no-whole-archive %{iotjs_lib_flag}
%install
mkdir -p %{buildroot}%{_bindir}
cp ./build/noarch-tizen/%{build_mode}/bin/iotjs %{buildroot}%{_bindir}/
-cp ./build/noarch-tizen/%{build_mode}/lib/* %{buildroot}%{_libdir}/iotjs/
+cp ./build/noarch-tizen/%{build_mode}/lib/*.so %{buildroot}%{_libdir}/
-cp ./include/*.h %{buildroot}%{_includedir}
-cp ./src/*.h %{buildroot}%{_includedir}
+cp ./src/platform/tizen/iotjs_tizen_service_app.h %{buildroot}%{_includedir}/iotjs
cp ./config/tizen/packaging/%{name}.pc.in %{buildroot}/%{_libdir}/pkgconfig/%{name}.pc
%post -p /sbin/ldconfig
%{_bindir}/*
%files devel
+%manifest config/tizen/packaging/%{name}.manifest
%defattr(-,root,root,-)
-%{_libdir}/iotjs/*.a
+%{_libdir}/libiotjs.so
%{_libdir}/pkgconfig/%{name}.pc
%{_includedir}/*
--- /dev/null
+# Sample bridge module
+
+See also:
+* [Writing-new-module](Writing-New-Module.md)
+* [Native Module vs. JS module](Native-Module-vs-JS-Module.md)
+* [Inside IoT.js](Inside-IoT.js.md)
+* [Developer Tutorial](Developer-Tutorial.md)
+
+
+## Description
+This sample show you how you can create a 'mixed' module using brige module that has some interfaces to support communicattion between JS and Native code. This sample created using tools/iotjs-create-module.py script.
+You can see how you could reduce your effor to create native module using simple methods provided bridge module.
+
+
+## Build
+
+$ ./tools/build.py --external-modules=./samples/bridge_sample --cmake-param=-DENABLE_MODULE_BRIDGE_SAMPLE=ON
+
+## Testing
+
+$ iotjs samples/bridge_sample/test.js
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var Bridge = require('bridge');
+
+function bridge_sample(){
+ this.bridge = new Bridge(native.MODULE_NAME);
+}
+
+bridge_sample.prototype.getResPath = function(){
+ return this.bridge.sendSync('getResPath', '');
+};
+
+bridge_sample.prototype.getSystemInfo = function(callback){
+ this.bridge.send('getSystemInfo', '', function(err, msg){
+ callback(err, msg);
+ });
+};
+
+bridge_sample.prototype.testThread = function(callback){
+ this.bridge.send('testThread', '', function(err, msg){
+ callback(err, msg);
+ });
+};
+
+module.exports = new bridge_sample();
--- /dev/null
+# Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# General variables usable from IoT.js cmake:
+# - TARGET_ARCH - the target architecture (as specified during cmake step)
+# - TARGET_BOARD - the target board(/device)
+# - TARGET_OS - the target operating system
+#
+# Module related variables usable from IoT.js cmake:
+# - MODULE_DIR - the modules root directory
+# - MODULE_BINARY_DIR - the build directory for the current module
+# - MODULE_LIBS - list of libraries to use during linking (set this)
+set(MODULE_NAME "bridge_sample")
+
+# DO NOT include the source files which are already in the modules.json file.
+
+# If the module builds its own files into a lib please use the line below.
+# Note: the subdir 'lib' should contain the CMakeLists.txt describing how the
+# module should be built.
+#add_subdirectory(${MODULE_DIR}/lib/ ${MODULE_BINARY_DIR}/${MODULE_NAME})
+
+# If you wish to link external libraries please add it to
+# the MODULE_LIBS list.
+#
+# IMPORTANT!
+# if the module builds its own library that should also be specified!
+#
+# Example (to add the 'demo' library for linking):
+#
+# list(APPEND MODULE_LIBS demo)
--- /dev/null
+{
+ "modules": {
+ "bridge_sample": {
+ "js_file": "js/bridge_sample.js",
+ "native_files": ["src/iotjs_bridge_sample.c"],
+ "init": "InitBridgeSample",
+ "cmakefile": "module.cmake",
+ "require": ["bridge"]
+ }
+ }
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "iotjs_def.h"
+#include "modules/iotjs_module_bridge.h"
+
+
+char* iotjs_bridge_sample_getSystemInfo(const char* message) {
+ return "{'OS':'tizen'}";
+}
+
+void thread1_worker(void* return_handle) {
+ uv_sleep(500);
+ iotjs_bridge_set_msg(return_handle, "{'return':'from thread..'}");
+}
+
+void iotjs_bridge_sample_func(const char* command, const char* message,
+ void* return_handle) {
+ char* result = 0;
+ if (strncmp(command, "getSystemInfo", strlen("getSystemInfo")) == 0) {
+ result = iotjs_bridge_sample_getSystemInfo(message);
+ if (result == 0) {
+ iotjs_bridge_set_err(return_handle, "Can't get the resource path");
+ } else {
+ iotjs_bridge_set_msg(return_handle, result);
+ }
+ } else if (strncmp(command, "testThread", strlen("testThread")) == 0) {
+ uv_thread_t thread1;
+ uv_thread_create(&thread1, thread1_worker, return_handle);
+ uv_thread_join(&thread1);
+ } else if (strncmp(command, "getResPath", strlen("getResPath")) == 0) {
+ iotjs_bridge_set_msg(return_handle, "res/");
+ } else {
+ iotjs_bridge_set_err(return_handle, "Can't find command");
+ }
+}
+
+/**
+ * Init method called by IoT.js
+ */
+jerry_value_t InitBridgeSample() {
+ char* module_name = "bridge_sample";
+ jerry_value_t mymodule = jerry_create_object();
+ iotjs_jval_set_property_string_raw(mymodule, IOTJS_MAGIC_STRING_MODULE_NAME,
+ module_name);
+ iotjs_bridge_register(module_name, iotjs_bridge_sample_func);
+ return mymodule;
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var bridgeSample = require('bridge_sample');
+
+
+console.log('TestApp: getResPath(): ' + bridgeSample.getResPath());
+
+
+bridgeSample.testThread(function(err, msg) {
+ console.log('TestApp: testThread(): err: ' + err + ' msg: ' + msg);
+});
+
+bridgeSample.getSystemInfo(function(err, msg) {
+ console.log('TestApp: getSystemInfo(): err: ' + err + ' msg: ' + msg);
+});
--- /dev/null
+<!--
+/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//-->
+<html lang="en">
+ <head>
+ <title>http gpio panel sample</title>
+ </head>
+ <body>
+ <form id="gpioconf">
+ <fieldset>
+ <legend>GPIO Pin configuration</legend>
+ <label>
+ Pin number
+ <input type="number" value="0" name="pin">
+ </label>
+ <label>
+ Direction
+ <select name="direction">
+ <option value="0" selected>IN</option>
+ <option value="1">OUT</option>
+ </select>
+ </label>
+ <label>
+ Mode
+ <select name="mode">
+ <option value="0" selected>NONE</option>
+ <option value="1">PULLUP</option>
+ <option value="2">PULLDOWN</option>
+ <option value="3">FLOAT</option>
+ <option value="4">PUSHPULL</option>
+ <option value="5">OPENDRAIN</option>
+ </select>
+ </label>
+ <label>
+ State
+ <select name="pinValue">
+ <option value="0" selected>LOW</option>
+ <option value="1">HIGH</option>
+ </select>
+ </label>
+ <input type="submit" value="Add">
+ </fieldset>
+ </form>
+ <h3>ACTIVE PINS</h3>
+ <table id="gpioresults">
+ <thead>
+ <tr>
+ <th>Pin</pin>
+ <th>Direction</th>
+ <th>Mode</th>
+ <th>State</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ </tbody>
+ </table>
+ <script type="text/javascript">
+ var form = document.getElementById('gpioconf'),
+ results = document.getElementById('gpioresults'),
+ GPIO_DIRECTION = {
+ '0': 'IN',
+ '1': 'OUT'
+ },
+ GPIO_MODE = {
+ '0': 'NONE',
+ '1': 'PULLUP',
+ '2': 'PULLDOWN',
+ '3': 'FLOAT',
+ '4': 'PUSHPULL',
+ '5': 'OPENDRAIN'
+ },
+ currentPins = {};
+
+ // synchronize pins with response from server
+ function syncPins(pins) {
+ var pin = '',
+ updated = {};
+ // handle updates and add
+ for (pin in pins) {
+ if (pins.hasOwnProperty(pin)) {
+ currentPins[pin] = pins[pin];
+ };
+ }
+ // handle removals
+ for (pin in currentPins) {
+ if (currentPins.hasOwnProperty(pin)) {
+ if (pins[pin] !== undefined) {
+ updated[pin] = currentPins[pin];
+ }
+ }
+ }
+ // update data
+ currentPins = updated;
+ }
+
+ // creates <tr> element with pin data in result table
+ function createRowForPin(pin, data) {
+ var row = document.createElement('tr'),
+ checked = !!parseInt(data.value, 0) ? ' checked' : '',
+ disabled = parseInt(data.direction, 10) === 0 ? ' disabled' : '',
+ attrs = checked + disabled;
+
+ row.setAttribute('id', 'pin_' + pin);
+ row.innerHTML = '<td>' + pin + '</td>'
+ + '<td>' + GPIO_DIRECTION[data.direction] + '</td>'
+ + '<td>' + GPIO_MODE[data.mode] + '</td>'
+ + '<td><input name="value" type="checkbox"' + attrs + '></td>'
+ + '<td><button value="remove">Remove</button></td>';
+
+ results.tBodies[0].appendChild(row);
+ }
+
+ // removes <tr> element for pin
+ function removeRowForPin(pin) {
+ var pinEl = document.getElementById('pin_' + pin);
+ if (pinEl) {
+ pinEl.parentNode.removeChild(pinEl);
+ }
+ }
+
+ // updates <tr> for pin with specified data
+ function updateRowForPin(row, pin, data) {
+ if (parseInt(data.direction, 10) === 0) {
+ row.children[3].children[0].checked = !!parseInt(data.value);
+ }
+ }
+
+ // updates table with new data
+ function updateResults(data) {
+ var pin = '',
+ pinEl = null;
+ syncPins(data);
+ for (pin in currentPins) {
+ if (currentPins.hasOwnProperty(pin)) {
+ pinEl = document.getElementById('pin_' + pin);
+ if (pinEl) {
+ updateRowForPin(pinEl, pin, data[pin]);
+ } else {
+ pinEl = createRowForPin(pin, data[pin]);
+ }
+ }
+ }
+ }
+
+ // polling for data
+ function updateDataPoll(interval) {
+ var xhr = new XMLHttpRequest();
+ xhr.addEventListener('load', function (e) {
+ var updatedData = [];
+ if (e.target.status === 200) {
+ updateResults(JSON.parse(e.target.responseText));
+ }
+ if (interval) {
+ setTimeout(updateDataPoll.bind(null, interval), interval);
+ }
+ });
+ xhr.open('POST', '/update', true);
+ xhr.send(JSON.stringify(currentPins));
+ }
+
+ // handle clicks on "remove" button
+ document.addEventListener('click', function (e) {
+ var pin = '',
+ id = '',
+ prop = '',
+ updated = {};
+ if (e.target.value && e.target.value === 'remove') {
+ id = e.target.parentNode.parentNode.id;
+ pin = id.replace(/[^0-9]+/gi, '');
+ for (prop in currentPins) {
+ if (currentPins.hasOwnProperty(prop) && prop !== pin) {
+ updated[pin] = currentPins[pin];
+ }
+ }
+ removeRowForPin(pin);
+ currentPins = updated;
+ updateDataPoll(0);
+ }
+ });
+
+ // handles changes on state checkboxes
+ document.addEventListener('change', function (e) {
+ var id = '',
+ pin = '';
+ if (e.target.name && e.target.name === 'value') {
+ id = e.target.parentNode.parentNode.id;
+ pin = id.replace(/[^0-9]+/gi, '');
+ if (currentPins[pin] && currentPins[pin].direction === '1') {
+ currentPins[pin].value = e.target.checked ? '1' : '0';
+ updateDataPoll(0);
+ }
+ }
+ });
+
+ // handles adding of new pins
+ form.addEventListener('submit', function (e) {
+ var formElements = e.target.elements;
+ if (currentPins[formElements.pin.value] === undefined) {
+ currentPins[formElements.pin.value] = {
+ mode: formElements.mode.value,
+ direction: formElements.direction.value,
+ value: formElements.pinValue.value
+ }
+ e.target.reset();
+ updateDataPoll(0);
+ } else {
+ alert('pin already exists');
+ }
+
+ e.preventDefault();
+ return false;
+ });
+
+ updateDataPoll(500);
+ </script>
+ </body>
+</html>
--- /dev/null
+/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Description:
+ *
+ * This sample allows to control GPIO input/output pins through browser
+ *
+ * Usage:
+ *
+ * To run this example execute:
+ *
+ * $ iotjs server.js
+ *
+ * and navigate your browser to http://[your-ip-address]:8080
+ *
+ */
+var http = require('http'),
+ fs = require('fs'),
+ Buffer = require('buffer'),
+ gpio = require('gpio'),
+ server = null,
+ port = 8080,
+ logs_enabled = true,
+ pinConfiguration = {},
+ activePins = {},
+ GPIO_DIRECTION = {
+ '0': gpio.DIRECTION.IN,
+ '1': gpio.DIRECTION.OUT
+ },
+ GPIO_MODE = {
+ '0': gpio.MODE.NONE,
+ '1': gpio.MODE.PULLUP,
+ '2': gpio.MODE.PULLDOWN,
+ '3': gpio.MODE.FLOAT,
+ '4': gpio.MODE.PUSHPULL,
+ '5': gpio.MODE.OPENDRAIN
+ };
+
+// splits url by "/" deliminator and removes empty entries
+function extractPath(url) {
+ var urlParts = url.split('/'),
+ i = 0,
+ l = urlParts.length,
+ result = [];
+ for (; i < l; ++i) {
+ if (urlParts[i].length > 0) {
+ result.push(urlParts[i]);
+ }
+ }
+ return result;
+}
+
+// processes request data stream and passes it to callback
+function fetchRequestTextBody(req, callback) {
+ var body = [];
+ req.on('data', function (chunk) {
+ body.push(chunk);
+ });
+ req.on('end', function () {
+ callback(body.join(""));
+ });
+}
+
+// sets 404 header and body as response
+function notFound(res) {
+ res.writeHead(404);
+ res.end('404 not found');
+}
+
+// logs only when log_enabled is set to true
+function log(/*...arg*/) {
+ if (logs_enabled) {
+ console.log.apply(console, [].slice.call(arguments));
+ }
+}
+
+// reads file from specified path
+function fetchFile(path) {
+ var data = null;
+
+ log('trying to open: ' + path);
+ if (fs.existsSync(path)) {
+ data = fs.readFileSync(path);
+ }
+ return data;
+}
+
+// synchronizes pin states with the data that was send with
+// request from panel
+function syncPins(pins) {
+ var pin = '',
+ updatedConf = {},
+ updatedPins = {},
+ value = 0;
+
+ // update and add
+ for (pin in pins) {
+ if (pins.hasOwnProperty(pin)) {
+ if (activePins[pin] === undefined) {
+ // open pin if it does not exist
+ log('opening new pin: ' + pin);
+ activePins[pin] = gpio.open({
+ pin: parseInt(pin, 10),
+ direction: GPIO_DIRECTION[pins[pin].direction],
+ mode: GPIO_MODE[pins[pin].mode]
+ }, function (err) {
+ if (err) {
+ log('error while opening pin: ' + pin);
+ } else {
+ log('pin opened: ' + pin);
+ if(parseInt(pins[pin].direction, 10) === 1) {
+ activePins[pin].writeSync(parseInt(pins[pin].value, 10));
+ }
+ }
+ });
+ } else if(parseInt(pins[pin].direction, 10) === 1 &&
+ pins[pin].value !== pinConfiguration[pin].value) {
+ // update value if pin exists and is writable
+ log('pin: ' + pin + ', new value: ' + parseInt(pins[pin].value, 10));
+ activePins[pin].writeSync(parseInt(pins[pin].value, 10));
+ }
+
+ // save old value if pin exists
+ if (pinConfiguration[pin] !== undefined) {
+ value = pinConfiguration[pin].value;
+ }
+
+ // update
+ pinConfiguration[pin] = pins[pin];
+
+ // if pin is 'readable' then restore the value
+ if(parseInt(pins[pin].direction, 10) === 0) {
+ pinConfiguration[pin].value = value;
+ }
+ }
+ }
+
+ // handle pin removal
+ for (pin in pinConfiguration) {
+ if (pinConfiguration.hasOwnProperty(pin)) {
+ if (pins[pin] !== undefined) {
+ updatedConf[pin] = pinConfiguration[pin];
+ updatedPins[pin] = activePins[pin];
+ } else if (activePins[pin]) {
+ log('closing pin: ' + pin);
+ activePins[pin].closeSync();
+ }
+ }
+ }
+
+ // update internal data
+ activePins = updatedPins;
+ pinConfiguration = updatedConf;
+}
+
+function handleRequest(req, res) {
+ var path = extractPath(req.url);
+ switch (path[0]) {
+ case 'update':
+ fetchRequestTextBody(req, function (data) {
+ syncPins(JSON.parse(data));
+ res.writeHead(200);
+ res.end(JSON.stringify(pinConfiguration));
+ });
+ break;
+ case undefined:
+ // front page
+ path[0] = 'index.html';
+ case 'favicon.ico':
+ // serve favicon as most browsers always fetch this
+ log('serving static: ' + path[0]);
+ var fileData = fetchFile(process.cwd() + '/' + path[0]);
+ if (fileData) {
+ res.writeHead(200);
+ res.end(fileData);
+ } else {
+ notFound(res);
+ }
+ break;
+ default:
+ // return 404 for all other requests
+ notFound(res);
+ break;
+ }
+}
+
+// handles input pin state changes
+setInterval(function () {
+ var pin = '',
+ value = null;
+ for (pin in activePins) {
+ if (activePins.hasOwnProperty(pin) &&
+ parseInt(pinConfiguration[pin].direction, 10) === 0) { // check pin is
+ // if input pin
+ value = activePins[pin].readSync() ? '1' : '0';
+ if (pinConfiguration[pin].value !== value) { // check if value changed
+ log('pin: ' + pin + ' value changed to: ' + value);
+ pinConfiguration[pin].value = value;
+ }
+ }
+ }
+}, 500);
+
+server = http.createServer(handleRequest);
+server.listen(port, function (err) {
+ if (err) {
+ log('error while starting server: ' + err);
+ } else {
+ log('listening for connections on port: ' + port);
+ }
+});
--- /dev/null
+/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Description:
+ *
+ * This sample runs a simple REPL mode console on the device UART port
+ *
+ * Usage:
+ *
+ * To run this sample, connect a UART device (ex. FTDI USB-UART, RPI UART pins)
+ * to RX/TX pin on the artik board (0 and 1 pin on CON709). Please note that
+ * the serial device used in this example is different than normal USB port on
+ * the Artik053 development board, so you need two connections, one to run
+ * the code and second to connect to REPL console. After connecting please run:
+ *
+ * $ iotjs console.js
+ *
+ * You can now run simple JS code and the device will evaluate it and return
+ * the results
+ */
+
+var uart = require('uart'),
+ uartConfig = {
+ device: '/dev/ttyS1',
+ baudRate: 115200,
+ dataBits: 8
+ },
+ buffer = [],
+ serialDevice = null,
+ log_enabled = true,
+ MSG_INFO = 0,
+ MSG_ERROR = 1,
+ EVALUATE_CODE_CHR = 18, // CTRL+R <CR>
+ uartResponseCodes = { // chars to send on specific input char codes
+ 8: '\b',
+ 13: '\r\n'
+ },
+ fakeConsole = { // fake console to allow sending console messages to user
+ messages: []
+ };
+
+// on linux the device is different
+if (process.platform === 'linux' ||
+ (process.iotjs && process.iotjs.board === 'RP2')) {
+ uartConfig.device = '/dev/serial0';
+}
+
+// tries to 'stringify' objects (and errors)
+function obj2str(obj) {
+ if (obj instanceof Error) {
+ return obj.name + ': ' + obj.message;
+ }
+
+ return JSON.stringify(obj);
+}
+
+// stringify and array of data (ex. arguments of functions)
+function arr2str(arr) {
+ var strArr = [],
+ i = 0,
+ l = arr.length;
+ for (; i < l; ++i) {
+ switch (typeof arr[i]) {
+ case 'object':
+ strArr.push(obj2str(arr[i]));
+ break;
+ case 'function':
+ strArr.push('function');
+ break;
+ default:
+ case 'string':
+ case 'number':
+ strArr.push(arr[i]);
+ break;
+ }
+ }
+ return strArr.join('');
+}
+
+fakeConsole.log = function (/*...args*/) {
+ var body = arr2str([].slice.call(arguments));
+ log('LOG: ' + body);
+ this.messages.push(body);
+};
+
+fakeConsole.error = function (/*...args*/) {
+ var body = arr2str([].slice.call(arguments));
+ log('ERROR: ' + body);
+ this.messages.push(body);
+};
+
+fakeConsole.toString = function () {
+ return this.messages.join('\r\n') + '\r\n';
+};
+
+fakeConsole.clear = function () {
+ this.messages = [];
+};
+
+// logs only if log_enabled flag is set to true
+function log(/*...args*/) {
+ if (log_enabled) {
+ console.log.apply(console, [].slice.call(arguments));
+ }
+}
+
+// faleConsole needs to be available to 'eval'ed scripts
+global.fakeConsole = fakeConsole;
+
+// execude code with 'eval'
+// this is done only for this sample, normally using eval is a no-no,
+// please avoid if possible
+function evalInContext(data) {
+ data = data.replace(/console\.(log|error)/g, 'fakeConsole.$1');
+ eval(data);
+}
+
+// handles code thats to be evaluated and sends response to uart device
+function handleCode(code) {
+ log('evaluating: >>>\r\n ' + code + ' \r\n>>>EOT');
+ try {
+ evalInContext(code);
+ } catch (err) {
+ fakeConsole.error(err);
+ }
+
+ serialDevice.write(fakeConsole.toString(), function (err) {
+ if (err) {
+ log('error while sending console data: ' + err);
+ } else {
+ fakeConsole.clear();
+ }
+ });
+}
+
+// handles data received from uart device
+function handleData(data) {
+ var arr = data.split(''),
+ chrCode = 0,
+ chr = '',
+ i = 0,
+ l = data.length,
+ localBuff = buffer;
+
+ for (;i < l; ++i) {
+ chr = arr[i];
+ chrCode = chr.charCodeAt(0);
+
+ if (chrCode === 8) { // handle backspace
+ localBuff.splice(localBuff.length - 1, 1);
+ serialDevice.writeSync('\b \b'); // move back, erase by space, move back
+ } else if ((chrCode > 31 && chrCode < 127) || chrCode === 13) {
+ // and only visible chars and new lines
+ localBuff.push(chr);
+ serialDevice.writeSync(uartResponseCodes[chrCode] || chr);
+ }
+
+ if (chrCode === EVALUATE_CODE_CHR) { // evaluate code on EVALUATE_CODE_CHR
+ handleCode(localBuff.join(''));
+ localBuff = []; // clear buffer after code evaluation
+ }
+ }
+
+ buffer = localBuff;
+}
+
+process.on('uncaughtException', function (err) {
+ // code errors need to be cached and redirected to uart console
+ log('uncaught exception: ' + err);
+ fakeConsole.error(err);
+});
+
+serialDevice = uart.open(uartConfig, function (err) {
+ if (err) {
+ log('could not opend device: ' + uartConfig.device + ', reason: ' + err);
+ } else {
+ log('waiting for user input');
+ serialDevice.on('data', handleData);
+ }
+});
#include <string.h>
-/**
- * Initialize JerryScript.
- */
-static bool iotjs_jerry_init(iotjs_environment_t* env) {
+static bool jerry_initialize(iotjs_environment_t* env) {
// Set jerry run flags.
jerry_init_flag_t jerry_flags = JERRY_INIT_EMPTY;
if (iotjs_environment_config(env)->debugger != NULL) {
jerry_debugger_init(iotjs_environment_config(env)->debugger->port);
+
+ if (!jerry_debugger_is_connected()) {
+ DLOG("jerry_debugger_init() failed");
+ return false;
+ }
+
jerry_debugger_continue();
}
jerry_set_vm_exec_stop_callback(vm_exec_stop_callback, &env->state, 2);
// Do parse and run to generate initial javascript environment.
- jerry_value_t parsed_code = jerry_parse((jerry_char_t*)"", 0, false);
+ jerry_value_t parsed_code =
+ jerry_parse(NULL, 0, (jerry_char_t*)"", 0, JERRY_PARSE_NO_OPTS);
if (jerry_value_has_error_flag(parsed_code)) {
DLOG("jerry_parse() failed");
jerry_release_value(parsed_code);
}
-static void iotjs_run(iotjs_environment_t* env) {
+bool iotjs_initialize(iotjs_environment_t* env) {
+ // Initialize JerryScript
+ if (!jerry_initialize(env)) {
+ DLOG("iotjs_jerry_init failed");
+ return false;
+ }
+
+ // Set event loop.
+ if (!uv_default_loop()) {
+ DLOG("iotjs uvloop init failed");
+ return false;
+ }
+ iotjs_environment_set_loop(env, uv_default_loop());
+
+ // Bind environment to global object.
+ const jerry_value_t global = jerry_get_global_object();
+ jerry_set_object_native_pointer(global, env, NULL);
+
+ // Initialize builtin process module.
+ const jerry_value_t process = iotjs_module_get("process");
+ iotjs_jval_set_property_jval(global, "process", process);
+
+ // Release the global object
+ jerry_release_value(global);
+
+ return true;
+}
+
+
+void iotjs_run(iotjs_environment_t* env) {
// Evaluating 'iotjs.js' returns a function.
#ifndef ENABLE_SNAPSHOT
jerry_value_t jmain = iotjs_jhelper_eval("iotjs.js", strlen("iotjs.js"),
iotjs_s, iotjs_l, false);
#else
jerry_value_t jmain =
- jerry_exec_snapshot_at((const void*)iotjs_js_modules_s,
- iotjs_js_modules_l, module_iotjs_idx, false);
+ jerry_exec_snapshot((const void*)iotjs_js_modules_s, iotjs_js_modules_l,
+ module_iotjs_idx, 0);
#endif
if (jerry_value_has_error_flag(jmain) && !iotjs_environment_is_exiting(env)) {
static int iotjs_start(iotjs_environment_t* env) {
- // Bind environment to global object.
- const jerry_value_t global = jerry_get_global_object();
- jerry_set_object_native_pointer(global, env, NULL);
-
- // Initialize builtin process module.
- const jerry_value_t process = iotjs_module_get("process");
- iotjs_jval_set_property_jval(global, "process", process);
-
- // Release the global object
- jerry_release_value(global);
-
iotjs_environment_set_state(env, kRunningMain);
// Load and call iotjs.js.
exit_code = iotjs_process_exitcode();
- // Release builtin modules.
- iotjs_module_list_cleanup();
-
return exit_code;
}
iotjs_handlewrap_close(handle_wrap, NULL);
}
+
+void iotjs_end(iotjs_environment_t* env) {
+ uv_loop_t* loop = iotjs_environment_loop(env);
+ // Close uv loop.
+ uv_walk(loop, iotjs_uv_walk_to_close_callback, NULL);
+ uv_run(loop, UV_RUN_DEFAULT);
+
+ int res = uv_loop_close(loop);
+ IOTJS_ASSERT(res == 0);
+}
+
+
+void iotjs_terminate(iotjs_environment_t* env) {
+ // Release builtin modules.
+ iotjs_module_list_cleanup();
+
+ // Release JerryScript engine.
+ jerry_cleanup();
+}
+
+
void iotjs_conf_console_out(int (*out)(int lv, const char* fmt, ...)) {
iotjs_set_console_out(out);
}
int iotjs_entry(int argc, char** argv) {
int ret_code = 0;
- // Initialize IoT.js
-
+ // Initialize debug log and environments
iotjs_debuglog_init();
iotjs_environment_t* env = iotjs_environment_get();
argv)) {
DLOG("iotjs_environment_parse_command_line_arguments failed");
ret_code = 1;
- goto terminate;
+ goto exit;
}
- if (!iotjs_jerry_init(env)) {
- DLOG("iotjs_jerry_init failed");
+ // Initialize IoT.js
+ if (!iotjs_initialize(env)) {
+ DLOG("iotjs_initialize failed");
ret_code = 1;
goto terminate;
}
- // Set event loop.
- iotjs_environment_set_loop(env, uv_default_loop());
-
- // Start IoT.js.
-
+ // Start IoT.js
ret_code = iotjs_start(env);
- // Close uv loop.
- uv_walk(iotjs_environment_loop(env), iotjs_uv_walk_to_close_callback, NULL);
- uv_run(iotjs_environment_loop(env), UV_RUN_DEFAULT);
+ // Ends IoT.js
+ iotjs_end(env);
- int res = uv_loop_close(iotjs_environment_loop(env));
- IOTJS_ASSERT(res == 0);
+terminate:
+ iotjs_terminate(env);
+exit:
+ if (iotjs_environment_config(env)->debugger &&
+ iotjs_environment_config(env)->debugger->context_reset) {
+ iotjs_environment_release();
+ iotjs_debuglog_release();
- // Release JerryScript engine.
- jerry_cleanup();
-
-terminate:;
- bool context_reset = false;
- if (iotjs_environment_config(env)->debugger != NULL) {
- context_reset = iotjs_environment_config(env)->debugger->context_reset;
+ return iotjs_entry(argc, argv);
}
- // Release environment.
- iotjs_environment_release();
+ iotjs_environment_release();
iotjs_debuglog_release();
-
- if (context_reset) {
- return iotjs_entry(argc, argv);
- }
return ret_code;
}
#include <string.h>
-static iotjs_jargs_t jargs_empty = {.unsafe = { 0, 0, NULL },
-#ifndef NDEBUG
- .flag_create = IOTJS_VALID_MAGIC_SEQUENCE
-#endif /* !NDEBUG */
-};
+static iotjs_jargs_t jargs_empty;
jerry_value_t iotjs_jval_create_string(const iotjs_string_t* v) {
}
-jerry_value_t iotjs_jval_get_string_size(const iotjs_string_t* str) {
- jerry_value_t str_val = iotjs_jval_create_string(str);
-
- jerry_size_t size = jerry_get_string_size(str_val);
- jerry_value_t jval = jerry_create_number(size);
-
- jerry_release_value(str_val);
-
- return jval;
-}
-
-
jerry_value_t iotjs_jval_create_byte_array(uint32_t len, const char* data) {
IOTJS_ASSERT(data != NULL);
}
-#ifndef NDEBUG
-static jerry_value_t iotjs_jargs_get(const iotjs_jargs_t* jargs,
- uint16_t index) {
- const IOTJS_VALIDATED_STRUCT_METHOD(iotjs_jargs_t, jargs);
-
- IOTJS_ASSERT(index < _this->argc);
- return _this->argv[index];
-}
-#endif
-
-
jerry_value_t iotjs_jhelper_call(jerry_value_t jfunc, jerry_value_t jthis,
const iotjs_jargs_t* jargs) {
IOTJS_ASSERT(jerry_value_is_object(jfunc));
- jerry_value_t* jargv_ = NULL;
jerry_length_t jargc_ = iotjs_jargs_length(jargs);
-#ifdef NDEBUG
- jargv_ = (jerry_value_t*)jargs->unsafe.argv;
-#else
- if (jargc_ > 0) {
- unsigned buffer_size = sizeof(jerry_value_t) * jargc_;
- jargv_ = (jerry_value_t*)iotjs_buffer_allocate(buffer_size);
- for (unsigned i = 0; i < jargc_; ++i) {
- jargv_[i] = iotjs_jargs_get(jargs, i);
- }
- }
-#endif
-
- jerry_value_t jres = jerry_call_function(jfunc, jthis, jargv_, jargc_);
-
-#ifndef NDEBUG
- if (jargv_) {
- iotjs_buffer_release((char*)jargv_);
- }
-#endif
+ jerry_value_t jres = jerry_call_function(jfunc, jthis, jargs->argv, jargc_);
return jres;
}
-jerry_value_t iotjs_jhelper_call_ok(jerry_value_t jfunc, jerry_value_t jthis,
- const iotjs_jargs_t* jargs) {
- jerry_value_t jres = iotjs_jhelper_call(jfunc, jthis, jargs);
- IOTJS_ASSERT(!jerry_value_has_error_flag(jres));
- return jres;
-}
-
-
jerry_value_t iotjs_jhelper_eval(const char* name, size_t name_len,
const uint8_t* data, size_t size,
bool strict_mode) {
- jerry_value_t jres =
- jerry_parse_named_resource((const jerry_char_t*)name, name_len,
- (const jerry_char_t*)data, size, strict_mode);
+ uint32_t opts = strict_mode ? JERRY_PARSE_STRICT_MODE : JERRY_PARSE_NO_OPTS;
+
+ jerry_value_t jres = jerry_parse((const jerry_char_t*)name, name_len,
+ (const jerry_char_t*)data, size, opts);
if (!jerry_value_has_error_flag(jres)) {
jerry_value_t func = jres;
}
iotjs_jargs_t jargs;
- IOTJS_VALIDATED_STRUCT_CONSTRUCTOR(iotjs_jargs_t, &jargs);
- _this->capacity = capacity;
- _this->argc = 0;
+ jargs.capacity = capacity;
+ jargs.argc = 0;
unsigned buffer_size = sizeof(jerry_value_t) * capacity;
- _this->argv = (jerry_value_t*)iotjs_buffer_allocate(buffer_size);
+ jargs.argv = (jerry_value_t*)iotjs_buffer_allocate(buffer_size);
return jargs;
}
void iotjs_jargs_destroy(iotjs_jargs_t* jargs) {
- IOTJS_VALIDATED_STRUCT_DESTRUCTOR(iotjs_jargs_t, jargs);
+ IOTJS_ASSERT(jargs && jargs->argc <= jargs->capacity);
- IOTJS_ASSERT(_this->argv == NULL || _this->argc > 0);
- IOTJS_ASSERT(_this->argc <= _this->capacity);
-
- if (_this->capacity > 0) {
- for (unsigned i = 0; i < _this->argc; ++i) {
- jerry_release_value(_this->argv[i]);
+ if (jargs->capacity > 0) {
+ IOTJS_ASSERT(jargs->argv);
+ for (unsigned i = 0; i < jargs->argc; ++i) {
+ jerry_release_value(jargs->argv[i]);
}
- iotjs_buffer_release((char*)_this->argv);
+ IOTJS_RELEASE(jargs->argv);
} else {
- IOTJS_ASSERT(_this->argv == NULL);
+ IOTJS_ASSERT(jargs->argv == NULL);
}
}
uint16_t iotjs_jargs_length(const iotjs_jargs_t* jargs) {
- const IOTJS_VALIDATED_STRUCT_METHOD(iotjs_jargs_t, jargs);
- return _this->argc;
+ IOTJS_ASSERT(jargs);
+ return jargs->argc;
}
void iotjs_jargs_append_jval(iotjs_jargs_t* jargs, jerry_value_t x) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_jargs_t, jargs);
- IOTJS_ASSERT(_this->argc < _this->capacity);
- _this->argv[_this->argc++] = jerry_acquire_value(x);
+ IOTJS_ASSERT(jargs && jargs->argc < jargs->capacity);
+ IOTJS_ASSERT(jargs->argv);
+ jargs->argv[jargs->argc++] = jerry_acquire_value(x);
}
void iotjs_jargs_append_undefined(iotjs_jargs_t* jargs) {
- IOTJS_VALIDATABLE_STRUCT_METHOD_VALIDATE(iotjs_jargs_t, jargs);
iotjs_jargs_append_jval(jargs, jerry_create_undefined());
}
void iotjs_jargs_append_null(iotjs_jargs_t* jargs) {
- IOTJS_VALIDATABLE_STRUCT_METHOD_VALIDATE(iotjs_jargs_t, jargs);
iotjs_jargs_append_jval(jargs, jerry_create_null());
}
void iotjs_jargs_append_bool(iotjs_jargs_t* jargs, bool x) {
- IOTJS_VALIDATABLE_STRUCT_METHOD_VALIDATE(iotjs_jargs_t, jargs);
iotjs_jargs_append_jval(jargs, jerry_create_boolean(x));
}
void iotjs_jargs_append_number(iotjs_jargs_t* jargs, double x) {
- IOTJS_VALIDATABLE_STRUCT_METHOD_VALIDATE(iotjs_jargs_t, jargs);
jerry_value_t jval = jerry_create_number(x);
iotjs_jargs_append_jval(jargs, jval);
jerry_release_value(jval);
void iotjs_jargs_append_string(iotjs_jargs_t* jargs, const iotjs_string_t* x) {
- IOTJS_VALIDATABLE_STRUCT_METHOD_VALIDATE(iotjs_jargs_t, jargs);
jerry_value_t jval = iotjs_jval_create_string(x);
iotjs_jargs_append_jval(jargs, jval);
jerry_release_value(jval);
void iotjs_jargs_append_error(iotjs_jargs_t* jargs, const char* msg) {
- IOTJS_VALIDATABLE_STRUCT_METHOD_VALIDATE(iotjs_jargs_t, jargs);
jerry_value_t error = iotjs_jval_create_error_without_error_flag(msg);
iotjs_jargs_append_jval(jargs, error);
jerry_release_value(error);
void iotjs_jargs_append_string_raw(iotjs_jargs_t* jargs, const char* x) {
- IOTJS_VALIDATABLE_STRUCT_METHOD_VALIDATE(iotjs_jargs_t, jargs);
jerry_value_t jval = jerry_create_string((const jerry_char_t*)x);
iotjs_jargs_append_jval(jargs, jval);
jerry_release_value(jval);
void iotjs_jargs_replace(iotjs_jargs_t* jargs, uint16_t index,
jerry_value_t x) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_jargs_t, jargs);
-
- IOTJS_ASSERT(index < _this->argc);
+ IOTJS_ASSERT(jargs && index < jargs->argc);
+ IOTJS_ASSERT(jargs->argv);
- jerry_release_value(_this->argv[index]);
- _this->argv[index] = jerry_acquire_value(x);
+ jerry_release_value(jargs->argv[index]);
+ jargs->argv[index] = jerry_acquire_value(x);
}
#ifndef IOTJS_BINDING_H
#define IOTJS_BINDING_H
+#include <stdbool.h>
+#include <string.h>
+
#include "iotjs_util.h"
#include "jerryscript.h"
jerry_value_t iotjs_jval_create_function(jerry_external_handler_t handler);
jerry_value_t iotjs_jval_create_error_without_error_flag(const char* msg);
-jerry_value_t iotjs_jval_get_string_size(const iotjs_string_t* str);
-
-
/* Type Converters */
bool iotjs_jval_as_boolean(jerry_value_t);
double iotjs_jval_as_number(jerry_value_t);
uint16_t capacity;
uint16_t argc;
jerry_value_t* argv;
-} IOTJS_VALIDATED_STRUCT(iotjs_jargs_t);
+} iotjs_jargs_t;
iotjs_jargs_t iotjs_jargs_create(uint16_t capacity);
jerry_value_t iotjs_jhelper_call(jerry_value_t jfunc, jerry_value_t jthis,
const iotjs_jargs_t* jargs);
-// Calls javascript function.
-jerry_value_t iotjs_jhelper_call_ok(jerry_value_t jfunc, jerry_value_t jthis,
- const iotjs_jargs_t* jargs);
-
// Evaluates javascript source file.
jerry_value_t iotjs_jhelper_eval(const char* name, size_t name_len,
const uint8_t* data, size_t size,
bool strict_mode);
+/* Note:
+ * Defines started with underscores should not be used
+ * outside of this header.
+ */
#define JS_CREATE_ERROR(TYPE, message) \
- jerry_create_error(JERRY_ERROR_##TYPE, (const jerry_char_t*)message);
+ jerry_create_error(JERRY_ERROR_##TYPE, (const jerry_char_t*)message)
#define JS_CHECK(predicate) \
if (!(predicate)) { \
return JS_CREATE_ERROR(COMMON, "Internal error"); \
}
-#define JS_CHECK_TYPE(jval, type) JS_CHECK(jerry_value_is_##type(jval));
+#define __JS_CHECK_TYPE(index, type) jerry_value_is_##type(jargv[index])
-#define JS_CHECK_ARG(index, type) JS_CHECK_TYPE(jargv[index], type);
+#define JS_CHECK_ARG(index, type) JS_CHECK(__JS_CHECK_TYPE(index, type))
#define JS_CHECK_ARG_IF_EXIST(index, type) \
if (jargc > index) { \
- JS_CHECK_TYPE(jargv[index], type); \
+ JS_CHECK(__JS_CHECK_TYPE(index, type)) \
}
#define JS_CHECK_ARGS_0()
#define JS_CHECK_ARGS_1(type0) \
- JS_CHECK_ARGS_0(); \
- JS_CHECK_ARG(0, type0);
+ JS_CHECK_ARGS_0() \
+ __JS_CHECK_TYPE(0, type0)
#define JS_CHECK_ARGS_2(type0, type1) \
- JS_CHECK_ARGS_1(type0); \
- JS_CHECK_ARG(1, type1);
+ JS_CHECK_ARGS_1(type0) \
+ &&__JS_CHECK_TYPE(1, type1)
#define JS_CHECK_ARGS_3(type0, type1, type2) \
- JS_CHECK_ARGS_2(type0, type1); \
- JS_CHECK_ARG(2, type2);
+ JS_CHECK_ARGS_2(type0, type1) \
+ &&__JS_CHECK_TYPE(2, type2)
#define JS_CHECK_ARGS_4(type0, type1, type2, type3) \
- JS_CHECK_ARGS_3(type0, type1, type2); \
- JS_CHECK_ARG(3, type3);
+ JS_CHECK_ARGS_3(type0, type1, type2) \
+ &&__JS_CHECK_TYPE(3, type3)
#define JS_CHECK_ARGS_5(type0, type1, type2, type3, type4) \
- JS_CHECK_ARGS_4(type0, type1, type2, type3); \
- JS_CHECK_ARG(4, type4);
+ JS_CHECK_ARGS_4(type0, type1, type2, type3) \
+ &&__JS_CHECK_TYPE(4, type4)
#define JS_CHECK_ARGS(argc, ...) \
- JS_CHECK(jargc >= argc); \
- JS_CHECK_ARGS_##argc(__VA_ARGS__)
+ JS_CHECK(jargc >= argc && JS_CHECK_ARGS_##argc(__VA_ARGS__))
-#define JS_CHECK_THIS() JS_CHECK_TYPE(jthis, object);
+#define JS_CHECK_THIS() JS_CHECK(jerry_value_is_object(jthis))
#define JS_GET_ARG(index, type) iotjs_jval_as_##type(jargv[index])
const jerry_value_t jargv[], \
const jerry_length_t jargc)
-
#if defined(EXPERIMENTAL) && !defined(DEBUG)
// This code branch is to be in #ifdef NDEBUG
#define DJS_CHECK_ARG(index, type) ((void)0)
#define DJS_CHECK_ARG_IF_EXIST(index, type) JS_CHECK_ARG_IF_EXIST(index, type)
#endif
-#define JS_DECLARE_THIS_PTR(type, name) \
+#define __JS_DECLARE_PTR(type, name, value) \
iotjs_##type##_t* name; \
do { \
JNativeInfoType* out_native_info; \
- jerry_get_object_native_pointer(jthis, (void**)&name, &out_native_info); \
+ jerry_get_object_native_pointer(value, (void**)&name, &out_native_info); \
if (!name || out_native_info != &this_module_native_info) { \
return JS_CREATE_ERROR(COMMON, ""); \
} \
} while (0)
-#define JS_DECLARE_OBJECT_PTR(index, type, name) \
- iotjs_##type##_t* name; \
- do { \
- JNativeInfoType* out_native_info; \
- jerry_get_object_native_pointer(jargv[index], (void**)&name, \
- &out_native_info); \
- if (!name || out_native_info != &this_module_native_info) { \
- return JS_CREATE_ERROR(COMMON, ""); \
- } \
- } while (0)
+#define JS_DECLARE_THIS_PTR(type, name) __JS_DECLARE_PTR(type, name, jthis)
+
+#define JS_DECLARE_OBJECT_PTR(index, type, name) \
+ __JS_DECLARE_PTR(type, name, jargv[index])
-#define JS_GET_REQUIRED_ARG_VALUE(index, target, property, type) \
+#define __JS_GET_REQUIRED_VALUE(target, property, type, value) \
do { \
- if (jerry_value_is_undefined(jargv[index])) { \
+ if (jerry_value_is_undefined(value)) { \
return JS_CREATE_ERROR(TYPE, "Missing argument, required " property); \
- } else if (jerry_value_is_##type(jargv[index])) { \
- target = iotjs_jval_as_##type(jargv[index]); \
+ } else if (jerry_value_is_##type(value)) { \
+ target = iotjs_jval_as_##type(value); \
} else { \
return JS_CREATE_ERROR(TYPE, "Bad arguments, required " property \
" is not a " #type); \
} \
} while (0)
-#define DJS_GET_REQUIRED_CONF_VALUE(src, target, property, type) \
- do { \
- jerry_value_t jtmp = iotjs_jval_get_property(src, property); \
- if (jerry_value_is_undefined(jtmp)) { \
- return JS_CREATE_ERROR(TYPE, "Missing argument, required " property); \
- } else if (jerry_value_is_##type(jtmp)) { \
- target = iotjs_jval_as_##type(jtmp); \
- } else { \
- return JS_CREATE_ERROR(TYPE, "Bad arguments, required " property \
- " is not a " #type); \
- } \
- jerry_release_value(jtmp); \
+#define JS_GET_REQUIRED_ARG_VALUE(index, target, property, type) \
+ __JS_GET_REQUIRED_VALUE(target, property, type, jargv[index])
+
+#define JS_GET_REQUIRED_CONF_VALUE(src, target, property, type) \
+ do { \
+ jerry_value_t jtmp = iotjs_jval_get_property(src, property); \
+ __JS_GET_REQUIRED_VALUE(target, property, type, jtmp); \
+ jerry_release_value(jtmp); \
} while (0)
jerry_value_t vm_exec_stop_callback(void* user_p);
+/**
+ * Dynamic module defintions (.iotjs)
+ */
+#define IOTJS_CURRENT_MODULE_VERSION ((uint32_t)1)
+
+typedef jerry_value_t (*ModuleInitializer)(void);
+
+typedef struct {
+ uint32_t iotjs_module_version;
+ uint32_t module_version;
+ ModuleInitializer initializer;
+} iotjs_module;
+
+typedef iotjs_module* (*iotjs_module_info_getter)(void);
+
+#define IOTJS_MODULE_ENTRYPOINT iotjs_module_info
+#define IOTJS_MODULE(IOTJS_VERSION, MODULE_VERSION, NAME) \
+ static const iotjs_module __module = { \
+ IOTJS_VERSION, MODULE_VERSION, init_##NAME, \
+ }; \
+ const iotjs_module* IOTJS_MODULE_ENTRYPOINT(void) { \
+ return &__module; \
+ }
+
#endif /* IOTJS_BINDING_H */
jerry_value_t jexit =
iotjs_jval_get_property(process, IOTJS_MAGIC_STRING_EMITEXIT);
- IOTJS_ASSERT(jerry_value_is_function(jexit));
- iotjs_jargs_t jargs = iotjs_jargs_create(1);
- iotjs_jargs_append_number(&jargs, code);
+ if (jerry_value_is_function(jexit)) {
+ iotjs_jargs_t jargs = iotjs_jargs_create(1);
+ iotjs_jargs_append_number(&jargs, code);
- jerry_value_t jres = iotjs_jhelper_call(jexit, process, &jargs);
+ jerry_value_t jres = iotjs_jhelper_call(jexit, process, &jargs);
- iotjs_jargs_destroy(&jargs);
- jerry_release_value(jexit);
+ if (jerry_value_has_error_flag(jres)) {
+ iotjs_set_process_exitcode(2);
+ }
- if (jerry_value_has_error_flag(jres)) {
- iotjs_set_process_exitcode(2);
+ iotjs_jargs_destroy(&jargs);
+ jerry_release_value(jres);
}
- jerry_release_value(jres);
+ jerry_release_value(jexit);
}
IOTJS_ASSERT(jerry_value_is_function(jon_next_tick));
jerry_value_t jres =
- iotjs_jhelper_call_ok(jon_next_tick, jerry_create_undefined(),
- iotjs_jargs_get_empty());
+ iotjs_jhelper_call(jon_next_tick, jerry_create_undefined(),
+ iotjs_jargs_get_empty());
- IOTJS_ASSERT(jerry_value_is_boolean(jres));
+ bool ret = false;
+
+ if (!jerry_value_has_error_flag(jres)) {
+ ret = iotjs_jval_as_boolean(jres);
+ }
- bool ret = iotjs_jval_as_boolean(jres);
jerry_release_value(jres);
jerry_release_value(jon_next_tick);
jerry_value_t iotjs_make_callback_with_result(jerry_value_t jfunction,
jerry_value_t jthis,
const iotjs_jargs_t* jargs) {
+ // If the environment is already exiting just return an undefined value.
+ if (iotjs_environment_is_exiting(iotjs_environment_get())) {
+ return jerry_create_undefined();
+ }
// Calls back the function.
jerry_value_t jres = iotjs_jhelper_call(jfunction, jthis, jargs);
if (jerry_value_has_error_flag(jres)) {
jerry_value_t jexitcode =
iotjs_jval_get_property(process, IOTJS_MAGIC_STRING_EXITCODE);
- IOTJS_ASSERT(jerry_value_is_number(jexitcode));
-
- const int exitcode = (int)iotjs_jval_as_number(jexitcode);
+ uint8_t exitcode = 0;
+ jerry_value_t num_val = jerry_value_to_number(jexitcode);
+ if (jerry_value_has_error_flag(num_val)) {
+ exitcode = 1;
+ jerry_value_clear_error_flag(&num_val);
+ } else {
+ exitcode = (uint8_t)iotjs_jval_as_number(num_val);
+ }
+ jerry_release_value(num_val);
jerry_release_value(jexitcode);
-
- return exitcode;
+ return (int)exitcode;
}
#ifdef ENABLE_DEBUG_LOG
int iotjs_debug_level = DBGLEV_ERR;
-FILE* iotjs_log_stream;
+FILE* iotjs_log_stream = NULL;
const char* iotjs_debug_prefix[4] = { "", "ERR", "WRN", "INF" };
#endif // ENABLE_DEBUG_LOG
void iotjs_debuglog_release() {
#ifdef ENABLE_DEBUG_LOG
- if (iotjs_log_stream != stderr && iotjs_log_stream != stdout) {
+ if (iotjs_log_stream && iotjs_log_stream != stderr &&
+ iotjs_log_stream != stdout) {
fclose(iotjs_log_stream);
}
// some embed systems(ex, nuttx) may need this
#ifdef ENABLE_DEBUG_LOG
-#include <stdio.h>
extern int iotjs_debug_level;
extern FILE* iotjs_log_stream;
extern const char* iotjs_debug_prefix[4];
-#define IOTJS_DLOG(lvl, ...) \
- do { \
- if (0 <= lvl && lvl <= iotjs_debug_level && iotjs_log_stream) { \
- if (iotjs_console_out) { \
- iotjs_console_out(lvl, __VA_ARGS__); \
- } else { \
- fprintf(iotjs_log_stream, "[%s] ", iotjs_debug_prefix[lvl]); \
- fprintf(iotjs_log_stream, __VA_ARGS__); \
- fprintf(iotjs_log_stream, "\n"); \
- fflush(iotjs_log_stream); \
- } \
- } \
+#if defined(__TIZEN__)
+#include <dlog.h>
+#define DLOG_TAG "IOTJS"
+#define DLOG_PRINT(lvl, ...) \
+ dlog_print((lvl == DBGLEV_ERR \
+ ? DLOG_ERROR \
+ : (lvl == DBGLEV_WARN ? DLOG_WARN : DLOG_INFO)), \
+ DLOG_TAG, __VA_ARGS__);
+#else
+#include <stdio.h>
+#define DLOG_PRINT(lvl, ...) \
+ fprintf(iotjs_log_stream, "[%s] ", iotjs_debug_prefix[lvl]); \
+ fprintf(iotjs_log_stream, __VA_ARGS__); \
+ fprintf(iotjs_log_stream, "\n"); \
+ fflush(iotjs_log_stream);
+#endif /* defined(__TIZEN__) */
+
+#define IOTJS_DLOG(lvl, ...) \
+ do { \
+ if (0 <= lvl && lvl <= iotjs_debug_level && iotjs_log_stream) { \
+ if (iotjs_console_out) { \
+ iotjs_console_out(lvl, __VA_ARGS__); \
+ } else { \
+ DLOG_PRINT(lvl, __VA_ARGS__) \
+ } \
+ } \
} while (0)
#define DLOG(...) IOTJS_DLOG(DBGLEV_ERR, __VA_ARGS__)
#define DDLOG(...) IOTJS_DLOG(DBGLEV_WARN, __VA_ARGS__)
#if defined(__NUTTX__) || defined(__TIZENRT__)
#define IOTJS_MAX_READ_BUFFER_SIZE 1023
#define IOTJS_MAX_PATH_SIZE 120
-#else
+#else /* !__NUTTX__ && !__TIZENRT__ */
#define IOTJS_MAX_READ_BUFFER_SIZE 65535
#define IOTJS_MAX_PATH_SIZE PATH_MAX
-#endif
-#endif
+#endif /* __NUTTX__ || TIZENRT */
+#endif /* IOTJS_MAX_READ_BUFFER_SIZE */
#ifndef IOTJS_ASSERT
#ifdef NDEBUG
#define IOTJS_ASSERT(x) ((void)(x))
-#else
+#else /* !NDEBUG */
extern void print_stacktrace();
extern void force_terminate();
#define IOTJS_ASSERT(x) \
force_terminate(); \
} \
} while (0)
-#endif
-#endif
+#endif /* NDEBUG */
+#endif /* IOTJS_ASSERT */
#if defined(__arm__)
#define TARGET_ARCH "arm"
#define TARGET_ARCH "ia32"
#elif defined(__x86_64__)
#define TARGET_ARCH "x64"
-#else
+#else /* !__arm__ && !__i686__ && !__x86_64__ */
#define TARGET_ARCH "unknown"
-#endif
+#endif /* __arm__ */
#if defined(__linux__)
+#if defined(__TIZEN__)
+#define TARGET_OS "tizen"
+#else
#define TARGET_OS "linux"
+#endif /* __TIZEN__ */
#elif defined(__NUTTX__)
#define TARGET_OS "nuttx"
#elif defined(__APPLE__)
#define TARGET_OS "darwin"
#elif defined(__TIZENRT__)
#define TARGET_OS "tizenrt"
-#else
+#else /* !__linux__ && !__NUTTX__ !__APPLE__ && !__TIZENRT__*/
#define TARGET_OS "unknown"
-#endif
+#endif /* __linux__ */
#define IOTJS_VERSION "1.0.0"
#if !defined(STRINGIFY)
#define STRINGIFY(x) #x
-#endif
+#endif /* STRINGIFY */
#if !defined(TOSTRING)
#define TOSTRING(x) STRINGIFY(x)
-#endif
-
+#endif /* TOSTRING */
#if !defined(TARGET_BOARD)
#define TARGET_BOARD "unknown"
-#endif
-
-
-#define IOTJS_VALID_MAGIC_SEQUENCE 0xfee1c001 /* feel cool */
-#define IOTJS_INVALID_MAGIC_SEQUENCE 0xfee1badd /* feel bad */
-
-#define IOTJS_DECLARE_THIS(iotjs_classname_t, x) \
- iotjs_classname_t##_impl_t* _this = &(x)->unsafe;
+#endif /* TARGET_BOARD */
/* Avoid compiler warnings if needed. */
#define IOTJS_UNUSED(x) ((void)(x))
.free_cb = (jerry_object_native_free_callback_t)iotjs_##name##_destroy \
}
-#ifdef NDEBUG
-
-#define IOTJS_VALIDATED_STRUCT(iotjs_classname_t) \
- iotjs_classname_t##_impl_t; \
- typedef struct iotjs_classname_t { \
- iotjs_classname_t##_impl_t unsafe; \
- } iotjs_classname_t;
-
-#define IOTJS_VALIDATED_STRUCT_STATIC_INITIALIZER(...) __VA_ARGS__
-
-#define IOTJS_VALIDATED_STRUCT_CONSTRUCTOR(iotjs_classname_t, x) \
- IOTJS_DECLARE_THIS(iotjs_classname_t, x);
-#define IOTJS_VALIDATED_STRUCT_DESTRUCTOR(iotjs_classname_t, x) \
- IOTJS_DECLARE_THIS(iotjs_classname_t, x);
-#define IOTJS_VALIDATED_STRUCT_METHOD(iotjs_classname_t, x) \
- IOTJS_DECLARE_THIS(iotjs_classname_t, x);
-
-#define IOTJS_VALIDATABLE_STRUCT_DESTRUCTOR_VALIDATE(iotjs_classname_t, x)
-#define IOTJS_VALIDATABLE_STRUCT_METHOD_VALIDATE(iotjs_classname_t, x)
-
-#else /* !NDEBUG */
-
-#define IOTJS_VALIDATED_STRUCT(iotjs_classname_t) \
- iotjs_classname_t##_impl_t; \
- typedef struct iotjs_classname_t { \
- iotjs_classname_t##_impl_t unsafe; \
- uint32_t flag_create; \
- char* valgrind_tracer; \
- } iotjs_classname_t;
-
-#define IOTJS_VALIDATED_STRUCT_STATIC_INITIALIZER(...) \
- { IOTJS_VALID_MAGIC_SEQUENCE, iotjs_buffer_allocate(4), __VA_ARGS__ }
-
-#define IOTJS_VALIDATE_FLAG(iotjs_classname_t, x) \
- if ((x)->flag_create != IOTJS_VALID_MAGIC_SEQUENCE) { \
- DLOG("`%s %s` is not initialized properly.", #iotjs_classname_t, #x); \
- IOTJS_ASSERT(false); \
- }
-
-#define IOTJS_VALIDATED_STRUCT_CONSTRUCTOR(iotjs_classname_t, x) \
- IOTJS_DECLARE_THIS(iotjs_classname_t, x); \
- /* IOTJS_ASSERT((x)->flag_create != IOTJS_VALID_MAGIC_SEQUENCE); */ \
- (x)->flag_create = IOTJS_VALID_MAGIC_SEQUENCE; \
- (x)->valgrind_tracer = iotjs_buffer_allocate(4);
-
-#define IOTJS_VALIDATED_STRUCT_DESTRUCTOR(iotjs_classname_t, x) \
- IOTJS_DECLARE_THIS(iotjs_classname_t, x); \
- IOTJS_VALIDATE_FLAG(iotjs_classname_t, x); \
- (x)->flag_create = IOTJS_INVALID_MAGIC_SEQUENCE; \
- iotjs_buffer_release((x)->valgrind_tracer);
-
-#define IOTJS_VALIDATED_STRUCT_METHOD(iotjs_classname_t, x) \
- IOTJS_DECLARE_THIS(iotjs_classname_t, x); \
- IOTJS_VALIDATE_FLAG(iotjs_classname_t, x);
-
-#define IOTJS_VALIDATABLE_STRUCT_DESTRUCTOR_VALIDATE(iotjs_classname_t, x) \
- IOTJS_VALIDATE_FLAG(iotjs_classname_t, x); \
- (x)->flag_create = IOTJS_INVALID_MAGIC_SEQUENCE; \
- iotjs_buffer_release((x)->valgrind_tracer);
-
-#define IOTJS_VALIDATABLE_STRUCT_METHOD_VALIDATE(iotjs_classname_t, x) \
- IOTJS_VALIDATE_FLAG(iotjs_classname_t, x);
-
-#endif /* NDEBUG */
-
#include <uv.h>
#include <assert.h>
#include <limits.h> /* PATH_MAX */
#include "iotjs_def.h"
#include "iotjs_env.h"
+#include <stdlib.h>
#include <string.h>
+typedef enum {
+ OPT_HELP,
+ OPT_MEM_STATS,
+ OPT_SHOW_OP,
+ OPT_DEBUG_SERVER,
+ OPT_DEBUGGER_WAIT_SOURCE,
+ OPT_DEBUG_PORT,
+ NUM_OF_OPTIONS
+} cli_option_id_t;
+
+typedef struct {
+ const cli_option_id_t id;
+ const char* opt;
+ const char* longopt;
+ const char* help;
+ const uint32_t more; // The number of options coming with the given option
+} cli_option_t;
+
+#define CLI_DEFAULT_HELP_STRING \
+ "Usage: iotjs [options] {FILE | FILE.js} [arguments]\n"
static iotjs_environment_t current_env;
static bool initialized = false;
return;
iotjs_environment_t* env = iotjs_environment_get();
- if (env->config.debugger)
- iotjs_buffer_release((char*)(env->config.debugger));
- if (env->argv)
- iotjs_buffer_release((char*)env->argv);
+ IOTJS_RELEASE(env->config.debugger);
+ IOTJS_RELEASE(env->argv);
initialized = false;
}
bool iotjs_environment_parse_command_line_arguments(iotjs_environment_t* env,
uint32_t argc,
char** argv) {
- // Parse IoT.js command line arguments.
+ // declare options
+ const cli_option_t opts[] = {
+ {
+ .id = OPT_HELP,
+ .opt = "h",
+ .longopt = "help",
+ .help = "print this help and exit",
+ },
+ {
+ .id = OPT_MEM_STATS,
+ .longopt = "mem-stats",
+ .help = "dump memory statistics",
+ },
+ {
+ .id = OPT_SHOW_OP,
+ .longopt = "show-opcodes",
+ .help = "dump parser byte-code",
+ },
+ {
+ .id = OPT_DEBUG_SERVER,
+ .opt = "d",
+ .longopt = "start-debug-server",
+ .help = "start debug server and wait for a connecting client",
+ },
+ {
+ .id = OPT_DEBUGGER_WAIT_SOURCE,
+ .opt = "w",
+ .longopt = "debugger-wait-source",
+ .help = "wait for an executable source from the client",
+ },
+ {
+ .id = OPT_DEBUG_PORT,
+ .longopt = "debug-port",
+ .more = 1,
+ .help = "debug server port (default: 5001)",
+ },
+ };
+
+ const cli_option_t* cur_opt;
uint32_t i = 1;
- uint8_t port_arg_len = strlen("--jerry-debugger-port=");
+
while (i < argc && argv[i][0] == '-') {
- if (!strcmp(argv[i], "--memstat")) {
- env->config.memstat = true;
- } else if (!strcmp(argv[i], "--show-opcodes")) {
- env->config.show_opcode = true;
- } else if (!strcmp(argv[i], "--start-debug-server")) {
- env->config.debugger =
- (DebuggerConfig*)iotjs_buffer_allocate(sizeof(DebuggerConfig));
- env->config.debugger->port = 5001;
- env->config.debugger->wait_source = false;
- env->config.debugger->context_reset = false;
- } else if (!strncmp(argv[i], "--jerry-debugger-port=", port_arg_len) &&
- env->config.debugger) {
- size_t port_length = sizeof(strlen(argv[i] - port_arg_len - 1));
- char port[port_length];
- memcpy(&port, argv[i] + port_arg_len, port_length);
- sscanf(port, "%hu", &env->config.debugger->port);
- } else if (!strcmp(argv[i], "--debugger-wait-source") &&
- env->config.debugger) {
- env->config.debugger->wait_source = true;
- } else {
+ cur_opt = NULL;
+
+ // check if the known option is given.
+ for (uint32_t k = 0; k < NUM_OF_OPTIONS; k++) {
+ if ((opts[k].opt && !strcmp(&argv[i][1], opts[k].opt)) ||
+ (opts[k].longopt && !strcmp(&argv[i][2], opts[k].longopt))) {
+ cur_opt = &opts[k];
+ break;
+ }
+ }
+
+ if (cur_opt == NULL) {
fprintf(stderr, "unknown command line option: %s\n", argv[i]);
return false;
}
- ++i;
+
+ switch (cur_opt->id) {
+ case OPT_HELP: {
+ fprintf(stderr, "%s\n Options:\n\n", CLI_DEFAULT_HELP_STRING);
+ for (uint32_t k = 0; k < NUM_OF_OPTIONS; k++) {
+ if (opts[k].opt) {
+ fprintf(stderr, " -%s, --%-21s %s\n", opts[k].opt,
+ opts[k].longopt, opts[k].help);
+ } else {
+ fprintf(stderr, " --%-25s %s\n", opts[k].longopt, opts[k].help);
+ }
+ }
+ fprintf(stderr, "\n");
+ return false;
+ } break;
+ case OPT_MEM_STATS: {
+ env->config.memstat = true;
+ } break;
+ case OPT_SHOW_OP: {
+ env->config.show_opcode = true;
+ } break;
+ case OPT_DEBUG_SERVER: {
+ if (!env->config.debugger) {
+ env->config.debugger =
+ (DebuggerConfig*)iotjs_buffer_allocate(sizeof(DebuggerConfig));
+ }
+ env->config.debugger->port = 5001;
+ env->config.debugger->wait_source = false;
+ env->config.debugger->context_reset = false;
+ } break;
+ case OPT_DEBUG_PORT: {
+ if (env->config.debugger) {
+ char* pos = NULL;
+ env->config.debugger->port = (uint16_t)strtoul(argv[i + 1], &pos, 10);
+ }
+ } break;
+ case OPT_DEBUGGER_WAIT_SOURCE: {
+ if (env->config.debugger)
+ env->config.debugger->wait_source = true;
+ } break;
+ default:
+ break;
+ }
+
+ // increase index of argv
+ i += (1 + cur_opt->more);
}
// If IoT.js is waiting for source from the debugger client,
// There must be at least one argument after processing the IoT.js args,
if (argc - i < 1) {
- fprintf(stderr,
- "Usage: iotjs [options] {script | script.js} [arguments]\n");
+ fprintf(stderr, CLI_DEFAULT_HELP_STRING);
return false;
}
void iotjs_handlewrap_initialize(iotjs_handlewrap_t* handlewrap,
jerry_value_t jobject, uv_handle_t* handle,
JNativeInfoType* native_info) {
- IOTJS_VALIDATED_STRUCT_CONSTRUCTOR(iotjs_handlewrap_t, handlewrap);
-
// Increase ref count of Javascript object to guarantee it is alive until the
// handle has closed.
jerry_value_t jobjectref = jerry_acquire_value(jobject);
- _this->jobject = jobjectref;
+ handlewrap->jobject = jobjectref;
jerry_set_object_native_pointer(jobjectref, handlewrap, native_info);
- _this->handle = handle;
- _this->on_close_cb = NULL;
+ handlewrap->handle = handle;
+ handlewrap->on_close_cb = NULL;
handle->data = handlewrap;
void iotjs_handlewrap_destroy(iotjs_handlewrap_t* handlewrap) {
- IOTJS_VALIDATED_STRUCT_DESTRUCTOR(iotjs_handlewrap_t, handlewrap);
-
// Handle should have been release before this.
- IOTJS_ASSERT(_this->handle == NULL);
+ IOTJS_ASSERT(handlewrap->handle == NULL);
}
uv_handle_t* iotjs_handlewrap_get_uv_handle(iotjs_handlewrap_t* handlewrap) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_handlewrap_t, handlewrap);
iotjs_handlewrap_validate(handlewrap);
- return _this->handle;
+ return handlewrap->handle;
}
jerry_value_t iotjs_handlewrap_jobject(iotjs_handlewrap_t* handlewrap) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_handlewrap_t, handlewrap);
iotjs_handlewrap_validate(handlewrap);
- return _this->jobject;
+ return handlewrap->jobject;
}
static void iotjs_handlewrap_on_close(iotjs_handlewrap_t* handlewrap) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_handlewrap_t, handlewrap);
-
// The handle closed.
// Calls registered close handler function.
- if (_this->on_close_cb) {
- _this->on_close_cb(_this->handle);
+ if (handlewrap->on_close_cb) {
+ handlewrap->on_close_cb(handlewrap->handle);
}
// Set handle null.
- _this->handle = NULL;
+ handlewrap->handle = NULL;
// Decrease ref count of Javascript object. From now the object can be
// reclaimed.
- jerry_release_value(_this->jobject);
+ jerry_release_value(handlewrap->jobject);
}
void iotjs_handlewrap_close(iotjs_handlewrap_t* handlewrap,
OnCloseHandler on_close_cb) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_handlewrap_t, handlewrap);
-
- if (_this->handle != NULL && !uv_is_closing(_this->handle)) {
- _this->on_close_cb = on_close_cb;
- uv_close(_this->handle, iotjs_on_handle_closed);
+ if (handlewrap->handle != NULL && !uv_is_closing(handlewrap->handle)) {
+ handlewrap->on_close_cb = on_close_cb;
+ uv_close(handlewrap->handle, iotjs_on_handle_closed);
} else {
DDLOG("Attempt to close uninitialized or already closed handle");
}
void iotjs_handlewrap_validate(iotjs_handlewrap_t* handlewrap) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_handlewrap_t, handlewrap);
-
- IOTJS_ASSERT((iotjs_handlewrap_t*)_this == handlewrap);
- IOTJS_ASSERT((void*)_this == _this->handle->data);
- IOTJS_ASSERT((uintptr_t)_this ==
- iotjs_jval_get_object_native_handle(_this->jobject));
+ IOTJS_ASSERT(handlewrap);
+ IOTJS_ASSERT((void*)handlewrap == handlewrap->handle->data);
+ IOTJS_ASSERT((uintptr_t)handlewrap ==
+ iotjs_jval_get_object_native_handle(handlewrap->jobject));
}
jerry_value_t jobject;
uv_handle_t* handle;
OnCloseHandler on_close_cb;
-} IOTJS_VALIDATED_STRUCT(iotjs_handlewrap_t);
+} iotjs_handlewrap_t;
// jobject: Object that connect with the uv handle
#define IOTJS_MAGIC_STRING_ADDRESS "address"
#define IOTJS_MAGIC_STRING_ARCH "arch"
#define IOTJS_MAGIC_STRING_ARGV "argv"
+#define IOTJS_MAGIC_STRING_BASE64 "base64"
#if ENABLE_MODULE_UART
#define IOTJS_MAGIC_STRING_BAUDRATE "baudRate"
#endif
#endif
#define IOTJS_MAGIC_STRING_BUFFER "Buffer"
#define IOTJS_MAGIC_STRING_BUILTIN_MODULES "builtin_modules"
-#define IOTJS_MAGIC_STRING__BUFFER "_buffer"
-#define IOTJS_MAGIC_STRING__BUILTIN "_builtin"
-#if ENABLE_MODULE_SPI
+#if ENABLE_MODULE_I2C || ENABLE_MODULE_SPI
#define IOTJS_MAGIC_STRING_BUS "bus"
#endif
#define IOTJS_MAGIC_STRING_BYTELENGTH "byteLength"
-#if ENABLE_MODULE_HTTPS
-#define IOTJS_MAGIC_STRING_REJECTUNAUTHORIZED "rejectUnauthorized"
-#endif
#define IOTJS_MAGIC_STRING_BYTEPARSED "byteParsed"
-#if ENABLE_MODULE_HTTPS
+#if ENABLE_MODULE_HTTPS || ENABLE_MODULE_TLS
#define IOTJS_MAGIC_STRING_CA "ca"
#define IOTJS_MAGIC_STRING_CERT "cert"
#endif
#endif
#define IOTJS_MAGIC_STRING_EMIT "emit"
#define IOTJS_MAGIC_STRING_EMITEXIT "emitExit"
+#if ENABLE_MODULE_TLS
+#define IOTJS_MAGIC_STRING_END "end"
+#endif
#define IOTJS_MAGIC_STRING_ENV "env"
#define IOTJS_MAGIC_STRING_ERRNAME "errname"
#define IOTJS_MAGIC_STRING_EXECUTE "execute"
#define IOTJS_MAGIC_STRING_HANDLER "handler"
#define IOTJS_MAGIC_STRING_HANDLETIMEOUT "handleTimeout"
#define IOTJS_MAGIC_STRING_HEADERS "headers"
-#define IOTJS_MAGIC_STRING_HEXWRITE "hexWrite"
+#define IOTJS_MAGIC_STRING_HEX "hex"
#if ENABLE_MODULE_SPI
#define IOTJS_MAGIC_STRING_HIGH_U "HIGH"
#endif
#define IOTJS_MAGIC_STRING__INCOMING "_incoming"
#define IOTJS_MAGIC_STRING_IOTJS_ENV_U "IOTJS_ENV"
#define IOTJS_MAGIC_STRING_IOTJS_PATH_U "IOTJS_PATH"
+#define IOTJS_MAGIC_STRING_IOTJS_EXTRA_MODULE_PATH_U "IOTJS_EXTRA_MODULE_PATH"
#define IOTJS_MAGIC_STRING_IOTJS "iotjs"
#define IOTJS_MAGIC_STRING_IPV4 "IPv4"
#define IOTJS_MAGIC_STRING_IPV6 "IPv6"
#define IOTJS_MAGIC_STRING_ISDEVUP "isDevUp"
#define IOTJS_MAGIC_STRING_ISDIRECTORY "isDirectory"
#define IOTJS_MAGIC_STRING_ISFILE "isFile"
+#if ENABLE_MODULE_TLS
+#define IOTJS_MAGIC_STRING_ISSERVER "isServer"
+#endif
#define IOTJS_MAGIC_STRING_KEY "key"
#define IOTJS_MAGIC_STRING_LENGTH "length"
#define IOTJS_MAGIC_STRING_LISTEN "listen"
#define IOTJS_MAGIC_STRING_ONDATA "onData"
#define IOTJS_MAGIC_STRING_ONEND "onEnd"
#define IOTJS_MAGIC_STRING_ONERROR "onError"
+#if ENABLE_MODULE_TLS
+#define IOTJS_MAGIC_STRING_ONHANDSHAKEDONE "onhandshakedone"
+#endif
#define IOTJS_MAGIC_STRING_ONHEADERSCOMPLETE "OnHeadersComplete"
#define IOTJS_MAGIC_STRING_ONHEADERS "OnHeaders"
#define IOTJS_MAGIC_STRING_ONMESSAGECOMPLETE "OnMessageComplete"
#define IOTJS_MAGIC_STRING_ONSOCKET "onSocket"
#define IOTJS_MAGIC_STRING_ONTIMEOUT "onTimeout"
#define IOTJS_MAGIC_STRING__ONUNCAUGHTEXCEPTION "_onUncaughtException"
+#if ENABLE_MODULE_TLS
+#define IOTJS_MAGIC_STRING_ONWRITE "onwrite"
+#endif
#define IOTJS_MAGIC_STRING_ONWRITABLE "onWritable"
#if ENABLE_MODULE_GPIO
#define IOTJS_MAGIC_STRING_OPENDRAIN_U "OPENDRAIN"
#endif
#define IOTJS_MAGIC_STRING_REF "ref"
#define IOTJS_MAGIC_STRING_REINITIALIZE "reinitialize"
+#if ENABLE_MODULE_TLS || ENABLE_MODULE_HTTPS
+#define IOTJS_MAGIC_STRING_REJECTUNAUTHORIZED "rejectUnauthorized"
+#endif
#define IOTJS_MAGIC_STRING_RENAME "rename"
#define IOTJS_MAGIC_STRING_REQUEST_U "REQUEST"
#define IOTJS_MAGIC_STRING_RESPONSE_U "RESPONSE"
#define IOTJS_MAGIC_STRING_RMDIR "rmdir"
#define IOTJS_MAGIC_STRING_SEND "send"
#define IOTJS_MAGIC_STRING_SENDREQUEST "sendRequest"
+#if ENABLE_MODULE_TLS
+#define IOTJS_MAGIC_STRING_SERVERNAME "servername"
+#endif
#if ENABLE_MODULE_I2C
#define IOTJS_MAGIC_STRING_SETADDRESS "setAddress"
#endif
#define IOTJS_MAGIC_STRING_STDERR "stderr"
#define IOTJS_MAGIC_STRING_STDOUT "stdout"
#define IOTJS_MAGIC_STRING_STOP "stop"
-#define IOTJS_MAGIC_STRING_TOHEXSTRING "toHexString"
+#if ENABLE_MODULE_TLS
+#define IOTJS_MAGIC_STRING_TLSSOCKET "TLSSocket"
+#define IOTJS_MAGIC_STRING_TLSCONTEXT "TlsContext"
+#define IOTJS_MAGIC_STRING_TLSINIT "TlsInit"
+#endif
#define IOTJS_MAGIC_STRING_TOSTRING "toString"
#if ENABLE_MODULE_SPI
#define IOTJS_MAGIC_STRING_TRANSFER "transfer"
#define IOTJS_MAGIC_STRING_VERSION "version"
#define IOTJS_MAGIC_STRING_WRITEUINT8 "writeUInt8"
#define IOTJS_MAGIC_STRING_WRITE "write"
+#define IOTJS_MAGIC_STRING_WRITEDECODE "writeDecode"
#define IOTJS_MAGIC_STRING_WRITESYNC "writeSync"
#if ENABLE_MODULE_HTTPS
#define IOTJS_MAGIC_STRING__WRITE "_write"
#endif
+#if ENABLE_MODULE_BRIDGE
+#define IOTJS_MAGIC_STRING_MODULE_NAME "MODULE_NAME"
+#endif
+#if ENABLE_MODULE_TIZEN
+#define IOTJS_MAGIC_STRING_TIZEN "tizen"
+#define IOTJS_MAGIC_STRING_APP_CONTROL "appControl"
+#endif
#endif /* IOTJS_MAGIC_STRINGS_H */
void iotjs_reqwrap_initialize(iotjs_reqwrap_t* reqwrap, jerry_value_t jcallback,
uv_req_t* request) {
- IOTJS_VALIDATED_STRUCT_CONSTRUCTOR(iotjs_reqwrap_t, reqwrap);
- _this->jcallback = jerry_acquire_value(jcallback);
- _this->request = request;
- _this->request->data = reqwrap;
+ reqwrap->jcallback = jerry_acquire_value(jcallback);
+ reqwrap->request = request;
+ reqwrap->request->data = reqwrap;
}
void iotjs_reqwrap_destroy(iotjs_reqwrap_t* reqwrap) {
- IOTJS_VALIDATED_STRUCT_DESTRUCTOR(iotjs_reqwrap_t, reqwrap);
- jerry_release_value(_this->jcallback);
+ jerry_release_value(reqwrap->jcallback);
}
static void iotjs_reqwrap_validate(iotjs_reqwrap_t* reqwrap) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_reqwrap_t, reqwrap);
- IOTJS_ASSERT(_this->request->data == reqwrap);
+ IOTJS_ASSERT(reqwrap->request->data == reqwrap);
}
jerry_value_t iotjs_reqwrap_jcallback(iotjs_reqwrap_t* reqwrap) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_reqwrap_t, reqwrap);
iotjs_reqwrap_validate(reqwrap);
- return _this->jcallback;
+ return reqwrap->jcallback;
}
uv_req_t* iotjs_reqwrap_req(iotjs_reqwrap_t* reqwrap) {
- IOTJS_VALIDATED_STRUCT_METHOD(iotjs_reqwrap_t, reqwrap);
iotjs_reqwrap_validate(reqwrap);
- return _this->request;
+ return reqwrap->request;
}
typedef struct {
jerry_value_t jcallback;
uv_req_t* request;
-} IOTJS_VALIDATED_STRUCT(iotjs_reqwrap_t);
+} iotjs_reqwrap_t;
void iotjs_reqwrap_initialize(iotjs_reqwrap_t* reqwrap, jerry_value_t jcallback,
void iotjs_string_destroy(iotjs_string_t* str) {
- if (str->data != NULL) {
- iotjs_buffer_release(str->data);
- str->size = 0;
- }
+ IOTJS_RELEASE(str->data);
+ str->size = 0;
}
return str->size == 0;
}
-
-void iotjs_string_make_empty(iotjs_string_t* str) {
- if (str->data != NULL) {
- iotjs_buffer_release(str->data);
- str->size = 0;
- str->data = NULL;
- }
-}
-
-
void iotjs_string_append(iotjs_string_t* str, const char* data, size_t size) {
IOTJS_ASSERT(data != NULL);
// Check if string is empty
bool iotjs_string_is_empty(const iotjs_string_t* str);
-// Make string empty
-void iotjs_string_make_empty(iotjs_string_t* str);
-
// Append `data` to tail of the string.
void iotjs_string_append(iotjs_string_t* str, const char* data, size_t size);
#include <stdlib.h>
#include <string.h>
-#if defined(__linux__)
+#if defined(__linux__) && !defined(__OPENWRT__)
#include <execinfo.h>
#endif
return empty_content;
}
- fseek(file, 0, SEEK_END);
+ int fseek_ret = fseek(file, 0, SEEK_END);
+ IOTJS_ASSERT(fseek_ret == 0);
long ftell_ret = ftell(file);
IOTJS_ASSERT(ftell_ret >= 0);
size_t len = (size_t)ftell_ret;
- fseek(file, 0, SEEK_SET);
+ fseek_ret = fseek(file, 0, SEEK_SET);
+ IOTJS_ASSERT(fseek_ret == 0);
char* buffer = iotjs_buffer_allocate(len + 1);
char* iotjs_buffer_allocate_from_number_array(size_t size,
const jerry_value_t array) {
char* buffer = iotjs_buffer_allocate(size);
- for (uint8_t i = 0; i < size; i++) {
+ for (size_t i = 0; i < size; i++) {
jerry_value_t jdata = iotjs_jval_get_property_by_index(array, i);
buffer[i] = iotjs_jval_as_number(jdata);
jerry_release_value(jdata);
void iotjs_buffer_release(char* buffer) {
- IOTJS_ASSERT(buffer != NULL);
- free(buffer);
+ if (buffer) {
+ free(buffer);
+ }
}
void print_stacktrace() {
-#if defined(__linux__) && defined(DEBUG)
+#if defined(__linux__) && defined(DEBUG) && !defined(__OPENWRT__)
// TODO: support other platforms
const int numOfStackTrace = 100;
void* buffer[numOfStackTrace];
}
free(strings);
-#endif // defined(__linux__) && defined(DEBUG)
+#endif // defined(__linux__) && defined(DEBUG) && !defined(__OPENWRT__)
}
void force_terminate() {
(type*)iotjs_buffer_allocate(sizeof(type))
#define IOTJS_RELEASE(ptr) /* Release memory allocated by IOTJS_ALLOC() */ \
- iotjs_buffer_release((char*)ptr)
+ ({ \
+ iotjs_buffer_release((char*)ptr); \
+ ptr = NULL; \
+ })
#endif /* IOTJS_UTIL_H */
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+function Bridge(moduleName) {
+ this.moduleName = moduleName;
+}
+
+Bridge.prototype.send = function(command, message, callback) {
+ native.send(this.moduleName, command, message, function(err, results) {
+ callback(err, results);
+ });
+};
+
+Bridge.prototype.sendSync = function(command, message) {
+ return native.send(this.moduleName, command, message);
+};
+
+module.exports = Bridge;
}
+function getEncodingType(encoding) {
+ switch (encoding) {
+ case 'hex':
+ return 0;
+ case 'base64':
+ return 1;
+ default:
+ return -1;
+ }
+}
+
+
// Buffer constructor
// [1] new Buffer(size)
// [2] new Buffer(buffer)
throw new TypeError('Bad arguments: Buffer(string|number|Buffer|Array)');
}
- this._builtin = new native(this, this.length);
+ // 'native' is the buffer object created via the C API.
+ native(this, this.length);
if (util.isString(subject)) {
- if (encoding !== undefined && util.isString(encoding)) {
- switch (encoding) {
- case 'hex':
- if (this._builtin.hexWrite(subject, 0, this.length) != this.length) {
- throw new TypeError('Invalid hex string');
- }
- break;
- default:
- this.write(subject);
+ if (typeof encoding === 'string') {
+ encoding = getEncodingType(encoding);
+ if (encoding != -1) {
+ native.writeDecode(this, encoding, subject, 0, this.length);
+ } else {
+ this.write(subject);
}
} else {
this.write(subject);
subject.copy(this);
} else if (util.isArray(subject)) {
for (var i = 0; i < this.length; ++i) {
- this._builtin.writeUInt8(subject[i], i);
+ native.writeUInt8(this, subject[i], i);
}
}
}
-// Buffer.byteLength(string)
+// Buffer.byteLength(string, encoding)
Buffer.byteLength = function(str, encoding) {
- var len = native.byteLength(str);
+ var bytes = native.byteLength(str);
- if (encoding !== undefined && util.isString(encoding)) {
+ if (typeof encoding === 'string') {
+ /* Might be invalid for incorrectly encoded strings. */
switch (encoding) {
case 'hex':
- return len >>> 1;
+ return bytes >>> 1;
+ case 'base64':
+ var len = str.length;
+
+ if (len >= 4 && str.charCodeAt(len - 1) === 0x3D) {
+ len--;
+
+ if (str.charCodeAt(len - 2) === 0x3D) {
+ len--;
+ }
+ }
+
+ return len;
}
}
- return len;
+ return bytes;
};
}
var length = 0;
- for (var i = 0; i < list.length; ++i) {
+ var i;
+ for (i = 0; i < list.length; ++i) {
if (!util.isBuffer(list[i])) {
throw new TypeError('Bad arguments: Buffer.concat([Buffer])');
}
var buffer = new Buffer(length);
var pos = 0;
- for (var i = 0; i < list.length; ++i) {
+ for (i = 0; i < list.length; ++i) {
list[i].copy(buffer, pos);
pos += list[i].length;
}
// Buffer.isBuffer(object)
-Buffer.isBuffer = function(object) {
- return util.isBuffer(object);
-};
+Buffer.isBuffer = util.isBuffer;
// buffer.equals(otherBuffer)
throw new TypeError('Bad arguments: buffer.equals(Buffer)');
}
- return this._builtin.compare(otherBuffer._builtin) == 0;
+ return native.compare(this, otherBuffer) == 0;
};
throw new TypeError('Bad arguments: buffer.compare(Buffer)');
}
- return this._builtin.compare(otherBuffer._builtin);
+ return native.compare(this, otherBuffer);
};
throw new RangeError('Attempt to write outside buffer bounds');
}
- return this._builtin.copy(target, targetStart, sourceStart, sourceEnd);
+ return native.copy(this, target, targetStart, sourceStart, sourceEnd);
};
// [3] buffer.write(string, offset, length)
// * offset - default to 0
// * length - default to buffer.length - offset
-Buffer.prototype.write = function(string, offset, length) {
+Buffer.prototype.write = function(string, offset, length, encoding) {
if (!util.isString(string)) {
throw new TypeError('Bad arguments: buff.write(string)');
}
var remaining = this.length - offset;
length = length === undefined ? remaining : ~~length;
- return this._builtin.write(string, offset, length);
+ if (typeof encoding === 'string') {
+ encoding = getEncodingType(encoding);
+ if (encoding != -1) {
+ return native.writeDecode(this, encoding, string, offset, length);
+ }
+ }
+
+ return native.write(this, string, offset, length);
};
start = start === undefined ? 0 : ~~start;
end = end === undefined ? this.length : ~~end;
- return this._builtin.slice(start, end);
+ return native.slice(this, start, end);
};
// buff.toString([encoding,[,start[, end]]])
// [1] buff.toString()
-// [2] buff.toString(start)
-// [3] buff.toString(start, end)
-// [4] buff.toString('hex')
+// [2] buff.toString(encoding)
+// [3] buff.toString(encoding, start)
+// [4] buff.toString(encoding, start, end)
// * start - default to 0
// * end - default to buff.length
-Buffer.prototype.toString = function(start, end) {
- if (util.isString(start) && start === 'hex' && end === undefined) {
- return this._builtin.toHexString();
+Buffer.prototype.toString = function(encoding, start, end) {
+ if (typeof encoding === 'string') {
+ encoding = getEncodingType(encoding);
+ } else {
+ encoding = -1;
}
+
start = start === undefined ? 0 : ~~start;
end = end === undefined ? this.length : ~~end;
- return this._builtin.toString(start, end);
+ return native.toString(this, encoding, start, end);
};
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 1, 0xff, 0);
- this._builtin.writeUInt8(value & 0xff, offset);
+ native.writeUInt8(this, value & 0xff, offset);
return offset + 1;
};
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 2, 0xffff, 0);
- this._builtin.writeUInt8(value & 0xff, offset);
- this._builtin.writeUInt8((value >>> 8) & 0xff, offset + 1);
+ native.writeUInt8(this, value & 0xff, offset);
+ native.writeUInt8(this, (value >>> 8) & 0xff, offset + 1);
return offset + 2;
};
offset = offset >>> 0;
if (!noAssert)
checkInt(this, value, offset, 4, 0xffffffff, 0);
- this._builtin.writeUInt8((value >>> 24) & 0xff, offset + 3);
- this._builtin.writeUInt8((value >>> 16) & 0xff, offset + 2);
- this._builtin.writeUInt8((value >>> 8) & 0xff, offset + 1);
- this._builtin.writeUInt8(value & 0xff, offset);
+ native.writeUInt8(this, (value >>> 24) & 0xff, offset + 3);
+ native.writeUInt8(this, (value >>> 16) & 0xff, offset + 2);
+ native.writeUInt8(this, (value >>> 8) & 0xff, offset + 1);
+ native.writeUInt8(this, value & 0xff, offset);
return offset + 4;
};
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 1, this.length);
- return this._builtin.readUInt8(offset);
+ return native.readUInt8(this, offset);
};
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 1, this.length);
- var val = this._builtin.readUInt8(offset);
+ var val = native.readUInt8(this, offset);
return !(val & 0x80) ? val : (0xff - val + 1) * -1;
};
offset = offset >>> 0;
if (!noAssert)
checkOffset(offset, 2, this.length);
- return this._builtin.readUInt8(offset) |
- (this._builtin.readUInt8(offset + 1) << 8);
+ return native.readUInt8(this, offset) |
+ (native.readUInt8(this, offset + 1) << 8);
};
if (util.isNumber(value)) {
value = value & 255;
for (var i = 0; i < this.length; i++) {
- this._builtin.writeUInt8(value, i);
+ native.writeUInt8(this, value, i);
}
}
return this;
var EventEmitter = require('events').EventEmitter;
var util = require('util');
-var udp = require('udp');
+var Udp = require('udp');
var BIND_STATE_UNBOUND = 0;
var BIND_STATE_BINDING = 1;
function newHandle(type) {
if (type == 'udp4') {
- var handle = new udp();
+ var handle = new Udp();
handle.lookup = lookup4;
return handle;
}
this._bindState = BIND_STATE_BINDING;
- var address;
-
if (util.isFunction(port)) {
callback = port;
port = 0;
self._handle._reuseAddr = self._reuseAddr;
- var err = self._handle.bind(ip, port | 0);
+ err = self._handle.bind(ip, port | 0);
if (err) {
var ex = util.exceptionWithHostPort(err, 'bind', ip, port);
self.emit('error', ex);
if (err && callback) {
// don't emit as error, dgram_legacy.js compatibility
- var ex = exceptionWithHostPort(err, 'send', address, port);
+ ex = util.exceptionWithHostPort(err, 'send', address, port);
process.nextTick(callback, ex);
}
}
function onMessage(nread, handle, buf, rinfo) {
var self = handle.owner;
if (nread < 0) {
- return self.emit('error', errnoException(nread, 'recvmsg'));
+ return self.emit('error', util.errnoException(nread, 'recvmsg'));
}
rinfo.size = buf.length; // compatibility
return;
}
- var cb = function(err, stat) {
+ var cb = function(err/* , stat */) {
if (callback) callback(err ? false : true);
};
};
-fs.open = function(path, flags, mode, callback) {
+fs.open = function(path, flags, mode/* , callback */) {
fsBuiltin.open(checkArgString(path, 'path'),
convertFlags(flags),
convertMode(mode, 438),
},
DIRECTION: native.DIRECTION,
EDGE: native.EDGE,
- MODE: native.MODE
+ MODE: native.MODE,
};
module.exports = gpio;
* limitations under the License.
*/
-var Server = require('http_server').Server;
+var net = require('net');
var ClientRequest = require('http_client').ClientRequest;
-var HTTPParser = require('httpparser');
+var HTTPParser = require('http_parser');
+var HTTPServer = require('http_server');
+var util = require('util');
exports.ClientRequest = ClientRequest;
exports.request = function(options, cb) {
- return new ClientRequest(options, cb);
+ // Create socket.
+ var socket = new net.Socket();
+ options.port = options.port || 80;
+
+ return new ClientRequest(options, cb, socket);
+};
+
+function Server(requestListener) {
+ if (!(this instanceof Server)) {
+ return new Server(requestListener);
+ }
+
+ net.Server.call(this, {allowHalfOpen: true},
+ HTTPServer.connectionListener);
+
+ HTTPServer.initServer.call(this, {}, requestListener);
+}
+util.inherits(Server, net.Server);
+
+Server.prototype.setTimeout = function(ms, cb) {
+ this.timeout = ms;
+ if (cb) {
+ this.on('timeout', cb);
+ }
};
+exports.Server = Server;
exports.createServer = function(requestListener) {
return new Server(requestListener);
*/
var util = require('util');
-var net = require('net');
var OutgoingMessage = require('http_outgoing').OutgoingMessage;
var common = require('http_common');
-var HTTPParser = require('httpparser').HTTPParser;
+var HTTPParser = require('http_parser').HTTPParser;
-function ClientRequest(options, cb) {
+function ClientRequest(options, cb, socket) {
OutgoingMessage.call(this);
// get port, host and method.
- var port = options.port = options.port || 80;
- var host = options.host = options.hostname || options.host || '127.0.0.1';
var method = options.method || 'GET';
var path = options.path || '/';
+ options.host = options.hostname || options.host || '127.0.0.1';
// If `options` contains header information, save it.
if (options.headers) {
}
}
- if (host && !this.getHeader('host')) {
- var hostHeader = host;
- if (port && +port !== 80) {
- hostHeader += ':' + port;
+ if (options.host && !this.getHeader('host')) {
+ var hostHeader = options.host;
+ if (this._port && +this._port !== 80) {
+ hostHeader += ':' + this._port;
}
this.setHeader('Host', hostHeader);
}
this.once('response', cb);
}
- // Create socket.
- var socket = new net.Socket();
-
- // connect server.
- socket.connect(port, host);
-
- // setup connection information.
- setupConnection(this, socket);
+ this.socket = socket;
+ this.options = options;
}
util.inherits(ClientRequest, OutgoingMessage);
exports.ClientRequest = ClientRequest;
+ClientRequest.prototype.end = function(data, encoding, callback) {
+ var self = this;
+
+ // connect server.
+ this.socket.connect(this.options, function() {
+ self._connected = true;
+ OutgoingMessage.prototype.end.call(self, data, encoding, callback);
+ });
+
+ // setup connection information.
+ setupConnection(this);
+};
-function setupConnection(req, socket) {
+function setupConnection(req) {
+ var socket = req.socket;
var parser = common.createHTTPParser();
parser.reinitialize(HTTPParser.RESPONSE);
socket.parser = parser;
parser._headers = [];
parser.onIncoming = parserOnIncomingClient;
- req.socket = socket;
- req.connection = socket;
req.parser = parser;
socket.on('error', socketOnError);
socket.on('data', socketOnData);
socket.on('end', socketOnEnd);
socket.on('close', socketOnClose);
- socket.on('lookup', socketOnLookup);
// socket emitted when a socket is assigned to req
process.nextTick(function() {
if (err) {
var host;
- if (host = req.getHeader('host')) {
+ if ((host = req.getHeader('host'))) {
err.message += ': ' + (host ? host : '');
}
req.emit('error', err);
function socketOnClose() {
var socket = this;
var req = socket._httpMessage;
- var parser = socket.parser;
-
- socket.read();
req.emit('close');
emitError(this, err);
}
-function socketOnLookup(err, ip, family) {
- emitError(this, err);
-}
-
function socketOnData(d) {
var socket = this;
var req = this._httpMessage;
// This is called by parserOnHeadersComplete after response header is parsed.
// TODO: keepalive support
-function parserOnIncomingClient(res, shouldKeepAlive) {
+function parserOnIncomingClient(res/* , shouldKeepAlive */) {
var socket = this.socket;
var req = socket._httpMessage;
}
};
+ClientRequest.prototype.abort = function() {
+ this.emit('abort');
+ if (this.socket) {
+ cleanUpSocket(this.socket);
+ }
+};
ClientRequest.prototype.setTimeout = function(ms, cb) {
var self = this;
if (cb) self.once('timeout', cb);
- var emitTimeout = function() {
+ setTimeout(function() {
self.emit('timeout');
- };
-
- // In IoT.js, socket is already assigned,
- // thus, it is sufficient to trigger timeout on socket 'connect' event.
- this.socket.once('connect', function() {
- self.socket.setTimeout(ms, emitTimeout);
- });
-
+ }, ms);
};
var util = require('util');
var IncomingMessage = require('http_incoming').IncomingMessage;
-var HTTPParser = require('httpparser').HTTPParser;
+var HTTPParser = require('http_parser').HTTPParser;
var createHTTPParser = function() {
// REQUEST is the default type.
stream.Readable.call(this);
this.socket = socket;
- this.connection = socket;
this.readable = true;
this.finished = false;
this._sentHeader = false;
+ this._connected = false;
+
+ // storage for chunks when there is no connection established
+ this._chunks = [];
this.socket = null;
- this.connection = null;
// response header string : same 'content' as this._headers
this._header = null;
// response header obj : (key, value) pairs
this.finished = true;
- this._finish();
+ this.emit('prefinish');
return true;
};
-OutgoingMessage.prototype._finish = function() {
- this.emit('prefinish');
-};
-
-
// This sends chunk directly into socket
-// TODO: buffering of chunk in the case of socket is not available
OutgoingMessage.prototype._send = function(chunk, encoding, callback) {
if (util.isFunction(encoding)) {
callback = encoding;
this._sentHeader = true;
}
- return this.connection.write(chunk, encoding, callback);
+ if (!this._connected) {
+ this._chunks.push(chunk);
+ return false;
+ } else {
+ while (this._chunks.length) {
+ this.socket.write(this._chunks.shift(), encoding, callback);
+ }
+ }
+
+ if (this.socket) {
+ return this.socket.write(chunk, encoding, callback);
+ }
+
+ return false;
};
return true;
}
- var ret = this._send(chunk, encoding, callback);
-
- return ret;
-
+ return this._send(chunk, encoding, callback);
};
OutgoingMessage.prototype.setTimeout = function(ms, cb) {
- if (cb)
+ if (cb) {
this.once('timeout', cb);
+ }
if (!this.socket) {
this.once('socket', function(socket) {
- socket.setTimeout(msecs);
+ socket.setTimeout(ms);
});
- } else
- this.socket.setTimeout(msecs);
+ } else {
+ this.socket.setTimeout(ms);
+ }
};
*/
var util = require('util');
-var net = require('net');
var OutgoingMessage = require('http_outgoing').OutgoingMessage;
var common = require('http_common');
ServerResponse.prototype.assignSocket = function(socket) {
+ this._connected = true;
socket._httpMessage = this;
this.socket = socket;
- this.connection = socket;
socket.on('close', onServerResponseClose);
this.emit('socket', socket);
};
ServerResponse.prototype.detachSocket = function() {
this.socket._httpMessage = null;
- this.socket = this.connection = null;
+ this.socket = null;
+ this._connected = false;
};
-function Server(requestListener) {
- if (!(this instanceof Server)) {
- return new Server(requestListener);
- }
-
- net.Server.call(this, {allowHalfOpen: true});
-
+function initServer(options, requestListener) {
if (util.isFunction(requestListener)) {
this.addListener('request', requestListener);
}
this.httpAllowHalfOpen = false;
- this.on('connection', connectionListener);
this.on('clientError', function(err, conn) {
conn.destroy(err);
});
this.timeout = 2 * 1000 * 60; // default timeout is 2 min
}
-util.inherits(Server, net.Server);
-exports.Server = Server;
-
-
-// TODO: Implement Server.prototype.setTimeout function
-// For this, socket.prototype.setTimeout is needed.
-Server.prototype.setTimeout = function(ms, cb) {
- this.timeout = ms;
- if (cb) {
- this.on('timeout', cb);
- }
-};
-
+exports.initServer = initServer;
function connectionListener(socket) {
var server = this;
}
}
+exports.connectionListener = connectionListener;
function socketOnData(data) {
var socket = this;
// This is called by parserOnHeadersComplete after req header is parsed.
// TODO: keepalive support
-function parserOnIncoming(req, shouldKeepAlive) {
+function parserOnIncoming(req/* , shouldKeepAlive */) {
var socket = req.socket;
var server = socket._server;
* limitations under the License.
*/
-var client = require('https_client');
+var tls = require('tls');
+var net = require('net');
+var ClientRequest = require('http_client').ClientRequest;
+var HTTPParser = require('http_parser');
+var HTTPServer = require('http_server');
+var util = require('util');
-var ClientRequest = exports.ClientRequest = client.ClientRequest;
+exports.ClientRequest = ClientRequest;
exports.request = function(options, cb) {
- return new ClientRequest(options, cb);
+ options.port = options.port || 443;
+ // Create socket.
+ var socket = new tls.TLSSocket(new net.Socket(), options);
+
+ return new ClientRequest(options, cb, socket);
+};
+
+function Server(options, requestListener) {
+ if (!(this instanceof Server)) {
+ return new Server(options, requestListener);
+ }
+ options.allowHalfOpen = true;
+ tls.Server.call(this, options, HTTPServer.connectionListener);
+
+ HTTPServer.initServer.call(this, options, requestListener);
+}
+util.inherits(Server, tls.Server);
+
+Server.prototype.setTimeout = function(ms, cb) {
+ this.timeout = ms;
+ if (cb) {
+ this.on('timeout', cb);
+ }
+};
+
+exports.createServer = function(options, requestListener) {
+ return new Server(options, requestListener);
};
-exports.METHODS = client.METHODS;
+exports.METHODS = HTTPParser.methods;
exports.get = function(options, cb) {
var req = exports.request(options, cb);
+++ /dev/null
-/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var util = require('util');
-var incoming = require('https_incoming');
-var stream = require('stream');
-var Buffer = require('buffer');
-var httpsNative = require('https_native');
-
-var methods = {'0': 'DELETE', '1': 'GET', '2': 'HEAD', '3': 'POST',
- '4': 'PUT', '5': 'CONNECT', '6': 'OPTIONS', '7': 'TRACE'};
-exports.METHODS = methods;
-
-function ClientRequest(options, cb) {
- this.stream = stream.Writable.call(this, options);
-
- // get port, host and method.
- var port = options.port = options.port || 443;
- var host = options.host = options.hostname || options.host || '127.0.0.1';
- var path = options.path || '/';
- var protocol = options.protocol || 'https:';
-
- this.host = protocol + '//' + host + ':' + port + path;
- this.method = options.method || 'GET';
- this.ca = options.ca || '';
- this.cert = options.cert || '';
- this.key = options.key || '';
-
- if (options.rejectUnauthorized == null) {
- this.rejectUnauthorized = true;
- } else {
- this.rejectUnauthorized = options.rejectUnauthorized;
- }
-
- var isMethodGood = false;
- for (var key in methods) {
- if (methods.hasOwnProperty(key)) {
- if (this.method === methods[key]) {
- isMethodGood = true;
- break;
- }
- }
- }
-
- if (!isMethodGood) {
- var err = new Error('Incorrect options.method.');
- this.emit('error', err);
- return;
- }
-
- this._incoming = new incoming.IncomingMessage(this);
- this._incoming.url = this.host;
- this._incoming.method = this.method;
- this.aborted = null;
-
- // Register response event handler.
- if (cb) {
- this.once('response', cb);
- }
- this.once('finish', this.onFinish);
-
- httpsNative.createRequest(this);
-
- if (options.auth) {
- var headerString = 'Authorization: Basic ' + toBase64(options.auth);
- httpsNative.addHeader(headerString, this);
- }
- if (options.headers) {
- var keys = Object.keys(options.headers);
- for (var i = 0, l = keys.length; i < l; i++) {
- var key = keys[i];
- httpsNative.addHeader(key + ': ' + options.headers[key], this);
- }
- }
- httpsNative.sendRequest(this);
-}
-
-util.inherits(ClientRequest, stream.Writable);
-
-// Concrete stream overriding the empty underlying _write method.
-ClientRequest.prototype._write = function(chunk, callback, onwrite) {
- httpsNative._write(this, chunk.toString(), callback, onwrite);
-};
-
-ClientRequest.prototype.headersComplete = function() {
- var self = this;
- self.emit('response', self._incoming);
- return (self.method == 'HEAD');
-};
-
-ClientRequest.prototype.onError = function(ret) {
- this.emit('error', ret);
-};
-
-ClientRequest.prototype.onFinish = function() {
- httpsNative.finishRequest(this);
-};
-
-ClientRequest.prototype.setTimeout = function(ms, cb) {
- this._incoming.setTimeout(ms, cb);
-};
-
-ClientRequest.prototype.abort = function(doNotEmit) {
- if (!this.aborted) {
- httpsNative.abort(this);
- var date = new Date();
- this.aborted = date.getTime();
-
- if (this._incoming.parser) {
- this._incoming.parser.finish();
- this._incoming.parser = null;
- }
-
- if (!doNotEmit) {
- this.emit('abort');
- }
- }
-};
-
-exports.ClientRequest = ClientRequest;
-
-function toBase64(input) {
- var output = '';
- var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
- var i = 0;
- // Convert to UTF-8
- input = Buffer(input).toString();
- var _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' +
- '0123456789+/=';
- while (i < input.length) {
- chr1 = input.charCodeAt(i++);
- chr2 = input.charCodeAt(i++);
- chr3 = input.charCodeAt(i++);
-
- enc1 = chr1 >> 2;
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
- enc4 = chr3 & 63;
-
- if (isNaN(chr2)) {
- enc3 = enc4 = 64;
- } else if (isNaN(chr3)) {
- enc4 = 64;
- }
-
- output = output +
- _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
- _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
- }
- return output;
-}
+++ /dev/null
-/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var util = require('util');
-var stream = require('stream');
-var Buffer = require('buffer');
-var httpsNative = require('https_native');
-var HTTPParser = require('httpparser').HTTPParser;
-
-function IncomingMessage(clientRequest) {
- stream.Readable.call(this);
- this.clientRequest = clientRequest;
-
- this.headers = {};
- this.started = false;
- this.completed = false;
- this.timeoutCallback = null;
- // for response (client)
- this.statusCode = null;
- this.statusMessage = null;
- this.url = null;
- this.method = null;
-
- this.parser = createHTTPParser(this);
-
- this.onData = cbOnData;
- this.onClosed = cbOnClosed;
- this.onEnd = cbOnEnd;
- this.onError = cbOnError;
- this.onSocket = cbOnSocket;
- this.onTimeout = cbOnTimeout;
- this.onWritable = cbOnWritable;
-}
-
-util.inherits(IncomingMessage, stream.Readable);
-exports.IncomingMessage = IncomingMessage;
-
-IncomingMessage.prototype.read = function(n) {
- this.read = stream.Readable.prototype.read;
- return this.read(n);
-};
-
-IncomingMessage.prototype.setTimeout = function(ms, cb) {
- if (cb) {
- this.timeoutCallback = cb;
- this.once('timeout', cb);
- }
- httpsNative.setTimeout(ms, this.clientRequest);
-};
-
-IncomingMessage.prototype.addHeaders = function(headers) {
- if (!this.headers) {
- this.headers = {};
- }
- if (!headers) {
- return;
- }
-
- for (var i = 0; i < headers.length; i = i + 2) {
- this.headers[headers[i]] = headers[i + 1];
- }
-};
-
-// HTTP PARSER Constructor
-var createHTTPParser = function(incoming) {
- var parser = new HTTPParser(HTTPParser.RESPONSE);
- parser.incoming = incoming;
- // cb during http parsing from C side(http_parser)
- parser.OnHeaders = parserOnHeaders;
- parser.OnHeadersComplete = parserOnHeadersComplete;
- parser.OnBody = parserOnBody;
- parser.OnMessageComplete = parserOnMessageComplete;
- return parser;
-};
-
-// ------------- HTTP PARSER CALLBACKS -------------
-// This is called when http header is fragmented and
-// HTTPParser sends it to JS in separate pieces.
-function parserOnHeaders(headers, url) {
- var parser = this;
- parser.incoming.addHeaders(headers);
-}
-
-// This is called when header part in http msg is parsed.
-function parserOnHeadersComplete(info) {
- var parser = this;
- var headers = info.headers;
-
- if (!headers) {
- headers = parser._headers;
- parser.incoming.addHeaders(headers);
- parser._headers = {};
- } else {
- parser.incoming.addHeaders(headers);
- }
-
- // add header fields of headers to incoming.headers
- parser.incoming.addHeaders(headers);
- parser.incoming.statusCode = info.status;
- parser.incoming.statusMessage = info.status_msg;
- parser.incoming.started = true;
-
- // For client side, if response to 'HEAD' request, we will skip parsing body
- if (parser.incoming.statusCode == 100) {
- return false;
- }
- return parser.incoming.clientRequest.headersComplete();
-}
-
-// parserOnBody is called when HTTPParser parses http msg(incoming) and
-// get body part(buf from start at length of len)
-function parserOnBody(buf, start, len) {
- var parser = this;
- var incoming = parser.incoming;
-
- if (!incoming) {
- return;
- }
-
- // Push body part into incoming stream, which will emit 'data' event
- var body = buf.slice(start, start + len);
- incoming.push(body);
-}
-
-// This is called when parsing of incoming http msg done
-function parserOnMessageComplete() {
- var parser = this;
- var incoming = parser.incoming;
-
- if (incoming) {
- if (incoming.statusCode == 100) {
- incoming.headers = {};
- incoming.statusCode = null;
- incoming.statusMessage = null;
- incoming.started = false;
- } else {
- incoming.completed = true;
- // no more data from incoming, stream will emit 'end' event
- incoming.push(null);
- }
- }
-}
-
-// ------------ LIBCURL PARSER CALLBACKS -----------------
-// Called by libcurl when Request is Done. Finish parser and unref
-function cbOnEnd() {
- var incoming = this;
- var parser = incoming.parser;
- if (parser) {
- // Unref all links to parser, make parser GCed
- parser.finish();
- parser = null;
- incoming.parser = null;
- }
-}
-
-function cbOnClosed() {
- var incoming = this;
- var parser = incoming.parser;
- var clientRequest = incoming.clientRequest;
-
- if (incoming.started && !incoming.completed) {
- // Socket closed before we emitted 'end'
- incoming.on('end', function() {
- incoming.emit('close');
- clientRequest.emit('close');
- });
- incoming.push(null);
- } else if (!incoming.started) {
- incoming.emit('close');
- clientRequest.emit('close');
- // Socket closed before response starts.
- var err = new Error('Could Not Start Connection');
- clientRequest.onError(err);
- } else {
- clientRequest.emit('close');
- }
-
- if (parser) {
- // Unref all links to parser, make parser GCed
- parser.finish();
- parser = null;
- incoming.parser = null;
- }
-}
-
-// Called by libcurl when Request is Done. Finish parser and unref
-function cbOnData(chunk) {
- var incoming = this;
-
- if (!incoming) {
- return false;
- }
-
- var parser = incoming.parser;
- var clientRequest = incoming.clientRequest;
-
- chunk = new Buffer(chunk);
- var ret = parser.execute(chunk);
-
- if (ret instanceof Error) {
- parser.finish();
- // Unref all links to parser, make parser GCed
- parser = null;
- clientRequest.onError(ret);
- return false;
- }
- return true;
-}
-
-function cbOnError(er) {
- var incoming = this;
- var clientRequest = incoming.clientRequest;
- var err = new Error(er);
- clientRequest.onError(err);
- clientRequest.abort(true);
- incoming.emit('error', err);
-}
-
-function cbOnTimeout() {
- var incoming = this;
- var clientRequest = incoming.clientRequest;
- incoming.emit('timeout');
- if (!incoming.timeoutCallback) {
- clientRequest.abort.call(clientRequest, false);
- }
- incoming.emit('aborted');
-}
-
-function cbOnSocket() {
- var incoming = this;
- var clientRequest = incoming.clientRequest;
- clientRequest.emit('socket');
-}
-
-function cbOnWritable() {
- var incoming = this;
- var clientRequest = incoming.clientRequest;
- clientRequest._readyToWrite();
-}
}
} else {
// Exit if there are no handler for uncaught exception.
- console.error('uncaughtException: ' + error);
+ console.error(error);
+ if (Array.isArray(error.stack)) {
+ error.stack.forEach(function(line) {
+ console.log(' at ' + line);
+ });
+ }
+
process.exit(1);
}
}
process.exitCode = 0;
process._exiting = false;
process.emitExit = function(code) {
+ if (typeof code !== 'number') {
+ code = 0;
+ }
if (!process._exiting) {
process._exiting = true;
if (code || code == 0) {
process.exitCode = code;
}
- process.emit('exit', process.exitCode || 0);
+ process.emit('exit', process.exitCode);
}
};
process.exit = function(code) {
- try {
- process.emitExit(code);
- } catch (e) {
- process.exitCode = 1;
- process._onUncaughtException(e);
- } finally {
- process.doExit(process.exitCode || 0);
+ if (!process._exiting) {
+ try {
+ process.emitExit(code);
+ } catch (e) {
+ process.exitCode = 1;
+ process._onUncaughtException(e);
+ } finally {
+ process.doExit(process.exitCode);
+ }
}
};
var Native = require('native');
var fs = Native.require('fs');
-function iotjs_module_t(id, parent) {
+function Module(id, parent) {
this.id = id;
this.exports = {};
this.filename = null;
this.parent = parent;
}
-module.exports = iotjs_module_t;
+module.exports = Module;
-iotjs_module_t.cache = {};
-iotjs_module_t.remoteCache = {};
+Module.cache = {};
+// Cache to store not yet compiled remote modules
+Module.remoteCache = {};
var cwd;
moduledirs.push(cwd + '/');
moduledirs.push(cwd + '/iotjs_modules/');
}
+
if (process.env.HOME) {
moduledirs.push(process.env.HOME + '/iotjs_modules/');
}
+
if (process.env.IOTJS_PATH) {
moduledirs.push(process.env.IOTJS_PATH + '/iotjs_modules/');
}
+if (process.env.IOTJS_EXTRA_MODULE_PATH) {
+ var extra_paths = process.env.IOTJS_EXTRA_MODULE_PATH.split(':');
+ extra_paths.forEach(function(path) {
+ if (path.slice(-1) !== '/') {
+ path += '/';
+ }
+ moduledirs.push(path);
+ });
+}
+
+var dynamicloader = Native.require('dynamicloader');
+
function tryPath(modulePath, ext) {
- return iotjs_module_t.tryPath(modulePath) ||
- iotjs_module_t.tryPath(modulePath + ext);
+ return Module.tryPath(modulePath) ||
+ Module.tryPath(modulePath + ext);
}
-iotjs_module_t.resolveDirectories = function(id, parent) {
+Module.resolveDirectories = function(id, parent) {
var dirs = moduledirs;
if (parent) {
if (!parent.dirs) {
};
-iotjs_module_t.resolveFilepath = function(id, directories) {
+Module.resolveFilepath = function(id, directories) {
for (var i = 0; i < directories.length; i++) {
var dir = directories[i];
var modulePath = dir + id;
modulePath = process.cwd() + '/' + modulePath;
}
- if (process.platform === 'tizenrt' &&
+ if ((process.platform === 'tizenrt' || process.platform === 'nuttx') &&
(modulePath.indexOf('../') != -1 || modulePath.indexOf('./') != -1)) {
- modulePath = iotjs_module_t.normalizePath(modulePath);
+ modulePath = Module.normalizePath(modulePath);
}
var filepath,
ext = '.js';
// id[.ext]
- if (filepath = tryPath(modulePath, ext)) {
+ if ((filepath = tryPath(modulePath, ext))) {
return filepath;
}
// 3. package path id/
var jsonpath = modulePath + '/package.json';
- filepath = iotjs_module_t.tryPath(jsonpath);
- if (filepath) {
+
+ if (Module.tryPath(jsonpath)) {
var pkgSrc = process.readSource(jsonpath);
var pkgMainFile = JSON.parse(pkgSrc).main;
// pkgmain[.ext]
- if (filepath = tryPath(modulePath + '/' + pkgMainFile, ext)) {
+ if (pkgMainFile &&
+ (filepath = tryPath(modulePath + '/' + pkgMainFile, ext))) {
return filepath;
}
+ }
- // index[.ext] as default
- if (filepath = tryPath(modulePath + '/index', ext)) {
- return filepath;
- }
+ // index[.ext] as default
+ if ((filepath = tryPath(modulePath + '/index', ext))) {
+ return filepath;
}
+ // id[.iotjs]
+ if (dynamicloader && (filepath = tryPath(modulePath, '.iotjs'))) {
+ return filepath;
+ }
}
return false;
};
-iotjs_module_t.resolveModPath = function(id, parent) {
+Module.resolveModPath = function(id, parent) {
if (parent != null && id === parent.id) {
return false;
}
// 0. resolve Directory for lookup
- var directories = iotjs_module_t.resolveDirectories(id, parent);
+ var directories = Module.resolveDirectories(id, parent);
- var filepath = iotjs_module_t.resolveFilepath(id, directories);
+ var filepath = Module.resolveFilepath(id, directories);
if (filepath) {
- return iotjs_module_t.normalizePath(filepath);
+ return Module.normalizePath(filepath);
}
return false;
};
-iotjs_module_t.normalizePath = function(path) {
+Module.normalizePath = function(path) {
var beginning = '';
if (path.indexOf('/') === 0) {
beginning = '/';
};
-iotjs_module_t.tryPath = function(path) {
+Module.tryPath = function(path) {
try {
var stats = fs.statSync(path);
if (stats && !stats.isDirectory()) {
};
-iotjs_module_t.load = function(id, parent) {
+Module.load = function(id, parent) {
if (process.builtin_modules[id]) {
return Native.require(id);
}
- var module = new iotjs_module_t(id, parent);
- var modPath = iotjs_module_t.resolveModPath(module.id, module.parent);
- var cachedModule = iotjs_module_t.cache[modPath];
+ if (Module.remoteCache[id]) {
+ Module.compileRemoteSource(id, Module.remoteCache[id]);
+ delete Module.remoteCache[id];
+ return Module.cache[id].exports;
+ }
+
+ var module = new Module(id, parent);
+ var modPath = Module.resolveModPath(module.id, module.parent);
+ var cachedModule = Module.cache[modPath];
if (cachedModule) {
return cachedModule.exports;
module.filename = modPath;
module.dirs = [modPath.substring(0, modPath.lastIndexOf('/') + 1)];
+ Module.cache[modPath] = module;
+
var ext = modPath.substr(modPath.lastIndexOf('.') + 1);
- var source = process.readSource(modPath);
+ var source;
if (ext === 'js') {
+ source = process.readSource(modPath);
module.compile(modPath, source);
} else if (ext === 'json') {
+ source = process.readSource(modPath);
module.exports = JSON.parse(source);
+ } else if (dynamicloader && ext === 'iotjs') {
+ module.exports = dynamicloader(modPath);
}
- iotjs_module_t.cache[modPath] = module;
+ Module.cache[modPath] = module;
return module.exports;
};
-iotjs_module_t.loadRemote = function(filename, source) {
- var module = new iotjs_module_t(filename, null);
- var cachedModule = iotjs_module_t.cache[filename];
+Module.compileRemoteSource = function(filename, source) {
+ var module = new Module(filename, null);
+ var cachedModule = Module.cache[filename];
if (cachedModule) {
return cachedModule.exports;
module.filename = filename;
module.compile(filename, source);
- iotjs_module_t.remoteCache[filename] = module;
+ Module.cache[filename] = module;
return module.exports;
};
-iotjs_module_t.prototype.compile = function(filename, source) {
+Module.prototype.compile = function(filename, source) {
var fn = process.compile(filename, source);
fn.call(this.exports, this.exports, this.require.bind(this), this);
};
-iotjs_module_t.runMain = function() {
+Module.runMain = function() {
if (process.debuggerWaitSource) {
- var fn = process.debuggerGetSource();
- fn.forEach(function (e) {
- iotjs_module_t.loadRemote(e[0], e[1]);
+ var sources = process.debuggerGetSource();
+ sources.forEach(function(rModule) {
+ Module.remoteCache[rModule[0]] = rModule[1];
});
+ // Name of the first module
+ var fModName = sources[sources.length - 1][0];
+ Module.compileRemoteSource(fModName, Module.remoteCache[fModName]);
} else {
- iotjs_module_t.load(process.argv[1], null);
+ Module.load(process.argv[1], null);
}
while (process._onNextTick());
};
-iotjs_module_t.prototype.require = function(id) {
- return iotjs_module_t.load(id, this);
+Module.prototype.require = function(id) {
+ return Module.load(id, this);
};
var stream = require('stream');
var util = require('util');
var assert = require('assert');
-var tcp = require('tcp');
+var Tcp = require('tcp');
function createTCP() {
- var _tcp = new tcp();
+ var _tcp = new Tcp();
return _tcp;
}
} else {
socket.destroy();
emitError(socket, new Error('connect failed - status: ' +
- tcp.errname(status)));
+ Tcp.errname(status)));
}
};
var err = socket._handle.connect(ip, port, afterConnect);
if (err) {
emitError(socket, new Error('connect failed - status: ' +
- tcp.errname(err)));
+ Tcp.errname(err)));
}
}
return self.destroy();
} else {
// Readable stream alive, shutdown only outgoing stream.
- var err = self._handle.shutdown(function() {
+ self._handle.shutdown(function() {
if (self._readableState.ended) {
self.destroy();
}
self._handle.createTCP = createTCP;
self._handle.owner = self;
- var err = self._handle.listen(backlog);
+ err = self._handle.listen(backlog);
if (err) {
self._handle.close();
var server = this.owner;
if (status) {
- server.emit('error', new Error('accept error: ' + tcp.errname(status)));
+ server.emit('error', new Error('accept error: ' + Tcp.errname(status)));
return;
}
},
openSync: function(config) {
return new native(config);
- }
+ },
};
module.exports = pwm;
},
MODE: native.MODE,
CHIPSELECT: native.CHIPSELECT,
- BITORDER: native.BITORDER
+ BITORDER: native.BITORDER,
};
module.exports = spi;
*/
-var eventEmitter = require('events').EventEmitter;
+var StreamInternal = require('stream_internal');
var util = require('util');
function Stream() {
- eventEmitter.call(this);
+ StreamInternal.call(this);
}
-
-util.inherits(Stream, eventEmitter);
-
+util.inherits(Stream, StreamInternal);
exports.Stream = Stream;
}
Readable.call(this, options);
+ options = options || {};
+ options._isDuplex = true;
Writable.call(this, options);
}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var eventEmitter = require('events').EventEmitter;
+var util = require('util');
+
+
+function Stream() {
+ eventEmitter.call(this);
+}
+
+util.inherits(Stream, eventEmitter);
+
+module.exports = Stream;
*/
-var Stream = require('stream').Stream;
+var Stream = require('stream_internal');
var util = require('util');
-var assert = require('assert');
function ReadableState(options) {
res = null;
}
- if (state.ended && state.length == 0) {
- emitEnd(this);
- }
-
return res;
};
var state = this._readableState;
if (!state.flowing) {
state.flowing = true;
- if (state.length > 0) {
- emitData(this, readBuffer(this));
- }
+ this.read();
}
return this;
};
res = Buffer.concat(state.buffer);
state.buffer = [];
state.length = 0;
+ emitData(stream, res);
} else {
throw new Error('not implemented');
}
function emitData(stream, data) {
var state = stream._readableState;
- assert.equal(readBuffer(stream), null);
- stream.emit('data', data);
+ if (state.buffer.length === 0 || state.length === 0) {
+ stream.emit('data', data);
+ }
if (state.ended && state.length == 0) {
emitEnd(stream);
*/
-var stream = require('stream');
+var Stream = require('stream_internal');
var util = require('util');
-var Stream = stream.Stream;
-var Duplex = stream.Duplex;
var defaultHighWaterMark = 128;
this.length = 0;
// high water mark.
- // The point where write() starts retuning false.
+ // The point where write() starts returning false.
this.highWaterMark = (options && util.isNumber(options.highWaterMark)) ?
options.highWaterMark : defaultHighWaterMark;
function Writable(options) {
- if (!(this instanceof Writable) && !(this instanceof stream.Duplex)) {
+ if (!(this instanceof Writable) && options._isDuplex !== true) {
return new Writable(options);
}
// This function object never to be called. concrete stream should override
// this method.
-Writable.prototype._write = function(chunk, callback, onwrite) {
+Writable.prototype._write = function(/* chunk, callback, onwrite */) {
throw new Error('unreachable');
};
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var Bridge = require('bridge');
+var EventEmitter = require('events').EventEmitter;
+var util = require('util');
+
+var APP_CONTROL_EVENT_TYPE = 'appControl';
+
+var BUNDLE_KEY_OPERATION = '__APP_SVC_OP_TYPE__';
+var BUNDLE_KEY_URI = '__APP_SVC_URI__';
+var BUNDLE_KEY_MIME = '__APP_SVC_MIME_TYPE__';
+var BUNDLE_KEY_LAUNCH_MODE = '__APP_SVC_LAUNCH_MODE__';
+var BUNDLE_KEY_CATEGORY = '__APP_SVC_CATEGORY__';
+var BUNDLE_KEY_PACKAGE = '__APP_SVC_PKG_NAME__';
+
+var bridge = new Bridge(native.MODULE_NAME);
+
+var startsWith = function(searchString, position) {
+ position = position || 0;
+ return this.substr(position, searchString.length) === searchString;
+};
+
+
+function ApplicationControl(bundle) {
+ if (!util.isObject(bundle)) {
+ return this;
+ }
+
+ this.operation = bundle[BUNDLE_KEY_OPERATION];
+ this.uri = bundle[BUNDLE_KEY_URI];
+ this.mime = bundle[BUNDLE_KEY_MIME];
+ this.launch_mode = bundle[BUNDLE_KEY_LAUNCH_MODE];
+ this.category = bundle[BUNDLE_KEY_CATEGORY];
+ this.app_id = bundle[BUNDLE_KEY_PACKAGE];
+
+ var extra_data = {};
+ for (var prop in bundle) {
+ if (bundle.hasOwnProperty(prop) && !startsWith.call(prop, '__')) {
+ extra_data[prop] = bundle[prop];
+ }
+ }
+ this.extra_data = Object.keys(extra_data).length ? extra_data : undefined;
+
+ return this;
+}
+
+
+function Bundle(appcontrol) {
+ if (!util.isObject(appcontrol)) {
+ return this;
+ }
+
+ var bundle = this;
+
+ if (util.isString(appcontrol.operation)) {
+ bundle[BUNDLE_KEY_OPERATION] = appcontrol.operation;
+ }
+
+ if (util.isString(appcontrol.uri)) {
+ bundle[BUNDLE_KEY_URI] = appcontrol.uri;
+ }
+
+ if (util.isString(appcontrol.mime)) {
+ bundle[BUNDLE_KEY_MIME] = appcontrol.mime;
+ }
+
+ if (util.isString(appcontrol.launch_mode)) {
+ if (appcontrol.launch_mode === 'group' ||
+ appcontrol.launch_mode === 'single') {
+ bundle[BUNDLE_KEY_LAUNCH_MODE] = appcontrol.launch_mode;
+ }
+ }
+
+ if (util.isString(appcontrol.category)) {
+ bundle[BUNDLE_KEY_CATEGORY] = appcontrol.category;
+ }
+
+ if (util.isString(appcontrol.app_id)) {
+ bundle[BUNDLE_KEY_PACKAGE] = appcontrol.app_id;
+ }
+
+ var extra_data = appcontrol.extra_data;
+ if (util.isObject(extra_data)) {
+ for (var prop in extra_data) {
+ if (extra_data.hasOwnProperty(prop)) {
+ // a bundle is a dictionary which consists of key and value pairs
+ bundle[prop] = extra_data[prop].toString();
+ }
+ }
+ }
+
+ return this;
+}
+
+
+function on(type, listener) {
+ var callback = listener;
+
+ if (type === APP_CONTROL_EVENT_TYPE) {
+ // replace callback for application control
+ callback = function(msg) {
+ if (util.isString(msg)) {
+ try {
+ var json = JSON.parse(msg);
+ listener(new ApplicationControl(json));
+ } catch (e) {
+ return; // ignore msg. data should be a json string
+ }
+ }
+ };
+ }
+
+ return EventEmitter.prototype.on.call(this, type, callback);
+}
+
+
+function launchAppControl(option) {
+ var bundle = new Bundle(option);
+ return 'OK' === bridge.sendSync('launchAppControl', JSON.stringify(bundle));
+}
+
+
+var getResPath = function() {
+ return this.bridge.sendSync('getResPath', '');
+};
+
+
+module.exports = util.mixin(native, EventEmitter.prototype, {
+ launchAppControl: launchAppControl,
+ getResPath: getResPath,
+ on: on,
+});
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var net = require('net');
+var util = require('util');
+var EventEmitter = require('events').EventEmitter;
+
+function TLSSocket(socket, options) {
+ if (!(this instanceof TLSSocket)) {
+ return new TLSSocket(socket, options);
+ }
+
+ if ('_tlsSocket' in socket) {
+ throw Error('Socket already bound');
+ }
+
+ this._socket = socket;
+ socket._tlsSocket = this;
+
+ EventEmitter.call(this);
+
+ this.authorized = false;
+
+ this._socket.on('connect', this.onconnect);
+ this._socket.on('data', this.ondata);
+ this._socket.on('error', this.onerror);
+ this._socket.on('close', this.onclose);
+ this._socket.on('finish', this.onfinish);
+ this._socket.on('end', this.onend);
+
+ // Native handle
+ var secureContext = options.secureContext;
+ if (!secureContext) {
+ secureContext = createSecureContext(options);
+ }
+
+ native.TlsInit(this, options, secureContext);
+ this._socketState = socket._socketState;
+}
+util.inherits(TLSSocket, EventEmitter);
+
+TLSSocket.prototype._read = native.read;
+TLSSocket.prototype._write = native.write;
+TLSSocket.prototype._connect = native.connect;
+
+TLSSocket.prototype.connect = function(options, callback) {
+ this._connect(options.servername || options.host || 'localhost');
+
+ if (util.isFunction(callback)) {
+ this.on('secureConnect', callback);
+ }
+
+ this._socket.connect(options);
+};
+
+TLSSocket.prototype.write = function(data, callback) {
+ if (!Buffer.isBuffer(data)) {
+ data = new Buffer(data);
+ }
+
+ data = this._write(data);
+ return this._socket.write(data, callback);
+};
+
+TLSSocket.prototype.pause = function() {
+ this._socket.pause();
+};
+
+TLSSocket.prototype.resume = function() {
+ this._socket.resume();
+};
+
+TLSSocket.prototype.end = function(data, callback) {
+ if (data) {
+ if (!Buffer.isBuffer(data)) {
+ data = new Buffer(data);
+ }
+ data = this._write(data, true);
+ } else {
+ data = this._write(null, true);
+ }
+
+ this._socket.end(data, callback);
+};
+
+TLSSocket.prototype.destroy = function() {
+ this._socket.destroy();
+};
+
+TLSSocket.prototype.destroySoon = function() {
+ this._socket.destroySoon();
+};
+
+TLSSocket.prototype.onconnect = function() {
+ var self = this._tlsSocket;
+ self._read(null);
+};
+
+TLSSocket.prototype.encrypted = function() {
+ return true;
+};
+
+TLSSocket.prototype.address = function() {
+ return this._socket.address();
+};
+
+TLSSocket.prototype.localAddress = function() {
+ return this._socket.address().address;
+};
+
+TLSSocket.prototype.setTimeout = function(msecs, callback) {
+ return this._socket.setTimeout(msecs, callback);
+};
+
+TLSSocket.prototype.ondata = function(data) {
+ var self = this._tlsSocket;
+ self._read(data);
+};
+
+TLSSocket.prototype.onerror = function(error) {
+ this._tlsSocket.emit('error', error);
+};
+
+TLSSocket.prototype.onclose = function() {
+ this._tlsSocket.emit('close');
+};
+
+TLSSocket.prototype.onfinish = function() {
+ this._tlsSocket.emit('finish');
+};
+
+TLSSocket.prototype.onend = function() {
+ this._tlsSocket.emit('end');
+};
+
+TLSSocket.prototype.onwrite = function(data) {
+ return this._socket.write(data);
+};
+
+TLSSocket.prototype.onread = function(chunk) {
+ this.emit('data', chunk);
+};
+
+TLSSocket.prototype.onhandshakedone = function(error, authorized) {
+ this.authorized = authorized;
+
+ var server = this._server;
+
+ if (error) {
+ error = Error('handshake failed');
+
+ if (server) {
+ server.emit('tlsClientError', error, this);
+ } else {
+ this.emit('error', error);
+ }
+ this.end();
+ return;
+ }
+
+ if (server) {
+ server.emit('secureConnection', this);
+ } else {
+ this.emit('secureConnect');
+ }
+};
+
+function tlsConnectionListener(rawSocket) {
+ var tlsSocket = new TLSSocket(rawSocket, {
+ isServer: true,
+ secureContext: this._secureContext,
+ });
+
+ tlsSocket._server = this;
+}
+
+function Server(options, listener) {
+ if (!(this instanceof Server)) {
+ return new Server(options, listener);
+ }
+
+ this._secureContext = createSecureContext(options);
+
+ // constructor call
+ net.Server.call(this, options, tlsConnectionListener);
+
+ if (listener) {
+ this.on('secureConnection', listener);
+ }
+}
+util.inherits(Server, net.Server);
+
+function createSecureContext(options) {
+ return new native.TlsContext(options);
+}
+
+function createServer(options, secureConnectionListener) {
+ return new Server(options, secureConnectionListener);
+}
+
+function connect(arg0, arg1, arg2, callback) {
+ var options;
+ var tlsSocket;
+ if (typeof arg0 == 'object') {
+ options = Object.create(arg0, {
+ isServer: { value: false, enumerable: true },
+ });
+ options.host = options.host || 'localhost';
+ options.port = options.port || 443;
+ options.rejectUnauthorized = options.rejectUnauthorized || false;
+ callback = arg1;
+ } else if (typeof arg0 == 'number') {
+ if (typeof arg1 == 'string') {
+ if (typeof arg2 == 'object') {
+ options = Object.create(arg2, {
+ isServer: { value: false, enumerable: true },
+ });
+ options.port = arg0;
+ options.host = arg1;
+ options.rejectUnauthorized = options.rejectUnauthorized || false;
+ } else {
+ options = {
+ isServer: false,
+ rejectUnauthorized: false,
+ port: arg0,
+ host: arg1,
+ };
+ callback = arg2;
+ }
+ } else if (typeof arg1 == 'object') {
+ options = Object.create(arg1, {
+ isServer: { value: false, enumerable: true },
+ });
+ options.port = arg0;
+ options.host = options.host || 'localhost';
+ options.rejectUnauthorized = options.rejectUnauthorized || false;
+ callback = arg2;
+ } else {
+ options = {
+ isServer: false,
+ rejectUnauthorized: false,
+ host: 'localhost',
+ port: arg0,
+ };
+ callback = arg1;
+ }
+ }
+ tlsSocket = new TLSSocket(new net.Socket(), options);
+ tlsSocket.connect(options, callback);
+
+ return tlsSocket;
+}
+
+exports.TLSSocket = TLSSocket;
+exports.Server = Server;
+exports.createSecureContext = createSecureContext;
+exports.createServer = createServer;
+exports.connect = connect;
*/
var EventEmitter = require('events').EventEmitter;
+var util = require('util');
+
+util.mixin(native.prototype, EventEmitter.prototype);
var uart = {
open: function(config, callback) {
- for(var prop in EventEmitter.prototype) {
- native.prototype[prop] = EventEmitter.prototype[prop];
- }
var uartPort = new native(config, function(err) {
callback(err);
});
return uartPort;
},
openSync: function(config) {
- for(var prop in EventEmitter.prototype) {
- native.prototype[prop] = EventEmitter.prototype[prop];
- }
return new native(config);
},
};
}
+function mixin(target) {
+ if (isNullOrUndefined(target)) {
+ throw new TypeError('target cannot be null or undefined');
+ }
+
+ for (var i = 1; i < arguments.length; ++i) {
+ var source = arguments[i];
+ if (!isNullOrUndefined(source)) {
+ for (var prop in source) {
+ if (source.hasOwnProperty(prop)) {
+ target[prop] = source[prop];
+ }
+ }
+ }
+ }
+
+ return target;
+}
+
function format(s) {
+ var i;
if (!isString(s)) {
var arrs = [];
- for (var i = 0; i < arguments.length; ++i) {
+ for (i = 0; i < arguments.length; ++i) {
arrs.push(formatValue(arguments[i]));
}
return arrs.join(' ');
}
- var i = 1;
+ i = 1;
var args = arguments;
var arg_string;
var str = '';
exports.errnoException = errnoException;
exports.stringToNumber = stringToNumber;
exports.inherits = inherits;
+exports.mixin = mixin;
exports.format = format;
{
"modules": {
"iotjs_basic_modules": {
- "require": ["assert", "dns", "http", "net", "stream", "testdriver"]
+ "require": ["assert", "dns", "http", "net", "stream"]
},
"iotjs_core_modules": {
"require": ["buffer", "console", "events", "fs", "module", "process",
"native_files": ["modules/iotjs_module_adc.c"]
}
},
- "native_files": ["modules/iotjs_module_adc.c"],
+ "native_files": ["modules/iotjs_module_adc.c",
+ "modules/iotjs_module_periph_common.c"],
"init": "InitAdc",
"js_file": "js/adc.js"
},
"js_file": "js/dns.js",
"require": ["util"]
},
+ "dynamicloader": {
+ "native_files": ["modules/iotjs_module_dynamicloader.c"],
+ "init": "InitDynamicloader",
+ "external_libs": ["dl"]
+ },
"events": {
"js_file": "js/events.js",
"require": ["util"]
"native_files": ["modules/tizenrt/iotjs_module_gpio-tizenrt.c"]
}
},
- "native_files": ["modules/iotjs_module_gpio.c"],
+ "native_files": ["modules/iotjs_module_gpio.c",
+ "modules/iotjs_module_periph_common.c"],
"init": "InitGpio",
"js_file": "js/gpio.js"
},
"http": {
"js_file": "js/http.js",
"require": ["http_client", "http_common", "http_incoming",
- "http_outgoing", "http_server", "httpparser"]
+ "http_outgoing", "http_server", "http_parser"]
},
"http_client": {
"js_file": "js/http_client.js",
- "require": ["http_common", "http_outgoing", "httpparser", "net", "util"]
+ "require": ["http_common", "http_outgoing", "http_parser", "net", "util"]
},
"http_common": {
"js_file": "js/http_common.js",
- "require": ["http_incoming", "httpparser"]
+ "require": ["http_incoming", "http_parser"]
},
"http_incoming": {
"js_file": "js/http_incoming.js",
"js_file": "js/http_server.js",
"require": ["http_common", "http_outgoing", "net", "util"]
},
- "httpparser": {
- "native_files": ["modules/iotjs_module_httpparser.c"],
- "init": "InitHttpparser"
+ "http_parser": {
+ "native_files": ["modules/iotjs_module_http_parser.c"],
+ "init": "InitHttpParser"
},
"https": {
"js_file": "js/https.js",
- "require": ["https_client", "https_incoming", "https_native"],
- "external_libs": ["curl"]
- },
- "https_client": {
- "js_file": "js/https_client.js",
- "require": ["buffer", "https_incoming", "stream", "util"]
- },
- "https_incoming": {
- "js_file": "js/https_incoming.js",
- "require": ["buffer", "stream", "util"]
- },
- "https_native": {
- "native_files": ["modules/iotjs_module_https.c"],
- "init": "InitHttps"
+ "require": ["http_client", "http_parser", "http_server", "net", "tls"]
},
"i2c": {
"platforms": {
"native_files": ["modules/tizenrt/iotjs_module_i2c-tizenrt.c"]
}
},
- "native_files": ["modules/iotjs_module_i2c.c"],
+ "native_files": ["modules/iotjs_module_i2c.c",
+ "modules/iotjs_module_periph_common.c"],
"init": "InitI2c",
"js_file": "js/i2c.js"
},
"module": {
+ "platforms": {
+ "linux": {
+ "require": ["dynamicloader"]
+ },
+ "tizen": {
+ "require": ["dynamicloader"]
+ }
+ },
"js_file": "js/module.js",
"require": ["fs"]
},
"nuttx": {
"native_files": ["modules/nuttx/iotjs_module_pwm-nuttx.c"]
},
+ "tizen": {
+ "native_files": ["modules/tizen/iotjs_module_pwm-tizen.c"]
+ },
"tizenrt": {
"native_files": ["modules/tizenrt/iotjs_module_pwm-tizenrt.c"]
}
},
- "native_files": ["modules/iotjs_module_pwm.c"],
+ "native_files": ["modules/iotjs_module_pwm.c",
+ "modules/iotjs_module_periph_common.c"],
"init": "InitPwm",
"js_file": "js/pwm.js"
},
"nuttx": {
"native_files": ["modules/nuttx/iotjs_module_spi-nuttx.c"]
},
+ "tizen": {
+ "native_files": ["modules/tizen/iotjs_module_spi-tizen.c"]
+ },
"tizenrt": {
"native_files": ["modules/tizenrt/iotjs_module_spi-tizenrt.c"]
}
},
- "native_files": ["modules/iotjs_module_spi.c"],
+ "native_files": ["modules/iotjs_module_spi.c",
+ "modules/iotjs_module_periph_common.c"],
"init": "InitSpi",
"js_file": "js/spi.js"
},
},
"stream": {
"js_file": "js/stream.js",
- "require": ["events", "stream_duplex", "stream_readable",
+ "require": ["stream_duplex", "stream_internal", "stream_readable",
"stream_writable", "util"]
},
"stream_duplex": {
"js_file": "js/stream_duplex.js",
"require": ["stream_readable", "stream_writable", "util"]
},
+ "stream_internal": {
+ "js_file": "js/stream_internal.js",
+ "require": ["events", "util"]
+ },
"stream_readable": {
"js_file": "js/stream_readable.js",
"require": ["assert", "util"]
"native_files": ["modules/iotjs_module_tcp.c"],
"init": "InitTcp"
},
- "testdriver": {
- "native_files": ["modules/iotjs_module_testdriver.c"],
- "init": "InitTestdriver",
- "require": ["assert"]
- },
"timers": {
"native_files": ["modules/iotjs_module_timer.c"],
"init": "InitTimer",
"js_file": "js/timers.js",
"require": ["util"]
},
+ "tls": {
+ "native_files": ["modules/iotjs_module_tls.c"],
+ "init": "InitTls",
+ "js_file": "js/tls.js",
+ "cmakefile": "../cmake/mbedtls.cmake",
+ "require": ["net", "util"]
+ },
"uart": {
"platforms": {
"linux": {
"nuttx": {
"native_files": ["modules/nuttx/iotjs_module_uart-nuttx.c"]
},
+ "tizen": {
+ "native_files": ["modules/tizen/iotjs_module_uart-tizen.c"]
+ },
"tizenrt": {
"native_files": ["modules/tizenrt/iotjs_module_uart-tizenrt.c"]
}
},
- "native_files": ["modules/iotjs_module_uart.c"],
+ "native_files": ["modules/iotjs_module_uart.c",
+ "modules/iotjs_module_periph_common.c"],
"init": "InitUart",
"js_file": "js/uart.js",
"require": ["events"]
},
"util": {
"js_file": "js/util.js"
+ },
+ "bridge": {
+ "native_files": ["modules/iotjs_module_bridge.c"],
+ "init": "InitBridge",
+ "js_file": "js/bridge.js"
+ },
+ "tizen": {
+ "platforms": {
+ "tizen": {
+ "native_files": ["modules/tizen/iotjs_module_tizen-tizen.c"]
+ }
+ },
+ "native_files": ["modules/iotjs_module_tizen.c"],
+ "init": "InitTizen",
+ "js_file": "js/tizen.js",
+ "require": ["bridge", "events", "util"]
}
}
}
#include "iotjs_module_adc.h"
-static JNativeInfoType this_module_native_info = {.free_cb = NULL };
+IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE(adc);
+IOTJS_DEFINE_PERIPH_CREATE_FUNCTION(adc);
-static iotjs_adc_t* adc_create(const jerry_value_t jadc) {
- iotjs_adc_t* adc = IOTJS_ALLOC(iotjs_adc_t);
- iotjs_adc_create_platform_data(adc);
- adc->jobject = jadc;
- jerry_set_object_native_pointer(jadc, adc, &this_module_native_info);
-
- return adc;
-}
-
-
-static void adc_destroy(iotjs_adc_t* adc) {
+static void iotjs_adc_destroy(iotjs_adc_t* adc) {
iotjs_adc_destroy_platform_data(adc->platform_data);
IOTJS_RELEASE(adc);
}
-
-static iotjs_adc_reqwrap_t* adc_reqwrap_create(const jerry_value_t jcallback,
- iotjs_adc_t* adc, AdcOp op) {
- iotjs_adc_reqwrap_t* adc_reqwrap = IOTJS_ALLOC(iotjs_adc_reqwrap_t);
-
- iotjs_reqwrap_initialize(&adc_reqwrap->reqwrap, jcallback,
- (uv_req_t*)&adc_reqwrap->req);
-
- adc_reqwrap->req_data.op = op;
- adc_reqwrap->adc_data = adc;
- return adc_reqwrap;
-}
-
-static void adc_reqwrap_destroy(iotjs_adc_reqwrap_t* adc_reqwrap) {
- iotjs_reqwrap_destroy(&adc_reqwrap->reqwrap);
- IOTJS_RELEASE(adc_reqwrap);
-}
-
-
static void adc_worker(uv_work_t* work_req) {
- iotjs_adc_reqwrap_t* req_wrap =
- (iotjs_adc_reqwrap_t*)(iotjs_reqwrap_from_request((uv_req_t*)work_req));
- iotjs_adc_reqdata_t* req_data = &req_wrap->req_data;
- iotjs_adc_t* adc = req_wrap->adc_data;
+ iotjs_periph_reqwrap_t* req_wrap =
+ (iotjs_periph_reqwrap_t*)(iotjs_reqwrap_from_request(
+ (uv_req_t*)work_req));
+ iotjs_adc_t* adc = (iotjs_adc_t*)req_wrap->data;
- switch (req_data->op) {
+ switch (req_wrap->op) {
case kAdcOpOpen:
- req_data->result = iotjs_adc_open(adc);
+ req_wrap->result = iotjs_adc_open(adc);
break;
case kAdcOpRead:
- req_data->result = iotjs_adc_read(adc);
+ req_wrap->result = iotjs_adc_read(adc);
break;
case kAdcOpClose:
- req_data->result = iotjs_adc_close(adc);
+ req_wrap->result = iotjs_adc_close(adc);
break;
default:
IOTJS_ASSERT(!"Invalid Adc Operation");
}
}
-
-static const char* adc_error_string(uint8_t op) {
- switch (op) {
- case kAdcOpClose:
- return "Close error, cannot close ADC";
- case kAdcOpOpen:
- return "Open error, cannot open ADC";
- case kAdcOpRead:
- return "Read error, cannot read ADC";
- default:
- return "Unknown ADC error";
- }
-}
-
-
-static void adc_after_worker(uv_work_t* work_req, int status) {
- iotjs_adc_reqwrap_t* req_wrap =
- (iotjs_adc_reqwrap_t*)(iotjs_reqwrap_from_request((uv_req_t*)work_req));
- iotjs_adc_reqdata_t* req_data = &req_wrap->req_data;
-
- iotjs_jargs_t jargs = iotjs_jargs_create(2);
- bool result = req_data->result;
-
- if (status) {
- iotjs_jargs_append_error(&jargs, "ADC System Error");
- } else {
- switch (req_data->op) {
- case kAdcOpOpen:
- if (!result) {
- iotjs_jargs_append_error(&jargs, adc_error_string(req_data->op));
- } else {
- iotjs_jargs_append_null(&jargs);
- }
- break;
- case kAdcOpRead:
- if (!result) {
- iotjs_jargs_append_error(&jargs, adc_error_string(req_data->op));
- } else {
- iotjs_adc_t* adc = req_wrap->adc_data;
-
- iotjs_jargs_append_null(&jargs);
- iotjs_jargs_append_number(&jargs, adc->value);
- }
- break;
- case kAdcOpClose:
- if (!result) {
- iotjs_jargs_append_error(&jargs, adc_error_string(req_data->op));
- } else {
- iotjs_jargs_append_null(&jargs);
- }
- break;
- default: {
- IOTJS_ASSERT(!"ADC after worker failed");
- break;
- }
- }
- }
-
- const jerry_value_t jcallback = iotjs_reqwrap_jcallback(&req_wrap->reqwrap);
- if (jerry_value_is_function(jcallback)) {
- iotjs_make_callback(jcallback, jerry_create_undefined(), &jargs);
- }
-
- if (req_data->op == kAdcOpClose) {
- adc_destroy(req_wrap->adc_data);
- }
-
- iotjs_jargs_destroy(&jargs);
- adc_reqwrap_destroy(req_wrap);
-}
-
-
-#define ADC_CALL_ASYNC(op, jcallback) \
- do { \
- uv_loop_t* loop = iotjs_environment_loop(iotjs_environment_get()); \
- iotjs_adc_reqwrap_t* req_wrap = adc_reqwrap_create(jcallback, adc, op); \
- uv_work_t* req = &req_wrap->req; \
- uv_queue_work(loop, req, adc_worker, adc_after_worker); \
- } while (0)
-
-
JS_FUNCTION(AdcCons) {
DJS_CHECK_THIS();
DJS_CHECK_ARGS(1, object);
// If the callback doesn't exist, it is completed synchronously.
// Otherwise, it will be executed asynchronously.
if (!jerry_value_is_null(jcallback)) {
- ADC_CALL_ASYNC(kAdcOpOpen, jcallback);
+ iotjs_periph_call_async(adc, jcallback, kAdcOpOpen, adc_worker);
} else if (!iotjs_adc_open(adc)) {
- return JS_CREATE_ERROR(COMMON, adc_error_string(kAdcOpOpen));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kAdcOpOpen));
}
return jerry_create_undefined();
JS_DECLARE_THIS_PTR(adc, adc);
DJS_CHECK_ARG_IF_EXIST(0, function);
- ADC_CALL_ASYNC(kAdcOpRead, JS_GET_ARG_IF_EXIST(0, function));
+ iotjs_periph_call_async(adc, JS_GET_ARG_IF_EXIST(0, function), kAdcOpRead,
+ adc_worker);
return jerry_create_undefined();
}
JS_DECLARE_THIS_PTR(adc, adc);
if (!iotjs_adc_read(adc)) {
- return JS_CREATE_ERROR(COMMON, adc_error_string(kAdcOpRead));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kAdcOpRead));
}
return jerry_create_number(adc->value);
JS_DECLARE_THIS_PTR(adc, adc);
DJS_CHECK_ARG_IF_EXIST(0, function);
- ADC_CALL_ASYNC(kAdcOpClose, JS_GET_ARG_IF_EXIST(0, function));
+ iotjs_periph_call_async(adc, JS_GET_ARG_IF_EXIST(0, function), kAdcOpClose,
+ adc_worker);
return jerry_create_undefined();
}
JS_DECLARE_THIS_PTR(adc, adc);
bool ret = iotjs_adc_close(adc);
- adc_destroy(adc);
if (!ret) {
- return JS_CREATE_ERROR(COMMON, adc_error_string(kAdcOpClose));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kAdcOpClose));
}
return jerry_create_undefined();
#define IOTJS_MODULE_ADC_H
#include "iotjs_def.h"
+#include "iotjs_module_periph_common.h"
#include "iotjs_reqwrap.h"
-
-typedef enum {
- kAdcOpOpen,
- kAdcOpRead,
- kAdcOpClose,
-} AdcOp;
-
// Forward declaration of platform data. These are only used by platform code.
// Generic ADC module never dereferences platform data pointer.
typedef struct iotjs_adc_platform_data_s iotjs_adc_platform_data_t;
int32_t value;
} iotjs_adc_t;
-
-typedef struct {
- bool result;
- AdcOp op;
-} iotjs_adc_reqdata_t;
-
-
-typedef struct {
- iotjs_reqwrap_t reqwrap;
- uv_work_t req;
- iotjs_adc_reqdata_t req_data;
- iotjs_adc_t* adc_data;
-} iotjs_adc_reqwrap_t;
-
-
bool iotjs_adc_read(iotjs_adc_t* adc);
bool iotjs_adc_close(iotjs_adc_t* adc);
bool iotjs_adc_open(iotjs_adc_t* adc);
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "iotjs_def.h"
+#include "iotjs_module_bridge.h"
+#include "iotjs_reqwrap.h"
+#include <stdio.h>
+
+typedef enum {
+ CALL_STATUS_ERROR = 0,
+ CALL_STATUS_INIT,
+ CALL_STATUS_CALLED,
+ CALL_STATUS_SETMSG,
+} iotjs_bridge_status_t;
+
+typedef struct _iotjs_bridge_object_t iotjs_bridge_object_t;
+typedef struct {
+ jerry_value_t jobject;
+ jerry_value_t jcallback;
+ uv_mutex_t call_lock;
+ uv_work_t req;
+ uv_async_t* async;
+ iotjs_string_t module;
+ iotjs_string_t command;
+ iotjs_string_t message;
+ iotjs_string_t ret_msg;
+ iotjs_bridge_status_t status;
+ iotjs_bridge_object_t* bridgeobj;
+} iotjs_bridge_call_t;
+
+struct _iotjs_bridge_object_t {
+ jerry_value_t jobject;
+ iotjs_bridge_call_t** calls;
+ size_t calls_alloc; // allocated size of calls
+};
+
+typedef struct {
+ char* module_name;
+ iotjs_bridge_func callback;
+} relation_info_t;
+
+static relation_info_t* g_module_list = 0;
+static unsigned int g_module_count = 0;
+
+IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE(bridge_object);
+
+static unsigned int iotjs_bridge_init() {
+ if (g_module_list == 0) {
+ g_module_list = (relation_info_t*)iotjs_buffer_allocate(
+ sizeof(relation_info_t) * iotjs_module_count);
+ IOTJS_ASSERT(g_module_list);
+ }
+ return iotjs_module_count;
+}
+
+int iotjs_bridge_register(char* module_name, iotjs_bridge_func callback) {
+ int empty_slot = -1;
+ iotjs_bridge_init();
+ for (int i = 0; i < (int)iotjs_module_count; i++) {
+ if (g_module_list[i].module_name == 0) {
+ if (empty_slot == -1)
+ empty_slot = i;
+ } else {
+ if (strncmp(g_module_list[i].module_name, module_name,
+ strlen(module_name)) == 0) {
+ return i;
+ }
+ }
+ }
+ if (empty_slot != -1) {
+ g_module_list[empty_slot].module_name =
+ iotjs_buffer_allocate(strlen(module_name) + 1);
+ IOTJS_ASSERT(g_module_list[empty_slot].module_name);
+ strncpy(g_module_list[empty_slot].module_name, module_name,
+ strlen(module_name));
+ g_module_list[empty_slot].callback = callback;
+ g_module_count++;
+ }
+ return empty_slot;
+}
+
+static int iotjs_bridge_call(const char* module_name, const char* command,
+ const char* message, void* handle) {
+ int ret = -1;
+ for (int i = 0; i < (int)iotjs_module_count; i++) {
+ if (g_module_list[i].module_name != 0) {
+ if (strncmp(g_module_list[i].module_name, module_name,
+ strlen(module_name) + 1) == 0) {
+ g_module_list[i].callback(command, message, handle);
+ ret = 0;
+ break;
+ }
+ }
+ }
+ return ret;
+}
+
+void iotjs_bridge_set_err(void* handle, char* err) {
+ iotjs_bridge_call_t* bridgecall = (iotjs_bridge_call_t*)handle;
+ IOTJS_ASSERT(iotjs_string_is_empty(&bridgecall->ret_msg));
+
+ if (err == NULL) {
+ err = "internal error";
+ }
+ if (!jerry_value_is_undefined(bridgecall->jcallback)) {
+ uv_mutex_lock(&bridgecall->call_lock);
+ }
+ bridgecall->ret_msg = iotjs_string_create_with_size(err, strlen(err) + 1);
+ bridgecall->status = CALL_STATUS_ERROR;
+
+ if (bridgecall->async != NULL) {
+ IOTJS_ASSERT(bridgecall->async->data == bridgecall);
+ uv_async_send(bridgecall->async);
+ }
+ if (!jerry_value_is_undefined(bridgecall->jcallback)) {
+ uv_mutex_unlock(&bridgecall->call_lock);
+ }
+}
+
+void iotjs_bridge_set_msg(void* handle, char* msg) {
+ iotjs_bridge_call_t* bridgecall = (iotjs_bridge_call_t*)handle;
+ IOTJS_ASSERT(iotjs_string_is_empty(&bridgecall->ret_msg));
+ size_t size = 0;
+ if (msg == NULL) {
+ msg = "";
+ } else {
+ size = strlen(msg) + 1;
+ }
+ if (size > MAX_RETURN_MESSAGE) {
+ iotjs_bridge_set_err(handle, "The message exceeds the maximum");
+ } else {
+ if (!jerry_value_is_undefined(bridgecall->jcallback)) {
+ uv_mutex_lock(&bridgecall->call_lock);
+ }
+ bridgecall->ret_msg = iotjs_string_create_with_size(msg, size);
+ bridgecall->status = CALL_STATUS_SETMSG;
+
+ if (bridgecall->async != NULL) {
+ IOTJS_ASSERT(bridgecall->async->data == bridgecall);
+ uv_async_send(bridgecall->async);
+ }
+ if (!jerry_value_is_undefined(bridgecall->jcallback)) {
+ uv_mutex_unlock(&bridgecall->call_lock);
+ }
+ }
+}
+
+static iotjs_bridge_call_t* iotjs_bridge_call_init(
+ iotjs_bridge_call_t* bridgecall, const jerry_value_t bridge,
+ const jerry_value_t jcallback, iotjs_string_t module,
+ iotjs_string_t command, iotjs_string_t message) {
+ if (bridge) {
+ bridgecall->jobject = jerry_acquire_value(bridge);
+ } else {
+ bridgecall->jobject = jerry_create_undefined();
+ }
+ if (!jerry_value_is_null(jcallback)) {
+ bridgecall->jcallback = jerry_acquire_value(jcallback);
+ bridgecall->req.data = (void*)bridgecall;
+ uv_mutex_init(&bridgecall->call_lock);
+ } else {
+ bridgecall->jcallback = jerry_create_undefined();
+ }
+ bridgecall->async = NULL;
+ bridgecall->module = module;
+ bridgecall->command = command;
+ bridgecall->message = message;
+ bridgecall->ret_msg = iotjs_string_create();
+ bridgecall->status = CALL_STATUS_INIT;
+ bridgecall->bridgeobj = NULL;
+
+ return bridgecall;
+}
+
+static void iotjs_bridge_call_destroy(iotjs_bridge_call_t* bridgecall) {
+ if (!jerry_value_is_undefined(bridgecall->jobject)) {
+ jerry_release_value(bridgecall->jobject);
+ }
+ if (!jerry_value_is_undefined(bridgecall->jcallback)) {
+ uv_mutex_destroy(&bridgecall->call_lock);
+ jerry_release_value(bridgecall->jcallback);
+ }
+ if (bridgecall->async) {
+ uv_close((uv_handle_t*)bridgecall->async, NULL);
+ IOTJS_RELEASE(bridgecall->async);
+ }
+ iotjs_string_destroy(&bridgecall->module);
+ iotjs_string_destroy(&bridgecall->command);
+ iotjs_string_destroy(&bridgecall->message);
+ iotjs_string_destroy(&bridgecall->ret_msg);
+ bridgecall->bridgeobj = NULL;
+ IOTJS_RELEASE(bridgecall);
+}
+
+static iotjs_bridge_object_t* iotjs_bridge_get_object(jerry_value_t obj_val) {
+ iotjs_bridge_object_t* bridgeobj = NULL;
+ bool is_ok = false;
+ is_ok = jerry_get_object_native_pointer(obj_val, (void**)&bridgeobj, NULL);
+ if (!is_ok) {
+ bridgeobj = IOTJS_ALLOC(iotjs_bridge_object_t);
+ bridgeobj->jobject = obj_val;
+ bridgeobj->calls = NULL;
+ bridgeobj->calls_alloc = 0;
+ jerry_set_object_native_pointer(obj_val, bridgeobj,
+ &this_module_native_info);
+ }
+ IOTJS_ASSERT(bridgeobj != NULL);
+ IOTJS_ASSERT(bridgeobj->jobject == obj_val);
+ return bridgeobj;
+}
+
+static void iotjs_bridge_object_destroy(iotjs_bridge_object_t* bridgeobj) {
+ if (bridgeobj->calls_alloc == 0) {
+ if (bridgeobj->calls != NULL) {
+ iotjs_bridge_call_destroy((iotjs_bridge_call_t*)bridgeobj->calls);
+ }
+ } else {
+ for (size_t i = 0; i < bridgeobj->calls_alloc; i++) {
+ if (bridgeobj->calls[i] != NULL) {
+ iotjs_bridge_call_destroy(bridgeobj->calls[i]);
+ }
+ }
+ IOTJS_ASSERT(bridgeobj->calls);
+ iotjs_buffer_release((char*)bridgeobj->calls);
+ }
+ IOTJS_RELEASE(bridgeobj);
+}
+
+static int iotjs_bridge_add_call(iotjs_bridge_object_t* bridgeobj,
+ iotjs_bridge_call_t* callobj) {
+ IOTJS_ASSERT(bridgeobj);
+ IOTJS_ASSERT(callobj);
+ callobj->bridgeobj = bridgeobj;
+ if (bridgeobj->calls_alloc == 0) {
+ if (bridgeobj->calls == NULL) {
+ bridgeobj->calls = (iotjs_bridge_call_t**)callobj;
+ } else {
+ iotjs_bridge_call_t* prev_obj = (iotjs_bridge_call_t*)bridgeobj->calls;
+ bridgeobj->calls = (iotjs_bridge_call_t**)iotjs_buffer_allocate(
+ sizeof(iotjs_bridge_call_t*) * 4);
+ bridgeobj->calls_alloc = 4;
+ bridgeobj->calls[0] = prev_obj;
+ bridgeobj->calls[1] = callobj;
+ }
+ } else {
+ for (size_t i = 0; i < bridgeobj->calls_alloc; i++) {
+ if (bridgeobj->calls[i] == 0) {
+ bridgeobj->calls[i] = callobj;
+ return bridgeobj->calls_alloc;
+ }
+ }
+ size_t prev_size = sizeof(iotjs_bridge_call_t*) * bridgeobj->calls_alloc;
+ bridgeobj->calls =
+ (iotjs_bridge_call_t**)iotjs_buffer_reallocate((char*)bridgeobj->calls,
+ prev_size * 2);
+ bridgeobj->calls[bridgeobj->calls_alloc] = callobj;
+ bridgeobj->calls_alloc *= 2;
+ }
+ return bridgeobj->calls_alloc;
+}
+
+static int iotjs_bridge_remove_call(iotjs_bridge_call_t* callobj) {
+ iotjs_bridge_object_t* bridgeobj = callobj->bridgeobj;
+
+ if (bridgeobj->calls_alloc == 0) {
+ if (bridgeobj->calls != NULL) {
+ iotjs_bridge_call_destroy((iotjs_bridge_call_t*)bridgeobj->calls);
+ bridgeobj->calls = NULL;
+ }
+ } else {
+ for (size_t i = 0; i < bridgeobj->calls_alloc; i++) {
+ if (bridgeobj->calls[i] == callobj) {
+ iotjs_bridge_call_destroy(bridgeobj->calls[i]);
+ bridgeobj->calls[i] = NULL;
+ }
+ }
+ }
+ return 0;
+}
+
+static void iotjs_bridge_js_call(iotjs_bridge_call_t* bridgecall) {
+ iotjs_jargs_t jargs = iotjs_jargs_create(2);
+ if (bridgecall->status == CALL_STATUS_ERROR) { // internal error
+ iotjs_jargs_append_error(&jargs, iotjs_string_data(&bridgecall->ret_msg));
+ iotjs_jargs_append_null(&jargs);
+ } else {
+ iotjs_jargs_append_null(&jargs);
+ iotjs_jargs_append_string_raw(&jargs,
+ iotjs_string_data(&bridgecall->ret_msg));
+ }
+ jerry_value_t jcallback = bridgecall->jcallback;
+ if (jerry_value_is_function(jcallback)) {
+ iotjs_make_callback(jcallback, jerry_create_undefined(), &jargs);
+ }
+ iotjs_jargs_destroy(&jargs);
+}
+
+static void aysnc_callback(uv_async_t* async) {
+ iotjs_bridge_call_t* bridgecall = (iotjs_bridge_call_t*)async->data;
+ iotjs_bridge_js_call(bridgecall);
+ iotjs_bridge_remove_call(bridgecall);
+}
+
+void after_worker(uv_work_t* req, int status) {
+ iotjs_bridge_call_t* bridgecall = (iotjs_bridge_call_t*)req->data;
+ uv_mutex_lock(&bridgecall->call_lock);
+ if ((bridgecall->status == CALL_STATUS_ERROR) ||
+ (bridgecall->status == CALL_STATUS_SETMSG)) {
+ iotjs_bridge_js_call(bridgecall);
+ uv_mutex_unlock(&bridgecall->call_lock);
+ iotjs_bridge_remove_call(bridgecall);
+ } else {
+ uv_loop_t* loop = iotjs_environment_loop(iotjs_environment_get());
+ uv_async_t* async = IOTJS_ALLOC(uv_async_t);
+ async->data = (void*)bridgecall;
+ uv_async_init(loop, async, aysnc_callback);
+ uv_mutex_unlock(&bridgecall->call_lock);
+ }
+}
+
+void bridge_worker(uv_work_t* req) {
+ iotjs_bridge_call_t* bridgecall = (iotjs_bridge_call_t*)req->data;
+ bridgecall->status = CALL_STATUS_CALLED;
+ int ret = iotjs_bridge_call(iotjs_string_data(&bridgecall->module),
+ iotjs_string_data(&bridgecall->command),
+ iotjs_string_data(&bridgecall->message),
+ (void*)bridgecall);
+ if (ret < 0) {
+ iotjs_bridge_set_err(bridgecall, "Can't find the module");
+ }
+}
+
+/**
+ * send async message
+ */
+JS_FUNCTION(MessageAsync) {
+ DJS_CHECK_THIS();
+ DJS_CHECK_ARGS(3, string, string, string);
+ DJS_CHECK_ARG_IF_EXIST(3, function);
+
+ jerry_value_t bridge_module = JS_GET_THIS();
+ iotjs_string_t module_name = JS_GET_ARG(0, string);
+ iotjs_string_t module_command = JS_GET_ARG(1, string);
+ iotjs_string_t command_message = JS_GET_ARG(2, string);
+ jerry_value_t jcallback = JS_GET_ARG_IF_EXIST(3, function);
+
+ if (!jerry_value_is_null(jcallback)) { // async call
+ uv_loop_t* loop = iotjs_environment_loop(iotjs_environment_get());
+ iotjs_bridge_object_t* bridgeobj = iotjs_bridge_get_object(bridge_module);
+ iotjs_bridge_call_t* bridgecall = IOTJS_ALLOC(iotjs_bridge_call_t);
+ iotjs_bridge_call_init(bridgecall, bridge_module, jcallback, module_name,
+ module_command, command_message);
+ iotjs_bridge_add_call(bridgeobj, bridgecall);
+
+ uv_queue_work(loop, &bridgecall->req, bridge_worker, after_worker);
+
+ } else { // sync call
+ jerry_value_t jmsg;
+ iotjs_bridge_call_t bridgecall_local;
+ iotjs_bridge_call_t* bridgecall = &bridgecall_local;
+
+ iotjs_bridge_call_init(bridgecall, 0, 0, module_name, module_command,
+ command_message);
+ int ret = iotjs_bridge_call(iotjs_string_data(&module_name),
+ iotjs_string_data(&module_command),
+ iotjs_string_data(&command_message),
+ (void*)bridgecall);
+ if (ret < 0) {
+ iotjs_bridge_set_err(bridgecall, "Can't find the module");
+ }
+ if (bridgecall->status == CALL_STATUS_ERROR) { // error..
+ if (iotjs_string_is_empty(&bridgecall->ret_msg)) {
+ jmsg = JS_CREATE_ERROR(COMMON, (jerry_char_t*)"Unknown native error..");
+ } else {
+ jmsg = JS_CREATE_ERROR(COMMON, iotjs_string_data(&bridgecall->ret_msg));
+ }
+ } else {
+ if (iotjs_string_is_empty(&bridgecall->ret_msg)) {
+ jmsg = jerry_create_string((jerry_char_t*)"");
+ } else {
+ jmsg = jerry_create_string(
+ (jerry_char_t*)iotjs_string_data(&bridgecall->ret_msg));
+ }
+ }
+ iotjs_string_destroy(&bridgecall->module);
+ iotjs_string_destroy(&bridgecall->command);
+ iotjs_string_destroy(&bridgecall->message);
+ iotjs_string_destroy(&bridgecall->ret_msg);
+ return jmsg;
+ }
+
+ return jerry_create_string((jerry_char_t*)"");
+}
+
+/**
+ * Init method called by IoT.js
+ */
+jerry_value_t InitBridge() {
+ jerry_value_t messagModule = jerry_create_object();
+ iotjs_jval_set_method(messagModule, "send", MessageAsync);
+ iotjs_bridge_init();
+ return messagModule;
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IOTJS_BRIDGE_H
+#define IOTJS_BRIDGE_H
+
+#define MAX_RETURN_MESSAGE 512 * 2
+
+/*
+ */
+typedef void (*iotjs_bridge_func)(const char* command, const char* message,
+ void* return_handle);
+
+int iotjs_bridge_register(char* module_name, iotjs_bridge_func callback);
+
+void iotjs_bridge_set_err(void* return_handle, char* err);
+void iotjs_bridge_set_msg(void* return_handle, char* msg);
+
+#endif
#include <stdlib.h>
#include <string.h>
+typedef enum {
+ BUFFER_HEX_ENC = 0,
+ BUFFER_BASE64_ENC = 1,
+} buffer_encoding_type_t;
+
IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE(bufferwrap);
-iotjs_bufferwrap_t* iotjs_bufferwrap_create(const jerry_value_t jbuiltin,
+iotjs_bufferwrap_t* iotjs_bufferwrap_create(const jerry_value_t jobject,
size_t length) {
iotjs_bufferwrap_t* bufferwrap = IOTJS_ALLOC(iotjs_bufferwrap_t);
- bufferwrap->jobject = jbuiltin;
- jerry_set_object_native_pointer(jbuiltin, bufferwrap,
+ bufferwrap->jobject = jobject;
+ jerry_set_object_native_pointer(jobject, bufferwrap,
&this_module_native_info);
if (length > 0) {
IOTJS_ASSERT(
bufferwrap ==
- (iotjs_bufferwrap_t*)(iotjs_jval_get_object_native_handle(jbuiltin)));
+ (iotjs_bufferwrap_t*)(iotjs_jval_get_object_native_handle(jobject)));
return bufferwrap;
}
static void iotjs_bufferwrap_destroy(iotjs_bufferwrap_t* bufferwrap) {
- if (bufferwrap->buffer != NULL) {
- iotjs_buffer_release(bufferwrap->buffer);
- }
+ IOTJS_RELEASE(bufferwrap->buffer);
IOTJS_RELEASE(bufferwrap);
}
-iotjs_bufferwrap_t* iotjs_bufferwrap_from_jbuiltin(
- const jerry_value_t jbuiltin) {
- IOTJS_ASSERT(jerry_value_is_object(jbuiltin));
- iotjs_bufferwrap_t* buffer =
- (iotjs_bufferwrap_t*)iotjs_jval_get_object_native_handle(jbuiltin);
- IOTJS_ASSERT(buffer != NULL);
- return buffer;
-}
-
-
iotjs_bufferwrap_t* iotjs_bufferwrap_from_jbuffer(const jerry_value_t jbuffer) {
IOTJS_ASSERT(jerry_value_is_object(jbuffer));
- jerry_value_t jbuiltin =
- iotjs_jval_get_property(jbuffer, IOTJS_MAGIC_STRING__BUILTIN);
- iotjs_bufferwrap_t* buffer = iotjs_bufferwrap_from_jbuiltin(jbuiltin);
- jerry_release_value(jbuiltin);
+ iotjs_bufferwrap_t* buffer =
+ (iotjs_bufferwrap_t*)iotjs_jval_get_object_native_handle(jbuffer);
+ IOTJS_ASSERT(buffer != NULL);
return buffer;
}
size_t iotjs_bufferwrap_length(iotjs_bufferwrap_t* bufferwrap) {
+ IOTJS_ASSERT(bufferwrap != NULL);
#ifndef NDEBUG
- jerry_value_t jbuf =
- iotjs_jval_get_property(bufferwrap->jobject, IOTJS_MAGIC_STRING__BUFFER);
jerry_value_t jlength =
- iotjs_jval_get_property(jbuf, IOTJS_MAGIC_STRING_LENGTH);
+ iotjs_jval_get_property(bufferwrap->jobject, IOTJS_MAGIC_STRING_LENGTH);
size_t length = iotjs_jval_as_number(jlength);
IOTJS_ASSERT(length == bufferwrap->length);
- jerry_release_value(jbuf);
jerry_release_value(jlength);
#endif
return bufferwrap->length;
}
-static int8_t hex2bin(char c) {
- if (c >= '0' && c <= '9')
+static int8_t hex_to_bin(char c) {
+ if (c >= '0' && c <= '9') {
return (int8_t)(c - '0');
- if (c >= 'A' && c <= 'F')
+ }
+ if (c >= 'A' && c <= 'F') {
return (int8_t)(10 + (c - 'A'));
- if (c >= 'a' && c <= 'f')
+ }
+ if (c >= 'a' && c <= 'f') {
return (int8_t)(10 + (c - 'a'));
+ }
return (int8_t)(-1);
}
static size_t hex_decode(char* buf, size_t len, const char* src,
const size_t srcLen) {
- size_t i;
+ const char* bufStart = buf;
+ const char* bufEnd = buf + len;
+ const char* srcEnd = src + srcLen;
- for (i = 0; i < len && i * 2 + 1 < srcLen; ++i) {
- int8_t a = hex2bin(src[i * 2 + 0]);
- int8_t b = hex2bin(src[i * 2 + 1]);
- if (a == -1 || b == -1)
- return i;
- buf[i] = (a << 4) | b;
+ if ((srcLen & 0x1) != 0) {
+ return 0;
}
- return i;
+ while (src < srcEnd) {
+ int8_t a = hex_to_bin(src[0]);
+ int8_t b = hex_to_bin(src[1]);
+
+ if (a == -1 || b == -1) {
+ return 0;
+ }
+
+ if (buf < bufEnd) {
+ *buf++ = (a << 4) | b;
+ }
+
+ src += 2;
+ }
+
+ return (size_t)((buf - bufStart) + 1);
+}
+
+
+static int32_t base64_to_bin(char c) {
+ if (c >= 'A' && c <= 'Z') {
+ return (int32_t)(c - 'A');
+ }
+ if (c >= 'a' && c <= 'z') {
+ return (int32_t)(26 + (c - 'a'));
+ }
+ if (c >= '0' && c <= '9') {
+ return (int32_t)(52 + (c - '0'));
+ }
+ if (c == '+') {
+ return 62;
+ }
+ if (c == '/') {
+ return 63;
+ }
+
+ return (int32_t)(-1);
+}
+
+
+static size_t base64_decode(char* buf, size_t len, const char* src,
+ const size_t srcLen) {
+ if (srcLen == 0) {
+ return 0 + 1;
+ }
+
+ if ((srcLen & 0x3) != 0) {
+ return 0;
+ }
+
+ const char* bufStart = buf;
+ const char* bufEnd = buf + len;
+ const char* srcEnd = src + srcLen;
+
+ if (srcEnd[-1] == '=') {
+ srcEnd--;
+ if (srcEnd[-1] == '=') {
+ srcEnd--;
+ }
+ }
+
+ int32_t current_bits = 0;
+ int32_t shift = 8;
+
+ while (src < srcEnd) {
+ int32_t value = base64_to_bin(*src++);
+
+ if (value == -1) {
+ return 0;
+ }
+
+ current_bits = (current_bits << 6) | value;
+ shift -= 2;
+
+ if (shift == 6) {
+ continue;
+ }
+
+ int32_t byte = (current_bits >> shift);
+ current_bits &= (1 << shift) - 1;
+
+ if (shift == 0) {
+ shift = 8;
+ }
+
+ if (buf < bufEnd) {
+ *buf++ = (char)byte;
+ }
+ }
+
+ return (size_t)((buf - bufStart) + 1);
}
return iotjs_bufferwrap_copy_internal(bufferwrap, src, 0, len, 0);
}
+static size_t index_normalizer(int64_t index, size_t max_length) {
+ size_t idx;
+ if (index < 0) {
+ if ((size_t)(-index) > max_length) {
+ idx = SIZE_MAX;
+ } else {
+ idx = (size_t)index + max_length;
+ }
+ } else {
+ idx = (size_t)index;
+ }
+
+ return bound_range(idx, 0, max_length);
+}
jerry_value_t iotjs_bufferwrap_create_buffer(size_t len) {
jerry_value_t jglobal = jerry_get_global_object();
jerry_release_value(jglobal);
IOTJS_ASSERT(jerry_value_is_function(jbuffer));
- iotjs_jargs_t jargs = iotjs_jargs_create(1);
- iotjs_jargs_append_number(&jargs, len);
+ jerry_value_t arg = jerry_create_number(len);
- jerry_value_t jres =
- iotjs_jhelper_call_ok(jbuffer, jerry_create_undefined(), &jargs);
+ jerry_value_t jres = jerry_construct_object(jbuffer, &arg, 1);
+ IOTJS_ASSERT(!jerry_value_has_error_flag(jres));
IOTJS_ASSERT(jerry_value_is_object(jres));
- iotjs_jargs_destroy(&jargs);
+ jerry_release_value(arg);
jerry_release_value(jbuffer);
return jres;
JS_FUNCTION(Buffer) {
- DJS_CHECK_THIS();
DJS_CHECK_ARGS(2, object, number);
- const jerry_value_t jbuiltin = JS_GET_THIS();
- const jerry_value_t jbuffer = JS_GET_ARG(0, object);
+ const jerry_value_t jobject = JS_GET_ARG(0, object);
size_t length = JS_GET_ARG(1, number);
- iotjs_jval_set_property_jval(jbuiltin, IOTJS_MAGIC_STRING__BUFFER, jbuffer);
-
- iotjs_bufferwrap_create(jbuiltin, length);
+ iotjs_bufferwrap_create(jobject, length);
return jerry_create_undefined();
}
-
JS_FUNCTION(Compare) {
- JS_DECLARE_THIS_PTR(bufferwrap, src_buffer_wrap);
- JS_DECLARE_OBJECT_PTR(0, bufferwrap, dst_buffer_wrap);
+ JS_DECLARE_OBJECT_PTR(0, bufferwrap, src_buffer_wrap);
+ JS_DECLARE_OBJECT_PTR(1, bufferwrap, dst_buffer_wrap);
int compare = iotjs_bufferwrap_compare(src_buffer_wrap, dst_buffer_wrap);
return jerry_create_number(compare);
JS_FUNCTION(Copy) {
- JS_DECLARE_THIS_PTR(bufferwrap, src_buffer_wrap);
- DJS_CHECK_ARGS(4, object, number, number, number);
+ DJS_CHECK_ARGS(5, object, object, number, number, number);
+ JS_DECLARE_OBJECT_PTR(0, bufferwrap, src_buffer_wrap);
- const jerry_value_t jdst_buffer = JS_GET_ARG(0, object);
+ const jerry_value_t jdst_buffer = JS_GET_ARG(1, object);
iotjs_bufferwrap_t* dst_buffer_wrap =
iotjs_bufferwrap_from_jbuffer(jdst_buffer);
size_t dst_length = iotjs_bufferwrap_length(dst_buffer_wrap);
size_t src_length = iotjs_bufferwrap_length(src_buffer_wrap);
- size_t dst_start = iotjs_convert_double_to_sizet(JS_GET_ARG(1, number));
+ size_t dst_start = iotjs_convert_double_to_sizet(JS_GET_ARG(2, number));
dst_start = bound_range(dst_start, 0, dst_length);
- size_t src_start = iotjs_convert_double_to_sizet(JS_GET_ARG(2, number));
+ size_t src_start = iotjs_convert_double_to_sizet(JS_GET_ARG(3, number));
src_start = bound_range(src_start, 0, src_length);
- size_t src_end = iotjs_convert_double_to_sizet(JS_GET_ARG(3, number));
+ size_t src_end = iotjs_convert_double_to_sizet(JS_GET_ARG(4, number));
src_end = bound_range(src_end, 0, src_length);
if (src_end < src_start) {
JS_FUNCTION(Write) {
- JS_DECLARE_THIS_PTR(bufferwrap, buffer_wrap);
- DJS_CHECK_ARGS(3, string, number, number);
+ DJS_CHECK_ARGS(4, object, string, number, number);
+ JS_DECLARE_OBJECT_PTR(0, bufferwrap, buffer_wrap);
- iotjs_string_t src = JS_GET_ARG(0, string);
+ iotjs_string_t src = JS_GET_ARG(1, string);
size_t buffer_length = iotjs_bufferwrap_length(buffer_wrap);
- size_t offset = iotjs_convert_double_to_sizet(JS_GET_ARG(1, number));
+ size_t offset = iotjs_convert_double_to_sizet(JS_GET_ARG(2, number));
offset = bound_range(offset, 0, buffer_length);
- size_t length = iotjs_convert_double_to_sizet(JS_GET_ARG(2, number));
+ size_t length = iotjs_convert_double_to_sizet(JS_GET_ARG(3, number));
length = bound_range(length, 0, buffer_length - offset);
length = bound_range(length, 0, iotjs_string_size(&src));
JS_FUNCTION(WriteUInt8) {
- JS_DECLARE_THIS_PTR(bufferwrap, buffer_wrap);
- DJS_CHECK_ARGS(2, number, number);
+ DJS_CHECK_ARGS(3, object, number, number);
+ JS_DECLARE_OBJECT_PTR(0, bufferwrap, buffer_wrap);
- const char src[] = { (char)JS_GET_ARG(0, number) };
+ const char src[] = { (char)JS_GET_ARG(1, number) };
size_t length = 1;
size_t buffer_length = iotjs_bufferwrap_length(buffer_wrap);
- size_t offset = iotjs_convert_double_to_sizet(JS_GET_ARG(1, number));
+ size_t offset = iotjs_convert_double_to_sizet(JS_GET_ARG(2, number));
offset = bound_range(offset, 0, buffer_length);
length = bound_range(length, 0, buffer_length - offset);
length = bound_range(length, 0, 1);
}
-JS_FUNCTION(HexWrite) {
- JS_DECLARE_THIS_PTR(bufferwrap, buffer_wrap);
- DJS_CHECK_ARGS(3, string, number, number);
+JS_FUNCTION(WriteDecode) {
+ DJS_CHECK_ARGS(5, object, number, string, number, number);
+ JS_DECLARE_OBJECT_PTR(0, bufferwrap, buffer_wrap);
- iotjs_string_t src = JS_GET_ARG(0, string);
+ double type = JS_GET_ARG(1, number);
+ iotjs_string_t src = JS_GET_ARG(2, string);
size_t buffer_length = iotjs_bufferwrap_length(buffer_wrap);
- size_t offset = iotjs_convert_double_to_sizet(JS_GET_ARG(1, number));
+ size_t offset = iotjs_convert_double_to_sizet(JS_GET_ARG(3, number));
offset = bound_range(offset, 0, buffer_length);
- size_t length = iotjs_convert_double_to_sizet(JS_GET_ARG(2, number));
+ size_t length = iotjs_convert_double_to_sizet(JS_GET_ARG(4, number));
length = bound_range(length, 0, buffer_length - offset);
const char* src_data = iotjs_string_data(&src);
unsigned src_length = iotjs_string_size(&src);
- char* src_buf = iotjs_buffer_allocate(length);
- size_t nbytes = hex_decode(src_buf, length, src_data, src_length);
+ size_t nbytes;
+ char* dst_data = buffer_wrap->buffer + offset;
+ const char* error_msg;
- size_t copied =
- iotjs_bufferwrap_copy_internal(buffer_wrap, src_buf, 0, nbytes, offset);
+ if (type == BUFFER_HEX_ENC) {
+ nbytes = hex_decode(dst_data, length, src_data, src_length);
+ error_msg = "Invalid hex string";
+ } else {
+ nbytes = base64_decode(dst_data, length, src_data, src_length);
+ error_msg = "Invalid base64 string";
+ }
- iotjs_buffer_release(src_buf);
iotjs_string_destroy(&src);
- return jerry_create_number(copied);
+ if (nbytes == 0)
+ return jerry_create_error(JERRY_ERROR_TYPE, (const jerry_char_t*)error_msg);
+
+ return jerry_create_number(nbytes - 1);
}
JS_FUNCTION(ReadUInt8) {
- JS_DECLARE_THIS_PTR(bufferwrap, buffer_wrap);
- DJS_CHECK_ARGS(1, number);
+ DJS_CHECK_ARGS(2, object, number);
+ JS_DECLARE_OBJECT_PTR(0, bufferwrap, buffer_wrap);
+
size_t buffer_length = iotjs_bufferwrap_length(buffer_wrap);
- size_t offset = iotjs_convert_double_to_sizet(JS_GET_ARG(0, number));
+ size_t offset = iotjs_convert_double_to_sizet(JS_GET_ARG(1, number));
offset = bound_range(offset, 0, buffer_length - 1);
char* buffer = buffer_wrap->buffer;
JS_FUNCTION(Slice) {
- JS_DECLARE_THIS_PTR(bufferwrap, buffer_wrap);
- DJS_CHECK_ARGS(2, number, number);
+ DJS_CHECK_ARGS(3, object, number, number);
+ JS_DECLARE_OBJECT_PTR(0, bufferwrap, buffer_wrap);
- int64_t start = JS_GET_ARG(0, number);
- int64_t end = JS_GET_ARG(1, number);
- size_t start_idx, end_idx;
-
- if (start < 0) {
- size_t len = iotjs_bufferwrap_length(buffer_wrap);
- if ((size_t)(-start) > len) {
- start_idx = SIZE_MAX;
- } else {
- start_idx = (size_t)start + len;
- }
- } else {
- start_idx = (size_t)start;
- }
- start_idx = bound_range(start_idx, 0, iotjs_bufferwrap_length(buffer_wrap));
-
- if (end < 0) {
- size_t len = iotjs_bufferwrap_length(buffer_wrap);
- if ((size_t)(-end) > len) {
- end_idx = SIZE_MAX;
- } else {
- end_idx = (size_t)end + len;
- }
- } else {
- end_idx = (size_t)end;
- }
- end_idx = bound_range(end_idx, 0, iotjs_bufferwrap_length(buffer_wrap));
+ int64_t start = JS_GET_ARG(1, number);
+ int64_t end = JS_GET_ARG(2, number);
+ size_t len = iotjs_bufferwrap_length(buffer_wrap);
+ size_t start_idx = index_normalizer(start, len);
+ size_t end_idx = index_normalizer(end, len);
if (end_idx < start_idx) {
end_idx = start_idx;
}
+static char to_hex_char(uint8_t digit) {
+ return (char)((digit < 10) ? (digit + '0') : (digit + 'a' - 10));
+}
+
+
+static jerry_value_t to_hex_string(const uint8_t* data, size_t length) {
+ if (length == 0) {
+ return jerry_create_string_sz(NULL, 0);
+ }
+
+ const uint8_t* end = data + length;
+
+ size_t buffer_length = length * 2;
+ char* buffer = iotjs_buffer_allocate(buffer_length);
+ const jerry_char_t* str = (const jerry_char_t*)buffer;
+
+ while (data < end) {
+ *buffer++ = to_hex_char(*data >> 4);
+ *buffer++ = to_hex_char(*data & 0xf);
+ data++;
+ }
+
+ jerry_value_t ret_value = jerry_create_string_sz(str, buffer_length);
+ IOTJS_RELEASE(str);
+
+ return ret_value;
+}
+
+static char to_base64_char(uint8_t digit) {
+ if (digit <= 25) {
+ return (char)digit + 'A';
+ }
+ if (digit <= 51) {
+ return (char)digit + 'a' - 26;
+ }
+ if (digit <= 61) {
+ return (char)digit + '0' - 52;
+ }
+
+ return (digit == 62) ? '+' : '/';
+}
+
+static jerry_value_t to_base64_string(const uint8_t* data, size_t length) {
+ if (length == 0) {
+ return jerry_create_string_sz(NULL, 0);
+ }
+
+ const uint8_t* end = data + length;
+
+ size_t buffer_length = ((length + 2) / 3) * 4;
+ char* buffer = iotjs_buffer_allocate(buffer_length);
+ const jerry_char_t* str = (const jerry_char_t*)buffer;
+
+ uint32_t current_bits = 0;
+ int32_t shift = 2;
+
+ while (data < end) {
+ current_bits = (current_bits << 8) | *data++;
+
+ *buffer++ = to_base64_char(current_bits >> shift);
+ current_bits &= (uint32_t)((1 << shift) - 1);
+
+ shift += 2;
+
+ if (shift == 8) {
+ *buffer++ = to_base64_char(current_bits);
+ current_bits = 0;
+ shift = 2;
+ }
+ }
+
+ char* buffer_end = (char*)str + buffer_length;
+ if (buffer < buffer_end) {
+ buffer[0] = to_base64_char(current_bits << (8 - shift));
+ buffer[1] = '=';
+
+ if (buffer + 2 < buffer_end)
+ buffer[2] = '=';
+ }
+
+ jerry_value_t ret_value = jerry_create_string_sz(str, buffer_length);
+ IOTJS_RELEASE(str);
+
+ return ret_value;
+}
+
+
JS_FUNCTION(ToString) {
- JS_DECLARE_THIS_PTR(bufferwrap, buffer_wrap);
- DJS_CHECK_ARGS(2, number, number);
+ DJS_CHECK_ARGS(4, object, number, number, number);
+ JS_DECLARE_OBJECT_PTR(0, bufferwrap, buffer_wrap);
+
+ double type = JS_GET_ARG(1, number);
- size_t start = iotjs_convert_double_to_sizet(JS_GET_ARG(0, number));
+ size_t start = iotjs_convert_double_to_sizet(JS_GET_ARG(2, number));
start = bound_range(start, 0, iotjs_bufferwrap_length(buffer_wrap));
- size_t end = iotjs_convert_double_to_sizet(JS_GET_ARG(1, number));
+ size_t end = iotjs_convert_double_to_sizet(JS_GET_ARG(3, number));
end = bound_range(end, 0, iotjs_bufferwrap_length(buffer_wrap));
if (end < start) {
end = start;
}
- size_t length = end - start;
-
- const char* data = buffer_wrap->buffer + start;
- length = strnlen(data, length);
+ if (start > buffer_wrap->length) {
+ start = buffer_wrap->length;
+ }
- if (!jerry_is_valid_utf8_string((const jerry_char_t*)data, length)) {
- return JS_CREATE_ERROR(TYPE, "Invalid UTF-8 string");
+ if (end > buffer_wrap->length) {
+ end = buffer_wrap->length;
}
- return jerry_create_string_sz_from_utf8((const jerry_char_t*)data, length);
-}
+ size_t length = end - start;
+ const char* data = buffer_wrap->buffer + start;
-JS_FUNCTION(ToHexString) {
- JS_DECLARE_THIS_PTR(bufferwrap, buffer_wrap);
+ if (type == BUFFER_HEX_ENC) {
+ return to_hex_string((const uint8_t*)data, length);
+ }
- size_t length = iotjs_bufferwrap_length(buffer_wrap);
- const char* data = buffer_wrap->buffer;
- JS_CHECK(data != NULL);
+ if (type == BUFFER_BASE64_ENC) {
+ return to_base64_string((const uint8_t*)data, length);
+ }
- char* buffer = iotjs_buffer_allocate(length * 2);
- iotjs_string_t str = iotjs_string_create_with_buffer(buffer, length * 2);
+ /* Stops at first zero. */
+ length = strnlen(data, length);
- for (size_t i = 0; i < length; i++) {
- memcpy(buffer, &"0123456789abcdef"[data[i] >> 4 & 0xF], 1);
- buffer++;
- memcpy(buffer, &"0123456789abcdef"[data[i] >> 0 & 0xF], 1);
- buffer++;
+ if (!jerry_is_valid_utf8_string((const jerry_char_t*)data, length)) {
+ return JS_CREATE_ERROR(TYPE, "Invalid UTF-8 string");
}
- jerry_value_t ret_value = iotjs_jval_create_string(&str);
- iotjs_string_destroy(&str);
-
- return ret_value;
+ return jerry_create_string_sz_from_utf8((const jerry_char_t*)data, length);
}
JS_FUNCTION(ByteLength) {
- DJS_CHECK_THIS();
DJS_CHECK_ARGS(1, string);
- iotjs_string_t str = JS_GET_ARG(0, string);
- jerry_value_t size = iotjs_jval_get_string_size(&str);
-
- iotjs_string_destroy(&str);
- return size;
+ jerry_size_t size = jerry_get_string_size(jargv[0]);
+ return jerry_create_number(size);
}
jerry_value_t InitBuffer() {
jerry_value_t buffer = jerry_create_external_function(Buffer);
-
- jerry_value_t prototype = jerry_create_object();
- iotjs_jval_set_property_jval(buffer, IOTJS_MAGIC_STRING_PROTOTYPE, prototype);
iotjs_jval_set_method(buffer, IOTJS_MAGIC_STRING_BYTELENGTH, ByteLength);
-
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_COMPARE, Compare);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_COPY, Copy);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_WRITE, Write);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_HEXWRITE, HexWrite);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_WRITEUINT8, WriteUInt8);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_READUINT8, ReadUInt8);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_SLICE, Slice);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_TOSTRING, ToString);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_TOHEXSTRING, ToHexString);
-
- jerry_release_value(prototype);
+ iotjs_jval_set_method(buffer, IOTJS_MAGIC_STRING_COMPARE, Compare);
+ iotjs_jval_set_method(buffer, IOTJS_MAGIC_STRING_COPY, Copy);
+ iotjs_jval_set_method(buffer, IOTJS_MAGIC_STRING_WRITE, Write);
+ iotjs_jval_set_method(buffer, IOTJS_MAGIC_STRING_WRITEDECODE, WriteDecode);
+ iotjs_jval_set_method(buffer, IOTJS_MAGIC_STRING_WRITEUINT8, WriteUInt8);
+ iotjs_jval_set_method(buffer, IOTJS_MAGIC_STRING_READUINT8, ReadUInt8);
+ iotjs_jval_set_method(buffer, IOTJS_MAGIC_STRING_SLICE, Slice);
+ iotjs_jval_set_method(buffer, IOTJS_MAGIC_STRING_TOSTRING, ToString);
return buffer;
}
iotjs_bufferwrap_t* iotjs_bufferwrap_create(const jerry_value_t jbuiltin,
size_t length);
-iotjs_bufferwrap_t* iotjs_bufferwrap_from_jbuiltin(
- const jerry_value_t jbuiltin);
iotjs_bufferwrap_t* iotjs_bufferwrap_from_jbuffer(const jerry_value_t jbuffer);
size_t iotjs_bufferwrap_length(iotjs_bufferwrap_t* bufferwrap);
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+
+#include "iotjs_def.h"
+
+#include <dlfcn.h>
+
+#define XSTR(ARG) #ARG
+#define STR(ARG) XSTR(ARG)
+
+
+jerry_value_t iotjs_load_module(const char* path) {
+ if (path == NULL) {
+ const char* error = "Invalid module path";
+ return jerry_create_error(JERRY_ERROR_TYPE, (const jerry_char_t*)error);
+ }
+
+ void* dynamic_lib = dlopen(path, RTLD_NOW);
+
+ if (dynamic_lib == NULL) {
+ const char* error = "Can not open module";
+ return jerry_create_error(JERRY_ERROR_TYPE, (const jerry_char_t*)error);
+ }
+
+ void* loader_function = dlsym(dynamic_lib, STR(IOTJS_MODULE_ENTRYPOINT));
+ if (loader_function == NULL) {
+ dlclose(dynamic_lib);
+ const char* error = "Entrypoint not found in module";
+ return jerry_create_error(JERRY_ERROR_TYPE, (const jerry_char_t*)error);
+ }
+
+ const iotjs_module* module =
+ (const iotjs_module*)((iotjs_module_info_getter)loader_function)();
+
+ if (module == NULL) {
+ dlclose(dynamic_lib);
+ const char* error = "Invalid module info";
+ return jerry_create_error(JERRY_ERROR_TYPE, (const jerry_char_t*)error);
+ }
+
+ if (module->iotjs_module_version != IOTJS_CURRENT_MODULE_VERSION) {
+ dlclose(dynamic_lib);
+ const char* error = "Incorrect version requested in the module";
+ return jerry_create_error(JERRY_ERROR_TYPE, (const jerry_char_t*)error);
+ }
+
+ return module->initializer();
+}
+
+
+JS_FUNCTION(DLload) {
+ DJS_CHECK_ARGS(1, string);
+
+ iotjs_string_t file = JS_GET_ARG(0, string);
+ const char* filename = iotjs_string_data(&file);
+
+ jerry_value_t jresult = iotjs_load_module(filename);
+
+ iotjs_string_destroy(&file);
+
+ return jresult;
+}
+
+
+jerry_value_t InitDynamicloader() {
+ jerry_value_t loader = jerry_create_external_function(DLload);
+ return loader;
+}
jerry_value_t jerror = iotjs_create_uv_exception(err, syscall_name);
jerry_value_set_error_flag(&jerror);
return jerror;
- } else {
- switch (req->fs_type) {
- case UV_FS_CLOSE:
- break;
- case UV_FS_OPEN:
- case UV_FS_READ:
- case UV_FS_WRITE:
- return jerry_create_number(err);
- case UV_FS_FSTAT:
- case UV_FS_STAT: {
- uv_stat_t* s = &(req->statbuf);
- return MakeStatObject(s);
- }
- case UV_FS_MKDIR:
- case UV_FS_RMDIR:
- case UV_FS_UNLINK:
- case UV_FS_RENAME:
- return jerry_create_undefined();
- case UV_FS_SCANDIR: {
- int r;
- uv_dirent_t ent;
- uint32_t idx = 0;
- jerry_value_t ret = jerry_create_array(0);
- while ((r = uv_fs_scandir_next(req, &ent)) != UV_EOF) {
- jerry_value_t name =
- jerry_create_string((const jerry_char_t*)ent.name);
- iotjs_jval_set_property_by_index(ret, idx, name);
- jerry_release_value(name);
- idx++;
- }
- return ret;
- }
- default: {
- IOTJS_ASSERT(false);
- break;
+ }
+
+ switch (req->fs_type) {
+ case UV_FS_CLOSE:
+ break;
+ case UV_FS_OPEN:
+ case UV_FS_READ:
+ case UV_FS_WRITE:
+ return jerry_create_number(err);
+ case UV_FS_FSTAT:
+ case UV_FS_STAT: {
+ uv_stat_t* s = &(req->statbuf);
+ return MakeStatObject(s);
+ }
+ case UV_FS_MKDIR:
+ case UV_FS_RMDIR:
+ case UV_FS_UNLINK:
+ case UV_FS_RENAME:
+ return jerry_create_undefined();
+ case UV_FS_SCANDIR: {
+ int r;
+ uv_dirent_t ent;
+ uint32_t idx = 0;
+ jerry_value_t ret = jerry_create_array(0);
+ while ((r = uv_fs_scandir_next(req, &ent)) != UV_EOF) {
+ jerry_value_t name = jerry_create_string((const jerry_char_t*)ent.name);
+ iotjs_jval_set_property_by_index(ret, idx, name);
+ jerry_release_value(name);
+ idx++;
}
+ return ret;
+ }
+ default: {
+ IOTJS_ASSERT(false);
+ break;
}
- return jerry_create_undefined();
}
+ return jerry_create_undefined();
}
static inline bool IsWithinBounds(size_t off, size_t len, size_t max) {
- if (off > max)
- return false;
-
- if (max - off < len)
+ if (off >= max || max - off < len)
return false;
return true;
iotjs_bufferwrap_t* buffer_wrap = iotjs_bufferwrap_from_jbuffer(jbuffer);
char* data = buffer_wrap->buffer;
size_t data_length = iotjs_bufferwrap_length(buffer_wrap);
- JS_CHECK(data != NULL);
- JS_CHECK(data_length > 0);
+ JS_CHECK(data != NULL && data_length > 0);
- if (offset >= data_length) {
- return JS_CREATE_ERROR(RANGE, "offset out of bound");
- }
if (!IsWithinBounds(offset, length, data_length)) {
return JS_CREATE_ERROR(RANGE, "length out of bound");
}
iotjs_bufferwrap_t* buffer_wrap = iotjs_bufferwrap_from_jbuffer(jbuffer);
char* data = buffer_wrap->buffer;
size_t data_length = iotjs_bufferwrap_length(buffer_wrap);
- JS_CHECK(data != NULL);
- JS_CHECK(data_length > 0);
+ JS_CHECK(data != NULL && data_length > 0);
- if (offset >= data_length) {
- return JS_CREATE_ERROR(RANGE, "offset out of bound");
- }
if (!IsWithinBounds(offset, length, data_length)) {
return JS_CREATE_ERROR(RANGE, "length out of bound");
}
* limitations under the License.
*/
-#include <string.h>
-
#include "iotjs_def.h"
#include "iotjs_module_gpio.h"
-#include <stdio.h>
IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE(gpio);
-static iotjs_gpio_t* gpio_create(jerry_value_t jgpio) {
- iotjs_gpio_t* gpio = IOTJS_ALLOC(iotjs_gpio_t);
- iotjs_gpio_create_platform_data(gpio);
- gpio->jobject = jgpio;
- jerry_set_object_native_pointer(jgpio, gpio, &this_module_native_info);
-
- return gpio;
-}
-
-
-static iotjs_gpio_reqwrap_t* gpio_reqwrap_create(jerry_value_t jcallback,
- iotjs_gpio_t* gpio,
- GpioOp op) {
- iotjs_gpio_reqwrap_t* gpio_reqwrap = IOTJS_ALLOC(iotjs_gpio_reqwrap_t);
-
- iotjs_reqwrap_initialize(&gpio_reqwrap->reqwrap, jcallback,
- (uv_req_t*)&gpio_reqwrap->req);
-
- gpio_reqwrap->req_data.op = op;
- gpio_reqwrap->gpio_data = gpio;
- return gpio_reqwrap;
-}
-
-
-static void gpio_reqwrap_destroy(iotjs_gpio_reqwrap_t* gpio_reqwrap) {
- iotjs_reqwrap_destroy(&gpio_reqwrap->reqwrap);
- IOTJS_RELEASE(gpio_reqwrap);
-}
-
-
-static void gpio_reqwrap_dispatched(iotjs_gpio_reqwrap_t* gpio_reqwrap) {
- gpio_reqwrap_destroy(gpio_reqwrap);
-}
-
-
-static uv_work_t* gpio_reqwrap_req(iotjs_gpio_reqwrap_t* gpio_reqwrap) {
- return &gpio_reqwrap->req;
-}
-
-
-static jerry_value_t gpio_reqwrap_jcallback(
- iotjs_gpio_reqwrap_t* gpio_reqwrap) {
- return iotjs_reqwrap_jcallback(&gpio_reqwrap->reqwrap);
-}
-
-
-static iotjs_gpio_reqwrap_t* gpio_reqwrap_from_request(uv_work_t* req) {
- return (iotjs_gpio_reqwrap_t*)(iotjs_reqwrap_from_request((uv_req_t*)req));
-}
-
-
-static iotjs_gpio_reqdata_t* gpio_reqwrap_data(
- iotjs_gpio_reqwrap_t* gpio_reqwrap) {
- return &gpio_reqwrap->req_data;
-}
-
-
-static iotjs_gpio_t* gpio_instance_from_reqwrap(
- iotjs_gpio_reqwrap_t* gpio_reqwrap) {
- return gpio_reqwrap->gpio_data;
-}
-
+IOTJS_DEFINE_PERIPH_CREATE_FUNCTION(gpio);
static void iotjs_gpio_destroy(iotjs_gpio_t* gpio) {
iotjs_gpio_destroy_platform_data(gpio->platform_data);
IOTJS_RELEASE(gpio);
}
-
-static iotjs_gpio_t* gpio_instance_from_jval(const jerry_value_t jgpio) {
- uintptr_t handle = iotjs_jval_get_object_native_handle(jgpio);
- return (iotjs_gpio_t*)handle;
-}
-
-
static void gpio_worker(uv_work_t* work_req) {
- iotjs_gpio_reqwrap_t* req_wrap = gpio_reqwrap_from_request(work_req);
- iotjs_gpio_reqdata_t* req_data = gpio_reqwrap_data(req_wrap);
- iotjs_gpio_t* gpio = gpio_instance_from_reqwrap(req_wrap);
+ iotjs_periph_reqwrap_t* req_wrap =
+ (iotjs_periph_reqwrap_t*)(iotjs_reqwrap_from_request(
+ (uv_req_t*)work_req));
+ iotjs_gpio_t* gpio = (iotjs_gpio_t*)req_wrap->data;
- switch (req_data->op) {
+ switch (req_wrap->op) {
case kGpioOpOpen:
- req_data->result = iotjs_gpio_open(gpio);
+ req_wrap->result = iotjs_gpio_open(gpio);
break;
case kGpioOpWrite:
- req_data->result = iotjs_gpio_write(gpio);
+ req_wrap->result = iotjs_gpio_write(gpio);
break;
case kGpioOpRead:
- req_data->result = iotjs_gpio_read(gpio);
+ req_wrap->result = iotjs_gpio_read(gpio);
break;
case kGpioOpClose:
- req_data->result = iotjs_gpio_close(gpio);
+ req_wrap->result = iotjs_gpio_close(gpio);
break;
default:
- IOTJS_ASSERT(!"Invalid Gpio Operation");
+ IOTJS_ASSERT(!"Invalid Operation");
}
}
-
-static void gpio_after_worker(uv_work_t* work_req, int status) {
- iotjs_gpio_reqwrap_t* req_wrap = gpio_reqwrap_from_request(work_req);
- iotjs_gpio_reqdata_t* req_data = gpio_reqwrap_data(req_wrap);
-
- iotjs_jargs_t jargs = iotjs_jargs_create(2);
- bool result = req_data->result;
-
- if (status) {
- iotjs_jargs_append_error(&jargs, "GPIO System Error");
- } else {
- switch (req_data->op) {
- case kGpioOpOpen:
- if (!result) {
- iotjs_jargs_append_error(&jargs, "GPIO Open Error");
- } else {
- iotjs_jargs_append_null(&jargs);
- }
- break;
- case kGpioOpWrite:
- if (!result) {
- iotjs_jargs_append_error(&jargs, "GPIO Write Error");
- } else {
- iotjs_jargs_append_null(&jargs);
- }
- break;
- case kGpioOpRead:
- if (!result) {
- iotjs_jargs_append_error(&jargs, "GPIO Read Error");
- } else {
- iotjs_gpio_t* gpio = gpio_instance_from_reqwrap(req_wrap);
-
- iotjs_jargs_append_null(&jargs);
- iotjs_jargs_append_bool(&jargs, gpio->value);
- }
- break;
- case kGpioOpClose:
- if (!result) {
- iotjs_jargs_append_error(&jargs, "GPIO Close Error");
- } else {
- iotjs_jargs_append_null(&jargs);
- }
- break;
- default:
- IOTJS_ASSERT(!"Unreachable");
- break;
- }
- }
-
- const jerry_value_t jcallback = gpio_reqwrap_jcallback(req_wrap);
- if (jerry_value_is_function(jcallback)) {
- iotjs_make_callback(jcallback, jerry_create_undefined(), &jargs);
- }
-
- iotjs_jargs_destroy(&jargs);
- gpio_reqwrap_dispatched(req_wrap);
-}
-
-
-static void gpio_set_configurable(iotjs_gpio_t* gpio,
- jerry_value_t jconfigurable) {
+static jerry_value_t gpio_set_configuration(iotjs_gpio_t* gpio,
+ jerry_value_t jconfigurable) {
jerry_value_t jpin =
iotjs_jval_get_property(jconfigurable, IOTJS_MAGIC_STRING_PIN);
gpio->pin = iotjs_jval_as_number(jpin);
jerry_value_t jdirection =
iotjs_jval_get_property(jconfigurable, IOTJS_MAGIC_STRING_DIRECTION);
- if (!jerry_value_is_undefined(jdirection)) {
- gpio->direction = (GpioDirection)iotjs_jval_as_number(jdirection);
- } else {
+ if (jerry_value_is_undefined(jdirection)) {
gpio->direction = kGpioDirectionOut;
+ } else {
+ if (jerry_value_is_number(jdirection)) {
+ gpio->direction = (GpioDirection)iotjs_jval_as_number(jdirection);
+ } else {
+ gpio->direction = __kGpioDirectionMax;
+ }
+ if (gpio->direction >= __kGpioDirectionMax) {
+ return JS_CREATE_ERROR(
+ TYPE, "Bad arguments - gpio.direction should be DIRECTION.IN or OUT");
+ }
}
jerry_release_value(jdirection);
jerry_value_t jmode =
iotjs_jval_get_property(jconfigurable, IOTJS_MAGIC_STRING_MODE);
- if (!jerry_value_is_undefined(jmode)) {
- gpio->mode = (GpioMode)iotjs_jval_as_number(jmode);
- } else {
+ if (jerry_value_is_undefined(jmode)) {
gpio->mode = kGpioModeNone;
+ } else {
+ if (jerry_value_is_number(jmode)) {
+ gpio->mode = (GpioMode)iotjs_jval_as_number(jmode);
+ } else {
+ gpio->mode = __kGpioModeMax;
+ }
+ if (gpio->mode >= __kGpioModeMax) {
+ return JS_CREATE_ERROR(TYPE,
+ "Bad arguments - gpio.mode should be MODE.NONE, "
+ "PULLUP, PULLDOWN, FLOAT, PUSHPULL or OPENDRAIN");
+
+ } else if (gpio->direction == kGpioDirectionIn &&
+ gpio->mode != kGpioModeNone && gpio->mode != kGpioModePullup &&
+ gpio->mode != kGpioModePulldown) {
+ return JS_CREATE_ERROR(TYPE,
+ "Bad arguments - DIRECTION.IN only supports "
+ "MODE.NONE, PULLUP and PULLDOWN");
+
+ } else if (gpio->direction == kGpioDirectionOut &&
+ gpio->mode != kGpioModeNone && gpio->mode != kGpioModeFloat &&
+ gpio->mode != kGpioModePushpull &&
+ gpio->mode != kGpioModeOpendrain) {
+ return JS_CREATE_ERROR(TYPE,
+ "Bad arguments - DIRECTION.OUT only supports "
+ "MODE.NONE, FLOAT, PUSHPULL and OPENDRAIN");
+ }
}
jerry_release_value(jmode);
jerry_value_t jedge =
iotjs_jval_get_property(jconfigurable, IOTJS_MAGIC_STRING_EDGE);
- if (!jerry_value_is_undefined(jedge)) {
- gpio->edge = (GpioEdge)iotjs_jval_as_number(jedge);
- } else {
+ if (jerry_value_is_undefined(jedge)) {
gpio->edge = kGpioEdgeNone;
+ } else {
+ if (jerry_value_is_number(jedge)) {
+ gpio->edge = (GpioEdge)iotjs_jval_as_number(jedge);
+ } else {
+ gpio->edge = __kGpioEdgeMax;
+ }
+ if (gpio->edge >= __kGpioEdgeMax) {
+ return JS_CREATE_ERROR(TYPE,
+ "Bad arguments - gpio.edge should be EDGE.NONE, "
+ "RISING, FALLING or BOTH");
+ }
}
jerry_release_value(jedge);
-}
-
-
-#define GPIO_CALL_ASYNC(op, jcallback) \
- do { \
- uv_loop_t* loop = iotjs_environment_loop(iotjs_environment_get()); \
- iotjs_gpio_reqwrap_t* req_wrap = gpio_reqwrap_create(jcallback, gpio, op); \
- uv_work_t* req = gpio_reqwrap_req(req_wrap); \
- uv_queue_work(loop, req, gpio_worker, gpio_after_worker); \
- } while (0)
+ return jerry_create_undefined();
+}
JS_FUNCTION(GpioCons) {
DJS_CHECK_THIS();
// Create GPIO object
const jerry_value_t jgpio = JS_GET_THIS();
iotjs_gpio_t* gpio = gpio_create(jgpio);
- IOTJS_ASSERT(gpio == gpio_instance_from_jval(jgpio));
- gpio_set_configurable(gpio, JS_GET_ARG(0, object));
+ jerry_value_t config_res =
+ gpio_set_configuration(gpio, JS_GET_ARG(0, object));
+ if (jerry_value_has_error_flag(config_res)) {
+ return config_res;
+ }
+ IOTJS_ASSERT(jerry_value_is_undefined(config_res));
const jerry_value_t jcallback = JS_GET_ARG_IF_EXIST(1, function);
// If the callback doesn't exist, it is completed synchronously.
// Otherwise, it will be executed asynchronously.
if (!jerry_value_is_null(jcallback)) {
- GPIO_CALL_ASYNC(kGpioOpOpen, jcallback);
+ iotjs_periph_call_async(gpio, jcallback, kGpioOpOpen, gpio_worker);
} else if (!iotjs_gpio_open(gpio)) {
- return JS_CREATE_ERROR(COMMON, "GPIO Error: cannot open GPIO");
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kGpioOpOpen));
}
return jerry_create_undefined();
}
-
JS_FUNCTION(Close) {
JS_DECLARE_THIS_PTR(gpio, gpio);
DJS_CHECK_ARG_IF_EXIST(0, function);
- GPIO_CALL_ASYNC(kGpioOpClose, JS_GET_ARG_IF_EXIST(0, function));
+ iotjs_periph_call_async(gpio, JS_GET_ARG_IF_EXIST(0, function), kGpioOpClose,
+ gpio_worker);
return jerry_create_undefined();
}
-
JS_FUNCTION(CloseSync) {
JS_DECLARE_THIS_PTR(gpio, gpio);
if (!iotjs_gpio_close(gpio)) {
- return JS_CREATE_ERROR(COMMON, "GPIO CloseSync Error");
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kGpioOpClose));
}
return jerry_create_undefined();
}
-
JS_FUNCTION(Write) {
JS_DECLARE_THIS_PTR(gpio, gpio);
} else if (jerry_value_is_boolean(jargv[0])) {
value = jerry_get_boolean_value(jargv[0]);
} else {
- return JS_CREATE_ERROR(COMMON, "GPIO Write Error - Wrong argument type");
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kGpioOpWrite));
}
DJS_CHECK_ARG_IF_EXIST(1, function);
gpio->value = value;
- GPIO_CALL_ASYNC(kGpioOpWrite, JS_GET_ARG_IF_EXIST(1, function));
+ iotjs_periph_call_async(gpio, JS_GET_ARG_IF_EXIST(1, function), kGpioOpWrite,
+ gpio_worker);
return jerry_create_undefined();
}
-
JS_FUNCTION(WriteSync) {
JS_DECLARE_THIS_PTR(gpio, gpio);
gpio->value = value;
if (!iotjs_gpio_write(gpio)) {
- return JS_CREATE_ERROR(COMMON, "GPIO WriteSync Error");
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kGpioOpWrite));
}
return jerry_create_undefined();
}
-
JS_FUNCTION(Read) {
JS_DECLARE_THIS_PTR(gpio, gpio);
DJS_CHECK_ARG_IF_EXIST(0, function);
- GPIO_CALL_ASYNC(kGpioOpRead, JS_GET_ARG_IF_EXIST(0, function));
+ iotjs_periph_call_async(gpio, JS_GET_ARG_IF_EXIST(0, function), kGpioOpRead,
+ gpio_worker);
return jerry_create_undefined();
}
-
JS_FUNCTION(ReadSync) {
JS_DECLARE_THIS_PTR(gpio, gpio);
if (!iotjs_gpio_read(gpio)) {
- return JS_CREATE_ERROR(COMMON, "GPIO ReadSync Error");
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kGpioOpRead));
}
return jerry_create_boolean(gpio->value);
}
-
jerry_value_t InitGpio() {
jerry_value_t jgpioConstructor = jerry_create_external_function(GpioCons);
#include "iotjs_def.h"
+#include "iotjs_module_periph_common.h"
#include "iotjs_reqwrap.h"
typedef enum {
kGpioDirectionIn = 0,
kGpioDirectionOut,
+ __kGpioDirectionMax
} GpioDirection;
-
typedef enum {
kGpioModeNone = 0,
kGpioModePullup,
kGpioModeFloat,
kGpioModePushpull,
kGpioModeOpendrain,
+ __kGpioModeMax
} GpioMode;
-
typedef enum {
kGpioEdgeNone = 0,
kGpioEdgeRising,
kGpioEdgeFalling,
kGpioEdgeBoth,
+ __kGpioEdgeMax
} GpioEdge;
-
-typedef enum {
- kGpioOpOpen,
- kGpioOpWrite,
- kGpioOpRead,
- kGpioOpClose,
-} GpioOp;
-
-
-typedef struct {
- GpioOp op;
- bool result;
-} iotjs_gpio_reqdata_t;
-
typedef struct iotjs_gpio_platform_data_s iotjs_gpio_platform_data_t;
// This Gpio class provides interfaces for GPIO operation.
GpioEdge edge;
} iotjs_gpio_t;
-
-typedef struct {
- iotjs_reqwrap_t reqwrap;
- uv_work_t req;
- iotjs_gpio_reqdata_t req_data;
- iotjs_gpio_t* gpio_data;
-} iotjs_gpio_reqwrap_t;
-
-
bool iotjs_gpio_open(iotjs_gpio_t* gpio);
bool iotjs_gpio_write(iotjs_gpio_t* gpio);
bool iotjs_gpio_read(iotjs_gpio_t* gpio);
--- /dev/null
+/* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "iotjs_def.h"
+#include "iotjs_module_buffer.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "http_parser.h"
+
+
+// If # of header fields == HEADER_MAX, flush header to JS side.
+// This is weired : # of maximum headers in C equals to HEADER_MAX-1.
+// This is because , OnHeaders cb, we increase n_fields first,
+// and check whether field == HEADER_MAX.
+// ex) HEADER_MAX 2 means that we can keep at most 1 header field/value
+// during http parsing.
+// Increase this to minimize inter JS-C call
+#define HEADER_MAX 10
+
+
+typedef struct {
+ jerry_value_t jobject;
+
+ http_parser parser;
+
+ iotjs_string_t url;
+ iotjs_string_t status_msg;
+
+ iotjs_string_t fields[HEADER_MAX];
+ iotjs_string_t values[HEADER_MAX];
+ size_t n_fields;
+ size_t n_values;
+
+ jerry_value_t cur_jbuf;
+ char* cur_buf;
+ size_t cur_buf_len;
+
+ bool flushed;
+} iotjs_http_parserwrap_t;
+
+
+typedef enum http_parser_type http_parser_type;
+
+
+static void iotjs_http_parserwrap_initialize(
+ iotjs_http_parserwrap_t* http_parserwrap, http_parser_type type) {
+ http_parser_init(&http_parserwrap->parser, type);
+ iotjs_string_destroy(&http_parserwrap->url);
+ iotjs_string_destroy(&http_parserwrap->status_msg);
+ http_parserwrap->n_fields = 0;
+ http_parserwrap->n_values = 0;
+ http_parserwrap->flushed = false;
+ http_parserwrap->cur_jbuf = jerry_create_null();
+ http_parserwrap->cur_buf = NULL;
+ http_parserwrap->cur_buf_len = 0;
+}
+
+
+IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE(http_parserwrap);
+
+
+static void iotjs_http_parserwrap_create(const jerry_value_t jparser,
+ http_parser_type type) {
+ iotjs_http_parserwrap_t* http_parserwrap =
+ IOTJS_ALLOC(iotjs_http_parserwrap_t);
+ http_parserwrap->jobject = jparser;
+ jerry_set_object_native_pointer(jparser, http_parserwrap,
+ &this_module_native_info);
+
+ http_parserwrap->url = iotjs_string_create();
+ http_parserwrap->status_msg = iotjs_string_create();
+ for (size_t i = 0; i < HEADER_MAX; i++) {
+ http_parserwrap->fields[i] = iotjs_string_create();
+ http_parserwrap->values[i] = iotjs_string_create();
+ }
+
+ iotjs_http_parserwrap_initialize(http_parserwrap, type);
+ http_parserwrap->parser.data = http_parserwrap;
+
+ IOTJS_ASSERT(jerry_value_is_object(http_parserwrap->jobject));
+}
+
+
+static void iotjs_http_parserwrap_destroy(
+ iotjs_http_parserwrap_t* http_parserwrap) {
+ iotjs_string_destroy(&http_parserwrap->url);
+ iotjs_string_destroy(&http_parserwrap->status_msg);
+ for (size_t i = 0; i < HEADER_MAX; i++) {
+ iotjs_string_destroy(&http_parserwrap->fields[i]);
+ iotjs_string_destroy(&http_parserwrap->values[i]);
+ }
+
+ IOTJS_RELEASE(http_parserwrap);
+}
+
+
+static jerry_value_t iotjs_http_parserwrap_make_header(
+ iotjs_http_parserwrap_t* http_parserwrap) {
+ jerry_value_t jheader = jerry_create_array(http_parserwrap->n_values * 2);
+ for (size_t i = 0; i < http_parserwrap->n_values; i++) {
+ jerry_value_t f = iotjs_jval_create_string(&http_parserwrap->fields[i]);
+ jerry_value_t v = iotjs_jval_create_string(&http_parserwrap->values[i]);
+ iotjs_jval_set_property_by_index(jheader, i * 2, f);
+ iotjs_jval_set_property_by_index(jheader, i * 2 + 1, v);
+ jerry_release_value(f);
+ jerry_release_value(v);
+ }
+ return jheader;
+}
+
+
+static void iotjs_http_parserwrap_flush(
+ iotjs_http_parserwrap_t* http_parserwrap) {
+ const jerry_value_t jobj = http_parserwrap->jobject;
+ jerry_value_t func =
+ iotjs_jval_get_property(jobj, IOTJS_MAGIC_STRING_ONHEADERS);
+ IOTJS_ASSERT(jerry_value_is_function(func));
+
+ iotjs_jargs_t argv = iotjs_jargs_create(2);
+ jerry_value_t jheader = iotjs_http_parserwrap_make_header(http_parserwrap);
+ iotjs_jargs_append_jval(&argv, jheader);
+ jerry_release_value(jheader);
+ if (http_parserwrap->parser.type == HTTP_REQUEST &&
+ !iotjs_string_is_empty(&http_parserwrap->url)) {
+ iotjs_jargs_append_string(&argv, &http_parserwrap->url);
+ }
+
+ iotjs_make_callback(func, jobj, &argv);
+
+ iotjs_string_destroy(&http_parserwrap->url);
+ iotjs_jargs_destroy(&argv);
+ jerry_release_value(func);
+ http_parserwrap->flushed = true;
+}
+
+
+static void iotjs_http_parserwrap_set_buf(
+ iotjs_http_parserwrap_t* http_parserwrap, jerry_value_t jbuf, char* buf,
+ size_t sz) {
+ http_parserwrap->cur_jbuf = jbuf;
+ http_parserwrap->cur_buf = buf;
+ http_parserwrap->cur_buf_len = sz;
+}
+
+
+// http-parser callbacks
+static int iotjs_http_parserwrap_on_message_begin(http_parser* parser) {
+ iotjs_http_parserwrap_t* http_parserwrap =
+ (iotjs_http_parserwrap_t*)(parser->data);
+ iotjs_string_destroy(&http_parserwrap->url);
+ iotjs_string_destroy(&http_parserwrap->status_msg);
+ return 0;
+}
+
+
+static int iotjs_http_parserwrap_on_url(http_parser* parser, const char* at,
+ size_t length) {
+ iotjs_http_parserwrap_t* http_parserwrap =
+ (iotjs_http_parserwrap_t*)(parser->data);
+ iotjs_string_append(&http_parserwrap->url, at, length);
+ return 0;
+}
+
+
+static int iotjs_http_parserwrap_on_status(http_parser* parser, const char* at,
+ size_t length) {
+ iotjs_http_parserwrap_t* http_parserwrap =
+ (iotjs_http_parserwrap_t*)(parser->data);
+ iotjs_string_append(&http_parserwrap->status_msg, at, length);
+ return 0;
+}
+
+
+static int iotjs_http_parserwrap_on_header_field(http_parser* parser,
+ const char* at,
+ size_t length) {
+ iotjs_http_parserwrap_t* http_parserwrap =
+ (iotjs_http_parserwrap_t*)(parser->data);
+ if (http_parserwrap->n_fields == http_parserwrap->n_values) {
+ http_parserwrap->n_fields++;
+ // values and fields are flushed to JS
+ // before corresponding OnHeaderValue is called.
+ if (http_parserwrap->n_fields == HEADER_MAX) {
+ iotjs_http_parserwrap_flush(http_parserwrap); // to JS world
+ http_parserwrap->n_fields = 1;
+ http_parserwrap->n_values = 0;
+ }
+ iotjs_string_destroy(
+ &http_parserwrap->fields[http_parserwrap->n_fields - 1]);
+ }
+ IOTJS_ASSERT(http_parserwrap->n_fields == http_parserwrap->n_values + 1);
+ iotjs_string_append(&http_parserwrap->fields[http_parserwrap->n_fields - 1],
+ at, length);
+
+ return 0;
+}
+
+
+static int iotjs_http_parserwrap_on_header_value(http_parser* parser,
+ const char* at,
+ size_t length) {
+ iotjs_http_parserwrap_t* http_parserwrap =
+ (iotjs_http_parserwrap_t*)(parser->data);
+ if (http_parserwrap->n_fields != http_parserwrap->n_values) {
+ http_parserwrap->n_values++;
+ iotjs_string_destroy(
+ &http_parserwrap->values[http_parserwrap->n_values - 1]);
+ }
+
+ IOTJS_ASSERT(http_parserwrap->n_fields == http_parserwrap->n_values);
+
+ iotjs_string_append(&http_parserwrap->values[http_parserwrap->n_values - 1],
+ at, length);
+
+ return 0;
+}
+
+
+static int iotjs_http_parserwrap_on_headers_complete(http_parser* parser) {
+ iotjs_http_parserwrap_t* http_parserwrap =
+ (iotjs_http_parserwrap_t*)(parser->data);
+ const jerry_value_t jobj = http_parserwrap->jobject;
+ jerry_value_t func =
+ iotjs_jval_get_property(jobj, IOTJS_MAGIC_STRING_ONHEADERSCOMPLETE);
+ IOTJS_ASSERT(jerry_value_is_function(func));
+
+ // URL
+ iotjs_jargs_t argv = iotjs_jargs_create(1);
+ jerry_value_t info = jerry_create_object();
+
+ if (http_parserwrap->flushed) {
+ // If some headers already are flushed,
+ // flush the remaining headers.
+ // In Flush function, url is already flushed to JS.
+ iotjs_http_parserwrap_flush(http_parserwrap);
+ } else {
+ // Here, there was no flushed header.
+ // We need to make a new header object with all header fields
+ jerry_value_t jheader = iotjs_http_parserwrap_make_header(http_parserwrap);
+ iotjs_jval_set_property_jval(info, IOTJS_MAGIC_STRING_HEADERS, jheader);
+ jerry_release_value(jheader);
+ if (http_parserwrap->parser.type == HTTP_REQUEST) {
+ IOTJS_ASSERT(!iotjs_string_is_empty(&http_parserwrap->url));
+ iotjs_jval_set_property_string(info, IOTJS_MAGIC_STRING_URL,
+ &http_parserwrap->url);
+ }
+ }
+ http_parserwrap->n_fields = http_parserwrap->n_values = 0;
+
+ // Method
+ if (http_parserwrap->parser.type == HTTP_REQUEST) {
+ iotjs_jval_set_property_number(info, IOTJS_MAGIC_STRING_METHOD,
+ http_parserwrap->parser.method);
+ }
+ // Status
+ else if (http_parserwrap->parser.type == HTTP_RESPONSE) {
+ iotjs_jval_set_property_number(info, IOTJS_MAGIC_STRING_STATUS,
+ http_parserwrap->parser.status_code);
+ iotjs_jval_set_property_string(info, IOTJS_MAGIC_STRING_STATUS_MSG,
+ &http_parserwrap->status_msg);
+ }
+
+
+ // For future support, current http_server module does not support
+ // upgrade and keepalive.
+ // upgrade
+ iotjs_jval_set_property_boolean(info, IOTJS_MAGIC_STRING_UPGRADE,
+ http_parserwrap->parser.upgrade);
+ // shouldkeepalive
+ iotjs_jval_set_property_boolean(info, IOTJS_MAGIC_STRING_SHOULDKEEPALIVE,
+ http_should_keep_alive(
+ &http_parserwrap->parser));
+
+
+ iotjs_jargs_append_jval(&argv, info);
+
+ jerry_value_t res = iotjs_make_callback_with_result(func, jobj, &argv);
+
+ int ret = 1;
+ if (jerry_value_is_boolean(res)) {
+ ret = iotjs_jval_as_boolean(res);
+ } else if (jerry_value_is_object(res)) {
+ // if exception throw occurs in iotjs_make_callback_with_result, then the
+ // result can be an object.
+ ret = 0;
+ }
+
+ iotjs_jargs_destroy(&argv);
+ jerry_release_value(func);
+ jerry_release_value(res);
+ jerry_release_value(info);
+
+ return ret;
+}
+
+
+static int iotjs_http_parserwrap_on_body(http_parser* parser, const char* at,
+ size_t length) {
+ iotjs_http_parserwrap_t* http_parserwrap =
+ (iotjs_http_parserwrap_t*)(parser->data);
+ const jerry_value_t jobj = http_parserwrap->jobject;
+ jerry_value_t func = iotjs_jval_get_property(jobj, IOTJS_MAGIC_STRING_ONBODY);
+ IOTJS_ASSERT(jerry_value_is_function(func));
+
+ iotjs_jargs_t argv = iotjs_jargs_create(3);
+ iotjs_jargs_append_jval(&argv, http_parserwrap->cur_jbuf);
+ iotjs_jargs_append_number(&argv, at - http_parserwrap->cur_buf);
+ iotjs_jargs_append_number(&argv, length);
+
+
+ iotjs_make_callback(func, jobj, &argv);
+
+ iotjs_jargs_destroy(&argv);
+ jerry_release_value(func);
+
+ return 0;
+}
+
+
+static int iotjs_http_parserwrap_on_message_complete(http_parser* parser) {
+ iotjs_http_parserwrap_t* http_parserwrap =
+ (iotjs_http_parserwrap_t*)(parser->data);
+ const jerry_value_t jobj = http_parserwrap->jobject;
+ jerry_value_t func =
+ iotjs_jval_get_property(jobj, IOTJS_MAGIC_STRING_ONMESSAGECOMPLETE);
+ IOTJS_ASSERT(jerry_value_is_function(func));
+
+ iotjs_make_callback(func, jobj, iotjs_jargs_get_empty());
+
+ jerry_release_value(func);
+
+ return 0;
+}
+
+
+const struct http_parser_settings settings = {
+ iotjs_http_parserwrap_on_message_begin,
+ iotjs_http_parserwrap_on_url,
+ iotjs_http_parserwrap_on_status,
+ iotjs_http_parserwrap_on_header_field,
+ iotjs_http_parserwrap_on_header_value,
+ iotjs_http_parserwrap_on_headers_complete,
+ iotjs_http_parserwrap_on_body,
+ iotjs_http_parserwrap_on_message_complete,
+ NULL, /* on_chunk_header */
+ NULL, /* on_chunk_complete */
+};
+
+
+static jerry_value_t iotjs_http_parser_return_parserrror(
+ http_parser* nativeparser) {
+ enum http_errno err = HTTP_PARSER_ERRNO(nativeparser);
+
+ jerry_value_t eobj =
+ iotjs_jval_create_error_without_error_flag("Parse Error");
+ iotjs_jval_set_property_number(eobj, IOTJS_MAGIC_STRING_BYTEPARSED, 0);
+ iotjs_jval_set_property_string_raw(eobj, IOTJS_MAGIC_STRING_CODE,
+ http_errno_name(err));
+ return eobj;
+}
+
+
+JS_FUNCTION(Reinitialize) {
+ JS_DECLARE_THIS_PTR(http_parserwrap, parser);
+ DJS_CHECK_ARGS(1, number);
+
+ http_parser_type httpparser_type = (http_parser_type)(JS_GET_ARG(0, number));
+
+ if (httpparser_type != HTTP_REQUEST && httpparser_type != HTTP_RESPONSE) {
+ return JS_CREATE_ERROR(TYPE, "Invalid type");
+ }
+
+ iotjs_http_parserwrap_initialize(parser, httpparser_type);
+
+ return jerry_create_undefined();
+}
+
+
+JS_FUNCTION(Finish) {
+ JS_DECLARE_THIS_PTR(http_parserwrap, parser);
+
+ http_parser* nativeparser = &parser->parser;
+ size_t rv = http_parser_execute(nativeparser, &settings, NULL, 0);
+
+ if (rv != 0) {
+ return iotjs_http_parser_return_parserrror(nativeparser);
+ }
+
+ return jerry_create_undefined();
+}
+
+
+JS_FUNCTION(Execute) {
+ JS_DECLARE_THIS_PTR(http_parserwrap, parser);
+ DJS_CHECK_ARGS(1, object);
+
+ jerry_value_t jbuffer = JS_GET_ARG(0, object);
+ iotjs_bufferwrap_t* buffer_wrap = iotjs_bufferwrap_from_jbuffer(jbuffer);
+ char* buf_data = buffer_wrap->buffer;
+ size_t buf_len = iotjs_bufferwrap_length(buffer_wrap);
+ JS_CHECK(buf_data != NULL && buf_len > 0);
+
+ iotjs_http_parserwrap_set_buf(parser, jbuffer, buf_data, buf_len);
+
+ http_parser* nativeparser = &parser->parser;
+ size_t nparsed =
+ http_parser_execute(nativeparser, &settings, buf_data, buf_len);
+
+ iotjs_http_parserwrap_set_buf(parser, jerry_create_null(), NULL, 0);
+
+
+ if (!nativeparser->upgrade && nparsed != buf_len) {
+ // nparsed should equal to buf_len except UPGRADE protocol
+ return iotjs_http_parser_return_parserrror(nativeparser);
+ } else {
+ return jerry_create_number(nparsed);
+ }
+}
+
+
+static jerry_value_t iotjs_http_parser_pause(jerry_value_t jthis, int paused) {
+ JS_DECLARE_THIS_PTR(http_parserwrap, parser);
+
+ http_parser* nativeparser = &parser->parser;
+ http_parser_pause(nativeparser, paused);
+ return jerry_create_undefined();
+}
+
+
+JS_FUNCTION(Pause) {
+ return iotjs_http_parser_pause(jthis, 1);
+}
+
+
+JS_FUNCTION(Resume) {
+ return iotjs_http_parser_pause(jthis, 0);
+}
+
+
+JS_FUNCTION(HTTPParserCons) {
+ DJS_CHECK_THIS();
+ DJS_CHECK_ARGS(1, number);
+
+ const jerry_value_t jparser = JS_GET_THIS();
+
+ http_parser_type httpparser_type = (http_parser_type)(JS_GET_ARG(0, number));
+
+ if (httpparser_type != HTTP_REQUEST && httpparser_type != HTTP_RESPONSE) {
+ return JS_CREATE_ERROR(TYPE, "Invalid type");
+ }
+
+ iotjs_http_parserwrap_create(jparser, httpparser_type);
+ return jerry_create_undefined();
+}
+
+
+jerry_value_t InitHttpParser() {
+ jerry_value_t http_parser = jerry_create_object();
+
+ jerry_value_t jParserCons = jerry_create_external_function(HTTPParserCons);
+ iotjs_jval_set_property_jval(http_parser, IOTJS_MAGIC_STRING_HTTPPARSER,
+ jParserCons);
+
+ iotjs_jval_set_property_number(jParserCons, IOTJS_MAGIC_STRING_REQUEST_U,
+ HTTP_REQUEST);
+ iotjs_jval_set_property_number(jParserCons, IOTJS_MAGIC_STRING_RESPONSE_U,
+ HTTP_RESPONSE);
+
+ jerry_value_t methods = jerry_create_object();
+#define V(num, name, string) \
+ iotjs_jval_set_property_string_raw(methods, #num, #string);
+ HTTP_METHOD_MAP(V)
+#undef V
+
+ iotjs_jval_set_property_jval(jParserCons, IOTJS_MAGIC_STRING_METHODS,
+ methods);
+
+ jerry_value_t prototype = jerry_create_object();
+
+ iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_EXECUTE, Execute);
+ iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_REINITIALIZE,
+ Reinitialize);
+ iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_FINISH, Finish);
+ iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_PAUSE, Pause);
+ iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_RESUME, Resume);
+
+ iotjs_jval_set_property_jval(jParserCons, IOTJS_MAGIC_STRING_PROTOTYPE,
+ prototype);
+
+ jerry_release_value(jParserCons);
+ jerry_release_value(methods);
+ jerry_release_value(prototype);
+
+ return http_parser;
+}
+++ /dev/null
-/* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "iotjs_def.h"
-#include "iotjs_module_buffer.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "http_parser.h"
-
-
-// If # of header fields == HEADER_MAX, flush header to JS side.
-// This is weired : # of maximum headers in C equals to HEADER_MAX-1.
-// This is because , OnHeaders cb, we increase n_fields first,
-// and check whether field == HEADER_MAX.
-// ex) HEADER_MAX 2 means that we can keep at most 1 header field/value
-// during http parsing.
-// Increase this to minimize inter JS-C call
-#define HEADER_MAX 10
-
-
-typedef struct {
- jerry_value_t jobject;
-
- http_parser parser;
-
- iotjs_string_t url;
- iotjs_string_t status_msg;
-
- iotjs_string_t fields[HEADER_MAX];
- iotjs_string_t values[HEADER_MAX];
- size_t n_fields;
- size_t n_values;
-
- jerry_value_t cur_jbuf;
- char* cur_buf;
- size_t cur_buf_len;
-
- bool flushed;
-} iotjs_httpparserwrap_t;
-
-
-typedef enum http_parser_type http_parser_type;
-
-
-static void iotjs_httpparserwrap_initialize(
- iotjs_httpparserwrap_t* httpparserwrap, http_parser_type type) {
- http_parser_init(&httpparserwrap->parser, type);
- iotjs_string_make_empty(&httpparserwrap->url);
- iotjs_string_make_empty(&httpparserwrap->status_msg);
- httpparserwrap->n_fields = 0;
- httpparserwrap->n_values = 0;
- httpparserwrap->flushed = false;
- httpparserwrap->cur_jbuf = jerry_create_null();
- httpparserwrap->cur_buf = NULL;
- httpparserwrap->cur_buf_len = 0;
-}
-
-
-IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE(httpparserwrap);
-
-
-static void iotjs_httpparserwrap_create(const jerry_value_t jparser,
- http_parser_type type) {
- iotjs_httpparserwrap_t* httpparserwrap = IOTJS_ALLOC(iotjs_httpparserwrap_t);
- httpparserwrap->jobject = jparser;
- jerry_set_object_native_pointer(jparser, httpparserwrap,
- &this_module_native_info);
-
- httpparserwrap->url = iotjs_string_create();
- httpparserwrap->status_msg = iotjs_string_create();
- for (size_t i = 0; i < HEADER_MAX; i++) {
- httpparserwrap->fields[i] = iotjs_string_create();
- httpparserwrap->values[i] = iotjs_string_create();
- }
-
- iotjs_httpparserwrap_initialize(httpparserwrap, type);
- httpparserwrap->parser.data = httpparserwrap;
-
- IOTJS_ASSERT(jerry_value_is_object(httpparserwrap->jobject));
-}
-
-
-static void iotjs_httpparserwrap_destroy(
- iotjs_httpparserwrap_t* httpparserwrap) {
- iotjs_string_destroy(&httpparserwrap->url);
- iotjs_string_destroy(&httpparserwrap->status_msg);
- for (size_t i = 0; i < HEADER_MAX; i++) {
- iotjs_string_destroy(&httpparserwrap->fields[i]);
- iotjs_string_destroy(&httpparserwrap->values[i]);
- }
-
- IOTJS_RELEASE(httpparserwrap);
-}
-
-
-static jerry_value_t iotjs_httpparserwrap_make_header(
- iotjs_httpparserwrap_t* httpparserwrap) {
- jerry_value_t jheader = jerry_create_array(httpparserwrap->n_values * 2);
- for (size_t i = 0; i < httpparserwrap->n_values; i++) {
- jerry_value_t f = iotjs_jval_create_string(&httpparserwrap->fields[i]);
- jerry_value_t v = iotjs_jval_create_string(&httpparserwrap->values[i]);
- iotjs_jval_set_property_by_index(jheader, i * 2, f);
- iotjs_jval_set_property_by_index(jheader, i * 2 + 1, v);
- jerry_release_value(f);
- jerry_release_value(v);
- }
- return jheader;
-}
-
-
-static void iotjs_httpparserwrap_flush(iotjs_httpparserwrap_t* httpparserwrap) {
- const jerry_value_t jobj = httpparserwrap->jobject;
- jerry_value_t func =
- iotjs_jval_get_property(jobj, IOTJS_MAGIC_STRING_ONHEADERS);
- IOTJS_ASSERT(jerry_value_is_function(func));
-
- iotjs_jargs_t argv = iotjs_jargs_create(2);
- jerry_value_t jheader = iotjs_httpparserwrap_make_header(httpparserwrap);
- iotjs_jargs_append_jval(&argv, jheader);
- jerry_release_value(jheader);
- if (httpparserwrap->parser.type == HTTP_REQUEST &&
- !iotjs_string_is_empty(&httpparserwrap->url)) {
- iotjs_jargs_append_string(&argv, &httpparserwrap->url);
- }
-
- iotjs_make_callback(func, jobj, &argv);
-
- iotjs_string_make_empty(&httpparserwrap->url);
- iotjs_jargs_destroy(&argv);
- jerry_release_value(func);
- httpparserwrap->flushed = true;
-}
-
-
-static void iotjs_httpparserwrap_set_buf(iotjs_httpparserwrap_t* httpparserwrap,
- jerry_value_t jbuf, char* buf,
- size_t sz) {
- httpparserwrap->cur_jbuf = jbuf;
- httpparserwrap->cur_buf = buf;
- httpparserwrap->cur_buf_len = sz;
-}
-
-
-// http-parser callbacks
-static int iotjs_httpparserwrap_on_message_begin(http_parser* parser) {
- iotjs_httpparserwrap_t* httpparserwrap =
- (iotjs_httpparserwrap_t*)(parser->data);
- iotjs_string_make_empty(&httpparserwrap->url);
- iotjs_string_make_empty(&httpparserwrap->status_msg);
- return 0;
-}
-
-
-static int iotjs_httpparserwrap_on_url(http_parser* parser, const char* at,
- size_t length) {
- iotjs_httpparserwrap_t* httpparserwrap =
- (iotjs_httpparserwrap_t*)(parser->data);
- iotjs_string_append(&httpparserwrap->url, at, length);
- return 0;
-}
-
-
-static int iotjs_httpparserwrap_on_status(http_parser* parser, const char* at,
- size_t length) {
- iotjs_httpparserwrap_t* httpparserwrap =
- (iotjs_httpparserwrap_t*)(parser->data);
- iotjs_string_append(&httpparserwrap->status_msg, at, length);
- return 0;
-}
-
-
-static int iotjs_httpparserwrap_on_header_field(http_parser* parser,
- const char* at, size_t length) {
- iotjs_httpparserwrap_t* httpparserwrap =
- (iotjs_httpparserwrap_t*)(parser->data);
- if (httpparserwrap->n_fields == httpparserwrap->n_values) {
- httpparserwrap->n_fields++;
- // values and fields are flushed to JS
- // before corresponding OnHeaderValue is called.
- if (httpparserwrap->n_fields == HEADER_MAX) {
- iotjs_httpparserwrap_flush(httpparserwrap); // to JS world
- httpparserwrap->n_fields = 1;
- httpparserwrap->n_values = 0;
- }
- iotjs_string_make_empty(
- &httpparserwrap->fields[httpparserwrap->n_fields - 1]);
- }
- IOTJS_ASSERT(httpparserwrap->n_fields == httpparserwrap->n_values + 1);
- iotjs_string_append(&httpparserwrap->fields[httpparserwrap->n_fields - 1], at,
- length);
-
- return 0;
-}
-
-
-static int iotjs_httpparserwrap_on_header_value(http_parser* parser,
- const char* at, size_t length) {
- iotjs_httpparserwrap_t* httpparserwrap =
- (iotjs_httpparserwrap_t*)(parser->data);
- if (httpparserwrap->n_fields != httpparserwrap->n_values) {
- httpparserwrap->n_values++;
- iotjs_string_make_empty(
- &httpparserwrap->values[httpparserwrap->n_values - 1]);
- }
-
- IOTJS_ASSERT(httpparserwrap->n_fields == httpparserwrap->n_values);
-
- iotjs_string_append(&httpparserwrap->values[httpparserwrap->n_values - 1], at,
- length);
-
- return 0;
-}
-
-
-static int iotjs_httpparserwrap_on_headers_complete(http_parser* parser) {
- iotjs_httpparserwrap_t* httpparserwrap =
- (iotjs_httpparserwrap_t*)(parser->data);
- const jerry_value_t jobj = httpparserwrap->jobject;
- jerry_value_t func =
- iotjs_jval_get_property(jobj, IOTJS_MAGIC_STRING_ONHEADERSCOMPLETE);
- IOTJS_ASSERT(jerry_value_is_function(func));
-
- // URL
- iotjs_jargs_t argv = iotjs_jargs_create(1);
- jerry_value_t info = jerry_create_object();
-
- if (httpparserwrap->flushed) {
- // If some headers already are flushed,
- // flush the remaining headers.
- // In Flush function, url is already flushed to JS.
- iotjs_httpparserwrap_flush(httpparserwrap);
- } else {
- // Here, there was no flushed header.
- // We need to make a new header object with all header fields
- jerry_value_t jheader = iotjs_httpparserwrap_make_header(httpparserwrap);
- iotjs_jval_set_property_jval(info, IOTJS_MAGIC_STRING_HEADERS, jheader);
- jerry_release_value(jheader);
- if (httpparserwrap->parser.type == HTTP_REQUEST) {
- IOTJS_ASSERT(!iotjs_string_is_empty(&httpparserwrap->url));
- iotjs_jval_set_property_string(info, IOTJS_MAGIC_STRING_URL,
- &httpparserwrap->url);
- }
- }
- httpparserwrap->n_fields = httpparserwrap->n_values = 0;
-
- // Method
- if (httpparserwrap->parser.type == HTTP_REQUEST) {
- iotjs_jval_set_property_number(info, IOTJS_MAGIC_STRING_METHOD,
- httpparserwrap->parser.method);
- }
- // Status
- else if (httpparserwrap->parser.type == HTTP_RESPONSE) {
- iotjs_jval_set_property_number(info, IOTJS_MAGIC_STRING_STATUS,
- httpparserwrap->parser.status_code);
- iotjs_jval_set_property_string(info, IOTJS_MAGIC_STRING_STATUS_MSG,
- &httpparserwrap->status_msg);
- }
-
-
- // For future support, current http_server module does not support
- // upgrade and keepalive.
- // upgrade
- iotjs_jval_set_property_boolean(info, IOTJS_MAGIC_STRING_UPGRADE,
- httpparserwrap->parser.upgrade);
- // shouldkeepalive
- iotjs_jval_set_property_boolean(info, IOTJS_MAGIC_STRING_SHOULDKEEPALIVE,
- http_should_keep_alive(
- &httpparserwrap->parser));
-
-
- iotjs_jargs_append_jval(&argv, info);
-
- jerry_value_t res = iotjs_make_callback_with_result(func, jobj, &argv);
-
- int ret = 1;
- if (jerry_value_is_boolean(res)) {
- ret = iotjs_jval_as_boolean(res);
- } else if (jerry_value_is_object(res)) {
- // if exception throw occurs in iotjs_make_callback_with_result, then the
- // result can be an object.
- ret = 0;
- }
-
- iotjs_jargs_destroy(&argv);
- jerry_release_value(func);
- jerry_release_value(res);
- jerry_release_value(info);
-
- return ret;
-}
-
-
-static int iotjs_httpparserwrap_on_body(http_parser* parser, const char* at,
- size_t length) {
- iotjs_httpparserwrap_t* httpparserwrap =
- (iotjs_httpparserwrap_t*)(parser->data);
- const jerry_value_t jobj = httpparserwrap->jobject;
- jerry_value_t func = iotjs_jval_get_property(jobj, IOTJS_MAGIC_STRING_ONBODY);
- IOTJS_ASSERT(jerry_value_is_function(func));
-
- iotjs_jargs_t argv = iotjs_jargs_create(3);
- iotjs_jargs_append_jval(&argv, httpparserwrap->cur_jbuf);
- iotjs_jargs_append_number(&argv, at - httpparserwrap->cur_buf);
- iotjs_jargs_append_number(&argv, length);
-
-
- iotjs_make_callback(func, jobj, &argv);
-
- iotjs_jargs_destroy(&argv);
- jerry_release_value(func);
-
- return 0;
-}
-
-
-static int iotjs_httpparserwrap_on_message_complete(http_parser* parser) {
- iotjs_httpparserwrap_t* httpparserwrap =
- (iotjs_httpparserwrap_t*)(parser->data);
- const jerry_value_t jobj = httpparserwrap->jobject;
- jerry_value_t func =
- iotjs_jval_get_property(jobj, IOTJS_MAGIC_STRING_ONMESSAGECOMPLETE);
- IOTJS_ASSERT(jerry_value_is_function(func));
-
- iotjs_make_callback(func, jobj, iotjs_jargs_get_empty());
-
- jerry_release_value(func);
-
- return 0;
-}
-
-
-const struct http_parser_settings settings = {
- iotjs_httpparserwrap_on_message_begin,
- iotjs_httpparserwrap_on_url,
- iotjs_httpparserwrap_on_status,
- iotjs_httpparserwrap_on_header_field,
- iotjs_httpparserwrap_on_header_value,
- iotjs_httpparserwrap_on_headers_complete,
- iotjs_httpparserwrap_on_body,
- iotjs_httpparserwrap_on_message_complete,
- NULL, /* on_chunk_header */
- NULL, /* on_chunk_complete */
-};
-
-
-static jerry_value_t iotjs_httpparser_return_parserrror(
- http_parser* nativeparser) {
- enum http_errno err = HTTP_PARSER_ERRNO(nativeparser);
-
- jerry_value_t eobj =
- iotjs_jval_create_error_without_error_flag("Parse Error");
- iotjs_jval_set_property_number(eobj, IOTJS_MAGIC_STRING_BYTEPARSED, 0);
- iotjs_jval_set_property_string_raw(eobj, IOTJS_MAGIC_STRING_CODE,
- http_errno_name(err));
- return eobj;
-}
-
-
-JS_FUNCTION(Reinitialize) {
- JS_DECLARE_THIS_PTR(httpparserwrap, parser);
- DJS_CHECK_ARGS(1, number);
-
- http_parser_type httpparser_type = (http_parser_type)(JS_GET_ARG(0, number));
- IOTJS_ASSERT(httpparser_type == HTTP_REQUEST ||
- httpparser_type == HTTP_RESPONSE);
-
- iotjs_httpparserwrap_initialize(parser, httpparser_type);
-
- return jerry_create_undefined();
-}
-
-
-JS_FUNCTION(Finish) {
- JS_DECLARE_THIS_PTR(httpparserwrap, parser);
-
- http_parser* nativeparser = &parser->parser;
- size_t rv = http_parser_execute(nativeparser, &settings, NULL, 0);
-
- if (rv != 0) {
- return iotjs_httpparser_return_parserrror(nativeparser);
- }
-
- return jerry_create_undefined();
-}
-
-
-JS_FUNCTION(Execute) {
- JS_DECLARE_THIS_PTR(httpparserwrap, parser);
- DJS_CHECK_ARGS(1, object);
-
- jerry_value_t jbuffer = JS_GET_ARG(0, object);
- iotjs_bufferwrap_t* buffer_wrap = iotjs_bufferwrap_from_jbuffer(jbuffer);
- char* buf_data = buffer_wrap->buffer;
- size_t buf_len = iotjs_bufferwrap_length(buffer_wrap);
- JS_CHECK(buf_data != NULL);
- JS_CHECK(buf_len > 0);
-
- iotjs_httpparserwrap_set_buf(parser, jbuffer, buf_data, buf_len);
-
- http_parser* nativeparser = &parser->parser;
- size_t nparsed =
- http_parser_execute(nativeparser, &settings, buf_data, buf_len);
-
- iotjs_httpparserwrap_set_buf(parser, jerry_create_null(), NULL, 0);
-
-
- if (!nativeparser->upgrade && nparsed != buf_len) {
- // nparsed should equal to buf_len except UPGRADE protocol
- return iotjs_httpparser_return_parserrror(nativeparser);
- } else {
- return jerry_create_number(nparsed);
- }
-}
-
-
-static jerry_value_t iotjs_httpparser_pause(jerry_value_t jthis, int paused) {
- JS_DECLARE_THIS_PTR(httpparserwrap, parser);
-
- http_parser* nativeparser = &parser->parser;
- http_parser_pause(nativeparser, paused);
- return jerry_create_undefined();
-}
-
-
-JS_FUNCTION(Pause) {
- return iotjs_httpparser_pause(jthis, 1);
-}
-
-
-JS_FUNCTION(Resume) {
- return iotjs_httpparser_pause(jthis, 0);
-}
-
-
-JS_FUNCTION(HTTPParserCons) {
- DJS_CHECK_THIS();
- DJS_CHECK_ARGS(1, number);
-
- const jerry_value_t jparser = JS_GET_THIS();
-
- http_parser_type httpparser_type = (http_parser_type)(JS_GET_ARG(0, number));
- IOTJS_ASSERT(httpparser_type == HTTP_REQUEST ||
- httpparser_type == HTTP_RESPONSE);
- iotjs_httpparserwrap_create(jparser, httpparser_type);
- return jerry_create_undefined();
-}
-
-
-jerry_value_t InitHttpparser() {
- jerry_value_t httpparser = jerry_create_object();
-
- jerry_value_t jParserCons = jerry_create_external_function(HTTPParserCons);
- iotjs_jval_set_property_jval(httpparser, IOTJS_MAGIC_STRING_HTTPPARSER,
- jParserCons);
-
- iotjs_jval_set_property_number(jParserCons, IOTJS_MAGIC_STRING_REQUEST_U,
- HTTP_REQUEST);
- iotjs_jval_set_property_number(jParserCons, IOTJS_MAGIC_STRING_RESPONSE_U,
- HTTP_RESPONSE);
-
- jerry_value_t methods = jerry_create_object();
-#define V(num, name, string) \
- iotjs_jval_set_property_string_raw(methods, #num, #string);
- HTTP_METHOD_MAP(V)
-#undef V
-
- iotjs_jval_set_property_jval(jParserCons, IOTJS_MAGIC_STRING_METHODS,
- methods);
-
- jerry_value_t prototype = jerry_create_object();
-
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_EXECUTE, Execute);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_REINITIALIZE,
- Reinitialize);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_FINISH, Finish);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_PAUSE, Pause);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_RESUME, Resume);
-
- iotjs_jval_set_property_jval(jParserCons, IOTJS_MAGIC_STRING_PROTOTYPE,
- prototype);
-
- jerry_release_value(jParserCons);
- jerry_release_value(methods);
- jerry_release_value(prototype);
-
- return httpparser;
-}
+++ /dev/null
-/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "iotjs_module_https.h"
-#include <inttypes.h>
-#include <limits.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "iotjs_module_buffer.h"
-
-// A Per-Request Struct, native bound to https.ClientRequest
-struct iotjs_https_t {
- // Original Request Details
- const char* URL;
- HTTPS_Methods method;
- struct curl_slist* header_list;
- // TLS certs Options
- const char* ca;
- const char* cert;
- const char* key;
- bool reject_unauthorized;
- // Content-Length for Post and Put
- long content_length;
-
- // Handles
- uv_loop_t* loop;
- jerry_value_t jthis_native;
- CURLM* curl_multi_handle;
- uv_timer_t timeout;
- CURL* curl_easy_handle;
- // Curl Context
- int running_handles;
- int closing_handles;
- bool request_done;
- iotjs_https_poll_t* poll_data;
-
- // For SetTimeOut
- uv_timer_t socket_timeout;
- long timeout_ms;
- double last_bytes_num;
- uint64_t last_bytes_time;
-
- // For Writable Stream ClientRequest
- size_t cur_read_index;
- bool is_stream_writable;
- bool data_to_read;
- bool stream_ended;
- bool to_destroy_read_onwrite;
- iotjs_string_t read_chunk;
- jerry_value_t read_callback;
- jerry_value_t read_onwrite;
- uv_timer_t async_read_onwrite;
-};
-
-struct iotjs_https_poll_t {
- uv_poll_t poll_handle;
- iotjs_https_poll_t* next;
- iotjs_https_t* https_data;
- curl_socket_t sockfd;
- bool closing;
-};
-
-IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE(https);
-
-//-------------Constructor------------
-iotjs_https_t* iotjs_https_create(const char* URL, const char* method,
- const char* ca, const char* cert,
- const char* key,
- const bool reject_unauthorized,
- jerry_value_t jthis) {
- iotjs_https_t* https_data = IOTJS_ALLOC(iotjs_https_t);
-
- // Original Request Details
- https_data->URL = URL;
- https_data->header_list = NULL;
- if (strcmp(method, STRING_GET) == 0)
- https_data->method = HTTPS_GET;
- else if (strcmp(method, STRING_POST) == 0)
- https_data->method = HTTPS_POST;
- else if (strcmp(method, STRING_PUT) == 0)
- https_data->method = HTTPS_PUT;
- else if (strcmp(method, STRING_DELETE) == 0)
- https_data->method = HTTPS_DELETE;
- else if (strcmp(method, STRING_HEAD) == 0)
- https_data->method = HTTPS_HEAD;
- else if (strcmp(method, STRING_CONNECT) == 0)
- https_data->method = HTTPS_CONNECT;
- else if (strcmp(method, STRING_OPTIONS) == 0)
- https_data->method = HTTPS_OPTIONS;
- else if (strcmp(method, STRING_TRACE) == 0)
- https_data->method = HTTPS_TRACE;
- else {
- IOTJS_ASSERT(0);
- }
-
- // TLS certs stuff
- https_data->ca = ca;
- https_data->cert = cert;
- https_data->key = key;
- https_data->reject_unauthorized = reject_unauthorized;
- // Content Length stuff
- https_data->content_length = -1;
-
- // Handles
- https_data->loop = iotjs_environment_loop(iotjs_environment_get());
- https_data->jthis_native = jerry_acquire_value(jthis);
- jerry_set_object_native_pointer(https_data->jthis_native, https_data,
- &this_module_native_info);
- https_data->curl_multi_handle = curl_multi_init();
- https_data->curl_easy_handle = curl_easy_init();
- https_data->timeout.data = (void*)https_data;
- uv_timer_init(https_data->loop, &(https_data->timeout));
- https_data->request_done = false;
- https_data->closing_handles = 3;
- https_data->poll_data = NULL;
-
- // Timeout stuff
- https_data->timeout_ms = -1;
- https_data->last_bytes_num = -1;
- https_data->last_bytes_time = 0;
- https_data->socket_timeout.data = (void*)https_data;
- uv_timer_init(https_data->loop, &(https_data->socket_timeout));
-
- // ReadData stuff
- https_data->cur_read_index = 0;
- https_data->is_stream_writable = false;
- https_data->stream_ended = false;
- https_data->data_to_read = false;
- https_data->to_destroy_read_onwrite = false;
- https_data->async_read_onwrite.data = (void*)https_data;
- uv_timer_init(https_data->loop, &(https_data->async_read_onwrite));
- // No Need to read data for following types of requests
- if (https_data->method == HTTPS_GET || https_data->method == HTTPS_DELETE ||
- https_data->method == HTTPS_HEAD || https_data->method == HTTPS_OPTIONS ||
- https_data->method == HTTPS_TRACE)
- https_data->stream_ended = true;
-
- return https_data;
-}
-
-// Destructor
-void iotjs_https_destroy(iotjs_https_t* https_data) {
- https_data->URL = NULL;
- IOTJS_RELEASE(https_data);
-}
-
-//----------------Utility Functions------------------
-void iotjs_https_check_done(iotjs_https_t* https_data) {
- char* done_url;
- CURLMsg* message;
- int pending;
- bool error = false;
-
- while ((message =
- curl_multi_info_read(https_data->curl_multi_handle, &pending))) {
- switch (message->msg) {
- case CURLMSG_DONE:
- curl_easy_getinfo(message->easy_handle, CURLINFO_EFFECTIVE_URL,
- &done_url);
- break;
- default:
- error = true;
- }
- if (error) {
- iotjs_jargs_t jarg = iotjs_jargs_create(1);
- char error[] = "Unknown Error has occured.";
- iotjs_string_t jresult_string =
- iotjs_string_create_with_size(error, strlen(error));
- iotjs_jargs_append_string(&jarg, &jresult_string);
- iotjs_https_jcallback(https_data, IOTJS_MAGIC_STRING_ONERROR, &jarg,
- false);
- iotjs_string_destroy(&jresult_string);
- iotjs_jargs_destroy(&jarg);
- }
- if (https_data->stream_ended) {
- iotjs_https_cleanup(https_data);
- } else {
- if (https_data->to_destroy_read_onwrite) {
- iotjs_https_call_read_onwrite_async(https_data);
- }
- https_data->request_done = true;
- }
- break;
- }
-}
-
-// Cleanup before destructor
-void iotjs_https_cleanup(iotjs_https_t* https_data) {
- https_data->loop = NULL;
-
- uv_close((uv_handle_t*)&https_data->timeout,
- (uv_close_cb)iotjs_https_uv_close_callback);
- uv_close((uv_handle_t*)&https_data->socket_timeout,
- (uv_close_cb)iotjs_https_uv_close_callback);
- uv_close((uv_handle_t*)&https_data->async_read_onwrite,
- (uv_close_cb)iotjs_https_uv_close_callback);
-
- iotjs_https_jcallback(https_data, IOTJS_MAGIC_STRING_ONEND,
- iotjs_jargs_get_empty(), false);
- iotjs_https_jcallback(https_data, IOTJS_MAGIC_STRING_ONCLOSED,
- iotjs_jargs_get_empty(), false);
-
- curl_multi_remove_handle(https_data->curl_multi_handle,
- https_data->curl_easy_handle);
- curl_easy_cleanup(https_data->curl_easy_handle);
- https_data->curl_easy_handle = NULL;
- curl_multi_cleanup(https_data->curl_multi_handle);
- https_data->curl_multi_handle = NULL;
- curl_slist_free_all(https_data->header_list);
-
- if (https_data->poll_data != NULL)
- iotjs_https_poll_close_all(https_data->poll_data);
-
- if (https_data->to_destroy_read_onwrite) {
- const iotjs_jargs_t* jarg = iotjs_jargs_get_empty();
- jerry_value_t jthis = https_data->jthis_native;
- IOTJS_ASSERT(jerry_value_is_function((https_data->read_onwrite)));
-
- if (!jerry_value_is_undefined((https_data->read_callback)))
- iotjs_make_callback(https_data->read_callback, jthis, jarg);
-
- iotjs_make_callback(https_data->read_onwrite, jthis, jarg);
- https_data->to_destroy_read_onwrite = false;
- iotjs_string_destroy(&(https_data->read_chunk));
- jerry_release_value((https_data->read_onwrite));
- jerry_release_value((https_data->read_callback));
- }
- return;
-}
-
-// Set various parameters of curl handles
-void iotjs_https_initialize_curl_opts(iotjs_https_t* https_data) {
- // Setup Some parameters for multi handle
- curl_multi_setopt(https_data->curl_multi_handle, CURLMOPT_SOCKETFUNCTION,
- iotjs_https_curl_socket_callback);
- curl_multi_setopt(https_data->curl_multi_handle, CURLMOPT_SOCKETDATA,
- (void*)https_data);
- curl_multi_setopt(https_data->curl_multi_handle, CURLMOPT_TIMERFUNCTION,
- iotjs_https_curl_start_timeout_callback);
- curl_multi_setopt(https_data->curl_multi_handle, CURLMOPT_TIMERDATA,
- (void*)https_data);
-
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_PROXY, "");
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_HEADERDATA,
- (void*)https_data);
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_WRITEFUNCTION,
- iotjs_https_curl_write_callback);
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_WRITEDATA,
- (void*)https_data);
-
- // Read and send data to server only for some request types
- if (https_data->method == HTTPS_POST || https_data->method == HTTPS_PUT ||
- https_data->method == HTTPS_CONNECT) {
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_READFUNCTION,
- iotjs_https_curl_read_callback);
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_READDATA,
- (void*)https_data);
- }
-
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_SOCKOPTFUNCTION,
- iotjs_https_curl_sockopt_callback);
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_SOCKOPTDATA,
- (void*)https_data);
-
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_URL, https_data->URL);
- https_data->URL = NULL;
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_PROTOCOLS,
- CURLPROTO_HTTP | CURLPROTO_HTTPS);
-
- if (strlen(https_data->ca) > 0)
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_CAINFO,
- https_data->ca);
- https_data->ca = NULL;
- if (strlen(https_data->cert) > 0)
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_SSLCERT,
- https_data->cert);
- https_data->cert = NULL;
- if (strlen(https_data->key) > 0)
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_SSLKEY,
- https_data->key);
- https_data->key = NULL;
- if (!https_data->reject_unauthorized) {
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_SSL_VERIFYPEER, 0);
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_SSL_VERIFYHOST, 0);
- }
-
- // Various request types
- switch (https_data->method) {
- case HTTPS_GET:
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_HTTPGET, 1L);
- break;
- case HTTPS_POST:
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_POST, 1L);
- break;
- case HTTPS_PUT:
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_UPLOAD, 1L);
- break;
- case HTTPS_DELETE:
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_CUSTOMREQUEST,
- "DELETE");
- break;
- case HTTPS_HEAD:
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_NOBODY, 1L);
- break;
- case HTTPS_CONNECT:
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_CUSTOMREQUEST,
- "CONNECT");
- break;
- case HTTPS_OPTIONS:
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_CUSTOMREQUEST,
- "OPTIONS");
- break;
- case HTTPS_TRACE:
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_CUSTOMREQUEST,
- "TRACE");
- break;
- }
-
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_HTTP_TRANSFER_DECODING,
- 0L);
-}
-
-// Call any property of ClientRequest._Incoming
-bool iotjs_https_jcallback(iotjs_https_t* https_data, const char* property,
- const iotjs_jargs_t* jarg, bool resultvalue) {
- jerry_value_t jthis = https_data->jthis_native;
- bool retval = true;
- if (jerry_value_is_null(jthis))
- return retval;
-
- jerry_value_t jincoming =
- iotjs_jval_get_property(jthis, IOTJS_MAGIC_STRING__INCOMING);
- jerry_value_t cb = iotjs_jval_get_property(jincoming, property);
-
- IOTJS_ASSERT(jerry_value_is_function(cb));
- if (!resultvalue) {
- iotjs_make_callback(cb, jincoming, jarg);
- } else {
- jerry_value_t result = iotjs_make_callback_with_result(cb, jincoming, jarg);
- retval = iotjs_jval_as_boolean(result);
- jerry_release_value(result);
- }
-
- jerry_release_value(jincoming);
- jerry_release_value(cb);
- return retval;
-}
-
-// Call onWrite and callback after ClientRequest._write
-void iotjs_https_call_read_onwrite(uv_timer_t* timer) {
- iotjs_https_t* https_data = (iotjs_https_t*)(timer->data);
-
- uv_timer_stop(&(https_data->async_read_onwrite));
- if (jerry_value_is_null(https_data->jthis_native))
- return;
- const iotjs_jargs_t* jarg = iotjs_jargs_get_empty();
- jerry_value_t jthis = https_data->jthis_native;
- IOTJS_ASSERT(jerry_value_is_function((https_data->read_onwrite)));
-
- if (!jerry_value_is_undefined((https_data->read_callback)))
- iotjs_make_callback(https_data->read_callback, jthis, jarg);
-
- iotjs_make_callback(https_data->read_onwrite, jthis, jarg);
-}
-
-// Call the above method Asynchronously
-void iotjs_https_call_read_onwrite_async(iotjs_https_t* https_data) {
- uv_timer_start(&(https_data->async_read_onwrite),
- iotjs_https_call_read_onwrite, 0, 0);
-}
-
-// ------------Functions almost directly called by JS----------
-// Add a header to outgoing request
-void iotjs_https_add_header(iotjs_https_t* https_data,
- const char* char_header) {
- https_data->header_list =
- curl_slist_append(https_data->header_list, char_header);
- if (https_data->method == HTTPS_POST || https_data->method == HTTPS_PUT) {
- if (strncmp(char_header, "Content-Length: ", strlen("Content-Length: ")) ==
- 0) {
- const char* numberString = char_header + strlen("Content-Length: ");
- https_data->content_length = strtol(numberString, NULL, 10);
- }
- }
-}
-
-// Recieved data to write from ClientRequest._write
-void iotjs_https_data_to_write(iotjs_https_t* https_data,
- iotjs_string_t read_chunk,
- jerry_value_t callback, jerry_value_t onwrite) {
- if (https_data->to_destroy_read_onwrite) {
- https_data->to_destroy_read_onwrite = false;
- iotjs_string_destroy(&(https_data->read_chunk));
- jerry_release_value((https_data->read_onwrite));
- jerry_release_value((https_data->read_callback));
- }
-
- https_data->read_chunk = read_chunk;
- https_data->data_to_read = true;
-
- https_data->read_callback = jerry_acquire_value(callback);
- https_data->read_onwrite = jerry_acquire_value(onwrite);
- https_data->to_destroy_read_onwrite = true;
-
- if (https_data->request_done) {
- iotjs_https_call_read_onwrite_async(https_data);
- } else if (https_data->is_stream_writable) {
- curl_easy_pause(https_data->curl_easy_handle, CURLPAUSE_CONT);
- uv_timer_stop(&(https_data->timeout));
- uv_timer_start(&(https_data->timeout), iotjs_https_uv_timeout_callback, 1,
- 0);
- }
-}
-
-// Finish writing all data from ClientRequest Stream
-void iotjs_https_finish_request(iotjs_https_t* https_data) {
- https_data->stream_ended = true;
- if (https_data->request_done) {
- iotjs_https_cleanup(https_data);
- } else if (https_data->is_stream_writable) {
- curl_easy_pause(https_data->curl_easy_handle, CURLPAUSE_CONT);
- uv_timer_stop(&(https_data->timeout));
- uv_timer_start(&(https_data->timeout), iotjs_https_uv_timeout_callback, 1,
- 0);
- }
-}
-
-// Start sending the request
-void iotjs_https_send_request(iotjs_https_t* https_data) {
- // Add all the headers to the easy handle
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_HTTPHEADER,
- https_data->header_list);
-
- if (https_data->method == HTTPS_POST && https_data->content_length != -1)
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_POSTFIELDSIZE,
- https_data->content_length);
- else if (https_data->method == HTTPS_PUT && https_data->content_length != -1)
- curl_easy_setopt(https_data->curl_easy_handle, CURLOPT_INFILESIZE,
- https_data->content_length);
-
- curl_multi_add_handle(https_data->curl_multi_handle,
- https_data->curl_easy_handle);
-}
-
-// Set timeout for request.
-void iotjs_https_set_timeout(long ms, iotjs_https_t* https_data) {
- if (ms < 0)
- return;
- https_data->timeout_ms = ms;
- uv_timer_start(&(https_data->socket_timeout),
- iotjs_https_uv_socket_timeout_callback, 1, (uint64_t)ms);
-}
-
-
-//--------------CURL Callbacks------------------
-// Read callback is actually to write data to outgoing request
-size_t iotjs_https_curl_read_callback(void* contents, size_t size, size_t nmemb,
- void* userp) {
- iotjs_https_t* https_data = (iotjs_https_t*)userp;
-
- // If stream wasnt made writable yet, make it so.
- if (!https_data->is_stream_writable) {
- https_data->is_stream_writable = true;
- iotjs_https_jcallback(https_data, IOTJS_MAGIC_STRING_ONWRITABLE,
- iotjs_jargs_get_empty(), false);
- }
-
- if (https_data->data_to_read) {
- size_t real_size = size * nmemb;
- size_t chunk_size = iotjs_string_size(&(https_data->read_chunk));
- size_t left_to_copy_size = chunk_size - https_data->cur_read_index;
-
- if (real_size < 1)
- return 0;
-
- // send some data
- if (https_data->cur_read_index < chunk_size) {
- size_t num_to_copy =
- (left_to_copy_size < real_size) ? left_to_copy_size : real_size;
- const char* buf = iotjs_string_data(&(https_data->read_chunk));
- buf = &buf[https_data->cur_read_index];
- strncpy((char*)contents, buf, num_to_copy);
- https_data->cur_read_index = https_data->cur_read_index + num_to_copy;
- return num_to_copy;
- }
-
- // Finished sending one chunk of data
- https_data->cur_read_index = 0;
- https_data->data_to_read = false;
- iotjs_https_call_read_onwrite_async(https_data);
- }
-
- // If the data is sent, and stream hasn't ended, wait for more data
- if (!https_data->stream_ended) {
- return CURL_READFUNC_PAUSE;
- }
-
- // All done, end the transfer
- return 0;
-}
-
-// Pass Curl events on its fd sockets
-int iotjs_https_curl_socket_callback(CURL* easy, curl_socket_t sockfd,
- int action, void* userp, void* socketp) {
- iotjs_https_t* https_data = (iotjs_https_t*)userp;
- if (action == CURL_POLL_IN || action == CURL_POLL_OUT ||
- action == CURL_POLL_INOUT) {
- iotjs_https_poll_t* poll_data = NULL;
-
- if (!socketp) {
- poll_data = iotjs_https_poll_create(https_data->loop, sockfd, https_data);
- curl_multi_assign(https_data->curl_multi_handle, sockfd,
- (void*)poll_data);
- https_data->closing_handles = https_data->closing_handles + 1;
- if (https_data->poll_data == NULL)
- https_data->poll_data = poll_data;
- else
- iotjs_https_poll_append(https_data->poll_data, poll_data);
- } else
- poll_data = (iotjs_https_poll_t*)socketp;
-
- if (action == CURL_POLL_IN)
- uv_poll_start(&poll_data->poll_handle, UV_READABLE,
- iotjs_https_uv_poll_callback);
- else if (action == CURL_POLL_OUT)
- uv_poll_start(&poll_data->poll_handle, UV_WRITABLE,
- iotjs_https_uv_poll_callback);
- else if (action == CURL_POLL_INOUT)
- uv_poll_start(&poll_data->poll_handle, UV_READABLE | UV_WRITABLE,
- iotjs_https_uv_poll_callback);
- } else {
- if (socketp) {
- iotjs_https_poll_t* poll_data = (iotjs_https_poll_t*)socketp;
- iotjs_https_poll_close(poll_data);
- curl_multi_assign(https_data->curl_multi_handle, sockfd, NULL);
- }
- }
- return 0;
-}
-
-// Socket Assigned Callback
-int iotjs_https_curl_sockopt_callback(void* userp, curl_socket_t curlfd,
- curlsocktype purpose) {
- iotjs_https_t* https_data = (iotjs_https_t*)userp;
- iotjs_https_jcallback(https_data, IOTJS_MAGIC_STRING_ONSOCKET,
- iotjs_jargs_get_empty(), false);
- return CURL_SOCKOPT_OK;
-}
-
-// Curl wants us to signal after timeout
-int iotjs_https_curl_start_timeout_callback(CURLM* multi, long timeout_ms,
- void* userp) {
- iotjs_https_t* https_data = (iotjs_https_t*)userp;
- if (timeout_ms < 0)
- uv_timer_stop(&(https_data->timeout));
- else {
- if (timeout_ms == 0)
- timeout_ms = 1;
- if ((https_data->timeout_ms != -1) && (timeout_ms > https_data->timeout_ms))
- timeout_ms = https_data->timeout_ms;
- uv_timer_start(&(https_data->timeout), iotjs_https_uv_timeout_callback,
- (uint64_t)timeout_ms, 0);
- }
- return 0;
-}
-
-// Write Callback is actually to read data from incoming response
-size_t iotjs_https_curl_write_callback(void* contents, size_t size,
- size_t nmemb, void* userp) {
- iotjs_https_t* https_data = (iotjs_https_t*)userp;
- size_t real_size = size * nmemb;
- if (jerry_value_is_null(https_data->jthis_native))
- return real_size - 1;
-
- iotjs_jargs_t jarg = iotjs_jargs_create(1);
-
- jerry_value_t jbuffer = iotjs_bufferwrap_create_buffer((size_t)real_size);
- iotjs_bufferwrap_t* buffer_wrap = iotjs_bufferwrap_from_jbuffer(jbuffer);
- iotjs_bufferwrap_copy(buffer_wrap, contents, (size_t)real_size);
-
- iotjs_jargs_append_jval(&jarg, jbuffer);
-
- bool result =
- iotjs_https_jcallback(https_data, IOTJS_MAGIC_STRING_ONDATA, &jarg, true);
-
- jerry_release_value(jbuffer);
- iotjs_jargs_destroy(&jarg);
-
- if (!result) {
- return real_size - 1;
- }
-
- return real_size;
-}
-
-
-//--------------LibTUV Callbacks------------------
-// Callback called on closing handles during cleanup
-void iotjs_https_uv_close_callback(uv_handle_t* handle) {
- iotjs_https_t* https_data = (iotjs_https_t*)handle->data;
- https_data->closing_handles = https_data->closing_handles - 1;
- if (https_data->closing_handles <= 0) {
- if (https_data->poll_data != NULL)
- iotjs_https_poll_destroy(https_data->poll_data);
- jerry_release_value(https_data->jthis_native);
- }
-}
-
-// Callback called when poll detects actions on FD
-void iotjs_https_uv_poll_callback(uv_poll_t* poll, int status, int events) {
- iotjs_https_poll_t* poll_data = (iotjs_https_poll_t*)poll->data;
- iotjs_https_t* https_data = (iotjs_https_t*)poll_data->https_data;
-
- int flags = 0;
- if (status < 0)
- flags = CURL_CSELECT_ERR;
- if (!status && events & UV_READABLE)
- flags |= CURL_CSELECT_IN;
- if (!status && events & UV_WRITABLE)
- flags |= CURL_CSELECT_OUT;
- int running_handles;
- curl_multi_socket_action(https_data->curl_multi_handle, poll_data->sockfd,
- flags, &running_handles);
- iotjs_https_check_done(https_data);
-}
-
-// This function is for signalling to curl a given time has passed.
-// This timeout is usually given by curl itself.
-void iotjs_https_uv_timeout_callback(uv_timer_t* timer) {
- iotjs_https_t* https_data = (iotjs_https_t*)(timer->data);
- uv_timer_stop(timer);
- curl_multi_socket_action(https_data->curl_multi_handle, CURL_SOCKET_TIMEOUT,
- 0, &https_data->running_handles);
- iotjs_https_check_done(https_data);
-}
-
-// Callback called to check if request has timed out
-void iotjs_https_uv_socket_timeout_callback(uv_timer_t* timer) {
- iotjs_https_t* https_data = (iotjs_https_t*)(timer->data);
- double download_bytes = 0;
- double upload_bytes = 0;
- uint64_t total_time_ms = 0;
-
- if (https_data->timeout_ms != -1) {
- curl_easy_getinfo(https_data->curl_easy_handle, CURLINFO_SIZE_DOWNLOAD,
- &download_bytes);
- curl_easy_getinfo(https_data->curl_easy_handle, CURLINFO_SIZE_UPLOAD,
- &upload_bytes);
- total_time_ms = uv_now(https_data->loop);
- double total_bytes = download_bytes + upload_bytes;
-
- if (https_data->last_bytes_num == total_bytes) {
- if (total_time_ms >
- ((uint64_t)https_data->timeout_ms + https_data->last_bytes_time)) {
- if (!https_data->request_done) {
- iotjs_https_jcallback(https_data, IOTJS_MAGIC_STRING_ONTIMEOUT,
- iotjs_jargs_get_empty(), false);
- }
- uv_timer_stop(&(https_data->socket_timeout));
- }
- } else {
- https_data->last_bytes_num = total_bytes;
- https_data->last_bytes_time = total_time_ms;
- }
- }
-}
-
-//--------------https_poll Functions------------------
-iotjs_https_poll_t* iotjs_https_poll_create(uv_loop_t* loop,
- curl_socket_t sockfd,
- iotjs_https_t* https_data) {
- iotjs_https_poll_t* poll_data = IOTJS_ALLOC(iotjs_https_poll_t);
- poll_data->sockfd = sockfd;
- poll_data->poll_handle.data = poll_data;
- poll_data->https_data = https_data;
- poll_data->closing = false;
- poll_data->next = NULL;
- uv_poll_init_socket(loop, &poll_data->poll_handle, sockfd);
- return poll_data;
-}
-
-void iotjs_https_poll_append(iotjs_https_poll_t* head,
- iotjs_https_poll_t* poll_data) {
- iotjs_https_poll_t* current = head;
- iotjs_https_poll_t* next = current->next;
- while (next != NULL) {
- current = next;
- next = current->next;
- }
- current->next = poll_data;
-}
-
-void iotjs_https_poll_close(iotjs_https_poll_t* poll_data) {
- if (poll_data->closing == false) {
- poll_data->closing = true;
- uv_poll_stop(&poll_data->poll_handle);
- poll_data->poll_handle.data = poll_data->https_data;
- uv_close((uv_handle_t*)&poll_data->poll_handle,
- iotjs_https_uv_close_callback);
- }
- return;
-}
-
-void iotjs_https_poll_close_all(iotjs_https_poll_t* head) {
- iotjs_https_poll_t* current = head;
- while (current != NULL) {
- iotjs_https_poll_close(current);
- current = current->next;
- }
-}
-
-void iotjs_https_poll_destroy(iotjs_https_poll_t* poll_data) {
- if (poll_data->next != NULL) {
- iotjs_https_poll_destroy(poll_data->next);
- }
- IOTJS_RELEASE(poll_data);
-}
-
-// ------------JHANDLERS----------------
-
-JS_FUNCTION(createRequest) {
- DJS_CHECK_THIS();
- DJS_CHECK_ARGS(1, object);
-
- const jerry_value_t joptions = JS_GET_ARG(0, object);
-
- jerry_value_t jhost =
- iotjs_jval_get_property(joptions, IOTJS_MAGIC_STRING_HOST);
- iotjs_string_t host = iotjs_jval_as_string(jhost);
- jerry_release_value(jhost);
-
- jerry_value_t jmethod =
- iotjs_jval_get_property(joptions, IOTJS_MAGIC_STRING_METHOD);
- iotjs_string_t method = iotjs_jval_as_string(jmethod);
- jerry_release_value(jmethod);
-
- jerry_value_t jca = iotjs_jval_get_property(joptions, IOTJS_MAGIC_STRING_CA);
- iotjs_string_t ca = iotjs_jval_as_string(jca);
- jerry_release_value(jca);
-
- jerry_value_t jcert =
- iotjs_jval_get_property(joptions, IOTJS_MAGIC_STRING_CERT);
- iotjs_string_t cert = iotjs_jval_as_string(jcert);
- jerry_release_value(jcert);
-
- jerry_value_t jkey =
- iotjs_jval_get_property(joptions, IOTJS_MAGIC_STRING_KEY);
- iotjs_string_t key = iotjs_jval_as_string(jkey);
- jerry_release_value(jkey);
-
- jerry_value_t jreject_unauthorized =
- iotjs_jval_get_property(joptions, IOTJS_MAGIC_STRING_REJECTUNAUTHORIZED);
- const bool reject_unauthorized = iotjs_jval_as_boolean(jreject_unauthorized);
-
- if (curl_global_init(CURL_GLOBAL_SSL)) {
- return jerry_create_null();
- }
-
- iotjs_https_t* https_data =
- iotjs_https_create(iotjs_string_data(&host), iotjs_string_data(&method),
- iotjs_string_data(&ca), iotjs_string_data(&cert),
- iotjs_string_data(&key), reject_unauthorized,
- joptions);
-
- iotjs_https_initialize_curl_opts(https_data);
-
- iotjs_string_destroy(&host);
- iotjs_string_destroy(&method);
- iotjs_string_destroy(&ca);
- iotjs_string_destroy(&cert);
- iotjs_string_destroy(&key);
- return jerry_create_null();
-}
-
-JS_FUNCTION(addHeader) {
- DJS_CHECK_THIS();
-
- DJS_CHECK_ARGS(2, string, object);
- iotjs_string_t header = JS_GET_ARG(0, string);
- const char* char_header = iotjs_string_data(&header);
-
- jerry_value_t jarg = JS_GET_ARG(1, object);
- iotjs_https_t* https_data =
- (iotjs_https_t*)iotjs_jval_get_object_native_handle(jarg);
- iotjs_https_add_header(https_data, char_header);
-
- iotjs_string_destroy(&header);
- return jerry_create_null();
-}
-
-JS_FUNCTION(sendRequest) {
- DJS_CHECK_THIS();
-
- DJS_CHECK_ARG(0, object);
- jerry_value_t jarg = JS_GET_ARG(0, object);
- iotjs_https_t* https_data =
- (iotjs_https_t*)iotjs_jval_get_object_native_handle(jarg);
- iotjs_https_send_request(https_data);
- return jerry_create_null();
-}
-
-JS_FUNCTION(setTimeout) {
- DJS_CHECK_THIS();
- DJS_CHECK_ARGS(2, number, object);
-
- double ms = JS_GET_ARG(0, number);
- jerry_value_t jarg = JS_GET_ARG(1, object);
-
- iotjs_https_t* https_data =
- (iotjs_https_t*)iotjs_jval_get_object_native_handle(jarg);
- iotjs_https_set_timeout((long)ms, https_data);
-
- return jerry_create_null();
-}
-
-JS_FUNCTION(_write) {
- DJS_CHECK_THIS();
- DJS_CHECK_ARGS(2, object, string);
- // Argument 3 can be null, so not checked directly, checked later
- DJS_CHECK_ARG(3, function);
-
- jerry_value_t jarg = JS_GET_ARG(0, object);
- iotjs_string_t read_chunk = JS_GET_ARG(1, string);
-
- jerry_value_t callback = jargv[2];
- jerry_value_t onwrite = JS_GET_ARG(3, function);
-
- iotjs_https_t* https_data =
- (iotjs_https_t*)iotjs_jval_get_object_native_handle(jarg);
- iotjs_https_data_to_write(https_data, read_chunk, callback, onwrite);
-
- // readchunk was copied to https_data, hence not destroyed.
- return jerry_create_null();
-}
-
-JS_FUNCTION(finishRequest) {
- DJS_CHECK_THIS();
- DJS_CHECK_ARG(0, object);
-
- jerry_value_t jarg = JS_GET_ARG(0, object);
- iotjs_https_t* https_data =
- (iotjs_https_t*)iotjs_jval_get_object_native_handle(jarg);
- iotjs_https_finish_request(https_data);
-
- return jerry_create_null();
-}
-
-JS_FUNCTION(Abort) {
- DJS_CHECK_THIS();
- DJS_CHECK_ARG(0, object);
-
- jerry_value_t jarg = JS_GET_ARG(0, object);
- iotjs_https_t* https_data =
- (iotjs_https_t*)iotjs_jval_get_object_native_handle(jarg);
- iotjs_https_cleanup(https_data);
-
- return jerry_create_null();
-}
-
-jerry_value_t InitHttps() {
- jerry_value_t https = jerry_create_object();
-
- iotjs_jval_set_method(https, IOTJS_MAGIC_STRING_CREATEREQUEST, createRequest);
- iotjs_jval_set_method(https, IOTJS_MAGIC_STRING_ADDHEADER, addHeader);
- iotjs_jval_set_method(https, IOTJS_MAGIC_STRING_SENDREQUEST, sendRequest);
- iotjs_jval_set_method(https, IOTJS_MAGIC_STRING_SETTIMEOUT, setTimeout);
- iotjs_jval_set_method(https, IOTJS_MAGIC_STRING__WRITE, _write);
- iotjs_jval_set_method(https, IOTJS_MAGIC_STRING_FINISHREQUEST, finishRequest);
- iotjs_jval_set_method(https, IOTJS_MAGIC_STRING_ABORT, Abort);
-
- return https;
-}
+++ /dev/null
-/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef IOTJS_MODULE_HTTPS_H
-#define IOTJS_MODULE_HTTPS_H
-
-#include "iotjs_def.h"
-#include <uv.h>
-#include <curl/curl.h>
-
-typedef enum {
- HTTPS_GET = 0,
- HTTPS_POST,
- HTTPS_PUT,
- HTTPS_DELETE,
- HTTPS_HEAD,
- HTTPS_CONNECT,
- HTTPS_OPTIONS,
- HTTPS_TRACE
-} HTTPS_Methods;
-
-#define STRING_GET "GET"
-#define STRING_POST "POST"
-#define STRING_PUT "PUT"
-#define STRING_DELETE "DELETE"
-#define STRING_HEAD "HEAD"
-#define STRING_CONNECT "CONNECT"
-#define STRING_OPTIONS "OPTIONS"
-#define STRING_TRACE "TRACE"
-
-typedef struct iotjs_https_poll_t iotjs_https_poll_t;
-typedef struct iotjs_https_t iotjs_https_t;
-
-iotjs_https_t* iotjs_https_create(const char* URL, const char* method,
- const char* ca, const char* cert,
- const char* key,
- const bool reject_unauthorized,
- jerry_value_t jthis);
-
-// Some utility functions
-void iotjs_https_check_done(iotjs_https_t* https_data);
-void iotjs_https_cleanup(iotjs_https_t* https_data);
-void iotjs_https_initialize_curl_opts(iotjs_https_t* https_data);
-jerry_value_t iotjs_https_jthis_from_https(iotjs_https_t* https_data);
-bool iotjs_https_jcallback(iotjs_https_t* https_data, const char* property,
- const iotjs_jargs_t* jarg, bool resultvalue);
-void iotjs_https_call_read_onwrite(uv_timer_t* timer);
-void iotjs_https_call_read_onwrite_async(iotjs_https_t* https_data);
-
-// Functions almost directly called by JS via JHANDLER
-void iotjs_https_add_header(iotjs_https_t* https_data, const char* char_header);
-void iotjs_https_data_to_write(iotjs_https_t* https_data,
- iotjs_string_t read_chunk,
- jerry_value_t callback, jerry_value_t onwrite);
-void iotjs_https_finish_request(iotjs_https_t* https_data);
-void iotjs_https_send_request(iotjs_https_t* https_data);
-void iotjs_https_set_timeout(long ms, iotjs_https_t* https_data);
-
-
-// CURL callbacks
-size_t iotjs_https_curl_read_callback(void* contents, size_t size, size_t nmemb,
- void* userp);
-int iotjs_https_curl_socket_callback(CURL* easy, curl_socket_t sockfd,
- int action, void* userp, void* socketp);
-int iotjs_https_curl_sockopt_callback(void* userp, curl_socket_t curlfd,
- curlsocktype purpose);
-int iotjs_https_curl_start_timeout_callback(CURLM* multi, long timeout_ms,
- void* userp);
-size_t iotjs_https_curl_write_callback(void* contents, size_t size,
- size_t nmemb, void* userp);
-
-// UV Callbacks
-void iotjs_https_uv_close_callback(uv_handle_t* handle);
-void iotjs_https_uv_poll_callback(uv_poll_t* poll, int status, int events);
-void iotjs_https_uv_socket_timeout_callback(uv_timer_t* timer);
-void iotjs_https_uv_timeout_callback(uv_timer_t* timer);
-
-iotjs_https_poll_t* iotjs_https_poll_create(uv_loop_t* loop,
- curl_socket_t sockfd,
- iotjs_https_t* https_data);
-void iotjs_https_poll_append(iotjs_https_poll_t* head,
- iotjs_https_poll_t* poll_data);
-void iotjs_https_poll_close(iotjs_https_poll_t* poll_data);
-void iotjs_https_poll_destroy(iotjs_https_poll_t* poll_data);
-void iotjs_https_poll_close_all(iotjs_https_poll_t* head);
-
-#endif /* IOTJS_MODULE_HTTPS_H */
IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE(i2c);
-static iotjs_i2c_t* i2c_create(const jerry_value_t ji2c) {
- iotjs_i2c_t* i2c = IOTJS_ALLOC(iotjs_i2c_t);
- iotjs_i2c_create_platform_data(i2c);
- i2c->jobject = ji2c;
- jerry_set_object_native_pointer(ji2c, i2c, &this_module_native_info);
-
- return i2c;
-}
-
-static iotjs_i2c_reqwrap_t* i2c_reqwrap_create(const jerry_value_t jcallback,
- iotjs_i2c_t* i2c, I2cOp op) {
- iotjs_i2c_reqwrap_t* i2c_reqwrap = IOTJS_ALLOC(iotjs_i2c_reqwrap_t);
-
- iotjs_reqwrap_initialize(&i2c_reqwrap->reqwrap, jcallback,
- (uv_req_t*)&i2c_reqwrap->req);
-
- i2c_reqwrap->req_data.op = op;
- i2c_reqwrap->i2c_data = i2c;
- return i2c_reqwrap;
-}
-
-static void i2c_reqwrap_destroy(iotjs_i2c_reqwrap_t* i2c_reqwrap) {
- iotjs_reqwrap_destroy(&i2c_reqwrap->reqwrap);
- IOTJS_RELEASE(i2c_reqwrap);
-}
+IOTJS_DEFINE_PERIPH_CREATE_FUNCTION(i2c);
static void iotjs_i2c_destroy(iotjs_i2c_t* i2c) {
iotjs_i2c_destroy_platform_data(i2c->platform_data);
}
static void i2c_worker(uv_work_t* work_req) {
- iotjs_i2c_reqwrap_t* req_wrap =
- (iotjs_i2c_reqwrap_t*)(iotjs_reqwrap_from_request((uv_req_t*)work_req));
- iotjs_i2c_reqdata_t* req_data = &req_wrap->req_data;
- iotjs_i2c_t* i2c = req_wrap->i2c_data;
+ iotjs_periph_reqwrap_t* req_wrap =
+ (iotjs_periph_reqwrap_t*)(iotjs_reqwrap_from_request(
+ (uv_req_t*)work_req));
+ iotjs_i2c_t* i2c = (iotjs_i2c_t*)req_wrap->data;
- switch (req_data->op) {
+ switch (req_wrap->op) {
case kI2cOpOpen:
- req_data->result = iotjs_i2c_open(i2c);
+ req_wrap->result = iotjs_i2c_open(i2c);
break;
case kI2cOpWrite:
- req_data->result = iotjs_i2c_write(i2c);
+ req_wrap->result = iotjs_i2c_write(i2c);
break;
case kI2cOpRead:
- req_data->result = iotjs_i2c_read(i2c);
+ req_wrap->result = iotjs_i2c_read(i2c);
break;
case kI2cOpClose:
- req_data->result = iotjs_i2c_close(i2c);
+ req_wrap->result = iotjs_i2c_close(i2c);
break;
default:
IOTJS_ASSERT(!"Invalid Operation");
}
}
-static const char* i2c_error_str(int op) {
- switch (op) {
- case kI2cOpOpen:
- return "Open error, cannot open I2C";
- case kI2cOpWrite:
- return "Write error, cannot write I2C";
- case kI2cOpRead:
- return "Read error, cannot read I2C";
- case kI2cOpClose:
- return "Close error, cannot close I2C";
- default:
- return "Unknown error";
- }
-}
-
-static void i2c_after_worker(uv_work_t* work_req, int status) {
- iotjs_i2c_reqwrap_t* req_wrap =
- (iotjs_i2c_reqwrap_t*)(iotjs_reqwrap_from_request((uv_req_t*)work_req));
- iotjs_i2c_reqdata_t* req_data = &req_wrap->req_data;
-
- iotjs_jargs_t jargs = iotjs_jargs_create(2);
-
- if (status) {
- iotjs_jargs_append_error(&jargs, "System error");
- } else {
- switch (req_data->op) {
- case kI2cOpOpen:
- case kI2cOpWrite:
- case kI2cOpClose: {
- if (!req_data->result) {
- iotjs_jargs_append_error(&jargs, i2c_error_str(req_data->op));
- } else {
- iotjs_jargs_append_null(&jargs);
- }
- break;
- }
- case kI2cOpRead: {
- if (!req_data->result) {
- iotjs_jargs_append_error(&jargs, i2c_error_str(req_data->op));
- } else {
- iotjs_i2c_t* i2c = req_wrap->i2c_data;
-
- iotjs_jargs_append_null(&jargs);
- jerry_value_t result =
- iotjs_jval_create_byte_array(i2c->buf_len, i2c->buf_data);
- iotjs_jargs_append_jval(&jargs, result);
- jerry_release_value(result);
-
- if (i2c->buf_data != NULL) {
- iotjs_buffer_release(i2c->buf_data);
- }
- }
- break;
- }
- default: {
- IOTJS_ASSERT(!"Unreachable");
- break;
- }
- }
- }
-
- const jerry_value_t jcallback = iotjs_reqwrap_jcallback(&req_wrap->reqwrap);
- if (jerry_value_is_function(jcallback)) {
- iotjs_make_callback(jcallback, jerry_create_undefined(), &jargs);
- }
-
- iotjs_jargs_destroy(&jargs);
- i2c_reqwrap_destroy(req_wrap);
-}
-
-#define I2C_CALL_ASYNC(op, jcallback) \
- do { \
- uv_loop_t* loop = iotjs_environment_loop(iotjs_environment_get()); \
- iotjs_i2c_reqwrap_t* req_wrap = i2c_reqwrap_create(jcallback, i2c, op); \
- uv_work_t* req = &req_wrap->req; \
- uv_queue_work(loop, req, i2c_worker, i2c_after_worker); \
- } while (0)
-
JS_FUNCTION(I2cCons) {
DJS_CHECK_THIS();
DJS_CHECK_ARGS(1, object);
return res;
}
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, i2c->address, IOTJS_MAGIC_STRING_ADDRESS,
- number);
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, i2c->address, IOTJS_MAGIC_STRING_ADDRESS,
+ number);
jerry_value_t jcallback = JS_GET_ARG_IF_EXIST(1, function);
// If the callback doesn't exist, it is completed synchronously.
// Otherwise, it will be executed asynchronously.
if (!jerry_value_is_null(jcallback)) {
- I2C_CALL_ASYNC(kI2cOpOpen, jcallback);
+ iotjs_periph_call_async(i2c, jcallback, kI2cOpOpen, i2c_worker);
} else if (!iotjs_i2c_open(i2c)) {
- return JS_CREATE_ERROR(COMMON, "I2C Error: cannot open I2C");
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kI2cOpOpen));
}
return jerry_create_undefined();
JS_DECLARE_THIS_PTR(i2c, i2c);
DJS_CHECK_ARG_IF_EXIST(1, function);
- I2C_CALL_ASYNC(kI2cOpClose, JS_GET_ARG_IF_EXIST(0, function));
+ iotjs_periph_call_async(i2c, JS_GET_ARG_IF_EXIST(0, function), kI2cOpClose,
+ i2c_worker);
return jerry_create_undefined();
}
JS_DECLARE_THIS_PTR(i2c, i2c);
if (!iotjs_i2c_close(i2c)) {
- return JS_CREATE_ERROR(COMMON, "I2C Error: cannot close");
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kI2cOpClose));
}
return jerry_create_undefined();
i2c->buf_data = iotjs_buffer_allocate_from_number_array(i2c->buf_len, jarray);
if (async) {
- I2C_CALL_ASYNC(kI2cOpWrite, JS_GET_ARG_IF_EXIST(1, function));
+ iotjs_periph_call_async(i2c, JS_GET_ARG_IF_EXIST(1, function), kI2cOpWrite,
+ i2c_worker);
} else {
if (!iotjs_i2c_write(i2c)) {
- return JS_CREATE_ERROR(COMMON, "I2C Error: writeSync");
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kI2cOpWrite));
}
}
JS_GET_REQUIRED_ARG_VALUE(0, i2c->buf_len, IOTJS_MAGIC_STRING_LENGTH, number);
- jerry_value_t jcallback = JS_GET_ARG_IF_EXIST(1, function);
- I2C_CALL_ASYNC(kI2cOpRead, jcallback);
+ iotjs_periph_call_async(i2c, JS_GET_ARG_IF_EXIST(1, function), kI2cOpRead,
+ i2c_worker);
return jerry_create_undefined();
}
JS_GET_REQUIRED_ARG_VALUE(0, i2c->buf_len, IOTJS_MAGIC_STRING_LENGTH, number);
if (!iotjs_i2c_read(i2c)) {
- return JS_CREATE_ERROR(COMMON, "I2C Error: readSync");
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kI2cOpRead));
}
return iotjs_jval_create_byte_array(i2c->buf_len, i2c->buf_data);
#define IOTJS_MODULE_I2C_H
#include "iotjs_def.h"
+#include "iotjs_module_periph_common.h"
#include "iotjs_reqwrap.h"
-typedef enum {
- kI2cOpOpen,
- kI2cOpClose,
- kI2cOpWrite,
- kI2cOpRead,
-} I2cOp;
-
-
-typedef struct {
- I2cOp op;
- bool result;
-} iotjs_i2c_reqdata_t;
-
// Forward declaration of platform data. These are only used by platform code.
// Generic I2C module never dereferences platform data pointer.
typedef struct iotjs_i2c_platform_data_s iotjs_i2c_platform_data_t;
char* buf_data;
uint8_t buf_len;
- uint8_t byte;
- uint8_t cmd;
uint8_t address;
} iotjs_i2c_t;
-typedef struct {
- iotjs_reqwrap_t reqwrap;
- uv_work_t req;
- iotjs_i2c_reqdata_t req_data;
- iotjs_i2c_t* i2c_data;
-} iotjs_i2c_reqwrap_t;
-
jerry_value_t iotjs_i2c_set_platform_config(iotjs_i2c_t* i2c,
const jerry_value_t jconfig);
bool iotjs_i2c_open(iotjs_i2c_t* i2c);
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "iotjs_module_periph_common.h"
+#include "iotjs_module_adc.h"
+#include "iotjs_module_gpio.h"
+#include "iotjs_module_i2c.h"
+#include "iotjs_module_pwm.h"
+#include "iotjs_module_spi.h"
+#include "iotjs_module_uart.h"
+
+const char* iotjs_periph_error_str(uint8_t op) {
+ switch (op) {
+#if ENABLE_MODULE_ADC
+ case kAdcOpClose:
+ return "Close error, cannot close ADC";
+ case kAdcOpOpen:
+ return "Open error, cannot open ADC";
+ case kAdcOpRead:
+ return "Read error, cannot read ADC";
+#endif /* ENABLE_MODULE_ADC */
+#if ENABLE_MODULE_GPIO
+ case kGpioOpOpen:
+ return "Open error, cannot open GPIO";
+ case kGpioOpWrite:
+ return "Write error, cannot write GPIO";
+ case kGpioOpRead:
+ return "Read error, cannot read GPIO";
+ case kGpioOpClose:
+ return "Close error, cannot close GPIO";
+#endif /* ENABLE_MODULE_GPIO */
+#if ENABLE_MODULE_I2C
+ case kI2cOpOpen:
+ return "Open error, cannot open I2C";
+ case kI2cOpWrite:
+ return "Write error, cannot write I2C";
+ case kI2cOpRead:
+ return "Read error, cannot read I2C";
+ case kI2cOpClose:
+ return "Close error, cannot close I2C";
+#endif /* ENABLE_MODULE_I2C */
+#if ENABLE_MODULE_PWM
+ case kPwmOpClose:
+ return "Cannot close PWM device";
+ case kPwmOpOpen:
+ return "Failed to open PWM device";
+ case kPwmOpSetDutyCycle:
+ return "Failed to set duty-cycle";
+ case kPwmOpSetEnable:
+ return "Failed to set enable";
+ case kPwmOpSetFrequency:
+ return "Failed to set frequency";
+ case kPwmOpSetPeriod:
+ return "Failed to set period";
+#endif /* ENABLE_MODULE_PWM */
+#if ENABLE_MODULE_SPI
+ case kSpiOpClose:
+ return "Close error, cannot close SPI";
+ case kSpiOpOpen:
+ return "Open error, cannot open SPI";
+ case kSpiOpTransferArray:
+ case kSpiOpTransferBuffer:
+ return "Transfer error, cannot transfer from SPI device";
+#endif /* ENABLE_MODULE_SPI */
+#if ENABLE_MODULE_UART
+ case kUartOpClose:
+ return "Close error, failed to close UART device";
+ case kUartOpOpen:
+ return "Open error, failed to open UART device";
+ case kUartOpWrite:
+ return "Write error, cannot write to UART device";
+#endif /* ENABLE_MODULE_UART */
+ default:
+ return "Unknown error";
+ }
+}
+
+static void after_worker(uv_work_t* work_req, int status) {
+ iotjs_periph_reqwrap_t* reqwrap =
+ (iotjs_periph_reqwrap_t*)iotjs_reqwrap_from_request((uv_req_t*)work_req);
+
+ iotjs_jargs_t jargs = iotjs_jargs_create(2);
+
+ if (status) {
+ iotjs_jargs_append_error(&jargs, "System error");
+ } else {
+ if (!reqwrap->result) {
+ iotjs_jargs_append_error(&jargs, iotjs_periph_error_str(reqwrap->op));
+ } else {
+ switch (reqwrap->op) {
+ case kAdcOpClose:
+ case kAdcOpOpen:
+ case kGpioOpClose:
+ case kGpioOpOpen:
+ case kGpioOpWrite:
+ case kI2cOpClose:
+ case kI2cOpOpen:
+ case kI2cOpWrite:
+ case kSpiOpClose:
+ case kSpiOpOpen:
+ case kPwmOpClose:
+ case kPwmOpOpen:
+ case kPwmOpSetDutyCycle:
+ case kPwmOpSetEnable:
+ case kPwmOpSetFrequency:
+ case kPwmOpSetPeriod:
+ case kUartOpClose:
+ case kUartOpOpen:
+ case kUartOpWrite: {
+ iotjs_jargs_append_null(&jargs);
+ break;
+ }
+ case kAdcOpRead: {
+#if ENABLE_MODULE_ADC
+ iotjs_adc_t* adc = (iotjs_adc_t*)reqwrap->data;
+
+ iotjs_jargs_append_null(&jargs);
+ iotjs_jargs_append_number(&jargs, adc->value);
+#endif /* ENABLE_MODULE_ADC */
+ break;
+ }
+ case kGpioOpRead: {
+#if ENABLE_MODULE_GPIO
+ iotjs_gpio_t* gpio = (iotjs_gpio_t*)reqwrap->data;
+
+ iotjs_jargs_append_null(&jargs);
+ iotjs_jargs_append_bool(&jargs, gpio->value);
+#endif /* ENABLE_MODULE_GPIO */
+ break;
+ }
+ case kI2cOpRead: {
+#if ENABLE_MODULE_I2C
+ iotjs_i2c_t* i2c = (iotjs_i2c_t*)reqwrap->data;
+
+ iotjs_jargs_append_null(&jargs);
+ jerry_value_t result =
+ iotjs_jval_create_byte_array(i2c->buf_len, i2c->buf_data);
+ iotjs_jargs_append_jval(&jargs, result);
+ jerry_release_value(result);
+
+ IOTJS_RELEASE(i2c->buf_data);
+#endif /* ENABLE_MODULE_I2C */
+ break;
+ }
+ case kSpiOpTransferArray:
+ case kSpiOpTransferBuffer: {
+#if ENABLE_MODULE_SPI
+ iotjs_spi_t* spi = (iotjs_spi_t*)reqwrap->data;
+
+ iotjs_jargs_append_null(&jargs);
+
+ // Append read data
+ jerry_value_t result =
+ iotjs_jval_create_byte_array(spi->buf_len, spi->rx_buf_data);
+ iotjs_jargs_append_jval(&jargs, result);
+ jerry_release_value(result);
+
+ IOTJS_RELEASE(spi->rx_buf_data);
+#endif /* ENABLE_MODULE_SPI */
+ break;
+ }
+ default: {
+ IOTJS_ASSERT(!"Unreachable");
+ break;
+ }
+ }
+ }
+#if ENABLE_MODULE_SPI
+ if (reqwrap->op == kSpiOpTransferArray) {
+ iotjs_spi_t* spi = (iotjs_spi_t*)reqwrap->data;
+ IOTJS_RELEASE(spi->tx_buf_data);
+ }
+#endif /* ENABLE_MODULE_SPI */
+#if ENABLE_MODULE_UART
+ if (reqwrap->op == kUartOpWrite) {
+ iotjs_uart_t* uart = (iotjs_uart_t*)reqwrap->data;
+ iotjs_string_destroy(&uart->buf_data);
+ }
+#endif /* ENABLE_MODULE_UART */
+ }
+
+ jerry_value_t jcallback = iotjs_reqwrap_jcallback(&reqwrap->reqwrap);
+ if (jerry_value_is_function(jcallback)) {
+ iotjs_make_callback(jcallback, jerry_create_undefined(), &jargs);
+ }
+
+ iotjs_jargs_destroy(&jargs);
+ iotjs_reqwrap_destroy(&reqwrap->reqwrap);
+ IOTJS_RELEASE(reqwrap);
+}
+
+static iotjs_periph_reqwrap_t* reqwrap_create(const jerry_value_t jcallback,
+ void* data, uint8_t op) {
+ iotjs_periph_reqwrap_t* reqwrap = IOTJS_ALLOC(iotjs_periph_reqwrap_t);
+ iotjs_reqwrap_initialize((iotjs_reqwrap_t*)reqwrap, jcallback,
+ (uv_req_t*)&reqwrap->req);
+ reqwrap->op = op;
+ reqwrap->data = data;
+ return (iotjs_periph_reqwrap_t*)reqwrap;
+}
+
+void iotjs_periph_call_async(void* data, jerry_value_t jcallback, uint8_t op,
+ uv_work_cb worker) {
+ uv_loop_t* loop = iotjs_environment_loop(iotjs_environment_get());
+ iotjs_periph_reqwrap_t* req_wrap = reqwrap_create(jcallback, data, op);
+ uv_queue_work(loop, &req_wrap->req, worker, after_worker);
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IOTJS_MODULE_PERIPH_COMMON_H
+#define IOTJS_MODULE_PERIPH_COMMON_H
+
+#include "iotjs_def.h"
+#include "iotjs_reqwrap.h"
+
+typedef enum {
+ kAdcOpOpen,
+ kAdcOpRead,
+ kAdcOpClose,
+ kGpioOpOpen,
+ kGpioOpWrite,
+ kGpioOpRead,
+ kGpioOpClose,
+ kI2cOpOpen,
+ kI2cOpClose,
+ kI2cOpWrite,
+ kI2cOpRead,
+ kPwmOpClose,
+ kPwmOpOpen,
+ kPwmOpSetDutyCycle,
+ kPwmOpSetEnable,
+ kPwmOpSetFrequency,
+ kPwmOpSetPeriod,
+ kSpiOpClose,
+ kSpiOpOpen,
+ kSpiOpTransferArray,
+ kSpiOpTransferBuffer,
+ kUartOpClose,
+ kUartOpOpen,
+ kUartOpWrite
+} iotjs_periph_op_t;
+
+typedef struct {
+ iotjs_reqwrap_t reqwrap; /* Note: must be the first */
+ uv_work_t req;
+ uint8_t op;
+ bool result;
+ void* data;
+} iotjs_periph_reqwrap_t;
+
+const char* iotjs_periph_error_str(uint8_t op);
+void iotjs_periph_call_async(void* type_p, jerry_value_t jcallback, uint8_t op,
+ uv_work_cb worker);
+
+#define IOTJS_DEFINE_PERIPH_CREATE_FUNCTION(name) \
+ static iotjs_##name##_t* name##_create(const jerry_value_t jobject) { \
+ iotjs_##name##_t* data = IOTJS_ALLOC(iotjs_##name##_t); \
+ iotjs_##name##_create_platform_data(data); \
+ data->jobject = jobject; \
+ jerry_set_object_native_pointer(jobject, data, &this_module_native_info); \
+ return data; \
+ }
+
+#endif /* IOTJS_MODULE_PERIPH_COMMON_H */
jerry_value_t res =
jerry_parse_function((const jerry_char_t*)name, name_len,
(const jerry_char_t*)args, strlen(args),
- (const jerry_char_t*)source, length, false);
+ (const jerry_char_t*)source, length,
+ JERRY_PARSE_NO_OPTS);
return res;
}
jerry_value_t jrequire = JS_GET_ARG(1, function);
jerry_value_t jid = iotjs_jval_get_property(jmodule, "id");
+ if (!jerry_value_is_string(jid)) {
+ return JS_CREATE_ERROR(COMMON, "Unknown native module");
+ }
iotjs_string_t id = iotjs_jval_as_string(jid);
jerry_release_value(jid);
const char* name = iotjs_string_data(&id);
if (js_modules[i].name != NULL) {
#ifdef ENABLE_SNAPSHOT
- jres = jerry_exec_snapshot_at((const void*)iotjs_js_modules_s,
- iotjs_js_modules_l, js_modules[i].idx, false);
+ jres = jerry_exec_snapshot((const void*)iotjs_js_modules_s,
+ iotjs_js_modules_l, js_modules[i].idx, 0);
#else
jres = WrapEval(name, iotjs_string_size(&id),
(const char*)js_modules[i].code, js_modules[i].length);
iotjs_string_t path = JS_GET_ARG(0, string);
const iotjs_environment_t* env = iotjs_environment_get();
-
+ int err;
uv_fs_t fs_req;
- uv_fs_stat(iotjs_environment_loop(env), &fs_req, iotjs_string_data(&path),
- NULL);
+ err = uv_fs_stat(iotjs_environment_loop(env), &fs_req,
+ iotjs_string_data(&path), NULL);
uv_fs_req_cleanup(&fs_req);
- if (!S_ISREG(fs_req.statbuf.st_mode)) {
+ if (err || !S_ISREG(fs_req.statbuf.st_mode)) {
iotjs_string_destroy(&path);
return JS_CREATE_ERROR(COMMON, "ReadSource error, not a regular file");
}
static void SetProcessEnv(jerry_value_t process) {
- const char *homedir, *iotjspath, *iotjsenv;
+ const char *homedir, *iotjspath, *iotjsenv, *extra_module_path;
- homedir = getenv("HOME");
+ homedir = getenv(IOTJS_MAGIC_STRING_HOME_U);
if (homedir == NULL) {
homedir = "";
}
- iotjspath = getenv("IOTJS_PATH");
+ iotjspath = getenv(IOTJS_MAGIC_STRING_IOTJS_PATH_U);
if (iotjspath == NULL) {
#if defined(__NUTTX__) || defined(__TIZENRT__)
iotjspath = "/mnt/sdcard";
iotjsenv = "";
#endif
+ extra_module_path = getenv(IOTJS_MAGIC_STRING_IOTJS_EXTRA_MODULE_PATH_U);
+
jerry_value_t env = jerry_create_object();
iotjs_jval_set_property_string_raw(env, IOTJS_MAGIC_STRING_HOME_U, homedir);
iotjs_jval_set_property_string_raw(env, IOTJS_MAGIC_STRING_IOTJS_PATH_U,
iotjspath);
iotjs_jval_set_property_string_raw(env, IOTJS_MAGIC_STRING_IOTJS_ENV_U,
iotjsenv);
+ iotjs_jval_set_property_string_raw(
+ env, IOTJS_MAGIC_STRING_IOTJS_EXTRA_MODULE_PATH_U,
+ extra_module_path ? extra_module_path : "");
iotjs_jval_set_property_jval(process, IOTJS_MAGIC_STRING_ENV, env);
IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE(pwm);
-static iotjs_pwm_t* pwm_create(jerry_value_t jpwm) {
- iotjs_pwm_t* pwm = IOTJS_ALLOC(iotjs_pwm_t);
- iotjs_pwm_create_platform_data(pwm);
- pwm->jobject = jpwm;
- pwm->period = -1;
- pwm->duty_cycle = 0;
- jerry_set_object_native_pointer(jpwm, pwm, &this_module_native_info);
-
- return pwm;
-}
-
-static iotjs_pwm_reqwrap_t* iotjs_pwm_reqwrap_create(jerry_value_t jcallback,
- iotjs_pwm_t* pwm,
- PwmOp op) {
- iotjs_pwm_reqwrap_t* pwm_reqwrap = IOTJS_ALLOC(iotjs_pwm_reqwrap_t);
-
- iotjs_reqwrap_initialize(&pwm_reqwrap->reqwrap, jcallback,
- (uv_req_t*)&pwm_reqwrap->req);
-
- pwm_reqwrap->req_data.op = op;
- pwm_reqwrap->pwm_data = pwm;
-
- return pwm_reqwrap;
-}
-
-static void pwm_reqwrap_destroy(iotjs_pwm_reqwrap_t* pwm_reqwrap) {
- iotjs_reqwrap_destroy(&pwm_reqwrap->reqwrap);
- IOTJS_RELEASE(pwm_reqwrap);
-}
+IOTJS_DEFINE_PERIPH_CREATE_FUNCTION(pwm);
static void iotjs_pwm_destroy(iotjs_pwm_t* pwm) {
iotjs_pwm_destroy_platform_data(pwm->platform_data);
}
static void pwm_worker(uv_work_t* work_req) {
- iotjs_pwm_reqwrap_t* req_wrap =
- (iotjs_pwm_reqwrap_t*)(iotjs_reqwrap_from_request((uv_req_t*)work_req));
- iotjs_pwm_reqdata_t* req_data = &req_wrap->req_data;
- iotjs_pwm_t* pwm = req_wrap->pwm_data;
+ iotjs_periph_reqwrap_t* req_wrap =
+ (iotjs_periph_reqwrap_t*)(iotjs_reqwrap_from_request(
+ (uv_req_t*)work_req));
+ iotjs_pwm_t* pwm = (iotjs_pwm_t*)req_wrap->data;
- switch (req_data->op) {
+ switch (req_wrap->op) {
case kPwmOpClose:
- req_data->result = iotjs_pwm_close(pwm);
+ req_wrap->result = iotjs_pwm_close(pwm);
break;
case kPwmOpOpen:
- req_data->result = iotjs_pwm_open(pwm);
+ req_wrap->result = iotjs_pwm_open(pwm);
break;
case kPwmOpSetDutyCycle:
- req_data->result = iotjs_pwm_set_dutycycle(pwm);
+ req_wrap->result = iotjs_pwm_set_dutycycle(pwm);
break;
case kPwmOpSetEnable:
- req_data->result = iotjs_pwm_set_enable(pwm);
+ req_wrap->result = iotjs_pwm_set_enable(pwm);
break;
case kPwmOpSetFrequency: /* update the period */
case kPwmOpSetPeriod:
- req_data->result = iotjs_pwm_set_period(pwm);
+ req_wrap->result = iotjs_pwm_set_period(pwm);
break;
default:
IOTJS_ASSERT(!"Invalid Operation");
}
}
-static const char* pwm_error_str(int op) {
- switch (op) {
- case kPwmOpClose:
- return "Cannot close PWM device";
- case kPwmOpOpen:
- return "Failed to open PWM device";
- case kPwmOpSetDutyCycle:
- return "Failed to set duty-cycle";
- case kPwmOpSetEnable:
- return "Failed to set enable";
- case kPwmOpSetFrequency:
- return "Failed to set frequency";
- case kPwmOpSetPeriod:
- return "Failed to set period";
- default:
- return "Unknown error";
+static jerry_value_t pwm_set_configuration(iotjs_pwm_t* pwm,
+ jerry_value_t jconfig) {
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, pwm->duty_cycle,
+ IOTJS_MAGIC_STRING_DUTYCYCLE, number);
+ if (pwm->duty_cycle < 0.0 || pwm->duty_cycle > 1.0) {
+ return JS_CREATE_ERROR(RANGE, "pwm.dutyCycle must be within 0.0 and 1.0");
}
-}
-
-static void pwm_after_worker(uv_work_t* work_req, int status) {
- iotjs_pwm_reqwrap_t* req_wrap =
- (iotjs_pwm_reqwrap_t*)(iotjs_reqwrap_from_request((uv_req_t*)work_req));
- iotjs_pwm_reqdata_t* req_data = &req_wrap->req_data;
- iotjs_jargs_t jargs = iotjs_jargs_create(1);
-
- if (status) {
- iotjs_jargs_append_error(&jargs, "System error");
- } else {
- switch (req_data->op) {
- case kPwmOpClose:
- case kPwmOpOpen:
- case kPwmOpSetDutyCycle:
- case kPwmOpSetEnable:
- case kPwmOpSetFrequency:
- case kPwmOpSetPeriod: {
- if (!req_data->result) {
- iotjs_jargs_append_error(&jargs, pwm_error_str(req_data->op));
- } else {
- iotjs_jargs_append_null(&jargs);
- }
- break;
- }
- default: {
- IOTJS_ASSERT(!"Unreachable");
- break;
- }
- }
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, pwm->period, IOTJS_MAGIC_STRING_PERIOD,
+ number);
+ if (pwm->period < 0) {
+ return JS_CREATE_ERROR(RANGE, "pwm.period must be a positive value");
}
- jerry_value_t jcallback = iotjs_reqwrap_jcallback(&req_wrap->reqwrap);
- if (jerry_value_is_function(jcallback)) {
- iotjs_make_callback(jcallback, jerry_create_undefined(), &jargs);
- }
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, pwm->pin, IOTJS_MAGIC_STRING_PIN, number);
- iotjs_jargs_destroy(&jargs);
- pwm_reqwrap_destroy(req_wrap);
+ return jerry_create_undefined();
}
-#define PWM_CALL_ASYNC(op, jcallback) \
- do { \
- uv_loop_t* loop = iotjs_environment_loop(iotjs_environment_get()); \
- iotjs_pwm_reqwrap_t* req_wrap = \
- iotjs_pwm_reqwrap_create(jcallback, pwm, op); \
- uv_work_t* req = &req_wrap->req; \
- uv_queue_work(loop, req, pwm_worker, pwm_after_worker); \
- } while (0)
-
JS_FUNCTION(PwmCons) {
DJS_CHECK_THIS();
DJS_CHECK_ARGS(1, object);
if (jerry_value_has_error_flag(res)) {
return res;
}
+ IOTJS_ASSERT(jerry_value_is_undefined(res));
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, pwm->duty_cycle,
- IOTJS_MAGIC_STRING_DUTYCYCLE, number);
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, pwm->period, IOTJS_MAGIC_STRING_PERIOD,
- number);
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, pwm->pin, IOTJS_MAGIC_STRING_PIN,
- number);
+ res = pwm_set_configuration(pwm, jconfig);
+ if (jerry_value_has_error_flag(res)) {
+ return res;
+ }
+ IOTJS_ASSERT(jerry_value_is_undefined(res));
jerry_value_t jcallback = JS_GET_ARG_IF_EXIST(1, function);
// If the callback doesn't exist, it is completed synchronously.
// Otherwise, it will be executed asynchronously.
if (!jerry_value_is_null(jcallback)) {
- PWM_CALL_ASYNC(kPwmOpOpen, jcallback);
+ iotjs_periph_call_async(pwm, jcallback, kPwmOpOpen, pwm_worker);
} else if (!iotjs_pwm_open(pwm)) {
- return JS_CREATE_ERROR(COMMON, pwm_error_str(kPwmOpOpen));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kPwmOpOpen));
}
return jerry_create_undefined();
JS_DECLARE_THIS_PTR(pwm, pwm);
DJS_CHECK_ARG_IF_EXIST(1, function);
- PWM_CALL_ASYNC(kPwmOpClose, JS_GET_ARG_IF_EXIST(0, function));
+ iotjs_periph_call_async(pwm, JS_GET_ARG_IF_EXIST(0, function), kPwmOpClose,
+ pwm_worker);
return jerry_create_undefined();
}
JS_DECLARE_THIS_PTR(pwm, pwm);
if (!iotjs_pwm_close(pwm)) {
- return JS_CREATE_ERROR(COMMON, pwm_error_str(kPwmOpClose));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kPwmOpClose));
}
return jerry_create_undefined();
jerry_value_t jcallback = JS_GET_ARG_IF_EXIST(1, function);
pwm->duty_cycle = JS_GET_ARG(0, number);
+ if (pwm->duty_cycle < 0.0 || pwm->duty_cycle > 1.0) {
+ return JS_CREATE_ERROR(RANGE, "pwm.dutyCycle must be within 0.0 and 1.0");
+ }
- PWM_CALL_ASYNC(kPwmOpSetDutyCycle, jcallback);
+ iotjs_periph_call_async(pwm, jcallback, kPwmOpSetDutyCycle, pwm_worker);
return jerry_create_undefined();
}
DJS_CHECK_ARGS(1, number);
pwm->duty_cycle = JS_GET_ARG(0, number);
+ if (pwm->duty_cycle < 0.0 || pwm->duty_cycle > 1.0) {
+ return JS_CREATE_ERROR(RANGE, "pwm.dutyCycle must be within 0.0 and 1.0");
+ }
if (!iotjs_pwm_set_dutycycle(pwm)) {
- return JS_CREATE_ERROR(COMMON, pwm_error_str(kPwmOpSetDutyCycle));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kPwmOpSetDutyCycle));
}
return jerry_create_undefined();
pwm->enable = JS_GET_ARG(0, boolean);
- PWM_CALL_ASYNC(kPwmOpSetEnable, jcallback);
+ iotjs_periph_call_async(pwm, jcallback, kPwmOpSetEnable, pwm_worker);
return jerry_create_undefined();
}
pwm->enable = JS_GET_ARG(0, boolean);
if (!iotjs_pwm_set_enable(pwm)) {
- return JS_CREATE_ERROR(COMMON, pwm_error_str(kPwmOpSetEnable));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kPwmOpSetEnable));
}
return jerry_create_undefined();
const jerry_value_t jargv[],
const jerry_length_t jargc,
uint8_t op, bool async) {
+ const double num_value = JS_GET_ARG(0, number);
+
if (op == kPwmOpSetFrequency) {
- pwm->period = 1.0 / JS_GET_ARG(0, number);
+ if (num_value <= 0) {
+ return JS_CREATE_ERROR(RANGE, "frequency must be greater than 0");
+ }
+ pwm->period = 1.0 / num_value;
+
} else {
- pwm->period = JS_GET_ARG(0, number);
+ if (num_value < 0) {
+ return JS_CREATE_ERROR(RANGE, "period must be a positive value");
+ }
+ pwm->period = num_value;
}
if (async) {
- PWM_CALL_ASYNC(op, JS_GET_ARG_IF_EXIST(1, function));
+ iotjs_periph_call_async(pwm, JS_GET_ARG_IF_EXIST(1, function), op,
+ pwm_worker);
} else {
if (!iotjs_pwm_set_period(pwm)) {
- return JS_CREATE_ERROR(COMMON, pwm_error_str(op));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(op));
}
}
#define IOTJS_MODULE_PWM_H
#include "iotjs_def.h"
+#include "iotjs_module_periph_common.h"
#include "iotjs_reqwrap.h"
#if defined(__TIZENRT__)
#include <stdint.h>
#endif
-
-typedef enum {
- kPwmOpClose,
- kPwmOpOpen,
- kPwmOpSetDutyCycle,
- kPwmOpSetEnable,
- kPwmOpSetFrequency,
- kPwmOpSetPeriod
-} PwmOp;
-
-
-typedef struct {
- bool result;
- PwmOp op;
-} iotjs_pwm_reqdata_t;
-
// Forward declaration of platform data. These are only used by platform code.
// Generic PWM module never dereferences platform data pointer.
typedef struct iotjs_pwm_platform_data_s iotjs_pwm_platform_data_t;
bool enable;
} iotjs_pwm_t;
-
-typedef struct {
- iotjs_reqwrap_t reqwrap;
- uv_work_t req;
- iotjs_pwm_reqdata_t req_data;
- iotjs_pwm_t* pwm_data;
-} iotjs_pwm_reqwrap_t;
-
jerry_value_t iotjs_pwm_set_platform_config(iotjs_pwm_t* pwm,
const jerry_value_t jconfig);
bool iotjs_pwm_open(iotjs_pwm_t* pwm);
#include "iotjs_def.h"
#include "iotjs_module_spi.h"
#include "iotjs_module_buffer.h"
-#include <unistd.h>
-#define SPI_TX_ARRAY_BIT 1u
-
IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE(spi);
-static iotjs_spi_t* spi_create(jerry_value_t jspi) {
- iotjs_spi_t* spi = IOTJS_ALLOC(iotjs_spi_t);
- iotjs_spi_create_platform_data(spi);
- spi->jobject = jspi;
- jerry_set_object_native_pointer(jspi, spi, &this_module_native_info);
-
- return spi;
-}
-
-static iotjs_spi_reqwrap_t* spi_reqwrap_create(jerry_value_t jcallback,
- iotjs_spi_t* spi, SpiOp op) {
- iotjs_spi_reqwrap_t* spi_reqwrap = IOTJS_ALLOC(iotjs_spi_reqwrap_t);
-
- iotjs_reqwrap_initialize(&spi_reqwrap->reqwrap, jcallback,
- (uv_req_t*)&spi_reqwrap->req);
-
- spi_reqwrap->req_data.op = op;
- spi_reqwrap->spi_data = spi;
-
- return spi_reqwrap;
-}
-
-static void spi_reqwrap_destroy(iotjs_spi_reqwrap_t* spi_reqwrap) {
- iotjs_reqwrap_destroy(&spi_reqwrap->reqwrap);
- IOTJS_RELEASE(spi_reqwrap);
-}
+IOTJS_DEFINE_PERIPH_CREATE_FUNCTION(spi);
static void iotjs_spi_destroy(iotjs_spi_t* spi) {
iotjs_spi_destroy_platform_data(spi->platform_data);
return jerry_create_undefined();
}
-
/*
* SPI worker function
*/
static void spi_worker(uv_work_t* work_req) {
- iotjs_spi_reqwrap_t* req_wrap =
- (iotjs_spi_reqwrap_t*)(iotjs_reqwrap_from_request((uv_req_t*)work_req));
- iotjs_spi_reqdata_t* req_data = &req_wrap->req_data;
- iotjs_spi_t* spi = req_wrap->spi_data;
+ iotjs_periph_reqwrap_t* req_wrap =
+ (iotjs_periph_reqwrap_t*)(iotjs_reqwrap_from_request(
+ (uv_req_t*)work_req));
+ iotjs_spi_t* spi = (iotjs_spi_t*)req_wrap->data;
- switch (req_data->op) {
+ switch (req_wrap->op) {
case kSpiOpClose: {
- req_data->result = iotjs_spi_close(spi);
+ req_wrap->result = iotjs_spi_close(spi);
break;
}
case kSpiOpOpen: {
- req_data->result = iotjs_spi_open(spi);
+ req_wrap->result = iotjs_spi_open(spi);
break;
}
case kSpiOpTransferArray:
case kSpiOpTransferBuffer: {
- req_data->result = iotjs_spi_transfer(spi);
+ req_wrap->result = iotjs_spi_transfer(spi);
break;
}
default:
}
}
-static const char* spi_error_str(uint8_t op) {
- switch (op) {
- case kSpiOpClose:
- return "Close error, cannot close SPI";
- case kSpiOpOpen:
- return "Open error, cannot open SPI";
- case kSpiOpTransferArray:
- case kSpiOpTransferBuffer:
- return "Transfer error, cannot transfer from SPI device";
- default:
- return "Unknown error";
- }
-}
-
-static void spi_after_work(uv_work_t* work_req, int status) {
- iotjs_spi_reqwrap_t* req_wrap =
- (iotjs_spi_reqwrap_t*)(iotjs_reqwrap_from_request((uv_req_t*)work_req));
- iotjs_spi_reqdata_t* req_data = &req_wrap->req_data;
-
- iotjs_jargs_t jargs = iotjs_jargs_create(2);
-
- if (status) {
- iotjs_jargs_append_error(&jargs, "System error");
- } else {
- switch (req_data->op) {
- case kSpiOpClose:
- case kSpiOpOpen: {
- if (!req_data->result) {
- iotjs_jargs_append_error(&jargs, spi_error_str(req_data->op));
- } else {
- iotjs_jargs_append_null(&jargs);
- }
- break;
- }
- case kSpiOpTransferArray:
- case kSpiOpTransferBuffer: {
- iotjs_spi_t* spi = req_wrap->spi_data;
-
- if (!req_data->result) {
- iotjs_jargs_append_error(&jargs, spi_error_str(req_data->op));
- } else {
- iotjs_jargs_append_null(&jargs);
-
- // Append read data
- jerry_value_t result =
- iotjs_jval_create_byte_array(spi->buf_len, spi->rx_buf_data);
- iotjs_jargs_append_jval(&jargs, result);
- jerry_release_value(result);
- }
-
- if (req_data->op == kSpiOpTransferArray) {
- iotjs_buffer_release(spi->tx_buf_data);
- }
-
- iotjs_buffer_release(spi->rx_buf_data);
- break;
- }
- default: {
- IOTJS_ASSERT(!"Unreachable");
- break;
- }
- }
- }
-
- jerry_value_t jcallback = iotjs_reqwrap_jcallback(&req_wrap->reqwrap);
- if (jerry_value_is_function(jcallback)) {
- iotjs_make_callback(jcallback, jerry_create_undefined(), &jargs);
- }
-
- iotjs_jargs_destroy(&jargs);
- spi_reqwrap_destroy(req_wrap);
-}
-
-#define SPI_CALL_ASYNC(op, jcallback) \
- do { \
- uv_loop_t* loop = iotjs_environment_loop(iotjs_environment_get()); \
- iotjs_spi_reqwrap_t* req_wrap = spi_reqwrap_create(jcallback, spi, op); \
- uv_work_t* req = &req_wrap->req; \
- uv_queue_work(loop, req, spi_worker, spi_after_work); \
- } while (0)
-
-
JS_FUNCTION(SpiCons) {
DJS_CHECK_THIS();
DJS_CHECK_ARGS(1, object);
// If the callback doesn't exist, it is completed synchronously.
// Otherwise, it will be executed asynchronously.
if (!jerry_value_is_null(jcallback)) {
- SPI_CALL_ASYNC(kSpiOpOpen, jcallback);
+ iotjs_periph_call_async(spi, jcallback, kSpiOpOpen, spi_worker);
} else if (!iotjs_spi_open(spi)) {
- return JS_CREATE_ERROR(COMMON, spi_error_str(kSpiOpOpen));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kSpiOpOpen));
}
return jerry_create_undefined();
DJS_CHECK_ARG_IF_EXIST(1, function);
uint8_t op = spi_transfer_helper(jargv[0], spi);
- SPI_CALL_ASYNC((SpiOp)op, JS_GET_ARG_IF_EXIST(1, function));
+ iotjs_periph_call_async(spi, JS_GET_ARG_IF_EXIST(1, function), op,
+ spi_worker);
return jerry_create_undefined();
}
jerry_value_t result = jerry_create_undefined();
if (!iotjs_spi_transfer(spi)) {
- result = JS_CREATE_ERROR(COMMON, spi_error_str(op));
+ result = JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(op));
} else {
result = iotjs_jval_create_byte_array(spi->buf_len, spi->rx_buf_data);
}
if (op == kSpiOpTransferArray) {
- iotjs_buffer_release(spi->tx_buf_data);
+ IOTJS_RELEASE(spi->tx_buf_data);
}
- iotjs_buffer_release(spi->rx_buf_data);
+ IOTJS_RELEASE(spi->rx_buf_data);
return result;
}
JS_DECLARE_THIS_PTR(spi, spi);
DJS_CHECK_ARG_IF_EXIST(1, function);
- SPI_CALL_ASYNC(kSpiOpClose, JS_GET_ARG_IF_EXIST(0, function));
+ iotjs_periph_call_async(spi, JS_GET_ARG_IF_EXIST(0, function), kSpiOpClose,
+ spi_worker);
return jerry_create_undefined();
}
JS_DECLARE_THIS_PTR(spi, spi);
if (!iotjs_spi_close(spi)) {
- return JS_CREATE_ERROR(COMMON, spi_error_str(kSpiOpClose));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kSpiOpClose));
}
return jerry_create_undefined();
#include "iotjs_def.h"
#include "iotjs_module_buffer.h"
+#include "iotjs_module_periph_common.h"
#include "iotjs_reqwrap.h"
-#if defined(__TIZENRT__)
-#include <iotbus_spi.h>
-#include <tinyara/config.h>
-#endif
-
-
-#if defined(__NUTTX__)
-#include <nuttx/spi/spi.h>
-#endif
-
-typedef enum {
- kSpiOpClose,
- kSpiOpOpen,
- kSpiOpTransferArray,
- kSpiOpTransferBuffer
-} SpiOp;
typedef enum {
kSpiMode_0,
uint8_t buf_len;
} iotjs_spi_t;
-typedef struct {
- bool result;
- SpiOp op;
-} iotjs_spi_reqdata_t;
-
-typedef struct {
- iotjs_reqwrap_t reqwrap;
- uv_work_t req;
- iotjs_spi_reqdata_t req_data;
- iotjs_spi_t* spi_data;
-} iotjs_spi_reqwrap_t;
-
-
jerry_value_t iotjs_spi_set_platform_config(iotjs_spi_t* spi,
const jerry_value_t jconfig);
bool iotjs_spi_open(iotjs_spi_t* spi);
}
-JS_FUNCTION(Open) {
- return jerry_create_undefined();
-}
-
-
// Socket close result handler.
void AfterClose(uv_handle_t* handle) {
iotjs_handlewrap_t* wrap = iotjs_handlewrap_from_handle(handle);
IOTJS_ASSERT(jerry_value_is_function(jcreate_tcp));
jerry_value_t jclient_tcp =
- iotjs_jhelper_call_ok(jcreate_tcp, jerry_create_undefined(),
- iotjs_jargs_get_empty());
+ iotjs_jhelper_call(jcreate_tcp, jerry_create_undefined(),
+ iotjs_jargs_get_empty());
+ IOTJS_ASSERT(!jerry_value_has_error_flag(jclient_tcp));
IOTJS_ASSERT(jerry_value_is_object(jclient_tcp));
iotjs_tcpwrap_t* tcp_wrap_client =
iotjs_jargs_append_bool(&jargs, false);
if (nread <= 0) {
- if (buf->base != NULL) {
- iotjs_buffer_release(buf->base);
- }
+ iotjs_buffer_release(buf->base);
+
if (nread < 0) {
if (nread == UV__EOF) {
iotjs_jargs_replace(&jargs, 2, jerry_create_boolean(true));
iotjs_jval_set_property_jval(tcp, IOTJS_MAGIC_STRING_PROTOTYPE, prototype);
iotjs_jval_set_method(tcp, IOTJS_MAGIC_STRING_ERRNAME, ErrName);
- iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_OPEN, Open);
iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_CLOSE, Close);
iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_CONNECT, Connect);
iotjs_jval_set_method(prototype, IOTJS_MAGIC_STRING_BIND, Bind);
+++ /dev/null
-/* Copyright 2016-present Samsung Electronics Co., Ltd. and other contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "iotjs_def.h"
-#include "iotjs_module_timer.h"
-
-
-// Only for test driver
-JS_FUNCTION(IsAliveExceptFor) {
- JS_CHECK(jargc == 1);
- const iotjs_environment_t* env = iotjs_environment_get();
- uv_loop_t* loop = iotjs_environment_loop(env);
-
- if (jerry_value_is_null(jargv[0])) {
- int alive = uv_loop_alive(loop);
-
- return jerry_create_boolean(alive);
- } else {
- JS_CHECK(jerry_value_is_object(jargv[0]));
-
- jerry_value_t jtimer =
- iotjs_jval_get_property(jargv[0], IOTJS_MAGIC_STRING_HANDLER);
-
- iotjs_timerwrap_t* timer_wrap = iotjs_timerwrap_from_jobject(jtimer);
- jerry_release_value(jtimer);
-
- bool has_active_reqs = uv_loop_has_active_reqs(loop);
- bool has_closing_handler = loop->closing_handles != NULL;
-
- bool ret = true;
- bool alive = !has_active_reqs && !has_closing_handler;
- if (alive) {
- unsigned int active_handlers = loop->active_handles;
- if (active_handlers == 1u) {
- const uv_timer_t* timer_handle = iotjs_timerwrap_handle(timer_wrap);
- int timer_alive = uv_is_active((uv_handle_t*)timer_handle);
-
- if (timer_alive) {
- // If the timer handler we set for test driver is alive,
- // then it can be safely terminated.
- ret = false;
- }
- }
- }
-
- return jerry_create_boolean(ret);
- }
-}
-
-
-jerry_value_t InitTestdriver() {
- jerry_value_t testdriver = jerry_create_object();
- iotjs_jval_set_method(testdriver, IOTJS_MAGIC_STRING_ISALIVEEXCEPTFOR,
- IsAliveExceptFor);
-
- return testdriver;
-}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "iotjs_def.h"
+#include "iotjs_module_bridge.h"
+
+extern void iotjs_tizen_func(const char* command, const char* message,
+ void* handle);
+
+/**
+ * Init method called by IoT.js
+ */
+jerry_value_t InitTizen() {
+ char* module_name = IOTJS_MAGIC_STRING_TIZEN;
+ jerry_value_t mymodule = jerry_create_object();
+ iotjs_jval_set_property_string_raw(mymodule, IOTJS_MAGIC_STRING_MODULE_NAME,
+ module_name);
+
+ iotjs_bridge_register(module_name, iotjs_tizen_func);
+ return mymodule;
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "iotjs_module_tls.h"
+#include "iotjs_module_buffer.h"
+
+#include "stdarg.h"
+
+static void iotjs_tls_context_destroy(iotjs_tls_context_t *tls_context);
+
+static const jerry_object_native_info_t tls_context_native_info = {
+ .free_cb = (jerry_object_native_free_callback_t)iotjs_tls_context_destroy
+};
+
+
+static void iotjs_tls_context_destroy(iotjs_tls_context_t *tls_context) {
+ if (tls_context->ref_count > 1) {
+ tls_context->ref_count--;
+ return;
+ }
+
+ mbedtls_x509_crt_free(&tls_context->cert_auth);
+ mbedtls_x509_crt_free(&tls_context->own_cert);
+ mbedtls_pk_free(&tls_context->pkey);
+ mbedtls_ctr_drbg_free(&tls_context->ctr_drbg);
+ mbedtls_entropy_free(&tls_context->entropy);
+
+ IOTJS_RELEASE(tls_context);
+}
+
+
+static iotjs_tls_context_t *iotjs_tls_context_create(
+ const jerry_value_t jobject) {
+ iotjs_tls_context_t *tls_context = IOTJS_ALLOC(iotjs_tls_context_t);
+
+ tls_context->ref_count = 1;
+ tls_context->context_flags = 0;
+ mbedtls_entropy_init(&tls_context->entropy);
+ mbedtls_ctr_drbg_init(&tls_context->ctr_drbg);
+ mbedtls_pk_init(&tls_context->pkey);
+ mbedtls_x509_crt_init(&tls_context->own_cert);
+ mbedtls_x509_crt_init(&tls_context->cert_auth);
+
+ jerry_set_object_native_pointer(jobject, tls_context,
+ &tls_context_native_info);
+
+ return tls_context;
+}
+
+
+IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE(tls);
+
+
+static void iotjs_tls_destroy(iotjs_tls_t *tls_data) {
+ mbedtls_ssl_free(&tls_data->ssl);
+ mbedtls_ssl_config_free(&tls_data->conf);
+ iotjs_tls_context_destroy(tls_data->tls_context);
+
+ IOTJS_RELEASE(tls_data->bio.receive_bio.mem);
+ IOTJS_RELEASE(tls_data->bio.send_bio.mem);
+
+ IOTJS_RELEASE(tls_data);
+}
+
+
+static iotjs_tls_t *iotjs_tls_create(const jerry_value_t jobject,
+ iotjs_tls_context_t *tls_context) {
+ iotjs_tls_t *tls_data = IOTJS_ALLOC(iotjs_tls_t);
+
+ tls_context->ref_count++;
+
+ tls_data->tls_context = tls_context;
+ mbedtls_ssl_config_init(&tls_data->conf);
+ mbedtls_ssl_init(&tls_data->ssl);
+ tls_data->state = TLS_HANDSHAKE_READY;
+
+ tls_data->jobject = jobject;
+ jerry_set_object_native_pointer(jobject, tls_data, &this_module_native_info);
+
+ return tls_data;
+}
+
+
+static void iotjs_bio_init(iotjs_bio_t *bio, size_t size) {
+ bio->mem = (char *)iotjs_buffer_allocate(size);
+ bio->size = size;
+ bio->read_index = 0;
+ bio->write_index = 0;
+}
+
+
+static size_t iotjs_bio_pending(iotjs_bio_t *bio) {
+ if (bio->read_index <= bio->write_index) {
+ return bio->write_index - bio->read_index;
+ }
+
+ return bio->write_index + bio->size - bio->read_index;
+}
+
+
+static size_t iotjs_bio_remaining(iotjs_bio_t *bio) {
+ if (bio->write_index < bio->read_index) {
+ return bio->read_index - bio->write_index - 1;
+ }
+
+ return bio->read_index + bio->size - bio->write_index - 1;
+}
+
+
+static void iotjs_bio_read(iotjs_bio_t *bio, char *buf, size_t size) {
+ IOTJS_ASSERT(size <= iotjs_bio_pending(bio));
+
+ if (bio->read_index + size > bio->size) {
+ size_t copy_size = bio->size - bio->read_index;
+
+ memcpy(buf, bio->mem + bio->read_index, copy_size);
+ size -= copy_size;
+ buf += copy_size;
+ bio->read_index = 0;
+ }
+
+ memcpy(buf, bio->mem + bio->read_index, size);
+ bio->read_index += size;
+}
+
+
+static void iotjs_bio_write(iotjs_bio_t *bio, const char *buf, size_t size) {
+ IOTJS_ASSERT(size <= iotjs_bio_remaining(bio));
+
+ if (bio->write_index + size > bio->size) {
+ size_t copy_size = bio->size - bio->write_index;
+
+ memcpy(bio->mem + bio->write_index, buf, copy_size);
+ size -= copy_size;
+ buf += copy_size;
+ bio->write_index = 0;
+ }
+
+ memcpy(bio->mem + bio->write_index, buf, size);
+ bio->write_index += size;
+}
+
+
+static int iotjs_bio_net_send(void *ctx, const unsigned char *buf, size_t len) {
+ iotjs_bio_t *send_bio = &(((iotjs_bio_pair_t *)ctx)->send_bio);
+
+ size_t remaining = iotjs_bio_remaining(send_bio);
+
+ if (remaining == 0) {
+ return MBEDTLS_ERR_SSL_WANT_WRITE;
+ }
+
+ if (len > remaining) {
+ len = remaining;
+ }
+
+ iotjs_bio_write(send_bio, (const char *)buf, len);
+ return (int)len;
+}
+
+static int iotjs_bio_net_receive(void *ctx, unsigned char *buf, size_t len) {
+ iotjs_bio_t *receive_bio = &(((iotjs_bio_pair_t *)ctx)->receive_bio);
+
+ size_t pending = iotjs_bio_pending(receive_bio);
+
+ if (pending == 0) {
+ return MBEDTLS_ERR_SSL_WANT_READ;
+ }
+
+ if (len > pending) {
+ len = pending;
+ }
+
+ iotjs_bio_read(receive_bio, (char *)buf, len);
+ return (int)len;
+}
+
+
+JS_FUNCTION(TlsContext) {
+ DJS_CHECK_THIS();
+ DJS_CHECK_ARGS(1, object);
+
+ jerry_value_t jtls = JS_GET_THIS();
+ iotjs_tls_context_t *tls_context = iotjs_tls_context_create(jtls);
+
+ jerry_value_t joptions = JS_GET_ARG(0, object);
+
+ // Set deterministic random bit generator
+ if (mbedtls_ctr_drbg_seed(&tls_context->ctr_drbg, mbedtls_entropy_func,
+ &tls_context->entropy, NULL, 0) != 0) {
+ return JS_CREATE_ERROR(COMMON, "drbg seeding failed");
+ }
+
+ // User provided certificate
+ int ret = 0;
+ jerry_value_t jcert =
+ iotjs_jval_get_property(joptions, IOTJS_MAGIC_STRING_CERT);
+ jerry_value_t jkey =
+ iotjs_jval_get_property(joptions, IOTJS_MAGIC_STRING_KEY);
+
+ if (jerry_value_is_string(jcert) && jerry_value_is_string(jkey)) {
+ iotjs_string_t cert = iotjs_jval_as_string(jcert);
+ const char *cert_chars = iotjs_string_data(&cert);
+
+ ret = mbedtls_x509_crt_parse(&tls_context->own_cert,
+ (const unsigned char *)cert_chars,
+ (size_t)iotjs_string_size(&cert) + 1);
+
+ iotjs_string_destroy(&cert);
+
+ if (ret == 0) {
+ iotjs_string_t key = iotjs_jval_as_string(jkey);
+ const char *key_chars = iotjs_string_data(&key);
+
+ ret = mbedtls_pk_parse_key(&tls_context->pkey,
+ (const unsigned char *)key_chars,
+ (size_t)iotjs_string_size(&key) + 1, NULL, 0);
+
+ iotjs_string_destroy(&key);
+
+ if (ret == 0) {
+ tls_context->context_flags |= SSL_CONTEXT_HAS_KEY;
+ }
+ }
+ }
+
+ jerry_release_value(jcert);
+ jerry_release_value(jkey);
+
+ if (ret != 0) {
+ return JS_CREATE_ERROR(COMMON, "key or certificate parsing failed");
+ }
+
+ // User provided trusted certificates
+ jerry_value_t jcert_auth =
+ iotjs_jval_get_property(joptions, IOTJS_MAGIC_STRING_CA);
+
+ if (jerry_value_is_string(jcert_auth)) {
+ iotjs_string_t cert_auth = iotjs_jval_as_string(jcert_auth);
+ const char *cert_auth_chars = iotjs_string_data(&cert_auth);
+
+ ret = mbedtls_x509_crt_parse(&tls_context->cert_auth,
+ (const unsigned char *)cert_auth_chars,
+ (size_t)iotjs_string_size(&cert_auth) + 1);
+
+ iotjs_string_destroy(&cert_auth);
+ } else {
+ // Parse the default certificate authority
+ ret = mbedtls_x509_crt_parse(&tls_context->cert_auth,
+ (const unsigned char *)SSL_CA_PEM,
+ sizeof(SSL_CA_PEM));
+ }
+
+ jerry_release_value(jcert_auth);
+
+ if (ret) {
+ return JS_CREATE_ERROR(COMMON, "certificate authority (CA) parsing failed");
+ }
+
+ return jerry_create_undefined();
+}
+
+
+JS_FUNCTION(TlsInit) {
+ DJS_CHECK_ARGS(3, object, object, object);
+
+ jerry_value_t jtls_socket = JS_GET_ARG(0, object);
+ jerry_value_t joptions = JS_GET_ARG(1, object);
+
+ // Get context
+ jerry_value_t jtls_context = JS_GET_ARG(2, object);
+
+ void *native_ptr;
+ const jerry_object_native_info_t *native_info;
+ bool tls_context_available =
+ jerry_get_object_native_pointer(jtls_context, &native_ptr, &native_info);
+
+ if (!tls_context_available || native_info != &tls_context_native_info) {
+ return JS_CREATE_ERROR(COMMON, "secure context not available");
+ }
+
+ iotjs_tls_context_t *tls_context = (iotjs_tls_context_t *)native_ptr;
+
+ iotjs_tls_t *tls_data = iotjs_tls_create(jtls_socket, tls_context);
+
+ // Check server
+ jerry_value_t jis_server =
+ iotjs_jval_get_property(joptions, IOTJS_MAGIC_STRING_ISSERVER);
+ bool is_server = jerry_value_to_boolean(jis_server);
+ jerry_release_value(jis_server);
+
+ if (tls_context->context_flags & SSL_CONTEXT_HAS_KEY) {
+ if (mbedtls_ssl_conf_own_cert(&tls_data->conf, &tls_context->own_cert,
+ &tls_context->pkey) != 0) {
+ return JS_CREATE_ERROR(COMMON, "certificate/private key cannot be set");
+ }
+ }
+
+ mbedtls_ssl_conf_ca_chain(&tls_data->conf, &tls_context->cert_auth, NULL);
+
+ mbedtls_ssl_conf_rng(&tls_data->conf, mbedtls_ctr_drbg_random,
+ &tls_context->ctr_drbg);
+
+ int endpoint = is_server ? MBEDTLS_SSL_IS_SERVER : MBEDTLS_SSL_IS_CLIENT;
+
+ if (mbedtls_ssl_config_defaults(&tls_data->conf, endpoint,
+ MBEDTLS_SSL_TRANSPORT_STREAM,
+ MBEDTLS_SSL_PRESET_DEFAULT)) {
+ return JS_CREATE_ERROR(COMMON, "SSL Configuration failed");
+ }
+
+ // if true, verifies CAs, must emit error if fails
+ int auth_mode =
+ is_server ? MBEDTLS_SSL_VERIFY_NONE : MBEDTLS_SSL_VERIFY_REQUIRED;
+
+ jerry_value_t jauth_mode =
+ iotjs_jval_get_property(joptions, IOTJS_MAGIC_STRING_REJECTUNAUTHORIZED);
+
+ if (!jerry_value_is_undefined(jauth_mode)) {
+ if (jerry_value_to_boolean(jauth_mode)) {
+ auth_mode = MBEDTLS_SSL_VERIFY_REQUIRED;
+ } else {
+ auth_mode = MBEDTLS_SSL_VERIFY_OPTIONAL;
+ }
+ }
+
+ jerry_release_value(jauth_mode);
+
+ mbedtls_ssl_conf_authmode(&tls_data->conf, auth_mode);
+
+ if (mbedtls_ssl_setup(&tls_data->ssl, &tls_data->conf)) {
+ return JS_CREATE_ERROR(COMMON, "SSL setup failed");
+ }
+
+ // Connect mbedtls with iotjs_net_send and iotjs_net_recv functions
+ iotjs_bio_init(&(tls_data->bio.receive_bio), SSL_BIO_SIZE);
+ iotjs_bio_init(&(tls_data->bio.send_bio), SSL_BIO_SIZE);
+ mbedtls_ssl_set_bio(&tls_data->ssl, &(tls_data->bio), iotjs_bio_net_send,
+ iotjs_bio_net_receive, NULL);
+
+ return jerry_create_undefined();
+}
+
+
+JS_FUNCTION(Connect) {
+ JS_DECLARE_THIS_PTR(tls, tls_data);
+ DJS_CHECK_ARGS(1, string);
+
+ if (tls_data->state == TLS_HANDSHAKE_READY) {
+ iotjs_string_t server_name = JS_GET_ARG(0, string);
+ mbedtls_ssl_set_hostname(&tls_data->ssl, iotjs_string_data(&server_name));
+ iotjs_string_destroy(&server_name);
+ }
+
+ return jerry_create_undefined();
+}
+
+
+static void iotjs_tls_send_pending(iotjs_tls_t *tls_data) {
+ iotjs_bio_t *send_bio = &(tls_data->bio.send_bio);
+ size_t pending = iotjs_bio_pending(send_bio);
+
+ if (pending == 0) {
+ return;
+ }
+
+ jerry_value_t jbuffer = iotjs_bufferwrap_create_buffer(pending);
+ iotjs_bufferwrap_t *buffer_wrap = iotjs_bufferwrap_from_jbuffer(jbuffer);
+ iotjs_bio_read(send_bio, buffer_wrap->buffer, pending);
+
+ jerry_value_t jthis = tls_data->jobject;
+ jerry_value_t fn = iotjs_jval_get_property(jthis, IOTJS_MAGIC_STRING_ONWRITE);
+
+ iotjs_jargs_t jargv = iotjs_jargs_create(1);
+ iotjs_jargs_append_jval(&jargv, jbuffer);
+ iotjs_make_callback(fn, jthis, &jargv);
+
+ jerry_release_value(fn);
+ jerry_release_value(jbuffer);
+ iotjs_jargs_destroy(&jargv);
+}
+
+
+static void iotjs_tls_notify_error(iotjs_tls_t *tls_data) {
+ jerry_value_t jerror = jerry_create_string((const jerry_char_t *)"error");
+ jerry_value_t jmessage =
+ jerry_create_string((const jerry_char_t *)"TLS error");
+
+ jerry_value_t jthis = tls_data->jobject;
+ jerry_value_t fn = iotjs_jval_get_property(jthis, IOTJS_MAGIC_STRING_EMIT);
+
+ iotjs_jargs_t jargv = iotjs_jargs_create(2);
+ iotjs_jargs_append_jval(&jargv, jerror);
+ iotjs_jargs_append_jval(&jargv, jmessage);
+ iotjs_make_callback(fn, jthis, &jargv);
+
+ jerry_release_value(fn);
+ iotjs_jargs_destroy(&jargv);
+}
+
+
+JS_FUNCTION(Write) {
+ JS_DECLARE_THIS_PTR(tls, tls_data);
+
+ if (tls_data->state != TLS_CONNECTED) {
+ return jerry_create_null();
+ }
+
+ const unsigned char *data = NULL;
+ size_t length = 0;
+ bool is_end = false;
+
+ if (jargc >= 1 && jerry_value_to_boolean(jargv[0])) {
+ jerry_value_t jbuffer = JS_GET_ARG(0, object);
+
+ iotjs_bufferwrap_t *buf = iotjs_bufferwrap_from_jbuffer(jbuffer);
+ data = (const unsigned char *)buf->buffer;
+ length = iotjs_bufferwrap_length(buf);
+ }
+
+ if (jargc >= 2 && jerry_value_to_boolean(jargv[1])) {
+ is_end = true;
+ }
+
+ while (true) {
+ int ret_val = mbedtls_ssl_write(&tls_data->ssl, data, length);
+
+ if ((int)length == ret_val) {
+ break;
+ }
+
+ iotjs_tls_send_pending(tls_data);
+
+ if (ret_val > 0) {
+ data += ret_val;
+ length -= ret_val;
+ } else if (ret_val != MBEDTLS_ERR_SSL_WANT_WRITE) {
+ tls_data->state = TLS_CLOSED;
+ return jerry_create_null();
+ }
+ }
+
+ if (is_end) {
+ while (true) {
+ int ret_val = mbedtls_ssl_close_notify(&tls_data->ssl);
+ if (ret_val == 0) {
+ tls_data->state = TLS_CLOSED;
+ break;
+ }
+
+ iotjs_tls_send_pending(tls_data);
+
+ if (ret_val != MBEDTLS_ERR_SSL_WANT_WRITE) {
+ iotjs_tls_notify_error(tls_data);
+ tls_data->state = TLS_CLOSED;
+ return jerry_create_null();
+ }
+ }
+ }
+
+ /* Last package is returned as a buffer. */
+ iotjs_bio_t *send_bio = &(tls_data->bio.send_bio);
+ size_t pending = iotjs_bio_pending(send_bio);
+
+ jerry_value_t jbuffer = iotjs_bufferwrap_create_buffer(pending);
+ iotjs_bufferwrap_t *buf = iotjs_bufferwrap_from_jbuffer(jbuffer);
+ iotjs_bio_read(send_bio, buf->buffer, pending);
+
+ return jbuffer;
+}
+
+
+static void tls_handshake(iotjs_tls_t *tls_data, jerry_value_t jthis) {
+ tls_data->state = TLS_HANDSHAKE_IN_PROGRESS;
+ // Continue handshaking process
+ int ret_val = mbedtls_ssl_handshake(&tls_data->ssl);
+
+ iotjs_tls_send_pending(tls_data);
+
+ bool error;
+ bool authorized;
+
+ // Check whether handshake completed
+ if (ret_val == 0) {
+ tls_data->state = TLS_CONNECTED;
+ error = false;
+ authorized = mbedtls_ssl_get_verify_result(&tls_data->ssl) == 0;
+ } else {
+ if (ret_val == MBEDTLS_ERR_SSL_WANT_READ ||
+ ret_val == MBEDTLS_ERR_SSL_WANT_WRITE) {
+ return;
+ }
+
+ tls_data->state = TLS_CLOSED;
+ error = true;
+ authorized = false;
+ }
+
+ // Result of certificate verification
+ iotjs_jargs_t jargv = iotjs_jargs_create(2);
+ iotjs_jargs_append_bool(&jargv, error);
+ iotjs_jargs_append_bool(&jargv, authorized);
+
+ jerry_value_t fn =
+ iotjs_jval_get_property(jthis, IOTJS_MAGIC_STRING_ONHANDSHAKEDONE);
+ iotjs_make_callback(fn, jthis, &jargv);
+
+ jerry_release_value(fn);
+ iotjs_jargs_destroy(&jargv);
+}
+
+
+JS_FUNCTION(Read) {
+ JS_DECLARE_THIS_PTR(tls, tls_data);
+
+ if (tls_data->state == TLS_CLOSED) {
+ return jerry_create_boolean(false);
+ }
+
+ iotjs_bio_t *receive_bio = &(tls_data->bio.receive_bio);
+ const char *data = NULL;
+ size_t length = 0;
+
+ if (jargc >= 1 && jerry_value_to_boolean(jargv[0])) {
+ jerry_value_t jbuffer = JS_GET_ARG(0, object);
+
+ iotjs_bufferwrap_t *buf = iotjs_bufferwrap_from_jbuffer(jbuffer);
+ data = buf->buffer;
+ length = iotjs_bufferwrap_length(buf);
+ }
+
+ do {
+ size_t copy_size = iotjs_bio_remaining(receive_bio);
+
+ if (copy_size > length) {
+ copy_size = length;
+ }
+
+ iotjs_bio_write(receive_bio, data, length);
+ data += copy_size;
+ length -= copy_size;
+
+ if (tls_data->state != TLS_CONNECTED) {
+ IOTJS_ASSERT(tls_data->state == TLS_HANDSHAKE_READY ||
+ tls_data->state == TLS_HANDSHAKE_IN_PROGRESS);
+ tls_handshake(tls_data, jthis);
+
+ if (tls_data->state != TLS_CONNECTED) {
+ IOTJS_ASSERT(tls_data->state == TLS_HANDSHAKE_IN_PROGRESS ||
+ tls_data->state == TLS_CLOSED);
+
+ bool result = (tls_data->state != TLS_CLOSED);
+ return jerry_create_boolean(result);
+ }
+ }
+
+ while (true) {
+ int ret_val = mbedtls_ssl_read(&tls_data->ssl, NULL, 0);
+ iotjs_tls_send_pending(tls_data);
+
+ if (ret_val == 0) {
+ size_t pending = mbedtls_ssl_get_bytes_avail(&tls_data->ssl);
+
+ if (pending == 0) {
+ continue;
+ }
+
+ jerry_value_t jbuffer = iotjs_bufferwrap_create_buffer(pending);
+ iotjs_bufferwrap_t *buf = iotjs_bufferwrap_from_jbuffer(jbuffer);
+ ret_val = mbedtls_ssl_read(&tls_data->ssl, (unsigned char *)buf->buffer,
+ pending);
+
+ IOTJS_ASSERT(ret_val == (int)pending);
+ IOTJS_UNUSED(ret_val);
+
+ jerry_value_t fn =
+ iotjs_jval_get_property(jthis, IOTJS_MAGIC_STRING_ONREAD);
+ iotjs_jargs_t jargv = iotjs_jargs_create(1);
+
+ iotjs_jargs_append_jval(&jargv, jbuffer);
+ iotjs_make_callback(fn, jthis, &jargv);
+
+ jerry_release_value(jbuffer);
+ jerry_release_value(fn);
+ iotjs_jargs_destroy(&jargv);
+ continue;
+ }
+
+ if (ret_val == MBEDTLS_ERR_SSL_WANT_READ) {
+ return jerry_create_boolean(true);
+ }
+
+ if (ret_val == MBEDTLS_ERR_SSL_WANT_WRITE) {
+ continue;
+ }
+
+ tls_data->state = TLS_CLOSED;
+
+ if (ret_val == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) {
+ return jerry_create_boolean(true);
+ }
+
+ iotjs_tls_notify_error(tls_data);
+ return jerry_create_boolean(false);
+ }
+ } while (length > 0);
+
+ return jerry_create_boolean(true);
+}
+
+
+jerry_value_t InitTls() {
+ jerry_value_t jtls = jerry_create_object();
+
+ iotjs_jval_set_method(jtls, IOTJS_MAGIC_STRING_CONNECT, Connect);
+ iotjs_jval_set_method(jtls, IOTJS_MAGIC_STRING_READ, Read);
+ iotjs_jval_set_method(jtls, IOTJS_MAGIC_STRING_TLSCONTEXT, TlsContext);
+ iotjs_jval_set_method(jtls, IOTJS_MAGIC_STRING_TLSINIT, TlsInit);
+ iotjs_jval_set_method(jtls, IOTJS_MAGIC_STRING_WRITE, Write);
+
+ return jtls;
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef IOTJS_MODULE_TLS_H
+#define IOTJS_MODULE_TLS_H
+
+#include "iotjs_def.h"
+#include "mbedtls/certs.h"
+#include "mbedtls/ctr_drbg.h"
+#include "mbedtls/entropy.h"
+#include "mbedtls/net.h"
+#include "mbedtls/net_sockets.h"
+#include "mbedtls/ssl.h"
+
+// Default certificate
+const char SSL_CA_PEM[] =
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMX\n"
+ "R2xvYmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMT\n"
+ "Ckdsb2JhbFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQL\n"
+ "ExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE\n"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EveegeGTLg==\n"
+ "-----END CERTIFICATE-----\n";
+
+// Handshake states for tls context
+enum {
+ TLS_HANDSHAKE_READY = 0,
+ TLS_HANDSHAKE_IN_PROGRESS = 1,
+ TLS_CONNECTED = 2,
+ TLS_CLOSED = 3
+};
+
+typedef struct {
+ char *mem;
+ size_t size;
+ size_t read_index;
+ size_t write_index;
+} iotjs_bio_t;
+
+typedef struct {
+ iotjs_bio_t receive_bio;
+ iotjs_bio_t send_bio;
+} iotjs_bio_pair_t;
+
+enum {
+ SSL_BIO_SUCCESS = 0,
+ SSL_BIO_ERROR = -1,
+ SSL_BIO_UNSET = -2,
+ SSL_BIO_SIZE = 4096
+};
+
+enum { SSL_CONTEXT_HAS_KEY = (1 << 0) };
+
+typedef struct {
+ int ref_count;
+ uint32_t context_flags;
+ mbedtls_entropy_context entropy;
+ mbedtls_ctr_drbg_context ctr_drbg;
+ mbedtls_pk_context pkey;
+ mbedtls_x509_crt own_cert;
+ mbedtls_x509_crt cert_auth;
+} iotjs_tls_context_t;
+
+typedef struct {
+ jerry_value_t jobject;
+ int state;
+
+ iotjs_tls_context_t *tls_context;
+ mbedtls_ssl_config conf;
+ mbedtls_ssl_context ssl;
+
+ iotjs_bio_pair_t bio;
+} iotjs_tls_t;
+
+#endif /* IOTJS_MODULE_TLS_H */
static iotjs_uart_t* uart_create(const jerry_value_t juart) {
iotjs_uart_t* uart = IOTJS_ALLOC(iotjs_uart_t);
+ iotjs_uart_create_platform_data(uart);
+
iotjs_handlewrap_initialize(&uart->handlewrap, juart,
(uv_handle_t*)(&uart->poll_handle),
&this_module_native_info);
static void iotjs_uart_destroy(iotjs_uart_t* uart) {
iotjs_handlewrap_destroy(&uart->handlewrap);
- iotjs_string_destroy(&uart->device_path);
+ iotjs_uart_destroy_platform_data(uart->platform_data);
IOTJS_RELEASE(uart);
}
-static iotjs_uart_reqwrap_t* uart_reqwrap_create(jerry_value_t jcallback,
- iotjs_uart_t* uart,
- UartOp op) {
- iotjs_uart_reqwrap_t* uart_reqwrap = IOTJS_ALLOC(iotjs_uart_reqwrap_t);
-
- iotjs_reqwrap_initialize(&uart_reqwrap->reqwrap, jcallback,
- (uv_req_t*)&uart_reqwrap->req);
-
- uart_reqwrap->req_data.op = op;
- uart_reqwrap->uart_data = uart;
-
- return uart_reqwrap;
-}
-
-static void uart_reqwrap_destroy(iotjs_uart_reqwrap_t* uart_reqwrap) {
- iotjs_reqwrap_destroy(&uart_reqwrap->reqwrap);
- IOTJS_RELEASE(uart_reqwrap);
-}
-
-static const char* uart_error_str(uint8_t op) {
- switch (op) {
- case kUartOpClose:
- return "Close error, failed to close UART device";
- case kUartOpOpen:
- return "Open error, failed to open UART device";
- case kUartOpWrite:
- return "Write error, cannot write to UART device";
- default:
- return "Unknown error";
- }
-}
-
-static void handlewrap_close_callback(uv_handle_t* handle) {
- iotjs_uart_t* uart = (iotjs_uart_t*)handle->data;
-
- if (close(uart->device_fd) < 0) {
- DLOG(uart_error_str(kUartOpClose));
- IOTJS_ASSERT(0);
- }
-}
-
-static void uart_after_worker(uv_work_t* work_req, int status) {
- iotjs_uart_reqwrap_t* req_wrap =
- (iotjs_uart_reqwrap_t*)(iotjs_reqwrap_from_request((uv_req_t*)work_req));
- iotjs_uart_reqdata_t* req_data = &req_wrap->req_data;
-
- iotjs_jargs_t jargs = iotjs_jargs_create(1);
-
- if (status) {
- iotjs_jargs_append_error(&jargs, "System error");
- } else {
- switch (req_data->op) {
- case kUartOpWrite: {
- iotjs_uart_t* uart = req_wrap->uart_data;
- iotjs_string_destroy(&uart->buf_data);
- /* FALLTHRU */
- }
- case kUartOpClose:
- case kUartOpOpen: {
- if (!req_data->result) {
- iotjs_jargs_append_error(&jargs, uart_error_str(req_data->op));
- } else {
- iotjs_jargs_append_null(&jargs);
- }
- break;
- }
- default: {
- IOTJS_ASSERT(!"Unreachable");
- break;
- }
- }
- }
-
- jerry_value_t jcallback = iotjs_reqwrap_jcallback(&req_wrap->reqwrap);
- if (jerry_value_is_function(jcallback)) {
- iotjs_make_callback(jcallback, jerry_create_undefined(), &jargs);
- }
-
- iotjs_jargs_destroy(&jargs);
- uart_reqwrap_destroy(req_wrap);
-}
-
static void uart_worker(uv_work_t* work_req) {
- iotjs_uart_reqwrap_t* req_wrap =
- (iotjs_uart_reqwrap_t*)(iotjs_reqwrap_from_request((uv_req_t*)work_req));
- iotjs_uart_reqdata_t* req_data = &req_wrap->req_data;
- iotjs_uart_t* uart = req_wrap->uart_data;
+ iotjs_periph_reqwrap_t* req_wrap =
+ (iotjs_periph_reqwrap_t*)(iotjs_reqwrap_from_request(
+ (uv_req_t*)work_req));
+ iotjs_uart_t* uart = (iotjs_uart_t*)req_wrap->data;
- switch (req_data->op) {
+ switch (req_wrap->op) {
case kUartOpOpen:
- req_data->result = iotjs_uart_open(uart);
+ req_wrap->result = iotjs_uart_open(uart);
break;
case kUartOpWrite:
- req_data->result = iotjs_uart_write(uart);
+ req_wrap->result = iotjs_uart_write(uart);
break;
case kUartOpClose:
- iotjs_handlewrap_close(&uart->handlewrap, handlewrap_close_callback);
- req_data->result = true;
+ iotjs_handlewrap_close(&uart->handlewrap, iotjs_uart_handlewrap_close_cb);
+ req_wrap->result = true;
break;
default:
IOTJS_ASSERT(!"Invalid Operation");
jerry_value_t data = jerry_create_string((const jerry_char_t*)buf);
iotjs_jargs_append_jval(&jargs, str);
iotjs_jargs_append_jval(&jargs, data);
- iotjs_jhelper_call_ok(jemit, iotjs_handlewrap_jobject(&uart->handlewrap),
- &jargs);
+ jerry_value_t jres =
+ iotjs_jhelper_call(jemit, iotjs_handlewrap_jobject(&uart->handlewrap),
+ &jargs);
+ IOTJS_ASSERT(!jerry_value_has_error_flag(jres));
+ jerry_release_value(jres);
jerry_release_value(str);
jerry_release_value(data);
iotjs_jargs_destroy(&jargs);
static jerry_value_t uart_set_configuration(iotjs_uart_t* uart,
jerry_value_t jconfig) {
- jerry_value_t jdevice =
- iotjs_jval_get_property(jconfig, IOTJS_MAGIC_STRING_DEVICE);
- if (!jerry_value_is_string(jdevice)) {
- jerry_release_value(jdevice);
- return JS_CREATE_ERROR(
- TYPE, "Bad configuration - device is mandatory and must be a String");
- }
- uart->device_path = iotjs_jval_as_string(jdevice);
- jerry_release_value(jdevice);
-
jerry_value_t jbaud_rate =
iotjs_jval_get_property(jconfig, IOTJS_MAGIC_STRING_BAUDRATE);
if (jerry_value_is_undefined(jbaud_rate)) {
if (br != 230400 && br != 115200 && br != 57600 && br != 38400 &&
br != 19200 && br != 9600 && br != 4800 && br != 2400 && br != 1800 &&
br != 1200 && br != 600 && br != 300 && br != 200 && br != 150 &&
- br != 134 && br != 110 && br != 75 && br != 50) {
+ br != 134 && br != 110 && br != 75 && br != 50 && br != 0) {
return JS_CREATE_ERROR(TYPE, "Invalid baud rate");
}
return jerry_create_undefined();
}
-#define UART_CALL_ASYNC(op, jcallback) \
- do { \
- uv_loop_t* loop = iotjs_environment_loop(iotjs_environment_get()); \
- iotjs_uart_reqwrap_t* req_wrap = uart_reqwrap_create(jcallback, uart, op); \
- uv_work_t* req = &req_wrap->req; \
- uv_queue_work(loop, req, uart_worker, uart_after_worker); \
- } while (0)
-
-
JS_FUNCTION(UartCons) {
DJS_CHECK_THIS();
DJS_CHECK_ARGS(1, object);
jerry_value_t jconfig = JS_GET_ARG(0, object);
// set configuration
- jerry_value_t res = uart_set_configuration(uart, jconfig);
+ jerry_value_t res = iotjs_uart_set_platform_config(uart, jconfig);
+ if (jerry_value_has_error_flag(res)) {
+ return res;
+ }
+
+ res = uart_set_configuration(uart, jconfig);
if (jerry_value_has_error_flag(res)) {
return res;
}
- DDDLOG("%s - path: %s, baudRate: %d, dataBits: %d", __func__,
- iotjs_string_data(&uart->device_path), uart->baud_rate,
+ DDDLOG("%s - baudRate: %d, dataBits: %d", __func__, uart->baud_rate,
uart->data_bits);
jerry_value_t jcallback = JS_GET_ARG_IF_EXIST(1, function);
// If the callback doesn't exist, it is completed synchronously.
// Otherwise, it will be executed asynchronously.
if (!jerry_value_is_null(jcallback)) {
- UART_CALL_ASYNC(kUartOpOpen, jcallback);
+ iotjs_periph_call_async(uart, jcallback, kUartOpOpen, uart_worker);
} else if (!iotjs_uart_open(uart)) {
- return JS_CREATE_ERROR(COMMON, uart_error_str(kUartOpOpen));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kUartOpOpen));
}
return jerry_create_undefined();
uart->buf_data = JS_GET_ARG(0, string);
uart->buf_len = iotjs_string_size(&uart->buf_data);
- UART_CALL_ASYNC(kUartOpWrite, JS_GET_ARG_IF_EXIST(1, function));
+ iotjs_periph_call_async(uart, JS_GET_ARG_IF_EXIST(1, function), kUartOpWrite,
+ uart_worker);
return jerry_create_undefined();
}
iotjs_string_destroy(&uart->buf_data);
if (!result) {
- return JS_CREATE_ERROR(COMMON, uart_error_str(kUartOpWrite));
+ return JS_CREATE_ERROR(COMMON, iotjs_periph_error_str(kUartOpWrite));
}
return jerry_create_undefined();
JS_DECLARE_THIS_PTR(uart, uart);
DJS_CHECK_ARG_IF_EXIST(0, function);
- UART_CALL_ASYNC(kUartOpClose, JS_GET_ARG_IF_EXIST(0, function));
+ iotjs_periph_call_async(uart, JS_GET_ARG_IF_EXIST(0, function), kUartOpClose,
+ uart_worker);
return jerry_create_undefined();
}
JS_FUNCTION(CloseSync) {
JS_DECLARE_THIS_PTR(uart, uart);
- iotjs_handlewrap_close(&uart->handlewrap, handlewrap_close_callback);
+ iotjs_handlewrap_close(&uart->handlewrap, iotjs_uart_handlewrap_close_cb);
return jerry_create_undefined();
}
#include "iotjs_def.h"
#include "iotjs_handlewrap.h"
+#include "iotjs_module_periph_common.h"
#include "iotjs_reqwrap.h"
#define UART_WRITE_BUFFER_SIZE 512
-
-typedef enum {
- kUartOpOpen,
- kUartOpClose,
- kUartOpWrite,
-} UartOp;
-
-typedef struct {
- UartOp op;
- bool result;
-} iotjs_uart_reqdata_t;
+typedef struct iotjs_uart_platform_data_s iotjs_uart_platform_data_t;
typedef struct {
iotjs_handlewrap_t handlewrap;
+ iotjs_uart_platform_data_t* platform_data;
int device_fd;
unsigned baud_rate;
uint8_t data_bits;
- iotjs_string_t device_path;
iotjs_string_t buf_data;
unsigned buf_len;
uv_poll_t poll_handle;
} iotjs_uart_t;
-typedef struct {
- iotjs_reqwrap_t reqwrap;
- uv_work_t req;
- iotjs_uart_reqdata_t req_data;
- iotjs_uart_t* uart_data;
-} iotjs_uart_reqwrap_t;
+jerry_value_t iotjs_uart_set_platform_config(iotjs_uart_t* uart,
+ const jerry_value_t jconfig);
void iotjs_uart_register_read_cb(iotjs_uart_t* uart);
bool iotjs_uart_open(iotjs_uart_t* uart);
bool iotjs_uart_write(iotjs_uart_t* uart);
+void iotjs_uart_handlewrap_close_cb(uv_handle_t* handle);
+
+void iotjs_uart_create_platform_data(iotjs_uart_t* uart);
+void iotjs_uart_destroy_platform_data(iotjs_uart_platform_data_t* pdata);
#endif /* IOTJS_MODULE_UART_H */
static void OnRecv(uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf,
const struct sockaddr* addr, unsigned int flags) {
if (nread == 0 && addr == NULL) {
- if (buf->base != NULL)
- iotjs_buffer_release(buf->base);
+ iotjs_buffer_release(buf->base);
return;
}
iotjs_jargs_append_jval(&jargs, judp);
if (nread < 0) {
- if (buf->base != NULL)
- iotjs_buffer_release(buf->base);
+ iotjs_buffer_release(buf->base);
iotjs_make_callback(jonmessage, jerry_create_undefined(), &jargs);
jerry_release_value(jonmessage);
iotjs_jargs_destroy(&jargs);
const jerry_value_t jconfig) {
iotjs_adc_platform_data_t* platform_data = adc->platform_data;
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->device,
- IOTJS_MAGIC_STRING_DEVICE, string);
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->device,
+ IOTJS_MAGIC_STRING_DEVICE, string);
return jerry_create_undefined();
}
iotjs_bufferwrap_copy(buf_wrap, data, (size_t)length);
iotjs_jargs_append_jval(&jargs, str);
iotjs_jargs_append_jval(&jargs, jbuf);
- iotjs_jhelper_call_ok(jemit, jhcisocket, &jargs);
+ jerry_value_t jres = iotjs_jhelper_call(jemit, jhcisocket, &jargs);
+ IOTJS_ASSERT(!jerry_value_has_error_flag(jres));
+ jerry_release_value(jres);
jerry_release_value(str);
jerry_release_value(jbuf);
iotjs_jargs_destroy(&jargs);
jerry_value_t str = jerry_create_string((const jerry_char_t*)"error");
iotjs_jargs_append_jval(&jargs, str);
iotjs_jargs_append_error(&jargs, strerror(errno));
- iotjs_jhelper_call_ok(jemit, jhcisocket, &jargs);
+ jerry_value_t jres = iotjs_jhelper_call(jemit, jhcisocket, &jargs);
+ IOTJS_ASSERT(!jerry_value_has_error_flag(jres));
+ jerry_release_value(jres);
jerry_release_value(str);
iotjs_jargs_destroy(&jargs);
jerry_release_value(jemit);
jerry_value_t jonChange = iotjs_jval_get_property(jgpio, "onChange");
IOTJS_ASSERT(jerry_value_is_function(jonChange));
- iotjs_jhelper_call_ok(jonChange, jgpio, iotjs_jargs_get_empty());
+ jerry_value_t jres =
+ iotjs_jhelper_call(jonChange, jgpio, iotjs_jargs_get_empty());
+ IOTJS_ASSERT(!jerry_value_has_error_flag(jres));
+ jerry_release_value(jres);
jerry_release_value(jonChange);
}
const jerry_value_t jconfig) {
iotjs_i2c_platform_data_t* platform_data = i2c->platform_data;
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->device,
- IOTJS_MAGIC_STRING_DEVICE, string);
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->device,
+ IOTJS_MAGIC_STRING_DEVICE, string);
return jerry_create_undefined();
}
char* data = i2c->buf_data;
int ret = write(platform_data->device_fd, data, len);
- if (i2c->buf_data != NULL) {
- iotjs_buffer_release(i2c->buf_data);
- }
+
+ IOTJS_RELEASE(i2c->buf_data);
return ret == len;
}
if (snprintf(buf, sizeof(buf), "%d", value) > 0) {
result = iotjs_systemio_open_write_close(devicePath, buf);
}
- iotjs_buffer_release(devicePath);
+ IOTJS_RELEASE(devicePath);
}
}
return result;
}
result = iotjs_systemio_open_write_close(devicePath, buf);
- iotjs_buffer_release(devicePath);
+ IOTJS_RELEASE(devicePath);
}
}
return result;
}
result = iotjs_systemio_open_write_close(devicePath, buf);
- iotjs_buffer_release(devicePath);
+ IOTJS_RELEASE(devicePath);
}
return result;
}
const jerry_value_t jconfig) {
iotjs_spi_platform_data_t* platform_data = spi->platform_data;
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->device,
- IOTJS_MAGIC_STRING_DEVICE, string);
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->device,
+ IOTJS_MAGIC_STRING_DEVICE, string);
return jerry_create_undefined();
}
#include "modules/iotjs_module_uart.h"
+struct iotjs_uart_platform_data_s {
+ iotjs_string_t device_path;
+};
+
static unsigned baud_to_constant(unsigned baudRate) {
switch (baudRate) {
case 50:
return -1;
}
+void iotjs_uart_create_platform_data(iotjs_uart_t* uart) {
+ uart->platform_data = IOTJS_ALLOC(iotjs_uart_platform_data_t);
+}
+
+void iotjs_uart_destroy_platform_data(
+ iotjs_uart_platform_data_t* platform_data) {
+ IOTJS_ASSERT(platform_data);
+
+ iotjs_string_destroy(&platform_data->device_path);
+ IOTJS_RELEASE(platform_data);
+}
+
+jerry_value_t iotjs_uart_set_platform_config(iotjs_uart_t* uart,
+ const jerry_value_t jconfig) {
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, uart->platform_data->device_path,
+ IOTJS_MAGIC_STRING_DEVICE, string);
+
+ return jerry_create_undefined();
+}
+
bool iotjs_uart_open(iotjs_uart_t* uart) {
- int fd =
- open(iotjs_string_data(&uart->device_path), O_RDWR | O_NOCTTY | O_NDELAY);
+ int fd = open(iotjs_string_data(&uart->platform_data->device_path),
+ O_RDWR | O_NOCTTY | O_NDELAY);
if (fd < 0) {
return false;
}
return true;
}
+
+void iotjs_uart_handlewrap_close_cb(uv_handle_t* handle) {
+ iotjs_uart_t* uart = (iotjs_uart_t*)handle->data;
+
+ if (close(uart->device_fd) < 0) {
+ DLOG(iotjs_periph_error_str(kUartOpClose));
+ IOTJS_ASSERT(0);
+ }
+}
const jerry_value_t jconfig) {
iotjs_adc_platform_data_t* platform_data = adc->platform_data;
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->pin,
- IOTJS_MAGIC_STRING_PIN, number);
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->pin,
+ IOTJS_MAGIC_STRING_PIN, number);
return jerry_create_undefined();
}
const jerry_value_t jconfig) {
iotjs_i2c_platform_data_t* platform_data = i2c->platform_data;
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->bus,
- IOTJS_MAGIC_STRING_BUS, number);
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->bus,
+ IOTJS_MAGIC_STRING_BUS, number);
return jerry_create_undefined();
}
int ret =
i2c_write(platform_data->i2c_master, &platform_data->config, data, len);
- if (i2c->buf_data != NULL) {
- iotjs_buffer_release(i2c->buf_data);
- }
+ IOTJS_RELEASE(i2c->buf_data);
if (ret < 0) {
DLOG("%s : cannot write - %d", __func__, ret);
const jerry_value_t jconfig) {
iotjs_spi_platform_data_t* platform_data = spi->platform_data;
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->bus,
- IOTJS_MAGIC_STRING_BUS, number);
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->bus,
+ IOTJS_MAGIC_STRING_BUS, number);
return jerry_create_undefined();
}
* limitations under the License.
*/
-#if !defined(__NUTTX__)
-#error "Module __FILE__ is for nuttx only"
-#endif
-
#include "modules/iotjs_module_uart.h"
+struct iotjs_uart_platform_data_s {
+ iotjs_string_t device_path;
+};
+
+void iotjs_uart_create_platform_data(iotjs_uart_t* uart) {
+ uart->platform_data = IOTJS_ALLOC(iotjs_uart_platform_data_t);
+}
+
+void iotjs_uart_destroy_platform_data(
+ iotjs_uart_platform_data_t* platform_data) {
+ IOTJS_ASSERT(platform_data);
+
+ iotjs_string_destroy(&platform_data->device_path);
+ IOTJS_RELEASE(platform_data);
+}
+
+jerry_value_t iotjs_uart_set_platform_config(iotjs_uart_t* uart,
+ const jerry_value_t jconfig) {
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, uart->platform_data->device_path,
+ IOTJS_MAGIC_STRING_DEVICE, string);
+
+ return jerry_create_undefined();
+}
bool iotjs_uart_open(iotjs_uart_t* uart) {
- int fd =
- open(iotjs_string_data(&uart->device_path), O_RDWR | O_NOCTTY | O_NDELAY);
+ int fd = open(iotjs_string_data(&uart->platform_data->device_path),
+ O_RDWR | O_NOCTTY | O_NDELAY);
if (fd < 0) {
return false;
return true;
}
+
+void iotjs_uart_handlewrap_close_cb(uv_handle_t* handle) {
+ iotjs_uart_t* uart = (iotjs_uart_t*)handle->data;
+
+ if (close(uart->device_fd) < 0) {
+ DLOG(iotjs_periph_error_str(kUartOpClose));
+ IOTJS_ASSERT(0);
+ }
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if !defined(__TIZEN__)
+#error "Module __FILE__ is for Tizen only"
+#endif
+
+#include <peripheral_io.h>
+
+#include "modules/iotjs_module_i2c.h"
+
+
+struct iotjs_i2c_platform_data_s {
+ int bus;
+ peripheral_i2c_h i2c_h;
+};
+
+void iotjs_i2c_create_platform_data(iotjs_i2c_t* i2c) {
+ i2c->platform_data = IOTJS_ALLOC(iotjs_i2c_platform_data_t);
+
+ i2c->platform_data->i2c_h = NULL;
+}
+
+void iotjs_i2c_destroy_platform_data(iotjs_i2c_platform_data_t* pdata) {
+ IOTJS_RELEASE(pdata);
+}
+
+jerry_value_t iotjs_i2c_set_platform_config(iotjs_i2c_t* i2c,
+ const jerry_value_t jconfig) {
+ iotjs_i2c_platform_data_t* platform_data = i2c->platform_data;
+
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->bus,
+ IOTJS_MAGIC_STRING_BUS, number);
+
+ return jerry_create_undefined();
+}
+
+#define I2C_METHOD_HEADER(arg) \
+ iotjs_i2c_platform_data_t* platform_data = arg->platform_data; \
+ IOTJS_ASSERT(platform_data); \
+ if (!platform_data->i2c_h) { \
+ DLOG("%s: I2C is not opened", __func__); \
+ return false; \
+ }
+
+bool iotjs_i2c_open(iotjs_i2c_t* i2c) {
+ iotjs_i2c_platform_data_t* platform_data = i2c->platform_data;
+ IOTJS_ASSERT(platform_data);
+
+ int ret = peripheral_i2c_open(platform_data->bus, i2c->address,
+ &platform_data->i2c_h);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s : cannot open(%d)", __func__, ret);
+ return false;
+ }
+
+ return true;
+}
+
+bool iotjs_i2c_close(iotjs_i2c_t* i2c) {
+ I2C_METHOD_HEADER(i2c);
+
+ int ret = peripheral_i2c_close(platform_data->i2c_h);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s : cannot close(%d)", __func__, ret);
+ return false;
+ }
+
+ return true;
+}
+
+bool iotjs_i2c_write(iotjs_i2c_t* i2c) {
+ I2C_METHOD_HEADER(i2c);
+
+ IOTJS_ASSERT(i2c->buf_len > 0);
+
+ int ret = peripheral_i2c_write(platform_data->i2c_h, (uint8_t*)i2c->buf_data,
+ i2c->buf_len);
+
+ IOTJS_RELEASE(i2c->buf_data);
+
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s : cannot write(%d)", __func__, ret);
+ return false;
+ }
+ return true;
+}
+
+bool iotjs_i2c_read(iotjs_i2c_t* i2c) {
+ I2C_METHOD_HEADER(i2c);
+
+ uint8_t len = i2c->buf_len;
+ i2c->buf_data = iotjs_buffer_allocate(len);
+ IOTJS_ASSERT(len > 0);
+
+ int ret =
+ peripheral_i2c_read(platform_data->i2c_h, (uint8_t*)i2c->buf_data, len);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s : cannot read(%d)", __func__, ret);
+ return false;
+ }
+
+ return true;
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <peripheral_io.h>
+
+#include "modules/iotjs_module_pwm.h"
+
+struct iotjs_pwm_platform_data_s {
+ peripheral_pwm_h pwm_h;
+};
+
+void iotjs_pwm_create_platform_data(iotjs_pwm_t* pwm) {
+ pwm->platform_data = IOTJS_ALLOC(iotjs_pwm_platform_data_t);
+ pwm->platform_data->pwm_h = NULL;
+}
+
+void iotjs_pwm_destroy_platform_data(iotjs_pwm_platform_data_t* pdata) {
+ IOTJS_RELEASE(pdata);
+}
+
+jerry_value_t iotjs_pwm_set_platform_config(iotjs_pwm_t* pwm,
+ const jerry_value_t jconfig) {
+ return jerry_create_undefined();
+}
+
+static bool pwm_set_options(iotjs_pwm_t* pwm) {
+ iotjs_pwm_platform_data_t* platform_data = pwm->platform_data;
+
+ if (platform_data->pwm_h == NULL) {
+ DLOG("%s - cannot set options", __func__);
+ return false;
+ }
+
+ return iotjs_pwm_set_period(pwm) && iotjs_pwm_set_dutycycle(pwm);
+}
+
+bool iotjs_pwm_open(iotjs_pwm_t* pwm) {
+ iotjs_pwm_platform_data_t* platform_data = pwm->platform_data;
+
+ int ret = peripheral_pwm_open(0, (int)pwm->pin, &platform_data->pwm_h);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s : cannot open(%d)", __func__, ret);
+ return false;
+ }
+
+ return pwm_set_options(pwm);
+}
+
+#define PWM_METHOD_HEADER \
+ IOTJS_ASSERT(pwm && pwm->platform_data); \
+ iotjs_pwm_platform_data_t* platform_data = pwm->platform_data; \
+ if (platform_data->pwm_h == NULL) { \
+ DLOG("%s: PWM is not opened", __func__); \
+ return false; \
+ }
+
+bool iotjs_pwm_set_period(iotjs_pwm_t* pwm) {
+ PWM_METHOD_HEADER
+
+ uint32_t period_ns = pwm->period * 1E9;
+ int ret = peripheral_pwm_set_period(platform_data->pwm_h, period_ns);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s : cannot set period(%d)", __func__, ret);
+ return false;
+ }
+
+ return true;
+}
+
+bool iotjs_pwm_set_dutycycle(iotjs_pwm_t* pwm) {
+ PWM_METHOD_HEADER
+
+ uint32_t duty_cycle_ns = pwm->period * pwm->duty_cycle * 1E9;
+ int ret = peripheral_pwm_set_duty_cycle(platform_data->pwm_h, duty_cycle_ns);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s : cannot set duty-cycle(%d)", __func__, ret);
+ return false;
+ }
+
+ return true;
+}
+
+bool iotjs_pwm_set_enable(iotjs_pwm_t* pwm) {
+ PWM_METHOD_HEADER
+
+ int ret = peripheral_pwm_set_enabled(platform_data->pwm_h, pwm->enable);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s : cannot set enable(%d)", __func__, ret);
+ return false;
+ }
+
+ return true;
+}
+
+bool iotjs_pwm_close(iotjs_pwm_t* pwm) {
+ PWM_METHOD_HEADER
+
+ int ret = peripheral_pwm_close(platform_data->pwm_h);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s : cannot close(%d)", __func__, ret);
+ return false;
+ }
+ platform_data->pwm_h = NULL;
+
+ return true;
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <peripheral_io.h>
+
+#include "modules/iotjs_module_spi.h"
+
+
+struct iotjs_spi_platform_data_s {
+ int bus;
+ peripheral_spi_h spi_h;
+};
+
+static peripheral_spi_mode_e mode_to_constant(SpiMode mode) {
+ switch (mode) {
+ case kSpiMode_0:
+ return PERIPHERAL_SPI_MODE_0;
+ case kSpiMode_1:
+ return PERIPHERAL_SPI_MODE_1;
+ case kSpiMode_2:
+ return PERIPHERAL_SPI_MODE_2;
+ case kSpiMode_3:
+ return PERIPHERAL_SPI_MODE_3;
+ default:
+ IOTJS_ASSERT(!"Invalid SPI mode");
+ return PERIPHERAL_SPI_MODE_0;
+ }
+}
+
+static peripheral_spi_bit_order_e bit_order_to_constant(SpiOrder order) {
+ switch (order) {
+ case kSpiOrderLsb:
+ return PERIPHERAL_SPI_BIT_ORDER_LSB;
+ case kSpiOrderMsb:
+ return PERIPHERAL_SPI_BIT_ORDER_MSB;
+ default:
+ IOTJS_ASSERT(!"Invalid SPI bitOrder");
+ return PERIPHERAL_SPI_BIT_ORDER_MSB;
+ }
+}
+
+void iotjs_spi_create_platform_data(iotjs_spi_t* spi) {
+ spi->platform_data = IOTJS_ALLOC(iotjs_spi_platform_data_t);
+
+ spi->platform_data->spi_h = NULL;
+}
+
+void iotjs_spi_destroy_platform_data(iotjs_spi_platform_data_t* platform_data) {
+ IOTJS_ASSERT(platform_data);
+ IOTJS_RELEASE(platform_data);
+}
+
+jerry_value_t iotjs_spi_set_platform_config(iotjs_spi_t* spi,
+ const jerry_value_t jconfig) {
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, spi->platform_data->bus,
+ IOTJS_MAGIC_STRING_BUS, number);
+
+ return jerry_create_undefined();
+}
+
+#define SPI_METHOD_HEADER(arg) \
+ iotjs_spi_platform_data_t* platform_data = arg->platform_data; \
+ IOTJS_ASSERT(platform_data); \
+ if (!platform_data->spi_h) { \
+ DLOG("%s: SPI is not opened", __func__); \
+ return false; \
+ }
+
+bool iotjs_spi_open(iotjs_spi_t* spi) {
+ iotjs_spi_platform_data_t* platform_data = spi->platform_data;
+
+ int ret = peripheral_spi_open(platform_data->bus, spi->chip_select,
+ &platform_data->spi_h);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s: cannot open(%d)", __func__, ret);
+ return false;
+ }
+
+ // Set mode
+ ret = peripheral_spi_set_mode(platform_data->spi_h,
+ mode_to_constant(spi->mode));
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s: cannot set mode(%d)", __func__, ret);
+ peripheral_spi_close(platform_data->spi_h);
+ return false;
+ }
+
+ // Set bit order
+ ret = peripheral_spi_set_bit_order(platform_data->spi_h,
+ bit_order_to_constant(spi->bit_order));
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s: cannot set bit order(%d)", __func__, ret);
+ peripheral_spi_close(platform_data->spi_h);
+ return false;
+ }
+
+ // Set bits per word
+ ret = peripheral_spi_set_bits_per_word(platform_data->spi_h,
+ spi->bits_per_word);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s: cannot set bit per word(%d)", __func__, ret);
+ peripheral_spi_close(platform_data->spi_h);
+ return false;
+ }
+
+ // Set maxSpeed
+ ret = peripheral_spi_set_frequency(platform_data->spi_h, spi->max_speed);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s: cannot set maxSpeed(%d)", __func__, ret);
+ peripheral_spi_close(platform_data->spi_h);
+ return false;
+ }
+ return true;
+}
+
+bool iotjs_spi_transfer(iotjs_spi_t* spi) {
+ SPI_METHOD_HEADER(spi)
+
+ int ret =
+ peripheral_spi_transfer(platform_data->spi_h, (uint8_t*)spi->tx_buf_data,
+ (uint8_t*)spi->rx_buf_data, spi->buf_len);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s: cannot transfer(%d)", __func__, ret);
+ return false;
+ }
+
+ return true;
+}
+
+bool iotjs_spi_close(iotjs_spi_t* spi) {
+ SPI_METHOD_HEADER(spi)
+
+ int ret = peripheral_spi_close(platform_data->spi_h);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s: cannot close(%d)", __func__, ret);
+ return false;
+ }
+
+ platform_data->spi_h = NULL;
+ return true;
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "iotjs_def.h"
+#include "modules/iotjs_module_bridge.h"
+
+#include <app_common.h>
+#include <app_control.h>
+#include <bundle.h>
+
+typedef enum {
+ IOTJS_ERROR_NONE = 0,
+ IOTJS_ERROR_RESULT_FAILED,
+ IOTJS_ERROR_INVALID_PARAMETER,
+} iotjs_error_t;
+
+// application control
+#include <app_control_internal.h>
+#include <bundle_internal.h>
+
+iotjs_error_t send_launch_request(const char* json, void* hbridge) {
+ DDDLOG("%s", __func__);
+
+ bundle* b;
+ int ret;
+
+ ret = bundle_from_json(json, &b);
+ if (ret != BUNDLE_ERROR_NONE) {
+ DDLOG("bundle_from_json failed");
+ return IOTJS_ERROR_INVALID_PARAMETER;
+ }
+
+ app_control_h app_control = NULL;
+
+ app_control_create(&app_control);
+ app_control_import_from_bundle(app_control, b);
+
+ ret = app_control_send_launch_request(app_control, NULL, NULL);
+
+ if (ret != APP_CONTROL_ERROR_NONE) {
+ DDDLOG("app_control_send_launch_request failed");
+ switch (ret) {
+ case APP_CONTROL_ERROR_INVALID_PARAMETER:
+ iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_INVALID_PARAMETER");
+ break;
+ case APP_CONTROL_ERROR_OUT_OF_MEMORY:
+ iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_OUT_OF_MEMORY");
+ break;
+ case APP_CONTROL_ERROR_APP_NOT_FOUND:
+ iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_APP_NOT_FOUND");
+ break;
+ case APP_CONTROL_ERROR_LAUNCH_REJECTED:
+ iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_LAUNCH_REJECTED");
+ break;
+ case APP_CONTROL_ERROR_LAUNCH_FAILED:
+ iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_LAUNCH_FAILED");
+ break;
+ case APP_CONTROL_ERROR_TIMED_OUT:
+ iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_TIMED_OUT");
+ break;
+ case APP_CONTROL_ERROR_PERMISSION_DENIED:
+ iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_PERMISSION_DENIED");
+ break;
+ default:
+ iotjs_bridge_set_err(hbridge, "APP_CONTROL_ERROR_UNKNOWN");
+ break;
+ }
+ return IOTJS_ERROR_RESULT_FAILED;
+ }
+
+ bundle_free(b);
+ app_control_destroy(app_control);
+
+ return IOTJS_ERROR_NONE;
+}
+
+
+void iotjs_service_app_control_cb(app_control_h app_control, void* user_data) {
+ DDDLOG("%s", __func__);
+
+ iotjs_environment_t* env = iotjs_environment_get();
+
+ if (env->state != kRunningMain && env->state != kRunningLoop) {
+ return;
+ }
+
+ // parse app control
+ char* json = NULL;
+ bundle* b = NULL;
+
+ app_control_export_as_bundle(app_control, &b);
+
+ if (BUNDLE_ERROR_NONE != bundle_to_json(b, &json)) {
+ DDLOG("bundle_to_json failed");
+ bundle_free(b);
+ return;
+ }
+ DDDLOG("JSON: %s", json);
+
+ // prepare emit
+ const char* event_emitter_name = IOTJS_MAGIC_STRING_TIZEN;
+ const char* event_name = IOTJS_MAGIC_STRING_APP_CONTROL;
+
+ jerry_value_t tizen = iotjs_module_get(event_emitter_name);
+ jerry_value_t fn = iotjs_jval_get_property(tizen, IOTJS_MAGIC_STRING_EMIT);
+
+ // call emit
+ iotjs_jargs_t jargv = iotjs_jargs_create(2);
+ iotjs_jargs_append_string_raw(&jargv, event_name);
+ iotjs_jargs_append_string_raw(&jargv, json);
+
+ iotjs_make_callback(fn, tizen, &jargv);
+
+ IOTJS_RELEASE(json);
+ bundle_free(b);
+
+ jerry_release_value(fn);
+ iotjs_jargs_destroy(&jargv);
+}
+
+
+void iotjs_tizen_func(const char* command, const char* message, void* handle) {
+ DDDLOG("%s, cmd: %s, msg: %s", __func__, command, message);
+
+ if (strncmp(command, "getResPath", strlen("getResPath")) == 0) {
+ char* app_res_path = app_get_resource_path();
+ iotjs_bridge_set_msg(handle, app_res_path);
+
+ } else if (strncmp(command, "launchAppControl", strlen("launchAppControl")) ==
+ 0) {
+ iotjs_error_t err = send_launch_request(message, handle);
+ if (err == IOTJS_ERROR_NONE) {
+ iotjs_bridge_set_msg(handle, "OK");
+ }
+
+ } else {
+ iotjs_bridge_set_err(handle, "Can't find command");
+ }
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <peripheral_io.h>
+
+#include "modules/iotjs_module_uart.h"
+
+struct _peripheral_uart_s {
+ unsigned handle;
+ int fd;
+};
+
+struct iotjs_uart_platform_data_s {
+ peripheral_uart_h uart_h;
+ uint8_t port;
+};
+
+static peripheral_uart_baud_rate_e baud_to_constant(unsigned baudRate) {
+ switch (baudRate) {
+ case 0:
+ return PERIPHERAL_UART_BAUD_RATE_0;
+ case 50:
+ return PERIPHERAL_UART_BAUD_RATE_50;
+ case 75:
+ return PERIPHERAL_UART_BAUD_RATE_75;
+ case 110:
+ return PERIPHERAL_UART_BAUD_RATE_110;
+ case 134:
+ return PERIPHERAL_UART_BAUD_RATE_134;
+ case 150:
+ return PERIPHERAL_UART_BAUD_RATE_150;
+ case 200:
+ return PERIPHERAL_UART_BAUD_RATE_200;
+ case 300:
+ return PERIPHERAL_UART_BAUD_RATE_300;
+ case 600:
+ return PERIPHERAL_UART_BAUD_RATE_600;
+ case 1200:
+ return PERIPHERAL_UART_BAUD_RATE_1200;
+ case 1800:
+ return PERIPHERAL_UART_BAUD_RATE_1800;
+ case 2400:
+ return PERIPHERAL_UART_BAUD_RATE_2400;
+ case 4800:
+ return PERIPHERAL_UART_BAUD_RATE_4800;
+ case 9600:
+ return PERIPHERAL_UART_BAUD_RATE_9600;
+ case 19200:
+ return PERIPHERAL_UART_BAUD_RATE_19200;
+ case 38400:
+ return PERIPHERAL_UART_BAUD_RATE_38400;
+ case 57600:
+ return PERIPHERAL_UART_BAUD_RATE_57600;
+ case 115200:
+ return PERIPHERAL_UART_BAUD_RATE_115200;
+ case 230400:
+ return PERIPHERAL_UART_BAUD_RATE_230400;
+ }
+
+ IOTJS_ASSERT(!"Invalid baud rate");
+ return -1;
+}
+
+static peripheral_uart_byte_size_e databits_to_constant(uint8_t dataBits) {
+ switch (dataBits) {
+ case 8:
+ return PERIPHERAL_UART_BYTE_SIZE_8BIT;
+ case 7:
+ return PERIPHERAL_UART_BYTE_SIZE_7BIT;
+ case 6:
+ return PERIPHERAL_UART_BYTE_SIZE_6BIT;
+ case 5:
+ return PERIPHERAL_UART_BYTE_SIZE_5BIT;
+ }
+
+ IOTJS_ASSERT(!"Invalid data bits");
+ return -1;
+}
+
+void iotjs_uart_create_platform_data(iotjs_uart_t* uart) {
+ uart->platform_data = IOTJS_ALLOC(iotjs_uart_platform_data_t);
+ uart->platform_data->uart_h = NULL;
+}
+
+void iotjs_uart_destroy_platform_data(
+ iotjs_uart_platform_data_t* platform_data) {
+ IOTJS_ASSERT(platform_data);
+ IOTJS_RELEASE(platform_data);
+}
+
+jerry_value_t iotjs_uart_set_platform_config(iotjs_uart_t* uart,
+ const jerry_value_t jconfig) {
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, uart->platform_data->port,
+ IOTJS_MAGIC_STRING_PORT, number);
+
+ return jerry_create_undefined();
+}
+
+bool iotjs_uart_open(iotjs_uart_t* uart) {
+ iotjs_uart_platform_data_t* platform_data = uart->platform_data;
+ IOTJS_ASSERT(platform_data);
+
+ int ret = peripheral_uart_open(platform_data->port, &platform_data->uart_h);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s: cannot open(%d)", __func__, ret);
+ return false;
+ }
+
+ // Set baud rate
+ ret = peripheral_uart_set_baud_rate(platform_data->uart_h,
+ baud_to_constant(uart->baud_rate));
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s: cannot set baud rate(%d)", __func__, ret);
+ peripheral_uart_close(platform_data->uart_h);
+ return false;
+ }
+
+ // Set data bits
+ ret = peripheral_uart_set_byte_size(platform_data->uart_h,
+ databits_to_constant(uart->data_bits));
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s: cannot set data bits(%d)", __func__, ret);
+ peripheral_uart_close(platform_data->uart_h);
+ return false;
+ }
+
+ uart->device_fd = platform_data->uart_h->fd;
+ iotjs_uart_register_read_cb(uart);
+
+ return true;
+}
+
+bool iotjs_uart_write(iotjs_uart_t* uart) {
+ iotjs_uart_platform_data_t* platform_data = uart->platform_data;
+ IOTJS_ASSERT(platform_data);
+ if (!platform_data->uart_h) {
+ DLOG("%s: UART is not opened", __func__);
+ return false;
+ }
+
+ const char* buf_data = iotjs_string_data(&uart->buf_data);
+ DDDLOG("%s: data: %s", __func__, buf_data);
+
+ int ret = peripheral_uart_write(platform_data->uart_h, (uint8_t*)buf_data,
+ uart->buf_len);
+ if (ret != PERIPHERAL_ERROR_NONE) {
+ DLOG("%s: cannot write(%d)", __func__, ret);
+ return false;
+ }
+
+ return true;
+}
+
+void iotjs_uart_handlewrap_close_cb(uv_handle_t* handle) {
+ iotjs_uart_t* uart = (iotjs_uart_t*)handle->data;
+
+ if (peripheral_uart_close(uart->platform_data->uart_h) !=
+ PERIPHERAL_ERROR_NONE) {
+ DLOG(iotjs_periph_error_str(kUartOpClose));
+ IOTJS_ASSERT(0);
+ }
+
+ uart->platform_data->uart_h = NULL;
+}
const jerry_value_t jconfig) {
iotjs_adc_platform_data_t* platform_data = adc->platform_data;
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->pin,
- IOTJS_MAGIC_STRING_PIN, number);
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->pin,
+ IOTJS_MAGIC_STRING_PIN, number);
return jerry_create_undefined();
}
const jerry_value_t jconfig) {
iotjs_i2c_platform_data_t* platform_data = i2c->platform_data;
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->bus,
- IOTJS_MAGIC_STRING_BUS, number);
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->bus,
+ IOTJS_MAGIC_STRING_BUS, number);
return jerry_create_undefined();
}
int ret = iotbus_i2c_write(platform_data->i2c_context, data, len);
- if (i2c->buf_data != NULL) {
- iotjs_buffer_release(i2c->buf_data);
- }
+ IOTJS_RELEASE(i2c->buf_data);
if (ret < 0) {
DLOG("%s: cannot write data", __func__);
const jerry_value_t jconfig) {
iotjs_spi_platform_data_t* platform_data = spi->platform_data;
- DJS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->bus,
- IOTJS_MAGIC_STRING_BUS, number);
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, platform_data->bus,
+ IOTJS_MAGIC_STRING_BUS, number);
return jerry_create_undefined();
}
#include "modules/iotjs_module_uart.h"
+struct iotjs_uart_platform_data_s {
+ iotjs_string_t device_path;
+};
+
+void iotjs_uart_create_platform_data(iotjs_uart_t* uart) {
+ uart->platform_data = IOTJS_ALLOC(iotjs_uart_platform_data_t);
+}
+
+void iotjs_uart_destroy_platform_data(
+ iotjs_uart_platform_data_t* platform_data) {
+ IOTJS_ASSERT(platform_data);
+
+ iotjs_string_destroy(&platform_data->device_path);
+ IOTJS_RELEASE(platform_data);
+}
+
+jerry_value_t iotjs_uart_set_platform_config(iotjs_uart_t* uart,
+ const jerry_value_t jconfig) {
+ JS_GET_REQUIRED_CONF_VALUE(jconfig, uart->platform_data->device_path,
+ IOTJS_MAGIC_STRING_DEVICE, string);
+
+ return jerry_create_undefined();
+}
+
bool iotjs_uart_open(iotjs_uart_t* uart) {
- int fd =
- open(iotjs_string_data(&uart->device_path), O_RDWR | O_NOCTTY | O_NDELAY);
+ int fd = open(iotjs_string_data(&uart->platform_data->device_path),
+ O_RDWR | O_NOCTTY | O_NDELAY);
if (fd < 0) {
return false;
return true;
}
+
+void iotjs_uart_handlewrap_close_cb(uv_handle_t* handle) {
+ iotjs_uart_t* uart = (iotjs_uart_t*)handle->data;
+
+ if (close(uart->device_fd) < 0) {
+ DLOG(iotjs_periph_error_str(kUartOpClose));
+ IOTJS_ASSERT(0);
+ }
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlog.h>
+#include <glib.h>
+#include <service_app_internal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "iotjs_def.h"
+#include "iotjs.h"
+
+extern bool iotjs_initialize(iotjs_environment_t* env);
+extern void iotjs_run(iotjs_environment_t* env);
+extern void iotjs_end(iotjs_environment_t* env);
+extern void iotjs_terminate(iotjs_environment_t* env);
+
+static char js_absolute_path[128];
+static GMainLoop* gmain_loop;
+static bool is_env_initialized = false;
+
+typedef struct {
+ GSource source;
+ iotjs_environment_t* env;
+} iotjs_gmain_source_t;
+
+static int console_log(int level, const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ dlog_vprint(DLOG_INFO, "IOTJS", format, args);
+ va_end(args);
+ return 0;
+}
+
+static gboolean gmain_loop_check(GSource* source) {
+ return TRUE;
+}
+
+static gboolean gmain_loop_dispatch(GSource* source, GSourceFunc callback,
+ gpointer user_data) {
+ iotjs_environment_t* env = ((iotjs_gmain_source_t*)source)->env;
+
+ bool more = uv_run(iotjs_environment_loop(env), UV_RUN_NOWAIT);
+ more |= iotjs_process_next_tick();
+
+ jerry_value_t ret_val = jerry_run_all_enqueued_jobs();
+ if (jerry_value_has_error_flag(ret_val)) {
+ DLOG("jerry_run_all_enqueued_jobs() failed");
+ }
+
+ if (more == false) {
+ more = uv_loop_alive(iotjs_environment_loop(env));
+ }
+
+ if (!more || iotjs_environment_is_exiting(env)) {
+ service_app_exit();
+ return false;
+ }
+ return true;
+}
+
+static void loop_method_init_cb(int argc, char** argv, void* data) {
+ int iotjs_argc = 2;
+ char* iotjs_argv[2] = { "iotjs", js_absolute_path };
+
+#ifdef ENABLE_DEBUG_LOG
+ setenv("IOTJS_DEBUG_LEVEL", "3", 0); // Enable all log.
+#endif
+
+ // Initialize debug log and environments
+ iotjs_debuglog_init();
+
+ iotjs_environment_t* env = iotjs_environment_get();
+
+ if (!iotjs_environment_parse_command_line_arguments(env, (uint32_t)iotjs_argc,
+ iotjs_argv)) {
+ DLOG("iotjs_environment_parse_command_line_arguments failed");
+ service_app_exit();
+ return;
+ }
+ is_env_initialized = true;
+
+ if (!iotjs_initialize(env)) {
+ DLOG("iotjs_initialize failed");
+ service_app_exit();
+ return;
+ }
+
+ DDDLOG("%s", __func__);
+
+ iotjs_conf_console_out(console_log);
+}
+
+static void loop_method_run_cb(void* data) {
+ DDDLOG("%s", __func__);
+ iotjs_environment_t* env = iotjs_environment_get();
+ iotjs_environment_set_state(env, kRunningMain);
+
+ // Load and call iotjs.js.
+ iotjs_run(env);
+
+ if (iotjs_environment_is_exiting(env)) {
+ service_app_exit();
+ return;
+ }
+
+ // Create GMain loop.
+ gmain_loop = g_main_loop_new(g_main_context_default(), FALSE);
+
+ // Add GSource in GMain context.
+ GSourceFuncs source_funcs = {
+ .check = gmain_loop_check, .dispatch = gmain_loop_dispatch,
+ };
+
+ iotjs_gmain_source_t* source =
+ (iotjs_gmain_source_t*)g_source_new(&source_funcs,
+ sizeof(iotjs_gmain_source_t));
+ source->env = env;
+ uv_loop_t* uv_loop = iotjs_environment_loop(env);
+ g_source_add_unix_fd(&source->source, uv_loop->backend_fd,
+ (GIOCondition)(G_IO_IN | G_IO_OUT | G_IO_ERR));
+ g_source_attach(&source->source, g_main_context_default());
+
+ iotjs_environment_set_state(env, kRunningLoop);
+
+ g_main_loop_run(gmain_loop); // Blocks until loop is quit.
+
+
+ if (!iotjs_environment_is_exiting(env)) {
+ // Emit 'exit' event.
+ iotjs_process_emit_exit(iotjs_process_exitcode());
+
+ iotjs_environment_set_state(env, kExiting);
+ }
+
+ DDDLOG("%s: Exit IoT.js(%d).", __func__, iotjs_process_exitcode());
+
+ iotjs_end(env);
+}
+
+static void loop_method_exit_cb(void* data) {
+ DDDLOG("%s", __func__);
+
+ if (g_main_loop_is_running(gmain_loop)) {
+ g_main_loop_quit(gmain_loop);
+ g_main_loop_unref(gmain_loop);
+ }
+}
+
+static void loop_method_fini_cb(void) {
+ DDDLOG("%s", __func__);
+ iotjs_environment_t* env = iotjs_environment_get();
+
+ if (is_env_initialized) {
+ iotjs_terminate(env);
+ }
+
+ iotjs_environment_release();
+ iotjs_debuglog_release();
+}
+
+int iotjs_service_app_start(int argc, char** argv, char* js_path,
+ void* event_callbacks, void* user_data) {
+ DDDLOG("%s", __func__);
+ char* app_res_path = app_get_resource_path();
+ if (!app_res_path) {
+ DLOG("app_res_path is NULL!");
+ return 1;
+ }
+
+ snprintf(js_absolute_path, sizeof(js_absolute_path), "%s%s", app_res_path,
+ js_path);
+ IOTJS_RELEASE(app_res_path);
+
+ service_app_loop_method_s loop_method = {.init = loop_method_init_cb,
+ .run = loop_method_run_cb,
+ .exit = loop_method_exit_cb,
+ .fini = loop_method_fini_cb };
+
+ return service_app_main_ext(argc, argv, (service_app_lifecycle_callback_s*)
+ event_callbacks,
+ &loop_method, user_data);
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IOTJS_TIZEN_SERVICE_APP_H
+#define IOTJS_TIZEN_SERVICE_APP_H
+
+
+#ifdef __cplusplus
+#define IOTJS_EXTERN_C extern "C"
+#else /* !__cplusplus */
+#define IOTJS_EXTERN_C extern
+#endif /* !__cplusplus */
+
+
+IOTJS_EXTERN_C int iotjs_service_app_start(int argc, char** argv, char* js_path,
+ void* event_callbacks,
+ void* user_data);
+
+
+#endif /* IOTJS_TIZEN_SERVICE_APP_H */
--- /dev/null
+# Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+cmake_minimum_required(VERSION 2.8)
+
+set(IOTJS_INCLUDE_DIR ${IOTJS_SOURCE_DIR})
+#set(JERRY_INCLUDE_DIR
+add_subdirectory(dynamicmodule)
--- /dev/null
+# Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# This is a standalone shared libray which
+# only requires the iotjs and jerry header file(s).
+#
+cmake_minimum_required(VERSION 2.8)
+set(NAME test-dynamicmodule)
+
+# Currently only Linux and Tizen targets are supported
+if(("${TARGET_OS}" STREQUAL "LINUX") OR ("${TARGET_OS}" STREQUAL "TIZEN"))
+
+ if((NOT IOTJS_INCLUDE_DIR) OR (NOT JERRY_INCLUDE_DIR))
+ message(FATAL_ERROR "No 'IOTJS_INCLUDE_DIR' or 'JERRY_INCLUDE_DIR'")
+ endif()
+
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
+
+ add_library(${NAME} SHARED
+ src/module_entry.c)
+ target_include_directories(${NAME}
+ PRIVATE ${IOTJS_INCLUDE_DIR} ${JERRY_INCLUDE_DIR})
+ set_target_properties(${NAME} PROPERTIES
+ PREFIX ""
+ SUFFIX ".iotjs")
+endif()
--- /dev/null
+Minimalistic dynamically loadable IoT.js module
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iotjs_binding.h>
+
+static uint32_t counter = 0;
+
+jerry_value_t init_dynamicmodule(void) {
+ jerry_value_t object = jerry_create_object();
+
+ jerry_value_t prop_name = jerry_create_string((const jerry_char_t*)"demokey");
+ jerry_value_t prop_value = jerry_create_number(3.4);
+
+ jerry_set_property(object, prop_name, prop_value);
+
+ jerry_release_value(prop_name);
+ jerry_release_value(prop_value);
+
+ iotjs_jval_set_property_number(object, "counter", ++counter);
+
+ return object;
+}
+
+IOTJS_MODULE(IOTJS_CURRENT_MODULE_VERSION, 1, dynamicmodule)
exports.isSunOS = process.platform === 'sunos';
exports.isFreeBSD = process.platform === 'freebsd';
exports.isLinux = process.platform === 'linux';
+exports.isTizen = process.platform === 'tizen';
exports.isOSX = process.platform === 'darwin';
exports.enoughTestMem = false;
if (e.code === 'ENOTDIR')
throw originalEr;
if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') {
- var enc = exports.isLinux ? 'buffer' : 'utf8';
+ var enc = (exports.isLinux || exports.isTizen) ? 'buffer' : 'utf8';
fs.readdirSync(p, enc).forEach(function(f) {
if (f instanceof Buffer) {
var buf = Buffer.concat([Buffer.from(p), Buffer.from(path.sep), f]);
var localhostIPv4 = null;
exports.localIPv6Hosts = ['localhost'];
-if (exports.isLinux) {
+if (exports.isLinux || exports.isTizen) {
exports.localIPv6Hosts = [
// Debian/Ubuntu
'ip6-localhost',
knownGlobals.push(Uint32Array);
knownGlobals.push(Float32Array);
knownGlobals.push(Float64Array);
- knownGlobals.push(DataView);
+ // knownGlobals.push(DataView);
}
// Harmony features.
--- /dev/null
+/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// 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:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'use strict';
+
+require('./test-module-circular');
+
--- /dev/null
+/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// 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:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'use strict';
+require('node/common');
+
+var assert = require('assert');
+require('./test-module-circular-b');
+
+assert.ok(true);
ENABLE_MODULE_IOTJS_BASIC_MODULES
ENABLE_MODULE_IOTJS_CORE_MODULES
+ENABLE_MODULE_HTTPS
ENABLE_MODULE_BLE
ENABLE_MODULE_DGRAM
ENABLE_MODULE_GPIO
+ENABLE_MODULE_HTTPS
ENABLE_MODULE_I2C
ENABLE_MODULE_PWM
ENABLE_MODULE_SPI
ENABLE_MODULE_BLE
ENABLE_MODULE_DGRAM
ENABLE_MODULE_GPIO
+ENABLE_MODULE_HTTPS
ENABLE_MODULE_I2C
ENABLE_MODULE_PWM
ENABLE_MODULE_SPI
ENABLE_MODULE_IOTJS_BASIC_MODULES
ENABLE_MODULE_IOTJS_CORE_MODULES
-ENABLE_MODULE_ADC
-ENABLE_MODULE_BLE
+ENABLE_MODULE_BRIDGE
ENABLE_MODULE_DGRAM
ENABLE_MODULE_GPIO
ENABLE_MODULE_HTTPS
ENABLE_MODULE_I2C
ENABLE_MODULE_PWM
ENABLE_MODULE_SPI
+ENABLE_MODULE_TIZEN
ENABLE_MODULE_UART
--- /dev/null
+-----BEGIN CERTIFICATE-----
+MIIFQDCCAyigAwIBAgIBATANBgkqhkiG9w0BAQsFADA5MREwDwYDVQQDEwhteXNl
+cnZlcjEXMBUGA1UEChMObXlvcmdhbmlzYXRpb24xCzAJBgNVBAYTAk5MMB4XDTEz
+MDEwMTAwMDAwMFoXDTE5MTIzMTIzNTk1OVowOTERMA8GA1UEAxMIbXlzZXJ2ZXIx
+FzAVBgNVBAoTDm15b3JnYW5pc2F0aW9uMQswCQYDVQQGEwJOTDCCAiIwDQYJKoZI
+hvcNAQEBBQADggIPADCCAgoCggIBAKXf+Q90/RFky3CS05PGso3PhnUmQYkTWKOC
+UgAn+C0q0wTon+FDf9z2YtNsJj3rDxcj2POnKiRov+yFcWl19rLSiwUWvmROz6e0
+/bSI5Mcf0cNRjBBy0oyTOCTAVCdlW+mtIyzwLzajvY4l3msOlyVbb1yaxO9c1To9
+EdU7atG91UNdKEIGVX2kcsYzBQ9rEzBaOwA5BsPl1Kr6dGTJXnjpNsirn5b0JK/w
+VB853HqQbbDHcRm/F5ufGUG1aHS5Wwg/jQKEaU51aYVcUqRrGEXyzXxB1mAPAg/t
+Sd5z0wGFPbewMWWD7KnB1hh3NgOm2nZ8C7IOIzW1BseGzkticLX+blUMTyx6GyOJ
+TBQGVwQRx7skj9zvVkzwfJv0h0RT9kwSwESV+AwqYrGnmdn9JLIXVAmWsSgiqIok
+NBKPNuokSSLYgDsflKNxOFT/fqpKYToz1ttxEcPBA2OQpv//z6eKv75RiAk596Xq
+MQ52HMvhQz728PnWpED7SiMbq0AvNEald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BcSQ
+7oUxhOoMlN0VC4FGtSHu1LLTvmWeYrHk9J6mpfNAj1/TfA/VvVKpNQVlaw==
+-----END RSA PRIVATE KEY-----
--- /dev/null
+/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var dns = require( 'dns' );
+var assert = require( 'assert' );
+assert.throws(function ( ) { dns.lookup ('localhost', require) } );
--- /dev/null
+/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+process.on('exit', function() {});
+setTimeout(function() { Array.prototype.slice += 'B' }, 500);
* limitations under the License.
*/
-var UART = require('uart');
-var uart = new UART();
+var uart = require('uart');
var res = uart.open({
device: '/dev/ttyS1',
baudRate: 115200,
--- /dev/null
+/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ process.on('uncaughtException', function(err) { } );
+ process.exit('callback');
--- /dev/null
+/* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+process.on('exit', function() { process.exit("callback"); } );
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+process.emitExit = 1;
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var x = require("console");
+process.exitCode = x.id_0;
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var fz_globalObject = Function("return this")( )
+var prop_names = Object.getOwnPropertyNames(fz_globalObject)
+console.log(prop_names)
+for (var i = 0; i < 10; i++) {
+ var prop_name = prop_names[i]
+ console.log(prop_name)
+}
var buff1 = new Buffer("test");
assert.equal(buff1.toString(), "test");
-assert.equal(buff1.toString(0, 0), "");
-assert.equal(buff1.toString(0, 1), "t");
-assert.equal(buff1.toString(0, 2), "te");
-assert.equal(buff1.toString(0, 3), "tes");
-assert.equal(buff1.toString(0, 4), "test");
-assert.equal(buff1.toString(1, 4), "est");
-assert.equal(buff1.toString(2, 4), "st");
-assert.equal(buff1.toString(3, 4), "t");
-assert.equal(buff1.toString(4, 4), "");
+assert.equal(buff1.toString(undefined, 0, 0), "");
+assert.equal(buff1.toString(undefined, 0, 1), "t");
+assert.equal(buff1.toString(undefined, 0, 2), "te");
+assert.equal(buff1.toString(undefined, 0, 3), "tes");
+assert.equal(buff1.toString(undefined, 0, 4), "test");
+assert.equal(buff1.toString(undefined, 1, 4), "est");
+assert.equal(buff1.toString(undefined, 2, 4), "st");
+assert.equal(buff1.toString(undefined, 3, 4), "t");
+assert.equal(buff1.toString(undefined, 4, 4), "");
assert.equal(buff1.length, 4);
var buff2 = new Buffer(10);
+++ /dev/null
-/* Copyright 2016-present Samsung Electronics Co., Ltd. and other contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-var assert = require('assert');
-
-
-var buff1 = new Buffer("test");
-assert.equal(buff1._builtin.toString(0, 0), "");
-assert.equal(buff1._builtin.toString(0, 1), "t");
-assert.equal(buff1._builtin.toString(0, 2), "te");
-assert.equal(buff1._builtin.toString(0, 3), "tes");
-assert.equal(buff1._builtin.toString(0, 4), "test");
-assert.equal(buff1._builtin.toString(1, 4), "est");
-assert.equal(buff1._builtin.toString(2, 4), "st");
-assert.equal(buff1._builtin.toString(3, 4), "t");
-assert.equal(buff1._builtin.toString(4, 4), "");
-
-assert.equal(buff1._builtin.toString(-1, 5), "test");
-assert.equal(buff1._builtin.toString(-1, 2), "te");
-assert.equal(buff1._builtin.toString(2, 5), "st");
-
-
-var buff2 = new Buffer(10);
-buff2._builtin.write("abcde", 0, 5);
-assert.equal(buff2.toString(), "abcde");
-assert.equal(buff2.length, 10);
-
-buff2._builtin.write("fgh", 5, 3);
-assert.equal(buff2.toString(), "abcdefgh");
-assert.equal(buff2.length, 10);
-
-buff2._builtin.write("AB", 0, 10);
-assert.equal(buff2.toString(), "ABcdefgh");
-assert.equal(buff2.length, 10);
-
-buff2._builtin.write("ab", -1, 11);
-assert.equal(buff2.toString(), "abcdefgh");
-assert.equal(buff2.length, 10);
-
-buff2._builtin.write("ijklmnopqrstu", 8, 5);
-assert.equal(buff2.toString(), "abcdefghij");
-assert.equal(buff2.length, 10);
-
-buff2._builtin.write("\0\0", 8, 2);
-assert.equal(buff2.toString(), "abcdefgh");
-assert.equal(buff2.length, 10);
-
-
-var buff3 = Buffer.concat([buff1, buff2]);
-
-
-var buff4 = new Buffer(10);
-var buff5 = new Buffer('a1b2c3');
-buff5._builtin.copy(buff4, 0, 0, 6);
-assert.equal(buff4.toString(), 'a1b2c3');
-buff5._builtin.copy(buff4, 4, 2, 6);
-assert.equal(buff4.toString(), 'a1b2b2c3');
-
-
-var buff6 = buff3._builtin.slice(1, buff3.length);
-assert.equal(buff6.toString(), 'estabcdefgh');
-assert.equal(buff6.length, 13);
-
-var buff7 = buff6._builtin.slice(3, 5);
-assert.equal(buff7.toString(), 'ab');
-assert.equal(buff7.length, 2);
-
-var buff8 = new Buffer(buff5);
-assert.equal(buff8.toString(), 'a1b2c3');
-assert.equal(buff8.equals(buff5), true);
-assert.equal(buff8.equals(buff6), false);
-
-var buff9 = new Buffer('abcabcabcd');
-var buff10 = buff9._builtin.slice(0, 3);
-var buff11 = buff9._builtin.slice(3, 6);
-var buff12 = buff9._builtin.slice(6, buff9.length);
-assert.equal(buff10.equals(buff11), true);
-assert.equal(buff11.equals(buff10), true);
-assert.equal(buff11.equals(buff12), false);
-assert.equal(buff10.compare(buff11), 0);
-assert.equal(buff11.compare(buff10), 0);
-assert.equal(buff11.compare(buff12), -1);
-assert.equal(buff12.compare(buff11), 1);
-
-assert.equal(buff9._builtin.slice(-2, buff9.length).toString(), 'cd');
-assert.equal(buff9._builtin.slice(-3, -2).toString(), 'b');
-assert.equal(buff9._builtin.slice(0, -2).toString(), 'abcabcab');
-
-
-assert.equal(buff3.toString(), 'testabcdefgh');
-
-
-assert.equal(Buffer.byteLength('\u007F'), 1);
-assert.equal(Buffer.byteLength('\u008F'), 2);
-assert.equal(Buffer.byteLength('\u08FF'), 3);
-assert.equal(Buffer.byteLength('abc'), 'abc'.length);
-assert.notEqual(Buffer.byteLength('\u2040'), '\u2040'.length);
--- /dev/null
+/* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var assert = require('assert');
+
+function decodeError(string, encode)
+{
+ try {
+ new Buffer(string, encode);
+ } catch (e) {
+ assert.assert(e instanceof TypeError);
+ }
+}
+
+function testWrite(input, string, offset, length,
+ encoding, expected, expectedLength)
+{
+ var buf = new Buffer(input);
+
+ assert.equal(buf.write(string, offset, length, encoding), expectedLength);
+ assert.equal(buf.toString(), expected);
+}
+
+/* Base64 tests. */
+
+assert.equal((new Buffer('YnVmZg==', 'base64')).toString(), 'buff');
+assert.equal((new Buffer('YnVmZmU=', 'base64')).toString(), 'buffe');
+assert.equal((new Buffer('YnVmZmVy', 'base64')).toString(), 'buffer');
+assert.equal((new Buffer('KiAxMjM0ICo=', 'base64')).toString(), '* 1234 *');
+assert.equal((new Buffer('f39/fw==', 'base64')).toString(),
+ '\u007f\u007f\u007f\u007f');
+assert.equal((new Buffer('fn5+fg==', 'base64')).toString(),
+ '\u007e\u007e\u007e\u007e');
+
+decodeError('Yn=mZg==', 'base64');
+decodeError('YnVmZ===', 'base64');
+decodeError('YnVmZm', 'base64');
+decodeError('KiAx*jM0ICo=', 'base64');
+
+testWrite('xxxxxxxx', 'MTIzNA==', 2, 16, 'base64', 'xx1234xx', 4);
+testWrite('xxxxxxxx', 'MTIzNA==', 2, 0, 'base64', 'xxxxxxxx', 0);
+testWrite('xxxxxxxx', 'MTIzNA==', 3, 2, 'base64', 'xxx12xxx', 2);
+testWrite('xxxx', 'MTIzNA==', 2, 16, 'base64', 'xx12', 2);
+
+assert.throws(function () {
+ /* Malformed string must throw error regardless of the buffer length. */
+ testWrite('xxxxxxxx', 'MTIzNA=!', 2, 2, 'base64', 'xx12xxxx');
+});
+
+
+assert.equal((new Buffer('buff')).toString('base64'), 'YnVmZg==');
+assert.equal((new Buffer('buffe')).toString('base64'), 'YnVmZmU=');
+assert.equal((new Buffer('buffer')).toString('base64'), 'YnVmZmVy');
+assert.equal((new Buffer('\u007f\u007f\u007f\u007f')).toString('base64'),
+ 'f39/fw==');
+assert.equal((new Buffer('\u007e\u007e\u007e\u007e')).toString('base64'),
+ 'fn5+fg==');
+
+assert.equal((new Buffer('**buffer**')).toString('base64', 2, 7), 'YnVmZmU=');
+
+
+/* Hex tests. */
+
+assert.equal((new Buffer('6768696A6b6c6D6e6f70', 'hex')).toString(),
+ 'ghijklmnop');
+assert.equal((new Buffer('2a20427546663352202a', 'hex')).toString(),
+ '* BuFf3R *');
+assert.equal((new Buffer('eFbfBf', 'hex')).toString(), '\uffff');
+
+decodeError('0*12', 'hex');
+decodeError('0fe', 'hex');
+decodeError('0g', 'hex');
+
+testWrite('xxxxxxxx', '31323334', 2, 16, 'hex', 'xx1234xx', 4);
+testWrite('xxxxxxxx', '31323334', 2, 0, 'hex', 'xxxxxxxx', 0);
+testWrite('xxxxxxxx', '31323334', 3, 2, 'hex', 'xxx12xxx', 2);
+testWrite('xxxx', '31323334', 2, 16, 'hex', 'xx12', 2);
+
+assert.throws(function () {
+ /* Malformed string must throw error regardless of the buffer length. */
+ testWrite('xxxxxxxx', '3132333g', 2, 2, 'base64', 'xx12xxxx');
+});
+
+assert.equal((new Buffer('ghijklmnop')).toString('hex'),
+ '6768696a6b6c6d6e6f70');
+
+assert.equal((new Buffer('ghijklmnop')).toString('hex', 2, 8),
+ '696a6b6c6d6e');
fs.rmdir(root, function() {
assert.equal(fs.existsSync(root), false);
- });
-
- var root2 = testRoot + "/test_dir2";
+ var root2 = testRoot + "/test_dir2";
- fs.mkdir(root2, 777, function(err) {
- assert.equal(err, null);
- assert.equal(fs.existsSync(root2), true);
+ fs.mkdir(root2, 777, function(err) {
+ assert.equal(err, null);
+ assert.equal(fs.existsSync(root2), true);
- fs.rmdir(root2, function(){
- assert.equal(fs.existsSync(root2), false);
- });
+ fs.rmdir(root2, function() {
+ assert.equal(fs.existsSync(root2), false);
+ });
- // Run read-only directory test only on linux
- // NuttX does not support read-only attribute.
- if (process.platform === 'linux') {
- // Try to create a folder in a read-only directory.
- fs.mkdir(root, '0444', function(err) {
- assert.equal(fs.existsSync(root), true);
+ // Run read-only directory test only on linux and Tizen
+ // NuttX does not support read-only attribute.
+ if (process.platform === 'linux' || process.platform === 'tizen') {
+ var testMode = '0444';
+ fs.mkdir(root, testMode, function(err) {
+ assert.equal(err, null);
+ assert.equal(fs.existsSync(root), true);
- var dirname = root + "/permission_test";
- try {
- fs.mkdirSync(dirname);
- assert.assert(false);
- } catch (e) {
- assert.equal(e instanceof Error, true);
- assert.equal(e instanceof assert.AssertionError, false);
- }
+ var mode = fs.statSync(root).mode;
+ assert.strictEqual(mode.toString(8).slice(-4), testMode);
- assert.equal(fs.existsSync(dirname), false);
- fs.rmdir(root, function() {
- assert.equal(fs.existsSync(root), false);
+ fs.rmdir(root, function() {
+ assert.equal(fs.existsSync(root), false);
+ });
});
- });
- }
+ }
+ });
});
});
}
var assert = require('assert');
var gpio = require('gpio');
+var pin = require('tools/systemio_common').pin;
+var checkError = require('tools/systemio_common').checkError;
var ledGpio = null, switchGpio = null;
-var ledPin, switchPin, ledMode;
var SWITCH_ON = false,
LED_ON = true,
var loopCnt = 0;
-if (process.platform === 'linux') {
- ledPin = 20;
- switchPin = 13;
- ledMode = gpio.MODE.NONE;
-} else if (process.platform === 'nuttx') {
- var pin = require('stm32f4dis').pin;
- ledPin = pin.PA10;
- switchPin = pin.PA15;
- ledMode = gpio.MODE.PUSHPULL;
-} else if(process.platform === 'tizenrt') {
- ledPin = 41;
- switchPin = 39;
- ledMode = gpio.MODE.NONE;
-} else {
- assert.fail();
-}
-
ledGpio = gpio.open({
- pin: ledPin,
+ pin: pin.led,
direction: gpio.DIRECTION.OUT,
- mode: ledMode
}, function(err) {
- assert.equal(err, null);
+ checkError(err);
ledGpio.writeSync(LED_OFF);
});
switchGpio = gpio.openSync({
- pin: switchPin,
+ pin: pin.switch,
direction: gpio.DIRECTION.IN
});
var assert = require('assert');
var gpio = require('gpio');
+var pin = require('tools/systemio_common').pin;
+var checkError = require('tools/systemio_common').checkError;
var LED_ON = true,
LED_OFF = false;
-var pin, mode;
var gpio20;
-if (process.platform === 'linux') {
- pin = 20;
- mode = gpio.MODE.NONE;
-} else if (process.platform === 'nuttx') {
- pin = require('stm32f4dis').pin.PA10;
- mode = gpio.MODE.PUSHPULL;
-} else if(process.platform === 'tizenrt') {
- pin = 41;
- mode = gpio.MODE.NONE;
-} else {
- assert.fail();
-}
-
test1();
gpio20 = gpio.open({
- pin: pin,
+ pin: pin.led,
direction: gpio.DIRECTION.OUT,
- mode: mode
}, test2);
function test1() {
assert.equal(err, null);
gpio20.write(LED_ON, function(writeErr) {
- assert.equal(writeErr, null);
+ checkError(writeErr);
console.log('gpio write');
gpio20.read(function(readErr, value) {
- assert.equal(readErr, null);
+ checkError(readErr);
console.log('gpio read:', value);
assert.equal(LED_ON, value);
console.log('gpio read:', value);
assert.equal(LED_OFF, value);
gpio20.close(function(closeErr) {
- assert.equal(closeErr, null);
+ checkError(closeErr);
console.log('finish test');
});
}, 3000);
var fulfill_ret;
var p = new Promise(function(resolve, reject) {
// mimic asynchronous operation via setTimeout
- setTimeout(function() { resolve("Resolved") }, 100);;
+ setTimeout(function() { resolve("Resolved") }, 100);
});
p.then(function (msg) {
});
// If Promise's fulfill worked well, assertion must be valid.
-setTimeout(function() { assert.equal(fulfill_ret, "Resolved"); }, 200);
+setTimeout(function() { assert.equal(fulfill_ret, "Resolved"); }, 1000);
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var assert = require('assert');
+var fs = require('fs');
+
+var iotjs_path = process.env["IOTJS_PATH"]
+/* Currenlty it is expected tha the loadable test module is at a given path. */
+var dynamicmodule_dir = iotjs_path + "/../test/dynamicmodule/"
+var dynamicmodule_name = "test-dynamicmodule"
+var dynamicmodule_path = dynamicmodule_dir + dynamicmodule_name + ".iotjs";
+
+assert.assert(fs.existsSync(dynamicmodule_path),
+ "Dynamic module does not exists: " + dynamicmodule_path);
+
+var testmodule = require(dynamicmodule_path);
+assert.equal(testmodule.demokey, 3.4);
+assert.equal(testmodule.counter, 1);
+testmodule.new_value = "hello";
+
+/* Loading the module via a differnt key.
+ * This should not initialize the module again.
+ */
+var load_2 = require(dynamicmodule_dir + dynamicmodule_name)
+assert.equal(load_2.demokey, 3.4);
+/* if the counter is not one then the module initializer was invoked again. */
+assert.equal(load_2.counter, 1);
+assert.equal(load_2.new_value, "hello");
var count = 40;
var connectionCount = 0;
-if (process.platform === 'linux' || process.platform === 'darwin') {
+if (process.platform === 'linux' || process.platform === 'darwin' ||
+ process.platform === 'tizen') {
var maxConnection = 40;
} else if (process.platform === 'nuttx' || process.platform === 'tizenrt') {
var maxConnection = 5;
// final res.headers = { 'h1' : 'h1', 'h3': 'h3prime' }
var responseSize;
- if (process.platform === 'linux') {
+ if (process.platform === 'linux' || process.platform === 'tizen') {
// For Desktop and RPI, test with large header.
responseSize = 500;
} else {
isRequest2Finished = true;
});
-// Call the request2 end again to test the finish state.
-request2.end(message, function() {
- // This clabback should never be called.
- assert.equal(isRequest2Finished, false);
-});
-
var server3 = http.createServer(function(request, response) {
var str = '';
*/
var assert = require('assert');
-var Server = require('http_server').Server;
var http = require('http');
-
+var Server = http.Server;
var responseCheck = '';
var connectionEvent = 0;
var options = {
method : 'POST',
port : 3001,
+ rejectUnauthorized: false,
headers : {'Content-Length': msg.length}
};
var finalOptions = {
method : 'POST',
port : 3001,
+ rejectUnauthorized: false,
headers : {'Content-Length': finalMsg.length}
};
assert.equal(timeouted, true);
assert.equal(code, 0);
});
+
+getReq.end();
// 1. GET req
options = {
method: 'GET',
- host: "httpbin.org",
+ host: 'httpbin.org',
path: '/user-agent',
+ rejectUnauthorized: false,
headers: {'user-agent': 'iotjs'}
};
var testMsg = 'Hello IoT.js';
var finalOptions = {
method: 'POST',
- host: "httpbin.org",
+ host: 'httpbin.org',
path: '/post',
+ rejectUnauthorized: false,
headers: {'Content-Length': testMsg.length,
'Content-Type': 'application/json'}
};
type: 'message' });
var options = {
- "method": "POST",
- "hostname": "api.artik.cloud",
- "path": "/v1.1/messages",
- "headers": {
- "content-type": "application/json",
- "content-length": data.length,
- "authorization": "Bearer 1718113118564ad495ad03f04116f379"
+ method: 'POST',
+ hostname: 'api.artik.cloud',
+ path: '/v1.1/messages',
+ rejectUnauthorized: false,
+ headers: {
+ 'content-type': 'application/json',
+ 'content-length': data.length,
+ 'authorization': 'Bearer 1718113118564ad495ad03f04116f379'
}
};
// Options for further requests.
var options = {
method: 'POST',
- host: "httpbin.org",
+ host: 'httpbin.org',
path: '/post',
+ rejectUnauthorized: false,
headers: {'Content-Length': message.length,
'Content-Type': 'application/json'}
};
isRequest2Finished = true;
});
-// Call the request2 end again to test the finish state.
-request2.end(message, function() {
- // This clabback should never be called.
- assert.equal(isRequest2Finished, false);
-});
-
// Simple request with buffer chunk as message parameter.
var isRequest3Finished = false;
var isRequest4Finished = false;
var readRequest = https.request({
method: 'GET',
- host: "httpbin.org",
+ host: 'httpbin.org',
+ rejectUnauthorized: false,
path: '/get'
});
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var assert = require('assert');
+var https = require('https');
+var fs = require('fs');
+
+var server_options = {
+ key: fs.readFileSync('resources/my_key.pem').toString(),
+ cert: fs.readFileSync('resources/my_crt.pem').toString()
+};
+
+var server = https.createServer(server_options, function(req, res) {
+ res.writeHead(200);
+ res.end('hello world\n');
+}).listen(8000);
+
+
+var client_options = {
+ host: 'localhost',
+ port: 8000,
+ rejectUnauthorized: false
+}
+
+var responseHandler = function (res) {
+ var res_body = '';
+
+ assert.equal(200, res.statusCode);
+
+ var endHandler = function(){
+ assert.equal(res_body, 'hello world\n');
+ };
+ res.on('end', endHandler);
+
+ res.on('data', function(chunk){
+ res_body += chunk.toString();
+ });
+
+ server.close();
+}
+
+https.get(client_options, responseHandler);
options = {
method: 'GET',
host: 'httpbin.org',
+ rejectUnauthorized: false,
path: '/delay/10'
};
var assert = require('assert');
var spi = require('spi');
+var pin = require('tools/systemio_common').pin;
-var configuration = {};
-
-if (process.platform === 'linux') {
- configuration.device = '/dev/spidev0.0';
-} else if (process.platform === 'nuttx') {
- configuration.bus = 1;
-} else if (process.platform === 'tizenrt') {
- configuration.bus = 0;
-} else {
- assert.fail('OS not supported:' + process.platform);
-}
+var configuration = {
+ device: pin.spi1, // for Linux
+ bus: pin.spi1, // for Tizen, TizenRT and Nuttx
+};
// ------ Test API existance
var assert = require('assert');
var spi = require('spi');
+var pin = require('tools/systemio_common').pin;
+var checkError = require('tools/systemio_common').checkError;
-var configuration = {};
-
-if (process.platform === 'linux') {
- configuration.device = '/dev/spidev0.0';
-} else if (process.platform === 'nuttx' || process.platform === 'tizenrt') {
- configuration.bus = 1;
-} else {
- assert.fail();
-}
+var configuration = {
+ device: pin.spi1, // for Linux
+ bus: pin.spi1, // for Tizen, TizenRT and Nuttx
+};
// Buffer test
var spi1 = spi.open(configuration, function(err) {
- assert.equal(err, null);
+ checkError(err);
var data = 'Hello IoTjs';
var tx = new Buffer(data);
spi1.transfer(tx, function(err, rx) {
- assert.equal(err, null);
- assert.equal(rx.length, 11);
+ checkError(err);
+ var len = data.length;
+ assert.equal(rx.length, len);
var value = '';
- for (var i = 0; i < 11; i++) {
+ for (var i = 0; i < len; i++) {
value += String.fromCharCode(rx[i]);
}
console.log(value);
assert.equal(value, data);
- spi1.close(function (err) {
- assert.equal(err, null);
+ spi1.close(function(err) {
+ checkError(err);
});
});
});
var assert = require('assert');
var spi = require('spi');
+var pin = require('tools/systemio_common').pin;
-var configuration = {};
-
-if (process.platform === 'linux') {
- configuration.device = '/dev/spidev0.0';
-} else if (process.platform === 'nuttx' || process.platform === 'tizenrt') {
- configuration.bus = 1;
-} else {
- assert.fail();
-}
+var configuration = {
+ device: pin.spi1, // for Linux
+ bus: pin.spi1, // for Tizen, TizenRT and Nuttx
+};
// Buffer test
var spi1 = spi.openSync(configuration);
var tx = new Buffer(data);
var rx = spi1.transferSync(tx);
-assert.equal(rx.length, 11);
+var len = data.length;
+assert.equal(rx.length, len);
var value = '';
-for (var i = 0; i < 11; i++) {
+for (var i = 0; i < len; i++) {
value += String.fromCharCode(rx[i]);
}
console.log(value);
var assert = require('assert');
var spi = require('spi');
+var pin = require('tools/systemio_common').pin;
+var checkError = require('tools/systemio_common').checkError;
-var configuration = {};
-
-if (process.platform === 'linux') {
- configuration.device = '/dev/spidev0.0';
-} else if (process.platform === 'nuttx' || process.platform === 'tizenrt') {
- configuration.bus = 1;
-} else {
- assert.fail();
-}
+var configuration = {
+ device: pin.spi1, // for Linux
+ bus: pin.spi1, // for Tizen, TizenRT and Nuttx
+};
// mcp3008 test
var channel = 0;
-var spi0 = spi.open(configuration, function() {
+var spi0 = spi.open(configuration, function(err) {
+ checkError(err);
+
var mode = (8 + channel) << 4;
var tx = [1, mode, 0];
var loopCnt = 10;
var loop = setInterval(function() {
spi0.transfer(tx, function(err, rx) {
- assert.equal(err, null);
+ checkError(err);
assert.equal(rx.length, 3);
var value = ((rx[1] & 0x03) << 8) + rx[2];
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var tizen = require('tizen');
+
+// Need to set target APP_ID e.g) app.control.receiver
+var app_id = '';
+var data = {
+ str: 'iotjs'
+};
+
+// test: tizen.on
+tizen.on('appControl', function(msg) {
+ console.log('appControl', msg);
+
+ var extra_data = msg.extra_data;
+ if(extra_data && extra_data.key === 'iotjs' ) {
+
+ //test: tizen.launchAppControl
+ try {
+ var res = tizen.launchAppControl({
+ app_id: app_id,
+ extra_data: data,
+ });
+ console.log('Result', res);
+ } catch(e) {
+ console.log(e);
+ }
+ }
+});
--- /dev/null
+/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ var tls = require('tls');
+ var assert = require('assert');
+ var fs = require('fs');
+
+ var port = 8080;
+
+ var server_closed = false;
+ var expected_client_msg = 'Client hello';
+ var expected_server_msg = 'Server hello';
+ var client_message = '';
+ var server_message = '';
+ var server_handshake_done = false;
+ var tlsClientError_caught = false;
+ var socket_handshake_error_caught = false;
+
+ var options = {
+ key: fs.readFileSync('resources/my_key.pem').toString(),
+ cert: fs.readFileSync('resources/my_crt.pem').toString(),
+ rejectUnauthorized: false,
+ isServer: true,
+ };
+
+ var server = tls.createServer(options, function(socket) {
+ socket.write('Server hello');
+
+ socket.on('data', function(data) {
+ client_message += data.toString();
+ });
+
+ }).listen(port, function() { });
+
+ server.on('secureConnection', function() {
+ server_handshake_done = true;
+ });
+
+ server.on('close', function() {
+ server_closed = true;
+ });
+
+ var error_caught = false;
+ var handshake_done = false;
+
+ var sockOpts = {
+ host: '127.0.0.1',
+ port: 8080,
+ rejectUnauthorized: false,
+ }
+
+ var socket = tls.connect(sockOpts, function() {
+ });
+
+ socket.on('secureConnect', function(){
+ handshake_done = true;
+ });
+
+ socket.on('end', function() {
+ server.close();
+ });
+
+ socket.on('data', function(data) {
+ server_message += data.toString();
+ socket.write('Client hello');
+ socket.end();
+ });
+
+ var socket2 = tls.connect({host: '127.123.123.123', port: 444}, function() {
+ socket2.end();
+ });
+
+ socket2.on('error', function(err) {
+ error_caught = true;
+ });
+
+
+var nocert_options = {
+ rejectUnauthorized: false,
+ isServer: true,
+}
+
+var server2_port = 8081;
+
+sockOpts = {
+ host: '127.0.0.1',
+ port: server2_port,
+ rejectUnauthorized: false,
+}
+
+var server2 = tls.createServer(nocert_options, function(socket) {
+}).listen(server2_port, function() { });
+
+server2.on('tlsClientError', function(error) {
+ tlsClientError_caught = error instanceof Error;
+ server2.close();
+});
+
+var socket3 = tls.connect(sockOpts, function() { });
+
+socket3.on('error', function(error) {
+ socket_handshake_error_caught = error instanceof Error;
+});
+
+var server3 = tls.createServer(options, function(socket) {
+ socket.write('Server hello');
+
+ socket.on('data', function(data) {
+ client_message = data.toString();
+ });
+
+}).listen(9090, function() { });
+
+server3.on('secureConnection', function() {
+ server_handshake_done = true;
+});
+
+server3.on('close', function() {
+ server_closed = true;
+});
+
+var opt = {
+ rejectUnauthorized: false,
+}
+
+var socket4 = tls.connect(9090);
+
+socket4.on('secureConnect', function(){
+ handshake_done = true;
+});
+
+socket4.on('data', function(data) {
+ server_message = data.toString();
+ socket4.write('Client hello');
+ socket4.end();
+});
+
+var socket5 = tls.connect(9090, 'localhost');
+
+socket5.on('secureConnect', function(){
+ handshake_done = true;
+});
+
+socket5.on('data', function(data) {
+ server_message = data.toString();
+ socket5.write('Client hello');
+ socket5.end();
+});
+
+var socket6 = tls.connect(9090, 'localhost', opt);
+
+socket6.on('secureConnect', function(){
+ handshake_done = true;
+});
+
+socket6.on('data', function(data) {
+ server_message = data.toString();
+ socket6.write('Client hello');
+ socket6.end();
+});
+
+var socket7 = tls.connect(9090, 'localhost', opt, function() {
+});
+
+socket7.on('secureConnect', function(){
+ handshake_done = true;
+});
+
+socket7.on('data', function(data) {
+ server_message = data.toString();
+ socket7.write('Client hello');
+ socket7.end();
+});
+
+var socket8 = tls.connect(9090, 'localhost', function() {
+});
+
+socket8.on('secureConnect', function(){
+ handshake_done = true;
+});
+
+socket8.on('data', function(data) {
+ server_message = data.toString();
+ socket8.write('Client hello');
+ socket8.end();
+});
+
+var socket9 = tls.connect(9090, function() {
+});
+
+socket9.on('secureConnect', function(){
+ handshake_done = true;
+});
+
+socket9.on('end', function() {
+ server3.close();
+});
+
+socket9.on('data', function(data) {
+ server_message = data.toString();
+ socket9.write('Client hello');
+ socket9.end();
+});
+
+process.on('exit', function() {
+ assert.equal(error_caught, true);
+ assert.equal(handshake_done, true);
+ assert.equal(server_handshake_done, true);
+ assert.equal(client_message === expected_client_msg, true);
+ assert.equal(server_message === expected_server_msg, true);
+ assert.equal(server_closed, true);
+ assert.equal(tlsClientError_caught, true);
+ assert.equal(socket_handshake_error_caught, true);
+});
* limitations under the License.
*/
-var assert = require('assert');
var uart = require('uart');
+var pin = require('tools/systemio_common').pin;
+var checkError = require('tools/systemio_common').checkError;
var configuration = {
+ device: pin.uart1, // for Linux, TizenRT and Nuttx
+ port: pin.uart1, // for Tizen
baudRate: 115200,
- dataBits: 8
+ dataBits: 8,
};
-if (process.platform === 'linux') {
- configuration.device = '/dev/ttyS0';
-} else if (process.platform === 'nuttx' || process.platform === 'tizenrt') {
- configuration.device = '/dev/ttyS1';
-} else {
- assert.fail();
-}
-
writeTest();
function writeTest() {
var serial = uart.openSync(configuration);
console.log('open done');
- serial.writeSync("Hello IoT.js.\n\r");
+ serial.writeSync('Hello IoT.js.\n\r');
serial.closeSync();
console.log('close done');
writeReadTest();
var write = 0;
var serial = uart.open(configuration, function(err) {
- assert.equal(err, null);
+ checkError(err);
console.log('open done');
serial.on('data', function(data) {
}
});
- serial.write("Hello there?\n\r", function(err) {
- assert.equal(err, null);
+ serial.write('Hello there?\n\r', function(err) {
+ checkError(err);
console.log('write done');
write = 1;
if (read && write) {
serial.close(function(err) {
- assert.equal(err, null);
+ checkError(err);
});
console.log('close done');
}
--- /dev/null
+{
+ "run_pass": [
+ { "name": "test_iotjs_promise.js" },
+ { "name": "test_iotjs_promise_chain_calls.js" }
+ ]
+}
--- /dev/null
+{
+ "external_modules": [
+ { "name": "test-external-module1.js" },
+ { "name": "test-external-module2.js" }
+ ]
+}
--- /dev/null
+{
+ "run_pass": [
+ { "name": "test_net_https_get.js", "timeout": 10 },
+ { "name": "test_net_https_post_status_codes.js", "timeout": 10 },
+ { "name": "test_net_https_request_response.js", "timeout": 10 },
+ { "name": "test_net_https_timeout.js", "timeout": 10 },
+ { "name": "test_net_https_server.js", "timeout": 10 },
+ { "name": "test_tls.js" }
+ ]
+}
--- /dev/null
+{
+ "run_pass": [
+ { "name": "test_net_https_get.js", "timeout": 10 },
+ { "name": "test_net_https_post_status_codes.js", "timeout": 10 },
+ { "name": "test_net_https_request_response.js", "timeout": 10 },
+ { "name": "test_net_https_timeout.js", "timeout": 10 },
+ { "name": "test_net_https_server.js", "timeout": 10 },
+ { "name": "test_tls.js" }
+ ]
+}
--- /dev/null
+{
+ "run_pass/issue": [
+ { "name": "issue-223.js", "skip": ["all"], "reason": "unsupported module by iotjs build" },
+ { "name": "issue-266.js", "skip": ["all"], "reason": "unsupported module by iotjs build" }
+ ],
+ "node/parallel": [
+ { "name": "test-assert.js", "skip": ["all"], "reason": "unsupported module by iotjs build" },
+ { "name": "test-http-catch-uncaughtexception.js", "skip": ["all"], "reason": "unsupported module by iotjs build" },
+ { "name": "test-http-status-message.js", "skip": ["all"], "reason": "unsupported module by iotjs build" },
+ { "name": "test-http-write-head.js", "skip": ["all"], "reason": "unsupported module by iotjs build" },
+ { "name": "test-net-bind-twice.js", "skip": ["all"], "reason": "unsupported module by iotjs build" },
+ { "name": "test-net-end-without-connect.js", "skip": ["all"], "reason": "unsupported module by iotjs build" },
+ { "name": "test-net-keepalive.js", "skip": ["all"], "reason": "unsupported module by iotjs build" },
+ { "name": "test-timers-clear-null-does-not-throw-error.js", "skip": ["all"], "reason": "unsupported module by iotjs build" }
+ ]
+}
{ "name": "test_ble_advertisement.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_ble_setservices.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_ble_setservices_central.js", "skip": ["all"], "reason": "run it with nodejs after running test_ble_setservices.js" },
- { "name": "test_buffer_builtin.js" },
{ "name": "test_buffer.js" },
+ { "name": "test_buffer_str_conv.js" },
{ "name": "test_console.js" },
{ "name": "test_dgram_1_server_1_client.js" },
{ "name": "test_dgram_1_server_n_clients.js", "skip": ["linux"], "reason": "[linux]: flaky on Travis" },
- { "name": "test_dgram_address.js", "skip": ["linux", "nuttx"], "reason": "[linux]: flaky on Travis, [nuttx]: not implemented for nuttx" },
+ { "name": "test_dgram_address.js", "skip": ["nuttx"], "reason": "[nuttx]: not implemented for nuttx" },
{ "name": "test_dgram_broadcast.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_dgram_multicast_membership.js", "skip": ["all"], "reason": "need to setup test environment" },
- { "name": "test_dgram_multicast_set_multicast_loop.js", "skip": ["linux", "nuttx"], "reason": "[linux]: flaky on Travis, [nuttx]: not implemented for nuttx" },
+ { "name": "test_dgram_multicast_set_multicast_loop.js", "skip": ["nuttx"], "reason": "[nuttx]: not implemented for nuttx" },
{ "name": "test_dgram_setttl_client.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_dgram_setttl_server.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_dns.js" },
{ "name": "test_dns_lookup.js", "skip": ["nuttx"], "reason": "not implemented for nuttx" },
{ "name": "test_events.js" },
- { "name": "test_events_assert_emit_error.js", "uncaught": true },
- { "name": "test_events_uncaught_error.js", "uncaught": true },
+ { "name": "test_events_assert_emit_error.js" },
+ { "name": "test_events_uncaught_error.js" },
{ "name": "test_fs_exists.js" },
{ "name": "test_fs_exists_sync.js" },
{ "name": "test_fs_fstat.js", "skip": ["nuttx", "tizenrt"], "reason": "not implemented for nuttx/TizenRT" },
{ "name": "test_fs_fstat_sync.js", "skip": ["nuttx", "tizenrt"], "reason": "not implemented for nuttx/TizenRT" },
- { "name": "test_fs_mkdir_rmdir.js", "skip": ["linux", "nuttx"], "reason": "[linux]: flaky on Travis, [nuttx]: implemented, run manually in default configuration" },
+ { "name": "test_fs_mkdir_rmdir.js", "skip": ["nuttx"], "reason": "[nuttx]: implemented, run manually in default configuration" },
{ "name": "test_fs_open_close.js", "skip": ["nuttx"], "reason": "not implemented for nuttx" },
{ "name": "test_fs_readdir.js" },
{ "name": "test_fs_readfile.js" },
{ "name": "test_fs_open_read_sync_1.js", "skip": ["nuttx"], "reason": "not implemented for nuttx" },
{ "name": "test_fs_open_read_sync_2.js" },
{ "name": "test_fs_open_read_sync_3.js" },
- { "name": "test_gpio_input.js", "skip": ["all"], "reason": "needs hardware" },
- { "name": "test_gpio_output.js", "skip": ["all"], "reason": "need user input"},
+ { "name": "test_gpio_input.js", "skip": ["all"], "reason": "need to setup test environment" },
+ { "name": "test_gpio_output.js", "skip": ["all"], "reason": "need to setup test environment"},
{ "name": "test_i2c_gy30.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_iotjs_promise.js", "skip": ["all"], "reason": "es2015 is off by default" },
{ "name": "test_iotjs_promise_chain_calls.js", "skip": ["all"], "reason": "es2015 is off by default" },
{ "name": "test_module_cache.js", "skip": ["nuttx"], "reason": "not implemented for nuttx" },
{ "name": "test_module_json.js" },
{ "name": "test_module_require.js", "skip": ["nuttx"], "reason": "not implemented for nuttx" },
+ { "name": "test_module_dynamicload.js", "skip": ["darwin", "nuttx", "tizenrt"], "reason": "embedded and macos does not support dynamic loading" },
{ "name": "test_net_1.js" },
{ "name": "test_net_2.js" },
- { "name": "test_net_3.js", "skip": ["linux", "nuttx"], "reason": "[linux]: flaky on Travis, [nuttx]: requires too many socket descriptors and too large buffers" },
+ { "name": "test_net_3.js", "skip": ["nuttx"], "reason": "[nuttx]: requires too many socket descriptors and too large buffers" },
{ "name": "test_net_4.js" },
{ "name": "test_net_5.js" },
{ "name": "test_net_6.js" },
{ "name": "test_net_7.js", "skip": ["nuttx"], "reason": "requires too many socket descriptors" },
- { "name": "test_net_8.js", "skip": ["linux"], "reason": "[linux]: flaky on Travis" },
+ { "name": "test_net_8.js" },
{ "name": "test_net_9.js" },
{ "name": "test_net_10.js" },
{ "name": "test_net_connect.js" },
{ "name": "test_net_http_get.js" },
{ "name": "test_net_http_response_twice.js" },
{ "name": "test_net_http_request_response.js", "skip": ["nuttx"], "reason": "not implemented for nuttx" },
- { "name": "test_net_http_status_codes.js", "skip": ["linux", "nuttx"], "reason": "[linux]: flaky on Travis, [nuttx]: not implemented" },
+ { "name": "test_net_http_status_codes.js", "skip": ["nuttx"], "reason": "[nuttx]: not implemented" },
{ "name": "test_net_httpclient_error.js", "skip": ["nuttx"], "reason": "not implemented for nuttx" },
{ "name": "test_net_httpclient_parse_error.js" },
{ "name": "test_net_httpclient_timeout_1.js" },
{ "name": "test_net_httpclient_timeout_2.js" },
- { "name": "test_net_httpserver_timeout.js" },
- { "name": "test_net_httpserver.js", "skip": ["nuttx"], "reason": "not implemented for nuttx" },
- { "name": "test_net_https_get.js", "timeout": 40, "skip": ["all"], "reason": "Implemented only for Tizen" },
- { "name": "test_net_https_post_status_codes.js", "timeout": 40, "skip": ["all"], "reason": "Implemented only for Tizen" },
- { "name": "test_net_https_request_response.js", "timeout": 40, "skip": ["all"], "reason": "Implemented only for Tizen" },
- { "name": "test_net_https_timeout.js", "timeout": 40, "skip": ["all"], "reason": "Implemented only for Tizen" },
+ { "name": "test_net_http_server_timeout.js" },
+ { "name": "test_net_http_server.js", "skip": ["nuttx"], "reason": "not implemented for nuttx" },
+ { "name": "test_net_https_get.js", "timeout": 10, "skip": ["all"], "reason": "HTTPS module is not enabled by default" },
+ { "name": "test_net_https_post_status_codes.js", "timeout": 10, "skip": ["all"], "reason": "HTTPS module is not enabled by default" },
+ { "name": "test_net_https_request_response.js", "timeout": 10, "skip": ["all"], "reason": "HTTPS module is not enabled by default" },
+ { "name": "test_net_https_timeout.js", "timeout": 10, "skip": ["all"], "reason": "HTTPS module is not enabled by default" },
+ { "name": "test_net_https_server.js", "timeout": 10, "skip": ["all"], "reason": "HTTPS module is not enabled by default" },
{ "name": "test_process.js" },
{ "name": "test_process_chdir.js" },
{ "name": "test_process_cwd.js" },
{ "name": "test_process_experimental_on.js", "skip": ["stable"], "reason": "needed if testing stablity is set with experimental" },
{ "name": "test_process_next_tick.js" },
{ "name": "test_process_readsource.js" },
- { "name": "test_process_uncaught_order.js", "uncaught": true },
- { "name": "test_process_uncaught_simple.js", "uncaught": true },
+ { "name": "test_process_uncaught_order.js" },
+ { "name": "test_process_uncaught_simple.js" },
{ "name": "test_pwm_async.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_pwm_sync.js", "skip": ["all"], "reason": "need to setup test environment" },
- { "name": "test_spi.js", "skip": ["linux"], "reason": "Differend env on Linux desktop/travis/rpi" },
+ { "name": "test_spi.js", "skip": ["linux"], "reason": "Different env on Linux desktop/travis/rpi" },
{ "name": "test_spi_buffer_async.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_spi_buffer_sync.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_spi_mcp3008.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_stream.js" },
- { "name": "test_stream_duplex.js"},
+ { "name": "test_stream_duplex.js" },
{ "name": "test_timers_arguments.js" },
{ "name": "test_timers_error.js" },
{ "name": "test_timers_simple.js", "timeout": 10 },
- { "name": "test_uart.js", "timeout": 10, "skip": ["all"], "reason": "need to setup test environment" },
+ { "name": "test_tizen_app_control.js", "skip": ["all"], "reason": "need to setup test environment" },
+ { "name": "test_tls.js", "skip": ["all"], "reason": "TLS module is not enabled by default" },
+ { "name": "test_uart.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_uart_api.js" },
{ "name": "test_util.js" }
],
{ "name": "issue-1046.js" },
{ "name": "issue-1077.js" },
{ "name": "issue-1101.js", "skip": ["all"], "reason": "need to setup test environment" },
- { "name": "issue-1351.js" }
+ { "name": "issue-1348.js" },
+ { "name": "issue-1351.js" },
+ { "name": "issue-1485.js" },
+ { "name": "issue-1507.js" },
+ { "name": "issue-1557.js" }
],
"run_fail": [
{ "name": "test_assert_equal.js", "expected-failure": true },
{ "name": "test_fs_callbacks_called.js", "expected-failure": true },
{ "name": "test_iotjs_runtime_error.js", "expected-failure": true },
{ "name": "test_iotjs_syntax_error.js", "expected-failure": true },
+ { "name": "test-issue-1349.js", "expected-failure": true},
+ { "name": "test-issue-1360.js", "expected-failure": true},
{ "name": "test_module_require_invalid_file.js", "expected-failure": true },
{ "name": "test_module_require_path_below_root.js", "expected-failure": true },
{ "name": "test_process_exitcode_arg.js", "expected-failure": true },
],
"node/parallel": [
{ "name": "test-assert.js" },
+ { "name": "test-module-circular.js" },
{ "name": "test-http-catch-uncaughtexception.js" },
{ "name": "test-http-status-message.js" },
{ "name": "test-http-write-head.js" },
var pin = {};
if (process.platform === 'linux') {
+ pin.led = 20;
+ pin.switch = 13;
pin.pwm1 = 0;
pin.i2c1 = '/dev/i2c-1';
+ pin.spi1 = '/dev/spidev0.0';
+ pin.uart1 = '/dev/ttyS0';
+} else if (process.platform === 'tizen') {
+ pin.led = 20;
+ pin.switch = 13;
+ pin.pwm1 = 2;
+ pin.i2c1 = 1;
+ pin.spi1 = 0;
+ pin.uart1 = 0;
} else if (process.platform === 'nuttx') {
var stm32_pin = require('stm32f4dis').pin;
+ pin.led = stm32_pin.PA10;
+ pin.switch = stm32_pin.PA15;
pin.pwm1 = stm32_pin.PWM1.CH1_1;
pin.i2c1 = 1;
+ pin.spi1 = 1;
+ pin.uart1 = '/dev/ttyS1';
} else if (process.platform === 'tizenrt') {
+ pin.led = 41;
+ pin.switch = 39;
pin.pwm1 = 0;
pin.i2c1 = 1;
+ pin.spi1 = 1;
+ pin.uart1 = '/dev/ttyS1';
} else {
throw new Error('Unsupported platform');
}
help='Specify the module profile file for IoT.js')
parser.add_argument('--target-arch',
- choices=['arm', 'x86', 'i686', 'x86_64', 'x64', 'noarch'],
+ choices=['arm', 'x86', 'i686', 'x86_64', 'x64', 'mips', 'noarch'],
default=platform.arch(),
help='Specify the target architecture: '
'%(choices)s (default: %(default)s)')
parser.add_argument('--target-os',
- choices=['linux', 'darwin', 'osx', 'nuttx', 'tizen', 'tizenrt'],
+ choices=['linux', 'darwin', 'osx', 'nuttx', 'tizen', 'tizenrt',
+ 'openwrt'],
default=platform.os(),
help='Specify the target os: %(choices)s (default: %(default)s)')
action='store_true', default=False,
help='Disable test execution with valgrind after build')
parser.add_argument('--run-test',
- action='store_true', default=False,
- help='Execute tests after build')
- parser.add_argument('--test-driver',
- choices=['js', 'py'], default='py',
- help='Specify the test driver for IoT.js: %(choices)s'
- ' (default: %(default)s)')
+ nargs='?', default=False, const="quiet", choices=["full", "quiet"],
+ help='Execute tests after build, optional argument specifies '
+ 'the level of output for the testrunner')
parser.add_argument('--no-parallel-build',
action='store_true', default=False,
help='Disable parallel build')
parser.add_argument('--no-snapshot',
action='store_true', default=False,
help='Disable snapshot generation for IoT.js')
+ parser.add_argument('--js-backtrace',
+ choices=['ON', 'OFF'], type=str.upper,
+ help='Enable/disable backtrace information of JavaScript code '
+ '(%(choices)s; default: ON in debug and OFF in release build)')
parser.add_argument('-e', '--experimental',
action='store_true', default=False,
help='Enable to build experimental features')
+ parser.add_argument('--testsets',
+ help='Specify the additional testsets file for IoT.js')
options = parser.parse_args(argv)
options.config = build_config
# --jerry-debugger
if options.jerry_debugger:
- cmake_opt.append('-DFEATURE_DEBUGGER=ON')
+ cmake_opt.append("-DFEATURE_DEBUGGER=ON")
+
+ # --js-backtrace
+ if not options.js_backtrace:
+ if options.buildtype == 'debug':
+ options.js_backtrace = "ON"
+ else:
+ options.js_backtrace = "OFF"
+ cmake_opt.append("-DFEATURE_JS_BACKTRACE=%s" %
+ options.js_backtrace)
# --cmake-param
cmake_opt.extend(options.cmake_param)
# --experimental
if options.experimental:
- options.compile_flag.append('-DEXPERIMENTAL')
+ cmake_opt.append('-DEXPERIMENTAL=ON')
# --profile
if options.profile:
def run_checktest(options):
- checktest_quiet = 'yes'
- if os.getenv('TRAVIS') == "true":
- checktest_quiet = 'no'
-
# IoT.js executable
iotjs = fs.join(options.build_root, 'bin', 'iotjs')
- cmd = []
- args = []
- if options.test_driver == "js":
- cmd = iotjs
- args = [path.CHECKTEST_PATH, 'quiet=' + checktest_quiet]
- # experimental
- if options.experimental:
- cmd.append('experimental=' + 'yes');
- else:
- cmd = fs.join(path.TOOLS_ROOT, 'testrunner.py')
- args = [iotjs]
- if checktest_quiet:
- args.append('--quiet')
+ cmd = fs.join(path.TOOLS_ROOT, 'testrunner.py')
+ args = [iotjs]
+ # testsets
+ if options.testsets:
+ args.append('--testsets=' + options.testsets);
+
+ if options.run_test == "quiet":
+ args.append('--quiet')
fs.chdir(path.PROJECT_ROOT)
code = ex.run_cmd(cmd, args)
ex.fail('Failed to pass unit tests')
if not options.no_check_valgrind:
- if options.test_driver == "js":
- code = ex.run_cmd('valgrind', ['--leak-check=full',
- '--error-exitcode=5',
- '--undef-value-errors=no',
- cmd] + args)
- if code == 5:
- ex.fail('Failed to pass valgrind test')
- if code != 0:
- ex.fail('Failed to pass unit tests in valgrind environment')
- else:
- code = ex.run_cmd(cmd, ['--valgrind'] + args)
- if code != 0:
- ex.fail('Failed to pass unit tests in valgrind environment')
+ code = ex.run_cmd(cmd, ['--valgrind'] + args)
+ if code != 0:
+ ex.fail('Failed to pass unit tests in valgrind environment')
if __name__ == '__main__':
print("\n%sTo run tests use '--run-test' "
"or one of the folowing commands:%s"
% (ex._TERM_BLUE, ex._TERM_EMPTY))
- print("\n tools/testrunner.py %s/%s/%s/bin/iotjs"
+ print("\n tools/testrunner.py %s/%s/%s/bin/iotjs\n"
% (options.builddir, options.target_tuple, options.buildtype))
- print("OR\n %s(deprecated)%s %s/%s/%s/bin/iotjs "
- "tools/check_test.js\n"
- % (ex._TERM_RED, ex._TERM_EMPTY, options.builddir,
- options.target_tuple, options.buildtype))
+++ /dev/null
-/* Copyright 2016-present Samsung Electronics Co., Ltd. and other contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var fs = require('fs');
-var Runner = require('test_runner').Runner;
-var Logger = require('common_js/logger').Logger;
-var OptionParser = require('common_js/option_parser').OptionParser;
-var util = require('common_js/util');
-var EventEmitter = require('events').EventEmitter;
-
-var root = 'test';
-var parent = '..';
-var watch = new util.Watch();
-
-function Driver() {
- this.results = {
- pass: 0,
- fail: 0,
- skip: 0,
- timeout: 0,
- };
-
- this.emitter = new EventEmitter();
- this.emitter.addListener('nextTest', function(driver, status, test) {
- var elapsedTime = ' (' + watch.delta().toFixed(2) + 's) ';
-
- if (driver.runner) {
- driver.runner.cleanup();
- }
- var filename = test['name'];
-
- if (status == 'pass') {
- driver.results.pass++;
- driver.logger.message('PASS : ' + filename + elapsedTime, status);
- } else if (status == 'fail') {
- driver.results.fail++;
- driver.logger.message('FAIL : ' + filename + elapsedTime, status);
- } else if (status == 'skip') {
- driver.results.skip++;
- driver.logger.message('SKIP : ' + filename +
- ' (reason : ' + test.reason + ")", status);
- } else if (status == 'timeout') {
- driver.results.timeout++;
- driver.logger.message('TIMEOUT : ' + filename + elapsedTime, status);
- }
- driver.fIdx++;
- driver.runNextTest();
- });
-
- this.os = process.platform;
- this.board = process.iotjs.board;
-
- this.root = util.absolutePath(root);
- process.chdir(this.root);
-
- return this;
-}
-
-Driver.prototype.config = function() {
- var parser = new OptionParser();
-
- parser.addOption('start-from', "", "",
- "a test case file name where the driver starts.");
- parser.addOption('quiet', "yes|no", "yes",
- "a flag that indicates if the driver suppresses " +
- "console outputs of test case");
- parser.addOption('output-file', "", "",
- "a file name where the driver leaves output");
- parser.addOption('skip-module', "", "",
- "a module list to skip test of specific modules");
- parser.addOption('output-coverage', "yes|no", "no",
- "output coverage information");
- parser.addOption('experimental', "yes|no", "no",
- "a flag that indicates if tests for experimental are needed");
- parser.addOption('default-timeout', "", 240,
- "the default timeout in seconds");
-
- var options = parser.parse();
-
- if (options == null) {
- parser.printHelp();
- return false;
- }
-
- var output = options['output-file'];
- if (output) {
- if (this.os == 'nuttx') {
- var path = util.join('/mnt/sdcard', output);
- } else {
- var path = util.join(this.root, '..', output);
- }
- fs.writeFileSync(path, new Buffer(''));
- }
- var skipModule = options['skip-module'];
- if (skipModule) {
- this.skipModule = skipModule.split(',');
- }
-
- var experimental = options['experimental'];
- if (experimental == 'no') {
- this.stability = 'stable';
- } else {
- this.stability = 'experimental';
- }
-
- this.logger = new Logger(path);
-
- this.options = options;
-
- var testfile = util.join(this.root, 'testsets.json');
- var testsets = fs.readFileSync(testfile).toString();
-
- this.tests = JSON.parse(testsets);
-
- this.dIdx = 0;
- this.dLength = Object.keys(this.tests).length;
-
- var skipped = this.skipTestSet(options['start-from']);
-
- this.nextTestSet(skipped);
- return true;
-};
-
-Driver.prototype.runNextTest = function() {
- if (this.dIdx == this.dLength) {
- this.finish();
- } else {
- if (this.fIdx == this.fLength) {
- this.dIdx++;
- if (this.dIdx == this.dLength) {
- this.finish();
- } else {
- this.nextTestSet();
- this.runNextTest();
- }
- } else {
- this.runner = new Runner(this);
- this.runner.run();
- }
- }
-};
-
-Driver.prototype.skipTestSet = function(filename) {
- if (!filename)
- return false;
-
- var dLength = this.dLength;
- for (var dIdx = 0; dIdx < dLength; dIdx++) {
- var dirname = Object.keys(this.tests)[dIdx];
- var dir = this.tests[dirname];
- var fLength = dir.length;
- for (var fIdx = 0; fIdx < fLength; fIdx++) {
- if (dir[fIdx]['name'] == filename) {
- this.fIdx = fIdx;
- this.dIdx = dIdx;
- return true;
- }
- }
- }
-
- return false;
-};
-
-Driver.prototype.nextTestSet = function(skipped) {
- if (!skipped) {
- this.fIdx = 0;
- }
-
- var dirname = this.dirname();
- this.fLength = this.tests[dirname].length;
- this.logger.message("\n");
- this.logger.message(">>>> " + dirname, "summary");
-};
-
-Driver.prototype.dirname = function() {
- return Object.keys(this.tests)[this.dIdx]
-};
-
-Driver.prototype.currentTest = function() {
- var dirname = this.dirname();
- return this.tests[dirname][this.fIdx];
-};
-
-Driver.prototype.test = function() {
- var test = this.currentTest();
- var dirname = this.dirname();
- var testfile = util.absolutePath(util.join(dirname, test['name']));
-
- return fs.readFileSync(testfile).toString();
-};
-
-Driver.prototype.finish = function() {
- this.logger.message('\n\nfinish all tests', this.logger.status.summary);
-
- this.logger.message('PASS : ' + this.results.pass, this.logger.status.pass);
- this.logger.message('FAIL : ' + this.results.fail, this.logger.status.fail);
- this.logger.message('TIMEOUT : ' +
- this.results.timeout, this.logger.status.timeout);
- this.logger.message('SKIP : ' + this.results.skip, this.logger.status.skip);
-
- if (this.options["output-coverage"] == "yes"
- && typeof __coverage__ !== "undefined") {
- data = JSON.stringify(__coverage__);
-
- if (!fs.existsSync("../.coverage_output/")) {
- fs.mkdirSync("../.coverage_output/");
- }
-
- fs.writeFileSync("../.coverage_output/js_coverage.data", Buffer(data));
- }
- else if (this.results.fail > 0 || this.results.timeout > 0) {
- originalExit(1);
- }
-
- originalExit(0);
-};
-
-var driver = new Driver();
-
-var originalExit = process.exit;
-process.exit = function(code) {
- // this function is called when the following happens.
- // 1. the test case is finished normally.
- // 2. assertion inside the callback function is failed.
- var should_fail = driver.runner.test['expected-failure'];
- try {
- process.emitExit(code);
- } catch(e) {
- // when assertion inside the process.on('exit', function { ... }) is failed,
- // this procedure is executed.
- process.removeAllListeners('exit');
-
- if (should_fail) {
- driver.runner.finish('pass');
- } else {
- console.error(e);
- driver.runner.finish('fail');
- }
- } finally {
- process.removeAllListeners('exit');
-
- if (code != 0 && !should_fail) {
- driver.runner.finish('fail');
- } else if (code == 0 && should_fail) {
- driver.runner.finish('fail');
- } else {
- driver.runner.finish('pass');
- }
- }
-};
-
-var conf = driver.config();
-if (conf) {
- watch.delta();
- driver.runNextTest();
-}
import os
import subprocess
import tempfile
+import re
from distutils import spawn
def parse_option():
parser = argparse.ArgumentParser()
parser.add_argument('--autoedit', action='store_true', default=False,
- help='Automatically edit the detected clang format errors.'
+ help='Automatically edit the detected clang format and eslint errors.'
'No diffs will be displayed')
option = parser.parse_args()
self.count_lines = 0
self.count_empty_lines = 0
self.errors = []
+ self.rules = []
+ self.err_msgs = []
@property
def error_count(self):
line = fileinput.filelineno()
self.errors.append("%s:%d: %s" % (name, line, msg))
+ def set_rules(self):
+ limit = StyleChecker.column_limit
+ self.rules.append(re.compile(r"[\t]"))
+ self.err_msgs.append("TAB character")
+ self.rules.append(re.compile(r"[\r]"))
+ self.err_msgs.append("CR character")
+ self.rules.append(re.compile(r"[ \t]+[\n]$"))
+ self.err_msgs.append("Trailing Whitespace")
+ self.rules.append(re.compile(r"[^\n]\Z"))
+ self.err_msgs.append("Line ends without NEW LINE character")
+ self.rules.append(re.compile("^.{" + str(limit+1) + ",}"))
+ self.err_msgs.append("Line exceeds %d characters" % limit)
+ # append additional rules
+
def check(self, files):
for line in fileinput.input(files):
- if '\t' in line:
- self.report_error('TAB character')
- if '\r' in line:
- self.report_error('CR character')
- if line.endswith(' \n') or line.endswith('\t\n'):
- self.report_error('trailing whitespace')
- if not line.endswith('\n'):
- self.report_error('line ends without NEW LINE character')
-
- if len(line) - 1 > StyleChecker.column_limit:
- self.report_error('line exceeds %d characters'
- % StyleChecker.column_limit)
+ for i, rule in enumerate(self.rules):
+ mc = rule.search(line)
+ if mc:
+ self.report_error(self.err_msgs[i])
if fileinput.isfirstline():
if not CheckLicenser.check(fileinput.filename()):
self.report_error('incorrect license')
-
self.count_lines += 1
if not line.strip():
self.count_empty_lines += 1
args = ['-style=file', file]
if self._options and self._options.autoedit:
args.append('-i')
- output = ex.run_cmd_output(self._clang_format,
- args,
- quiet=True)
+ output = ex.check_run_cmd_output(self._clang_format,
+ args, quiet=True)
if output:
with tempfile.NamedTemporaryFile() as temp:
# the diff from that it. Otherwise nothing to do.
self.diffs.append(error.output.decode())
+class EslintChecker(object):
+
+ def __init__(self, options=None):
+ self._check_eslint()
+ self._options = options
+
+ def _check_eslint(self):
+ self._node = spawn.find_executable('node')
+ if not self._node:
+ print('%sNo node found.%s'
+ % (ex._TERM_RED, ex._TERM_EMPTY))
+ return
+
+ self._eslint = spawn.find_executable('node_modules/.bin/eslint')
+ if not self._eslint:
+ self._eslint = spawn.find_executable('eslint')
+ if not self._eslint:
+ print('%sNo eslint found.%s'
+ % (ex._TERM_RED, ex._TERM_EMPTY))
+
+ def check(self):
+ self.error_count = 0
+
+ if not self._node or not self._eslint:
+ return
+ args = ['src', '-f', 'codeframe']
+ if self._options and self._options.autoedit:
+ args.append('--fix')
+
+ output = ex.run_cmd_output(self._eslint, args, quiet=True)
+ match = re.search('(\d+) error', output)
+ if match:
+ self.error_count = int(match.group(1))
+
+ # Delete unnecessary error messages.
+ self.errors = output.split('\n')[:-4]
+
class FileFilter(object):
allowed_exts = ['.c', '.h', '.js', '.py', '.sh', '.cmake']
allowed_files = ['CMakeLists.txt']
clang_format_exts = ['.c', '.h']
- skip_dirs = ['deps', 'build', '.git', 'node_modules', 'coverage']
+ skip_dirs = ['deps', 'build', '.git', 'node_modules', 'coverage',
+ 'iotjs_modules', 'IoTjsApp']
skip_files = ['check_signed_off.sh', '__init__.py',
'iotjs_js.c', 'iotjs_js.h', 'iotjs_string_ext.inl.h',
"iotjs_module_inl.h",
]
style = StyleChecker()
+ style.set_rules()
clang = ClangFormat(clang_format_exts, skip_files, options)
+ eslint = EslintChecker(options)
file_filter = FileFilter(allowed_exts, allowed_files, skip_files)
files = fs.files_under(src_dir, skip_dirs, file_filter)
clang.check(files)
style.check(files)
+ eslint.check()
if clang.error_count:
print("Detected clang-format problems:")
print("\n".join(style.errors))
print()
- total_errors = style.error_count + clang.error_count
+ if eslint.error_count:
+ print("Detected eslint problems:")
+ print("\n".join(eslint.errors))
+ print()
+
+ total_errors = style.error_count + clang.error_count + eslint.error_count
print("* total lines of code: %d" % style.count_lines)
print("* total non-blank lines of code: %d" % style.count_valid_lines)
print("* style errors: %d" % style.error_count)
print("* clang-format errors: %d" % clang.error_count)
+ print("* eslint errors: %d" % eslint.error_count)
msg_color = ex._TERM_RED if total_errors > 0 else ex._TERM_GREEN
print("%s* total errors: %d%s" % (msg_color, total_errors, ex._TERM_EMPTY))
print()
- return total_errors == 0
+ if total_errors:
+ ex.fail("Failed tidy check")
# Root directory for http-parser submodule.
HTTPPARSER_ROOT = fs.join(DEPS_ROOT, 'http-parser')
-# checktest
-CHECKTEST_PATH = fs.join(TOOLS_ROOT, 'check_test.js')
-
# Build configuration file path.
BUILD_CONFIG_PATH = fs.join(PROJECT_ROOT, 'build.config')
if not quiet:
Executor.print_cmd_line(cmd, args)
try:
+ process = subprocess.Popen([cmd] + args, stdout=subprocess.PIPE)
+ output = process.communicate()[0]
+
+ return output
+ except OSError as e:
+ Executor.fail("[Failed - %s] %s" % (cmd, e.strerror))
+
+ @staticmethod
+ def check_run_cmd_output(cmd, args=[], quiet=False):
+ if not quiet:
+ Executor.print_cmd_line(cmd, args)
+ try:
return subprocess.check_output([cmd] + args)
except OSError as e:
Executor.fail("[Failed - %s] %s" % (cmd, e.strerror))
--- /dev/null
+#!/usr/bin/env python
+
+# Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+from __future__ import print_function
+
+import os
+import re
+
+IOTJS_BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
+TEMPLATE_BASE_DIR = os.path.join(os.path.dirname(__file__), 'module_templates')
+MODULE_NAME_RE = "^[a-z0-9][a-z0-9\._]*$"
+
+def load_templates(template_dir):
+ for root, dirs, files in os.walk(template_dir):
+ for fp in files:
+ yield os.path.relpath(os.path.join(root, fp), template_dir)
+
+
+def replace_contents(input_file, module_name):
+ with open(input_file) as fp:
+ data = fp.read()
+ data = data.replace("$MODULE_NAME$", module_name)
+ data = data.replace("$IOTJS_PATH$", IOTJS_BASE_DIR)
+
+ return data
+
+def create_module(output_dir, module_name, template_dir, template_files):
+ module_path = os.path.join(output_dir, module_name)
+ print("Creating module in {}".format(module_path))
+
+ if os.path.exists(module_path):
+ print("Module path ({}) already exists! Exiting".format(module_path))
+ return False
+
+ for file_name in template_files:
+ file_path = os.path.join(template_dir, file_name)
+ print("loading template file: {}".format(file_path))
+ contents = replace_contents(file_path, module_name)
+ output_path = os.path.join(module_path, file_name)
+
+ # create sub-dir if required
+ base_dir = os.path.dirname(output_path)
+ if not os.path.exists(base_dir):
+ os.mkdir(base_dir)
+
+ with open(output_path, "w") as fp:
+ fp.write(contents)
+
+ return True
+
+def valid_module_name(value):
+ if not re.match(MODULE_NAME_RE, value):
+ msg = "Invalid module name, should match regexp: %s" % MODULE_NAME_RE
+ raise argparse.ArgumentTypeError(msg)
+ return value
+
+if __name__ == "__main__":
+ import argparse
+ import sys
+
+ desc = "Create an IoT.js external module using a template"
+ parser = argparse.ArgumentParser(description=desc)
+ parser.add_argument("module_name", metavar="<MODULE NAME>", nargs=1,
+ type=valid_module_name,
+ help="name of the new module ((must be in lowercase " +
+ "and should match regexp: %s)" % MODULE_NAME_RE)
+ parser.add_argument("--path", default=".",
+ help="directory where the module will be created " +
+ "(default: %(default)s)")
+ parser.add_argument("--template", default="basic",
+ choices=["basic", "shared"],
+ help="type of the template which should be used "
+ "(default: %(default)s)")
+ args = parser.parse_args()
+
+
+ template_dir = os.path.join(TEMPLATE_BASE_DIR,
+ "%s_module_template" % args.template)
+ template_files = load_templates(template_dir)
+ created = create_module(args.path,
+ args.module_name[0],
+ template_dir,
+ template_files)
+ if created:
+ module_path = os.path.join(args.path, args.module_name[0])
+ print("Module created in: {}".format(os.path.abspath(module_path)))
def parse_literals(code):
- JERRY_SNAPSHOT_VERSION = 8
+ JERRY_SNAPSHOT_VERSION = 12
JERRY_SNAPSHOT_MAGIC = 0x5952524A
literals = set()
ret = subprocess.call([snapshot_tool,
"generate",
- "--context", "eval",
"-o", snapshot_path,
wrapped_path])
echo " --node-modules-dir Specifies the node_module directory, where"
echo " the nodejs dependencies are installed."
echo ""
- echo " --testdriver Specifies the testrunner that should be used"
- echo " for measuring JavaScript coverage."
- echo " Possible values: jsdriver, pydriver"
- echo ""
echo " --target-board Specifies the target board, where the"
echo " coverage measurement will happen."
echo " Possible values: rpi2"
exit 1
}
-# Use Python based testrunner by default.
-test_driver="pydriver"
-
# Parse the given arguments.
while [[ $# -gt 0 ]]
do
node_modules_dir="$2"
shift
;;
- --testdriver)
- test_driver="$2"
- shift
- ;;
--target-board)
target_board="$2"
shift
fi
# Run the appropriate testrunner.
-if [ $test_driver = "jsdriver" ];
-then
- ${build_path}/bin/iotjs tools/check_test.js output-coverage=yes
-elif [ $test_driver = "pydriver" ];
-then
- python tools/testrunner.py ${build_path}/bin/iotjs --quiet --coverage
-else
- fail_with_msg "Not supported testdriver: $test_driver"
-fi
+python tools/testrunner.py ${build_path}/bin/iotjs --quiet --coverage
# Revert to original module files
rm -rf src/js
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * To export an object/value use the 'module.exports' object.
+ */
+var demo_value = "Hello";
+
+/* Export an object with two properties. */
+module.exports = {
+ /* the 'native' means the object returned by the C init method. */
+ demo2: function() { return native.message; },
+ add: native.add
+}
+
+/* Export a local variable. */
+module.exports.demo_value = demo_value;
--- /dev/null
+# Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# General variables usable from IoT.js cmake:
+# - TARGET_ARCH - the target architecture (as specified during cmake step)
+# - TARGET_BOARD - the target board(/device)
+# - TARGET_OS - the target operating system
+#
+# Module related variables usable from IoT.js cmake:
+# - MODULE_DIR - the modules root directory
+# - MODULE_BINARY_DIR - the build directory for the current module
+# - MODULE_LIBS - list of libraries to use during linking (set this)
+set(MODULE_NAME "$MODULE_NAME$")
+
+# DO NOT include the source files which are already in the modules.json file.
+
+# If the module builds its own files into a lib please use the line below.
+# Note: the subdir 'lib' should contain the CMakeLists.txt describing how the
+# module should be built.
+#add_subdirectory(${MODULE_DIR}/lib/ ${MODULE_BINARY_DIR}/${MODULE_NAME})
+
+# If you wish to link external libraries please add it to
+# the MODULE_LIBS list.
+#
+# IMPORTANT!
+# if the module builds its own library that should also be specified!
+#
+# Example (to add the 'demo' library for linking):
+#
+# list(APPEND MODULE_LIBS demo)
--- /dev/null
+{
+ "modules": {
+ "$MODULE_NAME$": {
+ "js_file": "js/module.js",
+ "native_files": ["src/module.c"],
+ "init": "Init$MODULE_NAME$",
+ "cmakefile": "module.cmake"
+ }
+ }
+}
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "iotjs_def.h"
+
+/**
+ * Demo method
+ */
+static jerry_value_t demo_method(
+ const jerry_value_t func_value, /**< function object */
+ const jerry_value_t this_value, /**< this arg */
+ const jerry_value_t *args_p, /**< function arguments */
+ const jerry_length_t args_cnt) /**< number of function arguments */
+{
+ if (args_cnt < 2) {
+ static char *error_msg = "Incorrect parameter count";
+ return jerry_create_error(JERRY_ERROR_TYPE,
+ (const jerry_char_t *)error_msg);
+ }
+
+ if (!jerry_value_is_number(args_p[0]) || !jerry_value_is_number(args_p[1])) {
+ static char *error_msg = "Incorrect parameter type(s)";
+ return jerry_create_error(JERRY_ERROR_TYPE,
+ (const jerry_char_t *)error_msg);
+ }
+
+ int arg_a = jerry_get_number_value(args_p[0]);
+ int arg_b = jerry_get_number_value(args_p[1]);
+
+ return jerry_create_number(arg_a + arg_b);
+}
+
+/**
+ * Init method called by IoT.js
+ */
+jerry_value_t Init$MODULE_NAME$() {
+ jerry_value_t mymodule = jerry_create_object();
+ iotjs_jval_set_property_string_raw(mymodule, "message", "Hello world!");
+ iotjs_jval_set_method(mymodule, "add", demo_method);
+ return mymodule;
+}
--- /dev/null
+# Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# This is a standalone shared libray which
+# only requires the iotjs and jerry header file(s).
+#
+cmake_minimum_required(VERSION 2.8)
+set(NAME $MODULE_NAME$)
+
+set(IOTJS_INCLUDE_DIR "$IOTJS_PATH$/src")
+set(JERRY_INCLUDE_DIR "$IOTJS_PATH$/deps/jerry/jerry-core/include")
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
+
+add_library(${NAME} SHARED
+ src/module_entry.c)
+target_include_directories(${NAME}
+ PRIVATE ${IOTJS_INCLUDE_DIR} ${JERRY_INCLUDE_DIR})
+set_target_properties(${NAME} PROPERTIES
+ PREFIX ""
+ SUFFIX ".iotjs")
--- /dev/null
+# IoT.js module: $MODULE_NAME$
+
+## How to build?
+
+In the source directory of the module:
+
+```sh
+$ cmake -Bbuild -H.
+$ make -C build
+```
+
+## How to test?
+
+In the source directory of the module:
+
+```sh
+$ iotjs js/test.js
+```
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var console = require("console");
+var demomod = require("build/lib/$MODULE_NAME$");
+
+console.log(demomod);
+
--- /dev/null
+/* Copyright 2018-present Samsung Electronics Co., Ltd. and other contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iotjs_binding.h>
+
+jerry_value_t init_$MODULE_NAME$(void) {
+ jerry_value_t object = jerry_create_object();
+
+ jerry_value_t prop_name = jerry_create_string((const jerry_char_t*)"demokey");
+ jerry_value_t prop_value = jerry_create_number(3.4);
+
+ jerry_set_property(object, prop_name, prop_value);
+
+ jerry_release_value(prop_name);
+ jerry_release_value(prop_value);
+
+ return object;
+}
+
+IOTJS_MODULE(IOTJS_CURRENT_MODULE_VERSION, 1, $MODULE_NAME$)
+++ /dev/null
-/* Copyright 2016-present Samsung Electronics Co., Ltd. and other contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var assert = require('assert');
-var util = require('util');
-var testdriver = require('testdriver');
-var console_wrapper = require('common_js/module/console');
-var builtin_modules = Object.keys(process.builtin_modules);
-
-function Runner(driver) {
- this.driver = driver;
- this.test = driver.currentTest();
- this.finished = false;
- if (driver.skipModule) {
- this.skipModule = driver.skipModule;
- this.skipModuleLength = this.skipModule.length;
- } else {
- this.skipModuleLength = 0;
- }
- if (driver.options.quiet == 'yes') {
- this.console = console;
- console = console_wrapper;
- }
-
- this.timeout = this.test['timeout'];
- if (!this.timeout) {
- this.timeout = driver.options['default-timeout'];
- }
- assert.assert(util.isNumber(this.timeout), "Timeout is not a number.");
-
- return this;
-}
-
-Runner.prototype.cleanup = function() {
- if (this.driver.options.quiet == 'yes') {
- console = this.console;
- }
-
- this.driver = null;
- this.test = null;
- if (this.timer != null) {
- clearTimeout(this.timer);
- this.timer = null;
- }
- if (this.timer_spin != null) {
- clearTimeout(this.timer_spin);
- this.timer_spin = null;
- }
-};
-
-Runner.prototype.spin = function() {
- var that = this;
- this.timer_spin = setTimeout(function() {
- var timerOnlyAlive = !testdriver.isAliveExceptFor(that.timer);
- if (timerOnlyAlive) {
- timerOnlyAlive = !process._onNextTick();
- }
-
- if (timerOnlyAlive) {
- process.exit(0);
- } else {
- if (!that.finished) {
- that.spin();
- }
- }
- }, 0);
-};
-
-Runner.prototype.checkSkipModule = function() {
- for (var i = 0; i < this.skipModuleLength; i++) {
- if (this.test['name'].indexOf(this.skipModule[i]) >= 0) {
- return true;
- }
- }
-
- return false;
-};
-
-Runner.prototype.checkSupportedModule = function() {
- // Cut off the '.js' ending
- var name = this.test['name'].slice(0, -3);
-
- // test_mod_smt -> [test, mod, smt]
- // test_modsmt -> [test, modsmt]
- var parts = name.split('_');
- if (parts[0] != 'test') {
- // test filename does not start with 'test_' so we'll just
- // assume we support it.
- return true;
- }
-
- // The second part of the array contains the module
- // which is under test
- var tested_module = parts[1];
- for (var i = 0; i < builtin_modules.length; i++) {
- if (tested_module == builtin_modules[i]) {
- return true;
- }
- }
-
- // In any other case we do not support this js file.
- return false;
-}
-
-Runner.prototype.run = function() {
- if (!this.checkSupportedModule()) {
- this.test.reason = 'unsupported module by iotjs build';
- this.finish('skip');
- return;
- }
-
- var skip = this.test['skip'];
- if (skip) {
- if ((skip.indexOf('all') >= 0) || (skip.indexOf(this.driver.os) >= 0)
- || (skip.indexOf(this.driver.stability) >= 0)) {
- this.finish('skip');
- return;
- }
- }
-
- if (this.skipModuleLength && this.checkSkipModule()) {
- this.test.reason = 'exclude module';
- this.finish('skip');
- return;
- }
-
- this.timer = null;
-
- var that = this;
- this.timer = setTimeout(function () {
- that.finish('timeout');
- }, this.timeout * 1000);
-
- try {
- var source = this.driver.test();
- eval(source);
- } catch(e) {
- if (this.test['expected-failure']) {
- this.finish('pass');
- } else if (this.test['uncaught']) {
- throw e;
- } else {
- console.error(e);
- this.finish('fail');
- }
- } finally {
- if (!this.finished) {
- this.spin();
- }
- }
-};
-
-Runner.prototype.finish = function(status) {
- if (this.finished)
- return;
-
- this.finished = true;
- process._exiting = false;
-
- this.driver.emitter.emit('nextTest', this.driver, status, this.test);
-};
-
-module.exports.Runner = Runner;
import argparse
import json
+import os
import signal
import subprocess
import sys
from common_py.system.filesystem import FileSystem as fs
from common_py.system.executor import Executor as ex
from common_py.system.platform import Platform
+from jsonmerge import Merger
# Defines the folder that will contain the coverage info.
"""
)
+JSON_SCHEMA = {
+ "properties": {
+ "run_pass": {
+ "mergeStrategy": "arrayMergeById",
+ "mergeOptions": { "idRef": "name"}
+ }
+ }
+}
# Append coverage source to the appropriate test.
def append_coverage_code(testfile, coverage):
def __init__(self, options):
self.iotjs = fs.abspath(options.iotjs)
self.quiet = options.quiet
+ self.testsets = options.testsets
self.timeout = options.timeout
self.valgrind = options.valgrind
self.coverage = options.coverage
self.skip_modules = []
self.results = {}
+ self._environment = os.environ.copy()
+ self._environment["IOTJS_PATH"] = fs.dirname(self.iotjs)
if options.skip_modules:
self.skip_modules = options.skip_modules.split(",")
# Process the iotjs build information.
- iotjs_output = ex.run_cmd_output(self.iotjs, [path.BUILD_INFO_PATH])
+ iotjs_output = ex.check_run_cmd_output(self.iotjs,
+ [path.BUILD_INFO_PATH])
build_info = json.loads(iotjs_output)
self.builtins = build_info["builtins"]
with open(fs.join(path.TEST_ROOT, "testsets.json")) as testsets_file:
testsets = json.load(testsets_file, object_pairs_hook=OrderedDict)
+ if self.testsets:
+ with open(fs.join(path.TEST_ROOT, self.testsets)) as testsets_file:
+ ext_testsets = json.load(testsets_file,
+ object_pairs_hook=OrderedDict)
+ merger = Merger(JSON_SCHEMA)
+ testsets = merger.merge(testsets, ext_testsets)
+
for testset, tests in testsets.items():
self.run_testset(testset, tests)
if not self.quiet:
print(output, end="")
- if not expected_failure or (expected_failure and exitcode <= 2):
+ is_normal_run = (not expected_failure and exitcode == 0)
+ is_expected_fail = (expected_failure and exitcode <= 2)
+ if is_normal_run or is_expected_fail:
Reporter.report_pass(test["name"], runtime)
self.results["pass"] += 1
else:
process = subprocess.Popen(args=command,
cwd=path.TEST_ROOT,
stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
+ stderr=subprocess.STDOUT,
+ env=self._environment)
stdout = process.communicate()[0]
exitcode = process.returncode
help="show or hide the output of the tests")
parser.add_argument("--skip-modules", action="store", metavar='list',
help="module list to skip test of specific modules")
+ parser.add_argument("--testsets", action="store",
+ help="JSON file to extend or override the default "
+ "testsets")
parser.add_argument("--timeout", action="store", default=300, type=int,
help="default timeout for the tests in seconds")
parser.add_argument("--valgrind", action="store_true", default=False,
TRAVIS_BUILD_PATH = fs.join(os.environ['TRAVIS_BUILD_DIR'])
# IoT.js path in docker
-DOCKER_IOTJS_PATH = fs.join(DOCKER_ROOT_PATH, 'iotjs')
+DOCKER_IOTJS_PATH = fs.join(DOCKER_ROOT_PATH, 'work_space/iotjs')
DOCKER_TIZENRT_PATH = fs.join(DOCKER_ROOT_PATH, 'TizenRT')
DOCKER_TIZENRT_OS_PATH = fs.join(DOCKER_TIZENRT_PATH, 'os')
'--no-check-valgrind',
'--no-snapshot',
'--profile=test/profiles/host-linux.profile',
+ '--testsets=testsets-host-linux.json',
+ '--run-test=full',
'--target-arch=i686'
]
def run_docker():
- ex.check_run_cmd('docker', ['run', '-dit', '--name', DOCKER_NAME, '-v',
+ ex.check_run_cmd('docker', ['run', '-dit', '--privileged',
+ '--name', DOCKER_NAME, '-v',
'%s:%s' % (TRAVIS_BUILD_PATH, DOCKER_IOTJS_PATH),
- 'iotjs/ubuntu:0.3'])
+ 'iotjs/ubuntu:0.6'])
def exec_docker(cwd, cmd):
exec_cmd = 'cd %s && ' % cwd + ' '.join(cmd)
test = os.getenv('OPTS')
if test == 'host-linux':
- build_iotjs('debug', [
- '--profile=profiles/minimal.profile'])
+ for buildtype in BUILDTYPES:
+ build_iotjs(buildtype, [
+ '--cmake-param=-DENABLE_MODULE_ASSERT=ON',
+ '--run-test=full',
+ '--profile=profiles/minimal.profile',
+ '--testsets=testsets-minimal.json'])
for buildtype in BUILDTYPES:
build_iotjs(buildtype, [
- '--run-test',
- '--profile=test/profiles/host-linux.profile'])
+ '--run-test=full',
+ '--profile=test/profiles/host-linux.profile',
+ '--testsets=testsets-host-linux.json'])
elif test == 'rpi2':
for buildtype in BUILDTYPES:
if buildtype == 'release':
set_release_config_tizenrt()
exec_docker(DOCKER_TIZENRT_OS_PATH, [
- 'make', 'IOTJS_ROOT_DIR=../../iotjs',
+ 'make', 'IOTJS_ROOT_DIR=' + DOCKER_IOTJS_PATH,
'IOTJS_BUILD_OPTION='
'--profile=test/profiles/tizenrt.profile'])
'make', 'all',
'IOTJS_ROOT_DIR=' + DOCKER_IOTJS_PATH, rflag])
+ elif test == 'tizen':
+ for buildtype in BUILDTYPES:
+ if buildtype == "debug":
+ exec_docker(DOCKER_IOTJS_PATH, [
+ 'config/tizen/gbsbuild.sh',
+ '--debug', '--clean'])
+ else:
+ exec_docker(DOCKER_IOTJS_PATH, ['config/tizen/gbsbuild.sh',
+ '--clean'])
+
elif test == "misc":
ex.check_run_cmd('tools/check_signed_off.sh', ['--travis'])
- if not check_tidy(TRAVIS_BUILD_PATH):
- ex.fail("Failed tidy check")
+ exec_docker(DOCKER_IOTJS_PATH, ['tools/check_tidy.py'])
elif test == "external-modules":
for buildtype in BUILDTYPES:
build_iotjs(buildtype, [
- '--run-test',
+ '--run-test=full',
+ '--testsets=testsets-external-modules.json',
'--profile=test/profiles/host-linux.profile',
'--external-modules=test/external_modules/'
'mymodule1,test/external_modules/mymodule2',
'--cmake-param=-DENABLE_MODULE_MYMODULE1=ON',
'--cmake-param=-DENABLE_MODULE_MYMODULE2=ON'])
- binary = fs.join('build',
- platform.arch() + '-' + platform.os(),
- buildtype, 'bin', 'iotjs')
- ext_mod_tests = [
- 'test/external_modules/test_external_module1.js',
- 'test/external_modules/test_external_module2.js']
- # TODO: Use testrunner to run an extended test set
- for test in ext_mod_tests:
- exec_docker(DOCKER_IOTJS_PATH, [binary, test])
+
+ elif test == 'es2015':
+ for buildtype in BUILDTYPES:
+ build_iotjs(buildtype, [
+ '--run-test=full',
+ '--jerry-profile=es2015-subset',
+ '--testsets=testsets-es2015.json'])
elif test == "no-snapshot":
for buildtype in BUILDTYPES:
- build_iotjs(buildtype, ['--run-test', '--no-snapshot',
+ build_iotjs(buildtype, ['--run-test=full', '--no-snapshot',
'--jerry-lto'])
elif test == "host-darwin":
for buildtype in BUILDTYPES:
ex.check_run_cmd('./tools/build.py', [
- '--run-test',
+ '--run-test=full',
'--buildtype=' + buildtype,
'--clean',
- '--profile=test/profiles/host-darwin.profile'])
+ '--profile=test/profiles/host-darwin.profile',
+ '--testsets=testsets-host-linux.json'])
elif test == "asan":
ex.check_run_cmd('./tools/build.py', [