/// <summary>
        /// Initializes a new instance of the <see cref="ElGamalDataProcessor"/> class.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        protected ElGamalDataProcessor(ElGamalKey key)
        {
            this.Key = key;

            this.PlaintextBlockSize  = key.GetPlaintextBlockSize();
            this.CiphertextBlockSize = key.GetCiphertextBlockSize();

            this.BlockSize = this.PlaintextBlockSize;
        }
        public static bool TryParseBytes(byte[] bytes, out ElGamalKey key)
        {
            try
            {
                if (bytes == null)
                {
                    throw new ArgumentNullException(nameof(key));
                }

                key = JsonConvert.DeserializeObject <ElGamalKey>(Encoding.UTF8.GetString(bytes));
                return(true);
            }
            catch
            {
                key = default(ElGamalKey);
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ElGamalEncryptor"/> class.
 /// </summary>
 /// <param name="key">
 /// The key.
 /// </param>
 public ElGamalEncryptor(ElGamalKey key) : base(key)
 {
     this.rng = RandomNumberGenerator.Create();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ElGamalDecryptor"/> class.
 /// </summary>
 /// <param name="key">
 /// The key.
 /// </param>
 public ElGamalDecryptor(ElGamalKey key)
     : base(key)
 {
     this.BlockSize = this.CiphertextBlockSize;
 }