Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add old pgp format support #261

Merged
merged 2 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions PgpCore/Abstractions/IPGP.EncryptAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ namespace PgpCore.Abstractions
{
public interface IEncryptAsync : IDisposable
{
Task EncryptAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task EncryptAsync(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task<string> EncryptAsync(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task EncryptAndSignAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task EncryptAndSignAsync(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task<string> EncryptAndSignAsync(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task EncryptAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task EncryptAsync(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task<string> EncryptAsync(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task EncryptAndSignAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task EncryptAndSignAsync(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task<string> EncryptAndSignAsync(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);

Task EncryptFileAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task EncryptStreamAsync(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task<string> EncryptArmoredStringAsync(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task EncryptFileAndSignAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task EncryptStreamAndSignAsync(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task<string> EncryptArmoredStringAndSignAsync(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
Task EncryptFileAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task EncryptStreamAsync(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task<string> EncryptArmoredStringAsync(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task EncryptFileAndSignAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task EncryptStreamAndSignAsync(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task<string> EncryptArmoredStringAndSignAsync(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
}
}
24 changes: 12 additions & 12 deletions PgpCore/Abstractions/IPGP.EncryptSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ namespace PgpCore.Abstractions
{
public interface IEncryptSync : IDisposable
{
void Encrypt(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
void Encrypt(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
string Encrypt(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
void EncryptAndSign(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
void EncryptAndSign(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
string EncryptAndSign(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
void Encrypt(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
void Encrypt(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
string Encrypt(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
void EncryptAndSign(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
void EncryptAndSign(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
string EncryptAndSign(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);

void EncryptFile(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
void EncryptStream(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
string EncryptArmoredString(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
void EncryptFileAndSign(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
void EncryptStreamAndSign(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
string EncryptArmoredStringAndSign(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null);
void EncryptFile(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
void EncryptStream(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
string EncryptArmoredString(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
void EncryptFileAndSign(FileInfo inputFile, FileInfo outputFile, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
void EncryptStreamAndSign(Stream inputStream, Stream outputStream, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
string EncryptArmoredStringAndSign(string input, bool armor = true, bool withIntegrityCheck = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
}
}
12 changes: 6 additions & 6 deletions PgpCore/Abstractions/IPGP.SignAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ namespace PgpCore.Abstractions
{
public interface ISignAsync : IDisposable
{
Task SignAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, string name = null, IDictionary<string, string> headers = null);
Task SignAsync(Stream inputStream, Stream outputStream, bool armor = true, string name = null, IDictionary<string, string> headers = null);
Task<string> SignAsync(string input, bool armor = true, string name = null, IDictionary<string, string> headers = null);
Task SignAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task SignAsync(Stream inputStream, Stream outputStream, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task<string> SignAsync(string input, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task ClearSignAsync(FileInfo inputFile, FileInfo outputFile, IDictionary<string, string> headers = null);
Task ClearSignAsync(Stream inputStream, Stream outputStream, IDictionary<string, string> headers = null);
Task<string> ClearSignAsync(string input, IDictionary<string, string> headers = null);

Task SignFileAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, string name = null, IDictionary<string, string> headers = null);
Task SignStreamAsync(Stream inputStream, Stream outputStream, bool armor = true, string name = null, IDictionary<string, string> headers = null);
Task<string> SignArmoredStringAsync(string input, bool armor = true, string name = null, IDictionary<string, string> headers = null);
Task SignFileAsync(FileInfo inputFile, FileInfo outputFile, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task SignStreamAsync(Stream inputStream, Stream outputStream, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task<string> SignArmoredStringAsync(string input, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
Task ClearSignFileAsync(FileInfo inputFile, FileInfo outputFile, IDictionary<string, string> headers = null);
Task ClearSignStreamAsync(Stream inputStream, Stream outputStream, IDictionary<string, string> headers = null);
Task<string> ClearSignArmoredStringAsync(string input, IDictionary<string, string> headers = null);
Expand Down
12 changes: 6 additions & 6 deletions PgpCore/Abstractions/IPGP.SignSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ namespace PgpCore.Abstractions
{
public interface ISignSync : IDisposable
{
void Sign(FileInfo inputFile, FileInfo outputFile, bool armor = true, string name = null, IDictionary<string, string> headers = null);
void Sign(Stream inputStream, Stream outputStream, bool armor = true, string name = null, IDictionary<string, string> headers = null);
string Sign(string input, bool armor = true, string name = null, IDictionary<string, string> headers = null);
void Sign(FileInfo inputFile, FileInfo outputFile, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
void Sign(Stream inputStream, Stream outputStream, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
string Sign(string input, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
void ClearSign(FileInfo inputFile, FileInfo outputFile, IDictionary<string, string> headers = null);
void ClearSign(Stream inputStream, Stream outputStream, IDictionary<string, string> headers = null);
string ClearSign(string input, IDictionary<string, string> headers = null);

void SignFile(FileInfo inputFile, FileInfo outputFile, bool armor = true, string name = null, IDictionary<string, string> headers = null);
void SignStream(Stream inputStream, Stream outputStream, bool armor = true, string name = null, IDictionary<string, string> headers = null);
string SignArmoredString(string input, bool armor = true, string name = null, IDictionary<string, string> headers = null);
void SignFile(FileInfo inputFile, FileInfo outputFile, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
void SignStream(Stream inputStream, Stream outputStream, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
string SignArmoredString(string input, bool armor = true, string name = null, IDictionary<string, string> headers = null, bool oldFormat = false);
void ClearSignFile(FileInfo inputFile, FileInfo outputFile, IDictionary<string, string> headers = null);
void ClearSignStream(Stream inputStream, Stream outputStream, IDictionary<string, string> headers = null);
string ClearSignArmoredString(string input, IDictionary<string, string> headers = null);
Expand Down
40 changes: 24 additions & 16 deletions PgpCore/Helpers/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,10 @@ public static KeyParameter MakeKeyFromPassPhrase(
public static async Task WriteFileToLiteralDataAsync(
Stream output,
char fileType,
FileInfo file)
FileInfo file,
bool oldFormat)
{
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator();
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator(oldFormat);
Stream pOut = lData.Open(output, fileType, file.Name, file.Length, file.LastWriteTime);
await PipeFileContentsAsync(file, pOut, 4096);
}
Expand All @@ -328,9 +329,10 @@ public static async Task WriteFileToLiteralDataAsync(
public static void WriteFileToLiteralData(
Stream output,
char fileType,
FileInfo file)
FileInfo file,
bool oldFormat)
{
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator();
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator(oldFormat);
Stream pOut = lData.Open(output, fileType, file.Name, file.Length, file.LastWriteTime);
PipeFileContents(file, pOut, 4096);
}
Expand All @@ -340,9 +342,10 @@ public static async Task WriteFileToLiteralDataAsync(
Stream output,
char fileType,
FileInfo file,
byte[] buffer)
byte[] buffer,
bool oldFormat)
{
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator();
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator(oldFormat);
Stream pOut = lData.Open(output, fileType, file.Name, file.LastWriteTime, buffer);
await PipeFileContentsAsync(file, pOut, buffer.Length);
}
Expand All @@ -352,9 +355,10 @@ public static void WriteFileToLiteralData(
Stream output,
char fileType,
FileInfo file,
byte[] buffer)
byte[] buffer,
bool oldFormat)
{
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator();
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator(oldFormat);
Stream pOut = lData.Open(output, fileType, file.Name, file.LastWriteTime, buffer);
PipeFileContents(file, pOut, buffer.Length);
}
Expand All @@ -363,9 +367,10 @@ public static async Task WriteStreamToLiteralDataAsync(
Stream output,
char fileType,
Stream input,
string name)
string name,
bool oldFormat)
{
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator();
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator(oldFormat);
Stream pOut = lData.Open(output, fileType, name, input.Length, DateTime.Now);
await PipeStreamContentsAsync(input, pOut, 4096);
}
Expand All @@ -374,9 +379,10 @@ public static void WriteStreamToLiteralData(
Stream output,
char fileType,
Stream input,
string name)
string name,
bool oldFormat)
{
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator();
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator(oldFormat);
Stream pOut = lData.Open(output, fileType, name, input.Length, DateTime.Now);
PipeStreamContents(input, pOut, 4096);
}
Expand All @@ -386,9 +392,10 @@ public static async Task WriteStreamToLiteralDataAsync(
char fileType,
Stream input,
byte[] buffer,
string name)
string name,
bool oldFormat)
{
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator();
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator(oldFormat);
Stream pOut = lData.Open(output, fileType, name, DateTime.Now, buffer);
await PipeStreamContentsAsync(input, pOut, buffer.Length);
}
Expand All @@ -398,9 +405,10 @@ public static void WriteStreamToLiteralData(
char fileType,
Stream input,
byte[] buffer,
string name)
string name,
bool oldFormat)
{
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator();
PgpLiteralDataGenerator lData = new PgpLiteralDataGenerator(oldFormat);
Stream pOut = lData.Open(output, fileType, name, DateTime.Now, buffer);
PipeStreamContents(input, pOut, buffer.Length);
}
Expand Down
Loading