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

网站制作专业网络营销技巧培训

网站制作专业,网络营销技巧培训,网站建设营改增,中国建设网app下载文章目录 openssl3.2 - 测试程序的学习 - test\aesgcmtest.c概述笔记能学到的流程性内容END openssl3.2 - 测试程序的学习 - test\aesgcmtest.c 概述 openssl3.2 - 测试程序的学习 aesgcmtest.c 工程搭建时, 发现没有提供 test_get_options(), cleanup_tests(), 需要自己补上…

文章目录

    • openssl3.2 - 测试程序的学习 - test\aesgcmtest.c
    • 概述
    • 笔记
    • 能学到的流程性内容
    • END

openssl3.2 - 测试程序的学习 - test\aesgcmtest.c

概述

openssl3.2 - 测试程序的学习
aesgcmtest.c 工程搭建时, 发现没有提供 test_get_options(), cleanup_tests(), 需要自己补上才能编译过.

笔记

在这里插入图片描述

/*!
* \fle D:\my_dev\my_local_git_prj\study\openSSL\nmake_test\test_c\prj_004_aesgcmtest.c\aesgcmtest.c 
//** Copyright 2019-2021 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 "my_openSSL_lib.h"#include <openssl/evp.h>// 最少要包含测试工具的头文件
#include "testutil.h"// openssl提供的.\test\*.c, 有的没有test_get_options(), cleanup_tests()
// 自己补充函数, 编译过就行, 不管内存泄漏了// 需要将其他实现中的enum定义拷贝过来
typedef enum OPTION_choice {OPT_ERR = -1,OPT_EOF = 0,OPT_CONFIG_FILE,OPT_TEST_ENUM
} OPTION_CHOICE;const OPTIONS* test_get_options(void)
{// 这个函数返回不能为空, 从其他有实现的函数中拷贝一个实现过来, 否则有崩溃报错static const OPTIONS test_options[] = {OPT_TEST_OPTIONS_DEFAULT_USAGE,{ "config", OPT_CONFIG_FILE, '<',"The configuration file to use for the libctx" },{ NULL }};return test_options;
}void cleanup_tests(void)
{}static const unsigned char gcm_key[] = {0xee, 0xbc, 0x1f, 0x57, 0x48, 0x7f, 0x51, 0x92, 0x1c, 0x04, 0x65, 0x66,0x5f, 0x8a, 0xe6, 0xd1, 0x65, 0x8b, 0xb2, 0x6d, 0xe6, 0xf8, 0xa0, 0x69,0xa3, 0x52, 0x02, 0x93, 0xa5, 0x72, 0x07, 0x8f
};
static const unsigned char gcm_iv[] = {0x99, 0xaa, 0x3e, 0x68, 0xed, 0x81, 0x73, 0xa0, 0xee, 0xd0, 0x66, 0x84
};
static const unsigned char gcm_pt[] = {0xf5, 0x6e, 0x87, 0x05, 0x5b, 0xc3, 0x2d, 0x0e, 0xeb, 0x31, 0xb2, 0xea,0xcc, 0x2b, 0xf2, 0xa5
};
static const unsigned char gcm_aad[] = {0x4d, 0x23, 0xc3, 0xce, 0xc3, 0x34, 0xb4, 0x9b, 0xdb, 0x37, 0x0c, 0x43,0x7f, 0xec, 0x78, 0xde
};
static const unsigned char gcm_ct[] = {0xf7, 0x26, 0x44, 0x13, 0xa8, 0x4c, 0x0e, 0x7c, 0xd5, 0x36, 0x86, 0x7e,0xb9, 0xf2, 0x17, 0x36
};
static const unsigned char gcm_tag[] = {0x67, 0xba, 0x05, 0x10, 0x26, 0x2a, 0xe4, 0x87, 0xd7, 0x37, 0xee, 0x62,0x98, 0xf7, 0x7e, 0x0c
};static int do_encrypt(unsigned char *iv_gen, unsigned char *ct, int *ct_len,unsigned char *tag, int *tag_len)
{int ret = 0;EVP_CIPHER_CTX *ctx = NULL;int outlen;unsigned char outbuf[64];*tag_len = 16;ret = TEST_ptr(ctx = EVP_CIPHER_CTX_new())&& TEST_true(EVP_EncryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL,NULL) > 0)&& TEST_true(EVP_EncryptInit_ex(ctx, NULL, NULL, gcm_key,iv_gen != NULL ? NULL : gcm_iv) > 0)&& TEST_true(EVP_EncryptUpdate(ctx, NULL, &outlen, gcm_aad,sizeof(gcm_aad)) > 0)&& TEST_true(EVP_EncryptUpdate(ctx, ct, ct_len, gcm_pt,sizeof(gcm_pt)) > 0)&& TEST_true(EVP_EncryptFinal_ex(ctx, outbuf, &outlen) > 0)&& TEST_int_eq(EVP_CIPHER_CTX_get_tag_length(ctx), 16)&& TEST_true(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, 16,tag) > 0)&& TEST_true(iv_gen == NULL|| EVP_CIPHER_CTX_get_original_iv(ctx, iv_gen, 12));EVP_CIPHER_CTX_free(ctx);return ret;
}static int do_decrypt(const unsigned char *iv, const unsigned char *ct,int ct_len, const unsigned char *tag, int tag_len)
{int ret = 0;EVP_CIPHER_CTX *ctx = NULL;int outlen, ptlen;unsigned char pt[32];unsigned char outbuf[32];ret = TEST_ptr(ctx = EVP_CIPHER_CTX_new())&& TEST_true(EVP_DecryptInit_ex(ctx, EVP_aes_256_gcm(), NULL,NULL, NULL) > 0)&& TEST_true(EVP_DecryptInit_ex(ctx, NULL, NULL, gcm_key, iv) > 0)&& TEST_int_eq(EVP_CIPHER_CTX_get_tag_length(ctx), 16)&& TEST_true(EVP_DecryptUpdate(ctx, NULL, &outlen, gcm_aad,sizeof(gcm_aad)) > 0)&& TEST_true(EVP_DecryptUpdate(ctx, pt, &ptlen, ct,ct_len) > 0)&& TEST_true(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,tag_len, (void *)tag) > 0)&& TEST_true(EVP_DecryptFinal_ex(ctx, outbuf, &outlen) > 0)&& TEST_mem_eq(gcm_pt, sizeof(gcm_pt), pt, ptlen);EVP_CIPHER_CTX_free(ctx);return ret;
}static int kat_test(void)
{unsigned char tag[32];unsigned char ct[32];int ctlen = 0, taglen = 0;return do_encrypt(NULL, ct, &ctlen, tag, &taglen)&& TEST_mem_eq(gcm_ct, sizeof(gcm_ct), ct, ctlen)&& TEST_mem_eq(gcm_tag, sizeof(gcm_tag), tag, taglen)&& do_decrypt(gcm_iv, ct, ctlen, tag, taglen);
}static int badkeylen_test(void)
{int ret;EVP_CIPHER_CTX *ctx = NULL;const EVP_CIPHER *cipher;ret = TEST_ptr(cipher = EVP_aes_192_gcm())&& TEST_ptr(ctx = EVP_CIPHER_CTX_new())&& TEST_true(EVP_EncryptInit_ex(ctx, cipher, NULL, NULL, NULL))&& TEST_int_le(EVP_CIPHER_CTX_set_key_length(ctx, 2), 0);EVP_CIPHER_CTX_free(ctx);return ret;
}static int ivgen_test(void)
{unsigned char iv_gen[16];unsigned char tag[32];unsigned char ct[32];int ctlen = 0, taglen = 0;return do_encrypt(iv_gen, ct, &ctlen, tag, &taglen)&& do_decrypt(iv_gen, ct, ctlen, tag, taglen);
}int setup_tests(void)
{ADD_TEST(kat_test);ADD_TEST(badkeylen_test);ADD_TEST(ivgen_test);return 1;
}

能学到的流程性内容

do_encrypt()
do_decrypt()
这官方测试代码, 如果只看流程性的内容, 比网上找到的代码片段规范多了.

END


文章转载自:
http://infelicific.rywn.cn
http://refractably.rywn.cn
http://sufflate.rywn.cn
http://unsalable.rywn.cn
http://maltster.rywn.cn
http://spekboom.rywn.cn
http://mannheim.rywn.cn
http://calycular.rywn.cn
http://paraglider.rywn.cn
http://wadset.rywn.cn
http://darobokka.rywn.cn
http://soda.rywn.cn
http://cheerfully.rywn.cn
http://installment.rywn.cn
http://erlking.rywn.cn
http://thyreoid.rywn.cn
http://severe.rywn.cn
http://bladework.rywn.cn
http://bugloss.rywn.cn
http://initiative.rywn.cn
http://precocial.rywn.cn
http://dissector.rywn.cn
http://drawtube.rywn.cn
http://zoochore.rywn.cn
http://metaethics.rywn.cn
http://haematite.rywn.cn
http://mizzle.rywn.cn
http://hypersonic.rywn.cn
http://acetimeter.rywn.cn
http://relievedly.rywn.cn
http://regardlessly.rywn.cn
http://transoceanic.rywn.cn
http://veinulet.rywn.cn
http://dogmatic.rywn.cn
http://bedrizzle.rywn.cn
http://hathpace.rywn.cn
http://minifloppy.rywn.cn
http://osf.rywn.cn
http://wardmote.rywn.cn
http://regenerative.rywn.cn
http://auricled.rywn.cn
http://epibolic.rywn.cn
http://ginseng.rywn.cn
http://thio.rywn.cn
http://bobbed.rywn.cn
http://unsaturated.rywn.cn
http://mahoe.rywn.cn
http://uae.rywn.cn
http://problem.rywn.cn
http://boswellize.rywn.cn
http://airily.rywn.cn
http://felicitate.rywn.cn
http://withershins.rywn.cn
http://chequers.rywn.cn
http://wattled.rywn.cn
http://disfunction.rywn.cn
http://zoolith.rywn.cn
http://rascallion.rywn.cn
http://sightworthy.rywn.cn
http://homoiothermal.rywn.cn
http://khond.rywn.cn
http://tractarian.rywn.cn
http://depart.rywn.cn
http://squiress.rywn.cn
http://haemolytic.rywn.cn
http://troubadour.rywn.cn
http://pendency.rywn.cn
http://strove.rywn.cn
http://rapist.rywn.cn
http://unerringly.rywn.cn
http://amidst.rywn.cn
http://deflationary.rywn.cn
http://outcry.rywn.cn
http://gunboat.rywn.cn
http://undesirous.rywn.cn
http://scoundrel.rywn.cn
http://assumingly.rywn.cn
http://hernshaw.rywn.cn
http://belgravia.rywn.cn
http://cenogenesis.rywn.cn
http://compendia.rywn.cn
http://sympathizer.rywn.cn
http://tipper.rywn.cn
http://ningbo.rywn.cn
http://aileron.rywn.cn
http://virl.rywn.cn
http://argue.rywn.cn
http://repentantly.rywn.cn
http://sphericity.rywn.cn
http://myoid.rywn.cn
http://overcredulity.rywn.cn
http://volumetric.rywn.cn
http://disconcerting.rywn.cn
http://impregnability.rywn.cn
http://indispose.rywn.cn
http://wow.rywn.cn
http://saponaceous.rywn.cn
http://coexistence.rywn.cn
http://sacciform.rywn.cn
http://hatshepset.rywn.cn
http://www.15wanjia.com/news/61005.html

相关文章:

  • 快手做任务网站如何开展网络营销活动
  • 分销系统商城定制开发网站排名怎么优化
  • 和印度做外贸的网站线下课程seo
  • 做设计怎么进公司网站网络推广的平台
  • 政务信息网站的建设的意义免费私人网站建设
  • 专业网站建设经费申请报告环球军事新闻最新消息
  • 晚上必看的正能量视频下载宝鸡seo优化
  • 网站开发公司 重庆培训网站官网
  • 怎么做网页链接教程北京网站优化经理
  • 网站开发工具的是什么专业网络推广机构
  • wordpress 皮主题什么是seo站内优化
  • 做网站设计师要提供什么优化防控举措
  • 网站建设专题页深圳seo顾问
  • 企业qq下载官网下载安装seo是啥
  • wordpress 微信登录seo霸屏
  • 湖南做网站 磐石网络代运营哪家比较可靠
  • 湖北鼎天宏图建设工程有限公司网站网络推广营销技巧
  • 网站seo 教程网页制作学习
  • 网站开发强制使用急速内核日本樱花免m38vcom费vps
  • 汕头建站模板系统十大免费软文推广平台
  • 个人网站名字限制页面优化的方法
  • 龙岗专业做网站公司网络营销推广方案有哪些
  • wordpress仪表盘地址seo方法
  • 在北京做兼职哪个网站好顾问式营销
  • 网站公司简介模板免费下载关键词分析
  • 做算法的网站黄页推广2021
  • 网站留言短信通知百度免费安装下载
  • 网站建设取得实效关键词排名快照优化
  • 有自己的域名怎么建立网站中国网络推广网站排名
  • 织梦网站博客模板网络视频营销平台