Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Security / December 2007

Tip: Looking for answers? Try searching our database.

What is exponent?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
olduncleamos - 25 Dec 2007 03:38 GMT
Hi all,

I have been reading up on security and cryptography lately. I *think*
I understand the different terms and concepts pretty well (gone
through the .Net Security and Cryptography by Peter Thorsteinson so
many times it is breaking apart). But I think I have some serious
difficulty trying to translate what I understand into code in .Net.

As an exercise, I am trying to use RSA to asymmetrically encrypt a
piece of plain text. But for the life of me I can't find the proper
syntax to do it. Or should I say there seem to be so many syntax I
don't know which to use. For example, the easiest one the I can do is:

           RSACryptoServiceProvider rsa = receiverCert.PublicKey.Key
as RSACryptoServiceProvider;
           byte[] cipheredKey = rsa.Encrypt(sessionKey, true);

Given that I have a certificate to use that seems to be the right
approach.

But when I flip through MSDN, they are using the RSAParameters to
store the key. From the code sample I can see the
RSAParameters.Modulus stores the public key. But it also seems to
require a RSAParameters.Exponent value.

What is this exponent value? I can't find any mention of this in any
of the materials that I can find on or off line.

Can somebody help explain this?

Much appreciated.
Valery Pryamikov - 25 Dec 2007 13:30 GMT
> Can somebody help explain this?

RSA algorithm involves modulus, which is  a product of two primes of
the same order that are usually called P and Q. Two exponents, one
private and one public that are usually called d and e and related to
each other by being multiplicative inverse to each other mod
(P-1)*(Q-1).

For simple description of RSA algorithm check http://en.wikipedia.org/wiki/RSA

From asymmetric algorithms RSA is one of the simpliest. Other
asymmetric algorithm use different components/parameters of public and
private key. You can find simple description of many algorithms on
wikipedia.

-Valery.
olduncleamos - 25 Dec 2007 20:49 GMT
On Dec 25, 8:30 am, Valery Pryamikov <valery.pryami...@q-free.com>
wrote:

> > Can somebody help explain this?
>
[quoted text clipped - 12 lines]
>
> -Valery.

Thank you for the wikipedia article. It certainly helped me understand
the concept better.

However, I am more interested in the practical coding in .Net terms.
Specifically there are two routines that I am trying to code:

Given that I represent the sender, thus in possession of the sender's
certificate. I also have the receiver's certificate (public key only).
I need the routines to:
1) Use RSA to encrypt the session key (using receiver's public key)
and
2) Use SHA1 to calculate the cipher text's hash value and then use RSA
to encrypt the message digest (using my private key).

I assume this is the most common scenario that eveybody does. I am
just unsure the function call and libraries that I need to use. I
would love to see some code sample that does exactly the above.

Thanks again for your help.
Joe Kaplan - 27 Dec 2007 05:20 GMT
Did you look at the classes for SignedData and EnvelopedData in the Pkcs
namespace?  I'd suggest using those for doing encryption and signing of
messages as they take care of all of the housekeeping details for handling
the symmetric keys and hashing while using the PKCS#7 standard for building
the messages so that you'll have interoperability with other systems that
can read PKCS#7 messages (SMIME, etc.).

It is totally possible to build up your own system for doing this stuff, but
it is not that easy and only your code will be able to read it.  It is also
pretty difficult building your own PKCS#7 messages from scratch, especially
without a low level managed code ASN.1 library to lean on (which the .NET
framework does not have built in, although there are add-ons you can get
that do).

There are good Wikipedia references on all the PKCS stuff if you want to
read up on that more.  :)

Joe K.

Signature

Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--

On Dec 25, 8:30 am, Valery Pryamikov <valery.pryami...@q-free.com>
wrote:
> On Dec 25, 4:38 am, olduncleamos <oldunclea...@yahoo.com> wrote:
>
[quoted text clipped - 15 lines]
>
> -Valery.

Thank you for the wikipedia article. It certainly helped me understand
the concept better.

However, I am more interested in the practical coding in .Net terms.
Specifically there are two routines that I am trying to code:

Given that I represent the sender, thus in possession of the sender's
certificate. I also have the receiver's certificate (public key only).
I need the routines to:
1) Use RSA to encrypt the session key (using receiver's public key)
and
2) Use SHA1 to calculate the cipher text's hash value and then use RSA
to encrypt the message digest (using my private key).

I assume this is the most common scenario that eveybody does. I am
just unsure the function call and libraries that I need to use. I
would love to see some code sample that does exactly the above.

Thanks again for your help.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.