diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-06-29 14:07:20 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-06-29 14:07:20 +0700 |
commit | fe7d3e0009ae2ba833be66729221f42ac3aa0464 (patch) | |
tree | 7008925a5fb5a59a32fcd40ab0638a8e6888de08 /crypto/src/cms | |
parent | Refactor Asn1Dump (diff) | |
download | BouncyCastle.NET-ed25519-fe7d3e0009ae2ba833be66729221f42ac3aa0464.tar.xz |
Refactoring around Platform
Diffstat (limited to 'crypto/src/cms')
-rw-r--r-- | crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs | 45 | ||||
-rw-r--r-- | crypto/src/cms/DefaultSignedAttributeTableGenerator.cs | 2 |
2 files changed, 18 insertions, 29 deletions
diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs index 261f67a15..90ecf0748 100644 --- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs @@ -250,51 +250,40 @@ namespace Org.BouncyCastle.Cms protected override void Dispose(bool disposing) { if (disposing) - { - Platform.Dispose(_out); - - // TODO Parent context(s) should really be closed explicitly - - _eiGen.Close(); - - if (_outer.unprotectedAttributeGenerator != null) - { - Asn1.Cms.AttributeTable attrTable = _outer.unprotectedAttributeGenerator.GetAttributes(Platform.CreateHashtable()); - - Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector()); - - _envGen.AddObject(new DerTaggedObject(false, 1, unprotectedAttrs)); - } - - _envGen.Close(); - _cGen.Close(); + { + ImplClose(); } base.Dispose(disposing); } #else public override void Close() { - Platform.Dispose(_out); + ImplClose(); + base.Close(); + } +#endif + + private void ImplClose() + { + Platform.Dispose(_out); - // TODO Parent context(s) should really be closed explicitly + // TODO Parent context(s) should really be closed explicitly - _eiGen.Close(); + _eiGen.Close(); - if (_outer.unprotectedAttributeGenerator != null) - { + if (_outer.unprotectedAttributeGenerator != null) + { Asn1.Cms.AttributeTable attrTable = _outer.unprotectedAttributeGenerator.GetAttributes( new Dictionary<CmsAttributeTableParameter, object>()); - Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector()); + Asn1Set unprotectedAttrs = new BerSet(attrTable.ToAsn1EncodableVector()); - _envGen.AddObject(new DerTaggedObject(false, 1, unprotectedAttrs)); - } + _envGen.AddObject(new DerTaggedObject(false, 1, unprotectedAttrs)); + } _envGen.Close(); _cGen.Close(); - base.Close(); } -#endif } } } diff --git a/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs b/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs index e1bec484a..d8b668c4e 100644 --- a/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs +++ b/crypto/src/cms/DefaultSignedAttributeTableGenerator.cs @@ -47,7 +47,7 @@ namespace Org.BouncyCastle.Cms * * @param parameters source parameters for table generation. * - * @return a filled in Hashtable of attributes. + * @return a filled in Dictionary of attributes. */ protected virtual IDictionary<DerObjectIdentifier, object> CreateStandardAttributeTable( IDictionary<CmsAttributeTableParameter, object> parameters) |