📄 privatekeyinfo.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: PrivateKeyInfo.java
package jit.asn1.pkcs.pkcs8;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Enumeration;
import jit.asn1.*;
import jit.asn1.pkcs.PKCSObjectIdentifiers;
import jit.asn1.x509.AlgorithmIdentifier;
import jit.math.BigInteger;
public class PrivateKeyInfo
implements PKCSObjectIdentifiers, DEREncodable
{
private DERObject privKey;
private AlgorithmIdentifier algId;
private DERInteger version;
private ASN1Set attributes;
public PrivateKeyInfo(AlgorithmIdentifier algId, DERObject privateKey)
{
privKey = privateKey;
this.algId = algId;
}
public PrivateKeyInfo(AlgorithmIdentifier algId, DERObject privateKey, ASN1Set attributes)
{
privKey = privateKey;
this.algId = algId;
this.attributes = attributes;
}
public PrivateKeyInfo(ASN1Sequence seq)
{
Enumeration e = seq.getObjects();
BigInteger version = ((DERInteger)e.nextElement()).getValue();
if(version.intValue() != 0)
throw new IllegalArgumentException(String.valueOf(String.valueOf((new StringBuffer("wrong version:")).append(version.intValue()).append(" for private key info"))));
algId = new AlgorithmIdentifier((ASN1Sequence)e.nextElement());
try
{
ByteArrayInputStream bIn = new ByteArrayInputStream(((ASN1OctetString)e.nextElement()).getOctets());
DERInputStream dIn = new DERInputStream(bIn);
privKey = dIn.readObject();
}
catch(IOException ex)
{
throw new IllegalArgumentException("Error recoverying private key from sequence");
}
if(e.hasMoreElements())
attributes = ASN1Set.getInstance((ASN1TaggedObject)e.nextElement(), false);
}
public AlgorithmIdentifier getAlgorithmId()
{
return algId;
}
public DERObject getPrivateKey()
{
return privKey;
}
public ASN1Set getAttributes()
{
return attributes;
}
public DERObject getDERObject()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DERInteger(0));
v.add(algId);
v.add(new DEROctetString(privKey));
if(attributes != null)
v.add(new DERTaggedObject(false, 0, attributes));
return new DERSequence(v);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -