summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLegrandin <helderijs@gmail.com>2013-05-08 07:27:03 +0200
committerDwayne Litzenberger <dlitz@dlitz.net>2013-07-14 23:08:47 -0700
commit74bd74f490f4eadbfa9a3d750645b21e46679317 (patch)
tree9351f33a1c48a7bac0a8eeef13dccb1146d5afb5
parent7636f5052bfb631ff9436d8cb2fe8ac01ea8ca01 (diff)
downloadpycrypto-74bd74f490f4eadbfa9a3d750645b21e46679317.tar.gz
FIX #1177614. Clarify that RSA OAEP only works on byte strings
Closes: https://bugs.launchpad.net/pycrypto/+bug/1177614
-rw-r--r--lib/Crypto/Cipher/PKCS1_OAEP.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/Crypto/Cipher/PKCS1_OAEP.py b/lib/Crypto/Cipher/PKCS1_OAEP.py
index f0754e4..ff45719 100644
--- a/lib/Crypto/Cipher/PKCS1_OAEP.py
+++ b/lib/Crypto/Cipher/PKCS1_OAEP.py
@@ -31,7 +31,7 @@ As an example, a sender may encrypt a message in this way:
>>> from Crypto.Cipher import PKCS1_OAEP
>>> from Crypto.PublicKey import RSA
>>>
- >>> message = 'To be encrypted'
+ >>> message = b'To be encrypted'
>>> key = RSA.importKey(open('pubkey.der').read())
>>> cipher = PKCS1_OAEP.new(key)
>>> ciphertext = cipher.encrypt(message)
@@ -70,8 +70,8 @@ class PKCS1OAEP_Cipher:
:Parameters:
key : an RSA key object
- If a private half is given, both encryption and decryption are possible.
- If a public half is given, only encryption is possible.
+ If a private half is given, both encryption and decryption are possible.
+ If a public half is given, only encryption is possible.
hashAlgo : hash object
The hash function to use. This can be a module under `Crypto.Hash`
or an existing hash object created from any of such modules. If not specified,
@@ -80,7 +80,7 @@ class PKCS1OAEP_Cipher:
A mask generation function that accepts two parameters: a string to
use as seed, and the lenth of the mask to generate, in bytes.
If not specified, the standard MGF1 is used (a safe choice).
- label : string
+ label : byte string
A label to apply to this particular encryption. If not specified,
an empty string is used. Specifying a label does not improve
security.
@@ -117,12 +117,12 @@ class PKCS1OAEP_Cipher:
section 7.1.1 of RFC3447.
:Parameters:
- message : string
+ message : byte string
The message to encrypt, also known as plaintext. It can be of
variable length, but not longer than the RSA modulus (in bytes)
minus 2, minus twice the hash output size.
- :Return: A string, the ciphertext in which the message is encrypted.
+ :Return: A byte string, the ciphertext in which the message is encrypted.
It is as long as the RSA modulus (in bytes).
:Raise ValueError:
If the RSA key length is not sufficiently long to deal with the given
@@ -173,10 +173,10 @@ class PKCS1OAEP_Cipher:
section 7.1.2 of RFC3447.
:Parameters:
- ct : string
+ ct : byte string
The ciphertext that contains the message to recover.
- :Return: A string, the original message.
+ :Return: A byte string, the original message.
:Raise ValueError:
If the ciphertext length is incorrect, or if the decryption does not
succeed.
@@ -243,7 +243,7 @@ def new(key, hashAlgo=None, mgfunc=None, label=b('')):
A mask generation function that accepts two parameters: a string to
use as seed, and the lenth of the mask to generate, in bytes.
If not specified, the standard MGF1 is used (a safe choice).
- label : string
+ label : byte string
A label to apply to this particular encryption. If not specified,
an empty string is used. Specifying a label does not improve
security.