# Clarifying terms for cipher, algorithm, rsa, asymmetric, openssl

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


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, 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.

• 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.. Feb 20 at 10:21
• @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.
– fgrieu
Feb 20 at 10:25
• I disagree with your answer to #3. A block cipher is a symmetric-key primitive. Feb 20 at 14:19
• Still too broad. We should not encourage the broad questions to be answered. Feb 20 at 14:20
• @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.
– fgrieu
Feb 20 at 14:29