当前位置: 首页>>代码示例>>C++>>正文


C++ EVP_MD_CTX_destroy函数代码示例

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


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

示例1: opensslecdsa_createctx

static isc_result_t
opensslecdsa_createctx(dst_key_t *key, dst_context_t *dctx) {
	EVP_MD_CTX *evp_md_ctx;
	const EVP_MD *type = NULL;

	UNUSED(key);
	REQUIRE(dctx->key->key_alg == DST_ALG_ECDSA256 ||
		dctx->key->key_alg == DST_ALG_ECDSA384);

	evp_md_ctx = EVP_MD_CTX_create();
	if (evp_md_ctx == NULL)
		return (ISC_R_NOMEMORY);
	if (dctx->key->key_alg == DST_ALG_ECDSA256)
		type = EVP_sha256();
	else
		type = EVP_sha384();

	if (!EVP_DigestInit_ex(evp_md_ctx, type, NULL)) {
		EVP_MD_CTX_destroy(evp_md_ctx);
		return (dst__openssl_toresult3(dctx->category,
					       "EVP_DigestInit_ex",
					       ISC_R_FAILURE));
	}

	dctx->ctxdata.evp_md_ctx = evp_md_ctx;

	return (ISC_R_SUCCESS);
}
开发者ID:Stichting-MINIX-Research-Foundation,项目名称:minix,代码行数:28,代码来源:opensslecdsa_link.c

示例2: sha_init

nyx_error_t sha_init(const char *name)
{
	const struct sha_algo_data_t *algo = sha_algo_data_lookup(name);

	if (algo == NULL)
	{
		return NYX_ERROR_INVALID_VALUE;
	}

	if (running_mdctx != NULL)
	{
		EVP_MD_CTX_cleanup(running_mdctx);
		EVP_MD_CTX_destroy(running_mdctx);
	}

	running_mdctx = EVP_MD_CTX_create();
	EVP_MD_CTX_init(running_mdctx);

	if (EVP_DigestInit_ex(running_mdctx, algo->md(), NULL) != 1)
	{
		return NYX_ERROR_GENERIC;
	}

	return NYX_ERROR_NONE;
}
开发者ID:ctbrowser,项目名称:nyx-modules,代码行数:25,代码来源:sha.c

示例3: verifySignature

static bool verifySignature(const char *data, int dataLength, const char *signature, int signatureLength, const char *cert) {
    X509* x509;
    BIO* bio = BIO_new(BIO_s_mem());
    BIO_puts(bio, cert);
    x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
    
    BIO_free(bio);
    
    if (!x509) {
        return false;
    }
    
    EVP_PKEY* pubKey = X509_get_pubkey(x509);
    EVP_MD_CTX *mdctx = NULL;
    mdctx = EVP_MD_CTX_create();
    EVP_DigestVerifyInit(mdctx, NULL, EVP_sha256(), NULL, pubKey);
    EVP_DigestVerifyUpdate(mdctx, data, dataLength);
    int result = EVP_DigestVerifyFinal(mdctx, signature, signatureLength);
    
    X509_free(x509);
    EVP_PKEY_free(pubKey);
    EVP_MD_CTX_destroy(mdctx);
    
    return result > 0;
}
开发者ID:7hunderbug,项目名称:moonlight-embedded,代码行数:25,代码来源:client.c

示例4: digestOfBytes

static int digestOfBytes(uint8_t *message, char **output, char *type, int inLength) {
    EVP_MD_CTX *mdctx;
    const EVP_MD *md;
    unsigned char md_value[EVP_MAX_MD_SIZE];
    unsigned int md_len, i;

    OpenSSL_add_all_digests();

    md = EVP_get_digestbyname(type);
    mdctx = EVP_MD_CTX_create();
    EVP_DigestInit_ex(mdctx, md, NULL);
    EVP_DigestUpdate(mdctx, message, inLength);
    EVP_DigestFinal_ex(mdctx, md_value, &md_len);
    EVP_MD_CTX_destroy(mdctx);

    char *digest = calloc((md_len*2) + 1, sizeof(char));
    
    for(i = 0; i < md_len; i++) {
      sprintf(&digest[2*i], "%02x", md_value[i]);
    }
    
    digest[md_len * 2] = '\0';
    memcpy(*output, digest, strlen(digest));
    
    free(digest);
    /* Call this once before exit. */
    //EVP_cleanup();
    
    return NOERROR;
}
开发者ID:kleetus,项目名称:bitpay-c-keyutils,代码行数:30,代码来源:key_utils.c

示例5: ssl2_PRF

int ssl2_PRF( const u_char* secret, uint32_t secret_len,
		const u_char* challenge, uint32_t challenge_len, 
		const u_char* conn_id, uint32_t conn_id_len,
		u_char* out, uint32_t out_len )
{
	u_char c= '0';
	int repeat = 0;
	int i = 0;
	const EVP_MD *md5 = NULL;
	EVP_MD_CTX *ctx;

	md5 = EVP_md5();

	if( !out ) return NM_ERROR( DSSL_E_INVALID_PARAMETER );
	if( out_len % EVP_MD_size(md5) != 0 ) { return NM_ERROR( DSSL_E_INVALID_PARAMETER ); }

	repeat = out_len / EVP_MD_size(md5);
	ctx = EVP_MD_CTX_create();
	EVP_MD_CTX_init( ctx );
	for( i = 0; i < repeat; i++ )
	{
		EVP_DigestInit_ex( ctx, md5, NULL );
		EVP_DigestUpdate( ctx, secret, secret_len );
		EVP_DigestUpdate( ctx, &c, 1);
		c++; /* '0', '1', etc. */
		EVP_DigestUpdate( ctx, challenge, challenge_len );
		EVP_DigestUpdate( ctx, conn_id, conn_id_len );
		EVP_DigestFinal_ex( ctx, out, NULL );
		out += EVP_MD_size( md5 );
	}

	EVP_MD_CTX_destroy( ctx );
	return DSSL_RC_OK;
}
开发者ID:voipmonitor,项目名称:sniffer,代码行数:34,代码来源:ssl_utils.c

示例6: BIO_new_mem_buf

bool
NvPairingManager::verifySignature(QByteArray data, QByteArray signature, QByteArray serverCertificate)
{
    BIO* bio = BIO_new_mem_buf(serverCertificate.data(), -1);
    THROW_BAD_ALLOC_IF_NULL(bio);

    X509* cert = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr);
    BIO_free_all(bio);

    EVP_PKEY* pubKey = X509_get_pubkey(cert);
    THROW_BAD_ALLOC_IF_NULL(pubKey);

    EVP_MD_CTX* mdctx = EVP_MD_CTX_create();
    THROW_BAD_ALLOC_IF_NULL(mdctx);

    EVP_DigestVerifyInit(mdctx, nullptr, EVP_sha256(), nullptr, pubKey);
    EVP_DigestVerifyUpdate(mdctx, data.data(), data.length());
    int result = EVP_DigestVerifyFinal(mdctx, reinterpret_cast<unsigned char*>(signature.data()), signature.length());

    EVP_PKEY_free(pubKey);
    EVP_MD_CTX_destroy(mdctx);
    X509_free(cert);

    return result > 0;
}
开发者ID:wwssr3,项目名称:moonlight-qt,代码行数:25,代码来源:nvpairingmanager.cpp

示例7: swupdate_HASH_cleanup

void swupdate_HASH_cleanup(struct swupdate_digest *dgst)
{
	if (dgst) {
		EVP_MD_CTX_destroy(dgst->ctx);
		free(dgst);
		dgst = NULL;
	}
}
开发者ID:3mdeb,项目名称:swupdate,代码行数:8,代码来源:verify_signature.c

示例8: sldns_digest_evp

int
sldns_digest_evp(unsigned char* data, unsigned int len, unsigned char* dest,
	const EVP_MD* md)
{
	EVP_MD_CTX* ctx;
	ctx = EVP_MD_CTX_create();
	if(!ctx)
		return 0;
	if(!EVP_DigestInit_ex(ctx, md, NULL) ||
		!EVP_DigestUpdate(ctx, data, len) ||
		!EVP_DigestFinal_ex(ctx, dest, NULL)) {
		EVP_MD_CTX_destroy(ctx);
		return 0;
	}
	EVP_MD_CTX_destroy(ctx);
	return 1;
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:17,代码来源:keyraw.c

示例9: LUA_FUNCTION

static LUA_FUNCTION(openssl_digest_ctx_free)
{
    EVP_MD_CTX *ctx = CHECK_OBJECT(1, EVP_MD_CTX, "openssl.evp_digest_ctx");
    lua_pushnil(L);
    lua_setmetatable(L, 1);
    EVP_MD_CTX_destroy(ctx);
    return 0;
}
开发者ID:witchu,项目名称:lua-openssl,代码行数:8,代码来源:digest.c

示例10: EVP_MD_CTX_destroy

Sha::~Sha()
{
	if(mdctx != nullptr)
	{
		EVP_MD_CTX_destroy(mdctx);
		mdctx = nullptr;
	}
}
开发者ID:ivanmilov,项目名称:shaDir,代码行数:8,代码来源:sha.cpp

示例11: sc_pkcs11_openssl_md_release

static void sc_pkcs11_openssl_md_release(sc_pkcs11_operation_t *op)
{
	EVP_MD_CTX	*md_ctx = DIGEST_CTX(op);

	if (md_ctx)
		EVP_MD_CTX_destroy(md_ctx);
	op->priv_data = NULL;
}
开发者ID:chmurek1985,项目名称:OpenSC,代码行数:8,代码来源:openssl.c

示例12: signMsgRSA

int signMsgRSA(EVP_PKEY* key, const unsigned char* msg, 
	unsigned char** sig, size_t* slen, size_t msglen){
	
	EVP_MD_CTX* ctx = NULL;
	const EVP_MD* md = NULL;
	
	if(msg == NULL || sig == NULL || slen == NULL)
		return 0;

	ctx = EVP_MD_CTX_create();
	md = EVP_get_digestbyname(hn);

	if(md == NULL){
		printf("ERR EVP_get_digestbyname\n");
		return 0;		
	}
	if(ctx == NULL){
		printf("ERR EVP_MD_CTX_create\n");
		return 0;		
	}

	if(1 != EVP_DigestInit_ex(ctx, md, NULL)){
		printf("ERR EVP_DigestInit_ex\n");
		return 0;
	}
	if(1 != EVP_DigestSignInit(ctx, NULL, md, NULL, key)){
		printf("ERR EVP_DigestSignInit\n");
		return 0;
	}

	/*SE FIRMA EL MENSAJE*/
	if(1 != EVP_DigestSignUpdate(ctx, msg, msglen)){
		printf("ERR EVP_DigestSignUpdate\n");
		return 0;
	}

	if(1 != EVP_DigestSignFinal(ctx, NULL, slen)){
		printf("ERR EVP_DigestSignFinal\n");
		return 0;	
	}
	*sig = OPENSSL_malloc(*slen);
	
	if(*sig == NULL){
		printf("ERR OPENSSL_malloc\n");
	}

	if(1 != EVP_DigestSignFinal(ctx, *sig, slen)){
		printf("ERR EVP_DigestSignFinal\n");
		return 0;
	}

	EVP_MD_CTX_destroy(ctx);
	ctx = NULL;

	return 1;

}
开发者ID:made1993,项目名称:chatlibgroupsig,代码行数:57,代码来源:funcionesRSA.c

示例13: opensslgost_destroyctx

static void
opensslgost_destroyctx(dst_context_t *dctx) {
	EVP_MD_CTX *evp_md_ctx = dctx->ctxdata.evp_md_ctx;

	if (evp_md_ctx != NULL) {
		EVP_MD_CTX_destroy(evp_md_ctx);
		dctx->ctxdata.evp_md_ctx = NULL;
	}
}
开发者ID:Distrotech,项目名称:bind,代码行数:9,代码来源:opensslgost_link.c

示例14: EVP_MD_CTX_destroy

bool Digest::shutdown() {											 //necessary IFF script uses pcre.
    if (loaded) {
        EVP_MD_CTX_destroy(context);
    }
    if ( lib_handle != nullptr ) {
        dlclose(lib_handle);
    }
    return true;
}
开发者ID:RedSnapper,项目名称:Obyx,代码行数:9,代码来源:crypto.cpp

示例15: calculateChecksumProto

int calculateChecksumProto(FILE *file, Song *s)
{
	unsigned char digest[EVP_MAX_MD_SIZE];
	EVP_MD_CTX *mdctx;
	const EVP_MD *md;
	int md_len;

    md = EVP_get_digestbyname("SHA256");
    mdctx = EVP_MD_CTX_create();
    EVP_DigestInit_ex(mdctx, md, NULL);
	
	int bufferSize = 4096;

	char *buff = malloc(bufferSize);
	if(!buff)
		fatal_error("malloc failed\n");

	int numBytesToRead = fileLen(file);
	int currBytesRead =0;
	int bytesRead = 0;

	while(numBytesToRead>bytesRead)
	{

		/* checks if bytes to be read in this iteration are greater than buffer */
		int currNumBytesToRead=(numBytesToRead-bytesRead>bufferSize)?bufferSize:numBytesToRead-bytesRead;

		/* read bytes */
		currBytesRead=fread(buff,1,currNumBytesToRead,file);
		if(currBytesRead<= 0)
			fatal_error("read failed\n"); 
		

		/* update md5 calculation */
		EVP_DigestUpdate(mdctx, buff, currNumBytesToRead);

		/* calculate the total number of bytes read thus far */
		bytesRead += currBytesRead;
	}

	EVP_DigestFinal_ex(mdctx, digest, &md_len);
	EVP_MD_CTX_destroy(mdctx);

	free(buff);
	
	if(fseek(file, 0, SEEK_SET))
		fatal_error("failed to return back to the beginning of the file\n");

	//s->checksum = malloc(sizeof (unsigned char) * (md_len));
	//memcpy(s->checksum, digest, md_len);
	s->checksum.data = malloc(sizeof(unsigned char) * (md_len));
	s->checksum.len = md_len;
	memcpy(s->checksum.data, digest, md_len);
	
	return 1;
}
开发者ID:pstoica,项目名称:CS3251-project-4,代码行数:56,代码来源:networking.c


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