Built-in OpenSSL.
See openssl docs for more info.
Usage: #include <swilib.h> or #include <swilib/openssl.h>
Also, you can use standart openssl headers with #include <builtin/openssl/...> Alternatively, you can add -Ipath/to/include/builtin to the compiler flags.
- Note
- For GCC: These functions is available only when define
-DSWILIB_OPENSSL is specified in compiler flags.
-
Alternatively, you can include these functions directly by
#include <swilib/openssl.h>
|
| uint8_t * | MD5_Hash (const uint8_t *data, unsigned long len, uint8_t *hash) |
| | Calculate MD5 hash by single function.
|
| |
| void | MD5_Init (MD5_CTX *c) |
| | Initialize a MD5_CTX structure.
|
| |
| void | MD5_Update (MD5_CTX *c, const void *data, unsigned long len) |
| | Hash chunk of the data.
|
| |
| void | MD5_Final (uint8_t *hash, MD5_CTX *c) |
| | Finalize the MD5 calculation and get hash.
|
| |
|
| RSA * | RSA_new_method (RSA_METHOD *method) |
| | Allocate and initialize an RSA structure so that method will be used for the RSA operations.
|
| |
| int | RSA_sign (int type, unsigned char *m, unsigned int m_len, unsigned char *sigret, unsigned int *siglen, RSA *rsa) |
| | Sign message digest by the RSA.
|
| |
| void | RSA_free (RSA *rsa) |
| | Free RSA structure.
|
| |
|
| SSL_METHOD * | TLSv1_client_method () |
| | Get the TLSv1 client method.
|
| |
| SSL_CTX * | SSL_CTX_new (SSL_METHOD *meth) |
| | Allocate and initialize an SSL_CTX structure so that method will be used for the SSL operations.
|
| |
| void | SSL_CTX_free (SSL_CTX *ctx) |
| | Free SSL_CTX structure.
|
| |
| long | SSL_CTX_ctrl (SSL_CTX *ctx, int cmd, long larg, void *parg) |
| | Manipulate settings of the SSL_CTX object.
|
| |
| SSL * | SSL_new (SSL_CTX *ctx) |
| | Create an SSL structure for a connection.
|
| |
| int | SSL_set_fd (SSL *s, int fd) |
| | Connect the SSL object with a file descriptor.
|
| |
| int | SSL_connect (SSL *ssl) |
| | Initiate the TLS/SSL handshake with an TLS/SSL server.
|
| |
| int | SSL_shutdown (SSL *ssl) |
| | Shut down a SSL connection.
|
| |
| int | SSL_read (SSL *ssl, void *buf, int num) |
| | Read bytes from a SSL connection.
|
| |
| int | SSL_peek (SSL *ssl, void *buf, int num) |
| | Read bytes from a SSL connection.
|
| |
| int | SSL_write (SSL *ssl, const void *buf, int num) |
| | Write bytes to a SSL connection.
|
| |
| void | SSL_free (SSL *ssl) |
| | Free an allocated SSL structure.
|
| |
| int | SSL_set_session (SSL *ssl, SSL_SESSION *session) |
| | Set a SSL session to be used during SSL connect.
|
| |
| void | SSL_SESSION_free (SSL_SESSION *sess) |
| | Free an allocated SSL_SESSION structure.
|
| |
◆ BN_bin2bn()
Convert the positive integer in big-endian form into a BIGNUM.
If ret is NULL, a new BIGNUM is created.
- Parameters
-
| s | positive integer in big-endian |
| len | size of s |
| [out] | ret | result of converting |
- Returns
- When
ret is NULL, then a new BIGNUM is allocated.
-
When
ret is specified, then it returns ret.
◆ MD5_Hash()
| uint8_t * MD5_Hash |
( |
const uint8_t * | data, |
|
|
unsigned long | len, |
|
|
uint8_t * | hash ) |
Calculate MD5 hash by single function.
- Parameters
-
| data | pointer to the data |
| len | size of the data |
| [out] | hash | pointer to the uint8_t[16] for md5 hash result (can be NULL) |
- Returns
- When
hash is NULL, then it returns the pointer to the static buffer with MD5 hash.
-
When
hash is specified, then it returns hash.
◆ MD5_Init()
Initialize a MD5_CTX structure.
- Parameters
-
◆ MD5_Update()
| void MD5_Update |
( |
MD5_CTX * | c, |
|
|
const void * | data, |
|
|
unsigned long | len ) |
Hash chunk of the data.
- Parameters
-
| c | pointer to the MD5_CTX |
| data | pointer to the data |
| len | size of the data |
◆ MD5_Final()
| void MD5_Final |
( |
uint8_t * | hash, |
|
|
MD5_CTX * | c ) |
Finalize the MD5 calculation and get hash.
- Parameters
-
| [out] | hash | pointer to the uint8_t[16] for md5 hash result |
| c | pointer to the MD5_CTX |
◆ SHA1_Init()
Initialize a SHA_CTX structure.
- Parameters
-
◆ SHA1_Update()
| void SHA1_Update |
( |
SHA_CTX * | c, |
|
|
const void * | data, |
|
|
unsigned long | len ) |
Hash chunk of the data.
- Parameters
-
| c | pointer to the SHA_CTX |
| data | pointer to the data |
| len | size of the data |
◆ SHA1_Final()
| void SHA1_Final |
( |
unsigned char * | hash, |
|
|
SHA_CTX * | c ) |
Finalize the SHA1 calculation and get hash.
- Parameters
-
| [out] | hash | pointer to the uint8_t[20] for the SHA1 hash result |
| c | pointer to the SHA_CTX |
◆ RSA_new_method()
Allocate and initialize an RSA structure so that method will be used for the RSA operations.
- Parameters
-
- Returns
- pointer to the allocated and initialized RSA structure
◆ RSA_sign()
| int RSA_sign |
( |
int | type, |
|
|
unsigned char * | m, |
|
|
unsigned int | m_len, |
|
|
unsigned char * | sigret, |
|
|
unsigned int * | siglen, |
|
|
RSA * | rsa ) |
Sign message digest by the RSA.
- Parameters
-
| type | message digest algorithm |
| m | input message |
| m_len | input message length |
| [out] | sigret | output RSA signature |
| [out] | siglen | output RSA signature length |
| rsa | initialized RSA structure |
- Returns
- 1: success, 0: error
◆ RSA_free()
| void RSA_free |
( |
RSA * | rsa | ) |
|
Free RSA structure.
- Parameters
-
| rsa | initialized RSA structure |
◆ RAND_get_rand_method()
Get selected random method.
- Returns
- pointer to random method
- Pointer to the memory:
- FLASH
◆ TLSv1_client_method()
Get the TLSv1 client method.
- Returns
- pointer to the static TLSv1 client SSL method
◆ SSL_CTX_new()
Allocate and initialize an SSL_CTX structure so that method will be used for the SSL operations.
- Parameters
-
- Returns
- pointer to the allocated and initialized SSL_CTX structure
◆ SSL_CTX_free()
Free SSL_CTX structure.
- Parameters
-
| ctx | initialized SSL_CTX structure |
◆ SSL_CTX_ctrl()
| long SSL_CTX_ctrl |
( |
SSL_CTX * | ctx, |
|
|
int | cmd, |
|
|
long | larg, |
|
|
void * | parg ) |
Manipulate settings of the SSL_CTX object.
- Parameters
-
| ctx | initialized SSL_CTX structure |
| cmd | internal command |
| larg,parg | command arguments |
- Returns
- The return values depend on the command supplied via the cmd parameter.
◆ SSL_new()
Create an SSL structure for a connection.
- Parameters
-
| ctx | initialized SSL_CTX structure |
- Returns
- pointer to the allocated and initialized SSL structure
◆ SSL_set_fd()
| int SSL_set_fd |
( |
SSL * | s, |
|
|
int | fd ) |
Connect the SSL object with a file descriptor.
- Parameters
-
| s | initialized SSL structure |
| fd | socked descriptor |
- Returns
- 1 or error
◆ SSL_connect()
| int SSL_connect |
( |
SSL * | ssl | ) |
|
Initiate the TLS/SSL handshake with an TLS/SSL server.
- Parameters
-
| ssl | initialized SSL structure |
- Returns
- 1 on success, 0 or negative value on error
◆ SSL_shutdown()
| int SSL_shutdown |
( |
SSL * | ssl | ) |
|
Shut down a SSL connection.
- Parameters
-
| ssl | initialized SSL structure |
- Returns
- 1 when finished, 0 when not yet finished, negative value on error
◆ SSL_read()
| int SSL_read |
( |
SSL * | ssl, |
|
|
void * | buf, |
|
|
int | num ) |
Read bytes from a SSL connection.
- Parameters
-
| ssl | initialized SSL structure |
| buf | pointer to a buffer for the read data |
| num | maximum size for read |
- Returns
- count of readed bytes or error (<= 0)
◆ SSL_peek()
| int SSL_peek |
( |
SSL * | ssl, |
|
|
void * | buf, |
|
|
int | num ) |
Read bytes from a SSL connection.
- Note
- SSL_peek() are identical to SSL_read() respectively except no bytes are actually removed from the underlying BIO during the read, so that a subsequent call to SSL_read() will yield at least the same bytes.
- Parameters
-
| ssl | initialized SSL structure |
| buf | pointer to a buffer for the read data |
| num | maximum size for read |
- Returns
- count of readed bytes or error (<= 0)
◆ SSL_write()
| int SSL_write |
( |
SSL * | ssl, |
|
|
const void * | buf, |
|
|
int | num ) |
Write bytes to a SSL connection.
- Parameters
-
| ssl | initialized SSL structure |
| buf | pointer to a buffer with data to be written |
| num | maximum size for write |
- Returns
- count of written bytes or error (<= 0)
◆ SSL_free()
| void SSL_free |
( |
SSL * | ssl | ) |
|
Free an allocated SSL structure.
- Parameters
-
| ssl | initialized SSL structure |
◆ SSL_set_session()
Set a SSL session to be used during SSL connect.
- Parameters
-
| ssl | initialized SSL structure |
| session | pointer to the SSL_SESSION |
- Returns
- 1 or error
◆ SSL_SESSION_free()
Free an allocated SSL_SESSION structure.
- Parameters
-
| sess | initialized SSL_SESSION structure |
◆ EVP_add_cipher()
Add new EVP cipher.
- Parameters
-
- Returns
- nonzero on success, 0 on error