NetBurner 3.0
SshServerUserKey/sshuser.h
1 /* Revision: 2.8.7 */
2 
3 /******************************************************************************
4 * Copyright 1998-2018 NetBurner, Inc. ALL RIGHTS RESERVED
5 *
6 * Permission is hereby granted to purchasers of NetBurner Hardware to use or
7 * modify this computer program for any use as long as the resultant program
8 * is only executed on NetBurner provided hardware.
9 *
10 * No other rights to use this program or its derivatives in part or in
11 * whole are granted.
12 *
13 * It may be possible to license this or other NetBurner software for use on
14 * non-NetBurner Hardware. Contact sales@Netburner.com for more information.
15 *
16 * NetBurner makes no representation or warranties with respect to the
17 * performance of this computer program, and specifically disclaims any
18 * responsibility for any damages, special or consequential, connected with
19 * the use of this program.
20 *
21 * NetBurner
22 * 5405 Morehouse Dr.
23 * San Diego, CA 92121
24 * www.netburner.com
25 ******************************************************************************/
26 
27 #ifndef _SSHUSER_H_
28 #define _SSHUSER_H_
29 
30 
31 /* Certificate and key status */
32 #define SSH_KEY_LIBRARY_DEFAULT ( (BYTE)0x00 )
33 #define SSH_KEY_DEFAULT ( (BYTE)0x01 )
34 #define SSH_KEY_USER_INSTALLED ( (BYTE)0x02 )
35 
36 /* HTML Certificate and Key file status */
37 #define SSH_KEY_VALID ( 0 )
38 #define SSH_KEY_NOT_FOUND ( 1 )
39 #define SSH_KEY_FILE_INVALID ( 2 )
40 #define SSH_KEY_CERTIFICATE_INVALID ( 3 )
41 #define SSH_KEY_INVALID ( 4 )
42 
43 
44 
45 /*
46  ******************************************************************************
47  * Key size
48  * SSH MAX_PRIVKEY_SIZE 1700 (options.h)
49  * SSH key size (PEM) < 4K (empirical)
50  * NULL terminated for conversion
51  *
52  ******************************************************************************
53  */
54 #define SSH_KEY_SIZE_MAX_PEM ( ( 4 * 1024 ) - 1 )
55 
56 
57 /*
58  ******************************************************************************
59  *
60  * Global data definitions (declared in sshuser.cpp)
61  *
62  ******************************************************************************
63  */
64 
65 /* SSH keys PEM encoded (sshuser.cpp) */
66 extern char* gSshRsaKeyPemEncoded[ ( SSH_KEY_SIZE_MAX_PEM + 1 ) ];
67 extern char* gSshDsaKeyPemEncoded[ ( SSH_KEY_SIZE_MAX_PEM + 1 ) ];
68 
69 /*
70  ******************************************************************************
71  *
72  * "C" Routines
73  *
74  ******************************************************************************
75  */
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79 
80 /*
81  ******************************************************************************
82 
83  User provided SSH username and password authenticate routine.
84 
85  Parameters:
86  usernamePtr - Username in plain text
87  passwordPtr - Password in plain text
88 
89  Return:
90  1 - Authenticated, all else error
91 
92  Notes:
93  None
94 
95  ******************************************************************************
96  */
97 int SshUserAuthenticate( const char* usernamePtr, const char* passwordPtr );
98 
99 /*
100  ******************************************************************************
101 
102  User provided SSH key retrieval
103 
104  Parameters:
105  keyRequested - Type key requested
106  SSH_KEY_RSA
107  SSH_KEY_DSS (DSA)
108  keyBufferPtr - Key from user storage
109  keyLengthPtr - Size of key in 8 bit bytes
110 
111  Return:
112  0 - key and length is valid, -1 - key requested not available
113 
114  Notes:
115  openSS(L|H) key pair, PEM encoded, no encrypted or with passphrase.
116  Key must be valid. Each type asked for once at at startup.
117  The buffer containing the key will NOT be deallocated.
118  Server will disable task scheduling calling OSLock, copy contents, then
119  call OSUnlock
120 
121  ******************************************************************************
122  */
123 int SshUserGetKey( int keyRequested, const unsigned char** keyBufferPtr, int* keyLengthPtr );
124 
125 /*
126  ******************************************************************************
127 
128  Verifies SSH key
129 
130  Parameters:
131  pemKeyPtr - PEM encoded key data
132  pemKeySize - PEM encoded key size in bytes
133  keyTypePtr - Pointer for key type
134 
135  Return:
136  TRUE - OK, FALSE invalid.
137 
138  Notes:
139  None
140 
141  ******************************************************************************
142  */
143 BOOL SshUserVerifyKey( char* pemKeyPtr, int pemKeySize, int* keyTypePtr );
144 
145 /*
146  ******************************************************************************
147 
148  Checks and installs SSH keys permanent defaults
149 
150  Parameters:
151  None
152 
153  Return:
154  None
155 
156  Notes:
157  Sets NV_Settings elements:
158  SshKeyRsaSource;
159  SshKeyRsaLength;
160  SshKeyDsaSource;
161  SshKeyDsaLength;
162 
163  ******************************************************************************
164  */
165 void SshUserSetDefault( void );
166 
167 /*
168  ******************************************************************************
169 
170  Retrieves and set keys
171 
172  Parameters:
173  None
174 
175  Return:
176  None
177 
178  Notes:
179  Clears SSH settings for CertificateNKeysDataStatus element of
180  struct NV_SettingsStruct if retrieval error occurs
181 
182  ******************************************************************************
183  */
184 void SshUserRetrieveKeys( void );
185 
186 #ifdef __cplusplus
187 };
188 #endif
189 
190 /*
191  ******************************************************************************
192  *
193  * "C++" Routines
194  *
195  ******************************************************************************
196  */
197 
198 #endif /* _SSHUSER_H_ */
199 
200