Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Security.​Cryptography.​Aes

Assembly: System.Security.Cryptography

Inheritance: object → SymmetricAlgorithm → Aes

Represents the abstract base class from which all implementations of the Advanced Encryption Standard (AES) must inherit.

Fields and Constants

protected int
BlockSizeValue
Represents the block size, in bits, of the cryptographic operation.
protected int
FeedbackSizeValue
Represents the feedback size, in bits, of the cryptographic operation.
protected byte[]
IVValue
Represents the initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ) for the symmetric algorithm.
protected int
KeySizeValue
Represents the size, in bits, of the secret key used by the symmetric algorithm.
protected byte[]
KeyValue
Represents the secret key for the symmetric algorithm.
protected KeySizes[]
LegalBlockSizesValue
Specifies the block sizes, in bits, that are supported by the symmetric algorithm.
protected KeySizes[]
LegalKeySizesValue
Specifies the key sizes, in bits, that are supported by the symmetric algorithm.
protected CipherMode
ModeValue
Represents the cipher mode used in the symmetric algorithm.
protected PaddingMode
PaddingValue
Represents the padding mode used in the symmetric algorithm.

Properties

public int
BlockSize
Gets or sets the block size, in bits, of the cryptographic operation.
public int
FeedbackSize
Gets or sets the feedback size, in bits, of the cryptographic operation for the Cipher Feedback (CFB) and Output Feedback (OFB) cipher modes.
public byte[]
IV
Gets or sets the initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ) for the symmetric algorithm.
public byte[]
Key
Gets or sets the secret key for the symmetric algorithm.
public int
KeySize
Gets or sets the size, in bits, of the secret key used by the symmetric algorithm.
public KeySizes[]
LegalBlockSizes
Gets the block sizes, in bits, that are supported by the symmetric algorithm.
public KeySizes[]
LegalKeySizes
Gets the key sizes, in bits, that are supported by the symmetric algorithm.
public CipherMode
Mode
Gets or sets the mode for operation of the symmetric algorithm.
public PaddingMode
Padding
Gets or sets the padding mode used in the symmetric algorithm.

Methods

public byte[]
DecryptKeyWrapPadded​(byte[] ciphertext)
ciphertext The data to unwrap.
Returns The unwrapped key.
Unwraps a key that was wrapped using the IETF RFC 5649 AES Key Wrap with Padding algorithm.
public byte[]
DecryptKeyWrapPadded​(ReadOnlySpan`1 ciphertext)
public int
DecryptKeyWrapPadded​(ReadOnlySpan`1 ciphertext, Span`1 destination)
protected int
DecryptKeyWrapPaddedCore​(ReadOnlySpan`1 source, Span`1 destination)
public byte[]
EncryptKeyWrapPadded​(byte[] plaintext)
plaintext The data to wrap.
Returns The wrapped data.
Wraps a key using the IETF RFC 5649 AES Key Wrap with Padding algorithm.
public byte[]
EncryptKeyWrapPadded​(ReadOnlySpan`1 plaintext)
public void
EncryptKeyWrapPadded​(ReadOnlySpan`1 plaintext, Span`1 destination)
protected void
EncryptKeyWrapPaddedCore​(ReadOnlySpan`1 source, Span`1 destination)
public bool
TryDecryptKeyWrapPadded​(ReadOnlySpan`1 ciphertext, Span`1 destination, Int32& bytesWritten)
public void
Clear​()
Inherited from SymmetricAlgorithm
Releases all resources used by the <see cref="T:System.Security.Cryptography.SymmetricAlgorithm" /> class.
CreateDecryptor​()
Inherited from SymmetricAlgorithm
Returns A symmetric decryptor object.
Creates a symmetric decryptor object with the current <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key" /> property and initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ).
CreateDecryptor​(byte[] rgbKey, byte[] rgbIV)
Inherited from SymmetricAlgorithm
rgbKey The secret key to use for the symmetric algorithm.
rgbIV The initialization vector to use for the symmetric algorithm.
Returns A symmetric decryptor object.
When overridden in a derived class, creates a symmetric decryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key" /> property and initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ).
CreateEncryptor​()
Inherited from SymmetricAlgorithm
Returns A symmetric encryptor object.
Creates a symmetric encryptor object with the current <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key" /> property and initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ).
CreateEncryptor​(byte[] rgbKey, byte[] rgbIV)
Inherited from SymmetricAlgorithm
rgbKey The secret key to use for the symmetric algorithm.
rgbIV The initialization vector to use for the symmetric algorithm.
Returns A symmetric encryptor object.
When overridden in a derived class, creates a symmetric encryptor object with the specified <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key" /> property and initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ).
public byte[]
DecryptCbc​(byte[] ciphertext, byte[] iv, PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
ciphertext The data to decrypt.
iv The initialization vector.
paddingMode The padding mode used to produce the ciphertext and remove during decryption.
Returns The decrypted plaintext data.
Decrypts data using CBC mode with the specified padding mode.
public byte[]
DecryptCbc​(ReadOnlySpan`1 ciphertext, ReadOnlySpan`1 iv, PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
public int
DecryptCbc​(ReadOnlySpan`1 ciphertext, ReadOnlySpan`1 iv, Span`1 destination, PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
public byte[]
DecryptCfb​(byte[] ciphertext, byte[] iv, PaddingMode paddingMode = 1, int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
ciphertext The data to decrypt.
iv The initialization vector.
paddingMode The padding mode used to produce the ciphertext and remove during decryption.
feedbackSizeInBits The feedback size, specified in bits.
Returns The decrypted plaintext data.
Decrypts data using CFB mode with the specified padding mode and feedback size.
public byte[]
DecryptCfb​(ReadOnlySpan`1 ciphertext, ReadOnlySpan`1 iv, PaddingMode paddingMode = 1, int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
public int
DecryptCfb​(ReadOnlySpan`1 ciphertext, ReadOnlySpan`1 iv, Span`1 destination, PaddingMode paddingMode = 1, int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
public byte[]
DecryptEcb​(byte[] ciphertext, PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
ciphertext The data to decrypt.
paddingMode The padding mode used to produce the ciphertext and remove during decryption.
Returns The decrypted plaintext data.
Decrypts data using ECB mode with the specified padding mode.
public byte[]
DecryptEcb​(ReadOnlySpan`1 ciphertext, PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
public int
DecryptEcb​(ReadOnlySpan`1 ciphertext, Span`1 destination, PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
public void
Dispose​()
Inherited from SymmetricAlgorithm
Releases all resources used by the current instance of the <see cref="T:System.Security.Cryptography.SymmetricAlgorithm" /> class.
protected void
Dispose​(bool disposing)
Inherited from SymmetricAlgorithm
disposing <see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.
Releases the unmanaged resources used by the <see cref="T:System.Security.Cryptography.SymmetricAlgorithm" /> and optionally releases the managed resources.
public byte[]
EncryptCbc​(byte[] plaintext, byte[] iv, PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
plaintext The data to encrypt.
iv The initialization vector.
paddingMode The padding mode used to produce the ciphertext and remove during decryption.
Returns The encrypted ciphertext data.
Encrypts data using CBC mode with the specified padding mode.
public byte[]
EncryptCbc​(ReadOnlySpan`1 plaintext, ReadOnlySpan`1 iv, PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
public int
EncryptCbc​(ReadOnlySpan`1 plaintext, ReadOnlySpan`1 iv, Span`1 destination, PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
public byte[]
EncryptCfb​(byte[] plaintext, byte[] iv, PaddingMode paddingMode = 1, int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
plaintext The data to encrypt.
iv The initialization vector.
paddingMode The padding mode used to produce the ciphertext and remove during decryption.
feedbackSizeInBits The feedback size, specified in bits.
Returns The encrypted ciphertext data.
Encrypts data using CFB mode with the specified padding mode and feedback size.
public byte[]
EncryptCfb​(ReadOnlySpan`1 plaintext, ReadOnlySpan`1 iv, PaddingMode paddingMode = 1, int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
public int
EncryptCfb​(ReadOnlySpan`1 plaintext, ReadOnlySpan`1 iv, Span`1 destination, PaddingMode paddingMode = 1, int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
public byte[]
EncryptEcb​(byte[] plaintext, PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
plaintext The data to encrypt.
paddingMode The padding mode used to produce the ciphertext and remove during decryption.
Returns The encrypted ciphertext data.
Encrypts data using ECB mode with the specified padding mode.
public byte[]
EncryptEcb​(ReadOnlySpan`1 plaintext, PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
public int
EncryptEcb​(ReadOnlySpan`1 plaintext, Span`1 destination, PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
public void
GenerateIV​()
Inherited from SymmetricAlgorithm
When overridden in a derived class, generates a random initialization vector ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.IV" /> ) to use for the algorithm.
public void
GenerateKey​()
Inherited from SymmetricAlgorithm
When overridden in a derived class, generates a random key ( <see cref="P:System.Security.Cryptography.SymmetricAlgorithm.Key" /> ) to use for the algorithm.
public int
GetCiphertextLengthCbc​(int plaintextLength, PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
plaintextLength The plaintext length, in bytes.
paddingMode The padding mode used to pad the plaintext to the algorithm's block size.
Returns The length, in bytes, of the ciphertext with padding.
Gets the length of a ciphertext with a given padding mode and plaintext length in CBC mode.
public int
GetCiphertextLengthCfb​(int plaintextLength, PaddingMode paddingMode = 1, int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
plaintextLength The plaintext length, in bytes.
paddingMode The padding mode used to pad the plaintext to the feedback size.
feedbackSizeInBits The feedback size, in bits.
Returns The length, in bytes, of the ciphertext with padding.
Gets the length of a ciphertext with a given padding mode and plaintext length in CFB mode.
public int
GetCiphertextLengthEcb​(int plaintextLength, PaddingMode paddingMode)
Inherited from SymmetricAlgorithm
plaintextLength The plaintext length, in bytes.
paddingMode The padding mode used to pad the plaintext to the algorithm's block size.
Returns The length, in bytes, of the ciphertext with padding.
Gets the length of a ciphertext with a given padding mode and plaintext length in ECB mode.
public void
SetKey​(ReadOnlySpan`1 key)
Inherited from SymmetricAlgorithm
protected void
SetKeyCore​(ReadOnlySpan`1 key)
Inherited from SymmetricAlgorithm
public bool
TryDecryptCbc​(ReadOnlySpan`1 ciphertext, ReadOnlySpan`1 iv, Span`1 destination, Int32& bytesWritten, PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
protected bool
TryDecryptCbcCore​(ReadOnlySpan`1 ciphertext, ReadOnlySpan`1 iv, Span`1 destination, PaddingMode paddingMode, Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public bool
TryDecryptCfb​(ReadOnlySpan`1 ciphertext, ReadOnlySpan`1 iv, Span`1 destination, Int32& bytesWritten, PaddingMode paddingMode = 1, int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
protected bool
TryDecryptCfbCore​(ReadOnlySpan`1 ciphertext, ReadOnlySpan`1 iv, Span`1 destination, PaddingMode paddingMode, int feedbackSizeInBits, Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public bool
TryDecryptEcb​(ReadOnlySpan`1 ciphertext, Span`1 destination, PaddingMode paddingMode, Int32& bytesWritten)
Inherited from SymmetricAlgorithm
protected bool
TryDecryptEcbCore​(ReadOnlySpan`1 ciphertext, Span`1 destination, PaddingMode paddingMode, Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public bool
TryEncryptCbc​(ReadOnlySpan`1 plaintext, ReadOnlySpan`1 iv, Span`1 destination, Int32& bytesWritten, PaddingMode paddingMode = 2)
Inherited from SymmetricAlgorithm
protected bool
TryEncryptCbcCore​(ReadOnlySpan`1 plaintext, ReadOnlySpan`1 iv, Span`1 destination, PaddingMode paddingMode, Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public bool
TryEncryptCfb​(ReadOnlySpan`1 plaintext, ReadOnlySpan`1 iv, Span`1 destination, Int32& bytesWritten, PaddingMode paddingMode = 1, int feedbackSizeInBits = 8)
Inherited from SymmetricAlgorithm
protected bool
TryEncryptCfbCore​(ReadOnlySpan`1 plaintext, ReadOnlySpan`1 iv, Span`1 destination, PaddingMode paddingMode, int feedbackSizeInBits, Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public bool
TryEncryptEcb​(ReadOnlySpan`1 plaintext, Span`1 destination, PaddingMode paddingMode, Int32& bytesWritten)
Inherited from SymmetricAlgorithm
protected bool
TryEncryptEcbCore​(ReadOnlySpan`1 plaintext, Span`1 destination, PaddingMode paddingMode, Int32& bytesWritten)
Inherited from SymmetricAlgorithm
public bool
ValidKeySize​(int bitLength)
Inherited from SymmetricAlgorithm
bitLength The length, in bits, to check for a valid key size.
Returns <see langword="true" /> if the specified key size is valid for the current algorithm; otherwise, <see langword="false" /> .
Determines whether the specified key size is valid for the current algorithm.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object