forked from wolfSSL/wolfssl
Merge pull request #1361 from connerWolfSSL/doxygen_project
wolfSSL with Doxygen Documentation
This commit is contained in:
@ -29,8 +29,8 @@
|
||||
#define DWT ((DWT_Type *) (0xE0001000UL) )
|
||||
typedef struct
|
||||
{
|
||||
uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */
|
||||
uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */
|
||||
uint32_t CTRL; /*< Offset: 0x000 (R/W) Control Register */
|
||||
uint32_t CYCCNT; /*< Offset: 0x004 (R/W) Cycle Count Register */
|
||||
} DWT_Type;
|
||||
|
||||
extern uint32_t SystemCoreClock ;
|
||||
|
@ -207,3 +207,4 @@ merge-clean:
|
||||
@find ./ | $(GREP) \.OTHER | xargs rm -f
|
||||
@find ./ | $(GREP) \.BASE | xargs rm -f
|
||||
@find ./ | $(GREP) \~$$ | xargs rm -f
|
||||
|
||||
|
178
doc/README_DOXYGEN
Normal file
178
doc/README_DOXYGEN
Normal file
@ -0,0 +1,178 @@
|
||||
wolfSSL with Doxygen 1.8.13
|
||||
|
||||
---- Dependencies ----
|
||||
|
||||
cmake
|
||||
make
|
||||
git
|
||||
latex-see below (With pdflatex included. However the pdflatex dependency can be removed by
|
||||
setting USE_PDFLATEX to NO in the file "Doxyfile" located at
|
||||
doc/formats/pdf/Doxyfile )
|
||||
|
||||
The following texlive packages were installed when creating this
|
||||
documentation on Linux Mint:
|
||||
sudo apt install texlive
|
||||
sudo apt install texlive-latex-extra
|
||||
|
||||
For Mac users Basic Tex from TUG is recommended. After installing BasicTex
|
||||
additional dependencies will need to be met:
|
||||
% sudo tlmgr update --self
|
||||
% sudo tlmgr install tabu varwidth multirow adjustbox collectbox sectsty tocloft collection-fontsextra
|
||||
|
||||
---- Generating the Documentation ----
|
||||
|
||||
If you are looking to just generate the html documentation and not interested in
|
||||
how to add your own just run one of the following commands from the main wolfssl
|
||||
directory:
|
||||
|
||||
make dox (this option will make both html and pdf documentation)
|
||||
make dox-html (only html documentation)
|
||||
make dox-pdf (only pdf documentation)
|
||||
|
||||
If it is the first time running one of the above commands the command will take
|
||||
some time to run. This is because the doxygen repository must be clones and then
|
||||
built along with the time taken to make the documentation.
|
||||
|
||||
Once documentation generation has completed to open the html use a browser to
|
||||
open doc/html/index.html. To open the generated pdf looking for
|
||||
refman.pdf located and doc/refman.pdf.
|
||||
|
||||
---- Configure ----
|
||||
|
||||
Doxygen uses a file called "Doxyfile" to hold all its values for configuration.
|
||||
If needed, to generate a fresh Doxfile run the command
|
||||
|
||||
doxygen -g
|
||||
|
||||
Once a Doxyfile is generate there are a few options to keep in mind.
|
||||
Below are some the the settings that are currently used:
|
||||
|
||||
EXTRACT_ALL
|
||||
|
||||
- this option determines if all API are extracted or just API that is documented.
|
||||
|
||||
OPTIMIZE_OUTPUT_FOR_C
|
||||
|
||||
- changes the look and naming schemes used in generated documentation.
|
||||
|
||||
RECURSIVE
|
||||
|
||||
- allows doxygen to search subdirectories in a library for documenting.
|
||||
|
||||
GENERATE_LATEX
|
||||
|
||||
- tells doxygen whether or not to generate LATEX documentation. The Latex
|
||||
that is generated is used to generate a PDF as well.
|
||||
|
||||
ENABLE_PREPROCESSING
|
||||
|
||||
- tells doxygen whether or not to ignore C/C++ preprocessors directives i.e #ifdef, #ifndef
|
||||
|
||||
EXCLUDE
|
||||
|
||||
- allows the user to specify files or directories to ignore when documenting.
|
||||
|
||||
HTML_EXTRA_STYLESHEET
|
||||
|
||||
-allows the user to specify their own css style sheet to use for the doxygen html.
|
||||
|
||||
SHOW_USED_FILES and SHOW_FILES
|
||||
|
||||
- when using groups it is important to keep these options set to yes otherwise
|
||||
functions with documentation that are not part of a group may fail to be included
|
||||
in the generated documentation.
|
||||
|
||||
---- Embedding Documentation ----
|
||||
|
||||
Doxygen API documentation should be placed in the doc/dox_comments/
|
||||
directory. The documentation should be stored in a file in this directory with the
|
||||
same name of the file in which the API resides in the wolfssl repository. C code
|
||||
header files (*.h) should be used when writing the API documentation. If API in a
|
||||
file is being documented for the first time be sure to add the to the top of the
|
||||
original file:
|
||||
|
||||
/*!
|
||||
\file wolfssl/PATH_TO_FILE/FILE_NAME
|
||||
*/
|
||||
|
||||
This ensures that the file will be linked to in the doxygen generated html.
|
||||
When specifying a specific file with the \file command be sure to include part of
|
||||
the file's path so that it is a unique name. This allows for linking to files even
|
||||
when multiple files share the same name.
|
||||
|
||||
To ensure that doxygen documents a specific API in to a desired module be sure
|
||||
to include that module's name in the \ingroup. The current modules to choose from
|
||||
are as follows but new group can be made:
|
||||
|
||||
\ingroup 3DES
|
||||
\ingroup AES
|
||||
\ingroup ARC4
|
||||
\ingroup BLAKE2
|
||||
\ingroup Camellia
|
||||
\ingroup ChaCha
|
||||
\ingroup ChaCha20Poly1305
|
||||
\ingroup Curve25519
|
||||
\ingroup DSA Algorithms
|
||||
\ingroup Diffie-Hellman
|
||||
\ingroup ECC
|
||||
\ingroup ED25519
|
||||
\ingroup HC128
|
||||
\ingroup HMAC
|
||||
\ingroup IDEA
|
||||
\ingroup MD2
|
||||
\ingroup MD4
|
||||
\ingroup MD5
|
||||
\ingroup PKCS7
|
||||
\ingroup Password
|
||||
\ingroup Poly1305
|
||||
\ingroup RIPEMD
|
||||
\ingroup RSA
|
||||
\ingroup Rabbit
|
||||
\ingroup SHA
|
||||
\ingroup SRP
|
||||
\ingroup wolfCrypt
|
||||
\ingroup openSSL
|
||||
\ingroup CertManager
|
||||
\ingroup TLS
|
||||
\ingroup CertsKeys
|
||||
\ingroup Setup
|
||||
\ingroup IO
|
||||
\ingroup Debug
|
||||
|
||||
If one of the above modules/ groups does not fit a desired function then a new
|
||||
group will need to be created. To do this include add a new group definition
|
||||
to the doxygen_groups.h file located at documentation/formats/pdf/doxygen_groups.h
|
||||
|
||||
/*!
|
||||
\defgroup <group name> <description>
|
||||
*/
|
||||
|
||||
The general outline when documenting within the wolfssl library in doxygen should
|
||||
look like as follows:
|
||||
|
||||
/*!
|
||||
\ingroup //if API should be in a separate module
|
||||
|
||||
\brief <description of API>
|
||||
|
||||
\return <name of return> <description> // each return will need \return.
|
||||
|
||||
\param <name of param> <description> // stands for parameter, each parameter will need \param.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
// any example code here
|
||||
\endcode
|
||||
|
||||
\sa // stands for see also. Each API reference here should begin with \sa
|
||||
\sa <Function>
|
||||
\sa <Function>
|
||||
*/
|
||||
|
||||
When adding new documentation be sure to keep the sections, \ingroup, \brief,
|
||||
\param, \return, Etc. separated with at least 1 newline. This insures that when
|
||||
doxygen attempts to generate documentation the sections do not overlap each other
|
||||
and produce errors (this is especially important when the latex is being generated).
|
||||
Once finished creating new documentation it is highly recommended to generate new
|
||||
html and pdf to ensure no errors were introduced that prevent documentation
|
||||
generation and that the documentation shows up correctly.
|
43
doc/check_api.sh
Executable file
43
doc/check_api.sh
Executable file
@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
|
||||
ls ./dox_comments/header_files/ |
|
||||
while read h_file; do
|
||||
grep -P -h -z -o 'WOLFSSL_API(\n|\s|[^;])*;' ./dox_comments/header_files/$h_file |
|
||||
tr '\n' ' ' |
|
||||
sed 's/\\n//g' |
|
||||
sed 's/ \+/ /g' |
|
||||
sed 's/\x00/\n/g' > dox_api.txt
|
||||
|
||||
find ../ -not -path '../doc/*' -name $h_file |
|
||||
while read -r h_file_path; do
|
||||
echo "Checking: $h_file_path"
|
||||
grep -P -h -z -o 'WOLFSSL_API(\n|\s|[^;])*;' "$h_file_path" |
|
||||
sed 's/#.*/ /g' |
|
||||
tr '\n' ' ' |
|
||||
sed 's/\\n//g' |
|
||||
sed 's/ \+/ /g' |
|
||||
sed 's/\x00/\n/g' > wolf_api.txt
|
||||
|
||||
api_count="$(wc -l < dox_api.txt)"
|
||||
match_count="$(grep -Ff dox_api.txt wolf_api.txt | wc -l)"
|
||||
if [ "$api_count" != "$match_count" ]; then
|
||||
echo "Mistmatch"
|
||||
echo "Dox_api: $api_count"
|
||||
echo "Matched_api: $match_count"
|
||||
echo "Header file: $h_file"
|
||||
echo "Check API: "
|
||||
sort dox_api.txt -o dox_api.txt
|
||||
sort wolf_api.txt -o wolf_api.txt
|
||||
comm -23 dox_api.txt wolf_api.txt
|
||||
exit 1
|
||||
else
|
||||
echo "$h_file is all good"
|
||||
break
|
||||
fi
|
||||
done || exit 1
|
||||
echo 'Next...\n'
|
||||
|
||||
done || exit 1
|
||||
|
||||
rm dox_api.txt
|
||||
rm wolf_api.txt
|
811
doc/dox_comments/header_files/aes.h
Normal file
811
doc/dox_comments/header_files/aes.h
Normal file
@ -0,0 +1,811 @@
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief This function initializes an AES structure by setting the key and
|
||||
then setting the initialization vector.
|
||||
|
||||
\return 0 On successfully setting key and initialization vector.
|
||||
\return BAD_FUNC_ARG Returned if key length is invalid.
|
||||
|
||||
\param aes pointer to the AES structure to modify
|
||||
\param key 16, 24, or 32 byte secret key for encryption and decryption
|
||||
\param len length of the key passed in
|
||||
\param iv pointer to the initialization vector used to initialize the key
|
||||
\param dir Cipher direction. Set AES_ENCRYPTION to encrypt, or
|
||||
AES_DECRYPTION to decrypt.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes enc;
|
||||
int ret = 0;
|
||||
byte key[] = { some 16, 24 or 32 byte key };
|
||||
byte iv[] = { some 16 byte iv };
|
||||
if (ret = wc_AesSetKey(&enc, key, AES_BLOCK_SIZE, iv,
|
||||
AES_ENCRYPTION) != 0) {
|
||||
// failed to set aes key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_AesSetKeyDirect
|
||||
\sa wc_AesSetIV
|
||||
*/
|
||||
WOLFSSL_API int wc_AesSetKey(Aes* aes, const byte* key, word32 len,
|
||||
const byte* iv, int dir);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief This function sets the initialization vector for a
|
||||
particular AES object. The AES object should be initialized before
|
||||
calling this function.
|
||||
|
||||
\return 0 On successfully setting initialization vector.
|
||||
\return BAD_FUNC_ARG Returned if AES pointer is NULL.
|
||||
|
||||
\param aes pointer to the AES structure on which to set the
|
||||
initialization vector
|
||||
\param iv initialization vector used to initialize the AES structure.
|
||||
If the value is NULL, the default action initializes the iv to 0.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes enc;
|
||||
// set enc key
|
||||
byte iv[] = { some 16 byte iv };
|
||||
if (ret = wc_AesSetIV(&enc, iv) != 0) {
|
||||
// failed to set aes iv
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_AesSetKeyDirect
|
||||
\sa wc_AesSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_AesSetIV(Aes* aes, const byte* iv);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief Encrypts a plaintext message from the input buffer in, and places
|
||||
the resulting cipher text in the output buffer out using cipher block
|
||||
chaining with AES. This function requires that the AES object has been
|
||||
initialized by calling AesSetKey before a message is able to be encrypted.
|
||||
This function assumes that the input message is AES block length aligned.
|
||||
PKCS#7 style padding should be added beforehand. This differs from the
|
||||
OpenSSL AES-CBC methods which add the padding for you. To make the wolfSSL
|
||||
function and equivalent OpenSSL functions interoperate, one should specify
|
||||
the -nopad option in the OpenSSL command line function so that it behaves
|
||||
like the wolfSSL AesCbcEncrypt method and does not add extra padding
|
||||
during encryption.
|
||||
|
||||
\return 0 On successfully encrypting message.
|
||||
\return BAD_ALIGN_E: Returned on block align error
|
||||
|
||||
\param aes pointer to the AES object used to encrypt data
|
||||
\param out pointer to the output buffer in which to store the ciphertext
|
||||
of the encrypted message
|
||||
\param in pointer to the input buffer containing message to be encrypted
|
||||
\param sz size of input message
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes enc;
|
||||
int ret = 0;
|
||||
// initialize enc with AesSetKey, using direction AES_ENCRYPTION
|
||||
byte msg[AES_BLOCK_SIZE * n]; // multiple of 16 bytes
|
||||
// fill msg with data
|
||||
byte cipher[AES_BLOCK_SIZE * n]; // Some multiple of 16 bytes
|
||||
if ((ret = wc_AesCbcEncrypt(&enc, cipher, message, sizeof(msg))) != 0 ) {
|
||||
// block align error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_AesSetKey
|
||||
\sa wc_AesSetIV
|
||||
\sa wc_AesCbcDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_AesCbcEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief Decrypts a cipher from the input buffer in, and places the
|
||||
resulting plain text in the output buffer out using cipher block chaining
|
||||
with AES. This function requires that the AES structure has been
|
||||
initialized by calling AesSetKey before a message is able to be decrypted.
|
||||
This function assumes that the original message was AES block length
|
||||
aligned. This differs from the OpenSSL AES-CBC methods which do not
|
||||
require alignment as it adds PKCS#7 padding automatically. To make the
|
||||
wolfSSL function and equivalent OpenSSL functions interoperate, one
|
||||
should specify the -nopad option in the OpenSSL command line function
|
||||
so that it behaves like the wolfSSL AesCbcEncrypt method and does not
|
||||
create errors during decryption.
|
||||
|
||||
\return 0 On successfully decrypting message.
|
||||
\return BAD_ALIGN_E Returned on block align error.
|
||||
|
||||
\param aes pointer to the AES object used to decrypt data.
|
||||
\param out pointer to the output buffer in which to store the plain text
|
||||
of the decrypted message.
|
||||
\param in pointer to the input buffer containing cipher text to be
|
||||
decrypted.
|
||||
\param sz size of input message.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes dec;
|
||||
int ret = 0;
|
||||
// initialize dec with AesSetKey, using direction AES_DECRYPTION
|
||||
byte cipher[AES_BLOCK_SIZE * n]; // some multiple of 16 bytes
|
||||
// fill cipher with cipher text
|
||||
byte plain [AES_BLOCK_SIZE * n];
|
||||
if ((ret = wc_AesCbcDecrypt(&dec, plain, cipher, sizeof(cipher))) != 0 ) {
|
||||
// block align error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_AesSetKey
|
||||
\sa wc_AesCbcEncrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_AesCbcDecrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief Encrypts/Decrypts a message from the input buffer in, and places
|
||||
the resulting cipher text in the output buffer out using CTR mode with
|
||||
AES. This function is only enabled if WOLFSSL_AES_COUNTER is enabled at
|
||||
compile time. The AES structure should be initialized through AesSetKey
|
||||
before calling this function. Note that this function is used for both
|
||||
decryption and encryption. _NOTE:_ Regarding using same API for encryption
|
||||
and decryption. User should differentiate between Aes structures
|
||||
for encrypt/decrypt.
|
||||
|
||||
\return int integer values corresponding to wolfSSL error or success
|
||||
status
|
||||
|
||||
\param aes pointer to the AES object used to decrypt data
|
||||
\param out pointer to the output buffer in which to store the cipher
|
||||
text of the encrypted message
|
||||
\param in pointer to the input buffer containing plain text to be encrypted
|
||||
\param sz size of the input plain text
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes enc;
|
||||
Aes dec;
|
||||
// initialize enc and dec with AesSetKeyDirect, using direction
|
||||
AES_ENCRYPTION
|
||||
// since the underlying API only calls Encrypt and by default calling
|
||||
encrypt on
|
||||
// a cipher results in a decryption of the cipher
|
||||
|
||||
byte msg[AES_BLOCK_SIZE * n]; //n being a positive integer making msg
|
||||
some multiple of 16 bytes
|
||||
// fill plain with message text
|
||||
byte cipher[AES_BLOCK_SIZE * n];
|
||||
byte decrypted[AES_BLOCK_SIZE * n];
|
||||
wc_AesCtrEncrypt(&enc, cipher, msg, sizeof(msg)); // encrypt plain
|
||||
wc_AesCtrEncrypt(&dec, decrypted, cipher, sizeof(cipher));
|
||||
// decrypt cipher text
|
||||
\endcode
|
||||
|
||||
\sa wc_AesSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_AesCtrEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief This function is a one-block encrypt of the input block, in, into
|
||||
the output block, out. It uses the key and iv (initialization vector)
|
||||
of the provided AES structure, which should be initialized with
|
||||
wc_AesSetKey before calling this function. It is only enabled if the
|
||||
configure option WOLFSSL_AES_DIRECT is enabled. __Warning:__ In nearly all
|
||||
use cases ECB mode is considered to be less secure. Please avoid using ECB
|
||||
API’s directly whenever possible
|
||||
|
||||
\param aes pointer to the AES object used to encrypt data
|
||||
\param out pointer to the output buffer in which to store the cipher
|
||||
text of the encrypted message
|
||||
\param in pointer to the input buffer containing plain text to be encrypted
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes enc;
|
||||
// initialize enc with AesSetKey, using direction AES_ENCRYPTION
|
||||
byte msg [AES_BLOCK_SIZE]; // 16 bytes
|
||||
// initialize msg with plain text to encrypt
|
||||
byte cipher[AES_BLOCK_SIZE];
|
||||
wc_AesEncryptDirect(&enc, cipher, msg);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesDecryptDirect
|
||||
\sa wc_AesSetKeyDirect
|
||||
*/
|
||||
WOLFSSL_API void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief This function is a one-block decrypt of the input block, in, into
|
||||
the output block, out. It uses the key and iv (initialization vector) of
|
||||
the provided AES structure, which should be initialized with wc_AesSetKey
|
||||
before calling this function. It is only enabled if the configure option
|
||||
WOLFSSL_AES_DIRECT is enabled, and there is support for direct AES
|
||||
encryption on the system in question. __Warning:__ In nearly all use cases
|
||||
ECB mode is considered to be less secure. Please avoid using ECB API’s
|
||||
directly whenever possible
|
||||
|
||||
\return none
|
||||
|
||||
\param aes pointer to the AES object used to encrypt data
|
||||
\param out pointer to the output buffer in which to store the plain
|
||||
text of the decrypted cipher text
|
||||
\param in pointer to the input buffer containing cipher text to be
|
||||
decrypted
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes dec;
|
||||
// initialize enc with AesSetKey, using direction AES_DECRYPTION
|
||||
byte cipher [AES_BLOCK_SIZE]; // 16 bytes
|
||||
// initialize cipher with cipher text to decrypt
|
||||
byte msg[AES_BLOCK_SIZE];
|
||||
wc_AesDecryptDirect(&dec, msg, cipher);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesEncryptDirect
|
||||
\sa wc_AesSetKeyDirect
|
||||
*/
|
||||
WOLFSSL_API void wc_AesDecryptDirect(Aes* aes, byte* out, const byte* in);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief This function is used to set the AES keys for CTR mode with AES.
|
||||
It initializes an AES object with the given key, iv
|
||||
(initialization vector), and encryption dir (direction). It is only
|
||||
enabled if the configure option WOLFSSL_AES_DIRECT is enabled.
|
||||
Currently wc_AesSetKeyDirect uses wc_AesSetKey internally. __Warning:__ In
|
||||
nearly all use cases ECB mode is considered to be less secure. Please avoid
|
||||
using ECB API’s directly whenever possible
|
||||
|
||||
\return 0 On successfully setting the key.
|
||||
\return BAD_FUNC_ARG Returned if the given key is an invalid length.
|
||||
|
||||
\param aes pointer to the AES object used to encrypt data
|
||||
\param key 16, 24, or 32 byte secret key for encryption and decryption
|
||||
\param len length of the key passed in
|
||||
\param iv initialization vector used to initialize the key
|
||||
\param dir Cipher direction. Set AES_ENCRYPTION to encrypt, or
|
||||
AES_DECRYPTION to decrypt. (See enum in wolfssl/wolfcrypt/aes.h)
|
||||
(NOTE: If using wc_AesSetKeyDirect with Aes Counter mode (Stream cipher)
|
||||
only use AES_ENCRYPTION for both encrypting and decrypting)
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes enc;
|
||||
int ret = 0;
|
||||
byte key[] = { some 16, 24, or 32 byte key };
|
||||
byte iv[] = { some 16 byte iv };
|
||||
if (ret = wc_AesSetKeyDirect(&enc, key, sizeof(key), iv,
|
||||
AES_ENCRYPTION) != 0) {
|
||||
// failed to set aes key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_AesEncryptDirect
|
||||
\sa wc_AesDecryptDirect
|
||||
\sa wc_AesSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
|
||||
const byte* iv, int dir);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief This function is used to set the key for AES GCM
|
||||
(Galois/Counter Mode). It initializes an AES object with the
|
||||
given key. It is only enabled if the configure option
|
||||
HAVE_AESGCM is enabled at compile time.
|
||||
|
||||
\return 0 On successfully setting the key.
|
||||
\return BAD_FUNC_ARG Returned if the given key is an invalid length.
|
||||
|
||||
\param aes pointer to the AES object used to encrypt data
|
||||
\param key 16, 24, or 32 byte secret key for encryption and decryption
|
||||
\param len length of the key passed in
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes enc;
|
||||
int ret = 0;
|
||||
byte key[] = { some 16, 24,32 byte key };
|
||||
if (ret = wc_AesGcmSetKey(&enc, key, sizeof(key)) != 0) {
|
||||
// failed to set aes key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_AesGcmEncrypt
|
||||
\sa wc_AesGcmDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief This function encrypts the input message, held in the buffer in,
|
||||
and stores the resulting cipher text in the output buffer out. It
|
||||
requires a new iv (initialization vector) for each call to encrypt.
|
||||
It also encodes the input authentication vector, authIn, into the
|
||||
authentication tag, authTag.
|
||||
|
||||
\return 0 On successfully encrypting the input message
|
||||
|
||||
\param aes - pointer to the AES object used to encrypt data
|
||||
\param out pointer to the output buffer in which to store the cipher text
|
||||
\param in pointer to the input buffer holding the message to encrypt
|
||||
\param sz length of the input message to encrypt
|
||||
\param iv pointer to the buffer containing the initialization vector
|
||||
\param ivSz length of the initialization vector
|
||||
\param authTag pointer to the buffer in which to store the
|
||||
authentication tag
|
||||
\param authTagSz length of the desired authentication tag
|
||||
\param authIn pointer to the buffer containing the input
|
||||
authentication vector
|
||||
\param authInSz length of the input authentication vector
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes enc;
|
||||
// initialize aes structure by calling wc_AesGcmSetKey
|
||||
|
||||
byte plain[AES_BLOCK_LENGTH * n]; //n being a positive integer
|
||||
making plain some multiple of 16 bytes
|
||||
// initialize plain with msg to encrypt
|
||||
byte cipher[sizeof(plain)];
|
||||
byte iv[] = // some 16 byte iv
|
||||
byte authTag[AUTH_TAG_LENGTH];
|
||||
byte authIn[] = // Authentication Vector
|
||||
|
||||
wc_AesGcmEncrypt(&enc, cipher, plain, sizeof(cipher), iv, sizeof(iv),
|
||||
authTag, sizeof(authTag), authIn, sizeof(authIn));
|
||||
\endcode
|
||||
|
||||
\sa wc_AesGcmSetKey
|
||||
\sa wc_AesGcmDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_AesGcmEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* iv, word32 ivSz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief This function decrypts the input cipher text, held in the buffer
|
||||
in, and stores the resulting message text in the output buffer out.
|
||||
It also checks the input authentication vector, authIn, against the
|
||||
supplied authentication tag, authTag.
|
||||
|
||||
\return 0 On successfully decrypting the input message
|
||||
\return AES_GCM_AUTH_E If the authentication tag does not match the
|
||||
supplied authentication code vector, authTag.
|
||||
|
||||
\param aes pointer to the AES object used to encrypt data
|
||||
\param out pointer to the output buffer in which to store the message text
|
||||
\param in pointer to the input buffer holding the cipher text to decrypt
|
||||
\param sz length of the cipher text to decrypt
|
||||
\param iv pointer to the buffer containing the initialization vector
|
||||
\param ivSz length of the initialization vector
|
||||
\param authTag pointer to the buffer containing the authentication tag
|
||||
\param authTagSz length of the desired authentication tag
|
||||
\param authIn pointer to the buffer containing the input
|
||||
authentication vector
|
||||
\param authInSz length of the input authentication vector
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes enc; //can use the same struct as was passed to wc_AesGcmEncrypt
|
||||
// initialize aes structure by calling wc_AesGcmSetKey if not already done
|
||||
|
||||
byte cipher[AES_BLOCK_LENGTH * n]; //n being a positive integer
|
||||
making cipher some multiple of 16 bytes
|
||||
// initialize cipher with cipher text to decrypt
|
||||
byte output[sizeof(cipher)];
|
||||
byte iv[] = // some 16 byte iv
|
||||
byte authTag[AUTH_TAG_LENGTH];
|
||||
byte authIn[] = // Authentication Vector
|
||||
|
||||
wc_AesGcmDecrypt(&enc, output, cipher, sizeof(cipher), iv, sizeof(iv),
|
||||
authTag, sizeof(authTag), authIn, sizeof(authIn));
|
||||
\endcode
|
||||
|
||||
\sa wc_AesGcmSetKey
|
||||
\sa wc_AesGcmEncrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_AesGcmDecrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* iv, word32 ivSz,
|
||||
const byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief This function initializes and sets the key for a GMAC object
|
||||
to be used for Galois Message Authentication.
|
||||
|
||||
\return 0 On successfully setting the key
|
||||
\return BAD_FUNC_ARG Returned if key length is invalid.
|
||||
|
||||
\param gmac pointer to the gmac object used for authentication
|
||||
\param key 16, 24, or 32 byte secret key for authentication
|
||||
\param len length of the key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Gmac gmac;
|
||||
key[] = { some 16, 24, or 32 byte length key };
|
||||
wc_GmacSetKey(&gmac, key, sizeof(key));
|
||||
\endcode
|
||||
|
||||
\sa wc_GmacUpdate
|
||||
*/
|
||||
WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief This function generates the Gmac hash of the authIn input and
|
||||
stores the result in the authTag buffer. After running wc_GmacUpdate,
|
||||
one should compare the generated authTag to a known authentication tag
|
||||
to verify the authenticity of a message.
|
||||
|
||||
\return 0 On successfully computing the Gmac hash.
|
||||
|
||||
\param gmac pointer to the gmac object used for authentication
|
||||
\param iv initialization vector used for the hash
|
||||
\param ivSz size of the initialization vector used
|
||||
\param authIn pointer to the buffer containing the authentication
|
||||
vector to verify
|
||||
\param authInSz size of the authentication vector
|
||||
\param authTag pointer to the output buffer in which to store the Gmac hash
|
||||
\param authTagSz the size of the output buffer used to store the Gmac hash
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Gmac gmac;
|
||||
key[] = { some 16, 24, or 32 byte length key };
|
||||
iv[] = { some 16 byte length iv };
|
||||
|
||||
wc_GmacSetKey(&gmac, key, sizeof(key));
|
||||
authIn[] = { some 16 byte authentication input };
|
||||
tag[AES_BLOCK_SIZE]; // will store authentication code
|
||||
|
||||
wc_GmacUpdate(&gmac, iv, sizeof(iv), authIn, sizeof(authIn), tag,
|
||||
sizeof(tag));
|
||||
\endcode
|
||||
|
||||
\sa wc_GmacSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
|
||||
const byte* authIn, word32 authInSz,
|
||||
byte* authTag, word32 authTagSz);
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief This function sets the key for an AES object using CCM
|
||||
(Counter with CBC-MAC). It takes a pointer to an AES structure and
|
||||
initializes it with supplied key.
|
||||
|
||||
\return none
|
||||
|
||||
\param aes aes structure in which to store the supplied key
|
||||
\param key 16, 24, or 32 byte secret key for encryption and decryption
|
||||
\param keySz size of the supplied key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes enc;
|
||||
key[] = { some 16, 24, or 32 byte length key };
|
||||
|
||||
wc_AesCcmSetKey(&aes, key, sizeof(key));
|
||||
\endcode
|
||||
|
||||
\sa wc_AesCcmEncrypt
|
||||
\sa wc_AesCcmDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz);
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief This function encrypts the input message, in, into the output
|
||||
buffer, out, using CCM (Counter with CBC-MAC). It subsequently
|
||||
calculates and stores the authorization tag, authTag, from the
|
||||
authIn input.
|
||||
|
||||
\return none
|
||||
|
||||
\param aes pointer to the AES object used to encrypt data
|
||||
\param out pointer to the output buffer in which to store the cipher text
|
||||
\param in pointer to the input buffer holding the message to encrypt
|
||||
\param sz length of the input message to encrypt
|
||||
\param nonce pointer to the buffer containing the nonce
|
||||
(number only used once)
|
||||
\param nonceSz length of the nonce
|
||||
\param authTag pointer to the buffer in which to store the
|
||||
authentication tag
|
||||
\param authTagSz length of the desired authentication tag
|
||||
\param authIn pointer to the buffer containing the input
|
||||
authentication vector
|
||||
\param authInSz length of the input authentication vector
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes enc;
|
||||
// initialize enc with wc_AesCcmSetKey
|
||||
|
||||
nonce[] = { initialize nonce };
|
||||
plain[] = { some plain text message };
|
||||
cipher[sizeof(plain)];
|
||||
|
||||
authIn[] = { some 16 byte authentication input };
|
||||
tag[AES_BLOCK_SIZE]; // will store authentication code
|
||||
|
||||
wc_AesCcmEncrypt(&enc, cipher, plain, sizeof(plain), nonce, sizeof(nonce),
|
||||
tag, sizeof(tag), authIn, sizeof(authIn));
|
||||
\endcode
|
||||
|
||||
\sa wc_AesCcmSetKey
|
||||
\sa wc_AesCcmDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_AesCcmEncrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 inSz,
|
||||
const byte* nonce, word32 nonceSz,
|
||||
byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief This function decrypts the input cipher text, in, into
|
||||
the output buffer, out, using CCM (Counter with CBC-MAC). It
|
||||
subsequently calculates the authorization tag, authTag, from the
|
||||
authIn input. If the authorization tag is invalid, it sets the
|
||||
output buffer to zero and returns the error: AES_CCM_AUTH_E.
|
||||
|
||||
\return 0 On successfully decrypting the input message
|
||||
\return AES_CCM_AUTH_E If the authentication tag does not match the
|
||||
supplied authentication code vector, authTag.
|
||||
|
||||
\param aes pointer to the AES object used to encrypt data
|
||||
\param out pointer to the output buffer in which to store the cipher text
|
||||
\param in pointer to the input buffer holding the message to encrypt
|
||||
\param sz length of the input cipher text to decrypt
|
||||
\param nonce pointer to the buffer containing the nonce
|
||||
(number only used once)
|
||||
\param nonceSz length of the nonce
|
||||
\param authTag pointer to the buffer in which to store the
|
||||
authentication tag
|
||||
\param authTagSz length of the desired authentication tag
|
||||
\param authIn pointer to the buffer containing the input
|
||||
authentication vector
|
||||
\param authInSz length of the input authentication vector
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Aes dec;
|
||||
// initialize dec with wc_AesCcmSetKey
|
||||
|
||||
nonce[] = { initialize nonce };
|
||||
cipher[] = { encrypted message };
|
||||
plain[sizeof(cipher)];
|
||||
|
||||
authIn[] = { some 16 byte authentication input };
|
||||
tag[AES_BLOCK_SIZE] = { authentication tag received for verification };
|
||||
|
||||
int return = wc_AesCcmDecrypt(&dec, plain, cipher, sizeof(cipher),
|
||||
nonce, sizeof(nonce),tag, sizeof(tag), authIn, sizeof(authIn));
|
||||
if(return != 0) {
|
||||
// decrypt error, invalid authentication code
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_AesCcmSetKey
|
||||
\sa wc_AesCcmEncrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_AesCcmDecrypt(Aes* aes, byte* out,
|
||||
const byte* in, word32 inSz,
|
||||
const byte* nonce, word32 nonceSz,
|
||||
const byte* authTag, word32 authTagSz,
|
||||
const byte* authIn, word32 authInSz);
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief This is to help with setting keys to correct encrypt or
|
||||
decrypt type. It is up to user to call wc_AesXtsFree on aes key when done.
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys for encrypt/decrypt process
|
||||
\param key buffer holding aes key | tweak key
|
||||
\param len length of key buffer in bytes. Should be twice that of
|
||||
key size.
|
||||
i.e. 32 for a 16 byte key.
|
||||
\param dir direction, either AES_ENCRYPTION or AES_DECRYPTION
|
||||
\param heap heap hint to use for memory. Can be NULL
|
||||
\param devId id to use with async crypto. Can be 0
|
||||
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
|
||||
if(wc_AesXtsSetKey(&aes, key, sizeof(key), AES_ENCRYPTION, NULL, 0) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsEncrypt
|
||||
\sa wc_AesXtsDecrypt
|
||||
\sa wc_AesXtsFree
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsSetKey(XtsAes* aes, const byte* key,
|
||||
word32 len, int dir, void* heap, int devId);
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief Same process as wc_AesXtsEncrypt but uses a word64 type as the tweak
|
||||
value instead of a byte array. This just converts the word64 to a
|
||||
byte array and calls wc_AesXtsEncrypt.
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys to use for block encrypt/decrypt
|
||||
\param out output buffer to hold cipher text
|
||||
\param in input plain text buffer to encrypt
|
||||
\param sz size of both out and in buffers
|
||||
\param sector value to use for tweak
|
||||
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
unsigned char plain[SIZE];
|
||||
unsigned char cipher[SIZE];
|
||||
word64 s = VALUE;
|
||||
|
||||
//set up keys with AES_ENCRYPTION as dir
|
||||
|
||||
if(wc_AesXtsEncryptSector(&aes, cipher, plain, SIZE, s) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsEncrypt
|
||||
\sa wc_AesXtsDecrypt
|
||||
\sa wc_AesXtsSetKey
|
||||
\sa wc_AesXtsFree
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsEncryptSector(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, word64 sector);
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief Same process as wc_AesXtsDecrypt but uses a word64 type as the tweak
|
||||
value instead of a byte array. This just converts the word64 to a
|
||||
byte array.
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys to use for block encrypt/decrypt
|
||||
\param out output buffer to hold plain text
|
||||
\param in input cipher text buffer to decrypt
|
||||
\param sz size of both out and in buffers
|
||||
\param sector value to use for tweak
|
||||
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
unsigned char plain[SIZE];
|
||||
unsigned char cipher[SIZE];
|
||||
word64 s = VALUE;
|
||||
|
||||
//set up aes key with AES_DECRYPTION as dir and tweak with AES_ENCRYPTION
|
||||
|
||||
if(wc_AesXtsDecryptSector(&aes, plain, cipher, SIZE, s) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsEncrypt
|
||||
\sa wc_AesXtsDecrypt
|
||||
\sa wc_AesXtsSetKey
|
||||
\sa wc_AesXtsFree
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsDecryptSector(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, word64 sector);
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief AES with XTS mode. (XTS) XEX encryption with Tweak and cipher text
|
||||
Stealing.
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys to use for block encrypt/decrypt
|
||||
\param out output buffer to hold cipher text
|
||||
\param in input plain text buffer to encrypt
|
||||
\param sz size of both out and in buffers
|
||||
\param i value to use for tweak
|
||||
\param iSz size of i buffer, should always be AES_BLOCK_SIZE but having
|
||||
this input adds a sanity check on how the user calls the
|
||||
function.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
unsigned char plain[SIZE];
|
||||
unsigned char cipher[SIZE];
|
||||
unsigned char i[AES_BLOCK_SIZE];
|
||||
|
||||
//set up key with AES_ENCRYPTION as dir
|
||||
|
||||
if(wc_AesXtsEncrypt(&aes, cipher, plain, SIZE, i, sizeof(i)) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsDecrypt
|
||||
\sa wc_AesXtsSetKey
|
||||
\sa wc_AesXtsFree
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsEncrypt(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, const byte* i, word32 iSz);
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief Same process as encryption but Aes key is AES_DECRYPTION type.
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys to use for block encrypt/decrypt
|
||||
\param out output buffer to hold plain text
|
||||
\param in input cipher text buffer to decrypt
|
||||
\param sz size of both out and in buffers
|
||||
\param i value to use for tweak
|
||||
\param iSz size of i buffer, should always be AES_BLOCK_SIZE but having
|
||||
this input adds a sanity check on how the user calls the
|
||||
function.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
unsigned char plain[SIZE];
|
||||
unsigned char cipher[SIZE];
|
||||
unsigned char i[AES_BLOCK_SIZE];
|
||||
|
||||
//set up key with AES_DECRYPTION as dir and tweak with AES_ENCRYPTION
|
||||
|
||||
if(wc_AesXtsDecrypt(&aes, plain, cipher, SIZE, i, sizeof(i)) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsEncrypt
|
||||
\sa wc_AesXtsSetKey
|
||||
\sa wc_AesXtsFree
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsDecrypt(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, const byte* i, word32 iSz);
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief This is to free up any resources used by the XtsAes structure
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
|
||||
if(wc_AesXtsSetKey(&aes, key, sizeof(key), AES_ENCRYPTION, NULL, 0) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsEncrypt
|
||||
\sa wc_AesXtsDecrypt
|
||||
\sa wc_AesXtsSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsFree(XtsAes* aes);
|
58
doc/dox_comments/header_files/arc4.h
Normal file
58
doc/dox_comments/header_files/arc4.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*!
|
||||
\ingroup ARC4
|
||||
\brief This function encrypts an input message from the buffer in, placing
|
||||
the ciphertext in the output buffer out, or decrypts a ciphertext from the
|
||||
buffer in, placing the plaintext in the output buffer out, using ARC4
|
||||
encryption. This function is used for both encryption and decryption.
|
||||
Before this method may be called, one must first initialize the ARC4
|
||||
structure using wc_Arc4SetKey.
|
||||
|
||||
\return none
|
||||
|
||||
\param arc4 pointer to the ARC4 structure used to process the message
|
||||
\param out pointer to the output buffer in which to store the
|
||||
processed message
|
||||
\param in pointer to the input buffer containing the message to process
|
||||
\param length length of the message to process
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Arc4 enc;
|
||||
byte key[] = { key to use for encryption };
|
||||
wc_Arc4SetKey(&enc, key, sizeof(key));
|
||||
|
||||
byte plain[] = { plain text to encode };
|
||||
byte cipher[sizeof(plain)];
|
||||
byte decrypted[sizeof(plain)];
|
||||
// encrypt the plain into cipher
|
||||
wc_Arc4Process(&enc, cipher, plain, sizeof(plain));
|
||||
// decrypt the cipher
|
||||
wc_Arc4Process(&enc, decrypted, cipher, sizeof(cipher));
|
||||
\endcode
|
||||
|
||||
\sa wc_Arc4SetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_Arc4Process(Arc4*, byte*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup ARC4
|
||||
|
||||
\brief This function sets the key for a ARC4 object, initializing it for
|
||||
use as a cipher. It should be called before using it for encryption
|
||||
with wc_Arc4Process.
|
||||
|
||||
\return none
|
||||
|
||||
\param arc4 pointer to an arc4 structure to be used for encryption
|
||||
\param key key with which to initialize the arc4 structure
|
||||
\param length length of the key used to initialize the arc4 structure
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Arc4 enc;
|
||||
byte key[] = { initialize with key to use for encryption };
|
||||
wc_Arc4SetKey(&enc, key, sizeof(key));
|
||||
\endcode
|
||||
|
||||
\sa wc_Arc4Process
|
||||
*/
|
||||
WOLFSSL_API int wc_Arc4SetKey(Arc4*, const byte*, word32);
|
34
doc/dox_comments/header_files/asn.h
Normal file
34
doc/dox_comments/header_files/asn.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*!
|
||||
\ingroup ASN
|
||||
|
||||
\brief This function converts a pem certificate to a der certificate,
|
||||
and places the resulting certificate in the derBuf buffer provided.
|
||||
|
||||
\return Success On success returns the size of the derBuf generated
|
||||
\return BUFFER_E Returned if the size of derBuf is too small to hold
|
||||
the certificate generated
|
||||
\return MEMORY_E Returned if the call to XMALLOC fails
|
||||
|
||||
\param fileName path to the file containing a pem certificate to
|
||||
convert to a der certificate
|
||||
\param derBuf pointer to a char buffer in which to store the
|
||||
converted certificate
|
||||
\param derSz size of the char buffer in which to store the
|
||||
converted certificate
|
||||
|
||||
_Example_
|
||||
\code
|
||||
char * file = “./certs/client-cert.pem”;
|
||||
int derSz;
|
||||
byte * der = (byte*)XMALLOC(EIGHTK_BUF, NULL, DYNAMIC_TYPE_CERT);
|
||||
|
||||
derSz = wolfsSSL_PemCertToDer(file, der, EIGHTK_BUF);
|
||||
if(derSz <= 0) {
|
||||
//PemCertToDer error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa none
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wolfSSL_PemCertToDer(const char* fileName,unsigned char* derBuf,int derSz);
|
1304
doc/dox_comments/header_files/asn_public.h
Normal file
1304
doc/dox_comments/header_files/asn_public.h
Normal file
File diff suppressed because it is too large
Load Diff
93
doc/dox_comments/header_files/blake2.h
Normal file
93
doc/dox_comments/header_files/blake2.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief This function initializes a Blake2b structure for use with the
|
||||
Blake2 hash function.
|
||||
|
||||
\return 0 Returned upon successfully initializing the Blake2b structure and
|
||||
setting the digest size.
|
||||
|
||||
\param b2b pointer to the Blake2b structure to initialize
|
||||
\param digestSz length of the blake 2 digest to implement
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Blake2b b2b;
|
||||
// initialize Blake2b structure with 64 byte digest
|
||||
wc_InitBlake2b(&b2b, 64);
|
||||
\endcode
|
||||
|
||||
\sa wc_Blake2bUpdate
|
||||
*/
|
||||
WOLFSSL_API int wc_InitBlake2b(Blake2b*, word32);
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief This function updates the Blake2b hash with the given input data.
|
||||
This function should be called after wc_InitBlake2b, and repeated until
|
||||
one is ready for the final hash: wc_Blake2bFinal.
|
||||
|
||||
\return 0 Returned upon successfully update the Blake2b structure with
|
||||
the given data
|
||||
\return -1 Returned if there is a failure while compressing the input data
|
||||
|
||||
\param b2b pointer to the Blake2b structure to update
|
||||
\param data pointer to a buffer containing the data to append
|
||||
\param sz length of the input data to append
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
Blake2b b2b;
|
||||
// initialize Blake2b structure with 64 byte digest
|
||||
wc_InitBlake2b(&b2b, 64);
|
||||
|
||||
byte plain[] = { // initialize input };
|
||||
|
||||
ret = wc_Blake2bUpdate(&b2b, plain, sizeof(plain));
|
||||
if( ret != 0) {
|
||||
// error updating blake2b
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitBlake2b
|
||||
\sa wc_Blake2bFinal
|
||||
*/
|
||||
WOLFSSL_API int wc_Blake2bUpdate(Blake2b*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup BLAKE2
|
||||
|
||||
\brief This function computes the Blake2b hash of the previously supplied
|
||||
input data. The output hash will be of length requestSz, or, if
|
||||
requestSz==0, the digestSz of the b2b structure. This function should be
|
||||
called after wc_InitBlake2b and wc_Blake2bUpdate has been processed for
|
||||
each piece of input data desired.
|
||||
|
||||
\return 0 Returned upon successfully computing the Blake2b hash
|
||||
\return -1 Returned if there is a failure while parsing the Blake2b hash
|
||||
|
||||
\param b2b pointer to the Blake2b structure to update
|
||||
\param final pointer to a buffer in which to store the blake2b hash.
|
||||
Should be of length requestSz
|
||||
\param requestSz length of the digest to compute. When this is zero,
|
||||
b2b->digestSz will be used instead
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
Blake2b b2b;
|
||||
byte hash[64];
|
||||
// initialize Blake2b structure with 64 byte digest
|
||||
wc_InitBlake2b(&b2b, 64);
|
||||
... // call wc_Blake2bUpdate to add data to hash
|
||||
|
||||
ret = 2c_Blake2bFinal(&b2b, hash, 64);
|
||||
if( ret != 0) {
|
||||
// error generating blake2b hash
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitBlake2b
|
||||
\sa wc_Blake2bUpdate
|
||||
*/
|
||||
WOLFSSL_API int wc_Blake2bFinal(Blake2b*, byte*, word32);
|
28
doc/dox_comments/header_files/bn.h
Normal file
28
doc/dox_comments/header_files/bn.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief This function performs the following math “r = (a^p) % m”.
|
||||
|
||||
\return SSL_SUCCESS On successfully performing math operation.
|
||||
\return SSL_FAILURE If an error case was encountered.
|
||||
|
||||
\param r structure to hold result.
|
||||
\param a value to be raised by a power.
|
||||
\param p power to raise a by.
|
||||
\param m modulus to use.
|
||||
\param ctx currently not used with wolfSSL can be NULL.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_BIGNUM r,a,p,m;
|
||||
int ret;
|
||||
// set big number values
|
||||
ret = wolfSSL_BN_mod_exp(r, a, p, m, NULL);
|
||||
// check ret value
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_BN_new
|
||||
\sa wolfSSL_BN_free
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_BN_mod_exp(WOLFSSL_BIGNUM *r, const WOLFSSL_BIGNUM *a,
|
||||
const WOLFSSL_BIGNUM *p, const WOLFSSL_BIGNUM *m, WOLFSSL_BN_CTX *ctx);
|
179
doc/dox_comments/header_files/camellia.h
Normal file
179
doc/dox_comments/header_files/camellia.h
Normal file
@ -0,0 +1,179 @@
|
||||
/*!
|
||||
\ingroup Camellia
|
||||
|
||||
\brief This function sets the key and initialization vector for a
|
||||
camellia object, initializing it for use as a cipher.
|
||||
|
||||
\return 0 Returned upon successfully setting the key and initialization
|
||||
vector
|
||||
\return BAD_FUNC_ARG returned if there is an error processing one of
|
||||
the input arguments
|
||||
\return MEMORY_E returned if there is an error allocating memory with
|
||||
XMALLOC
|
||||
|
||||
\param cam pointer to the camellia structure on which to set the key and iv
|
||||
\param key pointer to the buffer containing the 16, 24, or 32 byte key
|
||||
to use for encryption and decryption
|
||||
\param len length of the key passed in
|
||||
\param iv pointer to the buffer containing the 16 byte initialization
|
||||
vector for use with this camellia structure
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Camellia cam;
|
||||
byte key[32];
|
||||
// initialize key
|
||||
byte iv[16];
|
||||
// initialize iv
|
||||
if( wc_CamelliaSetKey(&cam, key, sizeof(key), iv) != 0) {
|
||||
// error initializing camellia structure
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_CamelliaEncryptDirect
|
||||
\sa wc_CamelliaDecryptDirect
|
||||
\sa wc_CamelliaCbcEncrypt
|
||||
\sa wc_CamelliaCbcDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_CamelliaSetKey(Camellia* cam,
|
||||
const byte* key, word32 len, const byte* iv);
|
||||
/*!
|
||||
\ingroup Camellia
|
||||
|
||||
\brief This function sets the initialization vector for a camellia object.
|
||||
|
||||
\return 0 Returned upon successfully setting the key and initialization
|
||||
vector
|
||||
\return BAD_FUNC_ARG returned if there is an error processing one of the
|
||||
input arguments
|
||||
|
||||
\param cam pointer to the camellia structure on which to set the iv
|
||||
\param iv pointer to the buffer containing the 16 byte initialization
|
||||
vector for use with this camellia structure
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Camellia cam;
|
||||
byte iv[16];
|
||||
// initialize iv
|
||||
if( wc_CamelliaSetIV(&cam, iv) != 0) {
|
||||
// error initializing camellia structure
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_CamelliaSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_CamelliaSetIV(Camellia* cam, const byte* iv);
|
||||
/*!
|
||||
\ingroup Camellia
|
||||
|
||||
\brief This function does a one-block encrypt using the provided camellia
|
||||
object. It parses the first 16 byte block from the buffer in and stores
|
||||
the encrypted result in the buffer out. Before using this function, one
|
||||
should initialize the camellia object using wc_CamelliaSetKey.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param cam pointer to the camellia structure to use for encryption
|
||||
\param out pointer to the buffer in which to store the encrypted block
|
||||
\param in pointer to the buffer containing the plaintext block to encrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Camellia cam;
|
||||
// initialize cam structure with key and iv
|
||||
byte plain[] = { // initialize with message to encrypt };
|
||||
byte cipher[16];
|
||||
|
||||
wc_CamelliaEncrypt(&ca, cipher, plain);
|
||||
\endcode
|
||||
|
||||
\sa wc_CamelliaDecryptDirect
|
||||
*/
|
||||
WOLFSSL_API int wc_CamelliaEncryptDirect(Camellia* cam, byte* out,
|
||||
const byte* in);
|
||||
/*!
|
||||
\ingroup Camellia
|
||||
|
||||
\brief This function does a one-block decrypt using the provided camellia
|
||||
object. It parses the first 16 byte block from the buffer in, decrypts it,
|
||||
and stores the result in the buffer out. Before using this function, one
|
||||
should initialize the camellia object using wc_CamelliaSetKey.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param cam pointer to the camellia structure to use for encryption
|
||||
\param out pointer to the buffer in which to store the decrypted
|
||||
plaintext block
|
||||
\param in pointer to the buffer containing the ciphertext block to decrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Camellia cam;
|
||||
// initialize cam structure with key and iv
|
||||
byte cipher[] = { // initialize with encrypted message to decrypt };
|
||||
byte decrypted[16];
|
||||
|
||||
wc_CamelliaDecryptDirect(&cam, decrypted, cipher);
|
||||
\endcode
|
||||
|
||||
\sa wc_CamelliaEncryptDirect
|
||||
*/
|
||||
WOLFSSL_API int wc_CamelliaDecryptDirect(Camellia* cam, byte* out,
|
||||
const byte* in);
|
||||
/*!
|
||||
\ingroup Camellia
|
||||
|
||||
\brief This function encrypts the plaintext from the buffer in and
|
||||
stores the output in the buffer out. It performs this encryption
|
||||
using Camellia with Cipher Block Chaining (CBC).
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param cam pointer to the camellia structure to use for encryption
|
||||
\param out pointer to the buffer in which to store the encrypted ciphertext
|
||||
\param in pointer to the buffer containing the plaintext to encrypt
|
||||
\param sz the size of the message to encrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Camellia cam;
|
||||
// initialize cam structure with key and iv
|
||||
byte plain[] = { // initialize with encrypted message to decrypt };
|
||||
byte cipher[sizeof(plain)];
|
||||
|
||||
wc_CamelliaCbcEncrypt(&cam, cipher, plain, sizeof(plain));
|
||||
\endcode
|
||||
|
||||
\sa wc_CamelliaCbcDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_CamelliaCbcEncrypt(Camellia* cam,
|
||||
byte* out, const byte* in, word32 sz);
|
||||
/*!
|
||||
\ingroup Camellia
|
||||
|
||||
\brief This function decrypts the ciphertext from the buffer in and
|
||||
stores the output in the buffer out. It performs this decryption using
|
||||
Camellia with Cipher Block Chaining (CBC).
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param cam pointer to the camellia structure to use for encryption
|
||||
\param out pointer to the buffer in which to store the decrypted message
|
||||
\param in pointer to the buffer containing the encrypted ciphertext
|
||||
\param sz the size of the message to encrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Camellia cam;
|
||||
// initialize cam structure with key and iv
|
||||
byte cipher[] = { // initialize with encrypted message to decrypt };
|
||||
byte decrypted[sizeof(cipher)];
|
||||
|
||||
wc_CamelliaCbcDecrypt(&cam, decrypted, cipher, sizeof(cipher));
|
||||
\endcode
|
||||
|
||||
\sa wc_CamelliaCbcEncrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_CamelliaCbcDecrypt(Camellia* cam,
|
||||
byte* out, const byte* in, word32 sz);
|
97
doc/dox_comments/header_files/chacha.h
Normal file
97
doc/dox_comments/header_files/chacha.h
Normal file
@ -0,0 +1,97 @@
|
||||
/*!
|
||||
\ingroup ChaCha
|
||||
|
||||
\brief This function sets the initialization vector (nonce) for a ChaCha
|
||||
object, initializing it for use as a cipher. It should be called after the
|
||||
key has been set, using wc_Chacha_SetKey. A difference nonce should be
|
||||
used for each round of encryption.
|
||||
|
||||
\return 0 Returned upon successfully setting the initialization vector
|
||||
\return BAD_FUNC_ARG returned if there is an error processing the ctx
|
||||
input argument
|
||||
|
||||
\param ctx pointer to the ChaCha structure on which to set the iv
|
||||
\param inIv pointer to a buffer containing the 12 byte initialization
|
||||
vector with which to initialize the ChaCha structure
|
||||
\param counter the value at which the block counter should start--usually
|
||||
zero.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ChaCha enc;
|
||||
// initialize enc with wc_Chacha_SetKey
|
||||
byte iv[12];
|
||||
// initialize iv
|
||||
if( wc_Chacha_SetIV(&enc, iv, 0) != 0) {
|
||||
// error initializing ChaCha structure
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Chacha_SetKey
|
||||
\sa wc_Chacha_Process
|
||||
*/
|
||||
WOLFSSL_API int wc_Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter);
|
||||
/*!
|
||||
\ingroup ChaCha
|
||||
|
||||
\brief This function processes the text from the buffer input, encrypts
|
||||
or decrypts it, and stores the result in the buffer output.
|
||||
|
||||
\return 0 Returned upon successfully encrypting or decrypting the input
|
||||
\return BAD_FUNC_ARG returned if there is an error processing the ctx
|
||||
input argument
|
||||
|
||||
\param ctx pointer to the ChaCha structure on which to set the iv
|
||||
\param output pointer to a buffer in which to store the output ciphertext
|
||||
or decrypted plaintext
|
||||
\param input pointer to the buffer containing the input plaintext to
|
||||
encrypt or the input ciphertext to decrypt
|
||||
\param msglen length of the message to encrypt or the ciphertext to decrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ChaCha enc;
|
||||
// initialize enc with wc_Chacha_SetKey and wc_Chacha_SetIV
|
||||
|
||||
byte plain[] = { // initialize plaintext };
|
||||
byte cipher[sizeof(plain)];
|
||||
if( wc_Chacha_Process(&enc, cipher, plain, sizeof(plain)) != 0) {
|
||||
// error processing ChaCha cipher
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Chacha_SetKey
|
||||
\sa wc_Chacha_Process
|
||||
*/
|
||||
WOLFSSL_API int wc_Chacha_Process(ChaCha* ctx, byte* cipher, const byte* plain,
|
||||
word32 msglen);
|
||||
/*!
|
||||
\ingroup ChaCha
|
||||
|
||||
\brief This function sets the key for a ChaCha object, initializing it for
|
||||
use as a cipher. It should be called before setting the nonce with
|
||||
wc_Chacha_SetIV, and before using it for encryption with wc_Chacha_Process.
|
||||
|
||||
\return 0 Returned upon successfully setting the key
|
||||
\return BAD_FUNC_ARG returned if there is an error processing the ctx
|
||||
input argument or if the key is not 16 or 32 bytes long
|
||||
|
||||
\param ctx pointer to the ChaCha structure in which to set the key
|
||||
\param key pointer to a buffer containing the 16 or 32 byte key with
|
||||
which to initialize the ChaCha structure
|
||||
\param keySz the length of the key passed in
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ChaCha enc;
|
||||
byte key[] = { // initialize key };
|
||||
|
||||
if( wc_Chacha_SetKey(&enc, key, sizeof(key)) != 0) {
|
||||
// error initializing ChaCha structure
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Chacha_SetIV
|
||||
\sa wc_Chacha_Process
|
||||
*/
|
||||
WOLFSSL_API int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz);
|
119
doc/dox_comments/header_files/chacha20_poly1305.h
Normal file
119
doc/dox_comments/header_files/chacha20_poly1305.h
Normal file
@ -0,0 +1,119 @@
|
||||
/*!
|
||||
\ingroup ChaCha20Poly1305
|
||||
|
||||
\brief This function encrypts an input message, inPlaintext, using the
|
||||
ChaCha20 stream cipher, into the output buffer, outCiphertext. It
|
||||
also performs Poly-1305 authentication (on the cipher text), and
|
||||
stores the generated authentication tag in the output buffer, outAuthTag.
|
||||
|
||||
\return 0 Returned upon successfully encrypting the message
|
||||
\return BAD_FUNC_ARG returned if there is an error during the encryption
|
||||
process
|
||||
|
||||
\param inKey pointer to a buffer containing the 32 byte key to use
|
||||
for encryption
|
||||
\param inIv pointer to a buffer containing the 12 byte iv to use for
|
||||
encryption
|
||||
\param inAAD pointer to the buffer containing arbitrary length additional
|
||||
authenticated data (AAD)
|
||||
\param inAADLen length of the input AAD
|
||||
\param inPlaintext pointer to the buffer containing the plaintext to
|
||||
encrypt
|
||||
\param inPlaintextLen the length of the plain text to encrypt
|
||||
\param outCiphertext pointer to the buffer in which to store the ciphertext
|
||||
\param outAuthTag pointer to a 16 byte wide buffer in which to store the
|
||||
authentication tag
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte key[] = { // initialize 32 byte key };
|
||||
byte iv[] = { // initialize 12 byte key };
|
||||
byte inAAD[] = { // initialize AAD };
|
||||
|
||||
byte plain[] = { // initialize message to encrypt };
|
||||
byte cipher[sizeof(plain)];
|
||||
byte authTag[16];
|
||||
|
||||
int ret = wc_ChaCha20Poly1305_Encrypt(key, iv, inAAD, sizeof(inAAD),
|
||||
plain, sizeof(plain), cipher, authTag);
|
||||
|
||||
if(ret != 0) {
|
||||
// error running encrypt
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ChaCha20Poly1305_Decrypt
|
||||
\sa wc_ChaCha_*
|
||||
\sa wc_Poly1305*
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ChaCha20Poly1305_Encrypt(
|
||||
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
|
||||
const byte* inAAD, const word32 inAADLen,
|
||||
const byte* inPlaintext, const word32 inPlaintextLen,
|
||||
byte* outCiphertext,
|
||||
byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]);
|
||||
/*!
|
||||
\ingroup ChaCha20Poly1305
|
||||
|
||||
\brief This function decrypts input ciphertext, inCiphertext, using the
|
||||
ChaCha20 stream cipher, into the output buffer, outPlaintext. It also
|
||||
performs Poly-1305 authentication, comparing the given inAuthTag to an
|
||||
authentication generated with the inAAD (arbitrary length additional
|
||||
authentication data). Note: If the generated authentication tag does
|
||||
not match the supplied authentication tag, the text is not decrypted.
|
||||
|
||||
\return 0 Returned upon successfully decrypting the message
|
||||
\return BAD_FUNC_ARG Returned if any of the function arguments do not
|
||||
match what is expected
|
||||
\return MAC_CMP_FAILED_E Returned if the generated authentication tag
|
||||
does not match the supplied inAuthTag.
|
||||
|
||||
\param inKey pointer to a buffer containing the 32 byte key to use for
|
||||
decryption
|
||||
\param inIv pointer to a buffer containing the 12 byte iv to use for
|
||||
decryption
|
||||
\param inAAD pointer to the buffer containing arbitrary length additional
|
||||
authenticated data (AAD)
|
||||
\param inAADLen length of the input AAD
|
||||
\param inCiphertext pointer to the buffer containing the ciphertext to
|
||||
decrypt
|
||||
\param outCiphertextLen the length of the ciphertext to decrypt
|
||||
\param inAuthTag pointer to the buffer containing the 16 byte digest
|
||||
for authentication
|
||||
\param outPlaintext pointer to the buffer in which to store the plaintext
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte key[] = { // initialize 32 byte key };
|
||||
byte iv[] = { // initialize 12 byte key };
|
||||
byte inAAD[] = { // initialize AAD };
|
||||
|
||||
byte cipher[] = { // initialize with received ciphertext };
|
||||
byte authTag[16] = { // initialize with received authentication tag };
|
||||
|
||||
byte plain[sizeof(cipher)];
|
||||
|
||||
int ret = wc_ChaCha20Poly1305_Decrypt(key, iv, inAAD, sizeof(inAAD),
|
||||
cipher, sizeof(cipher), plain, authTag);
|
||||
|
||||
if(ret == MAC_CMP_FAILED_E) {
|
||||
// error during authentication
|
||||
} else if( ret != 0) {
|
||||
// error with function arguments
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ChaCha20Poly1305_Encrypt
|
||||
\sa wc_ChaCha_*
|
||||
\sa wc_Poly1305*
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ChaCha20Poly1305_Decrypt(
|
||||
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
|
||||
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
|
||||
const byte* inAAD, const word32 inAADLen,
|
||||
const byte* inCiphertext, const word32 inCiphertextLen,
|
||||
const byte inAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE],
|
||||
byte* outPlaintext);
|
228
doc/dox_comments/header_files/coding.h
Normal file
228
doc/dox_comments/header_files/coding.h
Normal file
@ -0,0 +1,228 @@
|
||||
/*!
|
||||
\ingroup Base_Encoding
|
||||
|
||||
\brief This function decodes the given Base64 encoded input, in, and
|
||||
stores the result in the output buffer out. It also sets the size
|
||||
written to the output buffer in the variable outLen.
|
||||
|
||||
\return 0 Returned upon successfully decoding the Base64 encoded input
|
||||
\return BAD_FUNC_ARG Returned if the output buffer is too small to
|
||||
store the decoded input
|
||||
\return ASN_INPUT_E Returned if a character in the input buffer falls
|
||||
outside of the Base64 range ([A-Za-z0-9+/=]) or if there is an invalid
|
||||
line ending in the Base64 encoded input
|
||||
|
||||
\param in pointer to the input buffer to decode
|
||||
\param inLen length of the input buffer to decode
|
||||
\param out pointer to the output buffer in which to store the decoded
|
||||
message
|
||||
\param outLen pointer to the length of the output buffer. Updated with
|
||||
the bytes written at the end of the function call
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte encoded[] = { // initialize text to decode };
|
||||
byte decoded[sizeof(encoded)];
|
||||
// requires at least (sizeof(encoded) * 3 + 3) / 4 room
|
||||
|
||||
int outLen = sizeof(decoded);
|
||||
|
||||
if( Base64_Decode(encoded,sizeof(encoded), decoded, &outLen) != 0 ) {
|
||||
// error decoding input buffer
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa Base64_Encode
|
||||
\sa Base16_Decode
|
||||
*/
|
||||
WOLFSSL_API int Base64_Decode(const byte* in, word32 inLen, byte* out,
|
||||
word32* outLen);
|
||||
/*!
|
||||
\ingroup Base_Encoding
|
||||
|
||||
\brief This function encodes the given input, in, and stores the Base64
|
||||
encoded result in the output buffer out. It writes the data with the
|
||||
traditional ‘\n’ line endings, instead of escaped %0A line endings. Upon
|
||||
successfully completing, this function also sets outLen to the number
|
||||
of bytes written to the output buffer.
|
||||
|
||||
\return 0 Returned upon successfully decoding the Base64 encoded input
|
||||
\return BAD_FUNC_ARG Returned if the output buffer is too small to
|
||||
store the encoded input
|
||||
\return BUFFER_E Returned if the output buffer runs out of room
|
||||
while encoding
|
||||
|
||||
\param in pointer to the input buffer to encode
|
||||
\param inLen length of the input buffer to encode
|
||||
\param out pointer to the output buffer in which to store the
|
||||
encoded message
|
||||
\param outLen pointer to the length of the output buffer in
|
||||
which to store the encoded message
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte plain[] = { // initialize text to encode };
|
||||
byte encoded[MAX_BUFFER_SIZE];
|
||||
|
||||
int outLen = sizeof(encoded);
|
||||
|
||||
if( Base64_Encode(plain, sizeof(plain), encoded, &outLen) != 0 ) {
|
||||
// error encoding input buffer
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa Base64_EncodeEsc
|
||||
\sa Base64_Decode
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int Base64_Encode(const byte* in, word32 inLen, byte* out,
|
||||
word32* outLen);
|
||||
/*!
|
||||
\ingroup Base_Encoding
|
||||
|
||||
\brief This function encodes the given input, in, and stores the
|
||||
Base64 encoded result in the output buffer out. It writes the data
|
||||
with %0A escaped line endings instead of ‘\n’ line endings.
|
||||
Upon successfully completing, this function also sets outLen
|
||||
to the number of bytes written to the output buffer.
|
||||
|
||||
\return 0 Returned upon successfully decoding the Base64 encoded input
|
||||
\return BAD_FUNC_ARG Returned if the output buffer is too small
|
||||
to store the encoded input
|
||||
\return BUFFER_E Returned if the output buffer runs out of
|
||||
room while encoding
|
||||
\return ASN_INPUT_E Returned if there is an error processing
|
||||
the decode on the input message
|
||||
|
||||
\param in pointer to the input buffer to encode
|
||||
\param inLen length of the input buffer to encode
|
||||
\param out pointer to the output buffer in which to store
|
||||
the encoded message
|
||||
\param outLen pointer to the length of the output buffer in
|
||||
which to store the encoded message
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte plain[] = { // initialize text to encode };
|
||||
byte encoded[MAX_BUFFER_SIZE];
|
||||
|
||||
int outLen = sizeof(encoded);
|
||||
|
||||
if( Base64_EncodeEsc(plain, sizeof(plain), encoded, &outLen) != 0 ) {
|
||||
// error encoding input buffer
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa Base64_Encode
|
||||
\sa Base64_Decode
|
||||
*/
|
||||
int Base64_EncodeEsc(const byte* in, word32 inLen, byte* out,
|
||||
word32* outLen);
|
||||
/*!
|
||||
\ingroup Base_Encoding
|
||||
|
||||
\brief This function encodes the given input, in, and stores the
|
||||
Base64 encoded result in the output buffer out. It writes the data
|
||||
with no new lines. Upon successfully completing, this function
|
||||
also sets outLen to the number of bytes written to the output buffer
|
||||
|
||||
\return 0 Returned upon successfully decoding the Base64 encoded input
|
||||
\return BAD_FUNC_ARG Returned if the output buffer is too small
|
||||
to store the encoded input
|
||||
\return BUFFER_E Returned if the output buffer runs out of room
|
||||
while encoding
|
||||
\return ASN_INPUT_E Returned if there is an error processing the
|
||||
decode on the input message
|
||||
|
||||
\param in pointer to the input buffer to encode
|
||||
\param inLen length of the input buffer to encode
|
||||
\param out pointer to the output buffer in which to store the
|
||||
encoded message
|
||||
\param outLen pointer to the length of the output buffer in which to
|
||||
store the encoded message
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte plain[] = { // initialize text to encode };
|
||||
byte encoded[MAX_BUFFER_SIZE];
|
||||
int outLen = sizeof(encoded);
|
||||
if( Base64_Encode_NoNl(plain, sizeof(plain), encoded, &outLen) != 0 ) {
|
||||
// error encoding input buffer
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa Base64_Encode
|
||||
\sa Base64_Decode
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int Base64_Encode_NoNl(const byte* in, word32 inLen, byte* out,
|
||||
word32* outLen);
|
||||
/*!
|
||||
\ingroup Base_Encoding
|
||||
|
||||
\brief This function decodes the given Base16 encoded input, in, and
|
||||
stores the result in the output buffer out. It also sets the size written
|
||||
to the output buffer in the variable outLen.
|
||||
|
||||
\return 0 Returned upon successfully decoding the Base16 encoded input
|
||||
\return BAD_FUNC_ARG Returned if the output buffer is too small to store
|
||||
the decoded input or if the input length is not a multiple of two
|
||||
\return ASN_INPUT_E Returned if a character in the input buffer falls
|
||||
outside of the Base16 range ([0-9A-F])
|
||||
|
||||
\param in pointer to the input buffer to decode
|
||||
\param inLen length of the input buffer to decode
|
||||
\param out pointer to the output buffer in which to store the decoded
|
||||
message
|
||||
\param outLen pointer to the length of the output buffer. Updated with the
|
||||
bytes written at the end of the function call
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte encoded[] = { // initialize text to decode };
|
||||
byte decoded[sizeof(encoded)];
|
||||
int outLen = sizeof(decoded);
|
||||
|
||||
if( Base16_Decode(encoded,sizeof(encoded), decoded, &outLen) != 0 ) {
|
||||
// error decoding input buffer
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa Base64_Encode
|
||||
\sa Base64_Decode
|
||||
\sa Base16_Encode
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int Base16_Decode(const byte* in, word32 inLen, byte* out, word32* outLen);
|
||||
/*!
|
||||
\ingroup Base_Encoding
|
||||
|
||||
\brief Encode input to base16 output.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returns if in, out, or outLen is null or if outLen is
|
||||
less than 2 times inLen plus 1.
|
||||
|
||||
\param in Pointer to input buffer to be encoded.
|
||||
\param inLen Length of input buffer.
|
||||
\param out Pointer to output buffer.
|
||||
\param outLen Length of output buffer. Is set to len of encoded output.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte in[] = { // Contents of something to be encoded };
|
||||
byte out[NECESSARY_OUTPUT_SIZE];
|
||||
word32 outSz = sizeof(out);
|
||||
|
||||
if(Base16_Encode(in, sizeof(in), out, &outSz) != 0)
|
||||
{
|
||||
// Handle encode error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa Base64_Encode
|
||||
\sa Base64_Decode
|
||||
\sa Base16_Decode
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int Base16_Encode(const byte* in, word32 inLen, byte* out, word32* outLen);
|
71
doc/dox_comments/header_files/compress.h
Normal file
71
doc/dox_comments/header_files/compress.h
Normal file
@ -0,0 +1,71 @@
|
||||
/*!
|
||||
\ingroup Compression
|
||||
|
||||
\brief This function compresses the given input data using Huffman coding
|
||||
and stores the output in out. Note that the output buffer should still be
|
||||
larger than the input buffer because there exists a certain input for
|
||||
which there will be no compression possible, which will still require a
|
||||
lookup table. It is recommended that one allocate srcSz + 0.1% + 12 for
|
||||
the output buffer.
|
||||
|
||||
\return On successfully compressing the input data, returns the number
|
||||
of bytes stored in the output buffer
|
||||
\return COMPRESS_INIT_E Returned if there is an error initializing the
|
||||
stream for compression
|
||||
\return COMPRESS_E Returned if an error occurs during compression
|
||||
|
||||
\param out pointer to the output buffer in which to store the compressed
|
||||
data
|
||||
\param outSz size available in the output buffer for storage
|
||||
\param in pointer to the buffer containing the message to compress
|
||||
\param inSz size of the input message to compress
|
||||
\param flags flags to control how compression operates. Use 0 for normal
|
||||
decompression
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte message[] = { // initialize text to compress };
|
||||
byte compressed[(sizeof(message) + sizeof(message) * .001 + 12 )];
|
||||
// Recommends at least srcSz + .1% + 12
|
||||
|
||||
if( wc_Compress(compressed, sizeof(compressed), message, sizeof(message),
|
||||
0) != 0){
|
||||
// error compressing data
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_DeCompress
|
||||
*/
|
||||
WOLFSSL_API int wc_Compress(byte*, word32, const byte*, word32, word32);
|
||||
/*!
|
||||
\ingroup Compression
|
||||
|
||||
\brief This function decompresses the given compressed data using Huffman
|
||||
coding and stores the output in out.
|
||||
|
||||
\return Succes On successfully decompressing the input data, returns the
|
||||
number of bytes stored in the output buffer
|
||||
\return COMPRESS_INIT_E: Returned if there is an error initializing the
|
||||
stream for compression
|
||||
\return COMPRESS_E: Returned if an error occurs during compression
|
||||
|
||||
\param out pointer to the output buffer in which to store the decompressed
|
||||
data
|
||||
\param outSz size available in the output buffer for storage
|
||||
\param in pointer to the buffer containing the message to decompress
|
||||
\param inSz size of the input message to decompress
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte compressed[] = { // initialize compressed message };
|
||||
byte decompressed[MAX_MESSAGE_SIZE];
|
||||
|
||||
if( wc_DeCompress(decompressed, sizeof(decompressed),
|
||||
compressed, sizeof(compressed)) != 0 ) {
|
||||
// error decompressing data
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Compress
|
||||
*/
|
||||
WOLFSSL_API int wc_DeCompress(byte*, word32, const byte*, word32);
|
678
doc/dox_comments/header_files/curve25519.h
Normal file
678
doc/dox_comments/header_files/curve25519.h
Normal file
@ -0,0 +1,678 @@
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function generates a curve25519 key using the given random
|
||||
number generator, rng, of the size given (keysize), and stores it in
|
||||
the given curve25519_key structure. It should be called after the key
|
||||
structure has been initialized through wc_curve25519_init.
|
||||
|
||||
\return 0 Returned on successfully generating the key and and storing
|
||||
it in the given curve25519_key structure
|
||||
\return ECC_BAD_ARG_E Returned if rng or key evaluate to NULL, or
|
||||
the input keysize does not correspond to the keysize for a
|
||||
curve25519 key ( 32 bytes)
|
||||
\return RNG_FAILURE_E Returned if the rng internal status is not
|
||||
DRBG_OK or if there is in generating the next random block with rng
|
||||
|
||||
\param rng pointer to the RNG object used to generate the ecc key
|
||||
\param keysize size of the key to generate. Must be 32 bytes for curve25519
|
||||
\param key pointer to the curve25519_key structure in which to
|
||||
store the generated key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
curve25519_key key;
|
||||
wc_curve25519_init(&key); // initialize key
|
||||
RNG rng;
|
||||
wc_InitRng(&rng); // initialize random number generator
|
||||
|
||||
if( wc_curve25519_make_key(&rng, 32, &key) != 0) {
|
||||
// making 25519 key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_make_key(WC_RNG* rng, int keysize, curve25519_key* key);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function computes a shared secret key given a secret private
|
||||
key and a received public key. It stores the generated secret key in the
|
||||
buffer out and assigns the variable of the secret key to outlen. Only
|
||||
supports big endian.
|
||||
|
||||
\return 0 Returned on successfully computing a shared secret key
|
||||
\return BAD_FUNC_ARG Returned if any of the input parameters passed in
|
||||
are NULL
|
||||
\return ECC_BAD_ARG_E Returned if the first bit of the public key is
|
||||
set, to avoid implementation fingerprinting
|
||||
|
||||
\param private_key pointer to the curve25519_key structure initialized
|
||||
with the user’s private key
|
||||
\param public_key pointer to the curve25519_key structure containing
|
||||
the received public key
|
||||
\param out pointer to a buffer in which to store the 32 byte computed
|
||||
secret key
|
||||
\param outlen pointer in which to store the length written to the
|
||||
output buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte sharedKey[32];
|
||||
word32 keySz;
|
||||
curve25519_key privKey, pubKey;
|
||||
// initialize both keys
|
||||
|
||||
if ( wc_curve25519_shared_secret(&privKey, &pubKey, sharedKey,
|
||||
&keySz) != 0 ) {
|
||||
// error generating shared key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_make_key
|
||||
\sa wc_curve25519_shared_secret_ex
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_shared_secret(curve25519_key* private_key,
|
||||
curve25519_key* public_key,
|
||||
byte* out, word32* outlen);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function computes a shared secret key given a secret private
|
||||
key and a received public key. It stores the generated secret key in the
|
||||
buffer out and assigns the variable of the secret key to outlen. Supports
|
||||
both big and little endian.
|
||||
|
||||
\return 0 Returned on successfully computing a shared secret key
|
||||
\return BAD_FUNC_ARG Returned if any of the input parameters passed in
|
||||
are NULL
|
||||
\return ECC_BAD_ARG_E Returned if the first bit of the public key is set,
|
||||
to avoid implementation fingerprinting
|
||||
|
||||
\param private_key pointer to the curve25519_key structure initialized
|
||||
with the user’s private key
|
||||
\param public_key pointer to the curve25519_key structure containing
|
||||
the received public key
|
||||
\param out pointer to a buffer in which to store the 32 byte computed
|
||||
secret key
|
||||
\param outlen pointer in which to store the length written to the output
|
||||
buffer
|
||||
\param endian EC25519_BIG_ENDIAN or EC25519_LITTLE_ENDIAN to set which
|
||||
form to use.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte sharedKey[32];
|
||||
word32 keySz;
|
||||
|
||||
curve25519_key privKey, pubKey;
|
||||
// initialize both keys
|
||||
|
||||
if ( wc_curve25519_shared_secret_ex(&privKey, &pubKey, sharedKey, &keySz,
|
||||
EC25519_BIG_ENDIAN) != 0 ) {
|
||||
// error generating shared key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_make_key
|
||||
\sa wc_curve25519_shared_secret
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_shared_secret_ex(curve25519_key* private_key,
|
||||
curve25519_key* public_key,
|
||||
byte* out, word32* outlen, int endian);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function initializes a curve25519 key. It should be called
|
||||
before generating a key for the structure with wc_curve25519_init and
|
||||
before using the key to encrypt data.
|
||||
|
||||
\return 0 Returned on successfully initializing the curve25519_key
|
||||
structure
|
||||
|
||||
\param key pointer to the curve25519_key structure to initialize
|
||||
|
||||
_Example_
|
||||
\code
|
||||
curve25519_key key;
|
||||
wc_curve25519_init(&key); // initialize key
|
||||
// make key and proceed to encryption
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_make_key
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_init(curve25519_key* key);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function frees a curve 25519 object.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param key pointer to the key object to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
curve25519_key privKey;
|
||||
// initialize key, use it to generate shared secret key
|
||||
wc_curve25519_free(&privKey);
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_make_key
|
||||
*/
|
||||
WOLFSSL_API
|
||||
void wc_curve25519_free(curve25519_key* key);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function imports a curve25519 private key only. (Big endian).
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returns if key or priv is null.
|
||||
\return ECC_BAD_ARG_E Returns if privSz is not equal to
|
||||
wc_curve25519_size(key).
|
||||
|
||||
\param priv Private key buffer
|
||||
\param privSz Size of private key buffer.
|
||||
\param key The curve25519_key structure to store the private key.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte priv[] = { Contents of private key };
|
||||
curve25519_key key;
|
||||
wc_curve25519_init(&key);
|
||||
|
||||
if(wc_curve25519_import_private(priv, sizeof(priv), &key) != 0)
|
||||
{
|
||||
// Some error was thrown
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_import_private_ex
|
||||
\sa wc_curve25519_size
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_import_private(const byte* priv, word32 privSz,
|
||||
curve25519_key* key);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief curve25519 private key import only. (Big or Little endian).
|
||||
|
||||
\return 0 Success
|
||||
\return Returns if key or priv is null.
|
||||
\return ECC_BAD_ARG_E Returns if privSz is not equal to
|
||||
wc_curve25519_size(key).
|
||||
|
||||
\param priv Buffer for private key.
|
||||
\param privSz Size of private key buffer.
|
||||
\param key The curve25519_key structure to store the private key.
|
||||
\param endian EC25519_BIG_ENDIAN or EC25519_LITTLE_ENDIAN to
|
||||
set which form to use.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte priv[] = { // Contents of private key };
|
||||
curve25519_key key;
|
||||
wc_curve25519_init(&key);
|
||||
|
||||
if(wc_curve25519_import_private_ex(priv, sizeof(priv), &key,
|
||||
EC25519_BIG_ENDIAN) != 0)
|
||||
{
|
||||
// Some error was thrown
|
||||
}
|
||||
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_import_private
|
||||
\sa wc_curbe25519_size
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_import_private_ex(const byte* priv, word32 privSz,
|
||||
curve25519_key* key, int endian);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function imports a public-private key pair into a
|
||||
curve25519_key structure. Big endian only.
|
||||
|
||||
\return 0 Returned on importing into the curve25519_key structure
|
||||
\return ECC_BAD_ARG_E Returned if any of the input parameters
|
||||
are NULL, or the input key’s key size does not match the public
|
||||
or private key sizes
|
||||
|
||||
\param priv pointer to a buffer containing the private key to import
|
||||
\param privSz length of the private key to import
|
||||
\param pub pointer to a buffer containing the public key to import
|
||||
\param pubSz length of the public key to import
|
||||
\param key pointer to the structure in which to store the imported keys
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
|
||||
byte priv[32];
|
||||
byte pub[32];
|
||||
// initialize with public and private keys
|
||||
curve25519_key key;
|
||||
|
||||
wc_curve25519_init(&key);
|
||||
// initialize key
|
||||
|
||||
ret = wc_curve25519_import_private_raw(&priv, sizeof(priv), pub,
|
||||
sizeof(pub),&key);
|
||||
if (ret != 0) {
|
||||
// error importing keys
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_make_key
|
||||
\sa wc_curve25519_import_public
|
||||
\sa wc_curve25519_export_private_raw
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_import_private_raw(const byte* priv, word32 privSz,
|
||||
const byte* pub, word32 pubSz, curve25519_key* key);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function imports a public-private key pair into a curve25519_key structure. Supports both big and little endian.
|
||||
|
||||
\return 0 Returned on importing into the curve25519_key structure
|
||||
\return ECC_BAD_ARG_E Returned if any of the input parameters are NULL,
|
||||
or the input key’s key size does not match the public or private key sizes
|
||||
|
||||
\param priv pointer to a buffer containing the private key to import
|
||||
\param privSz length of the private key to import
|
||||
\param pub pointer to a buffer containing the public key to import
|
||||
\param pubSz length of the public key to import
|
||||
\param key pointer to the structure in which to store the imported keys
|
||||
\param endian EC25519_BIG_ENDIAN or EC25519_LITTLE_ENDIAN to set
|
||||
which form to use.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte priv[32];
|
||||
byte pub[32];
|
||||
// initialize with public and private keys
|
||||
curve25519_key key;
|
||||
|
||||
wc_curve25519_init(&key);
|
||||
// initialize key
|
||||
|
||||
ret = wc_curve25519_import_private_raw_ex(&priv, sizeof(priv), pub,
|
||||
sizeof(pub),&key, EC25519_BIG_ENDIAN);
|
||||
if (ret != 0) {
|
||||
// error importing keys
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_make_key
|
||||
\sa wc_curve25519_import_public
|
||||
\sa wc_curve25519_export_private_rawm
|
||||
\sa wc_curve25519_import_private_raw
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_import_private_raw_ex(const byte* priv, word32 privSz,
|
||||
const byte* pub, word32 pubSz,
|
||||
curve25519_key* key, int endian);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function exports a private key from a curve25519_key structure
|
||||
and stores it in the given out buffer. It also sets outLen to be the size
|
||||
of the exported key. Big Endian only.
|
||||
|
||||
\return 0 Returned on successfully exporting the private key from the
|
||||
curve25519_key structure
|
||||
\return BAD_FUNC_ARG Returned if any input parameters are NULL.
|
||||
\return ECC_BAD_ARG_E Returned if wc_curve25519_size() is not equal to key.
|
||||
|
||||
\param key pointer to the structure from which to export the key
|
||||
\param out pointer to the buffer in which to store the exported key
|
||||
\param outLen will store the bytes written to the output buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte priv[32];
|
||||
int privSz;
|
||||
|
||||
curve25519_key key;
|
||||
// initialize and make key
|
||||
|
||||
ret = wc_curve25519_export_private_raw(&key, priv, &privSz);
|
||||
if (ret != 0) {
|
||||
// error exporting key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_make_key
|
||||
\sa wc_curve25519_import_private_raw
|
||||
\sa wc_curve25519_export_private_raw_ex
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_export_private_raw(curve25519_key* key, byte* out,
|
||||
word32* outLen);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function exports a private key from a curve25519_key structure
|
||||
and stores it in the given out buffer. It also sets outLen to be the size
|
||||
of the exported key. Can specify whether it's big or little endian.
|
||||
|
||||
\return 0 Returned on successfully exporting the private key from the
|
||||
curve25519_key structure
|
||||
\return BAD_FUNC_ARG Returned if any input parameters are NULL.
|
||||
\return ECC_BAD_ARG_E Returned if wc_curve25519_size() is not equal to key.
|
||||
|
||||
\param key pointer to the structure from which to export the key
|
||||
\param out pointer to the buffer in which to store the exported key
|
||||
\param outLen will store the bytes written to the output buffer
|
||||
\param endian EC25519_BIG_ENDIAN or EC25519_LITTLE_ENDIAN to set which
|
||||
form to use.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
|
||||
byte priv[32];
|
||||
int privSz;
|
||||
curve25519_key key;
|
||||
// initialize and make key
|
||||
ret = wc_curve25519_export_private_raw_ex(&key, priv, &privSz,
|
||||
EC25519_BIG_ENDIAN);
|
||||
if (ret != 0) {
|
||||
// error exporting key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_make_key
|
||||
\sa wc_curve25519_import_private_raw
|
||||
\sa wc_curve25519_export_private_raw
|
||||
\sa wc_curve25519_size
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_export_private_raw_ex(curve25519_key* key, byte* out,
|
||||
word32* outLen, int endian);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function imports a public key from the given in buffer and
|
||||
stores it in the curve25519_key structure.
|
||||
|
||||
\return 0 Returned on successfully importing the public key into the
|
||||
curve25519_key structure
|
||||
\return ECC_BAD_ARG_E Returned if any of the input parameters are NULL,
|
||||
or if the inLen
|
||||
parameter does not match the key size of the key structure.
|
||||
\return BAD_FUNC_ARG Returned if any of the input parameters are NULL.
|
||||
|
||||
\param in pointer to the buffer containing the public key to import
|
||||
\param inLen length of the public key to import
|
||||
\param key pointer to the curve25519_key structure in which to store
|
||||
the key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
|
||||
byte pub[32];
|
||||
// initialize pub with public key
|
||||
|
||||
curve25519_key key;
|
||||
// initialize key
|
||||
|
||||
ret = wc_curve25519_import_public(pub,sizeof(pub), &key);
|
||||
if (ret != 0) {
|
||||
// error exporting key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_export_public
|
||||
\sa wc_curve25519_import_private_raw
|
||||
\sa wc_curve25519_public_ex
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_import_public(const byte* in, word32 inLen,
|
||||
curve25519_key* key);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function imports a public key from the given in buffer and
|
||||
stores it in the curve25519_key structure.
|
||||
|
||||
\brief 0 Returned on successfully importing the public key into the
|
||||
curve25519_key structure
|
||||
\brief ECC_BAD_ARG_E Returned if the inLen parameter does not match the
|
||||
key size of the key structure
|
||||
\brief BAD_FUNC_ARG Returned if any of the input parameters are NULL.
|
||||
|
||||
\param in pointer to the buffer containing the public key to import
|
||||
\param inLen length of the public key to import
|
||||
\param key pointer to the curve25519_key structure in which to store
|
||||
the key
|
||||
\param endian EC25519_BIG_ENDIAN or EC25519_LITTLE_ENDIAN to set which
|
||||
form to use.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte pub[32];
|
||||
// initialize pub with public key
|
||||
curve25519_key key;
|
||||
// initialize key
|
||||
|
||||
ret = wc_curve25519_import_public_ex(pub,sizeof(pub), &key,
|
||||
EC25519_BIG_ENDIAN);
|
||||
if (ret != 0) {
|
||||
// error exporting key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_export_public
|
||||
\sa wc_curve25519_import_private_raw
|
||||
\sa wc_curve25519_import_public
|
||||
\sa wc_25519_size
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_import_public_ex(const byte* in, word32 inLen,
|
||||
curve25519_key* key, int endian);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function exports a public key from the given key structure and
|
||||
stores the result in the out buffer. Big endian only.
|
||||
|
||||
\return 0 Returned on successfully exporting the public key from the
|
||||
curve25519_key structure
|
||||
\return ECC_BAD_ARG_E Returned if any of the input parameters are NULL
|
||||
|
||||
\param key pointer to the curve25519_key structure in from which to
|
||||
export the key
|
||||
\param out pointer to the buffer in which to store the public key
|
||||
\param outLen will store the bytes written to the output buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte pub[32];
|
||||
int pubSz;
|
||||
curve25519_key key;
|
||||
// initialize and make key
|
||||
ret = wc_curve25519_export_public(&key,pub, &pubSz);
|
||||
if (ret != 0) {
|
||||
// error exporting key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_export_private_raw
|
||||
\sa wc_curve25519_import_public
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_export_public(curve25519_key* key, byte* out, word32* outLen);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function exports a public key from the given key structure and
|
||||
stores the result in the out buffer. Supports both big and little endian.
|
||||
|
||||
\return 0 Returned on successfully exporting the public key from the
|
||||
curve25519_key structure
|
||||
\return ECC_BAD_ARG_E Returned if any of the input parameters are NULL
|
||||
|
||||
\param key pointer to the curve25519_key structure in from which to
|
||||
export the key
|
||||
\param out pointer to the buffer in which to store the public key
|
||||
\param outLen will store the bytes written to the output buffer
|
||||
\param endian EC25519_BIG_ENDIAN or EC25519_LITTLE_ENDIAN to set which
|
||||
form to use.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
|
||||
byte pub[32];
|
||||
int pubSz;
|
||||
curve25519_key key;
|
||||
// initialize and make key
|
||||
|
||||
ret = wc_curve25519_export_public_ex(&key,pub, &pubSz, EC25519_BIG_ENDIAN);
|
||||
if (ret != 0) {
|
||||
// error exporting key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_export_private_raw
|
||||
\sa wc_curve25519_import_public
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_export_public_ex(curve25519_key* key, byte* out,
|
||||
word32* outLen, int endian);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief Export curve25519 key pair. Big endian only.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returned if any input parameters are NULL.
|
||||
\return ECC_BAD_ARG_E Returned if wc_curve25519_size() is not equal to key.
|
||||
|
||||
\param key Description
|
||||
\param priv Private key buffer.
|
||||
\param privSz Size of private key buffer.
|
||||
\param pub Public key buffer.
|
||||
\param pubSz Size of public key buffer.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte pub[32];
|
||||
byte priv[32];
|
||||
int pubSz;
|
||||
int privSz;
|
||||
|
||||
curve25519_key key;
|
||||
// initialize and make key
|
||||
|
||||
ret = wc_curve25519_export_key_raw(&key, priv, &privSz, pub, &pubSz);
|
||||
if (ret != 0) {
|
||||
// error exporting key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_export_key_raw_ex
|
||||
\sa wc_curve25519_export_private_raw
|
||||
\sa wc_curve25519_export_public_raw
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_export_key_raw(curve25519_key* key,
|
||||
byte* priv, word32 *privSz,
|
||||
byte* pub, word32 *pubSz);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief Export curve25519 key pair. Big or little endian.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returned if any input parameters are NULL.
|
||||
\return ECC_BAD_ARG_E Returned if wc_curve25519_size() is not equal to key.
|
||||
|
||||
\param key Description
|
||||
\param priv Private key buffer.
|
||||
\param privSz Size of private key buffer.
|
||||
\param pub Public key buffer.
|
||||
\param pubSz Size of public key buffer.
|
||||
\param endian EC25519_BIG_ENDIAN or EC25519_LITTLE_ENDIAN to set which
|
||||
form to use.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
|
||||
byte pub[32];
|
||||
byte priv[32];
|
||||
int pubSz;
|
||||
int privSz;
|
||||
|
||||
curve25519_key key;
|
||||
// initialize and make key
|
||||
|
||||
ret = wc_curve25519_export_key_raw_ex(&key,priv, &privSz, pub, &pubSz,
|
||||
EC25519_BIG_ENDIAN);
|
||||
if (ret != 0) {
|
||||
// error exporting key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_export_key_raw
|
||||
\sa wc_curve25519_export_private_raw_ex
|
||||
\sa wc_curve25519_export_public_ex
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_export_key_raw_ex(curve25519_key* key,
|
||||
byte* priv, word32 *privSz,
|
||||
byte* pub, word32 *pubSz,
|
||||
int endian);
|
||||
/*!
|
||||
\ingroup Curve25519
|
||||
|
||||
\brief This function returns the key size of the given key structure.
|
||||
|
||||
\return Success Given a valid, initialized curve25519_key structure,
|
||||
returns the size of the key.
|
||||
\return 0 Returned if key is NULL
|
||||
|
||||
\param key pointer to the curve25519_key structure in for which to
|
||||
determine the key size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
curve25519_key key;
|
||||
// initialize and make key
|
||||
int keySz;
|
||||
keySz = wc_curve25519_size(&key);
|
||||
\endcode
|
||||
|
||||
\sa wc_curve25519_init
|
||||
\sa wc_curve25519_make_key
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_curve25519_size(curve25519_key* key);
|
323
doc/dox_comments/header_files/des3.h
Normal file
323
doc/dox_comments/header_files/des3.h
Normal file
@ -0,0 +1,323 @@
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function sets the key and initialization vector (iv) for the
|
||||
Des structure given as argument. It also initializes and allocates space
|
||||
for the buffers needed for encryption and decryption, if these have not
|
||||
yet been initialized. Note: If no iv is provided (i.e. iv == NULL)
|
||||
the initialization vector defaults to an iv of 0.
|
||||
|
||||
\return 0 On successfully setting the key and initialization vector for
|
||||
the Des structure
|
||||
|
||||
\param des pointer to the Des structure to initialize
|
||||
\param key pointer to the buffer containing the 8 byte key with which to
|
||||
initialize the Des structure
|
||||
\param iv pointer to the buffer containing the 8 byte iv with which to
|
||||
initialize the Des structure. If this is not provided, the iv defaults to 0
|
||||
\param dir direction of encryption. Valid options are: DES_ENCRYPTION,
|
||||
and DES_DECRYPTION
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des enc; // Des structure used for encryption
|
||||
int ret;
|
||||
byte key[] = { // initialize with 8 byte key };
|
||||
byte iv[] = { // initialize with 8 byte iv };
|
||||
|
||||
ret = wc_Des_SetKey(&des, key, iv, DES_ENCRYPTION);
|
||||
if (ret != 0) {
|
||||
// error initializing des structure
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des_SetIV
|
||||
\sa wc_Des3_SetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_Des_SetKey(Des* des, const byte* key,
|
||||
const byte* iv, int dir);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function sets the initialization vector (iv) for the Des
|
||||
structure given as argument. When passed a NULL iv, it sets the
|
||||
initialization vector to 0.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param des pointer to the Des structure for which to set the iv
|
||||
\param iv pointer to the buffer containing the 8 byte iv with which to
|
||||
initialize the Des structure. If this is not provided, the iv defaults to 0
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des enc; // Des structure used for encryption
|
||||
// initialize enc with wc_Des_SetKey
|
||||
byte iv[] = { // initialize with 8 byte iv };
|
||||
wc_Des_SetIV(&enc, iv);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des_SetKey
|
||||
*/
|
||||
WOLFSSL_API void wc_Des_SetIV(Des* des, const byte* iv);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function encrypts the input message, in, and stores the result
|
||||
in the output buffer, out. It uses DES encryption with cipher block
|
||||
chaining (CBC) mode.
|
||||
|
||||
\return 0 Returned upon successfully encrypting the given input message
|
||||
|
||||
\param des pointer to the Des structure to use for encryption
|
||||
\param out pointer to the buffer in which to store the encrypted ciphertext
|
||||
\param in pointer to the input buffer containing the message to encrypt
|
||||
\param sz length of the message to encrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des enc; // Des structure used for encryption
|
||||
// initialize enc with wc_Des_SetKey, use mode DES_ENCRYPTION
|
||||
|
||||
byte plain[] = { // initialize with message };
|
||||
byte cipher[sizeof(plain)];
|
||||
|
||||
if ( wc_Des_CbcEncrypt(&enc, cipher, plain, sizeof(plain)) != 0) {
|
||||
// error encrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des_SetKey
|
||||
\sa wc_Des_CbcDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_Des_CbcEncrypt(Des* des, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function decrypts the input ciphertext, in, and stores the
|
||||
resulting plaintext in the output buffer, out. It uses DES encryption
|
||||
with cipher block chaining (CBC) mode.
|
||||
|
||||
\return 0 Returned upon successfully decrypting the given ciphertext
|
||||
|
||||
\param des pointer to the Des structure to use for decryption
|
||||
\param out pointer to the buffer in which to store the decrypted plaintext
|
||||
\param in pointer to the input buffer containing the encrypted ciphertext
|
||||
\param sz length of the ciphertext to decrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des dec; // Des structure used for decryption
|
||||
// initialize dec with wc_Des_SetKey, use mode DES_DECRYPTION
|
||||
|
||||
byte cipher[] = { // initialize with ciphertext };
|
||||
byte decoded[sizeof(cipher)];
|
||||
|
||||
if ( wc_Des_CbcDecrypt(&dec, decoded, cipher, sizeof(cipher)) != 0) {
|
||||
// error decrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des_SetKey
|
||||
\sa wc_Des_CbcEncrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_Des_CbcDecrypt(Des* des, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function encrypts the input message, in, and stores the result
|
||||
in the output buffer, out. It uses Des encryption with Electronic
|
||||
Codebook (ECB) mode.
|
||||
|
||||
\return 0: Returned upon successfully encrypting the given plaintext.
|
||||
|
||||
\param des pointer to the Des structure to use for encryption
|
||||
\param out pointer to the buffer in which to store the encrypted message
|
||||
\param in pointer to the input buffer containing the plaintext to encrypt
|
||||
\param sz length of the plaintext to encrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des enc; // Des structure used for encryption
|
||||
// initialize enc with wc_Des_SetKey, use mode DES_ENCRYPTION
|
||||
|
||||
byte plain[] = { // initialize with message to encrypt };
|
||||
byte cipher[sizeof(plain)];
|
||||
|
||||
if ( wc_Des_EcbEncrypt(&enc,cipher, plain, sizeof(plain)) != 0) {
|
||||
// error encrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des_SetKe
|
||||
*/
|
||||
WOLFSSL_API int wc_Des_EcbEncrypt(Des* des, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function encrypts the input message, in, and stores the
|
||||
result in the output buffer, out. It uses Des3 encryption with
|
||||
Electronic Codebook (ECB) mode. Warning: In nearly all use cases ECB
|
||||
mode is considered to be less secure. Please avoid using ECB API’s
|
||||
directly whenever possible.
|
||||
|
||||
\return 0 Returned upon successfully encrypting the given plaintext
|
||||
|
||||
\param des3 pointer to the Des3 structure to use for encryption
|
||||
\param out pointer to the buffer in which to store the encrypted message
|
||||
\param in pointer to the input buffer containing the plaintext to encrypt
|
||||
\param sz length of the plaintext to encrypt
|
||||
|
||||
_Example_
|
||||
/code
|
||||
Des3 enc; // Des3 structure used for encryption
|
||||
// initialize enc with wc_Des3_SetKey, use mode DES_ENCRYPTION
|
||||
|
||||
byte plain[] = { // initialize with message to encrypt };
|
||||
byte cipher[sizeof(plain)];
|
||||
|
||||
if ( wc_Des3_EcbEncrypt(&enc,cipher, plain, sizeof(plain)) != 0) {
|
||||
// error encrypting message
|
||||
}
|
||||
/endcode
|
||||
|
||||
\sa wc_Des3_SetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_Des3_EcbEncrypt(Des3* des, byte* out,
|
||||
const byte* in, word32 sz);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function sets the key and initialization vector (iv) for
|
||||
the Des3 structure given as argument. It also initializes and allocates
|
||||
space for the buffers needed for encryption and decryption, if these
|
||||
have not yet been initialized. Note: If no iv is provided (i.e. iv ==
|
||||
NULL) the initialization vector defaults to an iv of 0.
|
||||
|
||||
\return 0 On successfully setting the key and initialization vector
|
||||
for the Des structure
|
||||
|
||||
\param des3 pointer to the Des3 structure to initialize
|
||||
\param key pointer to the buffer containing the 24 byte key with which
|
||||
to initialize the Des3 structure
|
||||
\param iv pointer to the buffer containing the 8 byte iv with which to
|
||||
initialize the Des3 structure. If this is not provided, the iv defaults
|
||||
to 0
|
||||
\param dir direction of encryption. Valid options are: DES_ENCRYPTION,
|
||||
and DES_DECRYPTION
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des3 enc; // Des3 structure used for encryption
|
||||
int ret;
|
||||
byte key[] = { // initialize with 24 byte key };
|
||||
byte iv[] = { // initialize with 8 byte iv };
|
||||
|
||||
ret = wc_Des3_SetKey(&des, key, iv, DES_ENCRYPTION);
|
||||
if (ret != 0) {
|
||||
// error initializing des structure
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des3_SetIV
|
||||
\sa wc_Des3_CbcEncrypt
|
||||
\sa wc_Des3_CbcDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_Des3_SetKey(Des3* des, const byte* key,
|
||||
const byte* iv,int dir);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function sets the initialization vector (iv) for the Des3
|
||||
structure given as argument. When passed a NULL iv, it sets the
|
||||
initialization vector to 0.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param des pointer to the Des3 structure for which to set the iv
|
||||
\param iv pointer to the buffer containing the 8 byte iv with which to
|
||||
initialize the Des3 structure. If this is not provided, the iv
|
||||
defaults to 0
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des3 enc; // Des3 structure used for encryption
|
||||
// initialize enc with wc_Des3_SetKey
|
||||
|
||||
byte iv[] = { // initialize with 8 byte iv };
|
||||
|
||||
wc_Des3_SetIV(&enc, iv);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des3_SetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_Des3_SetIV(Des3* des, const byte* iv);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function encrypts the input message, in, and stores the
|
||||
result in the output buffer, out. It uses Triple Des (3DES) encryption
|
||||
with cipher block chaining (CBC) mode.
|
||||
|
||||
\return 0 Returned upon successfully encrypting the given input message
|
||||
|
||||
\param des pointer to the Des3 structure to use for encryption
|
||||
\param out pointer to the buffer in which to store the encrypted ciphertext
|
||||
\param in pointer to the input buffer containing the message to encrypt
|
||||
\param sz length of the message to encrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des3 enc; // Des3 structure used for encryption
|
||||
// initialize enc with wc_Des3_SetKey, use mode DES_ENCRYPTION
|
||||
|
||||
byte plain[] = { // initialize with message };
|
||||
byte cipher[sizeof(plain)];
|
||||
|
||||
if ( wc_Des3_CbcEncrypt(&enc, cipher, plain, sizeof(plain)) != 0) {
|
||||
// error encrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des3_SetKey
|
||||
\sa wc_Des3_CbcDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_Des3_CbcEncrypt(Des3* des, byte* out,
|
||||
const byte* in,word32 sz);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function decrypts the input ciphertext, in, and stores the
|
||||
resulting plaintext in the output buffer, out. It uses Triple Des (3DES)
|
||||
encryption with cipher block chaining (CBC) mode.
|
||||
|
||||
\return 0 Returned upon successfully decrypting the given ciphertext
|
||||
|
||||
\param des pointer to the Des3 structure to use for decryption
|
||||
\param out pointer to the buffer in which to store the decrypted plaintext
|
||||
\param in pointer to the input buffer containing the encrypted ciphertext
|
||||
\param sz length of the ciphertext to decrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Des3 dec; // Des structure used for decryption
|
||||
// initialize dec with wc_Des3_SetKey, use mode DES_DECRYPTION
|
||||
|
||||
byte cipher[] = { // initialize with ciphertext };
|
||||
byte decoded[sizeof(cipher)];
|
||||
|
||||
if ( wc_Des3_CbcDecrypt(&dec, decoded, cipher, sizeof(cipher)) != 0) {
|
||||
// error decrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des3_SetKey
|
||||
\sa wc_Des3_CbcEncrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_Des3_CbcDecrypt(Des3* des, byte* out,
|
||||
const byte* in,word32 sz);
|
267
doc/dox_comments/header_files/dh.h
Normal file
267
doc/dox_comments/header_files/dh.h
Normal file
@ -0,0 +1,267 @@
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
|
||||
\brief This function initializes a Diffie-Hellman key for use in
|
||||
negotiating a secure secret key with the Diffie-Hellman exchange protocol.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param key pointer to the DhKey structure to initialize for use with
|
||||
secure key exchanges
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
wc_InitDhKey(&key); // initialize DH key
|
||||
\endcode
|
||||
|
||||
\sa wc_FreeDhKey
|
||||
\sa wc_DhGenerateKeyPair
|
||||
*/
|
||||
WOLFSSL_API int wc_InitDhKey(DhKey* key);
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
|
||||
\brief This function frees a Diffie-Hellman key after it has been used to
|
||||
negotiate a secure secret key with the Diffie-Hellman exchange protocol.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param key pointer to the DhKey structure to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
// initialize key, perform key exchange
|
||||
|
||||
wc_FreeDhKey(&key); // free DH key to avoid memory leaks
|
||||
\endcode
|
||||
|
||||
\sa wc_InitDhKey
|
||||
*/
|
||||
WOLFSSL_API void wc_FreeDhKey(DhKey* key);
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
|
||||
\brief This function generates a public/private key pair based on the
|
||||
Diffie-Hellman public parameters, storing the private key in priv and the
|
||||
public key in pub. It takes an initialized Diffie-Hellman key and an
|
||||
initialized rng structure.
|
||||
|
||||
\return BAD_FUNC_ARG Returned if there is an error parsing one of the
|
||||
inputs to this function
|
||||
\return RNG_FAILURE_E Returned if there is an error generating a random
|
||||
number using rng
|
||||
\return MP_INIT_E May be returned if there is an error in the math library
|
||||
while generating the public key
|
||||
\return MP_READ_E May be returned if there is an error in the math library
|
||||
while generating the public key
|
||||
\return MP_EXPTMOD_E May be returned if there is an error in the math
|
||||
library while generating the public key
|
||||
\return MP_TO_E May be returned if there is an error in the math library
|
||||
while generating the public key
|
||||
|
||||
\param key pointer to the DhKey structure from which to generate
|
||||
the key pair
|
||||
\param rng pointer to an initialized random number generator (rng) with
|
||||
which to generate the keys
|
||||
\param priv pointer to a buffer in which to store the private key
|
||||
\param privSz will store the size of the private key written to priv
|
||||
\param pub pointer to a buffer in which to store the public key
|
||||
\param pubSz will store the size of the private key written to pub
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
int ret;
|
||||
byte priv[256];
|
||||
byte pub[256];
|
||||
word32 privSz, pubSz;
|
||||
|
||||
wc_InitDhKey(&key); // initialize key
|
||||
// Set DH parameters using wc_DhSetKey or wc_DhKeyDecode
|
||||
RNG rng;
|
||||
wc_InitRng(&rng); // initialize rng
|
||||
ret = wc_DhGenerateKeyPair(&key, &rng, priv, &privSz, pub, &pubSz);
|
||||
\endcode
|
||||
|
||||
\sa wc_InitDhKey
|
||||
\sa wc_DhSetKey
|
||||
\sa wc_DhKeyDecode
|
||||
*/
|
||||
WOLFSSL_API int wc_DhGenerateKeyPair(DhKey* key, WC_RNG* rng, byte* priv,
|
||||
word32* privSz, byte* pub, word32* pubSz);
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
|
||||
\brief This function generates an agreed upon secret key based on a local
|
||||
private key and a received public key. If completed on both sides of an
|
||||
exchange, this function generates an agreed upon secret key for symmetric
|
||||
communication. On successfully generating a shared secret key, the size of
|
||||
the secret key written will be stored in agreeSz.
|
||||
|
||||
\return 0 Returned on successfully generating an agreed upon secret key
|
||||
\return MP_INIT_E May be returned if there is an error while generating
|
||||
the shared secret key
|
||||
\return MP_READ_E May be returned if there is an error while generating
|
||||
the shared secret key
|
||||
\return MP_EXPTMOD_E May be returned if there is an error while generating
|
||||
the shared secret key
|
||||
\return MP_TO_E May be returned if there is an error while generating the
|
||||
shared secret key
|
||||
|
||||
\param key pointer to the DhKey structure to use to compute the shared key
|
||||
\param agree pointer to the buffer in which to store the secret key
|
||||
\param agreeSz will hold the size of the secret key after
|
||||
successful generation
|
||||
\param priv pointer to the buffer containing the local secret key
|
||||
\param privSz size of the local secret key
|
||||
\param otherPub pointer to a buffer containing the received public key
|
||||
\param pubSz size of the received public key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
int ret;
|
||||
byte priv[256];
|
||||
byte agree[256];
|
||||
word32 agreeSz;
|
||||
|
||||
// initialize key, set key prime and base
|
||||
// wc_DhGenerateKeyPair -- store private key in priv
|
||||
byte pub[] = { // initialized with the received public key };
|
||||
ret = wc_DhAgree(&key, agree, &agreeSz, priv, sizeof(priv), pub,
|
||||
sizeof(pub));
|
||||
if ( ret != 0 ) {
|
||||
// error generating shared key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_DhGenerateKeyPair
|
||||
*/
|
||||
WOLFSSL_API int wc_DhAgree(DhKey* key, byte* agree, word32* agreeSz,
|
||||
const byte* priv, word32 privSz, const byte* otherPub,
|
||||
word32 pubSz);
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
|
||||
\brief This function decodes a Diffie-Hellman key from the given input
|
||||
buffer containing the key in DER format. It stores the result in the
|
||||
DhKey structure.
|
||||
|
||||
\return 0 Returned on successfully decoding the input key
|
||||
\return ASN_PARSE_E Returned if there is an error parsing the sequence
|
||||
of the input
|
||||
\return ASN_DH_KEY_E Returned if there is an error reading the private
|
||||
key parameters from the parsed input
|
||||
|
||||
\param input pointer to the buffer containing the DER formatted
|
||||
Diffie-Hellman key
|
||||
\param inOutIdx pointer to an integer in which to store the index parsed
|
||||
to while decoding the key
|
||||
\param key pointer to the DhKey structure to initialize with the input key
|
||||
\param inSz length of the input buffer. Gives the max length that may
|
||||
be read
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
word32 idx = 0;
|
||||
|
||||
byte keyBuff[1024];
|
||||
// initialize with DER formatted key
|
||||
wc_DhKeyInit(&key);
|
||||
ret = wc_DhKeyDecode(keyBuff, &idx, &key, sizeof(keyBuff));
|
||||
|
||||
if ( ret != 0 ) {
|
||||
// error decoding key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_DhSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_DhKeyDecode(const byte* input, word32* inOutIdx, DhKey* key,
|
||||
word32);
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
|
||||
\brief This function sets the key for a DhKey structure using the input
|
||||
private key parameters. Unlike wc_DhKeyDecode, this function does not
|
||||
require that the input key be formatted in DER format, and instead simply
|
||||
accepts the parsed input parameters p (prime) and g (base).
|
||||
|
||||
\return 0 Returned on successfully setting the key
|
||||
\return BAD_FUNC_ARG Returned if any of the input parameters
|
||||
evaluate to NULL
|
||||
\return MP_INIT_E Returned if there is an error initializing the key
|
||||
parameters for storage
|
||||
\return ASN_DH_KEY_E Returned if there is an error reading in the
|
||||
DH key parameters p and g
|
||||
|
||||
\param key pointer to the DhKey structure on which to set the key
|
||||
\param p pointer to the buffer containing the prime for use with the key
|
||||
\param pSz length of the input prime
|
||||
\param g pointer to the buffer containing the base for use with the key
|
||||
\param gSz length of the input base
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DhKey key;
|
||||
|
||||
byte p[] = { // initialize with prime };
|
||||
byte g[] = { // initialize with base };
|
||||
wc_DhKeyInit(&key);
|
||||
ret = wc_DhSetKey(key, p, sizeof(p), g, sizeof(g));
|
||||
|
||||
if ( ret != 0 ) {
|
||||
// error setting key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_DhKeyDecode
|
||||
*/
|
||||
WOLFSSL_API int wc_DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
|
||||
word32 gSz);
|
||||
/*!
|
||||
\ingroup Diffie-Hellman
|
||||
|
||||
\brief This function loads the Diffie-Hellman parameters, p (prime)
|
||||
and g (base) out of the given input buffer, DER formatted.
|
||||
|
||||
\return 0 Returned on successfully extracting the DH parameters
|
||||
\return ASN_PARSE_E Returned if an error occurs while parsing the DER
|
||||
formatted DH certificate
|
||||
\return BUFFER_E Returned if there is inadequate space in p or g to
|
||||
store the parsed parameters
|
||||
|
||||
\parma input pointer to a buffer containing a DER formatted
|
||||
Diffie-Hellman certificate to parse
|
||||
\parma inSz size of the input buffer
|
||||
\parma p pointer to a buffer in which to store the parsed prime
|
||||
\parma pInOutSz pointer to a word32 object containing the available
|
||||
size in the p buffer. Will be overwritten with the number of bytes
|
||||
written to the buffer after completing the function call
|
||||
\parma g pointer to a buffer in which to store the parsed base
|
||||
\parma gInOutSz pointer to a word32 object containing the available size
|
||||
in the g buffer. Will be overwritten with the number of bytes written to
|
||||
the buffer after completing the function call
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte dhCert[] = { initialize with DER formatted certificate };
|
||||
byte p[MAX_DH_SIZE];
|
||||
byte g[MAX_DH_SIZE];
|
||||
word32 pSz = MAX_DH_SIZE;
|
||||
word32 gSz = MAX_DH_SIZE;
|
||||
|
||||
ret = wc_DhParamsLoad(dhCert, sizeof(dhCert), p, &pSz, g, &gSz);
|
||||
if ( ret != 0 ) {
|
||||
// error parsing inputs
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_DhSetKey
|
||||
\sa wc_DhKeyDecode
|
||||
*/
|
||||
WOLFSSL_API int wc_DhParamsLoad(const byte* input, word32 inSz, byte* p,
|
||||
word32* pInOutSz, byte* g, word32* gInOutSz);
|
47
doc/dox_comments/header_files/doxygen_groups.h
Normal file
47
doc/dox_comments/header_files/doxygen_groups.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*!
|
||||
\defgroup 3DES Algorithms - 3DES
|
||||
\defgroup AES Algorithms - AES
|
||||
\defgroup ARC4 Algorithms - ARC4
|
||||
\defgroup BLAKE2 Algorithms - BLAKE2
|
||||
\defgroup Camellia Algorithms - Camellia
|
||||
\defgroup ChaCha Algorithms - ChaCha
|
||||
\defgroup ChaCha20Poly1305 Algorithms - ChaCha20_Poly1305
|
||||
\defgroup Curve25519 Algorithms - Curve25519
|
||||
\defgroup DSA Algorithms - DSA
|
||||
\defgroup Diffie-Hellman Algorithms - Diffie-Hellman
|
||||
\defgroup ECC Algorithms - ECC
|
||||
\defgroup ED25519 Algorithms - ED25519
|
||||
\defgroup HC128 Algorithms - HC-128
|
||||
\defgroup HMAC Algorithms - HMAC
|
||||
\defgroup IDEA Algorithms - IDEA
|
||||
\defgroup MD2 Algorithms - MD2
|
||||
\defgroup MD4 Algorithms - MD4
|
||||
\defgroup MD5 Algorithms - MD5
|
||||
\defgroup PKCS7 Algorithms - PKCS7
|
||||
\defgroup Password Algorithms - Password Based
|
||||
\defgroup Poly1305 Algorithms - Poly1305
|
||||
\defgroup RIPEMD Algorithms - RIPEMD
|
||||
\defgroup RSA Algorithms - RSA
|
||||
\defgroup Rabbit Algorithms - Rabbit
|
||||
\defgroup SHA Algorithms - SHA 128/224/256/384/512
|
||||
\defgroup SRP Algorithms - SRP
|
||||
|
||||
\defgroup ASN ASN.1
|
||||
\defgroup Base_Encoding Base Encoding
|
||||
\defgroup CertManager CertManager API
|
||||
\defgroup Compression Compression
|
||||
\defgroup Error Error Reporting
|
||||
\defgroup Keys Key and Cert Conversion
|
||||
\defgroup Logging Logging
|
||||
\defgroup Math Math API
|
||||
\defgroup Memory Memory Handling
|
||||
\defgroup Random Random Number Generation
|
||||
\defgroup Signature Signature API
|
||||
\defgroup openSSL OpenSSL API
|
||||
\defgroup wolfCrypt wolfCrypt Init and Cleanup
|
||||
\defgroup TLS wolfSSL Initialization/Shutdown
|
||||
\defgroup CertsKeys wolfSSL Certificates and Keys
|
||||
\defgroup Setup wolfSSL Context and Session Set Up
|
||||
\defgroup IO wolfSSL Connection, Session, and I/O
|
||||
\defgroup Debug wolfSSL Error Handling and Reporting
|
||||
*/
|
334
doc/dox_comments/header_files/dsa.h
Normal file
334
doc/dox_comments/header_files/dsa.h
Normal file
@ -0,0 +1,334 @@
|
||||
/*!
|
||||
\ingroup DSA
|
||||
|
||||
\brief This function initializes a DsaKey object in order to use it for
|
||||
authentication via the Digital Signature Algorithm (DSA).
|
||||
|
||||
\return 0 Returned on success.
|
||||
\return BAD_FUNC_ARG Returned if a NULL key is passed in.
|
||||
|
||||
\param key pointer to the DsaKey structure to initialize
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DsaKey key;
|
||||
int ret;
|
||||
ret = wc_InitDsaKey(&key); // initialize DSA key
|
||||
\endcode
|
||||
|
||||
\sa wc_FreeDsaKey
|
||||
*/
|
||||
WOLFSSL_API int wc_InitDsaKey(DsaKey* key);
|
||||
/*!
|
||||
\ingroup DSA
|
||||
|
||||
\brief This function frees a DsaKey object after it has been used.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param key pointer to the DsaKey structure to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DsaKey key;
|
||||
// initialize key, use for authentication
|
||||
...
|
||||
wc_FreeDsaKey(&key); // free DSA key
|
||||
\endcode
|
||||
|
||||
\sa wc_FreeDsaKey
|
||||
*/
|
||||
WOLFSSL_API void wc_FreeDsaKey(DsaKey* key);
|
||||
/*!
|
||||
\ingroup DSA
|
||||
|
||||
\brief This function signs the input digest and stores the result in the
|
||||
output buffer, out.
|
||||
|
||||
\return 0 Returned on successfully signing the input digest
|
||||
\return MP_INIT_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_READ_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_CMP_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_INVMOD_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_EXPTMOD_E may be returned if there is an error in processing
|
||||
the DSA signature.
|
||||
\return MP_MOD_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_MUL_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_ADD_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_MULMOD_E may be returned if there is an error in processing
|
||||
the DSA signature.
|
||||
\return MP_TO_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_MEM may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
|
||||
\param digest pointer to the hash to sign
|
||||
\param out pointer to the buffer in which to store the signature
|
||||
\param key pointer to the initialized DsaKey structure with which to
|
||||
generate the signature
|
||||
\param rng pointer to an initialized RNG to use with the signature
|
||||
generation
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DsaKey key;
|
||||
// initialize DSA key, load private Key
|
||||
int ret;
|
||||
RNG rng;
|
||||
wc_InitRng(&rng);
|
||||
byte hash[] = { // initialize with hash digest };
|
||||
byte signature[40]; // signature will be 40 bytes (320 bits)
|
||||
|
||||
ret = wc_DsaSign(hash, signature, &key, &rng);
|
||||
if (ret != 0) {
|
||||
// error generating DSA signature
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_DsaVerify
|
||||
*/
|
||||
WOLFSSL_API int wc_DsaSign(const byte* digest, byte* out,
|
||||
DsaKey* key, WC_RNG* rng);
|
||||
/*!
|
||||
\ingroup DSA
|
||||
|
||||
\brief This function verifies the signature of a digest, given a private
|
||||
key. It stores whether the key properly verifies in the answer parameter,
|
||||
with 1 corresponding to a successful verification, and 0 corresponding to
|
||||
failed verification.
|
||||
|
||||
\return 0 Returned on successfully processing the verify request. Note:
|
||||
this does not mean that the signature is verified, only that the function
|
||||
succeeded
|
||||
\return MP_INIT_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_READ_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_CMP_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_INVMOD_E may be returned if there is an error in processing
|
||||
the DSA signature.
|
||||
\return MP_EXPTMOD_E may be returned if there is an error in processing
|
||||
the DSA signature.
|
||||
\return MP_MOD_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_MUL_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_ADD_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_MULMOD_E may be returned if there is an error in processing
|
||||
the DSA signature.
|
||||
\return MP_TO_E may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
\return MP_MEM may be returned if there is an error in processing the
|
||||
DSA signature.
|
||||
|
||||
\param digest pointer to the digest containing the subject of the signature
|
||||
\param sig pointer to the buffer containing the signature to verify
|
||||
\param key pointer to the initialized DsaKey structure with which to
|
||||
verify the signature
|
||||
\param answer pointer to an integer which will store whether the
|
||||
verification was successful
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DsaKey key;
|
||||
// initialize DSA key, load public Key
|
||||
|
||||
int ret;
|
||||
int verified;
|
||||
byte hash[] = { // initialize with hash digest };
|
||||
byte signature[] = { // initialize with signature to verify };
|
||||
ret = wc_DsaVerify(hash, signature, &key, &verified);
|
||||
if (ret != 0) {
|
||||
// error processing verify request
|
||||
} else if (answer == 0) {
|
||||
// invalid signature
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_DsaSign
|
||||
*/
|
||||
WOLFSSL_API int wc_DsaVerify(const byte* digest, const byte* sig,
|
||||
DsaKey* key, int* answer);
|
||||
/*!
|
||||
\ingroup DSA
|
||||
|
||||
\brief This function decodes a DER formatted certificate buffer containing
|
||||
a DSA public key, and stores the key in the given DsaKey structure. It
|
||||
also sets the inOutIdx parameter according to the length of the input read.
|
||||
|
||||
\return 0 Returned on successfully setting the public key for the DsaKey
|
||||
object
|
||||
\return ASN_PARSE_E Returned if there is an error in the encoding while
|
||||
reading the certificate buffer
|
||||
\return ASN_DH_KEY_E Returned if one of the DSA parameters is incorrectly
|
||||
formatted
|
||||
|
||||
\param input pointer to the buffer containing the DER formatted DSA
|
||||
public key
|
||||
\param inOutIdx pointer to an integer in which to store the final index
|
||||
of the certificate read
|
||||
\param key pointer to the DsaKey structure in which to store the public key
|
||||
\param inSz size of the input buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret, idx=0;
|
||||
|
||||
DsaKey key;
|
||||
wc_InitDsaKey(&key);
|
||||
byte derBuff[] = { // DSA public key};
|
||||
ret = wc_DsaPublicKeyDecode(derBuff, &idx, &key, inSz);
|
||||
if (ret != 0) {
|
||||
// error reading public key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitDsaKey
|
||||
\sa wc_DsaPrivateKeyDecode
|
||||
*/
|
||||
WOLFSSL_API int wc_DsaPublicKeyDecode(const byte* input, word32* inOutIdx,
|
||||
DsaKey*, word32);
|
||||
/*!
|
||||
\ingroup DSA
|
||||
|
||||
\brief This function decodes a DER formatted certificate buffer containing
|
||||
a DSA private key, and stores the key in the given DsaKey structure. It
|
||||
also sets the inOutIdx parameter according to the length of the input read.
|
||||
|
||||
\return 0 Returned on successfully setting the private key for the DsaKey
|
||||
object
|
||||
\return ASN_PARSE_E Returned if there is an error in the encoding while
|
||||
reading the certificate buffer
|
||||
\return ASN_DH_KEY_E Returned if one of the DSA parameters is incorrectly
|
||||
formatted
|
||||
|
||||
\param input pointer to the buffer containing the DER formatted DSA
|
||||
private key
|
||||
\param inOutIdx pointer to an integer in which to store the final index
|
||||
of the certificate read
|
||||
\param key pointer to the DsaKey structure in which to store the private
|
||||
key
|
||||
\param inSz size of the input buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret, idx=0;
|
||||
|
||||
DsaKey key;
|
||||
wc_InitDsaKey(&key);
|
||||
byte derBuff[] = { // DSA private key };
|
||||
ret = wc_DsaPrivateKeyDecode(derBuff, &idx, &key, inSz);
|
||||
if (ret != 0) {
|
||||
// error reading private key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitDsaKey
|
||||
\sa wc_DsaPublicKeyDecode
|
||||
*/
|
||||
WOLFSSL_API int wc_DsaPrivateKeyDecode(const byte* input, word32* inOutIdx,
|
||||
DsaKey*, word32);
|
||||
/*!
|
||||
\ingroup DSA
|
||||
|
||||
\brief Convert DsaKey key to DER format, write to output (inLen),
|
||||
return bytes written.
|
||||
|
||||
\return outLen Success, number of bytes written
|
||||
\return BAD_FUNC_ARG key or output are null or key->type is not
|
||||
DSA_PRIVATE.
|
||||
\return MEMORY_E Error allocating memory.
|
||||
|
||||
\param key Pointer to DsaKey structure to convert.
|
||||
\param output Pointer to output buffer for converted key.
|
||||
\param inLen Length of key input.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DsaKey key;
|
||||
WC_RNG rng;
|
||||
int derSz;
|
||||
int bufferSize = // Sufficient buffer size;
|
||||
byte der[bufferSize];
|
||||
|
||||
wc_InitDsaKey(&key);
|
||||
wc_InitRng(&rng);
|
||||
wc_MakeDsaKey(&rng, &key);
|
||||
derSz = wc_DsaKeyToDer(&key, der, bufferSize);
|
||||
\endcode
|
||||
|
||||
\sa wc_InitDsaKey
|
||||
\sa wc_FreeDsaKey
|
||||
\sa wc_MakeDsaKey
|
||||
*/
|
||||
WOLFSSL_API int wc_DsaKeyToDer(DsaKey* key, byte* output, word32 inLen);
|
||||
/*!
|
||||
\ingroup DSA
|
||||
|
||||
\brief Create a DSA key.
|
||||
|
||||
\return MP_OKAY Success
|
||||
\return BAD_FUNC_ARG Either rng or dsa is null.
|
||||
\return MEMORY_E Couldn't allocate memory for buffer.
|
||||
\return MP_INIT_E Error initializing mp_int
|
||||
|
||||
\param rng Pointer to WC_RNG structure.
|
||||
\param dsa Pointer to DsaKey structure.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WC_RNG rng;
|
||||
DsaKey dsa;
|
||||
wc_InitRng(&rng);
|
||||
wc_InitDsa(&dsa);
|
||||
if(wc_MakeDsaKey(&rng, &dsa) != 0)
|
||||
{
|
||||
// Error creating key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitDsaKey
|
||||
\sa wc_FreeDsaKey
|
||||
\sa wc_DsaSign
|
||||
*/
|
||||
WOLFSSL_API int wc_MakeDsaKey(WC_RNG *rng, DsaKey *dsa);
|
||||
/*!
|
||||
\ingroup DSA
|
||||
|
||||
\brief FIPS 186-4 defines valid for modulus_size values as
|
||||
(1024, 160) (2048, 256) (3072, 256)
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG rng or dsa is null or modulus_size is invalid.
|
||||
\return MEMORY_E Error attempting to allocate memory.
|
||||
|
||||
\param rng pointer to wolfCrypt rng.
|
||||
\param modulus_size 1024, 2048, or 3072 are valid values.
|
||||
\param dsa Pointer to a DsaKey structure.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
DsaKey key;
|
||||
WC_RNG rng;
|
||||
wc_InitDsaKey(&key);
|
||||
wc_InitRng(&rng);
|
||||
if(wc_MakeDsaParameters(&rng, 1024, &genKey) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_MakeDsaKey
|
||||
\sa wc_DsaKeyToDer
|
||||
\sa wc_InitDsaKey
|
||||
*/
|
||||
WOLFSSL_API int wc_MakeDsaParameters(WC_RNG *rng, int modulus_size, DsaKey *dsa);
|
1631
doc/dox_comments/header_files/ecc.h
Normal file
1631
doc/dox_comments/header_files/ecc.h
Normal file
File diff suppressed because it is too large
Load Diff
497
doc/dox_comments/header_files/ed25519.h
Normal file
497
doc/dox_comments/header_files/ed25519.h
Normal file
@ -0,0 +1,497 @@
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief This function generates a new ed25519_key and stores it in key.
|
||||
|
||||
\retrun 0 Returned upon successfully making an ed25519_key
|
||||
\retrun BAD_FUNC_ARG Returned if rng or key evaluate to NULL, or if the
|
||||
specified key size is not 32 bytes (ed25519 has 32 byte keys)
|
||||
\retrun MEMORY_E Returned if there is an error allocating memory
|
||||
during function execution
|
||||
|
||||
\param rng pointer to an initialized RNG object with which to
|
||||
generate the key
|
||||
\param keysize length of key to generate. Should always be 32 for ed25519
|
||||
\param key pointer to the ed25519_key for which to generate a key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ed25519_key key;
|
||||
wc_ed25519_init(&key);
|
||||
RNG rng;
|
||||
wc_InitRng(&rng);
|
||||
wc_ed25519_make_key(&rng, 32, &key); // initialize 32 byte ed25519 key
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_init
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_make_key(WC_RNG* rng, int keysize, ed25519_key* key);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief This function signs a message digest using an ed25519_key object
|
||||
to guarantee authenticity.
|
||||
|
||||
\return 0 Returned upon successfully generating a signature for the
|
||||
message digest
|
||||
\return BAD_FUNC_ARG Returned any of the input parameters evaluate to
|
||||
NULL, or if the output buffer is too small to store the generated signature
|
||||
\return MEMORY_E Returned if there is an error allocating memory during
|
||||
function execution
|
||||
|
||||
\param in pointer to the buffer containing the message to sign
|
||||
\param inlen length of the message to sign
|
||||
\param out buffer in which to store the generated signature
|
||||
\param outlen max length of the output buffer. Will store the bytes
|
||||
written to out upon successfully generating a message signature
|
||||
\param key pointer to a private ed25519_key with which to generate the
|
||||
signature
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ed25519_key key;
|
||||
RNG rng;
|
||||
int ret, sigSz;
|
||||
|
||||
byte sig[64]; // will hold generated signature
|
||||
sigSz = sizeof(sig);
|
||||
byte message[] = { // initialize with message };
|
||||
|
||||
wc_InitRng(&rng); // initialize rng
|
||||
wc_ed25519_init(&key); // initialize key
|
||||
wc_ed25519_make_key(&rng, 32, &key); // make public/private key pair
|
||||
ret = wc_ed25519_sign_msg(message, sizeof(message), sig, &sigSz, &key);
|
||||
if ( ret != 0 ) {
|
||||
// error generating message signature
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_verify_msg
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_sign_msg(const byte* in, word32 inlen, byte* out,
|
||||
word32 *outlen, ed25519_key* key);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief This function verifies the ed25519 signature of a message to ensure
|
||||
authenticity. It returns the answer through stat, with 1 corresponding to
|
||||
a valid signature, and 0 corresponding to an invalid signature.
|
||||
|
||||
\return 0 Returned upon successfully performing the signature
|
||||
verification. Note: This does not mean that the signature is verified.
|
||||
The authenticity information is stored instead in stat
|
||||
\return BAD_FUNC_ARG Returned if any of the input parameters evaluate to
|
||||
NULL, or if the siglen does not match the actual length of a signature
|
||||
\return 1 Returned if verification completes, but the signature generated
|
||||
does not match the signature provided
|
||||
|
||||
\param sig pointer to the buffer containing the signature to verify
|
||||
\param siglen length of the signature to verify
|
||||
\param msg pointer to the buffer containing the message to verify
|
||||
\param msglen length of the message to verify
|
||||
\param stat pointer to the result of the verification. 1 indicates the
|
||||
message was successfully verified
|
||||
\param key pointer to a public ed25519 key with which to verify the
|
||||
signature
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ed25519_key key;
|
||||
int ret, verified = 0;
|
||||
|
||||
byte sig[] { // initialize with received signature };
|
||||
byte msg[] = { // initialize with message };
|
||||
// initialize key with received public key
|
||||
ret = wc_ed25519_verify_msg(sig, sizeof(sig), msg, sizeof(msg),
|
||||
&verified, &key);
|
||||
|
||||
if ( return < 0 ) {
|
||||
// error performing verification
|
||||
} else if ( verified == 0 )
|
||||
// the signature is invalid
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_sign_msg
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_verify_msg(const byte* sig, word32 siglen, const byte* msg,
|
||||
word32 msglen, int* stat, ed25519_key* key);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief This function initializes an ed25519_key object for future use
|
||||
with message verification.
|
||||
|
||||
\return 0 Returned upon successfully initializing the ed25519_key object
|
||||
\return BAD_FUNC_ARG Returned if key is NULL
|
||||
|
||||
\param key pointer to the ed25519_key object to initialize
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ed25519_key key;
|
||||
wc_ed25519_init(&key);
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_make_key
|
||||
\sa wc_ed25519_free
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_init(ed25519_key* key);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief This function frees an ed25519 object after it has been used.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param key pointer to the ed25519_key object to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ed25519_key key;
|
||||
// initialize key and perform secure exchanges
|
||||
...
|
||||
wc_ed25519_free(&key);
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_init
|
||||
*/
|
||||
WOLFSSL_API
|
||||
void wc_ed25519_free(ed25519_key* key);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief This function imports a public ed25519_key pair from a buffer
|
||||
containing the public key. This function will handle both compressed and
|
||||
uncompressed keys.
|
||||
|
||||
\return 0 Returned on successfully importing the ed25519_key
|
||||
\return BAD_FUNC_ARG Returned if in or key evaluate to NULL, or inLen is
|
||||
less than the size of an ed25519 key
|
||||
|
||||
\param in pointer to the buffer containing the public key
|
||||
\param inLen length of the buffer containing the public key
|
||||
\param key pointer to the ed25519_key object in which to store the
|
||||
public key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte pub[] = { // initialize ed25519 public key };
|
||||
|
||||
ed_25519 key;
|
||||
wc_ed25519_init_key(&key);
|
||||
ret = wc_ed25519_import_public(pub, sizeof(pub), &key);
|
||||
if ( ret != 0) {
|
||||
// error importing key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_import_private_key
|
||||
\sa wc_ed25519_export_public
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_import_public(const byte* in, word32 inLen, ed25519_key* key);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief This function imports a public/private ed25519 key pair from a
|
||||
pair of buffers. This function will handle both compressed and
|
||||
uncompressed keys.
|
||||
|
||||
\return 0 Returned on successfully importing the ed25519_key
|
||||
\return BAD_FUNC_ARG Returned if in or key evaluate to NULL, or if
|
||||
either privSz or pubSz are less than the size of an ed25519 key
|
||||
|
||||
\param priv pointer to the buffer containing the private key
|
||||
\param privSz size of the private key
|
||||
\param pub pointer to the buffer containing the public key
|
||||
\param pubSz length of the public key
|
||||
\param key pointer to the ed25519_key object in which to store the
|
||||
imported private/public key pair
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte priv[] = { // initialize with 32 byte private key };
|
||||
byte pub[] = { // initialize with the corresponding public key };
|
||||
|
||||
ed25519_key key;
|
||||
wc_ed25519_init_key(&key);
|
||||
ret = wc_ed25519_import_private_key(priv, sizeof(priv), pub,
|
||||
sizeof(pub), &key);
|
||||
if ( ret != 0) {
|
||||
// error importing key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_import_public_key
|
||||
\sa wc_ed25519_export_private_only
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_import_private_key(const byte* priv, word32 privSz,
|
||||
const byte* pub, word32 pubSz, ed25519_key* key);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief This function exports the private key from an ed25519_key
|
||||
structure. It stores the public key in the buffer out, and sets the bytes
|
||||
written to this buffer in outLen.
|
||||
|
||||
\return 0 Returned upon successfully exporting the public key
|
||||
\return BAD_FUNC_ARG Returned if any of the input values evaluate to NULL
|
||||
\return BUFFER_E Returned if the buffer provided is not large enough to
|
||||
store the private key. Upon returning this error, the function sets the
|
||||
size required in outLen
|
||||
|
||||
\param key pointer to an ed25519_key structure from which to export the
|
||||
public key
|
||||
\param out pointer to the buffer in which to store the public key
|
||||
\param outLen pointer to a word32 object with the size available in out.
|
||||
Set with the number of bytes written to out after successfully exporting
|
||||
the private key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
ed25519_key key;
|
||||
// initialize key, make key
|
||||
|
||||
char pub[32];
|
||||
word32 pubSz = sizeof(pub);
|
||||
|
||||
ret = wc_ed25519_export_public(&key, pub, &pubSz);
|
||||
if ( ret != 0) {
|
||||
// error exporting public key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_import_public_key
|
||||
\sa wc_ed25519_export_private_only
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_export_public(ed25519_key*, byte* out, word32* outLen);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief This function exports only the private key from an ed25519_key
|
||||
structure. It stores the private key in the buffer out, and sets
|
||||
the bytes written to this buffer in outLen.
|
||||
|
||||
\return 0 Returned upon successfully exporting the private key
|
||||
\return ECC_BAD_ARG_E Returned if any of the input values evaluate to NULL
|
||||
\return BUFFER_E Returned if the buffer provided is not large enough
|
||||
to store the private key
|
||||
|
||||
\param key pointer to an ed25519_key structure from which to export
|
||||
the private key
|
||||
\param out pointer to the buffer in which to store the private key
|
||||
\param outLen pointer to a word32 object with the size available in
|
||||
out. Set with the number of bytes written to out after successfully
|
||||
exporting the private key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
ed25519_key key;
|
||||
// initialize key, make key
|
||||
|
||||
char priv[32]; // 32 bytes because only private key
|
||||
word32 privSz = sizeof(priv);
|
||||
ret = wc_ed25519_export_private_only(&key, priv, &privSz);
|
||||
if ( ret != 0) {
|
||||
// error exporting private key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_export_public
|
||||
\sa wc_ed25519_import_private_key
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_export_private_only(ed25519_key* key, byte* out, word32* outLen);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief Export the private key, including public part.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returns if any argument is null.
|
||||
\return BUFFER_E Returns if outLen is less than ED25519_PRV_KEY_SIZE
|
||||
|
||||
\param key ed25519_key struct to export from.
|
||||
\param out Destination for private key.
|
||||
\param outLen Max length of output, set to the length of the exported
|
||||
private key.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ed25519_key key;
|
||||
wc_ed25519_init(&key);
|
||||
|
||||
RNG rng;
|
||||
wc_InitRng(&rng);
|
||||
|
||||
wc_ed25519_make_key(&rng, 32, &key); // initialize 32 byte ed25519 key
|
||||
|
||||
byte out[32]; // out needs to be a sufficient buffer size
|
||||
word32 outLen = sizeof(out);
|
||||
int key_size = wc_ed25519_export_private(&key, out, &outLen);
|
||||
if(key_size == BUFFER_E)
|
||||
{
|
||||
// Check size of out compared to outLen to see if function reset outLen
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa none
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_export_private(ed25519_key* key, byte* out, word32* outLen);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief Export full private key and public key.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG: Returns if any argument is null.
|
||||
\return BUFFER_E: Returns if outLen is less than ED25519_PRV_KEY_SIZE
|
||||
or ED25519_PUB_KEY_SIZE
|
||||
|
||||
\param key The ed25519_key structure to export to.
|
||||
\param priv Byte array to store private key.
|
||||
\param privSz Size of priv buffer.
|
||||
\param pub Byte array to store public key.
|
||||
\param pubSz Size of pub buffer.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
ed25519_key key;
|
||||
// initialize key, make key
|
||||
|
||||
char pub[32];
|
||||
word32 pubSz = sizeof(pub);
|
||||
char priv[32];
|
||||
word32 privSz = sizeof(priv);
|
||||
|
||||
ret = wc_ed25519_export_key(&key, priv, &pubSz, pub, &pubSz);
|
||||
if ( ret != 0) {
|
||||
// error exporting public key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_export_private
|
||||
\sa wc_ed25519_export_public
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_export_key(ed25519_key* key,
|
||||
byte* priv, word32 *privSz,
|
||||
byte* pub, word32 *pubSz);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief This function returns the key size of an ed25519_key structure,
|
||||
or 32 bytes.
|
||||
|
||||
\return Success Given a valid key, returns ED25519_KEY_SIZE (32 bytes)
|
||||
\return BAD_FUNC_ARGS Returned if the given key is NULL
|
||||
|
||||
\param key pointer to an ed25519_key structure for which to get the
|
||||
key size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int keySz;
|
||||
ed25519_key key;
|
||||
// initialize key, make key
|
||||
keySz = wc_ed25519_size(&key);
|
||||
if ( keySz == 0) {
|
||||
// error determining key size
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_make_key
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_size(ed25519_key* key);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief Returns the private key size (secret + public) in bytes.
|
||||
|
||||
\return BAD_FUNC_ARG Returns if key argument is null.
|
||||
\return ED25519_PRV_KEY_SIZE The size of the private key.
|
||||
|
||||
\param key The ed25119_key struct
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ed25519_key key;
|
||||
wc_ed25519_init(&key);
|
||||
|
||||
RNG rng;
|
||||
wc_InitRng(&rng);
|
||||
|
||||
wc_ed25519_make_key(&rng, 32, &key); // initialize 32 byte ed25519 key
|
||||
int key_size = wc_ed25519_priv_size(&key);
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25119_pub_size
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_priv_size(ed25519_key* key);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief Returns the compressed key size in bytes (public key).
|
||||
|
||||
\return BAD_FUNC_ARG returns if key is null.
|
||||
\return ED25519_PUB_KEY_SIZE Size of key.
|
||||
|
||||
\param key Pointer to the ed25519_key struct.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ed25519_key key;
|
||||
wc_ed25519_init(&key);
|
||||
RNG rng;
|
||||
wc_InitRng(&rng);
|
||||
|
||||
wc_ed25519_make_key(&rng, 32, &key); // initialize 32 byte ed25519 key
|
||||
int key_size = wc_ed25519_pub_size(&key);
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_priv_size
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_pub_size(ed25519_key* key);
|
||||
/*!
|
||||
\ingroup ED25519
|
||||
|
||||
\brief This function returns the size of an ed25519 signature (64 in bytes).
|
||||
|
||||
\return Success Given a valid key, returns ED25519_SIG_SIZE (64 in bytes)
|
||||
\return 0 Returned if the given key is NULL
|
||||
|
||||
\param key pointer to an ed25519_key structure for which to get the
|
||||
signature size
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int sigSz;
|
||||
ed25519_key key;
|
||||
// initialize key, make key
|
||||
|
||||
sigSz = wc_ed25519_sig_size(&key);
|
||||
if ( sigSz == 0) {
|
||||
// error determining sig size
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ed25519_sign_msg
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wc_ed25519_sig_size(ed25519_key* key);
|
48
doc/dox_comments/header_files/error-crypt.h
Normal file
48
doc/dox_comments/header_files/error-crypt.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*!
|
||||
\ingroup Error
|
||||
|
||||
\brief This function stores the error string for a particular error code
|
||||
in the given buffer.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param error error code for which to get the string
|
||||
\param buffer buffer in which to store the error string. Buffer should be
|
||||
at least WOLFSSL_MAX_ERROR_SZ (80 bytes) long
|
||||
|
||||
_Example_
|
||||
\code
|
||||
char errorMsg[WOLFSSL_MAX_ERROR_SZ];
|
||||
int err = wc_some_function();
|
||||
|
||||
if( err != 0) { // error occurred
|
||||
wc_ErrorString(err, errorMsg);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_GetErrorString
|
||||
*/
|
||||
WOLFSSL_API void wc_ErrorString(int err, char* buff);
|
||||
/*!
|
||||
\ingroup Error
|
||||
|
||||
\brief This function returns the error string for a particular error code.
|
||||
|
||||
\return string Returns the error string for an error code as a
|
||||
string literal.
|
||||
|
||||
\param error error code for which to get the string
|
||||
|
||||
_Example_
|
||||
\code
|
||||
char * errorMsg;
|
||||
int err = wc_some_function();
|
||||
|
||||
if( err != 0) { // error occurred
|
||||
errorMsg = wc_GetErrorString(err);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ErrorString
|
||||
*/
|
||||
WOLFSSL_API const char* wc_GetErrorString(int error);
|
385
doc/dox_comments/header_files/evp.h
Normal file
385
doc/dox_comments/header_files/evp.h
Normal file
@ -0,0 +1,385 @@
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief Getter functions for the respective WOLFSSL_EVP_CIPHER pointers.
|
||||
wolfSSL_EVP_init() must be called once in the program first to populate
|
||||
these cipher strings. WOLFSSL_DES_ECB macro must be defined for
|
||||
wolfSSL_EVP_des_ede3_ecb().
|
||||
|
||||
\return pointer Returns a WOLFSSL_EVP_CIPHER pointer for DES EDE3 operations.
|
||||
|
||||
\param none No parameters.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
printf("block size des ede3 cbc = %d\n",
|
||||
wolfSSL_EVP_CIPHER_block_size(wolfSSL_EVP_des_ede3_cbc()));
|
||||
printf("block size des ede3 ecb = %d\n",
|
||||
wolfSSL_EVP_CIPHER_block_size(wolfSSL_EVP_des_ede3_ecb()));
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_CIPHER_CTX_init
|
||||
*/
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ede3_ecb(void);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief Getter functions for the respective WOLFSSL_EVP_CIPHER pointers.
|
||||
wolfSSL_EVP_init() must be called once in the program first to populate
|
||||
these cipher strings. WOLFSSL_DES_ECB macro must be defined for
|
||||
wolfSSL_EVP_des_ecb().
|
||||
|
||||
\return pointer Returns a WOLFSSL_EVP_CIPHER pointer for DES operations.
|
||||
|
||||
\param none No parameters.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_EVP_CIPHER* cipher;
|
||||
cipher = wolfSSL_EVP_des_ecb();
|
||||
…
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_CIPHER_CTX_init
|
||||
*/
|
||||
WOLFSSL_API const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_cbc(void);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief Function for initializing WOLFSSL_EVP_MD_CTX. This function is a
|
||||
wrapper for wolfSSL_EVP_DigestInit() because wolfSSL does not
|
||||
use WOLFSSL_ENGINE.
|
||||
|
||||
\return SSL_SUCCESS If successfully set.
|
||||
\return SSL_FAILURE If not successful.
|
||||
|
||||
\param ctx structure to initialize.
|
||||
\param type type of hash to do, for example SHA.
|
||||
\param impl engine to use. N/A for wolfSSL, can be NULL.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_EVP_MD_CTX* md = NULL;
|
||||
wolfCrypt_Init();
|
||||
md = wolfSSL_EVP_MD_CTX_new();
|
||||
if (md == NULL) {
|
||||
printf("error setting md\n");
|
||||
return -1;
|
||||
}
|
||||
printf("cipher md init ret = %d\n", wolfSSL_EVP_DigestInit_ex(md,
|
||||
wolfSSL_EVP_sha1(), e));
|
||||
//free resources
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_MD_CTX_new
|
||||
\sa wolfCrypt_Init
|
||||
\sa wolfSSL_EVP_MD_CTX_free
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_EVP_DigestInit_ex(WOLFSSL_EVP_MD_CTX* ctx,
|
||||
const WOLFSSL_EVP_MD* type,
|
||||
WOLFSSL_ENGINE *impl);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a
|
||||
wrapper for wolfSSL_CipherInit() because wolfSSL does not
|
||||
use WOLFSSL_ENGINE.
|
||||
|
||||
\return SSL_SUCCESS If successfully set.
|
||||
\return SSL_FAILURE If not successful.
|
||||
|
||||
\param ctx structure to initialize.
|
||||
\param type type of encryption/decryption to do, for example AES.
|
||||
\param impl engine to use. N/A for wolfSSL, can be NULL.
|
||||
\param key key to set .
|
||||
\param iv iv if needed by algorithm.
|
||||
\param enc encryption (1) or decryption (0) flag.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_EVP_CIPHER_CTX* ctx = NULL;
|
||||
WOLFSSL_ENGINE* e = NULL;
|
||||
unsigned char key[16];
|
||||
unsigned char iv[12];
|
||||
wolfCrypt_Init();
|
||||
ctx = wolfSSL_EVP_CIPHER_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
printf("issue creating ctx\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("cipher init ex error ret = %d\n", wolfSSL_EVP_CipherInit_ex(NULL,
|
||||
EVP_aes_128_ cbc(), e, key, iv, 1));
|
||||
printf("cipher init ex success ret = %d\n", wolfSSL_EVP_CipherInit_ex(ctx,
|
||||
EVP_aes_128_c bc(), e, key, iv, 1));
|
||||
// free resources
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_CIPHER_CTX_new
|
||||
\sa wolfCrypt_Init
|
||||
\sa wolfSSL_EVP_CIPHER_CTX_free
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_EVP_CipherInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
const WOLFSSL_EVP_CIPHER* type,
|
||||
WOLFSSL_ENGINE *impl,
|
||||
const unsigned char* key,
|
||||
const unsigned char* iv,
|
||||
int enc);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a
|
||||
wrapper for wolfSSL_EVP_CipherInit() because wolfSSL does not use
|
||||
WOLFSSL_ENGINE. Sets encrypt flag to be encrypt.
|
||||
|
||||
\return SSL_SUCCESS If successfully set.
|
||||
\return SSL_FAILURE If not successful.
|
||||
|
||||
\param ctx structure to initialize.
|
||||
\param type type of encryption to do, for example AES.
|
||||
\param impl engine to use. N/A for wolfSSL, can be NULL.
|
||||
\param key key to use.
|
||||
\param iv iv to use.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_EVP_CIPHER_CTX* ctx = NULL;
|
||||
wolfCrypt_Init();
|
||||
ctx = wolfSSL_EVP_CIPHER_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
printf("error setting ctx\n");
|
||||
return -1;
|
||||
}
|
||||
printf("cipher ctx init ret = %d\n", wolfSSL_EVP_EncryptInit_ex(ctx,
|
||||
wolfSSL_EVP_aes_128_cbc(), e, key, iv));
|
||||
//free resources
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_CIPHER_CTX_new
|
||||
\sa wolfCrypt_Init
|
||||
\sa wolfSSL_EVP_CIPHER_CTX_free
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_EVP_EncryptInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
const WOLFSSL_EVP_CIPHER* type,
|
||||
WOLFSSL_ENGINE *impl,
|
||||
const unsigned char* key,
|
||||
const unsigned char* iv);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief Function for initializing WOLFSSL_EVP_CIPHER_CTX. This function is a
|
||||
wrapper for wolfSSL_EVP_CipherInit() because wolfSSL does not use
|
||||
WOLFSSL_ENGINE. Sets encrypt flag to be decrypt.
|
||||
|
||||
\return SSL_SUCCESS If successfully set.
|
||||
\return SSL_FAILURE If not successful.
|
||||
|
||||
\param ctx structure to initialize.
|
||||
\param type type of encryption/decryption to do, for example AES.
|
||||
\param impl engine to use. N/A for wolfSSL, can be NULL.
|
||||
\param key key to set .
|
||||
\param iv iv if needed by algorithm.
|
||||
\param enc encryption (1) or decryption (0) flag.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_EVP_CIPHER_CTX* ctx = NULL;
|
||||
WOLFSSL_ENGINE* e = NULL;
|
||||
unsigned char key[16];
|
||||
unsigned char iv[12];
|
||||
|
||||
wolfCrypt_Init();
|
||||
|
||||
ctx = wolfSSL_EVP_CIPHER_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
printf("issue creating ctx\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("cipher init ex error ret = %d\n", wolfSSL_EVP_DecryptInit_ex(NULL,
|
||||
EVP_aes_128_ cbc(), e, key, iv, 1));
|
||||
printf("cipher init ex success ret = %d\n", wolfSSL_EVP_DecryptInit_ex(ctx,
|
||||
EVP_aes_128_c bc(), e, key, iv, 1));
|
||||
// free resources
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_CIPHER_CTX_new
|
||||
\sa wolfCrypt_Init
|
||||
\sa wolfSSL_EVP_CIPHER_CTX_free
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_EVP_DecryptInit_ex(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
const WOLFSSL_EVP_CIPHER* type,
|
||||
WOLFSSL_ENGINE *impl,
|
||||
const unsigned char* key,
|
||||
const unsigned char* iv);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief Function for encrypting/decrypting data. In buffer is added to be
|
||||
encrypted or decrypted and out buffer holds the results. outl will be the
|
||||
length of encrypted/decrypted information.
|
||||
|
||||
\return SSL_SUCCESS If successfull.
|
||||
\return SSL_FAILURE If not successful.
|
||||
|
||||
\param ctx structure to get cipher type from.
|
||||
\param out buffer to hold output.
|
||||
\param outl adjusted to be size of output.
|
||||
\param in buffer to perform operation on.
|
||||
\param inl length of input buffer.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_EVP_CIPHER_CTX* ctx = NULL;
|
||||
unsigned char out[100];
|
||||
int outl;
|
||||
unsigned char in[100];
|
||||
int inl = 100;
|
||||
|
||||
ctx = wolfSSL_EVP_CIPHER_CTX_new();
|
||||
// set up ctx
|
||||
ret = wolfSSL_EVP_CipherUpdate(ctx, out, outl, in, inl);
|
||||
// check ret value
|
||||
// buffer out holds outl bytes of data
|
||||
// free resources
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_CIPHER_CTX_new
|
||||
\sa wolfCrypt_Init
|
||||
\sa wolfSSL_EVP_CIPHER_CTX_free
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_EVP_CipherUpdate(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||
unsigned char *out, int *outl,
|
||||
const unsigned char *in, int inl);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief This function performs the final cipher operations adding in
|
||||
padding. If WOLFSSL_EVP_CIPH_NO_PADDING flag is set in
|
||||
WOLFSSL_EVP_CIPHER_CTX structure then 1 is returned and no
|
||||
encryption/decryption is done. If padding flag is seti padding is added and
|
||||
encrypted when ctx is set to encrypt, padding values are checked when set
|
||||
to decrypt.
|
||||
|
||||
\return 1 Returned on success.
|
||||
\return 0 If encountering a failure.
|
||||
|
||||
\param ctx structure to decrypt/encrypt with.
|
||||
\param out buffer for final decrypt/encrypt.
|
||||
\param out1 size of out buffer when data has been added by function.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_EVP_CIPHER_CTX* ctx;
|
||||
int out1;
|
||||
unsigned char out[64];
|
||||
// create ctx
|
||||
wolfSSL_EVP_CipherFinal(ctx, out, &out1);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_CIPHER_CTX_new
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
|
||||
unsigned char *out, int *outl);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief Setter function for WOLFSSL_EVP_CIPHER_CTX structure key length.
|
||||
|
||||
\return SSL_SUCCESS If successfully set.
|
||||
\return SSL_FAILURE If failed to set key length.
|
||||
|
||||
\param ctx structure to set key length.
|
||||
\param keylen key length.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_EVP_CIPHER_CTX* ctx;
|
||||
int keylen;
|
||||
// create ctx
|
||||
wolfSSL_EVP_CIPHER_CTX_set_key_length(ctx, keylen);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_CIPHER_flags
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_set_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx,
|
||||
int keylen);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief This is a getter function for the ctx block size.
|
||||
|
||||
\return size Returns ctx->block_size.
|
||||
|
||||
\param ctx the cipher ctx to get block size of.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
const WOLFSSL_CVP_CIPHER_CTX* ctx;
|
||||
//set up ctx
|
||||
printf(“block size = %d\n”, wolfSSL_EVP_CIPHER_CTX_block_size(ctx));
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_CIPHER_block_size
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_block_size(const WOLFSSL_EVP_CIPHER_CTX *ctx);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief This is a getter function for the block size of cipher.
|
||||
|
||||
\return size returns the block size.
|
||||
|
||||
\param cipher cipher to get block size of.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
printf(“block size = %d\n”,
|
||||
wolfSSL_EVP_CIPHER_block_size(wolfSSL_EVP_aes_256_ecb()));
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_aes_256_ctr
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_block_size(const WOLFSSL_EVP_CIPHER *cipher);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief Setter function for WOLFSSL_EVP_CIPHER_CTX structure.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param ctx structure to set flag.
|
||||
\param flag flag to set in structure.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_EVP_CIPHER_CTX* ctx;
|
||||
int flag;
|
||||
// create ctx
|
||||
wolfSSL_EVP_CIPHER_CTX_set_flags(ctx, flag);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_CIPHER_flags
|
||||
*/
|
||||
WOLFSSL_API void wolfSSL_EVP_CIPHER_CTX_set_flags(WOLFSSL_EVP_CIPHER_CTX *ctx, int flags);
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief Setter function for WOLFSSL_EVP_CIPHER_CTX structure to use padding.
|
||||
|
||||
\return SSL_SUCCESS If successfully set.
|
||||
\return BAD_FUNC_ARG If null argument passed in.
|
||||
|
||||
\param ctx structure to set padding flag.
|
||||
\param padding 0 for not setting padding, 1 for setting padding.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_EVP_CIPHER_CTX* ctx;
|
||||
// create ctx
|
||||
wolfSSL_EVP_CIPHER_CTX_set_padding(ctx, 1);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_EVP_CIPHER_flags
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_EVP_CIPHER_CTX_set_padding(WOLFSSL_EVP_CIPHER_CTX *c, int pad);
|
235
doc/dox_comments/header_files/hash.h
Normal file
235
doc/dox_comments/header_files/hash.h
Normal file
@ -0,0 +1,235 @@
|
||||
/*!
|
||||
\ingroup wolfCrypt
|
||||
|
||||
\brief This function will return the OID for the wc_HashType provided.
|
||||
|
||||
\return OID returns value greater than 0
|
||||
\return HASH_TYPE_E hash type not supported.
|
||||
\return BAD_FUNC_ARG one of the provided arguments is incorrect.
|
||||
|
||||
\param hash_type A hash type from the “enum wc_HashType” such
|
||||
as “WC_HASH_TYPE_SHA256”.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
enum wc_HashType hash_type = WC_HASH_TYPE_SHA256;
|
||||
int oid = wc_HashGetOID(hash_type);
|
||||
if (oid > 0) {
|
||||
// Success
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_HashGetDigestSize
|
||||
\sa wc_Hash
|
||||
*/
|
||||
WOLFSSL_API int wc_HashGetOID(enum wc_HashType hash_type);
|
||||
/*!
|
||||
\ingroup wolfCrypt
|
||||
|
||||
\brief This function returns the size of the digest (output) for a
|
||||
hash_type. The returns size is used to make sure the output buffer
|
||||
provided to wc_Hash is large enough.
|
||||
|
||||
\return Success A positive return value indicates the digest size
|
||||
for the hash.
|
||||
\return Error Returns HASH_TYPE_E if hash_type is not supported.
|
||||
\return Failure Returns BAD_FUNC_ARG if an invalid hash_type was used.
|
||||
|
||||
\param hash_type A hash type from the “enum wc_HashType” such as
|
||||
“WC_HASH_TYPE_SHA256”.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int hash_len = wc_HashGetDigestSize(hash_type);
|
||||
if (hash_len <= 0) {
|
||||
WOLFSSL_MSG("Invalid hash type/len");
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Hash
|
||||
*/
|
||||
WOLFSSL_API int wc_HashGetDigestSize(enum wc_HashType hash_type);
|
||||
/*!
|
||||
\ingroup wolfCrypt
|
||||
|
||||
\brief This function performs a hash on the provided data buffer
|
||||
and returns it in the hash buffer provided.
|
||||
|
||||
\return 0 Success, else error (such as BAD_FUNC_ARG or BUFFER_E).
|
||||
|
||||
\param hash_type A hash type from the “enum wc_HashType”
|
||||
such as “WC_HASH_TYPE_SHA256”.
|
||||
\param data Pointer to buffer containing the data to hash.
|
||||
\param data_len Length of the data buffer.
|
||||
\param hash Pointer to buffer used to output the final hash to.
|
||||
\param hash_len Length of the hash buffer.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
enum wc_HashType hash_type = WC_HASH_TYPE_SHA256;
|
||||
int hash_len = wc_HashGetDigestSize(hash_type);
|
||||
if (hash_len > 0) {
|
||||
int ret = wc_Hash(hash_type, data, data_len, hash_data, hash_len);
|
||||
if(ret == 0) {
|
||||
// Success
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_HashGetDigestSize
|
||||
*/
|
||||
WOLFSSL_API int wc_Hash(enum wc_HashType hash_type,
|
||||
const byte* data, word32 data_len,
|
||||
byte* hash, word32 hash_len);
|
||||
/*!
|
||||
\ingroup MD5
|
||||
|
||||
\brief Convenience function, handles all the hashing and places the
|
||||
result into hash.
|
||||
|
||||
\return 0 Returned upon successfully hashing the data.
|
||||
\return Memory_E memory error, unable to allocate memory. This is only
|
||||
possible with the small stack option enabled.
|
||||
|
||||
\param data the data to hash
|
||||
\param len the length of data
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
const byte* data;
|
||||
word32 data_len;
|
||||
byte* hash;
|
||||
int ret;
|
||||
...
|
||||
ret = wc_Md5Hash(data, data_len, hash);
|
||||
if (ret != 0) {
|
||||
// Md5 Hash Failure Case.
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Md5Hash
|
||||
\sa wc_Md5Final
|
||||
\sa wc_InitMd5
|
||||
*/
|
||||
WOLFSSL_API int wc_Md5Hash(const byte* data, word32 len, byte* hash);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Convenience function, handles all the hashing and places the
|
||||
result into hash.
|
||||
|
||||
\return 0 Returned upon successfully ….
|
||||
\return Memory_E memory error, unable to allocate memory. This is only
|
||||
possible with the small stack option enabled.
|
||||
|
||||
\param data the data to hash
|
||||
\param len the length of data
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
none
|
||||
\endcode
|
||||
|
||||
\sa wc_ShaHash
|
||||
\sa wc_ShaFinal
|
||||
\sa wc_InitSha
|
||||
*/
|
||||
WOLFSSL_API int wc_ShaHash(const byte*, word32, byte*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Convenience function, handles all the hashing and places the
|
||||
result into hash.
|
||||
|
||||
\return 0 Returned upon successfully …
|
||||
\return Memory_E memory error, unable to allocate memory. This is only
|
||||
possible with the small stack option enabled.
|
||||
|
||||
\param data the data to hash
|
||||
\param len the length of data
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
none
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha256Hash
|
||||
\sa wc_Sha256Final
|
||||
\sa wc_InitSha256
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Convenience function, handles all the hashing and places the
|
||||
result into hash.
|
||||
|
||||
\return 0 Success
|
||||
\return <0 Error
|
||||
|
||||
\param data the data to hash
|
||||
\param len the length of data
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
none
|
||||
\endcode
|
||||
|
||||
\sa wc_InitSha224
|
||||
\sa wc_Sha224Update
|
||||
\sa wc_Sha224Final
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha224Hash(const byte*, word32, byte*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Convenience function, handles all the hashing and places the
|
||||
result into hash.
|
||||
|
||||
\return 0 Returned upon successfully hashing the inputted data
|
||||
\return Memory_E memory error, unable to allocate memory. This is only
|
||||
possible with the small stack option enabled.
|
||||
|
||||
\param data the data to hash
|
||||
\param len the length of data
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
none
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha512Hash
|
||||
\sa wc_Sha512Final
|
||||
\sa wc_InitSha512
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Convenience function, handles all the hashing and places the
|
||||
result into hash.
|
||||
|
||||
\return 0 Returned upon successfully hashing the data
|
||||
\return Memory_E memory error, unable to allocate memory. This is only
|
||||
possible with the small stack option enabled.
|
||||
|
||||
\param data the data to hash
|
||||
\param len the length of data
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
none
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha384Hash
|
||||
\sa wc_Sha384Final
|
||||
\sa wc_InitSha384
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*);
|
65
doc/dox_comments/header_files/hc128.h
Normal file
65
doc/dox_comments/header_files/hc128.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*!
|
||||
\ingroup HC128
|
||||
|
||||
\brief This function encrypts or decrypts a message of any size from the
|
||||
input buffer input, and stores the resulting plaintext/ciphertext in
|
||||
the output buffer output.
|
||||
|
||||
\return 0 Returned upon successfully encrypting/decrypting the given input
|
||||
\return MEMORY_E Returned if the input and output buffers are not aligned
|
||||
along a 4-byte boundary, and there is an error allocating memory
|
||||
\return BAD_ALIGN_E Returned if the input or output buffers are not
|
||||
aligned along a 4-byte boundary, and NO_WOLFSSL_ALLOC_ALIGN is defined
|
||||
|
||||
\param ctx pointer to a HC-128 context object with an initialized key
|
||||
to use for encryption or decryption
|
||||
\param output buffer in which to store the processed input
|
||||
\param input buffer containing the plaintext to encrypt or the
|
||||
ciphertext to decrypt
|
||||
\param msglen length of the plaintext to encrypt or the ciphertext
|
||||
to decrypt
|
||||
|
||||
_Example_
|
||||
\code
|
||||
HC128 enc;
|
||||
byte key[] = { // initialize with key };
|
||||
byte iv[] = { // initialize with iv };
|
||||
wc_Hc128_SetKey(&enc, key, iv);
|
||||
|
||||
byte msg[] = { // initialize with message };
|
||||
byte cipher[sizeof(msg)];
|
||||
|
||||
if (wc_Hc128_Process(*enc, cipher, plain, sizeof(plain)) != 0) {
|
||||
// error encrypting msg
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Hc128_SetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_Hc128_Process(HC128*, byte*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup HC128
|
||||
|
||||
\brief This function initializes an HC128 context object by
|
||||
setting its key and iv.
|
||||
|
||||
\return 0 Returned upon successfully setting the key and iv
|
||||
for the HC128 context object
|
||||
|
||||
\param ctx pointer to an HC-128 context object to initialize
|
||||
\param key pointer to the buffer containing the 16 byte key to
|
||||
use with encryption/decryption
|
||||
\param iv pointer to the buffer containing the 16 byte iv (nonce)
|
||||
with which to initialize the HC128 object
|
||||
|
||||
_Example_
|
||||
\code
|
||||
HC128 enc;
|
||||
byte key[] = { // initialize with key };
|
||||
byte iv[] = { // initialize with iv };
|
||||
wc_Hc128_SetKey(&enc, key, iv);
|
||||
\endcode
|
||||
|
||||
\sa wc_Hc128_Process
|
||||
*/
|
||||
WOLFSSL_API int wc_Hc128_SetKey(HC128*, const byte* key, const byte* iv);
|
168
doc/dox_comments/header_files/hmac.h
Normal file
168
doc/dox_comments/header_files/hmac.h
Normal file
@ -0,0 +1,168 @@
|
||||
/*!
|
||||
\ingroup HMAC
|
||||
|
||||
\brief This function initializes an Hmac object, setting its
|
||||
encryption type, key and HMAC length.
|
||||
|
||||
\return 0 Returned on successfully initializing the Hmac object
|
||||
\return BAD_FUNC_ARG Returned if the input type is invalid. Valid options
|
||||
are: MD5, SHA, SHA256, SHA384, SHA512, BLAKE2B_ID
|
||||
\return MEMORY_E Returned if there is an error allocating memory for the
|
||||
structure to use for hashing
|
||||
\return HMAC_MIN_KEYLEN_E May be returned when using a FIPS implementation
|
||||
and the key length specified is shorter than the minimum acceptable
|
||||
FIPS standard
|
||||
|
||||
\param hmac pointer to the Hmac object to initialize
|
||||
\param type type specifying which encryption method the Hmac object
|
||||
should use. Valid options are: MD5, SHA, SHA256, SHA384, SHA512, BLAKE2B_ID
|
||||
\param key pointer to a buffer containing the key with which to
|
||||
initialize the Hmac object
|
||||
\param length length of the key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Hmac hmac;
|
||||
byte key[] = { // initialize with key to use for encryption };
|
||||
if (wc_HmacSetKey(&hmac, MD5, key, sizeof(key)) != 0) {
|
||||
// error initializing Hmac object
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_HmacUpdate
|
||||
\sa wc_HmacFinal
|
||||
*/
|
||||
WOLFSSL_API int wc_HmacSetKey(Hmac*, int type, const byte* key, word32 keySz);
|
||||
/*!
|
||||
\ingroup HMAC
|
||||
|
||||
\brief This function updates the message to authenticate using HMAC.
|
||||
It should be called after the Hmac object has been initialized with
|
||||
wc_HmacSetKey. This function may be called multiple times to update
|
||||
the message to hash. After calling wc_HmacUpdate as desired, one should
|
||||
call wc_HmacFinal to obtain the final authenticated message tag.
|
||||
|
||||
\return 0 Returned on successfully updating the message to authenticate
|
||||
\return MEMORY_E Returned if there is an error allocating memory for
|
||||
use with a hashing algorithm
|
||||
|
||||
\param hmac pointer to the Hmac object for which to update the message
|
||||
\param msg pointer to the buffer containing the message to append
|
||||
\param length length of the message to append
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Hmac hmac;
|
||||
byte msg[] = { // initialize with message to authenticate };
|
||||
byte msg2[] = { // initialize with second half of message };
|
||||
// initialize hmac
|
||||
if( wc_HmacUpdate(&hmac, msg, sizeof(msg)) != 0) {
|
||||
// error updating message
|
||||
}
|
||||
if( wc_HmacUpdate(&hmac, msg2, sizeof(msg)) != 0) {
|
||||
// error updating with second message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_HmacSetKey
|
||||
\sa wc_HmacFinal
|
||||
*/
|
||||
WOLFSSL_API int wc_HmacUpdate(Hmac*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup HMAC
|
||||
|
||||
\brief This function computes the final hash of an Hmac object's message.
|
||||
|
||||
\return 0 Returned on successfully computing the final hash
|
||||
\return MEMORY_E Returned if there is an error allocating memory for
|
||||
use with a hashing algorithm
|
||||
|
||||
\param hmac pointer to the Hmac object for which to calculate the
|
||||
final hash
|
||||
\param hash pointer to the buffer in which to store the final hash.
|
||||
Should have room available as required by the hashing algorithm chosen
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Hmac hmac;
|
||||
byte hash[MD5_DIGEST_SIZE];
|
||||
// initialize hmac with MD5 as type
|
||||
// wc_HmacUpdate() with messages
|
||||
|
||||
if (wc_HmacFinal(&hmac, hash) != 0) {
|
||||
// error computing hash
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_HmacSetKey
|
||||
\sa wc_HmacUpdate
|
||||
*/
|
||||
WOLFSSL_API int wc_HmacFinal(Hmac*, byte*);
|
||||
/*!
|
||||
\ingroup HMAC
|
||||
|
||||
\brief This function returns the largest HMAC digest size available
|
||||
based on the configured cipher suites.
|
||||
|
||||
\return Success Returns the largest HMAC digest size available based
|
||||
on the configured cipher suites
|
||||
|
||||
\param none No parameters.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int maxDigestSz = wolfSSL_GetHmacMaxSize();
|
||||
\endcode
|
||||
|
||||
\sa none
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_GetHmacMaxSize(void);
|
||||
/*!
|
||||
\ingroup HMAC
|
||||
|
||||
\brief This function provides access to a HMAC Key Derivation Function
|
||||
(HKDF). It utilizes HMAC to convert inKey, with an optional salt and
|
||||
optional info into a derived key, which it stores in out. The hash type
|
||||
defaults to MD5 if 0 or NULL is given.
|
||||
|
||||
\return 0 Returned upon successfully generating a key with the given inputs
|
||||
\return BAD_FUNC_ARG Returned if an invalid hash type is given as
|
||||
argument. Valid types are: MD5, SHA, SHA256, SHA384, SHA512, BLAKE2B_ID
|
||||
\return MEMORY_E Returned if there is an error allocating memory
|
||||
\return HMAC_MIN_KEYLEN_E May be returned when using a FIPS implementation
|
||||
and the key length specified is shorter than the minimum acceptable FIPS
|
||||
standard
|
||||
|
||||
\param type hash type to use for the HKDF. Valid types are: MD5, SHA,
|
||||
SHA256, SHA384, SHA512, BLAKE2B_ID
|
||||
\param inKey pointer to the buffer containing the key to use for KDF
|
||||
\param inKeySz length of the input key
|
||||
\param salt pointer to a buffer containing an optional salt. Use NULL
|
||||
instead if not using a salt
|
||||
\param saltSz length of the salt. Use 0 if not using a salt
|
||||
\param info pointer to a buffer containing optional additional info.
|
||||
Use NULL if not appending extra info
|
||||
\param infoSz length of additional info. Use 0 if not using additional info
|
||||
\param out pointer to the buffer in which to store the derived key
|
||||
\param outSz space available in the output buffer to store the
|
||||
generated key
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte key[] = { // initialize with key };
|
||||
byte salt[] = { // initialize with salt };
|
||||
byte derivedKey[MAX_DIGEST_SIZE];
|
||||
|
||||
int ret = wc_HKDF(SHA512, key, sizeof(key), salt, sizeof(salt),
|
||||
NULL, 0, derivedKey, sizeof(derivedKey));
|
||||
if ( ret != 0 ) {
|
||||
// error generating derived key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_HmacSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
|
||||
const byte* salt, word32 saltSz,
|
||||
const byte* info, word32 infoSz,
|
||||
byte* out, word32 outSz);
|
159
doc/dox_comments/header_files/idea.h
Normal file
159
doc/dox_comments/header_files/idea.h
Normal file
@ -0,0 +1,159 @@
|
||||
/*!
|
||||
\ingroup IDEA
|
||||
|
||||
\brief Generate the 52, 16-bit key sub-blocks from the 128 key.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returns if idea or key is null, keySz is not equal to
|
||||
IDEA_KEY_SIZE, or dir is not IDEA_ENCRYPTION or IDEA_DECRYPTION.
|
||||
|
||||
\param idea Pointer to Idea structure.
|
||||
\param key Pointer to key in memory.
|
||||
\param keySz Size of key.
|
||||
\param iv Value for IV in Idea structure. Can be null.
|
||||
\param dir Direction, either IDEA_ENCRYPTION or IDEA_DECRYPTION
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte v_key[IDEA_KEY_SIZE] = { }; // Some Key
|
||||
Idea idea;
|
||||
int ret = wc_IdeaSetKey(&idea v_key, IDEA_KEY_SIZE, NULL, IDEA_ENCRYPTION);
|
||||
if (ret != 0)
|
||||
{
|
||||
// There was an error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_IdeaSetIV
|
||||
*/
|
||||
WOLFSSL_API int wc_IdeaSetKey(Idea *idea, const byte* key, word16 keySz,
|
||||
const byte *iv, int dir);
|
||||
/*!
|
||||
\ingroup IDEA
|
||||
|
||||
\brief Sets the IV in an Idea key structure.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returns if idea is null.
|
||||
|
||||
\param idea Pointer to idea key structure.
|
||||
\param iv The IV value to set, can be null.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Idea idea;
|
||||
// Initialize idea
|
||||
|
||||
byte iv[] = { }; // Some IV
|
||||
int ret = wc_IdeaSetIV(&idea, iv);
|
||||
if(ret != 0)
|
||||
{
|
||||
// Some error occured
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_IdeaSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_IdeaSetIV(Idea *idea, const byte* iv);
|
||||
/*!
|
||||
\ingroup IDEA
|
||||
|
||||
\brief Encryption or decryption for a block (64 bits).
|
||||
|
||||
\return 0 upon success.
|
||||
\return <0 an error occured
|
||||
|
||||
\param idea Pointer to idea key structure.
|
||||
\param out Pointer to destination.
|
||||
\param in Pointer to input data to encrypt or decrypt.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte v_key[IDEA_KEY_SIZE] = { }; // Some Key
|
||||
byte data[IDEA_BLOCK_SIZE] = { }; // Some encrypted data
|
||||
Idea idea;
|
||||
wc_IdeaSetKey(&idea, v_key, IDEA_KEY_SIZE, NULL, IDEA_DECRYPTION);
|
||||
int ret = wc_IdeaCipher(&idea, data, data);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
// There was an error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_IdeaSetKey
|
||||
\sa wc_IdeaSetIV
|
||||
\sa wc_IdeaCbcEncrypt
|
||||
\sa wc_IdeaCbcDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_IdeaCipher(Idea *idea, byte* out, const byte* in);
|
||||
/*!
|
||||
\ingroup IDEA
|
||||
|
||||
\brief Encrypt data using IDEA CBC mode.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returns if any arguments are null.
|
||||
|
||||
\param idea Pointer to Idea key structure.
|
||||
\param out Pointer to destination for encryption.
|
||||
\param in Pointer to input for encryption.
|
||||
\param len length of input.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Idea idea;
|
||||
// Initialize idea structure for encryption
|
||||
const char *message = "International Data Encryption Algorithm";
|
||||
byte msg_enc[40], msg_dec[40];
|
||||
|
||||
memset(msg_enc, 0, sizeof(msg_enc));
|
||||
ret = wc_IdeaCbcEncrypt(&idea, msg_enc, (byte *)message,
|
||||
(word32)strlen(message)+1);
|
||||
if(ret != 0)
|
||||
{
|
||||
// Some error occured
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_IdeaCbcDecrypt
|
||||
\sa wc_IdeaCipher
|
||||
\sa wc_IdeaSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_IdeaCbcEncrypt(Idea *idea, byte* out,
|
||||
const byte* in, word32 len);
|
||||
/*!
|
||||
\ingroup IDEA
|
||||
|
||||
\brief Decrypt data using IDEA CBC mode.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returns if any arguments are null.
|
||||
|
||||
\param idea Pointer to Idea key structure.
|
||||
\param out Pointer to destination for encryption.
|
||||
\param in Pointer to input for encryption.
|
||||
\param len length of input.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Idea idea;
|
||||
// Initialize idea structure for decryption
|
||||
const char *message = "International Data Encryption Algorithm";
|
||||
byte msg_enc[40], msg_dec[40];
|
||||
|
||||
memset(msg_dec, 0, sizeof(msg_dec));
|
||||
ret = wc_IdeaCbcDecrypt(&idea, msg_dec, msg_enc,
|
||||
(word32)strlen(message)+1);
|
||||
if(ret != 0)
|
||||
{
|
||||
// Some error occured
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_IdeaCbcEncrypt
|
||||
\sa wc_IdeaCipher
|
||||
\sa wc_IdeaSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_IdeaCbcDecrypt(Idea *idea, byte* out,
|
||||
const byte* in, word32 len);
|
76
doc/dox_comments/header_files/logging.h
Normal file
76
doc/dox_comments/header_files/logging.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*!
|
||||
\ingroup Logging
|
||||
|
||||
\brief This function registers a logging callback that will be used to
|
||||
handle the wolfSSL log message. By default, if the system supports it
|
||||
fprintf() to stderr is used but by using this function anything
|
||||
can be done by the user.
|
||||
|
||||
\return Success If successful this function will return 0.
|
||||
\return BAD_FUNC_ARG is the error that will be returned if a function
|
||||
pointer is not provided.
|
||||
|
||||
\param log_function function to register as a logging callback.
|
||||
Function signature must follow the above prototype.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret = 0;
|
||||
// Logging callback prototype
|
||||
void MyLoggingCallback(const int logLevel, const char* const logMessage);
|
||||
// Register the custom logging callback with wolfSSL
|
||||
ret = wolfSSL_SetLoggingCb(MyLoggingCallback);
|
||||
if (ret != 0) {
|
||||
// failed to set logging callback
|
||||
}
|
||||
void MyLoggingCallback(const int logLevel, const char* const logMessage)
|
||||
{
|
||||
// custom logging function
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Debugging_ON
|
||||
\sa wolfSSL_Debugging_OFF
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb log_function);
|
||||
/*!
|
||||
\ingroup Debug
|
||||
|
||||
\brief If logging has been enabled at build time this function turns on
|
||||
logging at runtime. To enable logging at build time use --enable-debug
|
||||
or define DEBUG_WOLFSSL.
|
||||
|
||||
\return 0 upon success.
|
||||
\return NOT_COMPILED_IN is the error that will be returned if logging
|
||||
isn’t enabled for this build.
|
||||
|
||||
\param none No parameters.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
wolfSSL_Debugging_ON();
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Debugging_OFF
|
||||
\sa wolfSSL_SetLoggingCb
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_Debugging_ON(void);
|
||||
/*!
|
||||
\ingroup Debug
|
||||
|
||||
\brief This function turns off runtime logging messages. If they’re
|
||||
already off, no action is taken.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param none No parameters.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
wolfSSL_Debugging_OFF();
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Debugging_ON
|
||||
\sa wolfSSL_SetLoggingCb
|
||||
*/
|
||||
WOLFSSL_API void wolfSSL_Debugging_OFF(void);
|
113
doc/dox_comments/header_files/md2.h
Normal file
113
doc/dox_comments/header_files/md2.h
Normal file
@ -0,0 +1,113 @@
|
||||
/*!
|
||||
\ingroup MD2
|
||||
|
||||
\brief This function initializes md2. This is automatically
|
||||
called by wc_Md2Hash.
|
||||
|
||||
\return 0 Returned upon successfully initializing
|
||||
|
||||
\param md2 pointer to the md2 structure to use for encryption
|
||||
|
||||
_Example_
|
||||
\code
|
||||
md2 md2[1];
|
||||
if ((ret = wc_InitMd2(md2)) != 0) {
|
||||
WOLFSSL_MSG("wc_Initmd2 failed");
|
||||
}
|
||||
else {
|
||||
wc_Md2Update(md2, data, len);
|
||||
wc_Md2Final(md2, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Md2Hash
|
||||
\sa wc_Md2Update
|
||||
\sa wc_Md2Final
|
||||
*/
|
||||
WOLFSSL_API void wc_InitMd2(Md2*);
|
||||
/*!
|
||||
\ingroup MD2
|
||||
|
||||
\brief Can be called to continually hash the provided byte
|
||||
array of length len.
|
||||
|
||||
\return 0 Returned upon successfully adding the data to the digest.
|
||||
|
||||
\param md2 pointer to the md2 structure to use for encryption
|
||||
\param data the data to be hashed
|
||||
\param len length of data to be hashed
|
||||
|
||||
_Example_
|
||||
\code
|
||||
md2 md2[1];
|
||||
byte data[] = { }; // Data to be hashed
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitMd2(md2)) != 0) {
|
||||
WOLFSSL_MSG("wc_Initmd2 failed");
|
||||
}
|
||||
else {
|
||||
wc_Md2Update(md2, data, len);
|
||||
wc_Md2Final(md2, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Md2Hash
|
||||
\sa wc_Md2Final
|
||||
\sa wc_InitMd2
|
||||
*/
|
||||
WOLFSSL_API void wc_Md2Update(Md2*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup MD2
|
||||
|
||||
\brief Finalizes hashing of data. Result is placed into hash.
|
||||
|
||||
\return 0 Returned upon successfully finalizing.
|
||||
|
||||
\param md2 pointer to the md2 structure to use for encryption
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
md2 md2[1];
|
||||
byte data[] = { }; // Data to be hashed
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitMd2(md2)) != 0) {
|
||||
WOLFSSL_MSG("wc_Initmd2 failed");
|
||||
}
|
||||
else {
|
||||
wc_Md2Update(md2, data, len);
|
||||
wc_Md2Final(md2, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Md2Hash
|
||||
\sa wc_Md2Final
|
||||
\sa wc_InitMd2
|
||||
*/
|
||||
WOLFSSL_API void wc_Md2Final(Md2*, byte*);
|
||||
/*!
|
||||
\ingroup MD2
|
||||
|
||||
\brief Convenience function, handles all the hashing and places
|
||||
the result into hash.
|
||||
|
||||
\return 0 Returned upon successfully hashing the data.
|
||||
\return Memory_E memory error, unable to allocate memory. This is only
|
||||
possible with the small stack option enabled.
|
||||
|
||||
\param data the data to hash
|
||||
\param len the length of data
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
none
|
||||
\endcode
|
||||
|
||||
\sa wc_Md2Hash
|
||||
\sa wc_Md2Final
|
||||
\sa wc_InitMd2
|
||||
*/
|
||||
WOLFSSL_API int wc_Md2Hash(const byte*, word32, byte*);
|
86
doc/dox_comments/header_files/md4.h
Normal file
86
doc/dox_comments/header_files/md4.h
Normal file
@ -0,0 +1,86 @@
|
||||
/*!
|
||||
\ingroup MD4
|
||||
|
||||
\brief This function initializes md4. This is automatically
|
||||
called by wc_Md4Hash.
|
||||
|
||||
\return 0 Returned upon successfully initializing
|
||||
|
||||
\param md4 pointer to the md4 structure to use for encryption
|
||||
|
||||
_Example_
|
||||
\code
|
||||
md4 md4[1];
|
||||
if ((ret = wc_InitMd4(md4)) != 0) {
|
||||
WOLFSSL_MSG("wc_Initmd4 failed");
|
||||
}
|
||||
else {
|
||||
wc_Md4Update(md4, data, len);
|
||||
wc_Md4Final(md4, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Md4Hash
|
||||
\sa wc_Md4Update
|
||||
\sa wc_Md4Final
|
||||
*/
|
||||
WOLFSSL_API void wc_InitMd4(Md4*);
|
||||
/*!
|
||||
\ingroup MD4
|
||||
|
||||
\brief Can be called to continually hash the provided byte array
|
||||
of length len.
|
||||
|
||||
\return 0 Returned upon successfully adding the data to the digest.
|
||||
|
||||
\param md4 pointer to the md4 structure to use for encryption
|
||||
\param data the data to be hashed
|
||||
\param len length of data to be hashed
|
||||
|
||||
_Example_
|
||||
\code
|
||||
md4 md4[1];
|
||||
byte data[] = { }; // Data to be hashed
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitMd4(md4)) != 0) {
|
||||
WOLFSSL_MSG("wc_Initmd4 failed");
|
||||
}
|
||||
else {
|
||||
wc_Md4Update(md4, data, len);
|
||||
wc_Md4Final(md4, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Md4Hash
|
||||
\sa wc_Md4Final
|
||||
\sa wc_InitMd4
|
||||
*/
|
||||
WOLFSSL_API void wc_Md4Update(Md4*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup MD4
|
||||
|
||||
\brief Finalizes hashing of data. Result is placed into hash.
|
||||
|
||||
\return 0 Returned upon successfully finalizing.
|
||||
|
||||
\param md4 pointer to the md4 structure to use for encryption
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
md4 md4[1];
|
||||
if ((ret = wc_InitMd4(md4)) != 0) {
|
||||
WOLFSSL_MSG("wc_Initmd4 failed");
|
||||
}
|
||||
else {
|
||||
wc_Md4Update(md4, data, len);
|
||||
wc_Md4Final(md4, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Md4Hash
|
||||
\sa wc_Md4Final
|
||||
\sa wc_InitMd4
|
||||
*/
|
||||
WOLFSSL_API void wc_Md4Final(Md4*, byte*);
|
176
doc/dox_comments/header_files/md5.h
Normal file
176
doc/dox_comments/header_files/md5.h
Normal file
@ -0,0 +1,176 @@
|
||||
/*!
|
||||
\ingroup MD5
|
||||
|
||||
\brief This function initializes md5. This is automatically
|
||||
called by wc_Md5Hash.
|
||||
|
||||
\return 0 Returned upon successfully initializing.
|
||||
\return BAD_FUNC_ARG Returned if the Md5 structure is passed
|
||||
as a NULL value.
|
||||
|
||||
\param md5 pointer to the md5 structure to use for encryption
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Md5 md5;
|
||||
byte* hash;
|
||||
if ((ret = wc_InitMd5(&md5)) != 0) {
|
||||
WOLFSSL_MSG("wc_Initmd5 failed");
|
||||
}
|
||||
else {
|
||||
ret = wc_Md5Update(&md5, data, len);
|
||||
if (ret != 0) {
|
||||
// Md5 Update Failure Case.
|
||||
}
|
||||
ret = wc_Md5Final(&md5, hash);
|
||||
if (ret != 0) {
|
||||
// Md5 Final Failure Case.
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Md5Hash
|
||||
\sa wc_Md5Update
|
||||
\sa wc_Md5Final
|
||||
*/
|
||||
WOLFSSL_API int wc_InitMd5(wc_Md5*);
|
||||
/*!
|
||||
\ingroup MD5
|
||||
|
||||
\brief Can be called to continually hash the provided byte array of
|
||||
length len.
|
||||
|
||||
\return 0 Returned upon successfully adding the data to the digest.
|
||||
\return BAD_FUNC_ARG Returned if the Md5 structure is NULL or if
|
||||
data is NULL and len is greater than zero. The function should
|
||||
not return an error if the data parameter is NULL and len is zero.
|
||||
|
||||
\param md5 pointer to the md5 structure to use for encryption
|
||||
\param data the data to be hashed
|
||||
\param len length of data to be hashed
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Md5 md5;
|
||||
byte data[] = { Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitMd5(&md5)) != 0) {
|
||||
WOLFSSL_MSG("wc_Initmd5 failed");
|
||||
}
|
||||
else {
|
||||
ret = wc_Md5Update(&md5, data, len);
|
||||
if (ret != 0) {
|
||||
// Md5 Update Error Case.
|
||||
}
|
||||
ret = wc_Md5Final(&md5, hash);
|
||||
if (ret != 0) {
|
||||
// Md5 Final Error Case.
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Md5Hash
|
||||
\sa wc_Md5Final
|
||||
\sa wc_InitMd5
|
||||
*/
|
||||
WOLFSSL_API int wc_Md5Update(wc_Md5*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup MD5
|
||||
|
||||
\brief Finalizes hashing of data. Result is placed into hash. Md5
|
||||
Struct is reset. Note: This function will also return the result
|
||||
of calling IntelQaSymMd5() in the case that HAVE_INTEL_QA is defined.
|
||||
|
||||
\return 0 Returned upon successfully finalizing.
|
||||
\return BAD_FUNC_ARG Returned if the Md5 structure or hash pointer
|
||||
is passed in NULL.
|
||||
|
||||
\param md5 pointer to the md5 structure to use for encryption
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
md5 md5[1];
|
||||
byte data[] = { Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitMd5(md5)) != 0) {
|
||||
WOLFSSL_MSG("wc_Initmd5 failed");
|
||||
}
|
||||
else {
|
||||
ret = wc_Md5Update(md5, data, len);
|
||||
if (ret != 0) {
|
||||
// Md5 Update Failure Case.
|
||||
}
|
||||
ret = wc_Md5Final(md5, hash);
|
||||
if (ret != 0) {
|
||||
// Md5 Final Failure Case.
|
||||
}
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Md5Hash
|
||||
\sa wc_InitMd5
|
||||
\sa wc_Md5GetHash
|
||||
*/
|
||||
WOLFSSL_API int wc_Md5Final(wc_Md5*, byte*);
|
||||
/*!
|
||||
\ingroup MD5
|
||||
|
||||
\brief Resets the Md5 structure. Note: this is only supported if
|
||||
you have WOLFSSL_TI_HASH defined.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param md5 Pointer to the Md5 structure to be reset.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Md5 md5;
|
||||
byte data[] = { Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitMd5(&md5)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitMd5 failed");
|
||||
}
|
||||
else {
|
||||
wc_Md5Update(&md5, data, len);
|
||||
wc_Md5Final(&md5, hash);
|
||||
wc_Md5Free(&md5);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitMd5
|
||||
\sa wc_Md5Update
|
||||
\sa wc_Md5Final
|
||||
*/
|
||||
WOLFSSL_API void wc_Md5Free(wc_Md5*);
|
||||
/*!
|
||||
\ingroup MD5
|
||||
|
||||
\brief Gets hash data. Result is placed into hash. Md5 struct
|
||||
is not reset.
|
||||
|
||||
\return none No returns
|
||||
|
||||
\param md5 pointer to the md5 structure to use for encryption.
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
md5 md5[1];
|
||||
if ((ret = wc_InitMd5(md5)) != 0) {
|
||||
WOLFSSL_MSG("wc_Initmd5 failed");
|
||||
}
|
||||
else {
|
||||
wc_Md5Update(md5, data, len);
|
||||
wc_Md5GetHash(md5, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Md5Hash
|
||||
\sa wc_Md5Final
|
||||
\sa wc_InitMd5
|
||||
*/
|
||||
WOLFSSL_API int wc_Md5GetHash(wc_Md5*, byte*);
|
292
doc/dox_comments/header_files/memory.h
Normal file
292
doc/dox_comments/header_files/memory.h
Normal file
@ -0,0 +1,292 @@
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This function calls the custom malloc function, if one has been
|
||||
defined, or simply calls the default C malloc function if no custom
|
||||
function exists. It is not called directly by wolfSSL, but instead
|
||||
generally called by using XMALLOC, which may be replaced by
|
||||
wolfSSL_Malloc during preprocessing.
|
||||
|
||||
\return Success On successfully allocating the desired memory,
|
||||
returns a void* to that location
|
||||
\return NULL Returned when there is a failure to allocate memory
|
||||
|
||||
\param size size, in bytes, of the memory to allocate
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int* tenInts = (int*)wolfSSL_Malloc(sizeof(int)*10);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Free
|
||||
\sa wolfSSL_Realloc
|
||||
\sa XMALLOC
|
||||
\sa XFREE
|
||||
\sa XREALLOC
|
||||
*/
|
||||
WOLFSSL_API void* wolfSSL_Malloc(size_t size, void* heap, int type, const char* func, unsigned int line);
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This function calls a custom free function, if one has been
|
||||
defined, or simply calls the default C free function if no custom
|
||||
function exists. It is not called directly by wolfSSL, but instead
|
||||
generally called by using XFREE, which may be replaced by wolfSSL_Free
|
||||
during preprocessing.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param ptr pointer to the memory to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int* tenInts = (int*)wolfSSL_Malloc(sizeof(int)*10);
|
||||
// process data as desired
|
||||
...
|
||||
if(tenInts) {
|
||||
wolfSSL_Free(tenInts);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Malloc
|
||||
\sa wolfSSL_Realloc
|
||||
\sa XMALLOC
|
||||
\sa XFREE
|
||||
\sa XREALLOC
|
||||
*/
|
||||
WOLFSSL_API void wolfSSL_Free(void *ptr, void* heap, int type, const char* func, unsigned int line);
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This function calls a custom realloc function, if one has been
|
||||
defined, or simply calls the default C realloc function if no custom
|
||||
function exists. It is not called directly by wolfSSL, but instead
|
||||
generally called by using XREALLOC, which may be replaced by
|
||||
wolfSSL_Realloc during preprocessing.
|
||||
|
||||
\return Success On successfully reallocating the desired memory,
|
||||
returns a void* to that location
|
||||
\return NULL Returned when there is a failure to reallocate memory
|
||||
|
||||
\param ptr pointer to the memory to the memory to reallocate
|
||||
\param size desired size after reallocation
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int* tenInts = (int*)wolfSSL_Malloc(sizeof(int)*10);
|
||||
int* twentyInts = (int*)realloc(tenInts, sizeof(tenInts)*2);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Malloc
|
||||
\sa wolfSSL_Free
|
||||
\sa XMALLOC
|
||||
\sa XFREE
|
||||
\sa XREALLOC
|
||||
*/
|
||||
WOLFSSL_API void* wolfSSL_Realloc(void *ptr, size_t size, void* heap, int type, const char* func, unsigned int line);
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This function is similar to malloc(), but calls the memory
|
||||
allocation function which wolfSSL has been configured to use. By default,
|
||||
wolfSSL uses malloc(). This can be changed using the wolfSSL memory
|
||||
abstraction layer - see wolfSSL_SetAllocators().
|
||||
|
||||
\return pointer If successful, this function returns a pointer to
|
||||
allocated memory.
|
||||
\return error If there is an error, NULL will be returned.
|
||||
\return other Specific return values may be dependent on the underlying
|
||||
memory allocation function being used (if not using the default malloc()).
|
||||
|
||||
\param size number of bytes to allocate.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
char* buffer;
|
||||
buffer = (char*) wolfSSL_Malloc(20);
|
||||
if (buffer == NULL) {
|
||||
// failed to allocate memory
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Free
|
||||
\sa wolfSSL_Realloc
|
||||
\sa wolfSSL_SetAllocators
|
||||
*/
|
||||
WOLFSSL_API void* wolfSSL_Malloc(size_t size, void* heap, int type);
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This function is similar to realloc(), but calls the memory
|
||||
re-allocation function which wolfSSL has been configured to use.
|
||||
By default, wolfSSL uses realloc(). This can be changed using the
|
||||
wolfSSL memory abstraction layer - see wolfSSL_SetAllocators().
|
||||
|
||||
\return pointer If successful, this function returns a pointer to
|
||||
re-allocated memory. This may be the same pointer as ptr, or a
|
||||
new pointer location.
|
||||
\return Null If there is an error, NULL will be returned.
|
||||
\return other Specific return values may be dependent on the
|
||||
underlying memory re-allocation function being used
|
||||
(if not using the default realloc()).
|
||||
|
||||
\param ptr pointer to the previously-allocated memory, to be reallocated.
|
||||
\param size number of bytes to allocate.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
char* buffer;
|
||||
|
||||
buffer = (char*) wolfSSL_Realloc(30);
|
||||
if (buffer == NULL) {
|
||||
// failed to re-allocate memory
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Free
|
||||
\sa wolfSSL_Malloc
|
||||
\sa wolfSSL_SetAllocators
|
||||
*/
|
||||
WOLFSSL_API void* wolfSSL_Realloc(void *ptr, size_t size, void* heap, int type);
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This function is similar to free(), but calls the memory free
|
||||
function which wolfSSL has been configured to use. By default, wolfSSL
|
||||
uses free(). This can be changed using the wolfSSL memory abstraction
|
||||
layer - see wolfSSL_SetAllocators().
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param ptr pointer to the memory to be freed.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
char* buffer;
|
||||
...
|
||||
wolfSSL_Free(buffer);
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Alloc
|
||||
\sa wolfSSL_Realloc
|
||||
\sa wolfSSL_SetAllocators
|
||||
*/
|
||||
WOLFSSL_API void wolfSSL_Free(void *ptr, const char* func, unsigned int line);
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This function registers the allocation functions used by wolfSSL.
|
||||
By default, if the system supports it, malloc/free and realloc are used.
|
||||
Using this function allows the user at runtime to install their own
|
||||
memory handlers.
|
||||
|
||||
\return Success If successful this function will return 0.
|
||||
\return BAD_FUNC_ARG is the error that will be returned if a
|
||||
function pointer is not provided.
|
||||
|
||||
\param malloc_function memory allocation function for wolfSSL to use.
|
||||
Function signature must match wolfSSL_Malloc_cb prototype, above.
|
||||
\param free_function memory free function for wolfSSL to use. Function
|
||||
signature must match wolfSSL_Free_cb prototype, above.
|
||||
\param realloc_function memory re-allocation function for wolfSSL to use.
|
||||
Function signature must match wolfSSL_Realloc_cb prototype, above.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret = 0;
|
||||
// Memory function prototypes
|
||||
void* MyMalloc(size_t size);
|
||||
void MyFree(void* ptr);
|
||||
void* MyRealloc(void* ptr, size_t size);
|
||||
|
||||
// Register custom memory functions with wolfSSL
|
||||
ret = wolfSSL_SetAllocators(MyMalloc, MyFree, MyRealloc);
|
||||
if (ret != 0) {
|
||||
// failed to set memory functions
|
||||
}
|
||||
|
||||
void* MyMalloc(size_t size)
|
||||
{
|
||||
// custom malloc function
|
||||
}
|
||||
|
||||
void MyFree(void* ptr)
|
||||
{
|
||||
// custom free function
|
||||
}
|
||||
|
||||
void* MyRealloc(void* ptr, size_t size)
|
||||
{
|
||||
// custom realloc function
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa none
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_SetAllocators(wolfSSL_Malloc_cb,
|
||||
wolfSSL_Free_cb,
|
||||
wolfSSL_Realloc_cb);
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This function is available when static memory feature is used
|
||||
(--enable-staticmemory). It gives the optimum buffer size for memory
|
||||
“buckets”. This allows for a way to compute buffer size so that no
|
||||
extra unused memory is left at the end after it has been partitioned.
|
||||
The returned value, if positive, is the computed buffer size to use.
|
||||
|
||||
\return Success On successfully completing buffer size calculations a
|
||||
positive value is returned. This returned value is for optimum buffer size.
|
||||
\return Failure All negative values are considered to be error cases.
|
||||
|
||||
\param buffer pointer to buffer
|
||||
\param size size of buffer
|
||||
\param type desired type of memory ie WOLFMEM_GENERAL or WOLFMEM_IO_POOL
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte buffer[1000];
|
||||
word32 size = sizeof(buffer);
|
||||
int optimum;
|
||||
optimum = wolfSSL_StaticBufferSz(buffer, size, WOLFMEM_GENERAL);
|
||||
if (optimum < 0) { //handle error case }
|
||||
printf(“The optimum buffer size to make use of all memory is %d\n”,
|
||||
optimum);
|
||||
...
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Malloc
|
||||
\sa wolfSSL_Free
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_StaticBufferSz(byte* buffer, word32 sz, int flag);
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This function is available when static memory feature is used
|
||||
(--enable-staticmemory). It gives the size of padding needed for each
|
||||
partition of memory. This padding size will be the size needed to
|
||||
contain a memory management structure along with any extra for
|
||||
memory alignment.
|
||||
|
||||
\return On successfully memory padding calculation the return value will
|
||||
be a positive value
|
||||
\return All negative values are considered error cases.
|
||||
|
||||
\param none No parameters.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int padding;
|
||||
padding = wolfSSL_MemoryPaddingSz();
|
||||
if (padding < 0) { //handle error case }
|
||||
printf(“The padding size needed for each \”bucket\” of memory is %d\n”,
|
||||
padding);
|
||||
// calculation of buffer for IO POOL size is number of buckets
|
||||
// times (padding + WOLFMEM_IO_SZ)
|
||||
...
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Malloc
|
||||
\sa wolfSSL_Free
|
||||
*/
|
||||
WOLFSSL_API int wolfSSL_MemoryPaddingSz(void);
|
34
doc/dox_comments/header_files/pem.h
Normal file
34
doc/dox_comments/header_files/pem.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*!
|
||||
\ingroup openSSL
|
||||
|
||||
\brief This function writes a key into a WOLFSSL_BIO structure
|
||||
in PEM format.
|
||||
|
||||
\return SSL_SUCCESS upon success.
|
||||
\return SSL_FAILURE upon failure.
|
||||
|
||||
\param bio WOLFSSL_BIO structure to get PEM buffer from.
|
||||
\param key key to convert to PEM format.
|
||||
\param cipher EVP cipher structure.
|
||||
\param passwd password.
|
||||
\param len length of password.
|
||||
\param cb password callback.
|
||||
\param arg optional argument.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_BIO* bio;
|
||||
WOLFSSL_EVP_PKEY* key;
|
||||
int ret;
|
||||
// create bio and setup key
|
||||
ret = wolfSSL_PEM_write_bio_PrivateKey(bio, key, NULL, NULL, 0, NULL, NULL);
|
||||
//check ret value
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_PEM_read_bio_X509_AUX
|
||||
*/
|
||||
WOLFSSL_API
|
||||
int wolfSSL_PEM_write_bio_PrivateKey(WOLFSSL_BIO* bio, WOLFSSL_EVP_PKEY* key,
|
||||
const WOLFSSL_EVP_CIPHER* cipher,
|
||||
unsigned char* passwd, int len,
|
||||
pem_password_cb* cb, void* arg);
|
402
doc/dox_comments/header_files/pkcs7.h
Normal file
402
doc/dox_comments/header_files/pkcs7.h
Normal file
@ -0,0 +1,402 @@
|
||||
/*!
|
||||
\ingroup PKCS7
|
||||
|
||||
\brief This function initializes a PKCS7 structure with a DER-formatted
|
||||
certificate. To initialize an empty PKCS7 structure, one can pass in a NULL
|
||||
cert and 0 for certSz.
|
||||
|
||||
\return 0 Returned on successfully initializing the PKCS7 structure
|
||||
\return MEMORY_E Returned if there is an error allocating memory
|
||||
with XMALLOC
|
||||
\return ASN_PARSE_E Returned if there is an error parsing the cert header
|
||||
\return ASN_OBJECT_ID_E Returned if there is an error parsing the
|
||||
encryption type from the cert
|
||||
\return ASN_EXPECT_0_E Returned if there is a formatting error in the
|
||||
encryption specification of the cert file
|
||||
\return ASN_BEFORE_DATE_E Returned if the date is before the certificate
|
||||
start date
|
||||
\return ASN_AFTER_DATE_E Returned if the date is after the certificate
|
||||
expiration date
|
||||
\return ASN_BITSTR_E Returned if there is an error parsing a bit string
|
||||
from the certificate
|
||||
\return ASN_NTRU_KEY_E Returned if there is an error parsing the NTRU
|
||||
key from the certificate
|
||||
\return ECC_CURVE_OID_E Returned if there is an error parsing the ECC
|
||||
key from the certificate
|
||||
\return ASN_UNKNOWN_OID_E Returned if the certificate is using an unknown
|
||||
key object id
|
||||
\return ASN_VERSION_E Returned if the ALLOW_V1_EXTENSIONS option is not
|
||||
defined and the certificate is a V1 or V2 certificate
|
||||
\return BAD_FUNC_ARG Returned if there is an error processing the
|
||||
certificate extension
|
||||
\return ASN_CRIT_EXT_E Returned if an unfamiliar critical extension is
|
||||
encountered in processing the certificate
|
||||
\return ASN_SIG_OID_E Returned if the signature encryption type is not
|
||||
the same as the encryption type of the certificate in the provided file
|
||||
\return ASN_SIG_CONFIRM_E Returned if confirming the certification
|
||||
signature fails
|
||||
\return ASN_NAME_INVALID_E Returned if the certificate’s name is not
|
||||
permitted by the CA name constraints
|
||||
\return ASN_NO_SIGNER_E Returned if there is no CA signer to verify
|
||||
the certificate’s authenticity
|
||||
|
||||
\param pkcs7 pointer to the PKCS7 structure in which to
|
||||
store the decoded cert
|
||||
\param cert pointer to a buffer containing a DER formatted ASN.1
|
||||
certificate with which to initialize the PKCS7 structure
|
||||
\param certSz size of the certificate buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
PKCS7 pkcs7;
|
||||
byte derBuff[] = { }; // initialize with DER-encoded certificate
|
||||
if ( wc_PKCS7_InitWithCert(&pkcs7, derBuff, sizeof(derBuff)) != 0 ) {
|
||||
// error parsing certificate into pkcs7 format
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_PKCS7_Free
|
||||
*/
|
||||
WOLFSSL_API int wc_PKCS7_InitWithCert(PKCS7* pkcs7, byte* cert, word32 certSz);
|
||||
/*!
|
||||
\ingroup PKCS7
|
||||
|
||||
\brief This function releases any memory allocated by a PKCS7 initializer.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param pkcs7 pointer to the PKCS7 structure to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
PKCS7 pkcs7;
|
||||
// initialize and use PKCS7 object
|
||||
|
||||
wc_PKCS7_Free(pkcs7);
|
||||
\endcode
|
||||
|
||||
\sa wc_PKCS7_InitWithCert
|
||||
*/
|
||||
WOLFSSL_API void wc_PKCS7_Free(PKCS7* pkcs7);
|
||||
/*!
|
||||
\ingroup PKCS7
|
||||
|
||||
\brief This function builds the PKCS7 data content type, encoding the
|
||||
PKCS7 structure into a buffer containing a parsable PKCS7 data packet.
|
||||
|
||||
\return Success On successfully encoding the PKCS7 data into the buffer,
|
||||
returns the index parsed up to in the PKCS7 structure. This index also
|
||||
corresponds to the bytes written to the output buffer.
|
||||
\return BUFFER_E Returned if the given buffer is not large enough to hold
|
||||
the encoded certificate
|
||||
|
||||
\param pkcs7 pointer to the PKCS7 structure to encode
|
||||
\param output pointer to the buffer in which to store the encoded
|
||||
certificate
|
||||
\param outputSz size available in the output buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
PKCS7 pkcs7;
|
||||
int ret;
|
||||
|
||||
byte derBuff[] = { }; // initialize with DER-encoded certificate
|
||||
byte pkcs7Buff[FOURK_BUF];
|
||||
|
||||
wc_PKCS7_InitWithCert(&pkcs7, derBuff, sizeof(derBuff));
|
||||
// update message and data to encode
|
||||
pkcs7.privateKey = key;
|
||||
pkcs7.privateKeySz = keySz;
|
||||
pkcs7.content = data;
|
||||
pkcs7.contentSz = dataSz;
|
||||
... etc.
|
||||
|
||||
ret = wc_PKCS7_EnocodeData(&pkcs7, pkcs7Buff, sizeof(pkcs7Buff));
|
||||
if ( ret != 0 ) {
|
||||
// error encoding into output buffer
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_PKCS7_InitWithCert
|
||||
*/
|
||||
WOLFSSL_API int wc_PKCS7_EncodeData(PKCS7* pkcs7, byte* output,
|
||||
word32 outputSz);
|
||||
/*!
|
||||
\ingroup PKCS7
|
||||
|
||||
\brief This function builds the PKCS7 signed data content type, encoding
|
||||
the PKCS7 structure into a buffer containing a parsable PKCS7
|
||||
signed data packet.
|
||||
|
||||
\return Success On successfully encoding the PKCS7 data into the buffer,
|
||||
returns the index parsed up to in the PKCS7 structure. This index also
|
||||
corresponds to the bytes written to the output buffer.
|
||||
\return BAD_FUNC_ARG Returned if the PKCS7 structure is missing one or
|
||||
more required elements to generate a signed data packet
|
||||
\return MEMORY_E Returned if there is an error allocating memory
|
||||
\return PUBLIC_KEY_E Returned if there is an error parsing the public key
|
||||
\return RSA_BUFFER_E Returned if buffer error, output too small or input
|
||||
too large
|
||||
\return BUFFER_E Returned if the given buffer is not large enough to hold
|
||||
the encoded certificate
|
||||
\return MP_INIT_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_READ_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_CMP_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_INVMOD_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_EXPTMOD_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_MOD_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_MUL_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_ADD_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_MULMOD_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_TO_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_MEM may be returned if there is an error generating the signature
|
||||
|
||||
\param pkcs7 pointer to the PKCS7 structure to encode
|
||||
\param output pointer to the buffer in which to store the
|
||||
encoded certificate
|
||||
\param outputSz size available in the output buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
PKCS7 pkcs7;
|
||||
int ret;
|
||||
|
||||
byte derBuff[] = { }; // initialize with DER-encoded certificate
|
||||
byte pkcs7Buff[FOURK_BUF];
|
||||
|
||||
wc_PKCS7_InitWithCert(&pkcs7, derBuff, sizeof(derBuff));
|
||||
// update message and data to encode
|
||||
pkcs7.privateKey = key;
|
||||
pkcs7.privateKeySz = keySz;
|
||||
pkcs7.content = data;
|
||||
pkcs7.contentSz = dataSz;
|
||||
... etc.
|
||||
|
||||
ret = wc_PKCS7_EnocodeSignedData(&pkcs7, pkcs7Buff, sizeof(pkcs7Buff));
|
||||
if ( ret != 0 ) {
|
||||
// error encoding into output buffer
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_PKCS7_InitWithCert
|
||||
\sa wc_PKCS7_VerifySignedData
|
||||
*/
|
||||
WOLFSSL_API int wc_PKCS7_EncodeSignedData(PKCS7* pkcs7,
|
||||
byte* output, word32 outputSz);
|
||||
/*!
|
||||
\ingroup PKCS7
|
||||
|
||||
\brief This function takes in a transmitted PKCS7 signed data message,
|
||||
extracts the certificate list and certificate revocation list, and then
|
||||
verifies the signature. It stores the extracted content in the given
|
||||
PKCS7 structure.
|
||||
|
||||
\return 0 Returned on successfully extracting the information
|
||||
from the message
|
||||
\return BAD_FUNC_ARG Returned if one of the input parameters is invalid
|
||||
\return ASN_PARSE_E Returned if there is an error parsing from the
|
||||
given pkiMsg
|
||||
\return PKCS7_OID_E Returned if the given pkiMsg is not a signed data type
|
||||
\return ASN_VERSION_E Returned if the PKCS7 signer info is not version 1
|
||||
\return MEMORY_E Returned if there is an error allocating memory
|
||||
\return PUBLIC_KEY_E Returned if there is an error parsing the public key
|
||||
\return RSA_BUFFER_E Returned if buffer error, output too small or
|
||||
input too large
|
||||
\return BUFFER_E Returned if the given buffer is not large enough to
|
||||
hold the encoded certificate
|
||||
\return MP_INIT_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_READ_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_CMP_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_INVMOD_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_EXPTMOD_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_MOD_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_MUL_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_ADD_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_MULMOD_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_TO_E may be returned if there is an error generating
|
||||
the signature
|
||||
\return MP_MEM may be returned if there is an error generating the signature
|
||||
|
||||
\param pkcs7 pointer to the PKCS7 structure in which to store the parsed
|
||||
certificates
|
||||
\param pkiMsg pointer to the buffer containing the signed message to verify
|
||||
and decode
|
||||
\param pkiMsgSz size of the signed message
|
||||
|
||||
_Example_
|
||||
\code
|
||||
PKCS7 pkcs7;
|
||||
int ret;
|
||||
|
||||
byte derBuff[] = { }; // initialize with DER-encoded certificate
|
||||
byte pkcs7Buff[FOURK_BUF];
|
||||
|
||||
wc_PKCS7_InitWithCert(&pkcs7, derBuff, sizeof(derBuff));
|
||||
// update message and data to encode
|
||||
pkcs7.privateKey = key;
|
||||
pkcs7.privateKeySz = keySz;
|
||||
pkcs7.content = data;
|
||||
pkcs7.contentSz = dataSz;
|
||||
... etc.
|
||||
|
||||
ret = wc_PKCS7_EnocodeSignedData(&pkcs7, pkcs7Buff, sizeof(pkcs7Buff));
|
||||
if ( ret != 0 ) {
|
||||
// error encoding into output buffer
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_PKCS7_InitWithCert
|
||||
\sa wc_PKCS7_EncodeSignedData
|
||||
*/
|
||||
WOLFSSL_API int wc_PKCS7_VerifySignedData(PKCS7* pkcs7,
|
||||
byte* pkiMsg, word32 pkiMsgSz);
|
||||
/*!
|
||||
\ingroup PKCS7
|
||||
|
||||
\brief This function builds the PKCS7 enveloped data content type, encoding
|
||||
the PKCS7 structure into a buffer containing a parsable PKCS7 enveloped
|
||||
data packet.
|
||||
|
||||
\return Success Returned on successfully encoding the message in enveloped
|
||||
data format, returns the size written to the output buffer
|
||||
\return BAD_FUNC_ARG: Returned if one of the input parameters is invalid,
|
||||
or if the PKCS7 structure is missing required elements
|
||||
\return ALGO_ID_E Returned if the PKCS7 structure is using an unsupported
|
||||
algorithm type. Currently, only DESb and DES3b are supported
|
||||
\return BUFFER_E Returned if the given output buffer is too small to store
|
||||
the output data
|
||||
\return MEMORY_E Returned if there is an error allocating memory
|
||||
\return RNG_FAILURE_E Returned if there is an error initializing the random
|
||||
number generator for encryption
|
||||
\return DRBG_FAILED Returned if there is an error generating numbers with
|
||||
the random number generator used for encryption
|
||||
|
||||
\param pkcs7 pointer to the PKCS7 structure to encode
|
||||
\param output pointer to the buffer in which to store the encoded
|
||||
certificate
|
||||
\param outputSz size available in the output buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
PKCS7 pkcs7;
|
||||
int ret;
|
||||
|
||||
byte derBuff[] = { }; // initialize with DER-encoded certificate
|
||||
byte pkcs7Buff[FOURK_BUF];
|
||||
|
||||
wc_PKCS7_InitWithCert(&pkcs7, derBuff, sizeof(derBuff));
|
||||
// update message and data to encode
|
||||
pkcs7.privateKey = key;
|
||||
pkcs7.privateKeySz = keySz;
|
||||
pkcs7.content = data;
|
||||
pkcs7.contentSz = dataSz;
|
||||
... etc.
|
||||
|
||||
ret = wc_PKCS7_EncodeEnvelopedData(&pkcs7, pkcs7Buff, sizeof(pkcs7Buff));
|
||||
if ( ret != 0 ) {
|
||||
// error encoding into output buffer
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_PKCS7_InitWithCert
|
||||
\sa wc_PKCS7_DecodeEnvelopedData
|
||||
*/
|
||||
WOLFSSL_API int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7,
|
||||
byte* output, word32 outputSz);
|
||||
/*!
|
||||
\ingroup PKCS7
|
||||
|
||||
\brief This function unwraps and decrypts a PKCS7 enveloped data content
|
||||
type, decoding the message into output. It uses the private key of the
|
||||
PKCS7 object passed in to decrypt the message.
|
||||
|
||||
\return On successfully extracting the information from the message,
|
||||
returns the bytes written to output
|
||||
\return BAD_FUNC_ARG Returned if one of the input parameters is invalid
|
||||
\return ASN_PARSE_E Returned if there is an error parsing from the
|
||||
given pkiMsg
|
||||
\return PKCS7_OID_E Returned if the given pkiMsg is not an enveloped
|
||||
data type
|
||||
\return ASN_VERSION_E Returned if the PKCS7 signer info is not version 0
|
||||
\return MEMORY_E Returned if there is an error allocating memory
|
||||
\return ALGO_ID_E Returned if the PKCS7 structure is using an unsupported
|
||||
algorithm type. Currently, only DESb and DES3b are supported for
|
||||
encryption, with RSAk for signature generation
|
||||
\return PKCS7_RECIP_E Returned if there is no recipient found in the
|
||||
enveloped data that matches the recipient provided
|
||||
\return RSA_BUFFER_E Returned if there is an error during RSA signature
|
||||
verification due to buffer error, output too small or input too large.
|
||||
\return MP_INIT_E may be returned if there is an error during signature
|
||||
verification
|
||||
\return MP_READ_E may be returned if there is an error during signature
|
||||
verification
|
||||
\return MP_CMP_E may be returned if there is an error during signature
|
||||
verification
|
||||
\return MP_INVMOD_E may be returned if there is an error during signature
|
||||
verification
|
||||
\return MP_EXPTMOD_E may be returned if there is an error during signature
|
||||
verification
|
||||
\return MP_MOD_E may be returned if there is an error during signature
|
||||
verification
|
||||
\return MP_MUL_E may be returned if there is an error during signature
|
||||
verification
|
||||
\return MP_ADD_E may be returned if there is an error during signature
|
||||
verification
|
||||
\return MP_MULMOD_E may be returned if there is an error during signature
|
||||
verification
|
||||
\return MP_TO_E may be returned if there is an error during signature
|
||||
verification
|
||||
\return MP_MEM may be returned if there is an error during signature
|
||||
verification
|
||||
|
||||
\param pkcs7 pointer to the PKCS7 structure containing the private key with
|
||||
which to decode the enveloped data package
|
||||
\param pkiMsg pointer to the buffer containing the enveloped data package
|
||||
\param pkiMsgSz size of the enveloped data package
|
||||
\param output pointer to the buffer in which to store the decoded message
|
||||
\param outputSz size available in the output buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
PKCS7 pkcs7;
|
||||
byte received[] = { }; // initialize with received enveloped message
|
||||
byte decoded[FOURK_BUF];
|
||||
int decodedSz;
|
||||
|
||||
// initialize pkcs7 with certificate
|
||||
// update key
|
||||
pkcs7.privateKey = key;
|
||||
pkcs7.privateKeySz = keySz;
|
||||
|
||||
decodedSz = wc_PKCS7_DecodeEnvelopedData(&pkcs7, received,
|
||||
sizeof(received),decoded, sizeof(decoded));
|
||||
if ( decodedSz != 0 ) {
|
||||
// error decoding message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_PKCS7_InitWithCert
|
||||
\sa wc_PKCS7_EncodeEnvelopedData
|
||||
*/
|
||||
WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg,
|
||||
word32 pkiMsgSz, byte* output,
|
||||
word32 outputSz);
|
136
doc/dox_comments/header_files/poly1305.h
Normal file
136
doc/dox_comments/header_files/poly1305.h
Normal file
@ -0,0 +1,136 @@
|
||||
/*!
|
||||
\ingroup Poly1305
|
||||
|
||||
\brief This function sets the key for a Poly1305 context structure,
|
||||
initializing it for hashing. Note: A new key should be set after
|
||||
generating a message hash with wc_Poly1305Final to ensure security.
|
||||
|
||||
\return 0 Returned on successfully setting the key and initializing
|
||||
the Poly1305 structure
|
||||
\return BAD_FUNC_ARG Returned if the given key is not 32 bytes long,
|
||||
or the Poly1305 context is NULL
|
||||
|
||||
\param ctx pointer to a Poly1305 structure to initialize
|
||||
\param key pointer to the buffer containing the key to use for hashing
|
||||
\param keySz size of the key in the buffer. Should be 32 bytes
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Poly1305 enc;
|
||||
byte key[] = { initialize with 32 byte key to use for hashing };
|
||||
wc_Poly1305SetKey(&enc, key, sizeof(key));
|
||||
\endcode
|
||||
|
||||
\sa wc_Poly1305Update
|
||||
\sa wc_Poly1305Final
|
||||
*/
|
||||
WOLFSSL_API int wc_Poly1305SetKey(Poly1305* poly1305, const byte* key,
|
||||
word32 kySz);
|
||||
/*!
|
||||
\ingroup Poly1305
|
||||
|
||||
\brief This function updates the message to hash with the
|
||||
Poly1305 structure.
|
||||
|
||||
\return 0 Returned on successfully updating the message to hash
|
||||
\return BAD_FUNC_ARG Returned if the Poly1305 structure is NULL
|
||||
|
||||
\param ctx pointer to a Poly1305 structure for which to update
|
||||
the message to hash
|
||||
\param m pointer to the buffer containing the message which should
|
||||
be added to the hash
|
||||
\param bytes size of the message to hash
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Poly1305 enc;
|
||||
byte key[] = { }; // initialize with 32 byte key to use for encryption
|
||||
|
||||
byte msg[] = { }; // initialize with message to hash
|
||||
wc_Poly1305SetKey(&enc, key, sizeof(key));
|
||||
|
||||
if( wc_Poly1305Update(key, msg, sizeof(msg)) != 0 ) {
|
||||
// error updating message to hash
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Poly1305SetKey
|
||||
\sa wc_Poly1305Final
|
||||
*/
|
||||
WOLFSSL_API int wc_Poly1305Update(Poly1305* poly1305, const byte*, word32);
|
||||
/*!
|
||||
\ingroup Poly1305
|
||||
|
||||
\brief This function calculates the hash of the input messages
|
||||
and stores the result in mac. After this is called, the key
|
||||
should be reset.
|
||||
|
||||
\return 0 Returned on successfully computing the final MAC
|
||||
\return BAD_FUNC_ARG Returned if the Poly1305 structure is NULL
|
||||
|
||||
\param ctx pointer to a Poly1305 structure with which to generate the MAC
|
||||
\param mac pointer to the buffer in which to store the MAC.
|
||||
Should be POLY1305_DIGEST_SIZE (16 bytes) wide
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Poly1305 enc;
|
||||
byte mac[POLY1305_DIGEST_SIZE]; // space for a 16 byte mac
|
||||
|
||||
byte key[] = { }; // initialize with 32 byte key to use for encryption
|
||||
|
||||
byte msg[] = { }; // initialize with message to hash
|
||||
wc_Poly1305SetKey(&enc, key, sizeof(key));
|
||||
wc_Poly1305Update(key, msg, sizeof(msg));
|
||||
|
||||
if ( wc_Poly1305Final(&enc, mac) != 0 ) {
|
||||
// error computing final MAC
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Poly1305SetKey
|
||||
\sa wc_Poly1305Update
|
||||
*/
|
||||
WOLFSSL_API int wc_Poly1305Final(Poly1305* poly1305, byte* tag);
|
||||
/*!
|
||||
\ingroup Poly1305
|
||||
|
||||
\brief Takes in an initialized Poly1305 struct that has a key
|
||||
loaded and creates a MAC (tag) using recent TLS AEAD padding scheme.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returned if ctx, input, or tag is null or if
|
||||
additional is null and addSz is greater than 0 or if tagSz is less
|
||||
than WC_POLY1305_MAC_SZ.
|
||||
|
||||
\param ctx Initialized Poly1305 struct to use
|
||||
\param additional Additional data to use
|
||||
\param addSz Size of additional buffer
|
||||
\param input Input buffer to create tag from
|
||||
\param sz Size of input buffer
|
||||
\param tag Buffer to hold created tag
|
||||
\param tagSz Size of input tag buffer (must be at least
|
||||
WC_POLY1305_MAC_SZ(16))
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Poly1305 ctx;
|
||||
byte key[] = { }; // initialize with 32 byte key to use for hashing
|
||||
byte additional[] = { }; // initialize with additional data
|
||||
byte msg[] = { }; // initialize with message
|
||||
byte tag[16];
|
||||
|
||||
wc_Poly1305SetKey(&ctx, key, sizeof(key));
|
||||
if(wc_Poly1305_MAC(&ctx, additional, sizeof(additional), (byte*)msg,
|
||||
sizeof(msg), tag, sizeof(tag)) != 0)
|
||||
{
|
||||
// Handle the error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Poly1305SetKey
|
||||
\sa wc_Poly1305Update
|
||||
\sa wcPoly1305Final
|
||||
*/
|
||||
WOLFSSL_API int wc_Poly1305_MAC(Poly1305* ctx, byte* additional, word32 addSz,
|
||||
byte* input, word32 sz, byte* tag, word32 tagSz);
|
164
doc/dox_comments/header_files/pwdbased.h
Normal file
164
doc/dox_comments/header_files/pwdbased.h
Normal file
@ -0,0 +1,164 @@
|
||||
/*!
|
||||
\ingroup Password
|
||||
|
||||
\brief This function implements the Password Based Key Derivation
|
||||
Function 1 (PBKDF1), converting an input password with a concatenated salt
|
||||
into a more secure key, which it stores in output. It allows the user to
|
||||
select between SHA and MD5 as hash functions.
|
||||
|
||||
\return 0 Returned on successfully deriving a key from the input password
|
||||
\return BAD_FUNC_ARG Returned if there is an invalid hash type given
|
||||
(valid type are: MD5 and SHA), iterations is less than 1, or the key
|
||||
length (kLen) requested is greater than the hash length of the provided hash
|
||||
\return MEMORY_E Returned if there is an error allocating memory for a
|
||||
SHA or MD5 object
|
||||
|
||||
\param output pointer to the buffer in which to store the generated key.
|
||||
Should be at least kLen long
|
||||
\param passwd pointer to the buffer containing the password to use for
|
||||
the key derivation
|
||||
\param pLen length of the password to use for key derivation
|
||||
\param salt pointer to the buffer containing the salt to use for
|
||||
key derivation
|
||||
\param sLen length of the salt
|
||||
\param iterations number of times to process the hash
|
||||
\param kLen desired length of the derived key. Should not be longer
|
||||
than the digest size of the hash chosen
|
||||
\param hashType the hashing algorithm to use. Valid choices are MD5 and SHA
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte key[MD5_DIGEST_SIZE];
|
||||
byte pass[] = { }; // initialize with password
|
||||
byte salt[] = { }; // initialize with salt
|
||||
|
||||
ret = wc_PBKDF1(key, pass, sizeof(pass), salt, sizeof(salt), 1000,
|
||||
sizeof(key), MD5);
|
||||
if ( ret != 0 ) {
|
||||
// error deriving key from password
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_PBKDF2
|
||||
\sa wc_PKCS12_PBKDF
|
||||
*/
|
||||
WOLFSSL_API int wc_PBKDF1(byte* output, const byte* passwd, int pLen,
|
||||
const byte* salt, int sLen, int iterations, int kLen,
|
||||
int typeH);
|
||||
/*!
|
||||
\ingroup Password
|
||||
|
||||
\brief This function implements the Password Based Key Derivation
|
||||
Function 2 (PBKDF2), converting an input password with a concatenated
|
||||
salt into a more secure key, which it stores in output. It allows the user
|
||||
to select any of the supported HMAC hash functions, including: MD5, SHA,
|
||||
SHA256, SHA384, SHA512, and BLAKE2B
|
||||
|
||||
\return 0 Returned on successfully deriving a key from the input password
|
||||
\return BAD_FUNC_ARG Returned if there is an invalid hash type given or
|
||||
iterations is less than 1
|
||||
\return MEMORY_E Returned if there is an allocating memory for
|
||||
the HMAC object
|
||||
|
||||
\param output pointer to the buffer in which to store the generated key.
|
||||
Should be kLen long
|
||||
\param passwd pointer to the buffer containing the password to use for
|
||||
the key derivation
|
||||
\param pLen length of the password to use for key derivation
|
||||
\param salt pointer to the buffer containing the salt to use for
|
||||
key derivation
|
||||
\param sLen length of the salt
|
||||
\param iterations number of times to process the hash
|
||||
\param kLen desired length of the derived key
|
||||
\param hashType the hashing algorithm to use. Valid choices are: MD5,
|
||||
SHA, SHA256, SHA384, SHA512, and BLAKE2B
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte key[64];
|
||||
byte pass[] = { }; // initialize with password
|
||||
byte salt[] = { }; // initialize with salt
|
||||
|
||||
ret = wc_PBKDF2(key, pass, sizeof(pass), salt, sizeof(salt), 2048, sizeof(key),
|
||||
SHA512);
|
||||
if ( ret != 0 ) {
|
||||
// error deriving key from password
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_PBKDF1
|
||||
\sa wc_PKCS12_PBKDF
|
||||
*/
|
||||
WOLFSSL_API int wc_PBKDF2(byte* output, const byte* passwd, int pLen,
|
||||
const byte* salt, int sLen, int iterations, int kLen,
|
||||
int typeH);
|
||||
/*!
|
||||
\ingroup Password
|
||||
|
||||
\brief This function implements the Password Based Key Derivation Function
|
||||
(PBKDF) described in RFC 7292 Appendix B. This function converts an input
|
||||
password with a concatenated salt into a more secure key, which it stores
|
||||
in output. It allows the user to select any of the supported HMAC hash
|
||||
functions, including: MD5, SHA, SHA256, SHA384, SHA512, and BLAKE2B.
|
||||
|
||||
\return 0 Returned on successfully deriving a key from the input password
|
||||
\return BAD_FUNC_ARG Returned if there is an invalid hash type given,
|
||||
iterations is less than 1, or the key length (kLen) requested is greater
|
||||
than the hash length of the provided hash
|
||||
\return MEMORY_E Returned if there is an allocating memory
|
||||
\return MP_INIT_E may be returned if there is an error during key generation
|
||||
\return MP_READ_E may be returned if there is an error during key generation
|
||||
\return MP_CMP_E may be returned if there is an error during key generation
|
||||
\return MP_INVMOD_E may be returned if there is an error during
|
||||
key generation
|
||||
\return MP_EXPTMOD_E may be returned if there is an error during
|
||||
key generation
|
||||
\return MP_MOD_E may be returned if there is an error during key generation
|
||||
\return MP_MUL_E may be returned if there is an error during key generation
|
||||
\return MP_ADD_E may be returned if there is an error during key generation
|
||||
\return MP_MULMOD_E may be returned if there is an error during
|
||||
key generation
|
||||
\return MP_TO_E may be returned if there is an error during key generation
|
||||
\return MP_MEM may be returned if there is an error during key generation
|
||||
|
||||
\param output pointer to the buffer in which to store the generated key.
|
||||
Should be kLen long
|
||||
\param passwd pointer to the buffer containing the password to use for
|
||||
the key derivation
|
||||
\param pLen length of the password to use for key derivation
|
||||
\param salt pointer to the buffer containing the salt to use
|
||||
for key derivation
|
||||
\param sLen length of the salt
|
||||
\param iterations number of times to process the hash
|
||||
\param kLen desired length of the derived key
|
||||
\param hashType the hashing algorithm to use. Valid choices are: MD5,
|
||||
SHA, SHA256, SHA384, SHA512, and BLAKE2B
|
||||
\param id this is a byte indetifier indicating the purpose of key
|
||||
generation. It is used to diversify the key output, and should be
|
||||
assigned as follows: ID=1: pseudorandom bits are to be used as key
|
||||
material for performing encryption or decryption. ID=2: pseudorandom
|
||||
bits are to be used an IV (Initial Value) for encryption or decryption.
|
||||
ID=3: pseudorandom bits are to be used as an integrity key for MACing.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte key[64];
|
||||
byte pass[] = { }; // initialize with password
|
||||
byte salt[] = { }; // initialize with salt
|
||||
|
||||
ret = wc_PKCS512_PBKDF(key, pass, sizeof(pass), salt, sizeof(salt), 2048,
|
||||
sizeof(key), SHA512, 1);
|
||||
if ( ret != 0 ) {
|
||||
// error deriving key from password
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_PBKDF1
|
||||
\sa wc_PBKDF2
|
||||
*/
|
||||
WOLFSSL_API int wc_PKCS12_PBKDF(byte* output, const byte* passwd, int pLen,
|
||||
const byte* salt, int sLen, int iterations,
|
||||
int kLen, int typeH, int purpose);
|
65
doc/dox_comments/header_files/rabbit.h
Normal file
65
doc/dox_comments/header_files/rabbit.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*!
|
||||
\ingroup Rabbit
|
||||
|
||||
\brief This function encrypts or decrypts a message of any size, storing
|
||||
the result in output. It requires that the Rabbit ctx structure be
|
||||
initialized with a key and an iv before encryption.
|
||||
|
||||
\return 0 Returned on successfully encrypting/decrypting input
|
||||
\return BAD_ALIGN_E Returned if the input message is not 4-byte aligned
|
||||
but is required to be by XSTREAM_ALIGN, but NO_WOLFSSL_ALLOC_ALIGN is
|
||||
defined
|
||||
\return MEMORY_E Returned if there is an error allocating memory to
|
||||
align the message, if NO_WOLFSSL_ALLOC_ALIGN is not defined
|
||||
|
||||
\param ctx pointer to the Rabbit structure to use for encryption/decryption
|
||||
\param output pointer to the buffer in which to store the processed
|
||||
message. Should be at least msglen long
|
||||
\param input pointer to the buffer containing the message to process
|
||||
\param msglen the length of the message to process
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
Rabbit enc;
|
||||
byte key[] = { }; // initialize with 16 byte key
|
||||
byte iv[] = { }; // initialize with 8 byte iv
|
||||
|
||||
wc_RabbitSetKey(&enc, key, iv);
|
||||
|
||||
byte message[] = { }; // initialize with plaintext message
|
||||
byte ciphertext[sizeof(message)];
|
||||
|
||||
wc_RabbitProcess(enc, ciphertext, message, sizeof(message));
|
||||
\endcode
|
||||
|
||||
\sa wc_RabbitSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_RabbitProcess(Rabbit*, byte*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup Rabbit
|
||||
|
||||
\brief This function initializes a Rabbit context for use with
|
||||
encryption or decryption by setting its iv and key.
|
||||
|
||||
\return 0 Returned on successfully setting the key and iv
|
||||
|
||||
\param ctx pointer to the Rabbit structure to initialize
|
||||
\param key pointer to the buffer containing the 16 byte key to
|
||||
use for encryption/decryption
|
||||
\param iv pointer to the buffer containing the 8 byte iv with
|
||||
which to initialize the Rabbit structure
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
Rabbit enc;
|
||||
byte key[] = { }; // initialize with 16 byte key
|
||||
byte iv[] = { }; // initialize with 8 byte iv
|
||||
|
||||
wc_RabbitSetKey(&enc, key, iv)
|
||||
\endcode
|
||||
|
||||
\sa wc_RabbitProcess
|
||||
*/
|
||||
WOLFSSL_API int wc_RabbitSetKey(Rabbit*, const byte* key, const byte* iv);
|
260
doc/dox_comments/header_files/random.h
Normal file
260
doc/dox_comments/header_files/random.h
Normal file
@ -0,0 +1,260 @@
|
||||
/*!
|
||||
\ingroup Random
|
||||
|
||||
\brief Init global Whitewood netRandom context
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Either configFile is null or timeout is negative.
|
||||
\return RNG_FAILURE_E There was a failure initializing the rng.
|
||||
|
||||
\param configFile Path to configuration file
|
||||
\param hmac_cb Optional to create HMAC callback.
|
||||
\param timeout A timeout duration.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
char* config = "path/to/config/example.conf";
|
||||
int time = // Some sufficient timeout value;
|
||||
|
||||
if (wc_InitNetRandom(config, NULL, time) != 0)
|
||||
{
|
||||
// Some error occured
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_FreeNetRandom
|
||||
*/
|
||||
WOLFSSL_API int wc_InitNetRandom(const char*, wnr_hmac_key, int);
|
||||
/*!
|
||||
\ingroup Random
|
||||
|
||||
\brief Free global Whitewood netRandom context.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_MUTEX_E Error locking mutex on wnr_mutex
|
||||
|
||||
\param none No returns.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret = wc_FreeNetRandom();
|
||||
if(ret != 0)
|
||||
{
|
||||
// Handle the error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitNetRandom
|
||||
*/
|
||||
WOLFSSL_API int wc_FreeNetRandom(void);
|
||||
/*!
|
||||
\ingroup Random
|
||||
|
||||
\brief Gets the seed (from OS) and key cipher for rng. rng->drbg
|
||||
(deterministic random bit generator) allocated (should be deallocated
|
||||
with wc_FreeRng). This is a blocking operation.
|
||||
|
||||
\return 0 on success.
|
||||
\return MEMORY_E XMALLOC failed
|
||||
\return WINCRYPT_E wc_GenerateSeed: failed to acquire context
|
||||
\return CRYPTGEN_E wc_GenerateSeed: failed to get random
|
||||
\return BAD_FUNC_ARG wc_RNG_GenerateBlock input is null or sz exceeds
|
||||
MAX_REQUEST_LEN
|
||||
\return DRBG_CONT_FIPS_E wc_RNG_GenerateBlock: Hash_gen returned
|
||||
DRBG_CONT_FAILURE
|
||||
\return RNG_FAILURE_E wc_RNG_GenerateBlock: Default error. rng’s
|
||||
status originally not ok, or set to DRBG_FAILED
|
||||
|
||||
\param rng random number generator to be initialized for use
|
||||
with a seed and key cipher
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RNG rng;
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_CAVIUM
|
||||
ret = wc_InitRngCavium(&rng, CAVIUM_DEV_ID);
|
||||
if (ret != 0){
|
||||
printf(“RNG Nitrox init for device: %d failed”, CAVIUM_DEV_ID);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
ret = wc_InitRng(&rng);
|
||||
if (ret != 0){
|
||||
printf(“RNG init failed”);
|
||||
return -1;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitRngCavium
|
||||
\sa wc_RNG_GenerateBlock
|
||||
\sa wc_RNG_GenerateByte
|
||||
\sa wc_FreeRng
|
||||
\sa wc_RNG_HealthTest
|
||||
*/
|
||||
WOLFSSL_API int wc_InitRng(WC_RNG*);
|
||||
/*!
|
||||
\ingroup Random
|
||||
|
||||
\brief Copies a sz bytes of pseudorandom data to output. Will
|
||||
reseed rng if needed (blocking).
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG an input is null or sz exceeds MAX_REQUEST_LEN
|
||||
\return DRBG_CONT_FIPS_E Hash_gen returned DRBG_CONT_FAILURE
|
||||
\return RNG_FAILURE_E Default error. rng’s status originally not
|
||||
ok, or set to DRBG_FAILED
|
||||
|
||||
\param rng random number generator initialized with wc_InitRng
|
||||
\param output buffer to which the block is copied
|
||||
\param sz size of output in bytes
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RNG rng;
|
||||
int sz = 32;
|
||||
byte block[sz];
|
||||
|
||||
int ret = wc_InitRng(&rng);
|
||||
if (ret != 0) {
|
||||
return -1; //init of rng failed!
|
||||
}
|
||||
|
||||
ret = wc_RNG_GenerateBlock(&rng, block, sz);
|
||||
if (ret != 0) {
|
||||
return -1; //generating block failed!
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitRngCavium, wc_InitRng
|
||||
\sa wc_RNG_GenerateByte
|
||||
\sa wc_FreeRng
|
||||
\sa wc_RNG_HealthTest
|
||||
*/
|
||||
WOLFSSL_API int wc_RNG_GenerateBlock(WC_RNG*, byte*, word32 sz);
|
||||
/*!
|
||||
\ingroup Random
|
||||
|
||||
\brief Calls wc_RNG_GenerateBlock to copy a byte of pseudorandom
|
||||
data to b. Will reseed rng if needed.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG an input is null or sz exceeds MAX_REQUEST_LEN
|
||||
\return DRBG_CONT_FIPS_E Hash_gen returned DRBG_CONT_FAILURE
|
||||
\return RNG_FAILURE_E Default error. rng’s status originally not
|
||||
ok, or set to DRBG_FAILED
|
||||
|
||||
\param rng: random number generator initialized with wc_InitRng
|
||||
\param b one byte buffer to which the block is copied
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RNG rng;
|
||||
int sz = 32;
|
||||
byte b[1];
|
||||
|
||||
int ret = wc_InitRng(&rng);
|
||||
if (ret != 0) {
|
||||
return -1; //init of rng failed!
|
||||
}
|
||||
|
||||
ret = wc_RNG_GenerateByte(&rng, b);
|
||||
if (ret != 0) {
|
||||
return -1; //generating block failed!
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitRngCavium
|
||||
\sa wc_InitRng
|
||||
\sa wc_RNG_GenerateBlock
|
||||
\sa wc_FreeRng
|
||||
\sa wc_RNG_HealthTest
|
||||
*/
|
||||
WOLFSSL_API int wc_RNG_GenerateByte(WC_RNG*, byte*);
|
||||
/*!
|
||||
\ingroup Random
|
||||
|
||||
\brief Should be called when RNG no longer needed in order to securely
|
||||
free drgb. Zeros and XFREEs rng-drbg.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG rng or rng->drgb null
|
||||
\return RNG_FAILURE_E Failed to deallocated drbg
|
||||
|
||||
\param rng random number generator initialized with wc_InitRng
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RNG rng;
|
||||
int ret = wc_InitRng(&rng);
|
||||
if (ret != 0) {
|
||||
return -1; //init of rng failed!
|
||||
}
|
||||
|
||||
int ret = wc_FreeRng(&rng);
|
||||
if (ret != 0) {
|
||||
return -1; //free of rng failed!
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitRngCavium
|
||||
\sa wc_InitRng
|
||||
\sa wc_RNG_GenerateBlock
|
||||
\sa wc_RNG_GenerateByte,
|
||||
\sa wc_RNG_HealthTest
|
||||
*/
|
||||
WOLFSSL_API int wc_FreeRng(WC_RNG*);
|
||||
/*!
|
||||
\ingroup Random
|
||||
|
||||
\brief Creates and tests functionality of drbg.
|
||||
|
||||
\return 0 on success
|
||||
\return BAD_FUNC_ARG entropyA and output must not be null. If reseed
|
||||
set entropyB must not be null
|
||||
\return -1 test failed
|
||||
|
||||
\param int reseed: if set, will test reseed functionality
|
||||
\param entropyA: entropy to instantiate drgb with
|
||||
\param entropyASz: size of entropyA in bytes
|
||||
\param entropyB: If reseed set, drbg will be reseeded with entropyB
|
||||
\param entropyBSz: size of entropyB in bytes
|
||||
\param output: initialized to random data seeded with entropyB if
|
||||
seedrandom is set, and entropyA otherwise
|
||||
\param outputSz: length of output in bytes
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte output[SHA256_DIGEST_SIZE * 4];
|
||||
const byte test1EntropyB[] = ....; // test input for reseed false
|
||||
const byte test1Output[] = ....; // testvector: expected output of
|
||||
// reseed false
|
||||
ret = wc_RNG_HealthTest(0, test1Entropy, sizeof(test1Entropy), NULL, 0,
|
||||
output, sizeof(output));
|
||||
if (ret != 0)
|
||||
return -1;//healthtest without reseed failed
|
||||
|
||||
if (XMEMCMP(test1Output, output, sizeof(output)) != 0)
|
||||
return -1; //compare to testvector failed: unexpected output
|
||||
|
||||
const byte test2EntropyB[] = ....; // test input for reseed
|
||||
const byte test2Output[] = ....; // testvector expected output of reseed
|
||||
ret = wc_RNG_HealthTest(1, test2EntropyA, sizeof(test2EntropyA),
|
||||
test2EntropyB, sizeof(test2EntropyB),
|
||||
output, sizeof(output));
|
||||
|
||||
if (XMEMCMP(test2Output, output, sizeof(output)) != 0)
|
||||
return -1; //compare to testvector failed
|
||||
\endcode
|
||||
|
||||
\sa wc_InitRngCavium
|
||||
\sa wc_InitRng
|
||||
\sa wc_RNG_GenerateBlock
|
||||
\sa wc_RNG_GenerateByte
|
||||
\sa wc_FreeRng
|
||||
*/
|
||||
WOLFSSL_API int wc_RNG_HealthTest(int reseed,
|
||||
const byte* entropyA, word32 entropyASz,
|
||||
const byte* entropyB, word32 entropyBSz,
|
||||
byte* output, word32 outputSz);
|
101
doc/dox_comments/header_files/ripemd.h
Normal file
101
doc/dox_comments/header_files/ripemd.h
Normal file
@ -0,0 +1,101 @@
|
||||
/*!
|
||||
\ingroup RIPEMD
|
||||
|
||||
\brief This function initializes a ripemd structure by initializing
|
||||
ripemd’s digest, buffer, loLen and hiLen.
|
||||
|
||||
\return 0 returned on successful execution of the function. The RipeMd
|
||||
structure is initialized.
|
||||
\return BAD_FUNC_ARG returned if the RipeMd structure is NULL.
|
||||
|
||||
\param ripemd pointer to the ripemd structure to initialize
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RipeMd md;
|
||||
int ret;
|
||||
ret = wc_InitRipeMd(&md);
|
||||
if (ret != 0) {
|
||||
// Failure case.
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RipeMdUpdate
|
||||
\sa wc_RipeMdFinal
|
||||
*/
|
||||
WOLFSSL_API int wc_InitRipeMd(RipeMd*);
|
||||
/*!
|
||||
\ingroup RIPEMD
|
||||
|
||||
\brief This function generates the RipeMd digest of the data input and
|
||||
stores the result in the ripemd->digest buffer. After running
|
||||
wc_RipeMdUpdate, one should compare the generated ripemd->digest to a
|
||||
known authentication tag to verify the authenticity of a message.
|
||||
|
||||
\return 0 Returned on successful execution of the function.
|
||||
\return BAD_FUNC_ARG Returned if the RipeMd structure is NULL or if data
|
||||
is NULL and len is not zero. This function should execute if data is NULL
|
||||
and len is 0.
|
||||
|
||||
\param ripemd: pointer to the ripemd structure to be initialized with
|
||||
wc_InitRipeMd
|
||||
\param data data to be hashed
|
||||
\param len sizeof data in bytes
|
||||
|
||||
_Example_
|
||||
\code
|
||||
const byte* data; // The data to be hashed
|
||||
....
|
||||
RipeMd md;
|
||||
int ret;
|
||||
ret = wc_InitRipeMd(&md);
|
||||
if (ret == 0) {
|
||||
ret = wc_RipeMdUpdate(&md, plain, sizeof(plain));
|
||||
if (ret != 0) {
|
||||
// Failure case …
|
||||
\endcode
|
||||
|
||||
\sa wc_InitRipeMd
|
||||
\sa wc_RipeMdFinal
|
||||
*/
|
||||
WOLFSSL_API int wc_RipeMdUpdate(RipeMd*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup RIPEMD
|
||||
|
||||
\brief This function copies the computed digest into hash. If there is a
|
||||
partial unhashed block, this method will pad the block with 0s, and
|
||||
include that block’s round in the digest before copying to hash. State
|
||||
of ripemd is reset.
|
||||
|
||||
\return 0 Returned on successful execution of the function. The state of
|
||||
the RipeMd structure has been reset.
|
||||
\return BAD_FUNC_ARG Returned if the RipeMd structure or hash parameters
|
||||
are NULL.
|
||||
|
||||
\param ripemd pointer to the ripemd structure to be initialized with
|
||||
wc_InitRipeMd, and containing hashes from wc_RipeMdUpdate. State will
|
||||
be reset
|
||||
\param hash buffer to copy digest to. Should be RIPEMD_DIGEST_SIZE bytes
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RipeMd md;
|
||||
int ret;
|
||||
byte digest[RIPEMD_DIGEST_SIZE];
|
||||
const byte* data; // The data to be hashed
|
||||
...
|
||||
ret = wc_InitRipeMd(&md);
|
||||
if (ret == 0) {
|
||||
ret = wc_RipeMdUpdate(&md, plain, sizeof(plain));
|
||||
if (ret != 0) {
|
||||
// RipeMd Update Failure Case.
|
||||
}
|
||||
ret = wc_RipeMdFinal(&md, digest);
|
||||
if (ret != 0) {
|
||||
// RipeMd Final Failure Case.
|
||||
}...
|
||||
\endcode
|
||||
|
||||
\sa none
|
||||
*/
|
||||
WOLFSSL_API int wc_RipeMdFinal(RipeMd*, byte*);
|
775
doc/dox_comments/header_files/rsa.h
Normal file
775
doc/dox_comments/header_files/rsa.h
Normal file
@ -0,0 +1,775 @@
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This function initializes a provided RsaKey struct. It also takes
|
||||
in a heap identifier, for use with user defined memory overrides
|
||||
(see XMALLOC, XFREE, XREALLOC).
|
||||
|
||||
\return 0 Returned upon successfully initializing the RSA structure for
|
||||
use with encryption and decryption
|
||||
\return BAD_FUNC_ARGS Returned if the RSA key pointer evaluates to NULL
|
||||
|
||||
\param key pointer to the RsaKey structure to initialize
|
||||
\param heap pointer to a heap identifier, for use with memory overrides,
|
||||
allowing custom handling of memory allocation. This heap will be the
|
||||
default used when allocating memory for use with this RSA object
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RsaKey enc;
|
||||
int ret;
|
||||
ret = wc_RsaInitKey(&enc, NULL); // not using heap hint. No custom memory
|
||||
if ( ret != 0 ) {
|
||||
// error initializing RSA key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaInitCavium
|
||||
\sa wc_FreeRsaKey
|
||||
*/
|
||||
WOLFSSL_API int wc_InitRsaKey(RsaKey* key, void* heap);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This function frees a provided RsaKey struct using mp_clear.
|
||||
|
||||
\return 0 Returned upon successfully freeing the key
|
||||
|
||||
\param key pointer to the RsaKey structure to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RsaKey enc;
|
||||
wc_RsaInitKey(&enc, NULL); // not using heap hint. No custom memory
|
||||
... set key, do encryption
|
||||
|
||||
wc_FreeRsaKey(&enc);
|
||||
\endcode
|
||||
|
||||
\sa wc_InitRsaKey
|
||||
*/
|
||||
WOLFSSL_API int wc_FreeRsaKey(RsaKey* key);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This function encrypts a message from in and stores the result
|
||||
in out. It requires an initialized public key and a random number
|
||||
generator. As a side effect, this function will return the bytes written
|
||||
to out in outLen.
|
||||
|
||||
\return Success Upon successfully encrypting the input message, returns
|
||||
the number bytes written to out
|
||||
\return -1 Returned if there is an error during RSA encryption and
|
||||
hardware acceleration via Cavium is enabled
|
||||
\return BAD_FUNC_ARG Returned if any of the input parameters are invalid
|
||||
\return RSA_BUFFER_E Returned if the output buffer is too small to store
|
||||
the ciphertext
|
||||
\return RNG_FAILURE_E Returned if there is an error generating a random
|
||||
block using the provided RNG structure
|
||||
\return MP_INIT_E May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
\return MP_READ_E May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
\return MP_CMP_E May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
\return MP_INVMOD_E May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
\return MP_EXPTMOD_E May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
\return MP_MOD_E May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
\return MP_MUL_E May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
\return MP_ADD_E May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
\return MP_MULMOD_E May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
\return MP_TO_E May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
\return MP_MEM May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
\return MP_ZERO_E May be returned if there is an error in the math
|
||||
library used while encrypting the message
|
||||
|
||||
\param in pointer to a buffer containing the input message to encrypt
|
||||
\param inLen the length of the message to encrypt
|
||||
\param out pointer to the buffer in which to store the output ciphertext
|
||||
\param outLen the length of the output buffer
|
||||
\param key pointer to the RsaKey structure containing the public
|
||||
key to use for encryption
|
||||
\param rng The RNG structure with which to generate random block padding
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RsaKey pub;
|
||||
int ret = 0;
|
||||
byte n[] = { // initialize with received n component of public key };
|
||||
byte e[] = { // initialize with received e component of public key };
|
||||
byte msg[] = { // initialize with plaintext of message to encrypt };
|
||||
byte cipher[256]; // 256 bytes is large enough to store 2048 bit RSA
|
||||
ciphertext
|
||||
|
||||
wc_InitRsaKey(&pub, NULL); // not using heap hint. No custom memory
|
||||
wc_RsaPublicKeyDecodeRaw(n, sizeof(n), e, sizeof(e), &pub);
|
||||
// initialize with received public key parameters
|
||||
ret = wc_RsaPublicEncrypt(msg, sizeof(msg), out, sizeof(out), &pub, &rng);
|
||||
if ( ret != 0 ) {
|
||||
// error encrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaPrivateDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaPublicEncrypt(const byte* in, word32 inLen, byte* out,
|
||||
word32 outLen, RsaKey* key, WC_RNG* rng);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This functions is utilized by the wc_RsaPrivateDecrypt function
|
||||
for decrypting.
|
||||
|
||||
\return Success Length of decrypted data.
|
||||
\return RSA_PAD_E RsaUnPad error, bad formatting
|
||||
|
||||
\param in The byte array to be decrypted.
|
||||
\param inLen The length of in.
|
||||
\param out The byte array for the decrypted data to be stored.
|
||||
\param key The key to use for decryption.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
none
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaPrivateDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out,
|
||||
RsaKey* key);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This functions provides private RSA decryption.
|
||||
|
||||
\return Success length of decrypted data.
|
||||
\return MEMORY_E -125, out of memory error
|
||||
\return BAD_FUNC_ARG -173, Bad function argument provided
|
||||
|
||||
\param in The byte array to be decrypted.
|
||||
\param inLen The length of in.
|
||||
\param out The byte array for the decrypted data to be stored.
|
||||
\param outLen The length of out.
|
||||
\param key The key to use for decryption.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ret = wc_RsaPublicEncrypt(in, inLen, out, sizeof(out), &key, &rng);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
ret = wc_RsaPrivateDecrypt(out, ret, plain, sizeof(plain), &key);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa RsaUnPad
|
||||
\sa wc_RsaFunction
|
||||
\sa wc_RsaPrivateDecryptInline
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out,
|
||||
word32 outLen, RsaKey* key);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief Signs the provided array with the private key.
|
||||
|
||||
\return RSA_BUFFER_E: -131, RSA buffer error, output too small or
|
||||
input too large
|
||||
|
||||
\param in The byte array to be encrypted.
|
||||
\param inLen The length of in.
|
||||
\param out The byte array for the encrypted data to be stored.
|
||||
\param outLen The length of out.
|
||||
\param key The key to use for encryption.
|
||||
\param RNG The RNG struct to use for random number purposes.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ret = wc_RsaSSL_Sign(in, inLen, out, sizeof(out), &key, &rng);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
memset(plain, 0, sizeof(plain));
|
||||
ret = wc_RsaSSL_Verify(out, ret, plain, sizeof(plain), &key);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaPad
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaSSL_Sign(const byte* in, word32 inLen, byte* out,
|
||||
word32 outLen, RsaKey* key, WC_RNG* rng);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief Used to verify that the message was signed by RSA key. The output
|
||||
uses the same byte array as the input.
|
||||
|
||||
\return >0 Length of text.
|
||||
\return <0 An error occurred.
|
||||
|
||||
\param in Byte array to be decrypted.
|
||||
\param inLen Length of the buffer input.
|
||||
\param out Pointer to a pointer for decrypted information.
|
||||
\param key RsaKey to use.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RsaKey key;
|
||||
RNG rng;
|
||||
int ret = 0;
|
||||
long e = 65537; // standard value to use for exponent
|
||||
wc_InitRsaKey(&key, NULL); // not using heap hint. No custom memory
|
||||
wc_InitRng(&rng);
|
||||
wc_MakeRsaKey(&key, 2048, e, &rng);
|
||||
|
||||
byte in[] = { // Initialize with some RSA encrypted information }
|
||||
byte* out;
|
||||
if(wc_RsaSSL_VerifyInline(in, sizeof(in), &out, &key) < 0)
|
||||
{
|
||||
// handle error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaSSL_Verify
|
||||
\sa wc_RsaSSL_Sign
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out,
|
||||
RsaKey* key);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief Used to verify that the message was signed by key.
|
||||
|
||||
\return Success Length of text on no error.
|
||||
\return MEMORY_E memory exception.
|
||||
|
||||
\param in The byte array to be decrypted.
|
||||
\param inLen The length of in.
|
||||
\param out The byte array for the decrypted data to be stored.
|
||||
\param outLen The length of out.
|
||||
\param key The key to use for verification.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
ret = wc_RsaSSL_Sign(in, inLen, out, sizeof(out), &key, &rng);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
memset(plain, 0, sizeof(plain));
|
||||
ret = wc_RsaSSL_Verify(out, ret, plain, sizeof(plain), &key);
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaSSL_Sign
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaSSL_Verify(const byte* in, word32 inLen, byte* out,
|
||||
word32 outLen, RsaKey* key);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief Returns the encryption size for the provided key structure.
|
||||
|
||||
\return Success Encryption size for the provided key structure.
|
||||
|
||||
\param key The key to use for verification.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int sz = wc_RsaEncryptSize(&key);
|
||||
\endcode
|
||||
|
||||
\sa wc_InitRsaKey
|
||||
\sa wc_InitRsaKey_ex
|
||||
\sa wc_MakeRsaKey
|
||||
\sa XMEMSET
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaEncryptSize(RsaKey* key);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This function parses a DER-formatted RSA private key, extracts the
|
||||
private key and stores it in the given RsaKey structure. It also sets the
|
||||
distance parsed in idx.
|
||||
|
||||
\return 0 Returned upon successfully parsing the private key from the DER
|
||||
encoded input
|
||||
\return ASN_PARSE_E Returned if there is an error parsing the private key
|
||||
from the input buffer. This may happen if the input private key is not
|
||||
properly formatted according to ASN.1 standards
|
||||
\return ASN_RSA_KEY_E Returned if there is an error reading the private
|
||||
key elements of the RSA key input
|
||||
|
||||
\param input pointer to the buffer containing the DER formatted private
|
||||
key to decode
|
||||
\param inOutIdx pointer to the index in the buffer at which the key begins
|
||||
(usually 0). As a side effect of this function, inOutIdx will store the
|
||||
distance parsed through the input buffer
|
||||
\param key pointer to the RsaKey structure in which to store the decoded
|
||||
private key
|
||||
\param inSz size of the input buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RsaKey enc;
|
||||
word32 idx = 0;
|
||||
int ret = 0;
|
||||
byte der[] = { // initialize with DER-encoded RSA private key };
|
||||
|
||||
wc_InitRsaKey(&enc, NULL); // not using heap hint. No custom memory
|
||||
ret = wc_RsaPrivateKeyDecode(der, &idx, &enc, sizeof(der));
|
||||
if( ret != 0 ) {
|
||||
// error parsing private key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaPublicKeyDecode
|
||||
\sa wc_MakeRsaKey
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx,
|
||||
RsaKey*, word32);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This function parses a DER-formatted RSA public key, extracts the
|
||||
public key and stores it in the given RsaKey structure. It also sets the
|
||||
distance parsed in idx.
|
||||
|
||||
\return 0 Returned upon successfully parsing the public key from the DER
|
||||
encoded input
|
||||
\return ASN_PARSE_E Returned if there is an error parsing the public key
|
||||
from the input buffer. This may happen if the input public key is not
|
||||
properly formatted according to ASN.1 standards
|
||||
\return ASN_OBJECT_ID_E Returned if the ASN.1 Object ID does not match
|
||||
that of a RSA public key
|
||||
\return ASN_EXPECT_0_E Returned if the input key is not correctly
|
||||
formatted according to ASN.1 standards
|
||||
\return ASN_BITSTR_E Returned if the input key is not correctly formatted
|
||||
according to ASN.1 standards
|
||||
\return ASN_RSA_KEY_E Returned if there is an error reading the public key
|
||||
elements of the RSA key input
|
||||
|
||||
\param input pointer to the buffer containing the input DER-encoded RSA
|
||||
public key to decode
|
||||
\param inOutIdx pointer to the index in the buffer at which the key
|
||||
begins (usually 0). As a side effect of this function, inOutIdx will
|
||||
store the distance parsed through the input buffer
|
||||
\param key pointer to the RsaKey structure in which to store the decoded
|
||||
public key
|
||||
\param inSz size of the input buffer
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RsaKey pub;
|
||||
word32 idx = 0;
|
||||
int ret = 0;
|
||||
byte der[] = { // initialize with DER-encoded RSA public key };
|
||||
|
||||
wc_InitRsaKey(&pub, NULL); // not using heap hint. No custom memory
|
||||
ret = wc_RsaPublicKeyDecode(der, &idx, &pub, sizeof(der));
|
||||
if( ret != 0 ) {
|
||||
// error parsing public key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaPublicKeyDecodeRaw
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx,
|
||||
RsaKey*, word32);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This function decodes the raw elements of an RSA public key, taking
|
||||
in the public modulus (n) and exponent (e). It stores these raw elements
|
||||
in the provided RsaKey structure, allowing one to use them in the
|
||||
encryption/decryption process.
|
||||
|
||||
\return 0 Returned upon successfully decoding the raw elements of the
|
||||
public key into the RsaKey structure
|
||||
\return BAD_FUNC_ARG Returned if any of the input arguments evaluates to
|
||||
NULL
|
||||
\return MP_INIT_E Returned if there is an error initializing an integer
|
||||
for use with the multiple precision integer (mp_int) library
|
||||
\return ASN_GETINT_E Returned if there is an error reading one of the
|
||||
provided RSA key elements, n or e
|
||||
|
||||
\param n pointer to a buffer containing the raw modulus parameter of the
|
||||
public RSA key
|
||||
\param nSz size of the buffer containing n
|
||||
\param e pointer to a buffer containing the raw exponent parameter of
|
||||
the public RSA key
|
||||
\param eSz size of the buffer containing e
|
||||
\param key pointer to the RsaKey struct to initialize with the provided
|
||||
public key elements
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RsaKey pub;
|
||||
int ret = 0;
|
||||
byte n[] = { // initialize with received n component of public key };
|
||||
byte e[] = { // initialize with received e component of public key };
|
||||
|
||||
wc_InitRsaKey(&pub, NULL); // not using heap hint. No custom memory
|
||||
ret = wc_RsaPublicKeyDecodeRaw(n, sizeof(n), e, sizeof(e), &pub);
|
||||
if( ret != 0 ) {
|
||||
// error parsing public key elements
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaPublicKeyDecode
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaPublicKeyDecodeRaw(const byte* n, word32 nSz,
|
||||
const byte* e, word32 eSz, RsaKey* key);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This function converts an RsaKey key to DER format. The result is
|
||||
written to output and it returns the number of bytes written.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returned if key or output is null, or if key->type
|
||||
is not RSA_PRIVATE, or if inLen isn't large enough for output buffer.
|
||||
\return MEMORY_E Returned if there is an error allocating memory.
|
||||
|
||||
\param key Initialized RsaKey structure.
|
||||
\param output Pointer to output buffer.
|
||||
\param inLen Size of output buffer.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte* der;
|
||||
// Allocate memory for der
|
||||
int derSz = // Amount of memory allocated for der;
|
||||
RsaKey key;
|
||||
RNG rng;
|
||||
long e = 65537; // standard value to use for exponent
|
||||
ret = wc_MakeRsaKey(&key, 2048, e, &rng); // generate 2048 bit long
|
||||
private key
|
||||
wc_InitRsaKey(&key, NULL);
|
||||
wc_InitRng(&rng);
|
||||
if(wc_RsaKeyToDer(&key, der, derSz) != 0)
|
||||
{
|
||||
// Handle the error thrown
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaKeyToPublicDer
|
||||
\sa wc_InitRsaKey
|
||||
\sa wc_MakeRsaKey
|
||||
\sa wc_InitRng
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaKeyToDer(RsaKey*, byte* output, word32 inLen);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This function performs RSA encrypt while allowing the choice of
|
||||
which padding to use.
|
||||
|
||||
\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 pointer to the buffer for encryption
|
||||
\param inLen length of the buffer to encrypt
|
||||
\param out encrypted msg created
|
||||
\param outLen length of buffer available to hold encrypted msg
|
||||
\param key initialized RSA key struct
|
||||
\param rng initialized WC_RNG struct
|
||||
\param type type of padding to use (WC_RSA_OAEP_PAD or WC_RSA_PKCSV15_PAD)
|
||||
\param hash type of hash to use (choices can be found in hash.h)
|
||||
\param mgf type of mask generation function to use
|
||||
\param label an optional label to associate with encrypted message
|
||||
\param labelSz size of the optional label used
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WC_RNG rng;
|
||||
RsaKey key;
|
||||
byte in[] = “I use Turing Machines to ask questions”
|
||||
byte out[256];
|
||||
int ret;
|
||||
…
|
||||
|
||||
ret = wc_RsaPublicEncrypt_ex(in, sizeof(in), out, sizeof(out), &key, &rng,
|
||||
WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
|
||||
if (ret < 0) {
|
||||
//handle error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaPublicEncrypt
|
||||
\sa wc_RsaPrivateDecrypt_ex
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaPublicEncrypt_ex(const byte* in, word32 inLen, byte* out,
|
||||
word32 outLen, RsaKey* key, WC_RNG* rng, int type,
|
||||
enum wc_HashType hash, int mgf, byte* label, word32 lableSz);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This function uses RSA to decrypt a message and gives the
|
||||
option of what padding type.
|
||||
|
||||
\return size On successful decryption, the size of the decrypted message
|
||||
is returned.
|
||||
\return MEMORY_E Returned if not enough memory on system to malloc a
|
||||
needed array.
|
||||
\return BAD_FUNC_ARG Returned if a bad argument was passed into the
|
||||
function.
|
||||
|
||||
\param in pointer to the buffer for decryption
|
||||
\param inLen length of the buffer to decrypt
|
||||
\param out decrypted msg created
|
||||
\param outLen length of buffer available to hold decrypted msg
|
||||
\param key initialized RSA key struct
|
||||
\param type type of padding to use (WC_RSA_OAEP_PAD or WC_RSA_PKCSV15_PAD)
|
||||
\param hash type of hash to use (choices can be found in hash.h)
|
||||
\param mgf type of mask generation function to use
|
||||
\param label an optional label to associate with encrypted message
|
||||
\param labelSz size of the optional label used
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WC_RNG rng;
|
||||
RsaKey key;
|
||||
byte in[] = “I use Turing Machines to ask questions”
|
||||
byte out[256];
|
||||
byte plain[256];
|
||||
int ret;
|
||||
…
|
||||
ret = wc_RsaPublicEncrypt_ex(in, sizeof(in), out, sizeof(out), &key,
|
||||
&rng, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
|
||||
if (ret < 0) {
|
||||
//handle error
|
||||
}
|
||||
…
|
||||
ret = wc_RsaPrivateDecrypt_ex(out, ret, plain, sizeof(plain), &key,
|
||||
WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
|
||||
|
||||
if (ret < 0) {
|
||||
//handle error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa none
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaPrivateDecrypt_ex(const byte* in, word32 inLen,
|
||||
byte* out, word32 outLen, RsaKey* key, int type,
|
||||
enum wc_HashType hash, int mgf, byte* label, word32 lableSz);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This function uses RSA to decrypt a message inline and gives the
|
||||
option of what padding type. The in buffer will contain the decrypted
|
||||
message after being called and the out byte pointer will point to the
|
||||
location in the “in” buffer where the plain text is.
|
||||
|
||||
\return size On successful decryption, the size of the decrypted message
|
||||
is returned.
|
||||
\return MEMORY_E: Returned if not enough memory on system to malloc a
|
||||
needed array.
|
||||
\return RSA_PAD_E: Returned if an error in the padding was encountered.
|
||||
\return BAD_PADDING_E: Returned if an error happened during parsing past
|
||||
padding.
|
||||
\return BAD_FUNC_ARG: Returned if a bad argument was passed into the
|
||||
function.
|
||||
|
||||
\param in pointer to the buffer for decryption
|
||||
\param inLen length of the buffer to decrypt
|
||||
\param out pointer to location of decrypted message in “in” buffer
|
||||
\param key initialized RSA key struct
|
||||
\param type type of padding to use (WC_RSA_OAEP_PAD or WC_RSA_PKCSV15_PAD)
|
||||
\param hash type of hash to use (choices can be found in hash.h)
|
||||
\param mgf type of mask generation function to use
|
||||
\param label an optional label to associate with encrypted message
|
||||
\param labelSz size of the optional label used
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WC_RNG rng;
|
||||
RsaKey key;
|
||||
byte in[] = “I use Turing Machines to ask questions”
|
||||
byte out[256];
|
||||
byte* plain;
|
||||
int ret;
|
||||
…
|
||||
ret = wc_RsaPublicEncrypt_ex(in, sizeof(in), out, sizeof(out), &key,
|
||||
&rng, WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
|
||||
|
||||
if (ret < 0) {
|
||||
//handle error
|
||||
}
|
||||
…
|
||||
ret = wc_RsaPrivateDecryptInline_ex(out, ret, &plain, &key,
|
||||
WC_RSA_OAEP_PAD, WC_HASH_TYPE_SHA, WC_MGF1SHA1, NULL, 0);
|
||||
|
||||
if (ret < 0) {
|
||||
//handle error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa none
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaPrivateDecryptInline_ex(byte* in, word32 inLen,
|
||||
byte** out, RsaKey* key, int type, enum wc_HashType hash,
|
||||
int mgf, byte* label, word32 lableSz);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief Flattens the RsaKey structure into individual elements (e, n)
|
||||
used for the RSA algorithm.
|
||||
|
||||
\return 0 Returned if the function executed normally, without error.
|
||||
\return BAD_FUNC_ARG: Returned if any of the parameters are passed in
|
||||
with a null value.
|
||||
\return RSA_BUFFER_E: Returned if the e or n buffers passed in are not
|
||||
the correct size.
|
||||
\return MP_MEM: Returned if an internal function has memory errors.
|
||||
\return MP_VAL: Returned if an internal function argument is not valid.
|
||||
|
||||
\param key The key to use for verification.
|
||||
\param e a buffer for the value of e. e is a large positive integer in
|
||||
the RSA modular arithmetic operation.
|
||||
\param eSz the size of the e buffer.
|
||||
\param n a buffer for the value of n. n is a large positive integer in
|
||||
the RSA modular arithmetic operation.
|
||||
\param nSz the size of the n buffer.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Rsa key; // A valid RSA key.
|
||||
byte e[ buffer sz E.g. 256 ];
|
||||
byte n[256];
|
||||
int ret;
|
||||
word32 eSz = sizeof(e);
|
||||
word32 nSz = sizeof(n);
|
||||
...
|
||||
ret = wc_RsaFlattenPublicKey(&key, e, &eSz, n, &nSz);
|
||||
if (ret != 0) {
|
||||
// Failure case.
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitRsaKey
|
||||
\sa wc_InitRsaKey_ex
|
||||
\sa wc_MakeRsaKey
|
||||
\sa XMEMSET
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaFlattenPublicKey(RsaKey*, byte*, word32*, byte*,
|
||||
word32*);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief Convert Rsa Public key to DER format. Writes to output, and
|
||||
returns count of bytes written.
|
||||
|
||||
\return >0 Success, number of bytes written.
|
||||
\return BAD_FUNC_ARG Returned if key or output is null.
|
||||
\return MEMORY_E Returned when an error allocating memory occurs.
|
||||
\return <0 Error
|
||||
|
||||
\param key The RSA key structure to convert.
|
||||
\param output Output buffer to hold DER.
|
||||
\param inLen Length of buffer.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RsaKey key;
|
||||
|
||||
wc_RsaInitKey(&key, NULL);
|
||||
// Use key
|
||||
|
||||
int BUFFER_SIZE = // Some adequate size for the buffer
|
||||
byte output[BUFFER_SIZE];
|
||||
if(wc_RsaKeyToPublicDer(&key, output, sizeof(output)) != 0)
|
||||
{
|
||||
// Handle Error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_RsaKeyToPublicDer
|
||||
\sa wc_RsaInitKey
|
||||
*/
|
||||
WOLFSSL_API int wc_RsaKeyToPublicDer(RsaKey*, byte* output, word32 inLen);
|
||||
/*!
|
||||
\ingroup RSA
|
||||
|
||||
\brief This function generates a RSA private key of length size (in bits)
|
||||
and given exponent (e). It then stores this key in the provided RsaKey
|
||||
structure, so that it may be used for encryption/decryption. A secure
|
||||
number to use for e is 65537. size is required to be greater than
|
||||
RSA_MIN_SIZE and less than RSA_MAX_SIZE. For this function to be
|
||||
available, the option WOLFSSL_KEY_GEN must be enabled at compile time.
|
||||
This can be accomplished with --enable-keygen if using ./configure.
|
||||
|
||||
\return 0 Returned upon successfully generating a RSA private key
|
||||
\return BAD_FUNC_ARG Returned if any of the input arguments are NULL,
|
||||
the size parameter falls outside of the necessary bounds, or e is
|
||||
incorrectly chosen
|
||||
\return RNG_FAILURE_E Returned if there is an error generating a random
|
||||
block using the provided RNG structure
|
||||
\return MP_INIT_E
|
||||
\return MP_READ_E May be May be returned if there is an error in the math
|
||||
library used while generating the RSA key returned if there is an error
|
||||
in the math library used while generating the RSA key
|
||||
\return MP_CMP_E May be returned if there is an error in the math library
|
||||
used while generating the RSA key
|
||||
\return MP_INVMOD_E May be returned if there is an error in the math
|
||||
library used while generating the RSA key
|
||||
\return MP_EXPTMOD_E May be returned if there is an error in the math
|
||||
library used while generating the RSA key
|
||||
\return MP_MOD_E May be returned if there is an error in the math
|
||||
library used while generating the RSA key
|
||||
\return MP_MUL_E May be returned if there is an error in the math
|
||||
library used while generating the RSA key
|
||||
\return MP_ADD_E May be returned if there is an error in the math
|
||||
library used while generating the RSA key
|
||||
\return MP_MULMOD_E May be returned if there is an error in the math
|
||||
library used while generating the RSA key
|
||||
\return MP_TO_E May be returned if there is an error in the math
|
||||
library used while generating the RSA key
|
||||
\return MP_MEM May be returned if there is an error in the math
|
||||
library used while generating the RSA key
|
||||
\return MP_ZERO_E May be returned if there is an error in the math
|
||||
library used while generating the RSA key
|
||||
|
||||
\param key pointer to the RsaKey structure in which to store the
|
||||
generated private key
|
||||
\param size desired keylenth, in bits. Required to be greater than
|
||||
RSA_MIN_SIZE and less than RSA_MAX_SIZE
|
||||
\param e exponent parameter to use for generating the key. A secure
|
||||
choice is 65537
|
||||
\param rng pointer to an RNG structure to use for random number generation
|
||||
while making the ke
|
||||
|
||||
_Example_
|
||||
\code
|
||||
RsaKey priv;
|
||||
RNG rng;
|
||||
int ret = 0;
|
||||
long e = 65537; // standard value to use for exponent
|
||||
|
||||
wc_InitRsaKey(&priv, NULL); // not using heap hint. No custom memory
|
||||
wc_InitRng(&rng);
|
||||
// generate 2048 bit long private key
|
||||
ret = wc_MakeRsaKey(&priv, 2048, e, &rng);
|
||||
if( ret != 0 ) {
|
||||
// error generating private key
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa none
|
||||
*/
|
||||
WOLFSSL_API int wc_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng);
|
141
doc/dox_comments/header_files/sha.h
Normal file
141
doc/dox_comments/header_files/sha.h
Normal file
@ -0,0 +1,141 @@
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief This function initializes SHA. This is automatically called
|
||||
by wc_ShaHash.
|
||||
|
||||
\return 0 Returned upon successfully initializing
|
||||
|
||||
\param sha pointer to the sha structure to use for encryption
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha sha[1];
|
||||
if ((ret = wc_InitSha(sha)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha failed");
|
||||
}
|
||||
else {
|
||||
wc_ShaUpdate(sha, data, len);
|
||||
wc_ShaFinal(sha, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ShaHash
|
||||
\sa wc_ShaUpdate
|
||||
\sa wc_ShaFinal
|
||||
*/
|
||||
WOLFSSL_API int wc_InitSha(wc_Sha*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Can be called to continually hash the provided byte array of
|
||||
length len.
|
||||
|
||||
\return 0 Returned upon successfully adding the data to the digest.
|
||||
|
||||
\param sha pointer to the sha structure to use for encryption
|
||||
\param data the data to be hashed
|
||||
\param len length of data to be hashed
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha sha[1];
|
||||
byte data[] = { // Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitSha(sha)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha failed");
|
||||
}
|
||||
else {
|
||||
wc_ShaUpdate(sha, data, len);
|
||||
wc_ShaFinal(sha, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ShaHash
|
||||
\sa wc_ShaFinal
|
||||
\sa wc_InitSha
|
||||
*/
|
||||
WOLFSSL_API int wc_ShaUpdate(wc_Sha*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Finalizes hashing of data. Result is placed into hash.
|
||||
Resets state of sha struct.
|
||||
|
||||
\return 0 Returned upon successfully finalizing.
|
||||
|
||||
\param sha pointer to the sha structure to use for encryption
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha sha[1];
|
||||
byte data[] = { Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitSha(sha)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha failed");
|
||||
}
|
||||
else {
|
||||
wc_ShaUpdate(sha, data, len);
|
||||
wc_ShaFinal(sha, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ShaHash
|
||||
\sa wc_InitSha
|
||||
\sa wc_ShaGetHash
|
||||
*/
|
||||
WOLFSSL_API int wc_ShaFinal(wc_Sha*, byte*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Used to clean up memory used by an initialized Sha struct.
|
||||
Note: this is only supported if you have WOLFSSL_TI_HASH defined.
|
||||
|
||||
\return No returns.
|
||||
|
||||
\param sha Pointer to the Sha struct to free.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha sha;
|
||||
wc_InitSha(&sha);
|
||||
// Use sha
|
||||
wc_ShaFree(&sha);
|
||||
\endcode
|
||||
|
||||
\sa wc_InitSha
|
||||
\sa wc_ShaUpdate
|
||||
\sa wc_ShaFinal
|
||||
*/
|
||||
WOLFSSL_API void wc_ShaFree(wc_Sha*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Gets hash data. Result is placed into hash. Does not reset state
|
||||
of sha struct.
|
||||
|
||||
\return 0 Returned upon successfully finalizing.
|
||||
|
||||
\param sha pointer to the sha structure to use for encryption
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha sha[1];
|
||||
if ((ret = wc_InitSha(sha)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha failed");
|
||||
}
|
||||
else {
|
||||
wc_ShaUpdate(sha, data, len);
|
||||
wc_ShaGetHash(sha, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ShaHash
|
||||
\sa wc_ShaFinal
|
||||
\sa wc_InitSha
|
||||
*/
|
||||
WOLFSSL_API int wc_ShaGetHash(wc_Sha*, byte*);
|
239
doc/dox_comments/header_files/sha256.h
Normal file
239
doc/dox_comments/header_files/sha256.h
Normal file
@ -0,0 +1,239 @@
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief This function initializes SHA256. This is automatically
|
||||
called by wc_Sha256Hash.
|
||||
|
||||
\return 0 Returned upon successfully initializing
|
||||
|
||||
\param sha256 pointer to the sha256 structure to use for encryption
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha256 sha256[1];
|
||||
if ((ret = wc_InitSha356(sha256)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha256 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha256Update(sha256, data, len);
|
||||
wc_Sha256Final(sha256, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha256Hash
|
||||
\sa wc_Sha256Update
|
||||
\sa wc_Sha256Final
|
||||
*/
|
||||
WOLFSSL_API int wc_InitSha256(wc_Sha256*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Can be called to continually hash the provided byte
|
||||
array of length len.
|
||||
|
||||
\return 0 Returned upon successfully adding the data to the digest.
|
||||
|
||||
\param sha256 pointer to the sha256 structure to use for encryption
|
||||
\param data the data to be hashed
|
||||
\param len length of data to be hashed
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha256 sha256[1];
|
||||
byte data[] = { Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitSha256(sha256)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha256 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha256Update(sha256, data, len);
|
||||
wc_Sha256Final(sha256, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha256Hash
|
||||
\sa wc_Sha256Final
|
||||
\sa wc_InitSha256
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha256Update(wc_Sha256*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Finalizes hashing of data. Result is placed into hash.
|
||||
Resets state of sha256 struct.
|
||||
|
||||
\return 0 Returned upon successfully finalizing.
|
||||
|
||||
\param sha256 pointer to the sha256 structure to use for encryption
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha256 sha256[1];
|
||||
byte data[] = { Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitSha356(sha256)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha256 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha256Update(sha256, data, len);
|
||||
wc_Sha256Final(sha256, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha256Hash
|
||||
\sa wc_Sha256GetHash
|
||||
\sa wc_InitSha256
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha256Final(wc_Sha256*, byte*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Resets the Sha256 structure. Note: this is only supported
|
||||
if you have WOLFSSL_TI_HASH defined.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param sha256 Pointer to the sha256 structure to be freed.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha256 sha256;
|
||||
byte data[] = { Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitSha256(&sha256)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha256 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha256Update(&sha256, data, len);
|
||||
wc_Sha256Final(&sha256, hash);
|
||||
wc_Sha256Free(&sha256);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitSha256
|
||||
\sa wc_Sha256Update
|
||||
\sa wc_Sha256Final
|
||||
*/
|
||||
WOLFSSL_API void wc_Sha256Free(wc_Sha256*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Gets hash data. Result is placed into hash. Does not
|
||||
reset state of sha256 struct.
|
||||
|
||||
\return 0 Returned upon successfully finalizing.
|
||||
|
||||
\param sha256 pointer to the sha256 structure to use for encryption
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha256 sha256[1];
|
||||
if ((ret = wc_InitSha356(sha256)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha256 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha256Update(sha256, data, len);
|
||||
wc_Sha256GetHash(sha256, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha256Hash
|
||||
\sa wc_Sha256Final
|
||||
\sa wc_InitSha256
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha256GetHash(wc_Sha256*, byte*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Used to initialize a Sha224 struct.
|
||||
|
||||
\return 0 Success
|
||||
\return 1 Error returned because sha224 is null.
|
||||
|
||||
\param sha224 Pointer to a Sha224 struct to initialize.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha224 sha224;
|
||||
if(wc_InitSha224(&sha224) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha224Hash
|
||||
\sa wc_Sha224Update
|
||||
\sa wc_Sha224Final
|
||||
*/
|
||||
WOLFSSL_API int wc_InitSha224(wc_Sha224*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Can be called to continually hash the provided byte array
|
||||
of length len.
|
||||
|
||||
\return 0 Success
|
||||
\return 1 Error returned if function fails.
|
||||
\return BAD_FUNC_ARG Error returned if sha224 or data is null.
|
||||
|
||||
\param sha224 Pointer to the Sha224 structure to use for encryption.
|
||||
\param data Data to be hashed.
|
||||
\param len Length of data to be hashed.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha224 sha224;
|
||||
byte data[] = { /* Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitSha224(&sha224)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha224 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha224Update(&sha224, data, len);
|
||||
wc_Sha224Final(&sha224, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitSha224
|
||||
\sa wc_Sha224Final
|
||||
\sa wc_Sha224Hash
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha224Update(wc_Sha224*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Finalizes hashing of data. Result is placed into hash.
|
||||
Resets state of sha224 struct.
|
||||
|
||||
\return 0 Success
|
||||
\return <0 Error
|
||||
|
||||
\param sha224 pointer to the sha224 structure to use for encryption
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha224 sha224;
|
||||
byte data[] = { /* Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitSha224(&sha224)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha224 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha256Update(&sha224, data, len);
|
||||
wc_Sha256Final(&sha224, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_InitSha224
|
||||
\sa wc_Sha224Hash
|
||||
\sa wc_Sha224Update
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha224Final(wc_Sha224*, byte*);
|
178
doc/dox_comments/header_files/sha512.h
Normal file
178
doc/dox_comments/header_files/sha512.h
Normal file
@ -0,0 +1,178 @@
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief This function initializes SHA512. This is automatically called
|
||||
by wc_Sha512Hash.
|
||||
|
||||
\return 0 Returned upon successfully initializing
|
||||
|
||||
\param sha512 pointer to the sha512 structure to use for encryption
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha512 sha512[1];
|
||||
if ((ret = wc_InitSha512(sha512)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha512 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha512Update(sha512, data, len);
|
||||
wc_Sha512Final(sha512, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha512Hash
|
||||
\sa wc_Sha512Update
|
||||
\sa wc_Sha512Final
|
||||
*/
|
||||
WOLFSSL_API int wc_InitSha512(wc_Sha512*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Can be called to continually hash the provided byte array
|
||||
of length len.
|
||||
|
||||
\return 0 Returned upon successfully adding the data to the digest.
|
||||
|
||||
\param sha512 pointer to the sha512 structure to use for encryption
|
||||
\param data the data to be hashed
|
||||
\param len length of data to be hashed
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha512 sha512[1];
|
||||
byte data[] = { Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitSha512(sha512)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha512 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha512Update(sha512, data, len);
|
||||
wc_Sha512Final(sha512, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha512Hash
|
||||
\sa wc_Sha512Final
|
||||
\sa wc_InitSha512
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha512Update(wc_Sha512*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Finalizes hashing of data. Result is placed into hash.
|
||||
|
||||
\return 0 Returned upon successfully finalizing the hash.
|
||||
|
||||
\param sha512 pointer to the sha512 structure to use for encryption
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha512 sha512[1];
|
||||
byte data[] = { Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitSha512(sha512)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha512 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha512Update(sha512, data, len);
|
||||
wc_Sha512Final(sha512, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha512Hash
|
||||
\sa wc_Sha512Final
|
||||
\sa wc_InitSha512
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha512Final(wc_Sha512*, byte*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief This function initializes SHA384. This is automatically called
|
||||
by wc_Sha384Hash.
|
||||
|
||||
\return 0 Returned upon successfully initializing
|
||||
|
||||
\param sha384 pointer to the sha384 structure to use for encryption
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha384 sha384[1];
|
||||
if ((ret = wc_InitSha384(sha384)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha384 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha384Update(sha384, data, len);
|
||||
wc_Sha384Final(sha384, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha384Hash
|
||||
\sa wc_Sha384Update
|
||||
\sa wc_Sha384Final
|
||||
*/
|
||||
WOLFSSL_API int wc_InitSha384(wc_Sha384*);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Can be called to continually hash the provided byte array
|
||||
of length len.
|
||||
|
||||
\return 0 Returned upon successfully adding the data to the digest.
|
||||
|
||||
\param sha384 pointer to the sha384 structure to use for encryption
|
||||
\param data the data to be hashed
|
||||
\param len length of data to be hashed
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha384 sha384[1];
|
||||
byte data[] = { Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitSha384(sha384)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha384 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha384Update(sha384, data, len);
|
||||
wc_Sha384Final(sha384, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha384Hash
|
||||
\sa wc_Sha384Final
|
||||
\sa wc_InitSha384
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha384Update(wc_Sha384*, const byte*, word32);
|
||||
/*!
|
||||
\ingroup SHA
|
||||
|
||||
\brief Finalizes hashing of data. Result is placed into hash.
|
||||
|
||||
\return 0 Returned upon successfully finalizing.
|
||||
|
||||
\param sha384 pointer to the sha384 structure to use for encryption
|
||||
\param hash Byte array to hold hash value.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Sha384 sha384[1];
|
||||
byte data[] = { Data to be hashed };
|
||||
word32 len = sizeof(data);
|
||||
|
||||
if ((ret = wc_InitSha384(sha384)) != 0) {
|
||||
WOLFSSL_MSG("wc_InitSha384 failed");
|
||||
}
|
||||
else {
|
||||
wc_Sha384Update(sha384, data, len);
|
||||
wc_Sha384Final(sha384, hash);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Sha384Hash
|
||||
\sa wc_Sha384Final
|
||||
\sa wc_InitSha384
|
||||
*/
|
||||
WOLFSSL_API int wc_Sha384Final(wc_Sha384*, byte*);
|
145
doc/dox_comments/header_files/signature.h
Normal file
145
doc/dox_comments/header_files/signature.h
Normal file
@ -0,0 +1,145 @@
|
||||
/*!
|
||||
\ingroup Signature
|
||||
|
||||
\brief This function returns the maximum size of the resulting signature.
|
||||
|
||||
\return Returns SIG_TYPE_E if sig_type is not supported. Returns
|
||||
BAD_FUNC_ARG if sig_type was invalid. A positive return value indicates
|
||||
the maximum size of a signature.
|
||||
|
||||
\param sig_type A signature type enum value such as
|
||||
WC_SIGNATURE_TYPE_ECC or WC_SIGNATURE_TYPE_RSA.
|
||||
\param key Pointer to a key structure such as ecc_key or RsaKey.
|
||||
\param key_len Size of the key structure.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
// Get signature length
|
||||
enum wc_SignatureType sig_type = WC_SIGNATURE_TYPE_ECC;
|
||||
ecc_key eccKey;
|
||||
word32 sigLen;
|
||||
wc_ecc_init(&eccKey);
|
||||
sigLen = wc_SignatureGetSize(sig_type, &eccKey, sizeof(eccKey));
|
||||
if (sigLen > 0) {
|
||||
// Success
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_HashGetDigestSize
|
||||
\sa wc_SignatureGenerate
|
||||
\sa wc_SignatureVerify
|
||||
*/
|
||||
WOLFSSL_API int wc_SignatureGetSize(enum wc_SignatureType sig_type,
|
||||
const void* key, word32 key_len);
|
||||
/*!
|
||||
\ingroup Signature
|
||||
|
||||
\brief This function validates a signature by hashing the data and
|
||||
using the resulting hash and key to verify the signature.
|
||||
|
||||
\return 0 Success
|
||||
\return SIG_TYPE_E -231, signature type not enabled/ available
|
||||
\return BAD_FUNC_ARG -173, bad function argument provided
|
||||
\return BUFFER_E -132, output buffer too small or input too large.
|
||||
|
||||
\param hash_type A hash type from the “enum wc_HashType” such as
|
||||
“WC_HASH_TYPE_SHA256”.
|
||||
\param sig_type A signature type enum value such as
|
||||
WC_SIGNATURE_TYPE_ECC or WC_SIGNATURE_TYPE_RSA.
|
||||
\param data Pointer to buffer containing the data to hash.
|
||||
\param data_len Length of the data buffer.
|
||||
\param sig Pointer to buffer to output signature.
|
||||
\param sig_len Length of the signature output buffer.
|
||||
\param key Pointer to a key structure such as ecc_key or RsaKey.
|
||||
\param key_len Size of the key structure.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
ecc_key eccKey;
|
||||
|
||||
// Import the public key
|
||||
wc_ecc_init(&eccKey);
|
||||
ret = wc_ecc_import_x963(eccPubKeyBuf, eccPubKeyLen, &eccKey);
|
||||
// Perform signature verification using public key
|
||||
ret = wc_SignatureVerify(
|
||||
WC_HASH_TYPE_SHA256, WC_SIGNATURE_TYPE_ECC,
|
||||
fileBuf, fileLen,
|
||||
sigBuf, sigLen,
|
||||
&eccKey, sizeof(eccKey));
|
||||
printf("Signature Verification: %s
|
||||
(%d)\n", (ret == 0) ? "Pass" : "Fail", ret);
|
||||
wc_ecc_free(&eccKey);
|
||||
\endcode
|
||||
|
||||
\sa wc_SignatureGetSize
|
||||
\sa wc_SignatureGenerate
|
||||
*/
|
||||
WOLFSSL_API int wc_SignatureVerify(
|
||||
enum wc_HashType hash_type, enum wc_SignatureType sig_type,
|
||||
const byte* data, word32 data_len,
|
||||
const byte* sig, word32 sig_len,
|
||||
const void* key, word32 key_len);
|
||||
/*!
|
||||
\ingroup Signature
|
||||
|
||||
\brief This function generates a signature from the data using a
|
||||
key. It first creates a hash of the data then signs the hash using the key.
|
||||
|
||||
\return 0 Success
|
||||
\return SIG_TYPE_E -231, signature type not enabled/ available
|
||||
\return BAD_FUNC_ARG -173, bad function argument provided
|
||||
\return BUFFER_E -132, output buffer too small or input too large.
|
||||
|
||||
\param hash_type A hash type from the “enum wc_HashType”
|
||||
such as “WC_HASH_TYPE_SHA256”.
|
||||
\param sig_type A signature type enum value such as
|
||||
WC_SIGNATURE_TYPE_ECC or WC_SIGNATURE_TYPE_RSA.
|
||||
\param data Pointer to buffer containing the data to hash.
|
||||
\param data_len Length of the data buffer.
|
||||
\param sig Pointer to buffer to output signature.
|
||||
\param sig_len Length of the signature output buffer.
|
||||
\param key Pointer to a key structure such as ecc_key or RsaKey.
|
||||
\param key_len Size of the key structure.
|
||||
\param rng Pointer to an initialized RNG structure.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
RNG rng;
|
||||
ecc_key eccKey;
|
||||
|
||||
wc_InitRng(&rng);
|
||||
wc_ecc_init(&eccKey);
|
||||
|
||||
// Generate key
|
||||
ret = wc_ecc_make_key(&rng, 32, &eccKey);
|
||||
|
||||
// Get signature length and allocate buffer
|
||||
sigLen = wc_SignatureGetSize(sig_type, &eccKey, sizeof(eccKey));
|
||||
sigBuf = malloc(sigLen);
|
||||
|
||||
// Perform signature verification using public key
|
||||
ret = wc_SignatureGenerate(
|
||||
WC_HASH_TYPE_SHA256, WC_SIGNATURE_TYPE_ECC,
|
||||
fileBuf, fileLen,
|
||||
sigBuf, &sigLen,
|
||||
&eccKey, sizeof(eccKey),
|
||||
&rng);
|
||||
printf("Signature Generation: %s
|
||||
(%d)\n", (ret == 0) ? "Pass" : "Fail", ret);
|
||||
|
||||
free(sigBuf);
|
||||
wc_ecc_free(&eccKey);
|
||||
wc_FreeRng(&rng);
|
||||
\endcode
|
||||
|
||||
\sa wc_SignatureGetSize
|
||||
\sa wc_SignatureVerify
|
||||
*/
|
||||
WOLFSSL_API int wc_SignatureGenerate(
|
||||
enum wc_HashType hash_type, enum wc_SignatureType sig_type,
|
||||
const byte* data, word32 data_len,
|
||||
byte* sig, word32 *sig_len,
|
||||
const void* key, word32 key_len,
|
||||
WC_RNG* rng);
|
496
doc/dox_comments/header_files/srp.h
Normal file
496
doc/dox_comments/header_files/srp.h
Normal file
@ -0,0 +1,496 @@
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Initializes the Srp struct for usage.
|
||||
|
||||
\return 0 on success.
|
||||
\return BAD_FUNC_ARG Returns when there's an issue with the arguments such
|
||||
as srp being null or SrpSide not being SRP_CLIENT_SIDE or SRP_SERVER_SIDE.
|
||||
\return NOT_COMPILED_IN Returns when a type is passed as an argument but
|
||||
hasn't been configured in the wolfCrypt build.
|
||||
\return <0 on error.
|
||||
|
||||
\param srp the Srp structure to be initialized.
|
||||
\param type the hash type to be used.
|
||||
\param side the side of the communication.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp srp;
|
||||
if (wc_SrpInit(&srp, SRP_TYPE_SHA, SRP_CLIENT_SIDE) != 0)
|
||||
{
|
||||
// Initialization error
|
||||
}
|
||||
else
|
||||
{
|
||||
wc_SrpTerm(&srp);
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpTerm
|
||||
\sa wc_SrpSetUsername
|
||||
*/
|
||||
WOLFSSL_API int wc_SrpInit(Srp* srp, SrpType type, SrpSide side);
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Releases the Srp struct resources after usage.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param srp Pointer to the Srp structure to be terminated.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp srp;
|
||||
wc_SrpInit(&srp, SRP_TYPE_SHA, SRP_CLIENT_SIDE);
|
||||
// Use srp
|
||||
wc_SrpTerm(&srp)
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpInit
|
||||
*/
|
||||
WOLFSSL_API void wc_SrpTerm(Srp* srp);
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Sets the username. This function MUST be called after wc_SrpInit.
|
||||
|
||||
\return 0 Username set successfully.
|
||||
\return BAD_FUNC_ARG: Return if srp or username is null.
|
||||
\return MEMORY_E: Returns if there is an issue allocating memory
|
||||
for srp->user
|
||||
\return < 0: Error.
|
||||
|
||||
\param srp the Srp structure.
|
||||
\param username the buffer containing the username.
|
||||
\param size the username size in bytes
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp srp;
|
||||
byte username[] = "user";
|
||||
word32 usernameSize = 4;
|
||||
|
||||
wc_SrpInit(&srp, SRP_TYPE_SHA, SRP_CLIENT_SIDE);
|
||||
if(wc_SrpSetUsername(&srp, username, usernameSize) != 0)
|
||||
{
|
||||
// Error occurred setting username.
|
||||
}
|
||||
wc_SrpTerm(&srp);
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpInit
|
||||
\sa wc_SrpSetParams
|
||||
\sa wc_SrpTerm
|
||||
*/
|
||||
WOLFSSL_API int wc_SrpSetUsername(Srp* srp, const byte* username, word32 size);
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Sets the srp parameters based on the username.. Must be called
|
||||
after wc_SrpSetUsername.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returns if srp, N, g, or salt is null or if nSz < gSz.
|
||||
\return SRP_CALL_ORDER_E Returns if wc_SrpSetParams is called before
|
||||
wc_SrpSetUsername.
|
||||
\return <0 Error
|
||||
|
||||
\param srp the Srp structure.
|
||||
\param N the Modulus. N = 2q+1, [q, N] are primes.
|
||||
\param nSz the N size in bytes.
|
||||
\param g the Generator modulo N.
|
||||
\param gSz the g size in bytes
|
||||
\param salt a small random salt. Specific for each username.
|
||||
\param saltSz the salt size in bytes
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp srp;
|
||||
byte username[] = "user";
|
||||
word32 usernameSize = 4;
|
||||
|
||||
byte N[] = { }; // Contents of byte array N
|
||||
byte g[] = { }; // Contents of byte array g
|
||||
byte salt[] = { }; // Contents of byte array salt
|
||||
|
||||
wc_SrpInit(&srp, SRP_TYPE_SHA, SRP_CLIENT_SIDE);
|
||||
wc_SrpSetUsername(&srp, username, usernameSize);
|
||||
|
||||
if(wc_SrpSetParams(&srp, N, sizeof(N), g, sizeof(g), salt,
|
||||
sizeof(salt)) != 0)
|
||||
{
|
||||
// Error setting params
|
||||
}
|
||||
wc_SrpTerm(&srp);
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpInit
|
||||
\sa wc_SrpSetUsername
|
||||
\sa wc_SrpTerm
|
||||
*/
|
||||
WOLFSSL_API int wc_SrpSetParams(Srp* srp, const byte* N, word32 nSz,
|
||||
const byte* g, word32 gSz,
|
||||
const byte* salt, word32 saltSz);
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Sets the password. Setting the password does not persists the
|
||||
clear password data in the srp structure. The client calculates
|
||||
x = H(salt + H(user:pswd)) and stores it in the auth field. This function
|
||||
MUST be called after wc_SrpSetParams and is CLIENT SIDE ONLY.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returns if srp or password is null or if srp->side
|
||||
is not set to SRP_CLIENT_SIDE.
|
||||
\return SRP_CALL_ORDER_E Returns when wc_SrpSetPassword is called out
|
||||
of order.
|
||||
\return <0 Error
|
||||
|
||||
\param srp The Srp structure.
|
||||
\param password The buffer containing the password.
|
||||
\param size The size of the password in bytes.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp srp;
|
||||
byte username[] = "user";
|
||||
word32 usernameSize = 4;
|
||||
byte password[] = "password";
|
||||
word32 passwordSize = 8;
|
||||
|
||||
byte N[] = { }; // Contents of byte array N
|
||||
byte g[] = { }; // Contents of byte array g
|
||||
byte salt[] = { }; // Contents of byte array salt
|
||||
|
||||
wc_SrpInit(&srp, SRP_TYPE_SHA, SRP_CLIENT_SIDE);
|
||||
wc_SrpSetUsername(&srp, username, usernameSize);
|
||||
wc_SrpSetParams(&srp, N, sizeof(N), g, sizeof(g), salt, sizeof(salt));
|
||||
|
||||
if(wc_SrpSetPassword(&srp, password, passwordSize) != 0)
|
||||
{
|
||||
// Error setting password
|
||||
}
|
||||
|
||||
wc_SrpTerm(&srp);
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpInit
|
||||
\sa wc_SrpSetUsername
|
||||
\sa wc_SrpSetParams
|
||||
*/
|
||||
WOLFSSL_API int wc_SrpSetPassword(Srp* srp, const byte* password, word32 size);
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Sets the verifier. This function MUST be called after
|
||||
wc_SrpSetParams and is SERVER SIDE ONLY.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returned if srp or verifier is null or
|
||||
srp->side is not SRP_SERVER_SIDE.
|
||||
\return <0 Error
|
||||
|
||||
\param srp The Srp structure.
|
||||
\param verifier The structure containing the verifier.
|
||||
\param size The verifier size in bytes.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp srp;
|
||||
byte username[] = "user";
|
||||
word32 usernameSize = 4;
|
||||
|
||||
byte N[] = { }; // Contents of byte array N
|
||||
byte g[] = { }; // Contents of byte array g
|
||||
byte salt[] = { }; // Contents of byte array salt
|
||||
wc_SrpInit(&srp, SRP_TYPE_SHA, SRP_SERVER_SIDE);
|
||||
wc_SrpSetUsername(&srp, username, usernameSize);
|
||||
wc_SrpSetParams(&srp, N, sizeof(N), g, sizeof(g), salt, sizeof(salt))
|
||||
byte verifier[] = { }; // Contents of some verifier
|
||||
|
||||
if(wc_SrpSetVerifier(&srp, verifier, sizeof(verifier)) != 0)
|
||||
{
|
||||
// Error setting verifier
|
||||
}
|
||||
|
||||
wc_SrpTerm(&srp);
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpInit
|
||||
\sa wc_SrpSetParams
|
||||
\sa wc_SrpGetVerifier
|
||||
*/
|
||||
WOLFSSL_API int wc_SrpSetVerifier(Srp* srp, const byte* verifier, word32 size);
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Gets the verifier. The client calculates the verifier
|
||||
with v = g ^ x % N.
|
||||
This function MAY be called after wc_SrpSetPassword and
|
||||
is CLIENT SIDE ONLY.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returned if srp, verifier or size is null
|
||||
or if srp->side is not SRP_CLIENT_SIDE.
|
||||
\return SRP_CALL_ORDER_E Returned if wc_SrpGetVerifier is called
|
||||
out of order.
|
||||
\return <0 Error
|
||||
|
||||
\param srp The Srp structure.
|
||||
\param verifier The buffer to write the verifier.
|
||||
\param size Buffer size in bytes. Updated with the verifier size.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp srp;
|
||||
byte username[] = "user";
|
||||
word32 usernameSize = 4;
|
||||
byte password[] = "password";
|
||||
word32 passwordSize = 8;
|
||||
|
||||
byte N[] = { }; // Contents of byte array N
|
||||
byte g[] = { }; // Contents of byte array g
|
||||
byte salt[] = { }; // Contents of byte array salt
|
||||
byte v[64];
|
||||
word32 vSz = 0;
|
||||
vSz = sizeof(v);
|
||||
|
||||
wc_SrpInit(&srp, SRP_TYPE_SHA, SRP_CLIENT_SIDE);
|
||||
wc_SrpSetUsername(&srp, username, usernameSize);
|
||||
wc_SrpSetParams(&srp, N, sizeof(N), g, sizeof(g), salt, sizeof(salt))
|
||||
wc_SrpSetPassword(&srp, password, passwordSize)
|
||||
|
||||
if( wc_SrpGetVerifier(&srp, v, &vSz ) != 0)
|
||||
{
|
||||
// Error getting verifier
|
||||
}
|
||||
wc_SrpTerm(&srp);
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpSetVerifier
|
||||
\sa wc_SrpSetPassword
|
||||
*/
|
||||
WOLFSSL_API int wc_SrpGetVerifier(Srp* srp, byte* verifier, word32* size);
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Sets the private ephemeral value. The private ephemeral value
|
||||
is known as:
|
||||
a at the client side. a = random()
|
||||
b at the server side. b = random()
|
||||
This function is handy for unit test cases or if the developer wants
|
||||
to use an external
|
||||
random source to set the ephemeral value. This function MAY be called
|
||||
before wc_SrpGetPublic.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returned if srp, private, or size is null.
|
||||
\return SRP_CALL_ORDER_E Returned if wc_SrpSetPrivate is called out
|
||||
of order.
|
||||
\return <0 Error
|
||||
|
||||
\param srp the Srp structure.
|
||||
\param priv the ephemeral value.
|
||||
\param size the private size in bytes.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp srp;
|
||||
byte username[] = "user";
|
||||
word32 usernameSize = 4;
|
||||
|
||||
byte N[] = { }; // Contents of byte array N
|
||||
byte g[] = { }; // Contents of byte array g
|
||||
byte salt[] = { }; // Contents of byte array salt
|
||||
byte verifier = { }; // Contents of some verifier
|
||||
wc_SrpInit(&srp, SRP_TYPE_SHA, SRP_SERVER_SIDE);
|
||||
wc_SrpSetUsername(&srp, username, usernameSize);
|
||||
wc_SrpSetParams(&srp, N, sizeof(N), g, sizeof(g), salt, sizeof(salt))
|
||||
wc_SrpSetVerifier(&srp, verifier, sizeof(verifier))
|
||||
|
||||
byte b[] = { }; // Some ephemeral value
|
||||
if( wc_SrpSetPrivate(&srp, b, sizeof(b)) != 0)
|
||||
{
|
||||
// Error setting private ephemeral
|
||||
}
|
||||
|
||||
wc_SrpTerm(&srp);
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpGetPublic
|
||||
*/
|
||||
WOLFSSL_API int wc_SrpSetPrivate(Srp* srp, const byte* priv, word32 size);
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Gets the public ephemeral value. The public ephemeral value
|
||||
is known as:
|
||||
A at the client side. A = g ^ a % N
|
||||
B at the server side. B = (k * v + (g ˆ b % N)) % N
|
||||
This function MUST be called after wc_SrpSetPassword or wc_SrpSetVerifier.
|
||||
The function wc_SrpSetPrivate may be called before wc_SrpGetPublic.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returned if srp, pub, or size is null.
|
||||
\return SRP_CALL_ORDER_E Returned if wc_SrpGetPublic is called out
|
||||
of order.
|
||||
\return BUFFER_E Returned if size < srp.N.
|
||||
\return <0 Error
|
||||
|
||||
\param srp the Srp structure.
|
||||
\param pub the buffer to write the public ephemeral value.
|
||||
\param size the the buffer size in bytes. Will be updated with
|
||||
the ephemeral value size.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp srp;
|
||||
byte username[] = "user";
|
||||
word32 usernameSize = 4;
|
||||
byte password[] = "password";
|
||||
word32 passwordSize = 8;
|
||||
|
||||
byte N[] = { }; // Contents of byte array N
|
||||
byte g[] = { }; // Contents of byte array g
|
||||
byte salt[] = { }; // Contents of byte array salt
|
||||
wc_SrpInit(&srp, SRP_TYPE_SHA, SRP_CLIENT_SIDE);
|
||||
wc_SrpSetUsername(&srp, username, usernameSize);
|
||||
wc_SrpSetParams(&srp, N, sizeof(N), g, sizeof(g), salt, sizeof(salt));
|
||||
wc_SrpSetPassword(&srp, password, passwordSize)
|
||||
|
||||
byte public[64];
|
||||
word32 publicSz = 0;
|
||||
|
||||
if( wc_SrpGetPublic(&srp, public, &publicSz) != 0)
|
||||
{
|
||||
// Error getting public ephemeral
|
||||
}
|
||||
|
||||
wc_SrpTerm(&srp);
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpSetPrivate
|
||||
\sa wc_SrpSetPassword
|
||||
\sa wc_SrpSetVerifier
|
||||
*/
|
||||
WOLFSSL_API int wc_SrpGetPublic(Srp* srp, byte* pub, word32* size);
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Computes the session key. The key can be accessed at
|
||||
srp->key after success.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returned if srp, clientPubKey, or serverPubKey
|
||||
or if clientPubKeySz or serverPubKeySz is 0.
|
||||
\return SRP_CALL_ORDER_E Returned if wc_SrpComputeKey is called out
|
||||
of order.
|
||||
\return <0 Error
|
||||
|
||||
\param srp the Srp structure.
|
||||
\param clientPubKey the client's public ephemeral value.
|
||||
\param clientPubKeySz the client's public ephemeral value size.
|
||||
\param serverPubKey the server's public ephemeral value.
|
||||
\param serverPubKeySz the server's public ephemeral value size.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp server;
|
||||
|
||||
byte username[] = "user";
|
||||
word32 usernameSize = 4;
|
||||
byte password[] = "password";
|
||||
word32 passwordSize = 8;
|
||||
byte N[] = { }; // Contents of byte array N
|
||||
byte g[] = { }; // Contents of byte array g
|
||||
byte salt[] = { }; // Contents of byte array salt
|
||||
byte verifier[] = { }; // Contents of some verifier
|
||||
byte serverPubKey[] = { }; // Contents of server pub key
|
||||
word32 serverPubKeySize = sizeof(serverPubKey);
|
||||
byte clientPubKey[64];
|
||||
word32 clientPubKeySize = 64;
|
||||
|
||||
wc_SrpInit(&server, SRP_TYPE_SHA, SRP_SERVER_SIDE);
|
||||
wc_SrpSetUsername(&server, username, usernameSize);
|
||||
wc_SrpSetParams(&server, N, sizeof(N), g, sizeof(g), salt, sizeof(salt));
|
||||
wc_SrpSetVerifier(&server, verifier, sizeof(verifier));
|
||||
wc_SrpGetPublic(&server, serverPubKey, &serverPubKeySize);
|
||||
|
||||
wc_SrpComputeKey(&server, clientPubKey, clientPubKeySz,
|
||||
serverPubKey, serverPubKeySize)
|
||||
wc_SrpTerm(&server);
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpGetPublic
|
||||
*/
|
||||
WOLFSSL_API int wc_SrpComputeKey(Srp* srp,
|
||||
byte* clientPubKey, word32 clientPubKeySz,
|
||||
byte* serverPubKey, word32 serverPubKeySz);
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Gets the proof. This function MUST be called after wc_SrpComputeKey.
|
||||
|
||||
\return 0 Success
|
||||
\return BAD_FUNC_ARG Returns if srp, proof, or size is null.
|
||||
\return BUFFER_E Returns if size is less than the hash size of srp->type.
|
||||
\return <0 Error
|
||||
|
||||
\param srp the Srp structure.
|
||||
\param proof the peers proof.
|
||||
\param size the proof size in bytes.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp cli;
|
||||
byte clientProof[SRP_MAX_DIGEST_SIZE];
|
||||
word32 clientProofSz = SRP_MAX_DIGEST_SIZE;
|
||||
|
||||
// Initialize Srp following steps from previous examples
|
||||
|
||||
if (wc_SrpGetProof(&cli, clientProof, &clientProofSz) != 0)
|
||||
{
|
||||
// Error getting proof
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpComputeKey
|
||||
*/
|
||||
WOLFSSL_API int wc_SrpGetProof(Srp* srp, byte* proof, word32* size);
|
||||
/*!
|
||||
\ingroup SRP
|
||||
|
||||
\brief Verifies the peers proof. This function MUST be called before
|
||||
wc_SrpGetSessionKey.
|
||||
|
||||
\return 0 Success
|
||||
\return <0 Error
|
||||
|
||||
\param srp the Srp structure.
|
||||
\param proof the peers proof.
|
||||
\param size the proof size in bytes.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
Srp cli;
|
||||
Srp srv;
|
||||
byte clientProof[SRP_MAX_DIGEST_SIZE];
|
||||
word32 clientProofSz = SRP_MAX_DIGEST_SIZE;
|
||||
|
||||
// Initialize Srp following steps from previous examples
|
||||
// First get the proof
|
||||
wc_SrpGetProof(&cli, clientProof, &clientProofSz)
|
||||
|
||||
if (wc_SrpVerifyPeersProof(&srv, clientProof, clientProofSz) != 0)
|
||||
{
|
||||
// Error verifying proof
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_SrpGetSessionKey
|
||||
\sa wc_SrpGetProof
|
||||
\sa wc_SrpTerm
|
||||
*/
|
||||
WOLFSSL_API int wc_SrpVerifyPeersProof(Srp* srp, byte* proof, word32 size);
|
11711
doc/dox_comments/header_files/ssl.h
Normal file
11711
doc/dox_comments/header_files/ssl.h
Normal file
File diff suppressed because it is too large
Load Diff
29
doc/dox_comments/header_files/tfm.h
Normal file
29
doc/dox_comments/header_files/tfm.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*!
|
||||
\ingroup Math
|
||||
|
||||
\brief This function checks the runtime fastmath settings for the maximum
|
||||
size of an integer. It is important when a user is using a wolfCrypt
|
||||
library independently, as the FP_SIZE must match for each library in order
|
||||
for math to work correctly. This check is defined as
|
||||
CheckFastMathSettings(), which simply compares CheckRunTimeFastMath
|
||||
and FP_SIZE, returning 0 if there is a mismatch, or 1 if they match.
|
||||
|
||||
\return FP_SIZE Returns FP_SIZE, corresponding to the max size
|
||||
available for the math library.
|
||||
|
||||
\param none No parameters.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
if (CheckFastMathSettings() != 1) {
|
||||
return err_sys("Build vs. runtime fastmath FP_MAX_BITS mismatch\n");
|
||||
}
|
||||
// This is converted by the preprocessor to:
|
||||
// if ( (CheckRunTimeFastMath() == FP_SIZE) != 1) {
|
||||
// and confirms that the fast math settings match
|
||||
// the compile time settings
|
||||
\endcode
|
||||
|
||||
\sa CheckRunTimeSettings
|
||||
*/
|
||||
WOLFSSL_API word32 CheckRunTimeFastMath(void);
|
169
doc/dox_comments/header_files/types.h
Normal file
169
doc/dox_comments/header_files/types.h
Normal file
@ -0,0 +1,169 @@
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This is not actually a function, but rather a preprocessor macro,
|
||||
which allows the user to substitute in their own malloc, realloc, and free
|
||||
functions in place of the standard C memory functions.
|
||||
To use external memory functions, define XMALLOC_USER. This will cause the
|
||||
memory functions to be replaced by external functions of the form:
|
||||
extern void *XMALLOC(size_t n, void* heap, int type);
|
||||
extern void *XREALLOC(void *p, size_t n, void* heap, int type);
|
||||
extern void XFREE(void *p, void* heap, int type);
|
||||
To use the basic C memory functions in place of wolfSSL_Malloc,
|
||||
wolfSSL_Realloc, wolfSSL_Free, define NO_WOLFSSL_MEMORY. This
|
||||
will replace the memory functions with:
|
||||
#define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s)))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) free((xp));}
|
||||
#define XREALLOC(p, n, h, t) realloc((p), (n))
|
||||
If none of these options are selected, the system will default to use
|
||||
the wolfSSL memory functions. A user can set custom memory functions
|
||||
through callback hooks, (see wolfSSL_Malloc,
|
||||
wolfSSL_Realloc, wolfSSL_Free). This option will replace the
|
||||
memory functions with:
|
||||
#define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s)))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));}
|
||||
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))
|
||||
|
||||
\return pointer Return a pointer to allocated memory on success
|
||||
\return NULL on failure
|
||||
|
||||
\param s size of memory to allocate
|
||||
\param h (used by custom XMALLOC function) pointer to the heap to use
|
||||
\param t memory allocation types for user hints. See enum in types.h
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int* 10 ints = XMALLOC(10 * sizeof(int), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
if ( ints == NULL) {
|
||||
// error allocating space
|
||||
return MEMORY_E;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Malloc
|
||||
\sa wolfSSL_Realloc
|
||||
\sa wolfSSL_Free
|
||||
\sa wolfSSL_SetAllocators
|
||||
*/
|
||||
WOLFSSL_API void* XMALLOC(size_t n, void* heap, int type);
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This is not actually a function, but rather a preprocessor macro,
|
||||
which allows the user to substitute in their own malloc, realloc, and
|
||||
free functions in place of the standard C memory functions.
|
||||
To use external memory functions, define XMALLOC_USER. This will cause the
|
||||
memory functions to be replaced by external functions of the form:
|
||||
extern void *XMALLOC(size_t n, void* heap, int type);
|
||||
extern void *XREALLOC(void *p, size_t n, void* heap, int type);
|
||||
extern void XFREE(void *p, void* heap, int type);
|
||||
To use the basic C memory functions in place of wolfSSL_Malloc,
|
||||
wolfSSL_Realloc, wolfSSL_Free, define NO_WOLFSSL_MEMORY. This will
|
||||
replace the memory functions with:
|
||||
#define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s)))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) free((xp));}
|
||||
#define XREALLOC(p, n, h, t) realloc((p), (n))
|
||||
If none of these options are selected, the system will default to
|
||||
use the wolfSSL memory functions. A user can set custom memory
|
||||
functions through callback hooks, (see wolfSSL_Malloc,
|
||||
wolfSSL_Realloc, wolfSSL_Free). This option will replace
|
||||
the memory functions with:
|
||||
#define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s)))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));}
|
||||
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))
|
||||
|
||||
\return Return a pointer to allocated memory on success
|
||||
\return NULL on failure
|
||||
|
||||
\param p pointer to the address to reallocate
|
||||
\param n size of memory to allocate
|
||||
\param h (used by custom XREALLOC function) pointer to the heap to use
|
||||
\param t memory allocation types for user hints. See enum in types.h
|
||||
|
||||
_Example_
|
||||
\code
|
||||
none
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Malloc
|
||||
\sa wolfSSL_Realloc
|
||||
\sa wolfSSL_Free
|
||||
\sa wolfSSL_SetAllocators
|
||||
*/
|
||||
WOLFSSL_API void* XREALLOC(void *p, size_t n, void* heap, int type);
|
||||
/*!
|
||||
\ingroup Memory
|
||||
|
||||
\brief This is not actually a function, but rather a preprocessor macro,
|
||||
which allows the user to substitute in their own malloc, realloc, and
|
||||
free functions in place of the standard C memory functions.
|
||||
To use external memory functions, define XMALLOC_USER. This will cause
|
||||
the memory functions to be replaced by external functions of the form:
|
||||
extern void *XMALLOC(size_t n, void* heap, int type);
|
||||
extern void *XREALLOC(void *p, size_t n, void* heap, int type);
|
||||
extern void XFREE(void *p, void* heap, int type);
|
||||
To use the basic C memory functions in place of wolfSSL_Malloc,
|
||||
wolfSSL_Realloc, wolfSSL_Free, define NO_WOLFSSL_MEMORY. This
|
||||
will replace the memory functions with:
|
||||
#define XMALLOC(s, h, t) ((void)h, (void)t, malloc((s)))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) free((xp));}
|
||||
#define XREALLOC(p, n, h, t) realloc((p), (n))
|
||||
If none of these options are selected, the system will default to use
|
||||
the wolfSSL memory functions. A user can set custom memory functions
|
||||
through callback hooks, (see wolfSSL_Malloc, wolfSSL_Realloc,
|
||||
wolfSSL_Free). This option will replace the memory functions with:
|
||||
#define XMALLOC(s, h, t) ((void)h, (void)t, wolfSSL_Malloc((s)))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) wolfSSL_Free((xp));}
|
||||
#define XREALLOC(p, n, h, t) wolfSSL_Realloc((p), (n))
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param p pointer to the address to free
|
||||
\param h (used by custom XFREE function) pointer to the heap to use
|
||||
\param t memory allocation types for user hints. See enum in types.h
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int* 10 ints = XMALLOC(10 * sizeof(int), NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||
|
||||
if ( ints == NULL) {
|
||||
// error allocating space
|
||||
return MEMORY_E;
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_Malloc
|
||||
\sa wolfSSL_Realloc
|
||||
\sa wolfSSL_Free
|
||||
\sa wolfSSL_SetAllocators
|
||||
*/
|
||||
WOLFSSL_API void XFREE(void *p, void* heap, int type);
|
||||
/*!
|
||||
\ingroup Math
|
||||
|
||||
\brief This function checks the compile time class settings. It is
|
||||
important when a user is using a wolfCrypt library independently, as
|
||||
the settings must match between libraries for math to work correctly.
|
||||
This check is defined as CheckCtcSettings(), which simply compares
|
||||
CheckRunTimeSettings and CTC_SETTINGS, returning 0 if there is a
|
||||
mismatch, or 1 if they match.
|
||||
|
||||
\return settings Returns the runtime CTC_SETTINGS (Compile Time Settings)
|
||||
|
||||
\param none No Parameters.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
if (CheckCtcSettings() != 1) {
|
||||
return err_sys("Build vs. runtime math mismatch\n");
|
||||
}
|
||||
// This is converted by the preprocessor to:
|
||||
// if ( (CheckCtcSettings() == CTC_SETTINGS) != 1) {
|
||||
// and will compare whether the compile time class settings
|
||||
// match the current settings
|
||||
\endcode
|
||||
|
||||
\sa CheckRunTimeFastMath
|
||||
*/
|
||||
WOLFSSL_API word32 CheckRunTimeSettings(void);
|
208
doc/dox_comments/header_files/wc_encrypt.h
Normal file
208
doc/dox_comments/header_files/wc_encrypt.h
Normal file
@ -0,0 +1,208 @@
|
||||
/*!
|
||||
\ingroup AES
|
||||
\brief Decrypts a cipher from the input buffer in, and places the
|
||||
resulting plain text in the output buffer out using cipher block
|
||||
chaining with AES. This function does not require an AES structure
|
||||
to be initialized. Instead, it takes in a key and an iv
|
||||
(initialization vector) and uses these to initialize an
|
||||
AES object and then decrypt the cipher text.
|
||||
|
||||
\return 0 On successfully decrypting message
|
||||
\return BAD_ALIGN_E Returned on block align error
|
||||
\return BAD_FUNC_ARG Returned if key length is invalid or AES object
|
||||
is null during AesSetIV
|
||||
\return MEMORY_E Returned if WOLFSSL_SMALL_STACK is enabled and
|
||||
XMALLOC fails to instantiate an AES object.
|
||||
|
||||
\param out pointer to the output buffer in which to store the plain
|
||||
text of the decrypted message
|
||||
\param in pointer to the input buffer containing cipher text to be
|
||||
decrypted
|
||||
\param inSz size of input message
|
||||
\param key 16, 24, or 32 byte secret key for decryption
|
||||
\param keySz size of key used for decryption
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret = 0;
|
||||
byte key[] = { some 16, 24, or 32 byte key };
|
||||
byte iv[] = { some 16 byte iv };
|
||||
byte cipher[AES_BLOCK_SIZE * n]; //n being a positive integer making
|
||||
cipher some multiple of 16 bytes
|
||||
// fill cipher with cipher text
|
||||
byte plain [AES_BLOCK_SIZE * n];
|
||||
if ((ret = wc_AesCbcDecryptWithKey(plain, cipher, AES_BLOCK_SIZE, key,
|
||||
AES_BLOCK_SIZE, iv)) != 0 ) {
|
||||
// Decrypt Error
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_AesSetKey
|
||||
\sa wc_AesSetIV
|
||||
\sa wc_AesCbcEncrypt
|
||||
\sa wc_AesCbcDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz,
|
||||
const byte* key, word32 keySz,
|
||||
const byte* iv);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function decrypts the input ciphertext, in, and stores the
|
||||
resulting plaintext in the output buffer, out. It uses DES encryption
|
||||
with cipher block chaining (CBC) mode. This function is a substitute
|
||||
for wc_Des_CbcDecrypt, allowing the user to decrypt a message without
|
||||
directly instantiating a Des structure.
|
||||
|
||||
\return 0 Returned upon successfully decrypting the given ciphertext
|
||||
\return MEMORY_E Returned if there is an error allocating space for a
|
||||
Des structure
|
||||
|
||||
\param out pointer to the buffer in which to store the decrypted plaintext
|
||||
\param in pointer to the input buffer containing the encrypted ciphertext
|
||||
\param sz length of the ciphertext to decrypt
|
||||
\param key pointer to the buffer containing the 8 byte key to use for
|
||||
decryption
|
||||
\param iv pointer to the buffer containing the 8 byte iv to use for
|
||||
decryption. If no iv is provided, the iv defaults to 0
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte key[] = { // initialize with 8 byte key };
|
||||
byte iv[] = { // initialize with 8 byte iv };
|
||||
|
||||
byte cipher[] = { // initialize with ciphertext };
|
||||
byte decoded[sizeof(cipher)];
|
||||
|
||||
if ( wc_Des_CbcDecryptWithKey(decoded, cipher, sizeof(cipher), key,
|
||||
iv) != 0) {
|
||||
// error decrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des_CbcDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_Des_CbcDecryptWithKey(byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* key, const byte* iv);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function encrypts the input plaintext, in, and stores the
|
||||
resulting ciphertext in the output buffer, out. It uses DES encryption
|
||||
with cipher block chaining (CBC) mode. This function is a substitute
|
||||
for wc_Des_CbcEncrypt, allowing the user to encrypt a message without
|
||||
directly instantiating a Des structure.
|
||||
|
||||
\return 0 Returned after successfully encrypting data.
|
||||
\return MEMORY_E Returned if there's an error allocating memory for a
|
||||
Des structure.
|
||||
\return <0 Returned on any error during encryption.
|
||||
|
||||
\param out Final encrypted data
|
||||
\param in Data to be encrypted, must be padded to Des block size.
|
||||
\param sz Size of input buffer.
|
||||
\param key Pointer to the key to use for encryption.
|
||||
\param iv Initialization vector
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte key[] = { // initialize with 8 byte key };
|
||||
byte iv[] = { // initialize with 8 byte iv };
|
||||
byte in[] = { // Initialize with plaintext };
|
||||
byte out[sizeof(in)];
|
||||
if ( wc_Des_CbcEncryptWithKey(&out, in, sizeof(in), key, iv) != 0)
|
||||
{
|
||||
// error encrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des_CbcDecryptWithKey
|
||||
\sa wc_Des_CbcEncrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_Des_CbcEncryptWithKey(byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* key, const byte* iv);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function encrypts the input plaintext, in, and stores
|
||||
the resulting ciphertext in the output buffer, out. It uses Triple
|
||||
DES (3DES) encryption with cipher block chaining (CBC) mode. This
|
||||
function is a substitute for wc_Des3_CbcEncrypt, allowing the user
|
||||
to encrypt a message without directly instantiating a Des3 structure.
|
||||
|
||||
\return 0 Returned after successfully encrypting data.
|
||||
\return MEMORY_E Returned if there's an error allocating memory for
|
||||
a Des structure.
|
||||
\return <0 Returned on any error during encryption.
|
||||
|
||||
\parma out Final encrypted data
|
||||
\param in Data to be encrypted, must be padded to Des block size.
|
||||
\param sz Size of input buffer.
|
||||
\param key Pointer to the key to use for encryption.
|
||||
\param iv Initialization vector
|
||||
|
||||
_Example_
|
||||
\code
|
||||
byte key[] = { // initialize with 8 byte key };
|
||||
byte iv[] = { // initialize with 8 byte iv };
|
||||
|
||||
byte in[] = { // Initialize with plaintext };
|
||||
byte out[sizeof(in)];
|
||||
|
||||
if ( wc_Des3_CbcEncryptWithKey(&out, in, sizeof(in), key, iv) != 0)
|
||||
{
|
||||
// error encrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des3_CbcDecryptWithKey
|
||||
\sa wc_Des_CbcEncryptWithKey
|
||||
\sa wc_Des_CbcDecryptWithKey
|
||||
*/
|
||||
WOLFSSL_API int wc_Des3_CbcEncryptWithKey(byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* key, const byte* iv);
|
||||
/*!
|
||||
\ingroup 3DES
|
||||
|
||||
\brief This function decrypts the input ciphertext, in, and stores
|
||||
the resulting plaintext in the output buffer, out. It uses Triple
|
||||
Des (3DES) encryption with cipher block chaining (CBC) mode. This
|
||||
function is a substitute for wc_Des3_CbcDecrypt, allowing the user
|
||||
to decrypt a message without directly instantiating a Des3 structure.
|
||||
|
||||
\return 0 Returned upon successfully decrypting the given ciphertext
|
||||
\return MEMORY_E Returned if there is an error allocating space for
|
||||
a Des structure
|
||||
|
||||
\param out pointer to the buffer in which to store the decrypted plaintext
|
||||
\param in pointer to the input buffer containing the encrypted ciphertext
|
||||
\param sz length of the ciphertext to decrypt
|
||||
\param key pointer to the buffer containing the 24 byte key to use
|
||||
for decryption
|
||||
\param iv pointer to the buffer containing the 8 byte iv to use for
|
||||
decryption. If no iv is provided, the iv defaults to 0
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int ret;
|
||||
byte key[] = { // initialize with 24 byte key };
|
||||
byte iv[] = { // initialize with 8 byte iv };
|
||||
|
||||
byte cipher[] = { // initialize with ciphertext };
|
||||
byte decoded[sizeof(cipher)];
|
||||
|
||||
if ( wc_Des3_CbcDecryptWithKey(decoded, cipher, sizeof(cipher),
|
||||
key, iv) != 0) {
|
||||
// error decrypting message
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_Des3_CbcDecrypt
|
||||
*/
|
||||
WOLFSSL_API int wc_Des3_CbcDecryptWithKey(byte* out,
|
||||
const byte* in, word32 sz,
|
||||
const byte* key, const byte* iv);
|
21
doc/dox_comments/header_files/wc_port.h
Normal file
21
doc/dox_comments/header_files/wc_port.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*!
|
||||
\ingroup wolfCrypt
|
||||
|
||||
\brief Used to clean up resources used by wolfCrypt.
|
||||
|
||||
\return 0 upon success.
|
||||
\return <0 upon failure of cleaning up resources.
|
||||
|
||||
\param none No parameters.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
...
|
||||
if (wolfCrypt_Cleanup() != 0) {
|
||||
WOLFSSL_MSG("Error with wolfCrypt_Cleanup call");
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfCrypt_Init
|
||||
*/
|
||||
WOLFSSL_API int wolfCrypt_Cleanup(void);
|
526
doc/dox_comments/header_files/wolfio.h
Normal file
526
doc/dox_comments/header_files/wolfio.h
Normal file
@ -0,0 +1,526 @@
|
||||
/*!
|
||||
\brief This function is the receive embedded callback.
|
||||
|
||||
\return Success This function returns the number of bytes read.
|
||||
\return WOLFSSL_CBIO_ERR_WANT_READ returned with a “Would block” message
|
||||
if the last error was SOCKET_EWOULDBLCOK or SOCKET_EAGAIN.
|
||||
\return WOLFSSL_CBIO_ERR_TIMEOUT returned with a “Socket timeout” message.
|
||||
\return WOLFSSL_CBIO_ERR_CONN_RST returned with a “Connection reset”
|
||||
message if the last error was SOCKET_ECONNRESET.
|
||||
\return WOLFSSL_CBIO_ERR_ISR returned with a “Socket interrupted” message
|
||||
if the last error was SOCKET_EINTR.
|
||||
\return WOLFSSL_CBIO_ERR_WANT_READ returned with a “Connection refused”
|
||||
messag if the last error was SOCKET_ECONNREFUSED.
|
||||
\return WOLFSSL_CBIO_ERR_CONN_CLOSE returned with a “Connection aborted”
|
||||
message if the last error was SOCKET_ECONNABORTED.
|
||||
\return WOLFSSL_CBIO_ERR_GENERAL returned with a “General error” message
|
||||
if the last error was not specified.
|
||||
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
\param buf a char pointer representation of the buffer.
|
||||
\param sz the size of the buffer.
|
||||
\param ctx a void pointer to user registered context. In the default case
|
||||
the ctx is a socket descriptor pointer.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_CTX* ctx = wolfSSL_CTX_new( protocol method );
|
||||
WOLFSSL* ssl = wolfSSL_new(ctx);
|
||||
char* buf;
|
||||
int sz;
|
||||
void* ctx;
|
||||
int bytesRead = EmbedReceive(ssl, buf, sz, ctx);
|
||||
if(bytesRead <= 0){
|
||||
// There were no bytes read. Failure case.
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_dtls_get_current_timeout
|
||||
\sa TranslateReturnCode
|
||||
\sa RECV_FUNCTION
|
||||
*/
|
||||
WOLFSSL_API int EmbedReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
/*!
|
||||
\brief This function is the send embedded callback.
|
||||
|
||||
\return Success This function returns the number of bytes sent.
|
||||
\return WOLFSSL_CBIO_ERR_WANT_WRITE returned with a “Would block” message
|
||||
if the last error was SOCKET_EWOULDBLOCK or SOCKET_EAGAIN.
|
||||
\return WOLFSSL_CBIO_ERR_CONN_RST returned with a “Connection reset”
|
||||
message if the last error was SOCKET_ECONNRESET.
|
||||
\return WOLFSSL_CBIO_ERR_ISR returned with a “Socket interrupted” message
|
||||
if the last error was SOCKET_EINTR.
|
||||
\return WOLFSSL_CBIO_ERR_CONN_CLOSE returned with a “Socket EPIPE” message
|
||||
if the last error was SOCKET_EPIPE.
|
||||
\return WOLFSSL_CBIO_ERR_GENERAL returned with a “General error” message
|
||||
if the last error was not specified.
|
||||
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
\param buf a char pointer representing the buffer.
|
||||
\param sz the size of the buffer.
|
||||
\param ctx a void pointer to user registered context.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL* ssl = wolfSSL_new(ctx);
|
||||
char* buf;
|
||||
int sz;
|
||||
void* ctx;
|
||||
int dSent = EmbedSend(ssl, buf, sz, ctx);
|
||||
if(dSent <= 0){
|
||||
// No byes sent. Failure case.
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa TranslateReturnCode
|
||||
\sa SEND_FUNCTION
|
||||
\sa LastError
|
||||
\sa InitSSL_Ctx
|
||||
\sa LastError
|
||||
*/
|
||||
WOLFSSL_API int EmbedSend(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
/*!
|
||||
\brief This function is the receive embedded callback.
|
||||
|
||||
\return Success This function returns the nb bytes read if the execution
|
||||
was successful.
|
||||
\return WOLFSSL_CBIO_ERR_WANT_READ if the connection refused or if a
|
||||
‘would block’ error was thrown in the function.
|
||||
\return WOLFSSL_CBIO_ERR_TIMEOUT returned if the socket timed out.
|
||||
\return WOLFSSL_CBIO_ERR_CONN_RST returned if the connection reset.
|
||||
\return WOLFSSL_CBIO_ERR_ISR returned if the socket was interrupted.
|
||||
\return WOLFSSL_CBIO_ERR_GENERAL returned if there was a general error.
|
||||
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
\param buf a constant char pointer to the buffer.
|
||||
\param sz an int type representing the size of the buffer.
|
||||
\param ctx a void pointer to the WOLFSSL_CTX context.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_CTX* ctx = wolfSSL_CTX_new( protocol method );
|
||||
WOLFSSL* ssl = WOLFSSL_new(ctx);
|
||||
char* buf;
|
||||
int sz = sizeof(buf)/sizeof(char);
|
||||
(void*)ctx;
|
||||
…
|
||||
int nb = EmbedReceiveFrom(ssl, buf, sz, ctx);
|
||||
if(nb > 0){
|
||||
// nb is the number of bytes written and is positive
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa TranslateReturnCode
|
||||
\sa RECVFROM_FUNCTION
|
||||
\sa Setsockopt
|
||||
*/
|
||||
WOLFSSL_API int EmbedReceiveFrom(WOLFSSL* ssl, char* buf, int sz, void*);
|
||||
/*!
|
||||
\brief This function is the send embedded callback.
|
||||
|
||||
\return Success This function returns the number of bytes sent.
|
||||
\return WOLFSSL_CBIO_ERR_WANT_WRITE returned with a “Would Block” message
|
||||
if the last error was either SOCKET_EWOULDBLOCK or SOCKET_EAGAIN error.
|
||||
\return WOLFSSL_CBIO_ERR_CONN_RST returned with a “Connection reset”
|
||||
message if the last error was SOCKET_ECONNRESET.
|
||||
\return WOLFSSL_CBIO_ERR_ISR returned with a “Socket interrupted” message
|
||||
if the last error was SOCKET_EINTR.
|
||||
\return WOLFSSL_CBIO_ERR_CONN_CLOSE returned with a “Socket EPIPE” message
|
||||
if the last error was WOLFSSL_CBIO_ERR_CONN_CLOSE.
|
||||
\return WOLFSSL_CBIO_ERR_GENERAL returned with a “General error” message
|
||||
if the last error was not specified.
|
||||
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
\param buf a char pointer representing the buffer.
|
||||
\param sz the size of the buffer.
|
||||
\param ctx a void pointer to the user registered context. The default case
|
||||
is a WOLFSSL_DTLS_CTX sructure.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL* ssl;
|
||||
…
|
||||
char* buf;
|
||||
int sz;
|
||||
void* ctx;
|
||||
|
||||
int sEmbed = EmbedSendto(ssl, buf, sz, ctx);
|
||||
if(sEmbed <= 0){
|
||||
// No bytes sent. Failure case.
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa LastError
|
||||
\sa EmbedSend
|
||||
\sa EmbedReceive
|
||||
*/
|
||||
WOLFSSL_API int EmbedSendTo(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
/*!
|
||||
\brief This function is the DTLS Generate Cookie callback.
|
||||
|
||||
\return Success This function returns the number of bytes copied
|
||||
into the buffer.
|
||||
\return GEN_COOKIE_E returned if the getpeername failed in
|
||||
EmbedGenerateCookie.
|
||||
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
\param buf byte pointer representing the buffer. It is the destination
|
||||
from XMEMCPY().
|
||||
\param sz the size of the buffer.
|
||||
\param ctx a void pointer to user registered context.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_CTX* ctx = wolfSSL_CTX_new( method );
|
||||
WOLFSSL* ssl = wolfSSL_new(ctx);
|
||||
byte buffer[BUFFER_SIZE];
|
||||
int sz = sizeof(buffer)/sizeof(byte);
|
||||
void* ctx;
|
||||
…
|
||||
int ret = EmbedGenerateCookie(ssl, buffer, sz, ctx);
|
||||
|
||||
if(ret > 0){
|
||||
// EmbedGenerateCookie code block for success
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wc_ShaHash
|
||||
\sa EmbedGenerateCookie
|
||||
\sa XMEMCPY
|
||||
\sa XMEMSET
|
||||
*/
|
||||
WOLFSSL_API int EmbedGenerateCookie(WOLFSSL* ssl, unsigned char* buf,
|
||||
int sz, void*);
|
||||
/*!
|
||||
\brief This function frees the response buffer.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param ctx a void pointer to heap hint.
|
||||
\param resp a byte pointer representing the response.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
void* ctx;
|
||||
byte* resp; // Response buffer.
|
||||
…
|
||||
EmbedOcspRespFree(ctx, resp);
|
||||
\endcode
|
||||
|
||||
\sa XFREE
|
||||
*/
|
||||
WOLFSSL_API void EmbedOcspRespFree(void*, unsigned char*);
|
||||
/*!
|
||||
\brief This function registers a receive callback for wolfSSL to get input
|
||||
data. By default, wolfSSL uses EmbedReceive() as the callback which uses
|
||||
the system’s TCP recv() function. The user can register a function to get
|
||||
input from memory, some other network module, or from anywhere. Please see
|
||||
the EmbedReceive() function in src/io.c as a guide for how the function
|
||||
should work and for error codes. In particular, IO_ERR_WANT_READ should
|
||||
be returned for non blocking receive when no data is ready.
|
||||
|
||||
\return none no Returns.
|
||||
|
||||
\param ctx pointer to the SSL context, created with wolfSSL_CTX_new().
|
||||
\param callback function to be registered as the receive callback for the
|
||||
wolfSSL context, ctx. The signature of this function must follow that as
|
||||
shown above in the Synopsis section.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_CTX* ctx = 0;
|
||||
// Receive callback prototype
|
||||
int MyEmbedReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
// Register the custom receive callback with wolfSSL
|
||||
wolfSSL_SetIORecv(ctx, MyEmbedReceive);
|
||||
int MyEmbedReceive(WOLFSSL* ssl, char* buf, int sz, void* ctx)
|
||||
{
|
||||
// custom EmbedReceive function
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_SetIOSend
|
||||
\sa wolfSSL_SetIOReadCtx
|
||||
\sa wolfSSL_SetIOWriteCtx
|
||||
*/
|
||||
WOLFSSL_API void wolfSSL_SetIORecv(WOLFSSL_CTX*, CallbackIORecv);
|
||||
/*!
|
||||
\brief This function registers a context for the SSL session’s receive
|
||||
callback function. By default, wolfSSL sets the file descriptor passed to
|
||||
wolfSSL_set_fd() as the context when wolfSSL is using the system’s TCP
|
||||
library. If you’ve registered your own receive callback you may want to set
|
||||
a specific context for the session. For example, if you’re using memory
|
||||
buffers the context may be a pointer to a structure describing where and
|
||||
how to access the memory buffers.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param ssl pointer to the SSL session, created with wolfSSL_new().
|
||||
\param rctx pointer to the context to be registered with the SSL session’s
|
||||
(ssl) receive callback function.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int sockfd;
|
||||
WOLFSSL* ssl = 0;
|
||||
...
|
||||
// Manually setting the socket fd as the receive CTX, for example
|
||||
wolfSSL_SetIOReadCtx(ssl, &sockfd);
|
||||
...
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_SetIORecv
|
||||
\sa wolfSSL_SetIOSend
|
||||
\sa wolfSSL_SetIOWriteCtx
|
||||
*/
|
||||
WOLFSSL_API void wolfSSL_SetIOReadCtx( WOLFSSL* ssl, void *ctx);
|
||||
/*!
|
||||
\brief This function registers a context for the SSL session’s send
|
||||
callback function. By default, wolfSSL sets the file descriptor passed to
|
||||
wolfSSL_set_fd() as the context when wolfSSL is using the system’s TCP
|
||||
library. If you’ve registered your own send callback you may want to set a
|
||||
specific context for the session. For example, if you’re using memory
|
||||
buffers the context may be a pointer to a structure describing where and
|
||||
how to access the memory buffers.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param ssl pointer to the SSL session, created with wolfSSL_new().
|
||||
\param wctx pointer to the context to be registered with the SSL session’s
|
||||
(ssl) send callback function.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
int sockfd;
|
||||
WOLFSSL* ssl = 0;
|
||||
...
|
||||
// Manually setting the socket fd as the send CTX, for example
|
||||
wolfSSL_SetIOSendCtx(ssl, &sockfd);
|
||||
...
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_SetIORecv
|
||||
\sa wolfSSL_SetIOSend
|
||||
\sa wolfSSL_SetIOReadCtx
|
||||
*/
|
||||
WOLFSSL_API void wolfSSL_SetIOWriteCtx(WOLFSSL* ssl, void *ctx);
|
||||
/*!
|
||||
\ingroup IO
|
||||
|
||||
\brief This function returns the IOCB_ReadCtx member of the WOLFSSL struct.
|
||||
|
||||
\return pointer This function returns a void pointer to the IOCB_ReadCtx
|
||||
member of the WOLFSSL structure.
|
||||
\return NULL returned if the WOLFSSL struct is NULL.
|
||||
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL* ssl = wolfSSL_new(ctx);
|
||||
void* ioRead;
|
||||
...
|
||||
ioRead = wolfSSL_GetIOReadCtx(ssl);
|
||||
if(ioRead == NULL){
|
||||
// Failure case. The ssl object was NULL.
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_GetIOWriteCtx
|
||||
\sa wolfSSL_SetIOReadFlags
|
||||
\sa wolfSSL_SetIOWriteCtx
|
||||
\sa wolfSSL_SetIOReadCtx
|
||||
\sa wolfSSL_SetIOSend
|
||||
*/
|
||||
WOLFSSL_API void* wolfSSL_GetIOReadCtx( WOLFSSL* ssl);
|
||||
/*!
|
||||
\ingroup IO
|
||||
|
||||
\brief This function returns the IOCB_WriteCtx member of the WOLFSSL structure.
|
||||
|
||||
\return pointer This function returns a void pointer to the IOCB_WriteCtx
|
||||
member of the WOLFSSL structure.
|
||||
\return NULL returned if the WOLFSSL struct is NULL.
|
||||
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL* ssl;
|
||||
void* ioWrite;
|
||||
...
|
||||
ioWrite = wolfSSL_GetIOWriteCtx(ssl);
|
||||
if(ioWrite == NULL){
|
||||
// The funciton returned NULL.
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_GetIOReadCtx
|
||||
\sa wolfSSL_SetIOWriteCtx
|
||||
\sa wolfSSL_SetIOReadCtx
|
||||
\sa wolfSSL_SetIOSend
|
||||
*/
|
||||
WOLFSSL_API void* wolfSSL_GetIOWriteCtx(WOLFSSL* ssl);
|
||||
/*!
|
||||
\brief This function sets the flags for the receive callback to use for
|
||||
the given SSL session. The receive callback could be either the default
|
||||
wolfSSL EmbedReceive callback, or a custom callback specified by the user
|
||||
(see wolfSSL_SetIORecv). The default flag value is set internally by
|
||||
wolfSSL to the value of 0. The default wolfSSL receive callback uses the
|
||||
recv() function to receive data from the socket. From the recv() man page:
|
||||
“The flags argument to a recv() function is formed by or'ing one or more
|
||||
of the values: MSG_OOB process out-of-band data, MSG_PEEK peek at incoming
|
||||
message, MSG_WAITALL wait for full request or error. The MSG_OOB flag
|
||||
requests receipt of out-of-band data that would not be received in the
|
||||
normal data stream. Some protocols place expedited data at the head of
|
||||
the normal data queue, and thus this flag cannot be used with such
|
||||
protocols. The MSG_PEEK flag causes the receive operation to return
|
||||
data from the beginning of the receive queue without removing that data
|
||||
from the queue. Thus, a subsequent receive call will return the same data.
|
||||
The MSG_WAITALL flag requests that the operation block until the full
|
||||
request is satisfied. However, the call may still return less data than
|
||||
requested if a signal is caught, an error or disconnect occurs, or the next
|
||||
data to be received is of a different type than that returned.”
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param ssl pointer to the SSL session, created with wolfSSL_new().
|
||||
\param flags value of the I/O read flags for the specified SSL
|
||||
session (ssl).
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL* ssl = 0;
|
||||
...
|
||||
// Manually setting recv flags to 0
|
||||
wolfSSL_SetIOReadFlags(ssl, 0);
|
||||
...
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_SetIORecv
|
||||
\sa wolfSSL_SetIOSend
|
||||
\sa wolfSSL_SetIOReadCtx
|
||||
*/
|
||||
WOLFSSL_API void wolfSSL_SetIOReadFlags( WOLFSSL* ssl, int flags);
|
||||
/*!
|
||||
\brief This function sets the flags for the send callback to use for the
|
||||
given SSL session. The send callback could be either the default wolfSSL
|
||||
EmbedSend callback, or a custom callback specified by the user (see
|
||||
wolfSSL_SetIOSend). The default flag value is set internally by wolfSSL
|
||||
to the value of 0. The default wolfSSL send callback uses the send()
|
||||
function to send data from the socket. From the send() man page: “The
|
||||
flags parameter may include one or more of the following:
|
||||
#define MSG_OOB 0x1 // process out-of-band data,
|
||||
#define MSG_DONTROUTE 0x4 // bypass routing, use direct interface.
|
||||
The flag MSG_OOB is used to send ``out-of-band'' data on sockets that
|
||||
support this notion (e.g. SOCK_STREAM); the underlying protocol must also
|
||||
support ``out-of-band'' data. MSG_DONTROUTE is usually used only by
|
||||
diagnostic or routing programs.”
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param ssl pointer to the SSL session, created with wolfSSL_new().
|
||||
\param flags value of the I/O send flags for the specified SSL session (ssl).
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL* ssl = 0;
|
||||
...
|
||||
// Manually setting send flags to 0
|
||||
wolfSSL_SetIOSendFlags(ssl, 0);
|
||||
...
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_SetIORecv
|
||||
\sa wolfSSL_SetIOSend
|
||||
\sa wolfSSL_SetIOReadCtx
|
||||
*/
|
||||
WOLFSSL_API void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags);
|
||||
/*!
|
||||
\ingroup IO
|
||||
|
||||
\brief This function sets the nxSocket and nxWait members of the nxCtx
|
||||
struct within the WOLFSSL structure.
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
\param nxSocket a pointer to type NX_TCP_SOCKET that is set to the
|
||||
nxSocket member of the nxCTX structure.
|
||||
\param waitOption a ULONG type that is set to the nxWait member of
|
||||
the nxCtx structure.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL* ssl = wolfSSL_new(ctx);
|
||||
NX_TCP_SOCKET* nxSocket;
|
||||
ULONG waitOption;
|
||||
…
|
||||
if(ssl != NULL || nxSocket != NULL || waitOption <= 0){
|
||||
wolfSSL_SetIO_NetX(ssl, nxSocket, waitOption);
|
||||
} else {
|
||||
// You need to pass in good parameters.
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa set_fd
|
||||
\sa NetX_Send
|
||||
\sa NetX_Receive
|
||||
*/
|
||||
WOLFSSL_API void wolfSSL_SetIO_NetX(WOLFSSL* ssl, NX_TCP_SOCKET* nxsocket,
|
||||
ULONG waitoption);
|
||||
/*!
|
||||
\brief This function sets the callback for the CBIOCookie member of the
|
||||
WOLFSSL_CTX structure. The CallbackGenCookie type is a function pointer
|
||||
and has the signature: int (*CallbackGenCookie)(WOLFSSL* ssl, unsigned
|
||||
char* buf, int sz, void* ctx);
|
||||
|
||||
\return none No returns.
|
||||
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
\param cb a CallbackGenCookie type function pointer with the signature
|
||||
of CallbackGenCookie.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_CTX* ctx = wolfSSL_CTX_new( method );
|
||||
WOLFSSL* ssl = wolfSSL_new(ctx);
|
||||
…
|
||||
int SetGenCookieCB(WOLFSSL* ssl, unsigned char* buf, int sz, void* ctx){
|
||||
// Callback function body.
|
||||
}
|
||||
…
|
||||
wolfSSL_CTX_SetGenCookie(ssl->ctx, SetGenCookieCB);
|
||||
\endcode
|
||||
|
||||
\sa CallbackGenCookie
|
||||
*/
|
||||
WOLFSSL_API void wolfSSL_CTX_SetGenCookie(WOLFSSL_CTX*, CallbackGenCookie);
|
||||
/*!
|
||||
\ingroup Setup
|
||||
|
||||
\brief This function returns the IOCB_CookieCtx member of the
|
||||
WOLFSSL structure.
|
||||
|
||||
\return pointer The function returns a void pointer value stored in
|
||||
the IOCB_CookieCtx.
|
||||
\return NULL if the WOLFSSL struct is NULL
|
||||
|
||||
\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
|
||||
|
||||
_Example_
|
||||
\code
|
||||
WOLFSSL_CTX* ctx = wolfSSL_CTX_new( method );
|
||||
WOLFSSL* ssl = wolfSSL_new(ctx);
|
||||
void* cookie;
|
||||
...
|
||||
cookie = wolfSSL_GetCookieCtx(ssl);
|
||||
if(cookie != NULL){
|
||||
// You have the cookie
|
||||
}
|
||||
\endcode
|
||||
|
||||
\sa wolfSSL_SetCookieCtx
|
||||
\sa wolfSSL_CTX_SetGenCookie
|
||||
*/
|
||||
WOLFSSL_API void* wolfSSL_GetCookieCtx(WOLFSSL* ssl);
|
2471
doc/formats/html/Doxyfile
Normal file
2471
doc/formats/html/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
57
doc/formats/html/footer.html
Normal file
57
doc/formats/html/footer.html
Normal file
@ -0,0 +1,57 @@
|
||||
<!-- HTML footer for doxygen 1.8.13-->
|
||||
<!-- start footer part -->
|
||||
<!--BEGIN GENERATE_TREEVIEW-->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
$navpath
|
||||
<li class="footer">$generatedby
|
||||
<a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="$relpath^doxygen.png" alt="doxygen"/></a> $doxygenversion </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="lowNav">
|
||||
<p class="footText">Product Information</p>
|
||||
<ul class="lowNavList">
|
||||
<a href="https://www.wolfssl.com/products/wolfssl/"><li>wolfSSL TLS Library</li></a>
|
||||
<a href="https://www.wolfssl.com/products/wolfcrypt/"><li>wolfCrypt Crypto Engine</li></a>
|
||||
<a href="https://www.wolfssl.com/products/wolfmqtt/"><li>wolfMQTT Client Library</li></a>
|
||||
<a href="https://www.wolfssl.com/products/wolfssh/"><li>wolfSSH SSH Library</li></a>
|
||||
<a href="https://www.wolfssl.com/license/"><li>License Information</li></a>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="lowNav">
|
||||
<p class="footText">Documentation</p>
|
||||
<ul class="lowNavList">
|
||||
<a href="https://www.wolfssl.com/docs/wolfssl-manual/"><li>wolfSSL Manual</li></a>
|
||||
<a href="https://www.wolfssl.com/docs/wolfssl-manual/ch17/"><li>wolfSSL API Reference</li></a>
|
||||
<a href="https://www.wolfssl.com/docs/wolfssl-manual/ch2/"><li>Building wolfSSL</li></a>
|
||||
<a href="https://www.wolfssl.com/docs/wolfssl-manual/ch11/"><li>SSL Tutorial</li></a>
|
||||
<a href="https://www.wolfssl.com/docs/"><li>Additional Documentation</li></a>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="lowCenter">
|
||||
<p class="footText" id="center">Copyright © 2017 wolfSSL Inc.<br>All rights reserved.</p>
|
||||
<div class="lowNav">
|
||||
<p class="footText">Help and Support</p>
|
||||
<ul class="lowNavList">
|
||||
<a href="https://www.wolfssl.com/forums/"><li>Support Forum</li></a>
|
||||
<a href="https://www.wolfssl.com/download/support-packages/"><li>Support Packages</li></a>
|
||||
<a href="https://www.wolfssl.com/docs/consulting/"><li>Consulting Services</li></a>
|
||||
<a href="https://www.wolfssl.com/docs/security-vulnerabilities/"><li>Vulnerability Info</li></a>
|
||||
<a href="https://www.wolfssl.com/contact/"><li>Contact Us</li></a>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="lowNav" id="lastLowNav">
|
||||
<p class="footText">Reference</p>
|
||||
<ul class="lowNavList">
|
||||
<a href="https://www.wolfssl.com/docs/wolfssl-manual/appendix-b/"><li>Algorithm/Protocol Reference</li></a>
|
||||
<a href="https://www.wolfssl.com/docs/media/"><li>Presentations</li></a>
|
||||
<a href="https://www.wolfssl.com/directory/"><li>Site Directory</li></a>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
55
doc/formats/html/header.html
Normal file
55
doc/formats/html/header.html
Normal file
@ -0,0 +1,55 @@
|
||||
<!-- HTML header for doxygen 1.8.11-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen $doxygenversion"/>
|
||||
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
|
||||
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="$relpath^jquery.js"></script>
|
||||
<script type="text/javascript" src="$relpath^dynsections.js"></script>
|
||||
$treeview
|
||||
$search
|
||||
$mathjax
|
||||
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
||||
$extrastylesheet
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="wolfssl_logo" style="width: 150px; height: 100px; display: inline-block;"><img alt="Logo" src="../images/wolfssl_logo.png" style="width: 150px; height: 100px;"/></div>
|
||||
<!--BEGIN TITLEAREA-->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<!--BEGIN PROJECT_LOGO-->
|
||||
<td id="wolfssl_logo"><img alt="Logo" src="../images/wolfssl_logo.png"/></td>
|
||||
<!--END PROJECT_LOGO-->
|
||||
<!--BEGIN PROJECT_NAME-->
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">$projectname
|
||||
<!--BEGIN PROJECT_NUMBER--> <span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER-->
|
||||
</div>
|
||||
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
|
||||
</td>
|
||||
<!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME-->
|
||||
<!--BEGIN PROJECT_BRIEF-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectbrief">$projectbrief</div>
|
||||
</td>
|
||||
<!--END PROJECT_BRIEF-->
|
||||
<!--END !PROJECT_NAME-->
|
||||
<!--BEGIN DISABLE_INDEX-->
|
||||
<!--BEGIN SEARCHENGINE-->
|
||||
<td>$searchbox</td>
|
||||
<!--END SEARCHENGINE-->
|
||||
<!--END DISABLE_INDEX-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--END TITLEAREA-->
|
||||
<!-- end header part -->
|
1756
doc/formats/html/html_changes/customdoxygen.css
Normal file
1756
doc/formats/html/html_changes/customdoxygen.css
Normal file
File diff suppressed because it is too large
Load Diff
1596
doc/formats/html/html_changes/doxygen.css
Normal file
1596
doc/formats/html/html_changes/doxygen.css
Normal file
File diff suppressed because it is too large
Load Diff
33
doc/formats/html/html_changes/menu.js
Normal file
33
doc/formats/html/html_changes/menu.js
Normal file
@ -0,0 +1,33 @@
|
||||
function initMenu(relPath,searchEnabled,serverSide,searchPage,search) {
|
||||
function makeTree(data,relPath) {
|
||||
var result='';
|
||||
if ('children' in data) {
|
||||
result+='<ul>';
|
||||
if (searchEnabled) {
|
||||
if (serverSide) {
|
||||
result+='<li id="wolfssl_search"><div id="MSearchBox" class="MSearchBoxInactive"><div class="left"><form id="FSearchBox" action="'+searchPage+'" method="get"><img id="MSearchSelect" src="'+relPath+'search/mag.png" alt=""/><input type="text" id="MSearchField" name="query" value="'+search+'" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)"></form></div><div class="right"></div></div></li>';
|
||||
} else {
|
||||
result+='<li id="wolfssl_search"><div id="MSearchBox" class="MSearchBoxInactive"><span class="left"><img id="MSearchSelect" src="'+relPath+'search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/><input type="text" id="MSearchField" value="'+search+'" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/></span><span class="right"><a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="'+relPath+'search/close.png" alt=""/></a></span></div></li>';
|
||||
}
|
||||
}
|
||||
for (var i in data.children) {
|
||||
if (relPath+data.children[i].style) {
|
||||
result+='<li style="'+relPath+data.children[i].style+'"><a href="'+relPath+data.children[i].url+'">'+
|
||||
data.children[i].text+'</a>'+
|
||||
makeTree(data.children[i],relPath)+'</li>';
|
||||
} else {
|
||||
result+='<li><a href="'+relPath+data.children[i].url+'">'+
|
||||
data.children[i].text+'</a>'+
|
||||
makeTree(data.children[i],relPath)+'</li>';
|
||||
}
|
||||
}
|
||||
result+='</ul>';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
$('#main-nav').append(makeTree(menudata,relPath));
|
||||
$('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu');
|
||||
|
||||
$('#main-menu').smartmenus();
|
||||
}
|
7
doc/formats/html/html_changes/menudata.js
Normal file
7
doc/formats/html/html_changes/menudata.js
Normal file
@ -0,0 +1,7 @@
|
||||
var menudata={children:[
|
||||
{text:"wolfSSL Home",url:"https://www.wolfssl.com/",style:"clear:right;"},
|
||||
{text:"Doc Home",url:"index.html"},
|
||||
{text:"Related Pages",url:"pages.html"},
|
||||
{text:"Modules",url:"modules.html"},
|
||||
{text:"Data Structures",url:"annotated.html"},
|
||||
{text:"Files",url:"files.html"}]}
|
277
doc/formats/html/html_changes/search/search.css
Normal file
277
doc/formats/html/html_changes/search/search.css
Normal file
@ -0,0 +1,277 @@
|
||||
/*---------------- Search Box */
|
||||
#FSearchBox {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#MSearchBox {
|
||||
white-space : nowrap;
|
||||
float: left;
|
||||
margin-top: 8px;
|
||||
right: 0px;
|
||||
width: 170px;
|
||||
height: 24px;
|
||||
z-index: 102;
|
||||
}
|
||||
|
||||
#MSearchBox .left
|
||||
{
|
||||
display:block;
|
||||
position:absolute;
|
||||
left:10px;
|
||||
width:20px;
|
||||
height:19px;
|
||||
background:url('search_l.png') no-repeat;
|
||||
background-position:right;
|
||||
}
|
||||
|
||||
#MSearchSelect {
|
||||
display:block;
|
||||
position:absolute;
|
||||
width:20px;
|
||||
height:19px;
|
||||
}
|
||||
|
||||
.left #MSearchSelect {
|
||||
left:4px;
|
||||
}
|
||||
|
||||
.right #MSearchSelect {
|
||||
right:5px;
|
||||
}
|
||||
|
||||
#MSearchField {
|
||||
display:block;
|
||||
position:absolute;
|
||||
height:19px;
|
||||
background:url('search_m.png') repeat-x;
|
||||
border:none;
|
||||
width:115px;
|
||||
margin-left:20px;
|
||||
padding-left:4px;
|
||||
color: #909090;
|
||||
outline: none;
|
||||
font: 9pt Arial, Verdana, sans-serif;
|
||||
-webkit-border-radius: 0px;
|
||||
}
|
||||
|
||||
#FSearchBox #MSearchField {
|
||||
margin-left:15px;
|
||||
}
|
||||
|
||||
#MSearchBox .right {
|
||||
display:block;
|
||||
position:absolute;
|
||||
right:10px;
|
||||
top:8px;
|
||||
width:20px;
|
||||
height:19px;
|
||||
background:url('search_r.png') no-repeat;
|
||||
background-position:left;
|
||||
}
|
||||
|
||||
#MSearchClose {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
background : none;
|
||||
border: none;
|
||||
margin: 0px 4px 0px 0px;
|
||||
padding: 0px 0px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.left #MSearchClose {
|
||||
left: 6px;
|
||||
}
|
||||
|
||||
.right #MSearchClose {
|
||||
right: 2px;
|
||||
}
|
||||
|
||||
.MSearchBoxActive #MSearchField {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
/*---------------- Search filter selection */
|
||||
|
||||
#MSearchSelectWindow {
|
||||
display: none;
|
||||
position: absolute;
|
||||
left: 0; top: 0;
|
||||
border: 1px solid #90A5CE;
|
||||
background-color: #F9FAFC;
|
||||
z-index: 10001;
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-top-left-radius: 4px;
|
||||
-webkit-border-top-right-radius: 4px;
|
||||
-webkit-border-bottom-left-radius: 4px;
|
||||
-webkit-border-bottom-right-radius: 4px;
|
||||
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.SelectItem {
|
||||
font: 8pt Arial, Verdana, sans-serif;
|
||||
padding-left: 2px;
|
||||
padding-right: 12px;
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
span.SelectionMark {
|
||||
margin-right: 4px;
|
||||
font-family: monospace;
|
||||
outline-style: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.SelectItem {
|
||||
display: block;
|
||||
outline-style: none;
|
||||
color: #000000;
|
||||
text-decoration: none;
|
||||
padding-left: 6px;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
a.SelectItem:focus,
|
||||
a.SelectItem:active {
|
||||
color: #000000;
|
||||
outline-style: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.SelectItem:hover {
|
||||
color: #FFFFFF;
|
||||
background-color: #3D578C;
|
||||
outline-style: none;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*---------------- Search results window */
|
||||
|
||||
iframe#MSearchResults {
|
||||
width: 60ex;
|
||||
height: 15em;
|
||||
}
|
||||
|
||||
#MSearchResultsWindow {
|
||||
display: none;
|
||||
position: absolute;
|
||||
left: 0; top: 0;
|
||||
border: 1px solid #000;
|
||||
background-color: #EEF1F7;
|
||||
z-index:10000;
|
||||
}
|
||||
|
||||
/* ----------------------------------- */
|
||||
|
||||
|
||||
#SRIndex {
|
||||
clear:both;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
.SREntry {
|
||||
font-size: 10pt;
|
||||
padding-left: 1ex;
|
||||
}
|
||||
|
||||
.SRPage .SREntry {
|
||||
font-size: 8pt;
|
||||
padding: 1px 5px;
|
||||
}
|
||||
|
||||
body.SRPage {
|
||||
margin: 5px 2px;
|
||||
}
|
||||
|
||||
.SRChildren {
|
||||
padding-left: 3ex; padding-bottom: .5em
|
||||
}
|
||||
|
||||
.SRPage .SRChildren {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.SRSymbol {
|
||||
font-weight: bold;
|
||||
color: #425E97;
|
||||
font-family: Arial, Verdana, sans-serif;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
a.SRScope {
|
||||
display: block;
|
||||
color: #425E97;
|
||||
font-family: Arial, Verdana, sans-serif;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
a.SRSymbol:focus, a.SRSymbol:active,
|
||||
a.SRScope:focus, a.SRScope:active {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
span.SRScope {
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.SRPage .SRStatus {
|
||||
padding: 2px 5px;
|
||||
font-size: 8pt;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.SRResult {
|
||||
display: none;
|
||||
}
|
||||
|
||||
DIV.searchresults {
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/*---------------- External search page results */
|
||||
|
||||
.searchresult {
|
||||
background-color: #F0F3F8;
|
||||
}
|
||||
|
||||
.pages b {
|
||||
color: white;
|
||||
padding: 5px 5px 3px 5px;
|
||||
background-image: url("../tab_a.png");
|
||||
background-repeat: repeat-x;
|
||||
text-shadow: 0 1px 1px #000000;
|
||||
}
|
||||
|
||||
.pages {
|
||||
line-height: 17px;
|
||||
margin-left: 4px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.hl {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#searchresults {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.searchpages {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
@media (max-width: 874px) {
|
||||
#MSearchBox {
|
||||
float: right;
|
||||
position: sticky;
|
||||
}
|
||||
}
|
||||
|
791
doc/formats/html/html_changes/search/search.js
Normal file
791
doc/formats/html/html_changes/search/search.js
Normal file
@ -0,0 +1,791 @@
|
||||
function convertToId(search)
|
||||
{
|
||||
var result = '';
|
||||
for (i=0;i<search.length;i++)
|
||||
{
|
||||
var c = search.charAt(i);
|
||||
var cn = c.charCodeAt(0);
|
||||
if (c.match(/[a-z0-9\u0080-\uFFFF]/))
|
||||
{
|
||||
result+=c;
|
||||
}
|
||||
else if (cn<16)
|
||||
{
|
||||
result+="_0"+cn.toString(16);
|
||||
}
|
||||
else
|
||||
{
|
||||
result+="_"+cn.toString(16);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function getXPos(item)
|
||||
{
|
||||
var x = 0;
|
||||
if (item.offsetWidth)
|
||||
{
|
||||
while (item && item!=document.body)
|
||||
{
|
||||
x += item.offsetLeft;
|
||||
item = item.offsetParent;
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
function getYPos(item)
|
||||
{
|
||||
var y = 0;
|
||||
if (item.offsetWidth)
|
||||
{
|
||||
while (item && item!=document.body)
|
||||
{
|
||||
y += item.offsetTop;
|
||||
item = item.offsetParent;
|
||||
}
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
/* A class handling everything associated with the search panel.
|
||||
|
||||
Parameters:
|
||||
name - The name of the global variable that will be
|
||||
storing this instance. Is needed to be able to set timeouts.
|
||||
resultPath - path to use for external files
|
||||
*/
|
||||
function SearchBox(name, resultsPath, inFrame, label)
|
||||
{
|
||||
if (!name || !resultsPath) { alert("Missing parameters to SearchBox."); }
|
||||
|
||||
// ---------- Instance variables
|
||||
this.name = name;
|
||||
this.resultsPath = resultsPath;
|
||||
this.keyTimeout = 0;
|
||||
this.keyTimeoutLength = 500;
|
||||
this.closeSelectionTimeout = 300;
|
||||
this.lastSearchValue = "";
|
||||
this.lastResultsPage = "";
|
||||
this.hideTimeout = 0;
|
||||
this.searchIndex = 0;
|
||||
this.searchActive = false;
|
||||
this.insideFrame = inFrame;
|
||||
this.searchLabel = label;
|
||||
|
||||
// ----------- DOM Elements
|
||||
|
||||
this.DOMSearchField = function()
|
||||
{ return document.getElementById("MSearchField"); }
|
||||
|
||||
this.DOMSearchSelect = function()
|
||||
{ return document.getElementById("MSearchSelect"); }
|
||||
|
||||
this.DOMSearchSelectWindow = function()
|
||||
{ return document.getElementById("MSearchSelectWindow"); }
|
||||
|
||||
this.DOMPopupSearchResults = function()
|
||||
{ return document.getElementById("MSearchResults"); }
|
||||
|
||||
this.DOMPopupSearchResultsWindow = function()
|
||||
{ return document.getElementById("MSearchResultsWindow"); }
|
||||
|
||||
this.DOMSearchClose = function()
|
||||
{ return document.getElementById("MSearchClose"); }
|
||||
|
||||
this.DOMSearchBox = function()
|
||||
{ return document.getElementById("MSearchBox"); }
|
||||
|
||||
// ------------ Event Handlers
|
||||
|
||||
// Called when focus is added or removed from the search field.
|
||||
this.OnSearchFieldFocus = function(isActive)
|
||||
{
|
||||
this.Activate(isActive);
|
||||
}
|
||||
|
||||
this.OnSearchSelectShow = function()
|
||||
{
|
||||
var searchSelectWindow = this.DOMSearchSelectWindow();
|
||||
var searchField = this.DOMSearchSelect();
|
||||
|
||||
if (this.insideFrame)
|
||||
{
|
||||
var left = getXPos(searchField);
|
||||
var top = getYPos(searchField);
|
||||
left += searchField.offsetWidth + 6;
|
||||
top += searchField.offsetHeight;
|
||||
|
||||
// show search selection popup
|
||||
searchSelectWindow.style.display='block';
|
||||
left -= searchSelectWindow.offsetWidth;
|
||||
searchSelectWindow.style.left = left + 'px';
|
||||
searchSelectWindow.style.top = top + 'px';
|
||||
}
|
||||
else
|
||||
{
|
||||
var left = getXPos(searchField);
|
||||
var top = getYPos(searchField);
|
||||
top += searchField.offsetHeight;
|
||||
|
||||
// show search selection popup
|
||||
searchSelectWindow.style.display='block';
|
||||
searchSelectWindow.style.left = left + 'px';
|
||||
searchSelectWindow.style.top = top + 'px';
|
||||
}
|
||||
|
||||
// stop selection hide timer
|
||||
if (this.hideTimeout)
|
||||
{
|
||||
clearTimeout(this.hideTimeout);
|
||||
this.hideTimeout=0;
|
||||
}
|
||||
return false; // to avoid "image drag" default event
|
||||
}
|
||||
|
||||
this.OnSearchSelectHide = function()
|
||||
{
|
||||
this.hideTimeout = setTimeout(this.name +".CloseSelectionWindow()",
|
||||
this.closeSelectionTimeout);
|
||||
}
|
||||
|
||||
// Called when the content of the search field is changed.
|
||||
this.OnSearchFieldChange = function(evt)
|
||||
{
|
||||
if (this.keyTimeout) // kill running timer
|
||||
{
|
||||
clearTimeout(this.keyTimeout);
|
||||
this.keyTimeout = 0;
|
||||
}
|
||||
|
||||
var e = (evt) ? evt : window.event; // for IE
|
||||
if (e.keyCode==40 || e.keyCode==13)
|
||||
{
|
||||
if (e.shiftKey==1)
|
||||
{
|
||||
this.OnSearchSelectShow();
|
||||
var win=this.DOMSearchSelectWindow();
|
||||
for (i=0;i<win.childNodes.length;i++)
|
||||
{
|
||||
var child = win.childNodes[i]; // get span within a
|
||||
if (child.className=='SelectItem')
|
||||
{
|
||||
child.focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (window.frames.MSearchResults.searchResults)
|
||||
{
|
||||
var elem = window.frames.MSearchResults.searchResults.NavNext(0);
|
||||
if (elem) elem.focus();
|
||||
}
|
||||
}
|
||||
else if (e.keyCode==27) // Escape out of the search field
|
||||
{
|
||||
this.DOMSearchField().blur();
|
||||
this.DOMPopupSearchResultsWindow().style.display = 'none';
|
||||
this.DOMSearchClose().style.display = 'none';
|
||||
this.lastSearchValue = '';
|
||||
this.Activate(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// strip whitespaces
|
||||
var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
|
||||
|
||||
if (searchValue != this.lastSearchValue) // search value has changed
|
||||
{
|
||||
if (searchValue != "") // non-empty search
|
||||
{
|
||||
// set timer for search update
|
||||
this.keyTimeout = setTimeout(this.name + '.Search()',
|
||||
this.keyTimeoutLength);
|
||||
}
|
||||
else // empty search field
|
||||
{
|
||||
this.DOMPopupSearchResultsWindow().style.display = 'none';
|
||||
this.DOMSearchClose().style.display = 'none';
|
||||
this.lastSearchValue = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.SelectItemCount = function(id)
|
||||
{
|
||||
var count=0;
|
||||
var win=this.DOMSearchSelectWindow();
|
||||
for (i=0;i<win.childNodes.length;i++)
|
||||
{
|
||||
var child = win.childNodes[i]; // get span within a
|
||||
if (child.className=='SelectItem')
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
this.SelectItemSet = function(id)
|
||||
{
|
||||
var i,j=0;
|
||||
var win=this.DOMSearchSelectWindow();
|
||||
for (i=0;i<win.childNodes.length;i++)
|
||||
{
|
||||
var child = win.childNodes[i]; // get span within a
|
||||
if (child.className=='SelectItem')
|
||||
{
|
||||
var node = child.firstChild;
|
||||
if (j==id)
|
||||
{
|
||||
node.innerHTML='•';
|
||||
}
|
||||
else
|
||||
{
|
||||
node.innerHTML=' ';
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called when an search filter selection is made.
|
||||
// set item with index id as the active item
|
||||
this.OnSelectItem = function(id)
|
||||
{
|
||||
this.searchIndex = id;
|
||||
this.SelectItemSet(id);
|
||||
var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
|
||||
if (searchValue!="" && this.searchActive) // something was found -> do a search
|
||||
{
|
||||
this.Search();
|
||||
}
|
||||
}
|
||||
|
||||
this.OnSearchSelectKey = function(evt)
|
||||
{
|
||||
var e = (evt) ? evt : window.event; // for IE
|
||||
if (e.keyCode==40 && this.searchIndex<this.SelectItemCount()) // Down
|
||||
{
|
||||
this.searchIndex++;
|
||||
this.OnSelectItem(this.searchIndex);
|
||||
}
|
||||
else if (e.keyCode==38 && this.searchIndex>0) // Up
|
||||
{
|
||||
this.searchIndex--;
|
||||
this.OnSelectItem(this.searchIndex);
|
||||
}
|
||||
else if (e.keyCode==13 || e.keyCode==27)
|
||||
{
|
||||
this.OnSelectItem(this.searchIndex);
|
||||
this.CloseSelectionWindow();
|
||||
this.DOMSearchField().focus();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// --------- Actions
|
||||
|
||||
// Closes the results window.
|
||||
this.CloseResultsWindow = function()
|
||||
{
|
||||
this.DOMPopupSearchResultsWindow().style.display = 'none';
|
||||
this.DOMSearchClose().style.display = 'none';
|
||||
this.Activate(false);
|
||||
}
|
||||
|
||||
this.CloseSelectionWindow = function()
|
||||
{
|
||||
this.DOMSearchSelectWindow().style.display = 'none';
|
||||
}
|
||||
|
||||
// Performs a search.
|
||||
this.Search = function()
|
||||
{
|
||||
this.keyTimeout = 0;
|
||||
|
||||
// strip leading whitespace
|
||||
var searchValue = this.DOMSearchField().value.replace(/^ +/, "");
|
||||
|
||||
var code = searchValue.toLowerCase().charCodeAt(0);
|
||||
var idxChar = searchValue.substr(0, 1).toLowerCase();
|
||||
if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair
|
||||
{
|
||||
idxChar = searchValue.substr(0, 2);
|
||||
}
|
||||
|
||||
var resultsPage;
|
||||
var resultsPageWithSearch;
|
||||
var hasResultsPage;
|
||||
|
||||
var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
|
||||
if (idx!=-1)
|
||||
{
|
||||
var hexCode=idx.toString(16);
|
||||
resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html';
|
||||
resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
|
||||
hasResultsPage = true;
|
||||
}
|
||||
else // nothing available for this search term
|
||||
{
|
||||
resultsPage = this.resultsPath + '/nomatches.html';
|
||||
resultsPageWithSearch = resultsPage;
|
||||
hasResultsPage = false;
|
||||
}
|
||||
|
||||
window.frames.MSearchResults.location = resultsPageWithSearch;
|
||||
var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
|
||||
|
||||
if (domPopupSearchResultsWindow.style.display!='block')
|
||||
{
|
||||
var domSearchBox = this.DOMSearchBox();
|
||||
this.DOMSearchClose().style.display = 'inline';
|
||||
if (this.insideFrame)
|
||||
{
|
||||
var domPopupSearchResults = this.DOMPopupSearchResults();
|
||||
domPopupSearchResultsWindow.style.position = 'relative';
|
||||
domPopupSearchResultsWindow.style.display = 'block';
|
||||
var width = document.body.clientWidth - 8; // the -8 is for IE :-(
|
||||
domPopupSearchResultsWindow.style.width = width + 'px';
|
||||
domPopupSearchResults.style.width = width + 'px';
|
||||
}
|
||||
else
|
||||
{
|
||||
var domPopupSearchResults = this.DOMPopupSearchResults();
|
||||
var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth;
|
||||
var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1;
|
||||
domPopupSearchResultsWindow.style.display = 'block';
|
||||
left -= domPopupSearchResults.offsetWidth;
|
||||
domPopupSearchResultsWindow.style.top = top + 'px';
|
||||
domPopupSearchResultsWindow.style.left = left + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
this.lastSearchValue = searchValue;
|
||||
this.lastResultsPage = resultsPage;
|
||||
}
|
||||
|
||||
// -------- Activation Functions
|
||||
|
||||
// Activates or deactivates the search panel, resetting things to
|
||||
// their default values if necessary.
|
||||
this.Activate = function(isActive)
|
||||
{
|
||||
if (isActive || // open it
|
||||
this.DOMPopupSearchResultsWindow().style.display == 'block'
|
||||
)
|
||||
{
|
||||
this.DOMSearchBox().className = 'MSearchBoxActive';
|
||||
|
||||
var searchField = this.DOMSearchField();
|
||||
|
||||
if (searchField.value == this.searchLabel) // clear "Search" term upon entry
|
||||
{
|
||||
searchField.value = '';
|
||||
this.searchActive = true;
|
||||
}
|
||||
}
|
||||
else if (!isActive) // directly remove the panel
|
||||
{
|
||||
this.DOMSearchBox().className = 'MSearchBoxInactive';
|
||||
this.DOMSearchField().value = this.searchLabel;
|
||||
this.searchActive = false;
|
||||
this.lastSearchValue = ''
|
||||
this.lastResultsPage = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// The class that handles everything on the search results page.
|
||||
function SearchResults(name)
|
||||
{
|
||||
// The number of matches from the last run of <Search()>.
|
||||
this.lastMatchCount = 0;
|
||||
this.lastKey = 0;
|
||||
this.repeatOn = false;
|
||||
|
||||
// Toggles the visibility of the passed element ID.
|
||||
this.FindChildElement = function(id)
|
||||
{
|
||||
var parentElement = document.getElementById(id);
|
||||
var element = parentElement.firstChild;
|
||||
|
||||
while (element && element!=parentElement)
|
||||
{
|
||||
if (element.nodeName == 'DIV' && element.className == 'SRChildren')
|
||||
{
|
||||
return element;
|
||||
}
|
||||
|
||||
if (element.nodeName == 'DIV' && element.hasChildNodes())
|
||||
{
|
||||
element = element.firstChild;
|
||||
}
|
||||
else if (element.nextSibling)
|
||||
{
|
||||
element = element.nextSibling;
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
element = element.parentNode;
|
||||
}
|
||||
while (element && element!=parentElement && !element.nextSibling);
|
||||
|
||||
if (element && element!=parentElement)
|
||||
{
|
||||
element = element.nextSibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.Toggle = function(id)
|
||||
{
|
||||
var element = this.FindChildElement(id);
|
||||
if (element)
|
||||
{
|
||||
if (element.style.display == 'block')
|
||||
{
|
||||
element.style.display = 'none';
|
||||
}
|
||||
else
|
||||
{
|
||||
element.style.display = 'block';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Searches for the passed string. If there is no parameter,
|
||||
// it takes it from the URL query.
|
||||
//
|
||||
// Always returns true, since other documents may try to call it
|
||||
// and that may or may not be possible.
|
||||
this.Search = function(search)
|
||||
{
|
||||
if (!search) // get search word from URL
|
||||
{
|
||||
search = window.location.search;
|
||||
search = search.substring(1); // Remove the leading '?'
|
||||
search = unescape(search);
|
||||
}
|
||||
|
||||
search = search.replace(/^ +/, ""); // strip leading spaces
|
||||
search = search.replace(/ +$/, ""); // strip trailing spaces
|
||||
search = search.toLowerCase();
|
||||
search = convertToId(search);
|
||||
|
||||
var resultRows = document.getElementsByTagName("div");
|
||||
var matches = 0;
|
||||
|
||||
var i = 0;
|
||||
while (i < resultRows.length)
|
||||
{
|
||||
var row = resultRows.item(i);
|
||||
if (row.className == "SRResult")
|
||||
{
|
||||
var rowMatchName = row.id.toLowerCase();
|
||||
rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_'
|
||||
|
||||
if (search.length<=rowMatchName.length &&
|
||||
rowMatchName.substr(0, search.length)==search)
|
||||
{
|
||||
row.style.display = 'block';
|
||||
matches++;
|
||||
}
|
||||
else
|
||||
{
|
||||
row.style.display = 'none';
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
document.getElementById("Searching").style.display='none';
|
||||
if (matches == 0) // no results
|
||||
{
|
||||
document.getElementById("NoMatches").style.display='block';
|
||||
}
|
||||
else // at least one result
|
||||
{
|
||||
document.getElementById("NoMatches").style.display='none';
|
||||
}
|
||||
this.lastMatchCount = matches;
|
||||
return true;
|
||||
}
|
||||
|
||||
// return the first item with index index or higher that is visible
|
||||
this.NavNext = function(index)
|
||||
{
|
||||
var focusItem;
|
||||
while (1)
|
||||
{
|
||||
var focusName = 'Item'+index;
|
||||
focusItem = document.getElementById(focusName);
|
||||
if (focusItem && focusItem.parentNode.parentNode.style.display=='block')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (!focusItem) // last element
|
||||
{
|
||||
break;
|
||||
}
|
||||
focusItem=null;
|
||||
index++;
|
||||
}
|
||||
return focusItem;
|
||||
}
|
||||
|
||||
this.NavPrev = function(index)
|
||||
{
|
||||
var focusItem;
|
||||
while (1)
|
||||
{
|
||||
var focusName = 'Item'+index;
|
||||
focusItem = document.getElementById(focusName);
|
||||
if (focusItem && focusItem.parentNode.parentNode.style.display=='block')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (!focusItem) // last element
|
||||
{
|
||||
break;
|
||||
}
|
||||
focusItem=null;
|
||||
index--;
|
||||
}
|
||||
return focusItem;
|
||||
}
|
||||
|
||||
this.ProcessKeys = function(e)
|
||||
{
|
||||
if (e.type == "keydown")
|
||||
{
|
||||
this.repeatOn = false;
|
||||
this.lastKey = e.keyCode;
|
||||
}
|
||||
else if (e.type == "keypress")
|
||||
{
|
||||
if (!this.repeatOn)
|
||||
{
|
||||
if (this.lastKey) this.repeatOn = true;
|
||||
return false; // ignore first keypress after keydown
|
||||
}
|
||||
}
|
||||
else if (e.type == "keyup")
|
||||
{
|
||||
this.lastKey = 0;
|
||||
this.repeatOn = false;
|
||||
}
|
||||
return this.lastKey!=0;
|
||||
}
|
||||
|
||||
this.Nav = function(evt,itemIndex)
|
||||
{
|
||||
var e = (evt) ? evt : window.event; // for IE
|
||||
if (e.keyCode==13) return true;
|
||||
if (!this.ProcessKeys(e)) return false;
|
||||
|
||||
if (this.lastKey==38) // Up
|
||||
{
|
||||
var newIndex = itemIndex-1;
|
||||
var focusItem = this.NavPrev(newIndex);
|
||||
if (focusItem)
|
||||
{
|
||||
var child = this.FindChildElement(focusItem.parentNode.parentNode.id);
|
||||
if (child && child.style.display == 'block') // children visible
|
||||
{
|
||||
var n=0;
|
||||
var tmpElem;
|
||||
while (1) // search for last child
|
||||
{
|
||||
tmpElem = document.getElementById('Item'+newIndex+'_c'+n);
|
||||
if (tmpElem)
|
||||
{
|
||||
focusItem = tmpElem;
|
||||
}
|
||||
else // found it!
|
||||
{
|
||||
break;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (focusItem)
|
||||
{
|
||||
focusItem.focus();
|
||||
}
|
||||
else // return focus to search field
|
||||
{
|
||||
parent.document.getElementById("MSearchField").focus();
|
||||
}
|
||||
}
|
||||
else if (this.lastKey==40) // Down
|
||||
{
|
||||
var newIndex = itemIndex+1;
|
||||
var focusItem;
|
||||
var item = document.getElementById('Item'+itemIndex);
|
||||
var elem = this.FindChildElement(item.parentNode.parentNode.id);
|
||||
if (elem && elem.style.display == 'block') // children visible
|
||||
{
|
||||
focusItem = document.getElementById('Item'+itemIndex+'_c0');
|
||||
}
|
||||
if (!focusItem) focusItem = this.NavNext(newIndex);
|
||||
if (focusItem) focusItem.focus();
|
||||
}
|
||||
else if (this.lastKey==39) // Right
|
||||
{
|
||||
var item = document.getElementById('Item'+itemIndex);
|
||||
var elem = this.FindChildElement(item.parentNode.parentNode.id);
|
||||
if (elem) elem.style.display = 'block';
|
||||
}
|
||||
else if (this.lastKey==37) // Left
|
||||
{
|
||||
var item = document.getElementById('Item'+itemIndex);
|
||||
var elem = this.FindChildElement(item.parentNode.parentNode.id);
|
||||
if (elem) elem.style.display = 'none';
|
||||
}
|
||||
else if (this.lastKey==27) // Escape
|
||||
{
|
||||
parent.searchBox.CloseResultsWindow();
|
||||
parent.document.getElementById("MSearchField").focus();
|
||||
}
|
||||
else if (this.lastKey==13) // Enter
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
this.NavChild = function(evt,itemIndex,childIndex)
|
||||
{
|
||||
var e = (evt) ? evt : window.event; // for IE
|
||||
if (e.keyCode==13) return true;
|
||||
if (!this.ProcessKeys(e)) return false;
|
||||
|
||||
if (this.lastKey==38) // Up
|
||||
{
|
||||
if (childIndex>0)
|
||||
{
|
||||
var newIndex = childIndex-1;
|
||||
document.getElementById('Item'+itemIndex+'_c'+newIndex).focus();
|
||||
}
|
||||
else // already at first child, jump to parent
|
||||
{
|
||||
document.getElementById('Item'+itemIndex).focus();
|
||||
}
|
||||
}
|
||||
else if (this.lastKey==40) // Down
|
||||
{
|
||||
var newIndex = childIndex+1;
|
||||
var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex);
|
||||
if (!elem) // last child, jump to parent next parent
|
||||
{
|
||||
elem = this.NavNext(itemIndex+1);
|
||||
}
|
||||
if (elem)
|
||||
{
|
||||
elem.focus();
|
||||
}
|
||||
}
|
||||
else if (this.lastKey==27) // Escape
|
||||
{
|
||||
parent.searchBox.CloseResultsWindow();
|
||||
parent.document.getElementById("MSearchField").focus();
|
||||
}
|
||||
else if (this.lastKey==13) // Enter
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function setKeyActions(elem,action)
|
||||
{
|
||||
elem.setAttribute('onkeydown',action);
|
||||
elem.setAttribute('onkeypress',action);
|
||||
elem.setAttribute('onkeyup',action);
|
||||
}
|
||||
|
||||
function setClassAttr(elem,attr)
|
||||
{
|
||||
elem.setAttribute('class',attr);
|
||||
elem.setAttribute('className',attr);
|
||||
}
|
||||
|
||||
function createResults()
|
||||
{
|
||||
var results = document.getElementById("SRResults");
|
||||
for (var e=0; e<searchData.length; e++)
|
||||
{
|
||||
var id = searchData[e][0];
|
||||
var srResult = document.createElement('div');
|
||||
srResult.setAttribute('id','SR_'+id);
|
||||
setClassAttr(srResult,'SRResult');
|
||||
var srEntry = document.createElement('div');
|
||||
setClassAttr(srEntry,'SREntry');
|
||||
var srLink = document.createElement('a');
|
||||
srLink.setAttribute('id','Item'+e);
|
||||
setKeyActions(srLink,'return searchResults.Nav(event,'+e+')');
|
||||
setClassAttr(srLink,'SRSymbol');
|
||||
srLink.innerHTML = searchData[e][1][0];
|
||||
srEntry.appendChild(srLink);
|
||||
if (searchData[e][1].length==2) // single result
|
||||
{
|
||||
srLink.setAttribute('href',searchData[e][1][1][0]);
|
||||
if (searchData[e][1][1][1])
|
||||
{
|
||||
srLink.setAttribute('target','_parent');
|
||||
}
|
||||
var srScope = document.createElement('span');
|
||||
setClassAttr(srScope,'SRScope');
|
||||
srScope.innerHTML = searchData[e][1][1][2];
|
||||
srEntry.appendChild(srScope);
|
||||
}
|
||||
else // multiple results
|
||||
{
|
||||
srLink.setAttribute('href','javascript:searchResults.Toggle("SR_'+id+'")');
|
||||
var srChildren = document.createElement('div');
|
||||
setClassAttr(srChildren,'SRChildren');
|
||||
for (var c=0; c<searchData[e][1].length-1; c++)
|
||||
{
|
||||
var srChild = document.createElement('a');
|
||||
srChild.setAttribute('id','Item'+e+'_c'+c);
|
||||
setKeyActions(srChild,'return searchResults.NavChild(event,'+e+','+c+')');
|
||||
setClassAttr(srChild,'SRScope');
|
||||
srChild.setAttribute('href',searchData[e][1][c+1][0]);
|
||||
if (searchData[e][1][c+1][1])
|
||||
{
|
||||
srChild.setAttribute('target','_parent');
|
||||
}
|
||||
srChild.innerHTML = searchData[e][1][c+1][2];
|
||||
srChildren.appendChild(srChild);
|
||||
}
|
||||
srEntry.appendChild(srChildren);
|
||||
}
|
||||
srResult.appendChild(srEntry);
|
||||
results.appendChild(srResult);
|
||||
}
|
||||
}
|
||||
|
||||
function init_search()
|
||||
{
|
||||
var results = document.getElementById("MSearchSelectWindow");
|
||||
for (var key in indexSectionLabels)
|
||||
{
|
||||
var link = document.createElement('a');
|
||||
link.setAttribute('class','SelectItem');
|
||||
link.setAttribute('onclick','searchBox.OnSelectItem('+key+')');
|
||||
link.href='javascript:void(0)';
|
||||
link.innerHTML='<span class="SelectionMark"> </span>'+indexSectionLabels[key];
|
||||
results.appendChild(link);
|
||||
}
|
||||
searchBox.OnSelectItem(0);
|
||||
}
|
||||
|
1
doc/formats/html/html_changes/tabs.css
Normal file
1
doc/formats/html/html_changes/tabs.css
Normal file
File diff suppressed because one or more lines are too long
12
doc/formats/html/mainpage.dox
Normal file
12
doc/formats/html/mainpage.dox
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
This file is for customizing the doxygen mainpage style.
|
||||
*/
|
||||
/*!
|
||||
\mainpage This Documentation Covers %wolfSSL, %wolfCrypt, and %CertManager API
|
||||
|
||||
\section website Useful Links
|
||||
https://wolfssl.com/wolfSSL/Home.html - Main website<br>
|
||||
https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-17-wolfssl-api-reference.html - %wolfSSL Manual<br>
|
||||
https://www.wolfssl.com/docs/wolfssl-manual/ch18/ - wolfCrypt Manual<br>
|
||||
https://github.com/wolfssl/wolfssl.git - Git repository
|
||||
*/
|
2480
doc/formats/pdf/Doxyfile
Normal file
2480
doc/formats/pdf/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
148
doc/formats/pdf/header.tex
Normal file
148
doc/formats/pdf/header.tex
Normal file
@ -0,0 +1,148 @@
|
||||
% Latex header for doxygen 1.8.13
|
||||
\documentclass[twoside]{book}
|
||||
|
||||
% Packages required by doxygen
|
||||
\usepackage{fixltx2e}
|
||||
\usepackage{calc}
|
||||
\usepackage{doxygen}
|
||||
\usepackage[export]{adjustbox} % also loads graphicx
|
||||
\usepackage{graphicx}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{makeidx}
|
||||
\usepackage{multicol}
|
||||
\usepackage{multirow}
|
||||
\PassOptionsToPackage{warn}{textcomp}
|
||||
\usepackage{textcomp}
|
||||
\usepackage[nointegrals]{wasysym}
|
||||
\usepackage[table]{xcolor}
|
||||
|
||||
% Font selection
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[scaled=.90]{helvet}
|
||||
\usepackage{courier}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{sectsty}
|
||||
\renewcommand{\familydefault}{\sfdefault}
|
||||
\allsectionsfont{%
|
||||
\fontseries{bc}\selectfont%
|
||||
\color{darkgray}%
|
||||
}
|
||||
\renewcommand{\DoxyLabelFont}{%
|
||||
\fontseries{bc}\selectfont%
|
||||
\color{darkgray}%
|
||||
}
|
||||
\newcommand{\+}{\discretionary{\mbox{\scriptsize$\hookleftarrow$}}{}{}}
|
||||
|
||||
% Page & text layout
|
||||
\usepackage{geometry}
|
||||
\geometry{%
|
||||
a4paper,%
|
||||
top=2.5cm,%
|
||||
bottom=2.5cm,%
|
||||
left=2.5cm,%
|
||||
right=2.5cm%
|
||||
}
|
||||
\tolerance=750
|
||||
\hfuzz=15pt
|
||||
\hbadness=750
|
||||
\setlength{\emergencystretch}{15pt}
|
||||
\setlength{\parindent}{0cm}
|
||||
\setlength{\parskip}{3ex plus 2ex minus 2ex}
|
||||
\makeatletter
|
||||
\renewcommand{\paragraph}{%
|
||||
\@startsection{paragraph}{4}{0ex}{-1.0ex}{1.0ex}{%
|
||||
\normalfont\normalsize\bfseries\SS@parafont%
|
||||
}%
|
||||
}
|
||||
\renewcommand{\subparagraph}{%
|
||||
\@startsection{subparagraph}{5}{0ex}{-1.0ex}{1.0ex}{%
|
||||
\normalfont\normalsize\bfseries\SS@subparafont%
|
||||
}%
|
||||
}
|
||||
\makeatother
|
||||
|
||||
% Headers & footers
|
||||
\usepackage{fancyhdr}
|
||||
\pagestyle{fancyplain}
|
||||
\fancyhead[LE]{\fancyplain{}{\bfseries\thepage}}
|
||||
\fancyhead[CE]{\fancyplain{}{}}
|
||||
\fancyhead[RE]{\fancyplain{}{\bfseries\leftmark}}
|
||||
\fancyhead[LO]{\fancyplain{}{\bfseries\rightmark}}
|
||||
\fancyhead[CO]{\fancyplain{}{}}
|
||||
\fancyhead[RO]{\fancyplain{}{\bfseries\thepage}}
|
||||
\fancyfoot[LE]{\fancyplain{}{}}
|
||||
\fancyfoot[CE]{\fancyplain{}{}}
|
||||
\fancyfoot[RE]{\fancyplain{}{\bfseries\scriptsize Copyright © 2018 wolfSSL Inc.
|
||||
All rights reserved. }}
|
||||
\fancyfoot[LO]{\fancyplain{}{\bfseries\scriptsize Copyright © 2018 wolfSSL Inc.
|
||||
All rights reserved. }}
|
||||
\fancyfoot[CO]{\fancyplain{}{}}
|
||||
\fancyfoot[RO]{\fancyplain{}{}}
|
||||
\renewcommand{\footrulewidth}{0.4pt}
|
||||
\renewcommand{\chaptermark}[1]{%
|
||||
\markboth{#1}{}%
|
||||
}
|
||||
\renewcommand{\sectionmark}[1]{%
|
||||
\markright{\thesection\ #1}%
|
||||
}
|
||||
|
||||
% Indices & bibliography
|
||||
\usepackage{natbib}
|
||||
\usepackage[titles]{tocloft}
|
||||
\setcounter{tocdepth}{3}
|
||||
\setcounter{secnumdepth}{5}
|
||||
\makeindex
|
||||
|
||||
% Hyperlinks (required, but should be loaded last)
|
||||
\usepackage{ifpdf}
|
||||
\ifpdf
|
||||
\usepackage[pdftex,pagebackref=true]{hyperref}
|
||||
\else
|
||||
\usepackage[ps2pdf,pagebackref=true]{hyperref}
|
||||
\fi
|
||||
\hypersetup{%
|
||||
colorlinks=true,%
|
||||
linkcolor=blue,%
|
||||
citecolor=blue,%
|
||||
unicode%
|
||||
}
|
||||
|
||||
% Custom commands
|
||||
\newcommand{\clearemptydoublepage}{%
|
||||
\newpage{\pagestyle{empty}\cleardoublepage}%
|
||||
}
|
||||
|
||||
\usepackage{caption}
|
||||
\captionsetup{labelsep=space,justification=centering,font={bf},singlelinecheck=off,skip=4pt,position=top}
|
||||
|
||||
%===== C O N T E N T S =====
|
||||
|
||||
\begin{document}
|
||||
|
||||
% Titlepage & ToC
|
||||
\hypersetup{pageanchor=false,
|
||||
bookmarksnumbered=true,
|
||||
pdfencoding=unicode
|
||||
}
|
||||
\pagenumbering{alph}
|
||||
\begin{titlepage}
|
||||
\vspace*{7cm}
|
||||
\begin{center}%
|
||||
{\Large wolfSSL API Reference}\\
|
||||
\vspace*{1cm}
|
||||
\graphicspath{{../images/}}
|
||||
\begin{figure}[ht!]
|
||||
\centering
|
||||
\includegraphics[width=70mm]{wolfssl_logo.png}
|
||||
\end{figure}
|
||||
{\large Generated by Doxygen 1.8.13}\\
|
||||
\end{center}
|
||||
\end{titlepage}
|
||||
\clearemptydoublepage
|
||||
\pagenumbering{roman}
|
||||
\tableofcontents
|
||||
\clearemptydoublepage
|
||||
\pagenumbering{arabic}
|
||||
\hypersetup{pageanchor=true}
|
||||
|
||||
%--- Begin generated contents ---
|
112
doc/generate_documentation.sh
Executable file
112
doc/generate_documentation.sh
Executable file
@ -0,0 +1,112 @@
|
||||
#!/bin/bash
|
||||
|
||||
POSIXLY_CORRECT=1
|
||||
|
||||
CHECK_API=false
|
||||
GEN_HTML=false
|
||||
GEN_PDF=false
|
||||
GEN_ALL=false
|
||||
INSTALL_DOX=false
|
||||
|
||||
command -v g++
|
||||
if [ $? -ne "0" ]; then
|
||||
echo "Please install g++"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command -v cmake
|
||||
if [ $? -ne "0" ]; then
|
||||
echo "Please install cmake"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command -v git
|
||||
if [ $? -ne "0" ]; then
|
||||
echo "Please install git"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
command -v make
|
||||
if [ $? -ne "0" ]; then
|
||||
echo "Please install make"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking arguments and setting appropriate option variables
|
||||
|
||||
for var in $@
|
||||
do
|
||||
case $var in
|
||||
-install)
|
||||
INSTALL_DOX=true
|
||||
;;
|
||||
-html)
|
||||
CHECK_API=true
|
||||
GEN_HTML=true
|
||||
;;
|
||||
-pdf)
|
||||
CHECK_API=true
|
||||
GEN_PDF=true
|
||||
;;
|
||||
-all)
|
||||
CHECK_API=true
|
||||
GEN_ALL=true
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Checking if doxygen is already installed
|
||||
# True - doxygen from "which doxygen" is used to generate documentation
|
||||
# False - clones doxygen Release_1_8_13 and ./build/bin/ added to PATH
|
||||
|
||||
if [ $INSTALL_DOX = true ] && [ ! "$(which doxygen)" ]; then
|
||||
mkdir -p build
|
||||
cd build
|
||||
echo "cloning doxygen 1.8.13..."
|
||||
git clone https://github.com/doxygen/doxygen --branch Release_1_8_13
|
||||
cmake -G "Unix Makefiles" doxygen/
|
||||
make
|
||||
cd ..
|
||||
export PATH="./build/bin/:$PATH"
|
||||
fi
|
||||
|
||||
# Runs script to check that all API with documentation match wolfSSL API
|
||||
if [ $CHECK_API = true ]; then
|
||||
./check_api.sh
|
||||
fi
|
||||
|
||||
if [ $? = 1 ]; then
|
||||
echo "Not all API match"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#HTML GENERATION
|
||||
if [ $GEN_HTML = true ] || [ $GEN_ALL = true ]; then
|
||||
cp -r formats/html/* ./
|
||||
echo "generating html..."
|
||||
doxygen Doxyfile
|
||||
cp html_changes/search/* html/search/
|
||||
cp html_changes/*.css html/
|
||||
cp html_changes/*.js html/
|
||||
rm footer.html header.html
|
||||
rm -rf html_changes
|
||||
rm mainpage.dox
|
||||
rm Doxyfile
|
||||
echo "finished generating html..."
|
||||
echo "To view the html files use a browser to open the index.html file located at doc/html/index.html"
|
||||
fi
|
||||
|
||||
#PDF GENERATION
|
||||
if [ $GEN_PDF = true ] || [ $GEN_ALL = true ]; then
|
||||
cp -r formats/pdf/* ./
|
||||
echo "generating pdf..."
|
||||
doxygen Doxyfile
|
||||
cd latex/
|
||||
make
|
||||
mv refman.pdf ../
|
||||
cd ..
|
||||
rm -rf latex/
|
||||
rm Doxyfile
|
||||
rm header.tex
|
||||
echo "finished generating pdf..."
|
||||
fi
|
BIN
doc/images/wolfssl_logo.png
Normal file
BIN
doc/images/wolfssl_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
@ -3,3 +3,19 @@
|
||||
# All paths should be given relative to the root
|
||||
|
||||
dist_doc_DATA+= doc/README.txt
|
||||
|
||||
dox-pdf:
|
||||
echo "Generating PDF"
|
||||
cd doc && ./generate_documentation.sh -install -pdf || (echo "HTML generation failed $$?"; exit 1)
|
||||
|
||||
dox-html:
|
||||
echo "Generating HTML"
|
||||
cd doc && ./generate_documentation.sh -install -html || (echo "HTML generation failed $$?"; exit 1)
|
||||
|
||||
dox: dox-html dox-pdf
|
||||
|
||||
clean-local:
|
||||
-rm -rf doc/build/
|
||||
-rm -rf doc/html/
|
||||
-rm -f doc/refman.pdf
|
||||
-rm -f doc/doxygen_warnings
|
||||
|
@ -21,6 +21,11 @@
|
||||
|
||||
/* bn.h for openssl */
|
||||
|
||||
/*!
|
||||
\file wolfssl/openssl/bn.h
|
||||
\brief bn.h for openssl
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLFSSL_BN_H_
|
||||
#define WOLFSSL_BN_H_
|
||||
|
@ -21,8 +21,9 @@
|
||||
|
||||
|
||||
|
||||
/* evp.h defines mini evp openssl compatibility layer
|
||||
*
|
||||
/*!
|
||||
\file wolfssl/openssl/evp.h
|
||||
\brief evp.h defines mini evp openssl compatibility layer
|
||||
*/
|
||||
|
||||
|
||||
|
@ -21,6 +21,10 @@
|
||||
|
||||
/* pem.h for openssl */
|
||||
|
||||
/*!
|
||||
\file wolfssl/openssl/pem.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLFSSL_PEM_H_
|
||||
#define WOLFSSL_PEM_H_
|
||||
|
@ -18,8 +18,10 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file ../wolfssl/ssl.h
|
||||
\brief Header file containing key wolfSSL API
|
||||
*/
|
||||
|
||||
/* wolfSSL API */
|
||||
|
||||
|
@ -19,6 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/aes.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_AES_H
|
||||
#define WOLF_CRYPT_AES_H
|
||||
@ -222,226 +226,22 @@ WOLFSSL_API int wc_AesEcbDecrypt(Aes* aes, byte* out,
|
||||
#endif /* HAVE_AES_KEYWRAP */
|
||||
|
||||
#ifdef WOLFSSL_AES_XTS
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief This is to help with setting keys to correct encrypt or decrypt type.
|
||||
|
||||
\note Is up to user to call wc_AesXtsFree on aes key when done.
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys for encrypt/decrypt process
|
||||
\param key buffer holding aes key | tweak key
|
||||
\param len length of key buffer in bytes. Should be twice that of key size.
|
||||
i.e. 32 for a 16 byte key.
|
||||
\param dir direction, either AES_ENCRYPTION or AES_DECRYPTION
|
||||
\param heap heap hint to use for memory. Can be NULL
|
||||
\param devId id to use with async crypto. Can be 0
|
||||
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
|
||||
if(wc_AesXtsSetKey(&aes, key, sizeof(key), AES_ENCRYPTION, NULL, 0) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsEncrypt
|
||||
\sa wc_AesXtsDecrypt
|
||||
\sa wc_AesXtsFree
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsSetKey(XtsAes* aes, const byte* key,
|
||||
word32 len, int dir, void* heap, int devId);
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief Same process as wc_AesXtsEncrypt but uses a word64 type as the tweak
|
||||
value instead of a byte array. This just converts the word64 to a
|
||||
byte array and calls wc_AesXtsEncrypt.
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys to use for block encrypt/decrypt
|
||||
\param out output buffer to hold cipher text
|
||||
\param in input plain text buffer to encrypt
|
||||
\param sz size of both out and in buffers
|
||||
\param sector value to use for tweak
|
||||
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
unsigned char plain[SIZE];
|
||||
unsigned char cipher[SIZE];
|
||||
word64 s = VALUE;
|
||||
|
||||
//set up keys with AES_ENCRYPTION as dir
|
||||
|
||||
if(wc_AesXtsEncryptSector(&aes, cipher, plain, SIZE, s) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsEncrypt
|
||||
\sa wc_AesXtsDecrypt
|
||||
\sa wc_AesXtsSetKey
|
||||
\sa wc_AesXtsFree
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsEncryptSector(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, word64 sector);
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief Same process as wc_AesXtsDecrypt but uses a word64 type as the tweak
|
||||
value instead of a byte array. This just converts the word64 to a
|
||||
byte array.
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys to use for block encrypt/decrypt
|
||||
\param out output buffer to hold plain text
|
||||
\param in input cipher text buffer to decrypt
|
||||
\param sz size of both out and in buffers
|
||||
\param sector value to use for tweak
|
||||
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
unsigned char plain[SIZE];
|
||||
unsigned char cipher[SIZE];
|
||||
word64 s = VALUE;
|
||||
|
||||
//set up aes key with AES_DECRYPTION as dir and tweak with AES_ENCRYPTION
|
||||
|
||||
if(wc_AesXtsDecryptSector(&aes, plain, cipher, SIZE, s) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsEncrypt
|
||||
\sa wc_AesXtsDecrypt
|
||||
\sa wc_AesXtsSetKey
|
||||
\sa wc_AesXtsFree
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsDecryptSector(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, word64 sector);
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief AES with XTS mode. (XTS) XEX encryption with Tweak and cipher text
|
||||
Stealing.
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys to use for block encrypt/decrypt
|
||||
\param out output buffer to hold cipher text
|
||||
\param in input plain text buffer to encrypt
|
||||
\param sz size of both out and in buffers
|
||||
\param i value to use for tweak
|
||||
\param iSz size of i buffer, should always be AES_BLOCK_SIZE but having
|
||||
this input adds a sanity check on how the user calls the
|
||||
function.
|
||||
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
unsigned char plain[SIZE];
|
||||
unsigned char cipher[SIZE];
|
||||
unsigned char i[AES_BLOCK_SIZE];
|
||||
|
||||
//set up key with AES_ENCRYPTION as dir
|
||||
|
||||
if(wc_AesXtsEncrypt(&aes, cipher, plain, SIZE, i, sizeof(i)) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsDecrypt
|
||||
\sa wc_AesXtsSetKey
|
||||
\sa wc_AesXtsFree
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsEncrypt(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, const byte* i, word32 iSz);
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief Same process as encryption but Aes key is AES_DECRYPTION type.
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys to use for block encrypt/decrypt
|
||||
\param out output buffer to hold plain text
|
||||
\param in input cipher text buffer to decrypt
|
||||
\param sz size of both out and in buffers
|
||||
\param i value to use for tweak
|
||||
\param iSz size of i buffer, should always be AES_BLOCK_SIZE but having
|
||||
this input adds a sanity check on how the user calls the
|
||||
function.
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
unsigned char plain[SIZE];
|
||||
unsigned char cipher[SIZE];
|
||||
unsigned char i[AES_BLOCK_SIZE];
|
||||
|
||||
//set up key with AES_DECRYPTION as dir and tweak with AES_ENCRYPTION
|
||||
|
||||
if(wc_AesXtsDecrypt(&aes, plain, cipher, SIZE, i, sizeof(i)) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsEncrypt
|
||||
\sa wc_AesXtsSetKey
|
||||
\sa wc_AesXtsFree
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsDecrypt(XtsAes* aes, byte* out,
|
||||
const byte* in, word32 sz, const byte* i, word32 iSz);
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup AES
|
||||
|
||||
\brief This is to free up any resources used by the XtsAes structure
|
||||
|
||||
\return 0 Success
|
||||
|
||||
\param aes AES keys to free
|
||||
|
||||
_Example_
|
||||
\code
|
||||
XtsAes aes;
|
||||
|
||||
if(wc_AesXtsSetKey(&aes, key, sizeof(key), AES_ENCRYPTION, NULL, 0) != 0)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
wc_AesXtsFree(&aes);
|
||||
\endcode
|
||||
|
||||
\sa wc_AesXtsEncrypt
|
||||
\sa wc_AesXtsDecrypt
|
||||
\sa wc_AesXtsSetKey
|
||||
*/
|
||||
WOLFSSL_API int wc_AesXtsFree(XtsAes* aes);
|
||||
#endif
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/arc4.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_ARC4_H
|
||||
#define WOLF_CRYPT_ARC4_H
|
||||
|
@ -19,6 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/asn.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_ASN_H
|
||||
#define WOLF_CRYPT_ASN_H
|
||||
|
@ -19,7 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/asn_public.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_ASN_PUBLIC_H
|
||||
#define WOLF_CRYPT_ASN_PUBLIC_H
|
||||
|
@ -19,8 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/blake2.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_BLAKE2_H
|
||||
#define WOLF_CRYPT_BLAKE2_H
|
||||
|
@ -46,6 +46,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/camellia.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_CAMELLIA_H
|
||||
#define WOLF_CRYPT_CAMELLIA_H
|
||||
|
@ -19,6 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/chacha.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_CHACHA_H
|
||||
#define WOLF_CRYPT_CHACHA_H
|
||||
|
@ -25,6 +25,10 @@
|
||||
* https://tools.ietf.org/html/draft-irtf-cfrg-chacha20-poly1305-10
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/chacha20_poly1305.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_CHACHA20_POLY1305_H
|
||||
#define WOLF_CRYPT_CHACHA20_POLY1305_H
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/coding.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_CODING_H
|
||||
#define WOLF_CRYPT_CODING_H
|
||||
|
@ -19,6 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/compress.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_COMPRESS_H
|
||||
#define WOLF_CRYPT_COMPRESS_H
|
||||
|
@ -19,6 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/curve25519.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_CURVE25519_H
|
||||
#define WOLF_CRYPT_CURVE25519_H
|
||||
|
@ -19,6 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/des3.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_DES3_H
|
||||
#define WOLF_CRYPT_DES3_H
|
||||
|
@ -19,6 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/dh.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_DH_H
|
||||
#define WOLF_CRYPT_DH_H
|
||||
|
@ -19,6 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/dsa.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_DSA_H
|
||||
#define WOLF_CRYPT_DSA_H
|
||||
|
@ -19,6 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/ecc.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_ECC_H
|
||||
#define WOLF_CRYPT_ECC_H
|
||||
|
@ -19,6 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/ed25519.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_ED25519_H
|
||||
#define WOLF_CRYPT_ED25519_H
|
||||
|
@ -19,7 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/error-crypt.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_ERROR_H
|
||||
#define WOLF_CRYPT_ERROR_H
|
||||
|
@ -19,6 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/hash.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_HASH_H
|
||||
#define WOLF_CRYPT_HASH_H
|
||||
|
@ -19,6 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/hc128.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_HC128_H
|
||||
#define WOLF_CRYPT_HC128_H
|
||||
|
@ -19,7 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/hmac.h
|
||||
*/
|
||||
|
||||
#ifndef NO_HMAC
|
||||
|
||||
|
@ -19,6 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/idea.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_IDEA_H
|
||||
#define WOLF_CRYPT_IDEA_H
|
||||
|
@ -19,6 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/logging.h
|
||||
*/
|
||||
|
||||
|
||||
/* submitted by eof */
|
||||
|
||||
|
@ -19,6 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/md2.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_MD2_H
|
||||
#define WOLF_CRYPT_MD2_H
|
||||
|
@ -19,6 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/md4.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_MD4_H
|
||||
#define WOLF_CRYPT_MD4_H
|
||||
|
@ -19,6 +19,10 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/md5.h
|
||||
*/
|
||||
|
||||
|
||||
#ifndef WOLF_CRYPT_MD5_H
|
||||
#define WOLF_CRYPT_MD5_H
|
||||
|
@ -22,6 +22,9 @@
|
||||
|
||||
/* submitted by eof */
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/memory.h
|
||||
*/
|
||||
|
||||
#ifndef WOLFSSL_MEMORY_H
|
||||
#define WOLFSSL_MEMORY_H
|
||||
|
@ -19,6 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/pksc7.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_PKCS7_H
|
||||
#define WOLF_CRYPT_PKCS7_H
|
||||
|
@ -19,6 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||
*/
|
||||
|
||||
/*!
|
||||
\file wolfssl/wolfcrypt/poly1305.h
|
||||
*/
|
||||
|
||||
#ifndef WOLF_CRYPT_POLY1305_H
|
||||
#define WOLF_CRYPT_POLY1305_H
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user