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
64df1344
Commit
64df1344
authored
12 years ago
by
Donald Stufft
Browse files
Options
Downloads
Patches
Plain Diff
Put the PrivateKey before the PublicKey
parent
45d46448
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/public.rst
+2
-2
2 additions, 2 deletions
docs/public.rst
nacl/public.py
+4
-4
4 additions, 4 deletions
nacl/public.py
tests/test_box.py
+2
-2
2 additions, 2 deletions
tests/test_box.py
with
8 additions
and
8 deletions
docs/public.rst
+
2
−
2
View file @
64df1344
...
@@ -56,7 +56,7 @@ with equal that from (pkbob, skalice). This is how the system works:
...
@@ -56,7 +56,7 @@ with equal that from (pkbob, skalice). This is how the system works:
# Bob wishes to send Alice an encrypted message
# Bob wishes to send Alice an encrypted message
# So Bob must make a Box with his private key and Alice's public key
# So Bob must make a Box with his private key and Alice's public key
bob_box = Box(pkalice
, skbob
)
bob_box = Box(
skbob,
pkalice)
# This is our message to send, it must be a bytestring as Box will
# This is our message to send, it must be a bytestring as Box will
# treat is as just a binary blob of data.
# treat is as just a binary blob of data.
...
@@ -72,7 +72,7 @@ with equal that from (pkbob, skalice). This is how the system works:
...
@@ -72,7 +72,7 @@ with equal that from (pkbob, skalice). This is how the system works:
ciphertext = bob_box.encrypt(message, nonce)
ciphertext = bob_box.encrypt(message, nonce)
# Alice creates a second box with her private key to decrypt the message
# Alice creates a second box with her private key to decrypt the message
alice_box = Box(
pkbob,
skalice)
alice_box = Box(skalice
, pkbob
)
# Decrypt our message, an exception will be raised if the encryption was
# Decrypt our message, an exception will be raised if the encryption was
# tampered with or there was otherwise an error.
# tampered with or there was otherwise an error.
...
...
This diff is collapsed.
Click to expand it.
nacl/public.py
+
4
−
4
View file @
64df1344
...
@@ -93,18 +93,18 @@ class Box(encoding.Encodable, six.StringFixer, object):
...
@@ -93,18 +93,18 @@ class Box(encoding.Encodable, six.StringFixer, object):
send are repudiable. For non-repudiable messages, sign them after
send are repudiable. For non-repudiable messages, sign them after
encryption.
encryption.
:param public_key: :class:`~nacl.public.PublicKey` used to encrypt and
decrypt messages
:param private_key: :class:`~nacl.public.PrivateKey` used to encrypt and
:param private_key: :class:`~nacl.public.PrivateKey` used to encrypt and
decrypt messages
decrypt messages
:param public_key: :class:`~nacl.public.PublicKey` used to encrypt and
decrypt messages
:cvar NONCE_SIZE: The size that the nonce is required to be.
:cvar NONCE_SIZE: The size that the nonce is required to be.
"""
"""
NONCE_SIZE
=
nacl
.
lib
.
crypto_box_NONCEBYTES
NONCE_SIZE
=
nacl
.
lib
.
crypto_box_NONCEBYTES
def
__init__
(
self
,
p
ublic
_key
,
p
rivate
_key
):
def
__init__
(
self
,
p
rivate
_key
,
p
ublic
_key
):
if
p
ublic
_key
and
p
rivate
_key
:
if
p
rivate
_key
and
p
ublic
_key
:
_shared_key_size
=
nacl
.
lib
.
crypto_box_BEFORENMBYTES
_shared_key_size
=
nacl
.
lib
.
crypto_box_BEFORENMBYTES
_shared_key
=
nacl
.
ffi
.
new
(
"
unsigned char[]
"
,
_shared_key_size
)
_shared_key
=
nacl
.
ffi
.
new
(
"
unsigned char[]
"
,
_shared_key_size
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_box.py
+
2
−
2
View file @
64df1344
...
@@ -37,7 +37,7 @@ def test_box_encryption(skalice, pkalice, skbob, pkbob, nonce, plaintext, cipher
...
@@ -37,7 +37,7 @@ def test_box_encryption(skalice, pkalice, skbob, pkbob, nonce, plaintext, cipher
pkalice
=
PublicKey
(
pkalice
,
encoder
=
HexEncoder
)
pkalice
=
PublicKey
(
pkalice
,
encoder
=
HexEncoder
)
skbob
=
PrivateKey
(
skbob
,
encoder
=
HexEncoder
)
skbob
=
PrivateKey
(
skbob
,
encoder
=
HexEncoder
)
box
=
Box
(
pkalice
,
skbob
)
box
=
Box
(
skbob
,
pkalice
)
plaintext
=
binascii
.
unhexlify
(
plaintext
)
plaintext
=
binascii
.
unhexlify
(
plaintext
)
nonce
=
binascii
.
unhexlify
(
nonce
)
nonce
=
binascii
.
unhexlify
(
nonce
)
...
@@ -50,7 +50,7 @@ def test_box_decryption(skalice, pkalice, skbob, pkbob, nonce, plaintext, cipher
...
@@ -50,7 +50,7 @@ def test_box_decryption(skalice, pkalice, skbob, pkbob, nonce, plaintext, cipher
pkbob
=
PublicKey
(
pkbob
,
encoder
=
HexEncoder
)
pkbob
=
PublicKey
(
pkbob
,
encoder
=
HexEncoder
)
skalice
=
PrivateKey
(
skalice
,
encoder
=
HexEncoder
)
skalice
=
PrivateKey
(
skalice
,
encoder
=
HexEncoder
)
box
=
Box
(
pkbob
,
skalice
)
box
=
Box
(
skalice
,
pkbob
)
nonce
=
binascii
.
unhexlify
(
nonce
)
nonce
=
binascii
.
unhexlify
(
nonce
)
decrypted
=
binascii
.
hexlify
(
decrypted
=
binascii
.
hexlify
(
...
...
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