Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

message.h

Go to the documentation of this file.
00001 /*
00002  *  message.h  -  functions to generate / parse all msg'es
00003  *  
00004  *  EAP-IKEv2
00005  *
00006  *  This library implements ideas of draft-tschofenig-eap-ikev2-10.txt
00007  *  Internet-Draft. Version of the document that this library corresponds
00008  *  to you can find at
00009  *  http://tools.ietf.org/wg/eap/draft-tschofenig-eap-ikev2-10.txt.
00010  *
00011  *  This file is part of libeap-ikev2.
00012  *
00013  *  libeap-ikev2 is free software; you can redistribute it and/or modify
00014  *  it under the terms of the GNU General Public License as published by
00015  *  the Free Software Foundation; either version 2 of the License, or
00016  *  (at your option) any later version.
00017  *
00018  *  libeap-ikev2 is distributed in the hope that it will be useful,
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *  GNU General Public License for more details.
00022  *
00023  *  You should have received a copy of the GNU General Public License
00024  *  along with libeap-ikev2; if not, write to the Free Software
00025  *
00026  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  *  Copyright (C) 2005-2006 Krzysztof Rzecki <krzysztof.rzecki@ccns.pl>      
00029  *  Copyright (C) 2005-2006 Rafal Mijal <rafal.mijal@ccns.pl>                
00030  *  Copyright (C) 2005-2006 Piotr Marnik <piotr.marnik@ccns.pl>              
00031  *  Copyright (C) 2005-2006 Pawel Matejski <pawel.matejski@ccns.pl>          
00032  *  Copyright (C) 2003      Udo Schilcher <udo.schilcher@edu.uni-klu.ac.at>
00033  *  Copyright (C) 2003      Thomas Hambrusch <thambrus@edu.uni-klu.ac.at>          
00034  *
00035  */
00036 
00037 #ifndef __message_h
00038 #define __message_h
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 #include"common.h"
00045 
00046 #include"session.h"
00047 
00048 
00049 // Version of IKE 
00050 #define IKEv2_MAJOR_VERSION 2
00051 #define IKEv2_MINOR_VERSION 0
00052 
00053 
00054 #define NONCE_LEN 128         // should be variable???
00055 #define TB_SIZE  4092
00056 
00057 
00058 // Exchange types
00059 #define IKEv2_EXT_IKE_SA_INIT       34
00060 #define IKEv2_EXT_IKE_AUTH          35
00061 #define IKEv2_EXT_CREATE_CHILD_SA   36
00062 #define IKEv2_EXT_INFORMATIONAL     37
00063 
00064 // Header Flags
00065 #define IKEv2_HDF_INITIATOR   (1<<3)
00066 #define IKEv2_HDF_VERSION     (1<<4)
00067 #define IKEv2_HDF_RESPONSE    (1<<5)
00068 
00069 // structures
00070 
00074 struct CertList
00075 {
00076   struct CertList *next;  
00077   uint8_t *cdata;         
00078   uint32_t cdlen;         
00079   uint8_t ctype;          
00080 };
00081 
00089 struct ParseMsgResult
00090 {
00091   struct Proposal *SA;     
00092   BIGNUM *KE;              
00093   uint16_t DHGroup;        
00094   BIGNUM *Nonce;           
00095   uint8_t *IDiData;        
00096   uint16_t IDiLen;         
00097   uint8_t *IDrData;        
00098   uint16_t IDrLen;         
00099   uint8_t *authData;       
00100   uint32_t adlen;          
00101   uint8_t authMeth;        
00102 
00103 
00104 
00105   struct CertList *cert;   
00106 
00107   uint8_t enc;             
00108   uint8_t failed;          
00109 
00110   uint8_t error;           
00111   uint8_t unsuppCritPl;    
00112   uint8_t plType;          
00113   uint8_t Authfailed;      
00114   uint8_t NoPropAcceptable;
00115   uint8_t KEInvalid;       
00116   uint16_t ChosenDHGroup;  
00117 };
00118 
00141 struct IKEv2Header
00142 {
00143   uint64_t InitiatorSPI;
00144   uint64_t ResponderSPI;
00145   uint8_t NextPayload;
00146   union
00147   {
00148     struct
00149     {
00150       uint8_t MjVersion:4;
00151       uint8_t MnVersion:4;
00152     }__attribute__((packed));
00153     uint8_t Version;
00154   }__attribute__((packed));
00155   uint8_t ExchangeType;
00156   uint8_t Flags;
00157   uint32_t MessageID;
00158   uint32_t Length;
00159 }__attribute__((packed));
00160 
00161 // function prototypes
00162 
00163 int IKEv2IBuild_SA_Init( const struct ikev2_ctx *i2, uint8_t **out, uint32_t *olen, struct IKEv2Session *session, uint16_t DHGroup );
00164 int IKEv2RBuild_SA_Init( const struct ikev2_ctx *i2, uint8_t *oldMsg, uint8_t **out, uint32_t *olen,
00165     struct Proposal *selTrans, struct IKEv2Session *session, BIGNUM *pubk );
00166 int IKEv2IBuild_Auth( const struct ikev2_ctx *i2, uint8_t **out, uint32_t *olen, struct IKEv2Session *session );
00167 int IKEv2RBuild_Auth( const struct ikev2_ctx *i2, uint8_t **out, uint32_t *olen, uint8_t *in, struct IKEv2Session *session );
00168 int IKEv2Build_Informational( uint8_t **out, uint32_t *olen, struct IKEv2Session *session,
00169     uint8_t first, uint8_t *payloads, uint32_t plsize );
00170 int IKEv2RespondInformational( uint8_t **out, uint32_t *olen, uint8_t *inf );
00171 #if 0
00172 int IKEv2BuildEndSession( uint8_t **out, uint32_t *olen, struct IKEv2Session *session, uint64_t SPI );
00173 #endif
00174 int IKEv2BuildErrorMsg( uint8_t **out, uint32_t *olen, struct IKEv2Session *session,
00175     struct ParseMsgResult *res );
00176 int IKEv2BuildErrorResponseMsg( uint8_t **out, uint32_t *olen, uint8_t *in, struct ParseMsgResult *res,
00177     struct IKEv2Session *session, int enc );
00178 int IKEv2ICreateChildSA( const struct ikev2_ctx *i2, uint8_t **out, uint32_t *olen, struct IKEv2Session *session, int DHGroup );
00179 int IKEv2RCreateChildSA( uint8_t *oldMsg, uint8_t **out, uint32_t *olen, struct IKEv2Session *session,
00180     struct Proposal *selTrans, int DHGroup );
00181 
00182 struct ParseMsgResult *ParseSAInitMsg( const struct ikev2_ctx *i2, struct IKEv2Session *session, uint8_t *p );
00183 struct ParseMsgResult *ParseAuthMsg( const struct ikev2_ctx *i2, struct IKEv2Session *session, uint8_t *p );
00184 struct ParseMsgResult *ParseInformationalMsg( const struct ikev2_ctx *i2, struct IKEv2Session *session, uint8_t *p );
00185 struct ParseMsgResult *ParseChildSAMsg( const struct ikev2_ctx *i2, struct IKEv2Session *session, uint8_t *p );
00186 void FreeMsgResult(struct ParseMsgResult *res);
00187 
00188 #ifdef __cplusplus
00189 }
00190 #endif
00191 
00192 #endif

Project hosted by: SourceForge.net Logo