-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decoupling business layer from hardware layer in Signer component (#177)
- Added HAL headers - Added HAL implementation for Ledger - Refactored necessary common sources - Refactored necessary Signer sources - Updated Signer Makefile to include HAL code - Removed HSM_SIMULATOR define in favor of HSM_PLATFORM_* defines - Included X86 (partial) implemenations of some HAL modules (exceptions, logging, hashing) - Renamed UI communication module to avoid name clashing with HAL - Changed platform define in Makefile
- Loading branch information
1 parent
5c19f28
commit 91d99cf
Showing
68 changed files
with
1,460 additions
and
841 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2021 RSK Labs Ltd | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to | ||
* deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
* sell copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
#ifndef __HAL_COMMUNICATION_H | ||
#define __HAL_COMMUNICATION_H | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
/** | ||
* @brief Initializes the communication module | ||
* | ||
* @param msg_buffer The buffer to use for communication | ||
* @param msg_buffer_size The size of the message buffer in bytes | ||
* | ||
* @returns whether the initialisation succeeded | ||
*/ | ||
bool communication_init(unsigned char* msg_buffer, size_t msg_buffer_size); | ||
|
||
/** | ||
* @brief Get a pointer to the message buffer | ||
* | ||
* @returns a pointer to the message buffer | ||
*/ | ||
unsigned char* communication_get_msg_buffer(); | ||
|
||
/** | ||
* @brief Get the message buffer size | ||
* | ||
* @returns the message buffer size | ||
*/ | ||
size_t communication_get_msg_buffer_size(); | ||
|
||
/** | ||
* @brief Exchanges bytes with the host. This function blocks until the host | ||
* sends a message. | ||
* | ||
* The message exchanges data with the host using the msg_buffer. If there are | ||
* any bytes to transmit, they are transmitted first. After that the function | ||
* blocks until a new message is received from the host. | ||
* | ||
* @param tx The number of bytes sent to the host | ||
* | ||
* @returns the number of bytes received from the host | ||
*/ | ||
unsigned short communication_io_exchange(unsigned short tx); | ||
|
||
/** | ||
* @brief Finalizes the communication module | ||
*/ | ||
void communication_finalize(void); | ||
|
||
#endif // __HAL_COMMUNICATION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2021 RSK Labs Ltd | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to | ||
* deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
* sell copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
#ifndef __HAL_ENDORSEMENT_H | ||
#define __HAL_ENDORSEMENT_H | ||
|
||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <stdbool.h> | ||
|
||
/** | ||
* @brief Endorses the given message | ||
* | ||
* @param msg The message to attest | ||
* @param msg_size The size of the message to attest | ||
* @param signature_out Where the signature should be output | ||
* @param signature_out_length [in/out] the length of the output buffer / | ||
* length of the produced signature | ||
* | ||
* @returns whether endorsement succeeded | ||
*/ | ||
bool endorsement_sign(uint8_t* msg, | ||
size_t msg_size, | ||
uint8_t* signature_out, | ||
uint8_t* signature_out_length); | ||
|
||
/** | ||
* @brief Grabs the hash of the currently running code | ||
* | ||
* @param code_hash_out Where the code hash should be output | ||
* @param code_hash_out_length [in/out] the length of the output buffer / | ||
* length of the produced code hash | ||
* | ||
* @returns whether code hash gathering succeeded | ||
*/ | ||
bool endorsement_get_code_hash(uint8_t* code_hash_out, | ||
uint8_t* code_hash_out_length); | ||
|
||
/** | ||
* @brief Grabs the endorsement public key | ||
* | ||
* @param public_key_out Where the public key should be output | ||
* @param public_key_out_length [in/out] the length of the output buffer / | ||
* length of the produced public key | ||
* | ||
* @returns whether public key gathering succeeded | ||
*/ | ||
bool endorsement_get_public_key(uint8_t* public_key_out, | ||
uint8_t* public_key_out_length); | ||
|
||
#endif // __HAL_ENDORSEMENT_H |
Oops, something went wrong.