Merge pull request #6229 from JacobBarthelmeh/Testing

fix for check on ecc public key size with FIPS and compressed keys
pull/6232/head
David Garske 2023-03-23 08:25:31 -07:00 committed by GitHub
commit 3ef7db8e1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -24427,7 +24427,19 @@ static int SetEccPublicKey(byte* output, ecc_key* key, int outLen,
if (ret == 0) {
/* Calculate the size of the encoded public point. */
PRIVATE_KEY_UNLOCK();
#if defined(HAVE_COMP_KEY) && defined(HAVE_FIPS) && \
defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION == 2)
/* in earlier versions of FIPS the get length functionality is not
* available with compressed keys */
pubSz = key->dp ? key->dp->size : MAX_ECC_BYTES;
if (comp)
pubSz = 1 + pubSz;
else
pubSz = 1 + 2 * pubSz;
ret = LENGTH_ONLY_E;
#else
ret = wc_ecc_export_x963_ex(key, NULL, &pubSz, comp);
#endif
PRIVATE_KEY_LOCK();
/* LENGTH_ONLY_E on success. */
if (ret == LENGTH_ONLY_E) {