NetBurner 3.5.6
PDF Version
SshServerUserKey/src/sshuser.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
5#ifndef _SSHUSER_H_
6#define _SSHUSER_H_
7
8#include <ssh/NetBurner/UserAuthManager.h>
9
10/* Certificate and key status */
11#define SSH_KEY_LIBRARY_DEFAULT ((uint8_t)0x00)
12#define SSH_KEY_DEFAULT ((uint8_t)0x01)
13#define SSH_KEY_USER_INSTALLED ((uint8_t)0x02)
14
15/* HTML Certificate and Key file status */
16#define SSH_KEY_VALID (0)
17#define SSH_KEY_NOT_FOUND (1)
18#define SSH_KEY_FILE_INVALID (2)
19#define SSH_KEY_CERTIFICATE_INVALID (3)
20#define SSH_KEY_INVALID (4)
21
22/*
23 ******************************************************************************
24 * Key size
25 * SSH MAX_PRIVKEY_SIZE 1700 (options.h)
26 * SSH key size (PEM) < 4K (empirical)
27 * NULL terminated for conversion
28 *
29 ******************************************************************************
30 */
31#define SSH_KEY_SIZE_MAX_PEM ((4 * 1024) - 1)
32
33/*
34 ******************************************************************************
35 *
36 * Global data definitions (declared in sshuser.cpp)
37 *
38 ******************************************************************************
39 */
40
41/* SSH keys PEM encoded (sshuser.cpp) */
42extern char *gSshRsaKeyPemEncoded[(SSH_KEY_SIZE_MAX_PEM + 1)];
43extern char *gSshEccKeyPemEncoded[(SSH_KEY_SIZE_MAX_PEM + 1)];
44
45/*
46 ******************************************************************************
47 *
48 * "C" Routines
49 *
50 ******************************************************************************
51 */
52#ifdef __cplusplus
53extern "C"
54{
55#endif
56
57 /*
58 ******************************************************************************
59
60 User provided SSH username and passuint16_t authenticate routine.
61
62 Parameters:
63 usernamePtr - Username in plain text
64 authValPtr - Password or Key in plain text
65 authType - Specify if the authorization value is a password or key
66
67 Return:
68 1 - Authenticated, all else error
69
70 Notes:
71 None
72
73 ******************************************************************************
74 */
75 int SshUserAuthenticate(const char *usernamePtr, const char *authValPtr, AuthType authType);
76
77 /*
78 ******************************************************************************
79
80 User provided SSH key retrieval
81
82 Parameters:
83 keyRequested - Type key requested
84 SSH_KEY_ECC
85 SSH_KEY_RSA
86 keyBufferPtr - Key from user storage
87 keyLengthPtr - Size of key in 8 bit uint8_ts
88
89 Return:
90 0 - key and length is valid, -1 - key requested not available
91
92 Notes:
93 openSS(L|H) key pair, PEM encoded, no encrypted or with passphrase.
94 Key must be valid. Each type asked for once at at startup.
95 The buffer containing the key will NOT be deallocated.
96 Server will disable task scheduling calling OSLock, copy contents, then
97 call OSUnlock
98
99 ******************************************************************************
100 */
101 int SshUserGetKey(int keyRequested, const unsigned char **keyBufferPtr, int *keyLengthPtr);
102
103 /*
104 ******************************************************************************
105
106 Verifies SSH key
107
108 Parameters:
109 pemKeyPtr - PEM encoded key data
110 pemKeySize - PEM encoded key size in uint8_ts
111 keyTypePtr - Pointer for key type
112
113 Return:
114 TRUE - OK, FALSE invalid.
115
116 Notes:
117 None
118
119 ******************************************************************************
120 */
121 BOOL SshUserVerifyKey(char *pemKeyPtr, int pemKeySize, int *keyTypePtr);
122
123 /*
124 ******************************************************************************
125
126 Checks and installs SSH keys permanent defaults
127
128 Parameters:
129 None
130
131 Return:
132 None
133
134 Notes:
135 Sets NV_Settings elements:
136 SshKeyEccSource;
137 SshKeyEccLength;
138 SshKeyRsaSource;
139 SshKeyRsaLength;
140
141 ******************************************************************************
142 */
143 void SshUserSetDefault(void);
144
145 /*
146 ******************************************************************************
147
148 Retrieves and set keys
149
150 Parameters:
151 None
152
153 Return:
154 None
155
156 Notes:
157 Clears SSH settings for CertificateNKeysDataStatus element of
158 struct NV_SettingsStruct if retrieval error occurs
159
160 ******************************************************************************
161 */
162 void SshUserRetrieveKeys(void);
163
164#ifdef __cplusplus
165};
166#endif
167
168 /*
169 ******************************************************************************
170 *
171 * "C++" Routines
172 *
173 ******************************************************************************
174 */
175
176#endif /* _SSHUSER_H_ */
AuthType
The types of authorization requests that are managed. These just indicate what the has value is,...
Definition UserAuthManager.h:44