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

00001 #ifndef _CRYPTOUNIT_H__
00002 #define _CRYPTOUNIT_H__
00003 
00004 /* how does it work?
00005  *
00006  *  ------------- -------------- ---------------- -------------
00007  * |             |              |                |             |
00008  * | Plain Block | Cypher Block | Checksum Block | Nonce Block |
00009  * |             |              |                |             |
00010  *  ------------- -------------- ---------------- -------------
00011  * |<-plain_len->| 
00012  *
00013  * |<------- total_len -------->|
00014  *
00015  *                              |<-------- crypto_len -------->|
00016  * 
00017  *
00018  * The crypto unit can authenticate and encrypt a continous block of bytes.
00019  * The additional data for this is appended to the block.
00020  * The plain block is authenticated but not encrypted.
00021  * The cyper block is encrypted.
00022  * The checksum and nonce block are arbitrarily depending on the implemetation.
00023  * 
00024  *
00025  *
00026  */
00027 
00028 #include <cstddef>
00029 #include <awds/NodeId.h>
00030 
00031 namespace awds {
00032 class CryptoUnit {
00033 
00034 public:
00035     struct MemoryBlock {
00036         void   *p;
00037         size_t size;
00038     };
00039     
00040     virtual void encrypt(void *data, size_t data_len, const MemoryBlock sg[]) = 0;
00041     virtual bool decryptDupDetect(const NodeId& src, void *data, size_t data_len, const MemoryBlock sg[]) = 0;
00042 
00047     virtual void sign(void *data, size_t data_len, const MemoryBlock sg[]) = 0;
00048     
00049     
00050     virtual bool verifySignature(const NodeId& src, void *data, size_t data_len, const MemoryBlock sg[]) = 0;
00051 
00052     virtual ~CryptoUnit() {}
00053     
00054 };
00055 }
00056 
00057 #endif //CRYPTOUNIT_H__
00058 /* This stuff is for emacs
00059  * Local variables:
00060  * mode:c++
00061  * c-basic-offset: 4
00062  * End:
00063  */

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