Skip to content

Commit 35798ec

Browse files
updated docstrings
1 parent 67b1742 commit 35798ec

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

paddingoracle.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
from itertools import izip, cycle
77
import logging
88

9+
__all__ = [
10+
'BadPaddingException',
11+
'PaddingOracle',
12+
]
13+
914

1015
class BadPaddingException(Exception):
1116
'''
@@ -20,10 +25,9 @@ class PaddingOracle(object):
2025
Implementations should subclass this object and implement
2126
the :meth:`oracle` method.
2227
23-
:param max_retries: Number of attempts per byte to reveal a
28+
:param int max_retries: Number of attempts per byte to reveal a
2429
padding oracle, default is 3. If an oracle does not reveal
25-
itself within `max_retries`, a :exception:`RuntimeError` is
26-
raised.
30+
itself within `max_retries`, a :exc:`RuntimeError` is raised.
2731
'''
2832

2933
def __init__(self, **kwargs):
@@ -38,14 +42,15 @@ def oracle(self, data):
3842
'''
3943
Feeds *data* to a decryption function that reveals a Padding
4044
Oracle. If a Padding Oracle was revealed, this method
41-
should raise a :class:`.BadPaddingException`, otherwise this
42-
method should just return. A history of all responses should be
43-
stored in :attribute:`history`, regardless
44-
of whether they revealed a Padding Oracle or not. Responses
45-
from :attribute:`history` are fed to
46-
:meth:`analyze` to help identify padding oracles.
47-
48-
:param data: A bytearray of (fuzzed) encrypted bytes.
45+
should raise a :exc:`.BadPaddingException`, otherwise this
46+
method should just return.
47+
48+
A history of all responses should be stored in :attr:`~.history`,
49+
regardless of whether they revealed a Padding Oracle or not.
50+
Responses from :attr:`~.history` are fed to :meth:`analyze` to
51+
help identify padding oracles.
52+
53+
:param bytearray data: A bytearray of (fuzzed) encrypted bytes.
4954
:raises: :class:`BadPaddingException` if decryption reveals an
5055
oracle.
5156
'''
@@ -54,7 +59,7 @@ def oracle(self, data):
5459
def analyze(self):
5560
'''
5661
This method analyzes return :meth:`oracle` values stored in
57-
:attribute:`history` and returns the most likely
62+
:attr:`~.history` and returns the most likely
5863
candidate(s) that reveals a padding oracle.
5964
'''
6065
raise NotImplementedError
@@ -64,7 +69,7 @@ def encrypt(self, plaintext, block_size=8, iv=None):
6469
Encrypts *plaintext* by exploiting a Padding Oracle.
6570
6671
:param plaintext: Plaintext data to encrypt.
67-
:param block_size: Cipher block size (in bytes).
72+
:param int block_size: Cipher block size (in bytes).
6873
:param iv: The initialization vector (iv), usually the first
6974
*block_size* bytes from the ciphertext. If no iv is given
7075
or iv is None, the first *block_size* bytes will be null's.
@@ -101,7 +106,7 @@ def decrypt(self, ciphertext, block_size=8, iv=None):
101106
Decrypts *ciphertext* by exploiting a Padding Oracle.
102107
103108
:param ciphertext: Encrypted data.
104-
:param block_size: Cipher block size (in bytes).
109+
:param int block_size: Cipher block size (in bytes).
105110
:param iv: The initialization vector (iv), usually the first
106111
*block_size* bytes from the ciphertext. If no iv is given
107112
or iv is None, the first *block_size* bytes will be used.
@@ -150,7 +155,7 @@ def bust(self, block, block_size=8):
150155
:meth:`decrypt`.
151156
152157
:param block:
153-
:param block_size:
158+
:param int block_size: Cipher block size (in bytes).
154159
:returns: A bytearray containing the decrypted bytes
155160
'''
156161
intermediate_bytes = bytearray()

0 commit comments

Comments
 (0)