summary refs log tree commit diff
path: root/crypto/src/bcpg/TrustPacket.cs
blob: a2a30177fbb65c16ad758692238f3a9ced195cb5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.IO;

namespace Org.BouncyCastle.Bcpg
{
	/// <summary>Basic type for a trust packet.</summary>
    public class TrustPacket
        : ContainedPacket
    {
        private readonly byte[] levelAndTrustAmount;

		public TrustPacket(BcpgInputStream bcpgIn)
        {
            MemoryStream bOut = new MemoryStream();

			int ch;
            while ((ch = bcpgIn.ReadByte()) >= 0)
            {
                bOut.WriteByte((byte) ch);
            }

			levelAndTrustAmount = bOut.ToArray();
        }

		public TrustPacket(int trustCode)
        {
			this.levelAndTrustAmount = new byte[]{ (byte)trustCode };
        }

		public byte[] GetLevelAndTrustAmount()
		{
			return (byte[]) levelAndTrustAmount.Clone();
		}

		public override void Encode(BcpgOutputStream bcpgOut)
        {
            bcpgOut.WritePacket(PacketTag.Trust, levelAndTrustAmount);
        }
    }
}