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
332 char * issuer_cn,
char * issuer_o,
char * issuer_ou);
361 #include "tomcrypt.h"
362 #define TW_SHA1_CTX hash_state
363 #define TW_SHA1_INIT(a) sha1_init(a)
364 #define TW_SHA1_UPDATE(a,b,c) sha1_process(a,b,c)
365 #define TW_SHA1_FINAL(a,b) sha1_done(b,a)
403 #include "tomcrypt.h"
404 #define TW_MD5_CTX hash_state
405 #define TW_MD5_INIT(a) md5_init(a)
406 #define TW_MD5_UPDATE(a,b,c) md5_process(a,b,c)
407 #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:62
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:278
int twTlsClient_EnableFipsMode(twTlsClient *t)
Enables FIPS mode for a twTlsClient. Wrapper function for TW_ENABLE_FIPS_MODE().
Definition: twTls.c:319
int twTlsClient_UsePrivateKeyFile(twTlsClient *t, const char *file, int type)
Loads the first private key stored in file into twTlsClient::ctx.
Definition: twTls.c:300
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:170
twSocket * connection
Definition: twTls.h:35
void * twTlsClient_GetSessionId(twTlsClient *t)
Gets the session ID of a twTlsClient.
Definition: twTls.c:268
#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:175
char selfSignedOk
Definition: twTls.h:43
Wrappers for OS-specific functionality.
void twTlsClient_DisableEncryption(twTlsClient *t)
Sets the twTlsClient to disable encryption (see twSocket_DisableEncryption()).
Definition: twTls.c:283
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:12
char ** x509_data
Definition: twTls.h:40
int twTlsClient_IsEncrypted(twTlsClient *t)
Checks to see if a twTlsClient is encrypted by getting the value of twTlsClient::isEncrypted.
Definition: twTls.c:324
char validateCert
Definition: twTls.h:44
void twSHA1_Init(TW_SHA1_CTX *ctx)
Initializes an SHA1 context.
Definition: twTls.c:353
void twMD5_Update(TW_MD5_CTX *, const uint8_t *msg, int len)
Add a new entry to an MD5 hash.
Definition: twTls.c:372
char * keypasswd
Definition: twTls.h:41
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:196
struct twTlsClient twTlsClient
TLS client structure definition.
void twTlsClient_SetDefaultPasswdCbUserdata(twTlsClient *t, void *u)
Sets the twTlsClient::keypasswd of a twTlsClient to u.
Definition: twTls.c:315
void twSHA1_Final(uint8_t *digest, TW_SHA1_CTX *ctx)
Finalize and get the calculated SHA1 digest.
Definition: twTls.c:361
void twMD5_Final(uint8_t *digest, TW_MD5_CTX *)
Finalize and get the calculated MD5 digest.
Definition: twTls.c:376
int twTlsClient_Close(twTlsClient *t)
Closes a twTlsClient::connection (see twSocket_Close()).
Definition: twTls.c:177
int twTlsServer_Create(twTlsClient *t)
Creates a new #TW_TLS server and associates it with a twTlsClient::ssl.
Definition: twTls.c:153
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:124
void twTlsClient_SetSelfSignedOk(twTlsClient *t)
Sets the twTlsClient to accept self signed certificates (see twSocket_SetSelfSignedOk()).
Definition: twTls.c:273
int twTlsClient_Delete(twTlsClient *t)
Frees all memory associated with a twTlsClient and all of its owned substructures.
Definition: twTls.c:247
#define TW_SHA1_CTX
Definition: twTls.h:362
TW_SSL_CTX * ctx
Definition: twTls.h:36
void twMD5_Init(TW_MD5_CTX *)
Initializes an MD5 context.
Definition: twTls.c:368
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:357
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:290
char isEnabled
Definition: twTls.h:46
#define TW_MD5_CTX
Definition: twTls.h:404
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:66
int twTlsClient_SetClientCaList(twTlsClient *t, char *caFile)
Loads a client certificate authority cert chain in file into twTlsClient::ctx.
Definition: twTls.c:310
int twTlsClient_UseCertificateFile(twTlsClient *t, const char *file, int type)
Loads the first certificate stored in file into twTlsClient::ctx.
Definition: twTls.c:295
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:305
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:329
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:230