 Hello, good morning. I'm going to speak here because of the recording, but the place is small. I could do it without the microphone. Thank you for coming. Usually, in these sessions about encryption, I don't expect to see too many people. Only the most interesting people. I would like to first say that I'm not drunk. I just a bit sleep deprived for the last three days, so be patient with me. My name is Rodrigo Pancinac Fernandes. I'm a Drupal developer for the last more than 10 years. In the last five, six years I have been working with client-side encryption in Drupal. I have been giving some presentations about this in the last four years, five years perhaps, in several Drupal camps in other IT events. But this is my first time in a Drupal com. The texts I submitted to propose this session had the word, more or less, you should use OpenPGPJS. This is a choice of words that me as a attendee in an event would not attract me. Because I don't feel comfortable when someone tells me what I should do. It's an option, not something required to do, right? It's not very humble to use this, but it seems that in our area people say this a lot, you should do this, you should do that, in reality it's not like that. But to go with this idea, this presentation will try to tell you that everything you are doing is wrong by not doing this. Why? Because a client-side encryption that protects the content against the site owner, against the system administrator is the only way of really protecting the content from any possible leakage. Why? But this comes with a price. The biggest price is that you cannot recover a password. So if you encrypt the content with a zero knowledge proof schema, like this presentation will show, if the user loses the password and the password is not recorded anywhere, the content is lost forever. Unless this content can be encrypted by some other recipient of that same content. So this is also a subject that I would like to try to explain. Let's see. I have split the topics in this presentation in three parts. Let me try to move to the next. So this is very simple summary of what comes ahead. There are some technical topics, some political ones and those that are like most the mathematical that are related to the number theory. These are the most interesting ones. But this session is called a workshop and it would not be a workshop if I did not show you some coding. So this is what comes first. I want to show these small pieces of JS code that do most of what is being proposed here. It's not much. And this is the tailored of the technical topics. So we are using RSA encryption, so we do generation of the keys. Then this is a symmetrical schema, but with a symmetrical encryption of the private key. And this is the second topic, symmetric encryption and the encryption of private keys. Then, and this is the part that relies most into Drupal, selection of recipients embedded in fields. But this approach could be, it goes beyond Drupal, could be used in any kind of web development technology. Then a symmetric encryption and the encryption of content. Obviously this is the main idea. And finally what I was saying before, update of encrypted content. That is something that is needed if someone loses or renews, someone receives a file, encrypted file or encrypted text, whatever. And this person that was a recipient, he used his encryption keys. So you have now a new public key. So the public key you had before that was used to encrypt is not going to be used for anymore for the now because you have a new one. So you lost that content. A solution for this is the crypt and encrypt again. So someone who has received that piece of content, if there is at least one person that still has access to it, this single person can save the entire group. Now, and these are the technical topics, but before jumping into them, I want to come here to the political topics as well. This is for me more appealing than the technical one because the technical topics, you go through the documentation of OpenPGPJS because this is what is being used here. And you learn it by the example, so it's not a big challenge. The details are complex. Sometimes it's hard to fulfill the details, but the main idea is simple. But this is what really makes difference in the community for the world is the certain kind of political view of what is the ownership of the content. And I think we are doing it wrong. And finally, and this is what I like the most, number theory topics. Because all of these only works based in this very amazing behavior of the numbers and especially the prime numbers. Because we cannot predict the next prime number. And why we cannot predict and we cannot prove, we cannot predict the next prime number. So it's an open question that takes us to the Riemann hypothesis. So, and this is why you were listening to this annoying music in the beginning. Let me play it a little bit more for those that came later. This is kind of a music that is a musical representation of a sequence of numbers. And this sequence of numbers you can find in a very nice encyclopedia that I will do a survey here to let's see. Please, hands up, who knows Wikipedia? Everyone. Now, please, hands up, who knows the online encyclopedia of integer sequences? No one. So this is interesting. Perhaps I'll read something that you can bring home. Some knowledge that you can bring home if you are interested in number theory. In science in general, because many Wikipedia articles will have links to the online encyclopedia of integer sequences. So most of the, every place in science where a sequence of numbers is important, probably that sequence of numbers is already encoded here. And if you come to find a sequence of numbers that is not here, you can propose it. So this encyclopedia allows you to search with the numbers of your sequence. So you can have it from the start or in the middle and it will try to match that sequence. Also, you can search here by the name of the person who found the sequence. And that one that I was playing, I found it. So if I look for my own name, I find it here. And it's a bit hard to follow the explanation because it's not only number theory mathematics, but it also follows a certain pattern of a way to describe the mathematical properties that is defined by the editors of this encyclopedia. So when you find a sequence, you have to propose it. And then there is a, it looks like a Drupal issue queue of editing and making that and try it better. So it can take a certain time. So you can see here the old discussion that happened until the final shape of the sequence. And this, you can put some, here I have proposed a JS code because this is what I knew with this notation of big integers. And this small piece of code is going to generate the sequence of numbers in the music you were listening before. My friends are here. I thought they would not come. Thank you for coming. They are my closest friends in the event. I thought not even they would come. But as I was saying, not too many people come, but the most interesting people come, right? Now back to the presentation. So this is, I have more, I like the most the number theory topics than the other ones, but as I was saying, I'm going, this is a workshop, so we need to go through some code. So let me start by the beginning. In summary, what it will look like for the final user is just that the content is behind a password. And bigger is the password, safer it is against a brute force attack. So the schema, this schema is asymmetric because it has a public key and a private key. But the private key is going to be stored encrypted in the server. So the original private key, we never saw it. It was never submitted. And the password the person has used to encrypt the private key, we never received it as well. So these fields that are, by the way, the strength of the password that we are using here is not very good. This should not, how strong the password is should be represented by how long it takes to brute force find it. But this is not going to be submitted. It's only what goes submitted is the encrypted version of the private key. So usually generates a pair of asymmetric keys, RSA 2048, or even better, double that by typing a symmetric keeping password for the protection of his private key. So the password field in the form is never submitted. This is what I was saying. Now a little bit of JS code that is handling the OpenPGP.js. This is the main object here, OpenPGP. You have to load the library. There are some settings here. We have a method generate key, and that's it. You need some input to generate the key. That is, you need a string, right? It could be any other string, but the email is usually used. So it's here, email, name and the password, the password that the person has typed. Here is hardcoded the size. It should be already double this. Now if you want to use for the encryption, then once you did that, your account, the account of the user is related to a public key and the encrypted version of the private key. The public key is going to be used to buy someone who wants to send you something. And the private key, the encrypted version of the private key is going to be used by yourself for decrypting a content received. So there is this intermediary step for decrypting something that is using the password that only you know, it's only recorded in your brain. And this is important for this schema, is the password should never be stored anywhere and only in your brain is the preferred media. Then this is OpenPGP version five. You have this really private key and then you loaded the encrypted version of the private key from the server and then you can decrypt key. And that's it. Now once you have decrypted your private key, the next step for the decryption itself is to use the decrypted private key. But before that, when someone was sending the content to you, what is needed, the public keys of the recipients. And then Drupal and this is Drupal seven, but this could be replicated in any version of Drupal and even beyond Drupal. You can define, for example, a view that's going to list some users, for example, my friends, for whom I want to send something. I could have in forms several fields, each field encrypting content for different users. So the sky is the limit, you can do whatever you want. You can also have, I have a list of my friends, but some friends like music or the friends like sports. And I want to decrypt different contents for each of those subgroups of friends. I could handle this with views and passing arguments to the view to return a different set of users with a different set of public keys. Now, once these public keys have been selected, I can start encrypting the content for those persons. And this is what happens here, OpenPGP encrypt. Yeah, it has also this create message method that is for the version five of OpenPGP.js. And after encrypted, the person wants to decrypt what means for the final user just typing exactly the same password that the user used when creating the keys. And when this is done, a message is going to be decrypted. Here is ciphertext, is the text representation in armored format of the file of text or whatever content was encrypted. And there is this decrypt method and the decrypted private keys used. So this came from the previous step we were talking before. Now, update of encrypted content, this is a bit of a challenge because you have, for example, a group of users and they need to receive certain content. But in a community platform, sorry, in a community platform, you always users are coming in and leaving the platform or moving from one group to another. So frequently, the list of recipients of a content becomes outdated. So what can be done is this concept of updating encrypted content that means he encrypting it. How we can do it, if at least one person still has access to that content, this person can trigger the decryption of that content and the encryption of the same content. Now, adjusted to the most up-to-date list of recipients. And this is a kind of maintenance that works better if it's automated. And to automate this, in my opinion, the best way is like the poor main scroll, the concept, meaning every time a person decrypts something, the system will try to find if there is some outdated content that person has access. And therefore, by typing the password to decrypt your content, behind the scenes you are also updating content to other people. So this is a way of keeping the privacy scheme as strong as possible. So the first step is you have to decrypt something and then you introduce your decryption password. Then the system needs to find if new recipients are needed for that content and then encrypt it. And this is two ways. Sometimes you want to add new users, sometimes you want to remove old users. But it's doable. It's a bit hard, but it's doable. Now, political topics, the way I see, we should be doing this by default. We are not owners of the content of our users. So if the CISA administrator, the DevOps team, if they can access something, it means the content does not really belong to the person it should belong to. Client-side encryption is hard, but it's the only known way to keep data really connected to the intended recipients. Then what we could do even for the anonymous user, there is something that we can do. Because this pretty good privacy scheme also contains signatures. We can sign content. And signing cryptographical signing means that the person who created the content cannot deny that action. This is the idea. The signature is against the person who signed it. So, for example, if I want to spread fake news, but I'm required to sign, the content becomes traceable. So this is also a strong way of killing fake news or making it easier to detect the origin of a content. So we could, for example, adopt a very weak, the most weak private key and give access to this private key to everyone. This is a bit weird concept because the private key should not be public, right? But we can do this. We can define a private key for the anonymous user. And then if we want to publish a content without restriction of access, I could encrypt that content to the anonymous user. And then every anonymous access will have by default access to that key and will be able to see the content. Now, if this comes together with unforeseen signature, all the public content would always be traceable back to the auto. For me, it's a bit amazing that these concepts, they exist since the 60s, and we are not using it. And the society is being harmed by not having this yet. It's amazing. Now, number theory topics. This is what I like the most, as I said before. All of these, the RSA schema comes from these amazing properties, properties of numbers that is, I hope it's simple to explain. You pick two priming numbers, you multiply them. This is easy to do. But you have the product of those numbers you want to find which were the two numbers that were used to get the product. This is not easy to do. So it's easy to go from one side to another, but it's not easy to reverse this function. It's like breaking an egg. It's easy to break an egg, but once you have the egg broken, it's very hard to put the pieces in the original state it had. Priming numbers, they have an algebraic definition that is based on division, right? So a priming number can be divided by itself and by one without anything left. But this is, it's not my preferred way of understanding a priming number. I like to think about priming numbers geometrically. So if you cannot make a shape without any hole on it, a certain shape, then you have a priming number. So for example, let's take the first example. If we don't consider one, we don't consider two because it's a bit artificial priming number. But let's jump into three, the number three. If you have three squares and you want to align these three squares, I can put the three squares one at the side of the order, so three divided by three. Or I can put the three squares one at the top of the order, it's three divided by one. Okay, now can I put two squares below and one above? I have a hole at the side. So the numbers where you have a hole are the priming numbers. Interesting behavior. And this is amazing because it's an unknown behavior of something that is totally arbitrary. So the natural numbers, sometimes called unassigned integers, but I like most the concept of natural numbers. They are one very basic, how can I say? They were created or they were invented, right? Perhaps you can see then as created, as discovered or as invented. But anyway, they are something very simple, but even though we don't know all the properties of the natural numbers. And one property is we cannot predict the next priming number. So because we cannot predict the priming numbers, it's not doable to revert a public key into the original priming numbers that generated it. And the priming numbers that generated the public key, they make the private key. And this is the only reason why a symmetric encryption works. Now that the time is going, I want to show a difference of what... So first I was showing this music. This is avoiding priming numbers. But because it is avoiding priming numbers, it's kind of connected to priming numbers as well. And you see that this is not random, but at the same time you cannot predict which sound will come. It's very interesting. And it's different from something that is really random, I can show. Now this is random. For me it sounds better the previous one than this, but I think this depends on the person. Well, I hope I have given you some new information, something that will stimulate you to learn more later about this subject. Thank you for your patience and attention. I have to open it for questions, right?