NetBurner 3.1
SecureSerToEthFactoryApp/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 
28 #ifndef _SSHUSER_H_
29 #define _SSHUSER_H_
30 
31 /*
32  ******************************************************************************
33  ******************************************************************************
34  *
35  * OpenSSL format is Privacy-enhanced Electronic Mail (PEM) encoded
36  *
37  ******************************************************************************
38  ******************************************************************************
39  */
40 
41 /*
42  ******************************************************************************
43  *
44  * Global data definitions (declared in sshuser.cpp)
45  *
46  ******************************************************************************
47  */
48 
49 /* SSH keys PEM encoded (sshuser.cpp) */
50 extern char* gSshRsaKeyPemEncoded[ ( SERIAL_BURNER_KEY_SIZE_MAX_PEM + 1 ) ];
51 extern char* gSshDsaKeyPemEncoded[ ( SERIAL_BURNER_KEY_SIZE_MAX_PEM + 1 ) ];
52 
53 /*
54  ******************************************************************************
55  *
56  * Functions
57  *
58  ******************************************************************************
59  */
60 /*
61  ******************************************************************************
62  *
63  * "C" Routines
64  *
65  ******************************************************************************
66  */
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
71 /*
72  ******************************************************************************
73 
74  User provided SSH username and password authenticate routine.
75 
76  Parameters:
77  usernamePtr - Username in plain text
78  passwordPtr - Password in plain text
79 
80  Return:
81  1 - Authenticated, all else error
82 
83  Notes:
84  None
85 
86  ******************************************************************************
87  */
88 int SshUserAuthenticate( const char* usernamePtr, const char* passwordPtr );
89 
90 /*
91  ******************************************************************************
92 
93  User provided SSH key retrieval
94 
95  Parameters:
96  keyRequested - Type key requested
97  SSH_KEY_RSA
98  SSH_KEY_DSS (DSA)
99  keyBufferPtr - Key from user storage
100  keyLengthPtr - Size of key in 8 bit bytes
101 
102  Return:
103  0 - key and length is valid, -1 - key requested not available
104 
105  Notes:
106  openSS(L|H) key pair, PEM encoded, no encrypted or with passphrase.
107  Key must be valid. Each type asked for once at at startup.
108  The buffer containing the key will NOT be deallocated.
109  Server will disable task scheduling calling OSLock, copy contents, then
110  call OSUnlock
111 
112  ******************************************************************************
113  */
114 int SshUserGetKey( int keyRequested, const unsigned char** keyBufferPtr,
115  int* keyLengthPtr );
116 
117 /*
118  ******************************************************************************
119 
120  Verifies SSH key
121 
122  Parameters:
123  pemKeyPtr - PEM encoded key data
124  pemKeySize - PEM encoded key size in bytes
125  keyTypePtr - Pointer for key type
126 
127  Return:
128  TRUE - OK, FALSE invalid.
129 
130  Notes:
131  None
132 
133  ******************************************************************************
134  */
135 BOOL SshUserVerifyKey( char* pemKeyPtr, int pemKeySize, int* keyTypePtr );
136 
137 /*
138  ******************************************************************************
139 
140  Checks and installs SSH keys permanent defaults
141 
142  Parameters:
143  None
144 
145  Return:
146  None
147 
148  Notes:
149  Sets NV_Settings elements:
150  SshKeyRsaSource;
151  SshKeyRsaLength;
152  SshKeyDsaSource;
153  SshKeyDsaLength;
154 
155  ******************************************************************************
156  */
157 void SshUserSetDefault( void );
158 
159 /*
160  ******************************************************************************
161 
162  Retrieves and set keys
163 
164  Parameters:
165  None
166 
167  Return:
168  None
169 
170  Notes:
171  Clears SSH settings for CertificateNKeysDataStatus element of
172  struct NV_SettingsStruct if retrieval error occurs
173 
174  ******************************************************************************
175  */
176 void SshUserRetrieveKeys( void );
177 
178 #ifdef __cplusplus
179 };
180 #endif
181 
182 /*
183  ******************************************************************************
184  *
185  * "C++" Routines
186  *
187  ******************************************************************************
188  */
189 
190 #endif /* _SSHUSER_H_ */
191 
192