live
MIKEY.hh
Go to the documentation of this file.
1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2025 Live Networks, Inc. All rights reserved.
18// A data structure that implements a MIKEY message (RFC 3830)
19// C++ header
20
21#ifndef _MIKEY_HH
22#define _MIKEY_HH
23
24#ifndef _NET_COMMON_H
25#include "NetCommon.h"
26#endif
27#ifndef _BOOLEAN_HH
28#include "Boolean.hh"
29#endif
30
32public:
33 static MIKEYState* createNew(Boolean useEncryption = True);
34 // initialize with default parameters
35 static MIKEYState* createNew(u_int8_t const* messageToParse, unsigned messageSize);
36 // (Attempts to) parse a binary MIKEY message, returning a new "MIKEYState" if successful
37 // (or NULL if unsuccessful).
38
39 virtual ~MIKEYState();
40
41 u_int8_t* generateMessage(unsigned& messageSize) const;
42 // Returns a binary message representing the current MIKEY state, of size "messageSize" bytes.
43 // This array is dynamically allocated by this routine, and must be delete[]d by the caller.
44
45 void setROC(u_int32_t roc);
46
47 // Accessors for the encryption/authentication parameters:
48 Boolean encryptSRTP() const { return fEncryptSRTP; }
50 u_int8_t const* keyData() const { return fKeyData; }
51 u_int32_t MKI() const { return fMKI; }
52 u_int32_t initialROC() const { return fInitialROC; }
54
55protected:
56 MIKEYState(Boolean useEncryption);
57 // called only by "createNew()"
58 MIKEYState(u_int8_t const* messageToParse, unsigned messageSize, Boolean& parsedOK);
59 // called only by "createNew()"
60
61 void addNewPayload(class MIKEYPayload* newPayload);
62 Boolean parseHDRPayload(u_int8_t const*& ptr, u_int8_t const* endPtr, u_int8_t& nextPayloadType);
63 Boolean parseNonHDRPayload(u_int8_t const*& ptr, u_int8_t const* endPtr, u_int8_t& nextPayloadType);
64
65private:
66 // Encryption/authentication parameters, either set by default
67 // (if the first (parameterless) constructor is used), or set by parsing an input message
68 // (if the second constructor is used):
71 u_int8_t fKeyData[16+14]; // encryption key + salt
72 u_int32_t fMKI; // used only if encryption is used. (We assume a MKI length of 4.)
73 u_int32_t fInitialROC; // initial SRTP roll-over-counter (assumes just one crypto session)
75
76 // Our internal binary representation of the MIKEY payloads:
77 class MIKEYPayload* fHeaderPayload;
78 class MIKEYPayload* fTailPayload;
80};
81
82#endif
const Boolean True
Definition: Boolean.hh:31
unsigned char Boolean
Definition: Boolean.hh:25
u_int32_t MKI() const
Definition: MIKEY.hh:51
Boolean fEncryptSRTP
Definition: MIKEY.hh:69
unsigned fTotalPayloadByteCount
Definition: MIKEY.hh:79
static MIKEYState * createNew(u_int8_t const *messageToParse, unsigned messageSize)
u_int32_t fMKI
Definition: MIKEY.hh:72
Boolean encryptSRTCP() const
Definition: MIKEY.hh:49
void setROC(u_int32_t roc)
static MIKEYState * createNew(Boolean useEncryption=True)
u_int32_t initialROC() const
Definition: MIKEY.hh:52
Boolean encryptSRTP() const
Definition: MIKEY.hh:48
Boolean parseHDRPayload(u_int8_t const *&ptr, u_int8_t const *endPtr, u_int8_t &nextPayloadType)
class MIKEYPayload * fTailPayload
Definition: MIKEY.hh:78
Boolean fUseAuthentication
Definition: MIKEY.hh:74
Boolean useAuthentication() const
Definition: MIKEY.hh:53
class MIKEYPayload * fHeaderPayload
Definition: MIKEY.hh:77
u_int8_t fKeyData[16+14]
Definition: MIKEY.hh:71
u_int32_t fInitialROC
Definition: MIKEY.hh:73
MIKEYState(Boolean useEncryption)
virtual ~MIKEYState()
MIKEYState(u_int8_t const *messageToParse, unsigned messageSize, Boolean &parsedOK)
void addNewPayload(class MIKEYPayload *newPayload)
Boolean parseNonHDRPayload(u_int8_t const *&ptr, u_int8_t const *endPtr, u_int8_t &nextPayloadType)
u_int8_t const * keyData() const
Definition: MIKEY.hh:50
Boolean fEncryptSRTCP
Definition: MIKEY.hh:70
u_int8_t * generateMessage(unsigned &messageSize) const