Solved

Symmetric Cryptography

Posted on 2003-11-28
7
988 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now