Created
October 20, 2022 10:14
-
-
Save paulsc/01f122d80fb8e981dabd5a44a7933722 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def verify(self, m, s): | |
if len(s) != self.bits//8: | |
raise Exception('incorrect signature length') | |
s = int.from_bytes(s, 'big') | |
k = pow(s, self.e, self.n) | |
k = int.to_bytes(k, self.bits//8, 'big') | |
if k[0] != 0x00: | |
raise Exception('incorrect prefix') | |
if k[1] != 0x01: | |
raise Exception('incorrect prefix') | |
padding, digest_info = k[2:].split(b'\x00', 1) | |
if len(padding) < 8: | |
raise Exception('invalid padding length') | |
if padding != b'\xff'*len(padding): | |
raise Exception('invalid padding content') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment