pbTLS  1.1
TLSLIB.h
Go to the documentation of this file.
1 
263 #ifndef TLSLIB_H
264 #define TLSLIB_H
265 
266  #ifndef UINT32
267 
268  typedef unsigned long UINT32;
269  #endif
270 
271  #ifndef UINT16
272 
273  typedef unsigned short UINT16;
274  #endif
275 
276  #ifndef UINT8
277 
278  typedef unsigned char UINT8;
279  #endif
280 
281  #ifndef BOOL
282 
283 typedef UINT8 BOOL;
284 #endif
285 
286 #ifndef TRUE
287 
288 # define TRUE ( (BOOL)1 )
289 #endif
290 
291 #ifndef FALSE
292 
293 # define FALSE ( (BOOL)0 )
294 #endif
295 
297 #ifndef SOCKET
298  typedef UINT8 SOCKET;
299 #endif
300 
307  typedef int (*PointerToSend)(SOCKET pSocket, const UINT8* pBuffer, UINT32 len_buffer);
308 
310  typedef int (*PointerToReceive)(SOCKET pSocket, UINT8* const pBuffer, UINT32 len_buffer);
311 
313  typedef void (*PointerToCloseSocket)(SOCKET pSocket);
314 
326  typedef void* (*PointerToMalloc)(UINT32 size);
327 
329  typedef void (*PointerToFree)(void* pMemory);
330 
332  typedef void* (*PointerToRealloc)(void* pMemory, UINT32 new_size);
333 
338 #if eWBM
339  typedef int (*PointerToTRNG)(void* out, uint32_t readSz, const void* reseed);
340 #else
341  typedef int (*PointerToTRNG)(UINT8 rng[32]);
342 #endif
343 
349 extern int TLSShutdown(const void** ppSession);
350 
445 //TODO Document the new parameters for dynamic certs!
446 extern int TLSEngine(SOCKET pSocket,
447  const void** ppSession,
448  const char fqdn[], const UINT8 len_fqdn,
449  PointerToSend Send,
450  PointerToReceive Receive,
451  PointerToCloseSocket CloseSocket,
452  PointerToMalloc Malloc,
453  PointerToFree Free,
454  PointerToRealloc Realloc,
455  PointerToTRNG pbTRNG,
456  UINT8 mode_of_operation,
457  BOOL bClientMode_Tolerate_FQDN_Mismatch,
458  BOOL bClientMode_Skip_Authorised_Root_CA_Check,
459  BOOL client_certificate_request, // new in 1.1: client certificate request by Server (in Server Mode)
460  const UINT8 server_cert[], const UINT32 len_server_cert,
461  const UINT8 ca_cert[], const UINT32 len_ca_cert,
462  const UINT8 client_cert[], const UINT32 len_client_cert,
463  const UINT8 server_rsa_private_key[], const UINT32 len_server_rsa_private_key,
464  const UINT8 client_rsa_private_key[], const UINT32 len_client_rsa_private_key);
465 
466 
476 extern int TLSReadAppData(const void* const* ppCurrentSession,
477  UINT8 output_buffer[], UINT32* len_output_buffer );
485 extern int TLSWriteAppData(const void* const* ppCurrentSession,
486  const UINT8 data[], UINT32 len_data);
487 
488 
489 #endif
int TLSReadAppData(const void *const *ppCurrentSession, UINT8 output_buffer[], UINT32 *len_output_buffer)
Reads incoming encrypted application data according to the established (after engine success) session...
int(* PointerToSend)(SOCKET pSocket, const UINT8 *pBuffer, UINT32 len_buffer)
Pointer to function which sends TCP packets. As TLS operates on a higher ISO/OSI level, we need interface functions at this point that take care of processing incoming and outgoing data on a lower network layer, i.e. TCP. Hence, PointerToSend is expected to hold reference to TCPSend().
Definition: TLSLIB.h:307
int TLSShutdown(const void **ppSession)
Closes an existing TLS session and realeases dynamically allocated resources.
unsigned short UINT16
Definition: TLSLIB.h:273
unsigned char UINT8
Definition: TLSLIB.h:278
int TLSEngine(SOCKET pSocket, const void **ppSession, const char fqdn[], const UINT8 len_fqdn, PointerToSend Send, PointerToReceive Receive, PointerToCloseSocket CloseSocket, PointerToMalloc Malloc, PointerToFree Free, PointerToRealloc Realloc, PointerToTRNG pbTRNG, UINT8 mode_of_operation, BOOL bClientMode_Tolerate_FQDN_Mismatch, BOOL bClientMode_Skip_Authorised_Root_CA_Check, BOOL client_certificate_request, const UINT8 server_cert[], const UINT32 len_server_cert, const UINT8 ca_cert[], const UINT32 len_ca_cert, const UINT8 client_cert[], const UINT32 len_client_cert, const UINT8 server_rsa_private_key[], const UINT32 len_server_rsa_private_key, const UINT8 client_rsa_private_key[], const UINT32 len_client_rsa_private_key)
Creates a TLS server or client session.
UINT8 BOOL
Definition: TLSLIB.h:283
int TLSWriteAppData(const void *const *ppCurrentSession, const UINT8 data[], UINT32 len_data)
Writes outgoing encrypted app data according to the established TLS session parameters.
void(* PointerToCloseSocket)(SOCKET pSocket)
Pointer to TCPClose().
Definition: TLSLIB.h:313
void *(* PointerToRealloc)(void *pMemory, UINT32 new_size)
Pointer to realloc().
Definition: TLSLIB.h:332
void(* PointerToFree)(void *pMemory)
Pointer to free().
Definition: TLSLIB.h:329
unsigned long UINT32
Definition: TLSLIB.h:268
int(* PointerToReceive)(SOCKET pSocket, UINT8 *const pBuffer, UINT32 len_buffer)
Pointer to TCPRecv().
Definition: TLSLIB.h:310
UINT8 SOCKET
Specifies a socket that has already been opened by either TCPClientOpen() or TCPServerOpen().
Definition: TLSLIB.h:298
int(* PointerToTRNG)(UINT8 rng[32])
Definition: TLSLIB.h:341
void *(* PointerToMalloc)(UINT32 size)
Pointer to malloc(). As dicussed during the introduction of TLSLib, TLS implementations have to work ...
Definition: TLSLIB.h:326