signature_digest.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. #ifndef VBOOT_REFERENCE_SIGNATURE_DIGEST_H_
  6. #define VBOOT_REFERENCE_SIGNATURE_DIGEST_H_
  7. #include <stdint.h>
  8. /* Returns a buffer with DigestInfo (which depends on [algorithm])
  9. * prepended to [digest].
  10. */
  11. uint8_t* PrependDigestInfo(enum vb2_hash_algorithm hash_alg, uint8_t* digest);
  12. /* Function that outputs the message digest of the contents of a buffer in a
  13. * format that can be used as input to OpenSSL for an RSA signature.
  14. * Needed until the stable OpenSSL release supports SHA-256/512 digests for
  15. * RSA signatures.
  16. *
  17. * Returns DigestInfo || Digest where DigestInfo is the OID depending on the
  18. * choice of the hash algorithm (see padding.c). Caller owns the returned
  19. * pointer and must Free() it.
  20. */
  21. uint8_t* SignatureDigest(const uint8_t* buf, uint64_t len,
  22. unsigned int algorithm);
  23. /* Calculates the signature on a buffer [buf] of length [len] using
  24. * the private RSA key file from [key_file] and signature algorithm
  25. * [algorithm].
  26. *
  27. * Returns the signature. Caller owns the buffer and must Free() it.
  28. */
  29. uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
  30. unsigned int algorithm);
  31. #endif /* VBOOT_REFERENCE_SIGNATURE_DIGEST_H_ */