/* ** ** Krishna Puttaswamy: created on 21st May 2006 ** description: This is the header file with details specific to cashmere code */ #ifndef _CASHMERE_H_ #define _CASHMERE_H_ #include "chimera.h" #include "mycrypto.h" #define PREFIX_SIZE 2 // This is the size of the prefix #define PATH_LENGTH 4 // This is the size of each path and is defined statically here #define GROUP_SIZE 5 // This actually won't get used in the initial design; adding just for the sake of completion #define MAGIC_NUMBER_LENGTH 4 static int magic_number = 0x12345678; static char endOfPath[100] = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"; #define ONIONE_LAYER_SIZE 10 #define INT_SIZE 4 // The message types used for cashmere #define CASHMERE_MESSAGE 21 #define CASHMERE_GROUP_BROADCAST_MESSAGE 22 #define CASHMERE_REPLY_MESSAGE 23 // this has some use in helping execute the cashmere legacy code for evaluating the lifetime of the cashmere path; not used for bluemoon #define CASHMERE_REPLY 24 #define CASHMERE_REPLY_GROUP_BROADCAST_MESSAGE 25 // To enable caching of paths, set this #define CACHING_ENABLED 1 #define TEST_NETWORK_SIZE 64 #ifdef __cplusplus extern "C" { #endif // The strucut for keeping track of the path to a destination typedef struct path { int pathLength; char destination[KEY_SIZE / BASE_B + 1]; // store the destination here int destPrefixPos; // the position of the destination prefix grop in the below array char nextPrefix[PREFIX_SIZE + 1]; // store the next prefix to send the message to unsigned char symmetricKeys[PATH_LENGTH][SYMMETRIC_KEY_LENGTH]; // list of symmetric keys corresponding to the prefixes unsigned char symmetricKeyIVs[PATH_LENGTH][IV_LENGTH]; // list of symmetric keys IVs to the prefixes unsigned char sessionKey[SYMMETRIC_KEY_LENGTH]; // the session key unsigned char sessionIV[IV_LENGTH]; // the session IV unsigned char *encryptedSessMagicNo; // generate and store the encrypted value K here int encryptedSessMagicNoLength; // length of K unsigned char *pathData; // store the encrypted path here int pathDataLength; // length of path data unsigned char mySymmetricKey[SYMMETRIC_KEY_LENGTH]; unsigned char mySymmetricIV[IV_LENGTH]; // the content below is for the reverse onion path; there are a few things that will be reused from the above part char revNextPrefix[PREFIX_SIZE + 1]; char revDestination[KEY_SIZE / BASE_B + 1]; // store the destination here int revDestPrefixPos; // the position of the destination prefix grop in the below array unsigned char revSymmetricKeys[PATH_LENGTH][SYMMETRIC_KEY_LENGTH]; // list of symmetric keys corresponding to the prefixes unsigned char revSymmetricKeyIVs[PATH_LENGTH][IV_LENGTH]; // list of symmetric keys IVs to the prefixes unsigned char revSessionKey[SYMMETRIC_KEY_LENGTH]; // the session key unsigned char revSessionIV[IV_LENGTH]; // the session IV unsigned char *revEncryptedSessMagicNo; // generate and store the encrypted value K here int revEncryptedSessMagicNoLength; // length of K unsigned char *revPathData; // store the encrypted path here int revPathDataLength; // length of path data } Path; typedef struct payload { unsigned char *payloadData; // generate and store the encrypted payload here int payloadLength; // corresponding lengths } Payload; typedef enum bf { NOFORWARD = 0, FORWARD_RIGHT, FORWARD_LEFT } BroadcastForward; #define PATH_CACHE_SIZE 2000 // An entry in the path cache typedef struct pathcache { int encryptedPathLen; unsigned char *encryptedPath; int decryptedPathLen; unsigned char *decryptedPath; } PathCacheEntry; /** cashmere_send: ** Route a message to the destination key containing size bytes of data. This will ** send data through the Chimera system anonymously and deliver it to the EXACT key. ** ** This is different from chimera in the sense that the desitnation should have the exact key ** and the routing is anonymous. */ void cashmere_send (ChimeraState * state, Key key, int len, char *data); /** cashmere__create_path: ** This function is responsible for forming a path from the current source to the specified ** destination through the Cashmere system. */ //Path *cashmere_create_path (ChimeraState * state, Key key, unsigned long long *temp); Path *cashmere_create_path (ChimeraState * state, Key key); // Initialize function that should be called by the applications built using cashmere void cashmere_init (ChimeraState * state); //clear an entry in the pathcache void cashmere_clear_sourcepathcache(ChimeraState *state, char *dest); void process_cashmere_message (ChimeraState *state, Message *message, int type); void process_group_broadcast_message (ChimeraState *state, Message *message, int type); void calc_cycles_persec(ChimeraState *state); unsigned long long get_cyclecounter(); unsigned long long get_cycles_per_second(); #ifdef __cplusplus } #endif #endif /* _CASHMERE_H_ */