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 support for encrypted rsa private key #1

Open
StefH opened this issue Jul 18, 2017 · 5 comments
Open

Add support for encrypted rsa private key #1

StefH opened this issue Jul 18, 2017 · 5 comments
Assignees
Labels

Comments

@StefH
Copy link
Owner

StefH commented Jul 18, 2017

No description provided.

@StefH StefH added the feature label Jul 18, 2017
@StefH StefH self-assigned this Jul 18, 2017
@oudi
Copy link

oudi commented Nov 7, 2018

hi @StefH How is it going?

@StefH
Copy link
Owner Author

StefH commented Nov 7, 2018

Sorry I don't have the knowledge to continue on this issue.

@oudi
Copy link

oudi commented Nov 16, 2018

@StefH I found a solution can encrypt data with private key , http:https://www.bouncycastle.org/csharp/

Here is the code, you can try.

        public static byte[] RSAPrivateEncrypt(System.Security.Cryptography.RSA priRsa, byte[] byteData)
        {
            var keyPair = DotNetUtilities.GetKeyPair(priRsa);
            var c = CipherUtilities.GetCipher("RSA/ECB/PKCS1Padding");
            c.Init(true, keyPair.Private); //init with private key
            var encryptedBytes = c.DoFinal(temp); //encrypt data with private key
            return encryptedBytes;
        }

@nmbro
Copy link

nmbro commented Nov 18, 2018

@oudi it is not the issue of how to encrypt data with the privatekey - but that the privatekey itself is encrypted.
RSA Privatekeys can be encrypted if so chosen upon creation with Triple DES.

@StefH
Copy link
Owner Author

StefH commented Nov 18, 2018

Correct.

What I want to build is that you can provide an encrypted private key in the
Decode and DecodeParameters in the class OpenSSLPrivateKeyDecoder.cs .

For that to work I

  1. need to be able to detect if a privateText is encrypted or not.
  2. Decrypt the encrypted text using that password. Maybe this method DecodeEncryptedPrivateKey(...) is a start ?

@nmbro Do you more details, and can you maybe create a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants