For example, in RSA, we use this for encryption: $ciphertext = (m^e \mod n)$ and for decryption.
If our message is "hello world", then what number do we have to put as $m$ in the RSA formula?
|
For example, in RSA, we use this for encryption: $ciphertext = (m^e \mod n)$ and for decryption. If our message is |
||||
|
|
|
For most real-life ciphers implemented on computer, plaintext is first changed into a sequence of bytes, similarly to the way text is stored in file. Variants abound: ASCII, UTF8.. and may involve lossless compression. For some encryption methods (e.g block cipher in CBC mode), that sequence of bytes is padded in order to make its size convenient, e.g. multiple of 128 bits. In a typical use case, RSA does not directly encrypt plaintext. Rather, the plaintext is handled as above, then enciphered using a block cipher, which key $K$ (perhaps 128-bit or 256-bit) is randomly drawn, RSA-encrypted, and send along the encrypted plaintext (typically as a header). This is called hybrid encryption. In that typical use case, RSA encryption shall yield a ciphertext representing $K$ encrypted (or if hybrid encryption is not used, a short message). One reasonably safe and popular way to proceed is known as RSAES-PKCS1-V1_5, and described in PKCS#1v2.1. Most good schemes follow a similar process:
Note: Step 4 is seen in two variants; one outputs a fixed-width byte string, the other a variable-width byte string with the first byte never equal to 00h. On top of that some wrapper bytes are often added. Note: Each of the four steps is reversible (with step 3 requiring the private key), so that decryption can work. |
||||
|
|
|
I am not an expert on this, and from what I understand there are different ways to use RSA. But I know of this one way that might answer your question. Alice wants to send a message to Bob. The first thing she does is to choose a "nice" cipher, say the blocks cipher AES. She generates an arbitrary key for this one message. This key might be say 256 bits long. So the key is string of 256 ones and zeros. If you convert each 8 bits to one byte, then you get a key of length 32 bytes. Now this key again can be written as a long string of ones and zeros. So that makes a large (binary) number. (As a concrete example. If the key was 16 bits long, say 1001011010001101, then that is the same as 38541) Take this number (the key) as your $m$ in your question and use RSA to encrypt the key using Bob's public key. Then Alice sends the message that has been encrypted with AES and the encrypted key to Bob. So the ciphertext that is sent really consists of an encrypted (using AES) message with an encrypted (using RSA) key. Bob can then decrypt the key using his secret key, and use the result to decrypt the message using AES. |
|||||||||
|
|
Every piece of information can be codes as a number. For messages, first encode each character, for example Compute the resulting number e.g. using the following recurrence
This would work, but the numbers quickly became unusable long for RSA. In practice, you generate a key for a symmetrical cipher (e.g. AES) and encrypt this key using RSA. |
|||||||||||
|