Skip to content

Commit 64ead2c

Browse files
committed
Add X9.31 padding support to we_rsa_pkey_ctrl_str.
1 parent a5d8c1d commit 64ead2c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/we_rsa.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static int we_add_x931_padding(unsigned char* to, size_t toLen,
245245
}
246246
else {
247247
/* Need at least two bytes for trailer and header. */
248-
padBytes = toLen - fromLen - 2;
248+
padBytes = (int)(toLen - fromLen - 2);
249249
if (padBytes < 0) {
250250
WOLFENGINE_ERROR_MSG(WE_LOG_PK, "Output buffer too small.");
251251
ret = 0;
@@ -289,7 +289,7 @@ static int we_remove_x931_padding(unsigned char** to, const unsigned char* from,
289289
{
290290
int ret = 1;
291291
size_t idx = 0;
292-
int numCopy = 0;
292+
size_t numCopy = 0;
293293

294294
WOLFENGINE_ENTER(WE_LOG_PK, "we_remove_x931_padding");
295295
WOLFENGINE_MSG_VERBOSE(WE_LOG_PK, "ARGS [to = %p, from = %p, fromLen = "
@@ -338,7 +338,7 @@ static int we_remove_x931_padding(unsigned char** to, const unsigned char* from,
338338
}
339339

340340
if (ret == 1) {
341-
ret = numCopy;
341+
ret = (int)numCopy;
342342
}
343343

344344
WOLFENGINE_LEAVE(WE_LOG_PK, "we_remove_x931_padding", ret);
@@ -1124,7 +1124,7 @@ static int we_rsa_priv_enc_int(size_t fromLen, const unsigned char *from,
11241124
ret = -1;
11251125
}
11261126
else {
1127-
rc = mp_read_unsigned_bin(&toMp, to, toLen);
1127+
rc = mp_read_unsigned_bin(&toMp, to, (int)toLen);
11281128
if (rc != MP_OKAY) {
11291129
WOLFENGINE_ERROR_FUNC(WE_LOG_PK, "mp_read_unsigned_bin",
11301130
rc);
@@ -1383,7 +1383,7 @@ static int we_rsa_pub_dec_int(size_t fromLen, const unsigned char *from,
13831383
ret = -1;
13841384
}
13851385
else {
1386-
rc = mp_read_unsigned_bin(&toMp, to, toLen);
1386+
rc = mp_read_unsigned_bin(&toMp, to, (int)toLen);
13871387
if (rc != MP_OKAY) {
13881388
WOLFENGINE_ERROR_FUNC(WE_LOG_PK,
13891389
"mp_read_unsigned_bin", ret);
@@ -2298,6 +2298,9 @@ static int we_rsa_pkey_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
22982298
else if (XSTRNCMP(value, "pss", 4) == 0) {
22992299
rsa->padMode = RSA_PKCS1_PSS_PADDING;
23002300
}
2301+
else if (XSTRNCMP(value, "x931", 5) == 0) {
2302+
rsa->padMode = RSA_X931_PADDING;
2303+
}
23012304
else {
23022305
ret = 0;
23032306
}

0 commit comments

Comments
 (0)