Skip to content

Commit f9af463

Browse files
committed
Update RSA verify documentation to specify that the output should be compared with the original plaintext
1 parent 2bcfff3 commit f9af463

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

  • doc/dox_comments/header_files

doc/dox_comments/header_files/rsa.h

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
int ret;
2424
ret = wc_InitRsaKey(&enc, NULL); // not using heap hint. No custom memory
2525
if ( ret != 0 ) {
26-
// error initializing RSA key
26+
// error initializing RSA key
2727
}
2828
\endcode
2929
@@ -166,7 +166,7 @@ int wc_FreeRsaKey(RsaKey* key);
166166
ret = wc_RsaDirect(in, (word32)sizeof(in), out, &outSz, &key,
167167
RSA_PRIVATE_ENCRYPT, &rng);
168168
if (ret < 0) {
169-
//handle error
169+
//handle error
170170
}
171171
\endcode
172172
@@ -240,7 +240,7 @@ int wc_RsaDirect(byte* in, word32 inLen, byte* out, word32* outSz,
240240
// initialize with received public key parameters
241241
ret = wc_RsaPublicEncrypt(msg, sizeof(msg), out, sizeof(out), &pub, &rng);
242242
if ( ret != 0 ) {
243-
// error encrypting message
243+
// error encrypting message
244244
}
245245
\endcode
246246
@@ -403,6 +403,12 @@ int wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out,
403403
if (ret < 0) {
404404
return -1;
405405
}
406+
if (ret != inLen) {
407+
return -1;
408+
}
409+
if (XMEMCMP(in, plain, ret) != 0) {
410+
return -1;
411+
}
406412
\endcode
407413
408414
\sa wc_RsaSSL_Sign
@@ -1037,7 +1043,7 @@ int wc_RsaEncryptSize(RsaKey* key);
10371043
wc_InitRsaKey(&enc, NULL); // not using heap hint. No custom memory
10381044
ret = wc_RsaPrivateKeyDecode(der, &idx, &enc, sizeof(der));
10391045
if( ret != 0 ) {
1040-
// error parsing private key
1046+
// error parsing private key
10411047
}
10421048
\endcode
10431049
@@ -1087,7 +1093,7 @@ int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx,
10871093
wc_InitRsaKey(&pub, NULL); // not using heap hint. No custom memory
10881094
ret = wc_RsaPublicKeyDecode(der, &idx, &pub, sizeof(der));
10891095
if( ret != 0 ) {
1090-
// error parsing public key
1096+
// error parsing public key
10911097
}
10921098
\endcode
10931099
@@ -1132,7 +1138,7 @@ int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx,
11321138
wc_InitRsaKey(&pub, NULL); // not using heap hint. No custom memory
11331139
ret = wc_RsaPublicKeyDecodeRaw(n, sizeof(n), e, sizeof(e), &pub);
11341140
if( ret != 0 ) {
1135-
// error parsing public key elements
1141+
// error parsing public key elements
11361142
}
11371143
\endcode
11381144
@@ -1215,7 +1221,7 @@ int wc_RsaKeyToDer(RsaKey* key, byte* output, word32 inLen);
12151221
ret = wc_RsaPublicEncrypt_ex(in, sizeof(in), out, sizeof(out), &key, &rng,
12161222
WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
12171223
if (ret < 0) {
1218-
//handle error
1224+
//handle error
12191225
}
12201226
\endcode
12211227
@@ -1262,14 +1268,14 @@ int wc_RsaPublicEncrypt_ex(const byte* in, word32 inLen, byte* out,
12621268
ret = wc_RsaPublicEncrypt_ex(in, sizeof(in), out, sizeof(out), &key,
12631269
&rng, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
12641270
if (ret < 0) {
1265-
//handle error
1271+
//handle error
12661272
}
12671273
12681274
ret = wc_RsaPrivateDecrypt_ex(out, ret, plain, sizeof(plain), &key,
12691275
WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
12701276
12711277
if (ret < 0) {
1272-
//handle error
1278+
//handle error
12731279
}
12741280
\endcode
12751281
@@ -1320,14 +1326,14 @@ int wc_RsaPrivateDecrypt_ex(const byte* in, word32 inLen,
13201326
&rng, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
13211327
13221328
if (ret < 0) {
1323-
//handle error
1329+
//handle error
13241330
}
13251331
13261332
ret = wc_RsaPrivateDecryptInline_ex(out, ret, &plain, &key,
13271333
WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
13281334
13291335
if (ret < 0) {
1330-
//handle error
1336+
//handle error
13311337
}
13321338
\endcode
13331339
@@ -1370,7 +1376,7 @@ int wc_RsaPrivateDecryptInline_ex(byte* in, word32 inLen,
13701376
...
13711377
ret = wc_RsaFlattenPublicKey(&key, e, &eSz, n, &nSz);
13721378
if (ret != 0) {
1373-
// Failure case.
1379+
// Failure case.
13741380
}
13751381
\endcode
13761382
@@ -1516,7 +1522,7 @@ int wc_RsaKeyToPublicDer_ex(RsaKey* key, byte* output, word32 inLen,
15161522
// generate 2048 bit long private key
15171523
ret = wc_MakeRsaKey(&priv, 2048, e, &rng);
15181524
if( ret != 0 ) {
1519-
// error generating private key
1525+
// error generating private key
15201526
}
15211527
\endcode
15221528

0 commit comments

Comments
 (0)