macdata.java

来自「《移动Agent技术》一书的所有章节源代码。」· Java 代码 · 共 70 行

JAVA
70
字号
package org.bouncycastle.asn1.pkcs;import java.math.BigInteger;import org.bouncycastle.asn1.*;import org.bouncycastle.asn1.x509.*;public class MacData    implements DEREncodable{	DERConstructedSequence		seq;	DigestInfo					digInfo;    byte[]                      salt;    BigInteger                  iterationCount;	public MacData(		DERConstructedSequence	seq)	{		this.seq = seq;		this.digInfo = new DigestInfo((DERConstructedSequence)seq.getObjectAt(0));		this.salt = ((DEROctetString)seq.getObjectAt(1)).getOctets();        if (seq.getSize() == 3)        {            this.iterationCount = ((DERInteger)seq.getObjectAt(2)).getValue();        }        else        {            this.iterationCount = BigInteger.valueOf(1);        }	}    public MacData(        DigestInfo  digInfo,        byte[]      salt,        int         iterationCount)    {        this.digInfo = digInfo;        this.salt = salt;        this.iterationCount = BigInteger.valueOf(iterationCount);    }	public DigestInfo getMac()	{		return digInfo;	}    public byte[] getSalt()    {        return salt;    }    public BigInteger getIterationCount()    {        return iterationCount;    }    public DERObject getDERObject()    {        DERConstructedSequence  seq = new DERConstructedSequence();        seq.addObject(digInfo);        seq.addObject(new DEROctetString(salt));        seq.addObject(new DERInteger(iterationCount));        return seq;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?