本文整理汇总了C++中EVP_MD_CTX_md函数的典型用法代码示例。如果您正苦于以下问题:C++ EVP_MD_CTX_md函数的具体用法?C++ EVP_MD_CTX_md怎么用?C++ EVP_MD_CTX_md使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EVP_MD_CTX_md函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: block_out
static int block_out(BIO *b)
{
BIO_OK_CTX *ctx;
EVP_MD_CTX *md;
unsigned long tl;
const EVP_MD *digest;
int md_size;
ctx = BIO_get_data(b);
md = ctx->md;
digest = EVP_MD_CTX_md(md);
md_size = EVP_MD_size(digest);
tl = ctx->buf_len - OK_BLOCK_BLOCK;
ctx->buf[0] = (unsigned char)(tl >> 24);
ctx->buf[1] = (unsigned char)(tl >> 16);
ctx->buf[2] = (unsigned char)(tl >> 8);
ctx->buf[3] = (unsigned char)(tl);
if (!EVP_DigestUpdate(md,
(unsigned char *)&(ctx->buf[OK_BLOCK_BLOCK]), tl))
goto berr;
if (!EVP_DigestFinal_ex(md, &(ctx->buf[ctx->buf_len]), NULL))
goto berr;
ctx->buf_len += md_size;
ctx->blockout = 1;
return 1;
berr:
BIO_clear_retry_flags(b);
return 0;
}
开发者ID:Ana06,项目名称:openssl,代码行数:30,代码来源:bio_ok.c
示例2: GetDigestPtr
/*
* Public
*/
const EVP_MD *
GetDigestPtr(VALUE obj)
{
const EVP_MD *md;
ASN1_OBJECT *oid = NULL;
if (RB_TYPE_P(obj, T_STRING)) {
const char *name = StringValueCStr(obj);
md = EVP_get_digestbyname(name);
if (!md) {
oid = OBJ_txt2obj(name, 0);
md = EVP_get_digestbyobj(oid);
ASN1_OBJECT_free(oid);
}
if(!md)
ossl_raise(rb_eRuntimeError, "Unsupported digest algorithm (%"PRIsVALUE").", obj);
} else {
EVP_MD_CTX *ctx;
SafeGetDigest(obj, ctx);
md = EVP_MD_CTX_md(ctx);
}
return md;
}
开发者ID:padde,项目名称:openssl,代码行数:30,代码来源:ossl_digest.c
示例3: cms_DigestAlgorithm_find_ctx
int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
X509_ALGOR *mdalg)
{
int nid;
ASN1_OBJECT *mdoid;
X509_ALGOR_get0(&mdoid, NULL, NULL, mdalg);
nid = OBJ_obj2nid(mdoid);
/* Look for digest type to match signature */
for (;;) {
EVP_MD_CTX *mtmp;
chain = BIO_find_type(chain, BIO_TYPE_MD);
if (chain == NULL) {
CMSerr(CMS_F_CMS_DIGESTALGORITHM_FIND_CTX,
CMS_R_NO_MATCHING_DIGEST);
return 0;
}
BIO_get_md_ctx(chain, &mtmp);
if (EVP_MD_CTX_type(mtmp) == nid
/*
* Workaround for broken implementations that use signature
* algorithm OID instead of digest.
*/
|| EVP_MD_pkey_type(EVP_MD_CTX_md(mtmp)) == nid)
return EVP_MD_CTX_copy_ex(mctx, mtmp);
chain = BIO_next(chain);
}
}
开发者ID:microcai,项目名称:openssl-cmake,代码行数:27,代码来源:cms_lib.c
示例4: ssl3_handshake_mac
static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx,
const char *sender, int len, unsigned char *p)
{
unsigned int ret;
int npad,n;
unsigned int i;
unsigned char md_buf[EVP_MAX_MD_SIZE];
EVP_MD_CTX ctx;
EVP_MD_CTX_copy(&ctx,in_ctx);
n=EVP_MD_CTX_size(&ctx);
npad=(48/n)*n;
if (sender != NULL)
EVP_DigestUpdate(&ctx,sender,len);
EVP_DigestUpdate(&ctx,s->session->master_key,
s->session->master_key_length);
EVP_DigestUpdate(&ctx,ssl3_pad_1,npad);
EVP_DigestFinal(&ctx,md_buf,&i);
EVP_DigestInit(&ctx,EVP_MD_CTX_md(&ctx));
EVP_DigestUpdate(&ctx,s->session->master_key,
s->session->master_key_length);
EVP_DigestUpdate(&ctx,ssl3_pad_2,npad);
EVP_DigestUpdate(&ctx,md_buf,i);
EVP_DigestFinal(&ctx,p,&ret);
memset(&ctx,0,sizeof(EVP_MD_CTX));
return((int)ret);
}
开发者ID:houzhenggang,项目名称:mt7688_mips_ecos,代码行数:32,代码来源:s3_enc.c
示例5: pkey_sm2_ctrl_digestinit
static int pkey_sm2_ctrl_digestinit(EVP_PKEY_CTX *pk_ctx, EVP_MD_CTX *md_ctx)
{
int ret;
EC_KEY *ec_key = pk_ctx->pkey->pkey.ec;
const EVP_MD *md = EVP_MD_CTX_md(md_ctx);
char *id;
unsigned char zid[EVP_MAX_MD_SIZE];
unsigned int zidlen = sizeof(zid);
if (!(id = SM2_get_id(ec_key))) {
return 0;
}
//FIXME: check this function
if (!SM2_compute_id_digest(zid, &zidlen, md, id, strlen(zidlen), ec_key)) {
return 0;
}
if (!EVP_DigestInit_ex(md_ctx, md, NULL)) {
goto end;
}
if (!EVP_DigestUpdate(md_ctx, zid, zidlen)) {
goto end;
}
EVP_MD_CTX_set_flags(md_ctx, EVP_MD_CTX_FLAG_NO_INIT);
end:
return ret;
}
开发者ID:brucechu,项目名称:GmSSL,代码行数:29,代码来源:ec_pmeth.c
示例6: ssl3_handshake_mac
static int ssl3_handshake_mac(SSL *s, EVP_MD_CTX *in_ctx,
const char *sender, int len, unsigned char *p)
{
unsigned int ret;
int npad,n;
unsigned int i;
unsigned char md_buf[EVP_MAX_MD_SIZE];
EVP_MD_CTX ctx;
EVP_MD_CTX_init(&ctx);
EVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
EVP_MD_CTX_copy_ex(&ctx,in_ctx);
n=EVP_MD_CTX_size(&ctx);
npad=(48/n)*n;
if (sender != NULL)
EVP_DigestUpdate(&ctx,sender,len);
EVP_DigestUpdate(&ctx,s->session->master_key,
s->session->master_key_length);
EVP_DigestUpdate(&ctx,ssl3_pad_1,npad);
EVP_DigestFinal_ex(&ctx,md_buf,&i);
EVP_DigestInit_ex(&ctx,EVP_MD_CTX_md(&ctx), NULL);
EVP_DigestUpdate(&ctx,s->session->master_key,
s->session->master_key_length);
EVP_DigestUpdate(&ctx,ssl3_pad_2,npad);
EVP_DigestUpdate(&ctx,md_buf,i);
EVP_DigestFinal_ex(&ctx,p,&ret);
EVP_MD_CTX_cleanup(&ctx);
return((int)ret);
}
开发者ID:RafaelRMachado,项目名称:MinnowBoard,代码行数:34,代码来源:s3_enc.c
示例7: DECLCALLBACK
/** @impl_interface_method{RTCRDIGESTDESC::pfnInit} */
static DECLCALLBACK(int) rtCrDigestOsslEvp_Init(void *pvState, void *pvOpaque, bool fReInit)
{
EVP_MD_CTX *pThis = (EVP_MD_CTX *)pvState;
EVP_MD const *pEvpType = (EVP_MD const *)pvOpaque;
if (fReInit)
{
pEvpType = EVP_MD_CTX_md(pThis);
# if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
EVP_MD_CTX_reset(pThis);
# else
EVP_MD_CTX_cleanup(pThis);
# endif
}
AssertPtrReturn(pEvpType, VERR_INVALID_PARAMETER);
# if OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(LIBRESSL_VERSION_NUMBER)
Assert(EVP_MD_block_size(pEvpType));
# else
Assert(pEvpType->md_size);
# endif
if (EVP_DigestInit(pThis, pEvpType))
return VINF_SUCCESS;
return VERR_CR_DIGEST_OSSL_DIGEST_INIT_ERROR;
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:26,代码来源:digest-builtin.cpp
示例8: evp_reset
static int evp_reset(lua_State *L)
{
EVP_MD_CTX *c = evp_pget(L, 1);
const EVP_MD *t = EVP_MD_CTX_md(c);
EVP_MD_CTX_cleanup(c);
EVP_MD_CTX_init(c);
EVP_DigestInit_ex(c, t, NULL);
return 0;
}
开发者ID:Odie,项目名称:moai-beta,代码行数:9,代码来源:lcrypto.c
示例9: ossl_digest_name
/*
* call-seq:
* digest.name -> string
*
* Returns the sn of this Digest instance.
*
* === Example
* digest = OpenSSL::Digest::SHA512.new
* puts digest.name # => SHA512
*
*/
static VALUE
ossl_digest_name(VALUE self)
{
EVP_MD_CTX *ctx;
GetDigest(self, ctx);
return rb_str_new2(EVP_MD_name(EVP_MD_CTX_md(ctx)));
}
开发者ID:padde,项目名称:openssl,代码行数:20,代码来源:ossl_digest.c
示例10: ossl_digest_reset
/*
* call-seq:
* digest.reset -> self
*
*/
static VALUE
ossl_digest_reset(VALUE self, SEL sel)
{
EVP_MD_CTX *ctx;
GetDigest(self, ctx);
EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL);
return self;
}
开发者ID:1nueve,项目名称:MacRuby,代码行数:15,代码来源:ossl_digest.c
示例11: digest_reset
static void
digest_reset(PX_MD * h)
{
EVP_MD_CTX *ctx = (EVP_MD_CTX *) h->p.ptr;
const EVP_MD *md;
md = EVP_MD_CTX_md(ctx);
EVP_DigestInit(ctx, md);
}
开发者ID:jaiminpan,项目名称:bizgres,代码行数:10,代码来源:openssl.c
示例12: lib_md_digest_bang
static mrb_value
lib_md_digest_bang(mrb_state *mrb, struct mrb_md *md)
{
unsigned int mdlen;
unsigned char mdstr[EVP_MAX_MD_SIZE];
EVP_DigestFinal_ex(md->ctx, mdstr, &mdlen);
EVP_DigestInit_ex(md->ctx, EVP_MD_CTX_md(md->ctx), NULL);
return mrb_str_new(mrb, (char *)mdstr, mdlen);
}
开发者ID:dai-yamashita,项目名称:plmruby,代码行数:10,代码来源:digest.c
示例13: LUA_FUNCTION
static LUA_FUNCTION(openssl_digest_ctx_info)
{
EVP_MD_CTX *ctx = CHECK_OBJECT(1, EVP_MD_CTX, "openssl.evp_digest_ctx");
lua_newtable(L);
AUXILIAR_SET(L, -1, "block_size", EVP_MD_CTX_block_size(ctx), integer);
AUXILIAR_SET(L, -1, "size", EVP_MD_CTX_size(ctx), integer);
AUXILIAR_SET(L, -1, "type", EVP_MD_CTX_type(ctx), integer);
AUXILIAR_SETOBJECT(L, EVP_MD_CTX_md(ctx), "openssl.evp_digest", -1, "digest");
return 1;
}
开发者ID:chk-jxcn,项目名称:lua-openssl,代码行数:11,代码来源:digest.c
示例14: ssl3_handshake_mac
static int ssl3_handshake_mac(SSL *s, int md_nid,
const char *sender, int len, unsigned char *p)
{
unsigned int ret;
int npad, n;
unsigned int i;
unsigned char md_buf[EVP_MAX_MD_SIZE];
EVP_MD_CTX ctx, *d = NULL;
if (!ssl3_digest_cached_records(s, 0))
return 0;
/*
* Search for digest of specified type in the handshake_dgst array
*/
for (i = 0; i < SSL_MAX_DIGEST; i++) {
if (s->s3->handshake_dgst[i]
&& EVP_MD_CTX_type(s->s3->handshake_dgst[i]) == md_nid) {
d = s->s3->handshake_dgst[i];
break;
}
}
if (!d) {
SSLerr(SSL_F_SSL3_HANDSHAKE_MAC, SSL_R_NO_REQUIRED_DIGEST);
return 0;
}
EVP_MD_CTX_init(&ctx);
EVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
EVP_MD_CTX_copy_ex(&ctx, d);
n = EVP_MD_CTX_size(&ctx);
if (n < 0)
return 0;
npad = (48 / n) * n;
if ((sender != NULL && EVP_DigestUpdate(&ctx, sender, len) <= 0)
|| EVP_DigestUpdate(&ctx, s->session->master_key,
s->session->master_key_length) <= 0
|| EVP_DigestUpdate(&ctx, ssl3_pad_1, npad) <= 0
|| EVP_DigestFinal_ex(&ctx, md_buf, &i) <= 0
|| EVP_DigestInit_ex(&ctx, EVP_MD_CTX_md(&ctx), NULL) <= 0
|| EVP_DigestUpdate(&ctx, s->session->master_key,
s->session->master_key_length) <= 0
|| EVP_DigestUpdate(&ctx, ssl3_pad_2, npad) <= 0
|| EVP_DigestUpdate(&ctx, md_buf, i) <= 0
|| EVP_DigestFinal_ex(&ctx, p, &ret) <= 0) {
SSLerr(SSL_F_SSL3_HANDSHAKE_MAC, ERR_R_INTERNAL_ERROR);
ret = 0;
}
EVP_MD_CTX_cleanup(&ctx);
return ((int)ret);
}
开发者ID:nyistsoft,项目名称:openssl,代码行数:54,代码来源:s3_enc.c
示例15: ikrt_openssl_evp_md_ctx_md
ikptr
ikrt_openssl_evp_md_ctx_md (ikptr s_ctx, ikpcb * pcb)
{
#ifdef HAVE_EVP_MD_CTX_MD
const EVP_MD_CTX * ctx = IK_EVP_MD_CTX(s_ctx);
const EVP_MD* rv;
rv = EVP_MD_CTX_md(ctx);
return (rv)? ika_pointer_alloc(pcb, (long)rv) : IK_FALSE;
#else
feature_failure(__func__);
#endif
}
开发者ID:marcomaggi,项目名称:vicare-openssl,代码行数:12,代码来源:vicare-openssl-evp-message-digest.c
示例16: ossl_digest_reset
/*
* call-seq:
* digest.reset -> self
*
* Resets the Digest in the sense that any Digest#update that has been
* performed is abandoned and the Digest is set to its initial state again.
*
*/
static VALUE
ossl_digest_reset(VALUE self)
{
EVP_MD_CTX *ctx;
GetDigest(self, ctx);
if (EVP_DigestInit_ex(ctx, EVP_MD_CTX_md(ctx), NULL) != 1) {
ossl_raise(eDigestError, "Digest initialization failed.");
}
return self;
}
开发者ID:padde,项目名称:openssl,代码行数:20,代码来源:ossl_digest.c
示例17: digest_reset
static int digest_reset(lua_State *L)
{
EVP_MD_CTX *c = (EVP_MD_CTX*)luaL_checkudata(L, 1, LUACRYPTO_DIGESTNAME);
const EVP_MD *t = EVP_MD_CTX_md(c);
if (!EVP_MD_CTX_cleanup(c)) {
return crypto_error(L);
}
EVP_MD_CTX_init(c);
if (!EVP_DigestInit_ex(c, t, NULL)) {
return crypto_error(L);
}
return 0;
}
开发者ID:dtiedy,项目名称:luaplus51-all,代码行数:13,代码来源:lcrypto.c
示例18: digest_finish
static void
digest_finish(PX_MD * h, uint8 *dst)
{
EVP_MD_CTX *ctx = (EVP_MD_CTX *) h->p.ptr;
const EVP_MD *md = EVP_MD_CTX_md(ctx);
EVP_DigestFinal(ctx, dst, NULL);
/*
* Some builds of 0.9.7x clear all of ctx in EVP_DigestFinal. Fix it by
* reinitializing ctx.
*/
EVP_DigestInit(ctx, md);
}
开发者ID:jaiminpan,项目名称:bizgres,代码行数:14,代码来源:openssl.c
示例19: tls_utils_keyblock_size_get
/** Returns the OpenSSL keyblock size
*
* @copyright (c) 2002-2016, Jouni Malinen <[email protected]> and contributors
* All Rights Reserved.
*
* These programs are licensed under the BSD license (the one with
* advertisement clause removed).
*
* this function shamelessly stolen from from
* hostap:src/crypto/tls_openssl.c:openssl_get_keyblock_size()
*
* @param[in] request The current request.
* @param[in] ssl The current SSL session.
* @return
* - -1 problem with the session.
* - >=0 length of the block.
*/
int tls_utils_keyblock_size_get(REQUEST *request, SSL *ssl)
{
const EVP_CIPHER *c;
const EVP_MD *h;
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
int md_size;
if (ssl->enc_read_ctx == NULL || ssl->enc_read_ctx->cipher == NULL || ssl->read_hash == NULL)
return -1;
c = ssl->enc_read_ctx->cipher;
h = EVP_MD_CTX_md(ssl->read_hash);
if (h)
md_size = EVP_MD_size(h);
else if (ssl->s3)
md_size = ssl->s3->tmp.new_mac_secret_size;
else
return -1;
RDEBUG2("OpenSSL: keyblock size: key_len=%d MD_size=%d "
"IV_len=%d", EVP_CIPHER_key_length(c), md_size,
EVP_CIPHER_iv_length(c));
return 2 * (EVP_CIPHER_key_length(c) +
md_size +
EVP_CIPHER_iv_length(c));
#else
const SSL_CIPHER *ssl_cipher;
int cipher, digest;
ssl_cipher = SSL_get_current_cipher(ssl);
if (!ssl_cipher)
return -1;
cipher = SSL_CIPHER_get_cipher_nid(ssl_cipher);
digest = SSL_CIPHER_get_digest_nid(ssl_cipher);
RDEBUG2("OpenSSL: cipher nid %d digest nid %d", cipher, digest);
if (cipher < 0 || digest < 0)
return -1;
c = EVP_get_cipherbynid(cipher);
h = EVP_get_digestbynid(digest);
if (!c || !h)
return -1;
RDEBUG2("OpenSSL: keyblock size: key_len=%d MD_size=%d IV_len=%d",
EVP_CIPHER_key_length(c), EVP_MD_size(h),
EVP_CIPHER_iv_length(c));
return 2 * (EVP_CIPHER_key_length(c) + EVP_MD_size(h) +
EVP_CIPHER_iv_length(c));
#endif
}
开发者ID:geaaru,项目名称:freeradius-server,代码行数:66,代码来源:utils.c
示例20: evp_reset
static int evp_reset(lua_State *L)
{
HANDLER_EVP *c = evp_pget(L, 1);
#if CRYPTO_OPENSSL
const EVP_MD *t = EVP_MD_CTX_md(c);
EVP_MD_CTX_cleanup(c);
EVP_MD_CTX_init(c);
EVP_DigestInit_ex(c, t, NULL);
#elif CRYPTO_GCRYPT
gcry_md_reset(*c);
#endif
return 0;
}
开发者ID:hahnakane,项目名称:junkcode,代码行数:15,代码来源:lcrypto.c
注:本文中的EVP_MD_CTX_md函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论