1 | // Copyright (c) Microsoft. All rights reserved.
|
---|
2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
---|
3 |
|
---|
4 | #ifndef DEVICE_AUTH_H
|
---|
5 | #define DEVICE_AUTH_H
|
---|
6 |
|
---|
7 | #ifdef __cplusplus
|
---|
8 | extern "C" {
|
---|
9 | #include <cstdint>
|
---|
10 | #include <cstddef>
|
---|
11 | #else
|
---|
12 | #include <stdint.h>
|
---|
13 | #include <stddef.h>
|
---|
14 | #endif /* __cplusplus */
|
---|
15 |
|
---|
16 | #include "umock_c/umock_c_prod.h"
|
---|
17 | #include "azure_macro_utils/macro_utils.h"
|
---|
18 |
|
---|
19 | typedef struct IOTHUB_SECURITY_INFO_TAG* IOTHUB_SECURITY_HANDLE;
|
---|
20 |
|
---|
21 | #define DEVICE_AUTH_TYPE_VALUES \
|
---|
22 | AUTH_TYPE_UNKNOWN, \
|
---|
23 | AUTH_TYPE_SAS, \
|
---|
24 | AUTH_TYPE_X509, \
|
---|
25 | AUTH_TYPE_SYMM_KEY
|
---|
26 |
|
---|
27 | MU_DEFINE_ENUM_WITHOUT_INVALID(DEVICE_AUTH_TYPE, DEVICE_AUTH_TYPE_VALUES);
|
---|
28 |
|
---|
29 | typedef struct DEVICE_AUTH_SAS_INFO_TAG
|
---|
30 | {
|
---|
31 | uint64_t expiry_seconds;
|
---|
32 | const char* token_scope;
|
---|
33 | const char* key_name;
|
---|
34 | } DEVICE_AUTH_SAS_INFO;
|
---|
35 |
|
---|
36 | typedef struct DEVICE_AUTH_SAS_RESULT_TAG
|
---|
37 | {
|
---|
38 | const char* sas_token;
|
---|
39 | } DEVICE_AUTH_SAS_RESULT;
|
---|
40 |
|
---|
41 | typedef struct DEVICE_AUTH_X509_RESULT_TAG
|
---|
42 | {
|
---|
43 | const char* x509_cert;
|
---|
44 | const char* x509_alias_key;
|
---|
45 | } DEVICE_AUTH_X509_RESULT;
|
---|
46 |
|
---|
47 | typedef struct DEVICE_AUTH_CREDENTIAL_INFO_TAG
|
---|
48 | {
|
---|
49 | DEVICE_AUTH_TYPE dev_auth_type;
|
---|
50 | DEVICE_AUTH_SAS_INFO sas_info;
|
---|
51 | } DEVICE_AUTH_CREDENTIAL_INFO;
|
---|
52 |
|
---|
53 | typedef struct CREDENTIAL_RESULT_TAG
|
---|
54 | {
|
---|
55 | DEVICE_AUTH_TYPE dev_auth_type;
|
---|
56 | union
|
---|
57 | {
|
---|
58 | DEVICE_AUTH_SAS_RESULT sas_result;
|
---|
59 | DEVICE_AUTH_X509_RESULT x509_result;
|
---|
60 | } auth_cred_result;
|
---|
61 | } CREDENTIAL_RESULT;
|
---|
62 |
|
---|
63 |
|
---|
64 | MOCKABLE_FUNCTION(, IOTHUB_SECURITY_HANDLE, iothub_device_auth_create);
|
---|
65 | MOCKABLE_FUNCTION(, void, iothub_device_auth_destroy, IOTHUB_SECURITY_HANDLE, handle);
|
---|
66 | MOCKABLE_FUNCTION(, DEVICE_AUTH_TYPE, iothub_device_auth_get_type, IOTHUB_SECURITY_HANDLE, handle);
|
---|
67 | MOCKABLE_FUNCTION(, CREDENTIAL_RESULT*, iothub_device_auth_generate_credentials, IOTHUB_SECURITY_HANDLE, handle, const DEVICE_AUTH_CREDENTIAL_INFO*, dev_auth_cred);
|
---|
68 |
|
---|
69 | #ifdef USE_EDGE_MODULES
|
---|
70 | MOCKABLE_FUNCTION(, char*, iothub_device_auth_get_trust_bundle, IOTHUB_SECURITY_HANDLE, handle);
|
---|
71 | #endif
|
---|
72 |
|
---|
73 |
|
---|
74 | #ifdef __cplusplus
|
---|
75 | }
|
---|
76 | #endif /* __cplusplus */
|
---|
77 |
|
---|
78 | #endif // DEVICE_AUTH
|
---|