Beispiel #1
0
        /// <summary>Creates the encrypted key exchange data from the specified input data.</summary>
        /// <returns>The encrypted key exchange data to be sent to the intended recipient.</returns>
        /// <param name="rgbData">The secret information to be passed in the key exchange. </param>
        /// <exception cref="T:System.Security.Cryptography.CryptographicUnexpectedOperationException">The key is missing.</exception>
        /// <PermissionSet>
        ///   <IPermission class="System.Security.Permissions.KeyContainerPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        /// </PermissionSet>
        public override byte[] CreateKeyExchange(byte[] rgbData)
        {
            if (this.random == null)
            {
                this.random = RandomNumberGenerator.Create();
            }
            if (this.rsa == null)
            {
                string text = Locale.GetText("No RSA key specified");
                throw new CryptographicUnexpectedOperationException(text);
            }
            SHA1 hash = SHA1.Create();

            return(PKCS1.Encrypt_OAEP(this.rsa, hash, this.random, rgbData));
        }
        public override byte[] CreateKeyExchange(byte[] rgbData)
        {
            if (random == null)
            {
                random = RandomNumberGenerator.Create();                   // create default
            }
            if (rsa == null)
            {
                string msg = Locale.GetText("No RSA key specified");
                throw new CryptographicUnexpectedOperationException(msg);
            }
            SHA1 sha1 = SHA1.Create();

            return(PKCS1.Encrypt_OAEP(rsa, sha1, random, rgbData));
        }