| OLD | NEW |
| 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 /* Implementation of RSA signature verification which uses a pre-processed | 6 /* Implementation of RSA signature verification which uses a pre-processed |
| 7 * key for computation. The code extends Android's RSA verification code to | 7 * key for computation. The code extends Android's RSA verification code to |
| 8 * support multiple RSA key lengths and hash digest algorithms. | 8 * support multiple RSA key lengths and hash digest algorithms. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 if (sig_len != (key->len * sizeof(uint32_t))) { | 140 if (sig_len != (key->len * sizeof(uint32_t))) { |
| 141 fprintf(stderr, "Signature is of incorrect length!\n"); | 141 fprintf(stderr, "Signature is of incorrect length!\n"); |
| 142 return 0; | 142 return 0; |
| 143 } | 143 } |
| 144 | 144 |
| 145 if (sig_type >= kNumAlgorithms) { | 145 if (sig_type >= kNumAlgorithms) { |
| 146 fprintf(stderr, "Invalid signature type!\n"); | 146 fprintf(stderr, "Invalid signature type!\n"); |
| 147 return 0; | 147 return 0; |
| 148 } | 148 } |
| 149 | 149 |
| 150 if (key->len != siglen_map[sig_type]) { | 150 if (key->len != siglen_map[sig_type] / sizeof(uint32_t)) { |
| 151 fprintf(stderr, "Wrong key passed in!\n"); | 151 fprintf(stderr, "Wrong key passed in!\n"); |
| 152 return 0; | 152 return 0; |
| 153 } | 153 } |
| 154 | 154 |
| 155 buf = (uint8_t*) Malloc(sig_len); | 155 buf = (uint8_t*) Malloc(sig_len); |
| 156 Memcpy(buf, sig, sig_len); | 156 Memcpy(buf, sig, sig_len); |
| 157 | 157 |
| 158 modpowF4(key, buf); | 158 modpowF4(key, buf); |
| 159 | 159 |
| 160 /* Determine padding to use depending on the signature type. */ | 160 /* Determine padding to use depending on the signature type. */ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 181 buf[i]); | 181 buf[i]); |
| 182 #endif | 182 #endif |
| 183 success = 0; | 183 success = 0; |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 Free(buf); | 187 Free(buf); |
| 188 | 188 |
| 189 return success; | 189 return success; |
| 190 } | 190 } |
| OLD | NEW |