static int extract_certificate_and_pkey(PluginInstance *inst, X509 **x509_out, EVP_PKEY **pkey_out) { int r; X509 *x509 = NULL; struct sc_pkcs15_id cert_id; struct sc_priv_data *priv = NULL; EVP_PKEY *pkey = NULL; RSA *rsa = NULL; r = init_pkcs15(inst); if (r) goto err; r = get_certificate(inst, &x509, &cert_id); if (r) goto err; r = -1; pkey = X509_get_pubkey(x509); if (pkey == NULL) goto err; if (pkey->type != EVP_PKEY_RSA) goto err; rsa = EVP_PKEY_get1_RSA(pkey); /* increases ref count */ if (rsa == NULL) goto err; rsa->flags |= RSA_FLAG_SIGN_VER; RSA_set_method(rsa, sc_get_method()); priv = (struct sc_priv_data *) calloc(1, sizeof(*priv)); if (priv == NULL) goto err; priv->cert_id = cert_id; priv->ref_count = 1; RSA_set_app_data(rsa, priv); RSA_free(rsa); /* decreases ref count */ *x509_out = x509; *pkey_out = pkey; return 0; err: if (pkey) EVP_PKEY_free(pkey); if (x509) X509_free(x509); return -1; }
int send_certificate(FILE* log_server, char * ciphersuite_to_use){ char * link_certificate = "./certificate_server/RSA_cert.pem"; char * certificate = get_certificate(link_certificate); // Send message to the channel FILE* channel = fopen(link_channel,"w"); send_message (channel, 4, TLS_VERSION, TLS_HANDSHAKE, TLS_SERVER_CERTIFICATE, certificate); fclose(channel); // Save message in log_server send_message (log_server, 5, sending, TLS_VERSION, TLS_HANDSHAKE, TLS_SERVER_CERTIFICATE, certificate); fprintf(log_server, "\n\n"); //free(certificate); return 1; }
int main (int argc, char *argv[]) { int result, der_len; unsigned char der[1024]; ASN1_TYPE PKIX1Implicit88 = ASN1_TYPE_EMPTY; char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE]; if (1) result = asn1_array2tree (pkix_asn1_tab, &PKIX1Implicit88, errorDescription); else result = asn1_parser2tree ("pkix.asn", &PKIX1Implicit88, errorDescription); if (result != ASN1_SUCCESS) { asn1_perror (result); printf ("%s", errorDescription); exit (1); } /* Use the following 3 lines to visit the PKIX1Implicit structures */ /* printf("-----------------\n"); asn1_visit_tree(PKIX1Implicit88,"PKIX1Implicit88"); printf("-----------------\n"); */ der_len = 1024; create_certificate (PKIX1Implicit88, der, &der_len); get_certificate (PKIX1Implicit88, der, der_len); /* Clear the "PKIX1Implicit88" structures */ asn1_delete_structure (&PKIX1Implicit88); return 0; }
propt::resultt qbf_skizzo_coret::prop_solve() { // sKizzo crashes on empty instances if(no_clauses()==0) return P_SATISFIABLE; { std::string msg= "Skizzo: "+ i2string(no_variables())+" variables, "+ i2string(no_clauses())+" clauses"; messaget::status(msg); } std::string result_tmp_file="sKizzo.out"; { std::ofstream out(qbf_tmp_file.c_str()); // write it break_lines=false; write_qdimacs_cnf(out); } std::string options=""; // solve it system(("sKizzo -log "+qbf_tmp_file+ options+ " > "+result_tmp_file).c_str()); bool result=false; // read result { std::ifstream in(result_tmp_file.c_str()); bool result_found=false; while(in) { std::string line; std::getline(in, line); if(line!="" && line[line.size()-1]=='\r') line.resize(line.size()-1); if(line=="The instance evaluates to TRUE.") { result=true; result_found=true; break; } else if(line=="The instance evaluates to FALSE.") { result=false; result_found=true; break; } } if(!result_found) { messaget::error("Skizzo failed: unknown result"); return P_ERROR; } } remove(result_tmp_file.c_str()); remove(qbf_tmp_file.c_str()); if(result) { messaget::status("Skizzo: TRUE"); if(get_certificate()) return P_ERROR; return P_SATISFIABLE; } else { messaget::status("Skizzo: FALSE"); return P_UNSATISFIABLE; } }