Example #1
0
 public override void LoadPublicKey(TreeBuilder tree)
 {
     tree.AddNode("RSA Public Key");
     tree.PushByteBlock();
     ModN = tree.ReadMPIBytes("Mod n");
     Exp  = tree.ReadMPIBytes("Exp");
     tree.PopByteBlock();
 }
Example #2
0
 public override void LoadPublicKey(TreeBuilder tree)
 {
     tree.AddNode("Elgamal Public Key");
     tree.PushByteBlock();
     P = tree.ReadMPIBytes("Elgamal Prime p");
     G = tree.ReadMPIBytes("Elgamal group generator g");
     Y = tree.ReadMPIBytes("Elgamal public key value y");
     tree.PopByteBlock();
 }
Example #3
0
        public override ITransformedData LoadPublicKeyTransformedData(TreeBuilder tree)
        {
            var Data = new PublicKeyTransformedRSAData();

            tree.AddNode("RSA Encrypted Data");
            tree.PushByteBlock();
            Data.M_E_ModN = tree.ReadMPIBytes("m ^ e Mod n");
            tree.PopByteBlock();
            return(Data);
        }
Example #4
0
 public override void LoadPublicKey(TreeBuilder tree)
 {
     tree.AddNode("DSA Public Key");
     tree.PushByteBlock();
     P = tree.ReadMPIBytes("DSA Prime p");
     Q = tree.ReadMPIBytes("DSA group order q");
     G = tree.ReadMPIBytes("DSA group generator g");
     Y = tree.ReadMPIBytes("DSA public key value y");
     tree.PopByteBlock();
 }
Example #5
0
        public override ITransformedData LoadSecretKeyTransformedData(TreeBuilder tree)
        {
            var Data = new SecretKeyTransformedRSAData();

            tree.AddNode("RSA Signed Data");
            tree.PushByteBlock();
            Data.M_D_ModN = tree.ReadMPIBytes("m ^ d Mod n");
            tree.PopByteBlock();

            return(Data);
        }
Example #6
0
        // Signature Value
        // ???


        public override ITransformedData LoadPublicKeyTransformedData(TreeBuilder tree)
        {
            var Data = new PublicKeyTransformedElgamalData();

            tree.AddNode("Elgamal Encrypted Data");
            tree.PushByteBlock();
            Data.G_K_ModP   = tree.ReadMPIBytes("g ^ k Mod p");
            Data.M_Y_K_ModP = tree.ReadMPIBytes("m * y ^ k Mod p");
            tree.PopByteBlock();
            return(Data);
        }
Example #7
0
        public override ITransformedData LoadSecretKeyTransformedData(TreeBuilder tree)
        {
            var Data = new SecretKeyTransformedDSAData();

            tree.AddNode("DSA Signed Data");
            tree.PushByteBlock();
            Data.R = tree.ReadMPIBytes("r");
            Data.S = tree.ReadMPIBytes("r");
            tree.PopByteBlock();

            return(Data);
        }
Example #8
0
 private void ReadByteTags(TreeBuilder tree, string Label, int DataLength, Func <byte, string> DescFunc)
 {
     tree.AddNode(Label);
     tree.PushByteBlock();
     //tree.AddChildLevel = true;
     while (DataLength-- > 0)
     {
         tree.SetBookMark();
         byte ByteCode = tree.ReadByte();
         tree.GoToBookMark();
         //tree.Seek(-1);
         tree.ReadByte(DescFunc(ByteCode));
     }
     tree.PopByteBlock();
 }
Example #9
0
        public void Parse(TreeBuilder tree, int SubPacketsLength)
        {
            long SubPacketsEnd = tree.BaseReader.Position + SubPacketsLength;

            tree.PushByteBlock();

            //if (tree.Position < SubPacketsEnd)
            //    tree.AddChildLevel = true;

            while (tree.BaseReader.Position < SubPacketsEnd)
            {
                byte LengthFinder    = tree.ReadByte();
                uint SubPacketLength = 0;

                if (LengthFinder < 192)
                {
                    SubPacketLength = LengthFinder;
                }
                else if (LengthFinder < 255)
                {
                    byte b = tree.ReadByte();
                    SubPacketLength = (uint)((LengthFinder - 192) << 8) + b + 192;
                }
                else
                {
                    byte[] b = new byte[4];
                    b[0]            = tree.ReadByte();
                    b[1]            = tree.ReadByte();
                    b[2]            = tree.ReadByte();
                    b[3]            = tree.ReadByte();
                    SubPacketLength = Program.GetBigEndian(b, 0, 4);
                }

                byte   SubPacketType = tree.ReadByte();
                string Label         = SignatureSubPacketTypes.Get(SubPacketType);

                int DataLength = (int)SubPacketLength - 1;

                if (SubPacketType == SignatureSubPacketTypes.SignatureCreationTime)
                {
                    tree.ReadFormatted(Label, BlockFormat.UnixTime);
                }
                else if (SubPacketType == SignatureSubPacketTypes.Issuer)
                {
                    Issuer = tree.ReadBytes(Label, 8);
                }
                else if (SubPacketType == SignatureSubPacketTypes.KeyExpirationTime)
                {
                    tree.ReadFormatted(Label, BlockFormat.Days);
                }
                else if (SubPacketType == SignatureSubPacketTypes.PreferredSymmetricAlgorithm)
                {
                    ReadByteTags(tree, Label, DataLength, SymmetricAlgorithmTypes.Get);
                }
                else if (SubPacketType == SignatureSubPacketTypes.PreferredHashAlgorithm)
                {
                    ReadByteTags(tree, Label, DataLength, HashAlgorithmTypes.Get);
                }
                else if (SubPacketType == SignatureSubPacketTypes.PreferredCompressionAlgorithm)
                {
                    ReadByteTags(tree, Label, DataLength, CompressionAlgorithmTypes.Get);
                }
                else if (SubPacketType == SignatureSubPacketTypes.KeyFlags)
                {
                    ReadByteTags(tree, Label, DataLength, KeyFlagsTypes.Get);
                }
                else if (SubPacketType == SignatureSubPacketTypes.PrimaryUserId)
                {
                    tree.ReadBytes(Label, DataLength);
                }
                else if (SubPacketType == SignatureSubPacketTypes.ReasonForRevocation)
                {
                    tree.AddNode(Label);
                    tree.PushByteBlock();
                    tree.ReadByte("Reason", RevocationReasonTypes.Get);
                    tree.ReadBytes("Message", DataLength - 1);
                    tree.PopByteBlock();
                }
                else
                {
                    tree.ReadBytes(Label, DataLength);
                }
            }

            tree.PopByteBlock();
        }