Add nonce and initial_value parameters to CTR mode

This commit is contained in:
Legrandin 2015-12-20 21:27:21 +01:00
parent 6fc0c734a2
commit c74b718aa6
13 changed files with 210 additions and 71 deletions

View file

@ -129,9 +129,12 @@ def new(key, mode, *args, **kwargs):
For all other modes, it must be 8 bytes long.
nonce : byte string
(*Only* `MODE_EAX`).
(*Only* `MODE_EAX` and `MODE_CTR`).
A mandatory value that must never be reused for any other encryption.
There are no restrictions on its length, but it is recommended to
For `MODE_CTR`, its length must be in the range ``[0..7]``.
For `MODE_EAX`, there are no restrictions, but it is recommended to
use at least 16 bytes.
counter : object
(*Only* `MODE_CTR`). An object created by `Crypto.Util.Counter`.
@ -142,6 +145,9 @@ def new(key, mode, *args, **kwargs):
(*Only* `MODE_CFB`).The number of bits the plaintext and ciphertext
are segmented in.
It must be a multiple of 8. If not specified, it will be assumed to be 8.
initial_value : integer
(*Only* `MODE_CTR`). The initial value for the counter within
the counter block. By default it is 0.
:Return: a CAST cipher object, of the applicable mode.
"""