Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

idea.h

Go to the documentation of this file.
00001 /*_############################################################################
00002   _## 
00003   _##  idea.h  
00004   _##
00005   _##  SNMP++v3.2.15
00006   _##  -----------------------------------------------
00007   _##  Copyright (c) 2001-2004 Jochen Katz, Frank Fock
00008   _##
00009   _##  This software is based on SNMP++2.6 from Hewlett Packard:
00010   _##  
00011   _##    Copyright (c) 1996
00012   _##    Hewlett-Packard Company
00013   _##  
00014   _##  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
00015   _##  Permission to use, copy, modify, distribute and/or sell this software 
00016   _##  and/or its documentation is hereby granted without fee. User agrees 
00017   _##  to display the above copyright notice and this license notice in all 
00018   _##  copies of the software and any documentation of the software. User 
00019   _##  agrees to assume all liability for the use of the software; 
00020   _##  Hewlett-Packard and Jochen Katz make no representations about the 
00021   _##  suitability of this software for any purpose. It is provided 
00022   _##  "AS-IS" without warranty of any kind, either express or implied. User 
00023   _##  hereby grants a royalty-free license to any and all derivatives based
00024   _##  upon this software code base. 
00025   _##  
00026   _##  Stuttgart, Germany, Tue Jan  4 21:42:42 CET 2005 
00027   _##  
00028   _##########################################################################*/
00029 // $Id: idea.h,v 1.4 2004/03/03 23:11:21 katz Exp $
00030 
00031 /*
00032 
00033 idea.h
00034 
00035 Author: Tatu Ylonen <ylo@cs.hut.fi>
00036 
00037 Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
00038                    All rights reserved
00039 
00040 Created: Sun Jun 25 04:44:30 1995 ylo
00041 
00042 The IDEA encryption algorithm.
00043 
00044 */
00045 
00046 #ifndef IDEA_H
00047 #define IDEA_H
00048 
00049 #include "snmp_pp/config_snmp_pp.h"
00050 
00051 #ifdef SNMP_PP_NAMESPACE
00052 namespace Snmp_pp {
00053 #endif
00054 
00055 #ifdef _USE_IDEA
00056 
00057 typedef unsigned short word16;
00058 typedef unsigned int word32;
00059 
00060 typedef struct
00061 {
00062   word16 key_schedule[52];
00063 } IDEAContext;
00064 
00065 /* Sets idea key for encryption. */
00066 void idea_set_key(IDEAContext *c, const unsigned char key[16]);
00067 
00068 /* Destroys any sensitive data in the context. */
00069 void idea_destroy_context(IDEAContext *c);
00070 
00071 /* Performs the IDEA cipher transform on a block of data. */
00072 void idea_transform(IDEAContext *c, word32 l, word32 r, word32 *output);
00073 
00074 /* Encrypts len bytes from src to dest in CFB mode.  Len need not be a multiple
00075    of 8; if it is not, iv at return will contain garbage.
00076    Otherwise, iv will be modified at end to a value suitable for continuing
00077    encryption. */
00078 void idea_cfb_encrypt(IDEAContext *c, unsigned char *iv, unsigned char *dest,
00079                       const unsigned char *src, unsigned int len);
00080 
00081 
00082 /* Decrypts len bytes from src to dest in CFB mode.  Len need not be a multiple
00083    of 8; if it is not, iv at return will contain garbage.
00084    Otherwise, iv will be modified at end to a value suitable for continuing
00085    decryption. */
00086 void idea_cfb_decrypt(IDEAContext *c, unsigned char *iv, unsigned char *dest,
00087                       const unsigned char *src, unsigned int len);
00088 
00089 #endif /* IDEA_H */
00090 #endif /* _USE_IDEA */
00091 
00092 #ifdef SNMP_PP_NAMESPACE
00093 }; // end of namespace Snmp_pp
00094 #endif 
00095 
00096 /*
00097 
00098 getput.h
00099 
00100 Author: Tatu Ylonen <ylo@cs.hut.fi>
00101 
00102 Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
00103                    All rights reserved
00104 
00105 Created: Wed Jun 28 22:36:30 1995 ylo
00106 
00107 Macros for storing and retrieving data in msb first and lsb first order.
00108 
00109 */
00110 
00111 #ifdef SNMP_PP_NAMESPACE
00112 namespace Snmp_pp {
00113 #endif
00114 
00115 #ifndef GETPUT_H
00116 #define GETPUT_H
00117 
00118 /*------------ macros for storing/extracting msb first words -------------*/
00119 
00120 #define GET_32BIT(cp) (((unsigned long)(unsigned char)(cp)[0] << 24) | \
00121                        ((unsigned long)(unsigned char)(cp)[1] << 16) | \
00122                        ((unsigned long)(unsigned char)(cp)[2] << 8) | \
00123                        ((unsigned long)(unsigned char)(cp)[3]))
00124 
00125 #define GET_16BIT(cp) (((unsigned long)(unsigned char)(cp)[0] << 8) | \
00126                        ((unsigned long)(unsigned char)(cp)[1]))
00127 
00128 #define PUT_32BIT(cp, value) do { \
00129   (cp)[0] = (value) >> 24; \
00130   (cp)[1] = (value) >> 16; \
00131   (cp)[2] = (value) >> 8; \
00132   (cp)[3] = (value); } while (0)
00133 
00134 #define PUT_16BIT(cp, value) do { \
00135   (cp)[0] = (value) >> 8; \
00136   (cp)[1] = (value); } while (0)
00137 
00138 /*------------ macros for storing/extracting lsb first words -------------*/
00139 
00140 #define GET_32BIT_LSB_FIRST(cp) \
00141   (((unsigned long)(unsigned char)(cp)[0]) | \
00142   ((unsigned long)(unsigned char)(cp)[1] << 8) | \
00143   ((unsigned long)(unsigned char)(cp)[2] << 16) | \
00144   ((unsigned long)(unsigned char)(cp)[3] << 24))
00145 
00146 #define GET_16BIT_LSB_FIRST(cp) \
00147   (((unsigned long)(unsigned char)(cp)[0]) | \
00148   ((unsigned long)(unsigned char)(cp)[1] << 8))
00149 
00150 #define PUT_32BIT_LSB_FIRST(cp, value) do { \
00151   (cp)[0] = (value); \
00152   (cp)[1] = (value) >> 8; \
00153   (cp)[2] = (value) >> 16; \
00154   (cp)[3] = (value) >> 24; } while (0)
00155 
00156 #define PUT_16BIT_LSB_FIRST(cp, value) do { \
00157   (cp)[0] = (value); \
00158   (cp)[1] = (value) >> 8; } while (0)
00159 
00160 #ifdef SNMP_PP_NAMESPACE
00161 }; // end of namespace Snmp_pp
00162 #endif 
00163 
00164 #endif /* GETPUT_H */
00165 

Generated on Tue Jan 4 22:42:13 2005 for SNMP++ by doxygen 1.3.2