Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="NerdyMishka.Security.Cryptography.HMACBlockStream"/> class.
        /// </summary>
        /// <param name="innerStream">The stream that will be read or written to.</param>
        /// <param name="write">If true, the stream will be written to; otherwise, read from.</param>
        /// <param name="encoding">The encoding that the stream should use.</param>
        /// <param name="keyedHashAlgorithm">The keyed hash algorithm used to create an authentication code.</param>
        /// <param name="key">The key for the keyed hash algorithm.</param>
        public HMACBlockStream(
            Stream innerStream,
            bool write,
            Encoding encoding,
            KeyedHashAlgorithmType keyedHashAlgorithm,
            byte[] key)
            : this(innerStream, write, encoding, HashAlgorithmName.SHA256)
        {
            var signer = KeyedHashAlgorithm.Create(keyedHashAlgorithm.ToString());

            signer.Key  = key;
            this.signer = signer;
        }
 /// <summary>
 /// Initializes a new instance of the KeyedHashAlgorithm class with the specified algorithm and key object.
 /// </summary>
 /// <param name="algorithm">The keyed hash algorithm to be used (HMACSHA1, HMACRIPEMD160, etc.)</param>
 /// <param name="key">The Cryptoki key object that will be used to sign the hashed value.</param>
 public KeyedHashAlgorithm(KeyedHashAlgorithmType algorithm, CryptoKey key)
     : base((HashAlgorithmType)algorithm, key.Session)
 {
     Key = key;
     OwnsKey = false;
 }
 /// <summary>
 /// Initializes a new instance of the KeyedHashAlgorithm class with the specified algorithm and crypto service provider.
 /// </summary>
 /// <param name="algorithm">The keyed hash algorithm to be used (HMACSHA1, HMACRIPEMD160, etc.)</param>
 /// <param name="serviceProvider">The crypto service provider that will be used for the keyed hash operation.</param>
 public KeyedHashAlgorithm(KeyedHashAlgorithmType algorithm, string serviceProvider="")
     : base((HashAlgorithmType)algorithm, serviceProvider)
 {
     GenerateKey(HashSize);
     OwnsKey = true;
 }
 /// <summary>
 /// Initializes a new instance of the KeyedHashAlgorithm class with the specified algorithm and session context.
 /// </summary>
 /// <param name="algorithm">The keyed hash algorithm to be used (HMACSHA1, HMACRIPEMD160, etc.)</param>
 /// <param name="session">The Cryptoki session context to associate with the keyed hash algorithm.</param>
 public KeyedHashAlgorithm(KeyedHashAlgorithmType algorithm, Session session)
     : base((HashAlgorithmType)algorithm, session)
 {
     GenerateKey(HashSize);
     OwnsKey = true;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the KeyedHashAlgorithm class with the specified algorithm and key object.
 /// </summary>
 /// <param name="algorithm">The keyed hash algorithm to be used (HMACSHA1, HMACRIPEMD160, etc.)</param>
 /// <param name="key">The Cryptoki key object that will be used to sign the hashed value.</param>
 public KeyedHashAlgorithm(KeyedHashAlgorithmType algorithm, CryptoKey key)
     : base((HashAlgorithmType)algorithm, key.Session)
 {
     Key     = key;
     OwnsKey = false;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the KeyedHashAlgorithm class with the specified algorithm and crypto service provider.
 /// </summary>
 /// <param name="algorithm">The keyed hash algorithm to be used (HMACSHA1, HMACRIPEMD160, etc.)</param>
 /// <param name="serviceProvider">The crypto service provider that will be used for the keyed hash operation.</param>
 public KeyedHashAlgorithm(KeyedHashAlgorithmType algorithm, string serviceProvider = "")
     : base((HashAlgorithmType)algorithm, serviceProvider)
 {
     GenerateKey(HashSize);
     OwnsKey = true;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the KeyedHashAlgorithm class with the specified algorithm and session context.
 /// </summary>
 /// <param name="algorithm">The keyed hash algorithm to be used (HMACSHA1, HMACRIPEMD160, etc.)</param>
 /// <param name="session">The Cryptoki session context to associate with the keyed hash algorithm.</param>
 public KeyedHashAlgorithm(KeyedHashAlgorithmType algorithm, Session session)
     : base((HashAlgorithmType)algorithm, session)
 {
     GenerateKey(HashSize);
     OwnsKey = true;
 }