Skip to content

Commit 0c98360

Browse files
committed
Added CTR mode
1 parent c6d8e66 commit 0c98360

36 files changed

Lines changed: 12430 additions & 360 deletions

README.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Features
2121

2222
Because it's build direct on top of the reference implementation, the python-camellia library provides direct
2323
access to extreme low-level functions like *Camellia-Ekeygen* but also provides a nearly PEP-compliant
24-
cryptographic interface. This semi low-level interface supports encryption (and decryption) in ECB and
25-
CBC mode.
24+
cryptographic interface. This semi low-level interface supports encryption (and decryption) in ECB,
25+
CBC and CTR mode.
2626

2727
Installation
2828
============
@@ -111,6 +111,7 @@ This software contains compiled encryption algorithms which is restricted by law
111111
Changelog
112112
=========
113113

114-
Version 1.0, 2016-10-19:
114+
For Version 1.0:
115115
- The "normal" camellia version is used instead of the mini or reference version.
116-
- Camellia is now loaded using CFFI. This improves speed and avoids shipped DLLs. It's better than the self-made-on-first-use compilation.
116+
- Camellia is now loaded using CFFI. This improves speed and avoids shipped DLLs. It's better than the self-made-on-first-use compilation.
117+
- Supports CTR mode

doc/_build/doctrees/API.doctree

1.45 KB
Binary file not shown.
-81.7 KB
Binary file not shown.

doc/_build/doctrees/index.doctree

105 Bytes
Binary file not shown.
-3 Bytes
Binary file not shown.
-3 Bytes
Binary file not shown.

doc/_build/html/.buildinfo

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Sphinx build info version 1
2-
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: c411847dc38334b72e6da1e42e416489
4-
tags: 645f666f9bcd5a90fca523b33c5a78b7
1+
# Sphinx build info version 1
2+
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: a9bd01a32b8279da3f18ac4c36c111ab
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7

doc/_build/html/API.html

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
VERSION: '1.0',
1818
COLLAPSE_INDEX: false,
1919
FILE_SUFFIX: '.html',
20-
HAS_SOURCE: true
20+
HAS_SOURCE: true,
21+
SOURCELINK_SUFFIX: '.txt'
2122
};
2223
</script>
2324
<script type="text/javascript" src="_static/jquery.js"></script>
2425
<script type="text/javascript" src="_static/underscore.js"></script>
2526
<script type="text/javascript" src="_static/doctools.js"></script>
26-
<link rel="top" title="python-camellia 1.0 documentation" href="index.html" />
27-
<link rel="prev" title="Welcome to python-camellia’s documentation!" href="index.html" />
27+
<link rel="index" title="Index" href="genindex.html" />
28+
<link rel="search" title="Search" href="search.html" />
29+
<link rel="prev" title="Licenses" href="license.html" />
2830

2931
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
3032

31-
3233
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
3334

3435
</head>
@@ -46,7 +47,7 @@ <h1>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</
4647
<h2>The <em>new</em> constructor<a class="headerlink" href="#the-new-constructor" title="Permalink to this headline"></a></h2>
4748
<dl class="function">
4849
<dt id="camellia.new">
49-
<code class="descclassname">camellia.</code><code class="descname">new</code><span class="sig-paren">(</span><em>key</em>, <em>mode=1</em>, <em>IV=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#camellia.new" title="Permalink to this definition"></a></dt>
50+
<code class="descclassname">camellia.</code><code class="descname">new</code><span class="sig-paren">(</span><em>key</em>, <em>mode=1</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#camellia.new" title="Permalink to this definition"></a></dt>
5051
<dd><p>Create an &#8220;CamelliaCipher&#8221; object.
5152
It&#8217;s not fully PEP-272 comliant (yet).
5253
The default mode is ECB.</p>
@@ -56,9 +57,9 @@ <h2>The <em>new</em> constructor<a class="headerlink" href="#the-new-constructor
5657
<tbody valign="top">
5758
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
5859
<li><strong>key</strong> (<em>bytestring</em>) &#8211; The key for encrytion/decryption. Must be 16/24/32 in length.</li>
59-
<li><strong>mode</strong> (<em>int, on of MODE_* constants</em>) &#8211; Mode of operation, only ECB (0) and CBC (1) are supported.</li>
60+
<li><strong>mode</strong> (<a class="reference external" href="https://docs.python.org/2/library/functions.html#int" title="(in Python v2.7)"><em>int</em></a><em>, </em><em>on of MODE_* constants</em>) &#8211; Mode of operation, only ECB (0) and CBC (1) are supported.</li>
6061
<li><strong>IV</strong> (<em>bytestring</em>) &#8211; Initialisation vector for CBC/CFB/OFB, must be 16 in length.</li>
61-
<li><strong>counter</strong> (<em>callable, must return bytestrings</em>) &#8211; Counter for CTR.</li>
62+
<li><strong>counter</strong> (<a class="reference external" href="https://docs.python.org/2/library/functions.html#callable" title="(in Python v2.7)"><em>callable</em></a><em>, </em><em>must return bytestrings</em>) &#8211; Counter for CTR.</li>
6263
</ul>
6364
</td>
6465
</tr>
@@ -102,7 +103,7 @@ <h2>Modes of operation<a class="headerlink" href="#modes-of-operation" title="Pe
102103
<dl class="data">
103104
<dt id="camellia.MODE_CTR">
104105
<code class="descclassname">camellia.</code><code class="descname">MODE_CTR</code><em class="property"> = 6</em><a class="headerlink" href="#camellia.MODE_CTR" title="Permalink to this definition"></a></dt>
105-
<dd><p>CTR mode of operation, currently not supported</p>
106+
<dd><p>CTR mode of operation</p>
106107
</dd></dl>
107108

108109
</div>
@@ -211,14 +212,14 @@ <h3><a href="index.html">Table Of Contents</a></h3>
211212
<h3>Related Topics</h3>
212213
<ul>
213214
<li><a href="index.html">Documentation overview</a><ul>
214-
<li>Previous: <a href="index.html" title="previous chapter">Welcome to python-camellia&#8217;s documentation!</a></li>
215+
<li>Previous: <a href="license.html" title="previous chapter">Licenses</a></li>
215216
</ul></li>
216217
</ul>
217218
</div>
218219
<div role="note" aria-label="source link">
219220
<h3>This Page</h3>
220221
<ul class="this-page-menu">
221-
<li><a href="_sources/API.txt"
222+
<li><a href="_sources/API.rst.txt"
222223
rel="nofollow">Show Source</a></li>
223224
</ul>
224225
</div>
@@ -240,11 +241,11 @@ <h3>Quick search</h3>
240241
&copy;2016, Simon Biewald.
241242

242243
|
243-
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.4.6</a>
244-
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.9</a>
244+
Powered by <a href="http://sphinx-doc.org/">Sphinx 1.5.3</a>
245+
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.8</a>
245246

246247
|
247-
<a href="_sources/API.txt"
248+
<a href="_sources/API.rst.txt"
248249
rel="nofollow">Page source</a>
249250
</div>
250251

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
API
2+
===
3+
4+
5+
The *new* constructor
6+
---------------------
7+
8+
.. autofunction:: camellia.new
9+
10+
Modes of operation
11+
------------------
12+
13+
.. autodata:: camellia.MODE_ECB
14+
.. autodata:: camellia.MODE_CBC
15+
.. autodata:: camellia.MODE_CFB
16+
.. autodata:: camellia.MODE_OFB
17+
.. autodata:: camellia.MODE_CTR
18+
19+
The *CamelliaCipher* class
20+
--------------------------
21+
22+
.. autoclass:: camellia.CamelliaCipher
23+
:members:
24+
25+
.. automethod:: camellia.CamelliaCipher.__init__
26+
27+
Low-level camellia functions
28+
----------------------------
29+
30+
.. autofunction:: camellia.Camellia_Ekeygen
31+
.. autofunction:: camellia.Camellia_Encrypt
32+
.. autofunction:: camellia.Camellia_Decrypt
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.. python-camellia documentation master file, created by
2+
sphinx-quickstart on Sun Oct 30 00:20:11 2016.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to python-camellia's documentation!
7+
===========================================
8+
9+
This is the documentation of python-camellia,
10+
a cryptographic library implementing the
11+
`Camellia <https://tools.ietf.org/html/rfc3713>`_ cipher in python.
12+
13+
.. code:: python
14+
15+
>>> import camellia
16+
>>> plain = b"This is a text. "
17+
>>> c1 = camellia.CamelliaCipher(key=b'16 byte long key', IV=b'16 byte iv. xxxx', mode=camellia.MODE_CBC)
18+
>>> encrypted = c1.encrypt(plain)
19+
>>> c2 = camellia.CamelliaCipher(key=b'16 byte long key', IV=b'16 byte iv. xxxx', mode=camellia.MODE_CBC)
20+
>>> c2.decrypt(encrypted)
21+
b'This is a text. '
22+
23+
24+
.. toctree::
25+
:maxdepth: 2
26+
27+
install
28+
license
29+
API
30+
31+

0 commit comments

Comments
 (0)