Giter Club home page Giter Club logo

chopgp's Introduction

chopgp's People

Contributors

athoik avatar chriscrew avatar cinchoo avatar nickromero avatar raceprouk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chopgp's Issues

License?

I couldn't find any license information for this project.

Unknown PGP public key algorithm encountered

Is there an issue in the package, or am I not doing something correctly?

Package version:

ChoPGP 1.0.1.5
BouncyCastle 1.8.1

I generated the key pair like so:

using (var pgp = new ChoPGPEncryptDecrypt())
{                  
    pgp.GenerateKey("public.asc", private.asc", "[email protected]", "Welcome1");
}

Then I tried to encrypt the file:

using (var pgp = new ChoPGPEncryptDecrypt())
{                  
    pgp.EncryptFile(filePath, encryptedFilePath, "public.asc", false, false);
}

And I get the error: System.IO.IOException: Unknown PGP public key algorithm encountered

why can not using the full file path?

I am using it now to develop a data exchange with bank. they say that my encrypted file will print full file path.
I noticed that in your demo code, you only use file name, not file path.

EndOfStreamException: Premature end of stream in PartialInputStream while file decryption

Hello!
I faced such an issue as "EndOdStreamException: Premature end of stream in PartialInputStream" with some pgp files that should be decrypted as ZIP archive.

Could you please advise what can be is the reason?

I had the following exception StackTrace:

System.IO.EndOfStreamException: Premature end of stream in PartialInputStream at Org.BouncyCastle.Bcpg.BcpgInputStream.PartialInputStream.Read(Byte[] buffer, Int32 offset, Int32 count) at Org.BouncyCastle.Bcpg.BcpgInputStream.Read(Byte[] buffer, Int32 offset, Int32 count) at Org.BouncyCastle.Crypto.IO.CipherStream.ReadAndProcessBlock() at Org.BouncyCastle.Crypto.IO.CipherStream.FillInBuf() at Org.BouncyCastle.Crypto.IO.CipherStream.Read(Byte[] buffer, Int32 offset, Int32 count) at Org.BouncyCastle.Bcpg.BcpgInputStream.Read(Byte[] buffer, Int32 offset, Int32 count) at Org.BouncyCastle.Utilities.Zlib.ZInputStream.Read(Byte[] b, Int32 off, Int32 len) at Org.BouncyCastle.Bcpg.BcpgInputStream.Read(Byte[] buffer, Int32 offset, Int32 count) at Org.BouncyCastle.Bcpg.BcpgInputStream.PartialInputStream.Read(Byte[] buffer, Int32 offset, Int32 count) at Org.BouncyCastle.Bcpg.BcpgInputStream.Read(Byte[] buffer, Int32 offset, Int32 count) at Org.BouncyCastle.Utilities.IO.Streams.PipeAll(Stream inStr, Stream outStr) at Cinchoo.PGP.ChoPGPEncryptDecrypt.Decrypt(Stream inputStream, Stream outputStream, Stream privateKeyStream, String passPhrase) at Cinchoo.PGP.ChoPGPEncryptDecrypt.DecryptFile(String inputFilePath, String outputFilePath, String privateKeyFilePath, String passPhrase)

Verification fails when using subkey for signatures

Some people like to separate the concerns of what their keys should do, so when you have 2 sub keys - 1 for signing and the other for encrypting, this library like many other fail at the step of verifying the signature.

Why is this such a troublesome topic to handle? the private key file contains both sub-keys.

Docs not clear enough

hi,
the library looks promising but adding a few comments about parameters and their uses in ReadMe will be better for a new user.

The public key required an expiry date.

First of all, thanks for simplifying the OpenPGP. The source is very helpful to me.

However, I am doing the key exchange with the bank, and the bank said that the expiry date is required for the Public Key.

I am only able to check the valid date by GetValidSeconds() or ValidDays.

Could you please help to show how to add the expiry date on the Public Key?

Many Thanks.

Null reference exception while decrypting stream to stream

I've been trying to encrypt and decrypt files in memory using streams, but there is a null reference exception on

DecryptAsync(Stream inputStream, Stream outputStream, Stream privateKeyStream, string passPhrase)

method.

My code:

  1. Key generating:
public static void CinchooPGP_GenerateKeys()
{
    using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
    {
        pgp.GenerateKey(@"C:\TEMP\Keys\public.asc", @"C:\TEMP\Keys\private.asc", null, "password");
    }
}
  1. Encryption:
        public static async Task<MemoryStream> CinchooPGPEncryption()
        {
            var ContentToEncryptStream = await FileToStreamMethod(@"C:\TEMP\Content\content.txt");
            var PublicKeyStream = await FileToStreamMethod(@"C:\TEMP\Keys\public.asc");
            MemoryStream encryptedContent = new MemoryStream();
            using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
            {
                //this accepts 3 streams: stream to encrypt, stream to decrypt, public keys
                await pgp.EncryptAsync(ContentToEncryptStream, encryptedContent, PublicKeyStream);
            }
            return encryptedContent;
        }
  1. Decryption:
        public static async Task<MemoryStream> CinchooPGPDecryption(MemoryStream encryptedContent, string passPhrase)
        {
            var PrivateKeyStream = await FileToStreamMethod(@"C:\TEMP\Keys\private.asc");
            MemoryStream decryptedContent = new MemoryStream();

            using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
            {
                await pgp.DecryptAsync(encryptedContent, decryptedContent, PrivateKeyStream, passPhrase); //exception is thrown here
            }
            return decryptedContent;
        }

Stacktrace:

   at Cinchoo.PGP.ChoPGPEncryptDecrypt.Decrypt(Stream inputStream, Stream outputStream, Stream privateKeyStream, String passPhrase)
   at Cinchoo.PGP.ChoPGPEncryptDecrypt.<>c__DisplayClass47_0.<DecryptAsync>b__0()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at Cinchoo.PGP.ChoPGPEncryptDecrypt.<DecryptAsync>d__47.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()

No stream is null while I was debugging the app, so I think it's thrown somewhere inside the lib. Or maybe I am doing something wrong?

DecryptAndVerify

Hi,
How can I decrypt a file that was encrypted with EncryptFileAndSign method?

Is there a method to decrypt and verify a file? After I encrypt a file with EncryptFileAndSign method I cannot decrypt it with Decrypt method I got the execption: "Encrypted message contains a signed message - not literal data."

Thank you!! Great work with the library.

Decrypt Method throwing error: "Object reference not set to an instance of an object"

Using version 1.0.1.3

My code is here:
using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt()) { EncryptionViewModel pem = rpt.Encryption_In; var from = setFiles.FileToProcessPath + setFiles.FileToProcess; var to = setFiles.ProcessedPath + setFiles.ProcessedName; if (from == to) { to = setFiles.ProcessedPath + "_" + setFiles.ProcessedName; pgp.DecryptFile(from, to, pem.PEMPath, pem.PassPhrase); File.Delete(from); File.Move(to, from); } else { pgp.DecryptFile(from, to, pem.PEMPath, pem.PassPhrase); } }

In this case, the file name I am decrypting is the same as the file name I want to send on to the customer (this is an EDI application), so I am renaming the To file to _To, doing the Decrypt, then deleting the From file and renaming _To to From.

My stack track is here:

at Cinchoo.PGP.ChoPGPEncryptDecrypt.Decrypt(Stream inputStream, Stream outputStream, Stream privateKeyStream, String passPhrase) at Cinchoo.PGP.ChoPGPEncryptDecrypt.DecryptFile(String inputFilePath, String outputFilePath, String privateKeyFilePath, String passPhrase) at EDI2.Data.Process_Unencrypt_File.Process(ReportAllDataViewModel rpt) in C:\TWRAProjects\EDI2\EDI2\Data\Data_Process.cs:line 544

This has been working. I have verified the From file exists, the To file does not, and that my pgp and pem references are valid. I have verified that the pem.PEMPath and pem.PassPhrase variables are filled, and are correct.

The Encrypt process is still working just fine. I encrypt three or four files per week for my customers.

decrypt and verify error

it was error when I decrypt and verify, because my private key has used passphrase,when i debug,i found ,it get the passphrase not secrekey when read secretkey ,in my private key,passphrase's type is same as secrekey,so i get secrekey if keyid>0.my english is bad.thank you for your project

EncryptAndSign methods Outputstream does not seem to return the encrypted Stream of the inputstream

Using the new Streaming methods seem to work for decryption but encryption all files seem to become
1 k files. I reverted my code back to using file based encryption (Which worked file)

Code:

using Cinchoo.PGP;
using Microsoft.Azure.KeyVault;
using Microsoft.Azure.KeyVault.Models;
using Microsoft.Azure.Services.AppAuthentication;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.IO;

namespace AzureERPFileEncryption
{
class Utils
{
internal static async System.Threading.Tasks.Task CopyKeysAsync(string key, string keyContainer)
{
Stream keyStream = new MemoryStream();
if (CloudStorageAccount.TryParse(Environment.GetEnvironmentVariable("AzureWebJobsStorage"), out CloudStorageAccount storageAccount))
{
var cloudBlobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer cloudBlobContainer = cloudBlobClient.GetContainerReference(keyContainer + "/");

            CloudBlockBlob blockBlob = cloudBlobContainer.GetBlockBlobReference(key);
        
            await blockBlob.DownloadToStreamAsync(keyStream);
        }
        return keyStream;
    }



    internal static async System.Threading.Tasks.Task<Stream> DecryptBlobAsync(Stream myBlob, string name, string source, String functionDirectory, TraceWriter log)
    {
        if (myBlob == null)
        {
            throw new ArgumentNullException(nameof(myBlob));
        }

        bool sign = false;
        string publicKey = null;
        string privateKey = null;
        string passPhrase = null;
        switch (source.ToLower())
        {
            /*
             *  Long term this data should be loaded into a database or a Config file 
             * 
             * 
             */ 
            case "one":
                publicKey = Environment.GetEnvironmentVariable("onePublicKey");
                privateKey = Environment.GetEnvironmentVariable("oneAcostaPrivate");
                sign = true;
                break;
            case "two":                 
                privateKey = Environment.GetEnvironmentVariable("twoAcostaPrivate");
                passPhrase = await GetSecertValue(Environment.GetEnvironmentVariable("twoPassphrase"));
                sign = false;
                break;
            case "three":                    
                privateKey = Environment.GetEnvironmentVariable("wageworksAcostaPrivate");
                passPhrase = await GetSecertValue(Environment.GetEnvironmentVariable("threePassphrase"));
                sign = false;
                break;
            default:
                break;
        }

        Stream decryptStream = new MemoryStream();        
        try
        {                                
            if (sign)
            {
                using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
                using (Stream privateStream = CopyKeysAsync(privateKey, Environment.GetEnvironmentVariable("privatekeyscontainer")).Result)
                using (Stream publicStream = CopyKeysAsync(publicKey, Environment.GetEnvironmentVariable("publickeyscontainer")).Result)

                {
                    privateStream.Seek(0, SeekOrigin.Begin);
                    publicStream.Seek(0, SeekOrigin.Begin);
                    pgp.DecryptAndVerify(myBlob, decryptStream, publicStream, privateStream, passPhrase);
                }
                }
                else
                {
                using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
                using (Stream privateStream = CopyKeysAsync(privateKey, Environment.GetEnvironmentVariable("privatekeyscontainer")).Result)
                    {
                    privateStream.Seek(0, SeekOrigin.Begin);
                   
                    pgp.Decrypt(myBlob, decryptStream, privateStream, passPhrase);
                    }
                }                
        }
        catch (Exception ex)
        {
            log.Error("Error in DecryptBlobAsync", ex.InnerException);
            log.Error("Error in DecryptBlobAsync " + ex.Message);
            log.Error("Error in DecryptBlobAsync" + ex.StackTrace);
            throw ex;
        }
        return decryptStream;
    }

    internal static async System.Threading.Tasks.Task<MemoryStream> SignAndEncryptBlobAsync(Stream myBlob, string name, string source, string functionDirectory, TraceWriter log)
    {

        bool sign = false;
        bool armor = true;
        bool withIntegrityCheck = false;
        string publicKey = null;
        string privateKey = null;
        string passPhrase = null;
        MemoryStream encryptedStream = new MemoryStream();
            switch (source.ToLower())
        {
            case "adp":
                publicKey = Environment.GetEnvironmentVariable("sfd");
                privateKey = Environment.GetEnvironmentVariable("asf");
                passPhrase = await GetSecertValue(Environment.GetEnvironmentVariable("asf"));
                sign = true;
                armor = true;
                withIntegrityCheck = false;
                break;
            case "kronos":
                publicKey = Environment.GetEnvironmentVariable("kronos");
                sign = false;
                break;
            default:
                break;
        }
        
        
            try
            {
                if (sign)
                {
                    using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
                    using (Stream publicStream = CopyKeysAsync(publicKey, Environment.GetEnvironmentVariable("publickeyscontainer")).Result)
                    using (Stream privateStream = CopyKeysAsync(privateKey, Environment.GetEnvironmentVariable("privatekeyscontainer")).Result)
                    {
                        privateStream.Seek(0, SeekOrigin.Begin);
                        publicStream.Seek(0, SeekOrigin.Begin);
                        pgp.EncryptAndSign(myBlob, encryptedStream, publicStream, privateStream, passPhrase, armor, withIntegrityCheck);
                    }
                }
                else
                {
                    using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
                    using (Stream publicStream = CopyKeysAsync(publicKey, Environment.GetEnvironmentVariable("publickeyscontainer")).Result)
                    {
                        publicStream.Seek(0, SeekOrigin.Begin);
                        pgp.Encrypt(myBlob, encryptedStream, publicStream, armor, withIntegrityCheck);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("Error in SignAndEncryptBlobAsync", ex.InnerException);
                throw ex;
            }
            return encryptedStream;          
    }                         


    internal static async System.Threading.Tasks.Task<string> GetSecertValue(string value)
    {
        try
        {
            var secretUri = SecretUri(value);
            var serviceTokenProvider = new AzureServiceTokenProvider();
            var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(serviceTokenProvider.KeyVaultTokenCallback));
            SecretBundle secretValue = await keyVaultClient.GetSecretAsync(secretUri);
            return secretValue.Value;
        }
        catch (Exception ex)
        {                
            throw ex;
        }
    }

    public static string SecretUri(string secret)
    {
        return $"{Environment.GetEnvironmentVariable("KeyVaultUri")}/Secrets/{secret}";
    }
}

}

DecryptToText method returning blank string

Need to seek to beginning of memoryStream before reading it to the string variable "end"

Streams.PipeAll(((PgpLiteralData)pgpObject1).GetInputStream(), memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
end = (new StreamReader(memoryStream)).ReadToEnd();

The Assembly is not stongly signed

Please make the assembly stongly signed. This is needed to be able to add the assembly to the Global Assembly Cache.

This could be done by creating a signing key using sn.exe and adding the key to the base of the project and adding the following to the .csproj file:

<PropertyGroup> <SignAssembly>true</SignAssembly> </PropertyGroup> <PropertyGroup> <AssemblyOriginatorKeyFile>ChoPGP.snk</AssemblyOriginatorKeyFile> </PropertyGroup> <ItemGroup> <None Include="ChoPGP.snk" /> <None Include="packages.config" /> </ItemGroup>

Use streaming for inputs to EncryptFileAndSign and EncryptFile

Started to use your API and so for really found it useful. So i was wondering if in your plans you where planning on using Streaming to replace file access in both EncryptFileAndSign and EncryptFile. (I am sure i would want decrypt as well but in my current project i do not need it)

Decrypt method with privateKeyFilePath parameter not disposing private key stream.

When passing the private key file path to the Decrypt method, it does not release the key file after decryption.

Decrypt(inputStream, outputStream, File.OpenRead(privateKeyFilePath), passPhrase);

It looks as though there is probably the same issue in other methods as well where the private key file path is passed in. I didn't try it but I think in the case of async methods, the file will be released however the non-async methods don't seem to be releasing the private key file.

DecryptFile method is not returning the plain text

Can you figure out anything that i am missing in my code.
Here is my code:

`
// to generate keys
using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
pgp.GenerateKey(@"c:\umesh\chopgp\keyPublic.asc", @"c:\umesh\chopgp\keyPrivate.asc", "[email protected]", "password");

        // to encrpyt
        using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
        {
            pgp.EncryptFile(@"c:\umesh\chopgp\MyTest.txt", @"c:\umesh\chopgp\MyTestEncrypted.txt", @"c:\umesh\chopgp\keyPublic.asc");
        }

        // to decrypt
        using (ChoPGPEncryptDecrypt pgp = new ChoPGPEncryptDecrypt())
        {
            pgp.DecryptFile(@"c:\umesh\chopgp\MyTestEncrypted.txt", @"c:\umesh\chopgp\MyTestDecrypted.txt", @"c:\umesh\chopgp\keyPrivate.asc", "password");
        } 

`

GetFirstPublicKey: check subpacket for encrypt keyflags

Hi,

It seems that GetFirstPublicKey doesn't check the KeyFlags on subpackets, so it's possible to encrypt with master key that usually doesn't contain Encrypt usage.

The following change implements the check for KeyFlags as mentioned in https://github.com/bcgit/bc-csharp/blob/master/crypto/src/openpgp/PgpPublicKey.cs#L426-L427

diff --git a/ChoPGP/ChoPGPEncryptDecrypt.cs b/ChoPGP/ChoPGPEncryptDecrypt.cs
index 25a80b3..26d4e3f 100644
--- a/ChoPGP/ChoPGPEncryptDecrypt.cs
+++ b/ChoPGP/ChoPGPEncryptDecrypt.cs
@@ -874,11 +874,23 @@ namespace Cinchoo.PGP
             // iterate through the key rings.
             foreach (PgpPublicKeyRing kRing in pgpPub.GetKeyRings())
             {
-                foreach (PgpPublicKey k in kRing.GetPublicKeys())
+                List<PgpPublicKey> keys = kRing.GetPublicKeys()
+                    .Cast<PgpPublicKey>()
+                    .Where(k => k.IsEncryptionKey).ToList();
+
+                const int encryptKeyFlags = PgpKeyFlags.CanEncryptCommunications | PgpKeyFlags.CanEncryptStorage;
+
+                foreach (PgpPublicKey key in keys.Where(k => k.Version >= 4 && !k.IsMasterKey))
                 {
-                    if (k.IsEncryptionKey)
-                        return k;
+                    foreach (PgpSignature s in key.GetSignatures())
+                    {
+                        if (s.GetHashedSubPackets().GetKeyFlags() == encryptKeyFlags)
+                            return key;
+                    }
                 }
+
+                if (keys.Any())
+                    return keys.First();
             }
 
             throw new ArgumentException("Can't find encryption key in key ring.");
diff --git a/ChoPGP/ChoPGPEncryptionKeys.cs b/ChoPGP/ChoPGPEncryptionKeys.cs
index 6f13228..56d9924 100644
--- a/ChoPGP/ChoPGPEncryptionKeys.cs
+++ b/ChoPGP/ChoPGPEncryptionKeys.cs
@@ -134,12 +134,23 @@ namespace Cinchoo.PGP
         {
             foreach (PgpPublicKeyRing kRing in publicKeyRingBundle.GetKeyRings())
             {
-                PgpPublicKey key = kRing.GetPublicKeys()
+                List<PgpPublicKey> keys = kRing.GetPublicKeys()
                     .Cast<PgpPublicKey>()
-                    .Where(k => k.IsEncryptionKey)
-                    .FirstOrDefault();
-                if (key != null)
-                    return key;
+                    .Where(k => k.IsEncryptionKey).ToList();
+
+                const int encryptKeyFlags = PgpKeyFlags.CanEncryptCommunications | PgpKeyFlags.CanEncryptStorage;
+
+                foreach (PgpPublicKey key in keys.Where(k => k.Version >= 4 && !k.IsMasterKey))
+                {
+                    foreach (PgpSignature s in key.GetSignatures())
+                    {
+                        if (s.GetHashedSubPackets().GetKeyFlags() == encryptKeyFlags)
+                            return key;
+                    }
+                }
+
+                if (keys.Any())
+                    return keys.First();
             }
             return null;
         }

If you find this change OK, I will create a PR.

PS. Maybe a function to return first public key should moved to Utils in order not to duplicate code?

3 Characters in front of decrypted file

Hello,

I am using your library to encrypt and sign files that are sent to a another system that uses GnuPG to decrypt them. The decryption works fine in their end but the result decrypted file is showing 3 charaters "" () right in front of my original XML encrypted file that makes them impossible to read with their system.

Do you know how is it possible that these 3 characters could be inserted in the encryption process?

Thank you,
Jose

Output Files Always Named "name"

Various files that are compressed and encrypted using this lib are all outputting as "name" after decryption by data partner.

During troubleshooting, I see ChoPGPEncryptDecrypt.Encrypt uses hard coded "name" as ChoPGPUtility.WriteStreamToLiteralData parameter. Also, EncryptAndSign.OutputEncrypted also using the "name" param.

Will System.IO Path.GetFileName(inputStream) work as a replacement?

System.IO.IOException: unknown packet type encountered: 20

Hey,

first of all i want to thank you for this great package! I like how easy it is for using, thanks for that!

I have one question. We have suddenly, without changing or updating the application or something, encountered the following error:

System.IO.IOException: unknown packet type encountered: 20
   at Org.BouncyCastle.Bcpg.BcpgInputStream.ReadPacket()
   at Org.BouncyCastle.Bcpg.OpenPgp.PgpEncryptedDataList..ctor(BcpgInputStream bcpgInput)
   at Org.BouncyCastle.Bcpg.OpenPgp.PgpObjectFactory.NextPgpObject()
   at Cinchoo.PGP.ChoPGPEncryptDecrypt.Decrypt(Stream inputStream, Stream outputStream, Stream privateKeyStream, String passPhrase)
   at Cinchoo.PGP.ChoPGPEncryptDecrypt.Decrypt(Stream inputStream, Stream outputStream, String privateKeyFilePath, String passPhrase)

It happens one week ago without any changes, so i asking myself, what could cause the issue? We tried some things to check, key is still valid, because we can decrypt the encrypted file with the gpg command in Windows PowerShell.

We tried also to change the key, but same thing happens, also if you provide an invalid key.

Any Idea what could happen here?

Thats the call were the Issue happens:
using (var pgp = new ChoPGPEncryptDecrypt()) { pgp.Decrypt(memInput, memOutput, _appSettings.ImportSettings.DecryptPrivateKeyPath, ""); }

on pgp.Decrypt

Thank you in advance!

BR

Exception while encrypt and signed

Hello can you please tell me why it is giving this error
Org.BouncyCastle.Bcpg.OpenPgp.PgpPublicKeyRing found where PgpSecretKeyRing expected

It throws only when I create keys through OpenPGP studio. otherwise, it is working fine

Unknown object in stream 47

Hi,

I am trying to use the DecryptFileAsync method to decrypt and it was working fine. Except for this one client, for which I am getting this error, "Unknown object in stream 47"

Unfortunately it's not easy to ask the client to check their file. I found a BouncyCastle post about the same thing and it seems like this exception could be caught and it will continue decrypting the file.

http://bouncy-castle.1462172.n4.nabble.com/unknown-object-in-stream-XX-td1467126.html

https://www.bouncycastle.org/devmailarchive/msg06901.html

Appreciate any help on this.

Thanks,
Daniel

Using subkey for encryption in EncryptAndSign

Hi

I have an issue with the usage of a subkeys in the method EncryptAndSign. This method uses the master key for encryption, even if there is a subkey for encryption. Have a look at the comment on IsEncryptionKey in the BouncyCastle Library: "Note: with version 4 keys KeyFlags subpackets should also be considered when present for determining the preferred use of the key."
Your method Encrypt() already uses the right logic, but EncryptAndSign() uses the method GetFirstPublicKey() which does't care about the logic with KeyFlags of subkeys.

I'll make a pull request with a possible solution. Perhaps you can check it out.

Thanks
Claudio

Signed a file only

Hello Is there possible to signed a file only not encryption because we have did encryption already we need to signed a file only?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.