One thing cryptography articles never seem to explain is how the message actually gets encrypted.
Either you're reading really bad articles or you're missing a step. Try reading better articles and follow along very carefully.
Then, they never explain the process of exactly how some 100,000 byte word document gets encrypted using the public key.
You break up the document into blocks of a particular byte size. Treat each block as a series of bits. That's a number. Feed the number into the crypto algorithm, get a number back out. That's also a series of bits. Now you have turned a series of plaintext blocks into a series of encrypted blocks.
Other times the explanations seem downright misleading. For example, in my book Cryptography (by Meyer and Matyas) it says for RSA the ciphertext is the plain text to the power of key. How do you exponentiate a word document?
If you really want to see how it works in practice then I encourage you to read the source code. For example, download the source code for BouncyCastle and take a look at the GetInputBlockSize
, GetOutputBlockSize
, ConvertInput
, ConvertOutput
and ProcessBlock
methods in the RSACoreEngine.cs
file. This is only 150 lines of pretty easy-to-follow code but it answers all your questions.
As others have mentioned, it is often impractical to use public key crypto on large documents because the math is slow. Usually what you do is choose a symmetric cryptosystem, choose a random key in that cryptosystem, encrypt the document in that cryptosystem, encrypt the symmetric key using the public key. Now the document cannot be decrypted without the symmetric key, and the symmetric key cannot be decryped without the private key.
How do you exponentiate a word document?
A word document is but a series of bytes. When doing encryption you don't care about the underlying format, you treat it as a big number, like the letterA
is the number 65 in ASCII. Go grab the nearest Word doc in your system and look for file size in bytes in the properties: You'll get the number $n$. If you decide to encrypt it with textbook RSA, you will have a $8n$-bits long number in your hands. – rath Mar 12 '14 at 01:23