[Python-modules-commits] [pysodium] 01/05: Import pysodium_0.6.14.orig.tar.gz

Christopher Stuart Hoskin mans0954 at moszumanska.debian.org
Fri Aug 11 19:47:09 UTC 2017


This is an automated email from the git hooks/post-receive script.

mans0954 pushed a commit to branch master
in repository pysodium.

commit c7486bd3754230fd5d6d7ec8305daa7810d5aa06
Author: Christopher Hoskin <mans0954 at debian.org>
Date:   Fri Aug 11 20:29:55 2017 +0100

    Import pysodium_0.6.14.orig.tar.gz
---
 AUTHORS                    |   1 +
 PKG-INFO                   |  12 ++++-
 README.md                  |  10 +++++
 pysodium.egg-info/PKG-INFO |  12 ++++-
 pysodium/__init__.py       | 110 ++++++++++++++++++++++++++++++++++++++-------
 setup.py                   |   4 +-
 test/__init__.py           |   8 +---
 test/test_pysodium.py      |  11 +++++
 8 files changed, 141 insertions(+), 27 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 1fdeb5c..00b273c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -14,3 +14,4 @@ Fredrick Brennan
 iachievedit
 Tacitus Aedifex
 venzen
+Blaz Bregar
diff --git a/PKG-INFO b/PKG-INFO
index 8a90293..8013662 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pysodium
-Version: 0.6.11
+Version: 0.6.14
 Summary: python libsodium wrapper
 Home-page: https://github.com/stef/pysodium
 Author: Stefan Marsiske
@@ -44,6 +44,9 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
         crypto_generichash_update(state, m)
         crypto_hash_sha256(message)
         crypto_hash_sha512(message)
+        crypto_kx_client_session_keys(client_pk, client_sk, server_pk)
+        crypto_kx_keypair()
+        crypto_kx_server_session_keys(server_pk, server_sk, client_pk)
         crypto_pwhash(outlen, passwd, salt, opslimit, memlimit, alg)
         crypto_pwhash_scryptsalsa208sha256(outlen, passwd, salt, opslimit, memlimit)
         crypto_pwhash_scryptsalsa208sha256_str(passwd, opslimit, memlimit)
@@ -54,6 +57,10 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
         crypto_scalarmult_curve25519(n, p)
         crypto_secretbox(msg, nonce, k)
         crypto_secretbox_open(c, nonce, k)
+        crypto_sign_init()
+        crypto_sign_update(state, m)
+        crypto_sign_final_create(state, sk)
+        crypto_sign_final_verify(state, sig, pk)
         crypto_sign_detached(m, sk)
         crypto_sign_keypair()
         crypto_sign(m, sk)
@@ -97,6 +104,9 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
         crypto_generichash_blake2b_SALTBYTES
         crypto_hash_sha256_BYTES
         crypto_hash_sha512_BYTES
+        crypto_kx_PUBLICKEYBYTES
+        crypto_kx_SECRETKEYBYTES
+        crypto_kx_SESSIONKEYBYTES
         crypto_pwhash_ALG_DEFAULT
         crypto_pwhash_MEMLIMIT_INTERACTIVE
         crypto_pwhash_MEMLIMIT_MODERATE
diff --git a/README.md b/README.md
index 325c01e..7d551e2 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,9 @@ crypto_generichash(m, k=b'', outlen=crypto_generichash_BYTES)
 crypto_generichash_update(state, m)
 crypto_hash_sha256(message)
 crypto_hash_sha512(message)
+crypto_kx_client_session_keys(client_pk, client_sk, server_pk)
+crypto_kx_keypair()
+crypto_kx_server_session_keys(server_pk, server_sk, client_pk)
 crypto_pwhash(outlen, passwd, salt, opslimit, memlimit, alg)
 crypto_pwhash_scryptsalsa208sha256(outlen, passwd, salt, opslimit, memlimit)
 crypto_pwhash_scryptsalsa208sha256_str(passwd, opslimit, memlimit)
@@ -46,6 +49,10 @@ crypto_scalarmult_curve25519_base(n)
 crypto_scalarmult_curve25519(n, p)
 crypto_secretbox(msg, nonce, k)
 crypto_secretbox_open(c, nonce, k)
+crypto_sign_init()
+crypto_sign_update(state, m)
+crypto_sign_final_create(state, sk)
+crypto_sign_final_verify(state, sig, pk)
 crypto_sign_detached(m, sk)
 crypto_sign_keypair()
 crypto_sign(m, sk)
@@ -89,6 +96,9 @@ crypto_generichash_blake2b_PERSONALBYTES
 crypto_generichash_blake2b_SALTBYTES
 crypto_hash_sha256_BYTES
 crypto_hash_sha512_BYTES
+crypto_kx_PUBLICKEYBYTES
+crypto_kx_SECRETKEYBYTES
+crypto_kx_SESSIONKEYBYTES
 crypto_pwhash_ALG_DEFAULT
 crypto_pwhash_MEMLIMIT_INTERACTIVE
 crypto_pwhash_MEMLIMIT_MODERATE
diff --git a/pysodium.egg-info/PKG-INFO b/pysodium.egg-info/PKG-INFO
index 8a90293..8013662 100644
--- a/pysodium.egg-info/PKG-INFO
+++ b/pysodium.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pysodium
-Version: 0.6.11
+Version: 0.6.14
 Summary: python libsodium wrapper
 Home-page: https://github.com/stef/pysodium
 Author: Stefan Marsiske
@@ -44,6 +44,9 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
         crypto_generichash_update(state, m)
         crypto_hash_sha256(message)
         crypto_hash_sha512(message)
+        crypto_kx_client_session_keys(client_pk, client_sk, server_pk)
+        crypto_kx_keypair()
+        crypto_kx_server_session_keys(server_pk, server_sk, client_pk)
         crypto_pwhash(outlen, passwd, salt, opslimit, memlimit, alg)
         crypto_pwhash_scryptsalsa208sha256(outlen, passwd, salt, opslimit, memlimit)
         crypto_pwhash_scryptsalsa208sha256_str(passwd, opslimit, memlimit)
@@ -54,6 +57,10 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
         crypto_scalarmult_curve25519(n, p)
         crypto_secretbox(msg, nonce, k)
         crypto_secretbox_open(c, nonce, k)
+        crypto_sign_init()
+        crypto_sign_update(state, m)
+        crypto_sign_final_create(state, sk)
+        crypto_sign_final_verify(state, sig, pk)
         crypto_sign_detached(m, sk)
         crypto_sign_keypair()
         crypto_sign(m, sk)
@@ -97,6 +104,9 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
         crypto_generichash_blake2b_SALTBYTES
         crypto_hash_sha256_BYTES
         crypto_hash_sha512_BYTES
+        crypto_kx_PUBLICKEYBYTES
+        crypto_kx_SECRETKEYBYTES
+        crypto_kx_SESSIONKEYBYTES
         crypto_pwhash_ALG_DEFAULT
         crypto_pwhash_MEMLIMIT_INTERACTIVE
         crypto_pwhash_MEMLIMIT_MODERATE
diff --git a/pysodium/__init__.py b/pysodium/__init__.py
index a7ee0e0..910a02d 100755
--- a/pysodium/__init__.py
+++ b/pysodium/__init__.py
@@ -152,19 +152,19 @@ if sodium_version_check(1, 0, 9):
     crypto_pwhash_ALG_DEFAULT = sodium.crypto_pwhash_alg_default()
 else:
     crypto_pwhash_ALG_DEFAULT = None
+if sodium_version_check(1, 0, 12):
+    crypto_kx_PUBLICKEYBYTES = sodium.crypto_kx_publickeybytes()
+    crypto_kx_SECRETKEYBYTES = sodium.crypto_kx_secretkeybytes()
+    crypto_kx_SESSIONKEYBYTES = sodium.crypto_kx_sessionkeybytes()
 
-class CryptoGenericHashState(ctypes.Structure):
+class CryptoSignState(ctypes.Structure):
     _pack_ = 1
     _fields_ = [
-        ('h', ctypes.c_uint64 * 8),
-        ('t', ctypes.c_uint64 * 2),
-        ('f', ctypes.c_uint64 * 2),
-        ('buf', ctypes.c_uint8 * 2 * 128),
-        ('buflen', ctypes.c_size_t),
-        ('last_node', ctypes.c_uint8)
+        ('state', ctypes.c_uint64 * 8),
+        ('count', ctypes.c_uint64 * 2),
+        ('buf', ctypes.c_uint8 * 128)
     ]
 
-
 def __check(code):
     if code != 0:
         raise ValueError
@@ -233,12 +233,12 @@ def crypto_aead_chacha20poly1305_decrypt(ciphertext, ad, nonce, key):
 @sodium_version(1, 0, 9)
 def crypto_aead_chacha20poly1305_encrypt_detached(message, ad, nonce, key):
     """ Return ciphertext, mac tag """
-    
+
     mlen = ctypes.c_ulonglong(len(message))
     adlen = ctypes.c_ulonglong(len(ad)) if ad is not None else ctypes.c_ulonglong(0)
     c = ctypes.create_string_buffer(mlen.value)
     maclen_p = ctypes.c_ulonglong(crypto_aead_chacha20poly1305_ABYTES)
-    mac = ctypes.create_string_buffer(maclen_p.value)    
+    mac = ctypes.create_string_buffer(maclen_p.value)
 
     __check(sodium.crypto_aead_chacha20poly1305_encrypt_detached(c, mac, ctypes.byref(maclen_p), message, mlen, ad, adlen, None, nonce, key))
     return c.raw, mac.raw
@@ -247,16 +247,16 @@ def crypto_aead_chacha20poly1305_encrypt_detached(message, ad, nonce, key):
 @sodium_version(1, 0, 9)
 def crypto_aead_chacha20poly1305_decrypt_detached(ciphertext, mac, ad, nonce, key):
     """ Return message if successful or -1 (ValueError) if not successful"""
-    
+
     if len(mac) != crypto_aead_chacha20poly1305_ABYTES:
         raise ValueError("mac length != %i" % crypto_aead_chacha20poly1305_ABYTES)
-    
+
     clen = ctypes.c_ulonglong(len(ciphertext))
     m = ctypes.create_string_buffer(clen.value)
     adlen = ctypes.c_ulonglong(len(ad)) if ad is not None else ctypes.c_ulonglong(0)
     __check(sodium.crypto_aead_chacha20poly1305_decrypt_detached(m, None, ciphertext, clen, mac, ad, adlen, nonce, key))
     return m.raw
-    
+
 # crypto_aead_chacha20poly1305_ietf_encrypt(unsigned char *c, unsigned long long *clen_p, const unsigned char *m, unsigned long long mlen, const unsigned char *ad, unsigned long long adlen, const unsigned char *nsec, const unsigned char *npub, const unsigned char *k)
 @sodium_version(1, 0, 4)
 def crypto_aead_chacha20poly1305_ietf_encrypt(message, ad, nonce, key):
@@ -305,21 +305,19 @@ def crypto_generichash(m, k=b'', outlen=crypto_generichash_BYTES):
 
 # crypto_generichash_init(crypto_generichash_state *state, const unsigned char *key, const size_t keylen, const size_t outlen);
 def crypto_generichash_init(outlen=crypto_generichash_BYTES, k=b''):
-    state = CryptoGenericHashState()
+    state = ctypes.create_string_buffer(sodium.crypto_generichash_statebytes())
     __check(sodium.crypto_generichash_init(ctypes.byref(state), k, ctypes.c_size_t(len(k)), ctypes.c_size_t(outlen)))
     return state
 
 
 # crypto_generichash_update(crypto_generichash_state *state, const unsigned char *in, unsigned long long inlen);
 def crypto_generichash_update(state, m):
-    assert isinstance(state, CryptoGenericHashState)
     __check(sodium.crypto_generichash_update(ctypes.byref(state), m, ctypes.c_ulonglong(len(m))))
     return state
 
 
 # crypto_generichash_final(crypto_generichash_state *state, unsigned char *out, const size_t outlen);
 def crypto_generichash_final(state, outlen=crypto_generichash_BYTES):
-    assert isinstance(state, CryptoGenericHashState)
     buf = ctypes.create_string_buffer(outlen)
     __check(sodium.crypto_generichash_final(ctypes.byref(state), buf, ctypes.c_size_t(outlen)))
     return buf.raw
@@ -515,6 +513,49 @@ def crypto_sign_verify_detached(sig, msg, pk):
     __check(sodium.crypto_sign_verify_detached(sig, msg, ctypes.c_ulonglong(len(msg)), pk))
 
 
+# crypto_sign_init(crypto_sign_state *state);
+ at sodium_version(1, 0, 12)
+def crypto_sign_init():
+    state = CryptoSignState()
+    __check(sodium.crypto_sign_init(ctypes.byref(state)))
+    return state
+
+
+# crypto_sign_update(crypto_sign_state *state, const unsigned char *m, unsigned long long mlen);
+ at sodium_version(1, 0, 12)
+def crypto_sign_update(state, m):
+    assert isinstance(state, CryptoSignState)
+    if m is None:
+        raise ValueError("invalid parameters")
+    __check(sodium.crypto_sign_update(ctypes.byref(state), m, ctypes.c_ulonglong(len(m))))
+
+
+# crypto_sign_final_create(crypto_sign_state *state, unsigned char *sig, unsigned long long *siglen_p, const unsigned char *sk);
+ at sodium_version(1, 0, 12)
+def crypto_sign_final_create(state, sk):
+    assert isinstance(state, CryptoSignState)
+    if sk is None:
+        raise ValueError("invalid parameters")
+    if len(sk) != crypto_sign_SECRETKEYBYTES:
+        raise ValueError("invalid secret key")
+    buf = ctypes.create_string_buffer(crypto_sign_BYTES)
+    __check(sodium.crypto_sign_final_create(ctypes.byref(state), buf, ctypes.c_void_p(0), sk))
+    return buf.raw
+
+
+# crypto_sign_final_verify(crypto_sign_state *state, unsigned char *sig, const unsigned char *sk);
+ at sodium_version(1, 0, 12)
+def crypto_sign_final_verify(state, sig, pk):
+    assert isinstance(state, CryptoSignState)
+    if None in (sig, pk):
+        raise ValueError("invalid parameters")
+    if len(sig) != crypto_sign_BYTES:
+        raise ValueError("invalid signature")
+    if len(pk) != crypto_sign_PUBLICKEYBYTES:
+        raise ValueError("invalid public key")
+    __check(sodium.crypto_sign_final_verify(ctypes.byref(state), sig, pk))
+
+
 # int crypto_stream_salsa20(unsigned char *c, unsigned long long clen,
 #                           const unsigned char *n, const unsigned char *k);
 def crypto_stream(cnt, nonce=None, key=None):
@@ -660,3 +701,40 @@ def crypto_hash_sha512(message):
     out = ctypes.create_string_buffer(crypto_hash_sha512_BYTES).raw
     __check(sodium.crypto_hash_sha512(out, message.encode(), ctypes.c_ulonglong(len(message))))
     return out
+
+# int crypto_kx_keypair(unsigned char pk[crypto_kx_PUBLICKEYBYTES],
+#                      unsigned char sk[crypto_kx_SECRETKEYBYTES]);
+ at sodium_version(1, 0, 12)
+def crypto_kx_keypair():
+    pk = ctypes.create_string_buffer(crypto_kx_PUBLICKEYBYTES)
+    sk = ctypes.create_string_buffer(crypto_kx_SECRETKEYBYTES)
+    __check(sodium.crypto_kx_keypair(pk, sk))
+    return pk.raw, sk.raw
+
+# int crypto_kx_client_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
+#                                  unsigned char tx[crypto_kx_SESSIONKEYBYTES],
+#                                  const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES],
+#                                  const unsigned char client_sk[crypto_kx_SECRETKEYBYTES],
+#                                  const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES]);
+ at sodium_version(1, 0, 12)
+def crypto_kx_client_session_keys(client_pk, client_sk, server_pk):
+    if None in (client_pk, client_sk, server_pk):
+        raise ValueError("invalid parameters")
+    rx = ctypes.create_string_buffer(crypto_kx_SESSIONKEYBYTES)
+    tx = ctypes.create_string_buffer(crypto_kx_SESSIONKEYBYTES)
+    __check(sodium.crypto_kx_client_session_keys(rx, tx, client_pk, client_sk, server_pk))
+    return rx.raw, tx.raw
+
+# int crypto_kx_server_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES],
+#                                  unsigned char tx[crypto_kx_SESSIONKEYBYTES],
+#                                  const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES],
+#                                  const unsigned char server_sk[crypto_kx_SECRETKEYBYTES],
+#                                  const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES]);
+ at sodium_version(1, 0, 12)
+def crypto_kx_server_session_keys(server_pk, server_sk, client_pk):
+    if None in (server_pk, server_sk, client_pk):
+        raise ValueError("invalid parameters")
+    rx = ctypes.create_string_buffer(crypto_kx_SESSIONKEYBYTES)
+    tx = ctypes.create_string_buffer(crypto_kx_SESSIONKEYBYTES)
+    __check(sodium.crypto_kx_server_session_keys(rx, tx, server_pk, server_sk, client_pk))
+    return rx.raw, tx.raw
diff --git a/setup.py b/setup.py
index 07e3193..3292ea8 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-import os 
+import os
 from setuptools import setup, find_packages
 
 
@@ -11,7 +11,7 @@ def read(fname):
 
 setup(
     name="pysodium",
-    version="0.6.11",
+    version="0.6.14",
     author="Stefan Marsiske",
     author_email="s at ctrlc.hu",
     description="python libsodium wrapper",
diff --git a/test/__init__.py b/test/__init__.py
index 3cf7ef2..8b13789 100644
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -1,7 +1 @@
-"""
- at file
- at brief    
- at details  Copyright (c) 2001-2014 Acronis
- at author   Bulat Gaifullin (bulat.gaifullin at acronis.com)
- at since    $Id: $
-"""
+
diff --git a/test/test_pysodium.py b/test/test_pysodium.py
index 1654c64..2500b3c 100755
--- a/test/test_pysodium.py
+++ b/test/test_pysodium.py
@@ -303,5 +303,16 @@ class TestPySodium(unittest.TestCase):
         tag = pysodium.crypto_auth("howdy", sk)
         pysodium.crypto_auth_verify(tag, "howdy", sk)
 
+    def test_crypto_kx(self):
+        if not pysodium.sodium_version_check(1, 0, 12): return
+        client_pk, client_sk = pysodium.crypto_kx_keypair()
+        server_pk, server_sk = pysodium.crypto_kx_keypair()
+
+        crx, ctx = pysodium.crypto_kx_client_session_keys(client_pk, client_sk, server_pk)
+        srx, stx = pysodium.crypto_kx_server_session_keys(server_pk, server_sk, client_pk)
+
+        self.assertEqual(crx, stx)
+        self.assertEqual(ctx, srx)
+
 if __name__ == '__main__':
     unittest.main()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pysodium.git



More information about the Python-modules-commits mailing list