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

免费建站模板网站搭建网站教学

免费建站模板网站,搭建网站教学,wordpress 主页链接,好用的wordpress app文章目录 openssl3.2 - 官方demo学习 - mac - gmac.c概述笔记END openssl3.2 - 官方demo学习 - mac - gmac.c 概述 使用GMAC算法, 设置参数(指定加密算法 e.g. AES-128-GCM, 设置iv) 用key执行初始化, 然后对明文生成MAC数据 官方注释给出建议, key, iv最好不要硬编码出现在程… 文章目录 openssl3.2 - 官方demo学习 - mac - gmac.c概述笔记END openssl3.2 - 官方demo学习 - mac - gmac.c 概述 使用GMAC算法, 设置参数(指定加密算法 e.g. AES-128-GCM, 设置iv) 用key执行初始化, 然后对明文生成MAC数据 官方注释给出建议, key, iv最好不要硬编码出现在程序中 笔记 /*! \file gmac.c \note openssl3.2 - 官方demo学习 - mac - gmac.c 使用GMAC算法, 设置参数(指定加密算法 e.g. AES-128-GCM, 设置iv) 用key执行初始化, 然后对明文生成MAC数据 *//** Copyright 2021-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*/#include stdio.h #include stdlib.h #include openssl/core_names.h #include openssl/evp.h #include openssl/params.h #include openssl/err.h#include my_openSSL_lib.h/** Taken from NISTs GCM Test Vectors* http://csrc.nist.gov/groups/STM/cavp/*//** Hard coding the key into an application is very bad.* It is done here solely for educational purposes.*/ static unsigned char key[] {0x77, 0xbe, 0x63, 0x70, 0x89, 0x71, 0xc4, 0xe2,0x40, 0xd1, 0xcb, 0x79, 0xe8, 0xd7, 0x7f, 0xeb };/** The initialisation vector (IV) is better not being hard coded too.* Repeating password/IV pairs compromises the integrity of GMAC.* The IV is not considered secret information and is safe to store with* an encrypted password.*/ static unsigned char iv[] {0xe0, 0xe0, 0x0f, 0x19, 0xfe, 0xd7, 0xba,0x01, 0x36, 0xa7, 0x97, 0xf3 };static unsigned char data[] {0x7a, 0x43, 0xec, 0x1d, 0x9c, 0x0a, 0x5a, 0x78,0xa0, 0xb1, 0x65, 0x33, 0xa6, 0x21, 0x3c, 0xab };static const unsigned char expected_output[] {0x20, 0x9f, 0xcc, 0x8d, 0x36, 0x75, 0xed, 0x93,0x8e, 0x9c, 0x71, 0x66, 0x70, 0x9d, 0xd9, 0x46 };/** A property query used for selecting the GMAC implementation and the* underlying GCM mode cipher.*/ static char* propq NULL;int main(int argc, char** argv) {int ret EXIT_FAILURE;EVP_MAC* _evp_mac NULL;EVP_MAC_CTX* _evp_mac_ctx NULL;unsigned char out[16];OSSL_PARAM _ossl_param_ary[4], * p_ossl_param _ossl_param_ary;OSSL_LIB_CTX* _ossl_lib_ctx NULL;size_t out_len 0;_ossl_lib_ctx OSSL_LIB_CTX_new();if (_ossl_lib_ctx NULL) {fprintf(stderr, OSSL_LIB_CTX_new() returned NULL\n);goto end;}/* Fetch the GMAC implementation */_evp_mac EVP_MAC_fetch(_ossl_lib_ctx, GMAC, propq);if (_evp_mac NULL) {fprintf(stderr, EVP_MAC_fetch() returned NULL\n);goto end;}/* Create a context for the GMAC operation */_evp_mac_ctx EVP_MAC_CTX_new(_evp_mac);if (_evp_mac_ctx NULL) {fprintf(stderr, EVP_MAC_CTX_new() returned NULL\n);goto end;}/* GMAC requires a GCM mode cipher to be specified */*p_ossl_param OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_CIPHER,AES-128-GCM, 0);/** If a non-default property query is required when fetching the GCM mode* cipher, it needs to be specified too.*/if (propq ! NULL)*p_ossl_param OSSL_PARAM_construct_utf8_string(OSSL_MAC_PARAM_PROPERTIES,propq, 0);/* Set the initialisation vector (IV) */*p_ossl_param OSSL_PARAM_construct_octet_string(OSSL_CIPHER_PARAM_IV,iv, sizeof(iv));*p_ossl_param OSSL_PARAM_construct_end();/* Initialise the GMAC operation */if (!EVP_MAC_init(_evp_mac_ctx, key, sizeof(key), _ossl_param_ary)) {fprintf(stderr, EVP_MAC_init() failed\n);goto end;}/* Make one or more calls to process the data to be authenticated */if (!EVP_MAC_update(_evp_mac_ctx, data, sizeof(data))) {fprintf(stderr, EVP_MAC_update() failed\n);goto end;}/* Make one call to the final to get the MAC */if (!EVP_MAC_final(_evp_mac_ctx, out, out_len, sizeof(out))) {fprintf(stderr, EVP_MAC_final() failed\n);goto end;}printf(Generated MAC:\n);BIO_dump_indent_fp(stdout, out, (int)out_len, 2);putchar(\n);if (out_len ! sizeof(expected_output)) {fprintf(stderr, Generated MAC has an unexpected length\n);goto end;}if (CRYPTO_memcmp(expected_output, out, sizeof(expected_output)) ! 0) {fprintf(stderr, Generated MAC does not match expected value\n);goto end;}ret EXIT_SUCCESS; end:EVP_MAC_CTX_free(_evp_mac_ctx);EVP_MAC_free(_evp_mac);OSSL_LIB_CTX_free(_ossl_lib_ctx);if (ret ! EXIT_SUCCESS)ERR_print_errors_fp(stderr);return ret; } END
http://www.hkea.cn/news/14476977/

相关文章:

  • 华宁县住房和城乡建设局网站海事网站服务平台
  • 网站备案背景墙博物馆网站 微信 微博 建设
  • 沈阳快速网站建设网站开发市场营销毕业后找什么工作
  • 做网站开发考什么研wordpress管理地址在哪里设置
  • 做好中心网站建设工作总结做防护用品的网站
  • 怎么做百度网站验证码中国做爰网站
  • 友情链接是在网站后台做吗wordpress做微信小程序商店
  • 制作钓鱼网站上海网站建设收费
  • 烟台市城市建设发展有限公司网站网站内容该怎么做
  • 威海专业做网站公司wordpress nginx配置
  • 上街做网站神马推广登录
  • 旅游网站建设合同电子商务网站建设合同样本
  • 重庆选科网站百度信息流广告平台
  • 重庆永川网站建设价格智慧记免费官方下载
  • 网站图片动态换名重庆市建设工程质量信息网
  • 中山免费建网站如何提高网站的知名度
  • 国办网站建设指引管理咨询有限公司经营范围
  • 江西手机版建站系统开发肥城市区seo关键词排名
  • 手机购物网站设计游戏大全免费版入口
  • 怎么面试一个网站开发的人江苏省国家示范校建设专题网站
  • 网站续费合同豪禾创意海报设计理念
  • 电子商务网站建设题想学做网站需要学什么
  • 汕头市澄海区建设局网站网站添加文字大小
  • 综合性门户网站列举网络广告有哪些
  • 娱乐网站的代理怎么做望野古诗朗读
  • 刚建设的网站如何推广昆明网站建设哪家合适
  • 佛山伦教网站设计做初中题赚钱的网站
  • 网站 维护 费用建易网官网
  • 视频播放网站开发的报告微站网建站系统
  • 北京网站制作网络推广公司人力外包