Bayonne2 / Common C++ 2 Framework: ZrtpConfigure.h Source File

Bayonne2 / Common C++ 2 Framework
ZrtpConfigure.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2010 Werner Dittmann
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 /*
19  * Authors: Werner Dittmann <Werner.Dittmann@t-online.de>
20  */
21 
22 #ifndef _ZRTPCONFIGURE_H_
23 #define _ZRTPCONFIGURE_H_
24 
32 #include <stdio.h>
33 #include <stdint.h>
34 #include <list>
35 #include <string>
36 #include <vector>
37 #include <string.h>
38 
39 #include <libzrtpcpp/ZrtpCallback.h>
40 
45  enum AlgoTypes {
46   Invalid = 0, HashAlgorithm = 1, CipherAlgorithm, PubKeyAlgorithm, SasType, AuthLength
47 };
48 
49  typedef void(*encrypt_t)(uint8_t*, int32_t, uint8_t*, uint8_t*, int32_t);
50  typedef void(*decrypt_t)(uint8_t*, int32_t, const uint8_t*, uint8_t*, int32_t);
51 
62  class AlgorithmEnum {
63 public:
86  AlgorithmEnum(const AlgoTypes type, const char* name, int32_t klen,
87  const char* ra, encrypt_t en, decrypt_t de, SrtpAlgorithms alId);
88 
92  ~AlgorithmEnum();
93 
101  const char* getName();
102 
110  const char* getReadable();
111 
118  int getKeylen();
119 
126  SrtpAlgorithms getAlgoId();
133  encrypt_t getEncrypt();
134 
141  decrypt_t getDecrypt();
142 
151  AlgoTypes getAlgoType();
152 
159  bool isValid();
160 
161 private:
162   AlgoTypes algoType;
163   std::string algoName;
164   int32_t keyLen;
165   std::string readable;
166   encrypt_t encrypt;
167   decrypt_t decrypt;
168   SrtpAlgorithms algoId;
169 };
170 
185  class EnumBase {
186 public:
196  AlgorithmEnum& getByName(const char* name);
197 
204  std::list<std::string>* getAllNames();
205 
212  int getSize();
213 
221  AlgoTypes getAlgoType();
222 
231  AlgorithmEnum& getByOrdinal(int ord);
232 
243  int getOrdinal(AlgorithmEnum& algo);
244 
245 protected:
246  EnumBase(AlgoTypes algo);
247  ~EnumBase();
248  void insert(const char* name);
249  void insert(const char* name, int32_t klen,
250  const char* ra, encrypt_t en, decrypt_t de, SrtpAlgorithms alId);
251 
252 private:
253   AlgoTypes algoType;
254   std::vector <AlgorithmEnum* > algos;
255 };
256 
260  class HashEnum : public EnumBase {
261 public:
262  HashEnum();
263  ~HashEnum();
264 };
265 
266  class SymCipherEnum : public EnumBase {
267 public:
268  SymCipherEnum();
269  ~SymCipherEnum();
270 };
271 
272  class PubKeyEnum : public EnumBase {
273 public:
274  PubKeyEnum();
275  ~PubKeyEnum();
276 };
277 
278  class SasTypeEnum : public EnumBase {
279 public:
280  SasTypeEnum();
281  ~SasTypeEnum();
282 };
283 
284  class AuthLengthEnum : public EnumBase {
285 public:
286  AuthLengthEnum();
287  ~AuthLengthEnum();
288 };
289 
290 extern HashEnum zrtpHashes;
291 extern SymCipherEnum zrtpSymCiphers;
292 extern PubKeyEnum zrtpPubKeys;
293 extern SasTypeEnum zrtpSasTypes;
294 extern AuthLengthEnum zrtpAuthLengths;
295 
312  class __EXPORT ZrtpConfigure {
313 public:
314  ZrtpConfigure(); /* Creates Configuration data */
315  ~ZrtpConfigure();
316 
321   static const int maxNoOfAlgos = 7;
334  void setStandardConfig();
335 
348  void setMandatoryOnly();
349 
355  void clear();
356 
372  int32_t addAlgo(AlgoTypes algoType, AlgorithmEnum& algo);
373 
390  int32_t addAlgoAt(AlgoTypes algoType, AlgorithmEnum& algo, int32_t index);
391 
411  int32_t removeAlgo(AlgoTypes algoType, AlgorithmEnum& algo);
412 
422  int32_t getNumConfiguredAlgos(AlgoTypes algoType);
423 
437  AlgorithmEnum& getAlgoAt(AlgoTypes algoType, int32_t index);
438 
451  bool containsAlgo(AlgoTypes algoType, AlgorithmEnum& algo);
452 
462  void setTrustedMitM(bool yesNo);
463 
470  bool isTrustedMitM();
471 
481  void setSasSignature(bool yesNo);
482 
489  bool isSasSignature();
490 
500  void setParanoidMode(bool yesNo);
501 
508  bool isParanoidMode();
509 
511  void printConfiguredAlgos(AlgoTypes algoTyp);
512 
513  private:
514   std::vector<AlgorithmEnum* > hashes;
515   std::vector<AlgorithmEnum* > symCiphers;
516   std::vector<AlgorithmEnum* > publicKeyAlgos;
517   std::vector<AlgorithmEnum* > sasTypes;
518   std::vector<AlgorithmEnum* > authLengths;
519 
520   bool enableTrustedMitM;
521   bool enableSasSignature;
522   bool enableParanoidMode;
523 
524 
525  AlgorithmEnum& getAlgoAt(std::vector<AlgorithmEnum* >& a, int32_t index);
526  int32_t addAlgo(std::vector<AlgorithmEnum* >& a, AlgorithmEnum& algo);
527  int32_t addAlgoAt(std::vector<AlgorithmEnum* >& a, AlgorithmEnum& algo, int32_t index);
528  int32_t removeAlgo(std::vector<AlgorithmEnum* >& a, AlgorithmEnum& algo);
529  int32_t getNumConfiguredAlgos(std::vector<AlgorithmEnum* >& a);
530  bool containsAlgo(std::vector<AlgorithmEnum* >& a, AlgorithmEnum& algo);
531  std::vector<AlgorithmEnum* >& getEnum(AlgoTypes algoType);
532 
533  void printConfiguredAlgos(std::vector<AlgorithmEnum* >& a);
534 
535  protected:
536 
537  public:
538 };
539 
543 #endif
544 
EnumBase::getOrdinal
int getOrdinal(AlgorithmEnum &algo)
Get the ordinal number of an AlgorithmEnum.
ZrtpConfigure
ZRTP configuration data.
Definition: ZrtpConfigure.h:312
EnumBase::algoType
AlgoTypes algoType
Definition: ZrtpConfigure.h:253
EnumBase::algos
std::vector< AlgorithmEnum * > algos
Definition: ZrtpConfigure.h:254
string.h
Common C++ generic string class.
AlgorithmEnum::getDecrypt
decrypt_t getDecrypt()
Get the algorihm's key length.
EnumBase::getByOrdinal
AlgorithmEnum & getByOrdinal(int ord)
Return the AlgorithmEnum by its ordinal number.
zrtpSymCiphers
SymCipherEnum zrtpSymCiphers
AlgorithmEnum::isValid
bool isValid()
Check if this AlgorithmEnum object is valid.
ZrtpConfigure::enableTrustedMitM
bool enableTrustedMitM
Definition: ZrtpConfigure.h:520
ZrtpConfigure::publicKeyAlgos
std::vector< AlgorithmEnum * > publicKeyAlgos
Definition: ZrtpConfigure.h:516
AlgorithmEnum::keyLen
int32_t keyLen
Definition: ZrtpConfigure.h:164
ZrtpConfigure::enableSasSignature
bool enableSasSignature
Definition: ZrtpConfigure.h:521
AlgorithmEnum::getAlgoId
SrtpAlgorithms getAlgoId()
Get the algorihm's integer id.
zrtpHashes
HashEnum zrtpHashes
AlgorithmEnum::getName
const char * getName()
Get the algorihm's name.
AlgorithmEnum::algoName
std::string algoName
Definition: ZrtpConfigure.h:163
HashEnum
The enumaration subclasses that contain the supported algorithm enumerations.
Definition: ZrtpConfigure.h:260
encrypt_t
void(* encrypt_t)(uint8_t *, int32_t, uint8_t *, uint8_t *, int32_t)
Definition: ZrtpConfigure.h:49
zrtpSasTypes
SasTypeEnum zrtpSasTypes
EnumBase::getByName
AlgorithmEnum & getByName(const char *name)
Get an AlgorithmEnum by its name.
ZrtpConfigure
struct ZrtpConfigure ZrtpConfigure
Definition: ZrtpCWrapper.h:262
EnumBase
EnumBase provides methods to store and access algorithm enumerations of a specific algorithm type...
Definition: ZrtpConfigure.h:185
zrtpPubKeys
PubKeyEnum zrtpPubKeys
AlgorithmEnum::encrypt
encrypt_t encrypt
Definition: ZrtpConfigure.h:166
ZrtpConfigure::hashes
std::vector< AlgorithmEnum * > hashes
Definition: ZrtpConfigure.h:514
ZrtpConfigure::symCiphers
std::vector< AlgorithmEnum * > symCiphers
Definition: ZrtpConfigure.h:515
EnumBase::insert
void insert(const char *name)
zrtpAuthLengths
AuthLengthEnum zrtpAuthLengths
ZrtpConfigure::authLengths
std::vector< AlgorithmEnum * > authLengths
Definition: ZrtpConfigure.h:518
EnumBase::getAlgoType
AlgoTypes getAlgoType()
Get the AlgoTypes to which this EnumBase belongs.
AlgorithmEnum::getReadable
const char * getReadable()
Get the algorihm's readable name.
ZrtpConfigure::enableParanoidMode
bool enableParanoidMode
Definition: ZrtpConfigure.h:522
SrtpAlgorithms
SrtpAlgorithms
The algorihms that we support in SRTP and that ZRTP can negotiate.
Definition: ZrtpCallback.h:66
AlgoTypes
AlgoTypes
This enumerations list all configurable algorithm types.
Definition: ZrtpConfigure.h:45
AlgorithmEnum::decrypt
decrypt_t decrypt
Definition: ZrtpConfigure.h:167
EnumBase::EnumBase
EnumBase(AlgoTypes algo)
decrypt_t
void(* decrypt_t)(uint8_t *, int32_t, const uint8_t *, uint8_t *, int32_t)
Definition: ZrtpConfigure.h:50
__EXPORT
#define __EXPORT
Definition: audio2.h:51
AlgorithmEnum::getKeylen
int getKeylen()
Get the algorihm's key length.
AlgorithmEnum::readable
std::string readable
Definition: ZrtpConfigure.h:165
AlgorithmEnum::getEncrypt
encrypt_t getEncrypt()
Get the algorihm's key length.
ZrtpCallback.h
Callback interface between ZRTP and the RTP stack implementation.
AlgorithmEnum::algoType
AlgoTypes algoType
Definition: ZrtpConfigure.h:162
AlgorithmEnum::getAlgoType
AlgoTypes getAlgoType()
Get the algorithm type of this AlgorithmEnum object.
AlgorithmEnum::algoId
SrtpAlgorithms algoId
Definition: ZrtpConfigure.h:168
ZrtpConfigure::sasTypes
std::vector< AlgorithmEnum * > sasTypes
Definition: ZrtpConfigure.h:517
EnumBase::getSize
int getSize()
Get the number of currently stored AlgorithmEnums.
AlgorithmEnum::~AlgorithmEnum
~AlgorithmEnum()
AlgorithmEnum destructor.
AlgorithmEnum::AlgorithmEnum
AlgorithmEnum(const AlgoTypes type, const char *name, int32_t klen, const char *ra, encrypt_t en, decrypt_t de, SrtpAlgorithms alId)
Create an AlgorithmEnum object.
AlgorithmEnum
The algorithm enumration class.
Definition: ZrtpConfigure.h:62
EnumBase::getAllNames
std::list< std::string > * getAllNames()
Return all names of all currently stored AlgorithmEnums.

Generated on Dec 21, 2017 for commoncpp2-1.8.1, ccrtp-1.7.2, libzrtpcpp-2.3.4, ccscript3-1.1.7, ccaudio2-1.0.0 and bayonne2-2.3.2 (after installation in /usr/local/) by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /