Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
26b16364
Commit
26b16364
authored
12 years ago
by
Donald Stufft
Browse files
Options
Downloads
Plain Diff
Merge pull request
#3
from dstufft/only-support-libsodium
Remove support for libnacl leaving only libsodium
parents
6eef06aa
7d494e9b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.travis.yml
+2
-4
2 additions, 4 deletions
.travis.yml
nacl/nacl.py
+2
-23
2 additions, 23 deletions
nacl/nacl.py
tasks.py
+33
-60
33 additions, 60 deletions
tasks.py
with
37 additions
and
87 deletions
.travis.yml
+
2
−
4
View file @
26b16364
...
...
@@ -8,13 +8,11 @@ python:
install
:
-
sudo apt-get -q install python-pip
-
sudo /usr/bin/pip -q install git+git://github.com/pyinvoke/invoke.git
-
invoke install
-nacl --library=$NACL
-
invoke install --dev
-
invoke install
.sodium
-
invoke install
.requirements
--dev
script
:
-
invoke tests
env
:
global
:
-
LD_LIBRARY_PATH=/usr/local/lib
-
LD_RUN_PATH=/usr/local/lib
matrix
:
-
NACL=libsodium
This diff is collapsed.
Click to expand it.
nacl/nacl.py
+
2
−
23
View file @
26b16364
...
...
@@ -3,7 +3,7 @@ CFFI interface to NaCl and libsodium library
"""
import
functools
from
cffi
import
FFI
,
VerificationError
from
cffi
import
FFI
__all__
=
[
"
ffi
"
,
"
lib
"
]
...
...
@@ -31,27 +31,6 @@ ffi.cdef(
)
# Check to make sure that we have a compiled interface to one of our library
# backends. We prefer NaCl here because it has compiled speed ups.
# TODO: Include some way to specify which backend you want and hard fail if
# that one doesn't exist?
try
:
# Try to compile the ffi interface with NaCl
lib
=
ffi
.
verify
(
"""
#include
"
crypto_hash.h
"
#include
"
crypto_hash_sha256.h
"
#include
"
crypto_hash_sha512.h
"
"""
# Secure Random
"""
#include
"
randombytes.h
"
"""
,
libraries
=
[
"
nacl
"
],
)
except
VerificationError
:
# Try to compile the ffi interface with libsodium if NaCl wasn't available
lib
=
ffi
.
verify
(
"
#include <sodium.h>
"
,
libraries
=
[
"
sodium
"
])
...
...
This diff is collapsed.
Click to expand it.
tasks.py
+
33
−
60
View file @
26b16364
...
...
@@ -5,77 +5,50 @@ import urllib2
from
invoke
import
task
,
run
def
download
(
url
,
hash
,
path
):
resp
=
urllib2
.
urlopen
(
url
)
content
=
resp
.
read
()
content_hash
=
hashlib
.
sha256
(
content
).
hexdigest
()
assert
hash
==
content_hash
with
open
(
path
,
"
wb
"
)
as
fp
:
fp
.
write
(
content
)
LIBSODIUM_VERSION
=
"
0.2
"
LIBSODIUM_URL
=
"
http://download.dnscrypt.org/libsodium/releases/libsodium-0.2.tar.gz
"
LIBSODIUM_HASH
=
b
"
e99a6b69adc080a5acf6b8a49fdc74b61d6f3579b590e85c93446a8325dde100
"
@task
(
aliases
=
[
"
install-nacl
"
])
def
install_nacl
(
library
):
def
_install_libsodium
():
tarball_path
=
os
.
path
.
expanduser
(
"
~/libsodium-0.2.tar.gz
"
)
# Download libsodium and verify it's hash
download
(
"
http://download.dnscrypt.org/libsodium/releases/libsodium-0.2.tar.gz
"
,
"
e99a6b69adc080a5acf6b8a49fdc74b61d6f3579b590e85c93446a8325dde100
"
,
tarball_path
,
@task
(
aliases
=
[
"
install.sodium
"
])
def
install_sodium
():
tarball_path
=
os
.
path
.
expanduser
(
"
~/libsodium-{}.tar.gz
"
.
format
(
LIBSODIUM_VERSION
),
)
curdir
=
os
.
getcwd
()
try
:
os
.
chdir
(
os
.
path
.
expanduser
(
"
~/
"
))
# Unpack the tarball
run
(
"
tar xf libsodium-0.2.tar.gz
"
)
# Configure and install the library
os
.
chdir
(
os
.
path
.
expanduser
(
"
~/libsodium-0.2/
"
))
run
(
"
./configure --disable-debug --disable-dependency-tracking
"
,
hide
=
"
out
"
)
run
(
"
make
"
,
hide
=
"
out
"
)
run
(
"
sudo make install
"
,
hide
=
"
out
"
)
finally
:
os
.
chdir
(
curdir
)
# Download libsodium and verify it's hash
resp
=
urllib2
.
urlopen
(
LIBSODIUM_URL
)
content
=
resp
.
read
()
content_hash
=
hashlib
.
sha256
(
content
).
hexdigest
()
def
_install_nacl
()
:
tarball_path
=
os
.
path
.
expanduser
(
"
~/nacl-20110221.tar.bz2
"
)
if
content_hash
!=
LIBSODIUM_HASH
:
raise
ValueError
(
"
Hash mismatch for downloaded libsodium
"
)
# Download libnacl and verify it's hash
download
(
"
http://hyperelliptic.org/nacl/nacl-20110221.tar.bz2
"
,
"
4f277f89735c8b0b8a6bbd043b3efb3fa1cc68a9a5da6a076507d067fc3b3bf8
"
,
tarball_path
,
)
with
open
(
tarball_path
,
"
wb
"
)
as
fp
:
fp
.
write
(
content
)
curdir
=
os
.
getcwd
()
try
:
os
.
chdir
(
os
.
path
.
expanduser
(
"
~/
"
))
# Unpack the tarball
run
(
"
tar xf
nacl-20110221.tar.bz2
"
,
hide
=
"
out
"
)
run
(
"
tar xf
libsodium-{}.tar.gz
"
.
format
(
LIBSODIUM_VERSION
)
)
# Configure and install the library
os
.
chdir
(
os
.
path
.
expanduser
(
"
~/nacl-20110221/
"
))
run
(
"
sudo ./do
"
,
hide
=
"
out
"
)
os
.
chdir
(
os
.
path
.
expanduser
(
"
~/libsodium-{}/
"
.
format
(
LIBSODIUM_VERSION
),
))
run
(
"
./configure --disable-debug --disable-dependency-tracking
"
,
hide
=
"
out
"
,
)
run
(
"
make
"
,
hide
=
"
out
"
)
run
(
"
sudo make install
"
,
hide
=
"
out
"
)
finally
:
os
.
chdir
(
curdir
)
libraries
=
{
"
libsodium
"
:
_install_libsodium
,
"
nacl
"
:
_install_nacl
,
}
# Install the library
libraries
[
library
]()
@task
def
install
(
dev
=
False
):
@task
(
aliases
=
[
"
install.requirements
"
])
def
install_requirements
(
dev
=
False
):
if
dev
:
# Install once to get the tests extra
run
(
"
pip install file://$PWD#egg=pynacl[tests]
"
,
hide
=
"
out
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment