I am trying to decrypt an encrypted openSSL certificate using the Crypto library. For that, I use the following function :
def decryptMessage(privateKeyString, encryptedMessage):
print 'Enter private key pass phrase'
passPhrase = raw_input()
privateKey= RSA.importKey(privateKeyString, passPhrase)
return privateKey.decrypt(ast.literal_eval(str(encryptedMessage)))
This function works fine with small strings such as foo
or lorem ipsum
.
However, when I try to decrypt a larger string such as an OpenSSL certificate, the decryption fails and returns this
#«$,^5ô¦┬{¯9██─╚áW¸ÍÀóÂ╗ö▓├ô{Òv&s´À;d▒§= I×òòòÿÞ:Mu▄ñ├Zc╬a╣fÙ╚g╝z¯¹þÞÖ*└²}?õÑ:~Ì ôı*▓açõ─░3Ñz{³é├ p}7Ĭ/tıN®╣¥‗Pzô£▄¤▄╩Ý,æQ'mfî.«¯┴C%tÏýõ/ñlÚ0╗ò¼(Ï5▓ø5Ì└ûƒuƒä£█ÂF=)─y@O~§L߯▄Ð░mËÅ9Uwõh▀Û/▓Ï,APð HѪm■Îç¼"§Ô,XvÓÏÄÃM■▓v╠@örÂùuE
Thus, I'd like to know how my function fails to decrypt bigger strings.