Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
...
...
#define NX_CRYPTO_DH_H
#include "nx_crypto_huge_number.h"
#define NX_CRYPTO_DIFFIE_HELLMAN_GROUP_2_KEY_SIZE
#define NX_CRYPTO_DIFFIE_HELLMAN_MAX_KEY_SIZE
#define NX_CRYPTO_DIFFIE_HELLMAN_BUFFER_SIZE
#define NX_CRYPTO_DIFFIE_HELLMAN_SCRATCH_SIZE
#define NX_CRYPTO_DH_GROUP_2_GENERATOR
#define NX_CRYPTO_DH_GROUP_2
#define NX_CRYPTO_DH_GROUP_TEST
NX_CRYPTO_DH_STRUCT
_nx_crypto_dh_setup(NX_CRYPTO_DH *, UCHAR *, UINT *, ULONG, ULONG *);
_nx_crypto_dh_compute_secret(NX_CRYPTO_DH *, UCHAR *, ULONG *, UCHAR *, ULONG, ULONG *);
Files
loading...
CodeScopeSTM32 Libraries and Samplesnetxduocrypto_libraries/inc/nx_crypto_dh.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** NetX Crypto Component */ /** */ /** Diffie-Hellman (DH) */ /** */... /**************************************************************************/ /**************************************************************************/ ... /**************************************************************************/ /* */ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* nx_crypto_dh.h PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* Timothy Stapko, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This file defines the basic Application Interface (API) to the */ /* NetX Crypto DH module. */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ /* 09-30-2020 Timothy Stapko Modified comment(s), */ /* resulting in version 6.1 */ /* */... /**************************************************************************/ #ifndef NX_CRYPTO_DH_H #define NX_CRYPTO_DH_H /* Determine if a C++ compiler is being used. If so, ensure that standard C is used to process the API information. *//* ... */ #ifdef __cplusplus /* Yes, C++ compiler is present. Use standard C. */ extern "C" { #endif #include "nx_crypto_huge_number.h" /* Diffie-Hellman key size. Buffer size for calculations is twice the key size */ #define NX_CRYPTO_DIFFIE_HELLMAN_GROUP_2_KEY_SIZE (128) /* 1024 bits/8. */ #define NX_CRYPTO_DIFFIE_HELLMAN_MAX_KEY_SIZE (NX_CRYPTO_DIFFIE_HELLMAN_GROUP_2_KEY_SIZE) /* Buffer and scratch buffer sizes are calculated from the maximum key size. */ #define NX_CRYPTO_DIFFIE_HELLMAN_BUFFER_SIZE (NX_CRYPTO_DIFFIE_HELLMAN_MAX_KEY_SIZE * 4) #define NX_CRYPTO_DIFFIE_HELLMAN_SCRATCH_SIZE (NX_CRYPTO_DIFFIE_HELLMAN_BUFFER_SIZE * 8) /* Diffie-Hellman groups and key constants. */ #define NX_CRYPTO_DH_GROUP_2_GENERATOR (0x2) /* Generator constant for Diffie-Hellman group 2. */ #define NX_CRYPTO_DH_GROUP_2 (0x2) /* Standard DH group 2 for IPSEC. */ #define NX_CRYPTO_DH_GROUP_TEST (0xFF) /* DH group used for testing. Note that this will only be valid in test builds. */ 7 defines /* Diffie-Hellman Key-exchange control structure. */ typedef struct NX_CRYPTO_DH_STRUCT { /* The size of the key being used. This is primarily for testing, but also allows for future expansion. The value is assigned in _nx_crypto_dh_setup depending on the chosen group. *//* ... */ UINT nx_crypto_dh_key_size; /* The private key is generated by nx_crypto_dh_setup and is a random number. During the computation, the private key is used as exponent. Therefore the buffer size is the same as the key size. This number does not expand during the power-modulus computation. Make the array in units of UINT to make sure the starting address is 4-byte aligned. *//* ... */ HN_UBASE nx_crypto_dh_private_key_buffer[NX_CRYPTO_DIFFIE_HELLMAN_MAX_KEY_SIZE >> HN_SIZE_SHIFT]; /* The modulus, determined by the Diffie-Hellman group selected in the call to nx_crypto_dh_setup. This number does not expand during the power-modulus computation. Make the array in units of UINT to make sure the starting address is 4-byte aligned. *//* ... */ HN_UBASE *nx_crypto_dh_modulus; ...} NX_CRYPTO_DH; /* Function prototypes */ UINT _nx_crypto_dh_setup(NX_CRYPTO_DH *dh_ptr, UCHAR *local_public_key_ptr, UINT *local_public_key_len_ptr, ULONG dh_group_num, HN_UBASE *scratch_buf_ptr); UINT _nx_crypto_dh_compute_secret(NX_CRYPTO_DH *dh_ptr, UCHAR *share_secret_key_ptr, ULONG *share_secret_key_len_ptr, UCHAR *remote_public_key, ULONG remote_public_key_len, HN_UBASE *scratch_buf_ptr); #ifdef __cplusplus }extern "C" { ... } #endif /* ... */ #endif /* NX_CRYPTO_DH_H */...