Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TrustPacket.java « bcpg « bouncycastle « org « java « main « src « pg - gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 05a0032265acbcb085d85f51afb97be64c689775 (plain)
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
41
42
43
44
45
46
47
48
package org.bouncycastle.bcpg;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * Basic type for a trust packet
 */
public class TrustPacket 
    extends ContainedPacket
{    
    byte[]    levelAndTrustAmount;
    
    public TrustPacket(
        BCPGInputStream  in)
        throws IOException
    {
        ByteArrayOutputStream    bOut = new ByteArrayOutputStream();
        int                      ch;
        
        while ((ch = in.read()) >= 0)
        {
            bOut.write(ch);
        }
        
        levelAndTrustAmount = bOut.toByteArray();
    }
    
    public TrustPacket(
        int    trustCode)
    {
        this.levelAndTrustAmount = new byte[1];
        
        this.levelAndTrustAmount[0] = (byte)trustCode;
    }

    public byte[] getLevelAndTrustAmount()
    {
        return levelAndTrustAmount;
    }

    public void encode(
        BCPGOutputStream    out)
        throws IOException
    {
        out.writePacket(TRUST, levelAndTrustAmount, true);
    }
}