0

I'm using AES on WP8 (Windows Phone 8) in C# on Visual Studio, and System.Security.Cryptography does not contain the attribute 'Mode' for AESManaged.

I've looked up this problem for the past 3 days now, and haven't found any reference or anything to import.

The code I am currently using is:

            AesManaged cipher = new AesManaged();
            cipher.BlockSize = 8;
            /*cipher.Mode = CipherMode.CFB;
            cipher.Padding = PaddingMode.None;*/
            //cipher.KeySize = 128;
            //cipher.FeedbackSize = 8;  
            cipher.Key = key;
            cipher.IV = key;
            return cipher;

While the BlockSize throws an exception 'Specified block size is not valid for this algorithm.'

I was originally using RijndaelManaged but that isn't available on WP8 but according to this it should be available.

Destiny Faith
  • 257
  • 6
  • 21

1 Answers1

0

Silverlight verison of AES have no mode property. Here is MSDN article about that.

"The AES algorithm is essentially the Rijndael symmetric algorithm with a fixed block size and iteration count. This class functions the same way as the .NET Framework RijndaelManaged class but limits blocks to 128 bits and does not allow feedback modes. The cipher mode is always CBC, and the padding mode is always PKCS7."

You can extract AES from BounceCastle library if you need more modes and flexibility. I did that before.

crea7or
  • 4,421
  • 2
  • 26
  • 37
  • Hi, @crea7or this isn't supported for WP8 – Destiny Faith Apr 08 '14 at 00:05
  • ***UPDATE*** I had added the reference BUT when I go to do `using WP8BouncyCastle;` it says that the reference does not exist. – Destiny Faith Apr 08 '14 at 00:19
  • Don't know where the problem in your case. However, maybe [Crypto++ library](http://developer.nokia.com/blogs/community/using-crypto-library-with-windows-phone-8-featured-article-windows-phone) will work better in your project? – crea7or Apr 08 '14 at 13:42
  • I'll try that; but it's not really building correctly. A lot of errors coming up. – Destiny Faith Apr 08 '14 at 14:55
  • Is there a C# way to make WP8 apps without Silverlight? – Destiny Faith Apr 08 '14 at 14:55
  • c# ways is: 1) AesManaged 2) BounceCastle 3) [Windows Phone RT Api](http://msdn.microsoft.com/en-US/library/windows/apps/windows.security.cryptography.core.symmetricalgorithmnames.aspx) (available in 8.1). Why not to exctract AES code from bounce castle? Here is the code of AES in BC library "\bccrypto-net-1.7-src\csharp\crypto\src\crypto\engines", additionally you'll need a few more files to support AES modes and Paddings. It's not hard at all. – crea7or Apr 08 '14 at 19:21