mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-16 00:57:35 +08:00
Add call-gates to px4_crypto for protected build
This adds kernel-userspace interfaces to crypto layer Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
committed by
Beat Küng
parent
d681782c7f
commit
d6a4e158cf
@@ -208,6 +208,8 @@ public:
|
||||
|
||||
size_t get_min_blocksize(uint8_t key_idx);
|
||||
|
||||
static int crypto_ioctl(unsigned int cmd, unsigned long arg);
|
||||
|
||||
private:
|
||||
crypto_session_handle_t _crypto_handle;
|
||||
static px4_sem_t _lock;
|
||||
|
||||
@@ -39,6 +39,7 @@ extern "C" {
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <px4_platform_common/crypto_algorithms.h>
|
||||
#include "crypto_backend_definitions.h"
|
||||
|
||||
@@ -181,6 +182,63 @@ bool crypto_encrypt_data(crypto_session_handle_t handle,
|
||||
|
||||
size_t crypto_get_min_blocksize(crypto_session_handle_t handle, uint8_t key_idx);
|
||||
|
||||
|
||||
/* Crypto IOCTLs, to access backend from user space */
|
||||
|
||||
#define _CRYPTOIOC(_n) (_IOC(_CRYPTOIOCBASE, _n))
|
||||
|
||||
#define CRYPTOIOCOPEN _CRYPTOIOC(1)
|
||||
typedef struct cryptoiocopen {
|
||||
px4_crypto_algorithm_t algorithm;
|
||||
crypto_session_handle_t *handle;
|
||||
} cryptoiocopen_t;
|
||||
|
||||
#define CRYPTOIOCCLOSE _CRYPTOIOC(2)
|
||||
|
||||
#define CRYPTOIOCENCRYPT _CRYPTOIOC(3)
|
||||
typedef struct cryptoiocencrypt {
|
||||
crypto_session_handle_t *handle;
|
||||
uint8_t key_index;
|
||||
const uint8_t *message;
|
||||
size_t message_size;
|
||||
uint8_t *cipher;
|
||||
size_t *cipher_size;
|
||||
bool ret;
|
||||
} cryptoiocencrypt_t;
|
||||
|
||||
#define CRYPTOIOCGENKEY _CRYPTOIOC(4)
|
||||
typedef struct cryptoiocgenkey {
|
||||
crypto_session_handle_t *handle;
|
||||
uint8_t idx;
|
||||
bool persistent;
|
||||
bool ret;
|
||||
} cryptoiocgenkey_t;
|
||||
|
||||
#define CRYPTOIOCGETNONCE _CRYPTOIOC(5)
|
||||
typedef struct cryptoiocgetnonce {
|
||||
crypto_session_handle_t *handle;
|
||||
uint8_t *nonce;
|
||||
size_t *nonce_len;
|
||||
bool ret;
|
||||
} cryptoiocgetnonce_t;
|
||||
|
||||
#define CRYPTOIOCGETKEY _CRYPTOIOC(6)
|
||||
typedef struct cryptoiocgetkey {
|
||||
crypto_session_handle_t *handle;
|
||||
uint8_t key_idx;
|
||||
uint8_t *key;
|
||||
size_t *max_len;
|
||||
uint8_t encryption_key_idx;
|
||||
bool ret;
|
||||
} cryptoiocgetkey_t;
|
||||
|
||||
#define CRYPTOIOCGETBLOCKSZ _CRYPTOIOC(7)
|
||||
typedef struct cryptoiocgetblocksz {
|
||||
crypto_session_handle_t *handle;
|
||||
uint8_t key_idx;
|
||||
size_t ret;
|
||||
} cryptoiocgetblocksz_t;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user