这篇教程C++ BIO_write_filename函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中BIO_write_filename函数的典型用法代码示例。如果您正苦于以下问题:C++ BIO_write_filename函数的具体用法?C++ BIO_write_filename怎么用?C++ BIO_write_filename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了BIO_write_filename函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: MAIN//.........这里部分代码省略......... BIO_printf(bio_out, "%08lx/n", X509_NAME_hash(X509_CRL_get_issuer(x))); }#ifndef OPENSSL_NO_MD5 if (hash_old == i) { BIO_printf(bio_out, "%08lx/n", X509_NAME_hash_old(X509_CRL_get_issuer(x))); }#endif if (lastupdate == i) { BIO_printf(bio_out, "lastUpdate="); ASN1_TIME_print(bio_out, X509_CRL_get_lastUpdate(x)); BIO_printf(bio_out, "/n"); } if (nextupdate == i) { BIO_printf(bio_out, "nextUpdate="); if (X509_CRL_get_nextUpdate(x)) ASN1_TIME_print(bio_out, X509_CRL_get_nextUpdate(x)); else BIO_printf(bio_out, "NONE"); BIO_printf(bio_out, "/n"); } if (fingerprint == i) { int j; unsigned int n; unsigned char md[EVP_MAX_MD_SIZE]; if (!X509_CRL_digest(x, digest, md, &n)) { BIO_printf(bio_err, "out of memory/n"); goto end; } BIO_printf(bio_out, "%s Fingerprint=", OBJ_nid2sn(EVP_MD_type(digest))); for (j = 0; j < (int)n; j++) { BIO_printf(bio_out, "%02X%c", md[j], (j + 1 == (int)n) ? '/n' : ':'); } } } } out = BIO_new(BIO_s_file()); if (out == NULL) { ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto end; } } if (text) X509_CRL_print(out, x); if (noout) { ret = 0; goto end; } if (badsig) x->signature->data[x->signature->length - 1] ^= 0x1; if (outformat == FORMAT_ASN1) i = (int)i2d_X509_CRL_bio(out, x); else if (outformat == FORMAT_PEM) i = PEM_write_bio_X509_CRL(out, x); else { BIO_printf(bio_err, "bad output format specified for outfile/n"); goto end; } if (!i) { BIO_printf(bio_err, "unable to write CRL/n"); goto end; } ret = 0; end: if (ret != 0) ERR_print_errors(bio_err); BIO_free_all(out); BIO_free_all(bio_out); bio_out = NULL; X509_CRL_free(x); if (store) { X509_STORE_CTX_cleanup(&ctx); X509_STORE_free(store); } apps_shutdown(); OPENSSL_EXIT(ret);}
开发者ID:johnjohnsp1,项目名称:opensgx,代码行数:101,
示例2: MAIN//.........这里部分代码省略......... if (x == NULL) goto end; if (CA_flag) { xca = load_cert (bio_err, CAfile, CAformat, NULL, e, "CA Certificate"); if (xca == NULL) goto end; } if (!noout || text || next_serial) { OBJ_create ("2.99999.3", "SET.ex3", "SET x509v3 extension 3"); out = BIO_new (BIO_s_file ()); if (out == NULL) { ERR_print_errors (bio_err); goto end; } if (outfile == NULL) { BIO_set_fp (out, stdout, BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new (BIO_f_linebuffer ()); out = BIO_push (tmpbio, out); }#endif } else { if (BIO_write_filename (out, outfile) <= 0) { perror (outfile); goto end; } } } if (alias) X509_alias_set1 (x, (unsigned char *) alias, -1); if (clrtrust) X509_trust_clear (x); if (clrreject) X509_reject_clear (x); if (trust) { for (i = 0; i < sk_ASN1_OBJECT_num (trust); i++) { objtmp = sk_ASN1_OBJECT_value (trust, i); X509_add1_trust_object (x, objtmp); } } if (reject) { for (i = 0; i < sk_ASN1_OBJECT_num (reject); i++) { objtmp = sk_ASN1_OBJECT_value (reject, i); X509_add1_reject_object (x, objtmp); } }
开发者ID:274914765,项目名称:C,代码行数:67,
示例3: MAIN//.........这里部分代码省略......... goto end; } } BIO_printf(bio_err, "read EC key/n"); if (informat == FORMAT_ASN1) { if (pubin) eckey = d2i_EC_PUBKEY_bio(in, NULL); else eckey = d2i_ECPrivateKey_bio(in, NULL); } else if (informat == FORMAT_PEM) { if (pubin) eckey = PEM_read_bio_EC_PUBKEY(in, NULL, NULL, NULL); else eckey = PEM_read_bio_ECPrivateKey(in, NULL, NULL, passin); } else { BIO_printf(bio_err, "bad input format specified for key/n"); goto end; } if (eckey == NULL) { BIO_printf(bio_err, "unable to load Key/n"); ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE);# ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }# endif } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto end; } } group = EC_KEY_get0_group(eckey); if (new_form) EC_KEY_set_conv_form(eckey, form); if (new_asn1_flag) EC_KEY_set_asn1_flag(eckey, asn1_flag); if (text) if (!EC_KEY_print(out, eckey, 0)) { perror(outfile); ERR_print_errors(bio_err); goto end; } if (noout) { ret = 0; goto end; } BIO_printf(bio_err, "writing EC key/n"); if (outformat == FORMAT_ASN1) { if (param_out) i = i2d_ECPKParameters_bio(out, group); else if (pubin || pubout) i = i2d_EC_PUBKEY_bio(out, eckey); else i = i2d_ECPrivateKey_bio(out, eckey); } else if (outformat == FORMAT_PEM) { if (param_out) i = PEM_write_bio_ECPKParameters(out, group); else if (pubin || pubout) i = PEM_write_bio_EC_PUBKEY(out, eckey); else i = PEM_write_bio_ECPrivateKey(out, eckey, enc, NULL, 0, NULL, passout); } else { BIO_printf(bio_err, "bad output format specified for " "outfile/n"); goto end; } if (!i) { BIO_printf(bio_err, "unable to write private key/n"); ERR_print_errors(bio_err); } else ret = 0; end: if (in) BIO_free(in); if (out) BIO_free_all(out); if (eckey) EC_KEY_free(eckey); if (passin) OPENSSL_free(passin); if (passout) OPENSSL_free(passout); apps_shutdown(); OPENSSL_EXIT(ret);}
开发者ID:GrayKing,项目名称:Leakfix-on-OpenSSL,代码行数:101,
示例4: MAIN//.........这里部分代码省略......... " -f4 use F4 (0x10001) for the E value/n"); BIO_printf(bio_err, " -3 use 3 for the E value/n");# ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, " -engine e use engine e, possibly a hardware device./n");# endif BIO_printf(bio_err, " -rand file%cfile%c.../n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); BIO_printf(bio_err, " load the file (or the files in the directory) into/n"); BIO_printf(bio_err, " the random number generator/n"); goto err; } ERR_load_crypto_strings(); if (!app_passwd(bio_err, NULL, passargout, NULL, &passout)) { BIO_printf(bio_err, "Error getting password/n"); goto err; }# ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0);# endif if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE);# ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }# endif } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto err; } } if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL && !RAND_status()) { BIO_printf(bio_err, "warning, not much extra random data, consider using the -rand option/n"); } if (inrand != NULL) BIO_printf(bio_err, "%ld semi-random bytes loaded/n", app_RAND_load_files(inrand)); BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus/n", num);# ifdef OPENSSL_NO_ENGINE rsa = RSA_new();# else rsa = RSA_new_method(e);# endif if (!rsa) goto err; if (!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, &cb)) goto err; app_RAND_write_file(NULL, bio_err); /* * We need to do the following for when the base number size is < long, * esp windows 3.1 :-(.
开发者ID:bbidd985,项目名称:IEEE_Taggant_System,代码行数:67,
示例5: MAIN//.........这里部分代码省略......... ERR_load_crypto_strings(); in=BIO_new(BIO_s_file()); out=BIO_new(BIO_s_file()); if ((in == NULL) || (out == NULL)) { ERR_print_errors(bio_err); goto end; } if (infile == NULL) BIO_set_fp(in,OPENSSL_TYPE__FILE_STDIN,BIO_NOCLOSE); else { if (BIO_read_filename(in,infile) <= 0) { TINYCLR_SSL_PERROR(infile); goto end; } } if (outfile == NULL) { BIO_set_fp(out,OPENSSL_TYPE__FILE_STDOUT,BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out,outfile) <= 0) { TINYCLR_SSL_PERROR(outfile); goto end; } }#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0);#endif if (list_curves) { EC_builtin_curve *curves = NULL; size_t crv_len = 0; size_t n = 0; crv_len = EC_get_builtin_curves(NULL, 0); curves = (EC_builtin_curve*)OPENSSL_malloc((int)(sizeof(EC_builtin_curve) * crv_len)); if (curves == NULL) goto end; if (!EC_get_builtin_curves(curves, crv_len)) { OPENSSL_free(curves); goto end; } for (n = 0; n < crv_len; n++) {
开发者ID:Wampamba-Nooh,项目名称:MicroFrameworkSDK-Mono,代码行数:67,
示例6: MAIN//.........这里部分代码省略......... e = setup_engine(bio_err, engine, 0);#endif in=BIO_new(BIO_s_file()); out=BIO_new(BIO_s_file()); if ((in == NULL) || (out == NULL)) { ERR_print_errors(bio_err); goto end; } if (infile == NULL) BIO_set_fp(in,OPENSSL_TYPE__FILE_STDIN,BIO_NOCLOSE); else { if (BIO_read_filename(in,infile) <= 0) { TINYCLR_SSL_PERROR(infile); goto end; } } if (outfile == NULL) { BIO_set_fp(out,OPENSSL_TYPE__FILE_STDOUT,BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out,outfile) <= 0) { TINYCLR_SSL_PERROR(outfile); goto end; } } if (informat == FORMAT_ASN1) dh=d2i_DHparams_bio(in,NULL); else if (informat == FORMAT_PEM) dh=PEM_read_bio_DHparams(in,NULL,NULL,NULL); else { BIO_printf(bio_err,"bad input format specified/n"); goto end; } if (dh == NULL) { BIO_printf(bio_err,"unable to load DH parameters/n"); ERR_print_errors(bio_err); goto end; } if (text) { DHparams_print(out,dh);#ifdef undef TINYCLR_SSL_PRINTF("p="); BN_print(OPENSSL_TYPE__FILE_STDOUT,dh->p); TINYCLR_SSL_PRINTF("/ng="); BN_print(OPENSSL_TYPE__FILE_STDOUT,dh->g);
开发者ID:Wampamba-Nooh,项目名称:MicroFrameworkSDK-Mono,代码行数:67,
示例7: MAIN//.........这里部分代码省略......... dh=d2i_DHparams_bio(in,NULL); else /* informat == FORMAT_PEM */ dh=PEM_read_bio_DHparams(in,NULL,NULL,NULL); if (dh == NULL) { BIO_printf(bio_err,"unable to load DH parameters/n"); ERR_print_errors(bio_err); goto end; } } /* dh != NULL */ } out=BIO_new(BIO_s_file()); if (out == NULL) { ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out,outfile) <= 0) { perror(outfile); goto end; } } if (text) { DHparams_print(out,dh); } if (check) { if (!DH_check(dh,&i)) { ERR_print_errors(bio_err); goto end; } if (i & DH_CHECK_P_NOT_PRIME) printf("p value is not prime/n"); if (i & DH_CHECK_P_NOT_SAFE_PRIME) printf("p value is not a safe prime/n"); if (i & DH_UNABLE_TO_CHECK_GENERATOR) printf("unable to check the generator value/n"); if (i & DH_NOT_SUITABLE_GENERATOR) printf("the g value is not a generator/n"); if (i == 0) printf("DH parameters appear to be ok./n"); } if (C) {
开发者ID:aleeehaider825,项目名称:hachi-roku,代码行数:67,
示例8: mainint main(int argc, char *argv[]) { BN_CTX *ctx; BIO *out; char *outfile=NULL; results = 0; RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime may fail */ argc--; argv++; while (argc >= 1) { if (strcmp(*argv,"-results") == 0) results=1; else if (strcmp(*argv,"-out") == 0) { if (--argc < 1) break; outfile= *(++argv); } argc--; argv++; } ctx=BN_CTX_new(); if (ctx == NULL) EXIT(1); out=BIO_new(BIO_s_file()); if (out == NULL) EXIT(1); if (outfile == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE); } else { if (!BIO_write_filename(out,outfile)) { perror(outfile); EXIT(1); } } if (!results) BIO_puts(out,"obase=16/nibase=16/n"); message(out,"BN_add"); if (!test_add(out)) goto err; BIO_flush(out); message(out,"BN_sub"); if (!test_sub(out)) goto err; BIO_flush(out); message(out,"BN_lshift1"); if (!test_lshift1(out)) goto err; BIO_flush(out); message(out,"BN_lshift (fixed)"); if (!test_lshift(out,ctx,BN_bin2bn(lst,sizeof(lst)-1,NULL))) goto err; BIO_flush(out); message(out,"BN_lshift"); if (!test_lshift(out,ctx,NULL)) goto err; BIO_flush(out); message(out,"BN_rshift1"); if (!test_rshift1(out)) goto err; BIO_flush(out); message(out,"BN_rshift"); if (!test_rshift(out,ctx)) goto err; BIO_flush(out); message(out,"BN_sqr"); if (!test_sqr(out,ctx)) goto err; BIO_flush(out); message(out,"BN_mul"); if (!test_mul(out)) goto err; BIO_flush(out); message(out,"BN_div"); if (!test_div(out,ctx)) goto err; BIO_flush(out); message(out,"BN_div_recp"); if (!test_div_recp(out,ctx)) goto err; BIO_flush(out); message(out,"BN_mod"); if (!test_mod(out,ctx)) goto err; BIO_flush(out); message(out,"BN_mod_mul"); if (!test_mod_mul(out,ctx)) goto err; BIO_flush(out);//.........这里部分代码省略.........
开发者ID:froggatt,项目名称:edimax-br-6528n,代码行数:101,
示例9: MAIN//.........这里部分代码省略......... if (infile == NULL) BIO_set_fp(in,OPENSSL_TYPE__FILE_STDIN,BIO_NOCLOSE); else { if (BIO_read_filename(in,infile) <= 0) { TINYCLR_SSL_PERROR(infile); goto end; } } if (informat == FORMAT_ASN1) crl=d2i_X509_CRL_bio(in,NULL); else if (informat == FORMAT_PEM) crl=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL); else { BIO_printf(bio_err,"bad input format specified for input crl/n"); goto end; } if (crl == NULL) { BIO_printf(bio_err,"unable to load CRL/n"); ERR_print_errors(bio_err); goto end; } } if ((p7=PKCS7_new()) == NULL) goto end; if ((p7s=PKCS7_SIGNED_new()) == NULL) goto end; p7->type=OBJ_nid2obj(NID_pkcs7_signed); p7->d.sign=p7s; p7s->contents->type=OBJ_nid2obj(NID_pkcs7_data); if (!ASN1_INTEGER_set(p7s->version,1)) goto end; if ((crl_stack=sk_X509_CRL_new_null()) == NULL) goto end; p7s->crl=crl_stack; if (crl != NULL) { sk_X509_CRL_push(crl_stack,crl); crl=NULL; /* now part of p7 for OPENSSL_freeing */ } if ((cert_stack=sk_X509_new_null()) == NULL) goto end; p7s->cert=cert_stack; if(certflst) for(i = 0; i < sk_OPENSSL_STRING_num(certflst); i++) { certfile = sk_OPENSSL_STRING_value(certflst, i); if (add_certs_from_file(cert_stack,certfile) < 0) { BIO_printf(bio_err, "error loading certificates/n"); ERR_print_errors(bio_err); goto end; } } sk_OPENSSL_STRING_free(certflst); if (outfile == NULL) { BIO_set_fp(out,OPENSSL_TYPE__FILE_STDOUT,BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out,outfile) <= 0) { TINYCLR_SSL_PERROR(outfile); goto end; } } if (outformat == FORMAT_ASN1) i=i2d_PKCS7_bio(out,p7); else if (outformat == FORMAT_PEM) i=PEM_write_bio_PKCS7(out,p7); else { BIO_printf(bio_err,"bad output format specified for outfile/n"); goto end; } if (!i) { BIO_printf(bio_err,"unable to write pkcs7 object/n"); ERR_print_errors(bio_err); goto end; } ret=0;end: if (in != NULL) BIO_free(in); if (out != NULL) BIO_free_all(out); if (p7 != NULL) PKCS7_free(p7); if (crl != NULL) X509_CRL_free(crl); apps_shutdown(); OPENSSL_EXIT(ret); }
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:101,
示例10: main//.........这里部分代码省略......... print_hex_data(f, signature); fclose(f); } } else if (!strcmp(argv[1], "-convkey")) { if (argc < 6) { usage(); exit(1); } if (strcmp(argv[2], "b2o") == 0) { b2o = true; } else if (strcmp(argv[2], "o2b") == 0) { b2o = false; } else { die("either 'o2b' or 'b2o' must be defined for -convkey/n"); } if (strcmp(argv[3], "pub") == 0) { kpriv = false; } else if (strcmp(argv[3], "priv") == 0) { kpriv = true; } else { die("either 'pub' or 'priv' must be defined for -convkey/n"); } OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); ENGINE_load_builtin_engines(); if (bio_err == NULL) { bio_err = BIO_new_fp(stdout, BIO_NOCLOSE); } //enc=EVP_get_cipherbyname("des"); //if (enc == NULL) // die("could not get cypher./n"); // no encription yet. bio_out=BIO_new(BIO_s_file()); if (BIO_write_filename(bio_out,argv[5]) <= 0) { perror(argv[5]); die("could not create output file./n"); } if (b2o) { rsa_key_ = RSA_new(); if (kpriv) { fpriv = fopen(argv[4], "r"); if (!fpriv) { die("fopen"); } scan_key_hex(fpriv, (KEY*)&private_key, sizeof(private_key)); fclose(fpriv); private_to_openssl(private_key, &rsa_key); //i = PEM_write_bio_RSAPrivateKey(bio_out, &rsa_key, // enc, NULL, 0, pass_cb, NULL); // no encryption yet. //i = PEM_write_bio_RSAPrivateKey(bio_out, &rsa_key, // NULL, NULL, 0, pass_cb, NULL); fpriv = fopen(argv[5], "w+"); PEM_write_RSAPrivateKey(fpriv, &rsa_key, NULL, NULL, 0, 0, NULL); fclose(fpriv); //if (i == 0) { // ERR_print_errors(bio_err); // die("could not write key file./n"); //} } else { fpub = fopen(argv[4], "r"); if (!fpub) { die("fopen"); }
开发者ID:keyz182,项目名称:BOINC-7.0,代码行数:67,
示例11: enc_main//.........这里部分代码省略......... int retval; retval = snprintf(buf, sizeof buf, "enter %s %s password:", OBJ_nid2ln(EVP_CIPHER_nid(enc_config.cipher)), enc_config.enc ? "encryption" : "decryption"); if ((size_t)retval >= sizeof buf) { BIO_printf(bio_err, "Password prompt too long/n"); goto end; } strbuf[0] = '/0'; i = EVP_read_pw_string((char *)strbuf, SIZE, buf, enc_config.enc); if (i == 0) { if (strbuf[0] == '/0') { ret = 1; goto end; } enc_config.keystr = strbuf; break; } if (i < 0) { BIO_printf(bio_err, "bad password read/n"); goto end; } } } if (enc_config.outf == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); if (enc_config.bufsize != NULL) setvbuf(stdout, (char *)NULL, _IONBF, 0); } else { if (BIO_write_filename(out, enc_config.outf) <= 0) { perror(enc_config.outf); goto end; } } rbio = in; wbio = out;#ifdef ZLIB if (do_zlib) { if ((bzl = BIO_new(BIO_f_zlib())) == NULL) goto end; if (enc) wbio = BIO_push(bzl, wbio); else rbio = BIO_push(bzl, rbio); }#endif if (enc_config.base64) { if ((b64 = BIO_new(BIO_f_base64())) == NULL) goto end; if (enc_config.debug) { BIO_set_callback(b64, BIO_debug_callback); BIO_set_callback_arg(b64, (char *) bio_err); } if (enc_config.olb64) BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); if (enc_config.enc) wbio = BIO_push(b64, wbio); else rbio = BIO_push(b64, rbio);
开发者ID:LucaBongiorni,项目名称:nextgen,代码行数:67,
示例12: genrsa_main//.........这里部分代码省略......... else if (strcmp(*argv, "-aes256") == 0) enc = EVP_aes_256_cbc();#endif#ifndef OPENSSL_NO_CAMELLIA else if (strcmp(*argv, "-camellia128") == 0) enc = EVP_camellia_128_cbc(); else if (strcmp(*argv, "-camellia192") == 0) enc = EVP_camellia_192_cbc(); else if (strcmp(*argv, "-camellia256") == 0) enc = EVP_camellia_256_cbc();#endif else if (strcmp(*argv, "-passout") == 0) { if (--argc < 1) goto bad; passargout = *(++argv); } else break; argv++; argc--; } if ((argc >= 1) && ((sscanf(*argv, "%d", &num) == 0) || (num < 0))) { bad: BIO_printf(bio_err, "usage: genrsa [args] [numbits]/n"); BIO_printf(bio_err, " -des encrypt the generated key with DES in cbc mode/n"); BIO_printf(bio_err, " -des3 encrypt the generated key with DES in ede cbc mode (168 bit key)/n");#ifndef OPENSSL_NO_IDEA BIO_printf(bio_err, " -idea encrypt the generated key with IDEA in cbc mode/n");#endif#ifndef OPENSSL_NO_AES BIO_printf(bio_err, " -aes128, -aes192, -aes256/n"); BIO_printf(bio_err, " encrypt PEM output with cbc aes/n");#endif#ifndef OPENSSL_NO_CAMELLIA BIO_printf(bio_err, " -camellia128, -camellia192, -camellia256/n"); BIO_printf(bio_err, " encrypt PEM output with cbc camellia/n");#endif BIO_printf(bio_err, " -out file output the key to 'file/n"); BIO_printf(bio_err, " -passout arg output file pass phrase source/n"); BIO_printf(bio_err, " -f4 use F4 (0x10001) for the E value/n"); BIO_printf(bio_err, " -3 use 3 for the E value/n"); goto err; } if (!app_passwd(bio_err, NULL, passargout, NULL, &passout)) { BIO_printf(bio_err, "Error getting password/n"); goto err; } if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto err; } } BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus/n", num); rsa = RSA_new(); if (!rsa) goto err; if (!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, &cb)) goto err; /* * We need to do the following for when the base number size is < * long, esp windows 3.1 :-(. */ l = 0L; for (i = 0; i < rsa->e->top; i++) {#ifndef _LP64 l <<= BN_BITS4; l <<= BN_BITS4;#endif l += rsa->e->d[i]; } BIO_printf(bio_err, "e is %ld (0x%lX)/n", l, l); { PW_CB_DATA cb_data; cb_data.password = passout; cb_data.prompt_info = outfile; if (!PEM_write_bio_RSAPrivateKey(out, rsa, enc, NULL, 0, password_callback, &cb_data)) goto err; } ret = 0; err: BN_free(bn); RSA_free(rsa); BIO_free_all(out); free(passout); if (ret != 0) ERR_print_errors(bio_err); return (ret);}
开发者ID:bbbrumley,项目名称:openbsd,代码行数:101,
示例13: MAIN//.........这里部分代码省略......... TINYCLR_SSL_PERROR(infile); goto end; } } if (informat == FORMAT_ASN1) p7=d2i_PKCS7_bio(in,NULL); else if (informat == FORMAT_PEM) p7=PEM_read_bio_PKCS7(in,NULL,NULL,NULL); else { BIO_printf(bio_err,"bad input format specified for pkcs7 object/n"); goto end; } if (p7 == NULL) { BIO_printf(bio_err,"unable to load PKCS7 object/n"); ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out,OPENSSL_TYPE__FILE_STDOUT,BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out,outfile) <= 0) { TINYCLR_SSL_PERROR(outfile); goto end; } } if (p7_print) PKCS7_print_ctx(out, p7, 0, NULL); if (print_certs) { STACK_OF(X509) *certs=NULL; STACK_OF(X509_CRL) *crls=NULL; i=OBJ_obj2nid(p7->type); switch (i) { case NID_pkcs7_signed: certs=p7->d.sign->cert; crls=p7->d.sign->crl; break; case NID_pkcs7_signedAndEnveloped: certs=p7->d.signed_and_enveloped->cert; crls=p7->d.signed_and_enveloped->crl; break; default: break; } if (certs != NULL) { X509 *x;
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:67,
示例14: strcpystatic ASN1_INTEGER *load_serial(char *CAfile, char *serialfile, int create) { char *buf = NULL, *p; MS_STATIC char buf2[1024]; ASN1_INTEGER *bs = NULL, *bs2 = NULL; BIO *io = NULL; BIGNUM *serial = NULL; buf=OPENSSL_malloc( ((serialfile == NULL) ?(strlen(CAfile)+strlen(POSTFIX)+1) :(strlen(serialfile)))+1); if (buf == NULL) { BIO_printf(bio_err,"out of mem/n"); goto end; } if (serialfile == NULL) { strcpy(buf,CAfile); for (p=buf; *p; p++) if (*p == '.') { *p='/0'; break; } strcat(buf,POSTFIX); } else strcpy(buf,serialfile); serial=BN_new(); bs=ASN1_INTEGER_new(); if ((serial == NULL) || (bs == NULL)) { ERR_print_errors(bio_err); goto end; } io=BIO_new(BIO_s_file()); if (io == NULL) { ERR_print_errors(bio_err); goto end; } if (BIO_read_filename(io,buf) <= 0) { if (!create) { perror(buf); goto end; } else { ASN1_INTEGER_set(bs,1); BN_one(serial); } } else { if (!a2i_ASN1_INTEGER(io,bs,buf2,sizeof buf2)) { BIO_printf(bio_err,"unable to load serial number from %s/n",buf); ERR_print_errors(bio_err); goto end; } else { serial=BN_bin2bn(bs->data,bs->length,serial); if (serial == NULL) { BIO_printf(bio_err,"error converting bin 2 bn"); goto end; } } } if (!BN_add_word(serial,1)) { BIO_printf(bio_err,"add_word failure/n"); goto end; } if (!(bs2 = BN_to_ASN1_INTEGER(serial, NULL))) { BIO_printf(bio_err,"error converting bn 2 asn1_integer/n"); goto end; } if (BIO_write_filename(io,buf) <= 0) { BIO_printf(bio_err,"error attempting to write serial number file/n"); perror(buf); goto end; } i2a_ASN1_INTEGER(io,bs2); BIO_puts(io,"/n"); BIO_free(io); if (buf) OPENSSL_free(buf); ASN1_INTEGER_free(bs2); BN_free(serial); io=NULL; return bs; end: if (buf) OPENSSL_free(buf); BIO_free(io); ASN1_INTEGER_free(bs); BN_free(serial); return NULL; }
开发者ID:xyzy,项目名称:mips-openssl_0.9.7,代码行数:100,
示例15: gendh_mainintgendh_main(int argc, char **argv){ BN_GENCB cb; DH *dh = NULL; int ret = 1, num = DEFBITS; int g = 2; char *outfile = NULL;#ifndef OPENSSL_NO_ENGINE char *engine = NULL;#endif BIO *out = NULL; BN_GENCB_set(&cb, dh_cb, bio_err); argv++; argc--; for (;;) { if (argc <= 0) break; if (strcmp(*argv, "-out") == 0) { if (--argc < 1) goto bad; outfile = *(++argv); } else if (strcmp(*argv, "-2") == 0) g = 2; /* * else if (strcmp(*argv,"-3") == 0) g=3; */ else if (strcmp(*argv, "-5") == 0) g = 5;#ifndef OPENSSL_NO_ENGINE else if (strcmp(*argv, "-engine") == 0) { if (--argc < 1) goto bad; engine = *(++argv); }#endif else break; argv++; argc--; } if ((argc >= 1) && ((sscanf(*argv, "%d", &num) == 0) || (num < 0))) {bad: BIO_printf(bio_err, "usage: gendh [args] [numbits]/n"); BIO_printf(bio_err, " -out file - output the key to 'file/n"); BIO_printf(bio_err, " -2 - use 2 as the generator value/n"); /* * BIO_printf(bio_err," -3 - use 3 as the generator * value/n"); */ BIO_printf(bio_err, " -5 - use 5 as the generator value/n");#ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, " -engine e - use engine e, possibly a hardware device./n");#endif goto end; }#ifndef OPENSSL_NO_ENGINE setup_engine(bio_err, engine, 0);#endif out = BIO_new(BIO_s_file()); if (out == NULL) { ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto end; } } BIO_printf(bio_err, "Generating DH parameters, %d bit long safe prime, generator %d/n", num, g); BIO_printf(bio_err, "This is going to take a long time/n"); if (((dh = DH_new()) == NULL) || !DH_generate_parameters_ex(dh, num, g, &cb)) goto end; if (!PEM_write_bio_DHparams(out, dh)) goto end; ret = 0;end: if (ret != 0) ERR_print_errors(bio_err); if (out != NULL) BIO_free_all(out); if (dh != NULL) DH_free(dh); return (ret);}
开发者ID:LeSuisse,项目名称:libressl-salsa20,代码行数:95,
示例16: rand_mainintrand_main(int argc, char **argv){ char *num_bytes = NULL; int ret = 1; int badopt = 0; int num = -1; int i, r; BIO *out = NULL; memset(&rand_config, 0, sizeof(rand_config)); if (options_parse(argc, argv, rand_options, &num_bytes, NULL) != 0) { rand_usage(); return (1); } if (num_bytes != NULL) { r = sscanf(num_bytes, "%d", &num); if (r == 0 || num < 0) badopt = 1; } else badopt = 1; if (rand_config.hex && rand_config.base64) badopt = 1; if (badopt) { rand_usage(); goto err; }#ifndef OPENSSL_NO_ENGINE setup_engine(bio_err, rand_config.engine, 0);#endif out = BIO_new(BIO_s_file()); if (out == NULL) goto err; if (rand_config.outfile != NULL) r = BIO_write_filename(out, rand_config.outfile); else r = BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); if (r <= 0) goto err; if (rand_config.base64) { BIO *b64 = BIO_new(BIO_f_base64()); if (b64 == NULL) goto err; out = BIO_push(b64, out); } while (num > 0) { unsigned char buf[4096]; int chunk; chunk = num; if (chunk > (int) sizeof(buf)) chunk = sizeof(buf); arc4random_buf(buf, chunk); if (rand_config.hex) { for (i = 0; i < chunk; i++) BIO_printf(out, "%02x", buf[i]); } else BIO_write(out, buf, chunk); num -= chunk; } if (rand_config.hex) BIO_puts(out, "/n"); (void) BIO_flush(out); ret = 0;err: ERR_print_errors(bio_err); if (out) BIO_free_all(out); return (ret);}
开发者ID:Heratom,项目名称:Firefly-project,代码行数:81,
示例17: MAIN//.........这里部分代码省略......... pkey = load_pubkey(bio_err, infile, (informat == FORMAT_NETSCAPE && sgckey ? FORMAT_IISSGC : informat), 1, passin, e, "Public Key"); else pkey = load_key(bio_err, infile, (informat == FORMAT_NETSCAPE && sgckey ? FORMAT_IISSGC : informat), 1, passin, e, "Private Key"); if (pkey != NULL) rsa = pkey == NULL ? NULL : EVP_PKEY_get1_RSA(pkey); EVP_PKEY_free(pkey); } if (rsa == NULL) { ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out,outfile) <= 0) { perror(outfile); goto end; } } if (text) if (!RSA_print(out,rsa,0)) { perror(outfile); ERR_print_errors(bio_err); goto end; } if (modulus) { BIO_printf(out,"Modulus="); BN_print(out,rsa->n); BIO_printf(out,"/n"); } if (check) { int r = RSA_check_key(rsa); if (r == 1) BIO_printf(out,"RSA key ok/n"); else if (r == 0) { unsigned long err; while ((err = ERR_peek_error()) != 0 &&
开发者ID:aosm,项目名称:OpenSSL098,代码行数:67,
示例18: MAIN//.........这里部分代码省略......... BIO_printf(bio_err, "read DSA key/n"); { EVP_PKEY *pkey; if (pubin) pkey = load_pubkey(bio_err, infile, informat, 1, passin, e, "Public Key"); else pkey = load_key(bio_err, infile, informat, 1, passin, e, "Private Key"); if (pkey) { dsa = EVP_PKEY_get1_DSA(pkey); EVP_PKEY_free(pkey); } } if (dsa == NULL) { BIO_printf(bio_err, "unable to load Key/n"); ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE);# ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }# endif } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto end; } } if (text) if (!DSA_print(out, dsa, 0)) { perror(outfile); ERR_print_errors(bio_err); goto end; } if (modulus) { fprintf(stdout, "Public Key="); BN_print(out, dsa->pub_key); fprintf(stdout, "/n"); } if (noout) goto end; BIO_printf(bio_err, "writing DSA key/n"); if (outformat == FORMAT_ASN1) { if (pubin || pubout) i = i2d_DSA_PUBKEY_bio(out, dsa); else i = i2d_DSAPrivateKey_bio(out, dsa); } else if (outformat == FORMAT_PEM) { if (pubin || pubout) i = PEM_write_bio_DSA_PUBKEY(out, dsa); else i = PEM_write_bio_DSAPrivateKey(out, dsa, enc, NULL, 0, NULL, passout);
开发者ID:2trill2spill,项目名称:freebsd,代码行数:67,
示例19: MAIN//.........这里部分代码省略......... {bad: BIO_printf(bio_err,"usage: gendsa [args] dsaparam-file/n"); BIO_printf(bio_err," -out file - output the key to 'file'/n");#ifndef OPENSSL_NO_DES BIO_printf(bio_err," -des - encrypt the generated key with DES in cbc mode/n"); BIO_printf(bio_err," -des3 - encrypt the generated key with DES in ede cbc mode (168 bit key)/n");#endif#ifndef OPENSSL_NO_IDEA BIO_printf(bio_err," -idea - encrypt the generated key with IDEA in cbc mode/n");#endif#ifndef OPENSSL_NO_AES BIO_printf(bio_err," -aes128, -aes192, -aes256/n"); BIO_printf(bio_err," encrypt PEM output with cbc aes/n");#endif#ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device./n");#endif BIO_printf(bio_err," -rand file%cfile%c.../n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); BIO_printf(bio_err," - load the file (or the files in the directory) into/n"); BIO_printf(bio_err," the random number generator/n"); BIO_printf(bio_err," dsaparam-file/n"); BIO_printf(bio_err," - a DSA parameter file as generated by the dsaparam command/n"); goto end; }#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0);#endif if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) { BIO_printf(bio_err, "Error getting password/n"); goto end; } in=BIO_new(BIO_s_file()); if (!(BIO_read_filename(in,dsaparams))) { perror(dsaparams); goto end; } if ((dsa=PEM_read_bio_DSAparams(in,NULL,NULL,NULL)) == NULL) { BIO_printf(bio_err,"unable to load DSA parameter file/n"); goto end; } BIO_free(in); in = NULL; out=BIO_new(BIO_s_file()); if (out == NULL) goto end; if (outfile == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out,outfile) <= 0) { perror(outfile); goto end; } } if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL) { BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option/n"); } if (inrand != NULL) BIO_printf(bio_err,"%ld semi-random bytes loaded/n", app_RAND_load_files(inrand)); BIO_printf(bio_err,"Generating DSA key, %d bits/n", BN_num_bits(dsa->p)); if (!DSA_generate_key(dsa)) goto end; app_RAND_write_file(NULL, bio_err); if (!PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL, passout)) goto end; ret=0;end: if (ret != 0) ERR_print_errors(bio_err); if (in != NULL) BIO_free(in); if (out != NULL) BIO_free_all(out); if (dsa != NULL) DSA_free(dsa); if(passout) OPENSSL_free(passout); apps_shutdown(); OPENSSL_EXIT(ret); }
开发者ID:BlueFireworks,项目名称:AuroraUX-SunOS,代码行数:101,
示例20: MAINint MAIN(int argc, char **argv) { ENGINE *e = NULL; DH *dh=NULL; int ret=1,num=DEFBITS; int g=2; char *outfile=NULL; char *inrand=NULL; char *engine=NULL; BIO *out=NULL; apps_startup(); if (bio_err == NULL) if ((bio_err=BIO_new(BIO_s_file())) != NULL) BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT); if (!load_config(bio_err, NULL)) goto end; argv++; argc--; for (;;) { if (argc <= 0) break; if (strcmp(*argv,"-out") == 0) { if (--argc < 1) goto bad; outfile= *(++argv); } else if (strcmp(*argv,"-2") == 0) g=2; /* else if (strcmp(*argv,"-3") == 0) g=3; */ else if (strcmp(*argv,"-5") == 0) g=5; else if (strcmp(*argv,"-engine") == 0) { if (--argc < 1) goto bad; engine= *(++argv); } else if (strcmp(*argv,"-rand") == 0) { if (--argc < 1) goto bad; inrand= *(++argv); } else break; argv++; argc--; } if ((argc >= 1) && ((sscanf(*argv,"%d",&num) == 0) || (num < 0))) {bad: BIO_printf(bio_err,"usage: gendh [args] [numbits]/n"); BIO_printf(bio_err," -out file - output the key to 'file/n"); BIO_printf(bio_err," -2 - use 2 as the generator value/n"); /* BIO_printf(bio_err," -3 - use 3 as the generator value/n"); */ BIO_printf(bio_err," -5 - use 5 as the generator value/n"); BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device./n"); BIO_printf(bio_err," -rand file%cfile%c.../n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); BIO_printf(bio_err," - load the file (or the files in the directory) into/n"); BIO_printf(bio_err," the random number generator/n"); goto end; } e = setup_engine(bio_err, engine, 0); out=BIO_new(BIO_s_file()); if (out == NULL) { ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out,outfile) <= 0) { perror(outfile); goto end; } } if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL) { BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option/n"); } if (inrand != NULL) BIO_printf(bio_err,"%ld semi-random bytes loaded/n",//.........这里部分代码省略.........
开发者ID:xyzy,项目名称:mips-openssl_0.9.7,代码行数:101,
示例21: MAIN//.........这里部分代码省略......... else if (strcmp(argv[i], "-base64") == 0) { if (!base64) base64 = 1; else badopt = 1; } else if (isdigit((unsigned char)argv[i][0])) { if (num < 0) { r = sscanf(argv[i], "%d", &num); if (r == 0 || num < 0) badopt = 1; } else badopt = 1; } else badopt = 1; } if (num < 0) badopt = 1; if (badopt) { BIO_printf(bio_err, "Usage: rand [options] num/n"); BIO_printf(bio_err, "where options are/n"); BIO_printf(bio_err, "-out file - write to file/n");#ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, "-engine e - use engine e, possibly a hardware device./n");#endif BIO_printf(bio_err, "-rand file%cfile%c... - seed PRNG from files/n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR); BIO_printf(bio_err, "-base64 - encode output/n"); goto err; }#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0);#endif app_RAND_load_file(NULL, bio_err, (inrand != NULL)); if (inrand != NULL) BIO_printf(bio_err,"%ld semi-random bytes loaded/n", app_RAND_load_files(inrand)); out = BIO_new(BIO_s_file()); if (out == NULL) goto err; if (outfile != NULL) r = BIO_write_filename(out, outfile); else { r = BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT); #ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } if (r <= 0) goto err; if (base64) { BIO *b64 = BIO_new(BIO_f_base64()); if (b64 == NULL) goto err; out = BIO_push(b64, out); } while (num > 0) { unsigned char buf[4096]; int chunk; chunk = num; if (chunk > (int)sizeof(buf)) chunk = sizeof buf; r = RAND_bytes(buf, chunk); if (r <= 0) goto err; BIO_write(out, buf, chunk); num -= chunk; } BIO_flush(out); app_RAND_write_file(NULL, bio_err); ret = 0; err: ERR_print_errors(bio_err); if (out) BIO_free_all(out); apps_shutdown(); OPENSSL_EXIT(ret); }
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:101,
示例22: MAIN//.........这里部分代码省略......... if (i == 0) { if (strbuf[0] == '/0') { ret=1; goto end; } str=strbuf; break; } if (i < 0) { BIO_printf(bio_err,"bad password read/n"); goto end; } } } if (outf == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE); if (bufsize != NULL) setvbuf(stdout, (char *)NULL, _IONBF, 0);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out,outf) <= 0) { perror(outf); goto end; } } rbio=in; wbio=out; if (base64) { if ((b64=BIO_new(BIO_f_base64())) == NULL) goto end; if (debug) { BIO_set_callback(b64,BIO_debug_callback); BIO_set_callback_arg(b64,(char *)bio_err); } if (olb64) BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL); if (enc) wbio=BIO_push(b64,wbio); else rbio=BIO_push(b64,rbio); } if (cipher != NULL) { /* Note that str is NULL if a key was passed on the command * line, so we get no salt in that case. Is this a bug? */ if (str != NULL)
开发者ID:1310701102,项目名称:sl4a,代码行数:67,
示例23: main//.........这里部分代码省略......... if(mimetype==NULL || mimetypeaccept == NULL) badarg = 1; if(badarg) { for(pp=curlx_usage; (*pp != NULL); pp++) BIO_printf(p.errorbio, "%s/n", *pp); BIO_printf(p.errorbio, "/n"); goto err; } /* set input */ if((in=BIO_new(BIO_s_file())) == NULL) { BIO_printf(p.errorbio, "Error setting input bio/n"); goto err; } else if(infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE|BIO_FP_TEXT); else if(BIO_read_filename(in, infile) <= 0) { BIO_printf(p.errorbio, "Error opening input file %s/n", infile); BIO_free(in); goto err; } /* set output */ if((out=BIO_new(BIO_s_file())) == NULL) { BIO_printf(p.errorbio, "Error setting output bio./n"); goto err; } else if(outfile == NULL) BIO_set_fp(out, stdout, BIO_NOCLOSE|BIO_FP_TEXT); else if(BIO_write_filename(out, outfile) <= 0) { BIO_printf(p.errorbio, "Error opening output file %s/n", outfile); BIO_free(out); goto err; } p.errorbio = BIO_new_fp(stderr, BIO_NOCLOSE); p.curl = curl_easy_init(); if(!p.curl) { BIO_printf(p.errorbio, "Cannot init curl lib/n"); goto err; } p12bio = BIO_new_file(p.p12file, "rb"); if(!p12bio) { BIO_printf(p.errorbio, "Error opening P12 file %s/n", p.p12file); goto err; } p.p12 = d2i_PKCS12_bio(p12bio, NULL); if(!p.p12) { BIO_printf(p.errorbio, "Cannot decode P12 structure %s/n", p.p12file); goto err; } p.ca= NULL; if(!(PKCS12_parse (p.p12, p.pst, &(p.pkey), &(p.usercert), &(p.ca) ) )) { BIO_printf(p.errorbio, "Invalid P12 structure in %s/n", p.p12file); goto err; } if(sk_X509_num(p.ca) <= 0) {
开发者ID:dnasdw,项目名称:3dstool,代码行数:67,
示例24: main//.........这里部分代码省略......... goto pollinginit; /* pack the request as a PKSCReq message, of type PKCSReq */ switch (reqversion) { case 0: msg->messageType = SCEP_MESSAGE_TYPE_PKCSREQ; msg->rd.req = scep.clientreq; break; case 1: /* build a version 2 payload */ if (debug) BIO_printf(bio_err, "%s:%d: building version 2 " "payload/n", __FILE__, __LINE__); if (scep.requestorreq) payload_set_req(msg->rd.payload, scep.requestorreq); if (scep.requestorspki) payload_set_spki(msg->rd.payload, scep.requestorspki); /* set the correct message type */ if (scep.community) { /* compute the authenticator from the original */ /* request and the community */ msg->messageType = SCEP_MESSAGE_TYPE_V2PROXY; } else { msg->messageType = SCEP_MESSAGE_TYPE_V2REQUEST; } break; } /* write the request to the request file, for later perusal */ if (savedrequestfile) { BIO *reqbio; reqbio = BIO_new(BIO_s_file()); BIO_write_filename(reqbio, savedrequestfile); switch (reqversion) { case 0: /* version 1 request has a X509_REQ payload */ PEM_write_bio_X509_REQ(reqbio, msg->rd.req); break; case 1: /* version 2 requests have a "real" payload */ i2d_payload_bio(reqbio, msg->rd.payload); break; } BIO_free(reqbio); } goto common;pollinginit: /* when polling, the request is a GetCertInitial message */ msg->messageType = SCEP_MESSAGE_TYPE_GETCERTINITIAL; /* the contents is the pair issuer and subject */ msg->rd.is = (issuer_and_subject_t *)malloc( sizeof(issuer_and_subject_t)); msg->rd.is->issuer = X509_get_subject_name(scep.cacert); msg->rd.is->subject = NULL; /* when polling we should read the request from request file */ /* (only needed for the distinguished name of the client) */ if (debug) BIO_printf(bio_err, "%s:%d: getting subject X509_NAME/n", __FILE__, __LINE__); switch (reqversion) { case 0:
开发者ID:xman1979,项目名称:openscep,代码行数:67,
示例25: MAIN//.........这里部分代码省略......... if (hash == i) { BIO_printf(bio_out,"%08lx/n", X509_NAME_hash(X509_CRL_get_issuer(x))); } if (lastupdate == i) { BIO_printf(bio_out,"lastUpdate="); ASN1_TIME_print(bio_out, X509_CRL_get_lastUpdate(x)); BIO_printf(bio_out,"/n"); } if (nextupdate == i) { BIO_printf(bio_out,"nextUpdate="); if (X509_CRL_get_nextUpdate(x)) ASN1_TIME_print(bio_out, X509_CRL_get_nextUpdate(x)); else BIO_printf(bio_out,"NONE"); BIO_printf(bio_out,"/n"); } if (fingerprint == i) { int j; unsigned int n; unsigned char md[EVP_MAX_MD_SIZE]; if (!X509_CRL_digest(x,digest,md,&n)) { BIO_printf(bio_err,"out of memory/n"); goto end; } BIO_printf(bio_out,"%s Fingerprint=", OBJ_nid2sn(EVP_MD_type(digest))); for (j=0; j<(int)n; j++) { BIO_printf(bio_out,"%02X%c",md[j], (j+1 == (int)n) ?'/n':':'); } } } } out=BIO_new(BIO_s_file()); if (out == NULL) { ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE);#ifdef VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out,outfile) <= 0) { perror(outfile); goto end; } } if (text) X509_CRL_print(out, x); if (noout) goto end; if (outformat == FORMAT_ASN1) i=(int)i2d_X509_CRL_bio(out,x); else if (outformat == FORMAT_PEM) i=PEM_write_bio_X509_CRL(out,x); else { BIO_printf(bio_err,"bad output format specified for outfile/n"); goto end; } if (!i) { BIO_printf(bio_err,"unable to write CRL/n"); goto end; } ret=0;end: BIO_free_all(out); BIO_free_all(bio_out); bio_out=NULL; X509_CRL_free(x); if(store) { X509_STORE_CTX_cleanup(&ctx); X509_STORE_free(store); } EXIT(ret);}
开发者ID:jhbsz,项目名称:actiontec_opensource_mi424wr-rev-acd-56-0-10-14-4,代码行数:101,
示例26: dsaparam_main//.........这里部分代码省略......... BIO_printf(bio_err, " -out arg output file/n"); BIO_printf(bio_err, " -text print as text/n"); BIO_printf(bio_err, " -C Output C code/n"); BIO_printf(bio_err, " -noout no output/n"); BIO_printf(bio_err, " -genkey generate a DSA key/n");#ifndef OPENSSL_NO_ENGINE BIO_printf(bio_err, " -engine e use engine e, possibly a hardware device./n");#endif#ifdef GENCB_TEST BIO_printf(bio_err, " -timebomb n interrupt keygen after <n> seconds/n");#endif BIO_printf(bio_err, " number number of bits to use for generating private key/n"); goto end; } ERR_load_crypto_strings(); in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); if ((in == NULL) || (out == NULL)) { ERR_print_errors(bio_err); goto end; } if (infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { if (BIO_read_filename(in, infile) <= 0) { perror(infile); goto end; } } if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { if (BIO_write_filename(out, outfile) <= 0) { perror(outfile); goto end; } }#ifndef OPENSSL_NO_ENGINE setup_engine(bio_err, engine, 0);#endif if (numbits > 0) { BN_GENCB cb; BN_GENCB_set(&cb, dsa_cb, bio_err); dsa = DSA_new(); if (!dsa) { BIO_printf(bio_err, "Error allocating DSA object/n"); goto end; } BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime/n", num); BIO_printf(bio_err, "This could take some time/n");#ifdef GENCB_TEST if (timebomb > 0) { struct sigaction act; act.sa_handler = timebomb_sigalarm; act.sa_flags = 0; BIO_printf(bio_err, "(though I'll stop it if not done within %d secs)/n", timebomb); if (sigaction(SIGALRM, &act, NULL) != 0) { BIO_printf(bio_err, "Error, couldn't set SIGALRM handler/n"); goto end; } alarm(timebomb); }
开发者ID:DiamondLovesYou,项目名称:libressl-pnacl-sys,代码行数:67,
示例27: dhparam_main//.........这里部分代码省略......... goto end; } dh = DSA_dup_DH(dsa); DSA_free(dsa); if (dh == NULL) { ERR_print_errors(bio_err); goto end; } } else { if (dhparam_config.informat == FORMAT_ASN1) dh = d2i_DHparams_bio(in, NULL); else /* informat == FORMAT_PEM */ dh = PEM_read_bio_DHparams(in, NULL, NULL, NULL); if (dh == NULL) { BIO_printf(bio_err, "unable to load DH parameters/n"); ERR_print_errors(bio_err); goto end; } } /* dh != NULL */ } out = BIO_new(BIO_s_file()); if (out == NULL) { ERR_print_errors(bio_err); goto end; } if (dhparam_config.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { if (BIO_write_filename(out, dhparam_config.outfile) <= 0) { perror(dhparam_config.outfile); goto end; } } if (dhparam_config.text) { DHparams_print(out, dh); } if (dhparam_config.check) { if (!DH_check(dh, &i)) { ERR_print_errors(bio_err); goto end; } if (i & DH_CHECK_P_NOT_PRIME) printf("p value is not prime/n"); if (i & DH_CHECK_P_NOT_SAFE_PRIME) printf("p value is not a safe prime/n"); if (i & DH_UNABLE_TO_CHECK_GENERATOR) printf("unable to check the generator value/n"); if (i & DH_NOT_SUITABLE_GENERATOR) printf("the g value is not a generator/n"); if (i == 0) printf("DH parameters appear to be ok./n"); } if (dhparam_config.C) { unsigned char *data; int len, l, bits; len = BN_num_bytes(dh->p); bits = BN_num_bits(dh->p); data = malloc(len);
开发者ID:LucaBongiorni,项目名称:nextgen,代码行数:67,
示例28: MAIN//.........这里部分代码省略......... { SSL_SESSION *s; char buf[1024*10],*p; int i; s=SSL_SESSION_new(); p= &buf; i=i2d_SSL_SESSION(x,&p); p= &buf; d2i_SSL_SESSION(&s,&p,(long)i); p= &buf; d2i_SSL_SESSION(&s,&p,(long)i); p= &buf; d2i_SSL_SESSION(&s,&p,(long)i); SSL_SESSION_free(s); }#endif if (!noout || text) { out=BIO_new(BIO_s_file()); if (out == NULL) { ERR_print_errors(bio_err); goto end; } if (outfile == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS { BIO *tmpbio = BIO_new(BIO_f_linebuffer()); out = BIO_push(tmpbio, out); }#endif } else { if (BIO_write_filename(out,outfile) <= 0) { perror(outfile); goto end; } } } if (text) { SSL_SESSION_print(out,x); if (cert) { if (peer == NULL) BIO_puts(out,"No certificate present/n"); else X509_print(out,peer); } } if (!noout && !cert) { if (outformat == FORMAT_ASN1) i=i2d_SSL_SESSION_bio(out,x); else if (outformat == FORMAT_PEM) i=PEM_write_bio_SSL_SESSION(out,x); else if (outformat == FORMAT_NSS) i=SSL_SESSION_print_keylog(out,x); else { BIO_printf(bio_err,"bad output format specified for outfile/n"); goto end; } if (!i) { BIO_printf(bio_err,"unable to write SSL_SESSION/n"); goto end; } } else if (!noout && (peer != NULL)) /* just print the certificate */ { if (outformat == FORMAT_ASN1) i=(int)i2d_X509_bio(out,peer); else if (outformat == FORMAT_PEM) i=PEM_write_bio_X509(out,peer); else { BIO_printf(bio_err,"bad output format specified for outfile/n"); goto end; } if (!i) { BIO_printf(bio_err,"unable to write X509/n"); goto end; } } ret=0;end: if (out != NULL) BIO_free_all(out); if (x != NULL) SSL_SESSION_free(x); apps_shutdown(); OPENSSL_EXIT(ret); }
开发者ID:Acidburn0zzz,项目名称:openssl,代码行数:101,
示例29: mainint main(int argc, char *argv[]) { BN_CTX *ctx; BIO *out; char *outfile=NULL; results = 0; argc--; argv++; while (argc >= 1) { if (strcmp(*argv,"-results") == 0) results=1; else if (strcmp(*argv,"-out") == 0) { if (--argc < 1) break; outfile= *(++argv); } argc--; argv++; } ctx=BN_CTX_new(); if (ctx == NULL) exit(1); out=BIO_new(BIO_s_file()); if (out == NULL) exit(1); if (outfile == NULL) { BIO_set_fp(out,stdout,BIO_NOCLOSE); } else { if (!BIO_write_filename(out,outfile)) { perror(outfile); exit(1); } } if (!results) BIO_puts(out,"obase=16/nibase=16/n"); message(out,"BN_add"); if (!test_add(out)) goto err; (void)BIO_flush(out); message(out,"BN_sub"); if (!test_sub(out)) goto err; (void)BIO_flush(out); message(out,"BN_lshift1"); if (!test_lshift1(out)) goto err; (void)BIO_flush(out); message(out,"BN_lshift (fixed)"); if (!test_lshift(out,ctx,BN_bin2bn(lst,sizeof(lst)-1,NULL))) goto err; (void)BIO_flush(out); message(out,"BN_lshift"); if (!test_lshift(out,ctx,NULL)) goto err; (void)BIO_flush(out); message(out,"BN_rshift1"); if (!test_rshift1(out)) goto err; (void)BIO_flush(out); message(out,"BN_rshift"); if (!test_rshift(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_sqr"); if (!test_sqr(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_mul"); if (!test_mul(out)) goto err; (void)BIO_flush(out); message(out,"BN_div"); if (!test_div(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_div_word"); if (!test_div_word(out)) goto err; (void)BIO_flush(out); message(out,"BN_div_recp"); if (!test_div_recp(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_mod"); if (!test_mod(out,ctx)) goto err; (void)BIO_flush(out); message(out,"BN_mod_mul"); if (!test_mod_mul(out,ctx)) goto err;//.........这里部分代码省略.........
开发者ID:busterb,项目名称:libcrypto-regress-openbsd,代码行数:101,
示例30: pkcs7_mainintpkcs7_main(int argc, char **argv){ PKCS7 *p7 = NULL; BIO *in = NULL, *out = NULL; int ret = 1; int i; memset(&pkcs7_config, 0, sizeof(pkcs7_config)); pkcs7_config.informat = FORMAT_PEM; pkcs7_config.outformat = FORMAT_PEM; if (options_parse(argc, argv, pkcs7_options, NULL, NULL) != 0) { pkcs7_usage(); goto end; }#ifndef OPENSSL_NO_ENGINE setup_engine(bio_err, pkcs7_config.engine, 0);#endif in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); if ((in == NULL) || (out == NULL)) { ERR_print_errors(bio_err); goto end; } if (pkcs7_config.infile == NULL) BIO_set_fp(in, stdin, BIO_NOCLOSE); else { if (BIO_read_filename(in, pkcs7_config.infile) <= 0) { perror(pkcs7_config.infile); goto end; } } if (pkcs7_config.informat == FORMAT_ASN1) p7 = d2i_PKCS7_bio(in, NULL); else if (pkcs7_config.informat == FORMAT_PEM) p7 = PEM_read_bio_PKCS7(in, NULL, NULL, NULL); else { BIO_printf(bio_err, "bad input format specified for pkcs7 object/n"); goto end; } if (p7 == NULL) { BIO_printf(bio_err, "unable to load PKCS7 object/n"); ERR_print_errors(bio_err); goto end; } if (pkcs7_config.outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); } else { if (BIO_write_filename(out, pkcs7_config.outfile) <= 0) { perror(pkcs7_config.outfile); goto end; } } if (pkcs7_config.p7_print) PKCS7_print_ctx(out, p7, 0, NULL); if (pkcs7_config.print_certs) { STACK_OF(X509) * certs = NULL; STACK_OF(X509_CRL) * crls = NULL; i = OBJ_obj2nid(p7->type); switch (i) { case NID_pkcs7_signed: certs = p7->d.sign->cert; crls = p7->d.sign->crl; break; case NID_pkcs7_signedAndEnveloped: certs = p7->d.signed_and_enveloped->cert; crls = p7->d.signed_and_enveloped->crl; break; default: break; } if (certs != NULL) { X509 *x; for (i = 0; i < sk_X509_num(certs); i++) { x = sk_X509_value(certs, i); if (pkcs7_config.text) X509_print(out, x); else dump_cert_text(out, x); if (!pkcs7_config.noout) PEM_write_bio_X509(out, x); BIO_puts(out, "/n"); } } if (crls != NULL) { X509_CRL *crl; for (i = 0; i < sk_X509_CRL_num(crls); i++) { crl = sk_X509_CRL_value(crls, i);//.........这里部分代码省略.........
开发者ID:aburgh,项目名称:openbsd,代码行数:101,
注:本文中的BIO_write_filename函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ BIT函数代码示例 C++ BIO_write函数代码示例 |