Skip to content

Commit

Permalink
Add getter for Curve25519 shared secret (#159)
Browse files Browse the repository at this point in the history
* add getter for Curve25519 shared secret

* remove blank line at EOF
  • Loading branch information
Markus Ottela authored and reaperhulk committed Jan 5, 2017
1 parent d77988a commit 705f958
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/public.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,15 @@ Reference
:param encoder: A class that is able to decode the plaintext.

:return bytes: The decrypted plaintext.

.. method:: shared_key()

Returns the Curve25519 shared secret, that can then be used as a key in
other symmetric ciphers.

.. warning:: It is **VITALLY** important that you use a nonce with your
symmetric cipher. If you fail to do this, you compromise the
privacy of the messages encrypted. Ensure that the key length of
your cipher is 32 bytes.

:return bytes: The shared secret.
14 changes: 14 additions & 0 deletions src/nacl/public.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,17 @@ def decrypt(self, ciphertext, nonce=None, encoder=encoding.RawEncoder):
)

return plaintext

def shared_key(self):
"""
Returns the Curve25519 shared secret, that can then be used as a key in
other symmetric ciphers.
.. warning:: It is **VITALLY** important that you use a nonce with your
symmetric cipher. If you fail to do this, you compromise the
privacy of the messages encrypted. Ensure that the key length of
your cipher is 32 bytes.
:rtype: [:class:`bytes`]
"""

return self._shared_key

0 comments on commit 705f958

Please sign in to comment.