The getEncoded() method in the public keys in the JCE produces a DER encoded one of these.
this.keyData = new DERBitString(publicKey); this.algId = algId;
if (seq.size() != 2) { throw new IllegalArgumentException("Bad sequence size: " + seq.size()); } Enumeration e = seq.getObjects(); this.algId = AlgorithmIdentifier.getInstance(e.nextElement()); this.keyData = DERBitString.getInstance(e.nextElement());
return algId;
return getInstance(ASN1Sequence.getInstance(obj, explicit));
if (obj instanceof SubjectPublicKeyInfo) { return (SubjectPublicKeyInfo)obj; } else if (obj instanceof ASN1Sequence) { return new SubjectPublicKeyInfo((ASN1Sequence)obj); } throw new IllegalArgumentException("unknown object in factory");
for when the public key is an encoded object - if the bitstring can't be decoded this routine throws an IOException.exceptionIOException - if the bit string doesn't represent a DER encoded object. ASN1InputStream aIn = new ASN1InputStream(keyData.getBytes()); return aIn.readObject();
ASN1InputStream aIn = new ASN1InputStream(keyData.getBytes()); return aIn.readObject();
for when the public key is raw bits... return keyData;
return keyData;
Produce an object suitable for an ASN1OutputStream. SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, publicKey BIT STRING } ASN1EncodableVector v = new ASN1EncodableVector(); v.add(algId); v.add(keyData); return new DERSequence(v);
SubjectPublicKeyInfo ::= SEQUENCE { algorithm AlgorithmIdentifier, publicKey BIT STRING }
ASN1EncodableVector v = new ASN1EncodableVector(); v.add(algId); v.add(keyData); return new DERSequence(v);