最优非对称加密填充(OAEP)和PSS(Probabilistic Signature Scheme)

Optimal asymmetric encryption padding(OAEP),最优非对称加密填充,RSA的加密解密是基于OAEP的。

PSS (Probabilistic Signature Scheme) ,RSA的签名验证是基于PSS的。


The signature schemes are actually signatures with appendix, which means that rather than signing some input data directly a hash function is used first to produce an intermediary representation of the data and then the result of the hash is signed. This technique is almost always used with RSA because the amount of data that can be directly signed is proportional to the size of the keys; which is almost always much smaller than the amount of data an application may wish to sign.

 

RSAES-OAEP: improved encryption/decryption scheme。
RSASSA-PSS: improved probabilistic signature scheme with appendix;
EMSA-PSS: encoding method for signature appendix, probabilistic signature scheme.

In cryptography, Optimal Asymmetric Encryption Padding (OAEP) is a padding scheme often used together with RSA encryption. OAEP was introduced by Bellare and Rogaway.[1]

The OAEP algorithm is a form of Feistel network which uses a pair of random oracles G and H to process the plaintext prior to asymmetric encryption. When combined with any secure trapdoor one-way permutation f, this processing is proved in the random oracle model to result in a combined scheme which is semantically secure under chosen plaintext attack (IND-CPA). When implemented with certain trapdoor permutations (e.g., RSA), OAEP is also proved secure against chosen ciphertext attack. OAEP can be used to build an all-or-nothing transform.

OAEP satisfies the following two goals:
Add an element of randomness which can be used to convert a deterministic encryption scheme (e.g., traditional RSA) into a probabilistic scheme.
Prevent partial decryption of ciphertexts (or other information leakage) by ensuring that an adversary cannot recover any portion of the plaintext without being able to invert the trapdoor one-way permutation f.

The original version of OAEP (Bellare/Rogaway, 1994) showed a form of "plaintext awareness" (which they claimed implies security against chosen ciphertext attack) in the random oracle model when OAEP is used with any trapdoor permutation. Subsequent results contradicted this claim, showing that OAEP was only IND-CCA1 secure. However, the original scheme was proved in the random oracle model to be IND-CCA2 secure when OAEP is used with the RSA permutation using standard encryption exponents, as in the case of RSA-OAEP. [2] An improved scheme (called OAEP+) that works with any trapdoor one-way permutation was offered by Victor Shoup to solve this problem.[3] More recent work has shown that in the standard model (that is, when hash functions are not modelled as random oracles), that it is impossible to prove the IND-CCA2 security of RSA-OAEP under the assumed hardness of the RSA problem

 

OAEP

In the diagram,
n is the number of bits in the RSA modulus.
k0 and k1 are integers fixed by the protocol.
m is the plaintext message, an (n − k0 − k1 )-bit string
G and H are typically some cryptographic hash functions fixed by the protocol.

To encode,
messages are padded with k1 zeros to be n − k0 bits in length.
r is a random k0-bit string
G expands the k0 bits of r to n − k0 bits.
X = m00..0 ⊕ G(r)
H reduces the n − k0 bits of X to k0 bits.
Y = r ⊕ H(X)
The output is X || Y where X is shown in the diagram as the leftmost block and Y as the rightmost block.

To decode,
recover the random string as r = Y ⊕ H(X)
recover the message as m00..0 = X ⊕ G(r)


The "all-or-nothing" security is from the fact that to recover m, you must recover the entire X and the entire Y; X is required to recover r from Y, and r is required to recover m from X. Since any bit of a cryptographic hash completely changes the result, the entire X, and the entire Y must both be completely recovered.

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python 提供了多种实现非对称加密的库,其中最常用的是 RSA 加密算法。RSA 算法是一种公钥加密算法,它可以用于加密和数字签名。在 RSA 算法中,公钥和私钥是一对密钥,其中公钥可以公开,任何人都可以使用它对数据进行加密,而私钥只有私有的所有者才能访问,用于解密数据或者签名。 在 Python 中,可以使用 Crypto 库来实现 RSA 加密。下面是一个简单的例子: ```python from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP # 生成密钥对 key = RSA.generate(2048) # 获取公钥和私钥 private_key = key.export_key() public_key = key.publickey().export_key() # 使用公钥加密数据 cipher = PKCS1_OAEP.new(RSA.import_key(public_key)) encrypted_data = cipher.encrypt(b"Hello World!") # 使用私钥解密数据 cipher = PKCS1_OAEP.new(RSA.import_key(private_key)) decrypted_data = cipher.decrypt(encrypted_data) print(decrypted_data.decode()) # 输出: Hello World! ``` 在这个例子中,首先使用 RSA.generate() 方法生成了一个 RSA 密钥对,然后使用 export_key() 方法获取了公钥和私钥。接着,使用公钥对一段数据进行了加密,并使用私钥对加密后的数据进行了解密。最后,输出了解密后的数据。 需要注意的是,在实际应用中,对于非对称加密算法,我们通常不会直接加密原始数据,而是会先使用对称加密算法加密原始数据,然后再使用公钥加密对称密钥,最后将加密后的对称密钥和加密后的密文一起发送给接收方。接收方使用私钥解密对称密钥,然后使用对称密钥解密密文。这样做的好处是可以避免使用非对称加密算法对大量数据进行加密和解密,从而提高效率。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值