/// <summary>
        /// Constructs a new instance with a set of encryption parameters
        /// </summary>
        ///
        /// <param name="CipherParams">Encryption parameters</param>
        /// <param name="Parallel">Use parallel processing when generating a key; set to false if using a passphrase type generator (default is true)</param>
        public NTRUKeyGenerator(NTRUParameters CipherParams, bool Parallel = true)
        {
            if (CipherParams.RandomEngine != Prngs.CTRPrng || CipherParams.RandomEngine != Prngs.CSPRng)
            {
                _isParallel = false;
            }
            else
            {
                _isParallel = Parallel;
            }

            _encParams = CipherParams;
            _dgtEngine = GetDigest(_encParams.MessageDigest);
            _rngEngine = GetPrng(_encParams.RandomEngine);
        }
Example #2
0
 /// <summary>
 /// Constructs a new instance with a set of encryption parameters
 /// </summary>
 /// 
 /// <param name="NtruParams">Encryption parameters</param>
 public NTRUEncrypt(NTRUParameters NtruParams)
 {
     _encParams = NtruParams;
     _dgtEngine = GetDigest(_encParams.Digest);
     _rndEngine = GetPrng(_encParams.RandomEngine);
 }
Example #3
0
 /// <summary>
 /// Constructs a new instance with a set of encryption parameters
 /// </summary>
 ///
 /// <param name="NtruParams">Encryption parameters</param>
 public NTRUEncrypt(NTRUParameters NtruParams)
 {
     _encParams = NtruParams;
     _dgtEngine = GetDigest(_encParams.MessageDigest);
     _rndEngine = GetPrng(_encParams.RandomEngine);
 }
Example #4
0
        /// <summary>
        /// Constructs a new instance with a set of encryption parameters
        /// </summary>
        /// 
        /// <param name="CipherParams">Encryption parameters</param>
        /// <param name="Parallel">Use parallel processing when generating a key; set to false if using a passphrase type generator (default is true)</param>
        public NTRUKeyGenerator(NTRUParameters CipherParams, bool Parallel = true)
        {
            if (CipherParams.RandomEngine != Prngs.CTRPrng || CipherParams.RandomEngine != Prngs.CSPRng)
                _isParallel = false;
            else
                _isParallel = Parallel;

            _ntruParams = CipherParams;
            _rndEngine = GetPrng(_ntruParams.RandomEngine);
        }
        /// <summary>
        /// Constructs a new instance with a set of encryption parameters
        /// </summary>
        /// 
        /// <param name="CipherParams">Encryption parameters</param>
        /// <param name="Parallel">Use parallel processing when generating a key; set to false if using a passphrase type generator (default is true)</param>
        public NTRUKeyGenerator(NTRUParameters CipherParams, bool Parallel = true)
        {
            if (CipherParams.RandomEngine != Prngs.CTRPrng || CipherParams.RandomEngine != Prngs.CSPRng)
                _isParallel = false;
            else
                _isParallel = Parallel;

            _encParams = CipherParams;
            _dgtEngine = GetDigest(_encParams.MessageDigest);
            _rngEngine = GetPrng(_encParams.RandomEngine);
        }
Example #6
0
        /// <summary>
        /// Compare this object instance with another
        /// </summary>
        ///
        /// <param name="Obj">Object to compare</param>
        ///
        /// <returns>True if equal, otherwise false</returns>
        public override bool Equals(Object Obj)
        {
            if (this == Obj)
            {
                return(true);
            }
            if (Obj == null)
            {
                return(false);
            }

            NTRUParameters other = (NTRUParameters)Obj;

            if (N != other.N)
            {
                return(false);
            }
            if (BufferLenBits != other.BufferLenBits)
            {
                return(false);
            }
            if (_bufferLenTrits != other._bufferLenTrits)
            {
                return(false);
            }
            if (CBits != other.CBits)
            {
                return(false);
            }
            if (Db != other.Db)
            {
                return(false);
            }
            if (DF != other.DF)
            {
                return(false);
            }
            if (DF1 != other.DF1)
            {
                return(false);
            }
            if (DF2 != other.DF2)
            {
                return(false);
            }
            if (DF3 != other.DF3)
            {
                return(false);
            }
            if (Dg != other.Dg)
            {
                return(false);
            }
            if (Dm0 != other.Dm0)
            {
                return(false);
            }
            if (MaxM1 != other.MaxM1)
            {
                return(false);
            }
            if (DR != other.DR)
            {
                return(false);
            }
            if (DR1 != other.DR1)
            {
                return(false);
            }
            if (DR2 != other.DR2)
            {
                return(false);
            }
            if (DR3 != other.DR3)
            {
                return(false);
            }
            if (FastFp != other.FastFp)
            {
                return(false);
            }
            if (!MessageDigest.Equals(other.MessageDigest))
            {
                return(false);
            }
            if (!RandomEngine.Equals(other.RandomEngine))
            {
                return(false);
            }
            if (HashSeed != other.HashSeed)
            {
                return(false);
            }
            if (Length != other.Length)
            {
                return(false);
            }
            if (MaxMsgLenBytes != other.MaxMsgLenBytes)
            {
                return(false);
            }
            if (MinMGFHashCalls != other.MinMGFHashCalls)
            {
                return(false);
            }
            if (MinIGFHashCalls != other.MinIGFHashCalls)
            {
                return(false);
            }
            if (!Compare.AreEqual(OId, other.OId))
            {
                return(false);
            }
            if (PkLen != other.PkLen)
            {
                return(false);
            }
            if (!PolyType.Equals(other.PolyType))
            {
                return(false);
            }
            if (Q != other.Q)
            {
                return(false);
            }
            if (Sparse != other.Sparse)
            {
                return(false);
            }

            return(true);
        }