diff options
author | Randall Spangler <rspangler@chromium.org> | 2010-06-17 14:45:22 -0700 |
---|---|---|
committer | Randall Spangler <rspangler@chromium.org> | 2010-06-17 14:45:22 -0700 |
commit | 620c38cf34eadcd222535b01fb71c5e9fbc1cb80 (patch) | |
tree | 55c883fd01447b0ffdf6c121f4b7c6817cbc53b0 /host/include | |
parent | d52030f340d14f8039360a39ec6a938d31e083d0 (diff) | |
download | vboot-620c38cf34eadcd222535b01fb71c5e9fbc1cb80.tar.gz |
Remove unused files, and tidy the directory structure of the remaining ones.
Review URL: http://codereview.chromium.org/2815011
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/file_keys.h | 43 | ||||
-rw-r--r-- | host/include/signature_digest.h | 35 |
2 files changed, 78 insertions, 0 deletions
diff --git a/host/include/file_keys.h b/host/include/file_keys.h new file mode 100644 index 00000000..285a3e5b --- /dev/null +++ b/host/include/file_keys.h @@ -0,0 +1,43 @@ +/* Copyright (c) 2010 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. + * + * Utility functions for file and key handling. + */ + +#ifndef VBOOT_REFERENCE_FILE_KEYS_H_ +#define VBOOT_REFERENCE_FILE_KEYS_H_ + +#include "cryptolib.h" + +/* Read file named [input_file] into a buffer and stores the length into + * [len]. + * + * Returns a pointer to the buffer. Caller owns the returned pointer and + * must free it. + */ +uint8_t* BufferFromFile(const char* input_file, uint64_t* len); + +/* Read a pre-processed RSA Public Key from file [input_file]. + * + * Returns a pointer to the read key. Caller owns the returned pointer and + * must free it. + */ +RSAPublicKey* RSAPublicKeyFromFile(const char* input_file); + +/* Returns the appropriate digest for the data in [input_file] + * based on the signature [algorithm]. + * Caller owns the returned digest and must free it. + */ +uint8_t* DigestFile(char* input_file, int sig_algorithm); + +/* Helper function to invoke external program to calculate signature on + * [input_file] using private key [key_file] and signature algorithm + * [algorithm]. + * + * Returns the signature. Caller owns the buffer and must Free() it. + */ +uint8_t* SignatureFile(const char* input_file, const char* key_file, + int algorithm); + +#endif /* VBOOT_REFERENCE_FILE_KEYS_H_ */ diff --git a/host/include/signature_digest.h b/host/include/signature_digest.h new file mode 100644 index 00000000..55662b94 --- /dev/null +++ b/host/include/signature_digest.h @@ -0,0 +1,35 @@ +/* Copyright (c) 2010 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. + */ + +#ifndef VBOOT_REFERENCE_SIGNATURE_DIGEST_H_ +#define VBOOT_REFERENCE_SIGNATURE_DIGEST_H_ + +#include <inttypes.h> + +/* Returns a buffer with DigestInfo (which depends on [algorithm]) + * prepended to [digest]. + */ +uint8_t* PrependDigestInfo(int algorithm, uint8_t* digest); + +/* Function that outputs the message digest of the contents of a buffer in a + * format that can be used as input to OpenSSL for an RSA signature. + * Needed until the stable OpenSSL release supports SHA-256/512 digests for + * RSA signatures. + * + * Returns DigestInfo || Digest where DigestInfo is the OID depending on the + * choice of the hash algorithm (see padding.c). Caller owns the returned + * pointer and must Free() it. + */ +uint8_t* SignatureDigest(const uint8_t* buf, uint64_t len, int algorithm); + +/* Calculates the signature on a buffer [buf] of length [len] using + * the private RSA key file from [key_file] and signature algorithm + * [algorithm]. + * + * Returns the signature. Caller owns the buffer and must Free() it. + */ +uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file, + int algorithm); +#endif /* VBOOT_REFERENCE_SIGNATURE_DIGEST_H_ */ |