Mercurial > trustbridge
comparison common/listutil.c @ 1394:8d27c6d226cd
Improve debug output for list verification and no installed list
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 23 Jan 2015 15:25:50 +0100 |
parents | 3cd8dd706aaa |
children | a2574a029322 |
comparison
equal
deleted
inserted
replaced
1393:a9dcf6c86d19 | 1394:8d27c6d226cd |
---|---|
133 /* Hash algroithm is sha256 */ | 133 /* Hash algroithm is sha256 */ |
134 unsigned char hash[32]; | 134 unsigned char hash[32]; |
135 | 135 |
136 if (!data || !size) | 136 if (!data || !size) |
137 { | 137 { |
138 ERRORPRINTF ("Invalid call.\n"); | |
138 return -1; | 139 return -1; |
139 } | 140 } |
140 | 141 |
141 /* Fetch the signature from the first line od data */ | 142 /* Fetch the signature from the first line od data */ |
142 p = strchr(data, '\r'); | 143 p = strchr(data, '\r'); |
143 if (p == 0 || (unsigned int)(p - (data + 2)) != sig_b64_size) | 144 if (p == 0 || (unsigned int)(p - (data + 2)) != sig_b64_size) |
144 { | 145 { |
145 /* printf("Invalid data. Signature might be too long.\n"); */ | 146 DEBUGPRINTF("Invalid data. Signature might be too long.\n"); |
147 DEBUGPRINTF("Should: %u is: %u\n", sig_b64_size, (unsigned int)(p - (data + 2))); | |
146 return -1; | 148 return -1; |
147 } | 149 } |
148 strncpy(signature_b64, data + 2, sig_b64_size); | 150 strncpy(signature_b64, data + 2, sig_b64_size); |
149 signature_b64[sig_b64_size] = '\0'; | 151 signature_b64[sig_b64_size] = '\0'; |
150 | 152 |
151 ret = base64_decode(signature, &sig_size, | 153 ret = base64_decode(signature, &sig_size, |
152 (unsigned char *)signature_b64, sig_b64_size); | 154 (unsigned char *)signature_b64, sig_b64_size); |
153 | 155 |
154 if (ret != 0 || sig_size != TRUSTBRIDGE_RSA_KEY_SIZE / 8) | 156 if (ret != 0 || sig_size != TRUSTBRIDGE_RSA_KEY_SIZE / 8) |
155 { | 157 { |
156 /* printf("failed to decode signature\n"); */ | 158 DEBUGPRINTF("failed to decode signature\n"); |
157 return -1; | 159 return -1; |
158 } | 160 } |
159 | 161 |
160 /* Hash is calculated over the data without the first line. | 162 /* Hash is calculated over the data without the first line. |
161 * linebreaks are \r\n so the first char of the new line is | 163 * linebreaks are \r\n so the first char of the new line is |