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
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
a6825f1c
Commit
a6825f1c
authored
12 years ago
by
Donald Stufft
Browse files
Options
Downloads
Patches
Plain Diff
Try to build against NaCl and fall back to libsodium
parent
a5f9ad35
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nacl/nacl.py
+19
-3
19 additions, 3 deletions
nacl/nacl.py
with
19 additions
and
3 deletions
nacl/nacl.py
+
19
−
3
View file @
a6825f1c
"""
"""
CFFI interface to libsodium
the
library
CFFI interface to
NaCl and
libsodium library
"""
"""
import
functools
import
functools
from
cffi
import
FFI
from
cffi
import
FFI
,
VerificationError
__all__
=
[
"
ffi
"
,
"
lib
"
]
__all__
=
[
"
ffi
"
,
"
lib
"
]
...
@@ -26,7 +26,23 @@ ffi.cdef(
...
@@ -26,7 +26,23 @@ ffi.cdef(
)
)
lib
=
ffi
.
verify
(
"
#include <sodium.h>
"
,
libraries
=
[
"
sodium
"
])
# 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
"
"""
,
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
"
])
# A lot of the functions in nacl return 0 for success and a negative integer
# A lot of the functions in nacl return 0 for success and a negative integer
...
...
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