Ejemplo n.º 1
0
        private Stream Seal()
        {
            IDataSealer sealer;

            if (!level.HasValue || level.Value == Level.B_Level)
            {
                sealer = DataSealerFactory.Create(level == null ? Level.B_Level : level.Value, key);
            }
            else
            {
                sealer = DataSealerFactory.Create(level.Value, tsa, key);
            }

            Stream output = sealer.Seal(new MemoryStream(Encoding.UTF8.GetBytes(clearMessage)), bobEtk);

            return(output);
        }
Ejemplo n.º 2
0
        private Stream Seal(Level level)
        {
            IDataSealer sealer;

            if (level == Level.B_Level)
            {
                if (useSenderWKey)
                {
                    sealer = new DataSealerFactory().Create(level, senderWKey);
                }
                else
                {
                    sealer = new EhDataSealerFactory().Create(level, alice);
                }
            }
            else
            {
                if (useSenderWKey)
                {
                    sealer = new DataSealerFactory().Create(level, tsa, senderWKey);
                }
                else
                {
                    sealer = new EhDataSealerFactory().Create(level, tsa, alice);
                }
            }

            Stream output;

            if (useReceiverWKey)
            {
                output = sealer.Seal(new MemoryStream(Encoding.UTF8.GetBytes(clearMessage)), receiverWKey);
            }
            else
            {
                output = sealer.Seal(new MemoryStream(Encoding.UTF8.GetBytes(clearMessage)), bobEtk);
            }

            return(output);
        }