| 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 for firmware image library. | 5 * Tests for firmware image library. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 GetSignatureData(sig)[0] ^= 0x5A; | 63 GetSignatureData(sig)[0] ^= 0x5A; |
| 64 TEST_EQ(VerifyData(test_data, sig, rsa), 1, "VerifyData() wrong sig"); | 64 TEST_EQ(VerifyData(test_data, sig, rsa), 1, "VerifyData() wrong sig"); |
| 65 | 65 |
| 66 RSAPublicKeyFree(rsa); | 66 RSAPublicKeyFree(rsa); |
| 67 Free(sig); | 67 Free(sig); |
| 68 } | 68 } |
| 69 | 69 |
| 70 | 70 |
| 71 static void VerifyDigestTest(const VbPublicKey* public_key, | 71 static void VerifyDigestTest(const VbPublicKey* public_key, |
| 72 const VbPrivateKey* private_key) { | 72 const VbPrivateKey* private_key) { |
| 73 | 73 |
| 74 const uint8_t test_data[] = "This is some other test data to sign."; | 74 const uint8_t test_data[] = "This is some other test data to sign."; |
| 75 VbSignature* sig; | 75 VbSignature* sig; |
| 76 RSAPublicKey* rsa; | 76 RSAPublicKey* rsa; |
| 77 uint8_t* digest; | 77 uint8_t* digest; |
| 78 | 78 |
| 79 sig = CalculateSignature(test_data, sizeof(test_data), private_key); | 79 sig = CalculateSignature(test_data, sizeof(test_data), private_key); |
| 80 rsa = PublicKeyToRSA(public_key); | 80 rsa = PublicKeyToRSA(public_key); |
| 81 digest = DigestBuf(test_data, sizeof(test_data), (int)public_key->algorithm); | 81 digest = DigestBuf(test_data, sizeof(test_data), (int)public_key->algorithm); |
| 82 TEST_NEQ(sig && rsa && digest, 0, "VerifyData() prerequisites"); | 82 TEST_NEQ(sig && rsa && digest, 0, "VerifyData() prerequisites"); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 VerifyDigestTest(public_key, private_key); | 230 VerifyDigestTest(public_key, private_key); |
| 231 VerifyKernelPreambleTest(public_key, private_key); | 231 VerifyKernelPreambleTest(public_key, private_key); |
| 232 | 232 |
| 233 if (public_key) | 233 if (public_key) |
| 234 Free(public_key); | 234 Free(public_key); |
| 235 if (private_key) | 235 if (private_key) |
| 236 Free(private_key); | 236 Free(private_key); |
| 237 | 237 |
| 238 return error_code; | 238 return error_code; |
| 239 } | 239 } |
| OLD | NEW |