Exemplo n.º 1
0
        public byte[] GetEncodedContents()
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.Write(pubKeyPacket.GetEncodedContents());

            pOut.WriteByte((byte)s2kUsage);

            if (s2kUsage == UsageChecksum || s2kUsage == UsageSha1)
            {
                pOut.WriteByte((byte)encAlgorithm);
                pOut.WriteObject(s2k);
            }

            if (iv != null)
            {
                pOut.Write(iv);
            }

            if (secKeyData != null && secKeyData.Length > 0)
            {
                pOut.Write(secKeyData);
            }

            return(bOut.ToArray());
        }
Exemplo n.º 2
0
 public override void Encode(
     BcpgOutputStream bcpgOut)
 {
     base.Encode(bcpgOut);
     bcpgOut.WriteByte(0x3);
     bcpgOut.WriteByte(reserved);
     bcpgOut.WriteByte((byte)hashFunctionId);
     bcpgOut.WriteByte((byte)symAlgorithmId);
 }
Exemplo n.º 3
0
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            bcpgOut.WriteByte((byte)type);
            bcpgOut.WriteByte((byte)algorithm);

            if (type != GnuDummyS2K)
            {
                if (type != 0)
                {
                    bcpgOut.Write(iv);
                }

                if (type == 3)
                {
                    bcpgOut.WriteByte((byte)itCount);
                }
            }
            else
            {
                bcpgOut.WriteByte((byte)'G');
                bcpgOut.WriteByte((byte)'N');
                bcpgOut.WriteByte((byte)'U');
                bcpgOut.WriteByte((byte)protectionMode);
            }
        }
Exemplo n.º 4
0
        public virtual byte[] GetEncodedContents()
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.WriteByte((byte)version);
            pOut.WriteInt((int)time);

            if (version <= 3)
            {
                pOut.WriteShort((short)validDays);
            }

            pOut.WriteByte((byte)algorithm);

            pOut.WriteObject((BcpgObject)key);

            return(bOut.ToArray());
        }
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.WriteByte((byte)version);

            pOut.WriteLong(keyId);

            pOut.WriteByte((byte)algorithm);

            for (int i = 0; i < data.Length; ++i)
            {
                pOut.Write(data[i]);
            }

            Platform.Dispose(pOut);

            bcpgOut.WritePacket(PacketTag.PublicKeyEncryptedSession, bOut.ToArray(), true);
        }
Exemplo n.º 6
0
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.WriteByte((byte)version);

            if (version == 3 || version == 2)
            {
                pOut.Write(
                    5,                     // the length of the next block
                    (byte)signatureType);

                pOut.WriteInt((int)(creationTime / 1000L));

                pOut.WriteLong(keyId);

                pOut.Write(
                    (byte)keyAlgorithm,
                    (byte)hashAlgorithm);
            }
            else if (version == 4)
            {
                pOut.Write(
                    (byte)signatureType,
                    (byte)keyAlgorithm,
                    (byte)hashAlgorithm);

                EncodeLengthAndData(pOut, GetEncodedSubpackets(hashedData));

                EncodeLengthAndData(pOut, GetEncodedSubpackets(unhashedData));
            }
            else
            {
                throw new IOException("unknown version: " + version);
            }

            pOut.Write(fingerprint);

            if (signature != null)
            {
                pOut.WriteObjects(signature);
            }
            else
            {
                pOut.Write(signatureEncoding);
            }

            bcpgOut.WritePacket(PacketTag.Signature, bOut.ToArray(), true);
        }
Exemplo n.º 7
0
        public override void Encode(
            BcpgOutputStream bcpgOut)
        {
            MemoryStream     bOut = new MemoryStream();
            BcpgOutputStream pOut = new BcpgOutputStream(bOut);

            pOut.Write(
                (byte)version,
                (byte)sigType,
                (byte)hashAlgorithm,
                (byte)keyAlgorithm);

            pOut.WriteLong(keyId);

            pOut.WriteByte((byte)nested);

            bcpgOut.WritePacket(PacketTag.OnePassSignature, bOut.ToArray(), true);
        }