Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Symmetric Cryptography

Posted on 2003-11-28
7
Medium Priority
?
997 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

650 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