Skip to content

Commit

Permalink
Update RSA verify documentation to specify that the output should be …
Browse files Browse the repository at this point in the history
…compared with the original plaintext
  • Loading branch information
ColtonWilley committed Sep 4, 2024
1 parent 2bcfff3 commit f9af463
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions doc/dox_comments/header_files/rsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
int ret;
ret = wc_InitRsaKey(&enc, NULL); // not using heap hint. No custom memory
if ( ret != 0 ) {
// error initializing RSA key
// error initializing RSA key
}
\endcode
Expand Down Expand Up @@ -166,7 +166,7 @@ int wc_FreeRsaKey(RsaKey* key);
ret = wc_RsaDirect(in, (word32)sizeof(in), out, &outSz, &key,
RSA_PRIVATE_ENCRYPT, &rng);
if (ret < 0) {
//handle error
//handle error
}
\endcode
Expand Down Expand Up @@ -240,7 +240,7 @@ int wc_RsaDirect(byte* in, word32 inLen, byte* out, word32* outSz,
// initialize with received public key parameters
ret = wc_RsaPublicEncrypt(msg, sizeof(msg), out, sizeof(out), &pub, &rng);
if ( ret != 0 ) {
// error encrypting message
// error encrypting message
}
\endcode
Expand Down Expand Up @@ -403,6 +403,12 @@ int wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out,
if (ret < 0) {
return -1;
}
if (ret != inLen) {
return -1;
}
if (XMEMCMP(in, plain, ret) != 0) {
return -1;
}
\endcode
\sa wc_RsaSSL_Sign
Expand Down Expand Up @@ -1037,7 +1043,7 @@ int wc_RsaEncryptSize(RsaKey* key);
wc_InitRsaKey(&enc, NULL); // not using heap hint. No custom memory
ret = wc_RsaPrivateKeyDecode(der, &idx, &enc, sizeof(der));
if( ret != 0 ) {
// error parsing private key
// error parsing private key
}
\endcode
Expand Down Expand Up @@ -1087,7 +1093,7 @@ int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx,
wc_InitRsaKey(&pub, NULL); // not using heap hint. No custom memory
ret = wc_RsaPublicKeyDecode(der, &idx, &pub, sizeof(der));
if( ret != 0 ) {
// error parsing public key
// error parsing public key
}
\endcode
Expand Down Expand Up @@ -1132,7 +1138,7 @@ int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx,
wc_InitRsaKey(&pub, NULL); // not using heap hint. No custom memory
ret = wc_RsaPublicKeyDecodeRaw(n, sizeof(n), e, sizeof(e), &pub);
if( ret != 0 ) {
// error parsing public key elements
// error parsing public key elements
}
\endcode
Expand Down Expand Up @@ -1215,7 +1221,7 @@ int wc_RsaKeyToDer(RsaKey* key, byte* output, word32 inLen);
ret = wc_RsaPublicEncrypt_ex(in, sizeof(in), out, sizeof(out), &key, &rng,
WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
if (ret < 0) {
//handle error
//handle error
}
\endcode
Expand Down Expand Up @@ -1262,14 +1268,14 @@ int wc_RsaPublicEncrypt_ex(const byte* in, word32 inLen, byte* out,
ret = wc_RsaPublicEncrypt_ex(in, sizeof(in), out, sizeof(out), &key,
&rng, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
if (ret < 0) {
//handle error
//handle error
}
ret = wc_RsaPrivateDecrypt_ex(out, ret, plain, sizeof(plain), &key,
WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
if (ret < 0) {
//handle error
//handle error
}
\endcode
Expand Down Expand Up @@ -1320,14 +1326,14 @@ int wc_RsaPrivateDecrypt_ex(const byte* in, word32 inLen,
&rng, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
if (ret < 0) {
//handle error
//handle error
}
ret = wc_RsaPrivateDecryptInline_ex(out, ret, &plain, &key,
WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
if (ret < 0) {
//handle error
//handle error
}
\endcode
Expand Down Expand Up @@ -1370,7 +1376,7 @@ int wc_RsaPrivateDecryptInline_ex(byte* in, word32 inLen,
...
ret = wc_RsaFlattenPublicKey(&key, e, &eSz, n, &nSz);
if (ret != 0) {
// Failure case.
// Failure case.
}
\endcode
Expand Down Expand Up @@ -1516,7 +1522,7 @@ int wc_RsaKeyToPublicDer_ex(RsaKey* key, byte* output, word32 inLen,
// generate 2048 bit long private key
ret = wc_MakeRsaKey(&priv, 2048, e, &rng);
if( ret != 0 ) {
// error generating private key
// error generating private key
}
\endcode
Expand Down

0 comments on commit f9af463

Please sign in to comment.