# Calculating RSA Decryption Key

D

#### DarkProtoman

How would I write a function to calculate RSA Decryption key. I'm
trying to write an RSA encryption program, and I'm stuck on calculating
the decryption key. How do you check for coprimality? Thanks!!!!! I'm
using C++.

V

#### Victor Bazarov

DarkProtoman said:
How would I write a function to calculate RSA Decryption key. I'm
trying to write an RSA encryption program, and I'm stuck on
calculating the decryption key. How do you check for coprimality?

Please don't cross-post this to comp.lang.c++. Your problem has
nothing to do with the topic of c.l.c++. Thanks!

K

#### Kai-Uwe Bux

DarkProtoman said:
How would I write a function to calculate RSA Decryption key. I'm
trying to write an RSA encryption program, and I'm stuck on calculating
the decryption key. How do you check for coprimality?

Google for Euclidean algorithm.

Best

Kai-Uwe Bux

D

#### DarkProtoman

Kai-Uwe Bux said:
Google for Euclidean algorithm.

Best

Kai-Uwe Bux

I have. But I can only find psuedocode for the Euclidean algorithm, not
the EXTENDED Euclidean algorithm which I need. Can any one here produce
the Extended Euclidean algorithm in psuedocode? Thanks!!!!!

J

#### Joseph Ashwood

Looking back a few days, reading the thread "Finding 'd' for RSA, why bother
with Extended Euclidian GCD ?" will probably be all you need.
Joe

S

#### Sebastian Gottschalk

DarkProtoman said:
I can't translate that into C++?

Then you should freshen up your knowledge.
Could you make it a little clearer?

I guess he could, and I guess he won't. You should try doing your
homework on your own rather than asking for pre-chewed code pieces.

P

#### Pubkeybreaker

DarkProtoman said:
How would I write a function to calculate RSA Decryption key. I'm
trying to write an RSA encryption program, and I'm stuck on calculating
the decryption key. How do you check for coprimality? Thanks!!!!! I'm
using C++.

Anyone who wants to implement algorithms should have a copy of
Knuth, TAOCP. The answer to your question can be found in volume 2.

The meaning of your question about co-primality isn't clear.
Co-primality
of what? The primes are always generated so that (p-1, e) = (q-1, e)
= 1.

T

#### Tom St Denis

DarkProtoman said:
I can't translate that into C++? Could you make it a little clearer?

Just use a crypto library.

Mon dieu, c'est pour cette raison les projets existes!

I mean... um...

Seriously, if you can't sort out the math on your own you shouldn't be
implementing the math in something you plan on using beyond your own
lab.

That said, there are books on bignum math [hint hint] that cover the
requisit algorithms...

Tom

D

#### DarkProtoman

Sebastian said:

Why?!! I'm trying to cast a wider net. Anything wrong with looking in
more than one place?!

## Ask a Question

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

### Members online

No members online now.