📄 derapplicationspecific.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: DERApplicationSpecific.java
package org.bouncycastle.asn1;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
// Referenced classes of package org.bouncycastle.asn1:
// ASN1Object, ASN1InputStream, DEROutputStream, DEREncodable,
// DERObject
public class DERApplicationSpecific extends ASN1Object
{
private int tag;
private byte octets[];
public DERApplicationSpecific(int tag, byte octets[])
{
this.tag = tag;
this.octets = octets;
}
public DERApplicationSpecific(int tag, DEREncodable object)
throws IOException
{
this(true, tag, object);
}
public DERApplicationSpecific(boolean explicit, int tag, DEREncodable object)
throws IOException
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
DEROutputStream dos = new DEROutputStream(bOut);
dos.writeObject(object);
byte data[] = bOut.toByteArray();
if (tag >= 31)
throw new IOException("unsupported tag number");
if (explicit)
{
this.tag = tag | 0x20;
octets = data;
} else
{
this.tag = tag;
int lenBytes = getLengthOfLength(data);
byte tmp[] = new byte[data.length - lenBytes];
System.arraycopy(data, lenBytes, tmp, 0, tmp.length);
octets = tmp;
}
}
private int getLengthOfLength(byte data[])
{
int count;
for (count = 2; (data[count - 1] & 0x80) != 0; count++);
return count;
}
public boolean isConstructed()
{
return (tag & 0x20) != 0;
}
public byte[] getContents()
{
return octets;
}
public int getApplicationTag()
{
return tag;
}
public DERObject getObject()
throws IOException
{
return (new ASN1InputStream(getContents())).readObject();
}
public DERObject getObject(int derTagNo)
throws IOException
{
if (tag >= 31)
{
throw new IOException("unsupported tag number");
} else
{
byte tmp[] = getEncoded();
tmp[0] = (byte)derTagNo;
return (new ASN1InputStream(tmp)).readObject();
}
}
void encode(DEROutputStream out)
throws IOException
{
out.writeEncoded(0x40 | tag, octets);
}
boolean asn1Equals(DERObject o)
{
if (!(o instanceof DERApplicationSpecific))
return false;
DERApplicationSpecific other = (DERApplicationSpecific)o;
if (tag != other.tag)
return false;
if (octets.length != other.octets.length)
return false;
for (int i = 0; i < octets.length; i++)
if (octets[i] != other.octets[i])
return false;
return true;
}
public int hashCode()
{
byte b[] = getContents();
int value = 0;
for (int i = 0; i != b.length; i++)
value ^= (b[i] & 0xff) << i % 4;
return value ^ getApplicationTag();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -