-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathXtsAes256.cs
32 lines (27 loc) · 847 Bytes
/
XtsAes256.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
using System;
using System.Security.Cryptography;
namespace XTSSharp;
public class XtsAes256 : Xts
{
private const int KEY_LENGTH = 256;
private const int KEY_BYTE_LENGTH = 32;
protected XtsAes256(Func<SymmetricAlgorithm> create, byte[] key1, byte[] key2)
: base(create, VerifyKey(256, key1), VerifyKey(256, key2))
{
}
public static Xts Create(byte[] key1, byte[] key2)
{
VerifyKey(256, key1);
VerifyKey(256, key2);
return new XtsAes256(Aes.Create, key1, key2);
}
public static Xts Create(byte[] key)
{
VerifyKey(512, key);
byte[] array = new byte[32];
byte[] array2 = new byte[32];
Buffer.BlockCopy(key, 0, array, 0, 32);
Buffer.BlockCopy(key, 32, array2, 0, 32);
return new XtsAes256(Aes.Create, array, array2);
}
}