• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2014 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  * Host-side misc functions for verified boot.
6  */
7 
8 #ifndef VBOOT_REFERENCE_UTIL_MISC_H_
9 #define VBOOT_REFERENCE_UTIL_MISC_H_
10 
11 #include "vboot_struct.h"
12 struct rsa_st;
13 
14 /* Prints the sha1sum of the given VbPublicKey to stdout. */
15 void PrintPubKeySha1Sum(VbPublicKey* key);
16 
17 /*
18  * Our packed RSBPublicKey buffer (historically in files ending with ".keyb",
19  * but also the part of VbPublicKey and struct vb2_packed_key that is
20  * referenced by .key_offset) has this binary format:
21  *
22  *   struct {
23  *       uint32_t nwords;            // size of RSA key in 32-bit words
24  *       uint32_t N0inv;             // -1 / N[0] mod 2^32
25  *       uint32_t modulus[nwords];   // modulus as a little endian array
26  *       uint32_t R2[nwords];        // R^2  as little endian array
27  *   };
28  *
29  * This function allocates and extracts that binary structure directly
30  * from the RSA private key, rather than from a file.
31  *
32  * @param rsa_private_key     RSA private key (duh)
33  * @param keyb_data	      Pointer to newly allocated binary blob
34  * @param keyb_size	      Size of newly allocated binary blob
35  *
36  * @return 0 on success, non-zero if unable to allocate enough memory.
37  */
38 int vb_keyb_from_rsa(struct rsa_st *rsa_private_key,
39 		     uint8_t **keyb_data, uint32_t *keyb_size);
40 
41 #endif  /* VBOOT_REFERENCE_UTIL_MISC_H_ */
42