?
Solved

Symmetric Cryptography

Posted on 2003-11-28
7
Medium Priority
?
996 Views
Last Modified: 2011-04-14
How can i change the min and max size of the keys for cryptografy in a SymmetricAlgorithm class?
I tried to modify the MinSize and MaxSize properties of the LegalKeySizes array but they are read only...
I instantiated a new class System.Security.Cryptography.KeySizes with my dimension in the constructor but i can't assign it to the cryptografy object...

Please help me..
0
Comment
Question by:DaniPro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 1

Expert Comment

by:AJMartin
ID: 9836090
> How can i change the min and max size of the keys for cryptografy in a SymmetricAlgorithm class?

You can't, according to the documentation:

SymmetricAlgorithm.KeySize Property
The valid key sizes are specified by the particular symmetric algorithm implementation and are listed in LegalKeySizes.

SymmetricAlgorithm.LegalKeySizes Property
Only key sizes that match an entry in this array are supported by the symmetric algorithm.

Of course, if you subclass your own Symmetric Algorithm class from System.Security.Cryptography.SymmetricAlgorithm just like System.Security.Cryptography.DES, System.Security.Cryptography.RC2, System.Security.Cryptography.Rijndael, & System.Security.Cryptography.TripleDES are, then you can do what you like.

Alternatively, you might need the highencryption pack, perhaps?

I hope that helps!
0
 
LVL 6

Author Comment

by:DaniPro
ID: 9836959
I instantiated a TripleDESCryptoServiceProvider class but i can't change the MinSize and MaxSize properties.
The "LegaleKeySizes" contains an array with the keys dimensions supported. How can i append a new item to this array?
0
 
LVL 1

Expert Comment

by:AJMartin
ID: 9839931
> How can i append a new item to this array?

You can't. The algorithm for TripleDES only supports the key sizes in LegalKeySizes.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 41

Expert Comment

by:graye
ID: 9863507
Are you perhaps thinking about the "block size" often used in cryptographic service providers for working on "sizeable chunks" of the cleartext/ciphertext?
0
 
LVL 6

Author Comment

by:DaniPro
ID: 9864997
Hi graye,

do you have any examples about "block size" or like that say about it?
0
 
LVL 41

Expert Comment

by:graye
ID: 9869462
Well, no examples, per se... but I've got a better explaination!

Consider the good-ole standard DES encryption.  It uses a varying key length 40, 56, 128 (in bits).  But the block size is 8 (characters)... and is always 8.  When DES applies it's crypo-magic, it does so in chunks of 8 characters at a time.  That's why the length of DES cipher text is always an even multiple of 8.  For example, if you encrypt the word "hello"... it always comes out 8 characters long (without regard to the key and initialization vector lengths).

You never really told us what you're trying to do... if you're trying to use one of the existing CSPs in your application, then the "maximum length" is the key (er, pardon the pun) to getting longer keys.

Remember, it hasn't been too long ago that the US Government wouldn't allow 128 bit key lengths in technology that was exported to other countries.  (Now the restriction is just to a few countries that sponsor terrorism).  

But, as you can imagine, the writers of the CSP would NOT allow you to change the maxium key lenghts on-the-fly.  They were hard-coded in to the encryption libraries for legal reasons.  Other CSP writers queried the OS to determine the maximum key length (back with IE5 came out...and with the "high encryption pack").  But then again, just because the OS says "I'll take 128 bits", doesn't mean that the CSP will honor that.

I suspect that you're trying to subclass an existing CSP class?  If so then that's simply not gonna work.  If on the other hand, you're writing your own... then have fun!
0
 
LVL 1

Accepted Solution

by:
pun1sher earned 1500 total points
ID: 9907858
use rijndael symetric encryption, I have used this extensivly, there are a few selection of key size on offer there...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question