安全传输资料
本文最后更新于 466 天前,内容如有失效请评论区留言。

昨天发现了2个自己以前一直没有发现的错误,导致调试了很久代码,因此上次的”实现保密性”的代码也有问题。今天又增加了消息长度,又检查出一个代码BUG(;′⌒`),经过多次测试,理论上应该没有大问题了


[toc]

总体实现思路

将消息用RSA加密得到密文,同时把消息添加一个递增序号,以避免重放攻击,通过mmh3和共享密钥计算出MAC,再把消息认证码使用RSA加密得到数字签名,将密文、MAC和数字签名打包发出,其中RSA的私钥、mmh3的共享密钥是事先分配好的且保密,接收者或第三方把数字签名使用解密密钥解密,如果得到正确的MAC,同时接收者添加对应的递增序号计算出MAC,与收到的MAC完成比对,再用RSA的私钥解密得到保密、完整、不可伪造的明文

具体实现细节

本次实现增加了密钥强度,密文加密使用128bit * 128bit的素数p, q,32位数字为一段分组加密,签名加密使用了1024bit * 1024bit的大素数p2, q2

  • RSA加密明文:
    • 将byte数组利用bytes_to_long()转化成数字
    • 将数字按照每32位为一组进行拆分,便于分块加密(可以调整拆分数的大小,但需保证拆分后的数字小于N,否则RSA会挂)
    • 将拆分后的数字用RSA进行加密,即将每个数字在模N的意义下e次方
    • 加密后的数字列表即为密文(其实本来想把密文也搞成bytes的,但在转化bytes的时候发现这需要记录下数与数哪里会有分割,为了避免代码冗长,就不搞了)
    • 密文是数字列表,将每个列表中的数字在模N的意义下d次方
    • 将列表中的数字顺次拼接成一个大整数
    • long_to_bytes()得到原bytes数组
  • mmh3哈希得到MAC:
    • 将消息开头添加递增序号,依次为[5],[10],[15]……
    • mmh3.hash128()哈希上述消息得到MAC
  • RSA数字签名:
    • 将MAC用RSA生成数字签名(e, d与加密消息的不同)

素数获取使用getPrime()函数:

image-20211017213625457

image-20211017213640072

遇到过的问题

  • 惊天BUG 1:

    我的RSA加解密写挂了Σ (゚Д゚;) ,关键是那份代码是一面做网安附加题第一次写的,之后做CNSS多次碰到RSA题需要计算e, d都是用自己写的那份代码,都没有发现,但我昨天把数字p, q加大到1024bit的时候就挂了,调试了很久发现是计算私钥取模取错了,应该mod phi而不是mod N

    正确写法:

    image-20211017214345315

  • 惊天BUG 2:

    Python传列表、对象等变量是传递的引用,在新函数中修改变量中的值原变量值也要变

    果真暑假Python没学好

    image-20211017215017936

    神奇的是通过这个特性,让我”实现保密性”那道题明明逻辑错了但最后却对了,以至于我没有发现

    image-20211017214646378

    查询百度后为了实现我原来传递参数的目的,干脆就copy.deepcopy()

    image-20211017215536547

  • BUG 3:

    将分段加密的密文解密合并的时候,由于明文bytes_to_long()后中间可能有0,这些0若分段时充当前导0,则在合并时会被漏掉,解决方法是用zfill()函数补齐缺少的0,但又要注意第1个数不需要补齐(zfill()这个方法是CNSS题目教我的

image-20211017220026347

Code

更多细节详见代码注释

#Author: LRL52  Date: 2021.10.16 - 10.17
#安全传输学习资料的完整方案,分别通过RSA加密、MAC、数字签名实现了保密性、完整性和不可伪造性
from Crypto.Util.number import *
import copy
import mmh3

class Message(): #传输消息的组成有3部分, 分别为密文、MAC、数字签名
    c = []
    MAC = 0
    signature = 0

class LRL52():
    def exgcd(self, a, b): #扩展欧几里得算法
        if b == 0: return (1, 0)
        x, y = self.exgcd(b, a % b)
        return (y, x - a // b * y)
    def __init__(self): #RSA加解密、MAC、数字签名参数设置,可根据身份自行调整
        self.p, self.q, self.e = 0, 0, 0
        self.p2, self.q2, self.e2 = 0, 0, 0
        self.bit = 32 #以32位数字为一组进行分块加解密
        self.base = 10**self.bit
        self.A = []
        self.cnt, self.MAC_KEY = 0, 0
        self.N, self.N2 = 0, 0
    def init(self): #发送消息的人知道所有保密参数,初始化
        self.N = self.p * self.q
        self.phi = (self.p - 1) * (self.q - 1)
        self.d, t = self.exgcd(self.e, self.phi)
        self.d %= self.phi #BUG1 是模phi不是模N!
        self.N2 = self.p2 * self.q2
        self.phi2 = (self.p2 - 1) * (self.q2 - 1)
        self.d2, t2 = self.exgcd(self.e2, self.phi2)
        self.d2 %= self.phi2
    def ksm(self, a, b, MOD): #快速幂算法
        ret = 1
        while b > 0:
            if b & 1: ret = ret * a % MOD
            a = a * a % MOD
            b >>= 1
        return ret
    def bytes_to_number(self, m): #将字节转化成数字,并进行分块拆分
        m = bytes_to_long(m)
        self.A.clear()
        while m > 0:
            self.A.append(m % self.base)
            m //= self.base
        self.A = self.A[::-1]
    def number_to_bytes(self, c): #将数字合并,还原信息
        s = str(c[0])
        for i in range(1, len(c)):
            s += str(c[i]).zfill(self.bit) ##BUG3 分块密文还原前导0补齐32位的处理!
        s = long_to_bytes(eval(s))
        return s
    def Enc(self, m): #先分块拆分,再RSA加密
        self.bytes_to_number(m)
        for i in range(0, len(self.A)):
            self.A[i] = self.ksm(self.A[i], self.e, self.N)
        return self.A
    def Dec(self, c): #解密
        for i in range(0, len(c)):
            c[i] = self.ksm(c[i], self.d, self.N)
        return self.number_to_bytes(c)
    def send(self, m): #发送消息
        ret = Message()
        ret.c = self.Enc(m) #将消息使用RSA分块加密
        self.cnt += 5 #MAC递增序号+5
        ret.MAC = mmh3.hash128('[' + str(self.cnt) + '] ' + m.decode(), self.MAC_KEY, signed=False) #计算MAC
        ret.signature = self.ksm(ret.MAC, self.e2, self.N2) #将MAC用RSA签名(e, d与加密消息的不同)
        return ret
    def check_signature(self, MAC, sig): #验证数字签名
        if self.ksm(sig, self.d2, self.N2) == MAC:
            print("Digital signature is correct.")
            return 1
        else:
            print("Fake signature!")
            return 0
    def receive(self, message): #接收消息
        if self.check_signature(message.MAC, message.signature) == 0: #第1步验证数字签名
            print("Stopped reading messages!")
            return
        text = self.Dec(message.c) #第2步解密
        self.cnt += 5 #接收消息人的递增序号也+5
        if mmh3.hash128('[' + str(self.cnt) + '] ' + text.decode(), self.MAC_KEY, signed=False) != message.MAC: #第3步比对MAC
            print("MAC doesn't mathch messages!")
            print("Stopped reading messages!")
            self.cnt -= 5 #MAC匹配失败,为了保持和真正的发送消息的人同步,递增序号恢复上次状态
            return
        print("MAC is correct.")
        return text

测试部分代码

#Alice配置传输消息相关参数
Alice = LRL52()
Alice.p, Alice.q, Alice.e = 257569026242097227573045456013596418709, 246470701802752293283580901333917438561, 525687841
Alice.MAC_KEY = 520
Alice.p2, Alice.q2, Alice.e2 = 126632381128636153834600469606581996651984311802729145615706915521450141847966575973595226078922707673188329373664186440454376542369176813246888471621939379090748064729026020610501249965930944451477180655504674385671789732435170819704384015173484473267737970458732460234837302942255527666935099316175475370037, 116907085065816772842274050181969393048094572380129684741235988965238863836621668040405878279932732703487988653472193665092519043575041621540455443957408827138980478633812222966134906122240485124712559641252197077532000126847184958443407352089882880726384854302340746068771679457204275163081834404962631060027, 65537
#Alice.p2, Alice.q2, Alice.e2 = 99762262020908138004082361886052588613671089759597712438865625154600318715191, 110461156644660053741146405876705228628967507046709709022111046141516461489313, 65537
Alice.init()

#(模拟)Bob可以从Alice处提前获取解密所需的参数
Bob = LRL52()
Bob.N, Bob.d, Bob.MAC_KEY = Alice.N, Alice.d, Alice.MAC_KEY
Bob.N2, Bob.d2 = Alice.N2, Alice.d2

#第一次发送
print("{:-^50}".format("第一次发送测试Begin"))
send_text = b"i_love_you"
message = Alice.send(send_text)
try:
    receive_text = Bob.receive(copy.deepcopy(message))  # BUG2 对象和列表的复制!直接传过去里面的相当于传引用
    if receive_text != None:
        print(receive_text)
except:
    print("Error:密钥错误,解密失败")
print("{:-^50}".format("END"))

#重放攻击测试
print("{:-^50}".format("重放攻击测试Begin"))
try:
    receive_text = Bob.receive(copy.deepcopy(message))
    if receive_text != None:
        print(receive_text)
except:
    print("Error:密钥错误,解密失败")
print("{:-^50}".format("END"))

#第三方验证,第三方只需要知道验证签名的N2, d2即可
print("{:-^50}".format("第三方验证测试Begin"))
third_party = LRL52()
third_party.N2, third_party.d2 = Alice.N2, Alice.d2
third_party.check_signature(message.MAC, message.signature)
print("{:-^50}".format("END"))

#第二次发送
print("{:-^50}".format("第二次发送测试Begin"))
send_text = b"I really want to be a member of LR Studio and Cohesion Network Security Studio."
message2 = Alice.send(send_text)
try:
    receive_text = Bob.receive(copy.deepcopy(message2))
    if receive_text != None:
        print(receive_text)
except:
    print("Error:密钥错误,解密失败")
print("{:-^50}".format("END"))

#签名验证测试
print("{:-^50}".format("签名使用上一条消息的签名Begin"))
message2.signature = message.signature
try:
    receive_text = Bob.receive(copy.deepcopy(message2))
    if receive_text != None:
        print(receive_text)
except:
    print("Error:密钥错误,解密失败")
print("{:-^50}".format("END"))

#第三次发送
print("{:-^50}".format("第三次发送测试(长消息)Begin"))
send_text = b"1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 65, 66, 68, 69, 70, 72, 74, 76, 77, 78, 80, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 95, 99, 102, 104, 105, 108, 110, 111, 112, 114, 115, 116, 117, 119, 120, 123, 124, 126, 129, 130, 132, 133, 135, 136, 138, 140, 143, 144, 145, 148, 152, 153, 154, 155, 156, 161, 164, 165, 168, 170, 171, 172, 174, 176, 180, 182, 184, 185, 186, 187, 189, 190, 195, 198, 203, 204, 205, 207, 208, 209, 210, 215, 216, 217, 220, 221, 222, 228, 230, 231, 232, 234, 238, 240, 246, 247, 248, 252, 253, 255, 258, 259, 260, 261, 264, 266, 270, 272, 273, 276, 279, 280, 285, 286, 287, 290, 296, 297, 299, 301, 304, 306, 308, 310, 312, 315, 319, 322, 323, 328, 330, 333, 336, 340, 341, 342, 344, 345, 348, 351, 357, 360, 364, 368, 369, 370, 372, 374, 377, 378, 380, 385, 387, 390, 391, 396, 399, 403, 406, 407, 408, 410, 414, 418, 420, 429, 430, 432, 434, 435, 437, 440, 442, 444, 451, 455, 456, 459, 460, 462, 464, 465, 468, 473, 476, 481, 483, 492, 493, 494, 495, 496, 504, 506, 510, 513, 516, 518, 520, 522, 527, 528, 532, 533, 540, 546, 551, 552, 555, 558, 559, 560, 561, 570, 572, 574, 580, 585, 589, 592, 594, 595, 598, 602, 609, 612, 615, 616, 620, 621, 624, 627, 629, 630, 638, 644, 645, 646, 651, 656, 660, 663, 665, 666, 667, 680, 682, 684, 688, 690, 693, 696, 697, 702, 703, 713, 714, 715, 720, 728, 731, 738, 740, 741, 744, 748, 754, 756, 759, 760, 765, 770, 774, 777, 779, 780, 782, 783, 792, 798, 805, 806, 812, 814, 816, 817, 819, 820, 828, 836, 837, 840, 851, 855, 858, 860, 861, 868, 870, 874, 880, 884, 888, 897, 899, 902, 903, 910, 912, 918, 920, 924, 930, 935, 936, 943, 945, 946, 952, 957, 962, 966, 969, 984, 986, 988, 989, 990, 999, 1001, 1008, 1012, 1015, 1020, 1023, 1026, 1032, 1035, 1036, 1040, 1044, 1045, 1054, 1064, 1066, 1071, 1073, 1080, 1085, 1092, 1102, 1104, 1105, 1107, 1110, 1116, 1118, 1122, 1131, 1140, 1144, 1147, 1148, 1155, 1160, 1161, 1170, 1173, 1178, 1188, 1189, 1190, 1196, 1197, 1204, 1209, 1218, 1221, 1224, 1230, 1232, 1235, 1240, 1242, 1247, 1254, 1258, 1260, 1265, 1271, 1276, 1287, 1288, 1290, 1292, 1295, 1302, 1305, 1309, 1311, 1320, 1326, 1330, 1332, 1333, 1334, 1353, 1360, 1364, 1365, 1368, 1380, 1386, 1392, 1394, 1395, 1404, 1406, 1419, 1426, 1428, 1430, 1435, 1443, 1449, 1456, 1462, 1463, 1476, 1479, 1480, 1482, 1485, 1488, 1495, 1496, 1505, 1508, 1512, 1517, 1518, 1520, 1530, 1540, 1547, 1548, 1554, 1558, 1560, 1564, 1566, 1581, 1584, 1591, 1595, 1596, 1599, 1610, 1612, 1615, 1624, 1628, 1634, 1638, 1640, 1653, 1656, 1665, 1672, 1674, 1677, 1680, 1683, 1702, 1705, 1710, 1716, 1720, 1722, 1729, 1736, 1740, 1748, 1755, 1763, 1767, 1768, 1771, 1776, 1785, 1794, 1798, 1804, 1806, 1820, 1827, 1836, 1840, 1845, 1848, 1860, 1870, 1872, 1881, 1885, 1886, 1887, 1890, 1892, 1904, 1914, 1924, 1932, 1935, 1938, 1953, 1955, 1968, 1972, 1976, 1978, 1980, 1989, 1995, 1998, 2001, 2002, 2015, 2024, 2030, 2035, 2040, 2046, 2052, 2064, 2070, 2072, 2079, 2088, 2090, 2091, 2093, 2108, 2109, 2128, 2132, 2139, 2142, 2145, 2146, 2160, 2170, 2184, 2185, 2193, 2204, 2210, 2214, 2220, 2223, 2232, 2233, 2236, 2244, 2255, 2261, 2262, 2277, 2280, 2288, 2294, 2295, 2296, 2310, 2320, 2322, 2331, 2337, 2340, 2346, 2356, 2365, 2376, 2378, 2380, 2387, 2392, 2394, 2405, 2408, 2415, 2418, 2431, 2436, 2442, 2448, 2451, 2457, 2460, 2465, 2470, 2480, 2484, 2494, 2508, 2516, 2520, 2530, 2542, 2552, 2553, 2565, 2574, 2576, 2580, 2583, 2584, 2590, 2604, 2610, 2618, 2622, 2635, 2639, 2640, 2652, 2660, 2664, 2665, 2666, 2668, 2691, 2697, 2706, 2709, 2717, 2728, 2730, 2736, 2737, 2755, 2760, 2772, 2788, 2790, 2795, 2805, 2808, 2812, 2821, 2829, 2838, 2849, 2852, 2856, 2860, 2870, 2871, 2886, 2898, 2907, 2924, 2926, 2945, 2952, 2958, 2960, 2964, 2967, 2970, 2990, 2992, 3003, 3010, 3016, 3024, 3034, 3036, 3045, 3059, 3060, 3069, 3080, 3094, 3096, 3105, 3108, 3116, 3120, 3128, 3132, 3135, 3145, 3157, 3162, 3182, 3190, 3192, 3198, 3213, 3219, 3220, 3224, 3230, 3248, 3255, 3256, 3268, 3276, 3280, 3289, 3306, 3311, 3312, 3315, 3330, 3335, 3344, 3348, 3354, 3366, 3367, 3393, 3404, 3410, 3420, 3432, 3440, 3441, 3444, 3451, 3458, 3465, 3472, 3480, 3485, 3496, 3510, 3515, 3519, 3526, 3534, 3536, 3542, 3553, 3565, 3567, 3570, 3588, 3591, 3596, 3608, 3612, 3627, 3640, 3654, 3655, 3663, 3672, 3689, 3690, 3696, 3705, 3720, 3731, 3740, 3741, 3762, 3770, 3772, 3774, 3780, 3784, 3795, 3813, 3828, 3848, 3857, 3861, 3864, 3870, 3876, 3885, 3895, 3906, 3910, 3913, 3915, 3927, 3933, 3944, 3952, 3956, 3960, 3978, 3990, 3996, 3999, 4002, 4004, 4030, 4048, 4059, 4060, 4070, 4080, 4085, 4092, 4095, 4104, 4123, 4140, 4144, 4147, 4158, 4176, 4180, 4182, 4185, 4186, 4199, 4216, 4218, 4255, 4257, 4264, 4278, 4284, 4290, 4292, 4301, 4305, 4329, 4340, 4347, 4368, 4370, 4386, 4389, 4403, 4408, 4420, 4428, 4433, 4437, 4440, 4446, 4464, 4466, 4472, 4485, 4488, 4495, 4510, 4515, 4522, 4524, 4551, 4554, 4560, 4588, 4590, 4592, 4620, 4641, 4644, 4662, 4669, 4674, 4680, 4692, 4712, 4715, 4730, 4743, 4752, 4756, 4760, 4773, 4774, 4784, 4785, 4788, 4797, 4807, 4810, 4816, 4830, 4836, 4845, 4862, 4872, 4879, 4884, 4902, 4914, 4920, 4921, 4930, 4940, 4945, 4959, 4968, 4988, 4991, 4995, 5005, 5016, 5031, 5032, 5040, 5049, 5060, 5083, 5084, 5104, 5106, 5115, 5117, 5130, 5148, 5160, 5166, 5168, 5180, 5187, 5208, 5220, 5236, 5244, 5270, 5278, 5289, 5291, 5301, 5304, 5313, 5320, 5328, 5330, 5332, 5336, 5355, 5365, 5382, 5394, 5412, 5418, 5423, 5434, 5453, 5456, 5460, 5474, 5481, 5510, 5520, 5535, 5544, 5576, 5580, 5590, 5610, 5616, 5624, 5642, 5643, 5655, 5658, 5661, 5676, 5681, 5698, 5704, 5712, 5719, 5720, 5735, 5740, 5742, 5772, 5796, 5797, 5805, 5814, 5848, 5852, 5859, 5863, 5865, 5890, 5904, 5916, 5928, 5934, 5940, 5945, 5957, 5967, 5980, 5985, 6003, 6006, 6020, 6032, 6045, 6061, 6068, 6072, 6090, 6105, 6118, 6120, 6138, 6149, 6160, 6188, 6192, 6210, 6216, 6232, 6235, 6256, 6264, 6270, 6273, 6279, 6290, 6293, 6314, 6324, 6327, 6355, 6364, 6380, 6384, 6396, 6409, 6417, 6426, 6435, 6438, 6440, 6448, 6460, 6479, 6510, 6512, 6536, 6545, 6552, 6555, 6578, 6579, 6601, 6612, 6622, 6630, 6660, 6665, 6669, 6670, 6696, 6699, 6708, 6732, 6734, 6765, 6783, 6786, 6808, 6820, 6831, 6840, 6851, 6864, 6882, 6888, 6902, 6916, 6919, 6923, 6930, 6960, 6970, 6992, 6993, 7011, 7020, 7030, 7038, 7052, 7068, 7084, 7095, 7106, 7130, 7134, 7140, 7161, 7163, 7176, 7182, 7192, 7215, 7216, 7224, 7245, 7254, 7280, 7293, 7308, 7310, 7315, 7326, 7337, 7344, 7353, 7378, 7380, 7395, 7410, 7429, 7440, 7462, 7480, 7482, 7511, 7524, 7540, 7544, 7548, 7560, 7568, 7585, 7590, 7626, 7656, 7657, 7659, 7667, 7696, 7714, 7722, 7728, 7733, 7735, 7740, 7749, 7752, 7770, 7790, 7812, 7820, 7826, 7830, 7843, 7854, 7866, 7888, 7905, 7912, 7917, 7920, 7955, 7956, 7980, 7992, 7995, 7998, 8004, 8008, 8029, 8041, 8060, 8073, 8091, 8118, 8120, 8127, 8140, 8151, 8170, 8177, 8184, 8190, 8208, 8211, 8246, 8265, 8280, 8294, 8316, 8323, 8360, 8364, 8370, 8372, 8385, 8398, 8415, 8432, 8436, 8463, 8487, 8510, 8514, 8528, 8547, 8556, 8568, 8569, 8580, 8584, 8602, 8610, 8613, 8645, 8658, 8671, 8680, 8694, 8721, 8729, 8740, 8772, 8778, 8806, 8815, 8816, 8835, 8840, 8855, 8856, 8866, 8874, 8880, 8892, 8897, 8901, 8932, 8944, 8970, 8976, 8987, 8990, 9009, 9020, 9030, 9044, 9048, 9061, 9102, 9108, 9135, 9139, 9176, 9177, 9180, 9207, 9240, 9269, 9282, 9288, 9324, 9331, 9338, 9348, 9360, 9361, 9367, 9384, 9405, 9424, 9430, 9435, 9460, 9471, 9486, 9503, 9512, 9520, 9546, 9548, 9570, 9576, 9594, 9614, 9620, 9657, 9660, 9672, 9690, 9724, 9744, 9758, 9765, 9768, 9804, 9828, 9840, 9842, 9860, 9867, 9880, 9889, 9890, 9918, 9933, 9936, 9945, 9976, 9982, 9990, 10005, 10010, 10013, 10032, 10062, 10064, 10098, 10101, 10120, 10127, 10166, 10168, 10179, 10212, 10230, 10234, 10260, 10296, 10320, 10323, 10332, 10353, 10360, 10373, 10374, 10395, 10416, 10440, 10455, 10465, 10472, 10488, 10540, 10545, 10556, 10557, 10578, 10582, 10602, 10608, 10619, 10621, 10626, 10640, 10659, 10660, 10664, 10672, 10695, 10701, 10710, 10730, 10764, 10788, 10824, 10836, 10846, 10868, 10879, 10881, 10906, 10920, 10948, 10962, 10965, 10989, 11020, 11063, 11067, 11070, 11088, 11115, 11137, 11152, 11160, 11165, 11180, 11193, 11220, 11223, 11248, 11284, 11286, 11305, 11310, 11316, 11322, 11339, 11352, 11362, 11385, 11396, 11408, 11438, 11439, 11440, 11470, 11480, 11484, 11544, 11571, 11592, 11594, 11610, 11628, 11655, 11685, 11687, 11696, 11704, 11718, 11726, 11730, 11739, 11780, 11781, 11799, 11803, 11832, 11856, 11868, 11880, 11890, 11914, 11934, 11935, 11951, 11960, 11970, 11997, 12006, 12012, 12040, 12090, 12121, 12122, 12136, 12144, 12155, 12177, 12180, 12210, 12236, 12240, 12255, 12259, 12276, 12285, 12298, 12341, 12369, 12376, 12420, 12432, 12441, 12464, 12470, 12528, 12540, 12546, 12558, 12580, 12586, 12597, 12617, 12628, 12648, 12654, 12673, 12710, 12728, 12760, 12765, 12771, 12792, 12818, 12834, 12852, 12857, 12870, 12876, 12880, 12903, 12915, 12920, 12958, 12987, 13020, 13072, 13079, 13090, 13104, 13110, 13156, 13158, 13167, 13195, 13202, 13209, 13224, 13243, 13244, 13260, 13299, 13311, 13320, 13330, 13338, 13340, 13392, 13398, 13416, 13455, 13464, 13468, 13485, 13530, 13545, 13547, 13566, 13572, 13585, 13616, 13640, 13653, 13662, 13680, 13685, 13702, 13717, 13764, 13776, 13804, 13832, 13838, 13846, 13860, 13889, 13923, 13940, 13949, 13981, 13986, 14007, 14022, 14040, 14060, 14076, 14104, 14105, 14136, 14145, 14168, 14190, 14212, 14229, 14245, 14260, 14268, 14280, 14319, 14322, 14326, 14352, 14355, 14364, 14384, 14391, 14421, 14430, 14448, 14467, 14490, 14508, 14535, 14586, 14616, 14620, 14630, 14637, 14652, 14663, 14674, 14706, 14756, 14760, 14763, 14790, 14820, 14835, 14858, 14877, 14911, 14924, 14960, 14964, 14973, 15015, 15022, 15048, 15080, 15088, 15093, 15096, 15120, 15170, 15180, 15249, 15252, 15283, 15295, 15312, 15314, 15318, 15334, 15345, 15351, 15428, 15444, 15457, 15466, 15470, 15480, 15498, 15504, 15540, 15561, 15580, 15624, 15640, 15652, 15660, 15686, 15708, 15732, 15785, 15810, 15824, 15834, 15867, 15873, 15903, 15910, 15912, 15939, 15960, 15984, 15990, 15996, 16008, 16016, 16031, 16058, 16065, 16082, 16095, 16120, 16146, 16169, 16182, 16211, 16236, 16240, 16254, 16269, 16280, 16302, 16340, 16354, 16359, 16368, 16380, 16422, 16445, 16492, 16523, 16530, 16555, 16560, 16588, 16632, 16646, 16687, 16720, 16728, 16740, 16744, 16770, 16796, 16813, 16830, 16835, 16872, 16926, 16965, 16974, 16983, 17017, 17020, 17028, 17043, 17081, 17094, 17112, 17136, 17138, 17157, 17160, 17168, 17204, 17205, 17220, 17226, 17255, 17290, 17316, 17329, 17342, 17360, 17388, 17391, 17442, 17458, 17480, 17501, 17544, 17556, 17589, 17595, 17612, 17630, 17670, 17680, 17710, 17712, 17732, 17748, 17765, 17784, 17794, 17802, 17835, 17864, 17871, 17917, 17940, 17955, 17974, 17980, 18009, 18018, 18040, 18060, 18088, 18096, 18122, 18135, 18183, 18204, 18216, 18241, 18270, 18278, 18315, 18352, 18354, 18360, 18414, 18445, 18447, 18480, 18538, 18564, 18576, 18648, 18655, 18662, 18676, 18696, 18705, 18722, 18734, 18768, 18791, 18810, 18819, 18837, 18860, 18870, 18879, 18920, 18942, 18972, 18981, 19006, 19019, 19024, 19065, 19092, 19096, 19140, 19152, 19188, 19227, 19228, 19240, 19251, 19285, 19305, 19314, 19320, 19344, 19380, 19393, 19437, 19448, 19499, 19516, 19530, 19536, 19565, 19608, 19635, 19656, 19665, 19684, 19720, 19721, 19734, 19737, 19760, 19778, 19780, 19803, 19836, 19866, 19890, 19952, 19964, 19980, 19995, 20010, 20020, 20026, 20097, 20124, 20196, 20202, 20213, 20240, 20254, 20295, 20332, 20336, 20349, 20358, 20387, 20424, 20460, 20468, 20520, 20553, 20592, 20615, 20646, 20664, 20677, 20683, 20706, 20720, 20735, 20746, 20748, 20757, 20769, 20790, 20880, 20910, 20930, 20944, 20976, 20995, 21033, 21080, 21090, 21112, 21114, 21156, 21164, 21199, 21204, 21238, 21242, 21252, 21285, 21318, 21320, 21328, 21390, 21402, 21420, 21460, 21483, 21489, 21505, 21528, 21576, 21607, 21645, 21648, 21672, 21692, 21735, 21736, 21758, 21762, 21793, 21812, 21840, 21879, 21896, 21924, 21930, 21945, 21978, 22011, 22015, 22040, 22059, 22126, 22134, 22140, 22165, 22185, 22230, 22274, 22287, 22320, 22330, 22360, 22386, 22440, 22446, 22533, 22568, 22572, 22591, 22610, 22620, 22632, 22644, 22661, 22678, 22704, 22724, 22755, 22770, 22792, 22876, 22878, 22919, 22940, 22960, 22968, 22971, 22977, 23001, 23023, 23088, 23142, 23184, 23188, 23199, 23205, 23220, 23256, 23310, 23345, 23370, 23374, 23408, 23436, 23452, 23460, 23478, 23529, 23560, 23562, 23598, 23606, 23664, 23693, 23715, 23736, 23751, 23760, 23780, 23828, 23865, 23868, 23870, 23902, 23920, 23940, 23985, 23994, 24012, 24024, 24035, 24080, 24087, 24123, 24149, 24180, 24242, 24244, 24272, 24273, 24310, 24354, 24360, 24395, 24420, 24453, 24472, 24510, 24518, 24531, 24552, 24570, 24596, 24605, 24633, 24679, 24682, 24738, 24752, 24795, 24840, 24871, 24882, 24940, 24955, 24969, 25080, 25092, 25116, 25155, 25160, 25172, 25194, 25234, 25245, 25256, 25296, 25308, 25327, 25346, 25389, 25415, 25420, 25456, 25461, 25520, 25530, 25542, 25584, 25585, 25636, 25641, 25668, 25704, 25707, 25714, 25740, 25752, 25789, 25806, 25830, 25840, 25916, 25935, 25974, 26013, 26040, 26158, 26180, 26187, 26220, 26312, 26316, 26334, 26381, 26390, 26404, 26418, 26445, 26448, 26455, 26486, 26488, 26505, 26520, 26565, 26598, 26622, 26640, 26660, 26676, 26680, 26691, 26703, 26796, 26832, 26910, 26928, 26936, 26961, 26970, 27027, 27047, 27060, 27090, 27094, 27115, 27132, 27144, 27170, 27183, 27265, 27280, 27306, 27324, 27347, 27370, 27404, 27405, 27417, 27434, 27528, 27531, 27608, 27664, 27676, 27692, 27720, 27778, 27807, 27846, 27880, 27898, 27962, 27972, 27993, 28014, 28044, 28080, 28083, 28101, 28120, 28152, 28208, 28210, 28215, 28272, 28290, 28305, 28336, 28380, 28405, 28413, 28424, 28458, 28490, 28509, 28520, 28536, 28560, 28595, 28638, 28644, 28652, 28681, 28710, 28728, 28782, 28823, 28842, 28860, 28934, 28971, 28980, 28985, 29016, 29029, 29070, 29172, 29232, 29233, 29240, 29260, 29274, 29295, 29304, 29315, 29326, 29348, 29393, 29412, 29512, 29520, 29526, 29580, 29601, 29640, 29667, 29670, 29716, 29754, 29785, 29799, 29822, 29835, 29848, 29928, 29946, 29971, 30015, 30030, 30039, 30044, 30096, 30107, 30160, 30186, 30192, 30229, 30303, 30305, 30340, 30360, 30381, 30498, 30504, 30566, 30590, 30628, 30636, 30659, 30668, 30690, 30702, 30745, 30856, 30888, 30914, 30932, 30940, 30960, 30969, 30996, 31031, 31059, 31080, 31119, 311"
message = Alice.send(send_text)
try:
    receive_text = Bob.receive(copy.deepcopy(message))
    if receive_text != None:
        print(receive_text)
except:
    print("Error:密钥错误,解密失败")
print("{:-^50}".format("END"))

测试截图

image-20211017220358619

写在最后:

  • 本文由$\color{Red}\text{21-信软-LRL52原创撰写}$
  • 由于CNSS截止日期更早难度更大,就不得不先做它们的题了,军训做题时间比较少,凌睿的网安题我一定会回来做的,但愿截止日期能晚一些(`・ω・´)
  • 写于$2021.10.17$日晚
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇