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 | |
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
-rw-r--r-- | crypto/src/pkcs/Pkcs12Store.cs | 23 | ||||
-rw-r--r-- | crypto/test/src/pkcs/test/PKCS12StoreTest.cs | 235 |
2 files changed, 249 insertions, 9 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 diff --git a/crypto/test/src/pkcs/test/PKCS12StoreTest.cs b/crypto/test/src/pkcs/test/PKCS12StoreTest.cs index 9d6f541fa..19749278c 100644 --- a/crypto/test/src/pkcs/test/PKCS12StoreTest.cs +++ b/crypto/test/src/pkcs/test/PKCS12StoreTest.cs @@ -541,8 +541,205 @@ namespace Org.BouncyCastle.Pkcs.Tests + "ToTFur9UoPgV3IoCIQDd6Lvuf1IHIZPeNbyuvBCynu+eDek8pO5B90BV6ImI" + "uTETMBEGCSqGSIb3DQEJFDEEHgIAADA7MB8wBwYFKw4DAhoEFBANsR/ZVCiJ" + "TzN4ZU2XvrYRR08dBBSWTwZIoxkxjXzd/mWKRFVbSOKwCAICB9A="); - - private readonly SecureRandom Random = new SecureRandom(); + + private static readonly byte[] sentrix1 = Base64.Decode( + "MIILRQIBAzCCCvEGCSqGSIb3DQEHAaCCCuIEggreMIIK2jCCAhAGCSqGSIb3" + + "DQEHAaCCAgEEggH9MIIB+TCCAfUGCyqGSIb3DQEMCgECoIIBEDCCAQwwVwYJ" + + "KoZIhvcNAQUNMEowKQYJKoZIhvcNAQUMMBwECNhVXbrzrAMNAgIH0DAMBggq" + + "hkiG9w0CCQUAMB0GCWCGSAFlAwQBKgQQ0BXsfgqcfDzPx5NaTbwA5gSBsLxT" + + "h8b5ZF/F7oq+45GTsDisspv1ZcJrp5fwg/PWmxA4ao/LarQX+b0xXq+TpCMN" + + "KtvWG+tRHoJfNcMlKLlppi0LV0WHQ6juj5zvb3lQX8BUvWOjCNz9z20tM5w+" + + "4lD6vZsDgXEi56feMwprdfw/Vq1mZJ3wBBsoSJtMRZoh580C5ij/BCbczA/O" + + "mFYGN/Ix9KYzxC/ecPWADbe7C7yVbIS1aNh5EVcSkVNf8zhEdOKNMYHRMBMG" + + "CSqGSIb3DQEJFTEGBAQBAAAAMFsGCSqGSIb3DQEJFDFOHkwAewA2AEQAQQA2" + + "AEQARQBGADAALQBFADAARQBDAC0ANAAxAEYANwAtAEEANQA2AEMALQBFADMA" + + "NQA5AEIAMgBFADEARgBBADQANQB9MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMA" + + "cgBvAHMAbwBmAHQAIABTAG8AZgB0AHcAYQByAGUAIABLAGUAeQAgAFMAdABv" + + "AHIAYQBnAGUAIABQAHIAbwB2AGkAZABlAHIwggjCBgkqhkiG9w0BBwagggiz" + + "MIIIrwIBADCCCKgGCSqGSIb3DQEHATBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG" + + "9w0BBQwwHAQIqytIbVkt24ICAgfQMAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUD" + + "BAEqBBCU1/xxOdG62x7n1Kz/4wPJgIIIQK4qtOJGR/+2+HD1MYVhFGaqYKpB" + + "wRQ4lg9HI4BYolGqJT19NgpSc95nFfq5nLoCI4nnH7b9U7p2t7wRR08tz5NO" + + "kPLt2DgOd3cOJCmSv9I40OVBuST6tukzwWi09x7uaOLqATvqfLrISDxYWWID" + + "O9QXqTLazwtgszk6eorZh9bogoINjdXOsZgDYHfHJvttBITI8fxLbUPjE/Fw" + + "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" + + "59no+6YCAgfQ"); + + private static readonly byte[] sentrix2 = Base64.Decode( + "MIIKxwIBAzCCCnMGCSqGSIb3DQEHAaCCCmQEggpgMIIKXDCCAhAGCSqGSIb3" + + "DQEHAaCCAgEEggH9MIIB+TCCAfUGCyqGSIb3DQEMCgECoIIBEDCCAQwwVwYJ" + + "KoZIhvcNAQUNMEowKQYJKoZIhvcNAQUMMBwECNLmcXtb3SOSAgIH0DAMBggq" + + "hkiG9w0CCQUAMB0GCWCGSAFlAwQBKgQQG3jOE88tMcGPYiMn4frFZASBsIXA" + + "JRyUSyy0UfmoW5093F213ROErwIKSwInMD2x/jAHBOK3tTLGiH0YZyy0kqnO" + + "BfjbvweJ1FZOLAAfFiERX+hEFJN0yll+mweUU/Yrgyrrmtre4Xn4bJWVN7k1" + + "j6dU/Ub5p8FMpROmG4biiY1L5GcjOFZCiQiVaSh6FWwsN/qcdaTfJi/mKjsf" + + "TGk/G/intuvPxTgQC6c/ZY4MXpQZ6CFHf41mF9THgR0Ur+WgNSW7MYHRMBMG" + + "CSqGSIb3DQEJFTEGBAQBAAAAMFsGCSqGSIb3DQEJFDFOHkwAewA2AEQAQQA2" + + "AEQARQBGADAALQBFADAARQBDAC0ANAAxAEYANwAtAEEANQA2AEMALQBFADMA" + + "NQA5AEIAMgBFADEARgBBADQANQB9MF0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CJwZMDsN2broPYLtjChQUP0SXpWaZXvReNZENmLRhmwQUHSk3B2Ij" + + "LOhDDVV1zCxAAQ7XjkwCAgfQ"); + + private static readonly byte[] sentrix3 = Base64.Decode( + "MIILRQIBAzCCCvEGCSqGSIb3DQEHAaCCCuIEggreMIIK2jCCAhAGCSqGSIb3" + + "DQEHAaCCAgEEggH9MIIB+TCCAfUGCyqGSIb3DQEMCgECoIIBEDCCAQwwVwYJ" + + "KoZIhvcNAQUNMEowKQYJKoZIhvcNAQUMMBwECKDaE6qqgBaCAgIH0DAMBggq" + + "hkiG9w0CCQUAMB0GCWCGSAFlAwQBKgQQ8/tQCUjOKfjw9utJiNBAXASBsHmJ" + + "/o9iTQbJFD0GsBDTyuAoqpC5l6FRr/yuAqRR9sr11qBg3qTsM7bggOjKR35D" + + "gHq1ODrrMAJQ/esG4xep6kpX7O5W1tGwTgYEQlucUI09Sel7otMJ+JNhKb+h" + + "6+9bklaNc33FOCnpuyfn/JT0xp1K4NTDIHT1XgTwRyJkaqYssINg3Hap7cyv" + + "EikgdFc/crpyXMkNwsmvavtYxaqTrLnizSiYgodrx/uMAUY/X1VEMYHRMBMG" + + "CSqGSIb3DQEJFTEGBAQBAAAAMFsGCSqGSIb3DQEJFDFOHkwAewA2AEQAQQA2" + + "AEQARQBGADAALQBFADAARQBDAC0ANAAxAEYANwAtAEEANQA2AEMALQBFADMA" + + "NQA5AEIAMgBFADEARgBBADQANQB9MF0GCSsGAQQBgjcRATFQHk4ATQBpAGMA" + + "cgBvAHMAbwBmAHQAIABTAG8AZgB0AHcAYQByAGUAIABLAGUAeQAgAFMAdABv" + + "AHIAYQBnAGUAIABQAHIAbwB2AGkAZABlAHIwggjCBgkqhkiG9w0BBwagggiz" + + "MIIIrwIBADCCCKgGCSqGSIb3DQEHATBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG" + + "9w0BBQwwHAQI5w8DkzTclKsCAgfQMAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUD" + + "BAEq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+lfZiUZ6toM+nTjMvnx/ezFu2srWGD1LLU2E" + + "KrgPzPPTd7sYT2zjegi5MHPHS7YVfoNk6svsPrkdGacPVdW3qBUkCUpveWz+" + + "65lAiGpoAybG+0NY5iSGI6oAS6lqEbI59ytUegiZfw/yCUzVorJOWT3sGx2e" + + "Jv/0GqsJzTk0Z44YGsD3oZC9vHjLqtGZFJGh4sBBFG79jz1y5yPCICczi1Ob" + + "m13RnzATdQIlHmGCgn/EYhs7L3aTuZzuouw9UF4H9/9KerDGHuTAXH91rBmM" + + "A7wbfEPa0ahVRznE6SY40mXnR4v/1OHLqR2LbQXF0yyMD3tUQU4Z5IamLETZ" + + "4czTGYe4jJ56DHoGCgUM0D7UcPYeCOkJ2dF08KGkaJK7+3m/hC5h5xeji4cZ" + + "9IWRWl5cs8Knbjj6UzzJoFhLEqAGpk2eVe/37GRBgAEYhYgVxgR6TSVjKTFr" + + "gR9SVXriBNbBtPXJ0FrnH7mB5CEvZutbWkMdUNhJScd91Hqxepigg8FLHGdk" + + "WlkyeTQKslfAbsmi9Fts662aH62av5cMAb/qNcXFDHYOaf8C9n0tj6oy3RTl" + + "3vWBaCHNElYbR5Mr7BgK4NDqf5gu2+7bznxNLQU9OEzF3fCFzk/yXBr1/jnw" + + "qp6kFDJ6juV6LOJx1GrZAMk4YYk7MbaNWrMhjMtjtgF+yULppQrm1kIS+AvL" + + "LrRKlFF/VkWHeYNsmZqLfuaYTK7sUG7lEiQJtyBzIMFJR7+4GYbgAjEbHUtU" + + "bCHLQzAOj3IyJRMBQ4nZwDpjeLQcSg6Hn36ChEEODvjgK6X6itdcpV3HUXEO" + + "I3QQrVjIwwlzb97t3amLIACawBnS6jBLMC8wCwYJYIZIAWUDBAIBBCAUXt8Q" + + "ibBrvMZx3gRniSJ3WyTswVw8Uhlh2334lHDeXwQUKbP3m3YDD6TKUgoo7yiq" + + "V71jzcoCAgfQ"); + private readonly SecureRandom Random = new SecureRandom(); /** * we generate a self signed certificate for the sake of testing - RSA @@ -925,12 +1122,44 @@ namespace Org.BouncyCastle.Pkcs.Tests stream = new MemoryStream(sentrixHard, false); store = new Pkcs12StoreBuilder().Build(); store.Load(stream, "0000".ToCharArray()); + CheckPKCS12(store); stream = new MemoryStream(sentrixSoft, false); store = new Pkcs12StoreBuilder().Build(); store.Load(stream, "0000".ToCharArray()); + CheckPKCS12(store); + + stream = new MemoryStream(sentrix1, false); + store = new Pkcs12StoreBuilder().Build(); + store.Load(stream, "0000".ToCharArray()); + CheckPKCS12(store); + + stream = new MemoryStream(sentrix2, false); + store = new Pkcs12StoreBuilder().Build(); + store.Load(stream, "0000".ToCharArray()); + CheckPKCS12(store); + + stream = new MemoryStream(sentrix3, false); + store = new Pkcs12StoreBuilder().Build(); + store.Load(stream, "0000".ToCharArray()); + CheckPKCS12(store); } + private void CheckPKCS12(Pkcs12Store store) + { + foreach (string alias in store.Aliases) + { + if (store.IsKeyEntry(alias)) + { + AsymmetricKeyEntry ent = store.GetKey(alias); + X509CertificateEntry[] crts = store.GetCertificateChain(alias); + } + else if (store.IsCertificateEntry(alias)) + { + X509CertificateEntry crt = store.GetCertificate(alias); + } + } + } private void DoTestSupportedTypes(AsymmetricKeyEntry privKey, X509CertificateEntry[] chain) { basicStoreTest(privKey, chain, @@ -1105,7 +1334,7 @@ namespace Org.BouncyCastle.Pkcs.Tests public void TestFunction() { string resultText = Perform().ToString(); - + Console.Out.WriteLine(resultText); Assert.AreEqual(Name + ": Okay", resultText); } } |