/* ** Author: Krishna Puttaswamy ** description: the header file with some definition to use in the operation of the CA */ #ifndef _CA_H_ #define _CA_H_ #include "key.h" #include "chimera.h" #define MAXPREFIXLENGTH (KEY_SIZE/BASE_B + 1) // same as the length of the key #define RSAKEYLENGTH 2049 // length depends on the number of bits specified during key generation. 1 byte extra #define TOTALNUMBEROFKEYS 9000 // For now, might need to change this later #define Debug(d, fmt, args...) (d==1 ? printf(fmt, ##args) : 0) #define DEBUGLEVEL 1 #define true 1 #define false 0 #ifdef __cplusplus extern "C" { #else typedef int bool; // This is one way of abstracting boolean in C #endif typedef enum KeyType { NONE = -1, // This is used to avoid initial value being 0 by default PRIVATEKEY = 0, PUBLICKEY } KeyType; typedef enum ReplyError { NOERROR = 0, PREFIXNOTINKEY, // if the source doenst contain the key PRIVATEKEYNOTFOUND, // For the given prefix if a request is made for a public key and there is no corresponding priv key OUTOFKEYS // this can happen when all precomputed keys are usedup. we will need to start the porgram to generate more keys } ReplyError; // This struct contains the error code for the reply from the server // Structure for requesting key from the central authority typedef struct KeyRequest { KeyType type; // Specify if the request is for the priv key or pub key char prefix[MAXPREFIXLENGTH]; // Prefix for which the request is sent char nodeid[MAXPREFIXLENGTH]; // This is the key of the key requestor } KeyRequest; // Structure for sending back the reply to the node from the CA typedef struct KeyReply { ReplyError error; char key[RSAKEYLENGTH]; // Send back the key } KeyReply; unsigned char *public_encrypt_data_with_key (ChimeraState * state, char *nodeid, char *prefix, unsigned char *input, int inputlen, int *outlen); unsigned char *private_decrypt_data_with_key (ChimeraState * state, char *nodeid, char *prefix, unsigned char *input, int inputlen, int *outlen); #ifdef __cplusplus } #endif #endif /* end _CA_H_ */