blob: 7c98c353a00110be78ddedba8122d7682fddf7c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/* Copyright 2015 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Platform.h"
#include "TPM_Types.h"
#include "trng.h"
#include "util.h"
#include "version.h"
uint16_t _cpri__GenerateRandom(size_t random_size,
uint8_t *buffer)
{
rand_bytes(buffer, random_size);
return random_size;
}
/*
* Return the pointer to the character immediately after the first dash
* encountered in the passed in string, or NULL if there is no dashes in the
* string.
*/
static const char *char_after_dash(const char *str)
{
char c;
do {
c = *str++;
if (c == '-')
return str;
} while (c);
return NULL;
}
/*
* The properly formatted build_info string has the ec code SHA1 after the
* first dash, and tpm2 code sha1 after the second dash.
*/
void _plat__GetFwVersion(uint32_t *firmwareV1, uint32_t *firmwareV2)
{
const char *ver_str = char_after_dash(build_info);
/* Just in case the build_info string is misformatted. */
*firmwareV1 = 0;
*firmwareV2 = 0;
if (!ver_str)
return;
*firmwareV1 = strtoi(ver_str, NULL, 16);
ver_str = char_after_dash(ver_str);
if (!ver_str)
return;
*firmwareV2 = strtoi(ver_str, NULL, 16);
}
|