Changeset 169
- Timestamp:
- 05/01/07 18:16:39 (2 years ago)
- Files:
-
- utu-core/build_logs/qualstats.log (modified) (1 diff)
- utu-core/doc/site/src/default.template (modified) (2 diffs)
- utu-core/src/client/client.c (modified) (1 diff)
- utu-core/src/hub/connection.c (modified) (2 diffs)
- utu-core/src/hub/connection_actions.rl (modified) (2 diffs)
- utu-core/src/hub/hub.h (modified) (1 diff)
- utu-core/src/protocol/crypto.c (modified) (7 diffs)
- utu-core/src/protocol/crypto.h (modified) (6 diffs)
- utu-core/src/protocol/message.c (modified) (2 diffs)
- utu-core/src/protocol/message.h (modified) (3 diffs)
- utu-core/src/stackish/node.c (modified) (4 diffs)
- utu-core/src/stackish/node.h (modified) (4 diffs)
- utu-core/src/stackish/stackish.c (modified) (1 diff)
- utu-core/src/stackish/stackish.rl (modified) (1 diff)
- utu-core/tests/test_crypto.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
utu-core/build_logs/qualstats.log
r167 r169 318 318 5879 0 0 0 0 0 0 0 0 319 319 5879 0 0 0 0 0 0 0 0 320 5879 0 0 0 0 0 0 0 0 321 5879 0 0 0 0 0 0 0 0 322 5879 21 0 0 0 0 0 0 0 323 5879 177 2 0 1 1 28716 61 0 324 5879 177 2 0 1 1 28716 61 0 325 5879 177 2 0 1 1 28716 61 0 326 5880 190 2 0 1 1 28692 59 0 327 5880 199 2 0 1 1 28692 59 0 328 5880 202 2 0 1 1 28692 59 0 329 5880 320 0 0 0 0 0 0 0 330 5880 335 0 0 0 0 0 0 0 331 5880 365 0 0 0 0 0 0 0 332 5880 378 0 0 0 0 0 0 0 333 5880 390 0 0 0 0 0 0 0 334 5881 413 0 0 0 0 0 0 0 utu-core/doc/site/src/default.template
r167 r169 26 26 the internet is dying 27 27 <br/><br/> 28 <a href="{relocatable: /download.html}">download</a><br/>29 if you're <a href="mailto:zedshaw-FU-SPAMMERS@zedshaw.com">invited</a>30 <br/><br/>31 28 <a href="{relocatable: /theory.html}">theory</a><br/> 32 29 what makes utu work … … 34 31 <a href="{relocatable: /design.html}">design</a><br/> 35 32 all that's good for geeks 33 <br/><br/> 34 <a href="{relocatable: /download.html}">download</a><br/> 35 if you're <a href="mailto:zedshaw-FU-SPAMMERS@zedshaw.com">invited</a> 36 36 <br/><br/> 37 37 <a href="{relocatable: /status.html}">status</a><br/> utu-core/src/client/client.c
r146 r169 69 69 void error(Proxy *conn, UtuMendicantErrorCode code, bstring message) 70 70 { 71 Node *err = Node_cons("[nbw", code, message, "err"); 71 Node *err = Node_cons("[nbw", (uint64_t)code, message, "err"); 72 Node_dump(err, ' ', 1); 72 73 Proxy_listener_send(conn, err, NULL); 73 74 } utu-core/src/hub/connection.c
r151 r169 291 291 } 292 292 } else { 293 log(ERROR, "%l dis not a valid circuit", state->recv.msg->circuit);293 log(ERROR, "%llu is not a valid circuit", state->recv.msg->circuit); 294 294 { state->cs = 11; goto _again;} 295 295 } … … 347 347 if(state->recv.msg->msgid != state->recv_count) { 348 348 Message_ref_inc(state->recv.msg); // we own it now 349 log(ERROR, "msg id is wrong, should be %l d but got %ld", state->recv_count, state->recv.msg->msgid);349 log(ERROR, "msg id is wrong, should be %llu but got %llu", state->recv_count, state->recv.msg->msgid); 350 350 { state->cs = 11; goto _again;} 351 351 } utu-core/src/hub/connection_actions.rl
r151 r169 74 74 } 75 75 } else { 76 log(ERROR, "%l dis not a valid circuit", state->recv.msg->circuit);76 log(ERROR, "%llu is not a valid circuit", state->recv.msg->circuit); 77 77 fgoto Aborting; 78 78 } … … 120 120 if(state->recv.msg->msgid != state->recv_count) { 121 121 Message_ref_inc(state->recv.msg); // we own it now 122 log(ERROR, "msg id is wrong, should be %l d but got %ld", state->recv_count, state->recv.msg->msgid);122 log(ERROR, "msg id is wrong, should be %llu but got %llu", state->recv_count, state->recv.msg->msgid); 123 123 fgoto Aborting; 124 124 } utu-core/src/hub/hub.h
r103 r169 81 81 typedef struct ConnectionState { 82 82 int cs; 83 u nsigned longrecv_count;84 u nsigned longsend_count;83 uint64_t recv_count; 84 uint64_t send_count; 85 85 MyriadClient *client; 86 86 struct Hub *hub; utu-core/src/protocol/crypto.c
r162 r169 718 718 } 719 719 720 Node *CryptState_generate_hate_challenge(CryptState *state, unsigned int level, u nsigned long long*expecting)720 Node *CryptState_generate_hate_challenge(CryptState *state, unsigned int level, uint64_t *expecting) 721 721 { 722 722 bstring hash = NULL; … … 726 726 Node *msg = NULL; 727 727 int rc = 0; 728 u nsigned long longlevel_max = 1;728 uint64_t level_max = 1; 729 729 level_max <<= (level + 1); 730 730 … … 754 754 755 755 // construct the challenge 756 msg = Node_cons("[nbbbw", (u nsigned long)level, blk2bstr(val.raw, NONCE_LENGTH), hash, signature, CRYPT_CHALLENGE_MSG);756 msg = Node_cons("[nbbbw", (uint64_t)level, blk2bstr(val.raw, NONCE_LENGTH), hash, signature, CRYPT_CHALLENGE_MSG); 757 757 check(msg, "failed constructing challenge message"); 758 758 … … 766 766 bstring nonce = NULL; 767 767 bstring ans_hash = NULL; 768 u nsigned longlevel;768 uint64_t level; 769 769 unsigned long signature_len = MAXBLOCKSIZE; 770 770 CryptNonce val; … … 773 773 unsigned char test_hash[MAXBLOCKSIZE]; 774 774 unsigned long hash_len; 775 u nsigned long longlevel_max = 1;775 uint64_t level_max = 1; 776 776 777 777 assert_not(state, NULL); … … 813 813 814 814 // swap the results 815 u nsigned long longtemp = val.num.left;815 uint64_t temp = val.num.left; 816 816 val.num.left = val.num.right; val.num.right = temp; 817 817 ans_hash = CryptState_hash_nonce(&val); … … 838 838 } 839 839 840 int CryptState_validate_hate_challenge(CryptState *state, Node *challenge, Node *answer, u nsigned long longexpecting)840 int CryptState_validate_hate_challenge(CryptState *state, Node *challenge, Node *answer, uint64_t expecting) 841 841 { 842 842 bstring ans_hash = NULL, ans_sig = NULL, ans_nonce = NULL; 843 843 bstring ch_hash = NULL, ch_nonce = NULL; 844 u nsigned longlevel;844 uint64_t level; 845 845 int rc = 0; 846 846 CryptNonce ch_val, ans_val; utu-core/src/protocol/crypto.h
r146 r169 66 66 * after that. 67 67 * 68 * Additionally, the nonces are 16 bytes but represented as two u nsigned long long68 * Additionally, the nonces are 16 bytes but represented as two uint64_t 69 69 * integers (which is 16 bytes on 32 bit machines, so really not portable). The 70 70 * two nonces that are exchanged encrypted are simply incremented for each message … … 97 97 98 98 /** Length of the nonce in bytes. */ 99 #define NONCE_LENGTH (sizeof(u nsigned long long) * 2)99 #define NONCE_LENGTH (sizeof(uint64_t) * 2) 100 100 /** Default key size for ECC and AES in bytes. */ 101 101 #define KEY_LENGTH 32 … … 108 108 109 109 /** A union that allows simply conversion from two 110 * u nsigned long longintegers and an array of unsigned110 * uint64_t integers and an array of unsigned 111 111 * bytes. This makes processing and then incrementing the 112 112 * nonce much easier. … … 115 115 unsigned char raw[NONCE_LENGTH]; 116 116 struct { 117 u nsigned long longleft;118 u nsigned long longright;117 uint64_t left; 118 uint64_t right; 119 119 } num; 120 120 } CryptNonce; … … 366 366 /** 367 367 * Constructs a signed hate challenge that the receiver must process. 368 * The algorithm is to construct two u nsigned long longintegers and368 * The algorithm is to construct two uint64_t integers and 369 369 * hash them. The receiver is then only given one of the numbers and 370 370 * has to calculate: … … 383 383 * for the right side. Larger values mean more work for the receiver. 384 384 */ 385 Node *CryptState_generate_hate_challenge(CryptState *state, unsigned int level, u nsigned long long*expecting);385 Node *CryptState_generate_hate_challenge(CryptState *state, unsigned int level, uint64_t *expecting); 386 386 387 387 Node *CryptState_answer_hate_challenge(CryptState *state, Node *challenge, int *sig_stat, unsigned int max_allowed_level); 388 388 389 int CryptState_validate_hate_challenge(CryptState *state, Node *challenge, Node *answer, u nsigned long longexpecting);389 int CryptState_validate_hate_challenge(CryptState *state, Node *challenge, Node *answer, uint64_t expecting); 390 390 391 391 #endif utu-core/src/protocol/message.c
r154 r169 57 57 } 58 58 59 inline Node *Message_cons_header(u nsigned long circuit, unsigned long more, unsigned longmsgid)59 inline Node *Message_cons_header(uint64_t circuit, uint64_t more, uint64_t msgid) 60 60 { 61 61 return Node_cons("[nnnw", circuit, msgid, more, "header"); 62 62 } 63 63 64 Node *Message_cons(Node **hdr, u nsigned long circuit, unsigned long more, unsigned longmsgid, Node *data, const char *type)64 Node *Message_cons(Node **hdr, uint64_t circuit, uint64_t more, uint64_t msgid, Node *data, const char *type) 65 65 { 66 66 assert_not(hdr, NULL); … … 91 91 void Message_dump(Message *msg) 92 92 { 93 fprintf(stderr, "Message: { circuit: %l u, msgid: %lu, more: %lu, type: %s received_at: %u, data: ",93 fprintf(stderr, "Message: { circuit: %llu, msgid: %llu, more: %llu, type: %s received_at: %u, data: ", 94 94 msg->circuit, msg->msgid, msg->more, 95 95 bdata(msg->type), (unsigned int)msg->received_at); utu-core/src/protocol/message.h
r148 r169 33 33 */ 34 34 typedef struct Message { 35 u nsigned longcircuit;36 u nsigned longmsgid;37 u nsigned longmore;35 uint64_t circuit; 36 uint64_t msgid; 37 uint64_t more; 38 38 bstring type; 39 39 time_t received_at; … … 98 98 * @return The frame body you can send. 99 99 */ 100 Node *Message_cons(Node **hdr, u nsigned long circuit, unsigned long more, unsigned longmsgid, Node *data, const char *type);100 Node *Message_cons(Node **hdr, uint64_t circuit, uint64_t more, uint64_t msgid, Node *data, const char *type); 101 101 102 102 /** … … 124 124 * @see Peer_send 125 125 */ 126 Node *Message_cons_header(u nsigned long circuit, unsigned long more, unsigned longmsgid);126 Node *Message_cons_header(uint64_t circuit, uint64_t more, uint64_t msgid); 127 127 128 128 #define Message_ref_inc(M) ((M)->ref_count++) utu-core/src/stackish/node.c
r154 r169 93 93 break; 94 94 case TYPE_NUMBER: 95 bformata(str, "%l u%c", d->value.number, sep);95 bformata(str, "%llu%c", d->value.number, sep); 96 96 break; 97 97 case TYPE_FLOAT: … … 176 176 177 177 178 Node *Node_new_number(Node *parent, u nsigned longdata)178 Node *Node_new_number(Node *parent, uint64_t data) 179 179 { 180 180 Node *node = calloc(1,sizeof(Node)); … … 266 266 break; 267 267 case 'n': { 268 u nsigned long number = va_arg(args, unsigned long);268 uint64_t number = va_arg(args, uint64_t); 269 269 Node *n = Node_new_number(cur_node, number); 270 270 assert_not(n,NULL); … … 365 365 break; 366 366 case 'n': { 367 u nsigned long *number = va_arg(args, unsigned long*);367 uint64_t *number = va_arg(args, uint64_t *); 368 368 check_type(number, NUMBER, cur_node); 369 369 *number = cur_node->value.number; utu-core/src/stackish/node.h
r124 r169 16 16 17 17 #include <myriad/bstring/bstrlib.h> 18 #include <stdint.h> 18 19 19 20 /** Determines what is contained in the Node.value union. */ … … 45 46 * holds both TYPE_STRING and TYPE_BLOB.*/ 46 47 union { 47 u nsigned longnumber;48 uint64_t number; 48 49 bstring string; 49 50 double floating; … … 120 121 121 122 /** Constructs a new node that represents a number, attaching to parent if not NULL. */ 122 Node *Node_new_number(Node *parent, u nsigned longdata);123 Node *Node_new_number(Node *parent, uint64_t data); 123 124 124 125 /** Constructs a new node that represents a float, attaching to parent if not NULL. */ … … 142 143 * 143 144 * '[' -- Start a new group, just like Stackish. 144 * 'n' -- A number. Argument is an u nsigned long.145 * 'n' -- A number. Argument is an uint64_t. 145 146 * 'f' -- A float. Argument is a double. 146 147 * 'b' -- A blob. Argument is a bstring. utu-core/src/stackish/stackish.c
r149 r169 41 41 case TYPE_NUMBER: 42 42 end = NULL; 43 u nsigned longnumber = strtoul(start, &end, 10);43 uint64_t number = strtoul(start, &end, 10); 44 44 check(end == start + length, "malformed number on input"); 45 45 node = Node_new_number(current, number); utu-core/src/stackish/stackish.rl
r106 r169 40 40 case TYPE_NUMBER: 41 41 end = NULL; 42 u nsigned longnumber = strtoul(start, &end, 10);42 uint64_t number = strtoul(start, &end, 10); 43 43 check(end == start + length, "malformed number on input"); 44 44 node = Node_new_number(current, number); utu-core/tests/test_crypto.c
r124 r169 171 171 peer1 = CryptState_create(p1name, NULL); 172 172 peer2 = CryptState_create(p2name, NULL); 173 int sig_stat ;173 int sig_stat = 0; 174 174 Node *challenge, *answer; 175 u nsigned long longexpecting = 0;175 uint64_t expecting = 0; 176 176 time_t start, end; 177 177 int level = 0; … … 194 194 ASSERT(answer != NULL, "failed to make answer"); 195 195 196 if(!answer) return; 197 196 198 start = time(NULL); 197 199 ASSERT(CryptState_validate_hate_challenge(peer1, challenge, answer, expecting), "challenge/response failed");
