Skip to content

Commit c5c97a3

Browse files
committed
Add UseDerForCerts, UseDerForCrls properties
- see #101
1 parent 3c6bc5b commit c5c97a3

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

crypto/src/cms/CMSSignedDataGenerator.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,15 +513,19 @@ public CmsSignedData Generate(
513513

514514
if (_certs.Count != 0)
515515
{
516-
certificates = CmsUtilities.CreateBerSetFromList(_certs);
516+
certificates = UseDerForCerts
517+
? CmsUtilities.CreateDerSetFromList(_certs)
518+
: CmsUtilities.CreateBerSetFromList(_certs);
517519
}
518520

519521
Asn1Set certrevlist = null;
520522

521523
if (_crls.Count != 0)
522524
{
523-
certrevlist = CmsUtilities.CreateBerSetFromList(_crls);
524-
}
525+
certrevlist = UseDerForCrls
526+
? CmsUtilities.CreateDerSetFromList(_crls)
527+
: CmsUtilities.CreateBerSetFromList(_crls);
528+
}
525529

526530
Asn1OctetString octs = null;
527531
if (encapsulate)

crypto/src/cms/CMSSignedDataStreamGenerator.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,14 +838,18 @@ private void DoClose()
838838

839839
if (outer._certs.Count > 0)
840840
{
841-
Asn1Set certs = CmsUtilities.CreateBerSetFromList(outer._certs);
841+
Asn1Set certs = outer.UseDerForCerts
842+
? CmsUtilities.CreateDerSetFromList(outer._certs)
843+
: CmsUtilities.CreateBerSetFromList(outer._certs);
842844

843845
WriteToGenerator(_sigGen, new BerTaggedObject(false, 0, certs));
844846
}
845847

846848
if (outer._crls.Count > 0)
847849
{
848-
Asn1Set crls = CmsUtilities.CreateBerSetFromList(outer._crls);
850+
Asn1Set crls = outer.UseDerForCrls
851+
? CmsUtilities.CreateDerSetFromList(outer._crls)
852+
: CmsUtilities.CreateBerSetFromList(outer._crls);
849853

850854
WriteToGenerator(_sigGen, new BerTaggedObject(false, 1, crls));
851855
}

crypto/src/cms/CMSSignedGenerator.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ public class CmsSignedGenerator
147147
internal IList _crls = Platform.CreateArrayList();
148148
internal IList _signers = Platform.CreateArrayList();
149149
internal IDictionary _digests = Platform.CreateHashtable();
150+
internal bool _useDerForCerts = false;
151+
internal bool _useDerForCrls = false;
150152

151153
protected readonly SecureRandom rand;
152154

@@ -251,6 +253,18 @@ public IDictionary GetGeneratedDigests()
251253
return Platform.CreateHashtable(_digests);
252254
}
253255

256+
public bool UseDerForCerts
257+
{
258+
get { return _useDerForCerts; }
259+
set { this._useDerForCerts = value; }
260+
}
261+
262+
public bool UseDerForCrls
263+
{
264+
get { return _useDerForCrls; }
265+
set { this._useDerForCrls = value; }
266+
}
267+
254268
internal virtual void AddSignerCallback(
255269
SignerInformation si)
256270
{

0 commit comments

Comments
 (0)