-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from mattosaurus/chore/improve-tests-decrypt
Chore/improve tests decrypt
- Loading branch information
Showing
21 changed files
with
3,865 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Org.BouncyCastle.Bcpg.OpenPgp; | ||
using Org.BouncyCastle.Bcpg; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace PgpCore.Tests | ||
{ | ||
internal static class TestHelper | ||
{ | ||
internal static PgpPublicKey ReadPublicKey(Stream inputStream) | ||
{ | ||
PgpPublicKeyRingBundle pgpPub = new PgpPublicKeyRingBundle(PgpUtilities.GetDecoderStream(inputStream)); | ||
foreach (PgpPublicKeyRing kRing in pgpPub.GetKeyRings()) | ||
{ | ||
foreach (PgpPublicKey k in kRing.GetPublicKeys()) | ||
{ | ||
if (k.IsEncryptionKey) | ||
return k; | ||
} | ||
} | ||
throw new ArgumentException("No encryption key found in public key ring."); | ||
} | ||
|
||
internal static IEnumerable<T> GetEnumValues<T>() where T : struct, IConvertible | ||
{ | ||
foreach (T enumValue in Enum.GetValues(typeof(T))) | ||
{ | ||
yield return enumValue; | ||
} | ||
} | ||
|
||
internal static IEnumerable<object[]> GetAllCombinations() | ||
{ | ||
foreach (CompressionAlgorithmTag compressionAlgorithmTag in GetEnumValues<CompressionAlgorithmTag>()) | ||
foreach (HashAlgorithmTag hashAlgorithmTag in GetEnumValues<HashAlgorithmTag>()) | ||
foreach (SymmetricKeyAlgorithmTag symmetricKeyAlgorithmTag in GetEnumValues<SymmetricKeyAlgorithmTag>()) | ||
{ | ||
yield return new object[] { compressionAlgorithmTag, hashAlgorithmTag, symmetricKeyAlgorithmTag }; | ||
} | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.