Skip to content

Commit a578b6f

Browse files
authored
Merge pull request #57 from bandi13/fixRSAOID
Hardcode OID
2 parents 4b118eb + 2985755 commit a578b6f

File tree

8 files changed

+72
-23
lines changed

8 files changed

+72
-23
lines changed

include/wolfprovider/internal.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@
3838

3939
#include "wp_params.h"
4040

41+
#ifndef AES_BLOCK_SIZE
42+
#include <openssl/aes.h>
43+
#ifndef AES_BLOCK_SIZE
44+
#ifdef WC_NO_COMPAT_AES_BLOCK_SIZE
45+
#define AES_BLOCK_SIZE WC_AES_BLOCK_SIZE
46+
#else
47+
#error AES_BLOCK_SIZE not defined when it should be
48+
#endif
49+
#endif
50+
#endif
51+
4152
#ifndef WP_INTERNAL_H
4253
#define WP_INTERNAL_H
4354

scripts/utils-wolfssl.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
2222
source ${SCRIPT_DIR}/utils-general.sh
2323

2424
WOLFSSL_GIT=${WOLFSSL_GIT:-"https://github.com/wolfSSL/wolfssl.git"}
25-
WOLFSSL_TAG=${WOLFSSL_TAG:-"v5.7.2-stable"}
25+
WOLFSSL_TAG=${WOLFSSL_TAG:-"v5.7.4-stable"}
2626
WOLFSSL_SOURCE_DIR=${SCRIPT_DIR}/../wolfssl-source
2727
WOLFSSL_INSTALL_DIR=${SCRIPT_DIR}/../wolfssl-install
2828
WOLFSSL_ISFIPS=${WOLFSSL_ISFIPS:-0}
@@ -78,10 +78,10 @@ install_wolfssl() {
7878
fi
7979
if [ "$WOLFSSL_ISFIPS" = "1" ]; then
8080
printf "with FIPS ... "
81-
CONF_ARGS+=" --enable-fips=ready"
81+
CONF_ARGS+=" --enable-fips=v5"
8282
if [ ! -e "XXX-fips-test" ]; then
8383
# Sometimes the system OpenSSL is different than the one we're using. So for the 'git' commands, we'll just use whatever the system comes with
84-
LD_LIBRARY_PATH="" ./fips-check.sh keep nomakecheck fips-ready >>$LOG_FILE 2>&1
84+
LD_LIBRARY_PATH="" ./fips-check.sh keep nomakecheck linuxv5 >>$LOG_FILE 2>&1
8585
if [ $? != 0 ]; then
8686
printf "ERROR checking out FIPS\n"
8787
rm -rf ${WOLFSSL_INSTALL_DIR}

src/wp_digests.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ static int name##_final(CTX* ctx, unsigned char* out, size_t* outLen, \
583583
ok = 0; \
584584
} \
585585
if (ok) { \
586-
int rc = fin(&ctx->obj, out, ctx->outLen); \
586+
int rc = fin(&ctx->obj, out, (word32)ctx->outLen); \
587587
if (rc != 0) { \
588588
ok = 0; \
589589
} \

src/wp_ecx_exch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static int wp_x25519_derive(wp_EcxCtx* ctx, unsigned char* secret,
230230
}
231231
else if (ok) {
232232
int rc;
233-
word32 len = secSize;
233+
word32 len = (word32)secSize;
234234
int i;
235235

236236
rc = wc_curve25519_shared_secret(wp_ecx_get_key(ctx->key),
@@ -316,7 +316,7 @@ static int wp_x448_derive(wp_EcxCtx* ctx, unsigned char* secret,
316316
}
317317
else if (ok) {
318318
int rc;
319-
word32 len = secSize;
319+
word32 len = (word32)secSize;
320320

321321
rc = wc_curve448_shared_secret(wp_ecx_get_key(ctx->key),
322322
wp_ecx_get_key(ctx->peer), secret, &len);

src/wp_ecx_kmgmt.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ static int wp_ecx_set_params(wp_Ecx* ecx, const OSSL_PARAM params[])
404404
ok = 0;
405405
}
406406
if (ok && (data != NULL)) {
407-
int rc = (*ecx->data->importPub)(data, len, (void*)&ecx->key,
407+
int rc = (*ecx->data->importPub)(data, (word32)len, (void*)&ecx->key,
408408
ECX_LITTLE_ENDIAN);
409409
if (rc != 0) {
410410
ok = 0;
@@ -479,7 +479,7 @@ static int wp_ecx_get_params_enc_pub_key(wp_Ecx* ecx, OSSL_PARAM params[],
479479

480480
p = OSSL_PARAM_locate(params, key);
481481
if (p != NULL) {
482-
word32 outLen = p->return_size;
482+
word32 outLen = (word32)p->return_size;
483483

484484
if (p->data == NULL) {
485485
outLen = ecx->data->len;
@@ -513,7 +513,7 @@ static int wp_ecx_get_params_priv_key(wp_Ecx* ecx, OSSL_PARAM params[])
513513

514514
p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_PRIV_KEY);
515515
if (p != NULL) {
516-
word32 outLen = p->return_size;
516+
word32 outLen = (word32)p->return_size;
517517

518518
if (p->data == NULL) {
519519
outLen = ecx->data->len;
@@ -869,7 +869,7 @@ static int wp_ecx_import(wp_Ecx* ecx, int selection, const OSSL_PARAM params[])
869869
if (ok && (privData != NULL)) {
870870
ecx->unclamped[0] = privData[0];
871871
ecx->unclamped[1] = privData[len - 1];
872-
rc = (*ecx->data->importPriv)(privData, len, (void*)&ecx->key,
872+
rc = (*ecx->data->importPriv)(privData, (word32)len, (void*)&ecx->key,
873873
ECX_LITTLE_ENDIAN);
874874
if (rc != 0) {
875875
ok = 0;
@@ -886,7 +886,7 @@ static int wp_ecx_import(wp_Ecx* ecx, int selection, const OSSL_PARAM params[])
886886
ok = 0;
887887
}
888888
if (ok && (pubData != NULL)) {
889-
rc = (*ecx->data->importPub)(pubData, len, (void*)&ecx->key,
889+
rc = (*ecx->data->importPub)(pubData, (word32)len, (void*)&ecx->key,
890890
ECX_LITTLE_ENDIAN);
891891
if (rc != 0) {
892892
ok = 0;
@@ -2034,7 +2034,7 @@ static int wp_ecx_encode(wp_EcxEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
20342034
keyLen = derLen;
20352035
}
20362036
else if (ok && (ctx->encoding == WP_FORMAT_PEM)) {
2037-
rc = wc_DerToPemEx(derData, derLen, NULL, 0, cipherInfo, pemType);
2037+
rc = wc_DerToPemEx(derData, (word32)derLen, NULL, 0, cipherInfo, pemType);
20382038
if (rc <= 0) {
20392039
ok = 0;
20402040
}
@@ -2046,7 +2046,7 @@ static int wp_ecx_encode(wp_EcxEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
20462046
}
20472047
}
20482048
if (ok) {
2049-
rc = wc_DerToPemEx(derData, derLen, pemData, pemLen, cipherInfo,
2049+
rc = wc_DerToPemEx(derData, (word32)derLen, pemData, (word32)pemLen, cipherInfo,
20502050
pemType);
20512051
if (rc <= 0) {
20522052
ok = 0;
@@ -2058,7 +2058,7 @@ static int wp_ecx_encode(wp_EcxEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
20582058
}
20592059
}
20602060
if (ok) {
2061-
rc = BIO_write(out, keyData, keyLen);
2061+
rc = BIO_write(out, keyData, (int)keyLen);
20622062
if (rc <= 0) {
20632063
ok = 0;
20642064
}

src/wp_ecx_sig.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ static int wp_ed25519_digest_sign(wp_EcxSigCtx *ctx, unsigned char *sig,
362362
if (sigSize == (size_t)-1) {
363363
sigSize = *sigLen;
364364
}
365-
len = sigSize;
365+
len = (word32)sigSize;
366366

367367
if (!ed25519->pubKeySet) {
368368
unsigned char pubKey[ED25519_PUB_KEY_SIZE];
@@ -379,7 +379,7 @@ static int wp_ed25519_digest_sign(wp_EcxSigCtx *ctx, unsigned char *sig,
379379
}
380380
}
381381
if (ok) {
382-
rc = wc_ed25519_sign_msg(tbs, tbsLen, sig, &len, ed25519);
382+
rc = wc_ed25519_sign_msg(tbs, (word32)tbsLen, sig, &len, ed25519);
383383
if (rc != 0) {
384384
ok = 0;
385385
}
@@ -434,8 +434,8 @@ static int wp_ed25519_digest_verify(wp_EcxSigCtx *ctx, unsigned char *sig,
434434
}
435435
if (ok) {
436436
int res;
437-
int rc = wc_ed25519_verify_msg(sig, sigLen, tbs, tbsLen, &res,
438-
wp_ecx_get_key(ctx->ecx));
437+
int rc = wc_ed25519_verify_msg(sig, (word32)sigLen, tbs, (word32)tbsLen,
438+
&res, wp_ecx_get_key(ctx->ecx));
439439
if (rc != 0) {
440440
ok = 0;
441441
}
@@ -504,7 +504,7 @@ static int wp_ed448_digest_sign(wp_EcxSigCtx *ctx, unsigned char *sig,
504504
if (sigSize == (size_t)-1) {
505505
sigSize = *sigLen;
506506
}
507-
len = sigSize;
507+
len = (word32)sigSize;
508508

509509
if (!ed448->pubKeySet) {
510510
unsigned char pubKey[ED448_PUB_KEY_SIZE];
@@ -521,7 +521,7 @@ static int wp_ed448_digest_sign(wp_EcxSigCtx *ctx, unsigned char *sig,
521521
}
522522
}
523523
if (ok) {
524-
rc = wc_ed448_sign_msg(tbs, tbsLen, sig, &len,
524+
rc = wc_ed448_sign_msg(tbs, (word32)tbsLen, sig, &len,
525525
(ed448_key*)wp_ecx_get_key(ctx->ecx), NULL, 0);
526526
if (rc != 0) {
527527
ok = 0;
@@ -582,8 +582,8 @@ static int wp_ed448_digest_verify(wp_EcxSigCtx *ctx, unsigned char *sig,
582582
}
583583
if (ok) {
584584
int res;
585-
int rc = wc_ed448_verify_msg(sig, sigLen, tbs, tbsLen, &res,
586-
wp_ecx_get_key(ctx->ecx), NULL, 0);
585+
int rc = wc_ed448_verify_msg(sig, (word32)sigLen, tbs, (word32)tbsLen,
586+
&res, wp_ecx_get_key(ctx->ecx), NULL, 0);
587587
if (rc != 0) {
588588
ok = 0;
589589
}

src/wp_rsa_sig.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,13 @@ static int wp_rsa_get_alg_id(wp_RsaSigCtx* ctx, OSSL_PARAM* p)
12471247
/* TODO: implement */
12481248
(void)ctx;
12491249
(void)p;
1250-
return 0;
1250+
const byte sha256WithRSAEncryptionOid[] = {0x30, 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x04, 0x10};
1251+
int ok = 1;
1252+
1253+
if (ok && (!OSSL_PARAM_set_octet_string(p, sha256WithRSAEncryptionOid, sizeof(sha256WithRSAEncryptionOid)))) {
1254+
ok = 0;
1255+
}
1256+
return ok;
12511257
}
12521258

12531259
/**

src/wp_wolfprov.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,34 @@ static const OSSL_DISPATCH wolfprov_dispatch_table[] = {
11231123
{ 0, NULL }
11241124
};
11251125

1126+
#ifdef HAVE_FIPS
1127+
#include <wolfssl/wolfcrypt/fips_test.h>
1128+
1129+
static void wp_fipsCb(int ok, int err, const char* hash)
1130+
{
1131+
(void)ok;
1132+
(void)err;
1133+
(void)hash;
1134+
WOLFPROVIDER_MSG(WE_LOG_PROVIDER,
1135+
"in my Fips callback, ok = %d, err = %d\n", ok, err);
1136+
WOLFPROVIDER_MSG(WE_LOG_PROVIDER,
1137+
"message = %s\n", wc_GetErrorString(err));
1138+
WOLFPROVIDER_MSG(WE_LOG_PROVIDER,
1139+
"hash = %s\n", hash);
1140+
1141+
#ifdef WC_NO_ERR_TRACE
1142+
if (err == WC_NO_ERR_TRACE(IN_CORE_FIPS_E)) {
1143+
#else
1144+
if (err == IN_CORE_FIPS_E) {
1145+
#endif
1146+
WOLFPROVIDER_MSG(WE_LOG_PROVIDER,
1147+
"In core integrity hash check failure, copy above hash\n");
1148+
WOLFPROVIDER_MSG(WE_LOG_PROVIDER,
1149+
"into verifyCore[] in fips_test.c and rebuild\n");
1150+
}
1151+
}
1152+
#endif
1153+
11261154
/*
11271155
* Initializes the wolfSSL provider.
11281156
*
@@ -1144,6 +1172,10 @@ int wolfssl_provider_init(const OSSL_CORE_HANDLE* handle,
11441172
wolfSSL_SetLoggingPrefix("wolfSSL");
11451173
#endif
11461174

1175+
#ifdef HAVE_FIPS
1176+
wolfCrypt_SetCb_fips(wp_fipsCb);
1177+
#endif
1178+
11471179
for (; in->function_id != 0; in++) {
11481180
switch (in->function_id) {
11491181
case OSSL_FUNC_CORE_GETTABLE_PARAMS:

0 commit comments

Comments
 (0)