Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Synss committed Mar 13, 2018
2 parents ec7d732 + 4a6b290 commit 4800923
Show file tree
Hide file tree
Showing 33 changed files with 353 additions and 175 deletions.
38 changes: 21 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,33 @@ jobs:

- restore_cache:
keys:
- py34-3.4.7
- py34-3.4.8
- run:
name: install python 3.4.7
name: install python 3.4.8
command: |
if [ ! -d ".pyenv/versions/3.4.7" ]; then
if [ ! -d ".pyenv/versions/3.4.8" ]; then
eval "$(pyenv init -)"
pyenv install 3.4.7
pyenv install 3.4.8
fi
- save_cache:
key: py34-3.4.7
key: py34-3.4.8
paths:
- .pyenv/versions/3.4.7
- .pyenv/versions/3.4.8

- restore_cache:
keys:
- py35-3.5.4
- py35-3.5.5
- run:
name: install python 3.5.4
name: install python 3.5.5
command: |
if [ ! -d ".pyenv/versions/3.5.4" ]; then
if [ ! -d ".pyenv/versions/3.5.5" ]; then
eval "$(pyenv init -)"
pyenv install 3.5.4
pyenv install 3.5.5
fi
- save_cache:
key: py35-3.5.4
key: py35-3.5.5
paths:
- .pyenv/versions/3.5.4
- .pyenv/versions/3.5.5

- restore_cache:
keys:
Expand Down Expand Up @@ -93,30 +93,34 @@ jobs:
- run:
name: install mbedtls
command: |
./install-mbedtls.sh "$VERSION" "$DESTDIR"
echo 'deb http://deb.debian.org/debian jessie-backports main' |\
sudo tee /etc/apt/sources.list.d/backports.list
sudo apt-get update
sudo apt-get install libmbedtls-dev
- run:
name: install tox
command: |
python -m venv venv
. venv/bin/activate
pip install tox tox-pyenv
pip install tox==2.9.1 tox-pyenv==1.1.0
- run:
name: run tests
command: |
eval "$(pyenv init -)"
pyenv shell 2.7.14 3.5.4 3.4.7 3.6.4
pyenv shell 2.7.14 3.4.8 3.5.5 3.6.4
. venv/bin/activate
tox
- deploy:
name: Publish to Pypi
command: |
if [ "$CIRCLE_BRANCH" = "master" ]; then
echo "[pypi]\nusername = Synss" > $HOME/.pypirc
echo "[pypi]" > $HOME/.pypirc
echo "username = Synss" >> $HOME/.pypirc
echo "password = $PYPI_PASSWORD" >> $HOME/.pypirc
. venv/bin/activate
python setup.py sdist
pip install twine
pip install twine==1.10.0
twine upload dist/*
fi
- store_artifacts:
Expand Down
16 changes: 15 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
[0.8] - 2018-02-24
[0.9] - 2018-03-13

API Changes

* x509/Certificate: next() returns the next certificate in a chain.
* md: Implement block_size property.

Misc.

* Clean up imports.
* Fix tests and packaging.
* Change git merge policy to fast-forward.


[0.8 withdrawn] - 2018-02-24

Support X.509 Certificates

Expand Down
16 changes: 5 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,18 @@ PYX += $(wildcard mbedtls/pk/*.pyx)

LIBMBEDTLS = $(HOME)/lib/mbedtls-2.4.2

release:
cython $(PYX)
python setup.py build_ext

debug:
cython -a -X linetrace=True $(PYX)
CFLAGS='-DCYTHON_TRACE=1' python setup.py build_ext --inplace \
-L$(LIBMBEDTLS)/lib \
-I$(LIBMBEDTLS)/include

test:
pytest --cov mbedtls tests

html:
cd docs && make html

clean:
$(RM) mbedtls/*.c mbedtls/*.so mbedtls/*.pyc
$(RM) mbedtls/cipher/*.c mbedtls/cipher/*.so mbedtls/cipher/*.pyc
$(RM) mbedtls/pk/*.c mbedtls/pk/*.so mbedtls/pk/*.pyc
$(RM) -r build
$(RM) mbedtls/*.c mbedtls/*.so mbedtls/*.pyc mbedtls/*.html
$(RM) mbedtls/cipher/*.c mbedtls/cipher/*.so mbedtls/cipher/*.pyc \
mbedtls/cipher/*.html
$(RM) mbedtls/pk/*.c mbedtls/pk/*.so mbedtls/pk/*.pyc mbedtls/pk/*.html
$(RM) -r build dist
9 changes: 7 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ The bindings are tested with Python 2.7, 3.4, 3.5, and 3.6.

`mbedtls` is available on Debian. Install with::

# aptitude install libmbedtls-dev
# apt-get install libmbedtls-dev
# apt-get install libpython-dev # for Python 2, or
# apt-get install libpython3-dev # for Python 3

and the `pyton-mbedtls`::
and `pyton-mbedtls`::

$ python -m pip install python-mbedtls

Expand Down Expand Up @@ -204,6 +206,9 @@ Create new X.509 certificates::
>>> csr = CSR.new(subject_key, hash.sha1(),
"C=NL,O=PolarSSL,CN=PolarSSL Server 1")

Call ``next(crt)`` to obtain the next certificate in a chain. The
call raises `StopIteration` if there is no further certificate.

and load existing certificates from file::

>>> crl = CRL.from_file("ca/wp_crl.pem")
16 changes: 16 additions & 0 deletions mbedtls/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""python-mbedtls is a this wrapper to ARM's mbed TLS library."""

__author__ = "Mathias Laurin"
__copyright__ = "Copyright 2015, Elaborated Networks GmbH"
__license__ = "MIT License"


import mbedtls.cipher as cipher
import mbedtls.exceptions as exceptions
import mbedtls.hash as hash
import mbedtls.hmac as hmac
import mbedtls.pk as pk
import mbedtls.random as random


__all__ = ("cipher", "exceptions", "hash", "hmac", "pk", "random")
16 changes: 0 additions & 16 deletions mbedtls/__init__.pyx

This file was deleted.

12 changes: 7 additions & 5 deletions mbedtls/_md.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ __copyright__ = "Copyright 2015, Elaborated Networks GmbH"
__license__ = "MIT License"


cdef extern from "mbedtls/md_internal.h":
ctypedef struct mbedtls_md_info_t:
int block_size


cdef extern from "mbedtls/md.h":
ctypedef enum mbedtls_md_type_t:
pass

ctypedef enum mbedtls_md_info_t:
pass

ctypedef enum mbedtls_md_context_t:
pass
ctypedef struct mbedtls_md_context_t:
const mbedtls_md_info_t *md_info

const int *mbedtls_md_list()
const mbedtls_md_info_t *mbedtls_md_info_from_string(
Expand Down
7 changes: 4 additions & 3 deletions mbedtls/_md.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2015, Elaborated Networks GmbH"
__license__ = "MIT License"


cimport _md
cimport mbedtls._md as _md
from libc.stdlib cimport malloc, free
import binascii
from mbedtls.exceptions import *
Expand Down Expand Up @@ -58,7 +58,8 @@ cdef class MDBase:
Attributes:
digest_size (int): The size of the message digest, in bytes.
block_size (int): Not implemented.
block_size (int): The internal block size of the hash
algorithm in bytes.
name (bytes): The name of the message digest.
"""
Expand Down Expand Up @@ -94,7 +95,7 @@ cdef class MDBase:
property block_size:
"""The internal block size of the hash algorithm in bytes."""
def __get__(self):
raise NotImplementedError
return self._ctx.md_info.block_size

property name:
"""The canonical name of the hashing algorithm."""
Expand Down
2 changes: 1 addition & 1 deletion mbedtls/_mpi.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ __copyright__ = "Copyright 2018, Mathias Laurin"
__license__ = "MIT License"


cimport _mpi
cimport mbedtls._mpi as _mpi
from libc.stdlib cimport malloc, free

import numbers
Expand Down
4 changes: 2 additions & 2 deletions mbedtls/cipher/AES.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ __copyright__ = "Copyright 2016, Elaborated Networks GmbH"
__license__ = "MIT License"


cimport _cipher
import _cipher
cimport mbedtls.cipher._cipher as _cipher
import mbedtls.cipher._cipher as _cipher
from mbedtls.exceptions import *


Expand Down
4 changes: 2 additions & 2 deletions mbedtls/cipher/ARC4.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ __copyright__ = "Copyright 2016, Elaborated Networks GmbH"
__license__ = "MIT License"


cimport _cipher
import _cipher
cimport mbedtls.cipher._cipher as _cipher
import mbedtls.cipher._cipher as _cipher
from mbedtls.exceptions import *


Expand Down
4 changes: 2 additions & 2 deletions mbedtls/cipher/Blowfish.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ __copyright__ = "Copyright 2016, Elaborated Networks GmbH"
__license__ = "MIT License"


cimport _cipher
import _cipher
cimport mbedtls.cipher._cipher as _cipher
import mbedtls.cipher._cipher as _cipher
from mbedtls.exceptions import *


Expand Down
4 changes: 2 additions & 2 deletions mbedtls/cipher/Camellia.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ __copyright__ = "Copyright 2016, Elaborated Networks GmbH"
__license__ = "MIT License"


cimport _cipher
import _cipher
cimport mbedtls.cipher._cipher as _cipher
import mbedtls.cipher._cipher as _cipher
from mbedtls.exceptions import *


Expand Down
4 changes: 2 additions & 2 deletions mbedtls/cipher/DES.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ __copyright__ = "Copyright 2016, Elaborated Networks GmbH"
__license__ = "MIT License"


cimport _cipher
import _cipher
cimport mbedtls.cipher._cipher as _cipher
import mbedtls.cipher._cipher as _cipher
from mbedtls.exceptions import *


Expand Down
4 changes: 2 additions & 2 deletions mbedtls/cipher/DES3.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ __copyright__ = "Copyright 2016, Elaborated Networks GmbH"
__license__ = "MIT License"


cimport _cipher
import _cipher
cimport mbedtls.cipher._cipher as _cipher
import mbedtls.cipher._cipher as _cipher
from mbedtls.exceptions import *


Expand Down
4 changes: 2 additions & 2 deletions mbedtls/cipher/DES3dbl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ __copyright__ = "Copyright 2016, Elaborated Networks GmbH"
__license__ = "MIT License"


cimport _cipher
import _cipher
cimport mbedtls.cipher._cipher as _cipher
import mbedtls.cipher._cipher as _cipher
from mbedtls.exceptions import *


Expand Down
22 changes: 22 additions & 0 deletions mbedtls/cipher/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""The cipher package provide symmetric encryption and decryption.
The API follows the recommendations from PEP 272 "API for Block
Encryption Algorithms"
"""
__author__ = "Mathias Laurin"
__copyright__ = "Copyright 2016, Elaborated Networks GmbH"
__license__ = "MIT License"

from ._cipher import *
from . import AES
from . import ARC4
from . import Blowfish
from . import Camellia
from . import DES
from . import DES3
from . import DES3dbl


__all__ = _cipher.__all__ + (
"AES", "ARC4", "Blowfish", "Camellia", "DES", "DES3", "DES3dbl")
21 changes: 0 additions & 21 deletions mbedtls/cipher/__init__.pyx

This file was deleted.

2 changes: 1 addition & 1 deletion mbedtls/cipher/_cipher.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ __copyright__ = "Copyright 2015, Elaborated Networks GmbH"
__license__ = "MIT License"


cimport _cipher
cimport mbedtls.cipher._cipher as _cipher
from libc.stdlib cimport malloc, free
from mbedtls.exceptions import *

Expand Down
Loading

0 comments on commit 4800923

Please sign in to comment.