41 #include <mbedtls/ssl.h> 42 #include <mbedtls/entropy.h> 43 #include <mbedtls/ctr_drbg.h> 44 #include <mbedtls/error.h> 45 #include <mbedtls/certs.h> 46 #include <mbedtls/ssl_cookie.h> 66 kApplicationDataMaxLength = 128,
94 typedef void (*
ReceiveHandler)(
void *aContext, uint8_t *aBuf, uint16_t aLength);
105 typedef otError(*
SendHandler)(
void *aContext,
const uint8_t *aBuf, uint16_t aLength, uint8_t aMessageSubType);
209 static otError MapError(
int rval);
211 static void HandleMbedtlsDebug(
void *ctx,
int level,
const char *file,
int line,
const char *str);
213 static int HandleMbedtlsGetTimer(
void *aContext);
214 int HandleMbedtlsGetTimer(
void);
216 static void HandleMbedtlsSetTimer(
void *aContext, uint32_t aIntermediate, uint32_t aFinish);
217 void HandleMbedtlsSetTimer(uint32_t aIntermediate, uint32_t aFinish);
219 static int HandleMbedtlsReceive(
void *aContext,
unsigned char *aBuf,
size_t aLength);
220 int HandleMbedtlsReceive(
unsigned char *aBuf,
size_t aLength);
222 static int HandleMbedtlsTransmit(
void *aContext,
const unsigned char *aBuf,
size_t aLength);
223 int HandleMbedtlsTransmit(
const unsigned char *aBuf,
size_t aLength);
225 static int HandleMbedtlsExportKeys(
void *aContext,
const unsigned char *aMasterSecret,
226 const unsigned char *aKeyBlock,
227 size_t aMacLength,
size_t aKeyLength,
size_t aIvLength);
228 int HandleMbedtlsExportKeys(
const unsigned char *aMasterSecret,
const unsigned char *aKeyBlock,
229 size_t aMacLength,
size_t aKeyLength,
size_t aIvLength);
231 static void HandleTimer(
Timer &aTimer);
232 void HandleTimer(
void);
239 uint8_t mPsk[kPskMaxLength];
242 mbedtls_entropy_context mEntropy;
243 mbedtls_ctr_drbg_context mCtrDrbg;
244 mbedtls_ssl_context mSsl;
245 mbedtls_ssl_config mConf;
246 mbedtls_ssl_cookie_ctx mCookieCtx;
250 uint32_t mTimerIntermediate;
254 uint16_t mReceiveOffset;
255 uint16_t mReceiveLength;
263 uint8_t mMessageSubType;
264 uint8_t mMessageDefaultSubType;
ProvisioningUrlTlv mProvisioningUrl
The provisioning URL is placed here so that both the Commissioner and Joiner can share the same objec...
Definition: dtls.hpp:206
This type represents all the static / global variables used by OpenThread allocated in one place...
Definition: openthread-instance.h:59
void(* ReceiveHandler)(void *aContext, uint8_t *aBuf, uint16_t aLength)
This function pointer is called when data is received from the DTLS session.
Definition: dtls.hpp:94
This file defines the types and structures used in the OpenThread library API.
otError Send(Message &aMessage, uint16_t aLength)
This method sends data within the DTLS session.
void SetDefaultMessageSubType(uint8_t aMessageSubType)
This method sets the default message sub-type that will be used for all messages without defined sub-...
Definition: dtls.hpp:200
This file includes definitions for locator class for OpenThread objects.
otError Receive(Message &aMessage, uint16_t aOffset, uint16_t aLength)
This method provides a received DTLS message to the DTLS object.
otError(* SendHandler)(void *aContext, const uint8_t *aBuf, uint16_t aLength, uint8_t aMessageSubType)
This function pointer is called when data is ready to transmit for the DTLS session.
Definition: dtls.hpp:105
This class implements a timer.
Definition: timer.hpp:69
This class implements the millisecond timer.
Definition: timer.hpp:145
This file includes definitions for performing SHA-256 computations.
This file includes definitions for generating and processing MeshCoP TLVs.
otError SetClientId(const uint8_t *aClientId, uint8_t aLength)
This method sets the Client ID used for generating the Hello Cookie.
void(* ConnectedHandler)(void *aContext, bool aConnected)
This function pointer is called when a connection is established or torn down.
Definition: dtls.hpp:84
This class implements definitions for maintaining a pointer to arbitrary context information.
Definition: context.hpp:61
bool IsConnected(void)
This method indicates whether or not the DTLS session is connected.
This class represents a message.
Definition: message.hpp:195
otError SetPsk(const uint8_t *aPsk, uint8_t aPskLength)
This method sets the PSK.
otError Stop(void)
This method stops the DTLS service.
This file includes definitions for the message buffer pool and message buffers.
bool IsStarted(void)
This method indicates whether or not the DTLS service is active.
This class implements locator for otInstance object.
Definition: locator.hpp:63
This file includes definitions for the multiplexed timer service.
Dtls(otInstance &aInstance)
This constructor initializes the DTLS object.
otError Start(bool aClient, ConnectedHandler aConnectedHandler, ReceiveHandler aReceiveHandler, SendHandler aSendHandler, void *aContext)
This method starts the DTLS service.
otError
This enumeration represents error codes used throughout OpenThread.
Definition: types.h:107
This file includes compile-time configuration constants for OpenThread.
This class implements Provisioning URL TLV generation and parsing.
Definition: meshcop_tlvs.hpp:1501