*/
public void setPrivateKey(PrivateKey key) throws InvalidKeyException {
if (key == null)
throw new NullPointerException("Key is null!");
DERDecoder dec;
clear();
version_ = new ASN1Integer(VERSION);
add(version_);
algorithm_ = new AlgorithmIdentifier();
add(algorithm_);
encodedKey_ = new ASN1OctetString();
add(encodedKey_);
attributes_ = new ASN1SetOf(Attribute.class);
add(new ASN1TaggedType(0, attributes_, false, true));
try {
dec = new DERDecoder(new ByteArrayInputStream(key.getEncoded()));
decode(dec);
dec.close();
} catch (IOException e) {
throw new InvalidKeyException("Caught IOException!");
} catch (ASN1Exception e) {
throw new InvalidKeyException("Bad encoding!");
}