From 750fc595961ed2fb325fa56e1918ccb2eff5130e Mon Sep 17 00:00:00 2001 From: David Hook Date: Wed, 21 Oct 2015 10:43:24 +1100 Subject: Renamed DoFinal to Value on IBlockResult. --- crypto/src/crypto/operators/Asn1Signature.cs | 6 +++--- crypto/src/ocsp/BasicOCSPRespGenerator.cs | 2 +- crypto/src/pkcs/Pkcs10CertificationRequest.cs | 2 +- crypto/src/x509/X509V1CertificateGenerator.cs | 2 +- crypto/src/x509/X509V2AttributeCertificateGenerator.cs | 2 +- crypto/src/x509/X509V2CRLGenerator.cs | 2 +- crypto/src/x509/X509V3CertificateGenerator.cs | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) (limited to 'crypto') diff --git a/crypto/src/crypto/operators/Asn1Signature.cs b/crypto/src/crypto/operators/Asn1Signature.cs index ba070f4fc..c762f47e9 100644 --- a/crypto/src/crypto/operators/Asn1Signature.cs +++ b/crypto/src/crypto/operators/Asn1Signature.cs @@ -422,14 +422,14 @@ namespace Org.BouncyCastle.Crypto.Operators this.sig = sig; } - public byte[] DoFinal() + public byte[] Value() { return sig.GenerateSignature(); } - public int DoFinal(byte[] destination, int offset) + public int Value(byte[] destination, int offset) { - byte[] signature = DoFinal(); + byte[] signature = Value(); Array.Copy(signature, 0, destination, offset, signature.Length); diff --git a/crypto/src/ocsp/BasicOCSPRespGenerator.cs b/crypto/src/ocsp/BasicOCSPRespGenerator.cs index a7d5f3da5..32b17c2dd 100644 --- a/crypto/src/ocsp/BasicOCSPRespGenerator.cs +++ b/crypto/src/ocsp/BasicOCSPRespGenerator.cs @@ -219,7 +219,7 @@ namespace Org.BouncyCastle.Ocsp streamCalculator.Stream.Close(); - bitSig = new DerBitString(((IBlockResult)streamCalculator.GetResult()).DoFinal()); + bitSig = new DerBitString(((IBlockResult)streamCalculator.GetResult()).Value()); } catch (Exception e) { diff --git a/crypto/src/pkcs/Pkcs10CertificationRequest.cs b/crypto/src/pkcs/Pkcs10CertificationRequest.cs index b68979cad..255f04177 100644 --- a/crypto/src/pkcs/Pkcs10CertificationRequest.cs +++ b/crypto/src/pkcs/Pkcs10CertificationRequest.cs @@ -282,7 +282,7 @@ namespace Org.BouncyCastle.Pkcs streamCalculator.Stream.Close(); // Generate Signature. - sigBits = new DerBitString(((IBlockResult)streamCalculator.GetResult()).DoFinal()); + sigBits = new DerBitString(((IBlockResult)streamCalculator.GetResult()).Value()); } // internal Pkcs10CertificationRequest( diff --git a/crypto/src/x509/X509V1CertificateGenerator.cs b/crypto/src/x509/X509V1CertificateGenerator.cs index a452df440..3ca81b8ed 100644 --- a/crypto/src/x509/X509V1CertificateGenerator.cs +++ b/crypto/src/x509/X509V1CertificateGenerator.cs @@ -186,7 +186,7 @@ namespace Org.BouncyCastle.X509 streamCalculator.Stream.Close(); - return GenerateJcaObject(tbsCert, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).DoFinal()); + return GenerateJcaObject(tbsCert, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).Value()); } private X509Certificate GenerateJcaObject( diff --git a/crypto/src/x509/X509V2AttributeCertificateGenerator.cs b/crypto/src/x509/X509V2AttributeCertificateGenerator.cs index 138f2ec6f..5f7d73708 100644 --- a/crypto/src/x509/X509V2AttributeCertificateGenerator.cs +++ b/crypto/src/x509/X509V2AttributeCertificateGenerator.cs @@ -180,7 +180,7 @@ namespace Org.BouncyCastle.X509 try { - v.Add(new DerBitString(((IBlockResult)streamCalculator.GetResult()).DoFinal())); + v.Add(new DerBitString(((IBlockResult)streamCalculator.GetResult()).Value())); return new X509V2AttributeCertificate(AttributeCertificate.GetInstance(new DerSequence(v))); } diff --git a/crypto/src/x509/X509V2CRLGenerator.cs b/crypto/src/x509/X509V2CRLGenerator.cs index c1cc8e824..97db6c9a0 100644 --- a/crypto/src/x509/X509V2CRLGenerator.cs +++ b/crypto/src/x509/X509V2CRLGenerator.cs @@ -243,7 +243,7 @@ namespace Org.BouncyCastle.X509 streamCalculator.Stream.Close(); - return GenerateJcaObject(tbsCertList, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).DoFinal()); + return GenerateJcaObject(tbsCertList, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).Value()); } private TbsCertificateList GenerateCertList() diff --git a/crypto/src/x509/X509V3CertificateGenerator.cs b/crypto/src/x509/X509V3CertificateGenerator.cs index a22cd9943..bbd34bd35 100644 --- a/crypto/src/x509/X509V3CertificateGenerator.cs +++ b/crypto/src/x509/X509V3CertificateGenerator.cs @@ -322,7 +322,7 @@ namespace Org.BouncyCastle.X509 streamCalculator.Stream.Close (); - return GenerateJcaObject(tbsCert, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).DoFinal()); + return GenerateJcaObject(tbsCert, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).Value()); } private X509Certificate GenerateJcaObject( -- cgit 1.4.1 From 0e67b3a7d3cc175fb8644abc839ac5a1ed29abe7 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 21 Oct 2015 10:52:05 +0700 Subject: Remove inapplicable comments in key generators --- crypto/src/crypto/generators/ECKeyPairGenerator.cs | 6 ------ crypto/src/crypto/generators/GOST3410KeyPairGenerator.cs | 6 ------ 2 files changed, 12 deletions(-) (limited to 'crypto') diff --git a/crypto/src/crypto/generators/ECKeyPairGenerator.cs b/crypto/src/crypto/generators/ECKeyPairGenerator.cs index d4afff750..26bc06e14 100644 --- a/crypto/src/crypto/generators/ECKeyPairGenerator.cs +++ b/crypto/src/crypto/generators/ECKeyPairGenerator.cs @@ -108,12 +108,6 @@ namespace Org.BouncyCastle.Crypto.Generators if (d.CompareTo(BigInteger.Two) < 0 || d.CompareTo(n) >= 0) continue; - /* - * Require a minimum weight of the NAF representation, since low-weight primes may be - * weak against a version of the number-field-sieve for the discrete-logarithm-problem. - * - * See "The number field sieve for integers of low weight", Oliver Schirokauer. - */ if (WNafUtilities.GetNafWeight(d) < minWeight) continue; diff --git a/crypto/src/crypto/generators/GOST3410KeyPairGenerator.cs b/crypto/src/crypto/generators/GOST3410KeyPairGenerator.cs index 013b81810..520820bfa 100644 --- a/crypto/src/crypto/generators/GOST3410KeyPairGenerator.cs +++ b/crypto/src/crypto/generators/GOST3410KeyPairGenerator.cs @@ -55,12 +55,6 @@ namespace Org.BouncyCastle.Crypto.Generators if (x.SignValue < 1 || x.CompareTo(q) >= 0) continue; - /* - * Require a minimum weight of the NAF representation, since low-weight primes may be - * weak against a version of the number-field-sieve for the discrete-logarithm-problem. - * - * See "The number field sieve for integers of low weight", Oliver Schirokauer. - */ if (WNafUtilities.GetNafWeight(x) < minWeight) continue; -- cgit 1.4.1 From e41a52b8f6ffba2a53b342cca3ce11a313f4027b Mon Sep 17 00:00:00 2001 From: David Hook Date: Wed, 21 Oct 2015 22:04:06 +1100 Subject: Added missed files on IBlockResult change --- crypto/src/cms/CMSSignedDataGenerator.cs | 2 +- crypto/src/crypto/IBlockResult.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'crypto') diff --git a/crypto/src/cms/CMSSignedDataGenerator.cs b/crypto/src/cms/CMSSignedDataGenerator.cs index e0caca9ff..789aa9145 100644 --- a/crypto/src/cms/CMSSignedDataGenerator.cs +++ b/crypto/src/cms/CMSSignedDataGenerator.cs @@ -174,7 +174,7 @@ namespace Org.BouncyCastle.Cms } sigStr.Close(); - byte[] sigBytes = ((IBlockResult)calculator.GetResult()).DoFinal(); + byte[] sigBytes = ((IBlockResult)calculator.GetResult()).Value(); Asn1Set unsignedAttr = null; if (unsAttr != null) diff --git a/crypto/src/crypto/IBlockResult.cs b/crypto/src/crypto/IBlockResult.cs index c12bdaa1d..f2149d951 100644 --- a/crypto/src/crypto/IBlockResult.cs +++ b/crypto/src/crypto/IBlockResult.cs @@ -11,7 +11,7 @@ namespace Org.BouncyCastle.Crypto /// Return the final result of the operation. /// /// A block of bytes, representing the result of an operation. - byte[] DoFinal(); + byte[] Value(); /// /// Store the final result of the operation by copying it into the destination array. @@ -19,6 +19,6 @@ namespace Org.BouncyCastle.Crypto /// The number of bytes copied into destination. /// The byte array to copy the result into. /// The offset into destination to start copying the result at. - int DoFinal(byte[] destination, int offset); + int Value(byte[] destination, int offset); } } -- cgit 1.4.1 From 90f260f459d7f15eeff2fd8dfa8bd5347b027e3b Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Thu, 22 Oct 2015 11:05:46 +0700 Subject: Fix faulty constructor and refactor --- crypto/src/asn1/cmp/RevDetails.cs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'crypto') diff --git a/crypto/src/asn1/cmp/RevDetails.cs b/crypto/src/asn1/cmp/RevDetails.cs index 1bd95f1db..6bdf5b2e9 100644 --- a/crypto/src/asn1/cmp/RevDetails.cs +++ b/crypto/src/asn1/cmp/RevDetails.cs @@ -11,17 +11,15 @@ namespace Org.BouncyCastle.Asn1.Cmp private readonly CertTemplate certDetails; private readonly X509Extensions crlEntryDetails; - private RevDetails(Asn1Sequence seq) + private RevDetails(Asn1Sequence seq) { certDetails = CertTemplate.GetInstance(seq[0]); - - if (seq.Count > 1) - { - crlEntryDetails = X509Extensions.GetInstance(seq[1]); - } + crlEntryDetails = seq.Count <= 1 + ? null + : X509Extensions.GetInstance(seq[1]); } - public static RevDetails GetInstance(object obj) + public static RevDetails GetInstance(object obj) { if (obj is RevDetails) return (RevDetails)obj; @@ -33,21 +31,22 @@ namespace Org.BouncyCastle.Asn1.Cmp } public RevDetails(CertTemplate certDetails) + : this(certDetails, null) { - this.certDetails = certDetails; } - - public RevDetails(CertTemplate certDetails, X509Extensions crlEntryDetails) + + public RevDetails(CertTemplate certDetails, X509Extensions crlEntryDetails) { - this.crlEntryDetails = crlEntryDetails; + this.certDetails = certDetails; + this.crlEntryDetails = crlEntryDetails; } - public virtual CertTemplate CertDetails + public virtual CertTemplate CertDetails { get { return certDetails; } } - public virtual X509Extensions CrlEntryDetails + public virtual X509Extensions CrlEntryDetails { get { return crlEntryDetails; } } -- cgit 1.4.1 From 15f6e0c1cd9ce96ffbd24dc7dc83a7593df71a8a Mon Sep 17 00:00:00 2001 From: David Hook Date: Thu, 22 Oct 2015 16:06:57 +1100 Subject: Changed name of Value() to Collect() --- crypto/src/cms/CMSSignedDataGenerator.cs | 2 +- crypto/src/crypto/IBlockResult.cs | 4 ++-- crypto/src/crypto/operators/Asn1Signature.cs | 6 +++--- crypto/src/ocsp/BasicOCSPRespGenerator.cs | 2 +- crypto/src/pkcs/Pkcs10CertificationRequest.cs | 2 +- crypto/src/x509/X509V1CertificateGenerator.cs | 2 +- crypto/src/x509/X509V2AttributeCertificateGenerator.cs | 2 +- crypto/src/x509/X509V2CRLGenerator.cs | 2 +- crypto/src/x509/X509V3CertificateGenerator.cs | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) (limited to 'crypto') diff --git a/crypto/src/cms/CMSSignedDataGenerator.cs b/crypto/src/cms/CMSSignedDataGenerator.cs index 789aa9145..f4720597d 100644 --- a/crypto/src/cms/CMSSignedDataGenerator.cs +++ b/crypto/src/cms/CMSSignedDataGenerator.cs @@ -174,7 +174,7 @@ namespace Org.BouncyCastle.Cms } sigStr.Close(); - byte[] sigBytes = ((IBlockResult)calculator.GetResult()).Value(); + byte[] sigBytes = ((IBlockResult)calculator.GetResult()).Collect(); Asn1Set unsignedAttr = null; if (unsAttr != null) diff --git a/crypto/src/crypto/IBlockResult.cs b/crypto/src/crypto/IBlockResult.cs index f2149d951..0f054fedc 100644 --- a/crypto/src/crypto/IBlockResult.cs +++ b/crypto/src/crypto/IBlockResult.cs @@ -11,7 +11,7 @@ namespace Org.BouncyCastle.Crypto /// Return the final result of the operation. /// /// A block of bytes, representing the result of an operation. - byte[] Value(); + byte[] Collect(); /// /// Store the final result of the operation by copying it into the destination array. @@ -19,6 +19,6 @@ namespace Org.BouncyCastle.Crypto /// The number of bytes copied into destination. /// The byte array to copy the result into. /// The offset into destination to start copying the result at. - int Value(byte[] destination, int offset); + int Collect(byte[] destination, int offset); } } diff --git a/crypto/src/crypto/operators/Asn1Signature.cs b/crypto/src/crypto/operators/Asn1Signature.cs index c762f47e9..9e66b6f0c 100644 --- a/crypto/src/crypto/operators/Asn1Signature.cs +++ b/crypto/src/crypto/operators/Asn1Signature.cs @@ -422,14 +422,14 @@ namespace Org.BouncyCastle.Crypto.Operators this.sig = sig; } - public byte[] Value() + public byte[] Collect() { return sig.GenerateSignature(); } - public int Value(byte[] destination, int offset) + public int Collect(byte[] destination, int offset) { - byte[] signature = Value(); + byte[] signature = Collect(); Array.Copy(signature, 0, destination, offset, signature.Length); diff --git a/crypto/src/ocsp/BasicOCSPRespGenerator.cs b/crypto/src/ocsp/BasicOCSPRespGenerator.cs index 32b17c2dd..9735ba177 100644 --- a/crypto/src/ocsp/BasicOCSPRespGenerator.cs +++ b/crypto/src/ocsp/BasicOCSPRespGenerator.cs @@ -219,7 +219,7 @@ namespace Org.BouncyCastle.Ocsp streamCalculator.Stream.Close(); - bitSig = new DerBitString(((IBlockResult)streamCalculator.GetResult()).Value()); + bitSig = new DerBitString(((IBlockResult)streamCalculator.GetResult()).Collect()); } catch (Exception e) { diff --git a/crypto/src/pkcs/Pkcs10CertificationRequest.cs b/crypto/src/pkcs/Pkcs10CertificationRequest.cs index 255f04177..6c6b4c87d 100644 --- a/crypto/src/pkcs/Pkcs10CertificationRequest.cs +++ b/crypto/src/pkcs/Pkcs10CertificationRequest.cs @@ -282,7 +282,7 @@ namespace Org.BouncyCastle.Pkcs streamCalculator.Stream.Close(); // Generate Signature. - sigBits = new DerBitString(((IBlockResult)streamCalculator.GetResult()).Value()); + sigBits = new DerBitString(((IBlockResult)streamCalculator.GetResult()).Collect()); } // internal Pkcs10CertificationRequest( diff --git a/crypto/src/x509/X509V1CertificateGenerator.cs b/crypto/src/x509/X509V1CertificateGenerator.cs index 3ca81b8ed..2279767e3 100644 --- a/crypto/src/x509/X509V1CertificateGenerator.cs +++ b/crypto/src/x509/X509V1CertificateGenerator.cs @@ -186,7 +186,7 @@ namespace Org.BouncyCastle.X509 streamCalculator.Stream.Close(); - return GenerateJcaObject(tbsCert, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).Value()); + return GenerateJcaObject(tbsCert, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).Collect()); } private X509Certificate GenerateJcaObject( diff --git a/crypto/src/x509/X509V2AttributeCertificateGenerator.cs b/crypto/src/x509/X509V2AttributeCertificateGenerator.cs index 5f7d73708..b6ab45c64 100644 --- a/crypto/src/x509/X509V2AttributeCertificateGenerator.cs +++ b/crypto/src/x509/X509V2AttributeCertificateGenerator.cs @@ -180,7 +180,7 @@ namespace Org.BouncyCastle.X509 try { - v.Add(new DerBitString(((IBlockResult)streamCalculator.GetResult()).Value())); + v.Add(new DerBitString(((IBlockResult)streamCalculator.GetResult()).Collect())); return new X509V2AttributeCertificate(AttributeCertificate.GetInstance(new DerSequence(v))); } diff --git a/crypto/src/x509/X509V2CRLGenerator.cs b/crypto/src/x509/X509V2CRLGenerator.cs index 97db6c9a0..869722219 100644 --- a/crypto/src/x509/X509V2CRLGenerator.cs +++ b/crypto/src/x509/X509V2CRLGenerator.cs @@ -243,7 +243,7 @@ namespace Org.BouncyCastle.X509 streamCalculator.Stream.Close(); - return GenerateJcaObject(tbsCertList, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).Value()); + return GenerateJcaObject(tbsCertList, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).Collect()); } private TbsCertificateList GenerateCertList() diff --git a/crypto/src/x509/X509V3CertificateGenerator.cs b/crypto/src/x509/X509V3CertificateGenerator.cs index bbd34bd35..d8cdc7521 100644 --- a/crypto/src/x509/X509V3CertificateGenerator.cs +++ b/crypto/src/x509/X509V3CertificateGenerator.cs @@ -322,7 +322,7 @@ namespace Org.BouncyCastle.X509 streamCalculator.Stream.Close (); - return GenerateJcaObject(tbsCert, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).Value()); + return GenerateJcaObject(tbsCert, (AlgorithmIdentifier)signatureCalculator.AlgorithmDetails, ((IBlockResult)streamCalculator.GetResult()).Collect()); } private X509Certificate GenerateJcaObject( -- cgit 1.4.1