AES-CTR

AES-CTR即AES算法的计算器模式(Counter (CTR)),这种计算器模式不常见,在CTR模式中, 有一个自增的算子(IV,后四个字节相当于计数器,每次计算递增),这个算子用密钥加密之后的输出和明文异或的结果得到密文,相当于一次一密。这种加密方式简单快速,安全可靠,而且可以并行加密,但是在计算器不能维持很长的情况下,密钥只能使用一次。CTR加密过程的示意图如下所示:
AES-CTR_第1张图片

##############################################################
Block Cipher Modes of Operation
Counter (CTR) 
Initial Counter is
	F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF 
Plaintext is
	6BC1BEE2 2E409F96 E93D7E11 7393172A 
	AE2D8A57 1E03AC9C 9EB76FAC 45AF8E51 
	30C81C46 A35CE411 E5FBC119 1A0A52EF 
	F69F2445 DF4F9B17 AD2B417B E66C3710 
############################################################## 
CTR-AES128 (Encryption) 
Key is
	2B7E1516 28AED2A6 ABF71588 09CF4F3C 
Plaintext is
	6BC1BEE2 2E409F96 E93D7E11 7393172A 
	AE2D8A57 1E03AC9C 9EB76FAC 45AF8E51 
	30C81C46 A35CE411 E5FBC119 1A0A52EF 
	F69F2445 DF4F9B17 AD2B417B E66C3710 
	
	Block #1
	InputBlock F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFEFF 
	OutputBlock EC8CDF73 98607CB0 F2D21675 EA9EA1E4 
	Text-In 6BC1BEE2 2E409F96 E93D7E11 7393172A 
	Text-Out 874D6191 B620E326 1BEF6864 990DB6CE 
	
	Block #2
	InputBlock F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFF00 
	OutputBlock 362B7C3C 67735163 18A077D7 FC5073AE 
	Text-In AE2D8A57 1E03AC9C 9EB76FAC 45AF8E51 
	Text-Out 9806F66B 7970FDFF 8617187B B9FFFDFF 
	
	Block #3
	InputBlock F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFF01 
	OutputBlock 6A2CC378 7889374F BEB4C81B 17BA6C44 
	Text-In 30C81C46 A35CE411 E5FBC119 1A0A52EF 
	Text-Out 5AE4DF3E DBD5D35E 5B4F0902 0DB03EAB 
	
	Block #4
	InputBlock F0F1F2F3 F4F5F6F7 F8F9FAFB FCFDFF02 
--------------------------------------------------------------
	OutputBlock E89C399F F0F198C6 D40A31DB 156CABFE 
	Text-In F69F2445 DF4F9B17 AD2B417B E66C3710 
	Text-Out 1E031DDA 2FBE03D1 792170A0 F3009CEE 
Ciphertext is
	874D6191 B620E326 1BEF6864 990DB6CE 
	9806F66B 7970FDFF 8617187B B9FFFDFF 
	5AE4DF3E DBD5D35E 5B4F0902 0DB03EAB 
	1E031DDA 2FBE03D1 792170A0 F3009CEE 
==============================================================

整体展示如下:
AES-CTR_第2张图片

********************* AES-CTR Encrypt *********************
Key=2B7E151628AED2A6ABF7158809CF4F3C
IV=F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
InData=6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710
EncData=874D6191B620E3261BEF6864990DB6CE9806F66B7970FDFF8617187BB9FFFDFF5AE4DF3EDBD5D35E5B4F09020DB03EAB1E031DDA2FBE03D1792170A0F3009CEE
加密完成

计算结果跟样例一致,完成。
如果有需要,可付费修改,或提供计算软件。联系微信(tainshanjinyou),非主业,赚个奶茶钱!

你可能感兴趣的:(加密算法,算法,c++)