2 // System.Security.Cryptography.AesManaged.cs
5 // Mark Crichton (crichton@gimp.org)
6 // Andrew Birkett (andy@nobugs.org)
7 // Sebastien Pouliot (sebastien@xamarin.com)
8 // Kazuki Oikawa (kazuki@panicode.com)
11 // Portions (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
12 // Copyright (C) 2004-2005,2008 Novell, Inc (http://www.novell.com)
13 // Copyright 2013 Xamarin Inc (http://www.xamarin.com)
15 // Permission is hereby granted, free of charge, to any person obtaining
16 // a copy of this software and associated documentation files (the
17 // "Software"), to deal in the Software without restriction, including
18 // without limitation the rights to use, copy, modify, merge, publish,
19 // distribute, sublicense, and/or sell copies of the Software, and to
20 // permit persons to whom the Software is furnished to do so, subject to
21 // the following conditions:
23 // The above copyright notice and this permission notice shall be
24 // included in all copies or substantial portions of the Software.
26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
30 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
31 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 using System.Security.Permissions;
37 using Mono.Security.Cryptography;
39 namespace System.Security.Cryptography {
42 // a. FIPS PUB 197: Advanced Encryption Standard
43 // http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf
44 // b. Aes Specification
45 // http://csrc.nist.gov/CryptoToolkit/aes/Aes/Aes-ammended.pdf
47 [HostProtection (SecurityAction.LinkDemand, MayLeakOnAbort=true)]
48 public sealed class AesManaged : Aes {
54 public override void GenerateIV ()
56 IVValue = KeyBuilder.IV (BlockSizeValue >> 3);
59 public override void GenerateKey ()
61 KeyValue = KeyBuilder.Key (KeySizeValue >> 3);
64 public override ICryptoTransform CreateDecryptor (byte[] key, byte[] iv)
66 return new AesTransform (this, false, key, iv);
69 public override ICryptoTransform CreateEncryptor (byte[] key, byte[] iv)
71 return new AesTransform (this, true, key, iv);
74 // I suppose some attributes differs ?!? because this does not look required
76 public override byte[] IV {
77 get { return base.IV; }
78 set { base.IV = value; }
81 public override byte[] Key {
82 get { return base.Key; }
83 set { base.Key = value; }
86 public override int KeySize {
87 get { return base.KeySize; }
88 set { base.KeySize = value; }
91 public override int FeedbackSize {
92 get { return base.FeedbackSize; }
93 set { base.FeedbackSize = value; }
96 public override CipherMode Mode {
97 get { return base.Mode; }
105 throw new CryptographicException ("CipherMode is not supported");
110 public override PaddingMode Padding {
111 get { return base.Padding; }
112 set { base.Padding = value; }
115 public override ICryptoTransform CreateDecryptor ()
117 return CreateDecryptor (Key, IV);
120 public override ICryptoTransform CreateEncryptor()
122 return CreateEncryptor (Key, IV);
125 protected override void Dispose (bool disposing)
127 base.Dispose (disposing);