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 |
|
package issrg.SAWS; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@author |
54 |
|
|
|
|
| 33.7% |
Uncovered Elements: 67 (101) |
Complexity: 31 |
Complexity Density: 0.34 |
|
55 |
|
public class SAWSConstant { |
56 |
|
|
57 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
58 |
0
|
public SAWSConstant() {... |
59 |
|
} |
60 |
|
|
61 |
|
final static public byte SAWSSecretRandomNumberType = 0x01; |
62 |
|
final static public byte SymmetricEncryptionKeyType = 0x02; |
63 |
|
final static public byte SAWSLastFileType = 0x03; |
64 |
|
final static public byte SAWSClientLogDataType = 0x04; |
65 |
|
final static public byte SAWSAccumulatedHashType = 0x05; |
66 |
|
final static public byte SAWSLogFileSignatureType = 0x06; |
67 |
|
final static public byte SAWSCertificateType = 0x07; |
68 |
|
final static public byte SysSAWSStartupType = 0x08; |
69 |
|
final static public byte SysSAWSShutdownType = 0x09; |
70 |
|
final static public byte SysUnauthorisedConnectionAttemptType = 0x0a; |
71 |
|
final static public byte SysAuditorNotificationType = 0x0b; |
72 |
|
final static public byte SysHeartbeatType = 0x0c; |
73 |
|
final static public byte SysClientIDType = 0x0d; |
74 |
|
final static public byte SAWSHashAlgorithmType = 0x0e; |
75 |
|
final static public byte SAWSHeaderSignatureType = 0x0f; |
76 |
|
|
77 |
|
|
78 |
|
final static public byte AsymmetricEncryptionFlag = 0x01; |
79 |
|
final static public byte SymmetricEncryptionFlag = 0x02; |
80 |
|
final static public byte NoEncryptionFlag = 0x03; |
81 |
|
final static public byte CommandFlag = 0x04; |
82 |
|
|
83 |
|
|
84 |
|
final static public byte USERSAWS = 0x00; |
85 |
|
final static public byte USERVT = 0x01; |
86 |
|
|
87 |
|
|
88 |
|
static public int HeaderLength = 27; |
89 |
|
|
90 |
|
static public int MAXINPUTSIZE = 117; |
91 |
|
static public int OUTPUTSIZE = 128; |
92 |
|
|
93 |
|
|
94 |
|
final static int TrustedLocationMissingErrCode = 0; |
95 |
|
final static int LogFileMissingErrCode = 1; |
96 |
|
final static int SNNotMatchBetweenLogAndTCBLocationErrCode =2; |
97 |
|
final static int AccHashNotMatchBetweenLogAndTCBLocationErrCode =3; |
98 |
|
final static int ADecryptErrCode = 4; |
99 |
|
|
100 |
|
final static int LogFileFormatErrCode =10; |
101 |
|
final static int LogFileReadingErrCode =11; |
102 |
|
final static int LogFileIncompleteErrCode = 12; |
103 |
|
final static int LogFileBodyReadingErrCode = 13; |
104 |
|
final static int LogFileHashReadingErrCode = 14; |
105 |
|
final static int CalculatedAccHashNotEqualsAccHashInLog = 15; |
106 |
|
final static int CertificateInLogIsNotValidAgainstRootCA =16; |
107 |
|
final static int SignatureIsNotValid = 17; |
108 |
|
final static int SecureHashNotCorrect = 18; |
109 |
|
final static int SNNotCorrectInLog =19; |
110 |
|
final static int SecureRandomRecordErrCode = 20; |
111 |
|
final static int HeaderSignatureIsNotValid = 21; |
112 |
|
|
113 |
|
final static int InvalidEncryptionFlag = 22; |
114 |
|
final static int UnauthorizedUser = 23; |
115 |
|
final static int LogFileClosed = 24; |
116 |
|
|
117 |
|
|
118 |
|
final static int VerboseInfo = 3; |
119 |
|
final static int WarningInfo = 2; |
120 |
|
final static int ErrorInfo = 1; |
121 |
|
final static int NoInfo = 0; |
122 |
|
|
123 |
|
|
124 |
|
public final static byte SHA1 = 0x00; |
125 |
|
public final static byte MD5 = 0x01; |
126 |
|
public final static byte SHA256 = 0x02; |
127 |
|
public final static byte SHA384 = 0x03; |
128 |
|
public final static byte SHA512 = 0x04; |
129 |
|
|
130 |
|
public final static String[] HASH_ALG_NAMES = {"SHA1", "MD5", "SHA256", "SHA384", "SHA512"}; |
131 |
|
public final static int[] HashLength = {20, 16, 32, 64, 64}; |
132 |
|
|
133 |
|
public static final byte ENCRYPTION_PURPOSE = 0x00; |
134 |
|
public static final byte SIGNING_PURPOSE = 0x01; |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
@param |
139 |
|
|
140 |
|
@return |
141 |
|
|
|
|
| 0% |
Uncovered Elements: 48 (48) |
Complexity: 16 |
Complexity Density: 0.33 |
|
142 |
0
|
static public String getErrorString(int errCode){... |
143 |
0
|
String str = null; |
144 |
0
|
switch (errCode){ |
145 |
0
|
case LogFileIncompleteErrCode: |
146 |
0
|
str = new String("This log file is not completed."); |
147 |
0
|
break; |
148 |
0
|
case SecureRandomRecordErrCode: |
149 |
0
|
str = new String("The secure random number is corrupt in the log file."); |
150 |
0
|
break; |
151 |
0
|
case SNNotCorrectInLog: |
152 |
0
|
str = new String("The sequence number is not correct."); |
153 |
0
|
break; |
154 |
0
|
case SecureHashNotCorrect: |
155 |
0
|
str = new String("Secure hash is not correct."); |
156 |
0
|
break; |
157 |
0
|
case SignatureIsNotValid: |
158 |
0
|
str = new String("Signature of this log is not valid."); |
159 |
0
|
break; |
160 |
0
|
case CertificateInLogIsNotValidAgainstRootCA: |
161 |
0
|
str = new String("Certificate in the log is not valid against the root CA."); |
162 |
0
|
break; |
163 |
0
|
case LogFileFormatErrCode: |
164 |
0
|
str = new String("log file format is wrong."); |
165 |
0
|
break; |
166 |
0
|
case LogFileReadingErrCode: |
167 |
0
|
str = new String("log file reading error"); |
168 |
0
|
break; |
169 |
0
|
case LogFileBodyReadingErrCode: |
170 |
0
|
str = new String("log file body reading error"); |
171 |
0
|
break; |
172 |
0
|
case LogFileHashReadingErrCode: |
173 |
0
|
str = new String("log file hash reading error"); |
174 |
0
|
break; |
175 |
0
|
case CalculatedAccHashNotEqualsAccHashInLog: |
176 |
0
|
str = new String("Calculated accumulated hash does not equal the one stored in the log."); |
177 |
0
|
break; |
178 |
0
|
case ADecryptErrCode: |
179 |
0
|
str = new String("Can't use the encryption key to read the log file."); |
180 |
0
|
break; |
181 |
0
|
case HeaderSignatureIsNotValid: |
182 |
0
|
str = new String("Signature of this log's header is not valid."); |
183 |
0
|
break; |
184 |
0
|
case InvalidEncryptionFlag: |
185 |
0
|
str = new String("The Encryption flag is not valid."); |
186 |
0
|
break; |
187 |
0
|
case UnauthorizedUser: |
188 |
0
|
str = new String("This user is not allowed to send log records."); |
189 |
0
|
break; |
190 |
|
|
191 |
|
} |
192 |
0
|
return str; |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
@param |
199 |
|
|
200 |
|
@return |
201 |
|
|
|
|
| 66% |
Uncovered Elements: 17 (50) |
Complexity: 16 |
Complexity Density: 0.32 |
|
202 |
540
|
static public String getRecordTypeString(byte RecordTypeIn){... |
203 |
540
|
String recordType = null; |
204 |
540
|
switch (RecordTypeIn) { |
205 |
28
|
case SAWSConstant.SAWSSecretRandomNumberType: recordType = new String("SAWSSecretRandomNumberType"); break; |
206 |
112
|
case SAWSConstant.SymmetricEncryptionKeyType: recordType = new String("SymmetricEncryptionKeyType"); break; |
207 |
28
|
case SAWSConstant.SAWSLastFileType: recordType = new String("SAWSLastFileType"); break; |
208 |
160
|
case SAWSConstant.SAWSClientLogDataType: recordType = new String("SAWSClientLogDataType");break; |
209 |
28
|
case SAWSConstant.SAWSAccumulatedHashType: recordType = new String("SAWSAccumulatedHashType");break; |
210 |
28
|
case SAWSConstant.SAWSLogFileSignatureType: recordType = new String("SAWSLogFileSignatureType");break; |
211 |
28
|
case SAWSConstant.SAWSCertificateType: recordType = new String("SAWSCertificateType");break; |
212 |
0
|
case SAWSConstant.SysSAWSStartupType: recordType = new String("SysSAWSStartupType");break; |
213 |
0
|
case SAWSConstant.SysSAWSShutdownType: recordType = new String("SysSAWSShutdownType");break; |
214 |
0
|
case SAWSConstant.SysUnauthorisedConnectionAttemptType: recordType = new String("SysUnauthorisedConnectionAttemptType");break; |
215 |
0
|
case SAWSConstant.SysAuditorNotificationType: recordType = new String("SysAuditorNotificationType");break; |
216 |
72
|
case SAWSConstant.SysHeartbeatType: recordType = new String("SysHeartbeatType");break; |
217 |
0
|
case SAWSConstant.SysClientIDType: recordType = new String("SysClientIDType");break; |
218 |
28
|
case SAWSConstant.SAWSHashAlgorithmType: recordType = new String("SAWSHashAlgorithmType"); break; |
219 |
28
|
case SAWSConstant.SAWSHeaderSignatureType: recordType = new String("SAWSHeaderSignatureType"); break; |
220 |
0
|
default: recordType = null; |
221 |
|
} |
222 |
540
|
return recordType; |
223 |
|
} |
224 |
|
|
225 |
|
|
226 |
|
} |