• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 448
  • Last Modified:

trying to understand Diffie Hellman/RSA and Ellipical Curve Algorithms

I have been studying for the CISSP, and how these algorithms function really intrigue me.  Unfortunately, I took stats, finite math, and trig.  I didn't take calc.

Can someone recommend a good book for those behind in math can understand these?  Elliptical Curve is the only one that somewhat makes sense.  

Your thought and insights would be helpful.

  • 3
  • 2
1 Solution
Dave HoweSoftware and Hardware EngineerCommented:
what is it you are trying to understand? the usage, or the formal proofs?
NYGiantsFanAuthor Commented:
well. something that will break this down for curious dummies.
 modulus ?


Key generation
RSA involves a public key and a private key. The public key can be known to everyone and is used for encrypting messages. Messages encrypted with the public key can only be decrypted using the private key. The keys for the RSA algorithm are generated the following way:

1.Choose two distinct prime numbers p and q.
For security purposes, the integers p and q should be chosen uniformly at random and should be of similar bit-length. Prime integers can be efficiently found using a Primality test.
2.Compute n = pq.
n is used as the modulus for both the public and private keys
3.Compute the totient: .
4.Choose an integer e such that , and e and  share no divisors other than 1 (i.e. e and  are coprime).
e is released as the public key exponent.
Choosing e having a short addition chain results in more efficient encryption. Small public exponents (such as e=3) could potentially lead to greater security risks.[2]
5.Determine d (using modular arithmetic) which satisfies the congruence relation .
Stated differently, ed  1 can be evenly divided by the totient (p  1)(q  1).
This is often computed using the Extended Euclidean Algorithm.
d is kept as the private key exponent.
The public key consists of the modulus n and the public (or encryption) exponent e. The private key consists of the modulus n and the private (or decryption) exponent d which must be kept secret.

Notes on some variants:

PKCS#1 v2.0 and PKCS#1 v2.1 specifies using , where lcm is the least common multiple instead of .
For efficiency the following values may be precomputed and stored as part of the private key:
p and q: the primes from the key generation,
 and ,

[edit] Encryption
Alice transmits her public key (n,e) to Bob and keeps the private key secret. Bob then wishes to send message M to Alice.

He first turns M into an integer 0 < m < n by using an agreed-upon reversible protocol known as a padding scheme. He then computes the ciphertext c corresponding to:

This can be done quickly using the method of exponentiation by squaring. Bob then transmits c to Alice.
Dave HoweSoftware and Hardware EngineerCommented:
ok. the totient is (p-1)(q-1) provided p and q are prime.

the reason for this is that the totient of a number is the number of integers that are relatively prime to it - and if p is prime, then there are p-1 other numbers relatively prime to it (and similarly for q)

the modulus function is the old "remainder" function you may remember from kindergarden division - where 8/5 isn't 1.6 but "one remainder 3"

it finds a place in integer math, where integer division only ever gives an integer as result, discarding the fractional part of the answer. from the above example:

modular math is also occasionally called "clock math" as the most common example is a clock - where minutes are modulo 60 and hours modulo 12 or 24 depending on where you were brought up :)

so, 27 hours is always 1 day 3 hours, not 1.125 days :)
Dave HoweSoftware and Hardware EngineerCommented:
so, from the above RSA:

find two prime numbers p and q

calculate n (where n is pq)

calculate x (where x is (p-1)(q-1)

choose some arbitrary integer e (where e < x/2) (512 is a common choice)

calculate d such that d times e modulo x is equal to 1 (the integer division result may be larger than 1 if this is easier)

for fairly complex reasons, for any integer m, the value of "m to the power (de) modulo n" is equal to m

therefore, "(m to the power of e mod n) to the power of d mod n", because it is the same as "m to the power (de) mod n", is equal to m

so by calculating some cyphertext value c equal to "m to the power of e mod n" then calculating "c to the power of d mod n" you get back the original m.

the bit that gets handwaved over there is the the proof for "(m^de)%n=m" :)

NYGiantsFanAuthor Commented:
Thanks.  I am going to print this out and try to understand when I have some time.  Thanks again Dave!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

We Need Your Input!

WatchGuard is currently running a beta program for our new macOS Host Sensor for our Threat Detection and Response service. We're looking for more macOS users to help provide insight and feedback to help us make the product even better. Please sign up for our beta program today!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now