summaryrefslogtreecommitdiff
path: root/host/lib/include/host_signature.h
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/include/host_signature.h')
-rw-r--r--host/lib/include/host_signature.h59
1 files changed, 42 insertions, 17 deletions
diff --git a/host/lib/include/host_signature.h b/host/lib/include/host_signature.h
index fb03c6c5..2c7f24ae 100644
--- a/host/lib/include/host_signature.h
+++ b/host/lib/include/host_signature.h
@@ -13,35 +13,57 @@
#include "utility.h"
#include "vboot_struct.h"
+struct vb2_private_key;
+struct vb2_signature;
-/* Initialize a signature struct. */
+/**
+ * Initialize a signature struct.
+ *
+ * @param sig Structure to initialize
+ * @param sig_data Pointer to signature data buffer (after sig)
+ * @param sig_size Size of signature data buffer in bytes
+ * @param data_size Amount of data signed in bytes
+ */
void SignatureInit(VbSignature* sig, uint8_t* sig_data,
uint64_t sig_size, uint64_t data_size);
+void vb2_init_signature(struct vb2_signature *sig, uint8_t *sig_data,
+ uint32_t sig_size, uint32_t data_size);
-/* Allocate a new signature with space for a [sig_size] byte signature. */
+/**
+ * Allocate a new signature.
+ *
+ * @param sig_size Size of signature in bytes
+ * @param data_size Amount of data signed in bytes
+ *
+ * @return The signature or NULL if error. Caller must free() it.
+ */
VbSignature* SignatureAlloc(uint64_t sig_size, uint64_t data_size);
+struct vb2_signature *vb2_alloc_signature(uint32_t sig_size,
+ uint32_t data_size);
-
-/* Copy a signature key from [src] to [dest].
+/**
+ * Copy a signature.
*
- * Returns 0 if success, non-zero if error. */
+ * @param dest Destination signature
+ * @param src Source signature
+ *
+ * @return VB2_SUCCESS, or non-zero if error. */
int SignatureCopy(VbSignature* dest, const VbSignature* src);
+int vb2_copy_signature(struct vb2_signature *dest,
+ const struct vb2_signature *src);
-
-/* Calculates a SHA-512 checksum.
- * Caller owns the returned pointer, and must free it with Free().
+/**
+ * Calculate a SHA-512 digest-only signature.
*
- * Returns NULL on error. */
-VbSignature* CalculateChecksum(const uint8_t* data, uint64_t size);
-
-
-/* Calculates a hash of the data using the algorithm from the specified key.
- * Caller owns the returned pointer, and must free it with Free().
+ * Caller owns the returned pointer, and must free() it.
*
- * Returns NULL on error. */
-VbSignature* CalculateHash(const uint8_t* data, uint64_t size,
- const VbPrivateKey* key);
+ * @param data Pointer to data to hash
+ * @param size Length of data in bytes
+ *
+ * @return The signature, or NULL if error.
+ */
+struct vb2_signature *vb2_sha512_signature(const uint8_t *data, uint32_t size);
/* Calculates a signature for the data using the specified key.
* Caller owns the returned pointer, and must free it with Free().
@@ -49,6 +71,9 @@ VbSignature* CalculateHash(const uint8_t* data, uint64_t size,
* Returns NULL on error. */
VbSignature* CalculateSignature(const uint8_t* data, uint64_t size,
const VbPrivateKey* key);
+struct vb2_signature *vb2_calculate_signature(
+ const uint8_t *data, uint32_t size,
+ const struct vb2_private_key *key);
/* Calculates a signature for the data using the specified key and
* an external program.