00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _CIPHERSUITE_C3_H_
00018 #define _CIPHERSUITE_C3_H_
00019
00020 #ifdef BSP_ENABLED
00021
00022 #include "gcm/gcm_aes.h"
00023 #include "gcm/gcm.h"
00024 #include "bundling/BlockProcessor.h"
00025 #include "C_BlockProcessor.h"
00026
00027 namespace dtn {
00028
00032 class Ciphersuite_C3 : public Ciphersuite {
00033 public:
00034 enum {
00035 op_invalid = 0,
00036 op_encrypt = 1,
00037 op_decrypt = 2
00038 };
00039
00040 typedef struct {
00041 u_int8_t operation;
00042 gcm_ctx c;
00043 } gcm_ctx_ex;
00044
00046 Ciphersuite_C3();
00047
00048 virtual u_int16_t cs_num();
00049
00051
00067 virtual int consume(Bundle* bundle, BlockInfo* block,
00068 u_char* buf, size_t len);
00069
00076 virtual bool validate(const Bundle* bundle,
00077 BlockInfoVec* block_list,
00078 BlockInfo* block,
00079 status_report_reason_t* reception_reason,
00080 status_report_reason_t* deletion_reason);
00081
00090 virtual int prepare(const Bundle* bundle,
00091 BlockInfoVec* xmit_blocks,
00092 const BlockInfo* source,
00093 const LinkRef& link,
00094 list_owner_t list);
00095
00101 virtual int generate(const Bundle* bundle,
00102 BlockInfoVec* xmit_blocks,
00103 BlockInfo* block,
00104 const LinkRef& link,
00105 bool last);
00106
00114 virtual int finalize(const Bundle* bundle,
00115 BlockInfoVec* xmit_blocks,
00116 BlockInfo* block,
00117 const LinkRef& link);
00118
00123 static bool do_crypt(const Bundle* bundle,
00124 const BlockInfo* caller_block,
00125 BlockInfo* target_block,
00126 void* buf,
00127 size_t len,
00128 OpaqueContext* r);
00129
00134 enum { CSNUM_C3 = 3,
00135 key_len = 128/8,
00136 nonce_len = 12,
00137 salt_len = 4,
00138 iv_len = nonce_len - salt_len,
00139 tag_len = 128/8
00140 };
00141
00143 };
00144
00145 }
00146
00147 #endif
00148
00149 #endif