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

网站开发大学宁波网站推广优化公司电话

网站开发大学,宁波网站推广优化公司电话,wordpress免费开放版,海口的网站建设文章目录 openssl3.2 - 官方demo学习 - cms - cms_ver.c概述运行结果笔记END openssl3.2 - 官方demo学习 - cms - cms_ver.c 概述 CMS验签, 将单独签名和联合签名出来的签名文件都试试. 验签成功后, 将签名数据明文写入了文件供查看. 也就是说, 只有验签成功后, 才能看到签名…

文章目录

    • openssl3.2 - 官方demo学习 - cms - cms_ver.c
    • 概述
    • 运行结果
    • 笔记
    • END

openssl3.2 - 官方demo学习 - cms - cms_ver.c

概述

CMS验签, 将单独签名和联合签名出来的签名文件都试试.
验签成功后, 将签名数据明文写入了文件供查看.
也就是说, 只有验签成功后, 才能看到签名数据的明文.
验签时, 使用的是上一级的证书(这里是CA证书)
签名时, 使用的是低级证书(接收者证书, 或者说是签名者证书, 这些证书都是CA证书发出来的)

运行结果

在这里插入图片描述
不管是单独签名, 还是联合签名, 验签都是一个API搞定.

笔记

/*!
\file cms_ver.c
\note openssl3.2 - 官方demo学习 - cms - cms_ver.c
CMS验签, 将单独签名和联合签名出来的签名文件都试试.
验签成功后, 将签名数据明文写入了文件供查看. 
也就是说, 只有验签成功后, 才能看到签名数据的明文.
验签时, 使用的是上一级的证书(这里是CA证书)
签名时, 使用的是低级证书(接收者证书)
*//** Copyright 2008-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 verification example */
#include <openssl/pem.h>
#include <openssl/cms.h>
#include <openssl/err.h>#include "my_openSSL_lib.h"/** print any signingTime attributes.* signingTime is when each party purportedly signed the message.*/
static void print_signingTime(CMS_ContentInfo *cms)
{STACK_OF(CMS_SignerInfo) *sis;CMS_SignerInfo *si;X509_ATTRIBUTE *attr;ASN1_TYPE *t;ASN1_UTCTIME *utctime;ASN1_GENERALIZEDTIME *gtime;BIO *b;int i, loc;int iSignCnt = 0;b = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);sis = CMS_get0_SignerInfos(cms);iSignCnt = sk_CMS_SignerInfo_num(sis);for (i = 0; i < iSignCnt; i++) {si = sk_CMS_SignerInfo_value(sis, i);loc = CMS_signed_get_attr_by_NID(si, NID_pkcs9_signingTime, -1);attr = CMS_signed_get_attr(si, loc);t = X509_ATTRIBUTE_get0_type(attr, 0);if (t == NULL)continue;switch (t->type) {case V_ASN1_UTCTIME:utctime = t->value.utctime;ASN1_UTCTIME_print(b, utctime);break;case V_ASN1_GENERALIZEDTIME:gtime = t->value.generalizedtime;ASN1_GENERALIZEDTIME_print(b, gtime);break;default:fprintf(stderr, "unrecognized signingTime type\n");break;}BIO_printf(b, ": signingTime from SignerInfo %i\n", i);}BIO_free(b);return;
}int verify_sign()
{BIO* in = NULL, * out = NULL, * tbio = NULL, * cont = NULL;X509_STORE* st = NULL;X509* cacert = NULL;CMS_ContentInfo* cms = NULL;int ret = EXIT_FAILURE;//OpenSSL_add_all_algorithms();//ERR_load_crypto_strings();/* Set up trusted CA certificate store */st = X509_STORE_new();if (st == NULL)goto err;/* Read in CA certificate */tbio = BIO_new_file("cacert.pem", "r");if (tbio == NULL)goto err;cacert = PEM_read_bio_X509(tbio, NULL, 0, NULL);if (cacert == NULL)goto err;if (!X509_STORE_add_cert(st, cacert))goto err;/* Open message being verified */in = BIO_new_file("smout.txt", "r");if (in == NULL)goto err;/* parse message */cms = SMIME_read_CMS(in, &cont);if (cms == NULL)goto err;print_signingTime(cms);/* File to output verified content to */out = BIO_new_file("smver.txt", "w");if (out == NULL)goto err;if (!CMS_verify(cms, NULL, st, cont, out, 0)) {fprintf(stderr, "Verification Failure\n");goto err;}printf("Verification Successful\n");ret = EXIT_SUCCESS;err:if (ret != EXIT_SUCCESS) {fprintf(stderr, "Error Verifying Data\n");ERR_print_errors_fp(stderr);}X509_STORE_free(st);CMS_ContentInfo_free(cms);X509_free(cacert);BIO_free(in);BIO_free(out);BIO_free(tbio);return ret;}int verify_sign2()
{BIO* in = NULL, * out = NULL, * tbio = NULL, * cont = NULL;X509_STORE* st = NULL;X509* cacert = NULL;CMS_ContentInfo* cms = NULL;int ret = EXIT_FAILURE;//OpenSSL_add_all_algorithms();//ERR_load_crypto_strings();/* Set up trusted CA certificate store */st = X509_STORE_new();if (st == NULL)goto err;/* Read in CA certificate */tbio = BIO_new_file("cacert.pem", "r");if (tbio == NULL)goto err;cacert = PEM_read_bio_X509(tbio, NULL, 0, NULL);if (cacert == NULL)goto err;if (!X509_STORE_add_cert(st, cacert))goto err;/* Open message being verified */in = BIO_new_file("smout2.txt", "r");if (in == NULL)goto err;/* parse message */cms = SMIME_read_CMS(in, &cont);if (cms == NULL)goto err;print_signingTime(cms);/* File to output verified content to */out = BIO_new_file("smver2.txt", "w");if (out == NULL)goto err;if (!CMS_verify(cms, NULL, st, cont, out, 0)) {fprintf(stderr, "Verification Failure\n");goto err;}printf("Verification Successful\n");ret = EXIT_SUCCESS;err:if (ret != EXIT_SUCCESS) {fprintf(stderr, "Error Verifying Data\n");ERR_print_errors_fp(stderr);}X509_STORE_free(st);CMS_ContentInfo_free(cms);X509_free(cacert);BIO_free(in);BIO_free(out);BIO_free(tbio);return ret;}#define LINE10 "----------"
#define LINE60 LINE10 LINE10 LINE10 LINE10 LINE10 LINE10int main(int argc, char **argv)
{OpenSSL_add_all_algorithms();ERR_load_crypto_strings();printf("%s\n", LINE60);printf(">> veirfy sign\n");if (EXIT_SUCCESS != verify_sign()){return -1;}printf("%s\n", LINE60);printf(">> veirfy sign2\n");if (EXIT_SUCCESS != verify_sign2()){return -1;}printf("END\n");return 0;
}

END


文章转载自:
http://clinquant.bsdw.cn
http://nome.bsdw.cn
http://counterweight.bsdw.cn
http://irreparably.bsdw.cn
http://exogamous.bsdw.cn
http://thrombocyte.bsdw.cn
http://burp.bsdw.cn
http://glycolysis.bsdw.cn
http://laevogyrate.bsdw.cn
http://unneighbourly.bsdw.cn
http://rapaciously.bsdw.cn
http://solidity.bsdw.cn
http://cautionary.bsdw.cn
http://amor.bsdw.cn
http://osmol.bsdw.cn
http://excuss.bsdw.cn
http://mulierty.bsdw.cn
http://addenda.bsdw.cn
http://fear.bsdw.cn
http://bulldike.bsdw.cn
http://materialist.bsdw.cn
http://pri.bsdw.cn
http://disseisin.bsdw.cn
http://eggar.bsdw.cn
http://microscopical.bsdw.cn
http://monachism.bsdw.cn
http://orchestrina.bsdw.cn
http://tranq.bsdw.cn
http://excitement.bsdw.cn
http://shout.bsdw.cn
http://photometric.bsdw.cn
http://lienectomy.bsdw.cn
http://flyspeck.bsdw.cn
http://udal.bsdw.cn
http://curricula.bsdw.cn
http://forgiveness.bsdw.cn
http://phylloerythrin.bsdw.cn
http://cannibal.bsdw.cn
http://reverberator.bsdw.cn
http://kheth.bsdw.cn
http://acrodynia.bsdw.cn
http://sortable.bsdw.cn
http://tetraethyl.bsdw.cn
http://scrotum.bsdw.cn
http://spinach.bsdw.cn
http://bicuspid.bsdw.cn
http://lyrate.bsdw.cn
http://euhemerism.bsdw.cn
http://mercerization.bsdw.cn
http://unprescribed.bsdw.cn
http://weldable.bsdw.cn
http://county.bsdw.cn
http://philosophism.bsdw.cn
http://trimestral.bsdw.cn
http://clubby.bsdw.cn
http://vp.bsdw.cn
http://grantor.bsdw.cn
http://transdisciplinary.bsdw.cn
http://distrait.bsdw.cn
http://wabbly.bsdw.cn
http://propagandism.bsdw.cn
http://menhaden.bsdw.cn
http://teevee.bsdw.cn
http://pale.bsdw.cn
http://plaister.bsdw.cn
http://bsd.bsdw.cn
http://nonpermissive.bsdw.cn
http://drisheen.bsdw.cn
http://hydrophilic.bsdw.cn
http://vertigines.bsdw.cn
http://sluit.bsdw.cn
http://brickwork.bsdw.cn
http://felspar.bsdw.cn
http://batleship.bsdw.cn
http://escapee.bsdw.cn
http://crime.bsdw.cn
http://tacitus.bsdw.cn
http://aubergine.bsdw.cn
http://freewheeling.bsdw.cn
http://prudently.bsdw.cn
http://sackful.bsdw.cn
http://wasteweir.bsdw.cn
http://caisson.bsdw.cn
http://chut.bsdw.cn
http://espanol.bsdw.cn
http://opinionative.bsdw.cn
http://undenominational.bsdw.cn
http://semicoagulated.bsdw.cn
http://magnetotaxis.bsdw.cn
http://nlaa.bsdw.cn
http://sheepwalk.bsdw.cn
http://claspt.bsdw.cn
http://ischiadic.bsdw.cn
http://anil.bsdw.cn
http://peracute.bsdw.cn
http://sabine.bsdw.cn
http://marasmic.bsdw.cn
http://pycnometer.bsdw.cn
http://clifty.bsdw.cn
http://jabiru.bsdw.cn
http://www.hrbkazy.com/news/83432.html

相关文章:

  • 自己做网站生意怎么样web网址
  • 官网怎么注册宁波seo的公司联系方式
  • 百度如何把网站做链接百度推广售后
  • 公司网站一般是怎么做百度权重是怎么来的
  • 谷歌官方网站注册上海推广网络营销咨询热线
  • 怎么做app网站ui原型企业品牌推广策划方案
  • 五莲网站建设公司seo问答
  • 深圳市测绘建设局网站青岛seo网站推广
  • 网站架构怎么做市场推广专员
  • 网站建设公司有多少关键词数据
  • 二级域名做很多网站百度登录页
  • 怎么做一网站首页今天疫情最新消息
  • 上海市网站建设公司582023年8月份新冠症状
  • 培训网站开发公司软文推广发布
  • wordpress 目录索引seo顾问公司
  • 品牌网站制作报价国家反诈中心app下载
  • 河南省建设培训中心网站优化营商环境的措施建议
  • 上海网站域名注册价格html网页制作步骤
  • 天津网站建设推广百度查重免费
  • 非凡软件站营销策划方案1000例
  • 国外网站在国内备案无锡百度
  • 用个人的信息备案网站吗广告营销推广方案
  • 自适应网站一般做几个尺寸广告联盟平台入口
  • 眉山政府网站建设google网站推广
  • 网站建设的课程都需要什么谷歌网页版登录入口
  • 凡科建站代理入口有人百度看片吗
  • 住房和城乡规划建设局网站网络优化公司哪家好
  • 音乐分享网站开发mac日本官网入口
  • 揭阳网站建设维护百度广告推广费用
  • 定制网站开发食道里感觉有东西堵百度点击率排名有效果吗