-
Notifications
You must be signed in to change notification settings - Fork 29
/
cryptography_interface.h
73 lines (66 loc) · 4.6 KB
/
cryptography_interface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright 2021, by the California Institute of Technology.
* ALL RIGHTS RESERVED. United States Government Sponsorship acknowledged.
* Any commercial use must be negotiated with the Office of Technology
* Transfer at the California Institute of Technology.
*
* This software may be subject to U.S. export control laws. By accepting
* this software, the user agrees to comply with all applicable U.S.
* export laws and regulations. User has the responsibility to obtain
* export licenses, or other export authority as may be required before
* exporting such information to foreign countries or providing access to
* foreign persons.
*/
#ifndef CRYPTOLIB_CRYPTOGRAPHY_INTERFACE_H
#define CRYPTOLIB_CRYPTOGRAPHY_INTERFACE_H
#ifdef NOS3 // NOS3/cFS build is ready
#include "common_types.h"
#include "osapi.h"
#else // Assume build outside of NOS3/cFS infrastructure
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#endif
#include "crypto_structs.h"
typedef struct
{
// Cryptography Interface Initialization & Management Functions
int32_t (*cryptography_config)(void);
int32_t (*cryptography_init)(void);
int32_t (*cryptography_shutdown)(void);
// Cryptography Interface Functions
int32_t (*cryptography_encrypt)(uint8_t *data_out, size_t len_data_out, uint8_t *data_in, size_t len_data_in,
uint8_t *key, uint32_t len_key, SecurityAssociation_t *sa_ptr, uint8_t *iv,
uint32_t iv_len, uint8_t *ecs, uint8_t padding, char *cam_cookies);
int32_t (*cryptography_decrypt)(uint8_t *data_out, size_t len_data_out, uint8_t *data_in, size_t len_data_in,
uint8_t *key, uint32_t len_key, SecurityAssociation_t *sa_ptr, uint8_t *iv,
uint32_t iv_len, uint8_t *ecs, uint8_t *acs, char *cam_cookies);
int32_t (*cryptography_authenticate)(uint8_t *data_out, size_t len_data_out, uint8_t *data_in, size_t len_data_in,
uint8_t *key, uint32_t len_key,
SecurityAssociation_t *sa_ptr, // For key index or key references (when key not
// passed in explicitly via key param)
uint8_t *iv, uint32_t iv_len, uint8_t *mac, uint32_t mac_size, uint8_t *aad,
uint32_t aad_len, uint8_t ecs, uint8_t acs, char *cam_cookies);
int32_t (*cryptography_validate_authentication)(uint8_t *data_out, size_t len_data_out, const uint8_t *data_in,
const size_t len_data_in, uint8_t *key, uint32_t len_key,
SecurityAssociation_t *sa_ptr, const uint8_t *iv, uint32_t iv_len,
const uint8_t *mac, uint32_t mac_size, const uint8_t *aad,
uint32_t aad_len, uint8_t ecs, uint8_t acs, char *cam_cookies);
int32_t (*cryptography_aead_encrypt)(uint8_t *data_out, size_t len_data_out, uint8_t *data_in, size_t len_data_in,
uint8_t *key, uint32_t len_key, SecurityAssociation_t *sa_ptr, uint8_t *iv,
uint32_t iv_len, uint8_t *mac, uint32_t mac_size, uint8_t *aad,
uint32_t aad_len, uint8_t encrypt_bool, uint8_t authenticate_bool,
uint8_t aad_bool, uint8_t *ecs, uint8_t *acs, char *cam_cookies);
int32_t (*cryptography_aead_decrypt)(uint8_t *data_out, size_t len_data_out, uint8_t *data_in, size_t len_data_in,
uint8_t *key, uint32_t len_key, SecurityAssociation_t *sa_ptr, uint8_t *iv,
uint32_t iv_len, uint8_t *aad, uint32_t aad_len, uint8_t *mac,
uint32_t mac_size, uint8_t decrypt_bool, uint8_t authenticate_bool,
uint8_t aad_bool, uint8_t *ecs, uint8_t *acs, char *cam_cookies);
int32_t (*cryptography_get_acs_algo)(int8_t algo_enum);
int32_t (*cryptography_get_ecs_algo)(int8_t algo_enum);
} CryptographyInterfaceStruct, *CryptographyInterface;
CryptographyInterface get_cryptography_interface_libgcrypt(void);
CryptographyInterface get_cryptography_interface_kmc_crypto_service(void);
CryptographyInterface get_cryptography_interface_wolfssl(void);
CryptographyInterface get_cryptography_interface_custom(void);
#endif // CRYPTOLIB_CRYPTOGRAPHY_INTERFACE_H