EnOcean Link  1.14.0.0
Middleware to Connect EnOcean easily to other Projects
eoSecurity.h
Go to the documentation of this file.
1 /******************************************************************************
2  DISCLAIMER
3 
4  THIS SOFTWARE PRODUCT ("SOFTWARE") IS PROPRIETARY TO ENOCEAN GMBH, OBERHACHING,
5  GERMANY (THE "OWNER") AND IS PROTECTED BY COPYRIGHT AND INTERNATIONAL TREATIES OR
6  PROTECTED AS TRADE SECRET OR AS OTHER INTELLECTUAL PROPERTY RIGHT. ALL RIGHTS, TITLE AND
7  INTEREST IN AND TO THE SOFTWARE, INCLUDING ANY COPYRIGHT, TRADE SECRET OR ANY OTHER
8  INTELLECTUAL PROPERTY EMBODIED IN THE SOFTWARE, AND ANY RIGHTS TO REPRODUCE,
9  DISTRIBUTE, MODIFY, DISPLAY OR OTHERWISE USE THE SOFTWARE SHALL EXCLUSIVELY VEST IN THE
10  OWNER. ANY UNAUTHORIZED REPRODUCTION, DISTRIBUTION, MODIFICATION, DISPLAY OR OTHER
11  USE OF THE SOFTWARE WITHOUT THE EXPLICIT PERMISSION OF OWNER IS PROHIBITED AND WILL
12  CONSTITUTE AN INFRINGEMENT OF THE OWNER'S RIGHT AND MAY BE SUBJECT TO CIVIL OR
13  CRIMINAL SANCTION.
14 
15  THIS SOFTWARE IS PROVIDED BY THE OWNER "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
17  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN PARTICULAR, THE OWNER DOES NOT WARRANT
18  THAT THE SOFTWARE SHALL BE ERROR FREE AND WORKS WITHOUT INTERRUPTION.
19 
20  IN NO EVENT SHALL THE OWNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  ******************************************************************************/
27 
33 #ifndef EO_SECURITY_H_
34 #define EO_SECURITY_H_
35 #include "eoMessage.h"
36 #include "eoMaintenanceMessage.h"
37 #include "eoDevice.h"
38 #include "api/sec.h"
39 #include "api/sec_api.h"
40 
41 #define AES_KEY_SIZE 16
42 
54 {
55 private:
56  MESSAGE_TYPE msg;
57  MESSAGE_TYPE msgTmp;
58  SECU_TYPE info;
59 
60  SEC_RESULT lastResult;
61 
62 public:
63  eoSecurity();
64  virtual ~eoSecurity();
65 
72  static void SetKey(uint8_t key[16], eoSecureInfo &info);
94  eoReturn Decrypt(const eoMessage &msgSec, eoMessage &msgNonSec, eoDevice &dev);
102  eoReturn Encrypt(const eoMessage &msgNonSec, eoMessage &msgSec, eoDevice &dev);
110  eoReturn Encrypt(const eoMaintenanceMessage &msgNonSec, eoMaintenanceMessage &msgSec, eoDevice &dev);
118  eoReturn Decrypt(const eoMaintenanceMessage &msgSec, eoMaintenanceMessage &msgNonSec, eoDevice &dev);
119 
120 
125  SEC_RESULT GetLastError();
126 
127 private:
129  void prepareInfoMaintenance();
130  static eoReturn MessageToType(eoMessage const &msg, MESSAGE_TYPE &mt);
131  static eoReturn TypeToMessage(MESSAGE_TYPE const &mt, eoMessage &msg);
132  static eoReturn TypeToSecuInfo(SECU_TYPE const &it, eoSecureInfo &info);
133  static eoReturn SecuInfoToType(eoSecureInfo const &info, SECU_TYPE &it) ;
134 
135 };
136 #endif // !defined(EA_C4479453_0471_4430_829A_098DBBFB613D__INCLUDED_)
eoReturn ParseTeachIn(eoMessage &msgTi, eoDevice &dev)
eoReturn CreateTeachIn(eoMessage &msgTi, eoDevice &dev)
a class to describe an EnOcean Device
Definition: eoDevice.h:49
Message Class for communication.
Definition: eoMessage.h:47
The maintenance message class, these messages represent an EnOcean maintenance message.
Definition: eoMaintenanceMessage.h:56
Definition: eoSecureInfo.h:100
eoReturn Encrypt(const eoMessage &msgNonSec, eoMessage &msgSec, eoDevice &dev)
eoReturn
contains all the return values from different functions
Definition: eoApiDef.h:40
handles EnOcean Security Telegrams
Definition: eoSecurity.h:53
static void SetKey(uint8_t key[16], eoSecureInfo &info)
eoDevice
SEC_RESULT GetLastError()
eoReturn Decrypt(const eoMessage &msgSec, eoMessage &msgNonSec, eoDevice &dev)