当前位置: 首页 > news >正文

光速东莞网站建设上海网站推广排名公司

光速东莞网站建设,上海网站推广排名公司,服务器卸载wordpress,辽宁网站建设公司电话文章目录 openssl3.2 - 官方demo学习 - smime - smenc.c概述笔记END openssl3.2 - 官方demo学习 - smime - smenc.c 概述 读取X509证书, 用PKCS7加密明文(证书 明文 3DES_CBC), 保存为MIME格式的密文 openssl API的命名含义 BIO_new_file “new” a “file”, return a “…

文章目录

    • openssl3.2 - 官方demo学习 - smime - smenc.c
    • 概述
    • 笔记
    • END

openssl3.2 - 官方demo学习 - smime - smenc.c

概述

读取X509证书, 用PKCS7加密明文(证书 + 明文 + 3DES_CBC), 保存为MIME格式的密文

openssl API的命名含义

BIO_new_file
“new” a “file”, return a “BIO” object

PEM_read_bio_X509() Read a certificate in PEM format from a BIO
data format is “PEM”, “read” from “bio”, return a object type is “X509”

笔记

/*!
\file smenc.c
\note
openssl3.2 - 官方demo学习 - smime - smenc.c
读取X509证书, 用PKCS7加密明文(证书 + 明文 + 3DES_CBC), 保存为MIME格式的密文openssl API的命名含义BIO_new_file
"new" a "file", return a "BIO" objectPEM_read_bio_X509() Read a certificate in PEM format from a BIO
data format is "PEM", "read" from "bio", return a object type is "X509"
*//** Copyright 2007-2023 The OpenSSL Project Authors. All Rights Reserved.** Licensed under the Apache License 2.0 (the "License").  You may not use* this file except in compliance with the License.  You can obtain a copy* in the file LICENSE in the source distribution or at* https://www.openssl.org/source/license.html*//* Simple S/MIME encrypt example */
#include <openssl/pem.h>
#include <openssl/pkcs7.h>
#include <openssl/err.h>#include "my_openSSL_lib.h"int main(int argc, char** argv)
{BIO* _bio_in = NULL, * _bio_out = NULL, * _bio_t = NULL;X509* _x509_r = NULL;STACK_OF(X509)* _sk_x509 = NULL;PKCS7* _pkcs7 = NULL;int ret = EXIT_FAILURE;/** On OpenSSL 0.9.9 only:* for streaming set PKCS7_STREAM*/int flags_encrypt = PKCS7_STREAM;OpenSSL_add_all_algorithms();ERR_load_crypto_strings();/* Read in recipient certificate */_bio_t = BIO_new_file("signer.pem", "r");if (!_bio_t)goto err;_x509_r = PEM_read_bio_X509(_bio_t, NULL, 0, NULL);if (!_x509_r)goto err;/* Create recipient STACK and add recipient cert to it */_sk_x509 = sk_X509_new_null();if (!_sk_x509 || !sk_X509_push(_sk_x509, _x509_r))goto err;/** OSSL_STACK_OF_X509_free() will free up recipient STACK and its contents* so set rcert to NULL so it isn't freed up twice.*/_x509_r = NULL;/* Open content being encrypted */_bio_in = BIO_new_file("encr.txt", "r");if (!_bio_in)goto err;/* encrypt content */_pkcs7 = PKCS7_encrypt(_sk_x509, _bio_in, EVP_des_ede3_cbc(), flags_encrypt);if (!_pkcs7)goto err;_bio_out = BIO_new_file("smencr.txt", "w");if (!_bio_out)goto err;/* Write out S/MIME message */if (!SMIME_write_PKCS7(_bio_out, _pkcs7, _bio_in, flags_encrypt))goto err;ret = EXIT_SUCCESS;err:if (ret != EXIT_SUCCESS) {fprintf(stderr, "Error Encrypting Data\n");ERR_print_errors_fp(stderr);}PKCS7_free(_pkcs7);X509_free(_x509_r);OSSL_STACK_OF_X509_free(_sk_x509);BIO_free(_bio_in);BIO_free(_bio_out);BIO_free(_bio_t);return ret;}

END

http://www.fp688.cn/news/146440.html

相关文章:

  • 制作网站需要注意什么中国网络优化公司排名
  • 企业官网的运营模式广东培训seo
  • 郑州做网站齿轮百度搜索关键词统计
  • 花店网站建设目的百度竞价排名点击软件
  • 怎么搭建一个视频网站百度推广怎么收费
  • 淘客怎么做推广网站百度收录的网站多久更新一次
  • 洛克设计平台seo属于技术还是营销
  • 网站实名网络推广专员
  • 南充 网站开发站长工具视频
  • 做阿里巴巴企业网站百度数据中心
  • 宿迁华夏建设集团网站邯郸seo优化公司
  • 自己做网站多少钱怎么自己做网站
  • wordpress 邮件 gmail引擎优化搜索
  • 网站左侧分类导航菜单十大互联网平台
  • 鲜花电子商务网站建设规划书新泰网站seo
  • 个人博客网站源码百度app下载安装普通下载
  • 女生做交互设计师好吗网站性能优化方法
  • 域名注册后怎么建设网站郑州seo竞价
  • 注册功能网站建设怀来网站seo
  • 检验是否安装wordpressseo整站优化多少钱
  • 广东微信网站制作价格软文案例大全
  • 广州天河建网站专业提升关键词排名工具
  • 港澳做愛网站百度学术搜索
  • 市政府网站建设建议网络营销教案ppt
  • 做文创的网站引流推广平台有哪些
  • 网站定制开发内容电商平台开发需要多少钱
  • 可以发锚文本的网站苏州seo网站系统
  • 网站由什么组成百度搜索引擎的网址是多少
  • 专做品牌的网站seo全网优化指南
  • 论坛网站建设模板seo教程自学