Skip to content

Commit 514fdfc

Browse files
authored
Merge pull request #7591 from dgarske/wolfssh_template
Template for wolfSSH minimal build using user_settings.h
2 parents 78b056c + 8763b12 commit 514fdfc

4 files changed

Lines changed: 217 additions & 0 deletions

File tree

.github/workflows/os-check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
'examples/configs/user_settings_min_ecc.h',
7777
'examples/configs/user_settings_wolfboot_keytools.h',
7878
'examples/configs/user_settings_wolftpm.h',
79+
'examples/configs/user_settings_wolfssh.h',
7980
'examples/configs/user_settings_tls12.h',
8081
]
8182
name: make user_setting.h (testwolfcrypt only)

examples/configs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Example wolfSSL configuration file templates for use when autoconf is not availa
1515
* `user_settings_stm32.h`: Example configuration file generated from the wolfSSL STM32 Cube pack.
1616
* `user_settings_tls12`: Example for TLS v1.2 client only, ECC only, AES GCM only, SHA2-256 only.
1717
* `user_settings_wolfboot_keytools.h`: This from wolfBoot tools/keytools and is ECC, RSA, ED25519 and ChaCha20.
18+
* `user_settings_wolfssh.h`: Minimum options for building wolfSSH. See comment at top for ./configure used to generate.
1819
* `user_settings_wolftpm.h`: Minimum options for building wolfTPM. See comment at top for ./configure used to generate.
1920

2021
## Usage

examples/configs/include.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ EXTRA_DIST += examples/configs/user_settings_stm32.h
1313
EXTRA_DIST += examples/configs/user_settings_template.h
1414
EXTRA_DIST += examples/configs/user_settings_tls12.h
1515
EXTRA_DIST += examples/configs/user_settings_wolfboot_keytools.h
16+
EXTRA_DIST += examples/configs/user_settings_wolfssh.h
1617
EXTRA_DIST += examples/configs/user_settings_wolftpm.h
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
/* user_settings_wolfssh.h
2+
*
3+
* Copyright (C) 2006-2024 wolfSSL Inc.
4+
*
5+
* This file is part of wolfSSL.
6+
*
7+
* wolfSSL is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfSSL is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20+
*/
21+
22+
23+
/* To use the rename file to user_settings.h and define WOLFSSL_USER_SETTINGS */
24+
25+
/* Started from the following configure and hand tuned, organized and commented:
26+
./configure --enable-wolfssh --enable-sp=small --enable-sp-math \
27+
--disable-sp-asm --disable-asm --disable-sys-ca-certs --enable-aesgcm=small \
28+
--enable-cryptonly --disable-sha3 --disable-chacha --disable-poly1305 \
29+
--disable-md5 --disable-error-queue-per-thread --disable-pkcs12 \
30+
--disable-errorstrings --disable-sni --disable-sha224
31+
make
32+
*/
33+
34+
/* Tested using:
35+
cp ./examples/configs/user_settings_wolfssh.h user_settings.h
36+
cp ./examples/configs/user_settings_wolfssh.h ../wolfSSH/user_settings.h
37+
38+
wolfSSL:
39+
./configure --enable-usersettings --disable-examples CFLAGS="-Os"
40+
make
41+
sudo make install
42+
43+
wolfSSH:
44+
./configure --enable-scp --disable-shared --disable-term \
45+
CFLAGS="-DWOLFSSL_USER_SETTINGS -Os"
46+
make
47+
*/
48+
49+
#ifndef WOLFSSL_USER_SETTINGS_SSH_H
50+
#define WOLFSSL_USER_SETTINGS_SSH_H
51+
52+
#ifdef __cplusplus
53+
extern "C" {
54+
#endif
55+
56+
/* #define USE_LOW_RESOURCE */
57+
58+
/* Platform */
59+
#ifdef USE_LOW_RESOURCE
60+
/* Threading and filesystem required for wolfSSH tests \
61+
* Can be set for wolfSSH library only use */
62+
#define SINGLE_THREADED
63+
#define NO_FILESYSTEM
64+
#define BENCH_EMBEDDED
65+
#endif
66+
67+
/* Features */
68+
#define WOLFSSL_WOLFSSH
69+
#if 1
70+
#define WOLFCRYPT_ONLY /* no TLS */
71+
#endif
72+
#define HAVE_HASHDRBG
73+
#define WOLFSSL_ASN_TEMPLATE
74+
#define WOLFSSL_PUBLIC_MP
75+
#ifndef USE_LOW_RESOURCE
76+
#define WOLFSSL_BASE64_ENCODE
77+
#endif
78+
79+
#ifndef WOLFCRYPT_ONLY
80+
#define HAVE_TLS_EXTENSIONS
81+
#define HAVE_SUPPORTED_CURVES
82+
#define HAVE_ENCRYPT_THEN_MAC
83+
#endif
84+
85+
/* Timing Resistance */
86+
#define TFM_TIMING_RESISTANT
87+
#define ECC_TIMING_RESISTANT
88+
#define WC_RSA_BLINDING
89+
90+
/* Asymmetric */
91+
#if 1 /* RSA - PKCS1v1.5 */
92+
#undef NO_RSA
93+
#define WC_NO_RSA_OAEP /* SSH does not use OAEP */
94+
95+
#ifdef USE_LOW_RESOURCE
96+
#define RSA_LOW_MEM
97+
#endif
98+
#else
99+
#define NO_RSA
100+
#endif
101+
102+
#if 1 /* DH */
103+
/* RFC 4253 requires "DH w/SHA-1"
104+
* RFC 9142 requires "diffie-hellman-group14-sha256"
105+
*/
106+
#undef NO_DH
107+
#ifndef WOLFCRYPT_ONLY
108+
#define HAVE_DH_DEFAULT_PARAMS
109+
#define HAVE_FFDHE_2048
110+
#endif
111+
#else
112+
#define NO_DH
113+
#endif
114+
#if 1 /* ECC */
115+
#define HAVE_ECC
116+
#ifndef USE_LOW_RESOURCE /* optional ECC SHAMIR speedup */
117+
#define ECC_SHAMIR
118+
#endif
119+
#define ECC_USER_CURVES
120+
#ifndef USE_LOW_RESOURCE
121+
#define HAVE_ECC384
122+
#define HAVE_ECC521
123+
#endif
124+
#endif
125+
126+
/* Symmetric AES CBC/GCM */
127+
#undef NO_AES_CBC
128+
#if 1 /* GCM */
129+
#define HAVE_AESGCM
130+
#define GCM_SMALL
131+
#endif
132+
#ifdef USE_LOW_RESOURCE
133+
#define WOLFSSL_AES_SMALL_TABLES
134+
#endif
135+
136+
/* Hashing SHA-1/SHA2-256 */
137+
#undef NO_SHA
138+
#undef NO_SHA256
139+
#ifdef USE_LOW_RESOURCE
140+
#define USE_SLOW_SHA
141+
#define USE_SLOW_SHA256
142+
#endif
143+
#if 0
144+
#define WOLFSSL_SHA384
145+
#define WOLFSSL_SHA512
146+
#ifdef USE_LOW_RESOURCE
147+
#define USE_SLOW_SHA512
148+
#endif
149+
#endif
150+
151+
152+
/* Math */
153+
/* Multi Precision (MP): Enable support for uncommon key sizes / curves */
154+
#if 0
155+
#define WOLFSSL_SP_MATH_ALL
156+
#endif
157+
158+
/* Single Precision (SP) Math */
159+
#define WOLFSSL_SP_MATH
160+
#define WOLFSSL_SP_SMALL
161+
162+
#if !defined(NO_RSA) || !defined(NO_DH)
163+
#undef WOLFSSL_SP_NO_2048 /* 2048-bit */
164+
#ifdef USE_LOW_RESOURCE
165+
#define WOLFSSL_SP_NO_3072 /* 3072-bit */
166+
#else
167+
#undef WOLFSSL_SP_NO_3072 /* 3072-bit */
168+
#define WOLFSSL_SP_4096 /* 4096-bit */
169+
#endif
170+
171+
#ifndef NO_RSA
172+
#define WOLFSSL_HAVE_SP_RSA
173+
#endif
174+
#ifndef NO_DH
175+
#define WOLFSSL_HAVE_SP_DH
176+
#endif
177+
#endif
178+
#ifdef HAVE_ECC
179+
#define WOLFSSL_HAVE_SP_ECC
180+
181+
#undef WOLFSSL_SP_NO_256 /* 256-bit */
182+
#ifdef HAVE_ECC384
183+
#define WOLFSSL_SP_384 /* 384-bit */
184+
#endif
185+
#ifdef HAVE_ECC521
186+
#define WOLFSSL_SP_521 /* 521-bit */
187+
#endif
188+
#endif
189+
190+
/* Disable Algorithms */
191+
#define NO_DSA
192+
#define NO_DES3
193+
#define NO_MD4
194+
#define NO_MD5
195+
#define NO_RC4
196+
#define NO_PSK
197+
#define NO_PKCS12
198+
#define NO_PWDBASED
199+
#define WOLFSSL_NO_SHAKE128
200+
#define WOLFSSL_NO_SHAKE256
201+
202+
/* Disable Features */
203+
#define NO_ERROR_STRINGS
204+
#define WC_NO_ASYNC_THREADING
205+
#define NO_DES3_TLS_SUITES
206+
#define NO_OLD_TLS
207+
#define WOLFSSL_NO_TLS12
208+
209+
#ifdef __cplusplus
210+
}
211+
#endif
212+
213+
214+
#endif /* WOLFSSL_USER_SETTINGS_SSH_H */

0 commit comments

Comments
 (0)