1 /*_############################################################################
6 _## -----------------------------------------------
7 _## Copyright (c) 2001-2010 Jochen Katz, Frank Fock
9 _## This software is based on SNMP++2.6 from Hewlett Packard:
11 _## Copyright (c) 1996
12 _## Hewlett-Packard Company
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.
26 _## Stuttgart, Germany, Thu Sep 2 00:07:47 CEST 2010
28 _##########################################################################*/
29 // $Id: idea.h 1791 2010-07-26 19:41:54Z katz $
35 Author: Tatu Ylonen <ylo@cs.hut.fi>
37 Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
40 Created: Sun Jun 25 04:44:30 1995 ylo
42 The IDEA encryption algorithm.
49 #include "snmp_pp/config_snmp_pp.h"
51 #ifdef SNMP_PP_NAMESPACE
57 typedef unsigned short word16;
58 typedef unsigned int word32;
62 word16 key_schedule[52];
65 /* Sets idea key for encryption. */
66 void idea_set_key(IDEAContext *c, const unsigned char key[16]);
68 /* Destroys any sensitive data in the context. */
69 void idea_destroy_context(IDEAContext *c);
71 /* Performs the IDEA cipher transform on a block of data. */
72 void idea_transform(IDEAContext *c, word32 l, word32 r, word32 *output);
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
78 void idea_cfb_encrypt(IDEAContext *c, unsigned char *iv, unsigned char *dest,
79 const unsigned char *src, unsigned int len);
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
86 void idea_cfb_decrypt(IDEAContext *c, unsigned char *iv, unsigned char *dest,
87 const unsigned char *src, unsigned int len);
90 #endif /* _USE_IDEA */
92 #ifdef SNMP_PP_NAMESPACE
93 } // end of namespace Snmp_pp
100 Author: Tatu Ylonen <ylo@cs.hut.fi>
102 Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
105 Created: Wed Jun 28 22:36:30 1995 ylo
107 Macros for storing and retrieving data in msb first and lsb first order.
111 #ifdef SNMP_PP_NAMESPACE
120 /*------------ macros for storing/extracting msb first words -------------*/
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]))
127 #define GET_16BIT(cp) (((unsigned long)(unsigned char)(cp)[0] << 8) | \
128 ((unsigned long)(unsigned char)(cp)[1]))
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)
136 #define PUT_16BIT(cp, value) do { \
137 (cp)[0] = (value) >> 8; \
138 (cp)[1] = (value); } while (0)
140 /*------------ macros for storing/extracting lsb first words -------------*/
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))
148 #define GET_16BIT_LSB_FIRST(cp) \
149 (((unsigned long)(unsigned char)(cp)[0]) | \
150 ((unsigned long)(unsigned char)(cp)[1] << 8))
152 #define PUT_32BIT_LSB_FIRST(cp, value) do { \
154 (cp)[1] = (value) >> 8; \
155 (cp)[2] = (value) >> 16; \
156 (cp)[3] = (value) >> 24; } while (0)
158 #define PUT_16BIT_LSB_FIRST(cp, value) do { \
160 (cp)[1] = (value) >> 8; } while (0)
164 #ifdef SNMP_PP_NAMESPACE
165 } // end of namespace Snmp_pp
168 #endif /* GETPUT_H */