Exemplo n.º 1
0
 /// <summary>Gets a value that indicates whether the specified algorithm uses symmetric keys.</summary>
 /// <param name="algorithm">The cryptographic algorithm.</param>
 /// <returns>
 /// <see langword="true" /> when the specified algorithm uses symmetric keys; otherwise, <see langword="false" />.</returns>
 public override bool IsSymmetricAlgorithm(string algorithm)
 {
     return(CryptoHelper.IsSymmetricAlgorithm(algorithm));
 }
Exemplo n.º 2
0
 /// <summary>Encrypts the specified key.</summary>
 /// <param name="algorithm">The cryptographic algorithm to encrypt the key with.</param>
 /// <param name="keyData">An array of <see cref="T:System.Byte" /> that contains the key.</param>
 /// <returns>An array of <see cref="T:System.Byte" /> that contains the encrypted key.</returns>
 /// <exception cref="T:System.InvalidOperationException">
 /// <paramref name="algorithm" /> is not supported. The supported algorithms are <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.TripleDesKeyWrap" />, <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes128KeyWrap" />, <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes192KeyWrap" />, or <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes256KeyWrap" />.</exception>
 public override byte[] EncryptKey(string algorithm, byte[] keyData)
 {
     return(CryptoHelper.WrapKey(this.symmetricKey, keyData, algorithm));
 }
Exemplo n.º 3
0
 /// <summary>Gets a value that indicates whether the specified algorithm is supported by this class. </summary>
 /// <param name="algorithm">The cryptographic algorithm.</param>
 /// <returns>
 /// <see langword="true" /> when the specified algorithm is supported by this class; otherwise, <see langword="false" />.</returns>
 public override bool IsSupportedAlgorithm(string algorithm)
 {
     return(CryptoHelper.IsSymmetricSupportedAlgorithm(algorithm, this.KeySize));
 }
Exemplo n.º 4
0
 /// <summary>Gets an instance of the specified symmetric algorithm.</summary>
 /// <param name="algorithm">The symmetric algorithm to get an instance of.</param>
 /// <returns>A <see cref="T:System.Security.Cryptography.SymmetricAlgorithm" /> that represents the symmetric algorithm.</returns>
 /// <exception cref="T:System.InvalidOperationException">
 /// <paramref name="algorithm" /> is not supported. The supported algorithms are <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.TripleDesEncryption" />, <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes128Encryption" />, <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes192Encryption" />,  <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes256Encryption" />, <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.TripleDesKeyWrap" />, <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes128KeyWrap" />, <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes192KeyWrap" />, and <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes256KeyWrap" /></exception>
 public override SymmetricAlgorithm GetSymmetricAlgorithm(string algorithm)
 {
     return(CryptoHelper.GetSymmetricAlgorithm(this.symmetricKey, algorithm));
 }
Exemplo n.º 5
0
 /// <summary>Gets an instance of the specified keyed hash algorithm.</summary>
 /// <param name="algorithm">The keyed hash algorithm to get an instance of.</param>
 /// <returns>A <see cref="T:System.Security.Cryptography.KeyedHashAlgorithm" /> that represents the keyed hash algorithm.</returns>
 /// <exception cref="T:System.InvalidOperationException">
 /// <paramref name="algorithm" /> is not supported. The supported algorithms is <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.HmacSha1Signature" />.</exception>
 public override KeyedHashAlgorithm GetKeyedHashAlgorithm(string algorithm)
 {
     return(CryptoHelper.CreateKeyedHashAlgorithm(this.symmetricKey, algorithm));
 }
Exemplo n.º 6
0
 /// <summary>Gets the size, in bits, of the initialization vector (<see langword="IV" />) that is required for the specified cryptographic algorithm.</summary>
 /// <param name="algorithm">The cryptographic algorithm to get the size of the initialization vector (<see langword="IV" />).</param>
 /// <returns>The size, in bits, of the initialization vector (<see langword="IV" />) that is required for the cryptographic algorithm specified in the <paramref name="algorithm" /> parameter.</returns>
 /// <exception cref="T:System.InvalidOperationException">
 /// <paramref name="algorithm" /> is not supported. The supported algorithms are <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.TripleDesEncryption" />, <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes128Encryption" />, <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes192Encryption" />, and <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes256Encryption" />.</exception>
 public override int GetIVSize(string algorithm)
 {
     return(CryptoHelper.GetIVSize(algorithm));
 }
Exemplo n.º 7
0
 /// <summary>Gets a transform that encrypts XML using the specified cryptographic algorithm.</summary>
 /// <param name="algorithm">A cryptographic algorithm that encrypts XML.</param>
 /// <param name="iv">An array of <see cref="T:System.Byte" /> that contains the initialization vector (<see langword="IV" />) for the specified algorithm.</param>
 /// <returns>An <see cref="T:System.Security.Cryptography.ICryptoTransform" /> that represents the encryption transform.</returns>
 /// <exception cref="T:System.InvalidOperationException">
 /// <paramref name="algorithm" /> is not supported. The supported algorithms are <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.TripleDesEncryption" />, <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes128Encryption" />, <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes192Encryption" />, and <see cref="F:System.IdentityModel.Tokens.SecurityAlgorithms.Aes256Encryption" />.</exception>
 public override ICryptoTransform GetEncryptionTransform(
     string algorithm,
     byte[] iv)
 {
     return(CryptoHelper.CreateEncryptor(this.symmetricKey, iv, algorithm));
 }