本文整理汇总了C++中EVP_MD_CTX_md函数的典型用法代码示例。如果您正苦于以下问题:C++ EVP_MD_CTX_md函数的具体用法?C++ EVP_MD_CTX_md怎么用?C++ EVP_MD_CTX_md使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EVP_MD_CTX_md函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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)));
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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
}