Added new ABI reference hooks. This is round two, more to come.

This commit is contained in:
Uriah Pollock
2022-07-28 09:59:41 -05:00
parent 46f423b8b9
commit b200d65a6a
8 changed files with 30 additions and 15 deletions

View File

@ -20790,6 +20790,7 @@ static int wc_EncryptedInfoAppend(char* dest, int destSz, char* cipherInfo)
#ifdef WOLFSSL_DER_TO_PEM #ifdef WOLFSSL_DER_TO_PEM
/* Used for compatibility API */ /* Used for compatibility API */
WOLFSSL_ABI
int wc_DerToPem(const byte* der, word32 derSz, int wc_DerToPem(const byte* der, word32 derSz,
byte* output, word32 outSz, int type) byte* output, word32 outSz, int type)
{ {
@ -22590,6 +22591,7 @@ static int SetEccPublicKey(byte* output, ecc_key* key, int outLen,
* @return BAD_FUNC_ARG when key or key's parameters is NULL. * @return BAD_FUNC_ARG when key or key's parameters is NULL.
* @return MEMORY_E when dynamic memory allocation failed. * @return MEMORY_E when dynamic memory allocation failed.
*/ */
WOLFSSL_ABI
int wc_EccPublicKeyToDer(ecc_key* key, byte* output, word32 inLen, int wc_EccPublicKeyToDer(ecc_key* key, byte* output, word32 inLen,
int with_AlgCurve) int with_AlgCurve)
{ {
@ -29043,6 +29045,7 @@ enum {
#define eccKeyASN_Length (sizeof(eccKeyASN) / sizeof(ASNItem)) #define eccKeyASN_Length (sizeof(eccKeyASN) / sizeof(ASNItem))
#endif #endif
WOLFSSL_ABI
int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key, int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, ecc_key* key,
word32 inSz) word32 inSz)
{ {
@ -29319,6 +29322,7 @@ static int EccKeyParamCopy(char** dst, char* src)
#endif /* !WOLFSSL_ASN_TEMPLATE */ #endif /* !WOLFSSL_ASN_TEMPLATE */
#endif /* WOLFSSL_CUSTOM_CURVES */ #endif /* WOLFSSL_CUSTOM_CURVES */
WOLFSSL_ABI
int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx, int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
ecc_key* key, word32 inSz) ecc_key* key, word32 inSz)
{ {
@ -29932,6 +29936,7 @@ static int wc_BuildEccKeyDer(ecc_key* key, byte* output, word32 *inLen,
/* Write a Private ecc key, including public to DER format, /* Write a Private ecc key, including public to DER format,
* length on success else < 0 */ * length on success else < 0 */
WOLFSSL_ABI
int wc_EccKeyToDer(ecc_key* key, byte* output, word32 inLen) int wc_EccKeyToDer(ecc_key* key, byte* output, word32 inLen)
{ {
return wc_BuildEccKeyDer(key, output, &inLen, 1, 1); return wc_BuildEccKeyDer(key, output, &inLen, 1, 1);

View File

@ -47,6 +47,7 @@ or Authenticated Encryption with Additional Data (AEAD) algorithm.
#endif #endif
#define CHACHA20_POLY1305_AEAD_INITIAL_COUNTER 0 #define CHACHA20_POLY1305_AEAD_INITIAL_COUNTER 0
WOLFSSL_ABI
int wc_ChaCha20Poly1305_Encrypt( int wc_ChaCha20Poly1305_Encrypt(
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE], const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE], const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
@ -79,6 +80,7 @@ int wc_ChaCha20Poly1305_Encrypt(
return ret; return ret;
} }
WOLFSSL_ABI
int wc_ChaCha20Poly1305_Decrypt( int wc_ChaCha20Poly1305_Decrypt(
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE], const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE], const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],

View File

@ -7446,6 +7446,7 @@ int ecc_mul2add(ecc_point* A, mp_int* kA,
key The corresponding public ECC key key The corresponding public ECC key
return MP_OKAY if successful (even if the signature is not valid) return MP_OKAY if successful (even if the signature is not valid)
*/ */
WOLFSSL_ABI
int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
word32 hashlen, int* res, ecc_key* key) word32 hashlen, int* res, ecc_key* key)
{ {
@ -8591,6 +8592,7 @@ done:
#endif /* HAVE_COMP_KEY */ #endif /* HAVE_COMP_KEY */
/* export public ECC key in ANSI X9.63 format */ /* export public ECC key in ANSI X9.63 format */
WOLFSSL_ABI
int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen) int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen)
{ {
int ret = MP_OKAY; int ret = MP_OKAY;
@ -8688,6 +8690,7 @@ done:
/* export public ECC key in ANSI X9.63 format, extended with /* export public ECC key in ANSI X9.63 format, extended with
* compression option */ * compression option */
WOLFSSL_ABI
int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen, int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen,
int compressed) int compressed)
{ {
@ -9762,6 +9765,7 @@ int wc_ecc_export_ex(ecc_key* key, byte* qx, word32* qxLen,
/* export ecc private key only raw, outLen is in/out size as unsigned bin /* export ecc private key only raw, outLen is in/out size as unsigned bin
return MP_OKAY on success */ return MP_OKAY on success */
WOLFSSL_ABI
int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen) int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen)
{ {
if (out == NULL || outLen == NULL) { if (out == NULL || outLen == NULL) {
@ -9961,6 +9965,7 @@ int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
} }
/* ecc private key import, public key in ANSI X9.63 format, private raw */ /* ecc private key import, public key in ANSI X9.63 format, private raw */
WOLFSSL_ABI
int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub, int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
word32 pubSz, ecc_key* key) word32 pubSz, ecc_key* key)
{ {
@ -9978,6 +9983,7 @@ int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
outlen [in/out] output buffer size, output signature size outlen [in/out] output buffer size, output signature size
return MP_OKAY on success return MP_OKAY on success
*/ */
WOLFSSL_ABI
int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen) int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen)
{ {
int err; int err;
@ -10353,6 +10359,7 @@ int wc_ecc_import_unsigned(ecc_key* key, const byte* qx, const byte* qy,
curveName ECC curve name, from ecc_sets[] curveName ECC curve name, from ecc_sets[]
return MP_OKAY on success return MP_OKAY on success
*/ */
WOLFSSL_ABI
int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy, int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy,
const char* d, const char* curveName) const char* d, const char* curveName)
{ {

View File

@ -34,6 +34,7 @@
#endif #endif
#ifndef NO_ERROR_STRINGS #ifndef NO_ERROR_STRINGS
WOLFSSL_ABI
const char* wc_GetErrorString(int error) const char* wc_GetErrorString(int error)
{ {
switch (error) { switch (error) {

View File

@ -613,7 +613,7 @@ WOLFSSL_API void wc_FreeDer(DerBuffer** pDer);
#endif /* WOLFSSL_CERT_GEN */ #endif /* WOLFSSL_CERT_GEN */
#ifdef WOLFSSL_DER_TO_PEM #ifdef WOLFSSL_DER_TO_PEM
WOLFSSL_API int wc_DerToPem(const byte* der, word32 derSz, byte* output, WOLFSSL_ABI WOLFSSL_API int wc_DerToPem(const byte* der, word32 derSz, byte* output,
word32 outputSz, int type); word32 outputSz, int type);
WOLFSSL_API int wc_DerToPemEx(const byte* der, word32 derSz, byte* output, WOLFSSL_API int wc_DerToPemEx(const byte* der, word32 derSz, byte* output,
word32 outputSz, byte *cipherIno, int type); word32 outputSz, byte *cipherIno, int type);
@ -658,9 +658,9 @@ WOLFSSL_API int wc_DhPrivKeyToDer(DhKey* key, byte* out, word32* outSz);
#ifdef HAVE_ECC #ifdef HAVE_ECC
/* private key helpers */ /* private key helpers */
WOLFSSL_API int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx, WOLFSSL_ABI WOLFSSL_API int wc_EccPrivateKeyDecode(const byte* input, word32* inOutIdx,
ecc_key* key, word32 inSz); ecc_key* key, word32 inSz);
WOLFSSL_API int wc_EccKeyToDer(ecc_key* key, byte* output, word32 inLen); WOLFSSL_ABI WOLFSSL_API int wc_EccKeyToDer(ecc_key* key, byte* output, word32 inLen);
WOLFSSL_API int wc_EccPrivateKeyToDer(ecc_key* key, byte* output, WOLFSSL_API int wc_EccPrivateKeyToDer(ecc_key* key, byte* output,
word32 inLen); word32 inLen);
WOLFSSL_API int wc_EccKeyDerSize(ecc_key* key, int pub); WOLFSSL_API int wc_EccKeyDerSize(ecc_key* key, int pub);
@ -670,9 +670,9 @@ WOLFSSL_API int wc_DhPrivKeyToDer(DhKey* key, byte* out, word32* outSz);
word32* outLen); word32* outLen);
/* public key helper */ /* public key helper */
WOLFSSL_API int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx, WOLFSSL_ABI WOLFSSL_API int wc_EccPublicKeyDecode(const byte* input, word32* inOutIdx,
ecc_key* key, word32 inSz); ecc_key* key, word32 inSz);
WOLFSSL_API int wc_EccPublicKeyToDer(ecc_key* key, byte* output, WOLFSSL_ABI WOLFSSL_API int wc_EccPublicKeyToDer(ecc_key* key, byte* output,
word32 inLen, int with_AlgCurve); word32 inLen, int with_AlgCurve);
WOLFSSL_API int wc_EccPublicKeyToDer_ex(ecc_key* key, byte* output, WOLFSSL_API int wc_EccPublicKeyToDer_ex(ecc_key* key, byte* output,
word32 inLen, int with_AlgCurve, word32 inLen, int with_AlgCurve,

View File

@ -86,7 +86,7 @@ typedef struct ChaChaPoly_Aead {
* concatenating a constant value. * concatenating a constant value.
*/ */
WOLFSSL_API WOLFSSL_ABI WOLFSSL_API
int wc_ChaCha20Poly1305_Encrypt( int wc_ChaCha20Poly1305_Encrypt(
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE], const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE], const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
@ -95,7 +95,7 @@ int wc_ChaCha20Poly1305_Encrypt(
byte* outCiphertext, byte* outCiphertext,
byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]); byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]);
WOLFSSL_API WOLFSSL_ABI WOLFSSL_API
int wc_ChaCha20Poly1305_Decrypt( int wc_ChaCha20Poly1305_Decrypt(
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE], const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE], const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],

View File

@ -619,7 +619,7 @@ int wc_ecc_sign_set_k(const byte* k, word32 klen, ecc_key* key);
#endif /* HAVE_ECC_SIGN */ #endif /* HAVE_ECC_SIGN */
#ifdef HAVE_ECC_VERIFY #ifdef HAVE_ECC_VERIFY
WOLFSSL_API WOLFSSL_ABI WOLFSSL_API
int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash, int wc_ecc_verify_hash(const byte* sig, word32 siglen, const byte* hash,
word32 hashlen, int* res, ecc_key* key); word32 hashlen, int* res, ecc_key* key);
WOLFSSL_API WOLFSSL_API
@ -722,9 +722,9 @@ int wc_ecc_mulmod_ex2(const mp_int* k, ecc_point *G, ecc_point *R, mp_int* a,
#ifdef HAVE_ECC_KEY_EXPORT #ifdef HAVE_ECC_KEY_EXPORT
/* ASN key helpers */ /* ASN key helpers */
WOLFSSL_API WOLFSSL_ABI WOLFSSL_API
int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen); int wc_ecc_export_x963(ecc_key* key, byte* out, word32* outLen);
WOLFSSL_API WOLFSSL_ABI WOLFSSL_API
int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen, int wc_ecc_export_x963_ex(ecc_key* key, byte* out, word32* outLen,
int compressed); int compressed);
/* extended functionality with compressed option */ /* extended functionality with compressed option */
@ -736,13 +736,13 @@ int wc_ecc_import_x963(const byte* in, word32 inLen, ecc_key* key);
WOLFSSL_API WOLFSSL_API
int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key, int wc_ecc_import_x963_ex(const byte* in, word32 inLen, ecc_key* key,
int curve_id); int curve_id);
WOLFSSL_API WOLFSSL_ABI WOLFSSL_API
int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub, int wc_ecc_import_private_key(const byte* priv, word32 privSz, const byte* pub,
word32 pubSz, ecc_key* key); word32 pubSz, ecc_key* key);
WOLFSSL_API WOLFSSL_API
int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz, int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
const byte* pub, word32 pubSz, ecc_key* key, int curve_id); const byte* pub, word32 pubSz, ecc_key* key, int curve_id);
WOLFSSL_API WOLFSSL_ABI WOLFSSL_API
int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen); int wc_ecc_rs_to_sig(const char* r, const char* s, byte* out, word32* outlen);
WOLFSSL_API WOLFSSL_API
int wc_ecc_rs_raw_to_sig(const byte* r, word32 rSz, const byte* s, word32 sSz, int wc_ecc_rs_raw_to_sig(const byte* r, word32 rSz, const byte* s, word32 sSz,
@ -750,7 +750,7 @@ int wc_ecc_rs_raw_to_sig(const byte* r, word32 rSz, const byte* s, word32 sSz,
WOLFSSL_API WOLFSSL_API
int wc_ecc_sig_to_rs(const byte* sig, word32 sigLen, byte* r, word32* rLen, int wc_ecc_sig_to_rs(const byte* sig, word32 sigLen, byte* r, word32* rLen,
byte* s, word32* sLen); byte* s, word32* sLen);
WOLFSSL_API WOLFSSL_ABI WOLFSSL_API
int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy, int wc_ecc_import_raw(ecc_key* key, const char* qx, const char* qy,
const char* d, const char* curveName); const char* d, const char* curveName);
WOLFSSL_API WOLFSSL_API
@ -766,7 +766,7 @@ WOLFSSL_API
int wc_ecc_export_ex(ecc_key* key, byte* qx, word32* qxLen, int wc_ecc_export_ex(ecc_key* key, byte* qx, word32* qxLen,
byte* qy, word32* qyLen, byte* d, word32* dLen, byte* qy, word32* qyLen, byte* d, word32* dLen,
int encType); int encType);
WOLFSSL_API WOLFSSL_ABI WOLFSSL_API
int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen); int wc_ecc_export_private_only(ecc_key* key, byte* out, word32* outLen);
WOLFSSL_API WOLFSSL_API
int wc_ecc_export_public_raw(ecc_key* key, byte* qx, word32* qxLen, int wc_ecc_export_public_raw(ecc_key* key, byte* qx, word32* qxLen,

View File

@ -269,7 +269,7 @@ enum {
#else #else
WOLFSSL_API void wc_ErrorString(int err, char* buff); WOLFSSL_API void wc_ErrorString(int err, char* buff);
WOLFSSL_API const char* wc_GetErrorString(int error); WOLFSSL_ABI WOLFSSL_API const char* wc_GetErrorString(int error);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus