Add comment to each added functions

This commit is contained in:
TakayukiMatsuo
2021-03-04 17:41:18 +09:00
parent 42e87fa542
commit 5043f0229a
2 changed files with 43 additions and 8 deletions

View File

@ -4517,7 +4517,7 @@ int wc_RsaPublicKeyDecodeRaw(const byte* n, word32 nSz, const byte* e,
#ifndef NO_DH #ifndef NO_DH
#if defined(WOLFSSL_DH_EXTRA) #if defined(WOLFSSL_DH_EXTRA)
/* /*
* Decodes DH public key * Decodes DH public key to fill specified DhKey.
* *
* return 0 on success, negative on failure * return 0 on success, negative on failure
*/ */
@ -16274,7 +16274,10 @@ static int EccKeyParamCopy(char** dst, char* src)
return ret; return ret;
} }
#endif /* WOLFSSL_CUSTOM_CURVES */ #endif /* WOLFSSL_CUSTOM_CURVES */
/* wc_EccPublicKeyDecode_ex gets ECC public key data in DER format via "input"
* and returns the curve id to "curveId" and the point position to "pointIdx".
* Returns 0 on success, negative values on failure.
*/
int wc_EccPublicKeyDecode_ex(const byte* input, int wc_EccPublicKeyDecode_ex(const byte* input,
word32* inOutIdx, int* curveId, word32* inOutIdx, int* curveId,
word32* pointIdx, int* pointSz, word32 inSz) word32* pointIdx, int* pointSz, word32 inSz)

View File

@ -6804,6 +6804,9 @@ void wolfSSL_EVP_PKEY_free(WOLFSSL_EVP_PKEY* key)
} }
} }
#if defined(OPENSSL_EXTRA) #if defined(OPENSSL_EXTRA)
/* Converts byte data into 2 digit hex code
* then put them to the specified buffer.
*/
static int ToHex( byte in, byte* hex ) static int ToHex( byte in, byte* hex )
{ {
byte UpNibble,LwNibble; byte UpNibble,LwNibble;
@ -6819,7 +6822,9 @@ static int ToHex( byte in, byte* hex )
*hex = HexTbl[LwNibble]; *hex = HexTbl[LwNibble];
return 2; return 2;
} }
/* convert input value to upto five digit decimal */ /* Converts input value "i" to upto five digit decimal
* and copys to the specified buffer.
*/
static int ToDec(word32 in, byte* hex) static int ToDec(word32 in, byte* hex)
{ {
int i = 0; int i = 0;
@ -6862,6 +6867,9 @@ static int ToDec(word32 in, byte* hex)
} }
return written; return written;
} }
/* Indent adds white spaces of the number specified by "indents"
* to the buffer specified by "dst".
*/
static int Indent(int indents, byte* dst ) static int Indent(int indents, byte* dst )
{ {
int i; int i;
@ -6871,6 +6879,12 @@ static int Indent(int indents, byte* dst )
for (i = indents; i; i--) {*dst++ = ' ';} for (i = indents; i; i--) {*dst++ = ' ';}
return indents; return indents;
} }
/* DumpElement dump byte-data specified by "input" to the "out".
* Each line has leading white spaces( "indent" gives the number ) plus
* four spaces, then hex coded 15 byte data with separator ":" follow.
* Each line looks like:
* " 00:e6:ab: --- 9f:ef:"
*/
static int DumpElement(WOLFSSL_BIO* out, const byte* input, static int DumpElement(WOLFSSL_BIO* out, const byte* input,
int inlen, int indent) int inlen, int indent)
{ {
@ -6933,6 +6947,10 @@ static int DumpElement(WOLFSSL_BIO* out, const byte* input,
return idx; return idx;
} }
/* PrintPubKeyRSA is a helper function for wolfSSL_EVP_PKEY_print_public
* to parses a DER format RSA public key specified in the second parameter.
* Returns 1 on success, 0 on failure.
*/
static int PrintPubKeyRSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, static int PrintPubKeyRSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
int indent, int bitlen, ASN1_PCTX* pctx) int indent, int bitlen, ASN1_PCTX* pctx)
{ {
@ -7085,6 +7103,10 @@ static int PrintPubKeyRSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
return WOLFSSL_SUCCESS; return WOLFSSL_SUCCESS;
} }
#if defined(HAVE_ECC) #if defined(HAVE_ECC)
/* PrintPubKeyEC is a helper function for wolfSSL_EVP_PKEY_print_public
* to parses a DER format ECC public key specified in the second parameter.
* Returns 1 on success, 0 on failure.
*/
static int PrintPubKeyEC(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, static int PrintPubKeyEC(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
int indent, int bitlen, ASN1_PCTX* pctx) int indent, int bitlen, ASN1_PCTX* pctx)
{ {
@ -7204,7 +7226,10 @@ static int PrintPubKeyEC(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
return WOLFSSL_SUCCESS; return WOLFSSL_SUCCESS;
} }
#endif /* HAVE_ECC */ #endif /* HAVE_ECC */
/* PrintPubKeyDSA is a helper function for wolfSSL_EVP_PKEY_print_public
* to parses a DER format DSA public key specified in the second parameter.
* Returns 1 on success, 0 on failure.
*/
static int PrintPubKeyDSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, static int PrintPubKeyDSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
int indent, int bitlen, ASN1_PCTX* pctx) int indent, int bitlen, ASN1_PCTX* pctx)
{ {
@ -7372,6 +7397,10 @@ static int PrintPubKeyDSA(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
return WOLFSSL_SUCCESS; return WOLFSSL_SUCCESS;
} }
/* PrintPubKeyDH is a helper function for wolfSSL_EVP_PKEY_print_public
* to parses a DER format DH public key specified in the second parameter.
* Returns 1 on success, 0 on failure.
*/
static int PrintPubKeyDH(WOLFSSL_BIO* out, const byte* pkey, int pkeySz, static int PrintPubKeyDH(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
int indent, int bitlen, ASN1_PCTX* pctx) int indent, int bitlen, ASN1_PCTX* pctx)
{ {
@ -7523,10 +7552,13 @@ static int PrintPubKeyDH(WOLFSSL_BIO* out, const byte* pkey, int pkeySz,
return WOLFSSL_SUCCESS; return WOLFSSL_SUCCESS;
} }
/* /* wolfSSL_EVP_PKEY_print_public parses the specified key then
* output public key info in human readable format * outputs public key info in human readable format to the specified BIO.
* returns 1 on success, 0 or negative on error. * White spaces of the same number which 'indent" gives, will be added to
* -2 means specified key algo is not supported. * each line to output and ignores pctx parameter.
* Returns 1 on success, 0 or negative on error, -2 means specified key
* algo is not supported.
* Can handle RSA, ECC, DSA and DH public keys.
*/ */
int wolfSSL_EVP_PKEY_print_public(WOLFSSL_BIO* out, int wolfSSL_EVP_PKEY_print_public(WOLFSSL_BIO* out,
const WOLFSSL_EVP_PKEY* pkey, int indent, ASN1_PCTX* pctx) const WOLFSSL_EVP_PKEY* pkey, int indent, ASN1_PCTX* pctx)