AuthorityKeyIdentifierExtension::AuthorityKeyIdentifierExtension(X509_EXTENSION *ext)
throw (CertificationException) : Extension(ext)
{
    AUTHORITY_KEYID *authKeyId;
    if (this->objectIdentifier.getNid() != NID_authority_key_identifier)
    {
        throw CertificationException(CertificationException::INVALID_TYPE, "AuthorityKeyIdentifierExtension::AuthorityKeyIdentifierExtension");
    }
    authKeyId = (AUTHORITY_KEYID *)X509V3_EXT_d2i(ext);
    if (authKeyId->keyid)
    {
        this->keyIdentifier = ByteArray(authKeyId->keyid->data, authKeyId->keyid->length);
    }
    if (authKeyId->issuer)
    {
        this->authorityCertIssuer = GeneralNames(authKeyId->issuer);
    }
    if (authKeyId->serial)
    {
        this->serialNumber = ASN1_INTEGER_get(authKeyId->serial);
    }
    else
    {
        this->serialNumber = -1;
    }
    AUTHORITY_KEYID_free(authKeyId);
}
DeltaCRLIndicatorExtension::DeltaCRLIndicatorExtension(X509_EXTENSION* ext) throw (CertificationException) : Extension(ext)
{
	ASN1_INTEGER* serialAsn1 = NULL;
	
	if (OBJ_obj2nid(ext->object) != NID_delta_crl)
	{
		X509_EXTENSION_free(ext);
		throw CertificationException(CertificationException::INVALID_TYPE, "DeltaCRLIndicatorExtension::DeltaCRLIndicatorExtension");
	}
	serialAsn1 = (ASN1_INTEGER *)X509V3_EXT_d2i(ext);
	
	if(!serialAsn1)
	{	
		throw CertificationException(CertificationException::INTERNAL_ERROR, "DeltaCRLIndicatorExtension::DeltaCRLIndicatorExtension");
	}
	
	this->baseCrlNumber = ASN1_INTEGER_get(serialAsn1);
	ASN1_INTEGER_free(serialAsn1);
}
示例#3
0
Extension::Extension(X509_EXTENSION *ext) throw (CertificationException)
{
	if (ext == NULL)
	{
		throw CertificationException(CertificationException::INVALID_EXTENSION, "Extension::Extension");
	}
	this->objectIdentifier = ObjectIdentifier(OBJ_dup(ext->object));
	this->critical = X509_EXTENSION_get_critical(ext)?true:false;
	this->value = ByteArray(ext->value->data, ext->value->length);
}
SubjectKeyIdentifierExtension::SubjectKeyIdentifierExtension(X509_EXTENSION *ext)
		throw (CertificationException) : Extension(ext)
{
	ASN1_OCTET_STRING *octetString;
	if (OBJ_obj2nid(ext->object) != NID_subject_key_identifier)
	{
		throw CertificationException(CertificationException::INVALID_TYPE, "SubjectKeyIdentifierExtension::SubjectKeyIdentifierExtension");
	}
	octetString = (ASN1_OCTET_STRING *)X509V3_EXT_d2i(ext);
	keyIdentifier = ByteArray(octetString->data, octetString->length);
	ASN1_OCTET_STRING_free(octetString);
}