Solved

Symmetric Cryptography

Posted on 2003-11-28
7
992 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
  • 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 500 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RegEx with optional part 4 52
jquery + C#.net radiobuttonlist 3 45
Stop Git from being my repository 1 15
Web page design problem 3 12
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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!

713 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