OpenSSL学习笔记三:实操

实操

未完待续…

对称加密

https://www.openssl.org/docs/man1.1.1/man3/
可以修改Key、IV、Nonce的最后一位,看加密后的密文是否修改

//man EVP_EncryptInit

//DES in CBC, ECB, CFB and OFB modes
const EVP_CIPHER * EVP_des_cbc(void);
const EVP_CIPHER * EVP_des_ecb(void);
const EVP_CIPHER * EVP_des_cfb(void);
const EVP_CIPHER * EVP_des_ofb(void);

//Two key triple DES in CBC, ECB, CFB and OFB modes
const EVP_CIPHER * EVP_des_ede_cbc(void);
const EVP_CIPHER * EVP_des_ede(void);
const EVP_CIPHER * EVP_des_ede_ofb(void);
const EVP_CIPHER * EVP_des_ede_cfb(void);

//Three key triple DES in CBC, ECB, CFB and OFB modes
const EVP_CIPHER * EVP_des_ede3_cbc(void);
const EVP_CIPHER * EVP_des_ede3(void);
const EVP_CIPHER * EVP_des_ede3_ofb(void);
const EVP_CIPHER * EVP_des_ede3_cfb(void);

//AES with 128 bit key length in CBC, ECB, OFB and CFB modes
const EVP_CIPHER * EVP_aes_128_cbc(void);
const EVP_CIPHER * EVP_aes_128_ecb(void);
const EVP_CIPHER * EVP_aes_128_ofb(void);
const EVP_CIPHER * EVP_aes_128_cfb1(void);
const EVP_CIPHER * EVP_aes_128_cfb8(void);
const EVP_CIPHER * EVP_aes_128_cfb128(void);

//AES with 192 bit key length in CBC, ECB, OFB and CFB modes
const EVP_CIPHER * EVP_aes_192_cbc(void);
const EVP_CIPHER * EVP_aes_192_ecb(void);
const EVP_CIPHER * EVP_aes_192_ofb(void);
const EVP_CIPHER * EVP_aes_192_cfb1(void);
const EVP_CIPHER * EVP_aes_192_cfb8(void);
const EVP_CIPHER * EVP_aes_192_cfb128(void);

//AES with 256 bit key length in CBC, ECB, OFB and CFB modes
const EVP_CIPHER * EVP_aes_256_cbc(void);
const EVP_CIPHER * EVP_aes_256_ecb(void);
const EVP_CIPHER * EVP_aes_256_ofb(void);
const EVP_CIPHER * EVP_aes_256_cfb1(void);
const EVP_CIPHER * EVP_aes_256_cfb8(void);
const EVP_CIPHER * EVP_aes_256_cfb128(void);

//AES Galois Counter Mode (GCM)
const EVP_CIPHER * EVP_aes_128_gcm(void);
const EVP_CIPHER * EVP_aes_192_gcm(void);
const EVP_CIPHER * EVP_aes_256_gcm(void);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, ivlen, NULL);//a default IV length is used (96 bits for AES)
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_GET_TAG, taglen, tag);//
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, taglen, tag);//


//AES Counter with CBC-MAC Mode (CCM)
const EVP_CIPHER * EVP_aes_128_ccm(void);
const EVP_CIPHER * EVP_aes_192_ccm(void);
const EVP_CIPHER * EVP_aes_256_ccm(void);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_TAG, taglen, tag);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_L, ivlen, NULL);
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_CCM_SET_IVLEN, ivlen, NULL);


const EVP_CIPHER *EVP_rc4(void);

aes_128_ecb

int encode_aes_128_ecb(unsigned char* plainText,int plainTextLen,\
unsigned char* cipherText,int cipherTextSize,\
unsigned char *key)
{
   
   
	int cipherTextLen=0,l=0;
	EVP_CIPHER_CTX ctx;
	EVP_CIPHER_CTX_init(&ctx);
	EVP_EncryptInit_ex(&ctx,EVP_aes_128_ecb(),NULL,key,NULL);
	EVP_EncryptUpdate(&ctx,cipherText+cipherTextLen,&l,plainText,plainTextLen);
	cipherTextLen += l;
	EVP_EncryptFinal_ex(&ctx,cipherText+cipherTextLen,&l);
	cipherTextLen += l;
	EVP_CIPHER_CTX_cleanup(&ctx);
	return cipherTextLen;
}

int decode_aes_128_ecb(unsigned char* cipherText,int cipherTextLen,\
unsigned char* plainText,int plainTextSize,\
unsigned char *key)
{
   
   
	int plainTextLen=0,l=0;
	int ret;
	EVP_CIPHER_CTX ctx;
	EVP_CIPHER_CTX_init(&ctx);
	EVP_DecryptInit_ex(&ctx,EVP_aes_128_ecb(),NULL,key,NULL);
	EVP_DecryptUpdate(&ctx,plainText+plainTextLen,&l,cipherText,cipherTextLen);
	plainTextLen += l;

	ret = EVP_DecryptFinal_ex(&ctx,plainText+plainTextLen,&l);//0 fail, 1 success
	plainTextLen += l;
	EVP_CIPHER_CTX_cleanup(&ctx);
	if(ret <=0)
		return ret;
	else
		return plainTextLen;
}

int main()
{
   
   
	char plainText[1024] = {
   
   0},cipherText[1024] = {
   
   0};
	int plainTextLen,cipherTextLen;
	unsigned char key[16] = "1111111111111111";
	//RAND_bytes(key,16);

	plainTextLen = sprintf(plainText,"hello world");
	memset(cipherText,0,sizeof(cipherText));
	//encrypt
	cipherTextLen = encode_aes_128_ecb(plainText,plainTextLen,cipherText,sizeof(cipherText),key);
	int i;
	for(i=0;i<cipherTextLen;i++){
   
   
		printf("%02x",cipherText[i]);
	}
	printf("\n");

	memset(plainText,0,sizeof(plainText));
	//decrypt
	plainTextLen =  decode_aes_128_ecb(cipherText,cipherTextLen,plainText,sizeof(plainText),key);
	printf("[%d][%s]\n",plainTextLen,plainText);
}

aes_192_cbc

int encode_aes_192_cbc(unsigned char* plainText,int plainTextLen,\
unsigned char* cipherText,int cipherTextSize,\
unsigned char *key,unsigned char *iv)
{
   
   
	int cipherTextLen=0,l=0;
	EVP_CIPHER_CTX ctx;
	EVP_CIPHER_CTX_init(&ctx);
	EVP_EncryptInit_ex(&ctx,EVP_aes_192_cbc(),NULL
<think>好的,用户希望我帮他制定一份软考信息安全工程师的详细学习计划,学习时间是5个月,而且他是小白,需要更详细的每日安排。首先,我需要确认用户的具体需求。软考信息安全工程师的考试内容主要包括哪些方面?根据考试大纲,通常包括信息安全基础、网络安全、系统安全、应用安全、密码学、安全管理、法律法规等模块。 用户是零基础,所以计划需要从最基础的概念开始,逐步深入。时间跨度是5个月,大约20周,我需要将整个学习过程分为几个阶段,每个阶段有明确的目标。比如,第一阶段打基础,学习基本概念和理论;第二阶段深入学习各个安全领域;第阶段强化重点和难点;第四阶段进行模拟考试和查漏补缺;最后冲刺复习。 接下来要考虑每周的学习安排,用户可能需要每天2小时左右的学习时间。需要确保每个知识点都有足够的时间消化,同时安排复习和练习的时间。例如,每周学习新知识,周末进行复习和做题。另外,实践操作也很重要,比如配置防火墙、加密解密实验等,可能需要用户有虚拟机环境或实验平台。 还要考虑到用户可能在学习过程中遇到困难,比如密码学部分可能比较复杂,需要更多的时间来理解和练习。此外,法律法规部分需要记忆,可以安排在后期,结合做题来巩固。 需要提醒用户注意的事项包括:保持每天的学习习惯,不要中断;多做真题和模拟题,熟悉考试题型;加入学习群组或论坛,交流经验;定期自我检测,调整学习计划。最后,冲刺阶段要集中复习错题和重点内容,确保知识点的巩固。 可能还需要检查是否有遗漏的考试重点,比如最新的安全技术或法规更新,确保计划覆盖所有考点。同时,建议用户使用官方教材和推荐的参考资料,避免信息过时或不准确。 总结下来,整个计划需要结构清晰,分阶段进行,每天的任务具体可行,兼顾理论和实践,定期复习和检测,确保用户能够系统地掌握所有考试内容,顺利通过考试。</think>以下是为您定制的5个月(约20周)软考信息安全工程师详细学习计划表,按零基础小白设计,每天学习2-3小时,含理论+实践+复习: --- ### **第1-4周:基础知识筑基** **每日安排:** ``` 08:00-08:30 预习当日知识点(教材目录/思维导图) 09:00-10:00 视频学习(信息安全基本概念/OSI七层模型/TCP/IP协议) 20:00-20:30 整理笔记(用XMind做知识框架) 20:30-21:00 做章节练习题(重点标记错题) ``` **重点内容:** - 计算机组成原理、操作系统基础 - 网络基础(IP地址划分/VLAN/路由协议) - 密码学基础(凯撒密码/DES/AES原理图解) --- ### **第5-8周:核心技术突破** **每日安排新增:** ``` 每周六下午 虚拟机实操(VMware安装Kali Linux) 每周日晚 真题演练(2018-2020年真题选择题精做) ``` **核心模块:** - 防火墙配置实验(iptables规则编写) - 数字证书实战(OpenSSL自建CA颁发证书) - 渗透测试基础(Nmap扫描/Wireshark抓包分析) --- ### **第9-12周:安全管理体系** **专项训练:** ``` 每日中午 碎片时间记忆(等保2.0分级标准/ISO27001控制项) 周四晚上 案例分析模板训练(安全事件处理六步法) ``` **重点领域:** - 网络安全法/个人信息保护法核心条款 - 风险评估方法(定性分析 vs 定量分析) - 灾备方案设计(RPO/RTO计算) --- ### **第13-16周:真题实战强化** **冲刺策略:** ``` 每日1套模拟卷(严格计时,使用考试原版答题卡) 错题本每日复盘(分类统计漏洞:概念类/计算类/应用类) 每周 专项突破(PKI体系/数字签名流程手绘) ``` --- ### **第17-20周:终极冲刺** **最后30天计划:** ``` 06:30-07:00 晨间记忆(口诀:等保级6个管理要求) 19:00-20:30 高频考点速记(安全攻击类型对照表) 22:00-22:30 考前心理调节(正念冥想训练) ``` --- ### **工具与资源推荐** 1. 教材:《信息安全工程师教程(第2版)》(清华大学出版社) 2. 实验平台:阿里云免费ECS(用于搭建蜜罐系统) 3. 刷题APP:软考通(带视频解析功能) 4. 学习社区:知乎「软考信息安全」话题精华帖 --- ### **关键里程碑** - 第4周末:完成所有基础概念思维导图 - 第8周末:独立配置完成防火墙双机热备 - 第12周末:能完整复述等级保护实施流程 - 第16周末:模拟考稳定达到65分以上 - 考试前3天:完成所有材料归档(准考证/身份证/2B铅笔) 建议每周日晚上进行20分钟学习复盘,使用Notion记录学习进度,及时调整节奏。考试前7天重点复习近年案例分析真题答案模板。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值