Skip to content

Commit ee96d10

Browse files
committed
Changes for openvpn tests to run successfully
1 parent 40d48ad commit ee96d10

5 files changed

Lines changed: 52 additions & 27 deletions

File tree

scripts/utils-openssl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ install_openssl() {
7070
if [ ! -d ${OPENSSL_INSTALL_DIR} ]; then
7171
printf "\tConfigure OpenSSL ${OPENSSL_TAG} ... "
7272
if [ "$WOLFPROV_DEBUG" = "1" ]; then
73-
./config shared --prefix=${OPENSSL_INSTALL_DIR} --debug >>$LOG_FILE 2>&1
73+
./config shared enable-trace --prefix=${OPENSSL_INSTALL_DIR} --debug >>$LOG_FILE 2>&1
7474
RET=$?
7575
else
7676
./config shared --prefix=${OPENSSL_INSTALL_DIR} >>$LOG_FILE 2>&1

src/wp_dh_kmgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,7 @@ static int wp_dh_decode(wp_DhEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
21192119
ok = 0;
21202120
}
21212121
if (ok && (ctx->format == WP_ENC_FORMAT_TYPE_SPECIFIC)) {
2122-
if (selection == OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) {
2122+
if (selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) {
21232123
if (!wp_dh_decode_params(dh, data, len)) {
21242124
ok = 0;
21252125
decoded = 0;

src/wp_ecc_kmgmt.c

Lines changed: 46 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,12 @@ static wp_Ecc* wp_ecc_gen(wp_EccGenCtx *ctx, OSSL_CALLBACK *cb, void *cbArg)
16441644
}
16451645
}
16461646
}
1647+
if (ok && ((ctx->selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)) {
1648+
rc = wc_ecc_set_curve(&ecc->key, 0, ecc->curveId);
1649+
if (rc != 0) {
1650+
ok = 0;
1651+
}
1652+
}
16471653
if (!ok) {
16481654
wp_ecc_free(ecc);
16491655
ecc = NULL;
@@ -2131,11 +2137,19 @@ static int wp_ecc_decode(wp_EccEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
21312137
*/
21322138
static int wp_ecc_encode_params_size(const wp_Ecc *ecc, size_t* keyLen)
21332139
{
2134-
/* ASN.1 type, len and data. */
2135-
*keyLen = ecc->key.dp->oidSz + 2;
2140+
int ok = 1;
2141+
word32 len = 0;
21362142

2137-
WOLFPROV_LEAVE(WP_LOG_PK, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), 1);
2138-
return 1;
2143+
if (wc_ecc_get_oid(ecc->key.dp->oidSum, NULL, &len) <= 0) {
2144+
ok = 0;
2145+
}
2146+
if (ok) {
2147+
/* ASN.1 type, len and data. */
2148+
*keyLen = len + 2;
2149+
}
2150+
2151+
WOLFPROV_LEAVE(WP_LOG_PK, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), ok);
2152+
return ok;
21392153
}
21402154

21412155
/**
@@ -2151,14 +2165,22 @@ static int wp_ecc_encode_params_size(const wp_Ecc *ecc, size_t* keyLen)
21512165
static int wp_ecc_encode_params(const wp_Ecc *ecc, unsigned char* keyData,
21522166
size_t* keyLen)
21532167
{
2154-
keyData[0] = 0x06;
2155-
keyData[1] = ecc->key.dp->oidSz;
2156-
XMEMCPY(keyData + 2, ecc->key.dp->oid, ecc->key.dp->oidSz);
2168+
int ok = 1;
2169+
word32 len;
2170+
const byte *oid;
21572171

2158-
*keyLen = ecc->key.dp->oidSz + 2;
2172+
if (wc_ecc_get_oid(ecc->key.dp->oidSum, &oid, &len) <= 0) {
2173+
ok = 0;
2174+
}
2175+
if (ok) {
2176+
keyData[0] = 0x06;
2177+
keyData[1] = len;
2178+
XMEMCPY(keyData + 2, oid, len);
2179+
*keyLen = len + 2;
2180+
}
21592181

2160-
WOLFPROV_LEAVE(WP_LOG_PK, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), 1);
2161-
return 1;
2182+
WOLFPROV_LEAVE(WP_LOG_PK, __FILE__ ":" WOLFPROV_STRINGIZE(__LINE__), ok);
2183+
return ok;
21622184
}
21632185

21642186
/**
@@ -2442,14 +2464,14 @@ static int wp_ecc_encode(wp_EccEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
24422464

24432465
if (ok && ((ctx->format == WP_ENC_FORMAT_TYPE_SPECIFIC) ||
24442466
(ctx->format == WP_ENC_FORMAT_X9_62))) {
2445-
if (selection == OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) {
2446-
if (!wp_ecc_encode_params_size(key, &derLen)) {
2467+
if (selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) {
2468+
private = 1;
2469+
if (!wp_ecc_encode_priv_size(key, &derLen)) {
24472470
ok = 0;
24482471
}
24492472
}
2450-
else {
2451-
private = 1;
2452-
if (!wp_ecc_encode_priv_size(key, &derLen)) {
2473+
else if(selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) {
2474+
if (!wp_ecc_encode_params_size(key, &derLen)) {
24532475
ok = 0;
24542476
}
24552477
}
@@ -2484,13 +2506,7 @@ static int wp_ecc_encode(wp_EccEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
24842506

24852507
if (ok && ((ctx->format == WP_ENC_FORMAT_TYPE_SPECIFIC) ||
24862508
(ctx->format == WP_ENC_FORMAT_X9_62))) {
2487-
if (selection == OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) {
2488-
pemType = DH_PARAM_TYPE;
2489-
if (!wp_ecc_encode_params(key, derData, &derLen)) {
2490-
ok = 0;
2491-
}
2492-
}
2493-
else {
2509+
if (selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) {
24942510
if (ctx->format == WP_ENC_FORMAT_X9_62) {
24952511
pemType = ECC_PRIVATEKEY_TYPE;
24962512
}
@@ -2499,6 +2515,12 @@ static int wp_ecc_encode(wp_EccEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
24992515
ok = 0;
25002516
}
25012517
}
2518+
else if(selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) {
2519+
pemType = DH_PARAM_TYPE;
2520+
if (!wp_ecc_encode_params(key, derData, &derLen)) {
2521+
ok = 0;
2522+
}
2523+
}
25022524
}
25032525
else if (ok && (ctx->format == WP_ENC_FORMAT_SPKI)) {
25042526
pemType = PUBLICKEY_TYPE;
@@ -2551,7 +2573,8 @@ static int wp_ecc_encode(wp_EccEncDecCtx* ctx, OSSL_CORE_BIO *cBio,
25512573
}
25522574
if (ok && ((ctx->format == WP_ENC_FORMAT_TYPE_SPECIFIC) ||
25532575
(ctx->format == WP_ENC_FORMAT_X9_62)) &&
2554-
(selection == OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS)) {
2576+
((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0) &&
2577+
(selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS)) {
25552578
pemData[11] = 'E';
25562579
pemData[12] = 'C';
25572580
pemData[pemLen - 19] = 'E';

src/wp_file_store.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ static wp_FileCtx* wp_file_open(WOLFPROV_CTX* provCtx, const char* uri)
109109
if (ctx != NULL) {
110110
int ok = 1;
111111

112-
/* TODO: support URI form 'file:'. */
112+
if (OPENSSL_strncasecmp(uri, "file:", 5) == 0) {
113+
/* TODO: may need more uri processing for extended/windows cases */
114+
uri += 5;
115+
}
113116
ctx->uri = OPENSSL_strdup(uri);
114117
if (ctx->uri == NULL) {
115118
ok = 0;

src/wp_wolfprov.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,6 @@ static const OSSL_ALGORITHM wolfprov_encoder[] = {
718718
wp_rsa_kp_pem_encoder_functions,
719719
"" },
720720
#ifdef WOLFSSL_RSA_PSS_ENCODING
721-
/* TODO: RSA-PSS encoding isn't supported in wolfSSL */
722721
{ WP_NAMES_RSA_PSS, WP_ENCODER_PROPERTIES(SubjectPublicKeyInfo, der),
723722
wp_rsapss_spki_der_encoder_functions,
724723
"" },

0 commit comments

Comments
 (0)