Software APIs
mod_exp_ibex.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_SIGVERIFY_MOD_EXP_IBEX_H_
6 #define OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_SIGVERIFY_MOD_EXP_IBEX_H_
7 
8 #include <stdbool.h>
9 #include <stdint.h>
10 
11 #include "sw/device/silicon_creator/lib/error.h"
12 #include "sw/device/silicon_creator/lib/sigverify/rsa_key.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif // __cplusplus
17 
18 /**
19  * Computes the modular exponentiation of an RSA signature on Ibex.
20  *
21  * Given an RSA public key and sig, this function computes sig^e mod n using
22  * Montgomery multiplication, where
23  * - sig is an RSA signature,
24  * - e and n are the exponent and the modulus of the key, respectively.
25  *
26  * The key exponent is always 65537; no other exponents are supported.
27  *
28  * @param key An RSA public key.
29  * @param sig Buffer that holds the signature, little-endian.
30  * @param result Buffer to write the result to, little-endian.
31  * @return The result of the operation.
32  */
34 rom_error_t sigverify_mod_exp_ibex(const sigverify_rsa_key_t *key,
35  const sigverify_rsa_buffer_t *sig,
36  sigverify_rsa_buffer_t *result);
37 
38 #ifdef __cplusplus
39 } // extern "C"
40 #endif // __cplusplus
41 
42 #endif // OPENTITAN_SW_DEVICE_SILICON_CREATOR_LIB_SIGVERIFY_MOD_EXP_IBEX_H_