Class ManagedChaCha20Poly1305
Inheritance
System.Object
ManagedChaCha20Poly1305
Assembly: Cloud-ShareSync.Core.Cryptography.dll
Syntax
public class ManagedChaCha20Poly1305 : object
Constructors
|
Improve this Doc
View Source
ManagedChaCha20Poly1305()
Declaration
public ManagedChaCha20Poly1305()
|
Improve this Doc
View Source
ManagedChaCha20Poly1305(Nullable<ILogger>)
Declaration
public ManagedChaCha20Poly1305(ILogger? log = null)
Parameters
Type |
Name |
Description |
System.Nullable<ILogger> |
log |
|
Fields
|
Improve this Doc
View Source
_log
Declaration
Field Value
Type |
Description |
System.Nullable<ILogger> |
|
|
Improve this Doc
View Source
_source
Declaration
readonly ActivitySource _source
Field Value
Type |
Description |
ActivitySource |
|
|
Improve this Doc
View Source
MaxValue
The number of bytes to process before changing nonces.
Declaration
public const int MaxValue = null
Field Value
Type |
Description |
System.Int32 |
|
Properties
|
Improve this Doc
View Source
Describes ChaCha20Poly1305 platform support status.
See:
Declaration
public static bool PlatformSupported { get; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
|
Improve this Doc
View Source
AppendFileChunk(FileInfo, Byte[], Int32)
Common method to append data
to the end of the outputFile
.
order
== 0 sets otherwise sets .
Declaration
async Task AppendFileChunk(FileInfo outputFile, byte[] data, int order)
Parameters
Type |
Name |
Description |
FileInfo |
outputFile |
|
System.Byte[] |
data |
|
System.Int32 |
order |
|
Returns
|
Improve this Doc
View Source
Decrypt(ManagedChaCha20Poly1305DecryptionData, FileInfo, FileInfo)
Uses initialized with decryptionData
.Key to
decrypt cypherTxtFile
into plaintextFile
.
Declaration
public async Task Decrypt(ManagedChaCha20Poly1305DecryptionData decryptionData, FileInfo cypherTxtFile, FileInfo plaintextFile)
Parameters
Returns
|
Improve this Doc
View Source
DecryptFileChunk(ChaCha20Poly1305, Byte[], Byte[], Byte[], FileInfo, FileInfo, Int64, Int32)
Declaration
async Task DecryptFileChunk(ChaCha20Poly1305 chaPoly, byte[] nonce, byte[] tag, byte[] cypherTxt, FileInfo cypherTxtFile, FileInfo plaintextFile, long offset, int order)
Parameters
Type |
Name |
Description |
ChaCha20Poly1305 |
chaPoly |
|
System.Byte[] |
nonce |
|
System.Byte[] |
tag |
|
System.Byte[] |
cypherTxt |
|
FileInfo |
cypherTxtFile |
|
FileInfo |
plaintextFile |
|
System.Int64 |
offset |
|
System.Int32 |
order |
|
Returns
|
Improve this Doc
View Source
DecryptFileChunkLoop(FileInfo, FileInfo, ChaCha20Poly1305, List<ManagedChaCha20Poly1305DecryptionKeyNote>, Int64, Int32)
Declaration
async Task DecryptFileChunkLoop(FileInfo plaintextFile, FileInfo cypherTxtFile, ChaCha20Poly1305 chaPoly, List<ManagedChaCha20Poly1305DecryptionKeyNote> keyNoteList, long processedBytes = null, int chunkCount = 0)
Parameters
Type |
Name |
Description |
FileInfo |
plaintextFile |
|
FileInfo |
cypherTxtFile |
|
ChaCha20Poly1305 |
chaPoly |
|
List<ManagedChaCha20Poly1305DecryptionKeyNote> |
keyNoteList |
|
System.Int64 |
processedBytes |
|
System.Int32 |
chunkCount |
|
Returns
|
Improve this Doc
View Source
DecryptFromKeyFile(FileInfo, FileInfo, FileInfo)
Declaration
public async Task DecryptFromKeyFile(FileInfo keyFile, FileInfo cypherTxtFile, FileInfo plaintextFile)
Parameters
Type |
Name |
Description |
FileInfo |
keyFile |
|
FileInfo |
cypherTxtFile |
|
FileInfo |
plaintextFile |
|
Returns
|
Improve this Doc
View Source
Encrypt(Byte[], FileInfo, FileInfo, Nullable<FileInfo>)
Declaration
public async Task<ManagedChaCha20Poly1305DecryptionData> Encrypt(byte[] key, FileInfo plaintextFile, FileInfo cypherTxtFile, FileInfo? keyFile = null)
Parameters
Type |
Name |
Description |
System.Byte[] |
key |
|
FileInfo |
plaintextFile |
|
FileInfo |
cypherTxtFile |
|
System.Nullable<FileInfo> |
keyFile |
|
Returns
|
Improve this Doc
View Source
EncryptFile(Byte[], FileInfo, FileInfo)
Uses initialized with key
to
encrypt plaintextFile
into cypherTxtFile
.
DecryptionData is returned.
Declaration
async Task<ManagedChaCha20Poly1305DecryptionData> EncryptFile(byte[] key, FileInfo plaintextFile, FileInfo cypherTxtFile)
Parameters
Type |
Name |
Description |
System.Byte[] |
key |
|
FileInfo |
plaintextFile |
|
FileInfo |
cypherTxtFile |
|
Returns
|
Improve this Doc
View Source
EncryptFileChunk(ChaCha20Poly1305, Byte[], Byte[], FileInfo, FileInfo, Int32, Int64)
Uses chaPoly
to read a plaintext
.Length section of
plaintextFile
from the offset
and encrypt it into
cypherTxtFile
.
Declaration
async Task<ManagedChaCha20Poly1305DecryptionKeyNote> EncryptFileChunk(ChaCha20Poly1305 chaPoly, byte[] nonce, byte[] plaintext, FileInfo plaintextFile, FileInfo cypherTxtFile, int order, long offset)
Parameters
Type |
Name |
Description |
ChaCha20Poly1305 |
chaPoly |
|
System.Byte[] |
nonce |
|
System.Byte[] |
plaintext |
|
FileInfo |
plaintextFile |
|
FileInfo |
cypherTxtFile |
|
System.Int32 |
order |
|
System.Int64 |
offset |
|
Returns
|
Improve this Doc
View Source
EncryptFileChunkLoop(FileInfo, FileInfo, ChaCha20Poly1305, List<Byte[]>, List<ManagedChaCha20Poly1305DecryptionKeyNote>, Int64, Int32)
Declaration
async Task EncryptFileChunkLoop(FileInfo plaintextFile, FileInfo cypherTxtFile, ChaCha20Poly1305 chaPoly, List<byte[]> uniqueNonces, List<ManagedChaCha20Poly1305DecryptionKeyNote> keyNoteList, long processedBytes = null, int chunkCount = 0)
Parameters
Type |
Name |
Description |
FileInfo |
plaintextFile |
|
FileInfo |
cypherTxtFile |
|
ChaCha20Poly1305 |
chaPoly |
|
List<System.Byte[]> |
uniqueNonces |
|
List<ManagedChaCha20Poly1305DecryptionKeyNote> |
keyNoteList |
|
System.Int64 |
processedBytes |
|
System.Int32 |
chunkCount |
|
Returns
|
Improve this Doc
View Source
EnsureFileExistsAndHasData(FileInfo)
Declaration
static void EnsureFileExistsAndHasData(FileInfo file)
Parameters
Type |
Name |
Description |
FileInfo |
file |
|
|
Improve this Doc
View Source
GetByteArray(Int32, Int32, Int64, Int64)
Declaration
static byte[] GetByteArray(int chunkCount, int nonceCount, long processedBytes, long plaintextFileLength)
Parameters
Type |
Name |
Description |
System.Int32 |
chunkCount |
|
System.Int32 |
nonceCount |
|
System.Int64 |
processedBytes |
|
System.Int64 |
plaintextFileLength |
|
Returns
Type |
Description |
System.Byte[] |
|
|
Improve this Doc
View Source
GetNonce()
Gets an array filled with 12 random bytes.
Declaration
Returns
Type |
Description |
System.Byte[] |
|
|
Improve this Doc
View Source
GetNonces(Int64)
Gets one random 12 byte array (nonce) per (MaxValue) bytes of file to encrypt.
Declaration
List<byte[]> GetNonces(long dataLength)
Parameters
Type |
Name |
Description |
System.Int64 |
dataLength |
|
Returns
Type |
Description |
List<System.Byte[]> |
|
|
Improve this Doc
View Source
GetUniqueNonce(List<Byte[]>)
Declaration
static void GetUniqueNonce(List<byte[]> nonces)
Parameters
Type |
Name |
Description |
List<System.Byte[]> |
nonces |
|
|
Improve this Doc
View Source
ReadFileChunkFromOffset(FileInfo, Byte[], Int64)
Reads and returns data
.Length bytes from inputFile
after
the offset
Declaration
async Task<byte[]> ReadFileChunkFromOffset(FileInfo inputFile, byte[] data, long offset)
Parameters
Type |
Name |
Description |
FileInfo |
inputFile |
|
System.Byte[] |
data |
|
System.Int64 |
offset |
|
Returns
Type |
Description |
Task<System.Byte[]> |
|
|
Improve this Doc
View Source
WriteDecryptionDataToKeyFile(Nullable<FileInfo>, ManagedChaCha20Poly1305DecryptionData)
Declaration
async Task WriteDecryptionDataToKeyFile(FileInfo? keyFile, ManagedChaCha20Poly1305DecryptionData decryptionData)
Parameters
Returns
|
Improve this Doc
View Source
WriteEncryptLogMessages(Boolean, FileInfo, FileInfo, Nullable<FileInfo>)
Declaration
void WriteEncryptLogMessages(bool message1, FileInfo plaintextFile, FileInfo cypherTxtFile, FileInfo? keyFile)
Parameters
Type |
Name |
Description |
System.Boolean |
message1 |
|
FileInfo |
plaintextFile |
|
FileInfo |
cypherTxtFile |
|
System.Nullable<FileInfo> |
keyFile |
|