|
23 | 23 | int ret; |
24 | 24 | ret = wc_InitRsaKey(&enc, NULL); // not using heap hint. No custom memory |
25 | 25 | if ( ret != 0 ) { |
26 | | - // error initializing RSA key |
| 26 | + // error initializing RSA key |
27 | 27 | } |
28 | 28 | \endcode |
29 | 29 |
|
@@ -166,7 +166,7 @@ int wc_FreeRsaKey(RsaKey* key); |
166 | 166 | ret = wc_RsaDirect(in, (word32)sizeof(in), out, &outSz, &key, |
167 | 167 | RSA_PRIVATE_ENCRYPT, &rng); |
168 | 168 | if (ret < 0) { |
169 | | - //handle error |
| 169 | + //handle error |
170 | 170 | } |
171 | 171 | \endcode |
172 | 172 |
|
@@ -240,7 +240,7 @@ int wc_RsaDirect(byte* in, word32 inLen, byte* out, word32* outSz, |
240 | 240 | // initialize with received public key parameters |
241 | 241 | ret = wc_RsaPublicEncrypt(msg, sizeof(msg), out, sizeof(out), &pub, &rng); |
242 | 242 | if ( ret != 0 ) { |
243 | | - // error encrypting message |
| 243 | + // error encrypting message |
244 | 244 | } |
245 | 245 | \endcode |
246 | 246 |
|
@@ -403,6 +403,12 @@ int wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out, |
403 | 403 | if (ret < 0) { |
404 | 404 | return -1; |
405 | 405 | } |
| 406 | + if (ret != inLen) { |
| 407 | + return -1; |
| 408 | + } |
| 409 | + if (XMEMCMP(in, plain, ret) != 0) { |
| 410 | + return -1; |
| 411 | + } |
406 | 412 | \endcode |
407 | 413 |
|
408 | 414 | \sa wc_RsaSSL_Sign |
@@ -1037,7 +1043,7 @@ int wc_RsaEncryptSize(RsaKey* key); |
1037 | 1043 | wc_InitRsaKey(&enc, NULL); // not using heap hint. No custom memory |
1038 | 1044 | ret = wc_RsaPrivateKeyDecode(der, &idx, &enc, sizeof(der)); |
1039 | 1045 | if( ret != 0 ) { |
1040 | | - // error parsing private key |
| 1046 | + // error parsing private key |
1041 | 1047 | } |
1042 | 1048 | \endcode |
1043 | 1049 |
|
@@ -1087,7 +1093,7 @@ int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, |
1087 | 1093 | wc_InitRsaKey(&pub, NULL); // not using heap hint. No custom memory |
1088 | 1094 | ret = wc_RsaPublicKeyDecode(der, &idx, &pub, sizeof(der)); |
1089 | 1095 | if( ret != 0 ) { |
1090 | | - // error parsing public key |
| 1096 | + // error parsing public key |
1091 | 1097 | } |
1092 | 1098 | \endcode |
1093 | 1099 |
|
@@ -1132,7 +1138,7 @@ int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx, |
1132 | 1138 | wc_InitRsaKey(&pub, NULL); // not using heap hint. No custom memory |
1133 | 1139 | ret = wc_RsaPublicKeyDecodeRaw(n, sizeof(n), e, sizeof(e), &pub); |
1134 | 1140 | if( ret != 0 ) { |
1135 | | - // error parsing public key elements |
| 1141 | + // error parsing public key elements |
1136 | 1142 | } |
1137 | 1143 | \endcode |
1138 | 1144 |
|
@@ -1215,7 +1221,7 @@ int wc_RsaKeyToDer(RsaKey* key, byte* output, word32 inLen); |
1215 | 1221 | ret = wc_RsaPublicEncrypt_ex(in, sizeof(in), out, sizeof(out), &key, &rng, |
1216 | 1222 | WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0); |
1217 | 1223 | if (ret < 0) { |
1218 | | - //handle error |
| 1224 | + //handle error |
1219 | 1225 | } |
1220 | 1226 | \endcode |
1221 | 1227 |
|
@@ -1262,14 +1268,14 @@ int wc_RsaPublicEncrypt_ex(const byte* in, word32 inLen, byte* out, |
1262 | 1268 | ret = wc_RsaPublicEncrypt_ex(in, sizeof(in), out, sizeof(out), &key, |
1263 | 1269 | &rng, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0); |
1264 | 1270 | if (ret < 0) { |
1265 | | - //handle error |
| 1271 | + //handle error |
1266 | 1272 | } |
1267 | 1273 | … |
1268 | 1274 | ret = wc_RsaPrivateDecrypt_ex(out, ret, plain, sizeof(plain), &key, |
1269 | 1275 | WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0); |
1270 | 1276 |
|
1271 | 1277 | if (ret < 0) { |
1272 | | - //handle error |
| 1278 | + //handle error |
1273 | 1279 | } |
1274 | 1280 | \endcode |
1275 | 1281 |
|
@@ -1320,14 +1326,14 @@ int wc_RsaPrivateDecrypt_ex(const byte* in, word32 inLen, |
1320 | 1326 | &rng, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0); |
1321 | 1327 |
|
1322 | 1328 | if (ret < 0) { |
1323 | | - //handle error |
| 1329 | + //handle error |
1324 | 1330 | } |
1325 | 1331 | … |
1326 | 1332 | ret = wc_RsaPrivateDecryptInline_ex(out, ret, &plain, &key, |
1327 | 1333 | WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0); |
1328 | 1334 |
|
1329 | 1335 | if (ret < 0) { |
1330 | | - //handle error |
| 1336 | + //handle error |
1331 | 1337 | } |
1332 | 1338 | \endcode |
1333 | 1339 |
|
@@ -1370,7 +1376,7 @@ int wc_RsaPrivateDecryptInline_ex(byte* in, word32 inLen, |
1370 | 1376 | ... |
1371 | 1377 | ret = wc_RsaFlattenPublicKey(&key, e, &eSz, n, &nSz); |
1372 | 1378 | if (ret != 0) { |
1373 | | - // Failure case. |
| 1379 | + // Failure case. |
1374 | 1380 | } |
1375 | 1381 | \endcode |
1376 | 1382 |
|
@@ -1516,7 +1522,7 @@ int wc_RsaKeyToPublicDer_ex(RsaKey* key, byte* output, word32 inLen, |
1516 | 1522 | // generate 2048 bit long private key |
1517 | 1523 | ret = wc_MakeRsaKey(&priv, 2048, e, &rng); |
1518 | 1524 | if( ret != 0 ) { |
1519 | | - // error generating private key |
| 1525 | + // error generating private key |
1520 | 1526 | } |
1521 | 1527 | \endcode |
1522 | 1528 |
|
|
0 commit comments