当前位置: 首页>>代码示例>>C#>>正文


C# Digests类代码示例

本文整理汇总了C#中Digests的典型用法代码示例。如果您正苦于以下问题:C# Digests类的具体用法?C# Digests怎么用?C# Digests使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Digests类属于命名空间,在下文中一共展示了Digests类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetInstance

 /// <summary>
 /// Get a Digest instance by name
 /// </summary>
 /// 
 /// <param name="DigestType">The message digest enumeration name</param>
 /// 
 /// <returns>An initialized digest</returns>
 /// 
 /// <exception cref="CryptoProcessingException">Thrown if the enumeration name is not supported</exception>
 public static IDigest GetInstance(Digests DigestType)
 {
     switch (DigestType)
     {
         case Digests.Blake256:
             return new Blake256();
         case Digests.Blake512:
             return new Blake512();
         case Digests.Keccak256:
             return new Keccak256();
         case Digests.Keccak512:
             return new Keccak512();
         case Digests.SHA256:
             return new SHA256();
         case Digests.SHA512:
             return new SHA512();
         case Digests.Skein256:
             return new Skein256();
         case Digests.Skein512:
             return new Skein512();
         case Digests.Skein1024:
             return new Skein1024();
         default:
             throw new CryptoProcessingException("DigestFromName:GetInstance", "The digest is not recognized!");
     }
 }
开发者ID:Steppenwolfe65,项目名称:GMSS-NET,代码行数:35,代码来源:DigestFromName.cs

示例2: KeyGenerator

        /// <summary>
        /// Initialize the class and generators
        /// </summary>
        /// <param name="SeedEngine">The <see cref="Prngs">Prng</see> that supplies the key and seed material to the hash function</param>
        /// <param name="HashEngine">The <see cref="Digests">Digest</see> type used to create the pseudo random keying material</param>
        public KeyGenerator(Prngs SeedEngine, Digests HashEngine)
        {
            this.SeedEngine = SeedEngine;
            this.HashEngine = HashEngine;

            // initialize the generators
            Reset();
        }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:13,代码来源:KeyGenerator.cs

示例3: GetDigest

 /// <summary>
 /// Get the digest engine
 /// </summary>
 /// 
 /// <param name="Digest">Engine type</param>
 /// 
 /// <returns>Instance of digest</returns>
 private IDigest GetDigest(Digests Digest)
 {
     switch (Digest)
     {
         case Digests.Blake256:
             return new Blake256();
         case Digests.Blake512:
             return new Blake512();
         case Digests.Keccak256:
             return new Keccak256();
         case Digests.Keccak512:
             return new Keccak512();
         case Digests.Keccak1024:
             return new Keccak1024();
         case Digests.SHA256:
             return new SHA256();
         case Digests.SHA512:
             return new SHA512();
         case Digests.Skein256:
             return new Skein256();
         case Digests.Skein512:
             return new Skein512();
         case Digests.Skein1024:
             return new Skein1024();
         default:
             throw new CryptoAsymmetricException("NTRUKeyGenerator:GetDigest", "The digest type is not supported!", new ArgumentException());
     }
 }
开发者ID:jesusgarza,项目名称:NTRU-Sharp,代码行数:35,代码来源:NTRUKeyGenerator.cs

示例4: NTRUParameters

        /// <summary>
        /// Builds a parameter set from an encoded input stream
        /// </summary>
        /// 
        /// <param name="ParamStream">Stream containing a parameter set</param>
        /// 
        /// <exception cref="CryptoAsymmetricException">Thrown if the Stream is unreadable</exception>
        public NTRUParameters(Stream ParamStream)
        {
            try
            {
                BinaryReader reader = new BinaryReader(ParamStream);

                _oId = new byte[OID_SIZE];
                reader.Read(_oId, 0, _oId.Length);
                _N = reader.ReadInt32();
                _Q = reader.ReadInt32();
                _DF = reader.ReadInt32();
                _DF1 = reader.ReadInt32();
                _DF2 = reader.ReadInt32();
                _DF3 = reader.ReadInt32();
                _Db = reader.ReadInt32();
                _Dm0 = reader.ReadInt32();
                _maxM1 = reader.ReadInt32();
                _cBits = reader.ReadInt32();
                _minIGFHashCalls = reader.ReadInt32();
                _minMGFHashCalls = reader.ReadInt32();
                _hashSeed = reader.ReadBoolean();
                _sparseMode = reader.ReadBoolean();
                _fastFp = reader.ReadBoolean();
                _polyType = (TernaryPolynomialType)reader.ReadInt32();
                _dgtEngineType = (Digests)reader.ReadInt32();
                _rndEngineType = (Prngs)reader.ReadInt32();

                Initialize();
            }
            catch (Exception ex)
            {
                throw new CryptoAsymmetricException("NTRUParameters:CTor", "The stream could not be read!", ex);
            }
        }
开发者ID:modulexcite,项目名称:CEX,代码行数:41,代码来源:NTRUParameters.cs

示例5: MPKCSign

 /// <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);
 }
开发者ID:jesusgarza,项目名称:McEliece-Sharp,代码行数:11,代码来源:MPKCSign.cs

示例6: NTRUParameters

        /// <summary>
        /// Reads a parameter set from an input stream
        /// </summary>
        /// 
        /// <param name="CipherParams">Stream containing a parameter set</param>
        public NTRUParameters(Stream CipherParams)
        {
            try
            {
                BinaryReader reader = new BinaryReader(CipherParams);

                _N = reader.ReadInt32();
                _Q = reader.ReadInt32();
                _DF = reader.ReadInt32();
                _DF1 = reader.ReadInt32();
                _DF2 = reader.ReadInt32();
                _DF3 = reader.ReadInt32();
                _Db = reader.ReadInt32();
                _Dm0 = reader.ReadInt32();
                _maxM1 = reader.ReadInt32();
                _cBits = reader.ReadInt32();
                _minIGFHashCalls = reader.ReadInt32();
                _minMGFHashCalls = reader.ReadInt32();
                _hashSeed = reader.ReadBoolean();
                _oId = new byte[3];
                reader.Read(_oId, 0, _oId.Length);
                _sparseMode = reader.ReadBoolean();
                _fastFp = reader.ReadBoolean();
                _polyType = (TernaryPolynomialType)reader.ReadInt32();
                _messageDigest = (Digests)reader.ReadInt32();
                _randomEngine = (Prngs)reader.ReadInt32();

                Initialize();
            }
            catch (Exception ex)
            {
                throw new NTRUException("NTRUParameters:CTor", "The stream could not be read!", ex);
            }
        }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:39,代码来源:NTRUParameters.cs

示例7: RSM

        /// <summary>
        /// Initialize the class
        /// </summary>
        /// 
        /// <param name="Rounds">Number of diffusion rounds. The <see cref="LegalRounds"/> property contains available sizes. Default is 18 rounds.</param>
        /// <param name="Block">Cipher input <see cref="BlockSize"/>. The <see cref="LegalBlockSizes"/> property contains available sizes. Default is 16 bytes.</param>
        /// <param name="KeyEngine">The Key Schedule KDF digest engine; can be any one of the <see cref="Digests">Digest</see> implementations. The default engine is <see cref="SHA512"/>.</param>
        /// 
        /// <exception cref="CryptoSymmetricException">Thrown if an invalid block size or invalid rounds count are used</exception>
        public RSM(int Rounds = ROUNDS18, int Block = BLOCK16, Digests KeyEngine = Digests.SHA512)
        {
            if (Block != BLOCK16 && Block != BLOCK32)
                throw new CryptoSymmetricException("RSM:CTor", "Invalid block size! Supported block sizes are 16 and 32 bytes.", new ArgumentException());
            if (Rounds != 10 && Rounds != 18 && Rounds != 26 && Rounds != 34 && Rounds != 42)
                throw new CryptoSymmetricException("RSM:CTor", "Invalid rounds size! Sizes supported are even numbers between 10, 18, 26, 34 and 42.", new ArgumentException());

            // get the kdf digest engine
            _keyEngine = GetKeyEngine(KeyEngine);
            // set the hmac key size
            _ikmSize = _ikmSize == 0 ? _keyEngine.DigestSize : _ikmSize;

            for (int i = 0; i < _legalKeySizes.Length; i++)
                _legalKeySizes[i] = (_keyEngine.BlockSize * (i + 1)) + _ikmSize;

            _dfnRounds = Rounds;
            _blockSize = Block;
        }
开发者ID:modulexcite,项目名称:CEX,代码行数:27,代码来源:RSM.cs

示例8: GetMinimumSeedSize

        private int GetMinimumSeedSize(Digests RngEngine)
        {
            int ctrLen = 8;

            switch (RngEngine)
            {
                case Digests.Blake256:
                    return ctrLen + 32;
                case Digests.Blake512:
                    return ctrLen + 64;
                case Digests.Keccak1024:
                    return ctrLen + 72;
                case Digests.Keccak256:
                    return ctrLen + 136;
                case Digests.Keccak512:
                    return ctrLen + 72;
                case Digests.SHA256:
                    return ctrLen + 64;
                case Digests.SHA512:
                    return ctrLen + 128;
                case Digests.Skein1024:
                    return ctrLen + 128;
                case Digests.Skein256:
                    return ctrLen + 32;
                case Digests.Skein512:
                    return ctrLen + 64;
                default:
                    return ctrLen + 128;
            }
        }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:30,代码来源:DGCPrng.cs

示例9: GetDigest

 private IDigest GetDigest(Digests RngEngine)
 {
     switch (RngEngine)
     {
         case Digests.Blake256:
             return new Blake256();
         case Digests.Blake512:
             return new Blake512();
         case Digests.Keccak1024:
             return new Keccak1024();
         case Digests.Keccak256:
             return new Keccak256();
         case Digests.Keccak512:
             return new Keccak512();
         case Digests.SHA256:
             return new SHA256();
         case Digests.SHA512:
             return new SHA512();
         case Digests.Skein1024:
             return new Skein1024();
         case Digests.Skein256:
             return new Skein256();
         case Digests.Skein512:
             return new Skein512();
         default:
             return new SHA512();
     }
 }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:28,代码来源:DGCPrng.cs

示例10: DGCPrng

        /// <summary>
        /// Initialize the class with a Seed; note: the same seed will produce the same random output
        /// </summary>
        /// 
        /// <param name="Seed">The Seed bytes used to initialize the digest counter; (min. length is digest blocksize + 8)</param>
        /// <param name="DigestEngine">The digest that powers the rng (default is Keccak512)</param>
        /// <param name="BufferSize">The size of the internal state buffer in bytes; must be at least 128 bytes size (default is 1024)</param>
        /// 
        /// <exception cref="CryptoRandomException">Thrown if the seed is null or buffer size is too small; (min. seed = digest blocksize + 8)</exception>
        public DGCPrng(byte[] Seed, Digests DigestEngine = Digests.Keccak512, int BufferSize = BUFFER_SIZE)
        {
            if (Seed == null)
                throw new CryptoRandomException("DGCPrng:Ctor", "Seed can not be null!", new ArgumentNullException());
            if (GetMinimumSeedSize(DigestEngine) < Seed.Length)
                throw new CryptoRandomException("DGCPrng:Ctor", String.Format("The state seed is too small! must be at least {0} bytes", GetMinimumSeedSize(DigestEngine)), new ArgumentException());
            if (BufferSize < 128)
                throw new CryptoRandomException("DGCPrng:Ctor", "BufferSize must be at least 128 bytes!", new ArgumentException());

            _digestType = DigestEngine;
            _stateSeed = Seed;
            _byteBuffer = new byte[BufferSize];
            _bufferSize = BufferSize;
            Reset();
        }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:24,代码来源:DGCPrng.cs

示例11: DtmSession

 /// <summary>
 /// SessionParams constructor
 /// </summary>
 /// 
 /// <param name="EngineType">The Cryptographic <see cref="VTDev.Libraries.CEXEngine.Crypto.Enumeration.BlockCiphers">Engine</see> type</param>
 /// <param name="KeySize">The cipher Key Size in bytes</param>
 /// <param name="IvSize">Size of the cipher <see cref="VTDev.Libraries.CEXEngine.Crypto.Enumeration.IVSizes">Initialization Vector</see></param>
 /// <param name="RoundCount">The number of diffusion <see cref="VTDev.Libraries.CEXEngine.Crypto.Enumeration.RoundCounts">Rounds</see></param>
 /// <param name="KdfEngine">The <see cref="VTDev.Libraries.CEXEngine.Crypto.Enumeration.Digests">Digest</see> engine used to power the key schedule Key Derivation Function in HX and M series ciphers</param>
 /// 
 /// <exception cref="System.ArgumentOutOfRangeException">Thrown if an invalid KeyId, MessageKey, or ExtensionKey is used</exception>
 public DtmSession(BlockCiphers EngineType = BlockCiphers.RDX, int KeySize = 32, IVSizes IvSize = IVSizes.V128, RoundCounts RoundCount = RoundCounts.R14, Digests KdfEngine = Digests.SHA512)
 {
     this.EngineType = (byte)EngineType;
     this.KeySize = (short)KeySize;
     this.IvSize = (byte)IvSize;
     this.RoundCount = (byte)RoundCount;
     this.KdfEngine = (byte)KdfEngine;
 }
开发者ID:modulexcite,项目名称:CEX,代码行数:19,代码来源:DtmSession.cs

示例12: MPKCParameters

 /// <summary>
 /// Set the default parameters: extension degree
 /// </summary>
 /// 
 /// <param name="OId">OId - Unique identifier; <c>Family</c>, <c>Set</c>, <c>SubSet</c>, and <c>Designator</c>. The McEliece family must be <c>1</c> corresponding with the <see cref="AsymmetricEngines"/> enumeration.</param>
 /// <param name="CCA2Engine">The McEliece CCA2 cipher engine</param>
 /// <param name="Digest">The digest used by the cipher engine</param>
 /// <param name="Prng">The prng used by the cipher engine</param>
 public MPKCParameters(byte[] OId, CCA2Ciphers CCA2Engine = CCA2Ciphers.Fujisaki, Digests Digest = Digests.SHA256, Prngs Prng = Prngs.CTRPrng)
     : this(OId, DEFAULT_M, DEFAULT_T)
 {
     this.Digest = Digest;
     this.CCA2Engine = CCA2Engine;
     this.RandomEngine = Prng;
 }
开发者ID:modulexcite,项目名称:McEliece-Sharp,代码行数:15,代码来源:MPKCParameters.cs

示例13: GetKeyEngine

 private IDigest GetKeyEngine(Digests KeyEngine)
 {
     switch (KeyEngine)
     {
         case Digests.Blake256:
             return new Blake256();
         case Digests.Blake512:
             return new Blake512();
         case Digests.Keccak256:
             return new Keccak256();
         case Digests.Keccak512:
             return new Keccak512();
         case Digests.SHA256:
             return new SHA256();
         case Digests.SHA512:
             return new SHA512();
         case Digests.Skein256:
             return new Skein256();
         case Digests.Skein512:
             return new Skein512();
         case Digests.Skein1024:
             return new Skein1024();
         default:
             throw new CryptoSymmetricException("RSM:GetKeyEngine", "The digest type is not supported!", new ArgumentException());
     }
 }
开发者ID:modulexcite,项目名称:CEX,代码行数:26,代码来源:RSM.cs

示例14: SHX

        /// <summary>
        /// Initialize the class
        /// </summary>
        /// 
        /// <param name="Rounds">Number of diffusion rounds. The <see cref="LegalRounds"/> property contains available sizes. Default is 32 rounds.</param>
        /// <param name="KeyEngine">The Key Schedule KDF digest engine; can be any one of the <see cref="Digests">Digest</see> implementations. The default engine is <see cref="SHA512"/>.</param>
        /// 
        /// <exception cref="CryptoSymmetricException">Thrown if an invalid rounds count is chosen</exception>
        public SHX(int Rounds = ROUNDS32, Digests KeyEngine = Digests.SHA512)
        {
            if (Rounds != 32 && Rounds != 40 && Rounds != 48 && Rounds != 56 && Rounds != 64 && Rounds != 80 && Rounds != 96 && Rounds != 128)
                throw new CryptoSymmetricException("SHX:CTor", "Invalid rounds size! Sizes supported are 32, 40, 48, 56, 64, 80, 96 and 128.", new ArgumentOutOfRangeException());

            // get the kdf digest engine
            _keyEngine = GetKeyEngine(KeyEngine);
            // set the hmac key size
            _ikmSize = _ikmSize == 0 ? _keyEngine.DigestSize : _ikmSize;

            for (int i = 0; i < _legalKeySizes.Length; i++)
                _legalKeySizes[i] = (_keyEngine.BlockSize * (i + 1)) + _ikmSize;


            _dfnRounds = Rounds;
        }
开发者ID:DeadlyEmbrace,项目名称:NTRU-NET,代码行数:24,代码来源:SHX.cs

示例15: GetDigest

 /// <summary>
 /// Get the digest engine
 /// </summary>
 /// 
 /// <param name="Engine">Engine type</param>
 /// 
 /// <returns>Instance of digest</returns>
 /// 
 /// <exception cref="CryptoAsymmetricException">Thrown if the digest is unrecognized or unsupported</c></exception>
 private IDigest GetDigest(Digests Engine)
 {
     switch (Engine)
     {
         case Digests.Blake256:
             return new Blake256();
         case Digests.Blake512:
             return new Blake512();
         case Digests.Keccak256:
             return new Keccak256();
         case Digests.Keccak512:
             return new Keccak512();
         case Digests.SHA256:
             return new SHA256();
         case Digests.SHA512:
             return new SHA512();
         case Digests.Skein256:
             return new Skein256();
         case Digests.Skein512:
             return new Skein512();
         default:
             throw new CryptoAsymmetricException("MPKCSign:GetDigest", "The digest is unrecognized or unsupported!", new ArgumentException());
     }
 }
开发者ID:jesusgarza,项目名称:McEliece-Sharp,代码行数:33,代码来源:MPKCSign.cs


注:本文中的Digests类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。