/home/aherms/Code/git/awds-routing/src/crypto/AesCcmCryptoUnit.h

00001 #ifndef _AESCCMCRYPTOUNIT_H__
00002 #define _AESCCMCRYPTOUNIT_H__
00003 
00004 #include "CryptoUnit.h"
00005 #include <map>
00006 
00007 #include <awds/NodeId.h>
00008 #include <sys/types.h>
00009 
00010 namespace awds {
00011 
00015 class AesCcmCryptoUnit : public awds::CryptoUnit {
00016     
00017     static const size_t IV_len = 1;
00018     
00019     unsigned char key[16];
00020     
00021     unsigned char nonce[16];
00022     
00023     u_int64_t lastIv;
00024     
00025     typedef std::map<NodeId, u_int64_t> IvMap;
00026     IvMap ivMap;
00027     
00028 public:
00029     AesCcmCryptoUnit();
00030     
00031     virtual void encrypt(void *data, size_t data_len, const MemoryBlock sg[]);
00032     bool decrypt(void *data, size_t data_len, const MemoryBlock sg[]);
00033     
00034     virtual bool decryptDupDetect(const NodeId& src, void *data, size_t data_len, const MemoryBlock sg[]);
00035     
00036     void setKey(void *key);
00037     
00038     
00043     virtual void sign(void *data, size_t data_len, const MemoryBlock sg[]);
00044         
00045     virtual bool verifySignature(const NodeId& src, void *data, size_t data_len, const MemoryBlock sg[]);
00046     
00047     void test();
00048     
00049 protected:
00050     
00051     void storeNonce(void *data);
00052     bool verifyNonce(const NodeId& src, const void *noncep_);
00053     
00054     bool crypt(bool isDecrypt, void *data, size_t data_len, const MemoryBlock sg[]);    
00055     
00056     char * saveNonsignArea(const MemoryBlock sg[]);
00057     void restoreNonsignArea(char * store, const MemoryBlock sg[]);
00058     
00059 };
00060 
00061 
00062 }
00063 
00064 #endif //AESCCMCRYPTOUNIT_H__
00065 /* This stuff is for emacs
00066  * Local variables:
00067  * mode:c++
00068  * c-basic-offset: 4
00069  * End:
00070  */

Generated on Tue Dec 11 17:58:48 2007 for AWDS by  doxygen 1.5.3-20071008