Ejemplo n.º 1
0
        public void Deserialize(IValueReader reader, IPublicKeyCrypto crypto)
        {
            if (reader == null)
                throw new ArgumentNullException ("reader");
            if (crypto == null)
                throw new ArgumentNullException ("crypto");

            if (reader.ReadBool())
            {
                D = crypto.Decrypt (reader.ReadBytes());
                DP = crypto.Decrypt (reader.ReadBytes());
                DQ = crypto.Decrypt (reader.ReadBytes());
                InverseQ = crypto.Decrypt (reader.ReadBytes());
                P = crypto.Decrypt (reader.ReadBytes());
                Q = crypto.Decrypt (reader.ReadBytes());
            }

            if (reader.ReadBool())
            {
                byte[] exponent = crypto.Decrypt (reader.ReadBytes());

                byte[] modulus1 = crypto.Decrypt (reader.ReadBytes());
                byte[] modulus2 = crypto.Decrypt (reader.ReadBytes());
                byte[] modulus = modulus1.Concat (modulus2).ToArray();

                this.exponentOffset = modulus.Length;
                this.publicKey = new byte[exponent.Length + modulus.Length];
                Buffer.BlockCopy (modulus, 0, this.publicKey, 0, modulus.Length);
                Buffer.BlockCopy (exponent, 0, this.publicKey, exponentOffset, exponent.Length);
            }

            SetupSignature();
        }