mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 23:13:34 +08:00
Add encryption function for the crypto_backend and px4_crypto
Take into use libtomcrypt library to add RSA and some other algorithms for SW ecnryption use case Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
committed by
Beat Küng
parent
634d911b74
commit
fc2668cba1
@@ -96,6 +96,37 @@ crypto_session_handle_t crypto_open(px4_crypto_algorithm_t algorithm);
|
||||
|
||||
void crypto_close(crypto_session_handle_t *handle);
|
||||
|
||||
/*
|
||||
* Get a key from keystore, possibly encrypted
|
||||
*
|
||||
* handle: an open crypto context; the returned key will be encrypted
|
||||
* according to this context
|
||||
* key_idx: Index of the requested key in the keystore
|
||||
* key: The provided buffer to the key
|
||||
* max_len: the length of the provided key buffer. Returns the actual key size
|
||||
* encryption_key_idx: The key index in keystore to be used for encrypting
|
||||
* returns true on success, false on failure
|
||||
*/
|
||||
bool crypto_get_encrypted_key(crypto_session_handle_t handle,
|
||||
uint8_t key_idx,
|
||||
uint8_t *key,
|
||||
size_t *max_len,
|
||||
uint8_t encryption_key_idx);
|
||||
|
||||
/*
|
||||
* Get the generated nonce value
|
||||
*
|
||||
* handle: an open crypto context; the returned nonce is the one associsated
|
||||
* with this context/algorithm
|
||||
* nonce: The provided buffer to the key. If NULL, only length is returned
|
||||
* nonce_len: the length of the nonce value
|
||||
* encryption_key_idx: The key index in keystore to be used for encrypting
|
||||
* returns true on success, false on failure
|
||||
*/
|
||||
bool crypto_get_nonce(crypto_session_handle_t handle,
|
||||
uint8_t *nonce,
|
||||
size_t *nonce_len);
|
||||
|
||||
/*
|
||||
* Perform signature check using an open session to crypto
|
||||
* handle: session handle, returned by open
|
||||
@@ -110,6 +141,25 @@ bool crypto_signature_check(crypto_session_handle_t handle,
|
||||
const uint8_t *message,
|
||||
size_t message_size);
|
||||
|
||||
bool crypto_encrypt_data(crypto_session_handle_t handle,
|
||||
uint8_t key_index,
|
||||
const uint8_t *message,
|
||||
size_t message_size,
|
||||
uint8_t *cipher,
|
||||
size_t *cipher_size);
|
||||
|
||||
/*
|
||||
* Returns a minimum data block size on which the crypto operations can be
|
||||
* performed. Performing encryption on sizes which are not multiple of this
|
||||
* are valid, but the output will be padded to the multiple of this value
|
||||
* Input for decryption must be multiple of this value.
|
||||
* handle: session handle, returned by open
|
||||
* key_idx: key to be used for encryption/decryption
|
||||
* returs the block size
|
||||
*/
|
||||
|
||||
size_t crypto_get_min_blocksize(crypto_session_handle_t handle, uint8_t key_idx);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user