Mixe for Privacy and Anonymity in the Internet
CASymChannelCipherFactory.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2000, The JAP-Team
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6 
7  - Redistributions of source code must retain the above copyright notice,
8  this list of conditions and the following disclaimer.
9 
10  - Redistributions in binary form must reproduce the above copyright
11 notice,
12  this list of conditions and the following disclaimer in the
13 documentation and/or
14  other materials provided with the distribution.
15 
16  - Neither the name of the University of Technology Dresden, Germany nor
17 the names of its contributors
18  may be used to endorse or promote products derived from this software
19 without specific
20  prior written permission.
21 
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
24 AND ANY EXPRESS
25 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 MERCHANTABILITY
27 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 REGENTS OR CONTRIBUTORS
29 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 CONSEQUENTIAL DAMAGES
31 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA,
33 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 LIABILITY, WHETHER
35 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 ARISING IN ANY WAY
37 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
38 DAMAGE
39 */
40 #ifndef __CAASYMCHANNELCIPHERFACTORY__
41 #define __CAASYMCHANNELCIPHERFACTROY__
42 #include "CASymChannelCipher.hpp"
43 #include "CASymCipherCTR.hpp"
44 #include "CASymCipherOFB.hpp"
45 #include "CASymCipherNull.hpp"
47  {
48  public:
50  {
51  switch (alg)
52  {
53  case OFB:
54  return new CASymCipherOFB();
55  case CTR:
56  return new CASymCipherCTR();
57  case NULL_CIPHER:
58 #ifdef DEBUG
59  CAMsg::printMsg(LOG_DEBUG, "Creating NULL-cipher for channel encryption!\n");
60 #endif
61  return new CASymCipherNull();
62  case UNDEFINED_CIPHER:
63  return NULL;
64  }
65  return NULL;
66  }
67 
69  {
70  if (strAlgID == NULL)
71  return UNDEFINED_CIPHER;
72  if (strcmp((const char*)SYMCHANNELCIPHER_ALG_NAME_OFB, (const char*)strAlgID) == 0)
73  {
74  return OFB;
75  }
76  if (strcmp((const char*)SYMCHANNELCIPHER_ALG_NAME_CTR, (const char*)strAlgID) == 0)
77  {
78  return CTR;
79  }
80  if (strcmp((const char*)SYMCHANNELCIPHER_ALG_NAME_NULL, (const char*)strAlgID) == 0)
81  {
82  return NULL_CIPHER;
83  }
84  return UNDEFINED_CIPHER;
85 
86  }
87  };
88 
89 
90 #endif //__CASYMCHANNELCIPHERFACTORY__
SYMCHANNELCIPHER_ALGORITHM
@ NULL_CIPHER
@ UNDEFINED_CIPHER
const UINT8 *const SYMCHANNELCIPHER_ALG_NAME_OFB
const UINT8 *const SYMCHANNELCIPHER_ALG_NAME_NULL
const UINT8 *const SYMCHANNELCIPHER_ALG_NAME_CTR
unsigned char UINT8
Definition: basetypedefs.h:135
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
Definition: CAMsg.cpp:251
static SYMCHANNELCIPHER_ALGORITHM getAlgIDFromString(UINT8 *strAlgID)
static CASymChannelCipher * createCipher(SYMCHANNELCIPHER_ALGORITHM alg)
This class could be used for encryption/decryption of data (streams) with AES using 128bit CTR mode.
This class implemtns the symmetric channel cipher interface - but does not do eny encryption!...
This class could be used for encryption/decryption of data (streams) with AES using 128bit OFB mode.