ssl_prequisites.tex 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. \chapter{The Secure Layer \label{chap:ssl}}
  2. Transport Layer Security, formerly known as SSL (Secure Socket Layer), aims
  3. to bring some security features over a communication channel, specifically
  4. providing \strong{integrity} and \strong{confidentiality} of the message, \strong{authenticity} of the server and
  5. optionally the client.
  6. %% fuck osi layers: there is no code explicitly structuring the internet in 7
  7. %% layers.
  8. Many ancient application protocols wrapped themselves to be over TLS/SSL, with
  9. the only difference of the ``s'' appended to the protocol name (such as HTTPs,
  10. IMAPs).It is nowadays widely adopted all over the world, becoming the de-facto standard for
  11. end-to-end encryption.
  12. \paragraph{Certification Authorities} are authorities to whom it is granted the
  13. power to \emph{authenticate} the peer. Pragmatically, they are public keys
  14. pre-installed on your computer that decide who and who not to trust employing
  15. a digital signature.
  16. In order to overcome the proliferation of keys to distribute, and satisfy the
  17. use-case of a mindless user willing to accomplish a secure transaction on the
  18. internet, the following, hierarchical trust model proliferated (~\cite{rfc4158},
  19. Fig.2):
  20. \\
  21. \\
  22. %% E` BELLISSIMO QUESTO COSO
  23. \begin{center}
  24. \begin{tikzpicture}[
  25. scale=0.9,
  26. align=center,
  27. level/.style={sibling distance=60mm/#1}]
  28. \node [draw] (z){Root CA}
  29. child {node [circle,draw] (a) {CA}
  30. child {node [circle,draw] (b) {CA}
  31. child {node {$\vdots$}
  32. child {node [circle,draw] (d) {EE}}
  33. child {node [circle,draw] (e) {EE}}
  34. }
  35. child {node {$\vdots$}}
  36. }
  37. child {node [circle,draw] (g) {CA}
  38. child {node {$\vdots$}}
  39. child {node {$\vdots$}}
  40. }
  41. }
  42. child {node [circle,draw] (j) {CA}
  43. child {node [circle,draw] (k) {CA}
  44. child {node {$\vdots$}}
  45. child {node {$\vdots$}}
  46. }
  47. child {node [circle,draw] (l) {CA}
  48. child {node {$\vdots$}}
  49. child {node (c) {$\vdots$}
  50. child {node [circle,draw] (o) {EE}}
  51. child {node [circle,draw] (p) {EE}
  52. child [grow=right] {node (q) {$\Rightarrow$} edge from parent[draw=none]
  53. child [grow=right] {node (q) {End Entities} edge from
  54. parent[draw=none]
  55. child [grow=up] {node (r) {$\vdots$} edge from parent[draw=none]
  56. child [grow=up] {node (s)
  57. {Certification\\ Authorities} edge from parent[draw=none]
  58. child [grow=up] {node (t)
  59. {Certification\\ Authorities} edge from parent[draw=none]
  60. child [grow=up] {node (u) {Root Authorities} edge from
  61. parent[draw=none]}
  62. }
  63. }
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }
  70. };
  71. \path (o) -- (e) node (x) [midway] {$\cdots$}
  72. child [grow=down] {
  73. %%node [draw] (y) {End User}
  74. edge from parent[draw=none]
  75. };
  76. \path (u) -- (z) node [midway] {$\Rightarrow$};
  77. \path (s) -- (l) node [midway] {$\Rightarrow$};
  78. \path (j) -- (t) node [midway] {$\Rightarrow$};
  79. %% \path (y) -- (x) node [midway] {$\Downarrow$};
  80. \path (e) -- (x) node [midway] {$\cdots$};
  81. \path (o) -- (x) node [midway] {$\cdots$};
  82. \path (r) -- (c) node [midway] {$\cdots$};
  83. \end{tikzpicture}
  84. \end{center}
  85. \vfill
  86. There are two types of authorities: root CAs and intermediate CAs. Root
  87. Authorities are the only nodes ultimately considered trustoworthy by the end
  88. user. Their private key is used to sign digital certificates, either to
  89. Certificate Authorities, to which is delegated the power of authenticating
  90. others, or End Entities, holders of a private key and their corresponding
  91. certificate whose identity has been verified.
  92. Upon connecting, the client will check to see if the certificate presented was issued
  93. by a CA present in the trust store (root CA); otherwise it will check to see if
  94. it has been issued by a truested CA, and so on until either a trusted CA is
  95. found or no
  96. \paragraph{The protocol} is actually a collection of many sub-protocols:
  97. \begin{itemize}
  98. \setlength{\itemsep}{1pt}
  99. \setlength{\parskip}{0pt}
  100. \setlength{\parsep}{0pt}
  101. \item \strong{\emph{handshake}} protocol, a messaging protocol that allows to
  102. \emph{authenticate} the peers, and eventually restore a past encrypted
  103. session.
  104. \item \strong{\emph{record}} protocol, permitting the encapsulation of higher level protocols,
  105. like HTTP and even the next two sub-protocols. It is the fulcrum for all data
  106. transfer.
  107. \item \strong{alert} protocol, which steps-in at any time from handshake to closure of the
  108. session in order to signal a fatal error. The connection will be closed
  109. immediately after sending an alert record.
  110. \item \strong{changespec} protocol, to negotiate with and notify the receiver that
  111. subsequent records will be protected under the just negotiated keys and
  112. \texttt{Cipher Spec}.
  113. \end{itemize}
  114. We will proceed with a brief synopsis of the first two of these protocols,due to
  115. their relevant role inside the connection and furthermore, because they are the
  116. only two we actually made use of during our investigations.
  117. \section{The \texttt{handshake} protocol}
  118. As mentioned above, the handshake occurs whenever a machine attempts to start
  119. a TLS connection. If there is no session identifier, a new one is being build
  120. up; otherwise the client will include the session-id in the initial
  121. communication and the server will eventually skip the key agreement phase since
  122. it has already happened recently.\footnote{``recently'' is not well-defined in
  123. the standard - it is suggested an upper limit of 24-hours lifetime, but the
  124. only constraint is that both client and server shall agree on it.}\\
  125. A new session-id identifier gets built via a challenge-response mechanism: the
  126. client issues a challenge, the server chooses a connection-id and presents it
  127. with its certificate. The client verifies the server's identity, and then
  128. chooses both a session key and the security specifications for the current
  129. session. Note that the session key should be different for any connection and
  130. direction. At this point the server can either send back the challenge and
  131. generate a session-id, or it can ask for the client
  132. certificate and finally ask for it (client authentication).
  133. \vfill
  134. \section{The \texttt{record} protocol}
  135. All TLS protocol messages moves in records of up to 16K, containing 3
  136. main components: MAC-data, data, and padding.
  137. \\
  138. {MAC-data} is no other than the Message Authentication Code over the
  139. encrypted \emph{data} sent
  140. (SSL performs the encrypt-than-mac mode of operation).
  141. It provides \strong{authenticity} and \strong{integrity} of the message.
  142. Failure to authenticate, decrypt will result in I/O error and a close of the
  143. connection.
  144. \\
  145. {Data} is the actual message, compressed and encrypted. Compression comes
  146. for free in order to fasten cryptanalysis of the cipher, since protocols such
  147. as HTTP have a common set of standard message.
  148. \\
  149. The {Padding} section contains informations about the padding algorithm
  150. adopted, and the padding size.
  151. \section{What's inside a certificate \label{sec:ssl:x509}}
  152. SSL certificates employed the X.509 PKI standard, which specifies, among other
  153. things, the format for revocation lists, and certificate path validation
  154. algorithms:
  155. \\
  156. \begin{center}
  157. \scalebox{0.7}{
  158. \begin{bytefield}[bitwidth=0.95em]{16}
  159. \begin{rightwordgroup}{Certificate}
  160. \wordbox{1}{Version} \\
  161. \wordbox{1}{Serial Number} \\
  162. \wordbox{1}{Algorithm ID} \\
  163. \wordbox{2}{Validity \\ \tiny{$\angular{\text{NotBefore, NotAfter}}$}} \\
  164. \wordbox{2}{Issuer \\ \tiny{eventually plus Issuer Unique Identifier}} \\
  165. \wordbox{2}{Subject \\ \tiny{eventually plus Subject Unique Identifier}} \\
  166. \wordbox{2}{Subject Public Key Information \\
  167. \tiny{$\angular{\text{PubKey algorithm, PubKey}}$}} \\
  168. \wordbox[lrt]{1}{Extensions} \\
  169. \skippedwords \\
  170. \wordbox[lrb]{1}{}
  171. \end{rightwordgroup} \\
  172. \wordbox{1}{Certificate Signature Algorithm} \\
  173. \wordbox{1}{Certificate Signature} \\
  174. \end{bytefield}
  175. }
  176. \end{center}
  177. It is a pretty old standard, defined in the eighties by the ITU.
  178. Born before HTTP, it was initially thought \emph{in abstracto} to be
  179. extremely flexible and general\footnote{
  180. \textit{``X.509 certificates can contain just anything''} ~\cite{SSLiverse}
  181. }.
  182. And precisely this flexibility and its adaptation to the SSL/TLS protocol
  183. without a very-well defined structure have been its major flaws: it is still
  184. difficult to write good, reliable software parsing a X.509 certificate.
  185. \section{Remarks among SSL/TLS versions}
  186. The first, important difference to point out here is that SSLv2 is no more
  187. considered secure. There are known attacks on the ciphers adopted (md5, for
  188. example) as well as protocol flaws.
  189. SSLv2 would allow a connection to be closed via a not-authenticated TCP segment
  190. with the \texttt{FIN} flag set. Padding informations are sent in clear, and the
  191. payload is not compressed before encrypting, allowing a malicious attacker
  192. traffic analysis capabilities. The ciphersuite is negotiated using
  193. non-authenticated informations, allowing an attacker to influence to choice and
  194. weaken the security of the communication.
  195. Most of these vulnerabilities have been addressed by the later SSLv3, which
  196. introduced compression and protection against truncation attacks.
  197. Its standardized twin, TLS 1.0, only differs on the cipher suite and key
  198. calculation requirements, strengthen in order to increase the security of the
  199. channel.
  200. Both SSLv3 and TLS 1.0 have been threatened in 2011 by an attack that could break
  201. the same origin policy, known as BEAST. It is not dramatic, and almost any
  202. browser now mitigates its spectrum of action.
  203. TLS 1.1, and TLS 1.2 are considered safe as of today.
  204. %%% Local Variables:
  205. %%% mode: latex
  206. %%% TeX-master: "question_authority.tex"
  207. %%% End: