rsa

Cube root modulo P — how do I do this?

Cube root modulo P — how do I do this? Question: I am trying to calculate the cube root of a many-hundred digit number modulo P in Python, and failing miserably. I found code for the Tonelli-Shanks algorithm which supposedly is simple to modify from square roots to cube roots, but this eludes me. I’ve …

Total answers: 4

RSA encryption in python

RSA encryption in python Question: I decided to write a simple RSA encryption implementation in Python, but every time I run it it prints the error IndexError: list out of range when it’s decrypting and in find_key. Here’s the error: p 937 q 353 n 330761 phi 329472 e 5 d 264609 Traceback (most recent …

Total answers: 3

extracting public key from certificate and encrypting data

extracting public key from certificate and encrypting data Question: This is for a homework assignment! I get the server’s certificate using get_peer_certificate() and the calling dump_certificate to dump the certificate in a variable. The format is PEM and looks right to me. —–BEGIN CERTIFICATE—– GIBBERISH……………. …………………. …………………… —–END CERTIFICATE—– How do I extract the server’s …

Total answers: 4

How do you verify an RSA SHA1 signature in Python?

How do you verify an RSA SHA1 signature in Python? Question: I’ve got a string, a signature, and a public key, and I want to verify the signature on the string. The key looks like this: —–BEGIN PUBLIC KEY—– MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDfG4IuFO2h/LdDNmonwGNw5srW nUEWzoBrPRF1NM8LqpOMD45FAPtZ1NmPtHGo0BAS1UsyJEGXx0NPJ8Gw1z+huLrl XnAVX5B4ec6cJfKKmpL/l94WhP2v8F3OGWrnaEX1mLMoxe124Pcfamt0SPCGkeal VvXw13PLINE/YptjkQIDAQAB —–END PUBLIC KEY—– I’ve been reading the pycrypto docs for a while, …

Total answers: 8