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

C++ ASN1_item_d2i_bio函数代码示例

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

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



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

示例1: read_signature

/**
 * Reads and parses the ASN.1 BootSignature block from the given offset
 * @param fd File descriptor to the boot image
 * @param offset Offset from the beginning of file to the signature
 * @param bs Pointer to receive the BootImage structure
 */
static int read_signature(int fd, off64_t offset, BootSignature **bs)
{
    BIO *in = NULL;

    if (!bs) {
        return -1;
    }

    if (lseek64(fd, offset, SEEK_SET) == -1) {
        return -1;
    }

    if ((in = BIO_new_fd(fd, BIO_NOCLOSE)) == NULL) {
        ERR_print_errors(g_error);
        return -1;
    }

    if ((*bs = ASN1_item_d2i_bio(ASN1_ITEM_rptr(BootSignature), in, bs)) == NULL) {
        ERR_print_errors(g_error);
        BIO_free(in);
        return -1;
    }

    BIO_free(in);
    return 0;
}
开发者ID:AOSP-JF-MM,项目名称:platform_system_extras,代码行数:32,代码来源:verify_boot_signature.c


示例2: ASN1err

void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x)
{
    BIO *b;
    char *ret;

    if ((b = BIO_new(BIO_s_file())) == NULL) {
        ASN1err(ASN1_F_ASN1_ITEM_D2I_FP, ERR_R_BUF_LIB);
        return (NULL);
    }
    BIO_set_fp(b, in, BIO_NOCLOSE);
    ret = ASN1_item_d2i_bio(it, b, x);
    BIO_free(b);
    return (ret);
}
开发者ID:4ker,项目名称:openssl,代码行数:14,代码来源:a_d2i_fp.c


示例3: OPENSSL_PUT_ERROR

void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x)
        {
        BIO *b;
        char *ret;

        if ((b=BIO_new(BIO_s_file())) == NULL)
		{
		OPENSSL_PUT_ERROR(ASN1, ASN1_item_d2i_fp, ERR_R_BUF_LIB);
                return(NULL);
		}
        BIO_set_fp(b,in,BIO_NOCLOSE);
        ret=ASN1_item_d2i_bio(it,b,x);
        BIO_free(b);
        return(ret);
        }
开发者ID:krunalsoni01,项目名称:src,代码行数:15,代码来源:a_d2i_fp.c


示例4: ASN1_item_d2i_bio

PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12)
{
    return ASN1_item_d2i_bio(ASN1_ITEM_rptr(PKCS12), bp, p12);
}
开发者ID:mz02005,项目名称:CScript,代码行数:4,代码来源:p12_utl.c


示例5: ERR_clear_error

DVT_STATUS CERTIFICATE_FILE_CLASS::importDer(const char* filename, bool certificatesOnly, const char*)

//  DESCRIPTION     : Import certificates from a PEM formated file.
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           : Returns MSG_OK, MSG_ERROR, MSG_FILE_NOT_EXIST, MSG_NO_VALUE
//					: DER does not support encryption, so MSG_INVALID_PASSWORD will never be returned
//<<===========================================================================
{
	DVT_STATUS status = MSG_ERROR;
	DVT_STATUS* status_ptr;
	BIO* bio_ptr;


	// clear the error queue
	ERR_clear_error();

	// open the file
	bio_ptr = BIO_new(BIO_s_file_internal());
	if (bio_ptr == NULL)
	{
		openSslM_ptr->printError(loggerM_ptr, LOG_ERROR, "setting up to read DER file");
		status = MSG_ERROR;
		goto end;
	}
	if (BIO_read_filename(bio_ptr, filename) <= 0)
	{
		unsigned long err;
		err = ERR_peek_error();
		if ((ERR_GET_LIB(err) == ERR_LIB_SYS) && (ERR_GET_REASON(err) == ERROR_FILE_NOT_FOUND))
		{
			// file does not exist
			ERR_clear_error(); // eat any errors
			status = MSG_FILE_NOT_EXIST;
		}
		else
		{
			openSslM_ptr->printError(loggerM_ptr, LOG_ERROR, "opening DER file for reading");
			status = MSG_ERROR;
		}
		goto end;
	}

	// read the file and convert the data
	if (certificatesOnly)
	{
		X509* cert_ptr;

		cert_ptr = (X509*)ASN1_item_d2i_bio(ASN1_ITEM_rptr(X509), bio_ptr, NULL);
		if (cert_ptr == NULL)
		{
			unsigned long err;
			err = ERR_peek_error();
			if ((ERR_GET_LIB(err) == ERR_LIB_ASN1) && (ERR_GET_REASON(err) == ASN1_R_WRONG_TAG))
			{
				// probably not a certificate
				ERR_clear_error(); // eat any errors
				status = MSG_NO_VALUE;
			}
			else
			{
				openSslM_ptr->printError(loggerM_ptr, LOG_ERROR, "decoding certificate in DER file");
				status = MSG_ERROR;
			}
		}
		else
		{
			// save the certificate
			if (!push(cert_ptr))
			{
				status = MSG_ERROR;
			}
			else
			{
				status = MSG_OK;
			}
		}
	}
	else
	{
		// this calls derDecode()
		status_ptr = (DVT_STATUS*)ASN1_d2i_bio(NULL, (char* (*)(void))derCallback, bio_ptr, (unsigned char**)this);
		status = *status_ptr;
		delete status_ptr;
	}

end:
	if (bio_ptr != NULL) BIO_free(bio_ptr);

	return status;
}
开发者ID:151706061,项目名称:DVTK-1,代码行数:92,代码来源:certificate.cpp


示例6: ASN1_item_d2i_bio

RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa)
{
    return ASN1_item_d2i_bio(ASN1_ITEM_rptr(RSAPublicKey), bp, rsa);
}
开发者ID:1234-,项目名称:openssl,代码行数:4,代码来源:x_all.c


示例7: return

RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa)
	{
	return (RSA*)ASN1_item_d2i_bio(ASN1_ITEM_rptr(RSAPrivateKey), bp, rsa);
	}
开发者ID:Wampamba-Nooh,项目名称:MicroFrameworkSDK-Mono,代码行数:4,代码来源:x_all.cpp


示例8: ASN1_item_d2i_bio

CPK_PUBLIC_PARAMS *d2i_CPK_PUBLIC_PARAMS_bio(BIO *bp, CPK_PUBLIC_PARAMS **params) {
	return ASN1_item_d2i_bio(ASN1_ITEM_rptr(CPK_PUBLIC_PARAMS), bp, params);
}
开发者ID:Mumblebo,项目名称:GmSSL,代码行数:3,代码来源:cpk_asn1.c


示例9: d2i_OCSP_RESPONSE_bio

OCSP_RESPONSE *
d2i_OCSP_RESPONSE_bio(BIO *bp, OCSP_RESPONSE **a)
{
	return ASN1_item_d2i_bio(&OCSP_RESPONSE_it, bp, a);
}
开发者ID:mr-moai-2016,项目名称:znk_project,代码行数:5,代码来源:ocsp_asn.c


示例10: d2i_OCSP_REQUEST_bio

OCSP_REQUEST *
d2i_OCSP_REQUEST_bio(BIO *bp, OCSP_REQUEST **a)
{
	return ASN1_item_d2i_bio(&OCSP_REQUEST_it, bp, a);
}
开发者ID:mr-moai-2016,项目名称:znk_project,代码行数:5,代码来源:ocsp_asn.c


示例11: d2i_DSAparams_bio

DSA *
d2i_DSAparams_bio(BIO *bp, DSA **a)
{
	return ASN1_item_d2i_bio(&DSAparams_it, bp, a);
}
开发者ID:mr-moai-2016,项目名称:znk_project,代码行数:5,代码来源:dsa_asn1.c


示例12: ASN1_item_d2i_bio

CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms)
{
    return ASN1_item_d2i_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms);
}
开发者ID:GrayKing,项目名称:Leakfix-on-OpenSSL,代码行数:4,代码来源:cms_io.c


示例13: execute_test

static int execute_test(D2I_TEST_FIXTURE fixture)
{
    BIO *bio = NULL;
    ASN1_VALUE *value = NULL;
    int ret = 0;
    unsigned char buf[2048];
    const unsigned char *buf_ptr = buf;
    unsigned char *der = NULL;
    int derlen;
    int len;

    if ((bio = BIO_new_file(test_file, "r")) == NULL)
        return 0;

    if (expected_error == ASN1_BIO) {
        value = ASN1_item_d2i_bio(item_type, bio, NULL);
        if (value == NULL)
            ret = 1;
        goto err;
    }

    /*
     * Unless we are testing it we don't use ASN1_item_d2i_bio because it
     * performs sanity checks on the input and can reject it before the
     * decoder is called.
     */
    len = BIO_read(bio, buf, sizeof(buf));
    if (len < 0)
        goto err;

    value = ASN1_item_d2i(NULL, &buf_ptr, len, item_type);
    if (value == NULL) {
        if (expected_error == ASN1_DECODE)
            ret = 1;
        goto err;
    }

    derlen = ASN1_item_i2d(value, &der, item_type);

    if (der == NULL || derlen < 0) {
        if (expected_error == ASN1_ENCODE)
            ret = 1;
        goto err;
    }

    if (derlen != len || memcmp(der, buf, derlen) != 0) {
        if (expected_error == ASN1_COMPARE)
            ret = 1;
        goto err;
    }

    if (expected_error == ASN1_OK)
        ret = 1;

 err:
    /* Don't indicate success for memory allocation errors */
    if (ret == 1 && ERR_GET_REASON(ERR_peek_error()) == ERR_R_MALLOC_FAILURE)
        ret = 0;
    BIO_free(bio);
    OPENSSL_free(der);
    ASN1_item_free(value, item_type);
    return ret;
}
开发者ID:AlexanderPankiv,项目名称:node,代码行数:63,代码来源:d2i_test.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ ASN1_item_d2i_fp函数代码示例发布时间:2022-05-30
下一篇:
C++ ASN1_item_d2i函数代码示例发布时间: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