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

C++ CMS_ContentInfo_free函数代码示例

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

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



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

示例1: openssl_cms_free

static int openssl_cms_free(lua_State *L)
{
  CMS_ContentInfo *cms = CHECK_OBJECT(1, CMS_ContentInfo, "openssl.cms");
  CMS_ContentInfo_free(cms);

  return 0;
}
开发者ID:witchu,项目名称:lua-openssl,代码行数:7,代码来源:cms.c


示例2: CMS_ContentInfo_new

CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md)
	{
	CMS_ContentInfo *cms;
	CMS_DigestedData *dd;
	cms = CMS_ContentInfo_new();
	if (!cms)
		return NULL;

	dd = M_ASN1_new_of(CMS_DigestedData);

	if (!dd)
		goto err;

	cms->contentType = OBJ_nid2obj(NID_pkcs7_digest);
	cms->d.digestedData = dd;

	dd->version = 0;
	dd->encapContentInfo->eContentType = OBJ_nid2obj(NID_pkcs7_data);

	cms_DigestAlgorithm_set(dd->digestAlgorithm, md);

	return cms;

	err:

	if (cms)
		CMS_ContentInfo_free(cms);

	return NULL;
	}
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:30,代码来源:cms_dd.cpp


示例3: CMSerr

CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,
					const unsigned char *key, size_t keylen,
					unsigned int flags)
	{
	CMS_ContentInfo *cms;
	if (!cipher)
		{
		CMSerr(CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT, CMS_R_NO_CIPHER);
		return NULL;
		}
	cms = CMS_ContentInfo_new();
	if (!cms)
		return NULL;
	if (!CMS_EncryptedData_set1_key(cms, cipher, key, keylen))
		return NULL;

	if(!(flags & CMS_DETACHED))
		CMS_set_detached(cms, 0);

	if ((flags & (CMS_STREAM|CMS_PARTIAL))
		|| CMS_final(cms, in, NULL, flags))
		return cms;

	CMS_ContentInfo_free(cms);
	return NULL;
	}
开发者ID:hlcherub,项目名称:src,代码行数:26,代码来源:cms_smime.c


示例4: ossl_cms_initialize

static VALUE
ossl_cms_initialize(int argc, VALUE *argv, VALUE self)
{
    CMS_ContentInfo *cms, *out = DATA_PTR(self);
    BIO *in;
    VALUE arg;

    if(rb_scan_args(argc, argv, "01", &arg) == 0)
        return self;

    arg = ossl_to_der_if_possible(arg);
    in = ossl_obj2bio(arg);

    cms = PEM_read_bio_CMS(in, &out, NULL, NULL);
    if (!cms) {
        OSSL_BIO_reset(in);
        cms = d2i_CMS_bio(in, &out);

        if (!cms) {
            BIO_free(in);
            CMS_ContentInfo_free(out);
            DATA_PTR(self) = NULL;
            ossl_raise(rb_eArgError, "Could not parse the CMS");
        }
    }

    DATA_PTR(self) = out;
    BIO_free(in);
    ossl_cms_set_data(self, Qnil);
    ossl_cms_set_err_string(self, Qnil);

    return self;
}
开发者ID:sustr4,项目名称:rCMS,代码行数:33,代码来源:ossl_cms.c


示例5: ossl_cms_s_read_cms

static VALUE
ossl_cms_s_read_cms(VALUE klass, VALUE arg)
{
    BIO *in;
    CMS_ContentInfo *cms, *out;
    VALUE ret;

    arg = ossl_to_der_if_possible(arg);
    in = ossl_obj2bio(arg);
    out = CMS_ContentInfo_new();
    cms = PEM_read_bio_CMS(in, &out, NULL, NULL);

    if (!cms) {
        OSSL_BIO_reset(in);
        cms = d2i_CMS_bio(in, &out);

        if (!cms) {
            BIO_free(in);
            CMS_ContentInfo_free(out);
            ossl_raise(rb_eArgError, "Could not parse the CMS");
        }
    }

    WrapCMS(cCMS, ret, cms);
    BIO_free(in);
    ossl_cms_set_data(ret, Qnil);
    ossl_cms_set_err_string(ret, Qnil);

    return ret;
}
开发者ID:sustr4,项目名称:rCMS,代码行数:30,代码来源:ossl_cms.c


示例6: main

int main(int argc, char **argv)
	{
	BIO *in = NULL, *out = NULL;
	CMS_ContentInfo *cms = NULL;
	int ret = 1;

	/*
	 * On OpenSSL 0.9.9 only:
	 * for streaming set CMS_STREAM
	 */
	int flags = CMS_STREAM;

	OpenSSL_add_all_algorithms();
	ERR_load_crypto_strings();

	/* Open content being compressed */

	in = BIO_new_file("comp.txt", "r");

	if (!in)
		goto err;

	/* compress content */
	cms = CMS_compress(in, NID_zlib_compression, flags);

	if (!cms)
		goto err;

	out = BIO_new_file("smcomp.txt", "w");
	if (!out)
		goto err;

	/* Write out S/MIME message */
	if (!SMIME_write_CMS(out, cms, in, flags))
		goto err;

	ret = 0;

	err:

	if (ret)
		{
		fprintf(stderr, "Error Compressing Data\n");
		ERR_print_errors_fp(stderr);
		}

	if (cms)
		CMS_ContentInfo_free(cms);
	if (in)
		BIO_free(in);
	if (out)
		BIO_free(out);

	return ret;

	}
开发者ID:AustinWise,项目名称:Netduino-Micro-Framework,代码行数:56,代码来源:cms_comp.c


示例7: main

int main(int argc, char **argv)
	{
	BIO *in = NULL, *out = NULL;
	CMS_ContentInfo *cms = NULL;
	int ret = 1;

	OpenSSL_add_all_algorithms();
	ERR_load_crypto_strings();

	/* Open compressed content */

	in = BIO_new_file("smcomp.txt", "r");

	if (!in)
		goto err;

	/* Sign content */
	cms = SMIME_read_CMS(in, NULL);

	if (!cms)
		goto err;

	out = BIO_new_file("smuncomp.txt", "w");
	if (!out)
		goto err;

	/* Uncompress S/MIME message */
	if (!CMS_uncompress(cms, out, NULL, 0))
		goto err;

	ret = 0;

	err:

	if (ret)
		{
		fprintf(stderr, "Error Uncompressing Data\n");
		ERR_print_errors_fp(stderr);
		}

	if (cms)
		CMS_ContentInfo_free(cms);

	if (in)
		BIO_free(in);
	if (out)
		BIO_free(out);

	return ret;

	}
开发者ID:0culus,项目名称:openssl,代码行数:51,代码来源:cms_uncomp.c


示例8: cms_Data_create

CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags)
	{
	CMS_ContentInfo *cms;
	cms = cms_Data_create();
	if (!cms)
		return NULL;

	if ((flags & CMS_STREAM) || CMS_final(cms, in, NULL, flags))
		return cms;

	CMS_ContentInfo_free(cms);

	return NULL;
	}
开发者ID:hlcherub,项目名称:src,代码行数:14,代码来源:cms_smime.c


示例9: EVP_sha1

CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,
					unsigned int flags)
	{
	CMS_ContentInfo *cms;
	if (!md)
		md = EVP_sha1();
	cms = cms_DigestedData_create(md);
	if (!cms)
		return NULL;

	if(!(flags & CMS_DETACHED))
		CMS_set_detached(cms, 0);

	if ((flags & CMS_STREAM) || CMS_final(cms, in, NULL, flags))
		return cms;

	CMS_ContentInfo_free(cms);
	return NULL;
	}
开发者ID:hlcherub,项目名称:src,代码行数:19,代码来源:cms_smime.c


示例10: CMS_ContentInfo_new

CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher)
{
    CMS_ContentInfo *cms;
    CMS_EnvelopedData *env;
    cms = CMS_ContentInfo_new();
    if (!cms)
        goto merr;
    env = cms_enveloped_data_init(cms);
    if (!env)
        goto merr;
    if (!cms_EncryptedContent_init(env->encryptedContentInfo,
                                   cipher, NULL, 0))
        goto merr;
    return cms;
merr:
    CMS_ContentInfo_free(cms);
    CMSerr(CMS_F_CMS_ENVELOPEDDATA_CREATE, ERR_R_MALLOC_FAILURE);
    return NULL;
}
开发者ID:redshodan,项目名称:mosh-openssl,代码行数:19,代码来源:cms_env.c


示例11: CMSerr

CMS_ContentInfo *cms_CompressedData_create(int comp_nid)
	{
	CMS_ContentInfo *cms;
	CMS_CompressedData *cd;
	/* Will need something cleverer if there is ever more than one
	 * compression algorithm or parameters have some meaning...
	 */
	if (comp_nid != NID_zlib_compression)
		{
		CMSerr(CMS_F_CMS_COMPRESSEDDATA_CREATE,
				CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM);
		return NULL;
		}
	cms = CMS_ContentInfo_new();
	if (!cms)
		return NULL;

	cd = M_ASN1_new_of(CMS_CompressedData);

	if (!cd)
		goto err;

	cms->contentType = OBJ_nid2obj(NID_id_smime_ct_compressedData);
	cms->d.compressedData = cd;

	cd->version = 0;

	X509_ALGOR_set0(cd->compressionAlgorithm,
			OBJ_nid2obj(NID_zlib_compression),
			V_ASN1_UNDEF, NULL);

	cd->encapContentInfo->eContentType = OBJ_nid2obj(NID_pkcs7_data);

	return cms;

	err:

	if (cms)
		CMS_ContentInfo_free(cms);

	return NULL;
	}
开发者ID:002301,项目名称:node,代码行数:42,代码来源:cms_cd.c


示例12: ossl_cms_copy

static VALUE
ossl_cms_copy(VALUE self, VALUE other)
{
    CMS_ContentInfo *a, *b, *cms;

    rb_check_frozen(self);
    if (self == other) return self;

    GetCMS(self, a);
    SafeGetCMS(other, b);

    cms = CMS_ContentInfo_dup(b);
    if (!cms) {
        ossl_raise(eCMSError, NULL);
    }
    DATA_PTR(self) = cms;
    CMS_ContentInfo_free(a);

    return self;
}
开发者ID:sustr4,项目名称:rCMS,代码行数:20,代码来源:ossl_cms.c


示例13: FuzzerTestOneInput

int FuzzerTestOneInput(const uint8_t *buf, size_t len)
{
    CMS_ContentInfo *cms;
    BIO *in;

    if (len == 0)
        return 0;

    in = BIO_new(BIO_s_mem());
    OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
    cms = d2i_CMS_bio(in, NULL);
    if (cms != NULL) {
        BIO *out = BIO_new(BIO_s_null());

        i2d_CMS_bio(out, cms);
        BIO_free(out);
        CMS_ContentInfo_free(cms);
    }

    BIO_free(in);
    ERR_clear_error();

    return 0;
}
开发者ID:Ana06,项目名称:openssl,代码行数:24,代码来源:cms.c


示例14: swupdate_verify_file

int swupdate_verify_file(struct swupdate_digest *dgst, const char *sigfile,
		const char *file, const char *signer_name)
{
	int status = -EFAULT;
	CMS_ContentInfo *cms = NULL;
	BIO *content_bio = NULL;

	/* Open CMS blob that needs to be checked */
	BIO *sigfile_bio = BIO_new_file(sigfile, "rb");
	if (!sigfile_bio) {
		ERROR("%s cannot be opened", sigfile);
		status = -EBADF;
		goto out;
	}

	/* Parse the DER-encoded CMS message */
	cms = d2i_CMS_bio(sigfile_bio, NULL);
	if (!cms) {
		ERROR("%s cannot be parsed as DER-encoded CMS signature blob", sigfile);
		status = -EFAULT;
		goto out;
	}

	if (check_signer_name(cms, signer_name)) {
		ERROR("failed to verify signer name");
		status = -EFAULT;
		goto out;
	}

	/* Open the content file (data which was signed) */
	content_bio = BIO_new_file(file, "rb");
	if (!content_bio) {
		ERROR("%s cannot be opened", file);
		status = -EBADF;
		goto out;
	}

	/* Then try to verify signature */
	if (!CMS_verify(cms, NULL, dgst->certs, content_bio,
			NULL, CMS_BINARY)) {
		ERR_print_errors_fp(stderr);
		ERROR("Signature verification failed");
		status = -EBADMSG;
		goto out;
	}

	TRACE("Verified OK");

	/* Signature is valid */
	status = 0;
out:

	if (cms) {
		CMS_ContentInfo_free(cms);
	}
	if (content_bio) {
		BIO_free(content_bio);
	}
	if (sigfile_bio) {
		BIO_free(sigfile_bio);
	}
	return status;
}
开发者ID:3mdeb,项目名称:swupdate,代码行数:63,代码来源:verify_signature.c


示例15: MAIN


//.........这里部分代码省略.........
            /* NULL these because call absorbs them */
            secret_key = NULL;
            secret_keyid = NULL;
        }
        if (pwri_pass) {
            pwri_tmp = (unsigned char *)BUF_strdup((char *)pwri_pass);
            if (!pwri_tmp)
                goto end;
            if (!CMS_add0_recipient_password(cms,
                                             -1, NID_undef, NID_undef,
                                             pwri_tmp, -1, NULL))
                goto end;
            pwri_tmp = NULL;
        }
        if (!(flags & CMS_STREAM)) {
            if (!CMS_final(cms, in, NULL, flags))
                goto end;
        }
    } else if (operation == SMIME_ENCRYPTED_ENCRYPT) {
        cms = CMS_EncryptedData_encrypt(in, cipher,
                                        secret_key, secret_keylen, flags);

    } else if (operation == SMIME_SIGN_RECEIPT) {
        CMS_ContentInfo *srcms = NULL;
        STACK_OF(CMS_SignerInfo) *sis;
        CMS_SignerInfo *si;
        sis = CMS_get0_SignerInfos(cms);
        if (!sis)
            goto end;
        si = sk_CMS_SignerInfo_value(sis, 0);
        srcms = CMS_sign_receipt(si, signer, key, other, flags);
        if (!srcms)
            goto end;
        CMS_ContentInfo_free(cms);
        cms = srcms;
    } else if (operation & SMIME_SIGNERS) {
        int i;
        /*
         * If detached data content we enable streaming if S/MIME output
         * format.
         */
        if (operation == SMIME_SIGN) {

            if (flags & CMS_DETACHED) {
                if (outformat == FORMAT_SMIME)
                    flags |= CMS_STREAM;
            }
            flags |= CMS_PARTIAL;
            cms = CMS_sign(NULL, NULL, other, in, flags);
            if (!cms)
                goto end;
            if (econtent_type)
                CMS_set1_eContentType(cms, econtent_type);

            if (rr_to) {
                rr = make_receipt_request(rr_to, rr_allorfirst, rr_from);
                if (!rr) {
                    BIO_puts(bio_err,
                             "Signed Receipt Request Creation Error\n");
                    goto end;
                }
            }
        } else
            flags |= CMS_REUSE_DIGEST;
        for (i = 0; i < sk_OPENSSL_STRING_num(sksigners); i++) {
            CMS_SignerInfo *si;
开发者ID:davidlt,项目名称:openssl-fedora,代码行数:67,代码来源:cms.c


示例16: main


//.........这里部分代码省略.........
    if ( ! key )
        FAIL( "reading private key", free_extra_cert_files );

    X509 * key_cert = PEM_read_bio_X509( key_cert_file, NULL, NULL, NULL );
    if ( ! key_cert )
        FAIL( "reading signing cert", free_key );

    STACK_OF(X509) * extra_certs = NULL;
    if ( num_extra_cert_files > 0 )
    {
        int success = 1;

        extra_certs = sk_X509_new_null();
        if ( ! extra_certs )
            FAIL( "allocating stack for extra certs", free_key_cert );

        for ( int i = 0; i < num_extra_cert_files; ++i )
        {
            X509 * tmp = PEM_read_bio_X509( extra_cert_files[i],
                                            NULL, NULL, NULL );
            if ( ! tmp )
            {
                fprintf( stderr, "error reading '%s'\n",
                         argv[ ARG_FIRST_EXTRA_CERT_FILE_IX + i ] );
                success = 0;
                break;
            }

            if ( ! sk_X509_push( extra_certs, tmp ) )
            {
                fprintf( stderr, "error pushing '%s'\n",
                         argv[ ARG_FIRST_EXTRA_CERT_FILE_IX + i ] );
                success = 0;
                X509_free( tmp );
                break;
            }
        }

        if ( ! success )
            FAIL( "could not read extra certs", free_extra_certs );
    }

    CMS_ContentInfo * ci = CMS_sign( key_cert, key, extra_certs, in_data_file,
                                     CMS_DETACHED | CMS_BINARY );

    /* if ( 1 != PEM_write_bio_CMS( out_sig_file, ci ) )
           FAIL( "could not write signature in PEM", free_ci ); */

    if ( 1 != i2d_CMS_bio( out_sig_file, ci ) )
           FAIL( "could not write signature in DER", free_ci );

    /* -------------------------------------------------------------- */
    /* success */

    exit_code = 0;

    /* -------------------------------------------------------------- */
    /* cleanup */

free_ci:
    CMS_ContentInfo_free( ci );

free_extra_certs:
    sk_X509_pop_free( extra_certs, &X509_free );

free_key_cert:
    X509_free( key_cert );

free_key:
    EVP_PKEY_free( key );

free_extra_cert_files:
    for ( int i = 0; i < num_extra_cert_files; ++i )
        BIO_vfree( extra_cert_files[ i ] );
    free( extra_cert_files );

free_key_cert_file:
    BIO_vfree( key_cert_file );

free_key_file:
    BIO_vfree( key_file );

free_out_sig_file:
    BIO_vfree( out_sig_file );

free_in_data_file:
    BIO_vfree( in_data_file );

    ERR_print_errors_fp( stderr );

    ERR_remove_state( /* pid= */ 0 );
    ENGINE_cleanup();
    CONF_modules_unload( /* all= */ 1 );
    EVP_cleanup();
    ERR_free_strings();
    CRYPTO_cleanup_all_ex_data();

end:
    return exit_code;
}
开发者ID:Agnara,项目名称:openssl-pkcs11-samples,代码行数:101,代码来源:sign.c


示例17: cms_main


//.........这里部分代码省略.........
            /* NULL these because call absorbs them */
            secret_key = NULL;
            secret_keyid = NULL;
        }
        if (pwri_pass) {
            pwri_tmp = (unsigned char *)OPENSSL_strdup((char *)pwri_pass);
            if (!pwri_tmp)
                goto end;
            if (!CMS_add0_recipient_password(cms,
                                             -1, NID_undef, NID_undef,
                                             pwri_tmp, -1, NULL))
                goto end;
            pwri_tmp = NULL;
        }
        if (!(flags & CMS_STREAM)) {
            if (!CMS_final(cms, in, NULL, flags))
                goto end;
        }
    } else if (operation == SMIME_ENCRYPTED_ENCRYPT) {
        cms = CMS_EncryptedData_encrypt(in, cipher,
                                        secret_key, secret_keylen, flags);

    } else if (operation == SMIME_SIGN_RECEIPT) {
        CMS_ContentInfo *srcms = NULL;
        STACK_OF(CMS_SignerInfo) *sis;
        CMS_SignerInfo *si;
        sis = CMS_get0_SignerInfos(cms);
        if (!sis)
            goto end;
        si = sk_CMS_SignerInfo_value(sis, 0);
        srcms = CMS_sign_receipt(si, signer, key, other, flags);
        if (!srcms)
            goto end;
        CMS_ContentInfo_free(cms);
        cms = srcms;
    } else if (operation & SMIME_SIGNERS) {
        int i;
        /*
         * If detached data content we enable streaming if S/MIME output
         * format.
         */
        if (operation == SMIME_SIGN) {

            if (flags & CMS_DETACHED) {
                if (outformat == FORMAT_SMIME)
                    flags |= CMS_STREAM;
            }
            flags |= CMS_PARTIAL;
            cms = CMS_sign(NULL, NULL, other, in, flags);
            if (!cms)
                goto end;
            if (econtent_type)
                CMS_set1_eContentType(cms, econtent_type);

            if (rr_to) {
                rr = make_receipt_request(rr_to, rr_allorfirst, rr_from);
                if (!rr) {
                    BIO_puts(bio_err,
                             "Signed Receipt Request Creation Error\n");
                    goto end;
                }
            }
        } else
            flags |= CMS_REUSE_DIGEST;
        for (i = 0; i < sk_OPENSSL_STRING_num(sksigners); i++) {
            CMS_SignerInfo *si;
开发者ID:Muffo,项目名称:openssl,代码行数:67,代码来源:cms.c


示例18: mz_crypt_sign

int32_t mz_crypt_sign(uint8_t *message, int32_t message_size, uint8_t *cert_data, int32_t cert_data_size, 
    const char *cert_pwd, uint8_t **signature, int32_t *signature_size)
{
    PKCS12 *p12 = NULL;
    EVP_PKEY *evp_pkey = NULL;
    BUF_MEM *buf_mem = NULL;
    BIO *cert_bio = NULL;
    BIO *message_bio = NULL;
    BIO *signature_bio = NULL;
    CMS_ContentInfo *cms = NULL;
    CMS_SignerInfo *signer_info = NULL;
    STACK_OF(X509) *ca_stack = NULL;
    X509 *cert = NULL;
    int32_t result = 0;
    int32_t err = MZ_OK;


    if (message == NULL || cert_data == NULL || signature == NULL || signature_size == NULL)
        return MZ_PARAM_ERROR;

    mz_crypt_init();

    *signature = NULL;
    *signature_size = 0;

    cert_bio = BIO_new_mem_buf(cert_data, cert_data_size);

    if (d2i_PKCS12_bio(cert_bio, &p12) == NULL)
        err = MZ_SIGN_ERROR;
    if (err == MZ_OK)
        result = PKCS12_parse(p12, cert_pwd, &evp_pkey, &cert, &ca_stack);
    if (result)
    {
        cms = CMS_sign(NULL, NULL, ca_stack, NULL, CMS_BINARY | CMS_PARTIAL);
        if (cms)
            signer_info = CMS_add1_signer(cms, cert, evp_pkey, EVP_sha256(), 0);
        if (signer_info == NULL)
        {
            err = MZ_SIGN_ERROR;
        }
        else
        {
            message_bio = BIO_new_mem_buf(message, message_size);
            signature_bio = BIO_new(BIO_s_mem());

            result = CMS_final(cms, message_bio, NULL, CMS_BINARY);
            if (result)
                result = i2d_CMS_bio(signature_bio, cms);
            if (result)
            {
                BIO_flush(signature_bio);
                BIO_get_mem_ptr(signature_bio, &buf_mem);

                *signature_size = buf_mem->length;
                *signature = MZ_ALLOC(buf_mem->length);
                
                memcpy(*signature, buf_mem->data, buf_mem->length);
            }
#if 0            
            BIO *yy = BIO_new_file("xyz", "wb");
            BIO_write(yy, *signature, *signature_size);
            BIO_flush(yy);
            BIO_free(yy);
#endif
        }
    }

    if (!result)
        err = MZ_SIGN_ERROR;

    if (cms)
        CMS_ContentInfo_free(cms);
    if (signature_bio)
        BIO_free(signature_bio);
    if (cert_bio)
        BIO_free(cert_bio);
    if (message_bio)
        BIO_free(message_bio);
    if (p12)
        PKCS12_free(p12);

    if (err != MZ_OK && *signature != NULL)
    {
        MZ_FREE(*signature);
        *signature = NULL;
        *signature_size = 0;
    }

    return err;
}
开发者ID:mschmieder,项目名称:minizip,代码行数:90,代码来源:mz_crypt_openssl.c


示例19: main

int main(int argc, char **argv)
	{
	BIO *in = NULL, *out = NULL, *tbio = NULL, *cont = NULL;
	X509_STORE *st = NULL;
	X509 *cacert = NULL;
	CMS_ContentInfo *cms = NULL;

	int ret = 1;

	OpenSSL_add_all_algorithms();
	ERR_load_crypto_strings();

	/* Set up trusted CA certificate store */

	st = X509_STORE_new();

	/* Read in CA certificate */
	tbio = BIO_new_file("cacert.pem", "r");

	if (!tbio)
		goto err;

	cacert = PEM_read_bio_X509(tbio, NULL, 0, NULL);

	if (!cacert)
		goto err;

	if (!X509_STORE_add_cert(st, cacert))
		goto err;

	/* Open message being verified */

	in = BIO_new_file("smout.txt", "r");

	if (!in)
		goto err;

	/* parse message */
	cms = SMIME_read_CMS(in, &cont);

	if (!cms)
		goto err;

	/* File to output verified content to */
	out = BIO_new_file("smver.txt", "w");
	if (!out)
		goto err;

	if (!CMS_verify(cms, NULL, st, cont, out, 0))
		{
		fprintf(stderr, "Verification Failure\n");
		goto err;
		}

	fprintf(stderr, "Verification Successful\n");

	ret = 0;

	err:

	if (ret)
		{
		fprintf(stderr, "Error Verifying Data\n");
		ERR_print_errors_fp(stderr);
		}

	if (cms)
		CMS_ContentInfo_free(cms);

	if (cacert)
		X509_free(cacert);

	if (in)
		BIO_free(in);
	if (out)
		BIO_free(out);
	if (tbio)
		BIO_free(tbio);

	return ret;

	}
开发者ID:0culus,项目名称:openssl,代码行数:82,代码来源:cms_ver.c


示例20: main

int main(int argc, char **argv)
{
    BIO *in = NULL, *out = NULL, *tbio = NULL;
    X509 *scert = NULL;
    EVP_PKEY *skey = NULL;
    CMS_ContentInfo *cms = NULL;
    int ret = 1;

    /*
     * For simple S/MIME signing use CMS_DETACHED. On OpenSSL 1.0.0 only: for
     * streaming detached set CMS_DETACHED|CMS_STREAM for streaming
     * non-detached set CMS_STREAM
     */
    int flags = CMS_DETACHED | CMS_STREAM;

    OpenSSL_add_all_algorithms();
    ERR_load_crypto_strings();

    /* Read in signer certificate and private key */
    tbio = BIO_new_file("signer.pem", "r");

    if (!tbio)
        goto err;

    scert = PEM_read_bio_X509(tbio, NULL, 0, NULL);

    BIO_reset(tbio);

    skey = PEM_read_bio_PrivateKey(tbio, NULL, 0, NULL);

    if (!scert || !skey)
        goto err;

    /* Open content being signed */

    in = BIO_new_file("sign.txt", "r");

    if (!in)
        goto err;

    /* Sign content */
    cms = CMS_sign(scert, skey, NULL, in, flags);

    if (!cms)
        goto err;

    out = BIO_new_file("smout.txt", "w");
    if (!out)
        goto err;

    if (!(flags & CMS_STREAM))
        BIO_reset(in);

    /* Write out S/MIME message */
    if (!SMIME_write_CMS(out, cms, in, flags))
        goto err;

    ret = 0;

 err:

    if (ret) {
        fprintf(stderr, "Error Signing Data\n");
        ERR_print_errors_fp(stderr);
    }

    if (cms)
        CMS_ContentInfo_free(cms);
    if (scert)
        X509_free(scert);
    EVP_PKEY_free(skey);

    BIO_free(in);
    BIO_free(out);
    BIO_free(tbio);

    return ret;

}
开发者ID:Adallom,项目名称:openssl,代码行数:79,代码来源:cms_sign.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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