16 #define TW_SUBJECT_CN 0
17 #define TW_SUBJECT_O 1
18 #define TW_SUBJECT_OU 2
19 #define TW_ISSUER_CN 3
21 #define TW_ISSUER_OU 5
23 #define TW_READ_TIMEOUT -333
25 #include TW_TLS_INCLUDE
321 char * issuer_cn,
char * issuer_o,
char * issuer_ou);
350 #include "tomcrypt.h"
351 #define TW_SHA1_CTX hash_state
352 #define TW_SHA1_INIT(a) sha1_init(a)
353 #define TW_SHA1_UPDATE(a,b,c) sha1_process(a,b,c)
354 #define TW_SHA1_FINAL(a,b) sha1_done(b,a)
392 #include "tomcrypt.h"
393 #define TW_MD5_CTX hash_state
394 #define TW_MD5_INIT(a) md5_init(a)
395 #define TW_MD5_UPDATE(a,b,c) md5_process(a,b,c)
396 #define TW_MD5_FINAL(a,b) md5_done(b,a)
int twTlsClient_Connect(twTlsClient *t)
Connects a twTlsClient::connection (see twSocket_Connect()).
Definition: twTls.c:75
char * read_buf
Definition: twTls.h:42
void twTlsClient_DisableCertValidation(twTlsClient *t)
Sets the twTlsClient to disable certificate validation (see twSocket_DisableCertValidation()).
Definition: twTls.c:291
int twTlsClient_UsePrivateKeyFile(twTlsClient *t, const char *file, int type)
Loads the first private key stored in file into twTlsClient::ctx.
Definition: twTls.c:313
void twTlsClient_SetDefaultPasswdCb(twTlsClient *t, twPasswdCallbackFunction u)
Sets the twTlsClient::keypasswdCallback of a twTlsClient to u.
Definition: twTls.c:333
ThingWorx C SDK error code definitions.
int twTlsServer_Accept(twTlsClient *t)
Waits for a twTlsClient::ssl to initiate a handshake with the server (see TW_SSL_ACCEPT()).
Definition: twTls.c:184
twSocket * connection
Definition: twTls.h:35
void * twTlsClient_GetSessionId(twTlsClient *t)
Gets the session ID of a twTlsClient.
Definition: twTls.c:281
#define TW_MUTEX
For Linux builds a TW_MUTEX is a pthread_mutex_t.
Definition: twLinux-openssl.h:81
twSocket base type definition.
Definition: twOSPort.h:174
char selfSignedOk
Definition: twTls.h:43
Wrappers for OS-specific functionality.
#define TW_SSL
The base SSL structure for your SSL library.
Definition: twTemplateSSL.h:21
void twTlsClient_DisableEncryption(twTlsClient *t)
Sets the twTlsClient to disable encryption (see twSocket_DisableEncryption()).
Definition: twTls.c:296
int twTlsClient_Create(const char *host, int16_t port, uint32_t options, twTlsClient **client)
Creates a new twTlsClient structure with the specified settings.
Definition: twTls.c:14
char ** x509_data
Definition: twTls.h:40
#define TW_SSL_CTX
The SSL context structure for your SSL library.
Definition: twTemplateSSL.h:38
int twTlsClient_IsEncrypted(twTlsClient *t)
Checks to see if a twTlsClient is encrypted by getting the value of twTlsClient::isEncrypted.
Definition: twTls.c:339
char validateCert
Definition: twTls.h:44
void twSHA1_Init(TW_SHA1_CTX *ctx)
Initializes an SHA1 context.
Definition: twTls.c:377
void twMD5_Update(TW_MD5_CTX *, const uint8_t *msg, int len)
Add a new entry to an MD5 hash.
Definition: twTls.c:396
int twTlsClient_Read(twTlsClient *t, char *buf, int len, int timeout)
Reads len bytes of data from a twTlsClient::connection into buf (see twSocket_Read()).
Definition: twTls.c:210
struct twTlsClient twTlsClient
TLS client structure definition.
void twSHA1_Final(uint8_t *digest, TW_SHA1_CTX *ctx)
Finalize and get the calculated SHA1 digest.
Definition: twTls.c:385
twPasswdCallbackFunction keypasswdCallback
Definition: twTls.h:41
void twMD5_Final(uint8_t *digest, TW_MD5_CTX *)
Finalize and get the calculated MD5 digest.
Definition: twTls.c:400
int twTlsClient_Close(twTlsClient *t)
Closes a twTlsClient::connection (see twSocket_Close()).
Definition: twTls.c:191
int twTlsServer_Create(twTlsClient *t)
Creates a new #TW_TLS server and associates it with a twTlsClient::ssl.
Definition: twTls.c:166
char isEncrypted
Definition: twTls.h:45
int twTlsClient_Reconnect(twTlsClient *t, const char *host, int16_t port)
Reconnects a twTlsClient::connection (see twSocket_Reconnect()).
Definition: twTls.c:137
void twTlsClient_SetSelfSignedOk(twTlsClient *t)
Sets the twTlsClient to accept self signed certificates (see twSocket_SetSelfSignedOk()).
Definition: twTls.c:286
int twTlsClient_Delete(twTlsClient *t)
Frees all memory associated with a twTlsClient and all of its owned substructures.
Definition: twTls.c:261
#define TW_SHA1_CTX
Definition: twTls.h:351
TW_SSL_CTX * ctx
Definition: twTls.h:36
int twTlsClient_SetClientCaList(twTlsClient *t, char *caFile, char *caPath)
Loads a client certificate authority cert chain in file into twTlsClient::ctx.
Definition: twTls.c:328
void twMD5_Init(TW_MD5_CTX *)
Initializes an MD5 context.
Definition: twTls.c:392
uint32_t options
Definition: twTls.h:39
void twSHA1_Update(TW_SHA1_CTX *ctx, const uint8_t *msg, int len)
Add a new entry to an SHA1 hash.
Definition: twTls.c:381
TW_SSL * ssl
Definition: twTls.h:37
int twTlsClient_ValidateCert(twTlsClient *t)
Tells the twTlsClient to validate its twTlsClient::ssl certificate (see TW_VALIDATE_CERT()).
Definition: twTls.c:303
char isEnabled
Definition: twTls.h:46
#define TW_MD5_CTX
Definition: twTls.h:393
TLS client structure definition.
Definition: twTls.h:34
int twTlsClient_ConnectSession(twTlsClient *t, void *sessionId, int sessionLength)
Connects a twTlsClient::connection (see twSocket_Connect()) with some additional session options...
Definition: twTls.c:79
int twTlsClient_UseCertificateFile(twTlsClient *t, const char *file, int type)
Loads the first certificate stored in file into twTlsClient::ctx.
Definition: twTls.c:308
int twTlsClient_UseCertificateChainFile(twTlsClient *t, const char *file, int type)
Loads the certificate authority cert chain used to validate the server's certificate in file into twT...
Definition: twTls.c:323
TW_MUTEX mtx
Definition: twTls.h:47
int twTlsClient_SetX509Fields(twTlsClient *t, char *subject_cn, char *subject_o, char *subject_ou, char *issuer_cn, char *issuer_o, char *issuer_ou)
Sets the X509 fields of a twTlsClient.
Definition: twTls.c:344
int twTlsClient_Write(twTlsClient *t, char *buf, int len, int timeout)
Writes len bytes of data from buf to a twTlsClient::connection (see twSocket_Write()).
Definition: twTls.c:244
Definition: gzappend.c:170