mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
DTLS Multicast
1. Add configured group ID to outbound DTLS datagrams. 2. Parse the group ID from inbound DTLS datagrams.
This commit is contained in:
@@ -4906,16 +4906,40 @@ static INLINE void DtlsGetSEQ(WOLFSSL* ssl, int order, word32 seq[2])
|
|||||||
{
|
{
|
||||||
if (order == PREV_ORDER) {
|
if (order == PREV_ORDER) {
|
||||||
/* Previous epoch case */
|
/* Previous epoch case */
|
||||||
|
if (ssl->options.haveMcast) {
|
||||||
|
#ifdef WOLFSSL_MULTICAST
|
||||||
|
seq[0] = ((ssl->keys.dtls_epoch - 1) << 16) |
|
||||||
|
(ssl->options.mcastID << 8) |
|
||||||
|
(ssl->keys.dtls_prev_sequence_number_hi & 0xFF);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
seq[0] = ((ssl->keys.dtls_epoch - 1) << 16) |
|
seq[0] = ((ssl->keys.dtls_epoch - 1) << 16) |
|
||||||
(ssl->keys.dtls_prev_sequence_number_hi & 0xFFFF);
|
(ssl->keys.dtls_prev_sequence_number_hi & 0xFFFF);
|
||||||
seq[1] = ssl->keys.dtls_prev_sequence_number_lo;
|
seq[1] = ssl->keys.dtls_prev_sequence_number_lo;
|
||||||
}
|
}
|
||||||
else if (order == PEER_ORDER) {
|
else if (order == PEER_ORDER) {
|
||||||
|
if (ssl->options.haveMcast) {
|
||||||
|
#ifdef WOLFSSL_MULTICAST
|
||||||
|
seq[0] = (ssl->keys.curEpoch << 16) |
|
||||||
|
(ssl->keys.curPeerId << 8) |
|
||||||
|
(ssl->keys.curSeq_hi & 0xFF);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
seq[0] = (ssl->keys.curEpoch << 16) |
|
seq[0] = (ssl->keys.curEpoch << 16) |
|
||||||
(ssl->keys.curSeq_hi & 0xFFFF);
|
(ssl->keys.curSeq_hi & 0xFFFF);
|
||||||
seq[1] = ssl->keys.curSeq_lo; /* explicit from peer */
|
seq[1] = ssl->keys.curSeq_lo; /* explicit from peer */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (ssl->options.haveMcast) {
|
||||||
|
#ifdef WOLFSSL_MULTICAST
|
||||||
|
seq[0] = (ssl->keys.dtls_epoch << 16) |
|
||||||
|
(ssl->options.mcastID << 8) |
|
||||||
|
(ssl->keys.dtls_sequence_number_hi & 0xFF);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
seq[0] = (ssl->keys.dtls_epoch << 16) |
|
seq[0] = (ssl->keys.dtls_epoch << 16) |
|
||||||
(ssl->keys.dtls_sequence_number_hi & 0xFFFF);
|
(ssl->keys.dtls_sequence_number_hi & 0xFFFF);
|
||||||
seq[1] = ssl->keys.dtls_sequence_number_lo;
|
seq[1] = ssl->keys.dtls_sequence_number_lo;
|
||||||
@@ -6217,6 +6241,13 @@ static int GetRecordHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||||||
*inOutIdx += ENUM_LEN + VERSION_SZ;
|
*inOutIdx += ENUM_LEN + VERSION_SZ;
|
||||||
ato16(input + *inOutIdx, &ssl->keys.curEpoch);
|
ato16(input + *inOutIdx, &ssl->keys.curEpoch);
|
||||||
*inOutIdx += OPAQUE16_LEN;
|
*inOutIdx += OPAQUE16_LEN;
|
||||||
|
if (ssl->options.haveMcast) {
|
||||||
|
#ifdef WOLFSSL_MULTICAST
|
||||||
|
ssl->keys.curPeerId = input[*inOutIdx];
|
||||||
|
ssl->keys.curSeq_hi = input[*inOutIdx+1];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
ato16(input + *inOutIdx, &ssl->keys.curSeq_hi);
|
ato16(input + *inOutIdx, &ssl->keys.curSeq_hi);
|
||||||
*inOutIdx += OPAQUE16_LEN;
|
*inOutIdx += OPAQUE16_LEN;
|
||||||
ato32(input + *inOutIdx, &ssl->keys.curSeq_lo);
|
ato32(input + *inOutIdx, &ssl->keys.curSeq_lo);
|
||||||
|
@@ -1756,6 +1756,9 @@ typedef struct Keys {
|
|||||||
word16 curEpoch; /* Received epoch in current record */
|
word16 curEpoch; /* Received epoch in current record */
|
||||||
word16 curSeq_hi; /* Received sequence in current record */
|
word16 curSeq_hi; /* Received sequence in current record */
|
||||||
word32 curSeq_lo;
|
word32 curSeq_lo;
|
||||||
|
#ifdef WOLFSSL_MULTICAST
|
||||||
|
byte curPeerId; /* Received peer group ID in current record */
|
||||||
|
#endif
|
||||||
|
|
||||||
word32 prevWindow[WOLFSSL_DTLS_WINDOW_WORDS];
|
word32 prevWindow[WOLFSSL_DTLS_WINDOW_WORDS];
|
||||||
/* Sliding window for old epoch */
|
/* Sliding window for old epoch */
|
||||||
@@ -2846,7 +2849,6 @@ typedef struct Options {
|
|||||||
word16 dtlsSctp:1; /* DTLS-over-SCTP mode */
|
word16 dtlsSctp:1; /* DTLS-over-SCTP mode */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef WOLFSSL_MULTICAST
|
|
||||||
word16 haveMcast:1; /* using multicast ? */
|
word16 haveMcast:1; /* using multicast ? */
|
||||||
#endif
|
#endif
|
||||||
word16 haveEMS:1; /* using extended master secret */
|
word16 haveEMS:1; /* using extended master secret */
|
||||||
|
Reference in New Issue
Block a user