]> git.stg.codes - ssmd.git/blob - 3rdparty/snmp++/include/snmp_pp/idea.h
Initial adding
[ssmd.git] / 3rdparty / snmp++ / include / snmp_pp / idea.h
1 /*_############################################################################
2   _## 
3   _##  idea.h  
4   _##
5   _##  SNMP++v3.2.25
6   _##  -----------------------------------------------
7   _##  Copyright (c) 2001-2010 Jochen Katz, Frank Fock
8   _##
9   _##  This software is based on SNMP++2.6 from Hewlett Packard:
10   _##  
11   _##    Copyright (c) 1996
12   _##    Hewlett-Packard Company
13   _##  
14   _##  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
15   _##  Permission to use, copy, modify, distribute and/or sell this software 
16   _##  and/or its documentation is hereby granted without fee. User agrees 
17   _##  to display the above copyright notice and this license notice in all 
18   _##  copies of the software and any documentation of the software. User 
19   _##  agrees to assume all liability for the use of the software; 
20   _##  Hewlett-Packard and Jochen Katz make no representations about the 
21   _##  suitability of this software for any purpose. It is provided 
22   _##  "AS-IS" without warranty of any kind, either express or implied. User 
23   _##  hereby grants a royalty-free license to any and all derivatives based
24   _##  upon this software code base. 
25   _##  
26   _##  Stuttgart, Germany, Thu Sep  2 00:07:47 CEST 2010 
27   _##  
28   _##########################################################################*/
29 // $Id: idea.h 1791 2010-07-26 19:41:54Z katz $
30
31 /*
32
33 idea.h
34
35 Author: Tatu Ylonen <ylo@cs.hut.fi>
36
37 Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
38                    All rights reserved
39
40 Created: Sun Jun 25 04:44:30 1995 ylo
41
42 The IDEA encryption algorithm.
43
44 */
45
46 #ifndef IDEA_H
47 #define IDEA_H
48
49 #include "snmp_pp/config_snmp_pp.h"
50
51 #ifdef SNMP_PP_NAMESPACE
52 namespace Snmp_pp {
53 #endif
54
55 #ifdef _USE_IDEA
56
57 typedef unsigned short word16;
58 typedef unsigned int word32;
59
60 typedef struct
61 {
62   word16 key_schedule[52];
63 } IDEAContext;
64
65 /* Sets idea key for encryption. */
66 void idea_set_key(IDEAContext *c, const unsigned char key[16]);
67
68 /* Destroys any sensitive data in the context. */
69 void idea_destroy_context(IDEAContext *c);
70
71 /* Performs the IDEA cipher transform on a block of data. */
72 void idea_transform(IDEAContext *c, word32 l, word32 r, word32 *output);
73
74 /* Encrypts len bytes from src to dest in CFB mode.  Len need not be a multiple
75    of 8; if it is not, iv at return will contain garbage.
76    Otherwise, iv will be modified at end to a value suitable for continuing
77    encryption. */
78 void idea_cfb_encrypt(IDEAContext *c, unsigned char *iv, unsigned char *dest,
79                       const unsigned char *src, unsigned int len);
80
81
82 /* Decrypts len bytes from src to dest in CFB mode.  Len need not be a multiple
83    of 8; if it is not, iv at return will contain garbage.
84    Otherwise, iv will be modified at end to a value suitable for continuing
85    decryption. */
86 void idea_cfb_decrypt(IDEAContext *c, unsigned char *iv, unsigned char *dest,
87                       const unsigned char *src, unsigned int len);
88
89 #endif /* IDEA_H */
90 #endif /* _USE_IDEA */
91
92 #ifdef SNMP_PP_NAMESPACE
93 } // end of namespace Snmp_pp
94 #endif 
95
96 /*
97
98 getput.h
99
100 Author: Tatu Ylonen <ylo@cs.hut.fi>
101
102 Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
103                    All rights reserved
104
105 Created: Wed Jun 28 22:36:30 1995 ylo
106
107 Macros for storing and retrieving data in msb first and lsb first order.
108
109 */
110
111 #ifdef SNMP_PP_NAMESPACE
112 namespace Snmp_pp {
113 #endif
114
115 #ifndef GETPUT_H
116 #define GETPUT_H
117
118 #ifdef _USE_IDEA
119
120 /*------------ macros for storing/extracting msb first words -------------*/
121
122 #define GET_32BIT(cp) (((unsigned long)(unsigned char)(cp)[0] << 24) | \
123                        ((unsigned long)(unsigned char)(cp)[1] << 16) | \
124                        ((unsigned long)(unsigned char)(cp)[2] << 8) | \
125                        ((unsigned long)(unsigned char)(cp)[3]))
126
127 #define GET_16BIT(cp) (((unsigned long)(unsigned char)(cp)[0] << 8) | \
128                        ((unsigned long)(unsigned char)(cp)[1]))
129
130 #define PUT_32BIT(cp, value) do { \
131   (cp)[0] = (value) >> 24; \
132   (cp)[1] = (value) >> 16; \
133   (cp)[2] = (value) >> 8; \
134   (cp)[3] = (value); } while (0)
135
136 #define PUT_16BIT(cp, value) do { \
137   (cp)[0] = (value) >> 8; \
138   (cp)[1] = (value); } while (0)
139
140 /*------------ macros for storing/extracting lsb first words -------------*/
141
142 #define GET_32BIT_LSB_FIRST(cp) \
143   (((unsigned long)(unsigned char)(cp)[0]) | \
144   ((unsigned long)(unsigned char)(cp)[1] << 8) | \
145   ((unsigned long)(unsigned char)(cp)[2] << 16) | \
146   ((unsigned long)(unsigned char)(cp)[3] << 24))
147
148 #define GET_16BIT_LSB_FIRST(cp) \
149   (((unsigned long)(unsigned char)(cp)[0]) | \
150   ((unsigned long)(unsigned char)(cp)[1] << 8))
151
152 #define PUT_32BIT_LSB_FIRST(cp, value) do { \
153   (cp)[0] = (value); \
154   (cp)[1] = (value) >> 8; \
155   (cp)[2] = (value) >> 16; \
156   (cp)[3] = (value) >> 24; } while (0)
157
158 #define PUT_16BIT_LSB_FIRST(cp, value) do { \
159   (cp)[0] = (value); \
160   (cp)[1] = (value) >> 8; } while (0)
161
162 #endif // _USE_IDEA
163
164 #ifdef SNMP_PP_NAMESPACE
165 } // end of namespace Snmp_pp
166 #endif 
167
168 #endif /* GETPUT_H */
169