0
$\begingroup$

I am a self taught front-end developer and I am just trying to get my cryptography terminologies straight. I will make some statements. Can someone correct my mistakes?

Question 1

I read that cipher is an algorithm used for encrypting and decrypting data. Did I misunderstand?

Question 2

I found these regarding RSA:

C = M^e mod N   # encrypt a message
M = C^d mod N   # decrypt a message

Where:
M is original message
C is encrypted message
ed = 1 mod (p - 1)(q - 1)
N = pq
p is a large prime number
q is a large prime number

Is it correct to call C = M^e mod N and M = C^d mod N asymmetric ciphers because it uses public private key encryption algorithms? When I search the web, I'm not finding the terms RSA and asymmetric ciphers mentioned in tandem, so that's why I feel like I've misunderstood something more fundamental.

Question 3

I read in some places that RSA is a block cipher. And I read in some places that block ciphers are symmetric. Because I am stuck on Question 2, and keep thinking of RSA as an asymmetric cipher, I am having difficulty understanding how it is symmetric as well. Can someone help me clarify the confusion?

Question 4

If I run these two commands:

openssl genrsa -out key.pem 1024
openssl rsa -in key.pem -pubout -out pub.pem

Am I effectively finding values that satisfy these relationships of the RSA system described in Question 2?

ed = 1 mod (p - 1)(q - 1)
N = pq
p is a large prime number
q is a large prime number
$\endgroup$
2

1 Answer 1

3
$\begingroup$

Q1: A cipher is an algorithm for encrypting data (the plaintext), turning it into ciphertext, and decrypting that ciphertext into the original plaintext. There are various notions of security, but broadly the goal is that nothing leaks about the plaintext for an adversary getting hold of the ciphertext.

Q2: With the addition that we must have $p\ne q$, and $0\le M<N$, and $p,q,d$ secret while $N,e$ is made public, and (in the most common variant where $d$ is found from a small $e$) that $e>1$ is chosen with no reference to the particular $p$ and $q$ beyond $\gcd(e,p-1)=1$ and $\gcd(e,q-1)=1$, yes that's a correct description of textbook RSA. It is believed secure for random $M$ when it's not an issue that a guess of $M$ can be checked and adversaries do not have access to a decryption oracle. RSA as practiced (e.g. RSAES-OAEP) is secure without these hypothesis.

Q3: Textbook RSA arguably becomes a block cipher if you make the key $p,q,e,d$ with all components secret (thus large). However it becomes a block cipher with an unusual block domain (the integer interval $[0,N)$ where $N$ is e.g. 2048-bit for common key size, versus bitstrings of some smaller size for standard block ciphers, e.g. 128-bit for AES), and undesirable characteristics for a block cipher (three easy to find fixed points $0,1,N-1$, and worse the so-called multiplicative property $\operatorname{Enc}(M_0\,M_1\bmod N)=\operatorname{Enc}(M_0)\,\operatorname{Enc}(M_1)\bmod N$. RSA as practiced does not have these drawbacks, but can not be considered a block cipher: encryption is not a function (encrypting the same message twice typically does not yield twice the same result), and the message space is (thus) much smaller than the ciphertext space.

Q4: Yes, this generates an RSA key satisfying the stated conditions, and the required extra ones stated in Q2. The 1024 parameter is the bit size of $N$, and somewhat too small by modern standards (a typical value would be 2048). To see the values, try openssl rsa -text -in key.pem after the first command. You'll get modulus $N$, publicExponent $e$, privateExponent $d$, prime1 $p$, prime2 $q$, in hexadecimal (except for $e$ also shown in decimal). There are other quantities to help a fast decryption, and a conventional representation of the private key encoded as characters.

$\endgroup$
6
  • $\begingroup$ IMHO, this question should be closed, not answered; it is too broad and has lots of words to mention that have no reference at all. The OP 15 years of experience on Stack Overflow.. $\endgroup$
    – kelalaka
    Commented Feb 20 at 10:21
  • 2
    $\begingroup$ @kelalaka I get your point of view. But well, once viewed as a terminology question and re-tagged accordingly, the question makes sense, and is answerable (I wish all our Qs would be). I'd still understand that it gets closed, though. $\endgroup$
    – fgrieu
    Commented Feb 20 at 10:25
  • 2
    $\begingroup$ I disagree with your answer to #3. A block cipher is a symmetric-key primitive. $\endgroup$
    – Mikero
    Commented Feb 20 at 14:19
  • $\begingroup$ Still too broad. We should not encourage the broad questions to be answered. $\endgroup$
    – kelalaka
    Commented Feb 20 at 14:20
  • 1
    $\begingroup$ @Mikero: my point is that with $p,q,e,d$ considered the key and all secret (thus large), RSA becomes symmetric key cryptography, and a block cipher with undesirable characteristics. I have trimmed the answer accordingly. Twice, actually. $\endgroup$
    – fgrieu
    Commented Feb 20 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.