1 00:00:00,000 --> 00:00:01,840 Let's give a warm welcome to Alan. 2 00:00:06,500 --> 00:00:13,720 Thank you. Good afternoon. My name is Alan. I'm now working for Q360 in Beijing. 3 00:00:14,310 --> 00:00:22,260 And today I'm so glad to be here to present a quick talk about cryptographic battle in OpenSSL. 4 00:00:22,480 --> 00:00:25,800 And I'll show you how to build a battle in OpenSSL. 5 00:00:25,800 --> 00:00:31,620 So before the presentation, I'd like to introduce ourselves briefly. 6 00:00:32,020 --> 00:00:38,840 The idea of this presentation was conceived by two people, Slay and me. 7 00:00:39,140 --> 00:00:42,700 And Slay is the main implementer of this idea. 8 00:00:43,180 --> 00:00:49,700 He's not only my colleague who is a keeper of mathematics, 9 00:00:50,020 --> 00:00:55,740 but also a vulnerability hunter in the Intel CPU architecture. 10 00:00:55,800 --> 00:01:04,080 Colonel in OpenSSL, and now he has found about ten OpenSSL vulnerabilities, 11 00:01:04,460 --> 00:01:07,660 including the SSL Death Alerts. 12 00:01:10,270 --> 00:01:14,020 And this is a picture of our team's office. 13 00:01:15,880 --> 00:01:20,140 So without further ado, let's look at the outline of this topic. 14 00:01:21,010 --> 00:01:25,780 In the first part, I'll introduce the cryptographic battle. 15 00:01:29,060 --> 00:01:34,560 And something about the architecture of the OpenSSL source code. 16 00:01:34,920 --> 00:01:41,040 In the second part, I'll show you how to build a new method of cryptographic battle in OpenSSL. 17 00:01:41,400 --> 00:01:43,640 And then I'll show you two demos. 18 00:01:45,080 --> 00:01:51,900 In the first part, we think this kind of battle can be used in supply chain attack scenarios. 19 00:01:55,800 --> 00:02:02,000 So firstly, as we all know, the most common example of a cryptographic battle is using weak random, 20 00:02:02,360 --> 00:02:07,280 such as dual EC, DRBG, and super random number generator. 21 00:02:08,220 --> 00:02:12,700 However, it's rarely to notice that there's another kind of battle, 22 00:02:12,940 --> 00:02:15,420 which is called the battle of mathematics. 23 00:02:16,720 --> 00:02:24,760 And security, you're really looking for vulnerabilities in cryptographic implementation. 24 00:02:25,800 --> 00:02:28,220 Instead of paying more attention to mathematics. 25 00:02:30,200 --> 00:02:36,860 Maybe because finding mathematics needs a high level mathematics skill. 26 00:02:37,560 --> 00:02:45,580 In fact, general developers do not have the same level of mathematics skills as the deniers of mathematics. 27 00:02:48,180 --> 00:02:55,300 So it is hard to detect the mathematics that is well designed, well structured, and logical. 28 00:02:55,800 --> 00:02:58,500 Who else can discover it? 29 00:02:58,840 --> 00:02:59,840 So for the open source code, 30 00:02:59,840 --> 00:03:06,080 You know, OpenSSL is the webiemf their first .. for TS and SSL codes. 31 00:03:06,840 --> 00:03:13,900 So let's do a little digging to the architecture of open source code. 32 00:03:14,200 --> 00:03:16,540 The open source code is called. 33 00:03:16,540 --> 00:03:16,620 Open source code! 34 00:03:16,620 --> 00:03:16,680 . 35 00:03:22,760 --> 00:03:25,400 Open source code! 36 00:03:25,800 --> 00:03:32,820 made in Crypto Engine SSL3 directories. And the application 37 00:03:32,820 --> 00:03:39,640 layout in the IPOS directory. The most important things are 38 00:03:39,640 --> 00:03:48,260 Crypto and SSL. The directory of Crypto includes ASN1 code 39 00:03:48,260 --> 00:03:52,980 interface, random number generator, engine mechanism, 40 00:03:52,980 --> 00:03:59,800 EVP cipher algorithm interface of a unified cryptographic 41 00:03:59,800 --> 00:04:04,160 algorithm, large number operation interface, private key 42 00:04:04,160 --> 00:04:09,900 information syntax, asymmetric cryptographic algorithm, etc. 43 00:04:10,700 --> 00:04:15,960 On the other hand, the directory of SSL is the implementation of 44 00:04:15,960 --> 00:04:22,920 SSL TR protocol. And technically, this is the 45 00:04:22,980 --> 00:04:26,060 most important thing. Today, I will build a back dog in RSA 46 00:04:26,060 --> 00:04:32,720 algorithm, cause RSA algorithm is quite clear. I first read, 47 00:04:32,880 --> 00:04:37,980 select two prime numbers P and Q and computing and after that we 48 00:04:37,980 --> 00:04:41,960 can get a public key and a private key. The second step is 49 00:04:41,960 --> 00:04:45,620 the encryption. We can get a ciphertext C. And finally, 50 00:04:46,580 --> 00:04:52,960 after the decryption, we can get a private text M. So, I 51 00:04:52,980 --> 00:05:00,020 see a simple back dog in RSA algorithm. In the key generation 52 00:05:00,020 --> 00:05:04,840 algorithm of RSA, it's easy to learn from cybersecurity papers 53 00:05:05,400 --> 00:05:10,540 that the difference between two prime numbers in RSA should not 54 00:05:10,540 --> 00:05:17,380 be too small. Otherwise, you'll be unsafe. But this definition is 55 00:05:17,380 --> 00:05:22,700 too vague. In particular, general developers could hardly know how 56 00:05:22,980 --> 00:05:27,180 more it will be in security as well as how much in security is 57 00:05:27,180 --> 00:05:31,880 there for a given difference. Therefore, we can think of the 58 00:05:31,880 --> 00:05:40,380 security as a reason of adding check patch to the key 59 00:05:40,380 --> 00:05:45,020 generation function as a generator key in the open SSL. 60 00:05:46,020 --> 00:05:51,280 And for it to give a unsaved prime time, more or less it's 61 00:05:51,280 --> 00:05:56,060 even possible to set the time complexity during which we can 62 00:05:56,060 --> 00:06:03,140 crack a private key as we wish. So let's see the patch. In this 63 00:06:03,140 --> 00:06:09,560 patch, by limiting the range of generated prime difference, we 64 00:06:09,560 --> 00:06:17,960 can crack the private key as we in one time complexity. The 65 00:06:17,960 --> 00:06:21,260 picture is look too small. So let's see what we can do. Let's 66 00:06:21,280 --> 00:06:25,900 take the example, too small, and I will upload this example to the 67 00:06:25,900 --> 00:06:34,920 Github in the later. So let's look at another compressed example. 68 00:06:36,660 --> 00:06:42,820 Imagine that we can patch a faster prime generating algorithm in order to 69 00:06:43,120 --> 00:06:48,620 generate primes with special defects under specific mathematics principles. 70 00:06:51,280 --> 00:06:56,400 we are able to control it difficultly for cracking the private key through for generating 71 00:06:56,400 --> 00:07:04,840 primes that are not strong enough, such as generating a prime number of a particular 72 00:07:04,840 --> 00:07:09,660 family, a prime prime that generates a special range difference. 73 00:07:10,340 --> 00:07:18,860 Even if the difference is large enough, indeed the prime prime doesn't seem to have any 74 00:07:18,860 --> 00:07:23,860 problem at all, but will be unsafe after certain transformation. 75 00:07:26,820 --> 00:07:30,440 So now it is our small conclusion. 76 00:07:31,640 --> 00:07:39,620 As far as I'm concerned, the problem comes from the lack of our understanding for the 77 00:07:39,620 --> 00:07:42,340 security principle of RSA optimum. 78 00:07:42,860 --> 00:07:46,700 Its safety has not been proven mathematically yet. 79 00:07:46,980 --> 00:07:48,840 The question is what is the RSA optimum? 80 00:07:48,860 --> 00:07:53,740 kinds of primes are safer and how to evaluate them. So, we 81 00:07:53,740 --> 00:07:59,900 have now come up with a strict mathematical judgment for this 82 00:07:59,900 --> 00:08:07,640 situation. And let's see the demos. I will show two demos. 83 00:08:08,340 --> 00:08:15,800 In the first demo, I will show the mandatory inspection patch 84 00:08:15,800 --> 00:08:20,060 is added. So that the difference between the two prime numbers 85 00:08:20,800 --> 00:08:29,000 output by the generator is the security boundary, which allows us to set 86 00:08:29,000 --> 00:08:45,500 time complexity to achieve a quality cracking. So, first we will 87 00:08:45,800 --> 00:09:08,780 generate a keypad. And then we will get a public key. After that, we kill the private key and then we will try to crack the private key. 88 00:09:19,900 --> 00:09:24,200 Yeah, we can print the information of the private key. And then we crack it. 89 00:09:31,200 --> 00:09:41,000 That is quite faster. So, let's look at a second demo. In the second demo, it allows the generator 90 00:09:41,000 --> 00:09:45,140 faction to output the two primes that appear to be okay. 91 00:09:45,800 --> 00:09:50,280 But it will become insecure after some transformation. 92 00:09:50,760 --> 00:09:54,920 In our case, we can require one prime number p after 93 00:09:57,580 --> 00:10:00,120 1826 range of transformation. 94 00:10:16,600 --> 00:10:22,600 Let's say as the last one, we generate a keypad. 95 00:10:39,860 --> 00:10:43,200 Yeah, we can crack it after a transformation. 96 00:10:47,480 --> 00:10:53,960 Yeah, it's quite fast and easy. It can be controlled. 97 00:10:56,920 --> 00:11:06,460 So, as I said, we think this kind of battle can be used in supply chain attack. 98 00:11:07,120 --> 00:11:15,780 Imagine that many of us may have used the public key generator in the SSL, in the SSL 99 00:11:15,800 --> 00:11:21,120 private key management, such as Excel. 100 00:11:22,620 --> 00:11:30,360 If the attacker starts attacking the compiler environment of the target software company, 101 00:11:30,900 --> 00:11:39,200 they can modify the generation algorithm of the keypad, which is harder to detect. 102 00:11:39,540 --> 00:11:42,820 So, this is what the industry needs to reveal. 103 00:11:45,800 --> 00:11:54,340 And at last, as John said, the biggest problem with the network defense is that the defender 104 00:11:54,340 --> 00:11:59,760 is thinking this and attack is thinking graphics. 105 00:12:00,100 --> 00:12:03,920 As long as this is true, attacks won. 106 00:12:04,860 --> 00:12:11,140 And that's there because it's a lot of attack methods related to the cryptographic battles. 107 00:12:11,680 --> 00:12:15,780 So, it's necessary for us to pay more attention to this. 108 00:12:15,780 --> 00:12:21,240 So, I will go back to the source code security and the cryptographic security. 109 00:12:21,820 --> 00:12:27,300 And I'll upload the code to GitHub after this meeting. 110 00:12:27,540 --> 00:12:29,620 So, thanks for your listening.