Skip to content

Commit cb0101f

Browse files
Merge pull request #298 from gilles-peskine-arm/config-symmetric-only
Test a build without any asymmetric cryptography
2 parents 2ad5e45 + 1a9bd94 commit cb0101f

File tree

6 files changed

+120
-2
lines changed

6 files changed

+120
-2
lines changed

configs/config-symmetric-only.h

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/**
2+
* \file config-symmetric-only.h
3+
*
4+
* \brief Configuration without any asymmetric cryptography.
5+
*/
6+
/*
7+
* Copyright (C) 2019, ARM Limited, All Rights Reserved
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
11+
* not use this file except in compliance with the License.
12+
* You may obtain a copy of the License at
13+
*
14+
* http://www.apache.org/licenses/LICENSE-2.0
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
*
22+
* This file is part of mbed TLS (https://tls.mbed.org)
23+
*/
24+
25+
#ifndef MBEDTLS_CONFIG_H
26+
#define MBEDTLS_CONFIG_H
27+
28+
/* System support */
29+
//#define MBEDTLS_HAVE_ASM
30+
#define MBEDTLS_HAVE_TIME
31+
#define MBEDTLS_HAVE_TIME_DATE
32+
33+
/* Mbed Crypto feature support */
34+
#define MBEDTLS_CIPHER_MODE_CBC
35+
#define MBEDTLS_CIPHER_MODE_CFB
36+
#define MBEDTLS_CIPHER_MODE_CTR
37+
#define MBEDTLS_CIPHER_MODE_OFB
38+
#define MBEDTLS_CIPHER_MODE_XTS
39+
#define MBEDTLS_CIPHER_PADDING_PKCS7
40+
#define MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS
41+
#define MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN
42+
#define MBEDTLS_CIPHER_PADDING_ZEROS
43+
#define MBEDTLS_ERROR_STRERROR_DUMMY
44+
#define MBEDTLS_FS_IO
45+
#define MBEDTLS_ENTROPY_NV_SEED
46+
#define MBEDTLS_SELF_TEST
47+
#define MBEDTLS_USE_PSA_CRYPTO
48+
#define MBEDTLS_VERSION_FEATURES
49+
50+
/* Mbed Crypto modules */
51+
#define MBEDTLS_AES_C
52+
#define MBEDTLS_ARC4_C
53+
#define MBEDTLS_ASN1_PARSE_C
54+
#define MBEDTLS_ASN1_WRITE_C
55+
#define MBEDTLS_BASE64_C
56+
#define MBEDTLS_BLOWFISH_C
57+
#define MBEDTLS_CAMELLIA_C
58+
#define MBEDTLS_ARIA_C
59+
#define MBEDTLS_CCM_C
60+
#define MBEDTLS_CHACHA20_C
61+
#define MBEDTLS_CHACHAPOLY_C
62+
#define MBEDTLS_CIPHER_C
63+
#define MBEDTLS_CMAC_C
64+
#define MBEDTLS_CTR_DRBG_C
65+
#define MBEDTLS_DES_C
66+
#define MBEDTLS_ENTROPY_C
67+
#define MBEDTLS_ERROR_C
68+
#define MBEDTLS_GCM_C
69+
//#define MBEDTLS_HAVEGE_C
70+
#define MBEDTLS_HKDF_C
71+
#define MBEDTLS_HMAC_DRBG_C
72+
#define MBEDTLS_NIST_KW_C
73+
#define MBEDTLS_MD_C
74+
#define MBEDTLS_MD2_C
75+
#define MBEDTLS_MD4_C
76+
#define MBEDTLS_MD5_C
77+
#define MBEDTLS_OID_C
78+
#define MBEDTLS_PEM_PARSE_C
79+
#define MBEDTLS_PEM_WRITE_C
80+
#define MBEDTLS_PKCS5_C
81+
#define MBEDTLS_PKCS12_C
82+
#define MBEDTLS_PLATFORM_C
83+
#define MBEDTLS_POLY1305_C
84+
#define MBEDTLS_PSA_CRYPTO_C
85+
#define MBEDTLS_PSA_CRYPTO_SE_C
86+
#define MBEDTLS_PSA_CRYPTO_STORAGE_C
87+
#define MBEDTLS_PSA_ITS_FILE_C
88+
#define MBEDTLS_RIPEMD160_C
89+
#define MBEDTLS_SHA1_C
90+
#define MBEDTLS_SHA256_C
91+
#define MBEDTLS_SHA512_C
92+
//#define MBEDTLS_THREADING_C
93+
#define MBEDTLS_TIMING_C
94+
#define MBEDTLS_VERSION_C
95+
#define MBEDTLS_XTEA_C
96+
97+
#include "check_config.h"
98+
99+
#endif /* MBEDTLS_CONFIG_H */

include/mbedtls/psa_util.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,11 @@ static inline int mbedtls_psa_get_ecc_oid_from_id(
230230
*oid_len = MBEDTLS_OID_SIZE( MBEDTLS_OID_EC_GRP_BP512R1 );
231231
return( 0 );
232232
#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */
233+
default:
234+
(void) oid;
235+
(void) oid_len;
236+
return( -1 );
233237
}
234-
235-
return( -1 );
236238
}
237239

238240
#define MBEDTLS_PSA_MAX_EC_PUBKEY_LENGTH 1

library/psa_crypto.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,7 @@ psa_status_t psa_copy_key( psa_key_handle_t source_handle,
20062006
/* Message digests */
20072007
/****************************************************************/
20082008

2009+
#if defined(MBEDTLS_RSA_C) || defined(MBEDTLS_ECDSA_DETERMINISTIC)
20092010
static const mbedtls_md_info_t *mbedtls_md_info_from_psa( psa_algorithm_t alg )
20102011
{
20112012
switch( alg )
@@ -2046,6 +2047,7 @@ static const mbedtls_md_info_t *mbedtls_md_info_from_psa( psa_algorithm_t alg )
20462047
return( NULL );
20472048
}
20482049
}
2050+
#endif
20492051

20502052
psa_status_t psa_hash_abort( psa_hash_operation_t *operation )
20512053
{

tests/scripts/all.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,8 @@ component_test_se_default () {
879879

880880
component_test_se_full () {
881881
msg "build: full config + MBEDTLS_PSA_CRYPTO_SE_C"
882+
scripts/config.pl full
883+
scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C
882884
scripts/config.pl set MBEDTLS_PSA_CRYPTO_SE_C
883885
make CC=gcc CFLAGS="$ASAN_CFLAGS -O2" LDFLAGS="$ASAN_CFLAGS"
884886

tests/scripts/test-ref-configs.pl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use strict;
1818

1919
my %configs = (
20+
'config-symmetric-only.h' => {
21+
},
2022
'config-suite-b.h' => {
2123
},
2224
);
@@ -48,6 +50,15 @@ sub abort {
4850
exit 1;
4951
}
5052

53+
# Create a seedfile for configurations that enable MBEDTLS_ENTROPY_NV_SEED.
54+
# For test purposes, this doesn't have to be cryptographically random.
55+
if (!-e "tests/seedfile" || -s "tests/seedfile" < 64) {
56+
local *SEEDFILE;
57+
open SEEDFILE, ">tests/seedfile" or die;
58+
print SEEDFILE "*" x 64 or die;
59+
close SEEDFILE or die;
60+
}
61+
5162
while( my ($conf, $data) = each %configs ) {
5263
system( "cp $config_h.bak $config_h" ) and die;
5364
system( "make clean" ) and die;

tests/suites/test_suite_psa_crypto.function

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,8 @@ static int exported_key_sanity_check( psa_key_type_t type, size_t bits,
899899
"No sanity check for public key type=0x%08lx",
900900
(unsigned long) type );
901901
test_fail( message, __LINE__, __FILE__ );
902+
(void) p;
903+
(void) end;
902904
return( 0 );
903905
}
904906
}

0 commit comments

Comments
 (0)