keyDerivation.h

Go to the documentation of this file.
00001 /*
00002  *  anytun
00003  *
00004  *  The secure anycast tunneling protocol (satp) defines a protocol used
00005  *  for communication between any combination of unicast and anycast
00006  *  tunnel endpoints.  It has less protocol overhead than IPSec in Tunnel
00007  *  mode and allows tunneling of every ETHER TYPE protocol (e.g.
00008  *  ethernet, ip, arp ...). satp directly includes cryptography and
00009  *  message authentication based on the methodes used by SRTP.  It is
00010  *  intended to deliver a generic, scaleable and secure solution for
00011  *  tunneling and relaying of packets of any protocol.
00012  *
00013  *
00014  *  Copyright (C) 2007 anytun.org <satp@wirdorange.org>
00015  *
00016  *  This program is free software; you can redistribute it and/or modify
00017  *  it under the terms of the GNU General Public License version 2
00018  *  as published by the Free Software Foundation.
00019  *
00020  *  This program is distributed in the hope that it will be useful,
00021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *  GNU General Public License for more details.
00024  *
00025  *  You should have received a copy of the GNU General Public License
00026  *  along with this program (see the file COPYING included with this
00027  *  distribution); if not, write to the Free Software Foundation, Inc.,
00028  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029  */
00030 
00031 #ifndef _KEYDERIVATION_H_
00032 #define _KEYDERIVATION_H_
00033 
00034 #include "datatypes.h"
00035 #include "buffer.h"
00036 
00037 #include <string>
00038 
00039 extern "C" {
00040   #include <srtp/crypto_kernel.h>
00041   #include <gcrypt.h>
00042 }
00043 
00044 
00045 typedef enum {
00046   label_satp_encryption  = 0x00,
00047   label_satp_msg_auth    = 0x01,
00048   label_satp_salt        = 0x02,
00049 } satp_prf_label;
00050 
00051 class KeyDerivation
00052 {
00053 public:
00054   KeyDerivation() : ld_kdr_(-1), cipher_(NULL) {};
00055   virtual ~KeyDerivation() {};
00056 
00057   void init(Buffer key, Buffer salt);
00058   err_status_t setLogKDRate(const uint8_t ld_rate);
00059   err_status_t generate(satp_prf_label label, seq_nr_t seq_nr, Buffer& key, uint32_t length);
00060   void clear();
00061 
00062   static const std::string MIN_GCRYPT_VERSION;
00063 
00064 protected:
00065   int8_t ld_kdr_;     // ld(key_derivation_rate)
00066   Buffer salt_;
00067 
00068   gcry_cipher_hd_t cipher_;
00069 };
00070 
00071 const std::string MIN_GCRYPT_VERSION = "1.2.3";
00072 
00073 #endif

Generated on Sun Oct 7 23:43:49 2007 for anytun by  doxygen 1.5.1