diff options
author | David Hook <dgh@cryptoworkshop.com> | 2020-11-17 14:49:04 +1100 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2020-11-17 14:49:04 +1100 |
commit | 19d5b6c6e5838c37ff48b11df1301a07a521fe4c (patch) | |
tree | 9635e77661cd5b1c066d5b866bcabfbb779da28a /crypto/src/pkcs | |
parent | Rework D/E range restriction (diff) | |
download | BouncyCastle.NET-ed25519-19d5b6c6e5838c37ff48b11df1301a07a521fe4c.tar.xz |
added suport for PKCS#5 scheme 2, tests for the same
Diffstat (limited to 'crypto/src/pkcs')
-rw-r--r-- | crypto/src/pkcs/Pkcs12Store.cs | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/crypto/src/pkcs/Pkcs12Store.cs b/crypto/src/pkcs/Pkcs12Store.cs index 0eff8eb92..dba76cdb5 100644 --- a/crypto/src/pkcs/Pkcs12Store.cs +++ b/crypto/src/pkcs/Pkcs12Store.cs @@ -1058,16 +1058,27 @@ namespace Org.BouncyCastle.Pkcs bool wrongPkcs12Zero, byte[] data) { - IBufferedCipher cipher = PbeUtilities.CreateEngine(algId.Algorithm) as IBufferedCipher; + IBufferedCipher cipher = PbeUtilities.CreateEngine(algId) as IBufferedCipher; if (cipher == null) throw new Exception("Unknown encryption algorithm: " + algId.Algorithm); - Pkcs12PbeParams pbeParameters = Pkcs12PbeParams.GetInstance(algId.Parameters); - ICipherParameters cipherParams = PbeUtilities.GenerateCipherParameters( - algId.Algorithm, password, wrongPkcs12Zero, pbeParameters); - cipher.Init(forEncryption, cipherParams); - return cipher.DoFinal(data); + if (algId.Algorithm.Equals(PkcsObjectIdentifiers.IdPbeS2)) + { + PbeS2Parameters pbeParameters = PbeS2Parameters.GetInstance(algId.Parameters); + ICipherParameters cipherParams = PbeUtilities.GenerateCipherParameters( + algId.Algorithm, password, pbeParameters); + cipher.Init(forEncryption, cipherParams); + return cipher.DoFinal(data); + } + else + { + Pkcs12PbeParams pbeParameters = Pkcs12PbeParams.GetInstance(algId.Parameters); + ICipherParameters cipherParams = PbeUtilities.GenerateCipherParameters( + algId.Algorithm, password, wrongPkcs12Zero, pbeParameters); + cipher.Init(forEncryption, cipherParams); + return cipher.DoFinal(data); + } } private class IgnoresCaseHashtable |