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

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

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

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

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

示例1: LOGE

const cipher_kt_t *get_cipher_type(int method){    if (method <= TABLE || method >= CIPHER_NUM) {        LOGE("get_cipher_type(): Illegal method");        return NULL;    }    if (method == RC4_MD5) {        method = RC4;    }    if (method >= SALSA20) {        return NULL;    }    const char *ciphername = supported_ciphers[method];#if defined(USE_CRYPTO_OPENSSL)    return EVP_get_cipherbyname(ciphername);#elif defined(USE_CRYPTO_POLARSSL)    const char *polarname = supported_ciphers_polarssl[method];    if (strcmp(polarname, CIPHER_UNSUPPORTED) == 0) {        LOGE("Cipher %s currently is not supported by PolarSSL library",             ciphername);        return NULL;    }    return cipher_info_from_string(polarname);#elif defined(USE_CRYPTO_MBEDTLS)    const char *mbedtlsname = supported_ciphers_mbedtls[method];    if (strcmp(mbedtlsname, CIPHER_UNSUPPORTED) == 0) {        LOGE("Cipher %s currently is not supported by mbed TLS library",             ciphername);        return NULL;    }    return mbedtls_cipher_info_from_string(mbedtlsname);#endif}
开发者ID:jackalchen,项目名称:shadowsocks-libev,代码行数:36,


示例2: load_ciphers

static void load_ciphers(void)	{	init_ciphers=0;	ssl_cipher_methods[SSL_ENC_DES_IDX]= 		EVP_get_cipherbyname(SN_des_cbc);	ssl_cipher_methods[SSL_ENC_3DES_IDX]=		EVP_get_cipherbyname(SN_des_ede3_cbc);	ssl_cipher_methods[SSL_ENC_RC4_IDX]=		EVP_get_cipherbyname(SN_rc4);	ssl_cipher_methods[SSL_ENC_RC2_IDX]= 		EVP_get_cipherbyname(SN_rc2_cbc);	ssl_cipher_methods[SSL_ENC_IDEA_IDX]= 		EVP_get_cipherbyname(SN_idea_cbc);	ssl_cipher_methods[SSL_ENC_AES128_IDX]=	  EVP_get_cipherbyname(SN_aes_128_cbc);	ssl_cipher_methods[SSL_ENC_AES256_IDX]=	  EVP_get_cipherbyname(SN_aes_256_cbc);	ssl_digest_methods[SSL_MD_MD5_IDX]=		EVP_get_digestbyname(SN_md5);	ssl_digest_methods[SSL_MD_SHA1_IDX]=		EVP_get_digestbyname(SN_sha1);	}
开发者ID:xyzy,项目名称:mips-openssl_0.9.7,代码行数:23,


示例3: espprint_decode_encalgo

USES_APPLE_DEPRECATED_APIstatic intespprint_decode_encalgo(netdissect_options *ndo,			char *decode, struct sa_list *sa){	size_t i;	const EVP_CIPHER *evp;	int authlen = 0;	char *colon, *p;		colon = strchr(decode, ':');	if (colon == NULL) {		(*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s/n", decode);		return 0;	}	*colon = '/0';		if (strlen(decode) > strlen("-hmac96") &&	    !strcmp(decode + strlen(decode) - strlen("-hmac96"),		    "-hmac96")) {		p = strstr(decode, "-hmac96");		*p = '/0';		authlen = 12;	}	if (strlen(decode) > strlen("-cbc") &&	    !strcmp(decode + strlen(decode) - strlen("-cbc"), "-cbc")) {		p = strstr(decode, "-cbc");		*p = '/0';	}	evp = EVP_get_cipherbyname(decode);	if (!evp) {		(*ndo->ndo_warning)(ndo, "failed to find cipher algo %s/n", decode);		sa->evp = NULL;		sa->authlen = 0;		sa->ivlen = 0;		return 0;	}		sa->evp = evp;	sa->authlen = authlen;	sa->ivlen = EVP_CIPHER_iv_length(evp);		colon++;	if (colon[0] == '0' && colon[1] == 'x') {		/* decode some hex! */		colon += 2;		sa->secretlen = espprint_decode_hex(ndo, sa->secret, sizeof(sa->secret), colon);		if(sa->secretlen == 0) return 0;	} else {		i = strlen(colon);				if (i < sizeof(sa->secret)) {			memcpy(sa->secret, colon, i);			sa->secretlen = i;		} else {			memcpy(sa->secret, colon, sizeof(sa->secret));			sa->secretlen = sizeof(sa->secret);		}	}	return 1;}
开发者ID:CriGio,项目名称:platform_external_tcpdump,代码行数:64,


示例4: MAIN

//.........这里部分代码省略.........            if (!args[1])                goto argerr;            certfile = *++args;        } else if (!strcmp(*args, "-CAfile")) {            if (!args[1])                goto argerr;            CAfile = *++args;        } else if (!strcmp(*args, "-CApath")) {            if (!args[1])                goto argerr;            CApath = *++args;        } else if (!strcmp(*args, "-in")) {            if (!args[1])                goto argerr;            infile = *++args;        } else if (!strcmp(*args, "-inform")) {            if (!args[1])                goto argerr;            informat = str2fmt(*++args);        } else if (!strcmp(*args, "-outform")) {            if (!args[1])                goto argerr;            outformat = str2fmt(*++args);        } else if (!strcmp(*args, "-out")) {            if (!args[1])                goto argerr;            outfile = *++args;        } else if (!strcmp(*args, "-content")) {            if (!args[1])                goto argerr;            contfile = *++args;        } else if (args_verify(&args, NULL, &badarg, bio_err, &vpm))            continue;        else if ((cipher = EVP_get_cipherbyname(*args + 1)) == NULL)            badarg = 1;        args++;    }    if (((rr_allorfirst != -1) || rr_from) && !rr_to) {        BIO_puts(bio_err, "No Signed Receipts Recipients/n");        goto argerr;    }    if (!(operation & SMIME_SIGNERS) && (rr_to || rr_from)) {        BIO_puts(bio_err, "Signed receipts only allowed with -sign/n");        goto argerr;    }    if (!(operation & SMIME_SIGNERS) && (skkeys || sksigners)) {        BIO_puts(bio_err, "Multiple signers or keys not allowed/n");        goto argerr;    }    if (operation & SMIME_SIGNERS) {        if (keyfile && !signerfile) {            BIO_puts(bio_err, "Illegal -inkey without -signer/n");            goto argerr;        }        /* Check to see if any final signer needs to be appended */        if (signerfile) {            if (!sksigners)                sksigners = sk_OPENSSL_STRING_new_null();            sk_OPENSSL_STRING_push(sksigners, signerfile);            if (!skkeys)                skkeys = sk_OPENSSL_STRING_new_null();            if (!keyfile)                keyfile = signerfile;
开发者ID:davidlt,项目名称:openssl-fedora,代码行数:67,


示例5: MAIN

int MAIN(int argc, char **argv){    ENGINE *e = NULL;    int ret=1;    DSA *dsa=NULL;    int i,badops=0;    const EVP_CIPHER *enc=NULL;    BIO *in=NULL,*out=NULL;    int informat,outformat,text=0,noout=0;    int pubin = 0, pubout = 0;    char *infile,*outfile,*prog;#ifndef OPENSSL_NO_ENGINE    char *engine;#endif    char *passargin = NULL, *passargout = NULL;    char *passin = NULL, *passout = NULL;    int modulus=0;    int pvk_encr = 2;    apps_startup();    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 end;#ifndef OPENSSL_NO_ENGINE    engine=NULL;#endif    infile=NULL;    outfile=NULL;    informat=FORMAT_PEM;    outformat=FORMAT_PEM;    prog=argv[0];    argc--;    argv++;    while (argc >= 1)    {        if 	(TINYCLR_SSL_STRCMP(*argv,"-inform") == 0)        {            if (--argc < 1) goto bad;            informat=str2fmt(*(++argv));        }        else if (TINYCLR_SSL_STRCMP(*argv,"-outform") == 0)        {            if (--argc < 1) goto bad;            outformat=str2fmt(*(++argv));        }        else if (TINYCLR_SSL_STRCMP(*argv,"-in") == 0)        {            if (--argc < 1) goto bad;            infile= *(++argv);        }        else if (TINYCLR_SSL_STRCMP(*argv,"-out") == 0)        {            if (--argc < 1) goto bad;            outfile= *(++argv);        }        else if (TINYCLR_SSL_STRCMP(*argv,"-passin") == 0)        {            if (--argc < 1) goto bad;            passargin= *(++argv);        }        else if (TINYCLR_SSL_STRCMP(*argv,"-passout") == 0)        {            if (--argc < 1) goto bad;            passargout= *(++argv);        }#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,"-pvk-strong") == 0)            pvk_encr=2;        else if (TINYCLR_SSL_STRCMP(*argv,"-pvk-weak") == 0)            pvk_encr=1;        else if (TINYCLR_SSL_STRCMP(*argv,"-pvk-none") == 0)            pvk_encr=0;        else if (TINYCLR_SSL_STRCMP(*argv,"-noout") == 0)            noout=1;        else if (TINYCLR_SSL_STRCMP(*argv,"-text") == 0)            text=1;        else if (TINYCLR_SSL_STRCMP(*argv,"-modulus") == 0)            modulus=1;        else if (TINYCLR_SSL_STRCMP(*argv,"-pubin") == 0)            pubin=1;        else if (TINYCLR_SSL_STRCMP(*argv,"-pubout") == 0)            pubout=1;        else if ((enc=EVP_get_cipherbyname(&(argv[0][1]))) == NULL)        {            BIO_printf(bio_err,"unknown option %s/n",*argv);            badops=1;            break;//.........这里部分代码省略.........
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:101,


示例6: sqlcipher_openssl_set_cipher

static int sqlcipher_openssl_set_cipher(void *ctx, const char *cipher_name) {  openssl_ctx *o_ctx = (openssl_ctx *)ctx;  o_ctx->evp_cipher = (EVP_CIPHER *) EVP_get_cipherbyname(cipher_name);  return SQLITE_OK;}
开发者ID:akrav,项目名称:sqlcipher,代码行数:5,


示例7: enc_main

intenc_main(int argc, char **argv){	static const char magic[] = "Salted__";	char mbuf[sizeof magic - 1];	char *strbuf = NULL, *pass = NULL;	unsigned char *buff = NULL;	int bsize = BSIZE;	int ret = 1, inl;	unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH];	unsigned char salt[PKCS5_SALT_LEN];#ifdef ZLIB	BIO *bzl = NULL;#endif	EVP_CIPHER_CTX *ctx = NULL;	const EVP_MD *dgst = NULL;	BIO *in = NULL, *out = NULL, *b64 = NULL, *benc = NULL;	BIO *rbio = NULL, *wbio = NULL;#define PROG_NAME_SIZE  39	char pname[PROG_NAME_SIZE + 1];	int i;	if (single_execution) {		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {			perror("pledge");			exit(1);		}	}	memset(&enc_config, 0, sizeof(enc_config));	enc_config.enc = 1;	/* first check the program name */	program_name(argv[0], pname, sizeof(pname));	if (strcmp(pname, "base64") == 0)		enc_config.base64 = 1;#ifdef ZLIB	if (strcmp(pname, "zlib") == 0)		enc_config.do_zlib = 1;#endif	enc_config.cipher = EVP_get_cipherbyname(pname);#ifdef ZLIB	if (!enc_config.do_zlib && !enc_config.base64 &&	    enc_config.cipher == NULL && strcmp(pname, "enc") != 0)#else	if (!enc_config.base64 && enc_config.cipher == NULL &&	    strcmp(pname, "enc") != 0)#endif	{		BIO_printf(bio_err, "%s is an unknown cipher/n", pname);		goto end;	}	if (options_parse(argc, argv, enc_options, NULL, NULL) != 0) {		enc_usage();		goto end;	}	if (enc_config.keyfile != NULL) {		static char buf[128];		FILE *infile;		infile = fopen(enc_config.keyfile, "r");		if (infile == NULL) {			BIO_printf(bio_err, "unable to read key from '%s'/n",			    enc_config.keyfile);			goto end;		}		buf[0] = '/0';		if (!fgets(buf, sizeof buf, infile)) {			BIO_printf(bio_err, "unable to read key from '%s'/n",			    enc_config.keyfile);			fclose(infile);			goto end;		}		fclose(infile);		i = strlen(buf);		if ((i > 0) && ((buf[i - 1] == '/n') || (buf[i - 1] == '/r')))			buf[--i] = '/0';		if ((i > 0) && ((buf[i - 1] == '/n') || (buf[i - 1] == '/r')))			buf[--i] = '/0';		if (i < 1) {			BIO_printf(bio_err, "zero length password/n");			goto end;		}		enc_config.keystr = buf;	}	if (enc_config.md != NULL &&	    (dgst = EVP_get_digestbyname(enc_config.md)) == NULL) {		BIO_printf(bio_err,		    "%s is an unsupported message digest type/n",		    enc_config.md);		goto end;	}	if (dgst == NULL) {//.........这里部分代码省略.........
开发者ID:darksoul42,项目名称:bitrig,代码行数:101,


示例8: MAIN

int MAIN(int argc, char **argv)	{	ENGINE *e = NULL;	char **args, *infile = NULL, *outfile = NULL;	char *passargin = NULL, *passargout = NULL;	BIO *in = NULL, *out = NULL;	int topk8 = 0;	int pbe_nid = -1;	const EVP_CIPHER *cipher = NULL;	int iter = PKCS12_DEFAULT_ITER;	int informat, outformat;	int p8_broken = PKCS8_OK;	int nocrypt = 0;	X509_SIG *p8 = NULL;	PKCS8_PRIV_KEY_INFO *p8inf = NULL;	EVP_PKEY *pkey=NULL;	char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL;	int badarg = 0;	int ret = 1;#ifndef OPENSSL_NO_ENGINE	char *engine=NULL;#endif	if (bio_err == NULL) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);	if (!load_config(bio_err, NULL))		goto end;	informat=FORMAT_PEM;	outformat=FORMAT_PEM;	ERR_load_crypto_strings();	OpenSSL_add_all_algorithms();	args = argv + 1;	while (!badarg && *args && *args[0] == '-')		{		if (!strcmp(*args,"-v2"))			{			if (args[1])				{				args++;				cipher=EVP_get_cipherbyname(*args);				if (!cipher)					{					BIO_printf(bio_err,						 "Unknown cipher %s/n", *args);					badarg = 1;					}				}			else				badarg = 1;			}		else if (!strcmp(*args,"-v1"))			{			if (args[1])				{				args++;				pbe_nid=OBJ_txt2nid(*args);				if (pbe_nid == NID_undef)					{					BIO_printf(bio_err,						 "Unknown PBE algorithm %s/n", *args);					badarg = 1;					}				}			else				badarg = 1;			}		else if (!strcmp(*args,"-v2prf"))			{			if (args[1])				{				args++;				pbe_nid=OBJ_txt2nid(*args);				if (!EVP_PBE_find(EVP_PBE_TYPE_PRF, pbe_nid, NULL, NULL, 0))					{					BIO_printf(bio_err,						 "Unknown PRF algorithm %s/n", *args);					badarg = 1;					}				}			else				badarg = 1;			}		else if (!strcmp(*args,"-inform"))			{			if (args[1])				{				args++;				informat=str2fmt(*args);				}			else badarg = 1;			}		else if (!strcmp(*args,"-outform"))			{			if (args[1])				{				args++;				outformat=str2fmt(*args);				}//.........这里部分代码省略.........
开发者ID:rfkrocktk,项目名称:openssl,代码行数:101,


示例9: Java_de_blinkt_openvpn_core_NativeUtils_getOpenSSLSpeed

    jdoubleArray Java_de_blinkt_openvpn_core_NativeUtils_getOpenSSLSpeed(JNIEnv* env, jclass thiz, jstring algorithm, jint testnumber){    static const unsigned char key16[16] = {        0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0,        0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x12    };    const EVP_CIPHER *evp_cipher = NULL;    const char* alg = (*env)->GetStringUTFChars( env, algorithm , NULL ) ;    evp_cipher = EVP_get_cipherbyname(alg);    if (evp_cipher == NULL)        evp_md = EVP_get_digestbyname(alg);    if (evp_cipher == NULL && evp_md == NULL) {        //        BIO_printf(bio_err, "%s: %s is an unknown cipher or digest/n", prog, opt_arg());        //jniThrowException(env, "java/security/NoSuchAlgorithmException", "Algorithm not found");        return NULL;    }    const char* name;    loopargs_t *loopargs = NULL;    int loopargs_len = 1;    int async_jobs=0;    loopargs = malloc(loopargs_len * sizeof(loopargs_t));    memset(loopargs, 0, loopargs_len * sizeof(loopargs_t));    jdoubleArray ret = (*env)->NewDoubleArray(env, 3);    if (testnum < 0 || testnum >= SIZE_NUM)        return NULL;    testnum = testnumber;    for (int i = 0; i < loopargs_len; i++) {        int misalign=0;        loopargs[i].buf_malloc = malloc((int)BUFSIZE + MAX_MISALIGNMENT + 1);        loopargs[i].buf2_malloc = malloc((int)BUFSIZE + MAX_MISALIGNMENT + 1);        /* Align the start of buffers on a 64 byte boundary */        loopargs[i].buf = loopargs[i].buf_malloc + misalign;        loopargs[i].buf2 = loopargs[i].buf2_malloc + misalign;    }    int count;    float d;    if (evp_cipher) {        name = OBJ_nid2ln(EVP_CIPHER_nid(evp_cipher));        /*         * -O3 -fschedule-insns messes up an optimization here!         * names[D_EVP] somehow becomes NULL         */        for (int k = 0; k < loopargs_len; k++) {            loopargs[k].ctx = EVP_CIPHER_CTX_new();            if (decrypt)                EVP_DecryptInit_ex(loopargs[k].ctx, evp_cipher, NULL, key16, iv);            else                EVP_EncryptInit_ex(loopargs[k].ctx, evp_cipher, NULL, key16, iv);            EVP_CIPHER_CTX_set_padding(loopargs[k].ctx, 0);        }        Time_F(START);        pthread_t timer_thread;        if (pthread_create(&timer_thread, NULL, stop_run, NULL))            return NULL;        count = run_benchmark(async_jobs, EVP_Update_loop, loopargs);        d = Time_F(STOP);        for (int k = 0; k < loopargs_len; k++) {            EVP_CIPHER_CTX_free(loopargs[k].ctx);        }    }    if (evp_md) {        name = OBJ_nid2ln(EVP_MD_type(evp_md));        //            print_message(names[D_EVP], save_count, lengths[testnum]);        pthread_t timer_thread;        if (pthread_create(&timer_thread, NULL, stop_run, NULL))            return NULL;        Time_F(START);        count = run_benchmark(async_jobs, EVP_Digest_loop, loopargs);        d = Time_F(STOP);    }    // Save results in hacky way    double results[] = {(double) lengths[testnum], (double) count, d};    (*env)->SetDoubleArrayRegion(env, ret, 0, 3, results);    //        print_result(D_EVP, testnum, count, d);    return ret;//.........这里部分代码省略.........
开发者ID:TomMD,项目名称:ics-openvpn,代码行数:101,


示例10: _libssh2_pub_priv_keyfile

int_libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,                          unsigned char **method,                          size_t *method_len,                          unsigned char **pubkeydata,                          size_t *pubkeydata_len,                          const char *privatekey,                          const char *passphrase){    int       st;    BIO*      bp;    EVP_PKEY* pk;    _libssh2_debug(session,                   LIBSSH2_TRACE_AUTH,                   "Computing public key from private key file: %s",                   privatekey);    bp = BIO_new_file(privatekey, "r");    if (bp == NULL) {        _libssh2_error(session,                       LIBSSH2_ERROR_FILE,                       "Unable to open private key file");        return -1;    }    if (!EVP_get_cipherbyname("des")) {        /* If this cipher isn't loaded it's a pretty good indication that none         * are.  I have *NO DOUBT* that there's a better way to deal with this         * ($#&%#$(%$#( Someone buy me an OpenSSL manual and I'll read up on         * it.         */        OpenSSL_add_all_ciphers();    }    BIO_reset(bp);    pk = PEM_read_bio_PrivateKey(bp, NULL, NULL, (void*)passphrase);    BIO_free(bp);    if (pk == NULL) {        _libssh2_error(session,                       LIBSSH2_ERROR_FILE,                       "Wrong passphrase or invalid/unrecognized "                       "private key file format");        return -1;    }    switch (pk->type) {    case EVP_PKEY_RSA :        st = gen_publickey_from_rsa_evp(            session, method, method_len, pubkeydata, pubkeydata_len, pk);        break;    case EVP_PKEY_DSA :        st = gen_publickey_from_dsa_evp(            session, method, method_len, pubkeydata, pubkeydata_len, pk);        break;    default :        st = -1;        _libssh2_error(session,                       LIBSSH2_ERROR_FILE,                       "Unsupported private key file format");        break;    }    EVP_PKEY_free(pk);    return st;}
开发者ID:pierrejoye,项目名称:libssh2,代码行数:67,


示例11: MAIN

int MAIN(int argc, char **argv){#ifndef OPENSSL_NO_ENGINE    ENGINE *e = NULL;#endif    int ret=1;    DSA *dsa=NULL;    int i,badops=0;    const EVP_CIPHER *enc=NULL;    BIO *in=NULL,*out=NULL;    int informat,outformat,text=0,noout=0;    int pubin = 0, pubout = 0;    char *infile,*outfile,*prog;#ifndef OPENSSL_NO_ENGINE    char *engine;#endif    char *passargin = NULL, *passargout = NULL;    char *passin = NULL, *passout = NULL;    int modulus=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);    if (!load_config(bio_err, NULL))        goto end;#ifndef OPENSSL_NO_ENGINE    engine=NULL;#endif    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);        }        else if (strcmp(*argv,"-passin") == 0)        {            if (--argc < 1) goto bad;            passargin= *(++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,"-noout") == 0)            noout=1;        else if (strcmp(*argv,"-text") == 0)            text=1;        else if (strcmp(*argv,"-modulus") == 0)            modulus=1;        else if (strcmp(*argv,"-pubin") == 0)            pubin=1;        else if (strcmp(*argv,"-pubout") == 0)            pubout=1;        else if ((enc=EVP_get_cipherbyname(&(argv[0][1]))) == NULL)        {            BIO_printf(bio_err,"unknown option %s/n",*argv);            badops=1;            break;        }        argc--;        argv++;    }    if (badops)//.........这里部分代码省略.........
开发者ID:neominds,项目名称:JPN-IWE14057,代码行数:101,


示例12: enc_main

int enc_main(int argc, char **argv){    static char buf[128];    static const char magic[] = "Salted__";    BIO *in = NULL, *out = NULL, *b64 = NULL, *benc = NULL, *rbio =                                            NULL, *wbio = NULL;    EVP_CIPHER_CTX *ctx = NULL;    const EVP_CIPHER *cipher = NULL, *c;    const EVP_MD *dgst = NULL;    char *hkey = NULL, *hiv = NULL, *hsalt = NULL, *p;    char *infile = NULL, *outfile = NULL, *prog;    char *str = NULL, *passarg = NULL, *pass = NULL, *strbuf = NULL;    char mbuf[sizeof magic - 1];    OPTION_CHOICE o;    int bsize = BSIZE, verbose = 0, debug = 0, olb64 = 0, nosalt = 0;    int enc = 1, printkey = 0, i, k;    int base64 = 0, informat = FORMAT_BINARY, outformat = FORMAT_BINARY;    int ret = 1, inl, nopad = 0, non_fips_allow = 0;    unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH];    unsigned char *buff = NULL, salt[PKCS5_SALT_LEN];    unsigned long n;#ifdef ZLIB    int do_zlib = 0;    BIO *bzl = NULL;#endif    /* first check the program name */    prog = opt_progname(argv[0]);    if (strcmp(prog, "base64") == 0)        base64 = 1;#ifdef ZLIB    else if (strcmp(prog, "zlib") == 0)        do_zlib = 1;#endif    else {        cipher = EVP_get_cipherbyname(prog);        if (cipher == NULL && strcmp(prog, "enc") != 0) {            BIO_printf(bio_err, "%s is not a known cipher/n", prog);            goto end;        }    }    prog = opt_init(argc, argv, enc_options);    while ((o = opt_next()) != OPT_EOF) {        switch (o) {        case OPT_EOF:        case OPT_ERR:opthelp:            BIO_printf(bio_err, "%s: Use -help for summary./n", prog);            goto end;        case OPT_HELP:            opt_help(enc_options);            ret = 0;            BIO_printf(bio_err, "Cipher Types/n");            OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH,                                   show_ciphers, bio_err);            BIO_printf(bio_err, "/n");            goto end;        case OPT_E:            enc = 1;            break;        case OPT_IN:            infile = opt_arg();            break;        case OPT_OUT:            outfile = opt_arg();            break;        case OPT_PASS:            passarg = opt_arg();            break;        case OPT_ENGINE:            (void)setup_engine(opt_arg(), 0);            break;        case OPT_D:            enc = 0;            break;        case OPT_P:            printkey = 1;            break;        case OPT_V:            verbose = 1;            break;        case OPT_NOPAD:            nopad = 1;            break;        case OPT_SALT:            nosalt = 0;            break;        case OPT_NOSALT:            nosalt = 1;            break;        case OPT_DEBUG:            debug = 1;            break;        case OPT_UPPER_P:            printkey = 2;            break;        case OPT_UPPER_A:            olb64 = 1;            break;//.........这里部分代码省略.........
开发者ID:a1sams1a,项目名称:openssl-is523,代码行数:101,


示例13: PEM_get_EVP_CIPHER_INFO

int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher){    const EVP_CIPHER *enc = NULL;    char *p, c;    char **header_pp = &header;    cipher->cipher = NULL;    if ((header == NULL) || (*header == '/0') || (*header == '/n'))        return (1);    if (strncmp(header, "Proc-Type: ", 11) != 0) {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_NOT_PROC_TYPE);        return (0);    }    header += 11;    if (*header != '4')        return (0);    header++;    if (*header != ',')        return (0);    header++;    if (strncmp(header, "ENCRYPTED", 9) != 0) {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_NOT_ENCRYPTED);        return (0);    }    for (; (*header != '/n') && (*header != '/0'); header++) ;    if (*header == '/0') {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_SHORT_HEADER);        return (0);    }    header++;    if (strncmp(header, "DEK-Info: ", 10) != 0) {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_NOT_DEK_INFO);        return (0);    }    header += 10;    p = header;    for (;;) {        c = *header;#ifndef CHARSET_EBCDIC        if (!(((c >= 'A') && (c <= 'Z')) || (c == '-') ||              ((c >= '0') && (c <= '9'))))            break;#else        if (!(isupper(c) || (c == '-') || isdigit(c)))            break;#endif        header++;    }    *header = '/0';    cipher->cipher = enc = EVP_get_cipherbyname(p);    *header = c;    header++;    if (enc == NULL) {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_UNSUPPORTED_ENCRYPTION);        return (0);    }    if (!load_iv(header_pp, &(cipher->iv[0]), enc->iv_len))        return (0);    return (1);}
开发者ID:endlessm,项目名称:shim,代码行数:63,


示例14: ssl_load_ciphers

void ssl_load_ciphers(void)	{	ssl_cipher_methods[SSL_ENC_DES_IDX]= 		EVP_get_cipherbyname(SN_des_cbc);	ssl_cipher_methods[SSL_ENC_3DES_IDX]=		EVP_get_cipherbyname(SN_des_ede3_cbc);	ssl_cipher_methods[SSL_ENC_RC4_IDX]=		EVP_get_cipherbyname(SN_rc4);	ssl_cipher_methods[SSL_ENC_RC2_IDX]= 		EVP_get_cipherbyname(SN_rc2_cbc);#ifndef OPENSSL_NO_IDEA	ssl_cipher_methods[SSL_ENC_IDEA_IDX]= 		EVP_get_cipherbyname(SN_idea_cbc);#else	ssl_cipher_methods[SSL_ENC_IDEA_IDX]= NULL;#endif	ssl_cipher_methods[SSL_ENC_AES128_IDX]=	  EVP_get_cipherbyname(SN_aes_128_cbc);	ssl_cipher_methods[SSL_ENC_AES256_IDX]=	  EVP_get_cipherbyname(SN_aes_256_cbc);	ssl_cipher_methods[SSL_ENC_CAMELLIA128_IDX]=	  EVP_get_cipherbyname(SN_camellia_128_cbc);	ssl_cipher_methods[SSL_ENC_CAMELLIA256_IDX]=	  EVP_get_cipherbyname(SN_camellia_256_cbc);	ssl_cipher_methods[SSL_ENC_GOST89_IDX]=	  EVP_get_cipherbyname(SN_gost89_cnt);	ssl_cipher_methods[SSL_ENC_SEED_IDX]=	  EVP_get_cipherbyname(SN_seed_cbc);	ssl_digest_methods[SSL_MD_MD5_IDX]=		EVP_get_digestbyname(SN_md5);	ssl_mac_secret_size[SSL_MD_MD5_IDX]=		EVP_MD_size(ssl_digest_methods[SSL_MD_MD5_IDX]);	OPENSSL_assert(ssl_mac_secret_size[SSL_MD_MD5_IDX] >= 0);	ssl_digest_methods[SSL_MD_SHA1_IDX]=		EVP_get_digestbyname(SN_sha1);	ssl_mac_secret_size[SSL_MD_SHA1_IDX]=		EVP_MD_size(ssl_digest_methods[SSL_MD_SHA1_IDX]);	OPENSSL_assert(ssl_mac_secret_size[SSL_MD_SHA1_IDX] >= 0);	ssl_digest_methods[SSL_MD_GOST94_IDX]=		EVP_get_digestbyname(SN_id_GostR3411_94);	if (ssl_digest_methods[SSL_MD_GOST94_IDX])		{			ssl_mac_secret_size[SSL_MD_GOST94_IDX]=			EVP_MD_size(ssl_digest_methods[SSL_MD_GOST94_IDX]);		OPENSSL_assert(ssl_mac_secret_size[SSL_MD_GOST94_IDX] >= 0);		}	ssl_digest_methods[SSL_MD_GOST89MAC_IDX]=		EVP_get_digestbyname(SN_id_Gost28147_89_MAC);		ssl_mac_pkey_id[SSL_MD_GOST89MAC_IDX] = get_optional_pkey_id("gost-mac");		if (ssl_mac_pkey_id[SSL_MD_GOST89MAC_IDX]) {			ssl_mac_secret_size[SSL_MD_GOST89MAC_IDX]=32;		}			}
开发者ID:735579768,项目名称:droidVncServer,代码行数:55,


示例15: MAIN

int MAIN(int argc, char **argv){    int ret = 1;    EC_KEY *eckey = NULL;    const EC_GROUP *group;    int i, badops = 0;    const EVP_CIPHER *enc = NULL;    BIO *in = NULL, *out = NULL;    int informat, outformat, text = 0, noout = 0;    int pubin = 0, pubout = 0, param_out = 0;    char *infile, *outfile, *prog, *engine;    char *passargin = NULL, *passargout = NULL;    char *passin = NULL, *passout = NULL;    point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED;    int new_form = 0;    int asn1_flag = OPENSSL_EC_NAMED_CURVE;    int new_asn1_flag = 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);    if (!load_config(bio_err, NULL))        goto end;    engine = NULL;    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);        } else if (strcmp(*argv, "-passin") == 0) {            if (--argc < 1)                goto bad;            passargin = *(++argv);        } else if (strcmp(*argv, "-passout") == 0) {            if (--argc < 1)                goto bad;            passargout = *(++argv);        } else if (strcmp(*argv, "-engine") == 0) {            if (--argc < 1)                goto bad;            engine = *(++argv);        } else if (strcmp(*argv, "-noout") == 0)            noout = 1;        else if (strcmp(*argv, "-text") == 0)            text = 1;        else if (strcmp(*argv, "-conv_form") == 0) {            if (--argc < 1)                goto bad;            ++argv;            new_form = 1;            if (strcmp(*argv, "compressed") == 0)                form = POINT_CONVERSION_COMPRESSED;            else if (strcmp(*argv, "uncompressed") == 0)                form = POINT_CONVERSION_UNCOMPRESSED;            else if (strcmp(*argv, "hybrid") == 0)                form = POINT_CONVERSION_HYBRID;            else                goto bad;        } else if (strcmp(*argv, "-param_enc") == 0) {            if (--argc < 1)                goto bad;            ++argv;            new_asn1_flag = 1;            if (strcmp(*argv, "named_curve") == 0)                asn1_flag = OPENSSL_EC_NAMED_CURVE;            else if (strcmp(*argv, "explicit") == 0)                asn1_flag = 0;            else                goto bad;        } else if (strcmp(*argv, "-param_out") == 0)            param_out = 1;        else if (strcmp(*argv, "-pubin") == 0)            pubin = 1;        else if (strcmp(*argv, "-pubout") == 0)            pubout = 1;        else if ((enc = EVP_get_cipherbyname(&(argv[0][1]))) == NULL) {//.........这里部分代码省略.........
开发者ID:GrayKing,项目名称:Leakfix-on-OpenSSL,代码行数:101,


示例16: soap_mec_init

/**@fn int soap_mec_init(struct soap *soap, struct soap_mec_data *data, int alg, SOAP_MEC_KEY_TYPE *pkey, unsigned char *key, int *keylen)@brief Initialize mecevp engine state and create context forencryption/decryption algorithm using a private/public key or symmetric secretkey.@param soap context@param[in,out] data mecevp engine context@param[in] alg encryption/decryption algorithm@param[in] pkey public/private key or NULL@param[in,out] key secret key or encrypted ephemeral secret key set with envelope encryption, or NULL@param[in,out] keylen secret key length@return SOAP_OK or SOAP_SSL_ERROR*/intsoap_mec_init(struct soap *soap, struct soap_mec_data *data, int alg, SOAP_MEC_KEY_TYPE *pkey, unsigned char *key, int *keylen){ int ok = 1;  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "soap_mec_init()/n"));  soap_ssl_init();  data->ctx = (EVP_CIPHER_CTX*)SOAP_MALLOC(soap, sizeof(EVP_CIPHER_CTX));  if (!data->ctx)    return soap->error = SOAP_EOM;  EVP_CIPHER_CTX_init(data->ctx);  data->alg = alg;  data->state = SOAP_MEC_STATE_NONE;  if (alg & SOAP_MEC_DES_CBC)    data->type = EVP_des_ede3_cbc(); /* triple DES CBC */  else if (alg & SOAP_MEC_AES128_CBC)    data->type = EVP_get_cipherbyname("AES128");  else if (alg & SOAP_MEC_AES192_CBC)    data->type = EVP_get_cipherbyname("AES192");  else if (alg & SOAP_MEC_AES256_CBC)    data->type = EVP_get_cipherbyname("AES256");  else if (alg & SOAP_MEC_AES512_CBC)    data->type = EVP_get_cipherbyname("AES512");  else    data->type = EVP_enc_null();  data->buf = NULL;  data->rest = NULL;  data->restlen = 0;  if (alg & SOAP_MEC_ENC)  { if (!data->type)      return soap_mec_check(soap, data, 0, "soap_mec_init() failed: cannot load cipher");    EVP_EncryptInit_ex(data->ctx, data->type, NULL, NULL, NULL);  }  if (alg & SOAP_MEC_OAEP)    EVP_CIPHER_CTX_set_padding(data->ctx, RSA_PKCS1_OAEP_PADDING);  else    EVP_CIPHER_CTX_set_padding(data->ctx, RSA_PKCS1_PADDING);  switch (alg & SOAP_MEC_MASK)  { case SOAP_MEC_ENV_ENC_AES128_CBC:    case SOAP_MEC_ENV_ENC_AES192_CBC:    case SOAP_MEC_ENV_ENC_AES256_CBC:    case SOAP_MEC_ENV_ENC_AES512_CBC:    case SOAP_MEC_ENV_ENC_DES_CBC:      ok = EVP_CIPHER_CTX_rand_key(data->ctx, data->ekey);      /* generate ephemeral secret key */#if (OPENSSL_VERSION_NUMBER >= 0x01000000L)      *keylen = EVP_PKEY_encrypt_old(key, data->ekey, EVP_CIPHER_CTX_key_length(data->ctx), pkey);#else      *keylen = EVP_PKEY_encrypt(key, data->ekey, EVP_CIPHER_CTX_key_length(data->ctx), pkey);#endif      key = data->ekey;      /* fall through to next arm */    case SOAP_MEC_ENC_DES_CBC:    case SOAP_MEC_ENC_AES128_CBC:    case SOAP_MEC_ENC_AES192_CBC:    case SOAP_MEC_ENC_AES256_CBC:    case SOAP_MEC_ENC_AES512_CBC:      data->bufidx = 0;      data->buflen = 1024; /* > iv in base64 must fit */      data->buf = (char*)SOAP_MALLOC(soap, data->buflen);      data->key = key;      break;    case SOAP_MEC_ENV_DEC_AES128_CBC:    case SOAP_MEC_ENV_DEC_AES192_CBC:    case SOAP_MEC_ENV_DEC_AES256_CBC:    case SOAP_MEC_ENV_DEC_AES512_CBC:    case SOAP_MEC_ENV_DEC_DES_CBC:    case SOAP_MEC_DEC_DES_CBC:    case SOAP_MEC_DEC_AES128_CBC:    case SOAP_MEC_DEC_AES192_CBC:    case SOAP_MEC_DEC_AES256_CBC:    case SOAP_MEC_DEC_AES512_CBC:      data->pkey = pkey;      data->key = key;      data->keylen = *keylen;      break;    default:      return soap_set_receiver_error(soap, "Unsupported encryption algorithm", NULL, SOAP_SSL_ERROR);  }  return soap_mec_check(soap, data, ok, "soap_mec_init() failed");}
开发者ID:haohd,项目名称:bananaPiCam,代码行数:92,


示例17: do_cipher

static intdo_cipher(ClipMachine *mp, int operation){	const EVP_CIPHER *cipher = 0;	const EVP_MD *digest = 0;	char *cipher_name, *digest_name;	char *key_str, *data, *iv_str, *data_ptr;	int key_len=0, data_len=0, iv_len=0;	EVP_CIPHER_CTX ectx;	unsigned char iv[EVP_MAX_IV_LENGTH];	unsigned char key[EVP_MAX_KEY_LENGTH];	char ebuf[BLOCK_SIZE + 8];	unsigned int ebuflen;	char *obuf = 0;	unsigned int olen = 0;	int l;	crypto_init();	if (mp->argc<2)		return EG_ARG;	cipher_name = _clip_parc(mp, 3);	if (!cipher_name)		cipher_name = "des-ede3-cbc";	digest_name = _clip_parc(mp, 4);	if (!digest_name)		digest_name  = "md5";	data = _clip_parcl(mp, 1, &data_len);	if (!data)		return EG_ARG;	key_str = _clip_parcl(mp, 2, &key_len);	if (!key_str)		return EG_ARG;	memset(iv, 0, sizeof(iv));	memset(key, 0, sizeof(key));	iv_str = _clip_parcl(mp, 5, &iv_len);	if (iv_str)	{		if (iv_len>sizeof(iv))			iv_len = sizeof(iv);		memcpy(iv, iv_str, iv_len);	}	cipher = EVP_get_cipherbyname(cipher_name);	if (!cipher)		return EG_ARG;	digest = EVP_get_digestbyname(digest_name);	if (!digest)		return EG_ARG;	EVP_BytesToKey(cipher, (EVP_MD*)digest, (const unsigned char *)"clip", (const unsigned char *)key_str, key_len, 1, key, iv);	EVP_CipherInit(&ectx, cipher, key, iv, operation);	for(l=0, data_ptr=data; l<data_len; )	{		int ll = data_len - l;		if (ll > BLOCK_SIZE)			ll = BLOCK_SIZE;		ebuflen = sizeof(ebuf);		EVP_CipherUpdate(&ectx, (unsigned char *)ebuf, (int *)&ebuflen, (unsigned char *)data_ptr, ll);		obuf = (char*) realloc( obuf, olen + ebuflen);		memcpy(obuf + olen, ebuf, ebuflen);		olen += ebuflen;		l += ll;		data_ptr += ll;	}	EVP_CipherFinal(&ectx, (unsigned char *)ebuf, (int *)&ebuflen);	obuf = (char*) realloc( obuf, olen + ebuflen + 1);	memcpy(obuf + olen, ebuf, ebuflen);	olen += ebuflen;	obuf[olen] = 0;	_clip_retcn_m(mp, obuf, olen);	return 0;}
开发者ID:amery,项目名称:clip-itk,代码行数:90,


示例18: soap_mec_start_alg

/**@fn int soap_mec_start_alg(struct soap *soap, int alg, const unsigned char *key)@brief Start encryption or decryption of current message. If key is non-NULL,use the symmetric triple DES key. Use soap_mec_start only after soap_mec_begin.The soap_mec_start should be followed by a soap_mec_stop call.@param soap context@param[in] alg algorithm@param[in] key secret triple DES key or NULL@return SOAP_OK or error code*/intsoap_mec_start_alg(struct soap *soap, int alg, const unsigned char *key){ struct soap_mec_data *data;  int ok = 1;  data = (struct soap_mec_data*)soap->data[1];  if (!data)    return soap->error = SOAP_USER_ERROR;  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "MEC Start alg=%x/n", data->alg));  if (key)    data->key = key;  if (alg != SOAP_MEC_NONE)    data->alg = alg;  if (data->alg & SOAP_MEC_ENC)  { unsigned char iv[EVP_MAX_IV_LENGTH];    int ivlen;    /* save and override the callbacks */    data->ffiltersend = soap->ffiltersend;    soap->ffiltersend = soap_mec_filtersend;    data->bufidx = 0;    data->i = 0;    data->m = 0;    ivlen = EVP_CIPHER_iv_length(data->type);    if (ivlen)    { RAND_pseudo_bytes(iv, ivlen);      soap_mec_put_base64(soap, data, (unsigned char*)iv, ivlen);    }    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "IV = "));    DBGHEX(TEST, iv, ivlen);    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "/n--/n"));    ok = EVP_EncryptInit_ex(data->ctx, NULL, NULL, data->key, iv);  }  else  { size_t len;    /* algorithm */    if (data->alg & SOAP_MEC_DES_CBC)      data->type = EVP_des_ede3_cbc(); /* triple DES CBC */    else if (data->alg & SOAP_MEC_AES128_CBC)      data->type = EVP_get_cipherbyname("AES128");    else if (data->alg & SOAP_MEC_AES192_CBC)      data->type = EVP_get_cipherbyname("AES192");    else if (data->alg & SOAP_MEC_AES256_CBC)      data->type = EVP_get_cipherbyname("AES256");    else if (data->alg & SOAP_MEC_AES512_CBC)      data->type = EVP_get_cipherbyname("AES512");    else      data->type = EVP_enc_null();    len = 2 * sizeof(soap->buf) + EVP_CIPHER_block_size(data->type);    if (!data->buf || data->buflen < len)    { if (data->buf)        SOAP_FREE(soap, data->buf);      data->buflen = len;      data->buf = (char*)SOAP_MALLOC(soap, data->buflen);    }    data->bufidx = soap->buflen - soap->bufidx;    /* copy buf[bufidx..buflen-1] to data buf */    memcpy(data->buf, soap->buf + soap->bufidx, data->bufidx);    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Alloc buf=%lu, copy %lu message bytes/n", (unsigned long)data->buflen, (unsigned long)data->bufidx));    /* trigger ffilterrecv() */    soap->bufidx = soap->buflen;    /* INIT state */    data->i = 0;    data->m = 0;    data->state = SOAP_MEC_STATE_INIT;  }  return soap_mec_check(soap, data, ok, "soap_mec_start() failed");}
开发者ID:haohd,项目名称:bananaPiCam,代码行数:76,


示例19: MAIN

int MAIN(int argc, char **argv){    ENGINE *e = NULL;    char **args, *infile = NULL, *outfile = NULL;    char *passargin = NULL, *passargout = NULL;    BIO *in = NULL, *out = NULL;    const EVP_CIPHER *cipher = NULL;    int informat, outformat;    int pubin = 0, pubout = 0, pubtext = 0, text = 0, noout = 0;    EVP_PKEY *pkey = NULL;    char *passin = NULL, *passout = NULL;    int badarg = 0;#ifndef OPENSSL_NO_ENGINE    char *engine = NULL;#endif    int ret = 1;    if (bio_err == NULL)        bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);    if (!load_config(bio_err, NULL))        goto end;    informat = FORMAT_PEM;    outformat = FORMAT_PEM;    ERR_load_crypto_strings();    OpenSSL_add_all_algorithms();    args = argv + 1;    while (!badarg && *args && *args[0] == '-') {        if (!strcmp(*args, "-inform")) {            if (args[1]) {                args++;                informat = str2fmt(*args);            } else                badarg = 1;        } else if (!strcmp(*args, "-outform")) {            if (args[1]) {                args++;                outformat = str2fmt(*args);            } else                badarg = 1;        } else if (!strcmp(*args, "-passin")) {            if (!args[1])                goto bad;            passargin = *(++args);        } else if (!strcmp(*args, "-passout")) {            if (!args[1])                goto bad;            passargout = *(++args);        }#ifndef OPENSSL_NO_ENGINE        else if (strcmp(*args, "-engine") == 0) {            if (!args[1])                goto bad;            engine = *(++args);        }#endif        else if (!strcmp(*args, "-in")) {            if (args[1]) {                args++;                infile = *args;            } else                badarg = 1;        } else if (!strcmp(*args, "-out")) {            if (args[1]) {                args++;                outfile = *args;            } else                badarg = 1;        } else if (strcmp(*args, "-pubin") == 0) {            pubin = 1;            pubout = 1;            pubtext = 1;        } else if (strcmp(*args, "-pubout") == 0)            pubout = 1;        else if (strcmp(*args, "-text_pub") == 0) {            pubtext = 1;            text = 1;        } else if (strcmp(*args, "-text") == 0)            text = 1;        else if (strcmp(*args, "-noout") == 0)            noout = 1;        else {            cipher = EVP_get_cipherbyname(*args + 1);            if (!cipher) {                BIO_printf(bio_err, "Unknown cipher %s/n", *args + 1);                badarg = 1;            }        }        args++;    }    if (badarg) { bad:        BIO_printf(bio_err, "Usage pkey [options]/n");        BIO_printf(bio_err, "where options are/n");        BIO_printf(bio_err, "-in file        input file/n");        BIO_printf(bio_err, "-inform X       input format (DER or PEM)/n");        BIO_printf(bio_err,//.........这里部分代码省略.........
开发者ID:1Project,项目名称:SafeBoardMessenger,代码行数:101,


示例20: commandhandler

int commandhandler(BIO *cbio, int cl){   BIO *bbody = NULL, *bbase64 = NULL, *bcrypt = NULL;   int ret = -1;   char buf[100 * 1024];   json_object *config = NULL;   unsigned char iv[16];   BIO *bmem = NULL;   char *bptr = NULL, *c = NULL;   long blen = 0;   char *command = NULL;   logme(LOGMSG_DEBUG, "commandhandler (cl=%d)", cl);   do {      if(!(bmem = BIO_new(BIO_s_mem()))) break;      if(!(bbody = BIO_new(BIO_s_mem()))) break;      if(!(bbase64 = BIO_new(BIO_f_base64()))) break;      BIO_set_flags(bbase64, BIO_FLAGS_BASE64_NO_NL);      if(!(bcrypt = BIO_new(BIO_f_cipher()))) break;      memset(iv, 0x00, sizeof(iv));      BIO_set_cipher(bcrypt, EVP_get_cipherbyname("aes-128-cbc"), (unsigned char *)conf.key, iv, 0);      BIO_push(bbase64, bbody);      BIO_push(bcrypt, bmem);      while(blen < cl) {         if((ret = BIO_read(cbio, buf, ((cl - blen) > sizeof(buf)) ? sizeof(buf) : (cl - blen))) <= 0) break;         blen += ret;         while((c = memchr(buf, '/n', ret)) || (c = memchr(buf, '/r', ret))) memmove(c, c + 1, --ret - (c - buf));         if(BIO_write(bbody, buf, ret) != ret) {            logme(LOGMSG_DEBUG, "BIO_write error");            break;         }      }      do {         blen = BIO_read(bbase64, buf, sizeof(buf));         if(blen > 0) {            BIO_write(bcrypt, buf, blen);         }      } while(blen > 0);      (void)BIO_flush(bcrypt);      blen = BIO_get_mem_data(bmem, &bptr);      if(!(config = json_tokener_parse(bptr))) break;      if(!(command = (char *)json_object_get_string(json_object_object_get(config, "command")))) break;      logme(LOGMSG_DEBUG, "command: %s", command);      if(!strcasecmp(command, "FORWARD")) {         ret = command_forward(config, cbio);      } else if(!strcasecmp(command, "CONFIG")) {         ret = command_config(config, cbio);      } else if(!strcasecmp(command, "UPGRADE")) {         ret = command_upgrade(config, cbio);      } else if(!strcasecmp(command, "CHECK")) {         ret = command_check(config, cbio);      }   } while(0);   if(bbody) BIO_free(bbody);   if(bbase64) BIO_free(bbase64);   if(bcrypt) BIO_free(bcrypt);   if(bmem) BIO_free(bmem);   if(config) json_object_put(config);   return ret;}
开发者ID:BwRy,项目名称:rcs-anonymizer,代码行数:68,


示例21: genpkey_main

intgenpkey_main(int argc, char **argv){	ENGINE *e = NULL;	char **args, *outfile = NULL;	char *passarg = NULL;	BIO *in = NULL, *out = NULL;	const EVP_CIPHER *cipher = NULL;	int outformat;	int text = 0;	EVP_PKEY *pkey = NULL;	EVP_PKEY_CTX *ctx = NULL;	char *pass = NULL;	int badarg = 0;	int ret = 1, rv;	int do_param = 0;	outformat = FORMAT_PEM;	args = argv + 1;	while (!badarg && *args && *args[0] == '-') {		if (!strcmp(*args, "-outform")) {			if (args[1]) {				args++;				outformat = str2fmt(*args);			} else				badarg = 1;		} else if (!strcmp(*args, "-pass")) {			if (!args[1])				goto bad;			passarg = *(++args);		}#ifndef OPENSSL_NO_ENGINE		else if (strcmp(*args, "-engine") == 0) {			if (!args[1])				goto bad;			e = setup_engine(bio_err, *(++args), 0);		}#endif		else if (!strcmp(*args, "-paramfile")) {			if (!args[1])				goto bad;			args++;			if (do_param == 1)				goto bad;			if (!init_keygen_file(bio_err, &ctx, *args, e))				goto end;		} else if (!strcmp(*args, "-out")) {			if (args[1]) {				args++;				outfile = *args;			} else				badarg = 1;		} else if (strcmp(*args, "-algorithm") == 0) {			if (!args[1])				goto bad;			if (!init_gen_str(bio_err, &ctx, *(++args), e, do_param))				goto end;		} else if (strcmp(*args, "-pkeyopt") == 0) {			if (!args[1])				goto bad;			if (!ctx) {				BIO_puts(bio_err, "No keytype specified/n");				goto bad;			} else if (pkey_ctrl_string(ctx, *(++args)) <= 0) {				BIO_puts(bio_err, "parameter setting error/n");				ERR_print_errors(bio_err);				goto end;			}		} else if (strcmp(*args, "-genparam") == 0) {			if (ctx)				goto bad;			do_param = 1;		} else if (strcmp(*args, "-text") == 0)			text = 1;		else {			cipher = EVP_get_cipherbyname(*args + 1);			if (!cipher) {				BIO_printf(bio_err, "Unknown cipher %s/n",				    *args + 1);				badarg = 1;			}			if (do_param == 1)				badarg = 1;		}		args++;	}	if (!ctx)		badarg = 1;	if (badarg) {bad:		BIO_printf(bio_err, "Usage: genpkey [options]/n");		BIO_printf(bio_err, "where options may be/n");		BIO_printf(bio_err, "-out file          output file/n");		BIO_printf(bio_err, "-outform X         output format (DER or PEM)/n");		BIO_printf(bio_err, "-pass arg          output file pass phrase source/n");		BIO_printf(bio_err, "-<cipher>          use cipher <cipher> to encrypt the key/n");//.........这里部分代码省略.........
开发者ID:aburgh,项目名称:openbsd,代码行数:101,


示例22: MAIN

int MAIN(int argc, char **argv)	{	static const char magic[]="Salted__";	char mbuf[sizeof magic-1];	char *strbuf=NULL;	unsigned char *buff=NULL,*bufsize=NULL;	int bsize=BSIZE,verbose=0;	int ret=1,inl;	int nopad = 0;	unsigned char key[EVP_MAX_KEY_LENGTH],iv[EVP_MAX_IV_LENGTH];	unsigned char salt[PKCS5_SALT_LEN];	char *str=NULL, *passarg = NULL, *pass = NULL;	char *hkey=NULL,*hiv=NULL,*hsalt = NULL;	char *md=NULL;	int enc=1,printkey=0,i,base64=0;#ifdef ZLIB	int do_zlib=0;	BIO *bzl = NULL;#endif	int debug=0,olb64=0,nosalt=0;	const EVP_CIPHER *cipher=NULL,*c;	EVP_CIPHER_CTX *ctx = NULL;	char *inf=NULL,*outf=NULL;	BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL;#define PROG_NAME_SIZE  39	char pname[PROG_NAME_SIZE+1];#ifndef OPENSSL_NO_ENGINE	char *engine = NULL;#endif	const EVP_MD *dgst=NULL;	int non_fips_allow = 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);	if (!load_config(bio_err, NULL))		goto end;	/* first check the program name */	program_name(argv[0],pname,sizeof pname);	if (strcmp(pname,"base64") == 0)		base64=1;#ifdef ZLIB	if (strcmp(pname,"zlib") == 0)		do_zlib=1;#endif	cipher=EVP_get_cipherbyname(pname);#ifdef ZLIB	if (!do_zlib && !base64 && (cipher == NULL)				&& (strcmp(pname,"enc") != 0))#else	if (!base64 && (cipher == NULL) && (strcmp(pname,"enc") != 0))#endif		{		BIO_printf(bio_err,"%s is an unknown cipher/n",pname);		goto bad;		}	argc--;	argv++;	while (argc >= 1)		{		if	(strcmp(*argv,"-e") == 0)			enc=1;		else if (strcmp(*argv,"-in") == 0)			{			if (--argc < 1) goto bad;			inf= *(++argv);			}		else if (strcmp(*argv,"-out") == 0)			{			if (--argc < 1) goto bad;			outf= *(++argv);			}		else if (strcmp(*argv,"-pass") == 0)			{			if (--argc < 1) goto bad;			passarg= *(++argv);			}#ifndef OPENSSL_NO_ENGINE		else if (strcmp(*argv,"-engine") == 0)			{			if (--argc < 1) goto bad;			engine= *(++argv);			}#endif		else if	(strcmp(*argv,"-d") == 0)			enc=0;		else if	(strcmp(*argv,"-p") == 0)			printkey=1;		else if	(strcmp(*argv,"-v") == 0)			verbose=1;		else if	(strcmp(*argv,"-nopad") == 0)			nopad=1;		else if	(strcmp(*argv,"-salt") == 0)			nosalt=0;//.........这里部分代码省略.........
开发者ID:gorlak,项目名称:panda3d-thirdparty,代码行数:101,


示例23: parse_rsa_private_key

static intparse_rsa_private_key(hx509_context context, const char *fn,		      struct hx509_collector *c,		      const hx509_pem_header *headers,		      const void *data, size_t len){    int ret = 0;    const char *enc;    enc = hx509_pem_find_header(headers, "Proc-Type");    if (enc) {	const char *dek;	char *type, *iv;	ssize_t ssize, size;	void *ivdata;	const EVP_CIPHER *cipher;	const struct _hx509_password *pw;	hx509_lock lock;	int i, decrypted = 0;	lock = _hx509_collector_get_lock(c);	if (lock == NULL) {	    hx509_set_error_string(context, 0, HX509_ALG_NOT_SUPP,				   "Failed to get password for "				   "password protected file %s", fn);	    return HX509_ALG_NOT_SUPP;	}	if (strcmp(enc, "4,ENCRYPTED") != 0) {	    hx509_set_error_string(context, 0, HX509_PARSING_KEY_FAILED,				   "RSA key encrypted in unknown method %s "				   "in file",				   enc, fn);	    hx509_clear_error_string(context);	    return HX509_PARSING_KEY_FAILED;	}	dek = hx509_pem_find_header(headers, "DEK-Info");	if (dek == NULL) {	    hx509_set_error_string(context, 0, HX509_PARSING_KEY_FAILED,				   "Encrypted RSA missing DEK-Info");	    return HX509_PARSING_KEY_FAILED;	}	type = strdup(dek);	if (type == NULL) {	    hx509_clear_error_string(context);	    return ENOMEM;	}	iv = strchr(type, ',');	if (iv == NULL) {	    free(type);	    hx509_set_error_string(context, 0, HX509_PARSING_KEY_FAILED,				   "IV missing");	    return HX509_PARSING_KEY_FAILED;	}	*iv++ = '/0';	size = strlen(iv);	ivdata = malloc(size);	if (ivdata == NULL) {	    hx509_clear_error_string(context);	    free(type);	    return ENOMEM;	}	cipher = EVP_get_cipherbyname(type);	if (cipher == NULL) {	    free(ivdata);	    hx509_set_error_string(context, 0, HX509_ALG_NOT_SUPP,				   "RSA key encrypted with "				   "unsupported cipher: %s",				   type);	    free(type);	    return HX509_ALG_NOT_SUPP;	}#define PKCS5_SALT_LEN 8	ssize = hex_decode(iv, ivdata, size);	free(type);	type = NULL;	iv = NULL;	if (ssize < 0 || ssize < PKCS5_SALT_LEN || ssize < EVP_CIPHER_iv_length(cipher)) {	    free(ivdata);	    hx509_set_error_string(context, 0, HX509_PARSING_KEY_FAILED,				   "Salt have wrong length in RSA key file");	    return HX509_PARSING_KEY_FAILED;	}		pw = _hx509_lock_get_passwords(lock);	if (pw != NULL) {	    const void *password;	    size_t passwordlen;	    for (i = 0; i < pw->len; i++) {		password = pw->val[i];//.........这里部分代码省略.........
开发者ID:gojdic,项目名称:samba,代码行数:101,


示例24: PEM_get_EVP_CIPHER_INFO

/* * This implements a very limited PEM header parser that does not support the * full grammar of rfc1421.  In particular, folded headers are not supported, * nor is additional whitespace. * * A robust implementation would make use of a library that turns the headers * into a BIO from which one folded line is read at a time, and is then split * into a header label and content.  We would then parse the content of the * headers we care about.  This is overkill for just this limited use-case, but * presumably we also parse rfc822-style headers for S/MIME, so a common * abstraction might well be more generally useful. */int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher){    static const char ProcType[] = "Proc-Type:";    static const char ENCRYPTED[] = "ENCRYPTED";    static const char DEKInfo[] = "DEK-Info:";    const EVP_CIPHER *enc = NULL;    int ivlen;    char *dekinfostart, c;    cipher->cipher = NULL;    memset(cipher->iv, 0, sizeof(cipher->iv));    if ((header == NULL) || (*header == '/0') || (*header == '/n'))        return 1;    if (strncmp(header, ProcType, sizeof(ProcType)-1) != 0) {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_NOT_PROC_TYPE);        return 0;    }    header += sizeof(ProcType)-1;    header += strspn(header, " /t");    if (*header++ != '4' || *header++ != ',')        return 0;    header += strspn(header, " /t");    /* We expect "ENCRYPTED" followed by optional white-space + line break */    if (strncmp(header, ENCRYPTED, sizeof(ENCRYPTED)-1) != 0 ||        strspn(header+sizeof(ENCRYPTED)-1, " /t/r/n") == 0) {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_NOT_ENCRYPTED);        return 0;    }    header += sizeof(ENCRYPTED)-1;    header += strspn(header, " /t/r");    if (*header++ != '/n') {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_SHORT_HEADER);        return 0;    }    /*-     * https://tools.ietf.org/html/rfc1421#section-4.6.1.3     * We expect "DEK-Info: algo[,hex-parameters]"     */    if (strncmp(header, DEKInfo, sizeof(DEKInfo)-1) != 0) {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_NOT_DEK_INFO);        return 0;    }    header += sizeof(DEKInfo)-1;    header += strspn(header, " /t");    /*     * DEK-INFO is a comma-separated combination of algorithm name and optional     * parameters.     */    dekinfostart = header;    header += strcspn(header, " /t,");    c = *header;    *header = '/0';    cipher->cipher = enc = EVP_get_cipherbyname(dekinfostart);    *header = c;    header += strspn(header, " /t");    if (enc == NULL) {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_UNSUPPORTED_ENCRYPTION);        return 0;    }    ivlen = EVP_CIPHER_iv_length(enc);    if (ivlen > 0 && *header++ != ',') {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_MISSING_DEK_IV);        return 0;    } else if (ivlen == 0 && *header == ',') {        PEMerr(PEM_F_PEM_GET_EVP_CIPHER_INFO, PEM_R_UNEXPECTED_DEK_IV);        return 0;    }    if (!load_iv(&header, cipher->iv, EVP_CIPHER_iv_length(enc)))        return 0;    return 1;}
开发者ID:Ana06,项目名称:openssl,代码行数:91,


示例25: esp_print_decode_onesecret

//.........这里部分代码省略.........#ifdef INET6		sin6 = (struct sockaddr_in6 *)&sa1.daddr;		if (inet_pton(AF_INET6, spikey, &sin6->sin6_addr) == 1) {#ifdef HAVE_SOCKADDR_SA_LEN			sin6->sin6_len = sizeof(struct sockaddr_in6);#endif			sin6->sin6_family = AF_INET6;		} else#endif		if (inet_pton(AF_INET, spikey, &sin->sin_addr) == 1) {#ifdef HAVE_SOCKADDR_SA_LEN			sin->sin_len = sizeof(struct sockaddr_in);#endif			sin->sin_family = AF_INET;		} else {			(*ndo->ndo_warning)(ndo, "print_esp: can not decode IP# %s/n", spikey);			return;		}	}	if (decode) {		char *colon, *p;		u_char espsecret_key[256];		int len;		size_t i;		const EVP_CIPHER *evp;		int authlen = 0;		/* skip any blank spaces */		while (isspace((unsigned char)*decode))			decode++;		colon = strchr(decode, ':');		if (colon == NULL) {			(*ndo->ndo_warning)(ndo, "failed to decode espsecret: %s/n", decode);			return;		}		*colon = '/0';		len = colon - decode;		if (strlen(decode) > strlen("-hmac96") &&		    !strcmp(decode + strlen(decode) - strlen("-hmac96"),		    "-hmac96")) {			p = strstr(decode, "-hmac96");			*p = '/0';			authlen = 12;		}		if (strlen(decode) > strlen("-cbc") &&		    !strcmp(decode + strlen(decode) - strlen("-cbc"), "-cbc")) {			p = strstr(decode, "-cbc");			*p = '/0';		}		evp = EVP_get_cipherbyname(decode);		if (!evp) {			(*ndo->ndo_warning)(ndo, "failed to find cipher algo %s/n", decode);			sa1.evp = NULL;			sa1.authlen = 0;			sa1.ivlen = 0;			return;		}		sa1.evp = evp;		sa1.authlen = authlen;		sa1.ivlen = EVP_CIPHER_iv_length(evp);		colon++;		if (colon[0] == '0' && colon[1] == 'x') {			/* decode some hex! */			colon += 2;			len = strlen(colon) / 2;			if (len > 256) {				(*ndo->ndo_warning)(ndo, "secret is too big: %d/n", len);				return;			}			i = 0;			while (colon[0] != '/0' && colon[1]!='/0') {				espsecret_key[i] = hex2byte(ndo, colon);				colon += 2;				i++;			}			memcpy(sa1.secret, espsecret_key, i);			sa1.secretlen = i;		} else {			i = strlen(colon);			if (i < sizeof(sa1.secret)) {				memcpy(sa1.secret, colon, i);				sa1.secretlen = i;			} else {				memcpy(sa1.secret, colon, sizeof(sa1.secret));				sa1.secretlen = sizeof(sa1.secret);			}		}	}	esp_print_addsa(ndo, &sa1, sa_def);}
开发者ID:jamesyan84,项目名称:mt36k_android_4.0.4,代码行数:101,


示例26: pkey_main

intpkey_main(int argc, char **argv){	char **args, *infile = NULL, *outfile = NULL;	char *passargin = NULL, *passargout = NULL;	BIO *in = NULL, *out = NULL;	const EVP_CIPHER *cipher = NULL;	int informat, outformat;	int pubin = 0, pubout = 0, pubtext = 0, text = 0, noout = 0;	EVP_PKEY *pkey = NULL;	char *passin = NULL, *passout = NULL;	int badarg = 0;	int ret = 1;	if (single_execution) {		if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {			perror("pledge");			exit(1);		}	}	informat = FORMAT_PEM;	outformat = FORMAT_PEM;	args = argv + 1;	while (!badarg && *args && *args[0] == '-') {		if (!strcmp(*args, "-inform")) {			if (args[1]) {				args++;				informat = str2fmt(*args);			} else				badarg = 1;		} else if (!strcmp(*args, "-outform")) {			if (args[1]) {				args++;				outformat = str2fmt(*args);			} else				badarg = 1;		} else if (!strcmp(*args, "-passin")) {			if (!args[1])				goto bad;			passargin = *(++args);		} else if (!strcmp(*args, "-passout")) {			if (!args[1])				goto bad;			passargout = *(++args);		}		else if (!strcmp(*args, "-in")) {			if (args[1]) {				args++;				infile = *args;			} else				badarg = 1;		} else if (!strcmp(*args, "-out")) {			if (args[1]) {				args++;				outfile = *args;			} else				badarg = 1;		} else if (strcmp(*args, "-pubin") == 0) {			pubin = 1;			pubout = 1;			pubtext = 1;		} else if (strcmp(*args, "-pubout") == 0)			pubout = 1;		else if (strcmp(*args, "-text_pub") == 0) {			pubtext = 1;			text = 1;		} else if (strcmp(*args, "-text") == 0)			text = 1;		else if (strcmp(*args, "-noout") == 0)			noout = 1;		else {			cipher = EVP_get_cipherbyname(*args + 1);			if (!cipher) {				BIO_printf(bio_err, "Unknown cipher %s/n",				    *args + 1);				badarg = 1;			}		}		args++;	}	if (badarg) {bad:		BIO_printf(bio_err, "Usage pkey [options]/n");		BIO_printf(bio_err, "where options are/n");		BIO_printf(bio_err, "-in file        input file/n");		BIO_printf(bio_err, "-inform X       input format (DER or PEM)/n");		BIO_printf(bio_err, "-passin arg     input file pass phrase source/n");		BIO_printf(bio_err, "-outform X      output format (DER or PEM)/n");		BIO_printf(bio_err, "-out file       output file/n");		BIO_printf(bio_err, "-passout arg    output file pass phrase source/n");		return 1;	}	if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) {		BIO_printf(bio_err, "Error getting passwords/n");		goto end;	}//.........这里部分代码省略.........
开发者ID:LucaBongiorni,项目名称:nextgen,代码行数:101,


示例27: MAIN

int MAIN(int argc, char **argv)	{	ENGINE *e = NULL;	int ret=1;	RSA *rsa=NULL;	int i,badops=0, sgckey=0;	const EVP_CIPHER *enc=NULL;	BIO *out=NULL;	int informat,outformat,text=0,check=0,noout=0;	int pubin = 0, pubout = 0;	char *infile,*outfile,*prog;	char *passargin = NULL, *passargout = NULL;	char *passin = NULL, *passout = NULL;#ifndef OPENSSL_NO_ENGINE	char *engine=NULL;#endif	int modulus=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);	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);			}		else if (strcmp(*argv,"-passin") == 0)			{			if (--argc < 1) goto bad;			passargin= *(++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,"-sgckey") == 0)			sgckey=1;		else if (strcmp(*argv,"-pubin") == 0)			pubin=1;		else if (strcmp(*argv,"-pubout") == 0)			pubout=1;		else if (strcmp(*argv,"-noout") == 0)			noout=1;		else if (strcmp(*argv,"-text") == 0)			text=1;		else if (strcmp(*argv,"-modulus") == 0)			modulus=1;		else if (strcmp(*argv,"-check") == 0)			check=1;		else if ((enc=EVP_get_cipherbyname(&(argv[0][1]))) == NULL)			{			BIO_printf(bio_err,"unknown option %s/n",*argv);			badops=1;			break;			}		argc--;		argv++;		}	if (badops)		{//.........这里部分代码省略.........
开发者ID:aosm,项目名称:OpenSSL098,代码行数:101,



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


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