Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/platform/vboot_reference/tests/rollback_index_mock.c

Issue 1241002: VBoot Reference: Add version checking to for preventing rollbacks. (Closed)
Patch Set: . Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 * found in the LICENSE file.
4 *
5 * Mock rollback index library for testing.
6 */
7
8 #include "rollback_index.h"
9
10 #include <stdio.h>
11 #include <stdint.h>
12
13 uint16_t g_firmware_key_version = 0;
14 uint16_t g_firmware_version = 0;
15 uint16_t g_kernel_key_version = 0;
16 uint16_t g_kernel_version = 0;
17
18 void SetupTPM(void) {
19 fprintf(stderr, "Rollback Index Library Mock: TPM initialized.\n");
20 }
21
22 uint16_t GetStoredVersion(int type) {
23 switch (type) {
24 case FIRMWARE_KEY_VERSION:
25 return g_firmware_key_version;
26 break;
27 case FIRMWARE_VERSION:
28 return g_firmware_version;
29 break;
30 case KERNEL_KEY_VERSION:
31 return g_kernel_key_version;
32 break;
33 case KERNEL_VERSION:
34 return g_kernel_version;
35 break;
36 }
37 return 0;
38 }
39
40 int WriteStoredVersion(int type, uint16_t version) {
41 switch (type) {
42 case FIRMWARE_KEY_VERSION:
43 g_firmware_key_version = version;
44 break;
45 case FIRMWARE_VERSION:
46 g_firmware_version = version;
47 break;
48 case KERNEL_KEY_VERSION:
49 g_kernel_key_version = version;
50 break;
51 case KERNEL_VERSION:
52 g_kernel_version = version;
53 break;
54 }
55 fprintf(stderr, "Rollback Index Library Mock: Stored Version written.\n");
56 return 1;
57 }
58
59 void LockStoredVersion(int type) {
60 fprintf(stderr, "Rollback Index Library Mock: Version Locked.\n");
61 }
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/tests/firmware_rollback_tests.c ('k') | src/platform/vboot_reference/tests/test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698