1 00:00:00,000 --> 00:00:06,220 So I'm David Wong but I'm going to skip the boring part and start right away. So I'll start 2 00:00:06,220 --> 00:00:14,120 with the timeline and I have a date here, it's 2007 but that's an arbitrary date and the point 3 00:00:14,120 --> 00:00:21,680 here is that back then nobody really used SSL or used correctly SSL especially before SSL 4 00:00:21,680 --> 00:00:29,520 was created but even after it was created in the 90s people still use it uh incorrectly. And 5 00:00:30,000 --> 00:00:37,600 one of the first case I could find of uh of uh public display of of that point uh was in 2007 6 00:00:38,440 --> 00:00:45,600 when Steele Graham gave a talk at Black Hat and showed how uh SSL was misused in websites. So 7 00:00:45,600 --> 00:00:51,600 most of the time websites use SSL to protect the login page and after they revert back to 8 00:00:51,600 --> 00:00:59,980 unsecure HTTP and that's bad because you can uh practically steal the session ID after. And 9 00:01:00,000 --> 00:01:08,380 I have a very short video of what happened on stage. So basically man in the middle, everyone 10 00:01:08,380 --> 00:01:13,700 in the room and then he used one of the cookies stole to connect on the Gmail of that person. 11 00:01:16,780 --> 00:01:17,700 And if we don't have. 12 00:01:18,820 --> 00:01:19,260 Male. 13 00:01:34,280 --> 00:01:38,960 So I just thought that was funny it's a very short video, it doesn't really have a point but 14 00:01:39,660 --> 00:01:47,200 basically it's one of the first time it was shown to hackers or tech people that uh you could do 15 00:01:47,200 --> 00:01:54,620 that kind of thing and that SSL was important. And 2 years after there's this Moxi guy who is 16 00:01:54,620 --> 00:01:59,980 playing with SSL and trying to break it and he releases uh his tool SSL Strip at Black Hat and he's 17 00:02:00,000 --> 00:02:09,320 and what SSL strip does is that basically even if you use SSL correctly the very first 18 00:02:09,320 --> 00:02:14,660 connection you make to a website is usually unsecure. So for example if you connect on 19 00:02:14,660 --> 00:02:20,340 facebook.com what you do is that you type facebook.com in your browser and you never type 20 00:02:20,340 --> 00:02:27,900 HTTPS before that right? So the first connection is made unsecurely and then facebook.com in 21 00:02:27,900 --> 00:02:33,600 the example will reply with hey man can you actually use my HTTPS website and that would be 22 00:02:33,600 --> 00:02:38,980 cool. And so your browser redirects you to the secure version of facebook and then you're 23 00:02:38,980 --> 00:02:45,780 good. And if your man in the middle is a victim, someone, you can basically remove that 24 00:02:45,780 --> 00:02:53,040 message, that redirection and successfully man in the middle the entire website. And so that 25 00:02:53,040 --> 00:02:57,000 was pretty bad for SSL right? It kind of breaks SSL. 26 00:02:57,900 --> 00:03:05,600 And so Firefox came up with the solution a year after and it's called HSTS and what HSTS 27 00:03:05,600 --> 00:03:11,940 basically is, it's a header and so imagine you're connecting to facebook.com, same, same 28 00:03:11,940 --> 00:03:17,660 thing. You have this unsecure connection and this time facebook.com will tell you hey man can 29 00:03:17,660 --> 00:03:22,640 you remember to connect to the HTTPS version of the website next time? And your browser will 30 00:03:22,640 --> 00:03:27,880 remember that and it will add facebook.com to, to a list. And then it will tell you hey man can you 31 00:03:27,900 --> 00:03:32,620 remember to connect? And next time it will directly go in the secure version of the, the 32 00:03:32,620 --> 00:03:39,440 website. It's also the year of Fireship. If you don't know Fireship it was a plug-in for 33 00:03:39,440 --> 00:03:44,360 Firefox that you could use, you could just install it, was very simple. And you could go to 34 00:03:44,360 --> 00:03:51,460 the nearest Starbucks and sell credentials. And it was so efficient that I think it's one of 35 00:03:51,460 --> 00:03:57,680 the first, um, the first moments where the layman, the, the normal people started understanding the, the 36 00:03:57,900 --> 00:04:05,220 importance of SSL and HTTPS. And this thing made the news and, and everybody started freaking 37 00:04:05,220 --> 00:04:13,200 out. Only three years after, Facebook goes full HTTPS. I chose Facebook because, uh, everybody 38 00:04:13,200 --> 00:04:19,540 knows our, back then it was one of the biggest websites. Um, so kind of, kind of blows my mind 39 00:04:19,540 --> 00:04:25,400 that only three years ago, uh, one of the biggest websites went full HTTPS. And it's also the 40 00:04:25,400 --> 00:04:27,880 year of Snowden. So we learned about Prism. We learned about, we learned about, we learned about, we 41 00:04:27,900 --> 00:04:32,040 learned about Prism and we learned about TNSA spying on us and everybody started freaking out. 42 00:04:32,380 --> 00:04:37,580 And we understand, everybody started understanding this HTTPS and what, what does it mean? 43 00:04:39,220 --> 00:04:44,780 Uh, this last point doesn't really have, um, it's not really important but I, I still want to 44 00:04:44,780 --> 00:04:52,120 talk about it. Whenever you use H, HSTS to counter this SSL strip attack, there is still one 45 00:04:52,120 --> 00:04:57,760 point of failure. Uh, and that is the, the very first connection you make. So the very first 46 00:04:57,900 --> 00:05:01,580 connection you make to Facebook, uh, when Facebook will tell you, hey, remember me next 47 00:05:01,580 --> 00:05:07,740 time? Cause, go directly to the HTTPS version. Well, that very first connection is unsecure, 48 00:05:07,880 --> 00:05:16,240 right? And if you can break that, then you break HSTS as well. And so the solution came in 2010, 49 00:05:16,640 --> 00:05:22,180 uh, from Chrome and it's called preloaded HSTS and you can basically guess what it is, right? 50 00:05:22,280 --> 00:05:27,540 It's, uh, a list that comes in your browser and your browser knows that if you ever connect to this 51 00:05:27,540 --> 00:05:35,140 website, you have to use HTTPS. Uh, in 2010 you had to manually email Adam Langley and it was 52 00:05:35,140 --> 00:05:42,720 kind of, um, uh, not perfect. Two years ago they released a form, uh, that you can use online and 53 00:05:42,720 --> 00:05:47,600 you can upload your, you can enter, submit your websites and the next version of Chrome will 54 00:05:47,600 --> 00:05:55,700 ship with, uh, your website as the preloaded HSTS. So the, the, the point of that timeline, or 55 00:05:55,700 --> 00:06:00,640 the point I'm trying to make is that back then it was very easy to spy on people. You could just 56 00:06:00,640 --> 00:06:06,600 man in the middle of people or be on the internet and you could just read what was happening. And 57 00:06:06,600 --> 00:06:13,700 nowadays it's becoming hard, harder and harder, especially because of Snowden, uh, etc. And I'm 58 00:06:13,700 --> 00:06:20,500 not even talking about mail encryption or end-to-end, uh, messaging and, uh, end-to-end 59 00:06:20,500 --> 00:06:24,460 encryption, uh, which is also becoming more and more secure. 60 00:06:26,040 --> 00:06:31,300 Two more slides to prove my point that it's becoming harder and harder. Um, Mozilla is 61 00:06:31,300 --> 00:06:37,780 become, is thinking about deprecating HTTP altogether and so in the future when you will visit 62 00:06:37,780 --> 00:06:43,820 an HTTP website, you will see something that tells you that it's not secure. And I cannot also 63 00:06:43,820 --> 00:06:49,380 talk about all of this without mentioning Let's Encrypt, which is a new, um, as of today a root 64 00:06:49,380 --> 00:06:55,180 certificate, but it has been operating, uh, since last year, December of last year I think. 65 00:06:55,180 --> 00:07:02,680 It has, at the time of that screenshot, which was a few months ago, uh, signed certificates, uh, 66 00:07:02,760 --> 00:07:11,320 issued certificates for more than 7 million, uh, domains. So it's, they issue certificates for 67 00:07:11,320 --> 00:07:15,880 free and it's very easy. You just have to install the client on your server and it will do all the 68 00:07:15,880 --> 00:07:24,720 hard work for you. So yeah, easy to spy on people back then and now hard. The next story is, uh, 69 00:07:24,720 --> 00:07:30,420 the story of Logjam. Logjam was a paper, uh, released last year and has a bunch of authors, 70 00:07:30,600 --> 00:07:36,500 uh, which is pretty rare, but many others, and they had a lot of things to say and one of the 71 00:07:36,500 --> 00:07:42,620 things they wanted to say was that if you have a website, you usually use a HTTP server to 72 00:07:43,240 --> 00:07:49,820 provide your websites and Apache is one of them and you can use that. There is a mod in Apache 73 00:07:49,820 --> 00:07:54,700 that allows you to use, um, SSL or TLS. And, uh, in fact, only the two servers are able to use the 74 00:07:54,700 --> 00:08:02,300 And if you use that for, to protect your connection for, for your users, and, and you use 75 00:08:02,300 --> 00:08:08,240 D-filament to do a key uncheck in the, this TLS, uh, TLS thing, usually you will use 76 00:08:08,240 --> 00:08:12,240 D-filament ephemeral because all implementations, actually I don't know any 77 00:08:12,240 --> 00:08:17,240 implementation that use plain D-filament and all implementations used ephemeral 78 00:08:17,240 --> 00:08:24,020 D-filament. And ephemeral D-filament is just using D-filament with fresh keys for every 79 00:08:24,020 --> 00:08:28,300 different users. So if you're a server, if you're websites and you have many users 80 00:08:28,300 --> 00:08:34,160 connecting to, to your websites, you will generate a different key for every, to do a key 81 00:08:34,160 --> 00:08:42,560 exchange with every user. So the point here is that, the point of logjam is that everyone 82 00:08:42,560 --> 00:08:48,500 would use the same parameters to generate those fresh keys. And you don't have to remember 83 00:08:48,500 --> 00:08:54,000 D-filament, I'll, I'll re-explain after how it works and, and where are those, uh, 84 00:08:54,020 --> 00:08:58,960 hard-coded parameters important. But those hard-coded parameters that everyone was using 85 00:08:58,960 --> 00:09:08,740 were weak and that was the problem. Uh, another point of, that the paper made was that, um, 86 00:09:10,040 --> 00:09:16,960 even 1024, so D-filament 1024 was thought to be unsecure against the NSA or state-sized 87 00:09:16,960 --> 00:09:24,000 adversaries. And, so we liked 1024 and now we're trying to move away from 1024, uh, uh, 88 00:09:24,020 --> 00:09:29,060 it's, in particular with paper like, papers like logjam that tells us that it's not as secure as 89 00:09:29,060 --> 00:09:35,820 we thought. Uh, but the point here, uh, or my opinion here is that it's too much work. If 90 00:09:35,820 --> 00:09:41,420 you're the NSA and you want to break this 1024 bits integer, uh, that are in, in D-filament 91 00:09:41,420 --> 00:09:47,120 1024, you have to do a lot of pre-computation, pre-computation, um, and it's actually not 92 00:09:47,120 --> 00:09:54,000 that easy. And then if you change that, that number in D-filament then you'll have to redo all 93 00:09:54,020 --> 00:10:00,300 the computation. And to prove that the NSA is very lazy and that they don't really want to do 94 00:10:00,300 --> 00:10:06,520 computations on numbers too much, uh, let me talk about the US export rules. So if you're 95 00:10:06,520 --> 00:10:12,820 familiar with that, uh, that was a set of rules, of laws, uh, that we had. They still exist 96 00:10:12,820 --> 00:10:17,940 today but they're way more relaxed. And basically back then if you had a product and you 97 00:10:17,940 --> 00:10:23,420 wanted to sell it to foreign countries, export it abroad, you had to weaken your cryptography. 98 00:10:24,820 --> 00:10:29,660 For SSL that means that you had to use these weak cipher suits that we called export cipher 99 00:10:29,660 --> 00:10:36,020 suits. And for example in D-filament you would use these 512 bit primes, uh, which is a very 100 00:10:36,020 --> 00:10:41,980 small number. So D-filament 512. And for symmetric cryptography you would use 40 bit keys 101 00:10:41,980 --> 00:10:49,340 for, uh, for DS for example. And so nowadays we don't really have to do that, uh, besides a list 102 00:10:49,340 --> 00:10:54,000 of blacklisted countries. Uh, but it's still biting us in the ass. If you look at the 103 00:10:54,020 --> 00:10:59,740 last attacks on TLS, all the major attacks, uh, like freak and logjam, uh, they all pretty 104 00:10:59,740 --> 00:11:05,900 much done great attacks. So the implementations still have those weak algorithms in them. And 105 00:11:05,900 --> 00:11:11,300 you're using SSL but with secure parameters. And someone in the middle puts you back into 106 00:11:11,300 --> 00:11:20,940 these weak, uh, cipher suits. And so the NSA really liked at that time that they were, they 107 00:11:20,940 --> 00:11:24,000 had to crack those 40 bit keys, uh, on D-filament. Uh, and, uh, uh, uh, uh, uh, uh, uh, uh, uh, uh, 108 00:11:24,020 --> 00:11:28,800 DMS for example, and they really didn't want to do more than that. For example, Lotus 109 00:11:28,800 --> 00:11:37,200 notes, anyone used that software before? A few people, a few old people. So Lotus Notes, uh, 110 00:11:37,740 --> 00:11:43,700 made a deal with the, uh, the US governments. The US government allowed them to use 64 bit 111 00:11:43,700 --> 00:11:51,700 crypto, um, for cerebral etching stuff with, uh, DS. If, and only if they would, uh, give 24 112 00:11:51,700 --> 00:11:54,000 bits of those keys to NSA. And they just should very gently, uh, rushing than keeping this 113 00:11:54,020 --> 00:11:58,760 they would encrypt 24 bits of these, uh, these keys that they would use to the NSS public 114 00:11:58,760 --> 00:12:05,060 key. And for the story, that, that key was called Big Brother. Uh, but basically they 115 00:12:05,060 --> 00:12:10,640 were using that public key so that only the NSA could decrypt this information and use it. 116 00:12:11,680 --> 00:12:17,180 And that kind of backdoor actually has a name. It's called a kleptographic backdoor. So 117 00:12:17,180 --> 00:12:23,920 you use, um, some asymmetric crypto to, to send some information to the right person. And, 118 00:12:25,480 --> 00:12:31,040 kleptography works well, uh, as long as your crypto system is a black box. If you don't know 119 00:12:31,040 --> 00:12:35,960 what's happening underneath the, the program, then you cannot really see that backdoor. But, 120 00:12:36,100 --> 00:12:42,500 if your system is a white box system or if you can reverse and generate, uh, you're in trouble. 121 00:12:42,680 --> 00:12:49,340 It's pretty obvious, uh, this kind of backdoors. And it doesn't work very well because we're 122 00:12:49,340 --> 00:12:53,600 getting more and more, um, we're using more and more open source libraries, right? So you 123 00:12:53,600 --> 00:12:54,000 cannot really see what's going on. Uh, and, and, and, and, and, and, and, and, and, and, and, and, 124 00:12:57,240 --> 00:12:58,880 and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and, and. 125 00:12:58,880 --> 00:13:03,840 So, we've seen that the weak crypto thing that DNS�the U.S. government tried 126 00:13:03,840 --> 00:13:08,840 doesn't really work anymore. Especially if you look at the list of Super Computers. China 127 00:13:09,300 --> 00:13:15,600 chis...he's the best right now. So, the U.S. might not be the only one being able to, to use 128 00:13:15,600 --> 00:13:19,920 those backdoors. So. Those backdoors, I think might not work so much either. 129 00:13:20,040 --> 00:13:22,660 I wouldn't consider system access for cloud tech, as, and, and, and. But then us, we'll, we'll 130 00:13:22,660 --> 00:13:23,960 talk to Microsoft about that later. 131 00:13:25,260 --> 00:13:31,780 So the, the NSA came up with a, a different scheme to try and spice things up. Uh, they 132 00:13:31,780 --> 00:13:36,500 invented this algorithm called Dual EC. And if you were in the previous talk at the Crypto 133 00:13:36,500 --> 00:13:42,660 Village you, you heard a bit about that. And Dual EC is a PRNG. It's a random number 134 00:13:42,660 --> 00:13:53,940 generator. You, yeah. Someone ask a question or, oh. Dual EC is a PRNG. And it's a 135 00:13:53,960 --> 00:14:00,020 random number generator. So you use it to generate random numbers. And this PRNG was 136 00:14:00,020 --> 00:14:06,420 standardized in the NIST document, uh, in that NIST document in 2007. It was 137 pages 137 00:14:06,420 --> 00:14:13,120 document. And, and Dual EC was one out of four PRNGs being standardized. And the same 138 00:14:13,120 --> 00:14:17,920 year we discovered that, uh, two guys from Microsoft discovered that there might be a 139 00:14:17,920 --> 00:14:23,940 back door inside this PRNG. We got, uh, the proof of that a few years after this. The 140 00:14:29,460 --> 00:14:35,720 NIST was running a program called, called Bullrun, uh, which aims to back door products to 141 00:14:35,720 --> 00:14:40,720 spy on people. And, and for the story the UK has the same kind of program called, uh, Edge 142 00:14:40,720 --> 00:14:48,380 Heal. And we discovered as well that the NSA paid RSA 10 million dollars so that they would 143 00:14:48,380 --> 00:14:53,940 implement this Dual EC back door, uh, back door PRNG into their B-Safe uh, product. So 144 00:14:56,520 --> 00:15:03,700 um, Juniper, so released a, a security bulletin last year in December, around Christmas, 145 00:15:04,510 --> 00:15:10,700 and they say that, uh, two vulnerabilities were found, but they didn't say where or what 146 00:15:10,700 --> 00:15:15,460 kind of vulnerabilities. But it was around Christmas, so every, every researcher was home, 147 00:15:15,620 --> 00:15:22,040 bored, and in two days it was reversed and we knew where the vulnerabilities were. And 148 00:15:22,040 --> 00:15:27,260 one was boring, I'll talk about the other one. The other one is interesting because you 149 00:15:27,260 --> 00:15:33,260 could spot it just by, uh, using that strings tool, just by analyzing the, the, the strings of 150 00:15:33,260 --> 00:15:38,380 the binaries. And so if you looked, I don't know if you can see, but if you look at the patch 151 00:15:38,380 --> 00:15:44,300 binaries and the vulnerable binaries, you can see that only one hex string was changed. And 152 00:15:44,300 --> 00:15:50,920 that was actually a point on a curve, which was a curve used in dual EC and we found out 153 00:15:50,920 --> 00:15:51,620 that, um, 154 00:15:52,160 --> 00:15:58,840 what was changed here was, uh, the owner of the back door, uh, or rather, by changing that 155 00:15:58,840 --> 00:16:07,260 point, the back door changed of hands, basically. Uh, the point I try to make here is that dual EC 156 00:16:07,260 --> 00:16:12,420 is obvious. If you look at the construction of dual EC, it used curves and it used, uh, a very 157 00:16:12,420 --> 00:16:19,900 well known property of curves. And basically if you know how the points that are used in dual EC 158 00:16:19,900 --> 00:16:22,020 are generated, then you have access to a back door. However, if you have a back door on the back, 159 00:16:22,040 --> 00:16:28,260 backdoor. And if you look at it, it's, it's obvious. So with crypto it doesn't work, right, 160 00:16:28,360 --> 00:16:33,360 because of we're not the on- the only super power being able to compute, uh, those big 161 00:16:33,360 --> 00:16:38,180 numbers. Cryptography doesn't work, it's too obvious, and these new backdoor algorithms, 162 00:16:38,440 --> 00:16:43,660 like dual EC, well it's too obvious and we saw that when they tried that, uh, it was a nice 163 00:16:43,660 --> 00:16:49,020 try, but on the same year we realized that there was a backdoor. So it didn't last a very 164 00:16:49,020 --> 00:16:59,220 long time. So, something interesting happened January of this year. Um, Socat, which is a 165 00:16:59,220 --> 00:17:06,960 tool, uh, like, uh, like, um, Netcat, but much more, you can, um, and, and they released 166 00:17:06,960 --> 00:17:14,100 their security advi- advisory of their own. And one thing was really strange in there. So, 167 00:17:14,200 --> 00:17:19,000 apparently, they were using OpenSSL to secure the data. So, uh, they were using OpenSSL to 168 00:17:19,020 --> 00:17:26,440 uh, to encrypt data. And OpenSSL was using DFLMAN, this ephemeral version of DFLMAN, right? 169 00:17:27,740 --> 00:17:31,880 And to generate those fresh keys they were using hard-coded parameters, so like every 170 00:17:31,880 --> 00:17:37,200 libraries, like Apache and etc. Of course you could generate your own parameters, but 171 00:17:37,200 --> 00:17:42,400 nobody really does that. And those parameters, uh, in those parameters there is a number 172 00:17:42,400 --> 00:17:48,080 that is supposed to be a prime. And we'll see what number it is. But that prime was actually 173 00:17:48,080 --> 00:17:54,840 not really a prime. And they say basically that, uh, the existence of a trapdoor, blah, blah, 174 00:17:54,900 --> 00:18:01,840 blah. So, they think there is a backdoor. I'm like, hmm. A backdoor in DFLMAN? That's, that's 175 00:18:01,840 --> 00:18:08,140 interesting. That's interesting because everyone trusts DFLMAN. That's the first public key 176 00:18:08,140 --> 00:18:14,700 crypto algorithm invented in the 70s. We've used that in, uh, in the past and nowadays. Everyone 177 00:18:14,700 --> 00:18:21,260 trusts it. Uh, most of the inventors of DFLMAN are actually alive. So, that's a good thing. If we 178 00:18:21,260 --> 00:18:31,180 can backdoor that then it's better than, than DLAC, right? LogJam told us that, uh, people use the 179 00:18:31,180 --> 00:18:35,620 same hard-coded parameters when they use DFLMAN. And so that's good. If we can backdoor them we 180 00:18:35,620 --> 00:18:44,680 can backdoor a lot of, uh, implementations or a lot of, uh, a lot of people. And the other good thing is that LogJam scared the 181 00:18:44,700 --> 00:18:52,780 us from these, uh, 1024 bits, uh, parameters and now people are moving away from these and trying to 182 00:18:52,780 --> 00:19:01,160 migrate to 2048 bits, uh, DFLMAN. And so that's, like, the perfect excuse to submit a patch and say, hey, look at my bigger 183 00:19:01,160 --> 00:19:09,740 number. It's more secure. I accept it. And then your backdoor is in place. Uh, yeah. So, what I said. 184 00:19:09,740 --> 00:19:16,620 it. Alright, so now I'll recap D-filament. Imagine that Alice and Bob wants to encrypt 185 00:19:16,620 --> 00:19:22,400 some data between them. First, they will usually do a key exchange so that they have this shared 186 00:19:22,400 --> 00:19:29,040 secret that they can use in AES, for example. So to do a key exchange with D-filament, Alice 187 00:19:29,040 --> 00:19:37,240 will generate a number A. And then she will use two other numbers, G and N. And those 188 00:19:37,240 --> 00:19:42,740 are the hard-coded parameters that, in TLS, the server sends to the client, and the client 189 00:19:42,740 --> 00:19:48,460 has to accept them. And so when I was talking about Apache and everyone was using the same 190 00:19:48,460 --> 00:19:56,260 parameters, I was talking about this G and this N. And so basically, Alice takes this G, 191 00:19:56,400 --> 00:20:02,660 the generator, raises it to the power A, her private key, takes that number mod N, and that's 192 00:20:02,660 --> 00:20:07,220 her public key, and she sends that to Bob. And in the context of TLS, that would be 193 00:20:07,220 --> 00:20:11,360 Alice would be the server, and Bob would have to accept those parameters, and Bob would be the 194 00:20:11,360 --> 00:20:17,440 client. So here, Bob does the same thing. He generates the number B, and that's his private 195 00:20:17,440 --> 00:20:25,980 key. Raised that public generator to the power B, mod N, and he sends that to Alice, his 196 00:20:25,980 --> 00:20:34,000 public key. So far, so good. And now, Alice and Bob have enough information to compute the 197 00:20:34,000 --> 00:20:37,140 shared secrets. I'll just do that for Bob. But Bob can take 198 00:20:37,220 --> 00:20:42,960 Alice's public key, raise that to the power of his private key, mod N, and that's the shared 199 00:20:42,960 --> 00:20:53,400 secret. G raised to the power AB. So now that we've recapped D-Failman, let me explain a bit of 200 00:20:53,400 --> 00:20:59,180 group theory. And I'm not sure of the level of everyone here. If you already know that, then 201 00:20:59,180 --> 00:21:04,900 that's a good recap before we see the attack. If you don't know that, then focus, and it's not 202 00:21:04,900 --> 00:21:05,820 going to be too hard. 203 00:21:05,820 --> 00:21:12,320 So I said that, uh, to use D-Failman, you have to use parameters, right? And here, the hard 204 00:21:12,320 --> 00:21:20,640 credit parameters are G and N. And G is called the generator for a good reason. Uh, it's because 205 00:21:20,640 --> 00:21:26,120 it generates all the possible public keys in a group. So if you take the generator, and you 206 00:21:26,120 --> 00:21:30,360 raise it to the different powers, you actually generates all the public keys, all the possible 207 00:21:30,360 --> 00:21:35,800 public keys in the group. Okay? And in our example of Alice, you can see that it generates all the 208 00:21:35,820 --> 00:21:37,220 leading private converter, PUB mobiles. So in this case, as is who is generating the public keys, 209 00:21:37,220 --> 00:21:41,520 Alice generates the private key A and having a public key if Alice generates a private 210 00:21:41,520 --> 00:21:45,320 key four. Here, G to the 4 mod N would be public key. 211 00:21:47,600 --> 00:21:48,560 For example, If Alice generated private key for, here G to the 4 mod N would be her public 212 00:21:48,560 --> 00:21:53,300 would be her public key. But we don't have infinite number of public keys, we have actually a 213 00:21:53,300 --> 00:22:00,040 bond on the, on the number of public keys, which is phi of N, which is a function of N. And we also 214 00:22:00,040 --> 00:22:05,100 call that Euler's Torsion function, but it doesn't really matter here. And, basically, this function 215 00:22:05,100 --> 00:22:12,860 function of n tells us how many, how many public keys we have in a group. How many possible 216 00:22:12,860 --> 00:22:17,040 public keys we have in a group. And so if you raise g to the power of phi of n, this 217 00:22:17,040 --> 00:22:22,220 function, you go back to the first elements and then if you continue raising this number, 218 00:22:22,340 --> 00:22:27,440 you go back to g, g square and basically you reiterate through all the possible public 219 00:22:27,440 --> 00:22:34,660 keys one more time. Until you reach the n and it's a loop. So I talked about that phi 220 00:22:34,660 --> 00:22:41,440 of n, which is the number of possible public keys in your group. That phi of n is actually 221 00:22:41,440 --> 00:22:46,600 very easy to compute if your modulus is a prime. So it should be a prime in d film n, 222 00:22:46,720 --> 00:22:52,320 but we saw that in SOCAT it wasn't a prime, okay? But if it is a prime, you just subtract 223 00:22:52,320 --> 00:22:57,420 one to that number and it gives you the number of possible public keys. Very easy. 224 00:22:57,420 --> 00:23:05,400 Now, imagine something else. Imagine that the modulus n is the multiplication of two 225 00:23:05,400 --> 00:23:13,020 primes, p and q. So you might recognize RSA, right? Then it's a bit more complicated and 226 00:23:13,020 --> 00:23:18,960 if you don't know p and q, then you don't really know how to compute this number of 227 00:23:18,960 --> 00:23:26,360 possible public keys. And that's actually how RSA works, right? So in RSA, nobody knows 228 00:23:26,360 --> 00:23:27,140 p and q. 229 00:23:27,420 --> 00:23:33,320 And so nobody can compute the number of possible public keys and nobody can reverse the RSA 230 00:23:33,320 --> 00:23:40,320 problem. So that's one important information. Let's go to the second and last important 231 00:23:40,320 --> 00:23:46,320 information to understand the attacks. So imagine that you have your generator g. It 232 00:23:46,320 --> 00:23:53,800 generates all the possible public keys, right? Until the last public key. But now imagine 233 00:23:53,800 --> 00:23:57,400 that you want to create another group. And for that other group, you take the number of 234 00:23:58,020 --> 00:23:59,920 possible public keys. And you pick your group, your generator g, your generator g. And you 235 00:23:59,920 --> 00:24:05,120 say that g square is your new generator. So you take g square. You raise it to the 236 00:24:05,120 --> 00:24:09,640 power 2, then you raise it to the power 3, etcetera. And what you do is that you 237 00:24:09,640 --> 00:24:15,160 actually skip elements, right? There are some elements you're not going to have. And that 238 00:24:15,160 --> 00:24:20,600 it's actually called a subgroup. And this is a very simplified explanation but it doesn't 239 00:24:20,600 --> 00:24:26,680 happen all the time. But sometimes, you pick a random public key. And you use it as a generator. 240 00:24:26,680 --> 00:24:35,100 generator and it will generate a smaller group, a subgroup. And we have a method to obtain 241 00:24:35,100 --> 00:24:41,760 all the possible subgroups in a Diffie-Hellman group. And imagine the, the modulus is a prime, 242 00:24:41,880 --> 00:24:47,460 P in a Diffie-Hellman. So I said that to compute the number of possible public keys, you just 243 00:24:47,460 --> 00:24:54,420 subtract 1 to that number. So P minus 1 is the number of possible public keys. And now 244 00:24:54,420 --> 00:25:01,940 if you factor that number into P1 times P2, et cetera, it tells you what possible subgroups 245 00:25:01,940 --> 00:25:08,460 you have. So here you have a subgroup of size P1 maybe. You have another subgroup of size 246 00:25:08,460 --> 00:25:18,260 P2, et cetera. Okay, that's enough group theory. And now let's see how we want to attack Diffie-Hellman. 247 00:25:19,060 --> 00:25:24,400 So imagine that we have a public key. Well, this is public key here. And now we want to 248 00:25:24,420 --> 00:25:30,920 find what? We want to find A, right? We want to find Alice's private key. And that's actually 249 00:25:30,920 --> 00:25:35,660 called the discrete logarithm problem, by the way. And one way of finding that private 250 00:25:35,660 --> 00:25:41,480 key out of that public key is to take the generator G and raise it to all the different 251 00:25:41,480 --> 00:25:47,980 powers and check if it's equal to Alice's public key. That's a very naive way of doing 252 00:25:47,980 --> 00:25:52,480 it. It's called the trial multiplication. And it's, of course, not efficient at all. 253 00:25:54,560 --> 00:26:01,960 Other better ways of doing it, if you're, if you look at all the past records of computing 254 00:26:01,960 --> 00:26:09,240 private keys out of public keys in large parameters, index calculus are the best kind of attacks 255 00:26:09,240 --> 00:26:14,700 we know, like a special number field sieve or the general number field sieve. The best 256 00:26:14,700 --> 00:26:24,400 attack was done this year in June, June 2016, and in a modulus of size 760. And this is 257 00:26:24,420 --> 00:26:29,020 68 bits. So it's far from what we want to use. We, nowadays, we want to use defilement 258 00:26:29,020 --> 00:26:37,020 2048. So it doesn't work that much. We have better algorithms than that. We have algorithm 259 00:26:37,020 --> 00:26:43,260 that works well if the number of possible public keys your generator is generating is 260 00:26:43,260 --> 00:26:49,300 small. So imagine you choose another generator and it doesn't generate a lot of public keys. 261 00:26:49,440 --> 00:26:54,300 Then you can use these kind of attacks. Shanks, baby step, giant step, polar row and 262 00:26:54,300 --> 00:27:00,540 kangaroo. And here we'll use polar row because it doesn't take a lot of memory and we have 263 00:27:00,540 --> 00:27:07,440 enough information to use it. Clever attacks exist. If you look at active attacks, you 264 00:27:07,440 --> 00:27:13,260 have the small subgroup attacks. And I don't really like this one because you have to send 265 00:27:13,260 --> 00:27:19,300 many, to do many TLS handshakes with a server to steal his key. And usually the server will 266 00:27:19,300 --> 00:27:23,880 generate new keys every time. So because he used ephemeral defilement. 267 00:27:24,300 --> 00:27:29,920 And so it doesn't work that well. Rather, we can use poly-Hellman, which is a passive attack. 268 00:27:30,180 --> 00:27:35,960 You just have to look at one key exchange between Alice and Bob or a client and a server. And you 269 00:27:35,960 --> 00:27:42,260 can compute someone's private key and so you can compute the shared secret. Let me, let me 270 00:27:42,260 --> 00:27:48,880 explain in details how poly-Hellman works. But that's what we're going to use. So remember, we 271 00:27:48,880 --> 00:27:54,280 have this public key and we want to find that private key. And so we observed a lot of the 272 00:27:54,300 --> 00:28:00,860 Alice's public key during this key exchange, right? And we could theoretically, uh, attack 273 00:28:00,860 --> 00:28:05,880 either Bob's or Alice's public key and then we would get the shared secret. But we could also 274 00:28:05,880 --> 00:28:11,940 attack both and see which one come up first. But here it doesn't matter. So we have Alice's 275 00:28:11,940 --> 00:28:17,560 public key and what we do is that we raise it to the power of something. And I won't go too 276 00:28:17,560 --> 00:28:24,280 much into the details. And once you raise that public key, uh, power of something, you can 277 00:28:24,300 --> 00:28:29,800 do something. It will, um, it will place that public key in a smaller subgroup. So remember 278 00:28:29,800 --> 00:28:35,360 when I was talking about subgroups, I said that we have groups of smaller sizes. And when we 279 00:28:35,360 --> 00:28:40,840 place that public key in a group of smaller size, we can do these new attacks like polar row 280 00:28:40,840 --> 00:28:47,160 because there aren't, there aren't so many possible public keys. But what we get out of this 281 00:28:47,160 --> 00:28:54,120 attack is only a partial private key. We only obtain one information on the private key. But when 282 00:28:54,300 --> 00:29:00,280 once we do that enough in enough subgroups, we obtain enough partial private keys and we can 283 00:29:00,280 --> 00:29:07,420 stitch them together to form the real private key. And we usually stitch them together using the 284 00:29:07,420 --> 00:29:14,020 Chinese remainder theorem, which we call CRT. Uh, but again, won't go too much into the details 285 00:29:14,020 --> 00:29:23,960 here. So let's try to use Pauli-Hellman to do, to place a backdoor in a group, in a Diffellman 286 00:29:23,960 --> 00:29:24,220 group. 287 00:29:25,860 --> 00:29:34,020 So imagine that we have control over the modulus, that number p, and it's a prime, right? And we 288 00:29:34,020 --> 00:29:40,880 want to create many subgroups so that we can do the attack. So we create p prime such that p minus 289 00:29:40,880 --> 00:29:46,980 1, which is the number of possible public keys, can be factored into small subgroups, small 290 00:29:46,980 --> 00:29:54,280 factors. And here we're trying to find x, the private key, uh, from a public key y. And we 291 00:29:54,300 --> 00:29:59,040 can do that. And so what we do is that we place that public key in all the different subgroups 292 00:29:59,040 --> 00:30:04,860 with our technique. We obtain a lot of partial private keys. And then we stitch them together 293 00:30:04,860 --> 00:30:10,200 with the Chinese remainder theorem. Uh, it's a bit of, it's a bit complicated. The diagram 294 00:30:10,200 --> 00:30:15,820 doesn't really make any sense if you look at it too fast. But the point is that you can do 295 00:30:15,820 --> 00:30:22,660 Pauli-Hellman here because you have many subgroups. And the many subgroups are the factors of, uh, 296 00:30:22,660 --> 00:30:28,980 this number of possible public keys. The bad thing here is that if your subgroups are small enough 297 00:30:28,980 --> 00:30:35,040 that you can do the Pauli-Hellman attack, then they're small enough that anyone can factor p minus 298 00:30:35,040 --> 00:30:41,580 1 and find the subgroups. And that means that anyone can use the backdoor. And it's not a no one 299 00:30:41,580 --> 00:30:48,720 but us backdoor. So what we want to do here is to hide all the factors of the number of possible 300 00:30:48,720 --> 00:30:52,640 public keys. And you, if you remember, I said that, uh, if you, if you remember, I said that, uh, 301 00:30:52,660 --> 00:31:00,100 if the prime, if that modulus p is not a prime, then we can hide the number of possible public keys. 302 00:31:01,520 --> 00:31:08,320 Right? Exactly like RSA. And if you hide that number of possible public keys, then no one can 303 00:31:08,320 --> 00:31:15,760 access the factors of that number, which are the small subgroups. And so only you can use the 304 00:31:15,760 --> 00:31:21,840 backdoor to compute Pauli-Hellman on those, on those subgroups. And here, uh, same thing, the 305 00:31:21,840 --> 00:31:22,640 diagram is a bit... 306 00:31:22,660 --> 00:31:29,760 uh, dense. But basically we hide, uh, the first line is the most important. We hide all the 307 00:31:29,760 --> 00:31:40,600 subgroups inside the factorization of a non-prime number. So this is basically how the nobody, uh, 308 00:31:40,660 --> 00:31:46,780 no one but us backdoor works. And I try to use SOCAT to implement it because, well, SOCAT is 309 00:31:46,780 --> 00:31:52,480 the perfect tool to test those things. And this is basically the, the code that SOCAT use. It's a 310 00:31:52,480 --> 00:31:52,640 copy and paste code. And it's basically the, the code that SOCAT use. It's a copy and paste code. 311 00:31:52,660 --> 00:31:57,140 It's a copy and paste from, um, some page on the internet. Everybody use the same code. And I 312 00:31:57,140 --> 00:32:04,180 just replace the modulus with my modulus. In a real situation, I would try to replace it with a 313 00:32:04,180 --> 00:32:11,120 larger modulus to tell the people that my number is bigger, so it's more secure. And they don't 314 00:32:11,120 --> 00:32:16,000 see that. And since nobody knows it has to be a prime, then it will, it would most likely pass. 315 00:32:16,960 --> 00:32:22,640 I have a demo. It's a very quick demo, but still a demo. On the left side of the table, I have a 316 00:32:22,640 --> 00:32:29,300 man in the middle. On the right side, you have a client and a server using SOCAT to chat. 317 00:32:32,100 --> 00:32:37,260 And basically the, the man in the middle will detect the backdoor parameters and then will 318 00:32:37,260 --> 00:32:45,060 compute the private key out of one, uh, out of the client or the server's public key. And then 319 00:32:45,060 --> 00:32:51,240 we'll have the shared secret to decrypt everything on the wire. So, yeah, it's very fast. 320 00:32:52,180 --> 00:32:58,500 So they both connect. Backdoor detected here. I derive all the keys. And here, when they say 321 00:32:58,500 --> 00:33:02,300 something, you can, I don't know if you can see that, but you can see everything in the clear. 322 00:33:04,120 --> 00:33:08,160 So I could have tampered with the message as well, but here I'm just observing the message, 323 00:33:08,260 --> 00:33:15,100 uh, messages passively. But it's a very efficient backdoor. And the only thing that blocks is 324 00:33:15,100 --> 00:33:21,220 that if they ever check if it's a prime. But if, if your patch is passed, then, uh, it's, it's a 325 00:33:21,240 --> 00:33:34,340 win. It's a win. The code is on GitHub. If you want to look at it, play with it. And I'll have 326 00:33:36,840 --> 00:33:44,440 one last slide on how to detect and protect against, uh, that kind of backdoors. I'll wait 327 00:33:44,440 --> 00:33:51,220 for pictures. All right. So how do you detect and protect against, uh, that kind of backdoors? 328 00:33:51,940 --> 00:33:58,980 Well, if you check if the server is sending you, uh, modules that is prime, then you 329 00:34:00,120 --> 00:34:05,080 prevent this kind of knowing about those backdoors. But you don't really prevent the other 330 00:34:05,080 --> 00:34:10,140 kind of backdoors that everybody can use. So to be sure, you have to detect if those primes are 331 00:34:10,140 --> 00:34:17,880 safe primes. And basically what safe primes are, um, they are specific kind of primes that 332 00:34:17,880 --> 00:34:21,220 maximize the... that minimize the number of subgroups at the sagt. And so if, uh, you go to a 333 00:34:21,220 --> 00:34:26,200 groups, but maximize the size of your subgroup so that you cannot use these kind of attacks. 334 00:34:28,200 --> 00:34:33,780 Uh, actually no browsers check for that. So if you browse the web, you will actually never 335 00:34:33,780 --> 00:34:39,500 detect that kind of backdoors. Uh, I actually did browse the web myself, well, parsed, uh, 336 00:34:40,280 --> 00:34:46,060 the internets to detect that kind of, uh, websites that would use composite modules. I 337 00:34:46,060 --> 00:34:51,200 found like a dozen of them, but not really targets except one which was a French group 338 00:34:51,200 --> 00:34:57,260 government testing page. So I don't know what they're playing with. But the problem of 339 00:34:57,260 --> 00:35:02,900 defilament in browsers is, uh, is more complicated than that. And if you look at Google Chrome, 340 00:35:03,040 --> 00:35:07,660 uh, they're completely deprecating in the future versions, they're deprecating defilament. 341 00:35:08,360 --> 00:35:15,560 Uh, because of the way it's used in TLS, it's not nice enough for us because we have to 342 00:35:15,560 --> 00:35:21,180 accept the server's parameters. And instead of defilament, they, they want to use the 343 00:35:21,200 --> 00:35:26,340 elliptic curve defilament. So if you know elliptic curve, uh, to do a key exchange in 344 00:35:26,340 --> 00:35:32,000 elliptic curves, we don't randomly generate parameters, but we use parameters from a predefined 345 00:35:32,000 --> 00:35:36,720 set of curves. So the same kind of attacks don't work. They can work, but if you control 346 00:35:36,720 --> 00:35:44,160 both the client and the server, the server. So this is the end. Uh, open question, how 347 00:35:44,160 --> 00:35:49,120 many VPN libraries, closed source, open source products do you think have these kind of 348 00:35:49,120 --> 00:35:49,460 backdoors? 349 00:35:50,160 --> 00:35:50,640 Uh, 350 00:35:51,200 --> 00:35:58,360 And what about elliptic curve defilament? It's open research, an open problem, and there 351 00:35:58,360 --> 00:36:04,120 might be things to, to be found in there. Follow me on Twitter, and if you have many, uh, 352 00:36:04,200 --> 00:36:06,300 any questions, now is the right time. 353 00:36:18,740 --> 00:36:19,280 Yes? 354 00:36:19,860 --> 00:36:21,080 Um, just checking. 355 00:36:21,200 --> 00:36:25,540 For the safe primes, that's, I mean, it depends on what scenario, but it's not really 356 00:36:25,540 --> 00:36:30,660 practical because there is some cases that don't use safe primes, but still use secure 357 00:36:30,940 --> 00:36:36,420 parameters. For example, new TLS is generating other primes that don't, yeah. 358 00:36:36,720 --> 00:36:42,320 Right. So you, yeah, you don't have, it's not because you don't have safe primes that 359 00:36:42,320 --> 00:36:43,480 you don't have secure parameters. 360 00:36:44,140 --> 00:36:44,700 Yeah. 361 00:36:44,700 --> 00:36:50,500 And if you check for safe primes and you refuse websites that don't send you safe primes, 362 00:36:50,500 --> 00:36:55,560 you might not be able to browse the Internet, because not many websites use that. Yeah. 363 00:36:58,140 --> 00:36:59,200 Any other questions? 364 00:37:02,100 --> 00:37:04,120 All right. Again? 365 00:37:04,760 --> 00:37:09,500 Would you find it a sane idea to say that the open-cell API should reject parameters 366 00:37:09,500 --> 00:37:15,000 that are not prime? I mean, that would be relatively easy, because checking for the 367 00:37:15,000 --> 00:37:17,800 prime in, like, the browser, that's a performance issue. 368 00:37:18,340 --> 00:37:18,860 Exactly. 369 00:37:18,860 --> 00:37:24,520 If the software loads the parameters that start up, then maybe, I mean, that doesn't 370 00:37:24,520 --> 00:37:26,760 really matter, because that takes... 371 00:37:26,760 --> 00:37:30,260 Oh, so the server should itself check if it's using a prime? 372 00:37:30,420 --> 00:37:36,140 Yeah, like, an open-cell API, because the SOPAT issue, if open-cells have just rejected 373 00:37:36,140 --> 00:37:41,480 these parameters and the software wouldn't run, then this patch wouldn't, it wouldn't 374 00:37:41,480 --> 00:37:43,660 have been applied because the software would have been broken. 375 00:37:43,900 --> 00:37:48,840 So if the server checks if he's using a prime, then that, that would be actually a 376 00:37:48,840 --> 00:37:49,340 very good fix. 377 00:37:49,640 --> 00:37:50,000 Yeah. 378 00:37:50,320 --> 00:37:50,800 But... 379 00:37:51,460 --> 00:37:51,940 Yeah. 380 00:37:53,220 --> 00:37:57,140 But then you can always remove that check if you really want to implement your backdoor. 381 00:37:57,560 --> 00:38:03,820 But at least it should prevent people from doing things that they don't know and, and 382 00:38:04,380 --> 00:38:11,920 creating a backdoor by mistake. But for intentional backdoors, it might be, uh, not as good. 383 00:38:15,160 --> 00:38:16,460 All right. Thank you. 384 00:38:18,840 --> 00:38:20,920 Thank you.