Skip to content

Commit

Permalink
fixed CURVE25519 public key only serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
bigbrett committed Nov 4, 2024
1 parent affda77 commit b634bc4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/wh_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "wolfssl/wolfcrypt/types.h"
#include "wolfssl/wolfcrypt/error-crypt.h"
#include "wolfssl/wolfcrypt/asn.h"
#include "wolfssl/wolfcrypt/asn_public.h"
#include "wolfssl/wolfcrypt/rsa.h"
#include "wolfssl/wolfcrypt/curve25519.h"
#include "wolfssl/wolfcrypt/ecc.h"
Expand Down Expand Up @@ -230,12 +229,16 @@ int wh_Crypto_Curve25519SerializeKey(curve25519_key* key, uint8_t* buffer,
uint16_t* derSize)
{
int ret = 0;
/* We must include the algorithm identifier in the DER encoding, or we will
* not be able to deserialize it properly in the public key only case*/
const int WITH_ALG_ENABLE_SUBJECT_PUBLIC_KEY_INFO = 1;

if ((key == NULL) || (buffer == NULL) || (derSize == NULL)) {
return WH_ERROR_BADARGS;
}

ret = wc_Curve25519KeyToDer(key, buffer, *derSize, 0);
ret = wc_Curve25519KeyToDer(key, buffer, *derSize,
WITH_ALG_ENABLE_SUBJECT_PUBLIC_KEY_INFO);

/* ASN.1 functions return the size of the DER encoded key on success */
if (ret > 0) {
Expand Down

0 comments on commit b634bc4

Please sign in to comment.