-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTorComm.tex
More file actions
276 lines (212 loc) · 11.2 KB
/
TorComm.tex
File metadata and controls
276 lines (212 loc) · 11.2 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
\documentclass[a4paper,12pt]{article}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{geometry}
\usepackage{listings}
\usepackage[svgnames, table]{xcolor}
\geometry{
a4paper,
total={180mm,255mm},
left=20mm,
top=20mm,
}
\definecolor{pseudoColor}{rgb}{0.94,0.94,0.93}
\definecolor{cgreen}{RGB}{8, 110, 16}
\lstdefinestyle{PseudoCode}{
backgroundcolor=\color{pseudoColor},
keepspaces=true,
numbers=left,
numbersep=5pt,
stringstyle=\color{purple},
keywordstyle=[1]\color{blue},
keywordstyle=[2]\color{red},
keywordstyle=[3]\color{cyan},
numberstyle=\tiny\color{magenta},
commentstyle=\color{cgreen},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=4
}
\lstdefinelanguage{Pseudo}{
keywords={Generate, set, if, If, Else, Pause, Sleep},
keywords=[2]{sha256, chacha},
keywords=[3]{key},
comment=[l]{\#},
}
\lstset{style=PseudoCode,language=Pseudo}
\hypersetup{
linktoc=all,
hidelinks=true
}
\title{
\Huge TorComm - Secure P2P Communication \\
\ \\
\ \\
\ \\
\Large Documentation
}
\author{Taha Canturk\\kibnakanoto@protonmail.com}
\date{2024-05-20}
\begin{document}
\maketitle
\newpage
\newpage
\tableofcontents
\newpage
\pagenumbering{roman}
\section{Networking}
\subsection{one on one}
\subsection{groupchat}
\section{Cryptography}
The key communication protocol used is Elliptic Cryptography Diffie Hellman ($ECDH$)
The encryption protocol used is Elliptic Cryptography Integrated Encryption Scheme ($ECIES$)
There are currently 140 cryptographic protocols to choose from. the protocol consists of all cryptographic algorithms required for a secure communication
i.e. Hashing algorithm, cipher algorithm, cipher mode, verification algorithm, elliptic curve
\subsection{Cipher Suites}
\tiny
\begin{center}
\begin{tabular}{ c c }
SECP256K1\_ECIES\_ECDSA\_AES256\_CBC\_SHA256 & SECP256K1\_ECIES\_ECDSA\_AES256\_CBC\_SHA512 \\
SECP256K1\_ECIES\_ECDSA\_AES192\_CBC\_SHA256 & SECP256K1\_ECIES\_ECDSA\_AES192\_CBC\_SHA512 \\
SECP256K1\_ECIES\_ECDSA\_AES128\_CBC\_SHA256 & SECP256K1\_ECIES\_ECDSA\_AES128\_CBC\_SHA512 \\
SECP256K1\_ECIES\_AES256\_GCM\_SHA256 & SECP256K1\_ECIES\_AES256\_GCM\_SHA512 \\
SECP256K1\_ECIES\_AES192\_GCM\_SHA256 & SECP256K1\_ECIES\_AES192\_GCM\_SHA512 \\
SECP256K1\_ECIES\_AES128\_GCM\_SHA256 & SECP256K1\_ECIES\_AES128\_GCM\_SHA512 \\
SECP256K1\_ECIES\_HMAC\_AES256\_CBC\_SHA256 & SECP256K1\_ECIES\_HMAC\_AES256\_CBC\_SHA512 \\
SECP256K1\_ECIES\_HMAC\_AES192\_CBC\_SHA256 & SECP256K1\_ECIES\_HMAC\_AES192\_CBC\_SHA512 \\
SECP256K1\_ECIES\_HMAC\_AES128\_CBC\_SHA256 & SECP256K1\_ECIES\_HMAC\_AES128\_CBC\_SHA512 \\
SECP256K1\_ECIES\_HMAC\_AES128\_GCM\_SHA512 & SECP256K1\_ECIES\_ECDSA\_CHACHA20\_SHA256 \\
SECP256K1\_ECIES\_ECDSA\_CHACHA20\_SHA512 & SECP256K1\_ECIES\_HMAC\_CHACHA20\_SHA256 \\
SECP256K1\_ECIES\_HMAC\_CHACHA20\_SHA512 & SECP256R1\_ECIES\_ECDSA\_AES256\_CBC\_SHA256 \\
SECP256R1\_ECIES\_ECDSA\_AES256\_CBC\_SHA512 & SECP256R1\_ECIES\_ECDSA\_AES192\_CBC\_SHA256 \\
SECP256R1\_ECIES\_ECDSA\_AES192\_CBC\_SHA512 & SECP256R1\_ECIES\_ECDSA\_AES128\_CBC\_SHA256 \\
SECP256R1\_ECIES\_ECDSA\_AES128\_CBC\_SHA512 & SECP256R1\_ECIES\_AES256\_GCM\_SHA256 \\
SECP256R1\_ECIES\_AES256\_GCM\_SHA512 & SECP256R1\_ECIES\_AES192\_GCM\_SHA256 \\
SECP256R1\_ECIES\_AES192\_GCM\_SHA512 & SECP256R1\_ECIES\_AES128\_GCM\_SHA256 \\
SECP256R1\_ECIES\_AES128\_GCM\_SHA512 & SECP256R1\_ECIES\_HMAC\_AES256\_CBC\_SHA256 \\
SECP256R1\_ECIES\_HMAC\_AES256\_CBC\_SHA512 & SECP256R1\_ECIES\_HMAC\_AES192\_CBC\_SHA256 \\
SECP256R1\_ECIES\_HMAC\_AES192\_CBC\_SHA512 & SECP256R1\_ECIES\_HMAC\_AES128\_CBC\_SHA256 \\
SECP256R1\_ECIES\_HMAC\_AES128\_CBC\_SHA512 & SECP256R1\_ECIES\_HMAC\_AES128\_GCM\_SHA512 \\
SECP256R1\_ECIES\_ECDSA\_CHACHA20\_SHA256 & SECP256R1\_ECIES\_ECDSA\_CHACHA20\_SHA512 \\
SECP256R1\_ECIES\_HMAC\_CHACHA20\_SHA256 & SECP256R1\_ECIES\_HMAC\_CHACHA20\_SHA512 \\
SECP521R1\_ECIES\_ECDSA\_AES256\_CBC\_SHA256 & SECP521R1\_ECIES\_ECDSA\_AES256\_CBC\_SHA512 \\
SECP521R1\_ECIES\_ECDSA\_AES192\_CBC\_SHA256 & SECP521R1\_ECIES\_ECDSA\_AES192\_CBC\_SHA512 \\
SECP521R1\_ECIES\_ECDSA\_AES128\_CBC\_SHA256 & SECP521R1\_ECIES\_ECDSA\_AES128\_CBC\_SHA512 \\
SECP521R1\_ECIES\_AES256\_GCM\_SHA256 & SECP521R1\_ECIES\_AES256\_GCM\_SHA512 \\
SECP521R1\_ECIES\_AES192\_GCM\_SHA256 & SECP521R1\_ECIES\_AES192\_GCM\_SHA512 \\
SECP521R1\_ECIES\_AES128\_GCM\_SHA256 & SECP521R1\_ECIES\_AES128\_GCM\_SHA512 \\
SECP521R1\_ECIES\_HMAC\_AES256\_CBC\_SHA256 & SECP521R1\_ECIES\_HMAC\_AES256\_CBC\_SHA512 \\
SECP521R1\_ECIES\_HMAC\_AES192\_CBC\_SHA256 & SECP521R1\_ECIES\_HMAC\_AES192\_CBC\_SHA512 \\
SECP521R1\_ECIES\_HMAC\_AES128\_CBC\_SHA256 & SECP521R1\_ECIES\_HMAC\_AES128\_CBC\_SHA512 \\
SECP521R1\_ECIES\_HMAC\_AES128\_GCM\_SHA512 & SECP521R1\_ECIES\_ECDSA\_CHACHA20\_SHA256 \\
SECP521R1\_ECIES\_ECDSA\_CHACHA20\_SHA512 & SECP521R1\_ECIES\_HMAC\_CHACHA20\_SHA256 \\
SECP521R1\_ECIES\_HMAC\_CHACHA20\_SHA512 & BRAINPOOL256R1\_ECIES\_ECDSA\_AES256\_CBC\_SHA256 \\
BRAINPOOL256R1\_ECIES\_ECDSA\_AES256\_CBC\_SHA512 & BRAINPOOL256R1\_ECIES\_ECDSA\_AES192\_CBC\_SHA256 \\
BRAINPOOL256R1\_ECIES\_ECDSA\_AES192\_CBC\_SHA512 & BRAINPOOL256R1\_ECIES\_ECDSA\_AES128\_CBC\_SHA256 \\
BRAINPOOL256R1\_ECIES\_ECDSA\_AES128\_CBC\_SHA512 & BRAINPOOL256R1\_ECIES\_AES256\_GCM\_SHA256 \\
BRAINPOOL256R1\_ECIES\_AES256\_GCM\_SHA512 & BRAINPOOL256R1\_ECIES\_AES192\_GCM\_SHA256 \\
BRAINPOOL256R1\_ECIES\_AES192\_GCM\_SHA512 & BRAINPOOL256R1\_ECIES\_AES128\_GCM\_SHA256 \\
BRAINPOOL256R1\_ECIES\_AES128\_GCM\_SHA512 & BRAINPOOL256R1\_ECIES\_HMAC\_AES256\_CBC\_SHA256 \\
BRAINPOOL256R1\_ECIES\_HMAC\_AES256\_CBC\_SHA512 & BRAINPOOL256R1\_ECIES\_HMAC\_AES192\_CBC\_SHA256 \\
BRAINPOOL256R1\_ECIES\_HMAC\_AES192\_CBC\_SHA512 & BRAINPOOL256R1\_ECIES\_HMAC\_AES128\_CBC\_SHA256 \\
BRAINPOOL256R1\_ECIES\_HMAC\_AES128\_CBC\_SHA512 & BRAINPOOL256R1\_ECIES\_HMAC\_AES128\_GCM\_SHA512 \\
BRAINPOOL256R1\_ECIES\_ECDSA\_CHACHA20\_SHA256 & BRAINPOOL256R1\_ECIES\_ECDSA\_CHACHA20\_SHA512 \\
BRAINPOOL256R1\_ECIES\_HMAC\_CHACHA20\_SHA256 & BRAINPOOL256R1\_ECIES\_HMAC\_CHACHA20\_SHA512 \\
BRAINPOOL512R1\_ECIES\_ECDSA\_AES256\_CBC\_SHA256 & BRAINPOOL512R1\_ECIES\_ECDSA\_AES256\_CBC\_SHA512 \\
BRAINPOOL512R1\_ECIES\_ECDSA\_AES192\_CBC\_SHA256 & BRAINPOOL512R1\_ECIES\_ECDSA\_AES192\_CBC\_SHA512 \\
BRAINPOOL512R1\_ECIES\_ECDSA\_AES128\_CBC\_SHA256 & BRAINPOOL512R1\_ECIES\_ECDSA\_AES128\_CBC\_SHA512 \\
BRAINPOOL512R1\_ECIES\_AES256\_GCM\_SHA256 & BRAINPOOL512R1\_ECIES\_AES256\_GCM\_SHA512 \\
BRAINPOOL512R1\_ECIES\_AES192\_GCM\_SHA256 & BRAINPOOL512R1\_ECIES\_AES192\_GCM\_SHA512 \\
BRAINPOOL512R1\_ECIES\_AES128\_GCM\_SHA256 & BRAINPOOL512R1\_ECIES\_AES128\_GCM\_SHA512 \\
BRAINPOOL512R1\_ECIES\_HMAC\_AES256\_CBC\_SHA256 & BRAINPOOL512R1\_ECIES\_HMAC\_AES256\_CBC\_SHA512 \\
BRAINPOOL512R1\_ECIES\_HMAC\_AES192\_CBC\_SHA256 & BRAINPOOL512R1\_ECIES\_HMAC\_AES192\_CBC\_SHA512 \\
BRAINPOOL512R1\_ECIES\_HMAC\_AES128\_CBC\_SHA256 & BRAINPOOL512R1\_ECIES\_HMAC\_AES128\_CBC\_SHA512 \\
BRAINPOOL512R1\_ECIES\_HMAC\_AES128\_GCM\_SHA512 & BRAINPOOL512R1\_ECIES\_ECDSA\_CHACHA20\_SHA256 \\
BRAINPOOL512R1\_ECIES\_ECDSA\_CHACHA20\_SHA512 & BRAINPOOL512R1\_ECIES\_HMAC\_CHACHA20\_SHA256 \\
\end{tabular}
\end{center}
\normalsize
\section{Errors}
Everything about errors and error codes are stored in errors.h file.
networking related errors are stored in $log/network.log$ and other bugs (mainly cryptographic) is stored in $log/errors.log$
\section{Blocking}
\subsection{Algorithm}
blocking an ip address code is in comm.cpp, the algorithm is as follows:
\begin{figure}[htb]
\begin{small}
\begin{lstlisting}[language=pseudo, escapeinside={(*}{*)}]
Generate(iv) # 12-byte iv
key = 32-byte key from (*$keys$*) file
pepper = 32-byte pepper from (*$keys$*) file
# encrypt ip
encrypted = AES-256-CBC(key=key, data=ip, iv=iv)
# store encrypted ip in blocked file
write(encrypted + " " + iv, "blocked")
\end{lstlisting}
\end{small}
\caption{Block}\label{blocking}
\end{figure}
\section{Key Protector}
\subsection{What Is It}
The Key protector app in security folder is used to secure a 32-byte symmetric key, 2-byte port key, 32-byte pepper. The output is in a file named $keys$. The data in this file is used for securing the local data. It needs a 4-32 byte password generated and stored by you.
To set the password, execute the $key$ file which would generate the $get\_keys$ executable which is the key protector program. Store a copy of $get\_keys$ in somewhere secure if you don't want to lose it. If you lose the $get\_keys$ and don't have the $keys$ file, then your key is forever lost.
\subsubsection{What is the keys used for}
The key is used for securing any personal data stored on the device. Such as the configuration file for each session. If you're texting somebody and want to save their ip address so you can conviniently text them again without re-entering the ip address and reconfiguring the communication session, the ip and other data needs to be encrypted and stored.
The 2-byte port key is used for encrypting the ports in configuration files
\bigskip
\bigskip
\bigskip
\bigskip
\bigskip
\bigskip
\bigskip
\bigskip
\subsection{Algorithm}
The C++ code is in $security/key.cpp$, but the basic idea is as following:
\begin{figure}[htb]
\begin{small}
\begin{lstlisting}[language=pseudo, escapeinside={(*}{*)}]
Generate key, pepper, iv
Ask user for 4-32 byte password
# chacha cipher function: chacha(data, key, iv)
(*$result = pepper \oplus password$*)
# Use sha256(result) as symmetric key to encrypt key using chacha
encrypted key = chacha(key, sha256(result), iv)
Store sha256(result) as sha256(sha256(result))
Generate exe for getting key ((*$get\_keys$*)):
Store sha256(sha256(result)), iv, encrypted key, pepper (excluding 3-bytes)
Ask user for password:
Guess 3 bytes of password of unknown pepper
(*$result = pepper \oplus password$*)
Compute sha256(sha256(result)) and compare with stored sha256(sha256(result)).
if no match:
Continue guessing all possible 3-bytes
if user guessed more than once:
If guessed 3 or 6 times and while guess count is smaller than 7:
Pause for 10s
Else if Every 5 guesses:
Pause for 30s
Sleep(random(1s,5s)) # make it a random range so that timing attacks aren't possible
If not valid match:
If more than 10 password inputs made:
Delete everything in current directory
ask user for password again and repeat process.
Else:
# Decrypt encrypted key using sha256(result) as key with chacha algorithm
decrypted key = chacha(encrypted key, sha256(result), iv)
Write decrypted key to file
set key, pepper, iv, password, and every other array stored in ram to zero
\end{lstlisting}
\end{small}
\caption{Key Protector}\label{key_protector}
\end{figure}
\subsection{Security}
since 2/3-bytes of the pepper is not stored in the $get\_keys$ file, they need to be guessed with every password that is entered. If we say 3 bytes of the data needs to be guessed. then the number of combinations in password is multiplied with $256^3$.
e.g. if you have a 4-digit pin as your password, then there are $10^4$ combinations in your password. Then the total number of combinations in password is $(256^3)(10^4) = 167772160000$.
This doesn't mean that your password needs to be smaller, it should still be 6-16 characters of numbers, small/capital letters, and symbols.
\end{document}