| 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 * Tests if firmware image library deals with very large firmware. This | 5 * Tests if firmware image library deals with very large firmware. This |
| 6 * is a quick and dirty test for detecting integer overflow issues. | 6 * is a quick and dirty test for detecting integer overflow issues. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 BIG_KERNEL_SIZE, | 43 BIG_KERNEL_SIZE, |
| 44 kFirmwareKeyFile, | 44 kFirmwareKeyFile, |
| 45 kKernelKeyFile, | 45 kKernelKeyFile, |
| 46 'K'); /* Kernel Data Fill. */ | 46 'K'); /* Kernel Data Fill. */ |
| 47 if (!firmware_key || !firmware_key_blob || !kernel_sign_key_buf || !image) { | 47 if (!firmware_key || !firmware_key_blob || !kernel_sign_key_buf || !image) { |
| 48 error_code = 1; | 48 error_code = 1; |
| 49 goto cleanup; | 49 goto cleanup; |
| 50 } | 50 } |
| 51 debug("Done.\n"); | 51 debug("Done.\n"); |
| 52 TEST_EQ(VerifyKernelImage(firmware_key, image, 0), | 52 TEST_EQ(VerifyKernelImage(firmware_key, image, 0), |
| 53 VERIFY_FIRMWARE_SUCCESS, | 53 VERIFY_KERNEL_SUCCESS, |
| 54 "Big KernelImage Verification"); | 54 "Big KernelImage Verification"); |
| 55 kernel_blob = GetKernelBlob(image, &len); | 55 kernel_blob = GetKernelBlob(image, &len); |
| 56 TEST_EQ(VerifyKernel(firmware_key_blob, kernel_blob, 0), | 56 TEST_EQ(VerifyKernel(firmware_key_blob, kernel_blob, 0), |
| 57 VERIFY_FIRMWARE_SUCCESS, | 57 VERIFY_KERNEL_SUCCESS, |
| 58 "Big Kernel Blob Verification"); | 58 "Big Kernel Blob Verification"); |
| 59 | 59 |
| 60 cleanup: | 60 cleanup: |
| 61 Free(kernel_blob); | 61 Free(kernel_blob); |
| 62 KernelImageFree(image); | 62 KernelImageFree(image); |
| 63 Free(kernel_sign_key_buf); | 63 Free(kernel_sign_key_buf); |
| 64 Free(firmware_key_blob); | 64 Free(firmware_key_blob); |
| 65 RSAPublicKeyFree(firmware_key); | 65 RSAPublicKeyFree(firmware_key); |
| 66 return error_code; | 66 return error_code; |
| 67 } | 67 } |
| 68 | 68 |
| 69 int main(int argc, char* argv[1]) | 69 int main(int argc, char* argv[1]) |
| 70 { | 70 { |
| 71 int error_code = 0; | 71 int error_code = 0; |
| 72 error_code = BigKernelTest(); | 72 error_code = BigKernelTest(); |
| 73 if (!gTestSuccess) | 73 if (!gTestSuccess) |
| 74 error_code = 255; | 74 error_code = 255; |
| 75 return error_code; | 75 return error_code; |
| 76 } | 76 } |
| OLD | NEW |