您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BIO_set_fp函数代码示例

51自学网 2021-06-01 19:50:20
  C++
这篇教程C++ BIO_set_fp函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中BIO_set_fp函数的典型用法代码示例。如果您正苦于以下问题:C++ BIO_set_fp函数的具体用法?C++ BIO_set_fp怎么用?C++ BIO_set_fp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了BIO_set_fp函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PEM_ASN1_write

int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp,		   char *x, const EVP_CIPHER *enc, unsigned char *kstr,		   int klen, pem_password_cb *callback, void *u)        {        BIO *b;        int ret;        if ((b=BIO_new(BIO_s_file())) == NULL)		{		PEMerr(PEM_F_PEM_ASN1_WRITE,ERR_R_BUF_LIB);                return(0);		}        BIO_set_fp(b,fp,BIO_NOCLOSE);        ret=PEM_ASN1_write_bio(i2d,name,b,x,enc,kstr,klen,callback,u);        BIO_free(b);        return(ret);        }
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:17,


示例2: ERR_print_errors

X509 *load_cert(BIO * err, const char *file, int format,                const char *pass, ENGINE * e, const char *cert_descrip){  ASN1_HEADER *ah = NULL;  BUF_MEM *buf = NULL;  X509 *x = NULL;  BIO *cert;  if ((cert = BIO_new(BIO_s_file())) == NULL)    {      ERR_print_errors(err);      goto end;    }  if (file == NULL)    {      setvbuf(stdin, NULL, _IONBF, 0);      BIO_set_fp(cert, stdin, BIO_NOCLOSE);    }  else    {      if (BIO_read_filename(cert, file) <= 0)        {          BIO_printf(err, "Error opening %s %s/n", cert_descrip, file);          ERR_print_errors(err);          goto end;        }    }  if (format == FORMAT_PEM)    x = PEM_read_bio_X509_AUX(cert, NULL, (pem_password_cb *) NULL, NULL);end:  if (x == NULL)    {      BIO_printf(err, "unable to load certificate/n");      ERR_print_errors(err);    }  if (ah != NULL)    ASN1_HEADER_free(ah);  if (cert != NULL)    BIO_free(cert);  if (buf != NULL)    BUF_MEM_free(buf);  return (x);}
开发者ID:gvsurenderreddy,项目名称:vpmn,代码行数:45,


示例3: SYSerr

BIO *BIO_new_file(const char *filename, const char *mode)	{	BIO *ret;	FILE *file;	if ((file=fopen(filename,mode)) == NULL)		{		SYSerr(SYS_F_FOPEN,get_last_sys_error());		ERR_add_error_data(5,"fopen('",filename,"','",mode,"')");		BIOerr(BIO_F_BIO_NEW_FILE,ERR_R_SYS_LIB);		return(NULL);		}	if ((ret=BIO_new(BIO_s_file_internal())) == NULL)		return(NULL);	BIO_set_fp(ret,file,BIO_CLOSE);	return(ret);	}
开发者ID:angeldv95,项目名称:pokerspot,代码行数:18,


示例4: print_dn

void print_dn(FILE *f, CK_ULONG type, CK_VOID_PTR value,              CK_ULONG size, CK_VOID_PTR arg){    print_generic(f, type, value, size, arg);#ifdef HAVE_OPENSSL    if(size && value) {        X509_NAME *name;        name = d2i_X509_NAME(NULL, (const unsigned char **)&value, size);        if(name) {            BIO *bio = BIO_new(BIO_s_file());            BIO_set_fp(bio, f, BIO_NOCLOSE);            fprintf(f, "    DN: ");            X509_NAME_print(bio, name, XN_FLAG_RFC2253);            fprintf(f, "/n");            BIO_free(bio);        }    }#endif}
开发者ID:mbrossard,项目名称:pkcs11,代码行数:19,


示例5: load_crl

static X509_CRL * load_crl(char * ca_name){    FILE * fp ;    BIO  * in ;    X509_CRL * crl ;    char filename[FIELD_SZ+5];    sprintf(filename, "%s.crl", ca_name);    in = BIO_new(BIO_s_file());    if ((fp=fopen(filename, "rb"))==NULL) {        BIO_free(in);        return NULL ;    }    BIO_set_fp(in, fp, BIO_NOCLOSE);    crl = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);    fclose(fp);    BIO_free(in);    return crl ;}
开发者ID:randunel,项目名称:2cca,代码行数:19,


示例6: ERR_print_errors

static X509_CRL *load_crl(char *infile, int format)	{	X509_CRL *x=NULL;	BIO *in=NULL;	in=BIO_new(BIO_s_file());	if (in == 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 	(format == FORMAT_ASN1)		x=d2i_X509_CRL_bio(in,NULL);	else if (format == FORMAT_PEM)		x=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 (x == NULL)		{		BIO_printf(bio_err,"unable to load CRL/n");		ERR_print_errors(bio_err);		goto end;		}	end:	BIO_free(in);	return(x);	}
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:41,


示例7: ERR_print_errors

static SSL_SESSION *load_sess_id(char *infile, int format)	{	SSL_SESSION *x=NULL;	BIO *in=NULL;	in=BIO_new(BIO_s_file());	if (in == 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 	(format == FORMAT_ASN1)		x=d2i_SSL_SESSION_bio(in,NULL);	else if (format == FORMAT_PEM)		x=PEM_read_bio_SSL_SESSION(in,NULL,NULL,NULL);	else	{		BIO_printf(bio_err,"bad input format specified for input crl/n");		goto end;		}	if (x == NULL)		{		BIO_printf(bio_err,"unable to load SSL_SESSION/n");		ERR_print_errors(bio_err);		goto end;		}	end:	if (in != NULL) BIO_free(in);	return(x);	}
开发者ID:ahenroid,项目名称:ptptl-0.2,代码行数:41,


示例8: main

int main(int argc, char* argv[]){	BIO *b = NULL;	b = BIO_new_file("bio_file.txt", "w");	BIO_printf(b, "%s %s %d :", __FILE__, __FUNCTION__, __LINE__);	BIO_write(b, "BIO_write()./n", 16);	BIO_flush(b);	BIO_free(b);	b = BIO_new_file("bio_file.txt", "r");	int len = BIO_ctrl_pending(b);		char *str = malloc(64);	if(!str) exit(-1);	memset(str, 0, 64);		char* p = str;	int ret = 0;	while((ret = BIO_read(b, p, 2)) > 0)	{		p += ret;		len += ret;	}	*p = 0;	BIO *bout = NULL;	bout = BIO_new(BIO_s_file());	BIO_set_fp(bout, stdout, BIO_NOCLOSE);	BIO_printf(bout, "Reading %d: %s", len, str);	BIO_flush(bout);	free(str);	BIO_free(b);	BIO_free(bout);	return 0;}
开发者ID:striver1205,项目名称:LTopenssl,代码行数:37,


示例9: file_fopen

BIO *BIO_new_file(const char *filename, const char *mode){    BIO  *ret;    FILE *file = file_fopen(filename, mode);    if (file == NULL) {        SYSerr(SYS_F_FOPEN, get_last_sys_error());        ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");        if (errno == ENOENT)            BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);        else            BIOerr(BIO_F_BIO_NEW_FILE, ERR_R_SYS_LIB);        return (NULL);    }    if ((ret = BIO_new(BIO_s_file())) == NULL) {        fclose(file);        return (NULL);    }    BIO_clear_flags(ret, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage                                             * UPLINK */    BIO_set_fp(ret, file, BIO_CLOSE);    return (ret);}
开发者ID:JackDanger,项目名称:openssl,代码行数:24,


示例10: ecparam_main

//.........这里部分代码省略.........		    " compressed/n");		BIO_printf(bio_err, "                                   "		    " uncompressed (default)/n");		BIO_printf(bio_err, "                                   "		    " hybrid/n");		BIO_printf(bio_err, " -param_enc arg    specifies the way"		    " the ec parameters are encoded/n");		BIO_printf(bio_err, "                   in the asn1 der "		    "encoding/n");		BIO_printf(bio_err, "                   possible values:"		    " named_curve (default)/n");		BIO_printf(bio_err, "                                   "		    " explicit/n");		BIO_printf(bio_err, " -no_seed          if 'explicit'"		    " parameters are chosen do not"		    " use the seed/n");		BIO_printf(bio_err, " -genkey           generate ec"		    " key/n");		BIO_printf(bio_err, " -rand file        files to use for"		    " random number input/n");		BIO_printf(bio_err, " -engine e         use engine e, "		    "possibly a hardware device/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 (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 = reallocarray(NULL, crv_len, sizeof(EC_builtin_curve));		if (curves == NULL)			goto end;		if (!EC_get_builtin_curves(curves, crv_len)) {
开发者ID:benwh4,项目名称:libressl,代码行数:67,


示例11: MAIN

int MAIN(int argc, char **argv)	{#ifndef OPENSSL_NO_ENGINE	ENGINE *e = NULL;#endif	int i, r, ret = 1;	int badopt;	char *outfile = NULL;	char *inrand = NULL;	int base64 = 0;	BIO *out = NULL;	int num = -1;#ifndef OPENSSL_NO_ENGINE	char *engine=NULL;#endif	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 err;	badopt = 0;	i = 0;	while (!badopt && argv[++i] != NULL)		{		if (strcmp(argv[i], "-out") == 0)			{			if ((argv[i+1] != NULL) && (outfile == NULL))				outfile = argv[++i];			else				badopt = 1;			}#ifndef OPENSSL_NO_ENGINE		else if (strcmp(argv[i], "-engine") == 0)			{			if ((argv[i+1] != NULL) && (engine == NULL))				engine = argv[++i];			else				badopt = 1;			}#endif		else if (strcmp(argv[i], "-rand") == 0)			{			if ((argv[i+1] != NULL) && (inrand == NULL))				inrand = argv[++i];			else				badopt = 1;			}		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));//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:101,


示例12: MAIN

int MAIN(int argc, char **argv){    ENGINE *e = NULL;    int operation = 0;    int ret = 0;    char **args;    const char *inmode = "r", *outmode = "w";    char *infile = NULL, *outfile = NULL, *rctfile = NULL;    char *signerfile = NULL, *recipfile = NULL;    STACK_OF(OPENSSL_STRING) *sksigners = NULL, *skkeys = NULL;    char *certfile = NULL, *keyfile = NULL, *contfile = NULL;    char *certsoutfile = NULL;    const EVP_CIPHER *cipher = NULL, *wrap_cipher = NULL;    CMS_ContentInfo *cms = NULL, *rcms = NULL;    X509_STORE *store = NULL;    X509 *cert = NULL, *recip = NULL, *signer = NULL;    EVP_PKEY *key = NULL;    STACK_OF(X509) *encerts = NULL, *other = NULL;    BIO *in = NULL, *out = NULL, *indata = NULL, *rctin = NULL;    int badarg = 0;    int flags = CMS_DETACHED, noout = 0, print = 0;    int verify_retcode = 0;    int rr_print = 0, rr_allorfirst = -1;    STACK_OF(OPENSSL_STRING) *rr_to = NULL, *rr_from = NULL;    CMS_ReceiptRequest *rr = NULL;    char *to = NULL, *from = NULL, *subject = NULL;    char *CAfile = NULL, *CApath = NULL;    char *passargin = NULL, *passin = NULL;    char *inrand = NULL;    int need_rand = 0;    const EVP_MD *sign_md = NULL;    int informat = FORMAT_SMIME, outformat = FORMAT_SMIME;    int rctformat = FORMAT_SMIME, keyform = FORMAT_PEM;# ifndef OPENSSL_NO_ENGINE    char *engine = NULL;# endif    unsigned char *secret_key = NULL, *secret_keyid = NULL;    unsigned char *pwri_pass = NULL, *pwri_tmp = NULL;    size_t secret_keylen = 0, secret_keyidlen = 0;    cms_key_param *key_first = NULL, *key_param = NULL;    ASN1_OBJECT *econtent_type = NULL;    X509_VERIFY_PARAM *vpm = NULL;    args = argv + 1;    ret = 1;    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;    while (!badarg && *args && *args[0] == '-') {        if (!strcmp(*args, "-encrypt"))            operation = SMIME_ENCRYPT;        else if (!strcmp(*args, "-decrypt"))            operation = SMIME_DECRYPT;        else if (!strcmp(*args, "-sign"))            operation = SMIME_SIGN;        else if (!strcmp(*args, "-sign_receipt"))            operation = SMIME_SIGN_RECEIPT;        else if (!strcmp(*args, "-resign"))            operation = SMIME_RESIGN;        else if (!strcmp(*args, "-verify"))            operation = SMIME_VERIFY;        else if (!strcmp(*args, "-verify_retcode"))            verify_retcode = 1;        else if (!strcmp(*args, "-verify_receipt")) {            operation = SMIME_VERIFY_RECEIPT;            if (!args[1])                goto argerr;            args++;            rctfile = *args;        } else if (!strcmp(*args, "-cmsout"))            operation = SMIME_CMSOUT;        else if (!strcmp(*args, "-data_out"))            operation = SMIME_DATAOUT;        else if (!strcmp(*args, "-data_create"))            operation = SMIME_DATA_CREATE;        else if (!strcmp(*args, "-digest_verify"))            operation = SMIME_DIGEST_VERIFY;        else if (!strcmp(*args, "-digest_create"))            operation = SMIME_DIGEST_CREATE;        else if (!strcmp(*args, "-compress"))            operation = SMIME_COMPRESS;        else if (!strcmp(*args, "-uncompress"))            operation = SMIME_UNCOMPRESS;        else if (!strcmp(*args, "-EncryptedData_decrypt"))            operation = SMIME_ENCRYPTED_DECRYPT;        else if (!strcmp(*args, "-EncryptedData_encrypt"))            operation = SMIME_ENCRYPTED_ENCRYPT;# ifndef OPENSSL_NO_DES        else if (!strcmp(*args, "-des3"))//.........这里部分代码省略.........
开发者ID:davidlt,项目名称:openssl-fedora,代码行数:101,


示例13: main

intmain(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))//.........这里部分代码省略.........
开发者ID:NSGod,项目名称:openbsd,代码行数:101,


示例14: MAIN

int MAIN(int argc, char **argv)	{#ifndef OPENSSL_NO_ENGINE	ENGINE *e = NULL;#endif	DSA *dsa=NULL;	int ret=1;	char *outfile=NULL;	char *inrand=NULL,*dsaparams=NULL;	char *passargout = NULL, *passout = NULL;	BIO *out=NULL,*in=NULL;	const EVP_CIPHER *enc=NULL;#ifndef OPENSSL_NO_ENGINE	char *engine=NULL;#endif	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,"-passout") == 0)			{			if (--argc < 1) goto bad;			passargout= *(++argv);			}#ifndef OPENSSL_NO_ENGINE		else if (strcmp(*argv,"-engine") == 0)			{			if (--argc < 1) goto bad;			engine= *(++argv);			}#endif		else if (strcmp(*argv,"-rand") == 0)			{			if (--argc < 1) goto bad;			inrand= *(++argv);			}		else if (strcmp(*argv,"-") == 0)			goto bad;#ifndef OPENSSL_NO_DES		else if (strcmp(*argv,"-des") == 0)			enc=EVP_des_cbc();		else if (strcmp(*argv,"-des3") == 0)			enc=EVP_des_ede3_cbc();#endif#ifndef OPENSSL_NO_IDEA		else if (strcmp(*argv,"-idea") == 0)			enc=EVP_idea_cbc();#endif#ifndef OPENSSL_NO_SEED		else if (strcmp(*argv,"-seed") == 0)			enc=EVP_seed_cbc();#endif#ifndef OPENSSL_NO_AES		else if (strcmp(*argv,"-aes128") == 0)			enc=EVP_aes_128_cbc();		else if (strcmp(*argv,"-aes192") == 0)			enc=EVP_aes_192_cbc();		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 (**argv != '-' && dsaparams == NULL)			{			dsaparams = *argv;			}		else			goto bad;		argv++;		argc--;		}	if (dsaparams == NULL)		{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//.........这里部分代码省略.........
开发者ID:LucidOne,项目名称:Rovio,代码行数:101,


示例15: MAIN

int MAIN(int argc, char **argv)	{	BN_GENCB cb;#ifndef OPENSSL_NO_ENGINE	ENGINE *e = NULL;#endif	int ret=1;	int i,num=DEFBITS;	long l;	const EVP_CIPHER *enc=NULL;	unsigned long f4=RSA_F4;	char *outfile=NULL;	char *passargout = NULL, *passout = NULL;#ifndef OPENSSL_NO_ENGINE	char *engine=NULL;#endif	char *inrand=NULL;	BIO *out=NULL;	BIGNUM *bn = BN_new();	RSA *rsa = NULL;	if(!bn) goto err;	apps_startup();	BN_GENCB_set(&cb, genrsa_cb, bio_err);	if (bio_err == NULL)		if ((bio_err=BIO_new(BIO_s_file())) != NULL)			BIO_set_fp(bio_err,OPENSSL_TYPE__FILE_STDERR,BIO_NOCLOSE|BIO_FP_TEXT);	if (!load_config(bio_err, NULL))		goto err;	if ((out=BIO_new(BIO_s_file())) == NULL)		{		BIO_printf(bio_err,"unable to create BIO for output/n");		goto err;		}	argv++;	argc--;	for (;;)		{		if (argc <= 0) break;		if (TINYCLR_SSL_STRCMP(*argv,"-out") == 0)			{			if (--argc < 1) goto bad;			outfile= *(++argv);			}		else if (TINYCLR_SSL_STRCMP(*argv,"-3") == 0)			f4=3;		else if (TINYCLR_SSL_STRCMP(*argv,"-F4") == 0 || TINYCLR_SSL_STRCMP(*argv,"-f4") == 0)			f4=RSA_F4;#ifndef OPENSSL_NO_ENGINE		else if (TINYCLR_SSL_STRCMP(*argv,"-engine") == 0)			{			if (--argc < 1) goto bad;			engine= *(++argv);			}#endif		else if (TINYCLR_SSL_STRCMP(*argv,"-rand") == 0)			{			if (--argc < 1) goto bad;			inrand= *(++argv);			}#ifndef OPENSSL_NO_DES		else if (TINYCLR_SSL_STRCMP(*argv,"-des") == 0)			enc=EVP_des_cbc();		else if (TINYCLR_SSL_STRCMP(*argv,"-des3") == 0)			enc=EVP_des_ede3_cbc();#endif#ifndef OPENSSL_NO_IDEA		else if (TINYCLR_SSL_STRCMP(*argv,"-idea") == 0)			enc=EVP_idea_cbc();#endif#ifndef OPENSSL_NO_SEED		else if (TINYCLR_SSL_STRCMP(*argv,"-seed") == 0)			enc=EVP_seed_cbc();#endif#ifndef OPENSSL_NO_AES		else if (TINYCLR_SSL_STRCMP(*argv,"-aes128") == 0)			enc=EVP_aes_128_cbc();		else if (TINYCLR_SSL_STRCMP(*argv,"-aes192") == 0)			enc=EVP_aes_192_cbc();		else if (TINYCLR_SSL_STRCMP(*argv,"-aes256") == 0)			enc=EVP_aes_256_cbc();#endif#ifndef OPENSSL_NO_CAMELLIA		else if (TINYCLR_SSL_STRCMP(*argv,"-camellia128") == 0)			enc=EVP_camellia_128_cbc();		else if (TINYCLR_SSL_STRCMP(*argv,"-camellia192") == 0)			enc=EVP_camellia_192_cbc();		else if (TINYCLR_SSL_STRCMP(*argv,"-camellia256") == 0)			enc=EVP_camellia_256_cbc();#endif		else if (TINYCLR_SSL_STRCMP(*argv,"-passout") == 0)			{			if (--argc < 1) goto bad;			passargout= *(++argv);			}		else//.........这里部分代码省略.........
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:101,


示例16: dgst_main

//.........这里部分代码省略.........            goto end;        }        if (sigopts) {            char *sigopt;            for (i = 0; i < sk_OPENSSL_STRING_num(sigopts); i++) {                sigopt = sk_OPENSSL_STRING_value(sigopts, i);                if (pkey_ctrl_string(pctx, sigopt) <= 0) {                    BIO_printf(bio_err, "parameter error /"%s/"/n", sigopt);                    ERR_print_errors(bio_err);                    goto end;                }            }        }    }    /* we use md as a filter, reading from 'in' */    else {        EVP_MD_CTX *mctx = NULL;        if (!BIO_get_md_ctx(bmd, &mctx)) {            BIO_printf(bio_err, "Error getting context/n");            ERR_print_errors(bio_err);            goto end;        }        if (md == NULL)            md = EVP_md5();        if (!EVP_DigestInit_ex(mctx, md, impl)) {            BIO_printf(bio_err, "Error setting digest/n");            ERR_print_errors(bio_err);            goto end;        }    }    if (sigfile && sigkey) {        BIO *sigbio = BIO_new_file(sigfile, "rb");        if (!sigbio) {            BIO_printf(bio_err, "Error opening signature file %s/n", sigfile);            ERR_print_errors(bio_err);            goto end;        }        siglen = EVP_PKEY_size(sigkey);        sigbuf = app_malloc(siglen, "signature buffer");        siglen = BIO_read(sigbio, sigbuf, siglen);        BIO_free(sigbio);        if (siglen <= 0) {            BIO_printf(bio_err, "Error reading signature file %s/n", sigfile);            ERR_print_errors(bio_err);            goto end;        }    }    inp = BIO_push(bmd, in);    if (md == NULL) {        EVP_MD_CTX *tctx;        BIO_get_md_ctx(bmd, &tctx);        md = EVP_MD_CTX_md(tctx);    }    if (argc == 0) {        BIO_set_fp(in, stdin, BIO_NOCLOSE);        ret = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf,                    siglen, NULL, NULL, "stdin", bmd);    } else {        const char *md_name = NULL, *sig_name = NULL;        if (!out_bin) {            if (sigkey) {                const EVP_PKEY_ASN1_METHOD *ameth;                ameth = EVP_PKEY_get0_asn1(sigkey);                if (ameth)                    EVP_PKEY_asn1_get0_info(NULL, NULL,                                            NULL, NULL, &sig_name, ameth);            }            if (md)                md_name = EVP_MD_name(md);        }        ret = 0;        for (i = 0; i < argc; i++) {            int r;            if (BIO_read_filename(in, argv[i]) <= 0) {                perror(argv[i]);                ret++;                continue;            } else                r = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf,                          siglen, sig_name, md_name, argv[i], bmd);            if (r)                ret = r;            (void)BIO_reset(bmd);        }    } end:    OPENSSL_clear_free(buf, BUFSIZE);    BIO_free(in);    OPENSSL_free(passin);    BIO_free_all(out);    EVP_PKEY_free(sigkey);    sk_OPENSSL_STRING_free(sigopts);    sk_OPENSSL_STRING_free(macopts);    OPENSSL_free(sigbuf);    BIO_free(bmd);    return (ret);}
开发者ID:GH-JY,项目名称:openssl,代码行数:101,


示例17: MAIN

//.........这里部分代码省略.........				}			}		X509V3_set_ctx_test(&ctx2);		X509V3_set_nconf(&ctx2, extconf);		if (!X509V3_EXT_add_nconf(extconf, &ctx2, extsect, NULL))			{			BIO_printf(bio_err,				"Error Loading extension section %s/n",								 extsect);			ERR_print_errors(bio_err);			goto end;			}		}	if (reqfile)		{		EVP_PKEY *pkey;		BIO *in;		if (!sign_flag && !CA_flag)			{			BIO_printf(bio_err,"We need a private key to sign with/n");			goto end;			}		in=BIO_new(BIO_s_file());		if (in == NULL)			{			ERR_print_errors(bio_err);			goto end;			}		if (infile == NULL)			BIO_set_fp(in,stdin,BIO_NOCLOSE|BIO_FP_TEXT);		else			{			if (BIO_read_filename(in,infile) <= 0)				{				perror(infile);				BIO_free(in);				goto end;				}			}		req=PEM_read_bio_X509_REQ(in,NULL,NULL,NULL);		BIO_free(in);		if (req == NULL)			{			ERR_print_errors(bio_err);			goto end;			}		if (	(req->req_info == NULL) ||			(req->req_info->pubkey == NULL) ||			(req->req_info->pubkey->public_key == NULL) ||			(req->req_info->pubkey->public_key->data == NULL))			{			BIO_printf(bio_err,"The certificate request appears to corrupted/n");			BIO_printf(bio_err,"It does not contain a public key/n");			goto end;			}		if ((pkey=X509_REQ_get_pubkey(req)) == NULL)	                {	                BIO_printf(bio_err,"error unpacking public key/n");	                goto end;	                }
开发者ID:0omega,项目名称:platform_external_openssl,代码行数:67,


示例18: MAIN

int MAIN(int argc, char **argv)	{	SSL_SESSION *x=NULL;	int ret=1,i,num,badops=0;	BIO *out=NULL;	int informat,outformat;	char *infile=NULL,*outfile=NULL,*context=NULL;	int cert=0,noout=0,text=0;	char **pp;	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);	informat=FORMAT_PEM;	outformat=FORMAT_PEM;	argc--;	argv++;	num=0;	while (argc >= 1)		{		if 	(strcmp(*argv,"-inform") == 0)			{			if (--argc < 1) goto bad;			informat=str2fmt(*(++argv));			}		else if (strcmp(*argv,"-outform") == 0)			{			if (--argc < 1) goto bad;			outformat=str2fmt(*(++argv));			}		else if (strcmp(*argv,"-in") == 0)			{			if (--argc < 1) goto bad;			infile= *(++argv);			}		else if (strcmp(*argv,"-out") == 0)			{			if (--argc < 1) goto bad;			outfile= *(++argv);			}		else if (strcmp(*argv,"-text") == 0)			text= ++num;		else if (strcmp(*argv,"-cert") == 0)			cert= ++num;		else if (strcmp(*argv,"-noout") == 0)			noout= ++num;		else if (strcmp(*argv,"-context") == 0)		    {		    if(--argc < 1) goto bad;		    context=*++argv;		    }		else			{			BIO_printf(bio_err,"unknown option %s/n",*argv);			badops=1;			break;			}		argc--;		argv++;		}	if (badops)		{bad:		for (pp=sess_id_usage; (*pp != NULL); pp++)			BIO_printf(bio_err,*pp);		goto end;		}	ERR_load_crypto_strings();	x=load_sess_id(infile,informat);	if (x == NULL) { goto end; }	if(context)	    {	    x->sid_ctx_length=strlen(context);	    if(x->sid_ctx_length > SSL_MAX_SID_CTX_LENGTH)		{		BIO_printf(bio_err,"Context too long/n");		goto end;		}	    memcpy(x->sid_ctx,context,x->sid_ctx_length);	    }#ifdef undef	/* just testing for memory leaks :-) */	{	SSL_SESSION *s;	char buf[1024*10],*p;	int i;	s=SSL_SESSION_new();	p= &buf;	i=i2d_SSL_SESSION(x,&p);	p= &buf;//.........这里部分代码省略.........
开发者ID:ahenroid,项目名称:ptptl-0.2,代码行数:101,


示例19: dhparam_main

intdhparam_main(int argc, char **argv){	BIO *in = NULL, *out = NULL;	char *num_bits = NULL;	DH *dh = NULL;	int num = 0;	int ret = 1;	int i;	memset(&dhparam_config, 0, sizeof(dhparam_config));	dhparam_config.informat = FORMAT_PEM;	dhparam_config.outformat = FORMAT_PEM;	if (options_parse(argc, argv, dhparam_options, &num_bits, NULL) != 0) {		dhparam_usage();		return (1);	}	if (num_bits != NULL) {		if(sscanf(num_bits, "%d", &num) == 0 || num <= 0) {			BIO_printf(bio_err, "invalid number of bits: %s/n",			    num_bits);			return (1);		}	}	if (dhparam_config.g && !num)		num = DEFBITS;	if (dhparam_config.dsaparam) {		if (dhparam_config.g) {			BIO_printf(bio_err, "generator may not be chosen for DSA parameters/n");			goto end;		}	} else {		/* DH parameters */		if (num && !dhparam_config.g)			dhparam_config.g = 2;	}	if (num) {		BN_GENCB cb;		BN_GENCB_set(&cb, dh_cb, bio_err);		if (dhparam_config.dsaparam) {			DSA *dsa = DSA_new();			BIO_printf(bio_err, "Generating DSA parameters, %d bit long prime/n", num);			if (!dsa || !DSA_generate_parameters_ex(dsa, num,				NULL, 0, NULL, NULL, &cb)) {				if (dsa)					DSA_free(dsa);				ERR_print_errors(bio_err);				goto end;			}			dh = DSA_dup_DH(dsa);			DSA_free(dsa);			if (dh == NULL) {				ERR_print_errors(bio_err);				goto end;			}		} else {			dh = DH_new();			BIO_printf(bio_err, "Generating DH parameters, %d bit long safe prime, generator %d/n", num, dhparam_config.g);			BIO_printf(bio_err, "This is going to take a long time/n");			if (!dh || !DH_generate_parameters_ex(dh, num, dhparam_config.g, &cb)) {				ERR_print_errors(bio_err);				goto end;			}		}	} else {		in = BIO_new(BIO_s_file());		if (in == NULL) {			ERR_print_errors(bio_err);			goto end;		}		if (dhparam_config.infile == NULL)			BIO_set_fp(in, stdin, BIO_NOCLOSE);		else {			if (BIO_read_filename(in, dhparam_config.infile) <= 0) {				perror(dhparam_config.infile);				goto end;			}		}		if (dhparam_config.informat != FORMAT_ASN1 &&		    dhparam_config.informat != FORMAT_PEM) {			BIO_printf(bio_err, "bad input format specified/n");			goto end;		}		if (dhparam_config.dsaparam) {			DSA *dsa;			if (dhparam_config.informat == FORMAT_ASN1)				dsa = d2i_DSAparams_bio(in, NULL);			else	/* informat == FORMAT_PEM */				dsa = PEM_read_bio_DSAparams(in, NULL, NULL, NULL);//.........这里部分代码省略.........
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:101,


示例20: MAIN

int MAIN(int argc, char **argv){    int i, badops = 0, offset = 0, ret = 1, j;    unsigned int length = 0;    long num, tmplen;    BIO *in = NULL, *out = NULL, *b64 = NULL, *derout = NULL;    int informat, indent = 0, noout = 0, dump = 0, strictpem = 0;    char *infile = NULL, *str = NULL, *prog, *oidfile = NULL, *derfile =        NULL, *name = NULL, *header = NULL;    char *genstr = NULL, *genconf = NULL;    unsigned char *tmpbuf;    const unsigned char *ctmpbuf;    BUF_MEM *buf = NULL;    STACK_OF(OPENSSL_STRING) *osk = NULL;    ASN1_TYPE *at = NULL;    informat = FORMAT_PEM;    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;    prog = argv[0];    argc--;    argv++;    if ((osk = sk_OPENSSL_STRING_new_null()) == NULL) {        BIO_printf(bio_err, "Memory allocation failure/n");        goto end;    }    while (argc >= 1) {        if (strcmp(*argv, "-inform") == 0) {            if (--argc < 1)                goto bad;            informat = str2fmt(*(++argv));        } else if (strcmp(*argv, "-in") == 0) {            if (--argc < 1)                goto bad;            infile = *(++argv);        } else if (strcmp(*argv, "-out") == 0) {            if (--argc < 1)                goto bad;            derfile = *(++argv);        } else if (strcmp(*argv, "-i") == 0) {            indent = 1;        } else if (strcmp(*argv, "-noout") == 0)            noout = 1;        else if (strcmp(*argv, "-oid") == 0) {            if (--argc < 1)                goto bad;            oidfile = *(++argv);        } else if (strcmp(*argv, "-offset") == 0) {            if (--argc < 1)                goto bad;            offset = atoi(*(++argv));        } else if (strcmp(*argv, "-length") == 0) {            if (--argc < 1)                goto bad;            length = atoi(*(++argv));            if (length == 0)                goto bad;        } else if (strcmp(*argv, "-dump") == 0) {            dump = -1;        } else if (strcmp(*argv, "-dlimit") == 0) {            if (--argc < 1)                goto bad;            dump = atoi(*(++argv));            if (dump <= 0)                goto bad;        } else if (strcmp(*argv, "-strparse") == 0) {            if (--argc < 1)                goto bad;            sk_OPENSSL_STRING_push(osk, *(++argv));        } else if (strcmp(*argv, "-genstr") == 0) {            if (--argc < 1)                goto bad;            genstr = *(++argv);        } else if (strcmp(*argv, "-genconf") == 0) {            if (--argc < 1)                goto bad;            genconf = *(++argv);        } else if (strcmp(*argv, "-strictpem") == 0) {            strictpem = 1;            informat = FORMAT_PEM;        } else {            BIO_printf(bio_err, "unknown option %s/n", *argv);            badops = 1;            break;        }        argc--;        argv++;    }    if (badops) { bad:        BIO_printf(bio_err, "%s [options] <infile/n", prog);//.........这里部分代码省略.........
开发者ID:Adallom,项目名称:openssl,代码行数:101,


示例21: MAIN

int MAIN(int argc, char **argv){    int i, badops = 0;    BIO *in = NULL, *out = NULL;    int informat, outformat;    char *infile, *outfile, *prog, *certfile;    PKCS7 *p7 = NULL;    PKCS7_SIGNED *p7s = NULL;    X509_CRL *crl = NULL;    STACK_OF(OPENSSL_STRING) *certflst = NULL;    STACK_OF(X509_CRL) *crl_stack = NULL;    STACK_OF(X509) *cert_stack = NULL;    int ret = 1, nocrl = 0;    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);    infile = NULL;    outfile = NULL;    informat = FORMAT_PEM;    outformat = FORMAT_PEM;    prog = argv[0];    argc--;    argv++;    while (argc >= 1) {        if (strcmp(*argv, "-inform") == 0) {            if (--argc < 1)                goto bad;            informat = str2fmt(*(++argv));        } else if (strcmp(*argv, "-outform") == 0) {            if (--argc < 1)                goto bad;            outformat = str2fmt(*(++argv));        } else if (strcmp(*argv, "-in") == 0) {            if (--argc < 1)                goto bad;            infile = *(++argv);        } else if (strcmp(*argv, "-nocrl") == 0) {            nocrl = 1;        } else if (strcmp(*argv, "-out") == 0) {            if (--argc < 1)                goto bad;            outfile = *(++argv);        } else if (strcmp(*argv, "-certfile") == 0) {            if (--argc < 1)                goto bad;            if (!certflst)                certflst = sk_OPENSSL_STRING_new_null();            if (!certflst)                goto end;            if (!sk_OPENSSL_STRING_push(certflst, *(++argv))) {                sk_OPENSSL_STRING_free(certflst);                goto end;            }        } else {            BIO_printf(bio_err, "unknown option %s/n", *argv);            badops = 1;            break;        }        argc--;        argv++;    }    if (badops) { bad:        BIO_printf(bio_err, "%s [options] <infile >outfile/n", prog);        BIO_printf(bio_err, "where options are/n");        BIO_printf(bio_err, " -inform arg    input format - DER or PEM/n");        BIO_printf(bio_err, " -outform arg   output format - DER or PEM/n");        BIO_printf(bio_err, " -in arg        input file/n");        BIO_printf(bio_err, " -out arg       output file/n");        BIO_printf(bio_err,                   " -certfile arg  certificates file of chain to a trusted CA/n");        BIO_printf(bio_err, "                (can be used more than once)/n");        BIO_printf(bio_err,                   " -nocrl         no crl to load, just certs from '-certfile'/n");        ret = 1;        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 (!nocrl) {        if (infile == NULL)            BIO_set_fp(in, stdin, BIO_NOCLOSE);        else {            if (BIO_read_filename(in, infile) <= 0) {                perror(infile);                goto end;//.........这里部分代码省略.........
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:101,


示例22: MAIN

int MAIN(int argc, char **argv)	{	int i,badops=0,offset=0,ret=1,j;	unsigned int length=0;	long num,tmplen;	BIO *in=NULL,*out=NULL,*b64=NULL, *derout = NULL;	int informat,indent=0, noout = 0, dump = 0;	char *infile=NULL,*str=NULL,*prog,*oidfile=NULL, *derfile=NULL;	unsigned char *tmpbuf;	BUF_MEM *buf=NULL;	STACK *osk=NULL;	ASN1_TYPE *at=NULL;	informat=FORMAT_PEM;	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);	prog=argv[0];	argc--;	argv++;	if ((osk=sk_new_null()) == NULL)		{		BIO_printf(bio_err,"Memory allocation failure/n");		goto end;		}	while (argc >= 1)		{		if 	(strcmp(*argv,"-inform") == 0)			{			if (--argc < 1) goto bad;			informat=str2fmt(*(++argv));			}		else if (strcmp(*argv,"-in") == 0)			{			if (--argc < 1) goto bad;			infile= *(++argv);			}		else if (strcmp(*argv,"-out") == 0)			{			if (--argc < 1) goto bad;			derfile= *(++argv);			}		else if (strcmp(*argv,"-i") == 0)			{			indent=1;			}		else if (strcmp(*argv,"-noout") == 0) noout = 1;		else if (strcmp(*argv,"-oid") == 0)			{			if (--argc < 1) goto bad;			oidfile= *(++argv);			}		else if (strcmp(*argv,"-offset") == 0)			{			if (--argc < 1) goto bad;			offset= atoi(*(++argv));			}		else if (strcmp(*argv,"-length") == 0)			{			if (--argc < 1) goto bad;			length= atoi(*(++argv));			if (length == 0) goto bad;			}		else if (strcmp(*argv,"-dump") == 0)			{			dump= -1;			}		else if (strcmp(*argv,"-dlimit") == 0)			{			if (--argc < 1) goto bad;			dump= atoi(*(++argv));			if (dump <= 0) goto bad;			}		else if (strcmp(*argv,"-strparse") == 0)			{			if (--argc < 1) goto bad;			sk_push(osk,*(++argv));			}		else			{			BIO_printf(bio_err,"unknown option %s/n",*argv);			badops=1;			break;			}		argc--;		argv++;		}	if (badops)		{bad:		BIO_printf(bio_err,"%s [options] <infile/n",prog);		BIO_printf(bio_err,"where options are/n");		BIO_printf(bio_err," -inform arg   input format - one of DER TXT PEM/n");		BIO_printf(bio_err," -in arg       input file/n");		BIO_printf(bio_err," -out arg      output file (output format is always DER/n");//.........这里部分代码省略.........
开发者ID:aosm,项目名称:OpenSSL096,代码行数:101,


示例23: rand_main

int rand_main(int argc, char **argv){	int i, r, ret = 1;	int badopt;	char *outfile = NULL;	int base64 = 0;	int hex = 0;	BIO *out = NULL;	int num = -1;#ifndef OPENSSL_NO_ENGINE	char *engine = NULL;#endif	if (!load_config(bio_err, NULL))		goto err;	badopt = 0;	i = 0;	while (!badopt && argv[++i] != NULL) {		if (strcmp(argv[i], "-out") == 0) {			if ((argv[i + 1] != NULL) && (outfile == NULL))				outfile = argv[++i];			else				badopt = 1;		}#ifndef OPENSSL_NO_ENGINE		else if (strcmp(argv[i], "-engine") == 0) {			if ((argv[i + 1] != NULL) && (engine == NULL))				engine = argv[++i];			else				badopt = 1;		}#endif		else if (strcmp(argv[i], "-base64") == 0) {			if (!base64)				base64 = 1;			else				badopt = 1;		} else if (strcmp(argv[i], "-hex") == 0) {			if (!hex)				hex = 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 (hex && base64)		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, "-base64               - base64 encode output/n");		BIO_printf(bio_err, "-hex                  - hex encode output/n");		goto err;	}#ifndef OPENSSL_NO_ENGINE	setup_engine(bio_err, engine, 0);#endif	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);	}	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;//.........这里部分代码省略.........
开发者ID:DiamondLovesYou,项目名称:libressl-pnacl-sys,代码行数:101,


示例24: main

int	main(int argc, char *argv[]) {	scep_t		scep;	int		c, rc, bytes, fd;	char		filename[1024];	BIO		*inbio = NULL, *outbio, *membio;	char		*conffile;	struct tms	start;	/* start timekeeping						*/	times(&start);	/* clean out the scep structure (some fields will be set by	*/	/* command line parsing routine)				*/	scep_clear(&scep);	if (debug)		fprintf(stderr, "%s:%d: cleared scep structure/n",			__FILE__, __LINE__);	/* initialize the OpenSSL library				*/	scepinit();	if (debug)		fprintf(stderr, "%s:%d: initialized libraries/n",			__FILE__, __LINE__);	/* set umask to something not dangerous				*/	umask(022);	/* read the command line arguments, if any			*/	while (EOF != (c = getopt(argc, argv, "df:")))		switch (c) {		case 'd':			debug++;			break;		case 'f':			conffile = optarg;			if (debug)				fprintf(stderr, "%s:%d: config file is %s/n",					__FILE__, __LINE__, conffile);			break;		}	/* read the configuration file					*/	scep_config(&scep, (conffile) ? conffile : OPENSCEPDIR "/openscep.cnf");	/* initialize the LDAP backend					*/	scep_ldap_init(&scep);	/* read the stuff from standard input and write it to a request	*/	/* file so that debugging becomes simpler			*/	inbio = BIO_new(BIO_s_file());	BIO_set_fp(inbio, stdin, BIO_NOCLOSE);	membio = BIO_new(BIO_s_mem());	do {		unsigned char	buffer[1024];		bytes = BIO_read(inbio, buffer, sizeof(buffer));		if (bytes > 0) {			BIO_write(membio, buffer, bytes);			if (debug)				BIO_printf(bio_err, "%s:%d: writing chunk of"					"size %d/n", __FILE__, __LINE__, bytes);		} else 			BIO_printf(bio_err, "%s:%d: no more data from inbio/n",				__FILE__, __LINE__);			} while (bytes > 0);	BIO_flush(membio);	/* the decode call does the following three things		*/	/* - verify the signed data PKCS#7				*/	/* - extract the signed attributes				*/	/* - decrypt the enveloped data					*/	scep.request.base64 = 1;	if (decode(&scep, membio) < 0) {		BIO_printf(bio_err, "%s:%d: decode failed/n", __FILE__,			__LINE__);		syslog(LOG_ERR, "%s:%d: scepd failed to decode request",			__FILE__, __LINE__);		goto err;	}	BIO_free(membio);	/* inform the debug log about the message we have received	*/	if (debug) {		char	name[1024];		BIO_printf(bio_err, "%s:%d: message with transaction id %s/n",			__FILE__, __LINE__, scep.transId);		X509_NAME_oneline(X509_get_subject_name((scep.selfsignedcert)			? scep.selfsignedcert : scep.clientcert), name, 1024);		BIO_printf(bio_err, "%s:%d: sender is %s/n", __FILE__, __LINE__,			name);	}	/* swap nonces and create a reply nonce				*/	if (scep.recipientNonce) {		free(scep.recipientNonce);	}	scep.recipientNonce = scep.senderNonce;	scep.recipientNonceLength = scep.senderNonceLength;	scep.senderNonceLength = 16;	scep.senderNonce = (unsigned char *)malloc(scep.senderNonceLength);//.........这里部分代码省略.........
开发者ID:xman1979,项目名称:openscep,代码行数:101,


示例25: dgst_main

//.........这里部分代码省略.........			}		}	}	/* we use md as a filter, reading from 'in' */	else {		if (md == NULL)			md = EVP_md5();		if (!BIO_set_md(bmd, md)) {			BIO_printf(bio_err, "Error setting digest %s/n", pname);			ERR_print_errors(bio_err);			goto end;		}	}	if (sigfile && sigkey) {		BIO *sigbio;		siglen = EVP_PKEY_size(sigkey);		sigbuf = malloc(siglen);		if (sigbuf == NULL) {			BIO_printf(bio_err, "out of memory/n");			ERR_print_errors(bio_err);			goto end;		}		sigbio = BIO_new_file(sigfile, "rb");		if (!sigbio) {			BIO_printf(bio_err, "Error opening signature file %s/n",			    sigfile);			ERR_print_errors(bio_err);			goto end;		}		siglen = BIO_read(sigbio, sigbuf, siglen);		BIO_free(sigbio);		if (siglen <= 0) {			BIO_printf(bio_err, "Error reading signature file %s/n",			    sigfile);			ERR_print_errors(bio_err);			goto end;		}	}	inp = BIO_push(bmd, in);	if (md == NULL) {		EVP_MD_CTX *tctx;		BIO_get_md_ctx(bmd, &tctx);		md = EVP_MD_CTX_md(tctx);	}	if (argc == 0) {		BIO_set_fp(in, stdin, BIO_NOCLOSE);		err = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf,		    siglen, NULL, NULL, "stdin", bmd);	} else {		const char *md_name = NULL, *sig_name = NULL;		if (!out_bin) {			if (sigkey) {				const EVP_PKEY_ASN1_METHOD *ameth;				ameth = EVP_PKEY_get0_asn1(sigkey);				if (ameth)					EVP_PKEY_asn1_get0_info(NULL, NULL,					    NULL, NULL, &sig_name, ameth);			}			md_name = EVP_MD_name(md);		}		err = 0;		for (i = 0; i < argc; i++) {			int r;			if (BIO_read_filename(in, argv[i]) <= 0) {				perror(argv[i]);				err++;				continue;			} else {				r = do_fp(out, buf, inp, separator, out_bin,				    sigkey, sigbuf, siglen, sig_name, md_name,				    argv[i], bmd);			}			if (r)				err = r;			(void) BIO_reset(bmd);		}	}end:	if (buf != NULL) {		OPENSSL_cleanse(buf, BUFSIZE);		free(buf);	}	if (in != NULL)		BIO_free(in);	free(passin);	BIO_free_all(out);	EVP_PKEY_free(sigkey);	if (sigopts)		sk_OPENSSL_STRING_free(sigopts);	if (macopts)		sk_OPENSSL_STRING_free(macopts);	free(sigbuf);	if (bmd != NULL)		BIO_free(bmd);	return (err);}
开发者ID:alan-mushi,项目名称:libressl-RSA-backdoor,代码行数:101,


示例26: defined

BIO *BIO_new_file(const char *filename, const char *mode){    BIO *ret;    FILE *file = NULL;#  if defined(_WIN32) && defined(CP_UTF8)    int sz, len_0 = (int)strlen(filename) + 1;    DWORD flags;    /*     * Basically there are three cases to cover: a) filename is     * pure ASCII string; b) actual UTF-8 encoded string and     * c) locale-ized string, i.e. one containing 8-bit     * characters that are meaningful in current system locale.     * If filename is pure ASCII or real UTF-8 encoded string,     * MultiByteToWideChar succeeds and _wfopen works. If     * filename is locale-ized string, chances are that     * MultiByteToWideChar fails reporting     * ERROR_NO_UNICODE_TRANSLATION, in which case we fall     * back to fopen...     */    if ((sz = MultiByteToWideChar(CP_UTF8, (flags = MB_ERR_INVALID_CHARS),                                  filename, len_0, NULL, 0)) > 0 ||        (GetLastError() == ERROR_INVALID_FLAGS &&         (sz = MultiByteToWideChar(CP_UTF8, (flags = 0),                                   filename, len_0, NULL, 0)) > 0)        ) {        WCHAR wmode[8];        WCHAR *wfilename = _alloca(sz * sizeof(WCHAR));        if (MultiByteToWideChar(CP_UTF8, flags,                                filename, len_0, wfilename, sz) &&            MultiByteToWideChar(CP_UTF8, 0, mode, strlen(mode) + 1,                                wmode, sizeof(wmode) / sizeof(wmode[0])) &&            (file = _wfopen(wfilename, wmode)) == NULL &&            (errno == ENOENT || errno == EBADF)            ) {            /*             * UTF-8 decode succeeded, but no file, filename             * could still have been locale-ized...             */            file = fopen(filename, mode);        }    } else if (GetLastError() == ERROR_NO_UNICODE_TRANSLATION) {        file = fopen(filename, mode);    }#  else    file = fopen(filename, mode);#  endif    if (file == NULL) {        SYSerr(SYS_F_FOPEN, get_last_sys_error());        ERR_add_error_data(5, "fopen('", filename, "','", mode, "')");        if (errno == ENOENT)            BIOerr(BIO_F_BIO_NEW_FILE, BIO_R_NO_SUCH_FILE);        else            BIOerr(BIO_F_BIO_NEW_FILE, ERR_R_SYS_LIB);        return (NULL);    }    if ((ret = BIO_new(BIO_s_file())) == NULL) {        fclose(file);        return (NULL);    }    BIO_clear_flags(ret, BIO_FLAGS_UPLINK); /* we did fopen -> we disengage                                             * UPLINK */    BIO_set_fp(ret, file, BIO_CLOSE);    return (ret);}
开发者ID:zyh329,项目名称:ipcam_thirdparties,代码行数:68,


示例27: main

int main ( int argc, char **argv ){    int status, length;    io_channel chan;    struct rpc_msg msg;	char *CApath=NULL,*CAfile=NULL;	int badop=0;	int ret=1;	int client_auth=0;	int server_auth=0;	SSL_CTX *s_ctx=NULL;    /*     * Confirm logical link with initiating client.     */    LIB$INIT_TIMER();    status = SYS$ASSIGN ( &sysnet, &chan, 0, 0, 0 );    printf("status of assign to SYS$NET: %d/n", status );    /*     * Initialize standard out and error files.     */	if (bio_err == NULL)		if ((bio_err=BIO_new(BIO_s_file())) != NULL)			BIO_set_fp(bio_err,stderr,BIO_NOCLOSE);	if (bio_stdout == NULL)		if ((bio_stdout=BIO_new(BIO_s_file())) != NULL)			BIO_set_fp(bio_stdout,stdout,BIO_NOCLOSE);    /*     * get the preferred cipher list and other initialization     */	if (cipher == NULL) cipher=getenv("SSL_CIPHER");	printf("cipher list: %s/n", cipher ? cipher : "{undefined}" );	SSL_load_error_strings();	OpenSSL_add_all_algorithms();/* DRM, this was the original, but there is no such thing as SSLv2()	s_ctx=SSL_CTX_new(SSLv2());*/	s_ctx=SSL_CTX_new(SSLv2_server_method());	if (s_ctx == NULL) goto end;	SSL_CTX_use_certificate_file(s_ctx,TEST_SERVER_CERT,SSL_FILETYPE_PEM);	SSL_CTX_use_RSAPrivateKey_file(s_ctx,TEST_SERVER_CERT,SSL_FILETYPE_PEM);	printf("Loaded server certificate: '%s'/n", TEST_SERVER_CERT );    /*     * Take commands from client until bad status.     */    LIB$SHOW_TIMER();    status = doit ( chan, s_ctx );    LIB$SHOW_TIMER();    /*     * do final cleanup and exit.     */end:	if (s_ctx != NULL) SSL_CTX_free(s_ctx);    LIB$SHOW_TIMER();    return 1;}
开发者ID:ahenroid,项目名称:ptptl-0.2,代码行数:61,


示例28: rsa_main

intrsa_main(int argc, char **argv){	int ret = 1;	RSA *rsa = NULL;	int i;	BIO *out = NULL;	char *passin = NULL, *passout = NULL;	if (single_execution) {		if (pledge("stdio cpath wpath rpath tty", NULL) == -1) {			perror("pledge");			exit(1);		}	}	memset(&rsa_config, 0, sizeof(rsa_config));	rsa_config.pvk_encr = 2;	rsa_config.informat = FORMAT_PEM;	rsa_config.outformat = FORMAT_PEM;	if (options_parse(argc, argv, rsa_options, NULL, NULL) != 0) {		rsa_usage();		goto end;	}	if (!app_passwd(bio_err, rsa_config.passargin, rsa_config.passargout,	    &passin, &passout)) {		BIO_printf(bio_err, "Error getting passwords/n");		goto end;	}	if (rsa_config.check && rsa_config.pubin) {		BIO_printf(bio_err, "Only private keys can be checked/n");		goto end;	}	out = BIO_new(BIO_s_file());	{		EVP_PKEY *pkey;		if (rsa_config.pubin) {			int tmpformat = -1;			if (rsa_config.pubin == 2) {				if (rsa_config.informat == FORMAT_PEM)					tmpformat = FORMAT_PEMRSA;				else if (rsa_config.informat == FORMAT_ASN1)					tmpformat = FORMAT_ASN1RSA;			} else if (rsa_config.informat == FORMAT_NETSCAPE &&			    rsa_config.sgckey)				tmpformat = FORMAT_IISSGC;			else				tmpformat = rsa_config.informat;			pkey = load_pubkey(bio_err, rsa_config.infile,			    tmpformat, 1, passin, "Public Key");		} else			pkey = load_key(bio_err, rsa_config.infile,			    (rsa_config.informat == FORMAT_NETSCAPE &&			    rsa_config.sgckey ? FORMAT_IISSGC :			    rsa_config.informat), 1, passin, "Private Key");		if (pkey != NULL)			rsa = EVP_PKEY_get1_RSA(pkey);		EVP_PKEY_free(pkey);	}	if (rsa == NULL) {		ERR_print_errors(bio_err);		goto end;	}	if (rsa_config.outfile == NULL) {		BIO_set_fp(out, stdout, BIO_NOCLOSE);	} else {		if (BIO_write_filename(out, rsa_config.outfile) <= 0) {			perror(rsa_config.outfile);			goto end;		}	}	if (rsa_config.text)		if (!RSA_print(out, rsa, 0)) {			perror(rsa_config.outfile);			ERR_print_errors(bio_err);			goto end;		}	if (rsa_config.modulus) {		BIO_printf(out, "Modulus=");		BN_print(out, rsa->n);		BIO_printf(out, "/n");	}	if (rsa_config.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 &&			    ERR_GET_LIB(err) == ERR_LIB_RSA &&//.........这里部分代码省略.........
开发者ID:soundsrc,项目名称:git-lfs-server,代码行数:101,


示例29: MAIN

int MAIN(int argc, char **argv)	{#ifndef OPENSSL_NO_ENGINE	ENGINE *e = NULL;#endif	DSA *dsa=NULL;	int i,badops=0,text=0;	BIO *in=NULL,*out=NULL;	int informat,outformat,noout=0,C=0,ret=1;	char *infile,*outfile,*prog,*inrand=NULL;	int numbits= -1,num,genkey=0;	int need_rand=0;#ifndef OPENSSL_NO_ENGINE	char *engine=NULL;#endif#ifdef GENCB_TEST	int timebomb=0;#endif	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;	infile=NULL;	outfile=NULL;	informat=FORMAT_PEM;	outformat=FORMAT_PEM;	prog=argv[0];	argc--;	argv++;	while (argc >= 1)		{		if 	(strcmp(*argv,"-inform") == 0)			{			if (--argc < 1) goto bad;			informat=str2fmt(*(++argv));			}		else if (strcmp(*argv,"-outform") == 0)			{			if (--argc < 1) goto bad;			outformat=str2fmt(*(++argv));			}		else if (strcmp(*argv,"-in") == 0)			{			if (--argc < 1) goto bad;			infile= *(++argv);			}		else if (strcmp(*argv,"-out") == 0)			{			if (--argc < 1) goto bad;			outfile= *(++argv);			}#ifndef OPENSSL_NO_ENGINE		else if(strcmp(*argv, "-engine") == 0)			{			if (--argc < 1) goto bad;			engine = *(++argv);			}#endif#ifdef GENCB_TEST		else if(strcmp(*argv, "-timebomb") == 0)			{			if (--argc < 1) goto bad;			timebomb = atoi(*(++argv));			}#endif		else if (strcmp(*argv,"-text") == 0)			text=1;		else if (strcmp(*argv,"-C") == 0)			C=1;		else if (strcmp(*argv,"-genkey") == 0)			{			genkey=1;			need_rand=1;			}		else if (strcmp(*argv,"-rand") == 0)			{			if (--argc < 1) goto bad;			inrand= *(++argv);			need_rand=1;			}		else if (strcmp(*argv,"-noout") == 0)			noout=1;		else if (sscanf(*argv,"%d",&num) == 1)			{			/* generate a key */			numbits=num;			need_rand=1;			}		else			{			BIO_printf(bio_err,"unknown option %s/n",*argv);			badops=1;			break;//.........这里部分代码省略.........
开发者ID:LucidOne,项目名称:Rovio,代码行数:101,



注:本文中的BIO_set_fp函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ BIO_set_init函数代码示例
C++ BIO_set_flags函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。