Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move programs/psa to tf-psa-crypto #9717

Open
wants to merge 20 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions programs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ pkey/rsa_sign
pkey/rsa_sign_pss
pkey/rsa_verify
pkey/rsa_verify_pss
psa/aead_demo
psa/crypto_examples
psa/hmac_demo
psa/key_ladder_demo
psa/psa_constant_names
psa/psa_hash
random/gen_entropy
random/gen_random_ctr_drbg
ssl/dtls_client
Expand Down Expand Up @@ -75,7 +69,6 @@ x509/req_app

###START_GENERATED_FILES###
# Generated source files
/psa/psa_constant_names_generated.c
/test/query_config.c

# Generated data files
Expand Down
2 changes: 1 addition & 1 deletion programs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (NOT WIN32)
endif()
add_subdirectory(hash)
add_subdirectory(pkey)
add_subdirectory(psa)
add_subdirectory(../tf-psa-crypto/programs/psa ../tf-psa-crypto/programs/psa)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment. Eventually we want to move that to tf-psa-cypto/programs/CMakeLists.txt but it will be easier when #9615 is completed.

add_subdirectory(random)
add_subdirectory(ssl)
add_subdirectory(test)
Expand Down
43 changes: 23 additions & 20 deletions programs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ endif
## be declared by appending with `APPS += ...` afterwards.
## See the get_app_list function in scripts/generate_visualc_files.pl and
## make sure to check that it still works if you tweak the format here.
##
## Note: Variables cannot be used to define an apps path. This cannot be
## substituted by the script generate_visualc_files.pl.
APPS = \
aes/crypt_and_hash \
cipher/cipher_aead_demo \
Expand All @@ -55,12 +58,12 @@ APPS = \
pkey/rsa_sign_pss \
pkey/rsa_verify \
pkey/rsa_verify_pss \
psa/aead_demo \
psa/crypto_examples \
psa/hmac_demo \
psa/key_ladder_demo \
psa/psa_constant_names \
psa/psa_hash \
../tf-psa-crypto/programs/psa/aead_demo \
../tf-psa-crypto/programs/psa/crypto_examples \
../tf-psa-crypto/programs/psa/hmac_demo \
../tf-psa-crypto/programs/psa/key_ladder_demo \
../tf-psa-crypto/programs/psa/psa_constant_names \
../tf-psa-crypto/programs/psa/psa_hash \
random/gen_entropy \
random/gen_random_ctr_drbg \
ssl/dtls_client \
Expand Down Expand Up @@ -132,13 +135,13 @@ ${MBEDTLS_TEST_OBJS}:
GENERATED_FILES = psa/psa_constant_names_generated.c test/query_config.c
generated_files: $(GENERATED_FILES)

psa/psa_constant_names_generated.c: $(gen_file_dep) ../scripts/generate_psa_constants.py
../tf-psa-crypto/psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/scripts/generate_psa_constants.py
psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/include/psa/crypto_values.h
psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/include/psa/crypto_extra.h
psa/psa_constant_names_generated.c: $(gen_file_dep) ../tf-psa-crypto/tests/suites/test_suite_psa_crypto_metadata.data
psa/psa_constant_names_generated.c:
echo " Gen $@"
$(PYTHON) ../scripts/generate_psa_constants.py
cd ../tf-psa-crypto; $(PYTHON) ./scripts/generate_psa_constants.py

test/query_config.c: $(gen_file_dep) ../scripts/generate_query_config.pl
## The generated file only depends on the options that are present in mbedtls_config.h,
Expand Down Expand Up @@ -252,29 +255,29 @@ pkey/rsa_encrypt$(EXEXT): pkey/rsa_encrypt.c $(DEP)
echo " CC pkey/rsa_encrypt.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) pkey/rsa_encrypt.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

psa/aead_demo$(EXEXT): psa/aead_demo.c $(DEP)
../tf-psa-crypto/programs/psa/aead_demo$(EXEXT): ../tf-psa-crypto/programs/psa/aead_demo.c $(DEP)
echo " CC psa/aead_demo.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) psa/aead_demo.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ../tf-psa-crypto/programs/psa/aead_demo.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

psa/crypto_examples$(EXEXT): psa/crypto_examples.c $(DEP)
../tf-psa-crypto/programs/psa/crypto_examples$(EXEXT): ../tf-psa-crypto/programs/psa/crypto_examples.c $(DEP)
echo " CC psa/crypto_examples.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) psa/crypto_examples.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ../tf-psa-crypto/programs/psa/crypto_examples.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

psa/hmac_demo$(EXEXT): psa/hmac_demo.c $(DEP)
../tf-psa-crypto/programs/psa/hmac_demo$(EXEXT): ../tf-psa-crypto/programs/psa/hmac_demo.c $(DEP)
echo " CC psa/hmac_demo.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) psa/hmac_demo.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ../tf-psa-crypto/programs/psa/hmac_demo.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

psa/key_ladder_demo$(EXEXT): psa/key_ladder_demo.c $(DEP)
../tf-psa-crypto/programs/psa/key_ladder_demo$(EXEXT): ../tf-psa-crypto/programs/psa/key_ladder_demo.c $(DEP)
echo " CC psa/key_ladder_demo.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) psa/key_ladder_demo.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ../tf-psa-crypto/programs/psa/key_ladder_demo.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

psa/psa_constant_names$(EXEXT): psa/psa_constant_names.c psa/psa_constant_names_generated.c $(DEP)
../tf-psa-crypto/programs/psa/psa_constant_names$(EXEXT): ../tf-psa-crypto/programs/psa/psa_constant_names.c psa/psa_constant_names_generated.c $(DEP)
echo " CC psa/psa_constant_names.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) psa/psa_constant_names.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ../tf-psa-crypto/programs/psa/psa_constant_names.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

psa/psa_hash$(EXEXT): psa/psa_hash.c $(DEP)
../tf-psa-crypto/programs/psa/psa_hash$(EXEXT): ../tf-psa-crypto/programs/psa/psa_hash.c $(DEP)
echo " CC psa/psa_hash.c"
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) psa/psa_hash.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) ../tf-psa-crypto/programs/psa/psa_hash.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@

random/gen_entropy$(EXEXT): random/gen_entropy.c $(DEP)
echo " CC random/gen_entropy.c"
Expand Down
7 changes: 5 additions & 2 deletions scripts/generate_visualc_files.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
my $vsx_sln_tpl_file = "scripts/data_files/vs2017-sln-template.sln";
my $vsx_sln_file = "$vsx_dir/mbedTLS.sln";

my $programs_dir = 'programs';
my $mbedtls_programs_dir = "programs";
my $tfpsacrypto_programs_dir = "tf-psa-crypto/programs";

my $mbedtls_header_dir = 'include/mbedtls';
my $drivers_builtin_header_dir = 'tf-psa-crypto/drivers/builtin/include/mbedtls';
my $psa_header_dir = 'tf-psa-crypto/include/psa';
Expand Down Expand Up @@ -122,7 +124,8 @@ sub check_dirs {
&& -d $test_header_dir
&& -d $tls_test_header_dir
&& -d $test_drivers_header_dir
&& -d $programs_dir;
&& -d $mbedtls_programs_dir
&& -d $tfpsacrypto_programs_dir;
}

sub slurp_file {
Expand Down
2 changes: 2 additions & 0 deletions scripts/make_generated_files.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ python framework\scripts\generate_ssl_debug_helpers.py || exit /b 1
perl scripts\generate_visualc_files.pl || exit /b 1

@rem @@@@ programs\** @@@@
cd tf-psa-crypto
python scripts\generate_psa_constants.py || exit /b 1
cd ..

@rem @@@@ tests\** @@@@
python framework\scripts\generate_bignum_tests.py --directory tf-psa-crypto\tests\suites || exit /b 1
Expand Down
3 changes: 2 additions & 1 deletion tests/scripts/check-generated-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ check()
# directory in Mbed TLS that is not just a TF-PSA-Crypto submodule.
if [ -d tf-psa-crypto ]; then
cd tf-psa-crypto
check ./scripts/generate_psa_constants.py ./programs/psa/psa_constant_names_generated.c
check ../framework/scripts/generate_bignum_tests.py $(../framework/scripts/generate_bignum_tests.py --list)
check ../framework/scripts/generate_config_tests.py tests/suites/test_suite_config.psa_boolean.data
check ../framework/scripts/generate_ecp_tests.py $(../framework/scripts/generate_ecp_tests.py --list)
Expand All @@ -163,7 +164,7 @@ else
check framework/scripts/generate_psa_tests.py $(framework/scripts/generate_psa_tests.py --list)
fi

check scripts/generate_psa_constants.py programs/psa/psa_constant_names_generated.c
check scripts/generate_psa_constants.py tf-psa-crypto/programs/psa/psa_constant_names_generated.c
check framework/scripts/generate_test_keys.py framework/tests/src/test_keys.h
check scripts/generate_driver_wrappers.py ${crypto_core_dir}/psa_crypto_driver_wrappers.h \
${crypto_core_dir}/psa_crypto_driver_wrappers_no_static.c
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/psa_collect_statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import sys

DEFAULT_STATUS_LOG_FILE = 'tests/statuses.log'
DEFAULT_PSA_CONSTANT_NAMES = 'programs/psa/psa_constant_names'
DEFAULT_PSA_CONSTANT_NAMES = 'tf-psa-crypto/programs/psa/psa_constant_names'

class Statuses:
"""Information about observed return statues of API functions."""
Expand Down
4 changes: 3 additions & 1 deletion tests/scripts/run_demos.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def run_all_demos(quiet=False):

Return True if all demos passed and False if a demo fails.
"""
all_demos = glob.glob('programs/*/*_demo.sh')
mbedtls_demos = glob.glob('programs/*/*_demo.sh')
tf_psa_crypto_demos = glob.glob('tf-psa-crypto/programs/*/*_demo.sh')
all_demos = mbedtls_demos + tf_psa_crypto_demos
if not all_demos:
# Keep the message on one line. pylint: disable=line-too-long
raise Exception('No demos found. run_demos needs to operate from the Mbed TLS toplevel directory.')
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/test_psa_constant_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def main():
action='store_false', dest='keep_c',
help='Don\'t keep the intermediate C file (default)')
parser.add_argument('--program',
default='programs/psa/psa_constant_names',
default='tf-psa-crypto/programs/psa/psa_constant_names',
help='Program to test')
parser.add_argument('--show',
action='store_true',
Expand Down
10 changes: 10 additions & 0 deletions tf-psa-crypto/programs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
psa/aead_demo
psa/crypto_examples
psa/hmac_demo
psa/key_ladder_demo
psa/psa_constant_names
psa/psa_hash

###START_GENERATED_FILES###
# Generated source files
psa/psa_constant_names_generated.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ if(GEN_FILES)
${CMAKE_CURRENT_SOURCE_DIR}/../..
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_psa_constants.py
${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include/psa/crypto_values.h
${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/include/psa/crypto_extra.h
${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_values.h
${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_extra.h
)
else()
link_to_source(psa_constant_names_generated.c)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright The Mbed TLS Contributors
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later

. "${0%/*}/../demo_common.sh"
. "${0%/*}/../../../programs/demo_common.sh"

msg <<'EOF'
This script demonstrates the use of the PSA cryptography interface to
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright The Mbed TLS Contributors
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later

. "${0%/*}/../demo_common.sh"
. "${0%/*}/../../../programs/demo_common.sh"

msg <<'EOF'
This program demonstrates the use of the PSA cryptography interface to
Expand Down
18 changes: 18 additions & 0 deletions tf-psa-crypto/scripts/framework_scripts_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Add our Python library directory to the module search path.

Usage:

import framework_scripts_path # pylint: disable=unused-import
"""

# Copyright The Mbed TLS Contributors
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
#

import os
import sys

sys.path.append(os.path.join(os.path.dirname(__file__),
os.path.pardir,
os.path.pardir,
'framework', 'scripts'))
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,6 @@ def generate_psa_constants(header_file_names, output_file_name):
# Allow to change the directory where psa_constant_names_generated.c is written to.
OUTPUT_FILE_DIR = sys.argv[1] if len(sys.argv) == 2 else "programs/psa"

generate_psa_constants(['tf-psa-crypto/include/psa/crypto_values.h',
'tf-psa-crypto/include/psa/crypto_extra.h'],
generate_psa_constants(['include/psa/crypto_values.h',
'include/psa/crypto_extra.h'],
OUTPUT_FILE_DIR + '/psa_constant_names_generated.c')