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
0667f390
Commit
0667f390
authored
12 years ago
by
Donald Stufft
Browse files
Options
Downloads
Patches
Plain Diff
Add an Encodable mixin that uses the encoder system
parent
2a7758c1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nacl/encoding.py
+7
-0
7 additions, 0 deletions
nacl/encoding.py
nacl/signing.py
+9
-3
9 additions, 3 deletions
nacl/signing.py
with
16 additions
and
3 deletions
nacl/encoding.py
+
7
−
0
View file @
0667f390
...
@@ -28,6 +28,13 @@ class Encoder(object):
...
@@ -28,6 +28,13 @@ class Encoder(object):
encoder
=
Encoder
()
encoder
=
Encoder
()
class
Encodable
(
object
):
def
encode
(
self
,
encoding
=
"
raw
"
):
data
=
bytes
(
self
)
return
encoder
[
encoding
].
encode
(
data
)
@encoder.register
(
"
raw
"
)
@encoder.register
(
"
raw
"
)
class
RawEncoder
(
object
):
class
RawEncoder
(
object
):
...
...
This diff is collapsed.
Click to expand it.
nacl/signing.py
+
9
−
3
View file @
0667f390
...
@@ -4,7 +4,7 @@ from __future__ import division
...
@@ -4,7 +4,7 @@ from __future__ import division
from
.
import
six
from
.
import
six
from
.
import
nacl
from
.
import
nacl
from
.encoding
import
encoder
from
.encoding
import
encoder
,
Encodable
from
.exceptions
import
CryptoError
from
.exceptions
import
CryptoError
from
.random
import
random
from
.random
import
random
...
@@ -42,7 +42,7 @@ class SignedMessage(six.binary_type):
...
@@ -42,7 +42,7 @@ class SignedMessage(six.binary_type):
return
self
.
_message
return
self
.
_message
class
VerifyKey
(
object
):
class
VerifyKey
(
Encodable
,
six
.
StringFixer
,
object
):
"""
"""
The public key counterpart to an Ed25519 SigningKey for producing digital
The public key counterpart to an Ed25519 SigningKey for producing digital
signatures.
signatures.
...
@@ -60,6 +60,9 @@ class VerifyKey(object):
...
@@ -60,6 +60,9 @@ class VerifyKey(object):
self
.
_key
=
key
self
.
_key
=
key
def
__bytes__
(
self
):
return
self
.
_key
def
verify
(
self
,
smessage
,
signature
=
None
,
encoding
=
"
raw
"
):
def
verify
(
self
,
smessage
,
signature
=
None
,
encoding
=
"
raw
"
):
"""
"""
Verifies the signature of a signed message, returning the message
Verifies the signature of a signed message, returning the message
...
@@ -89,7 +92,7 @@ class VerifyKey(object):
...
@@ -89,7 +92,7 @@ class VerifyKey(object):
return
nacl
.
ffi
.
buffer
(
message
,
message_len
[
0
])[:]
return
nacl
.
ffi
.
buffer
(
message
,
message_len
[
0
])[:]
class
SigningKey
(
object
):
class
SigningKey
(
Encodable
,
six
.
StringFixer
,
object
):
"""
"""
Private key for producing digital signatures using the Ed25519 algorithm.
Private key for producing digital signatures using the Ed25519 algorithm.
...
@@ -130,6 +133,9 @@ class SigningKey(object):
...
@@ -130,6 +133,9 @@ class SigningKey(object):
# Public values
# Public values
self
.
verify_key
=
VerifyKey
(
nacl
.
ffi
.
buffer
(
pk
,
nacl
.
lib
.
crypto_sign_PUBLICKEYBYTES
)[:])
self
.
verify_key
=
VerifyKey
(
nacl
.
ffi
.
buffer
(
pk
,
nacl
.
lib
.
crypto_sign_PUBLICKEYBYTES
)[:])
def
__bytes__
(
self
):
return
self
.
_seed
@classmethod
@classmethod
def
generate
(
cls
):
def
generate
(
cls
):
"""
"""
...
...
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