Software APIs
ecdsa.h
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #ifndef OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_OWNERSHIP_ECDSA_H_
6 #define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_OWNERSHIP_ECDSA_H_
7 
8 #include <stdint.h>
9 
11 #include "sw/device/silicon_creator/lib/drivers/hmac.h"
12 #include "sw/device/silicon_creator/lib/error.h"
13 #include "sw/device/silicon_creator/lib/ownership/datatypes.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /**
20  * Initializes ECDSA crypto.
21  */
22 rom_error_t ecdsa_init(void);
23 
24 /**
25  * Verifies an ECDSA P-256 signature.
26  *
27  * @param pubkey The public key needed to verify the signature
28  * expressed as 32-bit little endian words: (le(X) || le(Y)).
29  * @param signature The signature expressed as 32-bit little
30  * endian words: (le(R) || le(S))
31  * @param digest The digest of the message to verify.
32  * @return hardened_bool_t
33  */
34 
35 hardened_bool_t ecdsa_verify_digest(const ecdsa_p256_public_key_t *pubkey,
36  const ecdsa_p256_signature_t *signature,
37  const hmac_digest_t *digest);
38 
39 /**
40  * Verifies an ECDSA P-256 signature.
41  *
42  * @param pubkey The public key needed to verify the signature
43  * expressed as 32-bit little endian words: (le(X) || le(Y)).
44  * @param signature The signature expressed as 32-bit little
45  * endian words: (le(R) || le(S))
46  * @param message The message to verify.
47  * @param message_len The length of the message to verify.
48  * @return hardened_bool_t
49  */
50 hardened_bool_t ecdsa_verify_message(const ecdsa_p256_public_key_t *pubkey,
51  const ecdsa_p256_signature_t *signature,
52  const void *message, size_t message_len);
53 
54 #ifdef __cplusplus
55 }
56 #endif
57 
58 #endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_OWNERSHIP_ECDSA_H_