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

用asp.net做电商网站平台运营

用asp.net做电商网站,平台运营,岳阳房地产信息网,党建网站建设的目的文章目录 openssl3.2 - 官方demo学习 - mac - siphash.c概述笔记END openssl3.2 - 官方demo学习 - mac - siphash.c 概述 MAC算法为 SIPHASH, 设置参数(C-rounds, D-rounds, 也可以不设置, 有默认值) 用key初始化MAC算法, 算明文的MAC值 笔记 /*! \file siphash.c \note op…

文章目录

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

openssl3.2 - 官方demo学习 - mac - siphash.c

概述

MAC算法为 SIPHASH, 设置参数(C-rounds, D-rounds, 也可以不设置, 有默认值)
用key初始化MAC算法, 算明文的MAC值

笔记

/*!
\file siphash.c
\note
openssl3.2 - 官方demo学习 - mac - siphash.c
MAC算法为 SIPHASH, 设置参数(C-rounds, D-rounds, 也可以不设置, 有默认值)
用key初始化MAC算法, 算明文的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 the test vector from the paper "SipHash: a fast short-input PRF".* https://www.aumasson.jp/siphash/siphash.pdf*//** Hard coding the key into an application is very bad.* It is done here solely for educational purposes.*/
static unsigned char key[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
};static unsigned char data[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e
};static const unsigned char expected_output[] = {0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1
};/** A property query used for selecting the SIPHASH implementation.*/
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[8];OSSL_PARAM params[4], * p = params;OSSL_LIB_CTX* _ossl_lib_ctx = NULL;unsigned int digest_len = 8, c_rounds = 2, d_rounds = 4;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 SipHash implementation */_evp_mac = EVP_MAC_fetch(_ossl_lib_ctx, "SIPHASH", propq);if (_evp_mac == NULL) {fprintf(stderr, "EVP_MAC_fetch() returned NULL\n");goto end;}/* Create a context for the SipHash 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;}/* SipHash can support either 8 or 16-byte digests. */*p++ = OSSL_PARAM_construct_uint(OSSL_MAC_PARAM_SIZE, &digest_len);/** The number of C-rounds and D-rounds is configurable. Standard SipHash* uses values of 2 and 4 respectively. The following lines are unnecessary* as they set the default, but demonstrate how to change these values.*/*p++ = OSSL_PARAM_construct_uint(OSSL_MAC_PARAM_C_ROUNDS, &c_rounds);*p++ = OSSL_PARAM_construct_uint(OSSL_MAC_PARAM_D_ROUNDS, &d_rounds);*p = OSSL_PARAM_construct_end();/* Initialise the SIPHASH operation */if (!EVP_MAC_init(_evp_mac_ctx, key, sizeof(key), params)) {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/693291/

相关文章:

  • 深圳专业做网站的衡水网站优化推广
  • 徐汇科技网站建设2345中国最好的网址站
  • 邢台论坛吧百度seo收录软件
  • 做国外服务器网站吗怎么让百度搜索靠前
  • 做动态图网站有哪些自建站怎么推广
  • web网站开发课程设计报告seo技术培训沈阳
  • 会宁网站建设公司网站优化助手
  • 网站设计制作体会2023年5月最新疫情
  • 月亮湾设计有限公司网站南宁seo产品优化服务
  • 福田欧曼服务站电话上海高端seo公司
  • 高端网站建设哪家好谷歌seo和百度seo
  • 前端写一个页面多少钱海口网站关键词优化
  • 浦东新区建设局官方网站东莞seo关键词
  • 在百度做橱柜网站进入百度一下官网
  • wordpress调用分类标签站长工具查询seo
  • 网站做全局搜索云南新闻最新消息今天
  • 公司网站推广方案长春seo代理
  • 网站地图怎么样做更利于收录手机百度搜索引擎入口
  • 中国建筑公司网站谷歌浏览器官方app下载
  • 厦门网站建设策划seo网站优化培训找哪些
  • 宝安区住房和建设局官方网站seo搜索引擎优化书籍
  • 省建设厅执业资格注册中心网站2023搜索最多的关键词
  • 本地wordpress上传搜索引擎营销优化策略有哪些
  • html手机网站模板培训心得体会800字
  • 合肥做网站公司哪家好经典的软文广告
  • 网站备案哪个部门北京推广
  • 澳环网站设计公司网站建设方案
  • 云南旅行社网站建设网络推广有多少种方法
  • 龙岗做商城网站建设网络营销战略的内容
  • 网站建设网络公整站排名