Skip to content

Commit d866144

Browse files
committed
Merge branch 'master' into merge-fips-builds
2 parents db858fd + 298b488 commit d866144

38 files changed

Lines changed: 7637 additions & 1137 deletions

INSTALL

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,20 @@ We also have vcpkg ports for wolftpm, wolfmqtt and curl.
264264
branch of the hash-sigs project.
265265

266266
Currently the hash-sigs project only builds static libraries:
267+
- hss_verify.a: a single-threaded verify-only static lib.
267268
- hss_lib.a: a single-threaded static lib.
268269
- hss_lib_thread.a: a multi-threaded static lib.
269270

270271
The multi-threaded version will mainly have speedups for key
271272
generation and signing.
272273

273-
Additionally, the hash-sigs project can be modified to build
274-
and install a shared library in /usr/local with either single
275-
or multi-threaded versions. If the shared version has been
276-
built, libhss.so is the assumed name.
274+
The default LMS build (--enable-lms) will look for
275+
hss_lib.a first, and hss_lib_thread.a second, in a specified
276+
hash-sigs dir.
277277

278-
wolfSSL supports either option, and by default will look for
279-
hss_lib.a first, and hss_lib_thread.a second, and libhss.so
280-
lastly, in a specified hash-sigs dir.
278+
The LMS verify-only build (--enable-lms=verify-only) will look
279+
for hss_verify.a only, which is a slimmer library that includes
280+
only the minimal functions necessary for signature verification.
281281

282282
How to get and build the hash-sigs library:
283283
$ mkdir ~/hash_sigs
@@ -299,12 +299,17 @@ We also have vcpkg ports for wolftpm, wolfmqtt and curl.
299299
$ ls *.a
300300
hss_lib_thread.a
301301

302+
To build verify-only:
303+
$ make hss_verify.a
304+
$ ls *.a
305+
hss_verify.a
306+
302307
Build wolfSSL with
303308
$ ./configure \
304309
--enable-static \
305310
--disable-shared \
306-
--enable-lms=yes \
307-
--with-liblms=<path to dir containing hss_lib_thread.a>
311+
--enable-lms \
312+
--with-liblms=<path to dir containing hss_lib.a or hss_lib_thread.a>
308313
$ make
309314

310315
Run the benchmark against LMS/HSS with:

configure.ac

Lines changed: 65 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,49 @@ then
11411141
fi
11421142

11431143

1144+
# LMS
1145+
AC_ARG_ENABLE([lms],
1146+
[AS_HELP_STRING([--enable-lms],[Enable stateful LMS/HSS signatures (default: disabled)])],
1147+
[ ENABLED_LMS=$enableval ],
1148+
[ ENABLED_LMS=no ]
1149+
)
1150+
1151+
ENABLED_WC_LMS=no
1152+
for v in `echo $ENABLED_LMS | tr "," " "`
1153+
do
1154+
case $v in
1155+
yes)
1156+
;;
1157+
no)
1158+
;;
1159+
verify-only)
1160+
LMS_VERIFY_ONLY=yes
1161+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LMS_VERIFY_ONLY"
1162+
;;
1163+
wolfssl)
1164+
ENABLED_WC_LMS=yes
1165+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_WC_LMS"
1166+
;;
1167+
*)
1168+
AC_MSG_ERROR([Invalid choice for LMS []: $ENABLED_LMS.])
1169+
break;;
1170+
esac
1171+
done
1172+
1173+
if test "$ENABLED_LMS" != "no"
1174+
then
1175+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_LMS"
1176+
1177+
if test "$ENABLED_WC_LMS" = "no";
1178+
then
1179+
# Default is to use hash-sigs LMS lib. Make sure it's enabled.
1180+
if test "$ENABLED_LIBLMS" = "no"; then
1181+
AC_MSG_ERROR([The default implementation for LMS is the hash-sigs LMS/HSS lib.
1182+
Please use --with-liblms.])
1183+
fi
1184+
fi
1185+
fi
1186+
11441187
# liblms
11451188
# Get the path to the hash-sigs LMS HSS lib.
11461189
ENABLED_LIBLMS="no"
@@ -1160,10 +1203,21 @@ AC_ARG_WITH([liblms],
11601203
tryliblmsdir="/usr/local"
11611204
fi
11621205
1163-
# 1. By default use the hash-sigs single-threaded static library.
1164-
# 2. If 1 not found, then use the multi-threaded static lib.
1165-
# 3. If 2 not found, then use the multi-threaded dynamic lib.
1166-
if test -e $tryliblmsdir/hss_lib.a; then
1206+
# 1. If verify only build, use hss_verify.a
1207+
# 2. If normal build, by default use single-threaded hss_lib.a
1208+
# 3. If 2 not found, then use the multi-threaded hss_lib_thread.a
1209+
if test "$LMS_VERIFY_ONLY" = "yes"; then
1210+
if test -e $tryliblmsdir/hss_verify.a; then
1211+
CPPFLAGS="$AM_CPPFLAGS -DHAVE_LIBLMS -I$tryliblmsdir"
1212+
LIB_STATIC_ADD="$LIB_STATIC_ADD $tryliblmsdir/hss_verify.a"
1213+
enable_shared=no
1214+
enable_static=yes
1215+
liblms_linked=yes
1216+
else
1217+
AC_MSG_ERROR([hss_verify.a isn't found.
1218+
If it's already installed, specify its path using --with-liblms=/dir/])
1219+
fi
1220+
elif test -e $tryliblmsdir/hss_lib.a; then
11671221
CPPFLAGS="$AM_CPPFLAGS -DHAVE_LIBLMS -I$tryliblmsdir"
11681222
LIB_STATIC_ADD="$LIB_STATIC_ADD $tryliblmsdir/hss_lib.a"
11691223
enable_shared=no
@@ -1175,12 +1229,6 @@ AC_ARG_WITH([liblms],
11751229
enable_shared=no
11761230
enable_static=yes
11771231
liblms_linked=yes
1178-
elif test -e $tryliblmsdir/lib/libhss.so; then
1179-
LIBS="$LIBS -lhss"
1180-
CPPFLAGS="$AM_CPPFLAGS -DHAVE_LIBLMS -I$tryliblmsdir/include/hss"
1181-
LDFLAGS="$AM_LDFLAGS $LDFLAGS -L$tryliblmsdir/lib"
1182-
1183-
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <hss.h>]], [[ param_set_t lm_type; param_set_t lm_ots_type; hss_get_public_key_len(4, &lm_type, &lm_ots_type); ]])], [ liblms_linked=yes ],[ liblms_linked=no ])
11841232
else
11851233
AC_MSG_ERROR([liblms isn't found.
11861234
If it's already installed, specify its path using --with-liblms=/dir/])
@@ -1203,47 +1251,6 @@ AC_ARG_WITH([liblms],
12031251
]
12041252
)
12051253

1206-
1207-
# LMS
1208-
AC_ARG_ENABLE([lms],
1209-
[AS_HELP_STRING([--enable-lms],[Enable stateful LMS/HSS signatures (default: disabled)])],
1210-
[ ENABLED_LMS=$enableval ],
1211-
[ ENABLED_LMS=no ]
1212-
)
1213-
1214-
ENABLED_WC_LMS=no
1215-
for v in `echo $ENABLED_LMS | tr "," " "`
1216-
do
1217-
case $v in
1218-
yes)
1219-
;;
1220-
no)
1221-
;;
1222-
wolfssl)
1223-
ENABLED_WC_LMS=yes
1224-
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_WC_LMS"
1225-
;;
1226-
*)
1227-
AC_MSG_ERROR([Invalid choice for LMS []: $ENABLED_LMS.])
1228-
break;;
1229-
esac
1230-
done
1231-
1232-
if test "$ENABLED_LMS" != "no"
1233-
then
1234-
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_HAVE_LMS"
1235-
1236-
if test "$ENABLED_WC_LMS" = "no";
1237-
then
1238-
# Default is to use hash-sigs LMS lib. Make sure it's enabled.
1239-
if test "$ENABLED_LIBLMS" = "no"; then
1240-
AC_MSG_ERROR([The default implementation for LMS is the hash-sigs LMS/HSS lib.
1241-
Please use --with-liblms.])
1242-
fi
1243-
fi
1244-
fi
1245-
1246-
12471254
# SINGLE THREADED
12481255
AC_ARG_ENABLE([singlethreaded],
12491256
[AS_HELP_STRING([--enable-singlethreaded],[Enable wolfSSL single threaded (default: disabled)])],
@@ -2268,7 +2275,7 @@ AC_ARG_ENABLE([aescbc],
22682275
if test "$ENABLED_AESCBC" = "no"
22692276
then
22702277
AM_CFLAGS="$AM_CFLAGS -DNO_AES_CBC"
2271-
AM_CCASFLAGS="$AM_CCASFLAGS -DHAVE_AES_CBC"
2278+
AM_CCASFLAGS="$AM_CCASFLAGS -DNO_AES_CBC"
22722279
fi
22732280

22742281
# AES-CBC length checks (checks that input lengths are multiples of block size)
@@ -2582,7 +2589,7 @@ then
25822589
AC_MSG_NOTICE([64bit ARMv8 found, setting mcpu to generic+crypto])
25832590
;;
25842591
armv7a*)
2585-
AM_CPPFLAGS="$AM_CPPFLAGS -march=armv7-a -mfpu=neon -DWOLFSSL_ARM_ARCH=7"
2592+
AM_CPPFLAGS="$AM_CPPFLAGS -march=armv7-a -mfpu=neon -DWOLFSSL_ARM_ARCH=7 -marm"
25862593
# Include options.h
25872594
AM_CCASFLAGS="$AM_CCASFLAGS -DEXTERNAL_OPTS_OPENVPN"
25882595
ENABLED_ARMASM_CRYPTO=no
@@ -5984,6 +5991,11 @@ then
59845991
ENABLED_CERTGEN="yes"
59855992
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_GEN"
59865993
fi
5994+
if test "x$ENABLED_CERTREQ" = "xno"
5995+
then
5996+
ENABLED_CERTREQ="yes"
5997+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CERT_REQ"
5998+
fi
59875999
if test "x$ENABLED_SNI" = "xno"
59886000
then
59896001
ENABLED_SNI="yes"

doc/dox_comments/header_files-ja/asn_public.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ int wc_GetSubjectRaw(byte **subjectRaw, Cert *cert);
393393
\return ASN_NO_SIGNER_E CA証明書の主体者を検証することができない場合に返されます。
394394
395395
\param cert 主体者の別名を設定する対象のCert構造体へのポインタ
396-
\param file PEM形式の証明書を格納しているバッファへのポインタ。
396+
\param file PEM形式の証明書のファイルパス
397397
398398
_Example_
399399
\code
@@ -901,7 +901,7 @@ int wc_PubKeyPemToDer(const unsigned char* pem, int pemSz,
901901
\return MEMORY_E メモリの確保に失敗した際に返されます。
902902
903903
\param fileName PEM形式のファイルパス
904-
\param derBuf DER形式証明書を出力する先のバッファ
904+
\param derBuf DER形式証明書を出力する先のバッファへのポインタ
905905
\param derSz DER形式証明書を出力する先のバッファのサイズ
906906
907907
_Example_
@@ -1127,7 +1127,7 @@ int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx,
11271127
/*!
11281128
\ingroup ASN
11291129
1130-
\brief この関数はECC秘密鍵をDER形式で出力します
1130+
\brief この関数はECC秘密鍵をDER形式でバッファに出力します
11311131
11321132
\return ECC秘密鍵をDER形式での出力に成功した場合にはバッファへ出力したサイズを返します。
11331133
\return BAD_FUNC_ARG 出力バッファoutputがNULLあるいはinLenがゼロの場合に返します。
@@ -1201,7 +1201,7 @@ int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
12011201
処理したバッファのサイズを返します。変換して得られるDER形式のECC公開鍵は出力バッファに格納されます。
12021202
AlgCurveフラグの指定により、アルゴリズムと曲線情報をヘッダーに含めることができます。
12031203
1204-
\return >0 成功時には処理したバッファのサイズを返します。
1204+
\return 成功時には処理したバッファのサイズを返します。
12051205
\return BAD_FUNC_ARG 出力バッファoutputあるいはecc_key構造体keyがNULLの場合に返します。
12061206
\return LENGTH_ONLY_E ECC公開鍵のサイズ取得に失敗した場合に返します。
12071207
\return BUFFER_E 出力バッファが必要量より小さい場合に返します。
@@ -1496,7 +1496,7 @@ int wc_EncryptPKCS8Key(byte* key, word32 keySz, byte* out,
14961496
/*!
14971497
\ingroup ASN
14981498
1499-
\brief この関数は暗号化されたPKCS#8のDER形式の鍵を受け取り、復号してPKCS#8 非暗号化DER形式に変換します
1499+
\brief この関数は暗号化されたPKCS#8のDER形式の鍵を受け取り、復号してPKCS#8 DER形式に変換します
15001500
wc_EncryptPKCS8Keyによって行われた暗号化を元に戻します。RFC5208を参照してください。
15011501
入力データは復号データによって上書きされます。
15021502
@@ -1794,11 +1794,11 @@ int wc_SetCustomExtension(Cert *cert, int critical, const char *oid,
17941794
// failed to set the callback
17951795
}
17961796
1797-
// oid: Array of integers that are the dot separated values in an oid.
1798-
// oidSz: Number of values in oid.
1799-
// crit: Whether the extension was mark critical.
1800-
// der: The der encoding of the content of the extension.
1801-
// derSz: The size in bytes of the der encoding.
1797+
// oid: OIDを構成するドット区切りの数を格納した配列
1798+
// oidSz: oid内の値の数
1799+
// crit: 拡張がクリティカルとマークされているか
1800+
// der: DERエンコードされている拡張の内容
1801+
// derSz: 拡張の内容のサイズ
18021802
int myCustomExtCallback(const word16* oid, word32 oidSz, int crit,
18031803
const unsigned char* der, word32 derSz) {
18041804
@@ -1808,6 +1808,8 @@ int wc_SetCustomExtension(Cert *cert, int critical, const char *oid,
18081808
// 表明することになります。この拡張を処理できると判断できない場合にはエラーを
18091809
// 返してください。クリティカルとマークされている未知の拡張に遭遇した際の標準的
18101810
// な振る舞いはASN_CRIT_EXT_Eを返すことです。
1811+
// 簡潔にするためにこの例ではすべての拡張情報を受け入れ可としていますが、実際には実情に沿うようにロジックを追加してください。
1812+
18111813
return 0;
18121814
}
18131815
\endcode

src/include.am

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,26 @@ endif
157157

158158
if BUILD_AES
159159
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/aes.c
160-
if BUILD_ARMASM_NEON
160+
if BUILD_ARMASM
161161
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/armv8-aes.c
162+
endif BUILD_ARMASM
163+
if BUILD_ARMASM_NEON
162164
if !BUILD_ARMASM_CRYPTO
163165
if BUILD_ARMASM_INLINE
164166
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/armv8-32-aes-asm_c.c
165167
else
166168
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/armv8-32-aes-asm.S
167169
endif !BUILD_ARMASM_INLINE
168170
endif !BUILD_ARMASM_CRYPTO
169-
endif BUILD_ARMASM_NEON
171+
else
172+
if BUILD_ARMASM
173+
if BUILD_ARMASM_INLINE
174+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-aes-asm_c.c
175+
else
176+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-aes-asm.S
177+
endif !BUILD_ARMASM_INLINE
178+
endif BUILD_ARMASM
179+
endif !BUILD_ARMASM_NEON
170180
endif BUILD_AES
171181

172182
if BUILD_AESNI
@@ -401,16 +411,28 @@ endif
401411
if !BUILD_FIPS_CURRENT
402412
if BUILD_AES
403413
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/aes.c
404-
if BUILD_ARMASM_NEON
414+
if BUILD_ARMASM
405415
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/armv8-aes.c
416+
endif BUILD_ARMASM
417+
if BUILD_ARMASM_NEON
406418
if !BUILD_ARMASM_CRYPTO
407419
if BUILD_ARMASM_INLINE
408420
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/armv8-32-aes-asm_c.c
421+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-aes-asm_c.c
409422
else
410423
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/armv8-32-aes-asm.S
424+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-aes-asm.S
411425
endif !BUILD_ARMASM_INLINE
412426
endif !BUILD_ARMASM_CRYPTO
413-
endif BUILD_ARMASM_NEON
427+
else
428+
if BUILD_ARMASM
429+
if BUILD_ARMASM_INLINE
430+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-aes-asm_c.c
431+
else
432+
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/arm/thumb2-aes-asm.S
433+
endif !BUILD_ARMASM_INLINE
434+
endif BUILD_ARMASM
435+
endif !BUILD_ARMASM_NEON
414436
if BUILD_AFALG
415437
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/port/af_alg/afalg_aes.c
416438
endif BUILD_AFALG

src/internal.c

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9199,13 +9199,21 @@ int VerifyForDtlsMsgPoolSend(WOLFSSL* ssl, byte type, word32 fragOffset)
91999199
* to be used for triggering retransmission of whole DtlsMsgPool.
92009200
* change cipher suite type is not verified here
92019201
*/
9202-
return ((fragOffset == 0) &&
9203-
(((ssl->options.side == WOLFSSL_SERVER_END) &&
9204-
((type == client_hello) ||
9205-
((ssl->options.verifyPeer) && (type == certificate)) ||
9206-
((!ssl->options.verifyPeer) && (type == client_key_exchange)))) ||
9207-
((ssl->options.side == WOLFSSL_CLIENT_END) &&
9208-
(type == hello_request || type == server_hello))));
9202+
if (fragOffset == 0) {
9203+
if (ssl->options.side == WOLFSSL_SERVER_END) {
9204+
if (type == client_hello)
9205+
return 1;
9206+
else if (ssl->options.verifyPeer && type == certificate)
9207+
return 1;
9208+
else if (!ssl->options.verifyPeer && type == client_key_exchange)
9209+
return 1;
9210+
}
9211+
else {
9212+
if (type == hello_request || type == server_hello)
9213+
return 1;
9214+
}
9215+
}
9216+
return 0;
92099217
}
92109218

92119219

@@ -20003,9 +20011,10 @@ static int HandleDTLSDecryptFailed(WOLFSSL* ssl)
2000320011

2000420012
static int DtlsShouldDrop(WOLFSSL* ssl, int retcode)
2000520013
{
20006-
if (ssl->options.handShakeDone && !IsEncryptionOn(ssl, 0)) {
20014+
if (ssl->options.handShakeDone && !IsEncryptionOn(ssl, 0) &&
20015+
!ssl->options.dtlsHsRetain) {
2000720016
WOLFSSL_MSG("Silently dropping plaintext DTLS message "
20008-
"on established connection.");
20017+
"on established connection when we have nothing to send.");
2000920018
return 1;
2001020019
}
2001120020

src/ssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8300,7 +8300,7 @@ int wolfSSL_CTX_load_verify_locations_ex(WOLFSSL_CTX* ctx, const char* file,
83008300
/* pass directory read failure to response code */
83018301
if (fileRet != WC_READDIR_NOFILE) {
83028302
ret = fileRet;
8303-
#if defined(WOLFSSL_QT)
8303+
#if defined(WOLFSSL_QT) || defined(WOLFSSL_IGNORE_BAD_CERT_PATH)
83048304
if (ret == BAD_PATH_ERROR &&
83058305
flags & WOLFSSL_LOAD_FLAG_IGNORE_BAD_PATH_ERR) {
83068306
/* QSslSocket always loads certs in system folder

0 commit comments

Comments
 (0)