密码学基础---椭圆曲线加密算法ECC(ELGamal Diffie-Hellman)

在这里插入图片描述
1 数学基础
利用椭圆曲线上的有理点构成Abel加法群上椭圆离散对数的计算困难性
安全性依赖于求解椭圆曲线离散对数问题的困难性,即已知椭圆曲线上的点P 和 kP 计算k的困难程度
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述加密流程
在这里插入图片描述
示例
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
椭圆曲线的密钥协商(基于Diffie Hellman)
在这里插入图片描述
通过ELGamal改进的ECC加密解密
在这里插入图片描述
与传统ECC加密对比:
加密过程钟 C2中的加法运算变为与协商密钥相加
在这里插入图片描述

  • 4
    点赞
  • 40
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
AES(高级加密标准)加密代码: ```python from Crypto.Cipher import AES from Crypto.Random import get_random_bytes key = get_random_bytes(16) cipher = AES.new(key, AES.MODE_EAX) ciphertext, tag = cipher.encrypt_and_digest(data) ``` RSA(Rivest-Shamir-Adleman)加密代码: ```python from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP key = RSA.generate(2048) cipher = PKCS1_OAEP.new(key) ciphertext = cipher.encrypt(data) ``` ECC椭圆曲线加密)加密代码: ```python from tinyec import registry curve = registry.get_curve('secp256r1') public_key = curve.g * private_key shared_key = public_key * remote_private_key ``` DES(数据加密标准)加密代码: ```python from Crypto.Cipher import DES key = b'abcdefgh' cipher = DES.new(key, DES.MODE_ECB) ciphertext = cipher.encrypt(data) ``` 3DES(Triple DES)加密代码: ```python from Crypto.Cipher import DES3 key = b'abcdefghabcdefghabcdefgh' cipher = DES3.new(key, DES3.MODE_ECB) ciphertext = cipher.encrypt(data) ``` Rabin加密代码: ```python from Crypto.PublicKey import Rabin from Crypto.Cipher import PKCS1_v1_5 key = Rabin.generate(2048) cipher = PKCS1_v1_5.new(key) ciphertext = cipher.encrypt(data) ``` ElGamal加密代码: ```python from Crypto.PublicKey import ElGamal from Crypto.Cipher import ElGamal from Crypto import Random key = ElGamal.generate(2048, Random.new().read) cipher = ElGamal.new(key) ciphertext = cipher.encrypt(data, 0) ``` Diffie-Hellman加密代码: ```python from Crypto.PublicKey import DH from Crypto.Hash import SHA256 key = DH.generate(2048) public_key = key.publickey() ``` 以上代码仅用于演示目的,实际使用时应该仔细考虑安全性和性能等因素。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值