Gadgetory


All Cool Mind-blowing Gadgets You Love in One Place

How does encryption work? - Gary explains

2016-09-13
hello my name is Gary sim from Android Authority now you probably use encryption every single day if you have a TV or scalable service as bringing content down to your house then probably some of those channels are encrypted so that only people who pay for the right channels can get the content if you have a connect to a website that ask for your username and password then that's probably an encrypted connection even if you create a zip file with a password on it that again is encryption there are loads and loads of examples of encryption every single day in our lives and most of the time we don't even think about it but if we just stop and think we can ask ourselves the question how does encryption work how is it keeping all of my bank detail safe how is it keeping all of my personal information safe well let me explain so the first question of course is what is encryption encryption is a process of taking normal information let's say text and turning it into a version that can't be read by other people now to do that conversion you need a key and the analogy here is like a key that you put into a lock to open a door once you have the key you can unlock which is decrypt that information without the key it remains locked as the Tom Jericho character put it in that great film enigma it turns plaintext messages into gobbledygook it turns plaintext messages onto gobbledygook the problem is the machine has 150 million million long residue now of course the advantage of having things encrypted are enormous if you want to send something like bank details a day you don't want a cyber thief cyber criminal to be able to take that new information spend money on your credit card course encryption used by government has been used in warfare it's used by all manner of different things now the art of secret writing has been around for several thousand years but of course the most famous example is from Julius Caesar he wanted to write some secret messages to Cicero and to do so he used this thing we call today the Caesar cipher now it works like this if you take the alphabet ABCD all the way through to Z and then underneath it you place another alphabet but rather than placing a under a or b under B you shift the bottom alphabet by it to the left or to the right by a few characters now here's an example for us I've shifted the alphabet to the right by 3 now if I wanted to encrypt the word hello what I do is I look up H on the top row and then I see what character is beneath it on the bottom row in this case it's an e I then look up e for hello the second letter of hello and I look again to see what's below it and I get a B I then look up the L and I get AI and then look up L again and I get AI and then finally look up oh and I get L and now this word that we have here is not the word hello it's just complete gibberish so someone else seeing that wouldn't know what the message was now the great thing is if we shift the alphabet by five characters rather than by three we now get a different result so H becomes C e becomes Z L becomes G L becomes G and OB comes J so depending on where I've shifted the alphabet depends on how the message is encrypted and therefore when someone else sees it they don't know which alphabet I've used to encrypt this mesh in therefore the message remains hidden to them now of course there are some disadvantages first of all if I was writing hello how are you today then the spaces would also be appearing in the encrypt Mesa's so someone's seeing it would say our this looks like a sentence there are short words and longer words and there are spaces between them but I don't know what it means and that would give them a clue that they need to then try to crack this encryption also there are only 26 different possibilities to move the alphabet left or right and now if I was a an Army General and I had 26 soldiers at my disposal I have just called them all into a room and say right here's an alphabet for all of you try to decrypt this message and the first one that gets some good information out raise your hand up and actually they would do that in just a couple of minutes so it could be broken quite easily because there are other weaknesses as well for example the letter e appears the most frequent in the English language so if I look down my encrypted Mayson notice which one is the most frequent I can then just line that up on my alphabet and I've decrypted the whole mess it's called frequency analysis and of course a day with computers this could be just broken in just a mere moments because it's very easy to crack now one way to make a Caesar cipher stronger is to use multiple encryption alphabets not just one so here's an example where I'm using five alphabets now if these five alphabets if I take the key W V Y what that means is I start with the Alpha that begins with W then I use the alphabet that begins with the V and then I use the alphabet that begins with Y and if we again try to encrypt the word hello what we get is by looking at the W and then going across for H we find D then we move to the alphabet that starts with the V and we go across to we find E and now I get Z and then we get the alphabet that begins with a Y and then I move along until I find L and now I get J if you continue on you get H and J again now what's interesting about this is that now we've got the letter J appearing in our encrypted text twice but J doesn't refer to the same letter in both of those cases because they'd come from different alphabets in fact this system can be expanded to full 26 alphabets and that was a system used by Visionnaire in the 16th century and it proved to be a very popular cipher and in fact it was 300 years before it could be cracked eventually it was cracked by Charles Babbage the famous inventive inventor the difference machine and sometimes is called the father of computing but he didn't publish his work and then a few years later it was broken by Fredrik Kaczynski who did publish his work and the Visionaire cypher fell now following on from the Visionnaire cypher we have the idea of a cipher that is completely unbreakable that's both theoretically and practically it's no way to break this cipher and it's called the one-time pad now at the top level you might have ABCD all the way through to Z like before but below rather than having ABCD which is actually a sequence we really know what's going on there if it was a random sequence of letters then there were no way to know what that random sequence is and if that random sequence was as long as the message itself then you are always using something random to encode the key and if you never use it ever again that one sequence is only ever used once then there's never any other reference data which you can look at to try to find chinks or holes in the encryption is completely unique and it happened only once and there's no way of getting into it now the problem with a one-time cipher pad is that the recipient needs to have exactly the same pair of exactly the same a random sequence on it to be able to decode that information and because you can't send that over the internet you can't send it through email or something you have to meet them and you have to give them a pad a page in a notepad which has got this sequence of letters in it and then every day every hour whatever you can change which pad you're using and change which page you're using and once you've use the page you can rip it up and you throw it in the fire and that's it is destroyed and it can never ever be recovered now by the time we get to people like a Babbage we're now talking about the Industrial Revolution the steam age and mechanization and the upshot of this new industry was the encryption became meckley nice and probably the most famous example of that is the Enigma machine used by the Nazis during the Second World War rather than having to do encryption by hand the message were typed into a machine and it would pop out with the relevant encryption now of course that meant that the encryption could be very sophisticated with millions and of variations because the machine was doing the hard work now of course in crip the enigma was eventually cracked as well and if you really want to find out something interesting in history about encryption then you should study the story of the Enigma machine not only the cryptography but also the people involved and the history and the impact on the Second World War and so on now after mechanization we now have the age of computers and this brings us into a whole new age now computers are very different to mechanized machines like the Enigma machine for three different reasons one is they're flexible the Enigma machine was fixed once it was built it did it only one way you could change the key but it'd only be the encryption one way computers are reflectable we can write new encryption algorithms very very easily we can test them we can discard them we can investigate the more flexiblity second of course is the speed can be so much faster than any mechanized machine and thirdly and most importantly we are now dealing with data rather than text messages so even during the Second World War it was messages that were sent out into the field about the war effort but now we're dealing with data we're not dealing with ABC we're dealing with numbers we're dealing with movies JPEG files within with video files we're dealing with music files with dealing with databases we're dealing with any kind of data that can now be encrypted including of course our transactions on the Internet now when you start to deal with data you start dealing with ones and zeros as binary on and off and you can group those binary numbers in together and we might group them together as bytes or a 16-bit word or 64-bit words we do that but actually ultimate you're just dealing with ones and zeros now in the digital age as I said we're now dealing with data rather than dealing with letters so the idea of a simple substitution that the letter H is now equal to the letter L and the letter L is equal to a letter J doesn't work the same now because we're dealing with data now one of the key functions that's used in encryption is what's called the exclusive-or and it's a really a magical function now exclusive-or basically means that if you have two bits a and B we want to know whether it's a or b but not both okay so one or the other but not both of them at the same time now what that basically means is if you have a 1 and a 1 the answer is false 0 if you have a 0 and a 0 the answer is false 0 but if you have a 1 and a 0 or a 0 and a 1 you get 1 ok so that's the way it works as a logical operation on two bits now cause two bits means think about it the top alphabet and the bottom alphabet you're combining two things together but the great thing about XOR exclusive-or is that if you run it again you go back to your original numbers you can try this at home the rapini of websites where you can try this out so basically if you do a X or B and you get c if you then do C XOR B you get a so backwards it goes in both directions in fact actually if you do see X or a you also get B so it's really amazing you can just combine these things and which and it goes back and forth which means you get encryption and decryption now of course what you want to make sure is that the number your XOR in the plaintext against the key is random or is certainly difficult to guess so that you don't you can't just X on the back again and get the original information so if you just use a standard XOR on a key it's very easy to break in fact there's a website you can go to just give it a file and it will just tell you in about two seconds what the key that you use it so you have to use this in combination with other techniques but it's really important to understand XOR exclusive or a or b but not both not a and B together now there are two main types of cipher in the digital age the stream cipher and the block cipher now the stream cipher basically takes each byte or maybe something bigger each unit of the stream of data one of the time it applies encryption to it pass it to the output takes a next one doesn't to it part of the output the data streams pass the encoder and it deals with it in tiny any sections now our block cipher is different a block cipher tends to deal with the file or data as a whole now we get the word block because it divides up that data into blocks and the blocks might be 64-bit blocks or 128-bit blocks and then it does encryption on those individual blocks and sometimes the blocks interact with each other to do different things so there's are two different ways of doing the ciphers now a stream cipher is more like the one-time pad we're trying to have a sequence of numbers that we can apply to our original data that seems to be random and the more random it is the less chance there is of it being broken now the problem is it can't be truly random because the person at the other end needs to decrypt the data which means there has to be a starting point and there has to be a way of generating the same random numbers so the information can be decrypted so therefore we call it pseudo-random when you look at it casually it might look like random numbers are going up and down the spacing the frequency between them it seems to be all over the place however if you wound up the same machine plugged in the same numbers you get the same sequence of random numbers out again if you plug in the same key you get the same result and that means you can do encryption and decryption but because of this it also means that it can be attacked because in the end it's still a set of numbers that are being produced by a computer according to a function and if you can work out how that manifests itself you can then start to guess the keys now rc4 was a stream cipher and it's been used for many many years and we find it in a Wi-Fi we find it on the internet but it was using this pseudo-random sequence and in the end they've started to find ways of attacking the random numbers in the sequence and finding correlations between the original data and the random numbers and therefore they were able to produce some chinks in it now today it's not considered reliable because under certain stark circumstances it can be cracked in a matter of minutes in other situations it might still take years however is now considered unreliable when it comes to block ciphers things are a bit different there was a man called feistel who was working for IBM encryption during the 1970s and he came up the idea of a feistel network now a feistel network takes all the data needs to be encrypted and divides it into blocks then each of those blocks are encrypted using a key now once they're encrypted it goes round and does it again and then again and then again and these are called rounds and each round a modification of that key a variant of the key is used so effectively it's being encrypted again and again and again now the idea is the more rounds you have the greater the encryption now basically his work led to something called the data Equipe ssin standard which was basically american government saying they wanted a standard way for computers to talk to each other and so here's a standard for how to do it and you had to have a key it would then get encrypted it could be then sent to somebody else in a different company in a different department and they would know how to use DES to be encrypted now the problem with des was it had a limit of a 56 bytes of key size now in 1970s and 1980s that was absolutely fine however by time we get to the 1990s non-governmental organizations had enough computing power to be able to break deaths encrypted messages in a reasonable amount of time now the initial way to get around this was to use something called Triple DES which basically meant that the data was encrypted three times using three different keys and that extended the size of the encryption key from 56 bits up to 168 bits however because of some technical issues that actually the effective size is 112 bits now that's still pretty amazing because if you had a machine that could crack a DES message in one minute and there aren't any but if you did have a machine that could crack it in one minute then to crack a Triple DES message you'd need 260,000 years so that's still a pretty good encryption sister and it's use a day a lot by the payment industry however the American government again wanted to produce a new standard for encryption and so they started to look for a new algorithm the result was something called AES or the advanced encryption standard and that's what we use today now it's also a block cipher it also uses rounds so it has rounds and has keys just like a faisal network but it's not a vital network actually uses substitution and permutations now if you want to find out more about faisal networks des a aes stream ciphers and all these things I've mentioned the written article that goes with this video has got lots more detail more than I can cover in just this short video and AES is what we have today is what we find in android 5 and Android 6 I'm basically Android 5 and Android 6 there was the option to encrypt the entire disk so the entire disk was encrypting every single bite and bit that was done to that disk went through an encryption layer that could not be broken because it's with AES now with Android 7 what we've moved to is now file based encryption so rather encrypting the whole disk the disk itself is is in the clear is plain but the files on the disk are now encrypting that has two advantages one is that the files can be have different lengths of encryptions you gather a file that's got very very super super encryption on it and you've got files i've got good encryption but not as good as the super super encryption that of course affects speed slightly and secondly it means that only files when they are open do they need to be decrypted they can be decrypted independently of each other now that's android 7 now when are moved from its 32-bit architecture in arm v7 to its 64-bit architecture in arm v8 it included some extra instructions to do with encryption now because AES is a standard and the way it works is well-defined it's a published standard are more able to put some instructions in the hardware that made a AES quicker because it was too handled in the hardware and because it's a block cipher basically you've got these blocks of numbers and they need to be switched around they need to be swapped about a bit and you can do that in software you can say take this bit here and copy it over there and take that bit there and copy over there and that can happen however if you do it in hardware you can just say hey do that thing you need to do for a is there then basically it happens at the hardware level in fact you get a really good factor of performance increase because it's in the hardware so therefore arm v8 has AES encryption built into it which means 64-bit chips in our smartphones have aes built into them and there you have it my brief overview about encryption now encryption really is a huge area of study people do a PhDs in encryption so this really is just the minimalist of an introduction there's loads more things that could be said in particular I haven't touched at all on public key cryptography now if you'd like to see a part two to this video please do let me know because if there's enough interest I will make a follow-up video which looks at the ideas of public key cryptography well my name is Gary Sims from andr authority I hope you enjoyed this video if you did do please give it a thumbs up also please don't forget to subscribe to Android or ities YouTube channel please follow me on Twitter and on Google+ also follow and rathore 'ti on twitter and on google+ and on instagram don't forget to download the android or 'ti app because that will give you access to all of our news and features directly on your mobile phone and last but not least don't forget to go into android or thority comm because we are your source for all things Android you
We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.