Skip to content

Commit

Permalink
Merge pull request #22 from VirgilSecurity/development-v5
Browse files Browse the repository at this point in the history
Development v5
  • Loading branch information
kmuzychko authored Aug 9, 2019
2 parents 2d74a55 + 66139c1 commit 237cf09
Show file tree
Hide file tree
Showing 32 changed files with 1,024 additions and 1,346 deletions.
42 changes: 28 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ language: python

python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "3.7-dev"

env:
global:
- CDN_ARTIFACTS=$([ "$TRAVIS_BRANCH" == "master" ] && echo "virgil-crypto" || echo "virgil-crypto-dev")
- OS_NAME=$(echo $TRAVIS_OS_NAME)

matrix:
Expand All @@ -32,6 +30,31 @@ matrix:
- os: osx
language: generic
env: PYTHON=3.7.1 PYTHON_VERSION=3.7 OS_NAME=darwin
- os: windows
language: shell
before_install:
- choco install python2
- python -m pip install --upgrade pip
env: PATH=/c/Python27:/c/Python27/Scripts:$PATH
- os: windows
language: shell
before_install:
- choco install python --version 3.5.4
- python -m pip install --upgrade pip
env: PATH=/c/Python35:/c/Python35/Scripts:$PATH
- os: windows
language: shell
before_install:
- choco install python --version 3.6.7
- python -m pip install --upgrade pip
env: PATH=/c/Python36:/c/Python36/Scripts:$PATH
- os: windows
language: shell
before_install:
- choco install python --version 3.7.2
- python -m pip install --upgrade pip
env: PATH=/c/Python37:/c/Python37/Scripts:$PATH


before_install: |
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
Expand All @@ -44,21 +67,12 @@ before_install: |
export PATH="/Users/travis/.pyenv/shims:${PATH}"
pyenv-virtualenv venv
source venv/bin/activate
python --version
fi
python --version
install:
- if [ -z "$PYTHON_VERSION" ]; then export PYTHON_VERSION=$(echo "$TRAVIS_PYTHON_VERSION" | sed -e 's/-dev//g'); fi
- echo $CDN_ARTIFACTS
- echo $TRAVIS_PYTHON_VERSION
- echo $PYTHON_VERSION
- wget https://cdn.virgilsecurity.com/$CDN_ARTIFACTS/VERSION
- sed -i -e 's/-dev//g' VERSION
- echo "virgil-crypto-$(cat VERSION)-python-${PYTHON_VERSION}-${OS_NAME}-*x86_64.tgz"
- wget -np -nd -r https://cdn.virgilsecurity.com/$CDN_ARTIFACTS/python/ -A "virgil-crypto-$(cat VERSION)-python-${PYTHON_VERSION}-${OS_NAME}-*x86_64.tgz"
- cd virgil_crypto && tar xzf ../*.tgz --strip=2
- ls -la
- cd ..
- pip install virgil-crypto-lib || pip3 install virgil-crypto-lib
- pip install . || pip3 install .

script:
- pwd
Expand Down
456 changes: 65 additions & 391 deletions Jenkinsfile

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
The BSD 3-Clause License (BSD)

Copyright (c) 2019, Virgil Security, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 changes: 10 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
# Virgil Security Python Crypto Library

[![Travis (.com)](https://img.shields.io/travis/com/VirgilSecurity/virgil-crypto-python.svg)](https://travis-ci.com/VirgilSecurity/virgil-crypto-python) [![PyPI](https://img.shields.io/pypi/v/virgil-crypto.svg)](https://pypi.python.org/pypi/virgil-crypto) [![PyPI](https://img.shields.io/pypi/wheel/virgil-crypto.svg)](https://pypi.python.org/pypi/virgil-crypto) [![PyPI](https://img.shields.io/pypi/pyversions/virgil-crypto.svg)](https://pypi.python.org/pypi/virgil-crypto)
[![Travis (.com)](https://img.shields.io/travis/com/VirgilSecurity/virgil-crypto-python/master.svg)](https://travis-ci.com/VirgilSecurity/virgil-crypto-python) [![PyPI](https://img.shields.io/pypi/v/virgil-crypto.svg)](https://pypi.python.org/pypi/virgil-crypto) [![PyPI](https://img.shields.io/pypi/wheel/virgil-crypto.svg)](https://pypi.python.org/pypi/virgil-crypto) [![PyPI](https://img.shields.io/pypi/pyversions/virgil-crypto.svg)](https://pypi.python.org/pypi/virgil-crypto)

### [Introduction](#introduction) | [Library purposes](#library-purposes) | [Usage examples](#usage-examples) | [Installation](#installation) | [Docs](#docs) | [License](#license) | [Contacts](#support)

## Introduction
VirgilCrypto is a stack of security libraries (ECIES with Crypto Agility wrapped in Virgil Cryptogram) and an
open-source high-level [cryptographic library](https://github.com/VirgilSecurity/virgil-crypto) that allows you to
perform all necessary operations for securely storing and transferring data in your digital solutions. Crypto Library
is written in C++ and is suitable for mobile and server platforms.
VirgilCrypto is a stack of security libraries (ECIES with Crypto Agility wrapped in Virgil Cryptogram) and an open-source high-level [cryptographic library](https://github.com/VirgilSecurity/virgil-crypto) that allows you to perform all necessary operations for securely storing and transferring data in your digital solutions. Crypto Library is written in C++ and is suitable for mobile and server platforms.

Virgil Security, Inc., guides software developers into the forthcoming security world in which everything will be
encrypted (and passwords will be eliminated). In this world, the days of developers having to raise millions of
dollars to build a secure chat, secure email, secure file-sharing, or a secure anything have come to an end. Now
developers can instead focus on building features that give them a competitive market advantage while end-users can
enjoy the privacy and security they increasingly demand.
Virgil Security, Inc., guides software developers into the forthcoming security world in which everything will be encrypted (and passwords will be eliminated). In this world, the days of developers having to raise millions of dollars to build a secure chat, secure email, secure file-sharing, or a secure anything have come to an end. Now developers can instead focus on building features that give them a competitive market advantage while end-users can enjoy the privacy and security they increasingly demand.

## Library purposes
* Asymmetric Key Generation
Expand All @@ -31,24 +24,24 @@ Generate a Private Key with the default algorithm (EC_X25519):
from virgil_crypto import VirgilCrypto

crypto = VirgilCrypto()
key_pair = crypto.generate_keys()
key_pair = crypto.generate_key_pair()
```

#### Generate and verify a signature
#### Generate and verify_signature a signature

Generate signature and sign data with a private key:
Generate signature and generate_signature data with a private key:

```python
from virgil_crypto import VirgilCrypto

crypto = VirgilCrypto()
key_pair = crypto.generate_keys()
key_pair = crypto.generate_key_pair()
sender_private_key = key_pair.private_key

message_to_sign = "Hello, Bob!"
data_to_sign = message_to_sign.encode()

signature = crypto.sign(data_to_sign, sender_private_key)
signature = crypto.generate_signature(data_to_sign, sender_private_key)
```

Verify a signature with a public key:
Expand All @@ -58,7 +51,7 @@ from virgil_crypto import VirgilCrypto

crypto = VirgilCrypto()

verified = crypto.verify(data_to_sign, signature, sender_public_key)
verified = crypto.verify_signature(data_to_sign, signature, sender_public_key)
```

#### Encrypt and decrypt data
Expand Down Expand Up @@ -120,4 +113,4 @@ Our developer support team is here to help you. Find out more information on our

You can find us on [Twitter](https://twitter.com/VirgilSecurity) or send us email [email protected].

Also, get extra help from our support team on [Slack](https://virgilsecurity.slack.com/join/shared_invite/enQtMjg4MDE4ODM3ODA4LTc2OWQwOTQ3YjNhNTQ0ZjJiZDc2NjkzYjYxNTI0YzhmNTY2ZDliMGJjYWQ5YmZiOGU5ZWEzNmJiMWZhYWVmYTM).
Also, get extra help from our support team on [Slack](https://virgilsecurity.com/join-community).
24 changes: 3 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
import os
from virgil_crypto import __version__
from setuptools import setup, find_packages
from setuptools.dist import Distribution

crypto_version = os.getenv("CRYPTO_VERSION").split(".")
crypto_version[0] = crypto_version[0].replace("2", "3")


class BinaryDistribution(Distribution):
"""Distribution which always forces a binary package with platform name"""

def has_ext_modules(self):
return True

def is_pure(self):
return False


setup(
name="virgil-crypto",
version=".".join(crypto_version),
version=__version__,
author="Virgil Security",
url="https://virgilsecurity.com/",
classifiers=[
Expand All @@ -27,13 +13,13 @@ def is_pure(self):
"Natural Language :: English",
"Programming Language :: C++",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: Security :: Cryptography",
],
install_requires=["virgil-crypto-lib"],
license="BSD",
include_package_data=True,
zip_safe=False,
Expand All @@ -45,12 +31,8 @@ def is_pure(self):
Virgil Security provides a set of APIs for adding security to any application. In a few simple steps you can encrypt communication, securely store data, provide passwordless login, and ensure data integrity.
Virgil Python Crypto Library is a high-level cryptographic library that allows you to perform all necessary operations for secure storing and transferring data and everything required to become HIPAA and GDPR compliant.
""",
distclass=BinaryDistribution,
packages=find_packages(),
package_data={"virgil_crypto": [
"_virgil_crypto_python.so",
"virgil_crypto_python.py",
"_virgil_crypto_python.pyd",
"tests/*",
"tests/data/*.json"
]}
Expand Down
5 changes: 2 additions & 3 deletions virgil_crypto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from .virgil_crypto_python import *
from .streams import *
__version__ = "5.0.0"

from .crypto import VirgilCrypto
from .private_key_exporter import PrivateKeyExporter
34 changes: 25 additions & 9 deletions virgil_crypto/access_token_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
from virgil_crypto.keys import PrivateKey, PublicKey
from virgil_crypto.keys import VirgilPrivateKey, VirgilPublicKey

from virgil_crypto import VirgilCrypto

Expand All @@ -46,36 +46,52 @@ def __init__(self, crypto=VirgilCrypto()):
self.__crypto = crypto

def generate_token_signature(self, token, private_key):
# type: (Union[bytes, bytearray], PrivateKey) -> bytearray
# type: (Union[bytes, bytearray], VirgilPrivateKey) -> bytearray
"""Generate signature for Access token
Args:
token: Access Token.
token: Access Token bytes.
private_key: Signer Private Key.
Returns:
Signature bytes.
Raises:
ValueError: if token or private key missing or malformed
"""
if not private_key:
raise ValueError("Missing private key")

if not isinstance(private_key, PrivateKey):
if not token:
raise ValueError("Missing token for sign")

if not isinstance(private_key, VirgilPrivateKey):
raise ValueError("private_key must be a VirgilPrivateKey type")

return self.__crypto.sign(token, private_key)
return self.__crypto.generate_signature(token, private_key)

def verify_token_signature(self, signature, token, public_key):
# type: (Union[bytes, bytearray], Union[bytes, bytearray], PublicKey) -> bool
# type: (Union[bytes, bytearray], Union[bytes, bytearray], VirgilPublicKey) -> bool
"""Verify Access Token signature
Args:
signature: Token signature
signature: Token signature bytes
token: Access Token
public_key: Signer Public Key
Returns:
True if signature is valid, False otherwise.
Raises:
ValueError: if public key or token missed or malformed.
"""
if not isinstance(public_key, PublicKey):
if not isinstance(public_key, VirgilPublicKey):
raise ValueError("public_key must be a VirgilPublicKey type")

return self.__crypto.verify(
if not token:
raise ValueError("Missing token to verify")

return self.__crypto.verify_signature(
token, signature, public_key
)

Expand Down
Loading

0 comments on commit 237cf09

Please sign in to comment.