From d5dbff576ad27f166e4777f9383694ecd7babf0e Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Wed, 6 Jul 2022 20:12:01 +0700 Subject: Fix a few warnings --- crypto/src/openpgp/PgpSecretKeyRingBundle.cs | 2 +- crypto/src/pqc/crypto/lms/LMOtsSignature.cs | 4 ++-- crypto/src/pqc/crypto/saber/SABEREngine.cs | 13 +++++-------- crypto/src/pqc/crypto/sike/SIKEEngine.cs | 3 +-- crypto/src/pqc/crypto/sphincsplus/Adrs.cs | 4 ++-- crypto/src/util/IEncodable.cs | 16 ++++------------ 6 files changed, 15 insertions(+), 27 deletions(-) diff --git a/crypto/src/openpgp/PgpSecretKeyRingBundle.cs b/crypto/src/openpgp/PgpSecretKeyRingBundle.cs index af182de9c..695c882b7 100644 --- a/crypto/src/openpgp/PgpSecretKeyRingBundle.cs +++ b/crypto/src/openpgp/PgpSecretKeyRingBundle.cs @@ -87,7 +87,7 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp } /// Allow enumeration of the key rings associated with the passed in userId. - /// The user ID to be matched. + /// The user ID to be matched. /// If true, userId need only be a substring of an actual ID string to match. /// If true, case is ignored in user ID comparisons. /// An IEnumerable of key rings which matched (possibly none). diff --git a/crypto/src/pqc/crypto/lms/LMOtsSignature.cs b/crypto/src/pqc/crypto/lms/LMOtsSignature.cs index f5452f45a..599255fbd 100644 --- a/crypto/src/pqc/crypto/lms/LMOtsSignature.cs +++ b/crypto/src/pqc/crypto/lms/LMOtsSignature.cs @@ -76,8 +76,8 @@ namespace Org.BouncyCastle.Pqc.Crypto.Lms { return y; } - - public bool Equals(Object o) + + public override bool Equals(object o) { if (this == o) { diff --git a/crypto/src/pqc/crypto/saber/SABEREngine.cs b/crypto/src/pqc/crypto/saber/SABEREngine.cs index dfb766571..4be553957 100644 --- a/crypto/src/pqc/crypto/saber/SABEREngine.cs +++ b/crypto/src/pqc/crypto/saber/SABEREngine.cs @@ -441,15 +441,12 @@ namespace Org.BouncyCastle.Pqc.Crypto.Saber /* returns 0 for equal strings, 1 for non-equal strings */ static int verify(byte[] a, byte[] b, int len) { - long r; - int i; - r = 0; - - for (i = 0; i < len; i++) + int r = 0; + for (int i = 0; i < len; i++) + { r |= a[i] ^ b[i]; - - r = (-r) >> 63; - return (int) r; + } + return (int)((uint)-r >> 31); } /* b = 1 means mov, b = 0 means don't mov*/ diff --git a/crypto/src/pqc/crypto/sike/SIKEEngine.cs b/crypto/src/pqc/crypto/sike/SIKEEngine.cs index e5cd4e4f6..38a162978 100644 --- a/crypto/src/pqc/crypto/sike/SIKEEngine.cs +++ b/crypto/src/pqc/crypto/sike/SIKEEngine.cs @@ -102,11 +102,10 @@ public class SIKEEngine // todo/org: SIDH.random_mod_order_B(sk, random); byte[] random_digits = new byte[param.SECRETKEY_B_BYTES]; random.NextBytes(random_digits); - random_digits[param.SECRETKEY_B_BYTES-1] &= (byte) param.MASK_BOB; + random_digits[param.SECRETKEY_B_BYTES-1] &= (byte)param.MASK_BOB; System.Array.Copy(s, 0, sk, 0, param.MSG_BYTES); System.Array.Copy(random_digits, 0, sk, param.MSG_BYTES, param.SECRETKEY_B_BYTES); - /// sidh.EphemeralKeyGeneration_B(sk, pk); System.Array.Copy(pk, 0, sk, param.MSG_BYTES + param.SECRETKEY_B_BYTES, param.CRYPTO_PUBLICKEYBYTES); diff --git a/crypto/src/pqc/crypto/sphincsplus/Adrs.cs b/crypto/src/pqc/crypto/sphincsplus/Adrs.cs index 80f2e7159..a6ec753fd 100644 --- a/crypto/src/pqc/crypto/sphincsplus/Adrs.cs +++ b/crypto/src/pqc/crypto/sphincsplus/Adrs.cs @@ -89,8 +89,8 @@ namespace Org.BouncyCastle.Pqc.Crypto.SphincsPlus { Pack.UInt32_To_BE(type, value, OFFSET_TYPE); } - - public uint GetType() + + public new uint GetType() { return Pack.BE_To_UInt32(value, OFFSET_TYPE); } diff --git a/crypto/src/util/IEncodable.cs b/crypto/src/util/IEncodable.cs index 29d5af7f8..426394f35 100644 --- a/crypto/src/util/IEncodable.cs +++ b/crypto/src/util/IEncodable.cs @@ -4,17 +4,9 @@ namespace Org.BouncyCastle.Utilities { public interface IEncodable { - /// - /// - /// - /// - /// - /// - // * Return a byte array representing the implementing object. - // * - // * @return a byte array representing the encoding. - // * @throws IOException if an issue arises generation the encoding. - // */ + /// Return a byte array representing the implementing object. + /// An encoding of this object as a byte array. + /// byte[] GetEncoded(); } -} \ No newline at end of file +} -- cgit 1.4.1