> From: Andrew Arnott [mailto:andrewarn...@gmail.com]
> 
> I want to programmatically enumerate the allowed key sizes for a given
> Cipher. Is there an API to do this?

If it's a .NET cipher, you can use the LegalKeySizes property
https://msdn.microsoft.com/en-us/library/system.security.cryptography.symmetricalgorithm.legalkeysizes(v=vs.110).aspx

If it's a BouncyCastle derivative of IBlockCipher, there is no such analogous 
property of IBlockCipher. In fact, by looking at AESFastEngine, the only time 
the key size seems to be checked is during GenerateWorkingKey(), which is 
called by Init(). There, it's hard-coded in a private method, to check the Key 
length, must be 128, 192, or 256. Based on this, I'd say there is no 
programmatic way, nor even an enum you could use.

Reply via email to