示例#1
0
        private void Dispose(bool Disposing)
        {
            if (!_isDisposed && Disposing)
            {
                try
                {
                    if (_mcElieceParams != null)
                    {
                        _mcElieceParams.Dispose();
                        _mcElieceParams = null;
                    }
                    if (_rngEngine != null)
                    {
                        _rngEngine.Dispose();
                        _rngEngine = null;
                    }
                    _M         = 0;
                    _N         = 0;
                    _T         = 0;
                    _fieldPoly = 0;
                }
                catch { }

                _isDisposed = true;
            }
        }
 /// <summary>
 /// Initialize this class
 /// </summary>
 /// 
 /// <param name="CiphersParams">The MPKCParameters instance containing thecipher settings</param>
 public MPKCKeyGenerator(MPKCParameters CiphersParams)
 {
     _mcElieceParams = (MPKCParameters)CiphersParams;
     // set source of randomness
     _rngEngine = GetPrng(_mcElieceParams.RandomEngine);
     _M = _mcElieceParams.M;
     _N = _mcElieceParams.N;
     _T = _mcElieceParams.T;
     _fieldPoly = _mcElieceParams.FieldPolynomial;
 }
示例#3
0
 /// <summary>
 /// Initialize this class
 /// </summary>
 ///
 /// <param name="CiphersParams">The MPKCParameters instance containing thecipher settings</param>
 public MPKCKeyGenerator(MPKCParameters CiphersParams)
 {
     _mcElieceParams = (MPKCParameters)CiphersParams;
     // set source of randomness
     _rngEngine = GetPrng(_mcElieceParams.RandomEngine);
     _M         = _mcElieceParams.M;
     _N         = _mcElieceParams.N;
     _T         = _mcElieceParams.T;
     _fieldPoly = _mcElieceParams.FieldPolynomial;
 }
示例#4
0
        /// <summary>
        /// Get the cipher engine
        /// </summary>
        ///
        /// <param name="CipherParams">The engine type</param>
        ///
        /// <returns>An initialized cipher</returns>
        private IMPKCCiphers GetEngine(MPKCParameters CipherParams)
        {
            switch (CipherParams.CCA2Engine)
            {
            case McElieceCiphers.KobaraImai:
                return(new KobaraImaiCipher(CipherParams));

            case McElieceCiphers.Pointcheval:
                return(new PointchevalCipher(CipherParams));

            default:
                return(new FujisakiCipher(CipherParams));
            }
        }
示例#5
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 && this != null)
            {
                return(false);
            }

            MPKCParameters other = (MPKCParameters)Obj;

            if (Digest != other.Digest)
            {
                return(false);
            }
            if (CCA2Engine != other.CCA2Engine)
            {
                return(false);
            }
            if (RandomEngine != other.RandomEngine)
            {
                return(false);
            }
            if (M != other.M)
            {
                return(false);
            }
            if (N != other.N)
            {
                return(false);
            }
            if (T != other.T)
            {
                return(false);
            }
            if (FieldPolynomial != other.FieldPolynomial)
            {
                return(false);
            }

            return(true);
        }
示例#6
0
 /// <summary>
 /// Initialize this class
 /// </summary>
 /// 
 /// <param name="CipherParams">The McEliece cipher used to encrypt the hash</param>
 /// <param name="Digest">The type of digest engine used</param>
 public MPKCSign(MPKCParameters CipherParams, Digests Digest = Digests.SHA512)
 {
     _dgtEngine = GetDigest(CipherParams.Digest);
     _asyCipher = GetEngine(CipherParams);
 }
示例#7
0
 /// <summary>
 /// Get the cipher engine
 /// </summary>
 /// 
 /// <param name="CipherParams">The engine type</param>
 /// 
 /// <returns>An initialized cipher</returns>
 private IMPKCCiphers GetEngine(MPKCParameters CipherParams)
 {
     switch (CipherParams.CCA2Engine)
     {
         case McElieceCiphers.KobaraImai:
             return new KobaraImaiCipher(CipherParams);
         case McElieceCiphers.Pointcheval:
             return new PointchevalCipher(CipherParams);
         default:
             return new FujisakiCipher(CipherParams);
     }
 }
示例#8
0
 /// <summary>
 /// Initialize this class
 /// </summary>
 ///
 /// <param name="CipherParams">The McEliece cipher used to encrypt the hash</param>
 /// <param name="Digest">The type of digest engine used</param>
 public MPKCSign(MPKCParameters CipherParams, Digests Digest = Digests.SHA512)
 {
     _dgtEngine = GetDigest(CipherParams.Digest);
     _asyCipher = GetEngine(CipherParams);
 }
示例#9
0
 /// <summary>
 /// Initialize this class
 /// </summary>
 /// 
 /// <param name="CipherParams">The cipher engine</param>
 public MPKCEncrypt(MPKCParameters CipherParams)
 {
     _encEngine = GetEngine(CipherParams);
 }
示例#10
0
 /// <summary>
 /// Initialize this class
 /// </summary>
 ///
 /// <param name="CipherParams">The cipher engine</param>
 public MPKCEncrypt(MPKCParameters CipherParams)
 {
     _encEngine = GetEngine(CipherParams);
 }
        private void Dispose(bool Disposing)
        {
            if (!_isDisposed && Disposing)
            {
                try
                {
                    if (_mcElieceParams != null)
                    {
                        _mcElieceParams.Dispose();
                        _mcElieceParams = null;
                    }
                    if (_rngEngine != null)
                    {
                        _rngEngine.Dispose();
                        _rngEngine = null;
                    }
                    _M = 0;
                    _N = 0;
                    _T = 0;
                    _fieldPoly = 0;
                }
                catch { }

                _isDisposed = true;
            }
        }