mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Merge pull request #7159 from dgarske/features_20240122
Add PK Callback CMake support. Document `wc_RsaDirect`
This commit is contained in:
@ -1753,13 +1753,15 @@ else()
|
|||||||
list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_ASYNC_THREADING")
|
list(APPEND WOLFSSL_DEFINITIONS "-DWC_NO_ASYNC_THREADING")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# TODO: - cryptodev
|
# TODO: - Session export
|
||||||
# - Session export
|
|
||||||
|
|
||||||
add_option("WOLFSSL_CRYPTOCB"
|
add_option("WOLFSSL_CRYPTOCB"
|
||||||
"Enable crypto callbacks (default: disabled)"
|
"Enable crypto callbacks (default: disabled)"
|
||||||
"no" "yes;no")
|
"no" "yes;no")
|
||||||
|
|
||||||
|
add_option("WOLFSSL_PKCALLBACKS"
|
||||||
|
"Enable public key callbacks (default: disabled)"
|
||||||
|
"no" "yes;no")
|
||||||
|
|
||||||
add_option("WOLFSSL_OLD_NAMES"
|
add_option("WOLFSSL_OLD_NAMES"
|
||||||
"Keep backwards compat with old names (default: enabled)"
|
"Keep backwards compat with old names (default: enabled)"
|
||||||
@ -1960,6 +1962,11 @@ if(WOLFSSL_CRYPTOCB)
|
|||||||
list(APPEND WOLFSSL_DEFINITIONS "-DWOLF_CRYPTO_CB")
|
list(APPEND WOLFSSL_DEFINITIONS "-DWOLF_CRYPTO_CB")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Public Key Callbacks
|
||||||
|
if(WOLFSSL_PKCALLBACKS)
|
||||||
|
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_PK_CALLBACKS")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WOLFSSL_OCSPSTAPLING)
|
if(WOLFSSL_OCSPSTAPLING)
|
||||||
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CERTIFICATE_STATUS_REQUEST" "-DHAVE_TLS_EXTENSIONS")
|
list(APPEND WOLFSSL_DEFINITIONS "-DHAVE_CERTIFICATE_STATUS_REQUEST" "-DHAVE_TLS_EXTENSIONS")
|
||||||
override_cache(WOLFSSL_OCSP "yes")
|
override_cache(WOLFSSL_OCSP "yes")
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
// error initializing RSA key
|
// error initializing RSA key
|
||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
\sa wc_RsaInitCavium
|
|
||||||
\sa wc_FreeRsaKey
|
\sa wc_FreeRsaKey
|
||||||
\sa wc_RsaSetRNG
|
\sa wc_RsaSetRNG
|
||||||
*/
|
*/
|
||||||
@ -47,7 +46,6 @@ int wc_InitRsaKey(RsaKey* key, void* heap);
|
|||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
\sa wc_InitRsaKey
|
\sa wc_InitRsaKey
|
||||||
\sa wc_RsaInitCavium
|
|
||||||
\sa wc_FreeRsaKey
|
\sa wc_FreeRsaKey
|
||||||
\sa wc_RsaSetRNG
|
\sa wc_RsaSetRNG
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
\sa wc_RsaInitCavium
|
|
||||||
\sa wc_FreeRsaKey
|
\sa wc_FreeRsaKey
|
||||||
\sa wc_RsaSetRNG
|
\sa wc_RsaSetRNG
|
||||||
*/
|
*/
|
||||||
@ -77,7 +76,6 @@ int wc_InitRsaKey(RsaKey* key, void* heap);
|
|||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
\sa wc_InitRsaKey
|
\sa wc_InitRsaKey
|
||||||
\sa wc_RsaInitCavium
|
|
||||||
\sa wc_FreeRsaKey
|
\sa wc_FreeRsaKey
|
||||||
\sa wc_RsaSetRNG
|
\sa wc_RsaSetRNG
|
||||||
*/
|
*/
|
||||||
@ -133,6 +131,51 @@ int wc_RsaSetRNG(RsaKey* key, WC_RNG* rng);
|
|||||||
*/
|
*/
|
||||||
int wc_FreeRsaKey(RsaKey* key);
|
int wc_FreeRsaKey(RsaKey* key);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\ingroup RSA
|
||||||
|
|
||||||
|
\brief Function that does the RSA operation directly with no padding. The input
|
||||||
|
size must match key size. Typically this is
|
||||||
|
used when padding is already done on the RSA input.
|
||||||
|
|
||||||
|
\return size On successfully encryption the size of the encrypted buffer
|
||||||
|
is returned
|
||||||
|
\return RSA_BUFFER_E RSA buffer error, output too small or input too large
|
||||||
|
|
||||||
|
\param in buffer to do operation on
|
||||||
|
\param inLen length of input buffer
|
||||||
|
\param out buffer to hold results
|
||||||
|
\param outSz gets set to size of result buffer. Should be passed in as length
|
||||||
|
of out buffer. If the pointer "out" is null then outSz gets set to the
|
||||||
|
expected buffer size needed and LENGTH_ONLY_E gets returned.
|
||||||
|
\param key initialized RSA key to use for encrypt/decrypt
|
||||||
|
\param type if using private or public key (RSA_PUBLIC_ENCRYPT,
|
||||||
|
RSA_PUBLIC_DECRYPT, RSA_PRIVATE_ENCRYPT, RSA_PRIVATE_DECRYPT)
|
||||||
|
\param rng initialized WC_RNG struct
|
||||||
|
|
||||||
|
_Example_
|
||||||
|
\code
|
||||||
|
int ret;
|
||||||
|
WC_RNG rng;
|
||||||
|
RsaKey key;
|
||||||
|
byte in[256];
|
||||||
|
byte out[256];
|
||||||
|
word32 outSz = (word32)sizeof(out);
|
||||||
|
…
|
||||||
|
|
||||||
|
ret = wc_RsaDirect(in, (word32)sizeof(in), out, &outSz, &key,
|
||||||
|
RSA_PRIVATE_ENCRYPT, &rng);
|
||||||
|
if (ret < 0) {
|
||||||
|
//handle error
|
||||||
|
}
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
\sa wc_RsaPublicEncrypt
|
||||||
|
\sa wc_RsaPrivateDecrypt
|
||||||
|
*/
|
||||||
|
int wc_RsaDirect(byte* in, word32 inLen, byte* out, word32* outSz,
|
||||||
|
RsaKey* key, int type, WC_RNG* rng);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup RSA
|
\ingroup RSA
|
||||||
|
|
||||||
|
@ -2868,21 +2868,9 @@ static int wc_RsaFunctionAsync(const byte* in, word32 inLen, byte* out,
|
|||||||
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_RSA */
|
#endif /* WOLFSSL_ASYNC_CRYPT && WC_ASYNC_ENABLE_RSA */
|
||||||
|
|
||||||
#if defined(WC_RSA_DIRECT) || defined(WC_RSA_NO_PADDING)
|
#if defined(WC_RSA_DIRECT) || defined(WC_RSA_NO_PADDING)
|
||||||
/* Function that does the RSA operation directly with no padding.
|
/* Performs direct RSA computation without padding. The input and output must
|
||||||
*
|
* match the key size (ex: 2048-bits = 256 bytes). Returns the size of the
|
||||||
* in buffer to do operation on
|
* output on success or negative value on failure. */
|
||||||
* inLen length of input buffer
|
|
||||||
* out buffer to hold results
|
|
||||||
* outSz gets set to size of result buffer. Should be passed in as length
|
|
||||||
* of out buffer. If the pointer "out" is null then outSz gets set to
|
|
||||||
* the expected buffer size needed and LENGTH_ONLY_E gets returned.
|
|
||||||
* key RSA key to use for encrypt/decrypt
|
|
||||||
* type if using private or public key {RSA_PUBLIC_ENCRYPT,
|
|
||||||
* RSA_PUBLIC_DECRYPT, RSA_PRIVATE_ENCRYPT, RSA_PRIVATE_DECRYPT}
|
|
||||||
* rng wolfSSL RNG to use if needed
|
|
||||||
*
|
|
||||||
* returns size of result on success
|
|
||||||
*/
|
|
||||||
int wc_RsaDirect(byte* in, word32 inLen, byte* out, word32* outSz,
|
int wc_RsaDirect(byte* in, word32 inLen, byte* out, word32* outSz,
|
||||||
RsaKey* key, int type, WC_RNG* rng)
|
RsaKey* key, int type, WC_RNG* rng)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user