Skip to content

Commit 28ed8f3

Browse files
authored
Merge pull request #54 from bandi13/fixBuilds
Fix builds
2 parents 78b0165 + e2dcfaa commit 28ed8f3

File tree

8 files changed

+294
-32
lines changed

8 files changed

+294
-32
lines changed

include/wolfprovider/internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ enum wc_HashType wp_nid_to_wc_hash_type(int nid);
150150
int wp_name_to_wc_mgf(OSSL_LIB_CTX* libCtx, const char* name,
151151
const char* propQ);
152152
int wp_mgf1_from_hash(int nid);
153+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
154+
int wp_hash_copy(wc_HashAlg* src, wc_HashAlg* dst);
155+
#else
153156
int wp_hash_copy(wc_HashAlg* src, wc_HashAlg* dst, enum wc_HashType hashType);
157+
#endif
154158

155159
int wp_cipher_from_params(const OSSL_PARAM params[], int* cipher,
156160
const char** cipherName);

scripts/utils-general.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,19 @@ if [ "$UTILS_GENERAL_LOADED" != "yes" ]; then # only set once
2626

2727
export UTILS_GENERAL_LOADED=yes
2828
fi
29+
30+
check_folder_age() {
31+
folderA=$1
32+
folderB=$2
33+
folderA_age=$(find "$folderA" -type f -printf '%T@' | sort -n | tail -n 1)
34+
folderB_age=$(find "$folderB" -type f -printf '%T@' | sort -n | tail -n 1)
35+
36+
if awk "BEGIN {exit !($folderA_age > $folderB_age)}"; then
37+
echo 1
38+
elif awk "BEGIN {exit !($folderA_age < $folderB_age)}"; then
39+
echo -1
40+
else
41+
echo 0
42+
fi
43+
}
44+

scripts/utils-openssl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
2727
source ${SCRIPT_DIR}/utils-general.sh
2828

2929
OPENSSL_GIT="https://github.com/openssl/openssl.git"
30-
OPENSSL_TAG=${OPENSSL_TAG:-"openssl-3.0.0"}
30+
OPENSSL_TAG=${OPENSSL_TAG:-"openssl-3.2.0"}
3131
OPENSSL_SOURCE_DIR=${SCRIPT_DIR}/../openssl-source
3232
OPENSSL_INSTALL_DIR=${SCRIPT_DIR}/../openssl-install
3333

scripts/utils-wolfprovider.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ install_wolfprov() {
4343
init_wolfssl
4444
printf "LD_LIBRARY_PATH: $LD_LIBRARY_PATH\n"
4545

46-
if [ ! -d ${WOLFPROV_INSTALL_DIR} ]; then
46+
if [ ! -d ${WOLFPROV_INSTALL_DIR} ] || [ $(check_folder_age "${WOLFPROV_INSTALL_DIR}" "${WOLFSSL_INSTALL_DIR}") -lt 0 ] || [ $(check_folder_age "${WOLFPROV_INSTALL_DIR}" "${OPENSSL_INSTALL_DIR}") -lt 0 ]; then
4747
printf "\tConfigure wolfProvider ... "
4848
if [ ! -e "${WOLFPROV_SOURCE_DIR}/configure" ]; then
4949
./autogen.sh >>$LOG_FILE 2>&1

src/wp_ecdsa_sig.c

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ typedef struct wp_EcdsaSigCtx {
5151

5252
/** wolfSSL hash object. */
5353
wc_HashAlg hash;
54+
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
5455
/** Hash algorithm to use on data to be signed. */
5556
enum wc_HashType hashType;
57+
#endif
5658

5759
/** Property query string. */
5860
char* propQuery;
@@ -140,16 +142,21 @@ static wp_EcdsaSigCtx* wp_ecdsa_dupctx(wp_EcdsaSigCtx* srcCtx)
140142
ok = 0;
141143
}
142144

143-
if (ok && (!wp_hash_copy(&srcCtx->hash, &dstCtx->hash,
144-
srcCtx->hashType))) {
145+
if (ok && (!wp_hash_copy(&srcCtx->hash, &dstCtx->hash
146+
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
147+
,srcCtx->hashType
148+
#endif
149+
))) {
145150
ok = 0;
146151
}
147152
if (ok && (!wp_ecc_up_ref(srcCtx->ecc))) {
148153
ok = 0;
149154
}
150155
if (ok) {
151156
dstCtx->ecc = srcCtx->ecc;
157+
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
152158
dstCtx->hashType = srcCtx->hashType;
159+
#endif
153160
dstCtx->op = srcCtx->op;
154161
XMEMCPY(dstCtx->mdName, srcCtx->mdName, sizeof(srcCtx->mdName));
155162
}
@@ -249,8 +256,14 @@ static int wp_ecdsa_sign(wp_EcdsaSigCtx *ctx, unsigned char *sig,
249256
*sigLen = wc_ecc_sig_size(wp_ecc_get_key(ctx->ecc));
250257
}
251258
else {
259+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
260+
if ((ctx->hash.type != WC_HASH_TYPE_NONE) &&
261+
(tbsLen != (size_t)wc_HashGetDigestSize(ctx->hash.type)))
262+
#else
252263
if ((ctx->hashType != WC_HASH_TYPE_NONE) &&
253-
(tbsLen != (size_t)wc_HashGetDigestSize(ctx->hashType))) {
264+
(tbsLen != (size_t)wc_HashGetDigestSize(ctx->hashType)))
265+
#endif
266+
{
254267
ok = 0;
255268
}
256269
else if ((ok = wp_ecc_check_usage(ctx->ecc))) {
@@ -410,17 +423,33 @@ static int wp_ecdsa_setup_md(wp_EcdsaSigCtx *ctx, const char *mdName,
410423
if (mdName != NULL) {
411424
int rc;
412425

426+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
427+
ctx->hash.type = wp_name_to_wc_hash_type(ctx->libCtx, mdName, mdProps);
428+
if ((ctx->hash.type == WC_HASH_TYPE_NONE) ||
429+
(ctx->hash.type == WC_HASH_TYPE_MD5))
430+
#else
413431
ctx->hashType = wp_name_to_wc_hash_type(ctx->libCtx, mdName, mdProps);
414432
if ((ctx->hashType == WC_HASH_TYPE_NONE) ||
415-
(ctx->hashType == WC_HASH_TYPE_MD5)) {
433+
(ctx->hashType == WC_HASH_TYPE_MD5))
434+
#endif
435+
{
416436
ok = 0;
417437
}
418-
if ((ctx->hashType == WC_HASH_TYPE_SHA) && (op == EVP_PKEY_OP_SIGN)) {
438+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
439+
if ((ctx->hash.type == WC_HASH_TYPE_SHA) && (op == EVP_PKEY_OP_SIGN))
440+
#else
441+
if ((ctx->hashType == WC_HASH_TYPE_SHA) && (op == EVP_PKEY_OP_SIGN))
442+
#endif
443+
{
419444
ok = 0;
420445
}
421446

422447
if (ok) {
448+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
449+
rc = wc_HashInit_ex(&ctx->hash, ctx->hash.type, NULL, INVALID_DEVID);
450+
#else
423451
rc = wc_HashInit_ex(&ctx->hash, ctx->hashType, NULL, INVALID_DEVID);
452+
#endif
424453
if (rc != 0) {
425454
ok = 0;
426455
}
@@ -475,7 +504,13 @@ static int wp_ecdsa_digest_signverify_update(wp_EcdsaSigCtx *ctx,
475504
const unsigned char *data, size_t dataLen)
476505
{
477506
int ok = 1;
478-
int rc = wc_HashUpdate(&ctx->hash, ctx->hashType, data, (word32)dataLen);
507+
int rc = wc_HashUpdate(&ctx->hash,
508+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
509+
ctx->hash.type,
510+
#else
511+
ctx->hashType,
512+
#endif
513+
data, (word32)dataLen);
479514
if (rc != 0) {
480515
ok = 0;
481516
}
@@ -533,15 +568,27 @@ static int wp_ecdsa_digest_sign_final(wp_EcdsaSigCtx *ctx, unsigned char *sig,
533568
ok = 0;
534569
}
535570
else if (sig != NULL) {
536-
int rc = wc_HashFinal(&ctx->hash, ctx->hashType, digest);
571+
int rc = wc_HashFinal(&ctx->hash,
572+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
573+
ctx->hash.type,
574+
#else
575+
ctx->hashType,
576+
#endif
577+
digest);
537578
if (rc != 0) {
538579
ok = 0;
539580
}
540581
}
541582

542583
if (ok) {
543584
ok = wp_ecdsa_sign(ctx, sig, sigLen, sigSize, digest,
544-
wc_HashGetDigestSize(ctx->hashType));
585+
wc_HashGetDigestSize(
586+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
587+
ctx->hash.type
588+
#else
589+
ctx->hashType
590+
#endif
591+
));
545592
}
546593

547594
WOLFPROV_LEAVE(WP_LOG_KE, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), ok);
@@ -594,15 +641,26 @@ static int wp_ecdsa_digest_verify_final(wp_EcdsaSigCtx *ctx, unsigned char *sig,
594641
ok = 0;
595642
}
596643
else {
597-
int rc = wc_HashFinal(&ctx->hash, ctx->hashType, digest);
644+
int rc = wc_HashFinal(&ctx->hash,
645+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
646+
ctx->hash.type,
647+
#else
648+
ctx->hashType,
649+
#endif
650+
digest);
598651
if (rc != 0) {
599652
ok = 0;
600653
}
601654
}
602655

603656
if (ok) {
604657
ok = wp_ecdsa_verify(ctx,sig, sigLen, digest,
605-
wc_HashGetDigestSize(ctx->hashType));
658+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
659+
wc_HashGetDigestSize(ctx->hash.type)
660+
#else
661+
wc_HashGetDigestSize(ctx->hashType)
662+
#endif
663+
);
606664
}
607665

608666
WOLFPROV_LEAVE(WP_LOG_KE, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), ok);

src/wp_ecx_sig.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ typedef struct wp_EcxSigCtx {
5050

5151
/** wolfSSL hash object. */
5252
wc_HashAlg hash;
53+
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
5354
/** Hash algorithm to use on data to be signed. */
5455
enum wc_HashType hashType;
56+
#endif
5557

5658
/** Property query string. */
5759
char* propQuery;
@@ -135,16 +137,22 @@ static wp_EcxSigCtx* wp_ecx_dupctx(wp_EcxSigCtx* srcCtx)
135137
ok = 0;
136138
}
137139

138-
if (ok && (!wp_hash_copy(&srcCtx->hash, &dstCtx->hash,
139-
srcCtx->hashType))) {
140+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
141+
if (ok && (!wp_hash_copy(&srcCtx->hash, &dstCtx->hash)))
142+
#else
143+
if (ok && (!wp_hash_copy(&srcCtx->hash, &dstCtx->hash, srcCtx->hashType)))
144+
#endif
145+
{
140146
ok = 0;
141147
}
142148
if (ok && (!wp_ecx_up_ref(srcCtx->ecx))) {
143149
ok = 0;
144150
}
145151
if (ok) {
146152
dstCtx->ecx = srcCtx->ecx;
153+
#if LIBWOLFSSL_VERSION_HEX < 0x05007004
147154
dstCtx->hashType = srcCtx->hashType;
155+
#endif
148156
dstCtx->op = srcCtx->op;
149157
XMEMCPY(dstCtx->mdName, srcCtx->mdName, sizeof(srcCtx->mdName));
150158
}

src/wp_internal.c

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,62 +248,103 @@ int wp_mgf1_from_hash(int nid)
248248
* @return 1 on success.
249249
* @return 0 on failure.
250250
*/
251+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
252+
int wp_hash_copy(wc_HashAlg* src, wc_HashAlg* dst)
253+
#else
251254
int wp_hash_copy(wc_HashAlg* src, wc_HashAlg* dst, enum wc_HashType hashType)
255+
#endif
252256
{
253257
int ok = 1;
254258
int rc = 0;
255259

256-
switch (hashType) {
260+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
261+
switch (src->type)
262+
#else
263+
switch (hashType)
264+
#endif
265+
{
257266
case WC_HASH_TYPE_MD5:
258267
#ifdef WP_HAVE_MD5
268+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
269+
rc = wc_Md5Copy(&src->alg.md5, &dst->alg.md5);
270+
#else
259271
rc = wc_Md5Copy(&src->md5, &dst->md5);
272+
#endif
260273
#else
261274
ok = 0;
262275
#endif
263276
break;
264277
case WC_HASH_TYPE_SHA:
265278
#ifdef WP_HAVE_SHA1
279+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
280+
rc = wc_ShaCopy(&src->alg.sha, &dst->alg.sha);
281+
#else
266282
rc = wc_ShaCopy(&src->sha, &dst->sha);
283+
#endif
267284
#else
268285
ok = 0;
269286
#endif
270287
break;
271288
case WC_HASH_TYPE_SHA224:
272289
#ifdef WP_HAVE_SHA224
290+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
291+
rc = wc_Sha224Copy(&src->alg.sha224, &dst->alg.sha224);
292+
#else
273293
rc = wc_Sha224Copy(&src->sha224, &dst->sha224);
294+
#endif
274295
#else
275296
ok = 0;
276297
#endif
277298
break;
278299
case WC_HASH_TYPE_SHA256:
279300
#ifdef WP_HAVE_SHA256
301+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
302+
rc = wc_Sha256Copy(&src->alg.sha256, &dst->alg.sha256);
303+
#else
280304
rc = wc_Sha256Copy(&src->sha256, &dst->sha256);
305+
#endif
281306
#else
282307
ok = 0;
283308
#endif
284309
break;
285310
case WC_HASH_TYPE_SHA384:
286311
#ifdef WP_HAVE_SHA384
312+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
313+
rc = wc_Sha384Copy(&src->alg.sha384, &dst->alg.sha384);
314+
#else
287315
rc = wc_Sha384Copy(&src->sha384, &dst->sha384);
316+
#endif
288317
#else
289318
ok = 0;
290319
#endif
291320
break;
292321
#ifdef WP_HAVE_SHA512
293322
case WC_HASH_TYPE_SHA512:
323+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
324+
rc = wc_Sha512Copy(&src->alg.sha512, &dst->alg.sha512);
325+
#else
294326
rc = wc_Sha512Copy(&src->sha512, &dst->sha512);
327+
#endif
295328
break;
296329
#if LIBWOLFSSL_VERSION_HEX >= 0x05000000
297330
#if !defined(WOLFSSL_NOSHA512_224) && !defined(HAVE_FIPS) && \
298331
!defined(SELF_TEST)
299332
case WC_HASH_TYPE_SHA512_224:
333+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
334+
rc = wc_Sha512_224Copy(&src->alg.sha512, &dst->alg.sha512);
335+
#else
300336
rc = wc_Sha512_224Copy(&src->sha512, &dst->sha512);
337+
#endif
301338
break;
302339
#endif /* !WOLFSSL_NOSHA512_224 */
303340
#if !defined(WOLFSSL_NOSHA512_256) && !defined(HAVE_FIPS) && \
304341
!defined(SELF_TEST)
305342
case WC_HASH_TYPE_SHA512_256:
343+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
344+
rc = wc_Sha512_256Copy(&src->alg.sha512, &dst->alg.sha512);
345+
#else
306346
rc = wc_Sha512_256Copy(&src->sha512, &dst->sha512);
347+
#endif
307348
break;
308349
#endif /* !WOLFSSL_NOSHA512_256 */
309350
#endif /* LIBWOLFSSL_VERSION_HEX >= 0x05000000 */
@@ -316,16 +357,32 @@ int wp_hash_copy(wc_HashAlg* src, wc_HashAlg* dst, enum wc_HashType hashType)
316357
#endif /* WP_HAVE_SHA512 */
317358
#ifdef WP_HAVE_SHA3
318359
case WC_HASH_TYPE_SHA3_224:
360+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
361+
rc = wc_Sha3_224_Copy(&src->alg.sha3, &dst->alg.sha3);
362+
#else
319363
rc = wc_Sha3_224_Copy(&src->sha3, &dst->sha3);
364+
#endif
320365
break;
321366
case WC_HASH_TYPE_SHA3_256:
367+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
368+
rc = wc_Sha3_256_Copy(&src->alg.sha3, &dst->alg.sha3);
369+
#else
322370
rc = wc_Sha3_256_Copy(&src->sha3, &dst->sha3);
371+
#endif
323372
break;
324373
case WC_HASH_TYPE_SHA3_384:
374+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
375+
rc = wc_Sha3_384_Copy(&src->alg.sha3, &dst->alg.sha3);
376+
#else
325377
rc = wc_Sha3_384_Copy(&src->sha3, &dst->sha3);
378+
#endif
326379
break;
327380
case WC_HASH_TYPE_SHA3_512:
381+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
382+
rc = wc_Sha3_512_Copy(&src->alg.sha3, &dst->alg.sha3);
383+
#else
328384
rc = wc_Sha3_512_Copy(&src->sha3, &dst->sha3);
385+
#endif
329386
break;
330387
#else
331388
case WC_HASH_TYPE_SHA3_224:
@@ -355,6 +412,10 @@ int wp_hash_copy(wc_HashAlg* src, wc_HashAlg* dst, enum wc_HashType hashType)
355412
}
356413
if (rc != 0) {
357414
ok = 0;
415+
#if LIBWOLFSSL_VERSION_HEX >= 0x05007004
416+
} else {
417+
dst->type = src->type;
418+
#endif
358419
}
359420

360421
WOLFPROV_LEAVE(WP_LOG_PROVIDER, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), ok);

0 commit comments

Comments
 (0)