This is one reason why files are generally not encrypted using RSA directly. Adding the padding means a not-insignificant amount of overhead is added before the message is applied the amount of plaintext is much smaller than the RSA modulus. This would be either the PKCS#1 v1.5 defined padding or OAEP padding. In PKCS#1 based RSA OS2IP is not used directly though: first a security relevant padding is applied. If the bytes are already in the right form then it is just a question of interpreting the bytes as a number, as the computer always handles everything as binary anyway. An octet string is nothing more than a byte array. OS2IP means octet string to integer primitive. In your case the text is obviously already encoded as bytes files consist of bytes after all, and you are opening the file as a binary file (the b in the rb flag). encode the bytes to integer - this is part of the encryption operation in RSA as specified in PKCS#1, and is performed using a function called OS2IP.encode the text to bytes - this generally requires a character encoding such as UTF-8 or Latin encoding.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |