• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ EVP_md5函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: imap_state_cram_md5_auth

/* CRAM-MD5 auth state. */
int
imap_state_cram_md5_auth(struct account *a, struct fetch_ctx *fctx)
{
	struct fetch_imap_data	*data = a->data;
	char			*line, *ptr, *src, *b64;
	char			 out[EVP_MAX_MD_SIZE * 2 + 1];
	u_char			 digest[EVP_MAX_MD_SIZE];
	u_int			 i, n;

	if (imap_getln(a, fctx, IMAP_CONTINUE, &line) != 0)
		return (FETCH_ERROR);
	if (line == NULL)
		return (FETCH_BLOCK);

	ptr = line + 1;
	while (isspace((u_char) *ptr))
		ptr++;
	if (*ptr == '\0')
		return (imap_invalid(a, line));

	b64 = imap_base64_decode(ptr);
	HMAC(EVP_md5(),
	    data->pass, strlen(data->pass), b64, strlen(b64), digest, &n);
	xfree(b64);

	for (i = 0; i < n; i++)
		xsnprintf(out + i * 2, 3, "%02hhx", digest[i]);
	xasprintf(&src, "%s %s", data->user, out);
	b64 = imap_base64_encode(src);
	xfree(src);

	if (imap_putln(a, "%s", b64) != 0) {
		xfree(b64);
		return (FETCH_ERROR);
	}
	xfree(b64);

	fctx->state = imap_state_pass;
	return (FETCH_BLOCK);
}
开发者ID:avkrotov,项目名称:fdm,代码行数:41,代码来源:imap-common.c


示例2: ntlm_compute_lm_v2_response

void ntlm_compute_lm_v2_response(NTLM_CONTEXT* context)
{
    char* response;
    char value[16];
    char ntlm_v2_hash[16];

    /* Compute the NTLMv2 hash */
    ntlm_compute_ntlm_v2_hash(context, ntlm_v2_hash);

    /* Concatenate the server and client challenges */
    CopyMemory(value, context->ServerChallenge, 8);
    CopyMemory(&value[8], context->ClientChallenge, 8);

    sspi_SecBufferAlloc(&context->LmChallengeResponse, 24);
    response = (char*) context->LmChallengeResponse.pvBuffer;

    /* Compute the HMAC-MD5 hash of the resulting value using the NTLMv2 hash as the key */
    HMAC(EVP_md5(), (void*) ntlm_v2_hash, 16, (void*) value, 16, (void*) response, NULL);

    /* Concatenate the resulting HMAC-MD5 hash and the client challenge, giving us the LMv2 response (24 bytes) */
    CopyMemory(&response[16], context->ClientChallenge, 8);
}
开发者ID:resumejayaraj,项目名称:FreeRDP,代码行数:22,代码来源:ntlm_compute.c


示例3: X509_issuer_and_serial_hash

unsigned long X509_issuer_and_serial_hash(X509 *a)
	{
	unsigned long ret=0;
	EVP_MD_CTX ctx;
	unsigned char md[16];
	char *f;

	EVP_MD_CTX_init(&ctx);
	f=X509_NAME_oneline(a->cert_info->issuer,NULL,0);
	ret=strlen(f);
	EVP_DigestInit_ex(&ctx, EVP_md5(), NULL);
	EVP_DigestUpdate(&ctx,(unsigned char *)f,ret);
	OPENSSL_free(f);
	EVP_DigestUpdate(&ctx,(unsigned char *)a->cert_info->serialNumber->data,
		(unsigned long)a->cert_info->serialNumber->length);
	EVP_DigestFinal_ex(&ctx,&(md[0]),NULL);
	ret=(	((unsigned long)md[0]     )|((unsigned long)md[1]<<8L)|
		((unsigned long)md[2]<<16L)|((unsigned long)md[3]<<24L)
		)&0xffffffffL;
	EVP_MD_CTX_cleanup(&ctx);
	return(ret);
	}
开发者ID:hackshields,项目名称:antivirus,代码行数:22,代码来源:x509_cmp.c


示例4: _md_init_subsystem

static void
_md_init_subsystem (void)
{
    int i;

    for (i = 0; i < MUNGE_MAC_LAST_ITEM; i++) {
        _md_map [i] = NULL;
    }
    _md_map [MUNGE_MAC_MD5] = EVP_md5 ();
    _md_map [MUNGE_MAC_SHA1] = EVP_sha1 ();
    _md_map [MUNGE_MAC_RIPEMD160] = EVP_ripemd160 ();

#if HAVE_EVP_SHA256
    _md_map [MUNGE_MAC_SHA256] = EVP_sha256 ();
#endif /* HAVE_EVP_SHA256 */

#if HAVE_EVP_SHA512
    _md_map [MUNGE_MAC_SHA512] = EVP_sha512 ();
#endif /* HAVE_EVP_SHA512 */

    return;
}
开发者ID:dun,项目名称:munge,代码行数:22,代码来源:md.c


示例5: irssi_ssl_verify

static gboolean irssi_ssl_verify(SSL *ssl, SSL_CTX *ctx, const char* hostname, X509 *cert)
{
	long result;

	result = SSL_get_verify_result(ssl);
	if (result != X509_V_OK) {
		unsigned char md[EVP_MAX_MD_SIZE];
		unsigned int n;
		char *str;

		g_warning("Could not verify SSL servers certificate: %s",
				X509_verify_cert_error_string(result));
		if ((str = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0)) == NULL)
			g_warning("  Could not get subject-name from peer certificate");
		else {
			g_warning("  Subject : %s", str);
			free(str);
		}
		if ((str = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0)) == NULL)
			g_warning("  Could not get issuer-name from peer certificate");
		else {
			g_warning("  Issuer  : %s", str);
			free(str);
		}
		if (! X509_digest(cert, EVP_md5(), md, &n))
			g_warning("  Could not get fingerprint from peer certificate");
		else {
			char hex[] = "0123456789ABCDEF";
			char fp[EVP_MAX_MD_SIZE*3];
			if (n < sizeof(fp)) {
				unsigned int i;
				for (i = 0; i < n; i++) {
					fp[i*3+0] = hex[(md[i] >> 4) & 0xF];
					fp[i*3+1] = hex[(md[i] >> 0) & 0xF];
					fp[i*3+2] = i == n - 1 ? '\0' : ':';
				}
				g_warning("  MD5 Fingerprint : %s", fp);
			}
		}
开发者ID:mauke,项目名称:irssi-hax,代码行数:39,代码来源:network-openssl.c


示例6: X509_NAME_hash_old

unsigned long
X509_NAME_hash_old(X509_NAME *x)
{
	EVP_MD_CTX md_ctx;
	unsigned long ret = 0;
	unsigned char md[16];

	/* Make sure X509_NAME structure contains valid cached encoding */
	i2d_X509_NAME(x, NULL);
	EVP_MD_CTX_init(&md_ctx);
	if (EVP_DigestInit_ex(&md_ctx, EVP_md5(), NULL) &&
	    EVP_DigestUpdate(&md_ctx, x->bytes->data, x->bytes->length) &&
	    EVP_DigestFinal_ex(&md_ctx, md, NULL))
		ret = (((unsigned long)md[0]) |
		    ((unsigned long)md[1] << 8L) |
		    ((unsigned long)md[2] << 16L) |
		    ((unsigned long)md[3] << 24L)) &
		    0xffffffffL;
	EVP_MD_CTX_cleanup(&md_ctx);

	return (ret);
}
开发者ID:LucaBongiorni,项目名称:nextgen,代码行数:22,代码来源:x509_cmp.c


示例7: X509_NAME_hash_old

unsigned long X509_NAME_hash_old(X509_NAME *x)
{
    EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
    unsigned long ret = 0;
    unsigned char md[16];

    if (md_ctx == NULL)
        return ret;

    /* Make sure X509_NAME structure contains valid cached encoding */
    i2d_X509_NAME(x, NULL);
    EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
    if (EVP_DigestInit_ex(md_ctx, EVP_md5(), NULL)
        && EVP_DigestUpdate(md_ctx, x->bytes->data, x->bytes->length)
        && EVP_DigestFinal_ex(md_ctx, md, NULL))
        ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |
               ((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)
            ) & 0xffffffffL;
    EVP_MD_CTX_free(md_ctx);

    return (ret);
}
开发者ID:1234-,项目名称:openssl,代码行数:22,代码来源:x509_cmp.c


示例8: main

int main(int argc, char *argv[])
	{
#ifndef OPENSSL_NO_MD5
	int i;
	char *p;
#endif
	int err=0;

#ifdef OPENSSL_NO_MD5
	printf("test skipped: MD5 disabled\n");
#else

#ifdef CHARSET_EBCDIC
	ebcdic2ascii(test[0].data, test[0].data, test[0].data_len);
	ebcdic2ascii(test[1].data, test[1].data, test[1].data_len);
	ebcdic2ascii(test[2].key,  test[2].key,  test[2].key_len);
	ebcdic2ascii(test[2].data, test[2].data, test[2].data_len);
#endif

	for (i=0; i<4; i++)
		{
		p=pt(HMAC(EVP_md5(),
			test[i].key, test[i].key_len,
			test[i].data, test[i].data_len,
			NULL,NULL));

		if (strcmp(p,(char *)test[i].digest) != 0)
			{
			printf("error calculating HMAC on %d entry'\n",i);
			printf("got %s instead of %s\n",p,test[i].digest);
			err++;
			}
		else
			printf("test %d ok\n",i);
		}
#endif /* OPENSSL_NO_MD5 */
	EXIT(err);
	return(0);
	}
开发者ID:002301,项目名称:node,代码行数:39,代码来源:hmactest.c


示例9: EVP_cipher

int EVP_cipher(const char *passw, int cbpass, char *strin, int cbstr, int op, const char *cipher)
{
	const EVP_CIPHER * enc;
	if (cipher && *cipher) {
		if (!myEvpMap.Find(cipher,enc))
			return CIPHER_INVALID;
	} else 
		enc = EVP_des_ede_cbc();

	unsigned char key[EVP_MAX_KEY_LENGTH];
	unsigned char iv[EVP_MAX_IV_LENGTH];
	EVP_CIPHER_CTX ctx;

	EVP_BytesToKey(enc,EVP_md5(),NULL,(unsigned char *)passw,cbpass,1,key,iv);
	EVP_CIPHER_CTX_init(&ctx);
	EVP_CipherInit(&ctx,enc,key,iv,op);
	
	unsigned char out[CIPHER_BLOCK+EVP_MAX_IV_LENGTH];
	int outl;

	unsigned char *in = (unsigned char *) strin;
	unsigned char *endp = in + cbstr - CIPHER_BLOCK;
	unsigned char *outp = in;

	while (in < endp)	{
		EVP_CipherUpdate(&ctx,out,&outl,in,CIPHER_BLOCK);
		memcpy(outp, out, outl); outp += outl;
		in += CIPHER_BLOCK;
	}
	EVP_CipherUpdate(&ctx,out,&outl,in,endp+CIPHER_BLOCK-in);
	memcpy(outp, out, outl); outp += outl;

	EVP_CipherFinal(&ctx,out,&outl);
	memcpy(outp, out, outl); outp += outl;

	EVP_CIPHER_CTX_cleanup(&ctx);
	return (char *)outp-strin;
}
开发者ID:BackupTheBerlios,项目名称:smx-svn,代码行数:38,代码来源:open-enc.cpp


示例10: fr_hmac_md5

/** Calculate HMAC using OpenSSL's MD5 implementation
 *
 * @param digest Caller digest to be filled in.
 * @param in Pointer to data stream.
 * @param inlen length of data stream.
 * @param key Pointer to authentication key.
 * @param key_len Length of authentication key.
 *
 */
void fr_hmac_md5(uint8_t digest[MD5_DIGEST_LENGTH], uint8_t const *in, size_t inlen,
		 uint8_t const *key, size_t key_len)
{
	HMAC_CTX *ctx;

	if (unlikely(!md5_hmac_ctx)) {
		ctx = HMAC_CTX_new();
		if (unlikely(!ctx)) return;
		fr_thread_local_set_destructor(md5_hmac_ctx, _hmac_md5_ctx_free_on_exit, ctx);
	} else {
		ctx = md5_hmac_ctx;
	}

#ifdef EVP_MD_CTX_FLAG_NON_FIPS_ALLOW
	/* Since MD5 is not allowed by FIPS, explicitly allow it. */
	HMAC_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
#endif /* EVP_MD_CTX_FLAG_NON_FIPS_ALLOW */

	HMAC_Init_ex(ctx, key, key_len, EVP_md5(), NULL);
	HMAC_Update(ctx, in, inlen);
	HMAC_Final(ctx, digest, NULL);
	HMAC_CTX_reset(ctx);
}
开发者ID:FreeRADIUS,项目名称:freeradius-server,代码行数:32,代码来源:hmac_md5.c


示例11: snmp_digest_init

static int32_t
snmp_digest_init(const struct snmp_user *user, EVP_MD_CTX *ctx,
    const EVP_MD **dtype, uint32_t *keylen)
{
	if (user->auth_proto == SNMP_AUTH_HMAC_MD5) {
		*dtype = EVP_md5();
		*keylen = SNMP_AUTH_HMACMD5_KEY_SIZ;
	} else if (user->auth_proto == SNMP_AUTH_HMAC_SHA) {
		*dtype = EVP_sha1();
		*keylen = SNMP_AUTH_HMACSHA_KEY_SIZ;
	} else if (user->auth_proto == SNMP_AUTH_NOAUTH)
		return (0);
	else {
		snmp_error("unknown authentication option - %d",
		    user->auth_proto);
		return (-1);
	}

	if (EVP_DigestInit(ctx, *dtype) != 1)
		return (-1);

	return (1);
}
开发者ID:2014-class,项目名称:freerouter,代码行数:23,代码来源:snmpcrypto.c


示例12: switch

/*!
 * \brief Get message digest type for a given algorithm.
 *
 * \param algorithm  Algorithm number.
 *
 * \return Pointer to digest type specification, NULL if not implemented.
 */
static const EVP_MD *get_digest_type(knot_dnssec_algorithm_t algorithm)
{
	// EVP_<digest>() functions should not fail (return NULL)

	switch (algorithm) {
	case KNOT_DNSSEC_ALG_RSASHA1:
	case KNOT_DNSSEC_ALG_RSASHA1_NSEC3_SHA1:
	case KNOT_DNSSEC_ALG_DSA:
	case KNOT_DNSSEC_ALG_DSA_NSEC3_SHA1:
		return EVP_sha1();
	case KNOT_DNSSEC_ALG_RSAMD5:
		return EVP_md5();
	case KNOT_DNSSEC_ALG_RSASHA256:
	case KNOT_DNSSEC_ALG_ECDSAP256SHA256:
		return EVP_sha256();
	case KNOT_DNSSEC_ALG_ECDSAP384SHA384:
		return EVP_sha384();
	case KNOT_DNSSEC_ALG_RSASHA512:
		return EVP_sha512();
	default:
		return NULL;
	}
}
开发者ID:stribika,项目名称:curveprotect,代码行数:30,代码来源:dnssec.c


示例13: EVP_BytesToKey

       bool AESCipher::init2(unsigned char *key_data, int key_data_len)
    {
        int i, nrounds = 1;
        unsigned char key[32], iv[32];

        /*
        * Gen key & IV for AES 256 CBC mode. A SHA1 digest is used to hash the supplied key material.
        * nrounds is the number of times the we hash the material. More rounds are more secure but
        * slower.
        */
        i = EVP_BytesToKey(EVP_aes_256_cfb(), EVP_md5(), NULL, key_data, key_data_len, nrounds, key, iv);
        if (i != 32) {
            //printf("Key size is %d bits - should be 256 bits/n", i);
            return false;
        }

        EVP_CIPHER_CTX_init(&m_ectx);
        EVP_EncryptInit_ex(&m_ectx, EVP_aes_256_cfb(), NULL, key, iv);

        EVP_CIPHER_CTX_init(&m_dctx);
        EVP_DecryptInit_ex(&m_dctx, EVP_aes_256_cfb(), NULL, key, iv);
        return true;
    }
开发者ID:levyhoo,项目名称:mynet,代码行数:23,代码来源:Cipher.cpp


示例14: HmacMd5Init

/**
  Initializes user-supplied memory pointed by HmacMd5Context as HMAC-MD5 context for
  subsequent use.

  If HmacMd5Context is NULL, then return FALSE.

  @param[out]  HmacMd5Context  Pointer to HMAC-MD5 context being initialized.
  @param[in]   Key             Pointer to the user-supplied key.
  @param[in]   KeySize         Key size in bytes.

  @retval TRUE   HMAC-MD5 context initialization succeeded.
  @retval FALSE  HMAC-MD5 context initialization failed.

**/
BOOLEAN
EFIAPI
HmacMd5Init (
  OUT  VOID         *HmacMd5Context,
  IN   CONST UINT8  *Key,
  IN   UINTN        KeySize
  )
{
  //
  // Check input parameters.
  //
  if (HmacMd5Context == NULL || KeySize > INT_MAX) {
    return FALSE;
  }

  //
  // OpenSSL HMAC-MD5 Context Initialization
  //
  HMAC_CTX_init (HmacMd5Context);
  HMAC_Init_ex (HmacMd5Context, Key, (UINT32) KeySize, EVP_md5(), NULL);

  return TRUE;
}
开发者ID:Acidburn0zzz,项目名称:shim,代码行数:37,代码来源:CryptHmacMd5.c


示例15: cipher_new

cipher_t * cipher_new(const char * pass)
{
  OpenSSL_add_all_algorithms();
  
//  const char * name;
//  name = "aes-128-cfb";
//  name = "bf-cfb";
  
  cipher_t *
  cipher       = calloc(1, sizeof(cipher_t));
  cipher->type = EVP_get_cipherbyname(conf.method);
  cipher->keyl = EVP_CIPHER_key_length(cipher->type);
  cipher->key  = malloc(cipher->keyl);
  
  EVP_CIPHER_CTX_init(&cipher->encrypt.ctx);
  EVP_CIPHER_CTX_init(&cipher->decrypt.ctx);
  
  EVP_BytesToKey(cipher->type, EVP_md5(), NULL,
                 (uint8_t *)conf.pass, (int)strlen(conf.pass), 1,
                 cipher->key, NULL);
  
  return cipher;
}
开发者ID:cuber,项目名称:shadowsocks-libuv,代码行数:23,代码来源:crypt.c


示例16: md5_compute

void md5_compute(FILE *f, int start, int end, std::string &md5)
{
  // initialize openssl md5 digest
  static unsigned char data[102400]; // 100K buffer to read from file
  static unsigned char md_val[EVP_MAX_MD_SIZE];
  unsigned int md_len;
  EVP_MD_CTX mdctx;
  const EVP_MD *md = EVP_md5();
  EVP_MD_CTX_init(&mdctx);
  EVP_DigestInit_ex(&mdctx, md, NULL);

  // read data in chunks from the file and update the digest
  size_t rv;
  fseek(f, start, SEEK_SET);
  do {
    rv = end - start + 1;
    if(rv > 102400)
      rv = 102400;
    rv = fread(data, 1, rv, f);
    if(rv == 0)
      break;
    EVP_DigestUpdate(&mdctx, data, rv);
    start += rv;
  } while(start <= end);

  // finalize the digest
  EVP_DigestFinal_ex(&mdctx, md_val, &md_len);
  EVP_MD_CTX_cleanup(&mdctx);

  // output
  md5.reserve(64);
  char digit[3];
  for(unsigned int i = 0; i < md_len; ++i) {
    sprintf(digit, "%02x", md_val[i]);
    md5.append(digit);
  }
}
开发者ID:beevek,项目名称:testclient,代码行数:37,代码来源:testmd5.cpp


示例17: openssl_evp_keyiv

void openssl_evp_keyiv()
{
	int i;
	const EVP_MD *md;
	const EVP_CIPHER *type;
	unsigned char salt[32], data[COMM_LEN], *key, *iv;

	md = EVP_md5();
	printf("\nEVP_Md info: type[%d], ", EVP_MD_type(md));
	printf("nid[%d], ", EVP_MD_nid(md));
	printf("name[%s], ", EVP_MD_name(md));
	printf("pkey type[%d], ", EVP_MD_pkey_type(md));
	printf("size[%d], ", EVP_MD_size(md));
	printf("block size[%d], ", EVP_MD_block_size(md));

	type = EVP_des_ecb();
	printf("\nEVP_ECB info: encrypto nid[%d], ", EVP_CIPHER_nid(type));
	printf("name[%s], ", EVP_CIPHER_name(type));
	printf("bock size[%d]", EVP_CIPHER_block_size(type));

	key = (unsigned char *)malloc(EVP_CIPHER_key_length(type));
	iv = (unsigned char *)malloc(EVP_CIPHER_iv_length(type));
	for (i = 0; i < COMM_LEN; i++)
		memset(&data[i], i, 1);
	for (i = 0; i < 32; i++)
		memset(&salt[i], i, 1);

	EVP_BytesToKey(type, md, salt, data, COMM_LEN, 2, key, iv);
	printf("\nEVP_key value: ");
	for (i = 0; i < EVP_CIPHER_key_length(type); i++)
		printf("%x ", key[i]);

	printf("\nEVP_iv value: ");
	for (i = 0; i < EVP_CIPHER_iv_length(type); i++)
		printf("%x ", iv[i]);
	printf("\n");
}
开发者ID:beike2020,项目名称:source,代码行数:37,代码来源:openssl_base.c


示例18: ipmi20_generate_auth_code

/**
  *  @brief To generate Auth Code for RAKP 3, RAKP-HMAC-SHA1, RAKP-HMAC-MD5.
  *
  *  @param[in] alg algorithm
  *  @param[in] key
  *  @param[in] key_len
  *  @param[in] data the input data before encode
  *  @param[in] data_len the input data length
  *  @param[out] buf the output buffer
  *  @return  the output data length
  */
int ipmi20_generate_auth_code(unsigned char alg,
							  void *key,
							  int key_len,
							  unsigned char *data,
							  int data_len,
							  unsigned char *buf)
{
	unsigned int len = 0;

	switch (alg) {
	case AUTH_ALG_RAKP_NONE: /* INTEGRITY_ALG_NONE has the same value */
		return 0;
	case AUTH_ALG_RAKP_HMAC_SHA1: /* INTEGRITY_ALG_HMAC_SHA1_96 has the same value */
		HMAC(EVP_sha1(), key, key_len, data, data_len, buf, &len);
		break;
	case AUTH_ALG_RAKP_HMAC_MD5: /* INTEGRITY_ALG_HMAC_MD5_128 has the same value */
	case INTEGRITY_ALG_MD5_128:
		HMAC(EVP_md5(), key, key_len, data, data_len, buf, &len);
	default:
		break;
	}

	return len;
}
开发者ID:iamyaw,项目名称:IntelRackScaleArchitecture,代码行数:35,代码来源:ipmi20_crypto.c


示例19: md5_digest

/**
 * Consult EVP_DigestInit(3SSL) for details.
 */
static char *
md5_digest(int n, ...)
{
	EVP_MD_CTX mdctx;
	const EVP_MD *md;
	unsigned char md_value[EVP_MAX_MD_SIZE];
	unsigned int md_len = 0;
	int i, rc;
	char *string;
	char *md5_result = NULL;

	OpenSSL_add_all_digests();

	md = EVP_md5();
	if(!md)
		err(1, "Unknown message digest");

	EVP_MD_CTX_init(&mdctx);
	EVP_DigestInit_ex(&mdctx, md, NULL);
	va_list argPtr;
	va_start(argPtr, n);
	for (i = 0; i < n; i++) {
		string = va_arg(argPtr, char *);
		EVP_DigestUpdate(&mdctx, string, strlen(string));
	}
	va_end(argPtr);
	EVP_DigestFinal_ex(&mdctx, md_value, &md_len);
	EVP_MD_CTX_cleanup(&mdctx);
	EVP_cleanup();

	rc = md5toa(md_value, md_len, &md5_result);
	if (rc == -1)
		err(1, "md5 digest failure.");

	return md5_result;
}
开发者ID:HendrikStrobelt,项目名称:basex-api,代码行数:39,代码来源:md5.c


示例20: hmac_init

HMACCTX hmac_init(const void *key, int len, enum ssh_hmac_e type) {
  HMACCTX ctx = NULL;

  ctx = HMAC_CTX_new();
  if (ctx == NULL) {
    return NULL;
  }

#ifndef OLD_CRYPTO
  HMAC_CTX_reset(ctx); // openssl 0.9.7 requires it.
#endif

  switch(type) {
    case SSH_HMAC_SHA1:
      HMAC_Init_ex(ctx, key, len, EVP_sha1(), NULL);
      break;
    case SSH_HMAC_SHA256:
      HMAC_Init_ex(ctx, key, len, EVP_sha256(), NULL);
      break;
    case SSH_HMAC_SHA384:
      HMAC_Init_ex(ctx, key, len, EVP_sha384(), NULL);
      break;
    case SSH_HMAC_SHA512:
      HMAC_Init_ex(ctx, key, len, EVP_sha512(), NULL);
      break;
    case SSH_HMAC_MD5:
      HMAC_Init_ex(ctx, key, len, EVP_md5(), NULL);
      break;
    default:
      HMAC_CTX_free(ctx);
      SAFE_FREE(ctx);
      ctx = NULL;
  }

  return ctx;
}
开发者ID:codinn,项目名称:libssh,代码行数:36,代码来源:libcrypto.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ EXCEPTION_CONVERT函数代码示例发布时间:2022-05-30
下一篇:
C++ EVP_get_cipherbyname函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap