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-2024 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 MIKEYState(Boolean useEncryption = True); // initialize with default parameters
34 virtual ~MIKEYState();
35
36 static MIKEYState* createNew(u_int8_t const* messageToParse, unsigned messageSize);
37 // (Attempts to) parse a binary MIKEY message, returning a new "MIKEYState" if successful
38 // (or NULL if unsuccessful).
39
40 u_int8_t* generateMessage(unsigned& messageSize) const;
41 // Returns a binary message representing the current MIKEY state, of size "messageSize" bytes.
42 // This array is dynamically allocated by this routine, and must be delete[]d by the caller.
43
44 // Accessors for the encryption/authentication parameters:
45 Boolean encryptSRTP() const { return fEncryptSRTP; }
47 u_int8_t const* keyData() const { return fKeyData; }
48 u_int32_t MKI() const { return fMKI; }
50
51private:
52 MIKEYState(u_int8_t const* messageToParse, unsigned messageSize, Boolean& parsedOK);
53 // called only by "createNew()"
54
55 void addNewPayload(class MIKEYPayload* newPayload);
56 Boolean parseHDRPayload(u_int8_t const*& ptr, u_int8_t const* endPtr, u_int8_t& nextPayloadType);
57 Boolean parseNonHDRPayload(u_int8_t const*& ptr, u_int8_t const* endPtr, u_int8_t& nextPayloadType);
58
59private:
60 // Encryption/authentication parameters, either set by default
61 // (if the first (parameterless) constructor is used), or set by parsing an input message
62 // (if the second constructor is used):
65 u_int8_t fKeyData[16+14]; // encryption key + salt
66 u_int32_t fMKI; // used only if encryption is used. (We assume a MKI length of 4.)
68
69 // Our internal binary representation of the MIKEY payloads:
70 class MIKEYPayload* fHeaderPayload;
71 class MIKEYPayload* fTailPayload;
73};
74
75#endif
const Boolean True
Definition: Boolean.hh:31
unsigned char Boolean
Definition: Boolean.hh:25
u_int32_t MKI() const
Definition: MIKEY.hh:48
Boolean fEncryptSRTP
Definition: MIKEY.hh:63
unsigned fTotalPayloadByteCount
Definition: MIKEY.hh:72
static MIKEYState * createNew(u_int8_t const *messageToParse, unsigned messageSize)
u_int32_t fMKI
Definition: MIKEY.hh:66
Boolean encryptSRTCP() const
Definition: MIKEY.hh:46
Boolean encryptSRTP() const
Definition: MIKEY.hh:45
Boolean parseHDRPayload(u_int8_t const *&ptr, u_int8_t const *endPtr, u_int8_t &nextPayloadType)
MIKEYState(Boolean useEncryption=True)
class MIKEYPayload * fTailPayload
Definition: MIKEY.hh:71
Boolean fUseAuthentication
Definition: MIKEY.hh:67
Boolean useAuthentication() const
Definition: MIKEY.hh:49
class MIKEYPayload * fHeaderPayload
Definition: MIKEY.hh:70
u_int8_t fKeyData[16+14]
Definition: MIKEY.hh:65
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:47
Boolean fEncryptSRTCP
Definition: MIKEY.hh:64
u_int8_t * generateMessage(unsigned &messageSize) const