// returns NULL if CSR doesn't contain the extension, the commitment C value otherwise BIGNUM *getCommitmentValueFromCSR(char *req_filename) { /* read in the request */ X509_REQ *req; FILE *fp; if (!(fp = fopen(req_filename, "r"))) critical_error("Error reading request file"); if (!(req = PEM_read_X509_REQ(fp, NULL, NULL, NULL))) critical_error("Error reading request in file"); fclose(fp); BIGNUM *toret = NULL; // enable the extension handling (retrieve/print as string) int nid = _commitmentExt_start(); // get extensions stack of request STACK_OF(X509_EXTENSION) *extlist = X509_REQ_get_extensions(req); if (extlist!=NULL) { // if there are extensions int extpos = X509v3_get_ext_by_NID(extlist, nid, -1); // try to locate extension if (extpos!=-1) { // if found X509_EXTENSION *ext = X509v3_get_ext(extlist, extpos); toret = _commitmentExt2BN(ext); } } X509_REQ_free(req); _commitmentExt_end(); return toret; }
int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos) { return X509v3_get_ext_by_NID(x->tbsRequest->requestExtensions, nid, lastpos); }
int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos) { return X509v3_get_ext_by_NID(x->singleExtensions, nid, lastpos); }
int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos) { return X509v3_get_ext_by_NID(x->tbsResponseData->responseExtensions, nid, lastpos); }
int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos) { return X509v3_get_ext_by_NID(x->singleRequestExtensions, nid, lastpos); }
int TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos) { return X509v3_get_ext_by_NID(a->extensions, nid, lastpos); }
int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->cert_info.extensions, nid, lastpos)); }
int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->crl.extensions, nid, lastpos)); }
int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos) { return (X509v3_get_ext_by_NID(x->extensions, nid, lastpos)); }
int TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos) { return X509v3_get_ext_by_NID(a->extensions, nid, lastpos); }
EXPORT_C int X509_CRL_get_ext_by_NID(X509_CRL *x, int nid, int lastpos) { return(X509v3_get_ext_by_NID(x->crl->extensions,nid,lastpos)); }
EXPORT_C int X509_get_ext_by_NID(X509 *x, int nid, int lastpos) { return(X509v3_get_ext_by_NID(x->cert_info->extensions,nid,lastpos)); }