KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CryptoSystem.h
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 For Further Information Please Contact me at
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
29 
30 /********************************************************************
31  class: CryptoSystem
32  created: 2008/10/22
33  author: Karl Jones
34 
35  purpose: Stores details about a transmitters crypto system
36  size: 32 bits / 4 octets
37 *********************************************************************/
38 
39 #pragma once
40 
41 #include "./DataTypeBase.h"
42 
43 namespace KDIS {
44 namespace DATA_TYPE {
45 
47 {
48 protected:
49 
51 
52  union
53  {
54  struct
55  {
56  KUINT16 m_ui16EncryptionMode : 1;
57  KUINT16 m_ui16KeyID : 15;
58  };
59 
61  };
62 
63 public:
64 
65  static const KUINT16 CRYPTO_SYSTEM_SIZE = 4;
66 
67  CryptoSystem();
68 
69  CryptoSystem( KDataStream & stream )throw( KException );
70 
72 
73  virtual ~CryptoSystem();
74 
75  //************************************
76  // FullName: KDIS::DATA_TYPE::CryptoSystem::SetCryptoSystemType
77  // KDIS::DATA_TYPE::CryptoSystem::GetCryptoSystemType
78  //!Description: Equipment being used.
79  // Parameter: CryptoSystemType T
80  //************************************
81  void SetCryptoSystemType( KDIS::DATA_TYPE::ENUMS::CryptoSystemType T );
82  KDIS::DATA_TYPE::ENUMS::CryptoSystemType GetCryptoSystemType() const;
83 
84  //************************************
85  // FullName: KDIS::DATA_TYPE::CryptoSystem::SetEncryptionMode
86  // KDIS::DATA_TYPE::CryptoSystem::GetEncryptionMode
87  //!Description: Mode being used to encrypt the data.
88  // Parameter: EncryptionMode EM
89  //************************************
90  void SetEncryptionMode( KDIS::DATA_TYPE::ENUMS::EncryptionMode EM );
91  KDIS::DATA_TYPE::ENUMS::EncryptionMode GetEncryptionMode() const;
92 
93  //************************************
94  // FullName: KDIS::DATA_TYPE::CryptoSystem::SetKeyID
95  // KDIS::DATA_TYPE::CryptoSystem::GetKeyID
96  //!Description: Mode being used to encrypt the data.
97  // Parameter: EncryptionMode EM
98  //************************************
99  void SetKeyID( KUINT16 KeyID );
100  KUINT16 GetKeyID() const;
101 
102  //************************************
103  // FullName: KDIS::DATA_TYPE::CryptoSystem::SetKey
104  // KDIS::DATA_TYPE::CryptoSystem::GetKey
105  //!Description: Key. Not an actual crypto key, if the key
106  //! from the sender is the same as the key of the
107  //! receiver then they are considered to be using the
108  //! same key.
109  // Parameter: KUINT16 EM
110  //************************************
111  void SetKey( KUINT16 K );
112  KUINT16 GetKey() const;
113 
114  //************************************
115  // FullName: KDIS::DATA_TYPE::CryptoSystem::GetAsString
116  //!Description: Returns a string representation
117  //************************************
118  virtual KString GetAsString() const;
119 
120  //************************************
121  // FullName: KDIS::DATA_TYPE::CryptoSystem::Decode
122  //!Description: Convert From Network Data.
123  // Parameter: KDataStream & stream
124  //************************************
125  virtual void Decode( KDataStream & stream ) throw( KException );
126 
127  //************************************
128  // FullName: KDIS::DATA_TYPE::CryptoSystem::Encode
129  //!Description: Convert To Network Data.
130  // Parameter: KDataStream & stream
131  //************************************
132  virtual KDataStream Encode() const;
133  virtual void Encode( KDataStream & stream ) const;
134 
135  KBOOL operator == ( const CryptoSystem & Value ) const;
136  KBOOL operator != ( const CryptoSystem & Value ) const;
137 };
138 
139 } // END namespace DATA_TYPES
140 } // END namespace KDIS
unsigned short int KUINT16
Definition: KDefines.h:101
KUINT16 m_ui16CryptoSystemType
Definition: CryptoSystem.h:50
KUINT16 m_ui16CryptoKey
Definition: CryptoSystem.h:60
Definition: KDefines.h:182
Definition: KDataStream.h:48
Definition: DataTypeBase.h:49
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
Definition: CryptoSystem.h:46
#define KDIS_EXPORT
Definition: KDefines.h:82
EncryptionMode
Definition: EnumRadio.h:285
CryptoSystemType
Definition: EnumRadio.h:264