diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-27 18:49:31 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-07-27 18:49:31 +0700 |
commit | a41e9dbc22fda83c4e81e5f3c56d49b1fa124e3f (patch) | |
tree | c63951f0ed67be114833bec65256e5e03174dbe6 /crypto/src/crmf/PkiArchiveControlBuilder.cs | |
parent | Refactoring around stream calculators (diff) | |
download | BouncyCastle.NET-ed25519-a41e9dbc22fda83c4e81e5f3c56d49b1fa124e3f.tar.xz |
CMP, CRMF updates from bc-java
Diffstat (limited to 'crypto/src/crmf/PkiArchiveControlBuilder.cs')
-rw-r--r-- | crypto/src/crmf/PkiArchiveControlBuilder.cs | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/crypto/src/crmf/PkiArchiveControlBuilder.cs b/crypto/src/crmf/PkiArchiveControlBuilder.cs index d79f3b5ed..8cfa4ef19 100644 --- a/crypto/src/crmf/PkiArchiveControlBuilder.cs +++ b/crypto/src/crmf/PkiArchiveControlBuilder.cs @@ -12,8 +12,8 @@ namespace Org.BouncyCastle.Crmf { public class PkiArchiveControlBuilder { - private CmsEnvelopedDataGenerator envGen; - private CmsProcessableByteArray keyContent; + private readonly CmsEnvelopedDataGenerator m_envGen; + private readonly CmsProcessableByteArray m_keyContent; /// <summary> ///Basic constructor - specify the contents of the PKIArchiveControl structure. @@ -27,14 +27,14 @@ namespace Org.BouncyCastle.Crmf try { - this.keyContent = new CmsProcessableByteArray(CrmfObjectIdentifiers.id_ct_encKeyWithID, encKeyWithID.GetEncoded()); + m_keyContent = new CmsProcessableByteArray(CrmfObjectIdentifiers.id_ct_encKeyWithID, encKeyWithID.GetEncoded()); } catch (IOException e) { throw new InvalidOperationException("unable to encode key and general name info", e); } - this.envGen = new CmsEnvelopedDataGenerator(); + m_envGen = new CmsEnvelopedDataGenerator(); } ///<summary>Add a recipient generator to this control.</summary> @@ -42,7 +42,7 @@ namespace Org.BouncyCastle.Crmf ///<returns>this builder object.</returns> public PkiArchiveControlBuilder AddRecipientGenerator(RecipientInfoGenerator recipientGen) { - envGen.AddRecipientInfoGenerator(recipientGen); + m_envGen.AddRecipientInfoGenerator(recipientGen); return this; } @@ -51,9 +51,26 @@ namespace Org.BouncyCastle.Crmf /// <returns>a PKIArchiveControl object.</returns> public PkiArchiveControl Build(ICipherBuilderWithKey contentEncryptor) { - CmsEnvelopedData envContent = envGen.Generate(keyContent, contentEncryptor); + CmsEnvelopedData envContent = m_envGen.Generate(m_keyContent, contentEncryptor); EnvelopedData envD = EnvelopedData.GetInstance(envContent.ContentInfo.Content); return new PkiArchiveControl(new PkiArchiveOptions(new EncryptedKey(envD))); } + + // TODO[crmf] +#if false + /** + * Build the PKIArchiveControl using the passed in encryptor to encrypt its contents. + * + * @param contentEncryptor a suitable content encryptor. + * @return a PKIArchiveControl object. + * @throws CMSException in the event the build fails. + */ + public PkiArchiveControl Build(OutputEncryptor contentEncryptor) + { + CmsEnvelopedData envContent = m_envGen.Generate(m_keyContent, contentEncryptor); + EnvelopedData envD = EnvelopedData.GetInstance(envContent.ContentInfo.Content); + return new PkiArchiveControl(new PkiArchiveOptions(new EncryptedKey(envD))); + } +#endif } } |