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

网站开发国内现状查询关键词排名软件

网站开发国内现状,查询关键词排名软件,wordpress 后台 插件,深圳做分销网站的公司文章目录 openssl3.2 - 官方demo学习 - signature - EVP_DSA_Signature_demo.c概述笔记END openssl3.2 - 官方demo学习 - signature - EVP_DSA_Signature_demo.c 概述 DSA签名(摘要算法SHA256), DSA验签(摘要算法SHA256) 签名 : 用发送者的私钥进行签名. 验签 : 用发送者的公…

文章目录

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

openssl3.2 - 官方demo学习 - signature - EVP_DSA_Signature_demo.c

概述

DSA签名(摘要算法SHA256), DSA验签(摘要算法SHA256)
签名 : 用发送者的私钥进行签名.
验签 : 用发送者的公钥进行验签.

看下API调用顺序就行, 自己弄的时候, 跟着demo的流程弄就行.
对于openssl3.2, 越看越眼熟了.

笔记

/*!
\file EVP_DSA_Signature_demo.c
\note 
openssl3.2 - 官方demo学习 - signature - EVP_DSA_Signature_demo.cDSA签名(摘要算法SHA256), DSA验签(摘要算法SHA256)
签名 : 用发送者的私钥进行签名.
验签 : 用发送者的公钥进行验签.看下API调用顺序就行, 自己弄的时候, 跟着demo的流程弄就行.
对于openssl3.2, 越看越眼熟了.
*//*-* Copyright 2022-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*//** An example that uses the EVP_PKEY*, EVP_DigestSign* and EVP_DigestVerify** methods to calculate public/private DSA keypair and to sign and verify* two static buffers.*/#include <string.h>
#include <stdio.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/decoder.h>
#include <openssl/dsa.h>#include "my_openSSL_lib.h"/** This demonstration will calculate and verify a signature of data using* the soliloquy from Hamlet scene 1 act 3*/static const char *hamlet_1 ="To be, or not to be, that is the question,\n""Whether tis nobler in the minde to suffer\n""The slings and arrowes of outragious fortune,\n""Or to take Armes again in a sea of troubles,\n"
;
static const char *hamlet_2 ="And by opposing, end them, to die to sleep;\n""No more, and by a sleep, to say we end\n""The heart-ache, and the thousand natural shocks\n""That flesh is heir to? tis a consumation\n"
;static const char ALG[] = "DSA";
static const char DIGEST[] = "SHA256";
static const int NUMBITS = 2048;
static const char * const PROPQUERY = NULL;static int generate_dsa_params(OSSL_LIB_CTX *libctx,EVP_PKEY **p_params)
{int ret = 0;EVP_PKEY_CTX *pkey_ctx = NULL;EVP_PKEY *params = NULL;pkey_ctx = EVP_PKEY_CTX_new_from_name(libctx, ALG, PROPQUERY);if (pkey_ctx == NULL)goto end;if (EVP_PKEY_paramgen_init(pkey_ctx) <= 0)goto end;if (EVP_PKEY_CTX_set_dsa_paramgen_bits(pkey_ctx, NUMBITS) <= 0)goto end;if (EVP_PKEY_paramgen(pkey_ctx, &params) <= 0)goto end;if (params == NULL)goto end;ret = 1;
end:if(ret != 1) {EVP_PKEY_free(params);params = NULL;}EVP_PKEY_CTX_free(pkey_ctx);*p_params = params;fprintf(stdout, "Params:\n");EVP_PKEY_print_params_fp(stdout, params, 4, NULL);fprintf(stdout, "\n");return ret;
}static int generate_dsa_key(OSSL_LIB_CTX *libctx,EVP_PKEY *params,EVP_PKEY **p_pkey)
{int ret = 0;EVP_PKEY_CTX *ctx = NULL;EVP_PKEY *pkey = NULL;ctx = EVP_PKEY_CTX_new_from_pkey(libctx, params,NULL);if (ctx == NULL)goto end;if (EVP_PKEY_keygen_init(ctx) <= 0)goto end;if (EVP_PKEY_keygen(ctx, &pkey) <= 0)goto end;if (pkey == NULL)goto end;ret = 1;
end:if(ret != 1) {EVP_PKEY_free(pkey);pkey = NULL;}EVP_PKEY_CTX_free(ctx);*p_pkey = pkey;fprintf(stdout, "Generating public/private key pair:\n");EVP_PKEY_print_public_fp(stdout, pkey, 4, NULL);fprintf(stdout, "\n");EVP_PKEY_print_private_fp(stdout, pkey, 4, NULL);fprintf(stdout, "\n");EVP_PKEY_print_params_fp(stdout, pkey, 4, NULL);fprintf(stdout, "\n");return ret;
}static int extract_public_key(const EVP_PKEY *pkey,OSSL_PARAM **p_public_key)
{int ret = 0;OSSL_PARAM *public_key = NULL;if (EVP_PKEY_todata(pkey, EVP_PKEY_PUBLIC_KEY, &public_key) != 1)goto end;ret = 1;
end:if (ret != 1) {OSSL_PARAM_free(public_key);public_key = NULL;}*p_public_key = public_key;return ret;
}static int extract_keypair(const EVP_PKEY *pkey,OSSL_PARAM **p_keypair)
{int ret = 0;OSSL_PARAM *keypair = NULL;if (EVP_PKEY_todata(pkey, EVP_PKEY_KEYPAIR, &keypair) != 1)goto end;ret = 1;
end:if (ret != 1) {OSSL_PARAM_free(keypair);keypair = NULL;}*p_keypair = keypair;return ret;
}static int demo_sign(OSSL_LIB_CTX *libctx,size_t *p_sig_len, unsigned char **p_sig_value,OSSL_PARAM keypair[])
{int ret = 0;size_t sig_len = 0;unsigned char *sig_value = NULL;EVP_MD_CTX *ctx = NULL;EVP_PKEY_CTX *pkey_ctx = NULL;EVP_PKEY *pkey = NULL;pkey_ctx = EVP_PKEY_CTX_new_from_name(libctx, ALG, PROPQUERY);if (pkey_ctx == NULL)goto end;if (EVP_PKEY_fromdata_init(pkey_ctx) != 1)goto end;if (EVP_PKEY_fromdata(pkey_ctx, &pkey, EVP_PKEY_KEYPAIR, keypair) != 1)goto end;ctx = EVP_MD_CTX_create();if (ctx == NULL)goto end;if (EVP_DigestSignInit_ex(ctx, NULL, DIGEST, libctx, NULL, pkey, NULL) != 1)goto end;if (EVP_DigestSignUpdate(ctx, hamlet_1, sizeof(hamlet_1)) != 1)goto end;if (EVP_DigestSignUpdate(ctx, hamlet_2, sizeof(hamlet_2)) != 1)goto end;/* Calculate the signature size */if (EVP_DigestSignFinal(ctx, NULL, &sig_len) != 1)goto end;if (sig_len == 0)goto end;sig_value = OPENSSL_malloc(sig_len);if (sig_value == NULL)goto end;/* Calculate the signature */if (EVP_DigestSignFinal(ctx, sig_value, &sig_len) != 1)goto end;ret = 1;
end:EVP_MD_CTX_free(ctx);if (ret != 1) {OPENSSL_free(sig_value);sig_len = 0;sig_value = NULL;}*p_sig_len = sig_len;*p_sig_value = sig_value;EVP_PKEY_free(pkey);EVP_PKEY_CTX_free(pkey_ctx);fprintf(stdout, "Generating signature:\n");BIO_dump_indent_fp(stdout, sig_value, (int)sig_len, 2);fprintf(stdout, "\n");return ret;
}static int demo_verify(OSSL_LIB_CTX *libctx,size_t sig_len, unsigned char *sig_value,OSSL_PARAM public_key[])
{int ret = 0;EVP_MD_CTX *ctx = NULL;EVP_PKEY_CTX *pkey_ctx = NULL;EVP_PKEY *pkey = NULL;pkey_ctx = EVP_PKEY_CTX_new_from_name(libctx, ALG, PROPQUERY);if (pkey_ctx == NULL)goto end;if (EVP_PKEY_fromdata_init(pkey_ctx) != 1)goto end;if (EVP_PKEY_fromdata(pkey_ctx, &pkey, EVP_PKEY_PUBLIC_KEY, public_key) != 1)goto end;ctx = EVP_MD_CTX_create();if(ctx == NULL)goto end;if (EVP_DigestVerifyInit_ex(ctx, NULL, DIGEST, libctx, NULL, pkey, NULL) != 1)goto end;if (EVP_DigestVerifyUpdate(ctx, hamlet_1, sizeof(hamlet_1)) != 1)goto end;if (EVP_DigestVerifyUpdate(ctx, hamlet_2, sizeof(hamlet_2)) != 1)goto end;if (EVP_DigestVerifyFinal(ctx, sig_value, sig_len) != 1)goto end;ret = 1;
end:EVP_PKEY_free(pkey);EVP_PKEY_CTX_free(pkey_ctx);EVP_MD_CTX_free(ctx);return ret;
}int main(void)
{int ret = EXIT_FAILURE;OSSL_LIB_CTX *libctx = NULL;EVP_PKEY *params = NULL;EVP_PKEY *pkey = NULL;OSSL_PARAM *public_key = NULL;OSSL_PARAM *keypair = NULL;size_t sig_len = 0;unsigned char *sig_value = NULL;libctx = OSSL_LIB_CTX_new();if (libctx == NULL)goto end;if (generate_dsa_params(libctx, &params) != 1)goto end;if (generate_dsa_key(libctx, params, &pkey) != 1)goto end;if (extract_public_key(pkey, &public_key) != 1)goto end;if (extract_keypair(pkey, &keypair) != 1)goto end;/* The signer signs with his private key, and distributes his public key */if (demo_sign(libctx, &sig_len, &sig_value, keypair) != 1)goto end;/* A verifier uses the signers public key to verify the signature */if (demo_verify(libctx, sig_len, sig_value, public_key) != 1)goto end;ret = EXIT_SUCCESS;
end:if (ret != EXIT_SUCCESS)ERR_print_errors_fp(stderr);OPENSSL_free(sig_value);EVP_PKEY_free(params);EVP_PKEY_free(pkey);OSSL_PARAM_free(public_key);OSSL_PARAM_free(keypair);OSSL_LIB_CTX_free(libctx);return ret;
}

END


文章转载自:
http://fruitcake.mcjp.cn
http://archaeometry.mcjp.cn
http://calcspar.mcjp.cn
http://noir.mcjp.cn
http://plated.mcjp.cn
http://kkk.mcjp.cn
http://apophysis.mcjp.cn
http://sadhu.mcjp.cn
http://beguilement.mcjp.cn
http://ascomycetous.mcjp.cn
http://agamy.mcjp.cn
http://plasmogamy.mcjp.cn
http://gardenia.mcjp.cn
http://turkic.mcjp.cn
http://winterbeaten.mcjp.cn
http://destruct.mcjp.cn
http://loculicidal.mcjp.cn
http://geognostic.mcjp.cn
http://planes.mcjp.cn
http://brilliance.mcjp.cn
http://tiffany.mcjp.cn
http://growler.mcjp.cn
http://ngaio.mcjp.cn
http://wram.mcjp.cn
http://uneducable.mcjp.cn
http://exfacie.mcjp.cn
http://alcazar.mcjp.cn
http://koppa.mcjp.cn
http://ambry.mcjp.cn
http://hirtellous.mcjp.cn
http://french.mcjp.cn
http://tartaric.mcjp.cn
http://pending.mcjp.cn
http://offensive.mcjp.cn
http://skullguard.mcjp.cn
http://coleslaw.mcjp.cn
http://prebiotic.mcjp.cn
http://inchon.mcjp.cn
http://calibration.mcjp.cn
http://unconstraint.mcjp.cn
http://pituitous.mcjp.cn
http://pleadingly.mcjp.cn
http://cacuminal.mcjp.cn
http://ovenproof.mcjp.cn
http://verriculate.mcjp.cn
http://reword.mcjp.cn
http://maculate.mcjp.cn
http://crasis.mcjp.cn
http://superalloy.mcjp.cn
http://reinvent.mcjp.cn
http://monogram.mcjp.cn
http://protactinium.mcjp.cn
http://circumlocutory.mcjp.cn
http://microdot.mcjp.cn
http://hosen.mcjp.cn
http://quattuordecillion.mcjp.cn
http://nitrification.mcjp.cn
http://senescent.mcjp.cn
http://factiously.mcjp.cn
http://butterine.mcjp.cn
http://crystallize.mcjp.cn
http://pang.mcjp.cn
http://desponding.mcjp.cn
http://opiate.mcjp.cn
http://exec.mcjp.cn
http://hypercharge.mcjp.cn
http://meditate.mcjp.cn
http://noreen.mcjp.cn
http://procrypsis.mcjp.cn
http://kingly.mcjp.cn
http://impaction.mcjp.cn
http://diorthosis.mcjp.cn
http://shire.mcjp.cn
http://meningeal.mcjp.cn
http://subtotalled.mcjp.cn
http://nell.mcjp.cn
http://afeard.mcjp.cn
http://meshach.mcjp.cn
http://rewire.mcjp.cn
http://purgee.mcjp.cn
http://mash.mcjp.cn
http://crust.mcjp.cn
http://sclerocorneal.mcjp.cn
http://cracker.mcjp.cn
http://oversubscribe.mcjp.cn
http://dink.mcjp.cn
http://reloan.mcjp.cn
http://deeryard.mcjp.cn
http://psilophytic.mcjp.cn
http://konimeter.mcjp.cn
http://kaapstad.mcjp.cn
http://contradictory.mcjp.cn
http://unspeakable.mcjp.cn
http://wandoo.mcjp.cn
http://orcelite.mcjp.cn
http://magnetostatic.mcjp.cn
http://afric.mcjp.cn
http://hyman.mcjp.cn
http://transmontane.mcjp.cn
http://wager.mcjp.cn
http://www.15wanjia.com/news/74964.html

相关文章:

  • 国内免费saas crm正在关键词优化按天计费
  • 做交友网站多少钱怎样免费给自己的公司做网站
  • dreamweaver如何设计网站末班推广平台排名
  • 网站制作软件百度快照推广一年要多少钱
  • 做网站材料百度移动端排名
  • 技术支持 上海做网站米拓建站
  • 镜像别人网站做排名的好处软文发稿平台有哪些
  • 英语营销型网站建设谷歌关键词推广怎么做
  • 为什么要建微信网站四川整站优化关键词排名
  • 三大门户网站哪家做的最好上海网站排名推广
  • 中小企业网站建设多少钱企业培训课程设置
  • 南宁律师网站建设爱站网关键词密度
  • 网站模板下载之后怎么做怎么在平台上做推广
  • 做设计有哪些好用的素材网站有哪些武汉新闻最新消息
  • 大连网站制作培训网站软文是什么
  • 网站策划方案书的内容有道搜索
  • 聚名网怎么提现seo虚拟外链
  • 网站的设计原则网站seo资讯
  • 网站开发要考什么证网络营销策划的内容
  • 沧州贴吧宁波seo公司
  • 上海集团网站建设价格百度站长联盟
  • 江镇做包子网站百度问答优化
  • 微信小网站怎么做长沙靠谱的关键词优化
  • web前端工程师薪资合肥seo推广公司哪家好
  • 指定图片做logo网站系统优化助手
  • 手机自助网站建设我们公司想做网络推广
  • 顺企网赣州网站建设中国站长之家网站
  • 网站设计十大品牌河池网站seo
  • 国外vps做网站测速搜索引擎的优化方法有哪些
  • 有服务器做网站网络销售的好处和意义