Skip to content

Commit

Permalink
address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbrett committed Oct 31, 2024
1 parent 20cf6b7 commit 3252217
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 8 deletions.
86 changes: 84 additions & 2 deletions doc/dox_comments/header_files/asn_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,21 @@ int wc_EccPublicKeyToDer_ex(ecc_key* key, byte* output,
index is set to last position parsed of input buffer.
\param key Pointer to curve25519_key structure to store decoded key
\param inSz Size of input DER buffer
\sa wc_Curve25519KeyDecode
\sa wc_Curve25519PublicKeyDecode
_Example_
\code
byte der[] = { // DER encoded key };
word32 idx = 0;
curve25519_key key;
wc_curve25519_init(&key);
if (wc_Curve25519PrivateKeyDecode(der, &idx, &key, sizeof(der)) != 0) {
// Error decoding private key
}
\endcode
*/
int wc_Curve25519PrivateKeyDecode(const byte* input, word32* inOutIdx,
curve25519_key* key, word32 inSz);
Expand All @@ -1602,6 +1617,20 @@ int wc_Curve25519PrivateKeyDecode(const byte* input, word32* inOutIdx,
index is set to last position parsed of input buffer.
\param key Pointer to curve25519_key structure to store decoded key
\param inSz Size of input DER buffer
\sa wc_Curve25519KeyDecode
\sa wc_Curve25519PrivateKeyDecode
_Example_
\code
byte der[] = { // DER encoded key };
word32 idx = 0;
curve25519_key key;
wc_curve25519_init(&key);
if (wc_Curve25519PublicKeyDecode(der, &idx, &key, sizeof(der)) != 0) {
// Error decoding public key
}
\endcode
*/
int wc_Curve25519PublicKeyDecode(const byte* input, word32* inOutIdx,
curve25519_key* key, word32 inSz);
Expand All @@ -1626,6 +1655,20 @@ int wc_Curve25519PublicKeyDecode(const byte* input, word32* inOutIdx,
index is set to last position parsed of input buffer.
\param key Pointer to curve25519_key structure to store decoded key
\param inSz Size of input DER buffer
\sa wc_Curve25519PrivateKeyDecode
\sa wc_Curve25519PublicKeyDecode
_Example_
\code
byte der[] = { // DER encoded key };
word32 idx = 0;
curve25519_key key;
wc_curve25519_init(&key);
if (wc_Curve25519KeyDecode(der, &idx, &key, sizeof(der)) != 0) {
// Error decoding key
}
\endcode
*/
int wc_Curve25519KeyDecode(const byte* input, word32* inOutIdx,
curve25519_key* key, word32 inSz);
Expand All @@ -1645,6 +1688,19 @@ int wc_Curve25519KeyDecode(const byte* input, word32* inOutIdx,
encode
\param output Buffer to hold DER encoding
\param inLen Size of output buffer
\sa wc_Curve25519KeyToDer
\sa wc_Curve25519PublicKeyToDer
_Example_
\code
curve25519_key key;
wc_curve25519_init(&key);
...
int derSz = 128; // Some appropriate size for output DER
byte der[derSz];
wc_Curve25519PrivateKeyToDer(&key, der, derSz);
\endcode
*/
int wc_Curve25519PrivateKeyToDer(curve25519_key* key, byte* output,
word32 inLen);
Expand All @@ -1664,7 +1720,20 @@ int wc_Curve25519PrivateKeyToDer(curve25519_key* key, byte* output,
encode
\param output Buffer to hold DER encoding
\param inLen Size of output buffer
\param withAlg Whether to include algorithm identifier
\param withAlg Whether to include algorithm identifier in the DER encoding
\sa wc_Curve25519KeyToDer
\sa wc_Curve25519PrivateKeyToDer
_Example_
\code
curve25519_key key;
wc_curve25519_init(&key);
...
int derSz = 128; // Some appropriate size for output DER
byte der[derSz];
wc_Curve25519PublicKeyToDer(&key, der, derSz, 1);
\endcode
*/
int wc_Curve25519PublicKeyToDer(curve25519_key* key, byte* output, word32 inLen,
int withAlg);
Expand All @@ -1683,7 +1752,20 @@ int wc_Curve25519PublicKeyToDer(curve25519_key* key, byte* output, word32 inLen,
\param key Pointer to curve25519_key structure containing key to encode
\param output Buffer to hold DER encoding
\param inLen Size of output buffer
\param withAlg Whether to include algorithm identifier
\param withAlg Whether to include algorithm identifier in the DER encoding
\sa wc_Curve25519PrivateKeyToDer
\sa wc_Curve25519PublicKeyToDer
_Example_
\code
curve25519_key key;
wc_curve25519_init(&key);
...
int derSz = 128; // Some appropriate size for output DER
byte der[derSz];
wc_Curve25519KeyToDer(&key, der, derSz, 1);
\endcode
*/
int wc_Curve25519KeyToDer(curve25519_key* key, byte* output, word32 inLen,
int withAlg);
Expand Down
8 changes: 4 additions & 4 deletions wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -35670,9 +35670,9 @@ int wc_Curve25519KeyDecode(const byte* input, word32* inOutIdx,
{
int ret;
byte privKey[CURVE25519_KEYSIZE];
byte pubKey[CURVE25519_KEYSIZE];
byte pubKey[CURVE25519_PUB_KEY_SIZE];
word32 privKeyLen = CURVE25519_KEYSIZE;
word32 pubKeyLen = CURVE25519_KEYSIZE;
word32 pubKeyLen = CURVE25519_PUB_KEY_SIZE;

/* sanity check */
if (input == NULL || inOutIdx == NULL || key == NULL || inSz == 0) {
Expand Down Expand Up @@ -35925,9 +35925,9 @@ int wc_Curve25519KeyToDer(curve25519_key* key, byte* output, word32 inLen, int w
{
int ret;
byte privKey[CURVE25519_KEYSIZE];
byte pubKey[CURVE25519_KEYSIZE];
byte pubKey[CURVE25519_PUB_KEY_SIZE];
word32 privKeyLen = CURVE25519_KEYSIZE;
word32 pubKeyLen = CURVE25519_KEYSIZE;
word32 pubKeyLen = CURVE25519_PUB_KEY_SIZE;

if (key == NULL) {
return BAD_FUNC_ARG;
Expand Down
3 changes: 1 addition & 2 deletions wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -35098,8 +35098,7 @@ static wc_test_ret_t curve255519_der_test(void)
ret = WC_TEST_RET_ENC_NC;
}

/* Test decode/encode of a key file containing both public and private
* fields */
/* Test decode/encode key data containing both public and private fields */
if (ret == 0) {
XMEMSET(&key, 0 , sizeof(key));

Expand Down

0 comments on commit 3252217

Please sign in to comment.