-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
EncryptionAlgorithm.cs
75 lines (67 loc) · 3.04 KB
/
EncryptionAlgorithm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
//
using System.Security.Cryptography;
namespace Microsoft.Azure.KeyVault.Cryptography
{
/// <summary>
/// Abstract Encryption Algorithm
/// </summary>
public abstract class EncryptionAlgorithm : Algorithm
{
protected EncryptionAlgorithm( string name ) : base( name )
{
}
}
/// <summary>
/// Abstract Asymmetric Encryption Algorithm
/// </summary>
public abstract class AsymmetricEncryptionAlgorithm : EncryptionAlgorithm
{
protected AsymmetricEncryptionAlgorithm( string name )
: base( name )
{
}
/// <summary>
/// Create an encryptor for the specified key
/// </summary>
/// <param name="key">The key used to create the encryptor</param>
/// <returns>An ICryptoTransform for encrypting data</returns>
public abstract ICryptoTransform CreateEncryptor( AsymmetricAlgorithm key );
/// <summary>
/// Create a decryptor for the specified key
/// </summary>
/// <param name="key">The key used to create decryptor</param>
/// <returns>An ICryptoTransform for encrypting data</returns>
public abstract ICryptoTransform CreateDecryptor( AsymmetricAlgorithm key );
}
/// <summary>
/// Abstract SymmetricEncryption Algorithm
/// </summary>
public abstract class SymmetricEncryptionAlgorithm : EncryptionAlgorithm
{
protected SymmetricEncryptionAlgorithm( string name )
: base( name )
{
}
/// <summary>
/// Create an encryptor for the specified key
/// </summary>
/// <param name="key">The key material to be used</param>
/// <param name="iv">The initialization vector to be used</param>
/// <param name="authenticationData">The authentication data to be used with authenticating encryption algorithms (ignored for non-authenticating algorithms)</param>
/// <returns>An ICryptoTranform for encrypting data</returns>
public abstract ICryptoTransform CreateEncryptor( byte[] key, byte[] iv, byte[] authenticationData );
/// <summary>
/// Create a decryptor for the specified key
/// </summary>
/// <param name="key">The key material to be used</param>
/// <param name="iv">The initialization vector to be used</param>
/// <param name="authenticationData">The authentication data to be used with authenticating encryption algorithms (ignored for non-authenticating algorithms)</param>
/// <param name="authenticationTag">The authentication tag to verify when using authenticating encryption algorithms (ignored for non-authenticating algorithms)</param>
/// <returns>An ICryptoTransform for decrypting data</returns>
public abstract ICryptoTransform CreateDecryptor( byte[] key, byte[] iv, byte[] authenticationData, byte[] authenticationTag );
}
}