comparison cli-algo.c @ 26:0969767bca0d

snapshot of stuff
author Matt Johnston <matt@ucc.asn.au>
date Mon, 26 Jul 2004 02:44:20 +0000
parents e4b6e2d569b2
children 0cfba3034be5
comparison
equal deleted inserted replaced
25:e4b6e2d569b2 26:0969767bca0d
31 /* 31 /*
32 * The chosen [encryption | MAC | compression] algorithm to each 32 * The chosen [encryption | MAC | compression] algorithm to each
33 * direction MUST be the first algorithm on the client's list 33 * direction MUST be the first algorithm on the client's list
34 * that is also on the server's list. 34 * that is also on the server's list.
35 */ 35 */
36 algo_type * cli_buf_match_algo(buffer* buf, algo_type localalgos[]) { 36 algo_type * cli_buf_match_algo(buffer* buf, algo_type localalgos[],
37 int *goodguess) {
37 38
38 unsigned char * algolist = NULL; 39 unsigned char * algolist = NULL;
39 unsigned char * remotealgos[MAX_PROPOSED_ALGO]; 40 unsigned char * remotealgos[MAX_PROPOSED_ALGO];
40 unsigned int len; 41 unsigned int len;
41 unsigned int count, i, j; 42 unsigned int count, i, j;
42 algo_type * ret = NULL; 43 algo_type * ret = NULL;
44
45 *goodguess = 0;
43 46
44 /* get the comma-separated list from the buffer ie "algo1,algo2,algo3" */ 47 /* get the comma-separated list from the buffer ie "algo1,algo2,algo3" */
45 algolist = buf_getstring(buf, &len); 48 algolist = buf_getstring(buf, &len);
46 TRACE(("cli_buf_match_algo: %s", algolist)); 49 TRACE(("cli_buf_match_algo: %s", algolist));
47 if (len > MAX_PROPOSED_ALGO*(MAX_NAME_LEN+1)) { 50 if (len > MAX_PROPOSED_ALGO*(MAX_NAME_LEN+1)) {
76 len = strlen(localalgos[j].name); 79 len = strlen(localalgos[j].name);
77 for (i = 0; i < count; i++) { 80 for (i = 0; i < count; i++) {
78 if (len == strlen(remotealgos[i]) 81 if (len == strlen(remotealgos[i])
79 && strncmp(localalgos[j].name, 82 && strncmp(localalgos[j].name,
80 remotealgos[i], len) == 0) { 83 remotealgos[i], len) == 0) {
84 if (i == 0 && j == 0) {
85 /* was a good guess */
86 *goodguess = 1;
87 }
81 ret = &localalgos[j]; 88 ret = &localalgos[j];
82 goto out; 89 goto out;
83 } 90 }
84 } 91 }
85 } 92 }