Discussion:
Can CreateEncryptedPrivateKeyInfo() be used with pbes2/sha256 (C#)?
cartland
2014-07-18 04:24:55 UTC
Permalink
I’m currently using

EncryptedPrivateKeyInfoFactory.CreateEncryptedPrivateKeyInfo(PkcsObjectIdentifiers.PbewithShaAnd40BitRC2Cbc,
password, salt, iterationCount, privateKey);

And would like to do something like

EncryptedPrivateKeyInfoFactory.CreateEncryptedPrivateKeyInfo(“PBES2_WITH_SHA256”,
password, salt, iterationCount, privateKey);

If CreateEncryptedPrivateKeyInfo cannot be used, is the intent to add this
support in at some point? What mechanism can be used currently (in 1.7)?

BTW: Is this a bug?

PbeUtilties.CreateEngine() returns an IMac object when mechanism is
“PBEwithHmac…..”.
However, CreateEncryptedPrivateKeyInfo() casts this to IBufferedCipher.
IBufferedCipher cipher = PbeUtilities.CreateEngine(algorithm) as
IBufferedCipher;
The result is cipher is null and you get a “System.NullReferenceException:
Object reference not set to an instance of an object” (because the cipher ==
null check is not implemented).



--
View this message in context: http://bouncy-castle.1462172.n4.nabble.com/Can-CreateEncryptedPrivateKeyInfo-be-used-with-pbes2-sha256-C-tp4657230.html
Sent from the Bouncy Castle - Dev mailing list archive at Nabble.com.
cartland
2014-09-21 11:33:09 UTC
Permalink
No it can't - currently.

However, I have added support based on 1.8 and tested with OpenSSL 1.1.0.

I will add to https://github.com/nerfin/bc-csharp and submit a pull request
- hopefully next week sometime.

Regards





--
View this message in context: http://bouncy-castle.1462172.n4.nabble.com/Can-CreateEncryptedPrivateKeyInfo-be-used-with-pbes2-sha256-C-tp4657230p4657363.html
Sent from the Bouncy Castle - Dev mailing list archive at Nabble.com.
Loading...