diff options
Diffstat (limited to 'crypto/src')
59 files changed, 92 insertions, 119 deletions
diff --git a/crypto/src/asn1/Asn1EncodableVector.cs b/crypto/src/asn1/Asn1EncodableVector.cs index bf8d324ad..2bf1cf8e2 100644 --- a/crypto/src/asn1/Asn1EncodableVector.cs +++ b/crypto/src/asn1/Asn1EncodableVector.cs @@ -35,7 +35,7 @@ namespace Org.BouncyCastle.Asn1 public Asn1EncodableVector(int initialCapacity) { if (initialCapacity < 0) - throw new ArgumentException("must not be negative", "initialCapacity"); + throw new ArgumentException("must not be negative", nameof(initialCapacity)); this.elements = (initialCapacity == 0) ? EmptyElements : new Asn1Encodable[initialCapacity]; this.elementCount = 0; @@ -64,7 +64,7 @@ namespace Org.BouncyCastle.Asn1 public void Add(Asn1Encodable element) { if (null == element) - throw new ArgumentNullException("element"); + throw new ArgumentNullException(nameof(element)); int capacity = elements.Length; int minCapacity = elementCount + 1; @@ -144,7 +144,7 @@ namespace Org.BouncyCastle.Asn1 public void AddAll(Asn1EncodableVector other) { if (null == other) - throw new ArgumentNullException("other"); + throw new ArgumentNullException(nameof(other)); int otherElementCount = other.Count; if (otherElementCount < 1) @@ -182,10 +182,7 @@ namespace Org.BouncyCastle.Asn1 } } - public int Count - { - get { return elementCount; } - } + public int Count => elementCount; System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { diff --git a/crypto/src/asn1/cmp/Challenge.cs b/crypto/src/asn1/cmp/Challenge.cs index 21958da67..b86c3d800 100644 --- a/crypto/src/asn1/cmp/Challenge.cs +++ b/crypto/src/asn1/cmp/Challenge.cs @@ -111,7 +111,7 @@ namespace Org.BouncyCastle.Asn1.Cmp */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptional(m_owf); v.Add(m_witness, m_challenge); return new DerSequence(v); diff --git a/crypto/src/asn1/cmp/PKIHeaderBuilder.cs b/crypto/src/asn1/cmp/PKIHeaderBuilder.cs index ab8db958a..6c7a2db63 100644 --- a/crypto/src/asn1/cmp/PKIHeaderBuilder.cs +++ b/crypto/src/asn1/cmp/PKIHeaderBuilder.cs @@ -126,26 +126,14 @@ namespace Org.BouncyCastle.Asn1.Cmp return this; } - private static Asn1Sequence MakeGeneralInfoSeq( - InfoTypeAndValue generalInfo) + private static Asn1Sequence MakeGeneralInfoSeq(InfoTypeAndValue generalInfo) { return new DerSequence(generalInfo); } - - private static Asn1Sequence MakeGeneralInfoSeq( - InfoTypeAndValue[] generalInfos) - { - Asn1Sequence genInfoSeq = null; - if (generalInfos != null) - { - Asn1EncodableVector v = new Asn1EncodableVector(); - for (int i = 0; i < generalInfos.Length; ++i) - { - v.Add(generalInfos[i]); - } - genInfoSeq = new DerSequence(v); - } - return genInfoSeq; + + private static Asn1Sequence MakeGeneralInfoSeq(InfoTypeAndValue[] generalInfos) + { + return generalInfos == null ? null : new DerSequence(generalInfos); } /** diff --git a/crypto/src/asn1/cmp/RevRepContentBuilder.cs b/crypto/src/asn1/cmp/RevRepContentBuilder.cs index f23bed8b5..4ff85483e 100644 --- a/crypto/src/asn1/cmp/RevRepContentBuilder.cs +++ b/crypto/src/asn1/cmp/RevRepContentBuilder.cs @@ -35,7 +35,7 @@ namespace Org.BouncyCastle.Asn1.Cmp public virtual RevRepContent Build() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); v.Add(new DerSequence(m_status)); diff --git a/crypto/src/asn1/cms/OriginatorInfo.cs b/crypto/src/asn1/cms/OriginatorInfo.cs index 23acc2d9f..c11e01dfe 100644 --- a/crypto/src/asn1/cms/OriginatorInfo.cs +++ b/crypto/src/asn1/cms/OriginatorInfo.cs @@ -103,7 +103,7 @@ namespace Org.BouncyCastle.Asn1.Cms */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptionalTagged(false, 0, certs); v.AddOptionalTagged(false, 1, crls); return new DerSequence(v); diff --git a/crypto/src/asn1/cms/SCVPReqRes.cs b/crypto/src/asn1/cms/SCVPReqRes.cs index a6ebf7302..6544c852b 100644 --- a/crypto/src/asn1/cms/SCVPReqRes.cs +++ b/crypto/src/asn1/cms/SCVPReqRes.cs @@ -62,7 +62,7 @@ namespace Org.BouncyCastle.Asn1.Cms */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptionalTagged(true, 0, request); v.Add(response); return new DerSequence(v); diff --git a/crypto/src/asn1/crmf/CertTemplateBuilder.cs b/crypto/src/asn1/crmf/CertTemplateBuilder.cs index d26e6399c..a69e3beeb 100644 --- a/crypto/src/asn1/crmf/CertTemplateBuilder.cs +++ b/crypto/src/asn1/crmf/CertTemplateBuilder.cs @@ -98,7 +98,7 @@ namespace Org.BouncyCastle.Asn1.Crmf */ public virtual CertTemplate Build() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(10); v.AddOptionalTagged(false, 0, version); v.AddOptionalTagged(false, 1, serialNumber); v.AddOptionalTagged(false, 2, signingAlg); diff --git a/crypto/src/asn1/crmf/EncryptedValue.cs b/crypto/src/asn1/crmf/EncryptedValue.cs index 950298504..05a96fd37 100644 --- a/crypto/src/asn1/crmf/EncryptedValue.cs +++ b/crypto/src/asn1/crmf/EncryptedValue.cs @@ -104,7 +104,7 @@ namespace Org.BouncyCastle.Asn1.Crmf */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(6); v.AddOptionalTagged(false, 0, m_intendedAlg); v.AddOptionalTagged(false, 1, m_symmAlg); v.AddOptionalTagged(false, 2, m_encSymmKey); diff --git a/crypto/src/asn1/crmf/OptionalValidity.cs b/crypto/src/asn1/crmf/OptionalValidity.cs index d608ea5d1..722705232 100644 --- a/crypto/src/asn1/crmf/OptionalValidity.cs +++ b/crypto/src/asn1/crmf/OptionalValidity.cs @@ -59,7 +59,7 @@ namespace Org.BouncyCastle.Asn1.Crmf */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptionalTagged(true, 0, notBefore); v.AddOptionalTagged(true, 1, notAfter); return new DerSequence(v); diff --git a/crypto/src/asn1/crmf/PopoSigningKey.cs b/crypto/src/asn1/crmf/PopoSigningKey.cs index 11e735415..93e14e30d 100644 --- a/crypto/src/asn1/crmf/PopoSigningKey.cs +++ b/crypto/src/asn1/crmf/PopoSigningKey.cs @@ -100,7 +100,7 @@ namespace Org.BouncyCastle.Asn1.Crmf */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); v.AddOptionalTagged(false, 0, poposkInput); v.Add(algorithmIdentifier); v.Add(signature); diff --git a/crypto/src/asn1/crmf/PopoSigningKeyInput.cs b/crypto/src/asn1/crmf/PopoSigningKeyInput.cs index e43fa138e..30d017475 100644 --- a/crypto/src/asn1/crmf/PopoSigningKeyInput.cs +++ b/crypto/src/asn1/crmf/PopoSigningKeyInput.cs @@ -97,7 +97,7 @@ namespace Org.BouncyCastle.Asn1.Crmf */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); if (sender != null) { diff --git a/crypto/src/asn1/esf/CrlOcspRef.cs b/crypto/src/asn1/esf/CrlOcspRef.cs index 6153e0c53..6f55ff057 100644 --- a/crypto/src/asn1/esf/CrlOcspRef.cs +++ b/crypto/src/asn1/esf/CrlOcspRef.cs @@ -90,7 +90,7 @@ namespace Org.BouncyCastle.Asn1.Esf public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); if (crlids != null) { diff --git a/crypto/src/asn1/esf/RevocationValues.cs b/crypto/src/asn1/esf/RevocationValues.cs index 61bfd0be1..f3b36f1d1 100644 --- a/crypto/src/asn1/esf/RevocationValues.cs +++ b/crypto/src/asn1/esf/RevocationValues.cs @@ -119,7 +119,7 @@ namespace Org.BouncyCastle.Asn1.Esf public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); v.AddOptionalTagged(true, 0, m_crlVals); v.AddOptionalTagged(true, 1, m_ocspVals); diff --git a/crypto/src/asn1/esf/SignerAttribute.cs b/crypto/src/asn1/esf/SignerAttribute.cs index 39bd910b2..f90968cf8 100644 --- a/crypto/src/asn1/esf/SignerAttribute.cs +++ b/crypto/src/asn1/esf/SignerAttribute.cs @@ -80,18 +80,9 @@ namespace Org.BouncyCastle.Asn1.Esf */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); - - if (claimedAttributes != null) - { - v.Add(new DerTaggedObject(0, claimedAttributes)); - } - else - { - v.Add(new DerTaggedObject(1, certifiedAttributes)); - } - - return new DerSequence(v); + return claimedAttributes != null + ? new DerSequence(new DerTaggedObject(0, claimedAttributes)) + : new DerSequence(new DerTaggedObject(1, certifiedAttributes)); } } } diff --git a/crypto/src/asn1/ess/ContentHints.cs b/crypto/src/asn1/ess/ContentHints.cs index 81ba0a1fe..f61bf0df8 100644 --- a/crypto/src/asn1/ess/ContentHints.cs +++ b/crypto/src/asn1/ess/ContentHints.cs @@ -79,7 +79,7 @@ namespace Org.BouncyCastle.Asn1.Ess */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptional(contentDescription); v.Add(contentType); return new DerSequence(v); diff --git a/crypto/src/asn1/ess/ESSCertIDv2.cs b/crypto/src/asn1/ess/ESSCertIDv2.cs index 1711a769c..b3d49ceb5 100644 --- a/crypto/src/asn1/ess/ESSCertIDv2.cs +++ b/crypto/src/asn1/ess/ESSCertIDv2.cs @@ -125,7 +125,7 @@ namespace Org.BouncyCastle.Asn1.Ess */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); if (!hashAlgorithm.Equals(DefaultAlgID)) { diff --git a/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs b/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs index a45075ee4..eac5d9a1a 100644 --- a/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs +++ b/crypto/src/asn1/isismtt/x509/AdmissionSyntax.cs @@ -243,7 +243,7 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptional(admissionAuthority); v.Add(contentsOfAdmissions); return new DerSequence(v); diff --git a/crypto/src/asn1/isismtt/x509/Admissions.cs b/crypto/src/asn1/isismtt/x509/Admissions.cs index 1ade6093f..57c5a6183 100644 --- a/crypto/src/asn1/isismtt/x509/Admissions.cs +++ b/crypto/src/asn1/isismtt/x509/Admissions.cs @@ -160,7 +160,7 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); v.AddOptionalTagged(true, 0, admissionAuthority); v.AddOptionalTagged(true, 1, namingAuthority); v.Add(professionInfos); diff --git a/crypto/src/asn1/isismtt/x509/NamingAuthority.cs b/crypto/src/asn1/isismtt/x509/NamingAuthority.cs index 78ef25654..3c3f0a5f5 100644 --- a/crypto/src/asn1/isismtt/x509/NamingAuthority.cs +++ b/crypto/src/asn1/isismtt/x509/NamingAuthority.cs @@ -187,7 +187,7 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); v.AddOptional(namingAuthorityID); if (namingAuthorityUrl != null) diff --git a/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs b/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs index 23be2d388..2fb7323c6 100644 --- a/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs +++ b/crypto/src/asn1/isismtt/x509/ProcurationSyntax.cs @@ -202,7 +202,7 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); if (country != null) { diff --git a/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs b/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs index daa76730d..32ad31d9a 100644 --- a/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs +++ b/crypto/src/asn1/isismtt/x509/ProfessionInfo.cs @@ -296,7 +296,7 @@ namespace Org.BouncyCastle.Asn1.IsisMtt.X509 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(5); v.AddOptionalTagged(true, 0, namingAuthority); v.Add(professionItems); v.AddOptional(professionOids); diff --git a/crypto/src/asn1/misc/IDEACBCPar.cs b/crypto/src/asn1/misc/IDEACBCPar.cs index 9ae9f6faf..96bfb89b0 100644 --- a/crypto/src/asn1/misc/IDEACBCPar.cs +++ b/crypto/src/asn1/misc/IDEACBCPar.cs @@ -55,9 +55,9 @@ namespace Org.BouncyCastle.Asn1.Misc */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); - v.AddOptional(iv); - return new DerSequence(v); + return iv != null + ? new DerSequence(iv) + : DerSequence.Empty; } } } diff --git a/crypto/src/asn1/nist/KMACwithSHAKE128_params.cs b/crypto/src/asn1/nist/KMACwithSHAKE128_params.cs index a1fd8f403..df2bf0173 100644 --- a/crypto/src/asn1/nist/KMACwithSHAKE128_params.cs +++ b/crypto/src/asn1/nist/KMACwithSHAKE128_params.cs @@ -86,7 +86,7 @@ public class KMacWithShake128Params : Asn1Encodable public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); if (outputLength != DEF_LENGTH) { v.Add(new DerInteger(outputLength)); diff --git a/crypto/src/asn1/nist/KMACwithSHAKE256_params.cs b/crypto/src/asn1/nist/KMACwithSHAKE256_params.cs index f0560e9da..dfdfb2c36 100644 --- a/crypto/src/asn1/nist/KMACwithSHAKE256_params.cs +++ b/crypto/src/asn1/nist/KMACwithSHAKE256_params.cs @@ -85,7 +85,7 @@ public class KMacWithShake256Params : Asn1Encodable public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); if (outputLength != DEF_LENGTH) { v.Add(new DerInteger(outputLength)); diff --git a/crypto/src/asn1/ocsp/CrlID.cs b/crypto/src/asn1/ocsp/CrlID.cs index 8736b83ab..7a4172c57 100644 --- a/crypto/src/asn1/ocsp/CrlID.cs +++ b/crypto/src/asn1/ocsp/CrlID.cs @@ -73,7 +73,7 @@ namespace Org.BouncyCastle.Asn1.Ocsp */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); v.AddOptionalTagged(true, 0, crlUrl); v.AddOptionalTagged(true, 1, crlNum); v.AddOptionalTagged(true, 2, crlTime); diff --git a/crypto/src/asn1/ocsp/ResponseData.cs b/crypto/src/asn1/ocsp/ResponseData.cs index dfb234bc1..b18e1d623 100644 --- a/crypto/src/asn1/ocsp/ResponseData.cs +++ b/crypto/src/asn1/ocsp/ResponseData.cs @@ -138,7 +138,7 @@ namespace Org.BouncyCastle.Asn1.Ocsp */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); if (versionPresent || !version.Equals(V1)) { diff --git a/crypto/src/asn1/ocsp/TBSRequest.cs b/crypto/src/asn1/ocsp/TBSRequest.cs index 0166c5342..fd5f153d7 100644 --- a/crypto/src/asn1/ocsp/TBSRequest.cs +++ b/crypto/src/asn1/ocsp/TBSRequest.cs @@ -122,7 +122,7 @@ namespace Org.BouncyCastle.Asn1.Ocsp */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(4); // // if default don't include - unless explicitly provided. Not strictly correct diff --git a/crypto/src/asn1/pkcs/RC2CBCParameter.cs b/crypto/src/asn1/pkcs/RC2CBCParameter.cs index 48591f2e9..c1f09a088 100644 --- a/crypto/src/asn1/pkcs/RC2CBCParameter.cs +++ b/crypto/src/asn1/pkcs/RC2CBCParameter.cs @@ -65,7 +65,7 @@ namespace Org.BouncyCastle.Asn1.Pkcs public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptional(version); v.Add(iv); return new DerSequence(v); diff --git a/crypto/src/asn1/pkcs/RSAESOAEPparams.cs b/crypto/src/asn1/pkcs/RSAESOAEPparams.cs index 2419e33c7..988b230c8 100644 --- a/crypto/src/asn1/pkcs/RSAESOAEPparams.cs +++ b/crypto/src/asn1/pkcs/RSAESOAEPparams.cs @@ -128,7 +128,7 @@ namespace Org.BouncyCastle.Asn1.Pkcs */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); if (!hashAlgorithm.Equals(DefaultHashAlgorithm)) { diff --git a/crypto/src/asn1/pkcs/RSASSAPSSparams.cs b/crypto/src/asn1/pkcs/RSASSAPSSparams.cs index 85849c362..e5800993f 100644 --- a/crypto/src/asn1/pkcs/RSASSAPSSparams.cs +++ b/crypto/src/asn1/pkcs/RSASSAPSSparams.cs @@ -138,7 +138,7 @@ namespace Org.BouncyCastle.Asn1.Pkcs */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(4); if (!hashAlgorithm.Equals(DefaultHashAlgorithm)) { diff --git a/crypto/src/asn1/tsp/Accuracy.cs b/crypto/src/asn1/tsp/Accuracy.cs index 0cbc731ac..0d64e2dd4 100644 --- a/crypto/src/asn1/tsp/Accuracy.cs +++ b/crypto/src/asn1/tsp/Accuracy.cs @@ -110,7 +110,7 @@ namespace Org.BouncyCastle.Asn1.Tsp */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); v.AddOptional(seconds); v.AddOptionalTagged(false, 0, millis); v.AddOptionalTagged(false, 1, micros); diff --git a/crypto/src/asn1/x509/AuthorityKeyIdentifier.cs b/crypto/src/asn1/x509/AuthorityKeyIdentifier.cs index 64cfce214..810fda82e 100644 --- a/crypto/src/asn1/x509/AuthorityKeyIdentifier.cs +++ b/crypto/src/asn1/x509/AuthorityKeyIdentifier.cs @@ -166,7 +166,7 @@ namespace Org.BouncyCastle.Asn1.X509 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); v.AddOptionalTagged(false, 0, keyidentifier); v.AddOptionalTagged(false, 1, certissuer); v.AddOptionalTagged(false, 2, certserno); diff --git a/crypto/src/asn1/x509/CertificatePair.cs b/crypto/src/asn1/x509/CertificatePair.cs index 69861e1dc..055144464 100644 --- a/crypto/src/asn1/x509/CertificatePair.cs +++ b/crypto/src/asn1/x509/CertificatePair.cs @@ -128,7 +128,7 @@ namespace Org.BouncyCastle.Asn1.X509 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptionalTagged(true, 0, forward); v.AddOptionalTagged(true, 1, reverse); return new DerSequence(v); diff --git a/crypto/src/asn1/x509/IetfAttrSyntax.cs b/crypto/src/asn1/x509/IetfAttrSyntax.cs index 61fe78561..024c8dd68 100644 --- a/crypto/src/asn1/x509/IetfAttrSyntax.cs +++ b/crypto/src/asn1/x509/IetfAttrSyntax.cs @@ -143,7 +143,7 @@ namespace Org.BouncyCastle.Asn1.X509 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptionalTagged(true, 0, policyAuthority); v.Add(new DerSequence(values)); return new DerSequence(v); diff --git a/crypto/src/asn1/x509/IssuingDistributionPoint.cs b/crypto/src/asn1/x509/IssuingDistributionPoint.cs index 0287fd8f5..8ae4cafa0 100644 --- a/crypto/src/asn1/x509/IssuingDistributionPoint.cs +++ b/crypto/src/asn1/x509/IssuingDistributionPoint.cs @@ -70,7 +70,7 @@ namespace Org.BouncyCastle.Asn1.X509 this._onlyContainsUserCerts = onlyContainsUserCerts; this._onlySomeReasons = onlySomeReasons; - Asn1EncodableVector vec = new Asn1EncodableVector(); + Asn1EncodableVector vec = new Asn1EncodableVector(6); if (distributionPoint != null) { // CHOICE item so explicitly tagged vec.Add(new DerTaggedObject(true, 0, distributionPoint)); diff --git a/crypto/src/asn1/x509/NoticeReference.cs b/crypto/src/asn1/x509/NoticeReference.cs index 98a64ec55..2fb275d8f 100644 --- a/crypto/src/asn1/x509/NoticeReference.cs +++ b/crypto/src/asn1/x509/NoticeReference.cs @@ -28,7 +28,7 @@ namespace Org.BouncyCastle.Asn1.X509 private static Asn1EncodableVector ConvertVector(IList<object> numbers) { - Asn1EncodableVector av = new Asn1EncodableVector(); + Asn1EncodableVector av = new Asn1EncodableVector(numbers.Count); foreach (object o in numbers) { diff --git a/crypto/src/asn1/x509/PolicyMappings.cs b/crypto/src/asn1/x509/PolicyMappings.cs index a077f2059..01a6ae88f 100644 --- a/crypto/src/asn1/x509/PolicyMappings.cs +++ b/crypto/src/asn1/x509/PolicyMappings.cs @@ -38,7 +38,7 @@ namespace Org.BouncyCastle.Asn1.X509 */ public PolicyMappings(IDictionary<string, string> mappings) { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(mappings.Count); foreach (var entry in mappings) { diff --git a/crypto/src/asn1/x509/PrivateKeyUsagePeriod.cs b/crypto/src/asn1/x509/PrivateKeyUsagePeriod.cs index a87c2ee9e..2ca1557bc 100644 --- a/crypto/src/asn1/x509/PrivateKeyUsagePeriod.cs +++ b/crypto/src/asn1/x509/PrivateKeyUsagePeriod.cs @@ -66,7 +66,7 @@ namespace Org.BouncyCastle.Asn1.X509 public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptionalTagged(false, 0, _notBefore); v.AddOptionalTagged(false, 1, _notAfter); return new DerSequence(v); diff --git a/crypto/src/asn1/x509/RoleSyntax.cs b/crypto/src/asn1/x509/RoleSyntax.cs index b5b217b6b..163b3d07e 100644 --- a/crypto/src/asn1/x509/RoleSyntax.cs +++ b/crypto/src/asn1/x509/RoleSyntax.cs @@ -192,7 +192,7 @@ namespace Org.BouncyCastle.Asn1.X509 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptionalTagged(false, 0, roleAuthority); v.Add(new DerTaggedObject(true, 1, roleName)); return new DerSequence(v); diff --git a/crypto/src/asn1/x509/TBSCertificateStructure.cs b/crypto/src/asn1/x509/TBSCertificateStructure.cs index bd08d8bb8..5e3bf2601 100644 --- a/crypto/src/asn1/x509/TBSCertificateStructure.cs +++ b/crypto/src/asn1/x509/TBSCertificateStructure.cs @@ -216,7 +216,7 @@ namespace Org.BouncyCastle.Asn1.X509 if (null == property || Platform.EqualsIgnoreCase("true", property)) return seq; - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(8); // DEFAULT Zero if (!version.HasValue(0)) diff --git a/crypto/src/asn1/x509/UserNotice.cs b/crypto/src/asn1/x509/UserNotice.cs index 801ca0ded..c9a5e5309 100644 --- a/crypto/src/asn1/x509/UserNotice.cs +++ b/crypto/src/asn1/x509/UserNotice.cs @@ -101,7 +101,7 @@ namespace Org.BouncyCastle.Asn1.X509 public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptional(noticeRef, explicitText); return new DerSequence(v); } diff --git a/crypto/src/asn1/x509/V2Form.cs b/crypto/src/asn1/x509/V2Form.cs index 53475ffbe..ca1b75095 100644 --- a/crypto/src/asn1/x509/V2Form.cs +++ b/crypto/src/asn1/x509/V2Form.cs @@ -114,7 +114,7 @@ namespace Org.BouncyCastle.Asn1.X509 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); v.AddOptional(issuerName); v.AddOptionalTagged(false, 0, baseCertificateID); v.AddOptionalTagged(false, 1, objectDigestInfo); diff --git a/crypto/src/asn1/x509/qualified/SemanticsInformation.cs b/crypto/src/asn1/x509/qualified/SemanticsInformation.cs index 23818e916..1106e10b1 100644 --- a/crypto/src/asn1/x509/qualified/SemanticsInformation.cs +++ b/crypto/src/asn1/x509/qualified/SemanticsInformation.cs @@ -104,7 +104,7 @@ namespace Org.BouncyCastle.Asn1.X509.Qualified public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.AddOptional(semanticsIdentifier); if (null != nameRegistrationAuthorities) diff --git a/crypto/src/asn1/x9/X9Curve.cs b/crypto/src/asn1/x9/X9Curve.cs index 88198335f..568bcb316 100644 --- a/crypto/src/asn1/x9/X9Curve.cs +++ b/crypto/src/asn1/x9/X9Curve.cs @@ -127,7 +127,7 @@ namespace Org.BouncyCastle.Asn1.X9 */ public override Asn1Object ToAsn1Object() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(3); if (fieldIdentifier.Equals(X9ObjectIdentifiers.PrimeField) || fieldIdentifier.Equals(X9ObjectIdentifiers.CharacteristicTwoField)) diff --git a/crypto/src/cmp/CertificateConfirmationContentBuilder.cs b/crypto/src/cmp/CertificateConfirmationContentBuilder.cs index fa7e5a897..09ae71bbf 100644 --- a/crypto/src/cmp/CertificateConfirmationContentBuilder.cs +++ b/crypto/src/cmp/CertificateConfirmationContentBuilder.cs @@ -39,7 +39,7 @@ namespace Org.BouncyCastle.Cmp public CertificateConfirmationContent Build() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(m_acceptedCerts.Count); for (int i = 0; i != m_acceptedCerts.Count; i++) { X509Certificate cert = m_acceptedCerts[i]; diff --git a/crypto/src/cms/CMSAuthenticatedDataGenerator.cs b/crypto/src/cms/CMSAuthenticatedDataGenerator.cs index 95e710c9b..9f6815161 100644 --- a/crypto/src/cms/CMSAuthenticatedDataGenerator.cs +++ b/crypto/src/cms/CMSAuthenticatedDataGenerator.cs @@ -94,7 +94,7 @@ namespace Org.BouncyCastle.Cms throw new CmsException("exception decoding algorithm parameters.", e); } - var recipientInfos = new Asn1EncodableVector(); + var recipientInfos = new Asn1EncodableVector(recipientInfoGenerators.Count); foreach (RecipientInfoGenerator rig in recipientInfoGenerators) { @@ -111,13 +111,13 @@ namespace Org.BouncyCastle.Cms throw new CmsException("error making encrypted content.", e); } } - + var eci = new ContentInfo(CmsObjectIdentifiers.Data, encContent); var contentInfo = new ContentInfo( CmsObjectIdentifiers.AuthenticatedData, new AuthenticatedData(null, new DerSet(recipientInfos), macAlgId, null, eci, null, macResult, null)); - + return new CmsAuthenticatedData(contentInfo); } diff --git a/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs b/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs index 054a9c45e..d3f65af7a 100644 --- a/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSAuthenticatedDataStreamGenerator.cs @@ -93,7 +93,7 @@ namespace Org.BouncyCastle.Cms AlgorithmIdentifier macAlgId = GetAlgorithmIdentifier( macOid, encKey, asn1Params, out cipherParameters); - Asn1EncodableVector recipientInfos = new Asn1EncodableVector(); + Asn1EncodableVector recipientInfos = new Asn1EncodableVector(recipientInfoGenerators.Count); foreach (RecipientInfoGenerator rig in recipientInfoGenerators) { diff --git a/crypto/src/cms/CMSEnvelopedDataGenerator.cs b/crypto/src/cms/CMSEnvelopedDataGenerator.cs index d2cd18885..62fff7412 100644 --- a/crypto/src/cms/CMSEnvelopedDataGenerator.cs +++ b/crypto/src/cms/CMSEnvelopedDataGenerator.cs @@ -88,7 +88,7 @@ namespace Org.BouncyCastle.Cms } - Asn1EncodableVector recipientInfos = new Asn1EncodableVector(); + Asn1EncodableVector recipientInfos = new Asn1EncodableVector(recipientInfoGenerators.Count); foreach (RecipientInfoGenerator rig in recipientInfoGenerators) { @@ -180,7 +180,7 @@ namespace Org.BouncyCastle.Cms } - Asn1EncodableVector recipientInfos = new Asn1EncodableVector(); + Asn1EncodableVector recipientInfos = new Asn1EncodableVector(recipientInfoGenerators.Count); foreach (RecipientInfoGenerator rig in recipientInfoGenerators) { diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs index 64d501a41..48fe2eccc 100644 --- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs @@ -97,7 +97,7 @@ namespace Org.BouncyCastle.Cms AlgorithmIdentifier encAlgID = GetAlgorithmIdentifier( encryptionOid, encKey, asn1Params, out cipherParameters); - Asn1EncodableVector recipientInfos = new Asn1EncodableVector(); + Asn1EncodableVector recipientInfos = new Asn1EncodableVector(recipientInfoGenerators.Count); foreach (RecipientInfoGenerator rig in recipientInfoGenerators) { diff --git a/crypto/src/cms/CMSSignedData.cs b/crypto/src/cms/CMSSignedData.cs index 10278784e..5a73df4f1 100644 --- a/crypto/src/cms/CMSSignedData.cs +++ b/crypto/src/cms/CMSSignedData.cs @@ -276,10 +276,10 @@ namespace Org.BouncyCastle.Cms // // replace the signers in the SignedData object // - Asn1EncodableVector digestAlgs = new Asn1EncodableVector(); - Asn1EncodableVector vec = new Asn1EncodableVector(); - - foreach (SignerInformation signer in signerInformationStore.GetSigners()) + var storeSigners = signerInformationStore.GetSigners(); + Asn1EncodableVector digestAlgs = new Asn1EncodableVector(storeSigners.Count); + Asn1EncodableVector vec = new Asn1EncodableVector(storeSigners.Count); + foreach (SignerInformation signer in storeSigners) { digestAlgs.Add(Helper.FixAlgID(signer.DigestAlgorithmID)); vec.Add(signer.ToSignerInfo()); @@ -292,9 +292,9 @@ namespace Org.BouncyCastle.Cms // // signers are the last item in the sequence. // - vec = new Asn1EncodableVector( - sD[0], // version - digests); + vec = new Asn1EncodableVector(sD.Count); + vec.Add(sD[0]); // version + vec.Add(digests); for (int i = 2; i != sD.Count - 1; i++) { diff --git a/crypto/src/cms/CMSSignedDataStreamGenerator.cs b/crypto/src/cms/CMSSignedDataStreamGenerator.cs index 48abfbfa2..4883fc3f9 100644 --- a/crypto/src/cms/CMSSignedDataStreamGenerator.cs +++ b/crypto/src/cms/CMSSignedDataStreamGenerator.cs @@ -556,7 +556,7 @@ namespace Org.BouncyCastle.Cms sigGen.AddObject(CalculateVersion(contentTypeOid)); - Asn1EncodableVector digestAlgs = new Asn1EncodableVector(); + Asn1EncodableVector digestAlgs = new Asn1EncodableVector(_messageDigestOids.Count); foreach (string digestOid in _messageDigestOids) { diff --git a/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs b/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs index 8feb25b43..6bcba0d80 100644 --- a/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs +++ b/crypto/src/cms/KeyAgreeRecipientInfoGenerator.cs @@ -108,7 +108,7 @@ namespace Org.BouncyCastle.Cms DerSequence paramSeq = new DerSequence(m_keyEncryptionOid, DerNull.Instance); AlgorithmIdentifier keyEncAlg = new AlgorithmIdentifier(m_keyAgreementOid, paramSeq); - Asn1EncodableVector recipientEncryptedKeys = new Asn1EncodableVector(); + Asn1EncodableVector recipientEncryptedKeys = new Asn1EncodableVector(m_recipientIDs.Count); for (int i = 0; i < m_recipientIDs.Count; ++i) { var recipientID = m_recipientIDs[i]; diff --git a/crypto/src/cms/SignerInformation.cs b/crypto/src/cms/SignerInformation.cs index 4e21b1246..2e32a3ae6 100644 --- a/crypto/src/cms/SignerInformation.cs +++ b/crypto/src/cms/SignerInformation.cs @@ -784,12 +784,12 @@ namespace Org.BouncyCastle.Cms } else { - v = new Asn1EncodableVector(); + v = new Asn1EncodableVector(1); } - Asn1EncodableVector sigs = new Asn1EncodableVector(); - - foreach (SignerInformation sigInf in counterSigners.GetSigners()) + var signers = counterSigners.GetSigners(); + Asn1EncodableVector sigs = new Asn1EncodableVector(signers.Count); + foreach (SignerInformation sigInf in signers) { sigs.Add(sigInf.ToSignerInfo()); } diff --git a/crypto/src/crmf/CertificateRequestMessageBuilder.cs b/crypto/src/crmf/CertificateRequestMessageBuilder.cs index d09084fb3..dc5bc6224 100644 --- a/crypto/src/crmf/CertificateRequestMessageBuilder.cs +++ b/crypto/src/crmf/CertificateRequestMessageBuilder.cs @@ -201,7 +201,7 @@ namespace Org.BouncyCastle.Crmf if (m_controls.Count > 0) { - Asn1EncodableVector controlV = new Asn1EncodableVector(); + Asn1EncodableVector controlV = new Asn1EncodableVector(m_controls.Count); foreach (var control in m_controls) { diff --git a/crypto/src/pkcs/Pkcs12Store.cs b/crypto/src/pkcs/Pkcs12Store.cs index 9cb81a412..aede1653a 100644 --- a/crypto/src/pkcs/Pkcs12Store.cs +++ b/crypto/src/pkcs/Pkcs12Store.cs @@ -649,7 +649,7 @@ namespace Org.BouncyCastle.Pkcs // // handle the keys // - Asn1EncodableVector keyBags = new Asn1EncodableVector(); + Asn1EncodableVector keyBags = new Asn1EncodableVector(m_keys.Count); foreach (var keyEntry in m_keys) { var name = keyEntry.Key; @@ -732,7 +732,7 @@ namespace Org.BouncyCastle.Pkcs random.NextBytes(cSalt); - Asn1EncodableVector certBags = new Asn1EncodableVector(); + Asn1EncodableVector certBags = new Asn1EncodableVector(m_keys.Count); Pkcs12PbeParams cParams = new Pkcs12PbeParams(cSalt, MinIterations); AlgorithmIdentifier cAlgId = new AlgorithmIdentifier(certAlgorithm, cParams.ToAsn1Object()); var doneCerts = new HashSet<X509Certificate>(); @@ -836,8 +836,8 @@ namespace Org.BouncyCastle.Pkcs if (ext != null) { ExtendedKeyUsage usage = ExtendedKeyUsage.GetInstance(ext.GetOctets()); - Asn1EncodableVector v = new Asn1EncodableVector(); IList<DerObjectIdentifier> usages = usage.GetAllUsages(); + Asn1EncodableVector v = new Asn1EncodableVector(usages.Count); for (int i = 0; i != usages.Count; i++) { v.Add(usages[i]); diff --git a/crypto/src/pqc/asn1/CmcePrivateKey.cs b/crypto/src/pqc/asn1/CmcePrivateKey.cs index c6ba33352..743b801f5 100644 --- a/crypto/src/pqc/asn1/CmcePrivateKey.cs +++ b/crypto/src/pqc/asn1/CmcePrivateKey.cs @@ -18,6 +18,7 @@ using Org.BouncyCastle.Utilities; // </pre> namespace Org.BouncyCastle.Pqc.Asn1 { + // TODO[api] Should only be Asn1Encodable public class CmcePrivateKey : Asn1Object { @@ -84,7 +85,7 @@ namespace Org.BouncyCastle.Pqc.Asn1 public Asn1Object ToAsn1Primitive() { - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(7); v.Add(new DerInteger(version)); v.Add(new DerOctetString(delta)); @@ -94,9 +95,9 @@ namespace Org.BouncyCastle.Pqc.Asn1 v.Add(new DerOctetString(s)); // todo optional publickey - if(PublicKey != null) + if (publicKey != null) { - v.Add(new CmcePublicKey(PublicKey.T)); + v.Add(new CmcePublicKey(publicKey.T)); } return new DerSequence(v); diff --git a/crypto/src/pqc/asn1/CmcePublicKey.cs b/crypto/src/pqc/asn1/CmcePublicKey.cs index 1e417c5df..00a2afe19 100644 --- a/crypto/src/pqc/asn1/CmcePublicKey.cs +++ b/crypto/src/pqc/asn1/CmcePublicKey.cs @@ -4,6 +4,7 @@ using Org.BouncyCastle.Utilities; namespace Org.BouncyCastle.Pqc.Asn1 { + // TODO[api] Should only be Asn1Encodable public class CmcePublicKey : Asn1Object { @@ -23,9 +24,7 @@ namespace Org.BouncyCastle.Pqc.Asn1 public Asn1Object ToAsn1Primitive() { - Asn1EncodableVector v = new Asn1EncodableVector(); - v.Add(new DerOctetString(t)); - return new DerSequence(v); + return new DerSequence(new DerOctetString(t)); } public static CmcePublicKey GetInstance(Object o) diff --git a/crypto/src/pqc/crypto/utils/PqcPrivateKeyInfoFactory.cs b/crypto/src/pqc/crypto/utils/PqcPrivateKeyInfoFactory.cs index ce0300cf4..3d1b1b679 100644 --- a/crypto/src/pqc/crypto/utils/PqcPrivateKeyInfoFactory.cs +++ b/crypto/src/pqc/crypto/utils/PqcPrivateKeyInfoFactory.cs @@ -105,8 +105,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Utilities #pragma warning restore CS0618 // Type or member is obsolete if (privateKey is FalconPrivateKeyParameters falconPrivateKeyParameters) { - Asn1EncodableVector v = new Asn1EncodableVector(); - + Asn1EncodableVector v = new Asn1EncodableVector(4); v.Add(new DerInteger(1)); v.Add(new DerOctetString(falconPrivateKeyParameters.GetSpolyLittleF())); v.Add(new DerOctetString(falconPrivateKeyParameters.GetG())); @@ -120,8 +119,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Utilities } if (privateKey is KyberPrivateKeyParameters kyberPrivateKeyParameters) { - Asn1EncodableVector v = new Asn1EncodableVector(); - + Asn1EncodableVector v = new Asn1EncodableVector(4); v.Add(new DerInteger(0)); v.Add(new DerOctetString(kyberPrivateKeyParameters.S)); v.Add(new DerOctetString(kyberPrivateKeyParameters.Hpk)); @@ -130,7 +128,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Utilities AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier( PqcUtilities.KyberOidLookup(kyberPrivateKeyParameters.Parameters)); - Asn1EncodableVector vPub = new Asn1EncodableVector(); + Asn1EncodableVector vPub = new Asn1EncodableVector(2); vPub.Add(new DerOctetString(kyberPrivateKeyParameters.T)); vPub.Add(new DerOctetString(kyberPrivateKeyParameters.Rho)); @@ -139,8 +137,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Utilities } if (privateKey is DilithiumPrivateKeyParameters dilithiumPrivateKeyParameters) { - Asn1EncodableVector v = new Asn1EncodableVector(); - + Asn1EncodableVector v = new Asn1EncodableVector(7); v.Add(new DerInteger(0)); v.Add(new DerBitString(dilithiumPrivateKeyParameters.Rho)); v.Add(new DerBitString(dilithiumPrivateKeyParameters.K)); @@ -152,7 +149,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Utilities AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier( PqcUtilities.DilithiumOidLookup(dilithiumPrivateKeyParameters.Parameters)); - Asn1EncodableVector vPub = new Asn1EncodableVector(); + Asn1EncodableVector vPub = new Asn1EncodableVector(2); vPub.Add(new DerOctetString(dilithiumPrivateKeyParameters.Rho)); vPub.Add(new DerOctetString(dilithiumPrivateKeyParameters.T1)); diff --git a/crypto/src/pqc/crypto/utils/PqcSubjectPublicKeyInfoFactory.cs b/crypto/src/pqc/crypto/utils/PqcSubjectPublicKeyInfoFactory.cs index 756308460..672108789 100644 --- a/crypto/src/pqc/crypto/utils/PqcSubjectPublicKeyInfoFactory.cs +++ b/crypto/src/pqc/crypto/utils/PqcSubjectPublicKeyInfoFactory.cs @@ -115,7 +115,7 @@ namespace Org.BouncyCastle.Pqc.Crypto.Utilities { AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier( PqcUtilities.KyberOidLookup(kyberPublicKeyParameters.Parameters)); - Asn1EncodableVector v = new Asn1EncodableVector(); + Asn1EncodableVector v = new Asn1EncodableVector(2); v.Add(new DerOctetString(kyberPublicKeyParameters.T)); v.Add(new DerOctetString(kyberPublicKeyParameters.Rho)); return new SubjectPublicKeyInfo(algorithmIdentifier, new DerSequence(v)); |