mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Merge remote-tracking branch 'mbedtls/development' into montgomery-keys-clarification
This commit is contained in:
5
tests/.gitignore
vendored
5
tests/.gitignore
vendored
@ -8,4 +8,7 @@ data_files/hmac_drbg_seed
|
||||
data_files/ctr_drbg_seed
|
||||
data_files/entropy_seed
|
||||
|
||||
/instrument_record_status.h
|
||||
include/test/instrument_record_status.h
|
||||
|
||||
src/*.o
|
||||
src/libmbed*
|
||||
|
@ -17,9 +17,8 @@ if(ENABLE_ZLIB_SUPPORT)
|
||||
set(libs ${libs} ${ZLIB_LIBRARIES})
|
||||
endif(ENABLE_ZLIB_SUPPORT)
|
||||
|
||||
find_package(PythonInterp)
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
message(FATAL_ERROR "Cannot build test suites without Python 2 or 3")
|
||||
if(NOT MBEDTLS_PYTHON_EXECUTABLE)
|
||||
message(FATAL_ERROR "Cannot build test suites without Python 3")
|
||||
endif()
|
||||
|
||||
# Enable definition of various functions used throughout the testsuite
|
||||
@ -43,13 +42,20 @@ function(add_test_suite suite_name)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT test_suite_${data_name}.c
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py -f ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function -d ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data -t ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function -p ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function -s ${CMAKE_CURRENT_SOURCE_DIR}/suites --helpers-file ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function -o .
|
||||
COMMAND ${MBEDTLS_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py -f ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function -d ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data -t ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function -p ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function -s ${CMAKE_CURRENT_SOURCE_DIR}/suites --helpers-file ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function -o .
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py mbedtls ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data
|
||||
)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
add_executable(test_suite_${data_name} test_suite_${data_name}.c)
|
||||
add_executable(test_suite_${data_name} test_suite_${data_name}.c $<TARGET_OBJECTS:mbedtls_test>)
|
||||
target_link_libraries(test_suite_${data_name} ${libs})
|
||||
# Include test-specific header files from ./include and private header
|
||||
# files (used by some invasive tests) from ../library. Public header
|
||||
# files are automatically included because the library targets declare
|
||||
# them as PUBLIC.
|
||||
target_include_directories(test_suite_${data_name}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../library)
|
||||
|
||||
if(${data_name} MATCHES ${SKIP_TEST_SUITES_REGEX})
|
||||
message(STATUS "The test suite ${data_name} will not be executed.")
|
||||
else()
|
||||
|
@ -6,7 +6,10 @@ CFLAGS ?= -O2
|
||||
WARNING_CFLAGS ?= -Wall -Wextra
|
||||
LDFLAGS ?=
|
||||
|
||||
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -I../library -D_FILE_OFFSET_BITS=64
|
||||
# Include public header files from ../include, test-specific header files
|
||||
# from ./include, and private header files (used by some invasive tests)
|
||||
# from ../library.
|
||||
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I./include -I../include -I../library -D_FILE_OFFSET_BITS=64
|
||||
LOCAL_LDFLAGS = -L../library \
|
||||
-lmbedtls$(SHARED_SUFFIX) \
|
||||
-lmbedx509$(SHARED_SUFFIX) \
|
||||
@ -21,9 +24,9 @@ LOCAL_CFLAGS+=$(THIRDPARTY_INCLUDES)
|
||||
LOCAL_CFLAGS += -D_POSIX_C_SOURCE=200809L
|
||||
|
||||
ifndef SHARED
|
||||
DEP=../library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a
|
||||
MBEDLIBS=../library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a
|
||||
else
|
||||
DEP=../library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT)
|
||||
MBEDLIBS=../library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT)
|
||||
endif
|
||||
|
||||
ifdef DEBUG
|
||||
@ -74,9 +77,18 @@ BINARIES := $(addsuffix $(EXEXT),$(APPS))
|
||||
|
||||
all: $(BINARIES)
|
||||
|
||||
$(DEP):
|
||||
$(MBEDLIBS):
|
||||
$(MAKE) -C ../library
|
||||
|
||||
MBEDTLS_TEST_OBJS=$(patsubst %.c,%.o,$(wildcard src/*.c))
|
||||
|
||||
mbedtls_test: $(MBEDTLS_TEST_OBJS)
|
||||
|
||||
# Rule to compile common test C files in src folder
|
||||
src/%.o : src/%.c
|
||||
echo " CC $<"
|
||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
C_FILES := $(addsuffix .c,$(APPS))
|
||||
|
||||
# Wildcard target for test code generation:
|
||||
@ -105,23 +117,26 @@ C_FILES := $(addsuffix .c,$(APPS))
|
||||
-o .
|
||||
|
||||
|
||||
$(BINARIES): %$(EXEXT): %.c $(DEP)
|
||||
$(BINARIES): %$(EXEXT): %.c $(MBEDLIBS) $(MBEDTLS_TEST_OBJS)
|
||||
echo " CC $<"
|
||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(MBEDTLS_TEST_OBJS) $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
# Some test suites require additional header files.
|
||||
$(filter test_suite_psa_crypto%, $(BINARIES)): psa_crypto_helpers.h
|
||||
$(filter test_suite_psa_crypto%, $(BINARIES)): include/test/psa_crypto_helpers.h
|
||||
$(addprefix embedded_,$(filter test_suite_psa_crypto%, $(APPS))): embedded_%: TESTS/mbedtls/%/psa_crypto_helpers.h
|
||||
$(filter test_suite_psa_%, $(BINARIES)): psa_helpers.h
|
||||
$(filter test_suite_psa_%, $(BINARIES)): include/test/psa_helpers.h
|
||||
$(addprefix embedded_,$(filter test_suite_psa_%, $(APPS))): embedded_%: TESTS/mbedtls/%/psa_helpers.h
|
||||
|
||||
clean:
|
||||
ifndef WINDOWS
|
||||
rm -rf $(BINARIES) *.c *.datax TESTS
|
||||
rm -f src/*.o src/libmbed*
|
||||
else
|
||||
if exist *.c del /Q /F *.c
|
||||
if exist *.exe del /Q /F *.exe
|
||||
if exist *.datax del /Q /F *.datax
|
||||
if exist src/*.o del /Q /F src/*.o
|
||||
if exist src/libmbed* del /Q /F src/libmed*
|
||||
ifneq ($(wildcard TESTS/.*),)
|
||||
rmdir /Q /S TESTS
|
||||
endif
|
||||
@ -152,7 +167,7 @@ $(EMBEDDED_TESTS): embedded_%: suites/$$(firstword $$(subst ., ,$$*)).function s
|
||||
generate-target-tests: $(EMBEDDED_TESTS)
|
||||
|
||||
define copy_header_to_target
|
||||
TESTS/mbedtls/$(1)/$(2): $(2)
|
||||
TESTS/mbedtls/$(1)/$(2): include/test/$(2)
|
||||
echo " Copy ./$$@"
|
||||
ifndef WINDOWS
|
||||
mkdir -p $$(@D)
|
||||
@ -163,11 +178,11 @@ else
|
||||
endif
|
||||
|
||||
endef
|
||||
$(foreach app, $(APPS), $(foreach file, $(wildcard *.h), \
|
||||
$(foreach app, $(APPS), $(foreach file, $(notdir $(wildcard include/test/*.h)), \
|
||||
$(eval $(call copy_header_to_target,$(app),$(file)))))
|
||||
|
||||
ifdef RECORD_PSA_STATUS_COVERAGE_LOG
|
||||
$(BINARIES): instrument_record_status.h
|
||||
instrument_record_status.h: ../include/psa/crypto.h Makefile
|
||||
$(BINARIES): include/test/instrument_record_status.h
|
||||
include/test/instrument_record_status.h: ../include/psa/crypto.h Makefile
|
||||
sed <../include/psa/crypto.h >$@ -n 's/^psa_status_t \([A-Za-z0-9_]*\)(.*/#define \1(...) RECORD_STATUS("\1", \1(__VA_ARGS__))/p'
|
||||
endif
|
||||
|
@ -2,9 +2,22 @@
|
||||
|
||||
# compat.sh
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2012-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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
|
@ -2,9 +2,22 @@
|
||||
|
||||
# context-info.sh
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2012-2020, 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 program is intended for testing the ssl_context_info program
|
||||
#
|
||||
|
@ -1,2 +1,2 @@
|
||||
// TLS-RSA-WITH-AES-256-CCM-8
|
||||
AhUAAH8AAA4AAAQ8AAAAAF6K4ynAoQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADLBIQUrrPh7jxYz9e55cJvfpOkuBf2ZiVovlYa1Dkwbimp5q/CoWIn48C0x3Yj6N0AAAAAAAM7MIIDNzCCAh+gAwIBAgIBAjANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDERMA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcNMTkwMjEwMTQ0NDA2WhcNMjkwMjEwMTQ0NDA2WjA0MQswCQYDVQQGEwJOTDERMA8GA1UECgwIUG9sYXJTU0wxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMFNo93nzR3RBNdJcriZrA545Do8Ss86ExbQWuTNowCIp+4ea5anUrSQ7y1yej4kmvy2NKwk9XfgJmSMnLAofaHa6ozmyRyWvP7BBFKzNtSj+uGxdtiQwWG0ZlI2oiZTqqt0Xgd9GYLbKtgfoNkNHC1JZvdbJXNG6AuKT2kMtQCQ4dqCEGZ9rlQri2V5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Mgy1NR
|
||||
5RbzoLMOxq7hoOCyIaQeM/wgxeGE
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEAnQS0JLb8Dqy8V2mszkWkV8c/NPQcG3ivueXZHqOT9JTiPqri
|
||||
gGcLHtlmlaJ0aUUxix7q60aOds041TFyeknTSUFYY4ppOhiP+fOpWKPv4ZMwhSI2
|
||||
XzcgYhQSNHV0lIG1we9RAAfumomDMq7oMJhbEGf0ihibbwZXPUwBlm10GaB4K93P
|
||||
NY8Bz4ekBxzQ1WJkQ5LGsQnVZSuLnvp5dWSeJ2axxyY4hPXR30jzEyZvy4kv4nzA
|
||||
u5lqZ5XKLrRO4TKwZrtr+CCPVkPJRE36rWYttQaJEEpNOo0ZPpTtG6F8/tGh5r8j
|
||||
Fx/f6wG+nyANJJ98kEP8i6TPjRrg+697mLcdiQIDAQABAoIBAF7i3MnjGmbz080v
|
||||
OxJb23iAG54wdlvTjr3UPGTbjSmcXyxnsADQRFQcJHYAekCzY8EiqewL80OvuMx8
|
||||
2SU1P81hA70Dg5tsBHWT3Z6HUwsKG6QYjKr1cUhTwLyazhyAVgogSN6v7GzO9M3I
|
||||
DOBw8Xb0mz5oqGVre4S7TapN8n8ZG5oWm0XKGACXy0KbzY0KvWdkUzumFQ8X/ARE
|
||||
FsWyu+O69EbMqZRUKu45SrcubsdVGjOwseZHkmp5V6pc6Q/OrTHZqXJtDva5UIRq
|
||||
+Lof5scy9jiwwRnM/klvh23mz0ySU4YA3645m5KqyWR4YJCR1MnMANmXUSeYWfYz
|
||||
19+R1gECgYEAzm83lI7eIhTH38H0/jFpf3R7vNjPX3TR5waa4EXsCxhTOpoL89mR
|
||||
iNmzH0aOC4OR8rz/9PCnwmtH1lyQ4r/RokBmCp3pBxeWSlenFfV3rLCeEDo0Q/OL
|
||||
SX5DL4IbZD0VmNDt606WS7AEv93GhpN03Anw6kgHQUm1l030PR9DYZECgYEAwrgO
|
||||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niynd8dgPOML
|
||||
pA7GUfv5k2mMkMbSD15pTMgcavrBKYgyqcvF1C3qghfoL5+i38H8sKzF8hy7wHtE
|
||||
ESHtBq20RYA3m0UcA0e64GcanO2Ps/AQVBc7qMeHbqnqj3uUhtTkQcMUWnMgy1NR
|
||||
5RbzoLMOxq7hoOCyIaQeM/wgxeGE
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEAnQS0JLb8Dqy8V2mszkWkV8c/NPQcG3ivueXZHqOT9JTiPqri
|
||||
gGcLHtlmlaJ0aUUxix7q60aOds041TFyeknTSUFYY4ppOhiP+fOpWKPv4ZMwhSI2
|
||||
XzcgYhQSNHV0lIG1we9RAAfumomDMq7oMJhbEGf0ihibbwZXPUwBlm10GaB4K93P
|
||||
NY8Bz4ekBxzQ1WJkQ5LGsQnVZSuLnvp5dWSeJ2axxyY4hPXR30jzEyZvy4kv4nzA
|
||||
u5lqZ5XKLrRO4TKwZrtr+CCPVkPJRE36rWYttQaJEEpNOo0ZPpTtG6F8/tGh5r8j
|
||||
Fx/f6wG+nyANJJ98kEP8i6TPjRrg+697mLcdiQIDAQABAoIBAF7i3MnjGmbz080v
|
||||
OxJb23iAG54wdlvTjr3UPGTbjSmcXyxnsADQRFQcJHYAekCzY8EiqewL80OvuMx8
|
||||
2SU1P81hA70Dg5tsBHWT3Z6HUwsKG6QYjKr1cUhTwLyazhyAVgogSN6v7GzO9M3I
|
||||
DOBw8Xb0mz5oqGVre4S7TapN8n8ZG5oWm0XKGACXy0KbzY0KvWdkUzumFQ8X/ARE
|
||||
FsWyu+O69EbMqZRUKu45SrcubsdVGjOwseZHkmp5V6pc6Q/OrTHZqXJtDva5UIRq
|
||||
+Lof5scy9jiwwRnM/klvh23mz0ySU4YA3645m5KqyWR4YJCR1MnMANmXUSeYWfYz
|
||||
19+R1gECgYEAzm83lI7eIhTH38H0/jFpf3R7vNjPX3TR5waa4EXsCxhTOpoL89mR
|
||||
iNmzH0aOC4OR8rz/9PCnwmtH1lyQ4r/RokBmCp3pBxeWSlenFfV3rLCeEDo0Q/OL
|
||||
SX5DL4IbZD0VmNDt606WS7AEv93GhpN03Anw6kgHQUm1l030PR9DYZECgYEAwrgO
|
||||
/RyB/Ehw7smlysZb2sn1lvd6z8fg+pcu8ZNRKODaYCCOb8p1lnHrnIQdEmjhlmVp
|
||||
HAEuJ5jxCb+lyruV+dlx+0W/p6lHtKr0iBHG8EFkHnjN6Y+59Qu0HfSm0pZw7Ftr
|
||||
QcUDPuDJkTVUAvrZqciWlwzTWCC9KYXtasT+AHkCgYEAnP80dAUbpyvKvr/RxShr
|
||||
JYW/PWZegChmIp+BViOXWvDLC3xwrqm+5yc59QVBrjwH2WYn+26zB0dzwPFxNyHP
|
||||
GuiDMnvZ54zmve9foXGn7Gv+KjU53pvwSJqAGjeHAXr7W9c5uoVwBGv/kLPn8h1e
|
||||
+KGO2X6iFeMq+cFNiNan9iECgYBj+oGnsKWFVeS2ls8LyMGNGzmAZF2opiZ8RHgU
|
||||
DeIULS+zP8Qi3j92GdQyLxuGQlfiEvvfJzP9nOfWa5LC/4JIIUAHFo8LlT1+JHEe
|
||||
FJKi9dBkXP7NN8DxcyruXpnxctFUarQttuytslmMt2cFiKuOI7I+qJUzoMu/sEZx
|
||||
FeidcQKBgQCuralmtbl4nxjn3aR/ZgFTAKCL9WaJPh5hFJ9q4UuWxJdBX5z3Ey3/
|
||||
70ehLKYPumjmZtXynzz4BTWj1W9X+tgj/499uzV6LdQERGjT6WVy8xR9RELWW0an
|
||||
N9N1IAc4qTSjbI4EIMwMBSAoFfCux/jfDkG4g+RDnpV92sqxz2CtKg==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
@ -1,4 +1,21 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 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)
|
||||
|
||||
set -eu
|
||||
|
||||
|
@ -1,4 +1,22 @@
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
# Copyright (C) 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)
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[ ca ]
|
||||
default_ca = test-ca
|
||||
|
||||
|
||||
[ test-ca ]
|
||||
certificate = test-ca.crt
|
||||
private_key = test-ca.key
|
||||
|
@ -1,9 +1,22 @@
|
||||
#!/bin/sh
|
||||
# pre-push.sh
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
@ -32,18 +45,4 @@ 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
|
||||
run_test ./tests/scripts/check-files.py
|
||||
run_test ./tests/scripts/doxygen.sh
|
||||
tests/scripts/all.sh -q -k 'check_*'
|
||||
|
108
tests/include/test/helpers.h
Normal file
108
tests/include/test/helpers.h
Normal file
@ -0,0 +1,108 @@
|
||||
/**
|
||||
* \file helpers.h
|
||||
*
|
||||
* \brief This file contains the prototypes of helper functions for the
|
||||
* purpose of testing.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020, 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 TEST_HELPERS_H
|
||||
#define TEST_HELPERS_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define mbedtls_fprintf fprintf
|
||||
#define mbedtls_snprintf snprintf
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#define mbedtls_exit exit
|
||||
#define mbedtls_time time
|
||||
#define mbedtls_time_t time_t
|
||||
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int mbedtls_test_platform_setup( void );
|
||||
void mbedtls_test_platform_teardown( void );
|
||||
|
||||
/**
|
||||
* \brief This function translates an ASCII string encoding an
|
||||
* hexadecimal number into the encoded hexadecimal number. The
|
||||
* hexadecimal number is represented as an array of
|
||||
* unsigned char.
|
||||
*
|
||||
* \note The output buffer can be the same as the input buffer. For
|
||||
* any other overlapping of the input and output buffers, the
|
||||
* behavior is undefined.
|
||||
*
|
||||
* \param obuf Output buffer.
|
||||
* \param obufmax Size in number of bytes of \p obuf.
|
||||
* \param ibuf Input buffer.
|
||||
* \param len The number of unsigned char written in \p obuf. This must
|
||||
* not be \c NULL.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return \c -1 if the output buffer is too small or the input string
|
||||
* is not a valid ASCII encoding of an hexadecimal number.
|
||||
*/
|
||||
int mbedtls_test_unhexify( unsigned char *obuf, size_t obufmax,
|
||||
const char *ibuf, size_t *len );
|
||||
|
||||
void mbedtls_test_hexify( unsigned char *obuf,
|
||||
const unsigned char *ibuf,
|
||||
int len );
|
||||
|
||||
/**
|
||||
* Allocate and zeroize a buffer.
|
||||
*
|
||||
* If the size if zero, a pointer to a zeroized 1-byte buffer is returned.
|
||||
*
|
||||
* For convenience, dies if allocation fails.
|
||||
*/
|
||||
unsigned char *mbedtls_test_zero_alloc( size_t len );
|
||||
|
||||
/**
|
||||
* Allocate and fill a buffer from hex data.
|
||||
*
|
||||
* The buffer is sized exactly as needed. This allows to detect buffer
|
||||
* overruns (including overreads) when running the test suite under valgrind.
|
||||
*
|
||||
* If the size if zero, a pointer to a zeroized 1-byte buffer is returned.
|
||||
*
|
||||
* For convenience, dies if allocation fails.
|
||||
*/
|
||||
unsigned char *mbedtls_test_unhexify_alloc( const char *ibuf, size_t *olen );
|
||||
|
||||
int mbedtls_test_hexcmp( uint8_t * a, uint8_t * b,
|
||||
uint32_t a_len, uint32_t b_len );
|
||||
|
||||
#endif /* TEST_HELPERS_H */
|
138
tests/include/test/macros.h
Normal file
138
tests/include/test/macros.h
Normal file
@ -0,0 +1,138 @@
|
||||
/**
|
||||
* \file macros.h
|
||||
*
|
||||
* \brief This file contains generic macros for the purpose of testing.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020, 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 TEST_MACROS_H
|
||||
#define TEST_MACROS_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#define mbedtls_fprintf fprintf
|
||||
#define mbedtls_snprintf snprintf
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#define mbedtls_exit exit
|
||||
#define mbedtls_time time
|
||||
#define mbedtls_time_t time_t
|
||||
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||
#include "mbedtls/memory_buffer_alloc.h"
|
||||
#endif
|
||||
|
||||
#define TEST_HELPER_ASSERT(a) if( !( a ) ) \
|
||||
{ \
|
||||
mbedtls_fprintf( stderr, "Assertion Failed at %s:%d - %s\n", \
|
||||
__FILE__, __LINE__, #a ); \
|
||||
mbedtls_exit( 1 ); \
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
/* Test if arg and &(arg)[0] have the same type. This is true if arg is
|
||||
* an array but not if it's a pointer. */
|
||||
#define IS_ARRAY_NOT_POINTER( arg ) \
|
||||
( ! __builtin_types_compatible_p( __typeof__( arg ), \
|
||||
__typeof__( &( arg )[0] ) ) )
|
||||
#else
|
||||
/* On platforms where we don't know how to implement this check,
|
||||
* omit it. Oh well, a non-portable check is better than nothing. */
|
||||
#define IS_ARRAY_NOT_POINTER( arg ) 1
|
||||
#endif
|
||||
|
||||
/* A compile-time constant with the value 0. If `const_expr` is not a
|
||||
* compile-time constant with a nonzero value, cause a compile-time error. */
|
||||
#define STATIC_ASSERT_EXPR( const_expr ) \
|
||||
( 0 && sizeof( struct { int STATIC_ASSERT : 1 - 2 * ! ( const_expr ); } ) )
|
||||
/* Return the scalar value `value` (possibly promoted). This is a compile-time
|
||||
* constant if `value` is. `condition` must be a compile-time constant.
|
||||
* If `condition` is false, arrange to cause a compile-time error. */
|
||||
#define STATIC_ASSERT_THEN_RETURN( condition, value ) \
|
||||
( STATIC_ASSERT_EXPR( condition ) ? 0 : ( value ) )
|
||||
|
||||
#define ARRAY_LENGTH_UNSAFE( array ) \
|
||||
( sizeof( array ) / sizeof( *( array ) ) )
|
||||
/** Return the number of elements of a static or stack array.
|
||||
*
|
||||
* \param array A value of array (not pointer) type.
|
||||
*
|
||||
* \return The number of elements of the array.
|
||||
*/
|
||||
#define ARRAY_LENGTH( array ) \
|
||||
( STATIC_ASSERT_THEN_RETURN( IS_ARRAY_NOT_POINTER( array ), \
|
||||
ARRAY_LENGTH_UNSAFE( array ) ) )
|
||||
|
||||
/** Return the smaller of two values.
|
||||
*
|
||||
* \param x An integer-valued expression without side effects.
|
||||
* \param y An integer-valued expression without side effects.
|
||||
*
|
||||
* \return The smaller of \p x and \p y.
|
||||
*/
|
||||
#define MIN( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
|
||||
|
||||
/** Return the larger of two values.
|
||||
*
|
||||
* \param x An integer-valued expression without side effects.
|
||||
* \param y An integer-valued expression without side effects.
|
||||
*
|
||||
* \return The larger of \p x and \p y.
|
||||
*/
|
||||
#define MAX( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
#ifndef GET_UINT32_BE
|
||||
#define GET_UINT32_BE(n,b,i) \
|
||||
{ \
|
||||
(n) = ( (uint32_t) (b)[(i) ] << 24 ) \
|
||||
| ( (uint32_t) (b)[(i) + 1] << 16 ) \
|
||||
| ( (uint32_t) (b)[(i) + 2] << 8 ) \
|
||||
| ( (uint32_t) (b)[(i) + 3] ); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef PUT_UINT32_BE
|
||||
#define PUT_UINT32_BE(n,b,i) \
|
||||
{ \
|
||||
(b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
|
||||
(b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
|
||||
(b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
|
||||
(b)[(i) + 3] = (unsigned char) ( (n) ); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TEST_MACROS_H */
|
@ -1,7 +1,8 @@
|
||||
/*
|
||||
* Helper functions for tests that use the PSA Crypto API.
|
||||
*/
|
||||
/* Copyright (C) 2019, ARM Limited, All Rights Reserved
|
||||
/*
|
||||
* Copyright (C) 2019, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@ -22,7 +23,7 @@
|
||||
#ifndef PSA_CRYPTO_HELPERS_H
|
||||
#define PSA_CRYPTO_HELPERS_H
|
||||
|
||||
#include "psa_helpers.h"
|
||||
#include "test/psa_helpers.h"
|
||||
|
||||
#include <psa/crypto.h>
|
||||
|
@ -1,7 +1,8 @@
|
||||
/*
|
||||
* Helper functions for tests that use any PSA API.
|
||||
*/
|
||||
/* Copyright (C) 2019, ARM Limited, All Rights Reserved
|
||||
/*
|
||||
* Copyright (C) 2019, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
107
tests/include/test/random.h
Normal file
107
tests/include/test/random.h
Normal file
@ -0,0 +1,107 @@
|
||||
/**
|
||||
* \file random.h
|
||||
*
|
||||
* \brief This file contains the prototypes of helper functions to generate
|
||||
* random numbers for the purpose of testing.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020, 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 TEST_RANDOM_H
|
||||
#define TEST_RANDOM_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "mbedtls/config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char *buf;
|
||||
size_t length;
|
||||
} mbedtls_test_rnd_buf_info;
|
||||
|
||||
/**
|
||||
* Info structure for the pseudo random function
|
||||
*
|
||||
* Key should be set at the start to a test-unique value.
|
||||
* Do not forget endianness!
|
||||
* State( v0, v1 ) should be set to zero.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t key[16];
|
||||
uint32_t v0, v1;
|
||||
} mbedtls_test_rnd_pseudo_info;
|
||||
|
||||
/**
|
||||
* This function just returns data from rand().
|
||||
* Although predictable and often similar on multiple
|
||||
* runs, this does not result in identical random on
|
||||
* each run. So do not use this if the results of a
|
||||
* test depend on the random data that is generated.
|
||||
*
|
||||
* rng_state shall be NULL.
|
||||
*/
|
||||
int mbedtls_test_rnd_std_rand( void *rng_state,
|
||||
unsigned char *output,
|
||||
size_t len );
|
||||
|
||||
/**
|
||||
* This function only returns zeros
|
||||
*
|
||||
* rng_state shall be NULL.
|
||||
*/
|
||||
int mbedtls_test_rnd_zero_rand( void *rng_state,
|
||||
unsigned char *output,
|
||||
size_t len );
|
||||
|
||||
/**
|
||||
* This function returns random based on a buffer it receives.
|
||||
*
|
||||
* rng_state shall be a pointer to a rnd_buf_info structure.
|
||||
*
|
||||
* The number of bytes released from the buffer on each call to
|
||||
* the random function is specified by per_call. (Can be between
|
||||
* 1 and 4)
|
||||
*
|
||||
* After the buffer is empty it will return rand();
|
||||
*/
|
||||
int mbedtls_test_rnd_buffer_rand( void *rng_state,
|
||||
unsigned char *output,
|
||||
size_t len );
|
||||
|
||||
/**
|
||||
* This function returns random based on a pseudo random function.
|
||||
* This means the results should be identical on all systems.
|
||||
* Pseudo random is based on the XTEA encryption algorithm to
|
||||
* generate pseudorandom.
|
||||
*
|
||||
* rng_state shall be a pointer to a rnd_pseudo_info structure.
|
||||
*/
|
||||
int mbedtls_test_rnd_pseudo_rand( void *rng_state,
|
||||
unsigned char *output,
|
||||
size_t len );
|
||||
|
||||
#endif /* TEST_RANDOM_H */
|
@ -2,9 +2,22 @@
|
||||
|
||||
# all.sh
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2014-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)
|
||||
|
||||
|
||||
|
||||
@ -120,8 +133,17 @@ pre_initialize_variables () {
|
||||
append_outcome=0
|
||||
MEMORY=0
|
||||
FORCE=0
|
||||
QUIET=0
|
||||
KEEP_GOING=0
|
||||
|
||||
# Seed value used with the --release-test option.
|
||||
#
|
||||
# See also RELEASE_SEED in basic-build-test.sh. Debugging is easier if
|
||||
# both values are kept in sync. If you change the value here because it
|
||||
# breaks some tests, you'll definitely want to change it in
|
||||
# basic-build-test.sh as well.
|
||||
RELEASE_SEED=1
|
||||
|
||||
: ${MBEDTLS_TEST_OUTCOME_FILE=}
|
||||
: ${MBEDTLS_TEST_PLATFORM="$(uname -s | tr -c \\n0-9A-Za-z _)-$(uname -m | tr -c \\n0-9A-Za-z _)"}
|
||||
export MBEDTLS_TEST_OUTCOME_FILE
|
||||
@ -200,6 +222,7 @@ Special options:
|
||||
--list-components List components supported on this platform and exit.
|
||||
|
||||
General options:
|
||||
-q|--quiet Only output component names, and errors if any.
|
||||
-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.
|
||||
@ -215,11 +238,12 @@ General options:
|
||||
--no-force Refuse to overwrite modified files (default).
|
||||
--no-keep-going Stop at the first error (default).
|
||||
--no-memory No additional memory tests (default).
|
||||
--no-quiet Print full ouput from components.
|
||||
--out-of-source-dir=<path> Directory used for CMake out-of-source build tests.
|
||||
--outcome-file=<path> File where test outcomes are written (not done if
|
||||
empty; default: \$MBEDTLS_TEST_OUTCOME_FILE).
|
||||
--random-seed Use a random seed value for randomized tests (default).
|
||||
-r|--release-test Run this script in release mode. This fixes the seed value to 1.
|
||||
-r|--release-test Run this script in release mode. This fixes the seed value to ${RELEASE_SEED}.
|
||||
-s|--seed Integer seed value to use for this test run.
|
||||
|
||||
Tool path options:
|
||||
@ -288,6 +312,11 @@ msg()
|
||||
else
|
||||
current_section="$1"
|
||||
fi
|
||||
|
||||
if [ $QUIET -eq 1 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "******************************************************************"
|
||||
echo "* $current_section "
|
||||
@ -363,13 +392,15 @@ pre_parse_command_line () {
|
||||
--no-force) FORCE=0;;
|
||||
--no-keep-going) KEEP_GOING=0;;
|
||||
--no-memory) MEMORY=0;;
|
||||
--no-quiet) QUIET=0;;
|
||||
--openssl) shift; OPENSSL="$1";;
|
||||
--openssl-legacy) shift; OPENSSL_LEGACY="$1";;
|
||||
--openssl-next) shift; OPENSSL_NEXT="$1";;
|
||||
--outcome-file) shift; MBEDTLS_TEST_OUTCOME_FILE="$1";;
|
||||
--out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";;
|
||||
--quiet|-q) QUIET=1;;
|
||||
--random-seed) unset SEED;;
|
||||
--release-test|-r) SEED=1;;
|
||||
--release-test|-r) SEED=$RELEASE_SEED;;
|
||||
--seed|-s) shift; SEED="$1";;
|
||||
-*)
|
||||
echo >&2 "Unknown option: $1"
|
||||
@ -449,7 +480,7 @@ pre_setup_keep_going () {
|
||||
failure_summary="$failure_summary
|
||||
$text"
|
||||
failure_count=$((failure_count + 1))
|
||||
echo "${start_red}^^^^$text^^^^${end_color}"
|
||||
echo "${start_red}^^^^$text^^^^${end_color}" >&2
|
||||
fi
|
||||
}
|
||||
make () {
|
||||
@ -495,6 +526,24 @@ not() {
|
||||
! "$@"
|
||||
}
|
||||
|
||||
pre_setup_quiet_redirect () {
|
||||
if [ $QUIET -ne 1 ]; then
|
||||
redirect_out () {
|
||||
"$@"
|
||||
}
|
||||
redirect_err () {
|
||||
"$@"
|
||||
}
|
||||
else
|
||||
redirect_out () {
|
||||
"$@" >/dev/null
|
||||
}
|
||||
redirect_err () {
|
||||
"$@" 2>/dev/null
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
pre_prepare_outcome_file () {
|
||||
case "$MBEDTLS_TEST_OUTCOME_FILE" in
|
||||
[!/]*) MBEDTLS_TEST_OUTCOME_FILE="$PWD/$MBEDTLS_TEST_OUTCOME_FILE";;
|
||||
@ -505,6 +554,10 @@ pre_prepare_outcome_file () {
|
||||
}
|
||||
|
||||
pre_print_configuration () {
|
||||
if [ $QUIET -eq 1 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
msg "info: $0 configuration"
|
||||
echo "MEMORY: $MEMORY"
|
||||
echo "FORCE: $FORCE"
|
||||
@ -579,6 +632,11 @@ pre_check_tools () {
|
||||
"$ARMC6_CC" "$ARMC6_AR" "$ARMC6_FROMELF";;
|
||||
esac
|
||||
|
||||
# past this point, no call to check_tool, only printing output
|
||||
if [ $QUIET -eq 1 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
msg "info: output_env.sh"
|
||||
case $RUN_COMPONENTS in
|
||||
*_armcc*)
|
||||
@ -622,7 +680,19 @@ component_check_doxy_blocks () {
|
||||
|
||||
component_check_files () {
|
||||
msg "Check: file sanity checks (permissions, encodings)" # < 1s
|
||||
record_status tests/scripts/check-files.py
|
||||
record_status tests/scripts/check_files.py
|
||||
}
|
||||
|
||||
component_check_changelog () {
|
||||
msg "Check: changelog entries" # < 1s
|
||||
rm -f ChangeLog.new
|
||||
record_status scripts/assemble_changelog.py -o ChangeLog.new
|
||||
if [ -e ChangeLog.new ]; then
|
||||
# Show the diff for information. It isn't an error if the diff is
|
||||
# non-empty.
|
||||
diff -u ChangeLog ChangeLog.new || true
|
||||
rm ChangeLog.new
|
||||
fi
|
||||
}
|
||||
|
||||
component_check_names () {
|
||||
@ -632,7 +702,13 @@ component_check_names () {
|
||||
|
||||
component_check_test_cases () {
|
||||
msg "Check: test case descriptions" # < 1s
|
||||
record_status tests/scripts/check-test-cases.py
|
||||
if [ $QUIET -eq 1 ]; then
|
||||
opt='--quiet'
|
||||
else
|
||||
opt=''
|
||||
fi
|
||||
record_status tests/scripts/check_test_cases.py $opt
|
||||
unset opt
|
||||
}
|
||||
|
||||
component_check_doxygen_warnings () {
|
||||
@ -819,6 +895,77 @@ component_test_rsa_no_crt () {
|
||||
if_build_succeeded tests/context-info.sh
|
||||
}
|
||||
|
||||
component_test_no_ctr_drbg () {
|
||||
msg "build: Full minus CTR_DRBG"
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_CTR_DRBG_C
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires CTR_DRBG
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_SE_C # requires PSA Crypto
|
||||
scripts/config.py unset MBEDTLS_USE_PSA_CRYPTO # requires PSA Crypto
|
||||
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: no CTR_DRBG"
|
||||
make test
|
||||
|
||||
# no ssl-opt.sh/compat.sh as they all depend on CTR_DRBG so far
|
||||
}
|
||||
|
||||
component_test_no_hmac_drbg () {
|
||||
msg "build: Full minus HMAC_DRBG"
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_HMAC_DRBG_C
|
||||
scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
|
||||
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: no HMAC_DRBG"
|
||||
make test
|
||||
|
||||
# No ssl-opt.sh/compat.sh as they never use HMAC_DRBG so far,
|
||||
# so there's little value in running those lengthy tests here.
|
||||
}
|
||||
|
||||
component_test_ecp_no_internal_rng () {
|
||||
msg "build: Default plus ECP_NO_INTERNAL_RNG minus DRBG modules"
|
||||
scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
|
||||
scripts/config.py unset MBEDTLS_CTR_DRBG_C
|
||||
scripts/config.py unset MBEDTLS_HMAC_DRBG_C
|
||||
scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires a DRBG
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
|
||||
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: ECP_NO_INTERNAL_RNG, no DRBG module"
|
||||
make test
|
||||
|
||||
# no SSL tests as they all depend on having a DRBG
|
||||
}
|
||||
|
||||
component_test_ecp_restartable_no_internal_rng () {
|
||||
msg "build: Default plus ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG"
|
||||
scripts/config.py set MBEDTLS_ECP_NO_INTERNAL_RNG
|
||||
scripts/config.py set MBEDTLS_ECP_RESTARTABLE
|
||||
scripts/config.py unset MBEDTLS_CTR_DRBG_C
|
||||
scripts/config.py unset MBEDTLS_HMAC_DRBG_C
|
||||
scripts/config.py unset MBEDTLS_ECDSA_DETERMINISTIC # requires HMAC_DRBG
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_C # requires CTR_DRBG
|
||||
scripts/config.py unset MBEDTLS_PSA_CRYPTO_STORAGE_C # requires PSA Crypto
|
||||
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
|
||||
msg "test: ECP_RESTARTABLE and ECP_NO_INTERNAL_RNG, no DRBG module"
|
||||
make test
|
||||
|
||||
# no SSL tests as they all depend on having a DRBG
|
||||
}
|
||||
|
||||
component_test_new_ecdh_context () {
|
||||
msg "build: new ECDH context (ASan build)" # ~ 6 min
|
||||
scripts/config.py unset MBEDTLS_ECDH_LEGACY_CONTEXT
|
||||
@ -1701,6 +1848,15 @@ component_test_allow_sha1 () {
|
||||
if_build_succeeded tests/ssl-opt.sh -f SHA-1
|
||||
}
|
||||
|
||||
component_test_tls13_experimental () {
|
||||
msg "build: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
|
||||
scripts/config.pl set MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL
|
||||
CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan .
|
||||
make
|
||||
msg "test: default config with MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL enabled"
|
||||
make test
|
||||
}
|
||||
|
||||
component_build_mingw () {
|
||||
msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s
|
||||
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
|
||||
@ -1843,7 +1999,10 @@ component_check_python_files () {
|
||||
|
||||
component_check_generate_test_code () {
|
||||
msg "uint test: generate_test_code.py"
|
||||
record_status ./tests/scripts/test_generate_test_code.py
|
||||
# unittest writes out mundane stuff like number or tests run on stderr.
|
||||
# Our convention is to reserve stderr for actual errors, and write
|
||||
# harmless info on stdout so it can be suppress with --quiet.
|
||||
record_status ./tests/scripts/test_generate_test_code.py 2>&1
|
||||
}
|
||||
|
||||
################################################################
|
||||
@ -1874,13 +2033,18 @@ run_component () {
|
||||
# Unconditionally create a seedfile that's sufficiently long.
|
||||
# Do this before each component, because a previous component may
|
||||
# have messed it up or shortened it.
|
||||
dd if=/dev/urandom of=./tests/seedfile bs=64 count=1
|
||||
redirect_err dd if=/dev/urandom of=./tests/seedfile bs=64 count=1
|
||||
|
||||
# Run the component code.
|
||||
"$@"
|
||||
if [ $QUIET -eq 1 ]; then
|
||||
# msg() is silenced, so just print the component name here
|
||||
echo "${current_component#component_}"
|
||||
fi
|
||||
redirect_out "$@"
|
||||
|
||||
# Restore the build tree to a clean state.
|
||||
cleanup
|
||||
unset current_component
|
||||
}
|
||||
|
||||
# Preliminary setup
|
||||
@ -1898,6 +2062,7 @@ else
|
||||
"$@"
|
||||
}
|
||||
fi
|
||||
pre_setup_quiet_redirect
|
||||
pre_prepare_outcome_file
|
||||
pre_print_configuration
|
||||
pre_check_tools
|
||||
|
131
tests/scripts/analyze_outcomes.py
Executable file
131
tests/scripts/analyze_outcomes.py
Executable file
@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Analyze the test outcomes from a full CI run.
|
||||
|
||||
This script can also run on outcomes from a partial run, but the results are
|
||||
less likely to be useful.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
import check_test_cases
|
||||
|
||||
class Results:
|
||||
"""Process analysis results."""
|
||||
|
||||
def __init__(self):
|
||||
self.error_count = 0
|
||||
self.warning_count = 0
|
||||
|
||||
@staticmethod
|
||||
def log(fmt, *args, **kwargs):
|
||||
sys.stderr.write((fmt + '\n').format(*args, **kwargs))
|
||||
|
||||
def error(self, fmt, *args, **kwargs):
|
||||
self.log('Error: ' + fmt, *args, **kwargs)
|
||||
self.error_count += 1
|
||||
|
||||
def warning(self, fmt, *args, **kwargs):
|
||||
self.log('Warning: ' + fmt, *args, **kwargs)
|
||||
self.warning_count += 1
|
||||
|
||||
class TestCaseOutcomes:
|
||||
"""The outcomes of one test case across many configurations."""
|
||||
# pylint: disable=too-few-public-methods
|
||||
|
||||
def __init__(self):
|
||||
# Collect a list of witnesses of the test case succeeding or failing.
|
||||
# Currently we don't do anything with witnesses except count them.
|
||||
# The format of a witness is determined by the read_outcome_file
|
||||
# function; it's the platform and configuration joined by ';'.
|
||||
self.successes = []
|
||||
self.failures = []
|
||||
|
||||
def hits(self):
|
||||
"""Return the number of times a test case has been run.
|
||||
|
||||
This includes passes and failures, but not skips.
|
||||
"""
|
||||
return len(self.successes) + len(self.failures)
|
||||
|
||||
class TestDescriptions(check_test_cases.TestDescriptionExplorer):
|
||||
"""Collect the available test cases."""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.descriptions = set()
|
||||
|
||||
def process_test_case(self, _per_file_state,
|
||||
file_name, _line_number, description):
|
||||
"""Record an available test case."""
|
||||
base_name = re.sub(r'\.[^.]*$', '', re.sub(r'.*/', '', file_name))
|
||||
key = ';'.join([base_name, description.decode('utf-8')])
|
||||
self.descriptions.add(key)
|
||||
|
||||
def collect_available_test_cases():
|
||||
"""Collect the available test cases."""
|
||||
explorer = TestDescriptions()
|
||||
explorer.walk_all()
|
||||
return sorted(explorer.descriptions)
|
||||
|
||||
def analyze_coverage(results, outcomes):
|
||||
"""Check that all available test cases are executed at least once."""
|
||||
available = collect_available_test_cases()
|
||||
for key in available:
|
||||
hits = outcomes[key].hits() if key in outcomes else 0
|
||||
if hits == 0:
|
||||
# Make this a warning, not an error, as long as we haven't
|
||||
# fixed this branch to have full coverage of test cases.
|
||||
results.warning('Test case not executed: {}', key)
|
||||
|
||||
def analyze_outcomes(outcomes):
|
||||
"""Run all analyses on the given outcome collection."""
|
||||
results = Results()
|
||||
analyze_coverage(results, outcomes)
|
||||
return results
|
||||
|
||||
def read_outcome_file(outcome_file):
|
||||
"""Parse an outcome file and return an outcome collection.
|
||||
|
||||
An outcome collection is a dictionary mapping keys to TestCaseOutcomes objects.
|
||||
The keys are the test suite name and the test case description, separated
|
||||
by a semicolon.
|
||||
"""
|
||||
outcomes = {}
|
||||
with open(outcome_file, 'r', encoding='utf-8') as input_file:
|
||||
for line in input_file:
|
||||
(platform, config, suite, case, result, _cause) = line.split(';')
|
||||
key = ';'.join([suite, case])
|
||||
setup = ';'.join([platform, config])
|
||||
if key not in outcomes:
|
||||
outcomes[key] = TestCaseOutcomes()
|
||||
if result == 'PASS':
|
||||
outcomes[key].successes.append(setup)
|
||||
elif result == 'FAIL':
|
||||
outcomes[key].failures.append(setup)
|
||||
return outcomes
|
||||
|
||||
def analyze_outcome_file(outcome_file):
|
||||
"""Analyze the given outcome file."""
|
||||
outcomes = read_outcome_file(outcome_file)
|
||||
return analyze_outcomes(outcomes)
|
||||
|
||||
def main():
|
||||
try:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('outcomes', metavar='OUTCOMES.CSV',
|
||||
help='Outcome file to analyze')
|
||||
options = parser.parse_args()
|
||||
results = analyze_outcome_file(options.outcomes)
|
||||
if results.error_count > 0:
|
||||
sys.exit(1)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
# Print the backtrace and exit explicitly with our chosen status.
|
||||
traceback.print_exc()
|
||||
sys.exit(120)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -2,9 +2,22 @@
|
||||
|
||||
# basic-build-tests.sh
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
@ -43,6 +56,14 @@ fi
|
||||
: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"}
|
||||
: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"}
|
||||
|
||||
# Used to make ssl-opt.sh deterministic.
|
||||
#
|
||||
# See also RELEASE_SEED in all.sh. Debugging is easier if both values are kept
|
||||
# in sync. If you change the value here because it breaks some tests, you'll
|
||||
# definitely want to change it in all.sh as well.
|
||||
: ${SEED:=1}
|
||||
export SEED
|
||||
|
||||
# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh
|
||||
# we just export the variables they require
|
||||
export OPENSSL_CMD="$OPENSSL"
|
||||
@ -218,10 +239,12 @@ echo
|
||||
# Step 4e - Coverage
|
||||
echo "Coverage"
|
||||
|
||||
LINES_TESTED=$(tail -n3 cov-$TEST_OUTPUT|sed -n -e 's/ lines......: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* lines)/\1/p')
|
||||
LINES_TOTAL=$(tail -n3 cov-$TEST_OUTPUT|sed -n -e 's/ lines......: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) lines)/\1/p')
|
||||
FUNCS_TESTED=$(tail -n3 cov-$TEST_OUTPUT|sed -n -e 's/ functions..: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* functions)$/\1/p')
|
||||
FUNCS_TOTAL=$(tail -n3 cov-$TEST_OUTPUT|sed -n -e 's/ functions..: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) functions)$/\1/p')
|
||||
LINES_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ lines......: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* lines)/\1/p')
|
||||
LINES_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ lines......: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) lines)/\1/p')
|
||||
FUNCS_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ functions..: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* functions)$/\1/p')
|
||||
FUNCS_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ functions..: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) functions)$/\1/p')
|
||||
BRANCHES_TESTED=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ branches...: [0-9]*.[0-9]% (\([0-9]*\) of [0-9]* branches)$/\1/p')
|
||||
BRANCHES_TOTAL=$(tail -n4 cov-$TEST_OUTPUT|sed -n -e 's/ branches...: [0-9]*.[0-9]% ([0-9]* of \([0-9]*\) branches)$/\1/p')
|
||||
|
||||
LINES_PERCENT=$((1000*$LINES_TESTED/$LINES_TOTAL))
|
||||
LINES_PERCENT="$(($LINES_PERCENT/10)).$(($LINES_PERCENT-($LINES_PERCENT/10)*10))"
|
||||
@ -229,11 +252,14 @@ LINES_PERCENT="$(($LINES_PERCENT/10)).$(($LINES_PERCENT-($LINES_PERCENT/10)*10))
|
||||
FUNCS_PERCENT=$((1000*$FUNCS_TESTED/$FUNCS_TOTAL))
|
||||
FUNCS_PERCENT="$(($FUNCS_PERCENT/10)).$(($FUNCS_PERCENT-($FUNCS_PERCENT/10)*10))"
|
||||
|
||||
BRANCHES_PERCENT=$((1000*$BRANCHES_TESTED/$BRANCHES_TOTAL))
|
||||
BRANCHES_PERCENT="$(($BRANCHES_PERCENT/10)).$(($BRANCHES_PERCENT-($BRANCHES_PERCENT/10)*10))"
|
||||
|
||||
echo "Lines Tested : $LINES_TESTED of $LINES_TOTAL $LINES_PERCENT%"
|
||||
echo "Functions Tested : $FUNCS_TESTED of $FUNCS_TOTAL $FUNCS_PERCENT%"
|
||||
echo "Branches Tested : $BRANCHES_TESTED of $BRANCHES_TOTAL $BRANCHES_PERCENT%"
|
||||
echo
|
||||
|
||||
|
||||
rm unit-test-$TEST_OUTPUT
|
||||
rm sys-test-$TEST_OUTPUT
|
||||
rm compat-test-$TEST_OUTPUT
|
||||
|
@ -4,8 +4,10 @@
|
||||
#
|
||||
# Purpose
|
||||
# -------
|
||||
# This runs a rough equivalent of the travis.yml in a Docker container.
|
||||
# The tests are run for both clang and gcc.
|
||||
# This runs sanity checks and library tests in a Docker container. The tests
|
||||
# are run for both clang and gcc. The testing includes a full test run
|
||||
# in the default configuration, partial test runs in the reference
|
||||
# configurations, and some dependency tests.
|
||||
#
|
||||
# Notes for users
|
||||
# ---------------
|
||||
@ -30,12 +32,7 @@
|
||||
|
||||
source tests/scripts/docker_env.sh
|
||||
|
||||
run_in_docker tests/scripts/recursion.pl library/*.c
|
||||
run_in_docker tests/scripts/check-generated-files.sh
|
||||
run_in_docker tests/scripts/check-doxy-blocks.pl
|
||||
run_in_docker tests/scripts/check-names.sh
|
||||
run_in_docker tests/scripts/check-files.py
|
||||
run_in_docker tests/scripts/doxygen.sh
|
||||
run_in_docker tests/scripts/all.sh 'check_*'
|
||||
|
||||
for compiler in clang gcc; do
|
||||
run_in_docker -e CC=${compiler} cmake -D CMAKE_BUILD_TYPE:String="Check" .
|
||||
|
@ -7,6 +7,23 @@
|
||||
# sed -e '/EXTRACT/s/YES/NO/' doxygen/mbedtls.doxyfile | doxygen -
|
||||
# but that would warn about any undocumented item, while our goal is to find
|
||||
# items that are documented, but not marked as such by mistake.
|
||||
#
|
||||
# Copyright (C) 2012-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)
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
@ -1,8 +1,21 @@
|
||||
#! /usr/bin/env sh
|
||||
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2018, 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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
|
@ -1,8 +1,21 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2015-2019, 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)
|
||||
|
||||
set -eu
|
||||
|
||||
|
@ -1,8 +1,21 @@
|
||||
#! /usr/bin/env sh
|
||||
|
||||
# This file is part of Mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2018, 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)
|
||||
#
|
||||
# Purpose:
|
||||
#
|
||||
|
@ -1,136 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Sanity checks for test data.
|
||||
"""
|
||||
|
||||
# Copyright (C) 2019, 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)
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
class Results:
|
||||
"""Store file and line information about errors or warnings in test suites."""
|
||||
|
||||
def __init__(self, options):
|
||||
self.errors = 0
|
||||
self.warnings = 0
|
||||
self.ignore_warnings = options.quiet
|
||||
|
||||
def error(self, file_name, line_number, fmt, *args):
|
||||
sys.stderr.write(('{}:{}:ERROR:' + fmt + '\n').
|
||||
format(file_name, line_number, *args))
|
||||
self.errors += 1
|
||||
|
||||
def warning(self, file_name, line_number, fmt, *args):
|
||||
if not self.ignore_warnings:
|
||||
sys.stderr.write(('{}:{}:Warning:' + fmt + '\n')
|
||||
.format(file_name, line_number, *args))
|
||||
self.warnings += 1
|
||||
|
||||
def collect_test_directories():
|
||||
"""Get the relative path for the TLS and Crypto test directories."""
|
||||
if os.path.isdir('tests'):
|
||||
tests_dir = 'tests'
|
||||
elif os.path.isdir('suites'):
|
||||
tests_dir = '.'
|
||||
elif os.path.isdir('../suites'):
|
||||
tests_dir = '..'
|
||||
directories = [tests_dir]
|
||||
return directories
|
||||
|
||||
def check_description(results, seen, file_name, line_number, description):
|
||||
"""Check test case descriptions for errors."""
|
||||
if description in seen:
|
||||
results.error(file_name, line_number,
|
||||
'Duplicate description (also line {})',
|
||||
seen[description])
|
||||
return
|
||||
if re.search(br'[\t;]', description):
|
||||
results.error(file_name, line_number,
|
||||
'Forbidden character \'{}\' in description',
|
||||
re.search(br'[\t;]', description).group(0).decode('ascii'))
|
||||
if re.search(br'[^ -~]', description):
|
||||
results.error(file_name, line_number,
|
||||
'Non-ASCII character in description')
|
||||
if len(description) > 66:
|
||||
results.warning(file_name, line_number,
|
||||
'Test description too long ({} > 66)',
|
||||
len(description))
|
||||
seen[description] = line_number
|
||||
|
||||
def check_test_suite(results, data_file_name):
|
||||
"""Check the test cases in the given unit test data file."""
|
||||
in_paragraph = False
|
||||
descriptions = {}
|
||||
with open(data_file_name, 'rb') as data_file:
|
||||
for line_number, line in enumerate(data_file, 1):
|
||||
line = line.rstrip(b'\r\n')
|
||||
if not line:
|
||||
in_paragraph = False
|
||||
continue
|
||||
if line.startswith(b'#'):
|
||||
continue
|
||||
if not in_paragraph:
|
||||
# This is a test case description line.
|
||||
check_description(results, descriptions,
|
||||
data_file_name, line_number, line)
|
||||
in_paragraph = True
|
||||
|
||||
def check_ssl_opt_sh(results, file_name):
|
||||
"""Check the test cases in ssl-opt.sh or a file with a similar format."""
|
||||
descriptions = {}
|
||||
with open(file_name, 'rb') as file_contents:
|
||||
for line_number, line in enumerate(file_contents, 1):
|
||||
# Assume that all run_test calls have the same simple form
|
||||
# with the test description entirely on the same line as the
|
||||
# function name.
|
||||
m = re.match(br'\s*run_test\s+"((?:[^\\"]|\\.)*)"', line)
|
||||
if not m:
|
||||
continue
|
||||
description = m.group(1)
|
||||
check_description(results, descriptions,
|
||||
file_name, line_number, description)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--quiet', '-q',
|
||||
action='store_true',
|
||||
help='Hide warnings')
|
||||
parser.add_argument('--verbose', '-v',
|
||||
action='store_false', dest='quiet',
|
||||
help='Show warnings (default: on; undoes --quiet)')
|
||||
options = parser.parse_args()
|
||||
test_directories = collect_test_directories()
|
||||
results = Results(options)
|
||||
for directory in test_directories:
|
||||
for data_file_name in glob.glob(os.path.join(directory, 'suites',
|
||||
'*.data')):
|
||||
check_test_suite(results, data_file_name)
|
||||
ssl_opt_sh = os.path.join(directory, 'ssl-opt.sh')
|
||||
if os.path.exists(ssl_opt_sh):
|
||||
check_ssl_opt_sh(results, ssl_opt_sh)
|
||||
if (results.warnings or results.errors) and not options.quiet:
|
||||
sys.stderr.write('{}: {} errors, {} warnings\n'
|
||||
.format(sys.argv[0], results.errors, results.warnings))
|
||||
sys.exit(1 if results.errors else 0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,7 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# This file is part of Mbed TLS (https://tls.mbed.org)
|
||||
# Copyright (c) 2018, 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 script checks the current state of the source code for minor issues,
|
||||
@ -14,6 +28,8 @@ import os
|
||||
import argparse
|
||||
import logging
|
||||
import codecs
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
@ -23,28 +39,48 @@ class FileIssueTracker:
|
||||
To implement a checker that processes a file as a whole, inherit from
|
||||
this class and implement `check_file_for_issue` and define ``heading``.
|
||||
|
||||
``files_exemptions``: files whose name ends with a string in this set
|
||||
``suffix_exemptions``: files whose name ends with a string in this set
|
||||
will not be checked.
|
||||
|
||||
``path_exemptions``: files whose path (relative to the root of the source
|
||||
tree) matches this regular expression will not be checked. This can be
|
||||
``None`` to match no path. Paths are normalized and converted to ``/``
|
||||
separators before matching.
|
||||
|
||||
``heading``: human-readable description of the issue
|
||||
"""
|
||||
|
||||
files_exemptions = frozenset()
|
||||
suffix_exemptions = frozenset()
|
||||
path_exemptions = None
|
||||
# heading must be defined in derived classes.
|
||||
# pylint: disable=no-member
|
||||
|
||||
def __init__(self):
|
||||
self.files_with_issues = {}
|
||||
|
||||
@staticmethod
|
||||
def normalize_path(filepath):
|
||||
"""Normalize ``filepath`` with / as the directory separator."""
|
||||
filepath = os.path.normpath(filepath)
|
||||
# On Windows, we may have backslashes to separate directories.
|
||||
# We need slashes to match exemption lists.
|
||||
seps = os.path.sep
|
||||
if os.path.altsep is not None:
|
||||
seps += os.path.altsep
|
||||
return '/'.join(filepath.split(seps))
|
||||
|
||||
def should_check_file(self, filepath):
|
||||
"""Whether the given file name should be checked.
|
||||
|
||||
Files whose name ends with a string listed in ``self.files_exemptions``
|
||||
will not be checked.
|
||||
Files whose name ends with a string listed in ``self.suffix_exemptions``
|
||||
or whose path matches ``self.path_exemptions`` will not be checked.
|
||||
"""
|
||||
for files_exemption in self.files_exemptions:
|
||||
for files_exemption in self.suffix_exemptions:
|
||||
if filepath.endswith(files_exemption):
|
||||
return False
|
||||
if self.path_exemptions and \
|
||||
re.match(self.path_exemptions, self.normalize_path(filepath)):
|
||||
return False
|
||||
return True
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
@ -73,6 +109,17 @@ class FileIssueTracker:
|
||||
logger.info(filename)
|
||||
logger.info("")
|
||||
|
||||
BINARY_FILE_PATH_RE_LIST = [
|
||||
r'docs/.*\.pdf\Z',
|
||||
r'programs/fuzz/corpuses/[^.]+\Z',
|
||||
r'tests/data_files/[^.]+\Z',
|
||||
r'tests/data_files/.*\.(crt|csr|db|der|key|pubkey)\Z',
|
||||
r'tests/data_files/.*\.req\.[^/]+\Z',
|
||||
r'tests/data_files/.*malformed[^/]+\Z',
|
||||
r'tests/data_files/format_pkcs12\.fmt\Z',
|
||||
]
|
||||
BINARY_FILE_PATH_RE = re.compile('|'.join(BINARY_FILE_PATH_RE_LIST))
|
||||
|
||||
class LineIssueTracker(FileIssueTracker):
|
||||
"""Base class for line-by-line issue tracking.
|
||||
|
||||
@ -80,6 +127,9 @@ class LineIssueTracker(FileIssueTracker):
|
||||
this class and implement `line_with_issue`.
|
||||
"""
|
||||
|
||||
# Exclude binary files.
|
||||
path_exemptions = BINARY_FILE_PATH_RE
|
||||
|
||||
def issue_with_line(self, line, filepath):
|
||||
"""Check the specified line for the issue that this class is for.
|
||||
|
||||
@ -103,7 +153,7 @@ class LineIssueTracker(FileIssueTracker):
|
||||
|
||||
def is_windows_file(filepath):
|
||||
_root, ext = os.path.splitext(filepath)
|
||||
return ext in ('.bat', '.dsp', '.sln', '.vcxproj')
|
||||
return ext in ('.bat', '.dsp', '.dsw', '.sln', '.vcxproj')
|
||||
|
||||
|
||||
class PermissionIssueTracker(FileIssueTracker):
|
||||
@ -126,9 +176,18 @@ class EndOfFileNewlineIssueTracker(FileIssueTracker):
|
||||
|
||||
heading = "Missing newline at end of file:"
|
||||
|
||||
path_exemptions = BINARY_FILE_PATH_RE
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
with open(filepath, "rb") as f:
|
||||
if not f.read().endswith(b"\n"):
|
||||
try:
|
||||
f.seek(-1, 2)
|
||||
except OSError:
|
||||
# This script only works on regular files. If we can't seek
|
||||
# 1 before the end, it means that this position is before
|
||||
# the beginning of the file, i.e. that the file is empty.
|
||||
return
|
||||
if f.read(1) != b"\n":
|
||||
self.files_with_issues[filepath] = None
|
||||
|
||||
|
||||
@ -138,7 +197,8 @@ class Utf8BomIssueTracker(FileIssueTracker):
|
||||
|
||||
heading = "UTF-8 BOM present:"
|
||||
|
||||
files_exemptions = frozenset([".vcxproj", ".sln"])
|
||||
suffix_exemptions = frozenset([".vcxproj", ".sln"])
|
||||
path_exemptions = BINARY_FILE_PATH_RE
|
||||
|
||||
def check_file_for_issue(self, filepath):
|
||||
with open(filepath, "rb") as f:
|
||||
@ -152,6 +212,8 @@ class UnixLineEndingIssueTracker(LineIssueTracker):
|
||||
heading = "Non-Unix line endings:"
|
||||
|
||||
def should_check_file(self, filepath):
|
||||
if not super().should_check_file(filepath):
|
||||
return False
|
||||
return not is_windows_file(filepath)
|
||||
|
||||
def issue_with_line(self, line, _filepath):
|
||||
@ -164,6 +226,8 @@ class WindowsLineEndingIssueTracker(LineIssueTracker):
|
||||
heading = "Non-Windows line endings:"
|
||||
|
||||
def should_check_file(self, filepath):
|
||||
if not super().should_check_file(filepath):
|
||||
return False
|
||||
return is_windows_file(filepath)
|
||||
|
||||
def issue_with_line(self, line, _filepath):
|
||||
@ -174,7 +238,7 @@ class TrailingWhitespaceIssueTracker(LineIssueTracker):
|
||||
"""Track lines with trailing whitespace."""
|
||||
|
||||
heading = "Trailing whitespace:"
|
||||
files_exemptions = frozenset([".dsp", ".md"])
|
||||
suffix_exemptions = frozenset([".dsp", ".md"])
|
||||
|
||||
def issue_with_line(self, line, _filepath):
|
||||
return line.rstrip(b"\r\n") != line.rstrip()
|
||||
@ -184,7 +248,8 @@ class TabIssueTracker(LineIssueTracker):
|
||||
"""Track lines with tabs."""
|
||||
|
||||
heading = "Tabs present:"
|
||||
files_exemptions = frozenset([
|
||||
suffix_exemptions = frozenset([
|
||||
".pem", # some openssl dumps have tabs
|
||||
".sln",
|
||||
"/Makefile",
|
||||
"/Makefile.inc",
|
||||
@ -223,32 +288,6 @@ class IntegrityChecker:
|
||||
self.check_repo_path()
|
||||
self.logger = None
|
||||
self.setup_logger(log_file)
|
||||
self.extensions_to_check = (
|
||||
".bat",
|
||||
".c",
|
||||
".data",
|
||||
".dsp",
|
||||
".function",
|
||||
".h",
|
||||
".md",
|
||||
".pl",
|
||||
".py",
|
||||
".sh",
|
||||
".sln",
|
||||
".vcxproj",
|
||||
"/CMakeLists.txt",
|
||||
"/ChangeLog",
|
||||
"/Makefile",
|
||||
"/Makefile.inc",
|
||||
)
|
||||
self.excluded_directories = [
|
||||
'.git',
|
||||
'mbed-os',
|
||||
]
|
||||
self.excluded_paths = list(map(os.path.normpath, [
|
||||
'cov-int',
|
||||
'examples',
|
||||
]))
|
||||
self.issues_to_check = [
|
||||
PermissionIssueTracker(),
|
||||
EndOfFileNewlineIssueTracker(),
|
||||
@ -275,23 +314,22 @@ class IntegrityChecker:
|
||||
console = logging.StreamHandler()
|
||||
self.logger.addHandler(console)
|
||||
|
||||
def prune_branch(self, root, d):
|
||||
if d in self.excluded_directories:
|
||||
return True
|
||||
if os.path.normpath(os.path.join(root, d)) in self.excluded_paths:
|
||||
return True
|
||||
return False
|
||||
@staticmethod
|
||||
def collect_files():
|
||||
bytes_output = subprocess.check_output(['git', 'ls-files', '-z'])
|
||||
bytes_filepaths = bytes_output.split(b'\0')[:-1]
|
||||
ascii_filepaths = map(lambda fp: fp.decode('ascii'), bytes_filepaths)
|
||||
# Prepend './' to files in the top-level directory so that
|
||||
# something like `'/Makefile' in fp` matches in the top-level
|
||||
# directory as well as in subdirectories.
|
||||
return [fp if os.path.dirname(fp) else os.path.join(os.curdir, fp)
|
||||
for fp in ascii_filepaths]
|
||||
|
||||
def check_files(self):
|
||||
for root, dirs, files in os.walk("."):
|
||||
dirs[:] = sorted(d for d in dirs if not self.prune_branch(root, d))
|
||||
for filename in sorted(files):
|
||||
filepath = os.path.join(root, filename)
|
||||
if not filepath.endswith(self.extensions_to_check):
|
||||
continue
|
||||
for issue_to_check in self.issues_to_check:
|
||||
if issue_to_check.should_check_file(filepath):
|
||||
issue_to_check.check_file_for_issue(filepath)
|
||||
for issue_to_check in self.issues_to_check:
|
||||
for filepath in self.collect_files():
|
||||
if issue_to_check.should_check_file(filepath):
|
||||
issue_to_check.check_file_for_issue(filepath)
|
||||
|
||||
def output_issues(self):
|
||||
integrity_return_code = 0
|
194
tests/scripts/check_test_cases.py
Executable file
194
tests/scripts/check_test_cases.py
Executable file
@ -0,0 +1,194 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Sanity checks for test data.
|
||||
|
||||
This program contains a class for traversing test cases that can be used
|
||||
independently of the checks.
|
||||
"""
|
||||
|
||||
# Copyright (C) 2019, 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)
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
class Results:
|
||||
"""Store file and line information about errors or warnings in test suites."""
|
||||
|
||||
def __init__(self, options):
|
||||
self.errors = 0
|
||||
self.warnings = 0
|
||||
self.ignore_warnings = options.quiet
|
||||
|
||||
def error(self, file_name, line_number, fmt, *args):
|
||||
sys.stderr.write(('{}:{}:ERROR:' + fmt + '\n').
|
||||
format(file_name, line_number, *args))
|
||||
self.errors += 1
|
||||
|
||||
def warning(self, file_name, line_number, fmt, *args):
|
||||
if not self.ignore_warnings:
|
||||
sys.stderr.write(('{}:{}:Warning:' + fmt + '\n')
|
||||
.format(file_name, line_number, *args))
|
||||
self.warnings += 1
|
||||
|
||||
class TestDescriptionExplorer:
|
||||
"""An iterator over test cases with descriptions.
|
||||
|
||||
The test cases that have descriptions are:
|
||||
* Individual unit tests (entries in a .data file) in test suites.
|
||||
* Individual test cases in ssl-opt.sh.
|
||||
|
||||
This is an abstract class. To use it, derive a class that implements
|
||||
the process_test_case method, and call walk_all().
|
||||
"""
|
||||
|
||||
def process_test_case(self, per_file_state,
|
||||
file_name, line_number, description):
|
||||
"""Process a test case.
|
||||
|
||||
per_file_state: an object created by new_per_file_state() at the beginning
|
||||
of each file.
|
||||
file_name: a relative path to the file containing the test case.
|
||||
line_number: the line number in the given file.
|
||||
description: the test case description as a byte string.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def new_per_file_state(self):
|
||||
"""Return a new per-file state object.
|
||||
|
||||
The default per-file state object is None. Child classes that require per-file
|
||||
state may override this method.
|
||||
"""
|
||||
#pylint: disable=no-self-use
|
||||
return None
|
||||
|
||||
def walk_test_suite(self, data_file_name):
|
||||
"""Iterate over the test cases in the given unit test data file."""
|
||||
in_paragraph = False
|
||||
descriptions = self.new_per_file_state() # pylint: disable=assignment-from-none
|
||||
with open(data_file_name, 'rb') as data_file:
|
||||
for line_number, line in enumerate(data_file, 1):
|
||||
line = line.rstrip(b'\r\n')
|
||||
if not line:
|
||||
in_paragraph = False
|
||||
continue
|
||||
if line.startswith(b'#'):
|
||||
continue
|
||||
if not in_paragraph:
|
||||
# This is a test case description line.
|
||||
self.process_test_case(descriptions,
|
||||
data_file_name, line_number, line)
|
||||
in_paragraph = True
|
||||
|
||||
def walk_ssl_opt_sh(self, file_name):
|
||||
"""Iterate over the test cases in ssl-opt.sh or a file with a similar format."""
|
||||
descriptions = self.new_per_file_state() # pylint: disable=assignment-from-none
|
||||
with open(file_name, 'rb') as file_contents:
|
||||
for line_number, line in enumerate(file_contents, 1):
|
||||
# Assume that all run_test calls have the same simple form
|
||||
# with the test description entirely on the same line as the
|
||||
# function name.
|
||||
m = re.match(br'\s*run_test\s+"((?:[^\\"]|\\.)*)"', line)
|
||||
if not m:
|
||||
continue
|
||||
description = m.group(1)
|
||||
self.process_test_case(descriptions,
|
||||
file_name, line_number, description)
|
||||
|
||||
@staticmethod
|
||||
def collect_test_directories():
|
||||
"""Get the relative path for the TLS and Crypto test directories."""
|
||||
if os.path.isdir('tests'):
|
||||
tests_dir = 'tests'
|
||||
elif os.path.isdir('suites'):
|
||||
tests_dir = '.'
|
||||
elif os.path.isdir('../suites'):
|
||||
tests_dir = '..'
|
||||
directories = [tests_dir]
|
||||
return directories
|
||||
|
||||
def walk_all(self):
|
||||
"""Iterate over all named test cases."""
|
||||
test_directories = self.collect_test_directories()
|
||||
for directory in test_directories:
|
||||
for data_file_name in glob.glob(os.path.join(directory, 'suites',
|
||||
'*.data')):
|
||||
self.walk_test_suite(data_file_name)
|
||||
ssl_opt_sh = os.path.join(directory, 'ssl-opt.sh')
|
||||
if os.path.exists(ssl_opt_sh):
|
||||
self.walk_ssl_opt_sh(ssl_opt_sh)
|
||||
|
||||
class DescriptionChecker(TestDescriptionExplorer):
|
||||
"""Check all test case descriptions.
|
||||
|
||||
* Check that each description is valid (length, allowed character set, etc.).
|
||||
* Check that there is no duplicated description inside of one test suite.
|
||||
"""
|
||||
|
||||
def __init__(self, results):
|
||||
self.results = results
|
||||
|
||||
def new_per_file_state(self):
|
||||
"""Dictionary mapping descriptions to their line number."""
|
||||
return {}
|
||||
|
||||
def process_test_case(self, per_file_state,
|
||||
file_name, line_number, description):
|
||||
"""Check test case descriptions for errors."""
|
||||
results = self.results
|
||||
seen = per_file_state
|
||||
if description in seen:
|
||||
results.error(file_name, line_number,
|
||||
'Duplicate description (also line {})',
|
||||
seen[description])
|
||||
return
|
||||
if re.search(br'[\t;]', description):
|
||||
results.error(file_name, line_number,
|
||||
'Forbidden character \'{}\' in description',
|
||||
re.search(br'[\t;]', description).group(0).decode('ascii'))
|
||||
if re.search(br'[^ -~]', description):
|
||||
results.error(file_name, line_number,
|
||||
'Non-ASCII character in description')
|
||||
if len(description) > 66:
|
||||
results.warning(file_name, line_number,
|
||||
'Test description too long ({} > 66)',
|
||||
len(description))
|
||||
seen[description] = line_number
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--quiet', '-q',
|
||||
action='store_true',
|
||||
help='Hide warnings')
|
||||
parser.add_argument('--verbose', '-v',
|
||||
action='store_false', dest='quiet',
|
||||
help='Show warnings (default: on; undoes --quiet)')
|
||||
options = parser.parse_args()
|
||||
results = Results(options)
|
||||
checker = DescriptionChecker(results)
|
||||
checker.walk_all()
|
||||
if (results.warnings or results.errors) and not options.quiet:
|
||||
sys.stderr.write('{}: {} errors, {} warnings\n'
|
||||
.format(sys.argv[0], results.errors, results.warnings))
|
||||
sys.exit(1 if results.errors else 0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -3,6 +3,21 @@
|
||||
# curves.pl
|
||||
#
|
||||
# Copyright (c) 2014-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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
|
@ -3,6 +3,21 @@
|
||||
# depends-hashes.pl
|
||||
#
|
||||
# Copyright (c) 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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
|
@ -3,6 +3,21 @@
|
||||
# depends-pkalgs.pl
|
||||
#
|
||||
# Copyright (c) 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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
|
@ -60,12 +60,19 @@ else
|
||||
DOCKER="sudo docker"
|
||||
fi
|
||||
|
||||
# Figure out the number of processors available
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
NUM_PROC="$(sysctl -n hw.logicalcpu)"
|
||||
else
|
||||
NUM_PROC="$(nproc)"
|
||||
fi
|
||||
|
||||
# Build the Docker image
|
||||
echo "Getting docker image up to date (this may take a few minutes)..."
|
||||
${DOCKER} image build \
|
||||
-t ${DOCKER_IMAGE_TAG} \
|
||||
--cache-from=${DOCKER_IMAGE_TAG} \
|
||||
--build-arg MAKEFLAGS_PARALLEL="-j $(nproc)" \
|
||||
--build-arg MAKEFLAGS_PARALLEL="-j ${NUM_PROC}" \
|
||||
--network host \
|
||||
${http_proxy+--build-arg http_proxy=${http_proxy}} \
|
||||
${https_proxy+--build-arg https_proxy=${https_proxy}} \
|
||||
|
@ -1,6 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Make sure the doxygen documentation builds without warnings
|
||||
#
|
||||
# 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)
|
||||
|
||||
# Abort on errors (and uninitiliased variables)
|
||||
set -eu
|
||||
|
@ -3,6 +3,23 @@
|
||||
# Based on NIST CTR_DRBG.rsp validation file
|
||||
# Only uses AES-256-CTR cases that use a Derivation function
|
||||
# and concats nonce and personalization for initialization.
|
||||
#
|
||||
# Copyright (C) 2011, 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)
|
||||
|
||||
use strict;
|
||||
|
||||
|
@ -2,6 +2,23 @@
|
||||
#
|
||||
# Based on NIST gcmDecryptxxx.rsp validation files
|
||||
# Only first 3 of every set used for compile time saving
|
||||
#
|
||||
# Copyright (C) 2012-2013, 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)
|
||||
|
||||
use strict;
|
||||
|
||||
|
@ -2,6 +2,23 @@
|
||||
#
|
||||
# Based on NIST gcmEncryptIntIVxxx.rsp validation files
|
||||
# Only first 3 of every set used for compile time saving
|
||||
#
|
||||
# Copyright (C) 2012-2013, 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)
|
||||
|
||||
use strict;
|
||||
|
||||
|
@ -1,5 +1,21 @@
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
# Copyright (C) 2011-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)
|
||||
|
||||
use strict;
|
||||
|
||||
|
@ -7,6 +7,23 @@
|
||||
# Usage: generate-afl-tests.sh <test data file path>
|
||||
# <test data file path> - should be the path to one of the test suite files
|
||||
# such as 'test_suite_mpi.data'
|
||||
#
|
||||
# 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)
|
||||
|
||||
# Abort on errors
|
||||
set -e
|
||||
|
@ -3,6 +3,21 @@
|
||||
# key-exchanges.pl
|
||||
#
|
||||
# Copyright (c) 2015-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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
|
@ -1,4 +1,21 @@
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
# Copyright (C) 2015-2019, 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)
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
@ -5,6 +5,23 @@
|
||||
# Outputs the line count of the file to stdout.
|
||||
#
|
||||
# Usage: list-identifiers.sh [ -i | --internal ]
|
||||
#
|
||||
# Copyright (C) 2015-2019, 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)
|
||||
|
||||
set -eu
|
||||
|
||||
|
@ -1,4 +1,21 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2015-2019, 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)
|
||||
|
||||
set -eu
|
||||
|
||||
|
@ -1,4 +1,21 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2015-2019, 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)
|
||||
|
||||
set -eu
|
||||
|
||||
|
@ -12,6 +12,23 @@ The build command is "make -DRECORD_PSA_STATUS_COVERAGE_LOG", which is
|
||||
only supported with make (as opposed to CMake or other build methods).
|
||||
"""
|
||||
|
||||
# Copyright (C) 2019, 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)
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
@ -7,6 +7,23 @@
|
||||
# an unbounded way, those functions should use interation instead.
|
||||
#
|
||||
# Typical usage: scripts/recursion.pl library/*.c
|
||||
#
|
||||
# Copyright (C) 2014-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)
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
@ -2,9 +2,22 @@
|
||||
|
||||
# run-test-suites.pl
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2015-2018, 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)
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
@ -4,6 +4,23 @@
|
||||
# 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
|
||||
#
|
||||
# Copyright (C) 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)
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
|
@ -2,9 +2,22 @@
|
||||
|
||||
# test-ref-configs.pl
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2013-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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
|
@ -7,6 +7,23 @@ Return 0 if all test cases pass, 1 if the output was not always as expected,
|
||||
or 1 (with a Python backtrace) if there was an operational error.
|
||||
"""
|
||||
|
||||
# Copyright (C) 2018-2020, 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)
|
||||
|
||||
import argparse
|
||||
from collections import namedtuple
|
||||
import itertools
|
||||
|
@ -1,8 +1,21 @@
|
||||
# test_zeroize.gdb
|
||||
#
|
||||
# This file is part of Mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2018, 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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
@ -31,19 +44,13 @@
|
||||
# the compiler potentially has a bug.
|
||||
#
|
||||
# Note: This test requires that the test program is compiled with -g3.
|
||||
#
|
||||
# WARNING: There does not seem to be a mechanism in GDB scripts to set a
|
||||
# breakpoint at the end of a function (probably because there are a lot of
|
||||
# complications as function can have multiple exit points, etc). Therefore, it
|
||||
# was necessary to hard-code the line number of the breakpoint in the zeroize.c
|
||||
# test app. The assumption is that zeroize.c is a simple test app that does not
|
||||
# change often (as opposed to the actual library code), so the breakpoint line
|
||||
# number does not need to be updated often.
|
||||
|
||||
set confirm off
|
||||
|
||||
file ./programs/test/zeroize
|
||||
break zeroize.c:100
|
||||
|
||||
search GDB_BREAK_HERE
|
||||
break $_
|
||||
|
||||
set args ./programs/test/zeroize.c
|
||||
run
|
||||
|
@ -2,9 +2,22 @@
|
||||
|
||||
# travis-log-failure.sh
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
|
163
tests/src/helpers.c
Normal file
163
tests/src/helpers.c
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Copyright (C) 2020, 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)
|
||||
*/
|
||||
|
||||
#include <test/helpers.h>
|
||||
#include <test/macros.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
static mbedtls_platform_context platform_ctx;
|
||||
#endif
|
||||
|
||||
int mbedtls_test_platform_setup( void )
|
||||
{
|
||||
int ret = 0;
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
ret = mbedtls_platform_setup( &platform_ctx );
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
return( ret );
|
||||
}
|
||||
|
||||
void mbedtls_test_platform_teardown( void )
|
||||
{
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
mbedtls_platform_teardown( &platform_ctx );
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
}
|
||||
|
||||
static int ascii2uc(const char c, unsigned char *uc)
|
||||
{
|
||||
if( ( c >= '0' ) && ( c <= '9' ) )
|
||||
*uc = c - '0';
|
||||
else if( ( c >= 'a' ) && ( c <= 'f' ) )
|
||||
*uc = c - 'a' + 10;
|
||||
else if( ( c >= 'A' ) && ( c <= 'F' ) )
|
||||
*uc = c - 'A' + 10;
|
||||
else
|
||||
return( -1 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int mbedtls_test_unhexify( unsigned char *obuf,
|
||||
size_t obufmax,
|
||||
const char *ibuf,
|
||||
size_t *len )
|
||||
{
|
||||
unsigned char uc, uc2;
|
||||
|
||||
*len = strlen( ibuf );
|
||||
|
||||
/* Must be even number of bytes. */
|
||||
if ( ( *len ) & 1 )
|
||||
return( -1 );
|
||||
*len /= 2;
|
||||
|
||||
if ( (*len) > obufmax )
|
||||
return( -1 );
|
||||
|
||||
while( *ibuf != 0 )
|
||||
{
|
||||
if ( ascii2uc( *(ibuf++), &uc ) != 0 )
|
||||
return( -1 );
|
||||
|
||||
if ( ascii2uc( *(ibuf++), &uc2 ) != 0 )
|
||||
return( -1 );
|
||||
|
||||
*(obuf++) = ( uc << 4 ) | uc2;
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
void mbedtls_test_hexify( unsigned char *obuf,
|
||||
const unsigned char *ibuf,
|
||||
int len )
|
||||
{
|
||||
unsigned char l, h;
|
||||
|
||||
while( len != 0 )
|
||||
{
|
||||
h = *ibuf / 16;
|
||||
l = *ibuf % 16;
|
||||
|
||||
if( h < 10 )
|
||||
*obuf++ = '0' + h;
|
||||
else
|
||||
*obuf++ = 'a' + h - 10;
|
||||
|
||||
if( l < 10 )
|
||||
*obuf++ = '0' + l;
|
||||
else
|
||||
*obuf++ = 'a' + l - 10;
|
||||
|
||||
++ibuf;
|
||||
len--;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char *mbedtls_test_zero_alloc( size_t len )
|
||||
{
|
||||
void *p;
|
||||
size_t actual_len = ( len != 0 ) ? len : 1;
|
||||
|
||||
p = mbedtls_calloc( 1, actual_len );
|
||||
TEST_HELPER_ASSERT( p != NULL );
|
||||
|
||||
memset( p, 0x00, actual_len );
|
||||
|
||||
return( p );
|
||||
}
|
||||
|
||||
unsigned char *mbedtls_test_unhexify_alloc( const char *ibuf, size_t *olen )
|
||||
{
|
||||
unsigned char *obuf;
|
||||
size_t len;
|
||||
|
||||
*olen = strlen( ibuf ) / 2;
|
||||
|
||||
if( *olen == 0 )
|
||||
return( mbedtls_test_zero_alloc( *olen ) );
|
||||
|
||||
obuf = mbedtls_calloc( 1, *olen );
|
||||
TEST_HELPER_ASSERT( obuf != NULL );
|
||||
TEST_HELPER_ASSERT( mbedtls_test_unhexify( obuf, *olen, ibuf, &len ) == 0 );
|
||||
|
||||
return( obuf );
|
||||
}
|
||||
|
||||
int mbedtls_test_hexcmp( uint8_t * a, uint8_t * b,
|
||||
uint32_t a_len, uint32_t b_len )
|
||||
{
|
||||
int ret = 0;
|
||||
uint32_t i = 0;
|
||||
|
||||
if( a_len != b_len )
|
||||
return( -1 );
|
||||
|
||||
for( i = 0; i < a_len; i++ )
|
||||
{
|
||||
if( a[i] != b[i] )
|
||||
{
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
128
tests/src/random.c
Normal file
128
tests/src/random.c
Normal file
@ -0,0 +1,128 @@
|
||||
/**
|
||||
* \file random.c
|
||||
*
|
||||
* \brief This file contains the helper functions to generate random numbers
|
||||
* for the purpose of testing.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020, 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)
|
||||
*/
|
||||
|
||||
#include <test/macros.h>
|
||||
#include <test/random.h>
|
||||
#include <string.h>
|
||||
|
||||
int mbedtls_test_rnd_std_rand( void *rng_state,
|
||||
unsigned char *output,
|
||||
size_t len )
|
||||
{
|
||||
#if !defined(__OpenBSD__)
|
||||
size_t i;
|
||||
|
||||
if( rng_state != NULL )
|
||||
rng_state = NULL;
|
||||
|
||||
for( i = 0; i < len; ++i )
|
||||
output[i] = rand();
|
||||
#else
|
||||
if( rng_state != NULL )
|
||||
rng_state = NULL;
|
||||
|
||||
arc4random_buf( output, len );
|
||||
#endif /* !OpenBSD */
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int mbedtls_test_rnd_zero_rand( void *rng_state,
|
||||
unsigned char *output,
|
||||
size_t len )
|
||||
{
|
||||
if( rng_state != NULL )
|
||||
rng_state = NULL;
|
||||
|
||||
memset( output, 0, len );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int mbedtls_test_rnd_buffer_rand( void *rng_state,
|
||||
unsigned char *output,
|
||||
size_t len )
|
||||
{
|
||||
mbedtls_test_rnd_buf_info *info = (mbedtls_test_rnd_buf_info *) rng_state;
|
||||
size_t use_len;
|
||||
|
||||
if( rng_state == NULL )
|
||||
return( mbedtls_test_rnd_std_rand( NULL, output, len ) );
|
||||
|
||||
use_len = len;
|
||||
if( len > info->length )
|
||||
use_len = info->length;
|
||||
|
||||
if( use_len )
|
||||
{
|
||||
memcpy( output, info->buf, use_len );
|
||||
info->buf += use_len;
|
||||
info->length -= use_len;
|
||||
}
|
||||
|
||||
if( len - use_len > 0 )
|
||||
return( mbedtls_test_rnd_std_rand( NULL, output + use_len,
|
||||
len - use_len ) );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int mbedtls_test_rnd_pseudo_rand( void *rng_state,
|
||||
unsigned char *output,
|
||||
size_t len )
|
||||
{
|
||||
mbedtls_test_rnd_pseudo_info *info =
|
||||
(mbedtls_test_rnd_pseudo_info *) rng_state;
|
||||
uint32_t i, *k, sum, delta=0x9E3779B9;
|
||||
unsigned char result[4], *out = output;
|
||||
|
||||
if( rng_state == NULL )
|
||||
return( mbedtls_test_rnd_std_rand( NULL, output, len ) );
|
||||
|
||||
k = info->key;
|
||||
|
||||
while( len > 0 )
|
||||
{
|
||||
size_t use_len = ( len > 4 ) ? 4 : len;
|
||||
sum = 0;
|
||||
|
||||
for( i = 0; i < 32; i++ )
|
||||
{
|
||||
info->v0 += ( ( ( info->v1 << 4 ) ^ ( info->v1 >> 5 ) )
|
||||
+ info->v1 ) ^ ( sum + k[sum & 3] );
|
||||
sum += delta;
|
||||
info->v1 += ( ( ( info->v0 << 4 ) ^ ( info->v0 >> 5 ) )
|
||||
+ info->v0 ) ^ ( sum + k[( sum>>11 ) & 3] );
|
||||
}
|
||||
|
||||
PUT_UINT32_BE( info->v0, result, 0 );
|
||||
memcpy( out, result, use_len );
|
||||
len -= use_len;
|
||||
out += 4;
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
@ -2,9 +2,22 @@
|
||||
|
||||
# ssl-opt.sh
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# 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)
|
||||
#
|
||||
# Purpose
|
||||
#
|
||||
@ -228,6 +241,33 @@ requires_ciphersuite_enabled() {
|
||||
fi
|
||||
}
|
||||
|
||||
# maybe_requires_ciphersuite_enabled CMD [RUN_TEST_OPTION...]
|
||||
# If CMD (call to a TLS client or server program) requires a specific
|
||||
# ciphersuite, arrange to only run the test case if this ciphersuite is
|
||||
# enabled. As an exception, do run the test case if it expects a ciphersuite
|
||||
# mismatch.
|
||||
maybe_requires_ciphersuite_enabled() {
|
||||
case "$1" in
|
||||
*\ force_ciphersuite=*) :;;
|
||||
*) return;; # No specific required ciphersuite
|
||||
esac
|
||||
ciphersuite="${1##*\ force_ciphersuite=}"
|
||||
ciphersuite="${ciphersuite%%[!-0-9A-Z_a-z]*}"
|
||||
shift
|
||||
|
||||
case "$*" in
|
||||
*"-s SSL - The server has no ciphersuites in common"*)
|
||||
# This test case expects a ciphersuite mismatch, so it doesn't
|
||||
# require the ciphersuite to be enabled.
|
||||
;;
|
||||
*)
|
||||
requires_ciphersuite_enabled "$ciphersuite"
|
||||
;;
|
||||
esac
|
||||
|
||||
unset ciphersuite
|
||||
}
|
||||
|
||||
# skip next test if OpenSSL doesn't support FALLBACK_SCSV
|
||||
requires_openssl_with_fallback_scsv() {
|
||||
if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then
|
||||
@ -645,17 +685,9 @@ run_test() {
|
||||
requires_config_enabled MBEDTLS_FS_IO
|
||||
fi
|
||||
|
||||
# Check if server forces ciphersuite
|
||||
FORCE_CIPHERSUITE=$(echo "$SRV_CMD" | sed -n 's/^.*force_ciphersuite=\([a-zA-Z0-9\-]*\).*$/\1/p')
|
||||
if [ ! -z "$FORCE_CIPHERSUITE" ]; then
|
||||
requires_ciphersuite_enabled $FORCE_CIPHERSUITE
|
||||
fi
|
||||
|
||||
# Check if client forces ciphersuite
|
||||
FORCE_CIPHERSUITE=$(echo "$CLI_CMD" | sed -n 's/^.*force_ciphersuite=\([a-zA-Z0-9\-]*\).*$/\1/p')
|
||||
if [ ! -z "$FORCE_CIPHERSUITE" ]; then
|
||||
requires_ciphersuite_enabled $FORCE_CIPHERSUITE
|
||||
fi
|
||||
# If the client or serve requires a ciphersuite, check that it's enabled.
|
||||
maybe_requires_ciphersuite_enabled "$SRV_CMD" "$@"
|
||||
maybe_requires_ciphersuite_enabled "$CLI_CMD" "$@"
|
||||
|
||||
# should we skip?
|
||||
if [ "X$SKIP_NEXT" = "XYES" ]; then
|
||||
@ -2201,6 +2233,32 @@ run_test "Connection ID, 3D: Cli+Srv enabled, Srv disables on renegotiation"
|
||||
-c "ignoring unexpected CID" \
|
||||
-s "ignoring unexpected CID"
|
||||
|
||||
requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
|
||||
requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
|
||||
run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=512" \
|
||||
"$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
|
||||
"$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=512 dtls=1 cid=1 cid_val=beef" \
|
||||
0 \
|
||||
-c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
|
||||
-s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
|
||||
-s "(initial handshake) Use of Connection ID has been negotiated" \
|
||||
-c "(initial handshake) Use of Connection ID has been negotiated" \
|
||||
-s "Reallocating in_buf" \
|
||||
-s "Reallocating out_buf"
|
||||
|
||||
requires_config_enabled MBEDTLS_SSL_DTLS_CONNECTION_ID
|
||||
requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
|
||||
run_test "Connection ID: Cli+Srv enabled, variable buffer lengths, MFL=1024" \
|
||||
"$P_SRV dtls=1 cid=1 cid_val=dead debug_level=2" \
|
||||
"$P_CLI force_ciphersuite="TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8" max_frag_len=1024 dtls=1 cid=1 cid_val=beef" \
|
||||
0 \
|
||||
-c "(initial handshake) Peer CID (length 2 Bytes): de ad" \
|
||||
-s "(initial handshake) Peer CID (length 2 Bytes): be ef" \
|
||||
-s "(initial handshake) Use of Connection ID has been negotiated" \
|
||||
-c "(initial handshake) Use of Connection ID has been negotiated" \
|
||||
-s "Reallocating in_buf" \
|
||||
-s "Reallocating out_buf"
|
||||
|
||||
# Tests for Encrypt-then-MAC extension
|
||||
|
||||
run_test "Encrypt then MAC: default" \
|
||||
@ -9141,7 +9199,11 @@ run_test "export keys functionality" \
|
||||
-s "exported ivlen is " \
|
||||
-c "exported maclen is " \
|
||||
-c "exported keylen is " \
|
||||
-c "exported ivlen is "
|
||||
-c "exported ivlen is " \
|
||||
-c "EAP-TLS key material is:"\
|
||||
-s "EAP-TLS key material is:"\
|
||||
-c "EAP-TLS IV is:" \
|
||||
-s "EAP-TLS IV is:"
|
||||
|
||||
# Test heap memory usage after handshake
|
||||
requires_config_enabled MBEDTLS_MEMORY_DEBUG
|
||||
|
@ -2,6 +2,10 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Headers */
|
||||
|
||||
#include <test/macros.h>
|
||||
#include <test/helpers.h>
|
||||
#include <test/random.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
@ -311,65 +315,6 @@ typedef enum
|
||||
#define TEST_VALID_PARAM( TEST ) \
|
||||
TEST_ASSERT( ( TEST, 1 ) );
|
||||
|
||||
#define TEST_HELPER_ASSERT(a) if( !( a ) ) \
|
||||
{ \
|
||||
mbedtls_fprintf( stderr, "Assertion Failed at %s:%d - %s\n", \
|
||||
__FILE__, __LINE__, #a ); \
|
||||
mbedtls_exit( 1 ); \
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
/* Test if arg and &(arg)[0] have the same type. This is true if arg is
|
||||
* an array but not if it's a pointer. */
|
||||
#define IS_ARRAY_NOT_POINTER( arg ) \
|
||||
( ! __builtin_types_compatible_p( __typeof__( arg ), \
|
||||
__typeof__( &( arg )[0] ) ) )
|
||||
#else
|
||||
/* On platforms where we don't know how to implement this check,
|
||||
* omit it. Oh well, a non-portable check is better than nothing. */
|
||||
#define IS_ARRAY_NOT_POINTER( arg ) 1
|
||||
#endif
|
||||
|
||||
/* A compile-time constant with the value 0. If `const_expr` is not a
|
||||
* compile-time constant with a nonzero value, cause a compile-time error. */
|
||||
#define STATIC_ASSERT_EXPR( const_expr ) \
|
||||
( 0 && sizeof( struct { int STATIC_ASSERT : 1 - 2 * ! ( const_expr ); } ) )
|
||||
/* Return the scalar value `value` (possibly promoted). This is a compile-time
|
||||
* constant if `value` is. `condition` must be a compile-time constant.
|
||||
* If `condition` is false, arrange to cause a compile-time error. */
|
||||
#define STATIC_ASSERT_THEN_RETURN( condition, value ) \
|
||||
( STATIC_ASSERT_EXPR( condition ) ? 0 : ( value ) )
|
||||
|
||||
#define ARRAY_LENGTH_UNSAFE( array ) \
|
||||
( sizeof( array ) / sizeof( *( array ) ) )
|
||||
/** Return the number of elements of a static or stack array.
|
||||
*
|
||||
* \param array A value of array (not pointer) type.
|
||||
*
|
||||
* \return The number of elements of the array.
|
||||
*/
|
||||
#define ARRAY_LENGTH( array ) \
|
||||
( STATIC_ASSERT_THEN_RETURN( IS_ARRAY_NOT_POINTER( array ), \
|
||||
ARRAY_LENGTH_UNSAFE( array ) ) )
|
||||
|
||||
/** Return the smaller of two values.
|
||||
*
|
||||
* \param x An integer-valued expression without side effects.
|
||||
* \param y An integer-valued expression without side effects.
|
||||
*
|
||||
* \return The smaller of \p x and \p y.
|
||||
*/
|
||||
#define MIN( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
|
||||
|
||||
/** Return the larger of two values.
|
||||
*
|
||||
* \param x An integer-valued expression without side effects.
|
||||
* \param y An integer-valued expression without side effects.
|
||||
*
|
||||
* \return The larger of \p x and \p y.
|
||||
*/
|
||||
#define MAX( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
|
||||
|
||||
/** Allocate memory dynamically and fail the test case if this fails.
|
||||
*
|
||||
* You must set \p pointer to \c NULL before calling this macro and
|
||||
@ -402,30 +347,6 @@ typedef enum
|
||||
} \
|
||||
while( 0 )
|
||||
|
||||
/*
|
||||
* 32-bit integer manipulation macros (big endian)
|
||||
*/
|
||||
#ifndef GET_UINT32_BE
|
||||
#define GET_UINT32_BE(n,b,i) \
|
||||
{ \
|
||||
(n) = ( (uint32_t) (b)[(i) ] << 24 ) \
|
||||
| ( (uint32_t) (b)[(i) + 1] << 16 ) \
|
||||
| ( (uint32_t) (b)[(i) + 2] << 8 ) \
|
||||
| ( (uint32_t) (b)[(i) + 3] ); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef PUT_UINT32_BE
|
||||
#define PUT_UINT32_BE(n,b,i) \
|
||||
{ \
|
||||
(b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
|
||||
(b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
|
||||
(b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
|
||||
(b)[(i) + 3] = (unsigned char) ( (n) ); \
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Global variables */
|
||||
|
||||
@ -448,10 +369,6 @@ typedef struct
|
||||
test_info_t;
|
||||
static test_info_t test_info;
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
mbedtls_platform_context platform_ctx;
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
jmp_buf param_fail_jmp;
|
||||
jmp_buf jmp_tmp;
|
||||
@ -504,22 +421,6 @@ void test_skip( const char *test, int line_no, const char* filename )
|
||||
test_info.filename = filename;
|
||||
}
|
||||
|
||||
static int platform_setup()
|
||||
{
|
||||
int ret = 0;
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
ret = mbedtls_platform_setup( &platform_ctx );
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
return( ret );
|
||||
}
|
||||
|
||||
static void platform_teardown()
|
||||
{
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
mbedtls_platform_teardown( &platform_ctx );
|
||||
#endif /* MBEDTLS_PLATFORM_C */
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_CHECK_PARAMS)
|
||||
void mbedtls_param_failed( const char *failure_condition,
|
||||
const char *file,
|
||||
@ -586,268 +487,3 @@ static void close_output( FILE* out_stream )
|
||||
fclose( out_stream );
|
||||
}
|
||||
#endif /* __unix__ || __APPLE__ __MACH__ */
|
||||
|
||||
int unhexify( unsigned char *obuf, const char *ibuf )
|
||||
{
|
||||
unsigned char c, c2;
|
||||
int len = strlen( ibuf ) / 2;
|
||||
TEST_HELPER_ASSERT( strlen( ibuf ) % 2 == 0 ); /* must be even number of bytes */
|
||||
|
||||
while( *ibuf != 0 )
|
||||
{
|
||||
c = *ibuf++;
|
||||
if( c >= '0' && c <= '9' )
|
||||
c -= '0';
|
||||
else if( c >= 'a' && c <= 'f' )
|
||||
c -= 'a' - 10;
|
||||
else if( c >= 'A' && c <= 'F' )
|
||||
c -= 'A' - 10;
|
||||
else
|
||||
TEST_HELPER_ASSERT( 0 );
|
||||
|
||||
c2 = *ibuf++;
|
||||
if( c2 >= '0' && c2 <= '9' )
|
||||
c2 -= '0';
|
||||
else if( c2 >= 'a' && c2 <= 'f' )
|
||||
c2 -= 'a' - 10;
|
||||
else if( c2 >= 'A' && c2 <= 'F' )
|
||||
c2 -= 'A' - 10;
|
||||
else
|
||||
TEST_HELPER_ASSERT( 0 );
|
||||
|
||||
*obuf++ = ( c << 4 ) | c2;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void hexify( unsigned char *obuf, const unsigned char *ibuf, int len )
|
||||
{
|
||||
unsigned char l, h;
|
||||
|
||||
while( len != 0 )
|
||||
{
|
||||
h = *ibuf / 16;
|
||||
l = *ibuf % 16;
|
||||
|
||||
if( h < 10 )
|
||||
*obuf++ = '0' + h;
|
||||
else
|
||||
*obuf++ = 'a' + h - 10;
|
||||
|
||||
if( l < 10 )
|
||||
*obuf++ = '0' + l;
|
||||
else
|
||||
*obuf++ = 'a' + l - 10;
|
||||
|
||||
++ibuf;
|
||||
len--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate and zeroize a buffer.
|
||||
*
|
||||
* If the size if zero, a pointer to a zeroized 1-byte buffer is returned.
|
||||
*
|
||||
* For convenience, dies if allocation fails.
|
||||
*/
|
||||
static unsigned char *zero_alloc( size_t len )
|
||||
{
|
||||
void *p;
|
||||
size_t actual_len = ( len != 0 ) ? len : 1;
|
||||
|
||||
p = mbedtls_calloc( 1, actual_len );
|
||||
TEST_HELPER_ASSERT( p != NULL );
|
||||
|
||||
memset( p, 0x00, actual_len );
|
||||
|
||||
return( p );
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate and fill a buffer from hex data.
|
||||
*
|
||||
* The buffer is sized exactly as needed. This allows to detect buffer
|
||||
* overruns (including overreads) when running the test suite under valgrind.
|
||||
*
|
||||
* If the size if zero, a pointer to a zeroized 1-byte buffer is returned.
|
||||
*
|
||||
* For convenience, dies if allocation fails.
|
||||
*/
|
||||
unsigned char *unhexify_alloc( const char *ibuf, size_t *olen )
|
||||
{
|
||||
unsigned char *obuf;
|
||||
|
||||
*olen = strlen( ibuf ) / 2;
|
||||
|
||||
if( *olen == 0 )
|
||||
return( zero_alloc( *olen ) );
|
||||
|
||||
obuf = mbedtls_calloc( 1, *olen );
|
||||
TEST_HELPER_ASSERT( obuf != NULL );
|
||||
|
||||
(void) unhexify( obuf, ibuf );
|
||||
|
||||
return( obuf );
|
||||
}
|
||||
|
||||
/**
|
||||
* This function just returns data from rand().
|
||||
* Although predictable and often similar on multiple
|
||||
* runs, this does not result in identical random on
|
||||
* each run. So do not use this if the results of a
|
||||
* test depend on the random data that is generated.
|
||||
*
|
||||
* rng_state shall be NULL.
|
||||
*/
|
||||
static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len )
|
||||
{
|
||||
#if !defined(__OpenBSD__)
|
||||
size_t i;
|
||||
|
||||
if( rng_state != NULL )
|
||||
rng_state = NULL;
|
||||
|
||||
for( i = 0; i < len; ++i )
|
||||
output[i] = rand();
|
||||
#else
|
||||
if( rng_state != NULL )
|
||||
rng_state = NULL;
|
||||
|
||||
arc4random_buf( output, len );
|
||||
#endif /* !OpenBSD */
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* This function only returns zeros
|
||||
*
|
||||
* rng_state shall be NULL.
|
||||
*/
|
||||
int rnd_zero_rand( void *rng_state, unsigned char *output, size_t len )
|
||||
{
|
||||
if( rng_state != NULL )
|
||||
rng_state = NULL;
|
||||
|
||||
memset( output, 0, len );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char *buf;
|
||||
size_t length;
|
||||
} rnd_buf_info;
|
||||
|
||||
/**
|
||||
* This function returns random based on a buffer it receives.
|
||||
*
|
||||
* rng_state shall be a pointer to a rnd_buf_info structure.
|
||||
*
|
||||
* The number of bytes released from the buffer on each call to
|
||||
* the random function is specified by per_call. (Can be between
|
||||
* 1 and 4)
|
||||
*
|
||||
* After the buffer is empty it will return rand();
|
||||
*/
|
||||
int rnd_buffer_rand( void *rng_state, unsigned char *output, size_t len )
|
||||
{
|
||||
rnd_buf_info *info = (rnd_buf_info *) rng_state;
|
||||
size_t use_len;
|
||||
|
||||
if( rng_state == NULL )
|
||||
return( rnd_std_rand( NULL, output, len ) );
|
||||
|
||||
use_len = len;
|
||||
if( len > info->length )
|
||||
use_len = info->length;
|
||||
|
||||
if( use_len )
|
||||
{
|
||||
memcpy( output, info->buf, use_len );
|
||||
info->buf += use_len;
|
||||
info->length -= use_len;
|
||||
}
|
||||
|
||||
if( len - use_len > 0 )
|
||||
return( rnd_std_rand( NULL, output + use_len, len - use_len ) );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Info structure for the pseudo random function
|
||||
*
|
||||
* Key should be set at the start to a test-unique value.
|
||||
* Do not forget endianness!
|
||||
* State( v0, v1 ) should be set to zero.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint32_t key[16];
|
||||
uint32_t v0, v1;
|
||||
} rnd_pseudo_info;
|
||||
|
||||
/**
|
||||
* This function returns random based on a pseudo random function.
|
||||
* This means the results should be identical on all systems.
|
||||
* Pseudo random is based on the XTEA encryption algorithm to
|
||||
* generate pseudorandom.
|
||||
*
|
||||
* rng_state shall be a pointer to a rnd_pseudo_info structure.
|
||||
*/
|
||||
int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len )
|
||||
{
|
||||
rnd_pseudo_info *info = (rnd_pseudo_info *) rng_state;
|
||||
uint32_t i, *k, sum, delta=0x9E3779B9;
|
||||
unsigned char result[4], *out = output;
|
||||
|
||||
if( rng_state == NULL )
|
||||
return( rnd_std_rand( NULL, output, len ) );
|
||||
|
||||
k = info->key;
|
||||
|
||||
while( len > 0 )
|
||||
{
|
||||
size_t use_len = ( len > 4 ) ? 4 : len;
|
||||
sum = 0;
|
||||
|
||||
for( i = 0; i < 32; i++ )
|
||||
{
|
||||
info->v0 += ( ( ( info->v1 << 4 ) ^ ( info->v1 >> 5 ) )
|
||||
+ info->v1 ) ^ ( sum + k[sum & 3] );
|
||||
sum += delta;
|
||||
info->v1 += ( ( ( info->v0 << 4 ) ^ ( info->v0 >> 5 ) )
|
||||
+ info->v0 ) ^ ( sum + k[( sum>>11 ) & 3] );
|
||||
}
|
||||
|
||||
PUT_UINT32_BE( info->v0, result, 0 );
|
||||
memcpy( out, result, use_len );
|
||||
len -= use_len;
|
||||
out += 4;
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
int hexcmp( uint8_t * a, uint8_t * b, uint32_t a_len, uint32_t b_len )
|
||||
{
|
||||
int ret = 0;
|
||||
uint32_t i = 0;
|
||||
|
||||
if( a_len != b_len )
|
||||
return( -1 );
|
||||
|
||||
for( i = 0; i < a_len; i++ )
|
||||
{
|
||||
if( a[i] != b[i] )
|
||||
{
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -277,7 +277,13 @@ static int convert_params( size_t cnt , char ** params , int * int_params_store
|
||||
{
|
||||
if ( verify_string( &val ) == 0 )
|
||||
{
|
||||
*int_params_store = unhexify( (unsigned char *) val, val );
|
||||
size_t len;
|
||||
|
||||
TEST_HELPER_ASSERT(
|
||||
mbedtls_test_unhexify( (unsigned char *) val, strlen( val ),
|
||||
val, &len ) == 0 );
|
||||
|
||||
*int_params_store = len;
|
||||
*out++ = val;
|
||||
*out++ = (char *)(int_params_store++);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||
#if !defined(_POSIX_C_SOURCE)
|
||||
#define _POSIX_C_SOURCE 1 // for fileno() from <stdio.h>
|
||||
#define _POSIX_C_SOURCE 200112L // for fileno() from <stdio.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -261,7 +261,7 @@ $platform_code
|
||||
*/
|
||||
int main( int argc, const char *argv[] )
|
||||
{
|
||||
int ret = platform_setup();
|
||||
int ret = mbedtls_test_platform_setup();
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_fprintf( stderr,
|
||||
@ -271,6 +271,6 @@ int main( int argc, const char *argv[] )
|
||||
}
|
||||
|
||||
ret = execute_tests( argc, argv );
|
||||
platform_teardown();
|
||||
mbedtls_test_platform_teardown();
|
||||
return( ret );
|
||||
}
|
||||
|
@ -70,12 +70,16 @@ uint8_t receive_byte()
|
||||
{
|
||||
uint8_t byte;
|
||||
uint8_t c[3];
|
||||
char *endptr;
|
||||
size_t len;
|
||||
|
||||
c[0] = greentea_getc();
|
||||
c[1] = greentea_getc();
|
||||
c[2] = '\0';
|
||||
|
||||
TEST_HELPER_ASSERT( unhexify( &byte, c ) != 2 );
|
||||
TEST_HELPER_ASSERT( mbedtls_test_unhexify( &byte, sizeof( byte ),
|
||||
c, &len ) == 0 );
|
||||
TEST_HELPER_ASSERT( len != 2 );
|
||||
|
||||
return( byte );
|
||||
}
|
||||
|
||||
@ -90,6 +94,7 @@ uint8_t receive_byte()
|
||||
uint32_t receive_uint32()
|
||||
{
|
||||
uint32_t value;
|
||||
size_t len;
|
||||
const uint8_t c_be[8] = { greentea_getc(),
|
||||
greentea_getc(),
|
||||
greentea_getc(),
|
||||
@ -101,7 +106,11 @@ uint32_t receive_uint32()
|
||||
};
|
||||
const uint8_t c[9] = { c_be[6], c_be[7], c_be[4], c_be[5], c_be[2],
|
||||
c_be[3], c_be[0], c_be[1], '\0' };
|
||||
TEST_HELPER_ASSERT( unhexify( (uint8_t*)&value, c ) != 8 );
|
||||
|
||||
TEST_HELPER_ASSERT( mbedtls_test_unhexify( (uint8_t*)&value, sizeof( value ),
|
||||
c, &len ) == 0 );
|
||||
TEST_HELPER_ASSERT( len != 8 );
|
||||
|
||||
return( value );
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,8 @@ void aes_encrypt_ecb( data_t * key_str, data_t * src_str,
|
||||
{
|
||||
TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx, MBEDTLS_AES_ENCRYPT, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
16, hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -47,7 +48,8 @@ void aes_decrypt_ecb( data_t * key_str, data_t * src_str,
|
||||
{
|
||||
TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx, MBEDTLS_AES_DECRYPT, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
16, hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -72,7 +74,9 @@ void aes_encrypt_cbc( data_t * key_str, data_t * iv_str,
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -96,7 +100,9 @@ void aes_decrypt_cbc( data_t * key_str, data_t * iv_str,
|
||||
if( cbc_result == 0)
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -119,17 +125,18 @@ void aes_encrypt_xts( char *hex_key_string, char *hex_data_unit_string,
|
||||
|
||||
mbedtls_aes_xts_init( &ctx );
|
||||
|
||||
data_unit = unhexify_alloc( hex_data_unit_string, &data_unit_len );
|
||||
data_unit = mbedtls_test_unhexify_alloc( hex_data_unit_string,
|
||||
&data_unit_len );
|
||||
TEST_ASSERT( data_unit_len == AES_BLOCK_SIZE );
|
||||
|
||||
key = unhexify_alloc( hex_key_string, &key_len );
|
||||
key = mbedtls_test_unhexify_alloc( hex_key_string, &key_len );
|
||||
TEST_ASSERT( key_len % 2 == 0 );
|
||||
|
||||
src = unhexify_alloc( hex_src_string, &src_len );
|
||||
dst = unhexify_alloc( hex_dst_string, &dst_len );
|
||||
src = mbedtls_test_unhexify_alloc( hex_src_string, &src_len );
|
||||
dst = mbedtls_test_unhexify_alloc( hex_dst_string, &dst_len );
|
||||
TEST_ASSERT( src_len == dst_len );
|
||||
|
||||
output = zero_alloc( dst_len );
|
||||
output = mbedtls_test_zero_alloc( dst_len );
|
||||
|
||||
TEST_ASSERT( mbedtls_aes_xts_setkey_enc( &ctx, key, key_len * 8 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, src_len,
|
||||
@ -162,17 +169,18 @@ void aes_decrypt_xts( char *hex_key_string, char *hex_data_unit_string,
|
||||
|
||||
mbedtls_aes_xts_init( &ctx );
|
||||
|
||||
data_unit = unhexify_alloc( hex_data_unit_string, &data_unit_len );
|
||||
data_unit = mbedtls_test_unhexify_alloc( hex_data_unit_string,
|
||||
&data_unit_len );
|
||||
TEST_ASSERT( data_unit_len == AES_BLOCK_SIZE );
|
||||
|
||||
key = unhexify_alloc( hex_key_string, &key_len );
|
||||
key = mbedtls_test_unhexify_alloc( hex_key_string, &key_len );
|
||||
TEST_ASSERT( key_len % 2 == 0 );
|
||||
|
||||
src = unhexify_alloc( hex_src_string, &src_len );
|
||||
dst = unhexify_alloc( hex_dst_string, &dst_len );
|
||||
src = mbedtls_test_unhexify_alloc( hex_src_string, &src_len );
|
||||
dst = mbedtls_test_unhexify_alloc( hex_dst_string, &dst_len );
|
||||
TEST_ASSERT( src_len == dst_len );
|
||||
|
||||
output = zero_alloc( dst_len );
|
||||
output = mbedtls_test_zero_alloc( dst_len );
|
||||
|
||||
TEST_ASSERT( mbedtls_aes_xts_setkey_dec( &ctx, key, key_len * 8 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_DECRYPT, src_len,
|
||||
@ -241,7 +249,8 @@ void aes_encrypt_cfb128( data_t * key_str, data_t * iv_str,
|
||||
mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_ENCRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
16, hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_aes_free( &ctx );
|
||||
@ -263,7 +272,8 @@ void aes_decrypt_cfb128( data_t * key_str, data_t * iv_str,
|
||||
mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_DECRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
16, hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_aes_free( &ctx );
|
||||
@ -284,7 +294,9 @@ void aes_encrypt_cfb8( data_t * key_str, data_t * iv_str,
|
||||
mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_ENCRYPT, src_str->len, iv_str->x, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_aes_free( &ctx );
|
||||
@ -305,7 +317,9 @@ void aes_decrypt_cfb8( data_t * key_str, data_t * iv_str,
|
||||
mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_aes_free( &ctx );
|
||||
@ -313,51 +327,39 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_OFB */
|
||||
void aes_encrypt_ofb( int fragment_size, char *hex_key_string,
|
||||
char *hex_iv_string, char *hex_src_string,
|
||||
char *hex_dst_string )
|
||||
void aes_encrypt_ofb( int fragment_size, data_t *key_str,
|
||||
data_t *iv_str, data_t *src_str,
|
||||
char *expected_output_string)
|
||||
{
|
||||
unsigned char key_str[32];
|
||||
unsigned char iv_str[16];
|
||||
unsigned char src_str[64];
|
||||
unsigned char dst_str[64];
|
||||
unsigned char output[32];
|
||||
unsigned char output_string[65];
|
||||
mbedtls_aes_context ctx;
|
||||
size_t iv_offset = 0;
|
||||
int in_buffer_len;
|
||||
unsigned char* src_str_next;
|
||||
int key_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( output_string, 0x00, sizeof( output_string ) );
|
||||
mbedtls_aes_init( &ctx );
|
||||
|
||||
TEST_ASSERT( strlen( hex_key_string ) <= ( 32 * 2 ) );
|
||||
TEST_ASSERT( strlen( hex_iv_string ) <= ( 16 * 2 ) );
|
||||
TEST_ASSERT( strlen( hex_src_string ) <= ( 64 * 2 ) );
|
||||
TEST_ASSERT( strlen( hex_dst_string ) <= ( 64 * 2 ) );
|
||||
TEST_ASSERT( (size_t)fragment_size < sizeof( output ) );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
in_buffer_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 );
|
||||
src_str_next = src_str;
|
||||
TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str->x,
|
||||
key_str->len * 8 ) == 0 );
|
||||
in_buffer_len = src_str->len;
|
||||
src_str_next = src_str->x;
|
||||
|
||||
while( in_buffer_len > 0 )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_aes_crypt_ofb( &ctx, fragment_size, &iv_offset,
|
||||
iv_str, src_str_next, output ) == 0 );
|
||||
iv_str->x, src_str_next, output ) == 0 );
|
||||
|
||||
hexify( dst_str, output, fragment_size );
|
||||
TEST_ASSERT( strncmp( (char *) dst_str, hex_dst_string,
|
||||
mbedtls_test_hexify( output_string, output, fragment_size );
|
||||
TEST_ASSERT( strncmp( (char *) output_string, expected_output_string,
|
||||
( 2 * fragment_size ) ) == 0 );
|
||||
|
||||
in_buffer_len -= fragment_size;
|
||||
hex_dst_string += ( fragment_size * 2 );
|
||||
expected_output_string += ( fragment_size * 2 );
|
||||
src_str_next += fragment_size;
|
||||
|
||||
if( in_buffer_len < fragment_size )
|
||||
|
@ -21,7 +21,9 @@ void mbedtls_arc4_crypt( data_t * src_str, data_t * key_str,
|
||||
mbedtls_arc4_setup(&ctx, key_str->x, key_str->len);
|
||||
TEST_ASSERT( mbedtls_arc4_crypt(&ctx, src_str->len, src_str->x, dst_str ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( dst_str, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( dst_str, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_arc4_free( &ctx );
|
||||
|
@ -206,35 +206,28 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void aria_encrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
void aria_encrypt_ecb( data_t *key_str, data_t *src_str,
|
||||
char *hex_dst_string, int setkey_result )
|
||||
{
|
||||
unsigned char key_str[ARIA_MAX_KEY_STR];
|
||||
unsigned char src_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
int key_len, data_len, i;
|
||||
size_t i;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
TEST_ASSERT( mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 )
|
||||
TEST_ASSERT( mbedtls_aria_setkey_enc( &ctx, key_str->x, key_str->len * 8 )
|
||||
== setkey_result );
|
||||
if( setkey_result == 0 )
|
||||
{
|
||||
for( i = 0; i < data_len; i += MBEDTLS_ARIA_BLOCKSIZE )
|
||||
for( i = 0; i < src_str->len; i += MBEDTLS_ARIA_BLOCKSIZE )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ecb( &ctx, src_str + i, output + i )
|
||||
== 0 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ecb( &ctx, src_str->x + i,
|
||||
output + i ) == 0 );
|
||||
}
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str->len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -245,35 +238,28 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void aria_decrypt_ecb( char *hex_key_string, char *hex_src_string,
|
||||
void aria_decrypt_ecb( data_t *key_str, data_t *src_str,
|
||||
char *hex_dst_string, int setkey_result )
|
||||
{
|
||||
unsigned char key_str[ARIA_MAX_KEY_STR];
|
||||
unsigned char src_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
int key_len, data_len, i;
|
||||
size_t i;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
TEST_ASSERT( mbedtls_aria_setkey_dec( &ctx, key_str, key_len * 8 )
|
||||
TEST_ASSERT( mbedtls_aria_setkey_dec( &ctx, key_str->x, key_str->len * 8 )
|
||||
== setkey_result );
|
||||
if( setkey_result == 0 )
|
||||
{
|
||||
for( i = 0; i < data_len; i += MBEDTLS_ARIA_BLOCKSIZE )
|
||||
for( i = 0; i < src_str->len; i += MBEDTLS_ARIA_BLOCKSIZE )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ecb( &ctx, src_str + i, output + i )
|
||||
== 0 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ecb( &ctx, src_str->x + i,
|
||||
output + i ) == 0 );
|
||||
}
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str->len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -284,36 +270,25 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */
|
||||
void aria_encrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
char *hex_src_string, char *hex_dst_string,
|
||||
void aria_encrypt_cbc( data_t *key_str, data_t *iv_str,
|
||||
data_t *src_str, char *hex_dst_string,
|
||||
int cbc_result )
|
||||
{
|
||||
unsigned char key_str[ARIA_MAX_KEY_STR];
|
||||
unsigned char iv_str[ARIA_BLOCK_STR];
|
||||
unsigned char src_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
int key_len, data_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_ENCRYPT, data_len,
|
||||
iv_str, src_str, output )
|
||||
== cbc_result );
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_ENCRYPT,
|
||||
src_str->len, iv_str->x, src_str->x,
|
||||
output ) == cbc_result );
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str->len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -324,36 +299,25 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */
|
||||
void aria_decrypt_cbc( char *hex_key_string, char *hex_iv_string,
|
||||
char *hex_src_string, char *hex_dst_string,
|
||||
void aria_decrypt_cbc( data_t *key_str, data_t *iv_str,
|
||||
data_t *src_str, char *hex_dst_string,
|
||||
int cbc_result )
|
||||
{
|
||||
unsigned char key_str[ARIA_MAX_KEY_STR];
|
||||
unsigned char iv_str[ARIA_BLOCK_STR];
|
||||
unsigned char src_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
int key_len, data_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_dec( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_DECRYPT, data_len,
|
||||
iv_str, src_str, output )
|
||||
== cbc_result );
|
||||
mbedtls_aria_setkey_dec( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_DECRYPT,
|
||||
src_str->len, iv_str->x, src_str->x,
|
||||
output ) == cbc_result );
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str->len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
}
|
||||
@ -364,36 +328,25 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */
|
||||
void aria_encrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
char *hex_src_string, char *hex_dst_string,
|
||||
void aria_encrypt_cfb128( data_t *key_str, data_t *iv_str,
|
||||
data_t *src_str, char *hex_dst_string,
|
||||
int result )
|
||||
{
|
||||
unsigned char key_str[ARIA_MAX_KEY_STR];
|
||||
unsigned char iv_str[ARIA_BLOCK_STR];
|
||||
unsigned char src_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
size_t iv_offset = 0;
|
||||
int key_len, data_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cfb128( &ctx, MBEDTLS_ARIA_ENCRYPT,
|
||||
data_len, &iv_offset, iv_str,
|
||||
src_str, output )
|
||||
src_str->len, &iv_offset,
|
||||
iv_str->x, src_str->x, output )
|
||||
== result );
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str->len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
@ -403,36 +356,25 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */
|
||||
void aria_decrypt_cfb128( char *hex_key_string, char *hex_iv_string,
|
||||
char *hex_src_string, char *hex_dst_string,
|
||||
void aria_decrypt_cfb128( data_t *key_str, data_t *iv_str,
|
||||
data_t *src_str, char *hex_dst_string,
|
||||
int result )
|
||||
{
|
||||
unsigned char key_str[ARIA_MAX_KEY_STR];
|
||||
unsigned char iv_str[ARIA_BLOCK_STR];
|
||||
unsigned char src_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
size_t iv_offset = 0;
|
||||
int key_len, data_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_cfb128( &ctx, MBEDTLS_ARIA_DECRYPT,
|
||||
data_len, &iv_offset, iv_str,
|
||||
src_str, output )
|
||||
src_str->len, &iv_offset,
|
||||
iv_str->x, src_str->x, output )
|
||||
== result );
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str->len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
@ -442,36 +384,25 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CTR */
|
||||
void aria_encrypt_ctr( char *hex_key_string, char *hex_iv_string,
|
||||
char *hex_src_string, char *hex_dst_string,
|
||||
void aria_encrypt_ctr( data_t *key_str, data_t *iv_str,
|
||||
data_t *src_str, char *hex_dst_string,
|
||||
int result )
|
||||
{
|
||||
unsigned char key_str[ARIA_MAX_KEY_STR];
|
||||
unsigned char iv_str[ARIA_BLOCK_STR];
|
||||
unsigned char src_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
unsigned char blk[MBEDTLS_ARIA_BLOCKSIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
size_t iv_offset = 0;
|
||||
int key_len, data_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, data_len, &iv_offset, iv_str,
|
||||
blk, src_str, output )
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, src_str->len, &iv_offset,
|
||||
iv_str->x, blk, src_str->x, output )
|
||||
== result );
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str->len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
@ -481,36 +412,25 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CTR */
|
||||
void aria_decrypt_ctr( char *hex_key_string, char *hex_iv_string,
|
||||
char *hex_src_string, char *hex_dst_string,
|
||||
void aria_decrypt_ctr( data_t *key_str, data_t *iv_str,
|
||||
data_t *src_str, char *hex_dst_string,
|
||||
int result )
|
||||
{
|
||||
unsigned char key_str[ARIA_MAX_KEY_STR];
|
||||
unsigned char iv_str[ARIA_BLOCK_STR];
|
||||
unsigned char src_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char dst_str[ARIA_MAX_DATA_STR];
|
||||
unsigned char output[ARIA_MAX_DATASIZE];
|
||||
unsigned char blk[MBEDTLS_ARIA_BLOCKSIZE];
|
||||
mbedtls_aria_context ctx;
|
||||
size_t iv_offset = 0;
|
||||
int key_len, data_len;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
mbedtls_aria_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, data_len, &iv_offset, iv_str,
|
||||
blk, src_str, output )
|
||||
mbedtls_aria_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, src_str->len, &iv_offset,
|
||||
iv_str->x, blk, src_str->x, output )
|
||||
== result );
|
||||
hexify( dst_str, output, data_len );
|
||||
mbedtls_test_hexify( dst_str, output, src_str->len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 );
|
||||
|
||||
|
@ -55,7 +55,7 @@ void base64_encode_hex( data_t * src, char * dst, int dst_buf_size,
|
||||
unsigned char *res = NULL;
|
||||
size_t len;
|
||||
|
||||
res = zero_alloc( dst_buf_size );
|
||||
res = mbedtls_test_zero_alloc( dst_buf_size );
|
||||
|
||||
TEST_ASSERT( mbedtls_base64_encode( res, dst_buf_size, &len, src->x, src->len ) == result );
|
||||
if( result == 0 )
|
||||
@ -76,7 +76,7 @@ void base64_decode_hex( char * src, data_t * dst, int dst_buf_size,
|
||||
unsigned char *res = NULL;
|
||||
size_t len;
|
||||
|
||||
res = zero_alloc( dst_buf_size );
|
||||
res = mbedtls_test_zero_alloc( dst_buf_size );
|
||||
|
||||
TEST_ASSERT( mbedtls_base64_decode( res, dst_buf_size, &len, (unsigned char *) src,
|
||||
strlen( src ) ) == result );
|
||||
|
@ -181,7 +181,8 @@ void blowfish_encrypt_ecb( data_t * key_str, data_t * src_str,
|
||||
{
|
||||
TEST_ASSERT( mbedtls_blowfish_crypt_ecb( &ctx, MBEDTLS_BLOWFISH_ENCRYPT, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
8, hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -205,7 +206,8 @@ void blowfish_decrypt_ecb( data_t * key_str, data_t * src_str,
|
||||
{
|
||||
TEST_ASSERT( mbedtls_blowfish_crypt_ecb( &ctx, MBEDTLS_BLOWFISH_DECRYPT, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
8, hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -231,7 +233,9 @@ void blowfish_encrypt_cbc( data_t * key_str, data_t * iv_str,
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -256,7 +260,9 @@ void blowfish_decrypt_cbc( data_t * key_str, data_t * iv_str,
|
||||
if( cbc_result == 0)
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -280,7 +286,9 @@ void blowfish_encrypt_cfb64( data_t * key_str, data_t * iv_str,
|
||||
mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_blowfish_crypt_cfb64( &ctx, MBEDTLS_BLOWFISH_ENCRYPT, src_str->len, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_blowfish_free( &ctx );
|
||||
@ -303,7 +311,9 @@ void blowfish_decrypt_cfb64( data_t * key_str, data_t * iv_str,
|
||||
mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_blowfish_crypt_cfb64( &ctx, MBEDTLS_BLOWFISH_DECRYPT, src_str->len, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_blowfish_free( &ctx );
|
||||
@ -327,7 +337,9 @@ void blowfish_encrypt_ctr( data_t * key_str, data_t * iv_str,
|
||||
mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_blowfish_crypt_ctr( &ctx, src_str->len, &iv_offset, iv_str->x, stream_str, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_blowfish_free( &ctx );
|
||||
|
@ -189,7 +189,8 @@ void camellia_encrypt_ecb( data_t * key_str, data_t * src_str,
|
||||
{
|
||||
TEST_ASSERT( mbedtls_camellia_crypt_ecb( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
16, hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -213,7 +214,8 @@ void camellia_decrypt_ecb( data_t * key_str, data_t * src_str,
|
||||
{
|
||||
TEST_ASSERT( mbedtls_camellia_crypt_ecb( &ctx, MBEDTLS_CAMELLIA_DECRYPT, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
16, hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -238,7 +240,9 @@ void camellia_encrypt_cbc( data_t * key_str, data_t * iv_str,
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -263,7 +267,9 @@ void camellia_decrypt_cbc( data_t * key_str, data_t * iv_str,
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -287,7 +293,8 @@ void camellia_encrypt_cfb128( data_t * key_str, data_t * iv_str,
|
||||
mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_camellia_crypt_cfb128( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
16, hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_camellia_free( &ctx );
|
||||
@ -310,7 +317,8 @@ void camellia_decrypt_cfb128( data_t * key_str, data_t * iv_str,
|
||||
mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 );
|
||||
TEST_ASSERT( mbedtls_camellia_crypt_cfb128( &ctx, MBEDTLS_CAMELLIA_DECRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
16, hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_camellia_free( &ctx );
|
||||
|
@ -192,64 +192,51 @@ exit:
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_ccm_star_encrypt_and_tag( int cipher_id,
|
||||
char *key_hex, char *msg_hex,
|
||||
char *source_address_hex, char *frame_counter_hex,
|
||||
int sec_level, char *add_hex,
|
||||
char *result_hex, int output_ret )
|
||||
data_t *key, data_t *msg,
|
||||
data_t *source_address, data_t *frame_counter,
|
||||
int sec_level, data_t *add,
|
||||
data_t *expected_result, int output_ret )
|
||||
{
|
||||
unsigned char key[32];
|
||||
unsigned char msg[50];
|
||||
unsigned char iv[13];
|
||||
unsigned char add[32];
|
||||
unsigned char result[50];
|
||||
unsigned char source_address[8];
|
||||
unsigned char frame_counter[4];
|
||||
mbedtls_ccm_context ctx;
|
||||
size_t i, key_len, msg_len, iv_len, add_len, result_len, source_address_len, frame_counter_len, tag_len;
|
||||
size_t i, iv_len, tag_len;
|
||||
int ret;
|
||||
|
||||
mbedtls_ccm_init( &ctx );
|
||||
|
||||
memset( key, 0x00, sizeof( key ) );
|
||||
memset( msg, 0x00, sizeof( msg ) );
|
||||
memset( iv, 0x00, sizeof( iv ) );
|
||||
memset( add, 0x00, sizeof( add ) );
|
||||
memset( result, 0x00, sizeof( result ) );
|
||||
memset( source_address, 0x00, sizeof( source_address ) );
|
||||
memset( frame_counter, 0x00, sizeof( frame_counter ) );
|
||||
|
||||
key_len = unhexify( key, key_hex );
|
||||
msg_len = unhexify( msg, msg_hex );
|
||||
add_len = unhexify( add, add_hex );
|
||||
result_len = unhexify( result, result_hex );
|
||||
source_address_len = unhexify( source_address, source_address_hex );
|
||||
frame_counter_len = unhexify( frame_counter, frame_counter_hex );
|
||||
|
||||
if( sec_level % 4 == 0)
|
||||
tag_len = 0;
|
||||
else
|
||||
tag_len = 1 << ( sec_level % 4 + 1);
|
||||
|
||||
for( i = 0; i < source_address_len; i++ )
|
||||
iv[i] = source_address[i];
|
||||
for( i = 0; i < source_address->len; i++ )
|
||||
iv[i] = source_address->x[i];
|
||||
|
||||
for( i = 0; i < frame_counter_len; i++ )
|
||||
iv[source_address_len + i] = frame_counter[i];
|
||||
for( i = 0; i < frame_counter->len; i++ )
|
||||
iv[source_address->len + i] = frame_counter->x[i];
|
||||
|
||||
iv[source_address_len + frame_counter_len] = sec_level;
|
||||
iv[source_address->len + frame_counter->len] = sec_level;
|
||||
iv_len = sizeof( iv );
|
||||
|
||||
TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, key, key_len * 8 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id,
|
||||
key->x, key->len * 8 ) == 0 );
|
||||
|
||||
ret = mbedtls_ccm_star_encrypt_and_tag( &ctx, msg_len, iv, iv_len,
|
||||
add, add_len, msg, msg, msg + msg_len, tag_len );
|
||||
ret = mbedtls_ccm_star_encrypt_and_tag( &ctx, msg->len, iv, iv_len,
|
||||
add->x, add->len, msg->x,
|
||||
result, result + msg->len, tag_len );
|
||||
|
||||
TEST_ASSERT( ret == output_ret );
|
||||
|
||||
TEST_ASSERT( memcmp( msg, result, result_len ) == 0 );
|
||||
TEST_ASSERT( memcmp( result,
|
||||
expected_result->x, expected_result->len ) == 0 );
|
||||
|
||||
/* Check we didn't write past the end */
|
||||
TEST_ASSERT( msg[result_len] == 0 && msg[result_len + 1] == 0 );
|
||||
TEST_ASSERT( result[expected_result->len] == 0 &&
|
||||
result[expected_result->len + 1] == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_ccm_free( &ctx );
|
||||
@ -258,69 +245,51 @@ exit:
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_ccm_star_auth_decrypt( int cipher_id,
|
||||
char *key_hex, char *msg_hex,
|
||||
char *source_address_hex, char *frame_counter_hex,
|
||||
int sec_level, char *add_hex,
|
||||
char *result_hex, int output_ret )
|
||||
data_t *key, data_t *msg,
|
||||
data_t *source_address, data_t *frame_counter,
|
||||
int sec_level, data_t *add,
|
||||
data_t *expected_result, int output_ret )
|
||||
{
|
||||
unsigned char key[32];
|
||||
unsigned char msg[50];
|
||||
unsigned char iv[13];
|
||||
unsigned char add[32];
|
||||
unsigned char tag[16];
|
||||
unsigned char result[50];
|
||||
unsigned char source_address[8];
|
||||
unsigned char frame_counter[4];
|
||||
mbedtls_ccm_context ctx;
|
||||
size_t i, key_len, msg_len, iv_len, add_len, tag_len, result_len, source_address_len, frame_counter_len;
|
||||
size_t i, iv_len, tag_len;
|
||||
int ret;
|
||||
|
||||
mbedtls_ccm_init( &ctx );
|
||||
|
||||
memset( key, 0x00, sizeof( key ) );
|
||||
memset( msg, 0x00, sizeof( msg ) );
|
||||
memset( iv, 0x00, sizeof( iv ) );
|
||||
memset( add, 0x00, sizeof( add ) );
|
||||
memset( result, 0x00, sizeof( result ) );
|
||||
memset( source_address, 0x00, sizeof( source_address ) );
|
||||
memset( frame_counter, 0x00, sizeof( frame_counter ) );
|
||||
memset( tag, 0x00, sizeof( tag ) );
|
||||
|
||||
key_len = unhexify( key, key_hex );
|
||||
msg_len = unhexify( msg, msg_hex );
|
||||
add_len = unhexify( add, add_hex );
|
||||
result_len = unhexify( result, result_hex );
|
||||
source_address_len = unhexify( source_address, source_address_hex );
|
||||
frame_counter_len = unhexify( frame_counter, frame_counter_hex );
|
||||
memset( result, '+', sizeof( result ) );
|
||||
|
||||
if( sec_level % 4 == 0)
|
||||
tag_len = 0;
|
||||
else
|
||||
tag_len = 1 << ( sec_level % 4 + 1);
|
||||
|
||||
for( i = 0; i < source_address_len; i++ )
|
||||
iv[i] = source_address[i];
|
||||
for( i = 0; i < source_address->len; i++ )
|
||||
iv[i] = source_address->x[i];
|
||||
|
||||
for( i = 0; i < frame_counter_len; i++ )
|
||||
iv[source_address_len + i] = frame_counter[i];
|
||||
for( i = 0; i < frame_counter->len; i++ )
|
||||
iv[source_address->len + i] = frame_counter->x[i];
|
||||
|
||||
iv[source_address_len + frame_counter_len] = sec_level;
|
||||
iv[source_address->len + frame_counter->len] = sec_level;
|
||||
iv_len = sizeof( iv );
|
||||
|
||||
msg_len -= tag_len;
|
||||
memcpy( tag, msg + msg_len, tag_len );
|
||||
TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, key, key_len * 8 ) == 0 );
|
||||
|
||||
ret = mbedtls_ccm_star_auth_decrypt( &ctx, msg_len, iv, iv_len,
|
||||
add, add_len, msg, msg, msg + msg_len, tag_len );
|
||||
ret = mbedtls_ccm_star_auth_decrypt( &ctx, msg->len - tag_len, iv, iv_len,
|
||||
add->x, add->len, msg->x, result,
|
||||
msg->x + msg->len - tag_len, tag_len );
|
||||
|
||||
TEST_ASSERT( ret == output_ret );
|
||||
|
||||
TEST_ASSERT( memcmp( msg, result, result_len ) == 0 );
|
||||
TEST_ASSERT( memcmp( result, expected_result->x,
|
||||
expected_result->len ) == 0 );
|
||||
|
||||
/* Check we didn't write past the end (where the original tag is) */
|
||||
TEST_ASSERT( memcmp( msg + msg_len, tag, tag_len ) == 0 );
|
||||
TEST_ASSERT( ( msg->len + 2 ) <= sizeof( result ) );
|
||||
TEST_EQUAL( result[msg->len], '+' );
|
||||
TEST_EQUAL( result[msg->len + 1], '+' );
|
||||
|
||||
exit:
|
||||
mbedtls_ccm_free( &ctx );
|
||||
|
@ -8,60 +8,55 @@
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void chacha20_crypt( char *hex_key_string,
|
||||
char *hex_nonce_string,
|
||||
void chacha20_crypt( data_t *key_str,
|
||||
data_t *nonce_str,
|
||||
int counter,
|
||||
char *hex_src_string,
|
||||
char *hex_dst_string )
|
||||
data_t *src_str,
|
||||
data_t *expected_output_str )
|
||||
{
|
||||
unsigned char key_str[32]; /* size set by the standard */
|
||||
unsigned char nonce_str[12]; /* size set by the standard */
|
||||
unsigned char src_str[375]; /* max size of binary input */
|
||||
unsigned char dst_str[751]; /* hex expansion of the above */
|
||||
unsigned char output[751];
|
||||
size_t key_len;
|
||||
size_t nonce_len;
|
||||
size_t src_len;
|
||||
size_t dst_len;
|
||||
unsigned char output[375];
|
||||
mbedtls_chacha20_context ctx;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( nonce_str, 0x00, sizeof( nonce_str ) );
|
||||
memset( src_str, 0x00, sizeof( src_str ) );
|
||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
/*
|
||||
* Buffers to store the ASCII string representation of output and
|
||||
* expected_output_str.
|
||||
*/
|
||||
unsigned char output_string[751] = { '\0' };
|
||||
unsigned char expected_output_string[751] = { '\0' };
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
nonce_len = unhexify( nonce_str, hex_nonce_string );
|
||||
src_len = unhexify( src_str, hex_src_string );
|
||||
dst_len = unhexify( dst_str, hex_dst_string );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
|
||||
TEST_ASSERT( src_len == dst_len );
|
||||
TEST_ASSERT( key_len == 32U );
|
||||
TEST_ASSERT( nonce_len == 12U );
|
||||
TEST_ASSERT( src_str->len == expected_output_str->len );
|
||||
TEST_ASSERT( key_str->len == 32U );
|
||||
TEST_ASSERT( nonce_str->len == 12U );
|
||||
|
||||
/*
|
||||
* Test the integrated API
|
||||
*/
|
||||
TEST_ASSERT( mbedtls_chacha20_crypt( key_str, nonce_str, counter, src_len, src_str, output ) == 0 );
|
||||
TEST_ASSERT( mbedtls_chacha20_crypt( key_str->x, nonce_str->x, counter, src_str->len, src_str->x, output ) == 0 );
|
||||
|
||||
hexify( dst_str, output, src_len );
|
||||
TEST_ASSERT( strcmp( (char*) dst_str, hex_dst_string ) == 0 );
|
||||
mbedtls_test_hexify( expected_output_string,
|
||||
expected_output_str->x,
|
||||
expected_output_str->len);
|
||||
mbedtls_test_hexify( output_string, output, src_str->len );
|
||||
TEST_ASSERT( strcmp( (char *)output_string,
|
||||
(char *)expected_output_string ) == 0 );
|
||||
|
||||
/*
|
||||
* Test the streaming API
|
||||
*/
|
||||
mbedtls_chacha20_init( &ctx );
|
||||
|
||||
TEST_ASSERT( mbedtls_chacha20_setkey( &ctx, key_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_chacha20_setkey( &ctx, key_str->x ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_chacha20_starts( &ctx, nonce_str, counter ) == 0 );
|
||||
TEST_ASSERT( mbedtls_chacha20_starts( &ctx, nonce_str->x, counter ) == 0 );
|
||||
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
TEST_ASSERT( mbedtls_chacha20_update( &ctx, src_len, src_str, output ) == 0 );
|
||||
TEST_ASSERT( mbedtls_chacha20_update( &ctx, src_str->len, src_str->x, output ) == 0 );
|
||||
|
||||
hexify( dst_str, output, src_len );
|
||||
TEST_ASSERT( strcmp( (char*) dst_str, hex_dst_string ) == 0 );
|
||||
mbedtls_test_hexify( output_string, output, src_str->len );
|
||||
TEST_ASSERT( strcmp( (char *)output_string,
|
||||
(char *)expected_output_string ) == 0 );
|
||||
|
||||
/*
|
||||
* Test the streaming API again, piecewise
|
||||
@ -69,14 +64,16 @@ void chacha20_crypt( char *hex_key_string,
|
||||
|
||||
/* Don't free/init the context nor set the key again,
|
||||
* in order to test that starts() does the right thing. */
|
||||
TEST_ASSERT( mbedtls_chacha20_starts( &ctx, nonce_str, counter ) == 0 );
|
||||
TEST_ASSERT( mbedtls_chacha20_starts( &ctx, nonce_str->x, counter ) == 0 );
|
||||
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
TEST_ASSERT( mbedtls_chacha20_update( &ctx, 1, src_str, output ) == 0 );
|
||||
TEST_ASSERT( mbedtls_chacha20_update( &ctx, src_len - 1, src_str + 1, output + 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_chacha20_update( &ctx, 1, src_str->x, output ) == 0 );
|
||||
TEST_ASSERT( mbedtls_chacha20_update( &ctx, src_str->len - 1,
|
||||
src_str->x + 1, output + 1 ) == 0 );
|
||||
|
||||
hexify( dst_str, output, src_len );
|
||||
TEST_ASSERT( strcmp( (char*) dst_str, hex_dst_string ) == 0 );
|
||||
mbedtls_test_hexify( output_string, output, src_str->len );
|
||||
TEST_ASSERT( strcmp( (char *)output_string,
|
||||
(char *)expected_output_string ) == 0 );
|
||||
|
||||
mbedtls_chacha20_free( &ctx );
|
||||
}
|
||||
|
@ -8,53 +8,27 @@
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_chachapoly_enc( char *hex_key_string, char *hex_nonce_string, char *hex_aad_string, char *hex_input_string, char *hex_output_string, char *hex_mac_string )
|
||||
void mbedtls_chachapoly_enc( data_t *key_str, data_t *nonce_str, data_t *aad_str, data_t *input_str, data_t *output_str, data_t *mac_str )
|
||||
{
|
||||
unsigned char key_str[32]; /* size set by the standard */
|
||||
unsigned char nonce_str[12]; /* size set by the standard */
|
||||
unsigned char aad_str[12]; /* max size of test data so far */
|
||||
unsigned char input_str[265]; /* max size of binary input/output so far */
|
||||
unsigned char output_str[265];
|
||||
unsigned char output[265];
|
||||
unsigned char mac_str[16]; /* size set by the standard */
|
||||
unsigned char mac[16]; /* size set by the standard */
|
||||
size_t input_len;
|
||||
size_t output_len;
|
||||
size_t aad_len;
|
||||
size_t key_len;
|
||||
size_t nonce_len;
|
||||
size_t mac_len;
|
||||
mbedtls_chachapoly_context ctx;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( nonce_str, 0x00, sizeof( nonce_str ) );
|
||||
memset( aad_str, 0x00, sizeof( aad_str ) );
|
||||
memset( input_str, 0x00, sizeof( input_str ) );
|
||||
memset( output_str, 0x00, sizeof( output_str ) );
|
||||
memset( mac_str, 0x00, sizeof( mac_str ) );
|
||||
|
||||
aad_len = unhexify( aad_str, hex_aad_string );
|
||||
input_len = unhexify( input_str, hex_input_string );
|
||||
output_len = unhexify( output_str, hex_output_string );
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
nonce_len = unhexify( nonce_str, hex_nonce_string );
|
||||
mac_len = unhexify( mac_str, hex_mac_string );
|
||||
|
||||
TEST_ASSERT( key_len == 32 );
|
||||
TEST_ASSERT( nonce_len == 12 );
|
||||
TEST_ASSERT( mac_len == 16 );
|
||||
TEST_ASSERT( key_str->len == 32 );
|
||||
TEST_ASSERT( nonce_str->len == 12 );
|
||||
TEST_ASSERT( mac_str->len == 16 );
|
||||
|
||||
mbedtls_chachapoly_init( &ctx );
|
||||
|
||||
TEST_ASSERT( mbedtls_chachapoly_setkey( &ctx, key_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_chachapoly_setkey( &ctx, key_str->x ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_chachapoly_encrypt_and_tag( &ctx,
|
||||
input_len, nonce_str,
|
||||
aad_str, aad_len,
|
||||
input_str, output, mac ) == 0 );
|
||||
input_str->len, nonce_str->x,
|
||||
aad_str->x, aad_str->len,
|
||||
input_str->x, output, mac ) == 0 );
|
||||
|
||||
TEST_ASSERT( memcmp( output_str, output, output_len ) == 0 );
|
||||
TEST_ASSERT( memcmp( mac_str, mac, 16U ) == 0 );
|
||||
TEST_ASSERT( memcmp( output_str->x, output, output_str->len ) == 0 );
|
||||
TEST_ASSERT( memcmp( mac_str->x, mac, 16U ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_chachapoly_free( &ctx );
|
||||
@ -62,55 +36,29 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_chachapoly_dec( char *hex_key_string, char *hex_nonce_string, char *hex_aad_string, char *hex_input_string, char *hex_output_string, char *hex_mac_string, int ret_exp )
|
||||
void mbedtls_chachapoly_dec( data_t *key_str, data_t *nonce_str, data_t *aad_str, data_t *input_str, data_t *output_str, data_t *mac_str, int ret_exp )
|
||||
{
|
||||
unsigned char key_str[32]; /* size set by the standard */
|
||||
unsigned char nonce_str[12]; /* size set by the standard */
|
||||
unsigned char aad_str[12]; /* max size of test data so far */
|
||||
unsigned char input_str[265]; /* max size of binary input/output so far */
|
||||
unsigned char output_str[265];
|
||||
unsigned char output[265];
|
||||
unsigned char mac_str[16]; /* size set by the standard */
|
||||
size_t input_len;
|
||||
size_t output_len;
|
||||
size_t aad_len;
|
||||
size_t key_len;
|
||||
size_t nonce_len;
|
||||
size_t mac_len;
|
||||
int ret;
|
||||
mbedtls_chachapoly_context ctx;
|
||||
|
||||
memset( key_str, 0x00, sizeof( key_str ) );
|
||||
memset( nonce_str, 0x00, sizeof( nonce_str ) );
|
||||
memset( aad_str, 0x00, sizeof( aad_str ) );
|
||||
memset( input_str, 0x00, sizeof( input_str ) );
|
||||
memset( output_str, 0x00, sizeof( output_str ) );
|
||||
memset( mac_str, 0x00, sizeof( mac_str ) );
|
||||
|
||||
aad_len = unhexify( aad_str, hex_aad_string );
|
||||
input_len = unhexify( input_str, hex_input_string );
|
||||
output_len = unhexify( output_str, hex_output_string );
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
nonce_len = unhexify( nonce_str, hex_nonce_string );
|
||||
mac_len = unhexify( mac_str, hex_mac_string );
|
||||
|
||||
TEST_ASSERT( key_len == 32 );
|
||||
TEST_ASSERT( nonce_len == 12 );
|
||||
TEST_ASSERT( mac_len == 16 );
|
||||
TEST_ASSERT( key_str->len == 32 );
|
||||
TEST_ASSERT( nonce_str->len == 12 );
|
||||
TEST_ASSERT( mac_str->len == 16 );
|
||||
|
||||
mbedtls_chachapoly_init( &ctx );
|
||||
|
||||
TEST_ASSERT( mbedtls_chachapoly_setkey( &ctx, key_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_chachapoly_setkey( &ctx, key_str->x ) == 0 );
|
||||
|
||||
ret = mbedtls_chachapoly_auth_decrypt( &ctx,
|
||||
input_len, nonce_str,
|
||||
aad_str, aad_len,
|
||||
mac_str, input_str, output );
|
||||
input_str->len, nonce_str->x,
|
||||
aad_str->x, aad_str->len,
|
||||
mac_str->x, input_str->x, output );
|
||||
|
||||
TEST_ASSERT( ret == ret_exp );
|
||||
if( ret_exp == 0 )
|
||||
{
|
||||
TEST_ASSERT( memcmp( output_str, output, output_len ) == 0 );
|
||||
TEST_ASSERT( memcmp( output_str->x, output, output_str->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@ -10,7 +10,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
#include "psa_crypto_helpers.h"
|
||||
#include "test/psa_crypto_helpers.h"
|
||||
#endif
|
||||
|
||||
/* END_HEADER */
|
||||
@ -1125,26 +1125,17 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_WITH_PADDING */
|
||||
void test_vec_crypt( int cipher_id, int operation, char *hex_key,
|
||||
char *hex_iv, char *hex_input, char *hex_result,
|
||||
void test_vec_crypt( int cipher_id, int operation, data_t *key,
|
||||
data_t *iv, data_t *input, data_t *result,
|
||||
int finish_result, int use_psa )
|
||||
{
|
||||
unsigned char key[50];
|
||||
unsigned char input[16];
|
||||
unsigned char result[16];
|
||||
unsigned char iv[16];
|
||||
size_t key_len, iv_len, inputlen, resultlen;
|
||||
mbedtls_cipher_context_t ctx;
|
||||
unsigned char output[32];
|
||||
size_t outlen;
|
||||
|
||||
mbedtls_cipher_init( &ctx );
|
||||
|
||||
memset( key, 0x00, sizeof( key ) );
|
||||
memset( input, 0x00, sizeof( input ) );
|
||||
memset( result, 0x00, sizeof( result ) );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( iv, 0x00, sizeof( iv ) );
|
||||
|
||||
/* Prepare context */
|
||||
#if !defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
@ -1161,23 +1152,17 @@ void test_vec_crypt( int cipher_id, int operation, char *hex_key,
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_setup( &ctx,
|
||||
mbedtls_cipher_info_from_type( cipher_id ) ) );
|
||||
|
||||
key_len = unhexify( key, hex_key );
|
||||
inputlen = unhexify( input, hex_input );
|
||||
resultlen = unhexify( result, hex_result );
|
||||
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key, 8 * key_len, operation ) );
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key->x, 8 * key->len, operation ) );
|
||||
if( MBEDTLS_MODE_CBC == ctx.cipher_info->mode )
|
||||
TEST_ASSERT( 0 == mbedtls_cipher_set_padding_mode( &ctx, MBEDTLS_PADDING_NONE ) );
|
||||
|
||||
iv_len = unhexify( iv, hex_iv );
|
||||
|
||||
TEST_ASSERT( finish_result == mbedtls_cipher_crypt( &ctx, iv_len ? iv : NULL,
|
||||
iv_len, input, inputlen,
|
||||
TEST_ASSERT( finish_result == mbedtls_cipher_crypt( &ctx, iv->len ? iv->x : NULL,
|
||||
iv->len, input->x, input->len,
|
||||
output, &outlen ) );
|
||||
TEST_ASSERT( resultlen == outlen );
|
||||
TEST_ASSERT( result->len == outlen );
|
||||
/* check plaintext only if everything went fine */
|
||||
if( 0 == finish_result )
|
||||
TEST_ASSERT( 0 == memcmp( output, result, outlen ) );
|
||||
TEST_ASSERT( 0 == memcmp( output, result->x, outlen ) );
|
||||
|
||||
exit:
|
||||
mbedtls_cipher_free( &ctx );
|
||||
|
@ -3,7 +3,7 @@ depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_GCM_C
|
||||
dec_empty_buf:MBEDTLS_CIPHER_CAMELLIA_128_GCM:0:0
|
||||
|
||||
AES GCM Decrypt empty buffer
|
||||
depends_on:MBEDTLS_CIPHER_AES_128_GCM:MBEDTLS_GCM_C
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C
|
||||
dec_empty_buf:MBEDTLS_CIPHER_AES_128_GCM:0:0
|
||||
|
||||
Aria GCM Decrypt empty buffer
|
||||
|
@ -316,7 +316,8 @@ void ctr_drbg_seed_file( char * path, int ret )
|
||||
|
||||
mbedtls_ctr_drbg_init( &ctx );
|
||||
|
||||
TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctx, rnd_std_rand, NULL, NULL, 0 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctx, mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL, 0 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ctr_drbg_write_seed_file( &ctx, path ) == ret );
|
||||
TEST_ASSERT( mbedtls_ctr_drbg_update_seed_file( &ctx, path ) == ret );
|
||||
|
||||
|
@ -28,7 +28,8 @@ void des_encrypt_ecb( data_t * key_str, data_t * src_str,
|
||||
mbedtls_des_setkey_enc( &ctx, key_str->x );
|
||||
TEST_ASSERT( mbedtls_des_crypt_ecb( &ctx, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
8, hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_des_free( &ctx );
|
||||
@ -49,7 +50,8 @@ void des_decrypt_ecb( data_t * key_str, data_t * src_str,
|
||||
mbedtls_des_setkey_dec( &ctx, key_str->x );
|
||||
TEST_ASSERT( mbedtls_des_crypt_ecb( &ctx, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
8, hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_des_free( &ctx );
|
||||
@ -73,7 +75,9 @@ void des_encrypt_cbc( data_t * key_str, data_t * iv_str,
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -98,7 +102,9 @@ void des_decrypt_cbc( data_t * key_str, data_t * iv_str,
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -126,7 +132,8 @@ void des3_encrypt_ecb( int key_count, data_t * key_str,
|
||||
|
||||
TEST_ASSERT( mbedtls_des3_crypt_ecb( &ctx, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
8, hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_des3_free( &ctx );
|
||||
@ -153,7 +160,8 @@ void des3_decrypt_ecb( int key_count, data_t * key_str,
|
||||
|
||||
TEST_ASSERT( mbedtls_des3_crypt_ecb( &ctx, src_str->x, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
8, hex_dst_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_des3_free( &ctx );
|
||||
@ -184,7 +192,9 @@ void des3_encrypt_cbc( int key_count, data_t * key_str,
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -216,7 +226,9 @@ void des3_decrypt_cbc( int key_count, data_t * key_str,
|
||||
if( cbc_result == 0 )
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@ -36,17 +36,17 @@ void dhm_invalid_params( )
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( NULL, buflen,
|
||||
buf, &len,
|
||||
rnd_std_rand,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( &ctx, buflen,
|
||||
NULL, &len,
|
||||
rnd_std_rand,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( &ctx, buflen,
|
||||
buf, NULL,
|
||||
rnd_std_rand,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( &ctx, buflen,
|
||||
@ -69,12 +69,12 @@ void dhm_invalid_params( )
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_public( NULL, buflen,
|
||||
buf, buflen,
|
||||
rnd_std_rand,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_public( &ctx, buflen,
|
||||
NULL, buflen,
|
||||
rnd_std_rand,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_public( &ctx, buflen,
|
||||
@ -83,16 +83,16 @@ void dhm_invalid_params( )
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_calc_secret( NULL, buf, buflen,
|
||||
&len, rnd_std_rand,
|
||||
mbedtls_dhm_calc_secret( NULL, buf, buflen, &len,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_calc_secret( &ctx, NULL, buflen,
|
||||
&len, rnd_std_rand,
|
||||
mbedtls_dhm_calc_secret( &ctx, NULL, buflen, &len,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_calc_secret( &ctx, buf, buflen,
|
||||
NULL, rnd_std_rand,
|
||||
mbedtls_dhm_calc_secret( &ctx, buf, buflen, NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||
@ -130,7 +130,7 @@ void dhm_do_dhm( int radix_P, char *input_P,
|
||||
size_t sec_srv_len;
|
||||
size_t sec_cli_len;
|
||||
int x_size, i;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
|
||||
mbedtls_dhm_init( &ctx_srv );
|
||||
mbedtls_dhm_init( &ctx_cli );
|
||||
@ -138,7 +138,7 @@ void dhm_do_dhm( int radix_P, char *input_P,
|
||||
memset( pub_cli, 0x00, 1000 );
|
||||
memset( sec_srv, 0x00, 1000 );
|
||||
memset( sec_cli, 0x00, 1000 );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
/*
|
||||
* Set params
|
||||
@ -151,7 +151,9 @@ void dhm_do_dhm( int radix_P, char *input_P,
|
||||
/*
|
||||
* First key exchange
|
||||
*/
|
||||
TEST_ASSERT( mbedtls_dhm_make_params( &ctx_srv, x_size, ske, &ske_len, &rnd_pseudo_rand, &rnd_info ) == result );
|
||||
TEST_ASSERT( mbedtls_dhm_make_params( &ctx_srv, x_size, ske, &ske_len,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == result );
|
||||
if ( result != 0 )
|
||||
goto exit;
|
||||
|
||||
@ -159,10 +161,15 @@ void dhm_do_dhm( int radix_P, char *input_P,
|
||||
ske[ske_len++] = 0;
|
||||
TEST_ASSERT( mbedtls_dhm_read_params( &ctx_cli, &p, ske + ske_len ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_dhm_make_public( &ctx_cli, x_size, pub_cli, pub_cli_len, &rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_dhm_make_public( &ctx_cli, x_size, pub_cli, pub_cli_len,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_dhm_read_public( &ctx_srv, pub_cli, pub_cli_len ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv, sizeof( sec_srv ), &sec_srv_len, &rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv, sizeof( sec_srv ),
|
||||
&sec_srv_len,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_cli, sec_cli, sizeof( sec_cli ), &sec_cli_len, NULL, NULL ) == 0 );
|
||||
|
||||
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
||||
@ -173,7 +180,10 @@ void dhm_do_dhm( int radix_P, char *input_P,
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
sec_srv_len = 1000;
|
||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv, sizeof( sec_srv ), &sec_srv_len, &rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv,
|
||||
sizeof( sec_srv ), &sec_srv_len,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
|
||||
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
||||
TEST_ASSERT( sec_srv_len != 0 );
|
||||
@ -185,15 +195,22 @@ void dhm_do_dhm( int radix_P, char *input_P,
|
||||
*/
|
||||
p = ske;
|
||||
|
||||
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,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
ske[ske_len++] = 0;
|
||||
ske[ske_len++] = 0;
|
||||
TEST_ASSERT( mbedtls_dhm_read_params( &ctx_cli, &p, ske + ske_len ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_dhm_make_public( &ctx_cli, x_size, pub_cli, pub_cli_len, &rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_dhm_make_public( &ctx_cli, x_size, pub_cli, pub_cli_len,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_dhm_read_public( &ctx_srv, pub_cli, pub_cli_len ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv, sizeof( sec_srv ), &sec_srv_len, &rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv, sizeof( sec_srv ),
|
||||
&sec_srv_len,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_cli, sec_cli, sizeof( sec_cli ), &sec_cli_len, NULL, NULL ) == 0 );
|
||||
|
||||
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
||||
|
@ -19,7 +19,7 @@ exit:
|
||||
|
||||
static int load_private_key( int grp_id, data_t *private_key,
|
||||
mbedtls_ecp_keypair *ecp,
|
||||
rnd_pseudo_info *rnd_info )
|
||||
mbedtls_test_rnd_pseudo_info *rnd_info )
|
||||
{
|
||||
int ok = 0;
|
||||
TEST_ASSERT( mbedtls_ecp_read_key( grp_id, ecp,
|
||||
@ -29,7 +29,8 @@ static int load_private_key( int grp_id, data_t *private_key,
|
||||
/* Calculate the public key from the private key. */
|
||||
TEST_ASSERT( mbedtls_ecp_mul( &ecp->grp, &ecp->Q, &ecp->d,
|
||||
&ecp->grp.G,
|
||||
&rnd_pseudo_rand, rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
rnd_info ) == 0 );
|
||||
ok = 1;
|
||||
exit:
|
||||
return( ok );
|
||||
@ -72,49 +73,54 @@ void ecdh_invalid_param( )
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_gen_public( NULL, &m, &P,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_gen_public( &grp, NULL, &P,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_gen_public( &grp, &m, NULL,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_gen_public( &grp, &m, &P,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_compute_shared( NULL, &m, &P, &m,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_compute_shared( &grp, NULL, &P, &m,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_compute_shared( &grp, &m, NULL, &m,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_compute_shared( &grp, &m, &P, NULL,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_setup( NULL, valid_grp ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_params( NULL, &olen,
|
||||
buf, buflen,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_ecdh_make_params( NULL, &olen, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_params( &ctx, NULL,
|
||||
buf, buflen,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_ecdh_make_params( &ctx, NULL, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_params( &ctx, &olen,
|
||||
NULL, buflen,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_ecdh_make_params( &ctx, &olen, NULL, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_params( &ctx, &olen,
|
||||
buf, buflen,
|
||||
NULL, NULL ) );
|
||||
mbedtls_ecdh_make_params( &ctx, &olen, buf, buflen, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_read_params( NULL,
|
||||
@ -141,25 +147,19 @@ void ecdh_invalid_param( )
|
||||
invalid_side ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_public( NULL, &olen,
|
||||
buf, buflen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecdh_make_public( NULL, &olen, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_public( &ctx, NULL,
|
||||
buf, buflen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecdh_make_public( &ctx, NULL, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_public( &ctx, &olen,
|
||||
NULL, buflen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecdh_make_public( &ctx, &olen, NULL, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_make_public( &ctx, &olen,
|
||||
buf, buflen,
|
||||
NULL,
|
||||
NULL ) );
|
||||
mbedtls_ecdh_make_public( &ctx, &olen, buf, buflen, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_read_public( NULL, buf, buflen ) );
|
||||
@ -167,17 +167,16 @@ void ecdh_invalid_param( )
|
||||
mbedtls_ecdh_read_public( &ctx, NULL, buflen ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_calc_secret( NULL, &olen, buf, buflen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecdh_calc_secret( NULL, &olen, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_calc_secret( &ctx, NULL, buf, buflen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecdh_calc_secret( &ctx, NULL, buf, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdh_calc_secret( &ctx, &olen, NULL, buflen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecdh_calc_secret( &ctx, &olen, NULL, buflen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
@ -190,22 +189,25 @@ void ecdh_primitive_random( int id )
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecp_point qA, qB;
|
||||
mbedtls_mpi dA, dB, zA, zB;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
|
||||
mbedtls_ecp_group_init( &grp );
|
||||
mbedtls_ecp_point_init( &qA ); mbedtls_ecp_point_init( &qB );
|
||||
mbedtls_mpi_init( &dA ); mbedtls_mpi_init( &dB );
|
||||
mbedtls_mpi_init( &zA ); mbedtls_mpi_init( &zB );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dA, &qA, &rnd_pseudo_rand, &rnd_info )
|
||||
== 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dB, &qB, &rnd_pseudo_rand, &rnd_info )
|
||||
== 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dA, &qA,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dB, &qB,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_compute_shared( &grp, &zA, &qB, &dA,
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_compute_shared( &grp, &zB, &qA, &dB,
|
||||
NULL, NULL ) == 0 );
|
||||
|
||||
@ -227,7 +229,7 @@ void ecdh_primitive_testvec( int id, data_t * rnd_buf_A, char * xA_str,
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecp_point qA, qB;
|
||||
mbedtls_mpi dA, dB, zA, zB, check;
|
||||
rnd_buf_info rnd_info_A, rnd_info_B;
|
||||
mbedtls_test_rnd_buf_info rnd_info_A, rnd_info_B;
|
||||
|
||||
mbedtls_ecp_group_init( &grp );
|
||||
mbedtls_ecp_point_init( &qA ); mbedtls_ecp_point_init( &qB );
|
||||
@ -269,7 +271,8 @@ void ecdh_primitive_testvec( int id, data_t * rnd_buf_A, char * xA_str,
|
||||
}
|
||||
|
||||
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dA, &qA,
|
||||
rnd_buffer_rand, &rnd_info_A ) == 0 );
|
||||
mbedtls_test_rnd_buffer_rand,
|
||||
&rnd_info_A ) == 0 );
|
||||
TEST_ASSERT( ! mbedtls_ecp_is_zero( &qA ) );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &check, 16, xA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qA.X, &check ) == 0 );
|
||||
@ -277,7 +280,8 @@ void ecdh_primitive_testvec( int id, data_t * rnd_buf_A, char * xA_str,
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qA.Y, &check ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dB, &qB,
|
||||
rnd_buffer_rand, &rnd_info_B ) == 0 );
|
||||
mbedtls_test_rnd_buffer_rand,
|
||||
&rnd_info_B ) == 0 );
|
||||
TEST_ASSERT( ! mbedtls_ecp_is_zero( &qB ) );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &check, 16, xB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qB.X, &check ) == 0 );
|
||||
@ -305,28 +309,31 @@ void ecdh_exchange( int id )
|
||||
unsigned char buf[1000];
|
||||
const unsigned char *vbuf;
|
||||
size_t len;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
unsigned char res_buf[1000];
|
||||
size_t res_len;
|
||||
|
||||
mbedtls_ecdh_init( &srv );
|
||||
mbedtls_ecdh_init( &cli );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecdh_setup( &srv, id ) == 0 );
|
||||
|
||||
memset( buf, 0x00, sizeof( buf ) ); vbuf = buf;
|
||||
TEST_ASSERT( mbedtls_ecdh_make_params( &srv, &len, buf, 1000,
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_read_params( &cli, &vbuf, buf + len ) == 0 );
|
||||
|
||||
memset( buf, 0x00, sizeof( buf ) );
|
||||
TEST_ASSERT( mbedtls_ecdh_make_public( &cli, &len, buf, 1000,
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_read_public( &srv, buf, len ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecdh_calc_secret( &srv, &len, buf, 1000,
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_calc_secret( &cli, &res_len, res_buf, 1000,
|
||||
NULL, NULL ) == 0 );
|
||||
TEST_ASSERT( len == res_len );
|
||||
@ -339,7 +346,7 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_ECP_RESTARTABLE */
|
||||
void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str,
|
||||
void ecdh_restart( int id, data_t *dA, data_t *dB, data_t *z,
|
||||
int enable, int max_ops, int min_restart, int max_restart )
|
||||
{
|
||||
int ret;
|
||||
@ -347,11 +354,7 @@ void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str,
|
||||
unsigned char buf[1000];
|
||||
const unsigned char *vbuf;
|
||||
size_t len;
|
||||
unsigned char z[MBEDTLS_ECP_MAX_BYTES];
|
||||
size_t z_len;
|
||||
unsigned char rnd_buf_A[MBEDTLS_ECP_MAX_BYTES];
|
||||
unsigned char rnd_buf_B[MBEDTLS_ECP_MAX_BYTES];
|
||||
rnd_buf_info rnd_info_A, rnd_info_B;
|
||||
mbedtls_test_rnd_buf_info rnd_info_A, rnd_info_B;
|
||||
int cnt_restart;
|
||||
mbedtls_ecp_group grp;
|
||||
|
||||
@ -359,13 +362,11 @@ void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str,
|
||||
mbedtls_ecdh_init( &srv );
|
||||
mbedtls_ecdh_init( &cli );
|
||||
|
||||
z_len = unhexify( z, z_str );
|
||||
rnd_info_A.buf = dA->x;
|
||||
rnd_info_A.length = dA->len;
|
||||
|
||||
rnd_info_A.buf = rnd_buf_A;
|
||||
rnd_info_A.length = unhexify( rnd_buf_A, dA_str );
|
||||
|
||||
rnd_info_B.buf = rnd_buf_B;
|
||||
rnd_info_B.length = unhexify( rnd_buf_B, dB_str );
|
||||
rnd_info_B.buf = dB->x;
|
||||
rnd_info_B.length = dB->len;
|
||||
|
||||
/* The ECDH context is not guaranteed ot have an mbedtls_ecp_group structure
|
||||
* in every configuration, therefore we load it separately. */
|
||||
@ -393,7 +394,8 @@ void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str,
|
||||
cnt_restart = 0;
|
||||
do {
|
||||
ret = mbedtls_ecdh_make_params( &srv, &len, buf, sizeof( buf ),
|
||||
rnd_buffer_rand, &rnd_info_A );
|
||||
mbedtls_test_rnd_buffer_rand,
|
||||
&rnd_info_A );
|
||||
} while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart );
|
||||
|
||||
TEST_ASSERT( ret == 0 );
|
||||
@ -411,7 +413,8 @@ void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str,
|
||||
cnt_restart = 0;
|
||||
do {
|
||||
ret = mbedtls_ecdh_make_public( &cli, &len, buf, sizeof( buf ),
|
||||
rnd_buffer_rand, &rnd_info_B );
|
||||
mbedtls_test_rnd_buffer_rand,
|
||||
&rnd_info_B );
|
||||
} while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart );
|
||||
|
||||
TEST_ASSERT( ret == 0 );
|
||||
@ -435,8 +438,8 @@ void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str,
|
||||
TEST_ASSERT( cnt_restart >= min_restart );
|
||||
TEST_ASSERT( cnt_restart <= max_restart );
|
||||
|
||||
TEST_ASSERT( len == z_len );
|
||||
TEST_ASSERT( memcmp( buf, z, len ) == 0 );
|
||||
TEST_ASSERT( len == z->len );
|
||||
TEST_ASSERT( memcmp( buf, z->x, len ) == 0 );
|
||||
|
||||
/* client computes shared secret */
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
@ -452,8 +455,8 @@ void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str,
|
||||
TEST_ASSERT( cnt_restart >= min_restart );
|
||||
TEST_ASSERT( cnt_restart <= max_restart );
|
||||
|
||||
TEST_ASSERT( len == z_len );
|
||||
TEST_ASSERT( memcmp( buf, z, len ) == 0 );
|
||||
TEST_ASSERT( len == z->len );
|
||||
TEST_ASSERT( memcmp( buf, z->x, len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_ecp_group_free( &grp );
|
||||
@ -470,26 +473,29 @@ void ecdh_exchange_legacy( int id )
|
||||
const unsigned char *vbuf;
|
||||
size_t len;
|
||||
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
|
||||
mbedtls_ecdh_init( &srv );
|
||||
mbedtls_ecdh_init( &cli );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &srv.grp, id ) == 0 );
|
||||
|
||||
memset( buf, 0x00, sizeof( buf ) ); vbuf = buf;
|
||||
TEST_ASSERT( mbedtls_ecdh_make_params( &srv, &len, buf, 1000,
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_read_params( &cli, &vbuf, buf + len ) == 0 );
|
||||
|
||||
memset( buf, 0x00, sizeof( buf ) );
|
||||
TEST_ASSERT( mbedtls_ecdh_make_public( &cli, &len, buf, 1000,
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_read_public( &srv, buf, len ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecdh_calc_secret( &srv, &len, buf, 1000,
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_calc_secret( &cli, &len, buf, 1000, NULL,
|
||||
NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &srv.z, &cli.z ) == 0 );
|
||||
@ -507,14 +513,14 @@ void ecdh_exchange_calc_secret( int grp_id,
|
||||
int ours_first,
|
||||
data_t *expected )
|
||||
{
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
mbedtls_ecp_keypair our_key;
|
||||
mbedtls_ecp_keypair their_key;
|
||||
mbedtls_ecdh_context ecdh;
|
||||
unsigned char shared_secret[MBEDTLS_ECP_MAX_BYTES];
|
||||
size_t shared_secret_length = 0;
|
||||
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
mbedtls_ecdh_init( &ecdh );
|
||||
mbedtls_ecp_keypair_init( &our_key );
|
||||
mbedtls_ecp_keypair_init( &their_key );
|
||||
@ -545,7 +551,7 @@ void ecdh_exchange_calc_secret( int grp_id,
|
||||
&ecdh,
|
||||
&shared_secret_length,
|
||||
shared_secret, sizeof( shared_secret ),
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( shared_secret_length == expected->len );
|
||||
TEST_ASSERT( memcmp( expected->x, shared_secret,
|
||||
shared_secret_length ) == 0 );
|
||||
@ -565,12 +571,12 @@ void ecdh_exchange_get_params_fail( int our_grp_id,
|
||||
int ours_first,
|
||||
int expected_ret )
|
||||
{
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
mbedtls_ecp_keypair our_key;
|
||||
mbedtls_ecp_keypair their_key;
|
||||
mbedtls_ecdh_context ecdh;
|
||||
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
mbedtls_ecdh_init( &ecdh );
|
||||
mbedtls_ecp_keypair_init( &our_key );
|
||||
mbedtls_ecp_keypair_init( &their_key );
|
||||
|
@ -31,23 +31,28 @@ void ecdsa_invalid_param( )
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( NULL, &m, &m, &m,
|
||||
buf, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( &grp, NULL, &m, &m,
|
||||
buf, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( &grp, &m, NULL, &m,
|
||||
buf, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( &grp, &m, &m, NULL,
|
||||
buf, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( &grp, &m, &m, &m,
|
||||
NULL, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign( &grp, &m, &m, &m,
|
||||
buf, sizeof( buf ),
|
||||
@ -58,27 +63,32 @@ void ecdsa_invalid_param( )
|
||||
mbedtls_ecdsa_sign_det_ext( NULL, &m, &m, &m,
|
||||
buf, sizeof( buf ),
|
||||
valid_md,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign_det_ext( &grp, NULL, &m, &m,
|
||||
buf, sizeof( buf ),
|
||||
valid_md,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign_det_ext( &grp, &m, NULL, &m,
|
||||
buf, sizeof( buf ),
|
||||
valid_md,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign_det_ext( &grp, &m, &m, NULL,
|
||||
buf, sizeof( buf ),
|
||||
valid_md,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_sign_det_ext( &grp, &m, &m, &m,
|
||||
NULL, sizeof( buf ),
|
||||
valid_md,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
@ -103,62 +113,48 @@ void ecdsa_invalid_param( )
|
||||
&P, &m, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature( NULL,
|
||||
valid_md,
|
||||
buf, sizeof( buf ),
|
||||
buf, &slen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature( &ctx,
|
||||
valid_md,
|
||||
NULL, sizeof( buf ),
|
||||
buf, &slen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature( &ctx,
|
||||
valid_md,
|
||||
buf, sizeof( buf ),
|
||||
NULL, &slen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature( &ctx,
|
||||
valid_md,
|
||||
buf, sizeof( buf ),
|
||||
buf, NULL,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecdsa_write_signature( NULL, valid_md, buf, sizeof( buf ),
|
||||
buf, &slen, mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature_restartable( NULL,
|
||||
valid_md,
|
||||
buf, sizeof( buf ),
|
||||
buf, &slen,
|
||||
rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
mbedtls_ecdsa_write_signature( &ctx, valid_md, NULL, sizeof( buf ),
|
||||
buf, &slen, mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature_restartable( &ctx,
|
||||
valid_md,
|
||||
NULL, sizeof( buf ),
|
||||
buf, &slen,
|
||||
rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
mbedtls_ecdsa_write_signature( &ctx, valid_md, buf, sizeof( buf ),
|
||||
NULL, &slen, mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature_restartable( &ctx,
|
||||
valid_md,
|
||||
buf, sizeof( buf ),
|
||||
NULL, &slen,
|
||||
rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
mbedtls_ecdsa_write_signature( &ctx, valid_md, buf, sizeof( buf ),
|
||||
buf, NULL, mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature_restartable( &ctx,
|
||||
valid_md,
|
||||
buf, sizeof( buf ),
|
||||
buf, NULL,
|
||||
rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
mbedtls_ecdsa_write_signature_restartable( NULL, valid_md, buf,
|
||||
sizeof( buf ), buf, &slen,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature_restartable( &ctx, valid_md, NULL,
|
||||
sizeof( buf ), buf, &slen,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature_restartable( &ctx, valid_md, buf,
|
||||
sizeof( buf ), NULL, &slen,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_write_signature_restartable( &ctx, valid_md, buf,
|
||||
sizeof( buf ), buf, NULL,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_read_signature( NULL,
|
||||
@ -191,7 +187,8 @@ void ecdsa_invalid_param( )
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_genkey( NULL, valid_group,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecdsa_genkey( &ctx, valid_group,
|
||||
NULL, NULL ) );
|
||||
@ -213,23 +210,26 @@ void ecdsa_prim_random( int id )
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecp_point Q;
|
||||
mbedtls_mpi d, r, s;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
unsigned char buf[MBEDTLS_MD_MAX_SIZE];
|
||||
|
||||
mbedtls_ecp_group_init( &grp );
|
||||
mbedtls_ecp_point_init( &Q );
|
||||
mbedtls_mpi_init( &d ); mbedtls_mpi_init( &r ); mbedtls_mpi_init( &s );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
|
||||
/* prepare material for signature */
|
||||
TEST_ASSERT( rnd_pseudo_rand( &rnd_info, buf, sizeof( buf ) ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_rnd_pseudo_rand( &rnd_info,
|
||||
buf, sizeof( buf ) ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_gen_keypair( &grp, &d, &Q, &rnd_pseudo_rand, &rnd_info )
|
||||
== 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_gen_keypair( &grp, &d, &Q,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecdsa_sign( &grp, &r, &s, &d, buf, sizeof( buf ),
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdsa_verify( &grp, buf, sizeof( buf ), &Q, &r, &s ) == 0 );
|
||||
|
||||
exit:
|
||||
@ -248,7 +248,7 @@ void ecdsa_prim_test_vectors( int id, char * d_str, char * xQ_str,
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecp_point Q;
|
||||
mbedtls_mpi d, r, s, r_check, s_check;
|
||||
rnd_buf_info rnd_info;
|
||||
mbedtls_test_rnd_buf_info rnd_info;
|
||||
|
||||
mbedtls_ecp_group_init( &grp );
|
||||
mbedtls_ecp_point_init( &Q );
|
||||
@ -276,7 +276,7 @@ void ecdsa_prim_test_vectors( int id, char * d_str, char * xQ_str,
|
||||
}
|
||||
|
||||
TEST_ASSERT( mbedtls_ecdsa_sign( &grp, &r, &s, &d, hash->x, hash->len,
|
||||
rnd_buffer_rand, &rnd_info ) == result );
|
||||
mbedtls_test_rnd_buffer_rand, &rnd_info ) == result );
|
||||
|
||||
if ( result == 0)
|
||||
{
|
||||
@ -332,7 +332,8 @@ void ecdsa_det_test_vectors( int id, char * d_str, int md_alg, char * msg,
|
||||
|
||||
TEST_ASSERT(
|
||||
mbedtls_ecdsa_sign_det_ext( &grp, &r, &s, &d, hash, hlen,
|
||||
md_alg, rnd_std_rand, NULL )
|
||||
md_alg, mbedtls_test_rnd_std_rand,
|
||||
NULL )
|
||||
== 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &r, &r_check ) == 0 );
|
||||
@ -349,26 +350,30 @@ exit:
|
||||
void ecdsa_write_read_random( int id )
|
||||
{
|
||||
mbedtls_ecdsa_context ctx;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
unsigned char hash[32];
|
||||
unsigned char sig[200];
|
||||
size_t sig_len, i;
|
||||
|
||||
mbedtls_ecdsa_init( &ctx );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
memset( hash, 0, sizeof( hash ) );
|
||||
memset( sig, 0x2a, sizeof( sig ) );
|
||||
|
||||
/* prepare material for signature */
|
||||
TEST_ASSERT( rnd_pseudo_rand( &rnd_info, hash, sizeof( hash ) ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_rnd_pseudo_rand( &rnd_info,
|
||||
hash, sizeof( hash ) ) == 0 );
|
||||
|
||||
/* generate signing key */
|
||||
TEST_ASSERT( mbedtls_ecdsa_genkey( &ctx, id, &rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdsa_genkey( &ctx, id,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
|
||||
/* generate and write signature, then read and verify it */
|
||||
TEST_ASSERT( mbedtls_ecdsa_write_signature( &ctx, MBEDTLS_MD_SHA256,
|
||||
hash, sizeof( hash ),
|
||||
sig, &sig_len, &rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
sig, &sig_len, &mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdsa_read_signature( &ctx, hash, sizeof( hash ),
|
||||
sig, sig_len ) == 0 );
|
||||
|
||||
@ -406,33 +411,26 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_ECP_RESTARTABLE */
|
||||
void ecdsa_read_restart( int id, char *k_str, char *h_str, char *s_str,
|
||||
void ecdsa_read_restart( int id, data_t *pk, data_t *hash, data_t *sig,
|
||||
int max_ops, int min_restart, int max_restart )
|
||||
{
|
||||
mbedtls_ecdsa_context ctx;
|
||||
mbedtls_ecdsa_restart_ctx rs_ctx;
|
||||
unsigned char hash[64];
|
||||
unsigned char sig[200];
|
||||
unsigned char pk[65];
|
||||
size_t sig_len, hash_len, pk_len;
|
||||
int ret, cnt_restart;
|
||||
|
||||
mbedtls_ecdsa_init( &ctx );
|
||||
mbedtls_ecdsa_restart_init( &rs_ctx );
|
||||
|
||||
hash_len = unhexify(hash, h_str);
|
||||
sig_len = unhexify(sig, s_str);
|
||||
pk_len = unhexify(pk, k_str);
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &ctx.grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_point_read_binary( &ctx.grp, &ctx.Q, pk, pk_len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_point_read_binary( &ctx.grp, &ctx.Q,
|
||||
pk->x, pk->len ) == 0 );
|
||||
|
||||
mbedtls_ecp_set_max_ops( max_ops );
|
||||
|
||||
cnt_restart = 0;
|
||||
do {
|
||||
ret = mbedtls_ecdsa_read_signature_restartable( &ctx,
|
||||
hash, hash_len, sig, sig_len, &rs_ctx );
|
||||
hash->x, hash->len, sig->x, sig->len, &rs_ctx );
|
||||
} while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart );
|
||||
|
||||
TEST_ASSERT( ret == 0 );
|
||||
@ -440,29 +438,31 @@ void ecdsa_read_restart( int id, char *k_str, char *h_str, char *s_str,
|
||||
TEST_ASSERT( cnt_restart <= max_restart );
|
||||
|
||||
/* try modifying r */
|
||||
sig[10]++;
|
||||
|
||||
TEST_ASSERT( sig->len > 10 );
|
||||
sig->x[10]++;
|
||||
do {
|
||||
ret = mbedtls_ecdsa_read_signature_restartable( &ctx,
|
||||
hash, hash_len, sig, sig_len, &rs_ctx );
|
||||
hash->x, hash->len, sig->x, sig->len, &rs_ctx );
|
||||
} while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS );
|
||||
TEST_ASSERT( ret == MBEDTLS_ERR_ECP_VERIFY_FAILED );
|
||||
sig[10]--;
|
||||
sig->x[10]--;
|
||||
|
||||
/* try modifying s */
|
||||
sig[sig_len - 1]++;
|
||||
sig->x[sig->len - 1]++;
|
||||
do {
|
||||
ret = mbedtls_ecdsa_read_signature_restartable( &ctx,
|
||||
hash, hash_len, sig, sig_len, &rs_ctx );
|
||||
hash->x, hash->len, sig->x, sig->len, &rs_ctx );
|
||||
} while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS );
|
||||
TEST_ASSERT( ret == MBEDTLS_ERR_ECP_VERIFY_FAILED );
|
||||
sig[sig_len - 1]--;
|
||||
sig->x[sig->len - 1]--;
|
||||
|
||||
/* Do we leak memory when aborting an operation?
|
||||
* This test only makes sense when we actually restart */
|
||||
if( min_restart > 0 )
|
||||
{
|
||||
ret = mbedtls_ecdsa_read_signature_restartable( &ctx,
|
||||
hash, hash_len, sig, sig_len, &rs_ctx );
|
||||
hash->x, hash->len, sig->x, sig->len, &rs_ctx );
|
||||
TEST_ASSERT( ret == MBEDTLS_ERR_ECP_IN_PROGRESS );
|
||||
}
|
||||
|
||||
@ -474,7 +474,7 @@ exit:
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_ECP_RESTARTABLE:MBEDTLS_ECDSA_DETERMINISTIC */
|
||||
void ecdsa_write_restart( int id, char *d_str, int md_alg,
|
||||
char *msg, char *sig_str,
|
||||
char *msg, data_t *sig_check,
|
||||
int max_ops, int min_restart, int max_restart )
|
||||
{
|
||||
int ret, cnt_restart;
|
||||
@ -482,19 +482,16 @@ void ecdsa_write_restart( int id, char *d_str, int md_alg,
|
||||
mbedtls_ecdsa_context ctx;
|
||||
unsigned char hash[MBEDTLS_MD_MAX_SIZE];
|
||||
unsigned char sig[MBEDTLS_ECDSA_MAX_LEN];
|
||||
unsigned char sig_check[MBEDTLS_ECDSA_MAX_LEN];
|
||||
size_t hlen, slen, slen_check;
|
||||
size_t hlen, slen;
|
||||
const mbedtls_md_info_t *md_info;
|
||||
|
||||
mbedtls_ecdsa_restart_init( &rs_ctx );
|
||||
mbedtls_ecdsa_init( &ctx );
|
||||
memset( hash, 0, sizeof( hash ) );
|
||||
memset( sig, 0, sizeof( sig ) );
|
||||
memset( sig_check, 0, sizeof( sig_check ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &ctx.grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &ctx.d, 16, d_str ) == 0 );
|
||||
slen_check = unhexify( sig_check, sig_str );
|
||||
|
||||
md_info = mbedtls_md_info_from_type( md_alg );
|
||||
TEST_ASSERT( md_info != NULL );
|
||||
@ -514,8 +511,8 @@ void ecdsa_write_restart( int id, char *d_str, int md_alg,
|
||||
} while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart );
|
||||
|
||||
TEST_ASSERT( ret == 0 );
|
||||
TEST_ASSERT( slen == slen_check );
|
||||
TEST_ASSERT( memcmp( sig, sig_check, slen ) == 0 );
|
||||
TEST_ASSERT( slen == sig_check->len );
|
||||
TEST_ASSERT( memcmp( sig, sig_check->x, slen ) == 0 );
|
||||
|
||||
TEST_ASSERT( cnt_restart >= min_restart );
|
||||
TEST_ASSERT( cnt_restart <= max_restart );
|
||||
|
@ -136,54 +136,33 @@ void ecjpake_invalid_param( )
|
||||
mbedtls_ecjpake_check( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( NULL,
|
||||
buf, len,
|
||||
&olen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( &ctx,
|
||||
NULL, len,
|
||||
&olen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( &ctx,
|
||||
buf, len,
|
||||
NULL,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_one( &ctx,
|
||||
buf, len,
|
||||
&olen,
|
||||
NULL,
|
||||
NULL ) );
|
||||
mbedtls_ecjpake_write_round_one( NULL, buf, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( NULL,
|
||||
buf, len,
|
||||
&olen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecjpake_write_round_one( &ctx, NULL, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx,
|
||||
NULL, len,
|
||||
&olen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecjpake_write_round_one( &ctx, buf, len, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx,
|
||||
buf, len,
|
||||
NULL,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecjpake_write_round_one( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx,
|
||||
buf, len,
|
||||
&olen,
|
||||
NULL,
|
||||
NULL ) );
|
||||
mbedtls_ecjpake_write_round_two( NULL, buf, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx, NULL, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx, buf, len, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_write_round_two( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_read_round_one( NULL,
|
||||
@ -200,29 +179,19 @@ void ecjpake_invalid_param( )
|
||||
NULL, len ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( NULL,
|
||||
buf, len,
|
||||
&olen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecjpake_derive_secret( NULL, buf, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( &ctx,
|
||||
NULL, len,
|
||||
&olen,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecjpake_derive_secret( &ctx, NULL, len, &olen,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( &ctx,
|
||||
buf, len,
|
||||
NULL,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecjpake_derive_secret( &ctx, buf, len, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecjpake_derive_secret( &ctx,
|
||||
buf, len,
|
||||
&olen,
|
||||
NULL,
|
||||
NULL ) );
|
||||
mbedtls_ecjpake_derive_secret( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||
|
||||
exit:
|
||||
return;
|
||||
|
@ -450,6 +450,14 @@ ECP point multiplication Curve25519 (element of order 8) #5
|
||||
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
|
||||
ecp_test_mul:MBEDTLS_ECP_DP_CURVE25519:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2ABBACD29EC4AFF517369C660":"B8495F16056286FDB1329CEB8D09DA6AC49FF1FAE35616AEB8413B7C7AEBE0":"00":"01":"00":"01":"00":MBEDTLS_ERR_MPI_NOT_ACCEPTABLE
|
||||
|
||||
ECP point multiplication rng fail secp256r1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
ecp_test_mul_rng:MBEDTLS_ECP_DP_SECP256R1:"814264145F2F56F2E96A8E337A1284993FAF432A5ABCE59E867B7291D507A3AF"
|
||||
|
||||
ECP point multiplication rng fail Curve25519
|
||||
depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED
|
||||
ecp_test_mul_rng:MBEDTLS_ECP_DP_CURVE25519:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2ABBACD29EC4AFF517369C660"
|
||||
|
||||
ECP test vectors Curve448 (RFC 7748 6.2, after decodeUCoordinate)
|
||||
depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED
|
||||
ecp_test_vec_x:MBEDTLS_ECP_DP_CURVE448:"eb7298a5c0d8c29a1dab27f1a6826300917389449741a974f5bac9d98dc298d46555bce8bae89eeed400584bb046cf75579f51d125498f98":"a01fc432e5807f17530d1288da125b0cd453d941726436c8bbd9c5222c3da7fa639ce03db8d23b274a0721a1aed5227de6e3b731ccf7089b":"ad997351b6106f36b0d1091b929c4c37213e0d2b97e85ebb20c127691d0dad8f1d8175b0723745e639a3cb7044290b99e0e2a0c27a6a301c":"0936f37bc6c1bd07ae3dec7ab5dc06a73ca13242fb343efc72b9d82730b445f3d4b0bd077162a46dcfec6f9b590bfcbcf520cdb029a8b73e":"9d874a5137509a449ad5853040241c5236395435c36424fd560b0cb62b281d285275a740ce32a22dd1740f4aa9161cec95ccc61a18f4ff07"
|
||||
|
@ -69,12 +69,12 @@ void ecp_invalid_param( )
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_privkey( NULL,
|
||||
&m,
|
||||
rnd_std_rand,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_privkey( &grp,
|
||||
NULL,
|
||||
rnd_std_rand,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_privkey( &grp,
|
||||
@ -222,29 +222,37 @@ void ecp_invalid_param( )
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul( NULL, &P, &m, &P,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul( &grp, NULL, &m, &P,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul( &grp, &P, NULL, &P,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul( &grp, &P, &m, NULL,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul_restartable( NULL, &P, &m, &P,
|
||||
rnd_std_rand, NULL , NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL , NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul_restartable( &grp, NULL, &m, &P,
|
||||
rnd_std_rand, NULL , NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL , NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul_restartable( &grp, &P, NULL, &P,
|
||||
rnd_std_rand, NULL , NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL , NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_mul_restartable( &grp, &P, &m, NULL,
|
||||
rnd_std_rand, NULL , NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL , NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_muladd( NULL, &P, &m, &P,
|
||||
@ -300,45 +308,38 @@ void ecp_invalid_param( )
|
||||
mbedtls_ecp_check_privkey( &grp, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair_base( NULL, &P,
|
||||
&m, &P,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecp_gen_keypair_base( NULL, &P, &m, &P,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair_base( &grp, NULL,
|
||||
&m, &P,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecp_gen_keypair_base( &grp, NULL, &m, &P,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair_base( &grp, &P,
|
||||
NULL, &P,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecp_gen_keypair_base( &grp, &P, NULL, &P,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair_base( &grp, &P,
|
||||
&m, NULL,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
mbedtls_ecp_gen_keypair_base( &grp, &P, &m, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair_base( &grp, &P,
|
||||
&m, &P,
|
||||
NULL,
|
||||
NULL ) );
|
||||
mbedtls_ecp_gen_keypair_base( &grp, &P, &m, &P, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair( NULL,
|
||||
&m, &P,
|
||||
rnd_std_rand,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair( &grp,
|
||||
NULL, &P,
|
||||
rnd_std_rand,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair( &grp,
|
||||
&m, NULL,
|
||||
rnd_std_rand,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_keypair( &grp,
|
||||
@ -348,7 +349,8 @@ void ecp_invalid_param( )
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_key( valid_group, NULL,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
mbedtls_ecp_gen_key( valid_group, &kp,
|
||||
NULL, NULL ) );
|
||||
@ -576,12 +578,12 @@ void ecp_test_vect( int id, char * dA_str, char * xA_str, char * yA_str,
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecp_point R;
|
||||
mbedtls_mpi dA, xA, yA, dB, xB, yB, xZ, yZ;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
|
||||
mbedtls_ecp_group_init( &grp ); mbedtls_ecp_point_init( &R );
|
||||
mbedtls_mpi_init( &dA ); mbedtls_mpi_init( &xA ); mbedtls_mpi_init( &yA ); mbedtls_mpi_init( &dB );
|
||||
mbedtls_mpi_init( &xB ); mbedtls_mpi_init( &yB ); mbedtls_mpi_init( &xZ ); mbedtls_mpi_init( &yZ );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
|
||||
@ -597,7 +599,7 @@ void ecp_test_vect( int id, char * dA_str, char * xA_str, char * yA_str,
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &yZ, 16, yZ_str ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_mul( &grp, &R, &dA, &grp.G,
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.X, &xA ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.Y, &yA ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &R ) == 0 );
|
||||
@ -611,7 +613,7 @@ void ecp_test_vect( int id, char * dA_str, char * xA_str, char * yA_str,
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.Y, &yB ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &R ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_mul( &grp, &R, &dA, &R,
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.X, &xZ ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.Y, &yZ ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &R ) == 0 );
|
||||
@ -630,13 +632,13 @@ void ecp_test_vec_x( int id, char * dA_hex, char * xA_hex, char * dB_hex,
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecp_point R;
|
||||
mbedtls_mpi dA, xA, dB, xB, xS;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
|
||||
mbedtls_ecp_group_init( &grp ); mbedtls_ecp_point_init( &R );
|
||||
mbedtls_mpi_init( &dA ); mbedtls_mpi_init( &xA );
|
||||
mbedtls_mpi_init( &dB ); mbedtls_mpi_init( &xB );
|
||||
mbedtls_mpi_init( &xS );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
|
||||
@ -649,12 +651,12 @@ void ecp_test_vec_x( int id, char * dA_hex, char * xA_hex, char * dB_hex,
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &xS, 16, xS_hex ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_mul( &grp, &R, &dA, &grp.G,
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &R ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.X, &xA ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_mul( &grp, &R, &dB, &R,
|
||||
&rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &R ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.X, &xS ) == 0 );
|
||||
|
||||
@ -683,12 +685,12 @@ void ecp_test_mul( int id, data_t * n_hex,
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecp_point P, nP, R;
|
||||
mbedtls_mpi n;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
|
||||
mbedtls_ecp_group_init( &grp ); mbedtls_ecp_point_init( &R );
|
||||
mbedtls_ecp_point_init( &P ); mbedtls_ecp_point_init( &nP );
|
||||
mbedtls_mpi_init( &n );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
|
||||
@ -707,7 +709,7 @@ void ecp_test_mul( int id, data_t * n_hex,
|
||||
== 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_mul( &grp, &R, &n, &P,
|
||||
&rnd_pseudo_rand, &rnd_info )
|
||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info )
|
||||
== expected_ret );
|
||||
|
||||
if( expected_ret == 0 )
|
||||
@ -724,6 +726,32 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void ecp_test_mul_rng( int id, data_t * d_hex)
|
||||
{
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_mpi d;
|
||||
mbedtls_ecp_point Q;
|
||||
|
||||
mbedtls_ecp_group_init( &grp ); mbedtls_mpi_init( &d );
|
||||
mbedtls_ecp_point_init( &Q );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &grp.G ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_binary( &d, d_hex->x, d_hex->len ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_mul( &grp, &Q, &d, &grp.G,
|
||||
&mbedtls_test_rnd_zero_rand, NULL )
|
||||
== MBEDTLS_ERR_ECP_RANDOM_FAILED );
|
||||
|
||||
exit:
|
||||
mbedtls_ecp_group_free( &grp ); mbedtls_mpi_free( &d );
|
||||
mbedtls_ecp_point_free( &Q );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void ecp_fast_mod( int id, char * N_str )
|
||||
{
|
||||
@ -781,7 +809,7 @@ void ecp_write_binary( int id, char * x, char * y, char * z, int format,
|
||||
|
||||
if( ret == 0 )
|
||||
{
|
||||
TEST_ASSERT( hexcmp( buf, out->x, olen, out->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( buf, out->x, olen, out->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -1027,17 +1055,18 @@ void mbedtls_ecp_gen_keypair( int id )
|
||||
mbedtls_ecp_group grp;
|
||||
mbedtls_ecp_point Q;
|
||||
mbedtls_mpi d;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
|
||||
mbedtls_ecp_group_init( &grp );
|
||||
mbedtls_ecp_point_init( &Q );
|
||||
mbedtls_mpi_init( &d );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_gen_keypair( &grp, &d, &Q, &rnd_pseudo_rand, &rnd_info )
|
||||
== 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_gen_keypair( &grp, &d, &Q,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_check_privkey( &grp, &d ) == 0 );
|
||||
@ -1053,12 +1082,14 @@ exit:
|
||||
void mbedtls_ecp_gen_key( int id )
|
||||
{
|
||||
mbedtls_ecp_keypair key;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
|
||||
mbedtls_ecp_keypair_init( &key );
|
||||
memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_gen_key( id, &key, &rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_gen_key( id, &key,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &key.grp, &key.Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_check_privkey( &key.grp, &key.d ) == 0 );
|
||||
|
@ -55,8 +55,11 @@ void gcm_encrypt_and_tag( int cipher_id, data_t * key_str,
|
||||
{
|
||||
TEST_ASSERT( mbedtls_gcm_crypt_and_tag( &ctx, MBEDTLS_GCM_ENCRYPT, src_str->len, iv_str->x, iv_str->len, add_str->x, add_str->len, src_str->x, output, tag_len, tag_output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( hexcmp( tag_output, hex_tag_string->x, tag_len, hex_tag_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_dst_string->x,
|
||||
src_str->len,
|
||||
hex_dst_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( tag_output, hex_tag_string->x,
|
||||
tag_len, hex_tag_string->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -94,7 +97,9 @@ void gcm_decrypt_and_verify( int cipher_id, data_t * key_str,
|
||||
{
|
||||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, pt_result->x, src_str->len, pt_result->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, pt_result->x,
|
||||
src_str->len,
|
||||
pt_result->len ) == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,37 +9,36 @@
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void test_hkdf( int md_alg, char *hex_ikm_string, char *hex_salt_string,
|
||||
char *hex_info_string, char *hex_okm_string )
|
||||
void test_hkdf( int md_alg, data_t *ikm, data_t *salt, data_t *info,
|
||||
data_t *expected_okm )
|
||||
{
|
||||
int ret;
|
||||
size_t ikm_len, salt_len, info_len, okm_len;
|
||||
unsigned char ikm[128] = { '\0' };
|
||||
unsigned char salt[128] = { '\0' };
|
||||
unsigned char info[128] = { '\0' };
|
||||
unsigned char expected_okm[128] = { '\0' };
|
||||
unsigned char okm[128] = { '\0' };
|
||||
/*
|
||||
* okm_hex is the string representation of okm,
|
||||
* so its size is twice the size of okm, and an extra null-termination.
|
||||
* okm_string and expected_okm_string are the ASCII string representations
|
||||
* of km and expected_okm, so their size should be twice the size of
|
||||
* okm and expected_okm, and an extra null-termination.
|
||||
*/
|
||||
unsigned char okm_hex[257] = { '\0' };
|
||||
unsigned char okm_string[257] = { '\0' };
|
||||
unsigned char expected_okm_string[257] = { '\0' };
|
||||
|
||||
const mbedtls_md_info_t *md = mbedtls_md_info_from_type( md_alg );
|
||||
TEST_ASSERT( md != NULL );
|
||||
|
||||
ikm_len = unhexify( ikm, hex_ikm_string );
|
||||
salt_len = unhexify( salt, hex_salt_string );
|
||||
info_len = unhexify( info, hex_info_string );
|
||||
okm_len = unhexify( expected_okm, hex_okm_string );
|
||||
TEST_ASSERT( expected_okm->len <= sizeof( okm ) );
|
||||
|
||||
ret = mbedtls_hkdf( md, salt, salt_len, ikm, ikm_len, info, info_len, okm,
|
||||
okm_len);
|
||||
ret = mbedtls_hkdf( md, salt->x, salt->len, ikm->x, ikm->len,
|
||||
info->x, info->len, okm, expected_okm->len );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
// Run hexify on it so that it looks nicer if the assertion fails
|
||||
hexify( okm_hex, okm, okm_len );
|
||||
TEST_ASSERT( !strcmp( (char *)okm_hex, hex_okm_string ) );
|
||||
/*
|
||||
* Run mbedtls_test_hexify on okm and expected_okm so that it looks nicer
|
||||
* if the assertion fails.
|
||||
*/
|
||||
mbedtls_test_hexify( okm_string, okm, expected_okm->len );
|
||||
mbedtls_test_hexify( expected_okm_string,
|
||||
expected_okm->x, expected_okm->len );
|
||||
TEST_ASSERT( !strcmp( (char *)okm_string, (char *)expected_okm_string ) );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -60,9 +59,9 @@ void test_hkdf_extract( int md_alg, char *hex_ikm_string,
|
||||
output_prk_len = mbedtls_md_get_size( md );
|
||||
output_prk = mbedtls_calloc( 1, output_prk_len );
|
||||
|
||||
ikm = unhexify_alloc( hex_ikm_string, &ikm_len );
|
||||
salt = unhexify_alloc( hex_salt_string, &salt_len );
|
||||
prk = unhexify_alloc( hex_prk_string, &prk_len );
|
||||
ikm = mbedtls_test_unhexify_alloc( hex_ikm_string, &ikm_len );
|
||||
salt = mbedtls_test_unhexify_alloc( hex_salt_string, &salt_len );
|
||||
prk = mbedtls_test_unhexify_alloc( hex_prk_string, &prk_len );
|
||||
TEST_ASSERT( prk_len == output_prk_len );
|
||||
|
||||
ret = mbedtls_hkdf_extract( md, salt, salt_len, ikm, ikm_len, output_prk );
|
||||
@ -95,9 +94,9 @@ void test_hkdf_expand( int md_alg, char *hex_info_string,
|
||||
|
||||
output_okm = mbedtls_calloc( OKM_LEN, 1 );
|
||||
|
||||
prk = unhexify_alloc( hex_prk_string, &prk_len );
|
||||
info = unhexify_alloc( hex_info_string, &info_len );
|
||||
okm = unhexify_alloc( hex_okm_string, &okm_len );
|
||||
prk = mbedtls_test_unhexify_alloc( hex_prk_string, &prk_len );
|
||||
info = mbedtls_test_unhexify_alloc( hex_info_string, &info_len );
|
||||
okm = mbedtls_test_unhexify_alloc( hex_okm_string, &okm_len );
|
||||
TEST_ASSERT( prk_len == mbedtls_md_get_size( md ) );
|
||||
TEST_ASSERT( okm_len < OKM_LEN );
|
||||
|
||||
|
@ -129,8 +129,9 @@ void hmac_drbg_seed_file( int md_alg, char * path, int ret )
|
||||
md_info = mbedtls_md_info_from_type( md_alg );
|
||||
TEST_ASSERT( md_info != NULL );
|
||||
|
||||
TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, rnd_std_rand, NULL,
|
||||
NULL, 0 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info,
|
||||
mbedtls_test_rnd_std_rand, NULL,
|
||||
NULL, 0 ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_hmac_drbg_write_seed_file( &ctx, path ) == ret );
|
||||
TEST_ASSERT( mbedtls_hmac_drbg_update_seed_file( &ctx, path ) == ret );
|
||||
|
@ -145,7 +145,9 @@ void md_text( char * text_md_name, char * text_src_string,
|
||||
|
||||
TEST_ASSERT ( 0 == mbedtls_md( md_info, src_str, strlen( (char *) src_str ), output ) );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
mbedtls_md_get_size( md_info ),
|
||||
hex_hash_string->len ) == 0 );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -167,8 +169,9 @@ void md_hex( char * text_md_name, data_t * src_str,
|
||||
TEST_ASSERT ( 0 == mbedtls_md( md_info, src_str->x, src_str->len, output ) );
|
||||
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x,
|
||||
mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
mbedtls_md_get_size( md_info ),
|
||||
hex_hash_string->len ) == 0 );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -208,15 +211,18 @@ void md_text_multi( char * text_md_name, char * text_src_string,
|
||||
|
||||
TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str + halfway, len - halfway ) );
|
||||
TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx, output ) );
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x,
|
||||
mbedtls_md_get_size( md_info ), hex_hash_string->len) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
mbedtls_md_get_size( md_info ),
|
||||
hex_hash_string->len) == 0 );
|
||||
|
||||
/* Test clone */
|
||||
memset( output, 0x00, 100 );
|
||||
|
||||
TEST_ASSERT ( 0 == mbedtls_md_update( &ctx_copy, src_str + halfway, len - halfway ) );
|
||||
TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx_copy, output ) );
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
mbedtls_md_get_size( md_info ),
|
||||
hex_hash_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_md_free( &ctx );
|
||||
@ -255,14 +261,18 @@ void md_hex_multi( char * text_md_name, data_t * src_str,
|
||||
|
||||
TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str->x + halfway, src_str->len - halfway) );
|
||||
TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx, output ) );
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
mbedtls_md_get_size( md_info ),
|
||||
hex_hash_string->len ) == 0 );
|
||||
|
||||
/* Test clone */
|
||||
memset( output, 0x00, 100 );
|
||||
|
||||
TEST_ASSERT ( 0 == mbedtls_md_update( &ctx_copy, src_str->x + halfway, src_str->len - halfway ) );
|
||||
TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx_copy, output ) );
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
mbedtls_md_get_size( md_info ),
|
||||
hex_hash_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_md_free( &ctx );
|
||||
@ -289,7 +299,8 @@ void mbedtls_md_hmac( char * text_md_name, int trunc_size,
|
||||
|
||||
TEST_ASSERT ( mbedtls_md_hmac( md_info, key_str->x, key_str->len, src_str->x, src_str->len, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
trunc_size, hex_hash_string->len ) == 0 );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -321,7 +332,8 @@ void md_hmac_multi( char * text_md_name, int trunc_size, data_t * key_str,
|
||||
TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str->x + halfway, src_str->len - halfway ) );
|
||||
TEST_ASSERT ( 0 == mbedtls_md_hmac_finish( &ctx, output ) );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
trunc_size, hex_hash_string->len ) == 0 );
|
||||
|
||||
/* Test again, for reset() */
|
||||
memset( output, 0x00, 100 );
|
||||
@ -331,7 +343,8 @@ void md_hmac_multi( char * text_md_name, int trunc_size, data_t * key_str,
|
||||
TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str->x + halfway, src_str->len - halfway ) );
|
||||
TEST_ASSERT ( 0 == mbedtls_md_hmac_finish( &ctx, output ) );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
trunc_size, hex_hash_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_md_free( &ctx );
|
||||
@ -355,6 +368,8 @@ void mbedtls_md_file( char * text_md_name, char * filename,
|
||||
|
||||
TEST_ASSERT( mbedtls_md_file( md_info, filename, output ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
mbedtls_md_get_size( md_info ),
|
||||
hex_hash_string->len ) == 0 );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -20,7 +20,9 @@ void md2_text( char * text_src_string, data_t * hex_hash_string )
|
||||
ret = mbedtls_md2_ret( src_str, strlen( (char *) src_str ), output );
|
||||
TEST_ASSERT( ret == 0 ) ;
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
sizeof output,
|
||||
hex_hash_string->len ) == 0 );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -39,7 +41,9 @@ void md4_text( char * text_src_string, data_t * hex_hash_string )
|
||||
ret = mbedtls_md4_ret( src_str, strlen( (char *) src_str ), output );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
sizeof output,
|
||||
hex_hash_string->len ) == 0 );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -58,7 +62,9 @@ void md5_text( char * text_src_string, data_t * hex_hash_string )
|
||||
ret = mbedtls_md5_ret( src_str, strlen( (char *) src_str ), output );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
sizeof output,
|
||||
hex_hash_string->len ) == 0 );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -77,7 +83,9 @@ void ripemd160_text( char * text_src_string, data_t * hex_hash_string )
|
||||
ret = mbedtls_ripemd160_ret( src_str, strlen( (char *) src_str ), output );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, hex_hash_string->x,
|
||||
sizeof output,
|
||||
hex_hash_string->len ) == 0 );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
@ -240,7 +240,8 @@ void mpi_invalid_param( )
|
||||
mbedtls_mpi_exp_mod( &X, &X, &X, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_fill_random( NULL, 42, rnd_std_rand,
|
||||
mbedtls_mpi_fill_random( NULL, 42,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||
mbedtls_mpi_fill_random( &X, 42, NULL, NULL ) );
|
||||
@ -373,7 +374,8 @@ void mbedtls_mpi_write_binary( int radix_X, char * input_X,
|
||||
if( result == 0)
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( buf, input_A->x,
|
||||
buflen, input_A->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -404,7 +406,8 @@ void mbedtls_mpi_write_binary_le( int radix_X, char * input_X,
|
||||
if( result == 0)
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( buf, input_A->x,
|
||||
buflen, input_A->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -438,7 +441,8 @@ void mbedtls_mpi_read_file( int radix_X, char * input_file,
|
||||
TEST_ASSERT( mbedtls_mpi_write_binary( &X, buf, buflen ) == 0 );
|
||||
|
||||
|
||||
TEST_ASSERT( hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( buf, input_A->x,
|
||||
buflen, input_A->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -1192,7 +1196,7 @@ void mbedtls_mpi_is_prime( int radix_X, char * input_X, int div_result )
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &X, radix_X, input_X ) == 0 );
|
||||
res = mbedtls_mpi_is_prime_ext( &X, 40, rnd_std_rand, NULL );
|
||||
res = mbedtls_mpi_is_prime_ext( &X, 40, mbedtls_test_rnd_std_rand, NULL );
|
||||
TEST_ASSERT( res == div_result );
|
||||
|
||||
exit:
|
||||
@ -1241,7 +1245,8 @@ void mbedtls_mpi_gen_prime( int bits, int flags, int ref_ret )
|
||||
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
my_ret = mbedtls_mpi_gen_prime( &X, bits, flags, rnd_std_rand, NULL );
|
||||
my_ret = mbedtls_mpi_gen_prime( &X, bits, flags,
|
||||
mbedtls_test_rnd_std_rand, NULL );
|
||||
TEST_ASSERT( my_ret == ref_ret );
|
||||
|
||||
if( ref_ret == 0 )
|
||||
@ -1251,14 +1256,16 @@ void mbedtls_mpi_gen_prime( int bits, int flags, int ref_ret )
|
||||
TEST_ASSERT( actual_bits >= (size_t) bits );
|
||||
TEST_ASSERT( actual_bits <= (size_t) bits + 1 );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_is_prime_ext( &X, 40, rnd_std_rand, NULL )
|
||||
== 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_is_prime_ext( &X, 40,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) == 0 );
|
||||
if( flags & MBEDTLS_MPI_GEN_PRIME_FLAG_DH )
|
||||
{
|
||||
/* X = ( X - 1 ) / 2 */
|
||||
TEST_ASSERT( mbedtls_mpi_shift_r( &X, 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_is_prime_ext( &X, 40, rnd_std_rand, NULL )
|
||||
== 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_is_prime_ext( &X, 40,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -242,42 +242,31 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_nist_kw_wrap( int cipher_id, int mode,
|
||||
char *key_hex, char *msg_hex,
|
||||
char *result_hex )
|
||||
void mbedtls_nist_kw_wrap( int cipher_id, int mode, data_t *key, data_t *msg,
|
||||
data_t *expected_result )
|
||||
{
|
||||
unsigned char key[32];
|
||||
unsigned char msg[512];
|
||||
unsigned char result[528];
|
||||
unsigned char expected_result[528];
|
||||
mbedtls_nist_kw_context ctx;
|
||||
size_t key_len, msg_len, output_len, result_len, i, padlen;
|
||||
size_t result_len, i, padlen;
|
||||
|
||||
mbedtls_nist_kw_init( &ctx );
|
||||
|
||||
memset( key, 0x00, sizeof( key ) );
|
||||
memset( msg, 0x00, sizeof( msg ) );
|
||||
memset( result, '+', sizeof( result ) );
|
||||
|
||||
key_len = unhexify( key, key_hex );
|
||||
msg_len = unhexify( msg, msg_hex );
|
||||
result_len = unhexify( expected_result, result_hex );
|
||||
output_len = sizeof( result );
|
||||
|
||||
TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx, cipher_id, key, key_len * 8, 1 )
|
||||
== 0 );
|
||||
TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx, cipher_id,
|
||||
key->x, key->len * 8, 1 ) == 0 );
|
||||
|
||||
/* Test with input == output */
|
||||
TEST_ASSERT( mbedtls_nist_kw_wrap( &ctx, mode, msg, msg_len,
|
||||
result, &output_len, sizeof( result ) ) == 0 );
|
||||
TEST_ASSERT( mbedtls_nist_kw_wrap( &ctx, mode, msg->x, msg->len,
|
||||
result, &result_len, sizeof( result ) ) == 0 );
|
||||
|
||||
TEST_ASSERT( output_len == result_len );
|
||||
TEST_ASSERT( result_len == expected_result->len );
|
||||
|
||||
TEST_ASSERT( memcmp( expected_result, result, result_len ) == 0 );
|
||||
TEST_ASSERT( memcmp( expected_result->x, result, result_len ) == 0 );
|
||||
|
||||
padlen = ( msg_len % 8 != 0 ) ? 8 - (msg_len % 8 ) : 0;
|
||||
padlen = ( msg->len % 8 != 0 ) ? 8 - (msg->len % 8 ) : 0;
|
||||
/* Check that the function didn't write beyond the end of the buffer. */
|
||||
for( i = msg_len + 8 + padlen; i < sizeof( result ); i++ )
|
||||
for( i = msg->len + 8 + padlen; i < sizeof( result ); i++ )
|
||||
{
|
||||
TEST_ASSERT( result[i] == '+' );
|
||||
}
|
||||
@ -288,47 +277,35 @@ exit:
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_nist_kw_unwrap( int cipher_id, int mode,
|
||||
char *key_hex, char *msg_hex,
|
||||
char *result_hex, int expected_ret )
|
||||
void mbedtls_nist_kw_unwrap( int cipher_id, int mode, data_t *key, data_t *msg,
|
||||
data_t *expected_result, int expected_ret )
|
||||
{
|
||||
unsigned char key[32];
|
||||
unsigned char msg[528];
|
||||
unsigned char result[528];
|
||||
unsigned char expected_result[528];
|
||||
mbedtls_nist_kw_context ctx;
|
||||
size_t key_len, msg_len, output_len, result_len, i;
|
||||
size_t result_len, i;
|
||||
|
||||
mbedtls_nist_kw_init( &ctx );
|
||||
|
||||
memset( key, 0x00, sizeof( key ) );
|
||||
memset( msg, 0x00, sizeof( msg ) );
|
||||
memset( result, '+', sizeof( result ) );
|
||||
memset( expected_result, 0x00, sizeof( expected_result ) );
|
||||
|
||||
key_len = unhexify( key, key_hex );
|
||||
msg_len = unhexify( msg, msg_hex );
|
||||
result_len = unhexify( expected_result, result_hex );
|
||||
output_len = sizeof( result );
|
||||
|
||||
TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx, cipher_id, key, key_len * 8, 0 )
|
||||
== 0 );
|
||||
TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx, cipher_id,
|
||||
key->x, key->len * 8, 0 ) == 0 );
|
||||
|
||||
/* Test with input == output */
|
||||
TEST_ASSERT( mbedtls_nist_kw_unwrap( &ctx, mode, msg, msg_len,
|
||||
result, &output_len, sizeof( result ) ) == expected_ret );
|
||||
TEST_ASSERT( mbedtls_nist_kw_unwrap( &ctx, mode, msg->x, msg->len,
|
||||
result, &result_len, sizeof( result ) ) == expected_ret );
|
||||
if( expected_ret == 0 )
|
||||
{
|
||||
TEST_ASSERT( output_len == result_len );
|
||||
TEST_ASSERT( memcmp( expected_result, result, result_len ) == 0 );
|
||||
TEST_ASSERT( result_len == expected_result->len );
|
||||
TEST_ASSERT( memcmp( expected_result->x, result, result_len ) == 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
TEST_ASSERT( output_len == 0 );
|
||||
TEST_ASSERT( result_len == 0 );
|
||||
}
|
||||
|
||||
/* Check that the function didn't write beyond the end of the buffer. */
|
||||
for( i = msg_len - 8; i < sizeof( result ); i++ )
|
||||
for( i = msg->len - 8; i < sizeof( result ); i++ )
|
||||
{
|
||||
TEST_ASSERT( result[i] == '+' );
|
||||
}
|
||||
|
@ -273,37 +273,37 @@ pk_sign_verify_restart:MBEDTLS_PK_ECKEY:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75
|
||||
|
||||
PSA wrapped sign: SECP256R1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP256R1:PSA_ECC_CURVE_SECP_R1:256
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP256R1:PSA_ECC_FAMILY_SECP_R1:256
|
||||
|
||||
PSA wrapped sign: SECP384R1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP384R1:PSA_ECC_CURVE_SECP_R1:384
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP384R1:PSA_ECC_FAMILY_SECP_R1:384
|
||||
|
||||
PSA wrapped sign: SECP521R1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP521R1:PSA_ECC_CURVE_SECP_R1:521
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP521R1:PSA_ECC_FAMILY_SECP_R1:521
|
||||
|
||||
PSA wrapped sign: SECP192K1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP192K1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP192K1:PSA_ECC_CURVE_SECP_K1:192
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP192K1:PSA_ECC_FAMILY_SECP_K1:192
|
||||
|
||||
## Currently buggy: https://github.com/ARMmbed/mbed-crypto/issues/336
|
||||
# PSA wrapped sign: SECP224K1
|
||||
# depends_on:MBEDTLS_ECP_DP_SECP224K1_ENABLED
|
||||
# pk_psa_sign:MBEDTLS_ECP_DP_SECP224K1:PSA_ECC_CURVE_SECP_K1:224
|
||||
# pk_psa_sign:MBEDTLS_ECP_DP_SECP224K1:PSA_ECC_FAMILY_SECP_K1:224
|
||||
|
||||
PSA wrapped sign: SECP256K1
|
||||
depends_on:MBEDTLS_ECP_DP_SECP256K1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP256K1:PSA_ECC_CURVE_SECP_K1:256
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_SECP256K1:PSA_ECC_FAMILY_SECP_K1:256
|
||||
|
||||
PSA wrapped sign: BP256R1
|
||||
depends_on:MBEDTLS_ECP_DP_BP256R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_BP256R1:PSA_ECC_CURVE_BRAINPOOL_P_R1:256
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_BP256R1:PSA_ECC_FAMILY_BRAINPOOL_P_R1:256
|
||||
|
||||
PSA wrapped sign: BP384R1
|
||||
depends_on:MBEDTLS_ECP_DP_BP384R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_BP384R1:PSA_ECC_CURVE_BRAINPOOL_P_R1:384
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_BP384R1:PSA_ECC_FAMILY_BRAINPOOL_P_R1:384
|
||||
|
||||
PSA wrapped sign: BP512R1
|
||||
depends_on:MBEDTLS_ECP_DP_BP512R1_ENABLED
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_BP512R1:PSA_ECC_CURVE_BRAINPOOL_P_R1:512
|
||||
pk_psa_sign:MBEDTLS_ECP_DP_BP512R1:PSA_ECC_FAMILY_BRAINPOOL_P_R1:512
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
#include "mbedtls/psa_util.h"
|
||||
#include "psa_crypto_helpers.h"
|
||||
#include "test/psa_crypto_helpers.h"
|
||||
#define PSA_INIT( ) PSA_ASSERT( psa_crypto_init( ) )
|
||||
#else
|
||||
/* Define empty macros so that we can use them in the preamble and teardown
|
||||
@ -27,8 +27,6 @@
|
||||
#define PSA_DONE( ) ( (void) 0 )
|
||||
#endif
|
||||
|
||||
static int rnd_std_rand( void *rng_state, unsigned char *output, size_t len );
|
||||
|
||||
#define RSA_KEY_SIZE 512
|
||||
#define RSA_KEY_LEN 64
|
||||
|
||||
@ -51,7 +49,7 @@ static int pk_genkey( mbedtls_pk_context *pk, int parameter )
|
||||
#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_GENPRIME)
|
||||
if( mbedtls_pk_get_type( pk ) == MBEDTLS_PK_RSA )
|
||||
return mbedtls_rsa_gen_key( mbedtls_pk_rsa( *pk ),
|
||||
rnd_std_rand, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL,
|
||||
parameter, 3 );
|
||||
#endif
|
||||
#if defined(MBEDTLS_ECP_C)
|
||||
@ -64,8 +62,10 @@ static int pk_genkey( mbedtls_pk_context *pk, int parameter )
|
||||
parameter ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
return mbedtls_ecp_gen_keypair( &mbedtls_pk_ec( *pk )->grp, &mbedtls_pk_ec( *pk )->d,
|
||||
&mbedtls_pk_ec( *pk )->Q, rnd_std_rand, NULL );
|
||||
return mbedtls_ecp_gen_keypair( &mbedtls_pk_ec( *pk )->grp,
|
||||
&mbedtls_pk_ec( *pk )->d,
|
||||
&mbedtls_pk_ec( *pk )->Q,
|
||||
mbedtls_test_rnd_std_rand, NULL );
|
||||
}
|
||||
#endif
|
||||
return( -1 );
|
||||
@ -77,8 +77,8 @@ int mbedtls_rsa_decrypt_func( void *ctx, int mode, size_t *olen,
|
||||
size_t output_max_len )
|
||||
{
|
||||
return( mbedtls_rsa_pkcs1_decrypt( (mbedtls_rsa_context *) ctx,
|
||||
rnd_std_rand, NULL, mode, olen,
|
||||
input, output, output_max_len ) );
|
||||
mbedtls_test_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,
|
||||
@ -87,8 +87,9 @@ int mbedtls_rsa_sign_func( void *ctx,
|
||||
{
|
||||
((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 ) );
|
||||
return( mbedtls_rsa_pkcs1_sign( (mbedtls_rsa_context *) ctx,
|
||||
mbedtls_test_rnd_std_rand, NULL, mode,
|
||||
md_alg, hashlen, hash, sig ) );
|
||||
}
|
||||
size_t mbedtls_rsa_key_len_func( void *ctx )
|
||||
{
|
||||
@ -108,7 +109,7 @@ psa_key_handle_t pk_psa_genkey( void )
|
||||
psa_key_handle_t key;
|
||||
psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
|
||||
const psa_key_type_t type =
|
||||
PSA_KEY_TYPE_ECC_KEY_PAIR( PSA_ECC_CURVE_SECP_R1 );
|
||||
PSA_KEY_TYPE_ECC_KEY_PAIR( PSA_ECC_FAMILY_SECP_R1 );
|
||||
const size_t bits = 256;
|
||||
|
||||
psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_HASH );
|
||||
@ -237,7 +238,7 @@ void valid_parameters( )
|
||||
MBEDTLS_MD_NONE,
|
||||
NULL, 0,
|
||||
buf, &len,
|
||||
rnd_std_rand, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL,
|
||||
NULL ) ==
|
||||
MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
@ -245,7 +246,7 @@ void valid_parameters( )
|
||||
MBEDTLS_MD_NONE,
|
||||
NULL, 0,
|
||||
buf, &len,
|
||||
rnd_std_rand, NULL,
|
||||
mbedtls_test_rnd_std_rand, NULL,
|
||||
NULL ) ==
|
||||
MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
@ -253,7 +254,7 @@ void valid_parameters( )
|
||||
MBEDTLS_MD_NONE,
|
||||
NULL, 0,
|
||||
buf, &len,
|
||||
rnd_std_rand, NULL ) ==
|
||||
mbedtls_test_rnd_std_rand, NULL ) ==
|
||||
MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_verify_restartable( &pk,
|
||||
@ -279,13 +280,13 @@ void valid_parameters( )
|
||||
TEST_ASSERT( mbedtls_pk_encrypt( &pk,
|
||||
NULL, 0,
|
||||
NULL, &len, 0,
|
||||
rnd_std_rand, NULL ) ==
|
||||
mbedtls_test_rnd_std_rand, NULL ) ==
|
||||
MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_decrypt( &pk,
|
||||
NULL, 0,
|
||||
NULL, &len, 0,
|
||||
rnd_std_rand, NULL ) ==
|
||||
mbedtls_test_rnd_std_rand, NULL ) ==
|
||||
MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
#if defined(MBEDTLS_PK_PARSE_C)
|
||||
@ -433,100 +434,71 @@ void invalid_parameters( )
|
||||
NULL, sizeof( buf ) ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign_restartable( NULL,
|
||||
MBEDTLS_MD_NONE,
|
||||
buf, sizeof( buf ),
|
||||
buf, &len,
|
||||
rnd_std_rand, NULL,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign_restartable( &pk,
|
||||
MBEDTLS_MD_NONE,
|
||||
NULL, sizeof( buf ),
|
||||
buf, &len,
|
||||
rnd_std_rand, NULL,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign_restartable( &pk,
|
||||
valid_md,
|
||||
NULL, 0,
|
||||
buf, &len,
|
||||
rnd_std_rand, NULL,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign_restartable( &pk,
|
||||
MBEDTLS_MD_NONE,
|
||||
buf, sizeof( buf ),
|
||||
NULL, &len,
|
||||
rnd_std_rand, NULL,
|
||||
NULL ) );
|
||||
mbedtls_pk_sign_restartable( NULL, MBEDTLS_MD_NONE, buf, sizeof( buf ),
|
||||
buf, &len, mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign( NULL,
|
||||
MBEDTLS_MD_NONE,
|
||||
buf, sizeof( buf ),
|
||||
buf, &len,
|
||||
rnd_std_rand, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign( &pk,
|
||||
MBEDTLS_MD_NONE,
|
||||
NULL, sizeof( buf ),
|
||||
buf, &len,
|
||||
rnd_std_rand, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign( &pk,
|
||||
valid_md,
|
||||
NULL, 0,
|
||||
buf, &len,
|
||||
rnd_std_rand, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign( &pk,
|
||||
MBEDTLS_MD_NONE,
|
||||
buf, sizeof( buf ),
|
||||
NULL, &len,
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_pk_sign_restartable( &pk, MBEDTLS_MD_NONE, NULL, sizeof( buf ),
|
||||
buf, &len, mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( NULL,
|
||||
buf, sizeof( buf ),
|
||||
buf, &len, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( &pk,
|
||||
NULL, sizeof( buf ),
|
||||
buf, &len, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( &pk,
|
||||
buf, sizeof( buf ),
|
||||
NULL, &len, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( &pk,
|
||||
buf, sizeof( buf ),
|
||||
buf, NULL, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_pk_sign_restartable( &pk, valid_md, NULL, 0, buf, &len,
|
||||
mbedtls_test_rnd_std_rand, NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( NULL,
|
||||
buf, sizeof( buf ),
|
||||
buf, &len, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_pk_sign_restartable( &pk, MBEDTLS_MD_NONE, buf, sizeof( buf ),
|
||||
NULL, &len, mbedtls_test_rnd_std_rand,
|
||||
NULL, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( &pk,
|
||||
NULL, sizeof( buf ),
|
||||
buf, &len, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_pk_sign( NULL, MBEDTLS_MD_NONE, buf, sizeof( buf ),
|
||||
buf, &len, mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( &pk,
|
||||
buf, sizeof( buf ),
|
||||
NULL, &len, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_pk_sign( &pk, MBEDTLS_MD_NONE, NULL, sizeof( buf ),
|
||||
buf, &len, mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( &pk,
|
||||
buf, sizeof( buf ),
|
||||
buf, NULL, sizeof( buf ),
|
||||
rnd_std_rand, NULL ) );
|
||||
mbedtls_pk_sign( &pk, valid_md, NULL, 0, buf, &len,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_sign( &pk, MBEDTLS_MD_NONE, buf, sizeof( buf ), NULL, &len,
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( NULL, buf, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( &pk, NULL, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( &pk, buf, sizeof( buf ), NULL, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_decrypt( &pk, buf, sizeof( buf ), buf, NULL, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( NULL, buf, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( &pk, NULL, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( &pk, buf, sizeof( buf ), NULL, &len, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_encrypt( &pk, buf, sizeof( buf ), buf, NULL, sizeof( buf ),
|
||||
mbedtls_test_rnd_std_rand, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||
mbedtls_pk_check_pair( NULL, &pk ) );
|
||||
@ -816,7 +788,7 @@ exit:
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_ECP_RESTARTABLE:MBEDTLS_ECDSA_C:MBEDTLS_ECDSA_DETERMINISTIC */
|
||||
void pk_sign_verify_restart( int pk_type, int grp_id, char *d_str,
|
||||
char *QX_str, char *QY_str,
|
||||
int md_alg, char *msg, char *sig_str,
|
||||
int md_alg, char *msg, data_t *sig_check,
|
||||
int max_ops, int min_restart, int max_restart )
|
||||
{
|
||||
int ret, cnt_restart;
|
||||
@ -824,8 +796,7 @@ void pk_sign_verify_restart( int pk_type, int grp_id, char *d_str,
|
||||
mbedtls_pk_context prv, pub;
|
||||
unsigned char hash[MBEDTLS_MD_MAX_SIZE];
|
||||
unsigned char sig[MBEDTLS_ECDSA_MAX_LEN];
|
||||
unsigned char sig_check[MBEDTLS_ECDSA_MAX_LEN];
|
||||
size_t hlen, slen, slen_check;
|
||||
size_t hlen, slen;
|
||||
const mbedtls_md_info_t *md_info;
|
||||
|
||||
mbedtls_pk_restart_init( &rs_ctx );
|
||||
@ -833,7 +804,6 @@ void pk_sign_verify_restart( int pk_type, int grp_id, char *d_str,
|
||||
mbedtls_pk_init( &pub );
|
||||
memset( hash, 0, sizeof( hash ) );
|
||||
memset( sig, 0, sizeof( sig ) );
|
||||
memset( sig_check, 0, sizeof( sig_check ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_setup( &prv, mbedtls_pk_info_from_type( pk_type ) ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &mbedtls_pk_ec( prv )->grp, grp_id ) == 0 );
|
||||
@ -843,8 +813,6 @@ void pk_sign_verify_restart( int pk_type, int grp_id, char *d_str,
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &mbedtls_pk_ec( pub )->grp, grp_id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_point_read_string( &mbedtls_pk_ec( pub )->Q, 16, QX_str, QY_str ) == 0 );
|
||||
|
||||
slen_check = unhexify( sig_check, sig_str );
|
||||
|
||||
md_info = mbedtls_md_info_from_type( md_alg );
|
||||
TEST_ASSERT( md_info != NULL );
|
||||
|
||||
@ -863,8 +831,8 @@ void pk_sign_verify_restart( int pk_type, int grp_id, char *d_str,
|
||||
} while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart );
|
||||
|
||||
TEST_ASSERT( ret == 0 );
|
||||
TEST_ASSERT( slen == slen_check );
|
||||
TEST_ASSERT( memcmp( sig, sig_check, slen ) == 0 );
|
||||
TEST_ASSERT( slen == sig_check->len );
|
||||
TEST_ASSERT( memcmp( sig, sig_check->x, slen ) == 0 );
|
||||
|
||||
TEST_ASSERT( cnt_restart >= min_restart );
|
||||
TEST_ASSERT( cnt_restart <= max_restart );
|
||||
@ -947,7 +915,7 @@ void pk_sign_verify( int type, int parameter, int sign_ret, int verify_ret )
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_sign_restartable( &pk, MBEDTLS_MD_SHA256,
|
||||
hash, sizeof hash, sig, &sig_len,
|
||||
rnd_std_rand, NULL, rs_ctx ) == sign_ret );
|
||||
mbedtls_test_rnd_std_rand, NULL, rs_ctx ) == sign_ret );
|
||||
if( sign_ret == 0 )
|
||||
TEST_ASSERT( sig_len <= MBEDTLS_PK_SIGNATURE_MAX_SIZE );
|
||||
else
|
||||
@ -970,7 +938,9 @@ void pk_sign_verify( int type, int parameter, int sign_ret, int verify_ret )
|
||||
}
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_sign( &pk, MBEDTLS_MD_SHA256, hash, sizeof hash,
|
||||
sig, &sig_len, rnd_std_rand, NULL ) == sign_ret );
|
||||
sig, &sig_len,
|
||||
mbedtls_test_rnd_std_rand,
|
||||
NULL ) == sign_ret );
|
||||
if( sign_ret == 0 )
|
||||
TEST_ASSERT( sig_len <= MBEDTLS_PK_SIGNATURE_MAX_SIZE );
|
||||
else
|
||||
@ -1007,12 +977,12 @@ void pk_rsa_encrypt_test_vec( data_t * message, int mod, int radix_N,
|
||||
data_t * result, int ret )
|
||||
{
|
||||
unsigned char output[300];
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
mbedtls_rsa_context *rsa;
|
||||
mbedtls_pk_context pk;
|
||||
size_t olen;
|
||||
|
||||
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
memset( output, 0, sizeof( output ) );
|
||||
|
||||
|
||||
@ -1025,8 +995,8 @@ void pk_rsa_encrypt_test_vec( data_t * message, int mod, int radix_N,
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &rsa->E, radix_E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_encrypt( &pk, message->x, message->len,
|
||||
output, &olen, sizeof( output ),
|
||||
rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
output, &olen, sizeof( output ),
|
||||
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
TEST_ASSERT( olen == result->len );
|
||||
TEST_ASSERT( memcmp( output, result->x, olen ) == 0 );
|
||||
|
||||
@ -1042,7 +1012,7 @@ void pk_rsa_decrypt_test_vec( data_t * cipher, int mod, int radix_P,
|
||||
char * input_E, data_t * clear, int ret )
|
||||
{
|
||||
unsigned char output[256];
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
mbedtls_mpi N, P, Q, E;
|
||||
mbedtls_rsa_context *rsa;
|
||||
mbedtls_pk_context pk;
|
||||
@ -1052,7 +1022,7 @@ void pk_rsa_decrypt_test_vec( data_t * cipher, int mod, int radix_P,
|
||||
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( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
|
||||
/* init pk-rsa context */
|
||||
@ -1074,8 +1044,8 @@ void pk_rsa_decrypt_test_vec( data_t * cipher, int mod, int radix_P,
|
||||
memset( output, 0, sizeof( output ) );
|
||||
olen = 0;
|
||||
TEST_ASSERT( mbedtls_pk_decrypt( &pk, cipher->x, cipher->len,
|
||||
output, &olen, sizeof( output ),
|
||||
rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
output, &olen, sizeof( output ),
|
||||
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
if( ret == 0 )
|
||||
{
|
||||
TEST_ASSERT( olen == clear->len );
|
||||
@ -1095,25 +1065,25 @@ void pk_ec_nocrypt( int type )
|
||||
mbedtls_pk_context pk;
|
||||
unsigned char output[100];
|
||||
unsigned char input[100];
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
size_t olen = 0;
|
||||
int ret = MBEDTLS_ERR_PK_TYPE_MISMATCH;
|
||||
|
||||
mbedtls_pk_init( &pk );
|
||||
|
||||
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
memset( output, 0, sizeof( output ) );
|
||||
memset( input, 0, sizeof( input ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( type ) ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_encrypt( &pk, input, sizeof( input ),
|
||||
output, &olen, sizeof( output ),
|
||||
rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
output, &olen, sizeof( output ),
|
||||
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_decrypt( &pk, input, sizeof( input ),
|
||||
output, &olen, sizeof( output ),
|
||||
rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
output, &olen, sizeof( output ),
|
||||
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
|
||||
exit:
|
||||
mbedtls_pk_free( &pk );
|
||||
@ -1147,8 +1117,9 @@ void pk_rsa_overflow( )
|
||||
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 );
|
||||
TEST_ASSERT( mbedtls_pk_sign( &pk, MBEDTLS_MD_NONE, hash, hash_len, sig,
|
||||
&sig_len, mbedtls_test_rnd_std_rand, NULL )
|
||||
== MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||
|
||||
exit:
|
||||
mbedtls_pk_free( &pk );
|
||||
@ -1201,12 +1172,13 @@ void pk_rsa_alt( )
|
||||
|
||||
/* 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 );
|
||||
TEST_ASSERT( mbedtls_pk_sign( &alt, MBEDTLS_MD_NONE, hash, SIZE_MAX, sig,
|
||||
&sig_len, mbedtls_test_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 );
|
||||
TEST_ASSERT( mbedtls_pk_sign( &alt, MBEDTLS_MD_NONE, hash, sizeof hash, sig,
|
||||
&sig_len, mbedtls_test_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 );
|
||||
@ -1214,17 +1186,17 @@ void pk_rsa_alt( )
|
||||
/* Test decrypt */
|
||||
TEST_ASSERT( mbedtls_pk_encrypt( &rsa, msg, sizeof msg,
|
||||
ciph, &ciph_len, sizeof ciph,
|
||||
rnd_std_rand, NULL ) == 0 );
|
||||
mbedtls_test_rnd_std_rand, NULL ) == 0 );
|
||||
TEST_ASSERT( mbedtls_pk_decrypt( &alt, ciph, ciph_len,
|
||||
test, &test_len, sizeof test,
|
||||
rnd_std_rand, NULL ) == 0 );
|
||||
mbedtls_test_rnd_std_rand, NULL ) == 0 );
|
||||
TEST_ASSERT( test_len == sizeof msg );
|
||||
TEST_ASSERT( memcmp( test, msg, test_len ) == 0 );
|
||||
|
||||
/* Test forbidden operations */
|
||||
TEST_ASSERT( mbedtls_pk_encrypt( &alt, msg, sizeof msg,
|
||||
ciph, &ciph_len, sizeof ciph,
|
||||
rnd_std_rand, NULL ) == ret );
|
||||
mbedtls_test_rnd_std_rand, NULL ) == ret );
|
||||
TEST_ASSERT( mbedtls_pk_verify( &alt, MBEDTLS_MD_NONE,
|
||||
hash, sizeof hash, sig, sig_len ) == ret );
|
||||
TEST_ASSERT( mbedtls_pk_debug( &alt, dbg_items ) == ret );
|
||||
@ -1269,7 +1241,7 @@ void pk_psa_sign( int grpid_arg,
|
||||
mbedtls_pk_info_from_type( MBEDTLS_PK_ECKEY ) ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_gen_key( grpid,
|
||||
(mbedtls_ecp_keypair*) pk.pk_ctx,
|
||||
rnd_std_rand, NULL ) == 0 );
|
||||
mbedtls_test_rnd_std_rand, NULL ) == 0 );
|
||||
|
||||
/* Export underlying public key for re-importing in a legacy context. */
|
||||
ret = mbedtls_pk_write_pubkey_der( &pk, pkey_legacy,
|
||||
|
@ -16,7 +16,7 @@ void pkcs1_rsaes_v15_encrypt( int mod, int radix_N, char * input_N,
|
||||
{
|
||||
unsigned char output[128];
|
||||
mbedtls_rsa_context ctx;
|
||||
rnd_buf_info info;
|
||||
mbedtls_test_rnd_buf_info info;
|
||||
mbedtls_mpi N, E;
|
||||
|
||||
info.buf = rnd_buf->x;
|
||||
@ -34,10 +34,16 @@ void pkcs1_rsaes_v15_encrypt( int mod, int radix_N, char * input_N,
|
||||
|
||||
if( message_str->len == 0 )
|
||||
message_str->x = NULL;
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PUBLIC, message_str->len, message_str->x, output ) == result );
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx,
|
||||
&mbedtls_test_rnd_buffer_rand,
|
||||
&info, MBEDTLS_RSA_PUBLIC,
|
||||
message_str->len, message_str->x,
|
||||
output ) == result );
|
||||
|
||||
if( result == 0 )
|
||||
{
|
||||
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
||||
ctx.len, result_hex_str->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -57,7 +63,7 @@ void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char * input_P,
|
||||
unsigned char output[128];
|
||||
mbedtls_rsa_context ctx;
|
||||
size_t output_len;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
mbedtls_mpi N, P, Q, E;
|
||||
((void) seed);
|
||||
|
||||
@ -66,7 +72,7 @@ void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char * input_P,
|
||||
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, hash );
|
||||
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
|
||||
@ -80,14 +86,25 @@ void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char * input_P,
|
||||
|
||||
if( result_hex_str->len == 0 )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str->x, NULL, 0 ) == result );
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info,
|
||||
MBEDTLS_RSA_PRIVATE,
|
||||
&output_len, message_str->x,
|
||||
NULL, 0 ) == result );
|
||||
}
|
||||
else
|
||||
{
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str->x, output, 1000 ) == result );
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info, MBEDTLS_RSA_PRIVATE,
|
||||
&output_len, message_str->x,
|
||||
output, 1000 ) == result );
|
||||
if( result == 0 )
|
||||
{
|
||||
TEST_ASSERT( hexcmp( output, result_hex_str->x, output_len, result_hex_str->len) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
||||
output_len,
|
||||
result_hex_str->len) == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +124,7 @@ void pkcs1_v15_decode( int mode,
|
||||
{
|
||||
size_t expected_plaintext_length = expected_plaintext_length_arg;
|
||||
size_t output_size = output_size_arg;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
mbedtls_mpi Nmpi, Empi, Pmpi, Qmpi;
|
||||
mbedtls_rsa_context ctx;
|
||||
static unsigned char N[128] = {
|
||||
@ -173,7 +190,7 @@ void pkcs1_v15_decode( int mode,
|
||||
unsigned char final[128];
|
||||
size_t output_length = 0x7EA0;
|
||||
|
||||
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
mbedtls_mpi_init( &Nmpi ); mbedtls_mpi_init( &Empi );
|
||||
mbedtls_mpi_init( &Pmpi ); mbedtls_mpi_init( &Qmpi );
|
||||
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, 0 );
|
||||
@ -193,16 +210,15 @@ void pkcs1_v15_decode( int mode,
|
||||
if( mode == MBEDTLS_RSA_PRIVATE )
|
||||
TEST_ASSERT( mbedtls_rsa_public( &ctx, original, intermediate ) == 0 );
|
||||
else
|
||||
TEST_ASSERT( mbedtls_rsa_private( &ctx, &rnd_pseudo_rand, &rnd_info,
|
||||
original, intermediate ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_private( &ctx, &mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info, original,
|
||||
intermediate ) == 0 );
|
||||
|
||||
memcpy( final, default_content, sizeof( final ) );
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx,
|
||||
&rnd_pseudo_rand, &rnd_info,
|
||||
mode,
|
||||
&output_length,
|
||||
intermediate,
|
||||
final,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info, mode, &output_length,
|
||||
intermediate, final,
|
||||
output_size ) == expected_result );
|
||||
if( expected_result == 0 )
|
||||
{
|
||||
@ -257,7 +273,7 @@ void pkcs1_rsassa_v15_sign( int mod, int radix_P, char * input_P, int radix_Q,
|
||||
unsigned char output[128];
|
||||
mbedtls_rsa_context ctx;
|
||||
mbedtls_mpi N, P, Q, E;
|
||||
rnd_buf_info info;
|
||||
mbedtls_test_rnd_buf_info info;
|
||||
|
||||
info.buf = rnd_buf->x;
|
||||
info.length = rnd_buf->len;
|
||||
@ -283,11 +299,14 @@ void pkcs1_rsassa_v15_sign( int mod, int radix_P, char * input_P, int radix_Q,
|
||||
if( mbedtls_md_info_from_type( digest ) != NULL )
|
||||
TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->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, &mbedtls_test_rnd_buffer_rand,
|
||||
&info, MBEDTLS_RSA_PRIVATE, digest,
|
||||
0, hash_result, output ) == result );
|
||||
if( result == 0 )
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
||||
ctx.len, result_hex_str->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@ -16,7 +16,7 @@ void pkcs1_rsaes_oaep_encrypt( int mod, int radix_N, char * input_N,
|
||||
{
|
||||
unsigned char output[256];
|
||||
mbedtls_rsa_context ctx;
|
||||
rnd_buf_info info;
|
||||
mbedtls_test_rnd_buf_info info;
|
||||
mbedtls_mpi N, E;
|
||||
|
||||
info.buf = rnd_buf->x;
|
||||
@ -34,10 +34,15 @@ void pkcs1_rsaes_oaep_encrypt( int mod, int radix_N, char * input_N,
|
||||
|
||||
if( message_str->len == 0 )
|
||||
message_str->x = NULL;
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PUBLIC, message_str->len, message_str->x, output ) == result );
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx,
|
||||
&mbedtls_test_rnd_buffer_rand,
|
||||
&info, MBEDTLS_RSA_PUBLIC,
|
||||
message_str->len, message_str->x,
|
||||
output ) == result );
|
||||
if( result == 0 )
|
||||
{
|
||||
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
||||
ctx.len, result_hex_str->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
@ -57,7 +62,7 @@ void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char * input_P,
|
||||
unsigned char output[64];
|
||||
mbedtls_rsa_context ctx;
|
||||
size_t output_len;
|
||||
rnd_pseudo_info rnd_info;
|
||||
mbedtls_test_rnd_pseudo_info rnd_info;
|
||||
mbedtls_mpi N, P, Q, E;
|
||||
((void) seed);
|
||||
|
||||
@ -67,7 +72,7 @@ void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char * input_P,
|
||||
mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V21, hash );
|
||||
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
||||
memset( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 );
|
||||
@ -81,19 +86,27 @@ void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char * input_P,
|
||||
|
||||
if( result_hex_str->len == 0 )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &rnd_pseudo_rand, &rnd_info,
|
||||
MBEDTLS_RSA_PRIVATE, &output_len,
|
||||
message_str->x, NULL, 0 ) == result );
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info,
|
||||
MBEDTLS_RSA_PRIVATE,
|
||||
&output_len, message_str->x,
|
||||
NULL, 0 ) == result );
|
||||
}
|
||||
else
|
||||
{
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &rnd_pseudo_rand, &rnd_info,
|
||||
MBEDTLS_RSA_PRIVATE, &output_len,
|
||||
message_str->x, output,
|
||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info,
|
||||
MBEDTLS_RSA_PRIVATE,
|
||||
&output_len, message_str->x,
|
||||
output,
|
||||
sizeof( output ) ) == result );
|
||||
if( result == 0 )
|
||||
{
|
||||
TEST_ASSERT( hexcmp( output, result_hex_str->x, output_len, result_hex_str->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
||||
output_len,
|
||||
result_hex_str->len ) == 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,7 +127,7 @@ void pkcs1_rsassa_pss_sign( int mod, int radix_P, char * input_P, int radix_Q,
|
||||
unsigned char hash_result[MBEDTLS_MD_MAX_SIZE];
|
||||
unsigned char output[256];
|
||||
mbedtls_rsa_context ctx;
|
||||
rnd_buf_info info;
|
||||
mbedtls_test_rnd_buf_info info;
|
||||
mbedtls_mpi N, P, Q, E;
|
||||
|
||||
info.buf = rnd_buf->x;
|
||||
@ -141,12 +154,14 @@ void pkcs1_rsassa_pss_sign( int mod, int radix_P, char * input_P, int radix_Q,
|
||||
if( mbedtls_md_info_from_type( digest ) != NULL )
|
||||
TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->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, &mbedtls_test_rnd_buffer_rand,
|
||||
&info, MBEDTLS_RSA_PRIVATE, digest, 0,
|
||||
hash_result, output ) == result );
|
||||
if( result == 0 )
|
||||
{
|
||||
|
||||
TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
||||
ctx.len, result_hex_str->len ) == 0 );
|
||||
}
|
||||
|
||||
exit:
|
||||
|
@ -24,7 +24,8 @@ void pbkdf2_hmac( int hash, data_t * pw_str, data_t * salt_str,
|
||||
TEST_ASSERT( mbedtls_pkcs5_pbkdf2_hmac( &ctx, pw_str->x, pw_str->len, salt_str->x, salt_str->len,
|
||||
it_cnt, key_len, key ) == 0 );
|
||||
|
||||
TEST_ASSERT( hexcmp( key, result_key_string->x, key_len, result_key_string->len ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_hexcmp( key, result_key_string->x,
|
||||
key_len, result_key_string->len ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_md_free( &ctx );
|
||||
@ -43,7 +44,7 @@ void mbedtls_pkcs5_pbes2( int params_tag, data_t *params_hex, data_t *pw,
|
||||
params.p = params_hex->x;
|
||||
params.len = params_hex->len;
|
||||
|
||||
my_out = zero_alloc( ref_out->len );
|
||||
my_out = mbedtls_test_zero_alloc( ref_out->len );
|
||||
|
||||
my_ret = mbedtls_pkcs5_pbes2( ¶ms, MBEDTLS_PKCS5_DECRYPT,
|
||||
pw->x, pw->len, data->x, data->len, my_out );
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user