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

网站开发项目需要哪些人员策划师什么是百度竞价推广

网站开发项目需要哪些人员策划师,什么是百度竞价推广,辽宁网站优化,广州开发区控股集团有限公司文章目录 openssl3.2 - 官方demo学习 - pkey - EVP_PKEY_RSA_keygen.c概述笔记END openssl3.2 - 官方demo学习 - pkey - EVP_PKEY_RSA_keygen.c 概述 官方指出 : RSA key 如果小于2048位, 就属于弱key 官方demo中, 给出的默认key长度为4096位 从名字生成上下文 初始化上下文…

文章目录

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

openssl3.2 - 官方demo学习 - pkey - EVP_PKEY_RSA_keygen.c

概述

官方指出 : RSA key 如果小于2048位, 就属于弱key
官方demo中, 给出的默认key长度为4096位

从名字生成上下文
初始化上下文
设置上下的key位数
设置质数数量为2
产生RSA Key. (在我的本本上, 单步调试时, 感觉产生 RSA key时, 卡了一下, 大概不到1秒钟)
打印rsa key内容(可以得到 n, e, d, p, q, key的位数, 公钥, 私钥)
PEM_write_x时, 如果文件句柄是具体的文件, 就是将公钥/密钥保存成了PEM文件.

笔记

/*!
\file EVP_PKEY_RSA_keygen.c
\note
openssl3.2 - 官方demo学习 - pkey - EVP_PKEY_RSA_keygen.c官方指出 : RSA key 如果小于2048位, 就属于弱key
官方demo中, 给出的默认key长度为4096位从名字生成上下文
初始化上下文
设置上下的key位数
设置质数数量为2
产生RSA Key. (在我的本本上, 单步调试时, 感觉产生 RSA key时, 卡了一下, 大概不到1秒钟)
打印rsa key内容(可以得到 n, e, d, p, q, key的位数, 公钥, 私钥)
PEM_write_x时, 如果文件句柄是具体的文件, 就是将公钥/密钥保存成了PEM文件.
*//*-* 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*//** Example showing how to generate an RSA key pair.** When generating an RSA key, you must specify the number of bits in the key. A* reasonable value would be 4096. Avoid using values below 2048. These values* are reasonable as of 2022.*/#include <string.h>
#include <stdio.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/rsa.h>
#include <openssl/core_names.h>
#include <openssl/pem.h>#include "my_openSSL_lib.h"/* A property query used for selecting algorithm implementations. */
static const char* propq = NULL;/** Generates an RSA public-private key pair and returns it.* The number of bits is specified by the bits argument.** This uses the long way of generating an RSA key.*/
static EVP_PKEY* generate_rsa_key_long(OSSL_LIB_CTX* libctx, unsigned int bits)
{EVP_PKEY_CTX* genctx = NULL;EVP_PKEY* pkey = NULL;unsigned int primes = 2;/* Create context using RSA algorithm. "RSA-PSS" could also be used here. */genctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA", propq);if (genctx == NULL) {fprintf(stderr, "EVP_PKEY_CTX_new_from_name() failed\n");goto cleanup;}/* Initialize context for key generation purposes. */if (EVP_PKEY_keygen_init(genctx) <= 0) {fprintf(stderr, "EVP_PKEY_keygen_init() failed\n");goto cleanup;}/** Here we set the number of bits to use in the RSA key.* See comment at top of file for information on appropriate values.*/if (EVP_PKEY_CTX_set_rsa_keygen_bits(genctx, bits) <= 0) {fprintf(stderr, "EVP_PKEY_CTX_set_rsa_keygen_bits() failed\n");goto cleanup;}/** It is possible to create an RSA key using more than two primes.* Do not do this unless you know why you need this.* You ordinarily do not need to specify this, as the default is two.** Both of these parameters can also be set via EVP_PKEY_CTX_set_params, but* these functions provide a more concise way to do so.*/if (EVP_PKEY_CTX_set_rsa_keygen_primes(genctx, primes) <= 0) {fprintf(stderr, "EVP_PKEY_CTX_set_rsa_keygen_primes() failed\n");goto cleanup;}/** Generating an RSA key with a number of bits large enough to be secure for* modern applications can take a fairly substantial amount of time (e.g.* one second). If you require fast key generation, consider using an EC key* instead.** If you require progress information during the key generation process,* you can set a progress callback using EVP_PKEY_set_cb; see the example in* EVP_PKEY_generate(3).*/fprintf(stderr, "Generating RSA key, this may take some time...\n");if (EVP_PKEY_generate(genctx, &pkey) <= 0) {fprintf(stderr, "EVP_PKEY_generate() failed\n");goto cleanup;}/* pkey is now set to an object representing the generated key pair. */cleanup:EVP_PKEY_CTX_free(genctx);return pkey;
}/** Generates an RSA public-private key pair and returns it.* The number of bits is specified by the bits argument.** This uses a more concise way of generating an RSA key, which is suitable for* simple cases. It is used if -s is passed on the command line, otherwise the* long method above is used. The ability to choose between these two methods is* shown here only for demonstration; the results are equivalent.*/
static EVP_PKEY* generate_rsa_key_short(OSSL_LIB_CTX* libctx, unsigned int bits)
{EVP_PKEY* pkey = NULL;fprintf(stderr, "Generating RSA key, this may take some time...\n");pkey = EVP_PKEY_Q_keygen(libctx, propq, "RSA", (size_t)bits);if (pkey == NULL)fprintf(stderr, "EVP_PKEY_Q_keygen() failed\n");return pkey;
}/** Prints information on an EVP_PKEY object representing an RSA key pair.*/
static int dump_key(const EVP_PKEY* pkey)
{int ret = 0;int bits = 0;BIGNUM* n = NULL, * e = NULL, * d = NULL, * p = NULL, * q = NULL;/** Retrieve value of n. This value is not secret and forms part of the* public key.** Calling EVP_PKEY_get_bn_param with a NULL BIGNUM pointer causes* a new BIGNUM to be allocated, so these must be freed subsequently.*/if (EVP_PKEY_get_bn_param(pkey, OSSL_PKEY_PARAM_RSA_N, &n) == 0) {fprintf(stderr, "Failed to retrieve n\n");goto cleanup;}/** Retrieve value of e. This value is not secret and forms part of the* public key. It is typically 65537 and need not be changed.*/if (EVP_PKEY_get_bn_param(pkey, OSSL_PKEY_PARAM_RSA_E, &e) == 0) {fprintf(stderr, "Failed to retrieve e\n");goto cleanup;}/** Retrieve value of d. This value is secret and forms part of the private* key. It must not be published.*/if (EVP_PKEY_get_bn_param(pkey, OSSL_PKEY_PARAM_RSA_D, &d) == 0) {fprintf(stderr, "Failed to retrieve d\n");goto cleanup;}/** Retrieve value of the first prime factor, commonly known as p. This value* is secret and forms part of the private key. It must not be published.*/if (EVP_PKEY_get_bn_param(pkey, OSSL_PKEY_PARAM_RSA_FACTOR1, &p) == 0) {fprintf(stderr, "Failed to retrieve p\n");goto cleanup;}/** Retrieve value of the second prime factor, commonly known as q. This value* is secret and forms part of the private key. It must not be published.** If you are creating an RSA key with more than two primes for special* applications, you can retrieve these primes with* OSSL_PKEY_PARAM_RSA_FACTOR3, etc.*/if (EVP_PKEY_get_bn_param(pkey, OSSL_PKEY_PARAM_RSA_FACTOR2, &q) == 0) {fprintf(stderr, "Failed to retrieve q\n");goto cleanup;}/** We can also retrieve the key size in bits for informational purposes.*/if (EVP_PKEY_get_int_param(pkey, OSSL_PKEY_PARAM_BITS, &bits) == 0) {fprintf(stderr, "Failed to retrieve bits\n");goto cleanup;}/* Output hexadecimal representations of the BIGNUM objects. */fprintf(stdout, "\nNumber of bits: %d\n\n", bits);fprintf(stderr, "Public values:\n");fprintf(stdout, "  n = 0x");BN_print_fp(stdout, n);fprintf(stdout, "\n");fprintf(stdout, "  e = 0x");BN_print_fp(stdout, e);fprintf(stdout, "\n\n");fprintf(stdout, "Private values:\n");fprintf(stdout, "  d = 0x");BN_print_fp(stdout, d);fprintf(stdout, "\n");fprintf(stdout, "  p = 0x");BN_print_fp(stdout, p);fprintf(stdout, "\n");fprintf(stdout, "  q = 0x");BN_print_fp(stdout, q);fprintf(stdout, "\n\n");/* Output a PEM encoding of the public key. */if (PEM_write_PUBKEY(stdout, pkey) == 0) {fprintf(stderr, "Failed to output PEM-encoded public key\n");goto cleanup;}/** Output a PEM encoding of the private key. Please note that this output is* not encrypted. You may wish to use the arguments to specify encryption of* the key if you are storing it on disk. See PEM_write_PrivateKey(3).*/if (PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, NULL) == 0) {fprintf(stderr, "Failed to output PEM-encoded private key\n");goto cleanup;}ret = 1;
cleanup:BN_free(n); /* not secret */BN_free(e); /* not secret */BN_clear_free(d); /* secret - scrub before freeing */BN_clear_free(p); /* secret - scrub before freeing */BN_clear_free(q); /* secret - scrub before freeing */return ret;
}int main(int argc, char** argv)
{int ret = EXIT_FAILURE;OSSL_LIB_CTX* libctx = NULL;EVP_PKEY* pkey = NULL;unsigned int bits = 4096;int bits_i, use_short = 0;/* usage: [-s] [<bits>] */if (argc > 1 && strcmp(argv[1], "-s") == 0) {--argc;++argv;use_short = 1;}if (argc > 1) {bits_i = atoi(argv[1]);if (bits < 512) {fprintf(stderr, "Invalid RSA key size\n");return EXIT_FAILURE;}bits = (unsigned int)bits_i;}/* Avoid using key sizes less than 2048 bits; see comment at top of file. */if (bits < 2048)fprintf(stderr, "Warning: very weak key size\n\n");/* Generate RSA key. */if (use_short)pkey = generate_rsa_key_short(libctx, bits);elsepkey = generate_rsa_key_long(libctx, bits);if (pkey == NULL)goto cleanup;/* Dump the integers comprising the key. */if (dump_key(pkey) == 0) {fprintf(stderr, "Failed to dump key\n");goto cleanup;}ret = EXIT_SUCCESS;
cleanup:EVP_PKEY_free(pkey);OSSL_LIB_CTX_free(libctx);return ret;
}

END


文章转载自:
http://dinncoshaking.tpps.cn
http://dinncofrey.tpps.cn
http://dinncosnye.tpps.cn
http://dinncogermanization.tpps.cn
http://dinncomalapropos.tpps.cn
http://dinncoautodial.tpps.cn
http://dinncobenefactress.tpps.cn
http://dinncoschematism.tpps.cn
http://dinncohest.tpps.cn
http://dinncoannette.tpps.cn
http://dinncoaccrue.tpps.cn
http://dinncoraphia.tpps.cn
http://dinncohygrograph.tpps.cn
http://dinncotablet.tpps.cn
http://dinncoudo.tpps.cn
http://dinncodhl.tpps.cn
http://dinncoplainstones.tpps.cn
http://dinncoburhel.tpps.cn
http://dinncoironmould.tpps.cn
http://dinncoepically.tpps.cn
http://dinncocpo.tpps.cn
http://dinncodopy.tpps.cn
http://dinncopharmacologist.tpps.cn
http://dinncofurrow.tpps.cn
http://dinncokiang.tpps.cn
http://dinncotableland.tpps.cn
http://dinncocorfam.tpps.cn
http://dinncounconfident.tpps.cn
http://dinncocolumniation.tpps.cn
http://dinncorulable.tpps.cn
http://dinncodisambiguition.tpps.cn
http://dinncoscorebook.tpps.cn
http://dinncoextensile.tpps.cn
http://dinncoconvincingly.tpps.cn
http://dinncoseesaw.tpps.cn
http://dinncohaematocele.tpps.cn
http://dinncomemcon.tpps.cn
http://dinncoweaponshaw.tpps.cn
http://dinncopickeer.tpps.cn
http://dinncoquicksanded.tpps.cn
http://dinncoimprecate.tpps.cn
http://dinncosized.tpps.cn
http://dinncoalme.tpps.cn
http://dinncoof.tpps.cn
http://dinncoenrichment.tpps.cn
http://dinncocrowhop.tpps.cn
http://dinncomoonstruck.tpps.cn
http://dinncoduotone.tpps.cn
http://dinncopaymaster.tpps.cn
http://dinncojn.tpps.cn
http://dinncodcvo.tpps.cn
http://dinncotenurable.tpps.cn
http://dinncotambourine.tpps.cn
http://dinncomonarch.tpps.cn
http://dinncoworkwoman.tpps.cn
http://dinncocriticize.tpps.cn
http://dinncodishonorable.tpps.cn
http://dinnconeurologist.tpps.cn
http://dinncodistrainment.tpps.cn
http://dinnconucleon.tpps.cn
http://dinncopato.tpps.cn
http://dinncomutinous.tpps.cn
http://dinncocoprophilous.tpps.cn
http://dinncoladdish.tpps.cn
http://dinncodistribute.tpps.cn
http://dinncounbridle.tpps.cn
http://dinncoirreproachably.tpps.cn
http://dinncosenatorial.tpps.cn
http://dinncofairily.tpps.cn
http://dinncoselfless.tpps.cn
http://dinncomicroporosity.tpps.cn
http://dinncoramal.tpps.cn
http://dinncoanticathode.tpps.cn
http://dinncodimer.tpps.cn
http://dinncopiddling.tpps.cn
http://dinncotectrix.tpps.cn
http://dinncoagaric.tpps.cn
http://dinncorhinopharyngeal.tpps.cn
http://dinncotonsure.tpps.cn
http://dinncotif.tpps.cn
http://dinncoexornation.tpps.cn
http://dinncohonourable.tpps.cn
http://dinncohypnograph.tpps.cn
http://dinncosalaried.tpps.cn
http://dinncovermination.tpps.cn
http://dinncoreddest.tpps.cn
http://dinncofishhook.tpps.cn
http://dinncoovertalk.tpps.cn
http://dinncorident.tpps.cn
http://dinncolaodicea.tpps.cn
http://dinncopau.tpps.cn
http://dinncooperette.tpps.cn
http://dinncovillein.tpps.cn
http://dinncoalameda.tpps.cn
http://dinncomohism.tpps.cn
http://dinncoaruba.tpps.cn
http://dinncospecies.tpps.cn
http://dinncotroll.tpps.cn
http://dinncomagnetobiology.tpps.cn
http://dinncoleucoplast.tpps.cn
http://www.dinnco.com/news/3048.html

相关文章:

  • 团购做的比较好的网站seo人工智能
  • 三门峡网站设计seo顾问培训
  • 可以在哪些网站 APP做推广武汉网站开发公司
  • 做兼职那个网站比较靠谱平台seo
  • 用php做一网站有哪些百度 营销怎么收费
  • 德州做网站dzqifan经典的软文广告
  • 威海做网站今日热点新闻事件2021
  • 美团网站制作的特色百度指数的使用
  • 北京假山设计制作天津百度快速排名优化
  • 淘宝联盟怎么建网站湖南网站建设推荐
  • 建设银行网站怎样查询贷款信息吗百度学术论文查重
  • 郑州加盟做网站项目宣传推广方案
  • 个人空间网站建设广告投放平台公司
  • 郑州商城网站制作seo站内优化
  • 企业网站推广文案优化seo教程技术
  • 营销一型网站建设公司百度人工服务24小时
  • 网站建设公司fjfzwl好用的搜索引擎有哪些
  • 泰州市城市建设网站seoul是什么国家
  • 岐山县住房和城市建设局网站如何设计企业网站
  • 佛山专业外贸网站建设百度seo怎么把关键词优化上去
  • 宁夏建设工程质量监督站网站成都疫情最新消息
  • 备案域名购买完过户简单吗咸宁网站seo
  • 优化网站找哪家百度seo刷排名网址
  • 网站模板做网站乐陵seo外包
  • 网站制作出租软件开发培训机构去哪个学校
  • 模板网站购买沈阳网站制作
  • wordpress国内主机推荐抖音seo排名
  • 怎样做生成的二维码链接到网站西安seo排名
  • 专业网站设计方案公司杭州seo网站建设靠谱
  • 青海西宁制作网站企业怎么申请域名建网站