Ejemplo n.º 1
0
        /// <exception cref="ArgumentNullException">factory == null. -or- signImpl == null. -or-
        /// publicKeyForm == null.</exception>
        /// <exception cref="InvalidOperationException">Login == null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Source: <see cref="CryptoFactoryBase.CreateHashAlgorithm(string, string)"/></exception>
        public byte[] CreateSign(CryptoFactoryBase factory, PublicKeyForm publicKeyForm, ISign signImpl,
                                 out byte[] hash)
        {
            if (publicKeyForm == null)
            {
                throw new ArgumentNullException(nameof(publicKeyForm))
                      {
                          Source = GetType().AssemblyQualifiedName
                      }
            }
            ;

            return(CreateSign(factory, publicKeyForm.HashAlg, publicKeyForm.CryptoProvider, signImpl, out hash));
        }
Ejemplo n.º 2
0
        /// <exception cref="ArgumentNullException">cryptoFactory == null. -or- publicKeyForm == null. -or-
        /// Source: <see cref="IAsymmetricKeysExchange.Import(byte[])"/>. -or- cryptoProvider == null. -or- hashAlgName == null. -or-
        /// signAlgName == null. -or- publicKey == null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Source: <see cref="CryptoFactoryBase.CreateHashAlgorithm(string, string)"/>. -or-
        /// Source: <see cref="CryptoFactoryBase.CreateSignAlgoritm(string, string)"/>. -or-
        /// Source: <see cref="IAsymmetricKeysExchange.Import(byte[])"/>.</exception>
        /// <exception cref="CryptographicException">Source: <see cref="IAsymmetricKeysExchange.Import(byte[])"/>.</exception>
        /// <exception cref="InvalidOperationException">Login == null.</exception>
        public bool ValidateSign(CryptoFactoryBase cryptoFactory, PublicKeyForm publicKeyForm)
        {
            if (cryptoFactory == null)
            {
                throw new ArgumentNullException(nameof(cryptoFactory))
                      {
                          Source = GetType().AssemblyQualifiedName
                      }
            }
            ;
            if (publicKeyForm == null)
            {
                throw new ArgumentNullException(nameof(publicKeyForm))
                      {
                          Source = GetType().AssemblyQualifiedName
                      }
            }
            ;
            if (Login == null)
            {
                throw new InvalidOperationException("Login == null.")
                      {
                          Source = GetType().AssemblyQualifiedName
                      }
            }
            ;

            try
            {
                return(ValidateSignImpl(cryptoFactory, publicKeyForm.CryptoProvider, publicKeyForm.HashAlg,
                                        publicKeyForm.CryptoAlg, publicKeyForm.Key));
            }
            catch (ArgumentOutOfRangeException ex)
            {
                //cryptoFactory.CreateHashAlgorithm(publicKeyForm.CryptoProvider, publicKeyForm.HashAlg);
                //cryptoFactory.CreateSignAlgoritm(publicKeyForm.CryptoProvider, publicKeyForm.CryptoAlg);
                //signAlg.Import(publicKeyForm.Key);
                throw;
            }
            catch (ArgumentNullException ex)
            {
                //signAlg.Import(publicKeyForm.Key);
                throw;
            }
            catch (CryptographicException ex)
            {
                //signAlg.Import(publicKeyForm.Key);
                throw;
            }
        }
Ejemplo n.º 3
0
 /// <exception cref="Exception">All exceptions from Source: <see cref="CreateSign(CryptoFactoryBase, PublicKeyForm, ISign, out byte[])"/>.</exception>
 public void CreateSign(CryptoFactoryBase factory, PublicKeyForm publicKeyForm, ISign signImpl)
 {
     byte[] hash;
     Sign = CreateSign(factory, publicKeyForm, signImpl, out hash);
     Hash = hash;
 }