mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
address review feedback
This commit is contained in:
@ -1578,6 +1578,21 @@ int wc_EccPublicKeyToDer_ex(ecc_key* key, byte* output,
|
|||||||
index is set to last position parsed of input buffer.
|
index is set to last position parsed of input buffer.
|
||||||
\param key Pointer to curve25519_key structure to store decoded key
|
\param key Pointer to curve25519_key structure to store decoded key
|
||||||
\param inSz Size of input DER buffer
|
\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,
|
int wc_Curve25519PrivateKeyDecode(const byte* input, word32* inOutIdx,
|
||||||
curve25519_key* key, word32 inSz);
|
curve25519_key* key, word32 inSz);
|
||||||
@ -1602,6 +1617,20 @@ int wc_Curve25519PrivateKeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
index is set to last position parsed of input buffer.
|
index is set to last position parsed of input buffer.
|
||||||
\param key Pointer to curve25519_key structure to store decoded key
|
\param key Pointer to curve25519_key structure to store decoded key
|
||||||
\param inSz Size of input DER buffer
|
\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,
|
int wc_Curve25519PublicKeyDecode(const byte* input, word32* inOutIdx,
|
||||||
curve25519_key* key, word32 inSz);
|
curve25519_key* key, word32 inSz);
|
||||||
@ -1626,6 +1655,20 @@ int wc_Curve25519PublicKeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
index is set to last position parsed of input buffer.
|
index is set to last position parsed of input buffer.
|
||||||
\param key Pointer to curve25519_key structure to store decoded key
|
\param key Pointer to curve25519_key structure to store decoded key
|
||||||
\param inSz Size of input DER buffer
|
\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,
|
int wc_Curve25519KeyDecode(const byte* input, word32* inOutIdx,
|
||||||
curve25519_key* key, word32 inSz);
|
curve25519_key* key, word32 inSz);
|
||||||
@ -1645,6 +1688,19 @@ int wc_Curve25519KeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
encode
|
encode
|
||||||
\param output Buffer to hold DER encoding
|
\param output Buffer to hold DER encoding
|
||||||
\param inLen Size of output buffer
|
\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,
|
int wc_Curve25519PrivateKeyToDer(curve25519_key* key, byte* output,
|
||||||
word32 inLen);
|
word32 inLen);
|
||||||
@ -1664,7 +1720,20 @@ int wc_Curve25519PrivateKeyToDer(curve25519_key* key, byte* output,
|
|||||||
encode
|
encode
|
||||||
\param output Buffer to hold DER encoding
|
\param output Buffer to hold DER encoding
|
||||||
\param inLen Size of output buffer
|
\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 wc_Curve25519PublicKeyToDer(curve25519_key* key, byte* output, word32 inLen,
|
||||||
int withAlg);
|
int withAlg);
|
||||||
@ -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 key Pointer to curve25519_key structure containing key to encode
|
||||||
\param output Buffer to hold DER encoding
|
\param output Buffer to hold DER encoding
|
||||||
\param inLen Size of output buffer
|
\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 wc_Curve25519KeyToDer(curve25519_key* key, byte* output, word32 inLen,
|
||||||
int withAlg);
|
int withAlg);
|
||||||
|
@ -35670,9 +35670,9 @@ int wc_Curve25519KeyDecode(const byte* input, word32* inOutIdx,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
byte privKey[CURVE25519_KEYSIZE];
|
byte privKey[CURVE25519_KEYSIZE];
|
||||||
byte pubKey[CURVE25519_KEYSIZE];
|
byte pubKey[CURVE25519_PUB_KEY_SIZE];
|
||||||
word32 privKeyLen = CURVE25519_KEYSIZE;
|
word32 privKeyLen = CURVE25519_KEYSIZE;
|
||||||
word32 pubKeyLen = CURVE25519_KEYSIZE;
|
word32 pubKeyLen = CURVE25519_PUB_KEY_SIZE;
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
if (input == NULL || inOutIdx == NULL || key == NULL || inSz == 0) {
|
if (input == NULL || inOutIdx == NULL || key == NULL || inSz == 0) {
|
||||||
@ -35925,9 +35925,9 @@ int wc_Curve25519KeyToDer(curve25519_key* key, byte* output, word32 inLen, int w
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
byte privKey[CURVE25519_KEYSIZE];
|
byte privKey[CURVE25519_KEYSIZE];
|
||||||
byte pubKey[CURVE25519_KEYSIZE];
|
byte pubKey[CURVE25519_PUB_KEY_SIZE];
|
||||||
word32 privKeyLen = CURVE25519_KEYSIZE;
|
word32 privKeyLen = CURVE25519_KEYSIZE;
|
||||||
word32 pubKeyLen = CURVE25519_KEYSIZE;
|
word32 pubKeyLen = CURVE25519_PUB_KEY_SIZE;
|
||||||
|
|
||||||
if (key == NULL) {
|
if (key == NULL) {
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
@ -35098,8 +35098,7 @@ static wc_test_ret_t curve255519_der_test(void)
|
|||||||
ret = WC_TEST_RET_ENC_NC;
|
ret = WC_TEST_RET_ENC_NC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test decode/encode of a key file containing both public and private
|
/* Test decode/encode key data containing both public and private fields */
|
||||||
* fields */
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
XMEMSET(&key, 0 , sizeof(key));
|
XMEMSET(&key, 0 , sizeof(key));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user