1 /* Copyright 2020 The ChromiumOS Authors
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 *
5 * Stub hwcrypto API implementations which should be implemented by the caller.
6 */
7
8 #include "2api.h"
9
10 #if !defined(X86_SHA_EXT) && !defined(ARMV8_CRYPTO_EXT)
11 __attribute__((weak))
vb2ex_hwcrypto_digest_init(enum vb2_hash_algorithm hash_alg,uint32_t data_size)12 vb2_error_t vb2ex_hwcrypto_digest_init(enum vb2_hash_algorithm hash_alg,
13 uint32_t data_size)
14 {
15 return VB2_ERROR_EX_HWCRYPTO_UNSUPPORTED;
16 }
17
18 __attribute__((weak))
vb2ex_hwcrypto_digest_extend(const uint8_t * buf,uint32_t size)19 vb2_error_t vb2ex_hwcrypto_digest_extend(const uint8_t *buf, uint32_t size)
20 {
21 return VB2_ERROR_SHA_EXTEND_ALGORITHM; /* Should not be called. */
22 }
23
24 __attribute__((weak))
vb2ex_hwcrypto_digest_finalize(uint8_t * digest,uint32_t digest_size)25 vb2_error_t vb2ex_hwcrypto_digest_finalize(uint8_t *digest,
26 uint32_t digest_size)
27 {
28 return VB2_ERROR_SHA_FINALIZE_ALGORITHM; /* Should not be called. */
29 }
30 #endif
31
32 __attribute__((weak))
vb2ex_hwcrypto_rsa_verify_digest(const struct vb2_public_key * key,const uint8_t * sig,const uint8_t * digest)33 vb2_error_t vb2ex_hwcrypto_rsa_verify_digest(const struct vb2_public_key *key,
34 const uint8_t *sig, const uint8_t *digest)
35 {
36 return VB2_ERROR_EX_HWCRYPTO_UNSUPPORTED;
37 }
38
39 #if !defined(VB2_X86_RSA_ACCELERATION) && !defined(ARM64_RSA_ACCELERATION)
40 __attribute__((weak))
vb2ex_hwcrypto_modexp(const struct vb2_public_key * key,uint8_t * inout,void * workbuf,size_t workbuf_size,int exp)41 vb2_error_t vb2ex_hwcrypto_modexp(const struct vb2_public_key *key, uint8_t *inout,
42 void *workbuf, size_t workbuf_size, int exp)
43 {
44 return VB2_ERROR_EX_HWCRYPTO_UNSUPPORTED;
45 }
46 #endif
47