3 M(ÌYxã@s,dZddlmZdd„Zdd„Zdd„Zd S) z}Core mathematical operations. This is the actual core RSA implementation, which is only defined mathematically on integers. é)Ú is_integercCs"t|ƒr dStd||jfƒ‚dS)Nz%s should be an integer, not %s)rÚ TypeErrorÚ __class__)ÚvarÚname©rú//private/tmp/pip-build-nl73fm5q/rsa/rsa/core.pyÚ assert_intsr cCsRt|dƒt|dƒt|dƒ|dkr.tdƒ‚||krFtd||fƒ‚t|||ƒS)z@Encrypts a message using encryption key 'ekey', working modulo nÚmessageÚekeyÚnrz'Only non-negative numbers are supportedz#The message %i is too long for n=%i)r Ú ValueErrorÚ OverflowErrorÚpow)r r r rrrÚ encrypt_int!s   rcCs.t|dƒt|dƒt|dƒt|||ƒ}|S)zHDecrypts a cypher text using the decryption key 'dkey', working modulo nÚ cyphertextÚdkeyr )r r)rrr r rrrÚ decrypt_int1s     rN)Ú__doc__Z rsa._compatrr rrrrrrÚs