Go to the documentation of this file.
1 /**********
2 This library is free software; you can redistribute it and/or modify it under
3 the terms of the GNU Lesser General Public License as published by the
4 Free Software Foundation; either version 3 of the License, or (at your
5 option) any later version. (See <>.)
7 This library is distributed in the hope that it will be useful, but WITHOUT
8 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10 more details.
12 You should have received a copy of the GNU Lesser General Public License
13 along with this library; if not, write to the Free Software Foundation, Inc.,
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 **********/
16 // "liveMedia"
17 // Copyright (c) 1996-2022 Live Networks, Inc. All rights reserved.
18 // A data structure that implements a MIKEY message (RFC 3830)
19 // C++ header
21 #ifndef _MIKEY_HH
22 #define _MIKEY_HH
24 #ifndef _NET_COMMON_H
25 #include "NetCommon.h"
26 #endif
27 #ifndef _BOOLEAN_HH
28 #include "Boolean.hh"
29 #endif
31 class MIKEYState {
32 public:
33  MIKEYState(); // initialize with default parameters
34  virtual ~MIKEYState();
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).
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.
44  // Accessors for the encryption/authentication parameters:
45  Boolean encryptSRTP() const { return fEncryptSRTP; }
46  Boolean encryptSRTCP() const { return fEncryptSRTCP; }
47  u_int8_t const* keyData() const { return fKeyData; }
48  u_int32_t MKI() const { return fMKI; }
51 private:
52  MIKEYState(u_int8_t const* messageToParse, unsigned messageSize, Boolean& parsedOK);
53  // called only by "createNew()"
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);
59 private:
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.)
69  // Our internal binary representation of the MIKEY payloads:
70  class MIKEYPayload* fHeaderPayload;
71  class MIKEYPayload* fTailPayload;
73 };
75 #endif
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
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)
static MIKEYState * createNew(u_int8_t const *messageToParse, unsigned messageSize)
u_int8_t * generateMessage(unsigned &messageSize) const
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)
u_int8_t const * keyData() const
Definition: MIKEY.hh:47
void addNewPayload(class MIKEYPayload *newPayload)
Boolean parseNonHDRPayload(u_int8_t const *&ptr, u_int8_t const *endPtr, u_int8_t &nextPayloadType)
Boolean fEncryptSRTCP
Definition: MIKEY.hh:64