Wiselib
|
00001 /* 00002 * File: common.h 00003 * Author: angelo 00004 * 00005 * Created on May 19, 2009, 11:01 AM 00006 */ 00007 00008 #ifndef _COMMON_H 00009 #define _COMMON_H 00010 00011 #ifdef __cplusplus 00012 extern "C" { 00013 #endif 00014 00015 #include <pbc.h> 00016 00017 typedef struct { 00018 element_t C; 00019 element_t C_0; 00020 element_t C_1; 00021 element_t C_2; 00022 element_t C_3; 00023 } Enc; 00024 00025 typedef struct { 00026 Enc *C; 00027 Enc *U; 00028 } CipherText; 00029 00030 typedef struct { 00031 element_t m; 00032 } PlainText; 00033 00034 typedef struct { 00035 pairing_t pairing; 00036 00037 element_t g; 00038 element_t g_0; 00039 element_t g_1; 00040 element_t omega; 00041 element_t T_1, T_2, T_3; 00042 } Pub; 00043 00044 typedef struct { 00045 element_t t_1; 00046 element_t t_2; 00047 element_t t_3; 00048 element_t w; 00049 } Msk; 00050 00051 typedef struct { 00052 Pub pub; 00053 Msk msk; 00054 } PubTriple; 00055 00056 typedef struct { 00057 element_t pk; 00058 } Pk; 00059 00060 typedef struct { 00061 element_t D_0; 00062 element_t D_1; 00063 element_t D_2; 00064 element_t D_3; 00065 } Sk; 00066 00067 typedef struct { 00068 Pk pk; 00069 Sk sk; 00070 } Key; 00071 00072 00073 00074 00075 PlainText* fromString(pairing_t pairing, char* message); 00076 00077 char* toString(pairing_t pairing, PlainText* message); 00078 00079 00080 unsigned char * ciphertext2bytes(pairing_t pairing, CipherText* ct); 00081 00082 CipherText* bytes2ciphertext(pairing_t pairing, unsigned char* buffer); 00083 00084 00085 unsigned char* key2bytes(pairing_t pairing, Key* key); 00086 00087 Key* bytes2key(pairing_t pairing, unsigned char* buffer); 00088 00089 00090 unsigned char* pk2bytes(pairing_t pairing, Pk* key); 00091 00092 Pk* bytes2pk(pairing_t pairing, unsigned char* buffer); 00093 00094 00095 unsigned char* sk2bytes(pairing_t pairing, Sk* key); 00096 00097 Sk* bytes2sk(pairing_t pairing, unsigned char* buffer); 00098 00099 00100 unsigned char* pub2bytes(pairing_t pairing, Pub* key); 00101 00102 Pub* bytes2pub(pairing_t pairing, unsigned char* buffer); 00103 00104 00105 unsigned char* msk2bytes(pairing_t pairing, Msk* key); 00106 00107 Msk* bytes2msk(pairing_t pairing, unsigned char* buffer); 00108 00109 00110 int ciphertext_size(pairing_t pairing); 00111 00112 int key_size(pairing_t pairing); 00113 00114 int pk_size(pairing_t pairing); 00115 00116 int sk_size(pairing_t pairing); 00117 00118 int msk_size(pairing_t pairing); 00119 00120 int pub_size(pairing_t pairing); 00121 00122 int pubtriple_size(pairing_t pairing); 00123 00124 void clear_ciphertext( CipherText* ct); 00125 00126 void clear_plaintext(PlainText* message); 00127 00128 void clear_key(Key* key); 00129 00130 00131 00132 00133 void store(unsigned char* buffer, int len, char* filename); 00134 00135 void load(unsigned char* buffer, int len, char* filename); 00136 00137 #ifdef __cplusplus 00138 } 00139 #endif 00140 00141 #endif /* _COMMON_H */ 00142