Fix EMSA-PKCS1-v1_5-ENCODE digest length check. The spec requires at least 8 bytes of padding.
This commit is contained in:
+3
-2
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'DigestTooLargeError',
|
'DigestTooLargeError',
|
||||||
|
'parse_pem_private_key',
|
||||||
'parse_private_key',
|
'parse_private_key',
|
||||||
'parse_public_key',
|
'parse_public_key',
|
||||||
'RSASSA_PKCS1_v1_5_sign',
|
'RSASSA_PKCS1_v1_5_sign',
|
||||||
@@ -138,7 +139,7 @@ def parse_private_key(data):
|
|||||||
|
|
||||||
|
|
||||||
def parse_pem_private_key(data):
|
def parse_pem_private_key(data):
|
||||||
"""Parse a PEM private key.
|
"""Parse a PEM RSA private key.
|
||||||
|
|
||||||
@param data: RFC3447 RSAPrivateKey in PEM format.
|
@param data: RFC3447 RSAPrivateKey in PEM format.
|
||||||
@return: RSA private key
|
@return: RSA private key
|
||||||
@@ -168,7 +169,7 @@ def EMSA_PKCS1_v1_5_encode(hash, mlen):
|
|||||||
]),
|
]),
|
||||||
(OCTET_STRING, hash.digest()),
|
(OCTET_STRING, hash.digest()),
|
||||||
]))
|
]))
|
||||||
if len(dinfo)+3 > mlen:
|
if len(dinfo) + 11 > mlen:
|
||||||
raise DigestTooLargeError()
|
raise DigestTooLargeError()
|
||||||
return "\x00\x01"+"\xff"*(mlen-len(dinfo)-3)+"\x00"+dinfo
|
return "\x00\x01"+"\xff"*(mlen-len(dinfo)-3)+"\x00"+dinfo
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user