VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main/Forms/BenchmarkDialog.h
blob: 228bbf21adedec7d5f7bab0351795b299117a66d (plain)
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
/*
 Derived from source code of TrueCrypt 7.1a, which is
 Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
 by the TrueCrypt License 3.0.

 Modifications and additions to the original source code (contained in this file) 
 and all other portions of this file are Copyright (c) 2013-2016 IDRIX
 and are governed by the Apache License 2.0 the full text of which is
 contained in the file License.txt included in VeraCrypt binary and source
 code distribution packages.
*/

#ifndef TC_HEADER_Main_Forms_BenchmarkDialog
#define TC_HEADER_Main_Forms_BenchmarkDialog

#include "Forms.h"
#include "Main/Main.h"

namespace VeraCrypt
{
	class BenchmarkDialog : public BenchmarkDialogBase
	{
	public:
		BenchmarkDialog (wxWindow *parent);

	protected:
		enum
		{
			ColumnAlgorithm = 0,
			ColumnEncryption,
			ColumnDecryption,
			ColumnMean
		};

		struct BenchmarkResult
		{
			wstring AlgorithmName;
			uint64 EncryptionSpeed;
			uint64 DecryptionSpeed;
			uint64 MeanSpeed;
		};

		void DoBenchmark (list<BenchmarkResult>& results, Buffer& buffer);
		void OnBenchmarkButtonClick (wxCommandEvent& event);
		
		class BenchmarkThreadRoutine : public WaitThreadRoutine
		{
		public:
			BenchmarkDialog* m_pDlg;
			list<BenchmarkResult>& m_results;
			Buffer& m_buffer;
			BenchmarkThreadRoutine(BenchmarkDialog* pDlg, list<BenchmarkResult>& results, Buffer& buffer)
				: m_pDlg(pDlg), m_results(results), m_buffer(buffer) { }
			virtual ~BenchmarkThreadRoutine() { }
			virtual void ExecutionCode(void) { m_pDlg->DoBenchmark (m_results, m_buffer); }
		};
	};
}

#endif // TC_HEADER_Main_Forms_BenchmarkDialog
an> { system_error_buffer = (char *)malloc(128); snprintf_s(system_error_buffer, 128, "Unknown error %d", err->zip_err); system_error_buffer[128 - 1] = '\0'; /* make sure string is NUL-terminated */ zip_error_string = NULL; system_error_string = system_error_buffer; } else { zip_error_string = _zip_err_str[err->zip_err].description; switch (_zip_err_str[err->zip_err].type) { case ZIP_ET_SYS: { size_t len = strerrorlen_s(err->sys_err) + 1; system_error_buffer = malloc(len); strerror_s(system_error_buffer, len, err->sys_err); system_error_string = system_error_buffer; break; } case ZIP_ET_ZLIB: system_error_string = zError(err->sys_err); break; case ZIP_ET_LIBZIP: { zip_uint8_t error = GET_ERROR_FROM_DETAIL(err->sys_err); int index = GET_INDEX_FROM_DETAIL(err->sys_err); if (error == 0) { system_error_string = NULL; } else if (error >= _zip_err_details_count) { system_error_buffer = (char *)malloc(128); snprintf_s(system_error_buffer, 128, "invalid detail error %u", error); system_error_buffer[128 - 1] = '\0'; /* make sure string is NUL-terminated */ system_error_string = system_error_buffer; } else if (_zip_err_details[error].type == ZIP_DETAIL_ET_ENTRY && index < MAX_DETAIL_INDEX) { system_error_buffer = (char *)malloc(128); snprintf_s(system_error_buffer, 128, "entry %d: %s", index, _zip_err_details[error].description); system_error_buffer[128 - 1] = '\0'; /* make sure string is NUL-terminated */ system_error_string = system_error_buffer; } else { system_error_string = _zip_err_details[error].description; } break; } default: system_error_string = NULL; } } if (system_error_string == NULL) { free(system_error_buffer); return zip_error_string; } else { size_t length = strlen(system_error_string); if (zip_error_string) { size_t length_error = strlen(zip_error_string); if (length + length_error + 2 < length) { free(system_error_buffer); return _zip_err_str[ZIP_ER_MEMORY].description; } length += length_error + 2; } if (length == SIZE_MAX || (s = (char *)malloc(length + 1)) == NULL) { free(system_error_buffer); return _zip_err_str[ZIP_ER_MEMORY].description; } snprintf_s(s, length + 1, "%s%s%s", (zip_error_string ? zip_error_string : ""), (zip_error_string ? ": " : ""), system_error_string); err->str = s; free(system_error_buffer); return s; } }