Beispiel #1
0
    public override void Encode(BcpgOutputStream bcpgOut)
    {
        MemoryStream     memoryStream     = new MemoryStream();
        BcpgOutputStream bcpgOutputStream = new BcpgOutputStream(memoryStream);

        bcpgOutputStream.WriteByte((byte)version);
        if (version == 3 || version == 2)
        {
            bcpgOutputStream.Write(5, (byte)signatureType);
            bcpgOutputStream.WriteInt((int)(creationTime / 1000));
            bcpgOutputStream.WriteLong(keyId);
            bcpgOutputStream.Write((byte)keyAlgorithm, (byte)hashAlgorithm);
        }
        else
        {
            if (version != 4)
            {
                throw new IOException("unknown version: " + version);
            }
            bcpgOutputStream.Write((byte)signatureType, (byte)keyAlgorithm, (byte)hashAlgorithm);
            EncodeLengthAndData(bcpgOutputStream, GetEncodedSubpackets(hashedData));
            EncodeLengthAndData(bcpgOutputStream, GetEncodedSubpackets(unhashedData));
        }
        bcpgOutputStream.Write(fingerprint);
        if (signature != null)
        {
            bcpgOutputStream.WriteObjects(signature);
        }
        else
        {
            bcpgOutputStream.Write(signatureEncoding);
        }
        bcpgOut.WritePacket(PacketTag.Signature, memoryStream.ToArray(), oldFormat: true);
    }
Beispiel #2
0
    public override void Encode(BcpgOutputStream bcpgOut)
    {
        MemoryStream     memoryStream     = new MemoryStream();
        BcpgOutputStream bcpgOutputStream = new BcpgOutputStream(memoryStream);

        bcpgOutputStream.Write((byte)version, (byte)sigType, (byte)hashAlgorithm, (byte)keyAlgorithm);
        bcpgOutputStream.WriteLong(keyId);
        bcpgOutputStream.WriteByte((byte)nested);
        bcpgOut.WritePacket(PacketTag.OnePassSignature, memoryStream.ToArray(), oldFormat: true);
    }
    public override void Encode(BcpgOutputStream bcpgOut)
    {
        MemoryStream     memoryStream     = new MemoryStream();
        BcpgOutputStream bcpgOutputStream = new BcpgOutputStream(memoryStream);

        bcpgOutputStream.WriteByte((byte)version);
        bcpgOutputStream.WriteLong(keyId);
        bcpgOutputStream.WriteByte((byte)algorithm);
        for (int i = 0; i < data.Length; i++)
        {
            bcpgOutputStream.Write(data[i]);
        }
        Platform.Dispose(bcpgOutputStream);
        bcpgOut.WritePacket(PacketTag.PublicKeyEncryptedSession, memoryStream.ToArray(), oldFormat: true);
    }