*
*/
public class AuthorityKeyIdentifier
- implements DEREncodable
+ implements DEREncodable, DERTags
{
- DEROctetString keyidentifier=null;
+ ASN1OctetString keyidentifier=null;
GeneralNames certissuer=null;
DERInteger certserno=null;
+ public static AuthorityKeyIdentifier getInstance(
+ ASN1TaggedObject obj,
+ boolean explicit)
+ {
+ return getInstance(ASN1Sequence.getInstance(obj, explicit));
+ }
+
+ public static AuthorityKeyIdentifier getInstance(
+ Object obj)
+ {
+ if (obj instanceof AuthorityKeyIdentifier)
+ {
+ return (AuthorityKeyIdentifier)obj;
+ }
+ else if (obj instanceof ASN1Sequence)
+ {
+ return new AuthorityKeyIdentifier((ASN1Sequence)obj);
+ }
+
+ throw new IllegalArgumentException("unknown object in factory");
+ }
+
public AuthorityKeyIdentifier(
- DERConstructedSequence seq)
+ ASN1Sequence seq)
{
- Enumeration e = seq.getObjects();
+ Enumeration e = seq.getObjects();
while (e.hasMoreElements())
{
switch (o.getTagNo())
{
case 0:
- this.keyidentifier= (DEROctetString)o.getObject();
+ this.keyidentifier = ASN1OctetString.getInstance(o, false);
break;
-
case 1:
- if (o.getObject() instanceof DERConstructedSequence)
- {
- this.certissuer = new GeneralNames((DERConstructedSequence)o.getObject());
- }
- else
- {
- // as it's implicitly tagged we can loose the"sequence"
- // if there is only one object.
- //
- DERConstructedSequence s = new DERConstructedSequence();
-
- s.addObject(o.getObject());
-
- this.certissuer = new GeneralNames(s);
- }
+ this.certissuer = GeneralNames.getInstance(o, false);
break;
case 2:
- //
- // implicit tagging again...
- //
- DEROctetString oct = (DEROctetString)o.getObject();
-
- this.certserno = new DERInteger(new BigInteger(oct.getOctets()));
+ this.certserno = DERInteger.getInstance(o, false);
break;
default:
throw new IllegalArgumentException("illegal tag");
Digest digest = new SHA1Digest();
byte[] resBuf = new byte[digest.getDigestSize()];
- DERBitString derpk = new DERBitString(spki.getPublicKey());
- byte[] bytes = derpk.getBytes();
+ byte[] bytes = spki.getPublicKeyData().getBytes();
digest.update(bytes, 0, bytes.length);
digest.doFinal(resBuf, 0);
- this.keyidentifier=new DEROctetString(resBuf);
+ this.keyidentifier = new DEROctetString(resBuf);
}
/**
Digest digest = new SHA1Digest();
byte[] resBuf = new byte[digest.getDigestSize()];
- DERBitString derpk = new DERBitString(spki.getPublicKey());
- byte[] bytes = derpk.getBytes();
+ byte[] bytes = spki.getPublicKeyData().getBytes();
digest.update(bytes, 0, bytes.length);
digest.doFinal(resBuf, 0);