예제 #1
0
        /// <summary>
        /// Sign a hash of the input data using the supplied Signature Provider and encrypt with the private key.
        /// </summary>
        /// <param name="dataBytes">Data to be hashed and signed</param>
        /// <param name="signatureProvider">The signature provider to use for signature generation.</param>
        /// <returns>Signed hash bytes</returns>
        public byte[] SignData(byte[] dataBytes, ISignatureProvider signatureProvider)
        {
            if (m_isBusy == true)
            {
                throw new CryptographicException("Operation cannot be performed while a current key generation operation is in progress.");
            }

            if (m_KeyLoaded == false)
            {
                throw new CryptographicException("No key has been loaded.  You must import a key or make a call to GenerateKeys() before performing data operations.");
            }

            //Key validation is done in the DoEncryptPrivate method.
            return(DoEncryptPrivate(signatureProvider.EncodeSignature(dataBytes, m_RSAParams)));
        }
예제 #2
0
        /// <summary>
        /// Sign a hash of the input data using the supplied Signature Provider and encrypt with the private key.    
        /// </summary>
        /// <param name="dataBytes">Data to be hashed and signed</param>
        /// <param name="signatureProvider">The signature provider to use for signature generation.</param>
        /// <returns>Signed hash bytes</returns>
        public byte[] SignData(byte[] dataBytes, ISignatureProvider signatureProvider)
        {
            if (m_isBusy == true)
                throw new CryptographicException("Operation cannot be performed while a current key generation operation is in progress.");

            if (m_KeyLoaded == false)
                throw new CryptographicException("No key has been loaded.  You must import a key or make a call to GenerateKeys() before performing data operations.");

            //Key validation is done in the DoEncryptPrivate method.
            return DoEncryptPrivate(signatureProvider.EncodeSignature(dataBytes, m_RSAParams));
        }