[Python-modules-commits] [pysodium] 01/03: Import pysodium_0.7.0.orig.tar.gz
Christopher Stuart Hoskin
mans0954 at moszumanska.debian.org
Fri Feb 2 22:40:08 UTC 2018
This is an automated email from the git hooks/post-receive script.
mans0954 pushed a commit to branch master
in repository pysodium.
commit 45313e797b90c9c7805497680bf44277e377f443
Author: Christopher Hoskin <mans0954 at debian.org>
Date: Fri Feb 2 21:31:03 2018 +0000
Import pysodium_0.7.0.orig.tar.gz
---
PKG-INFO | 67 +++++++-
README.md | 65 +++++++-
pysodium.egg-info/PKG-INFO | 67 +++++++-
pysodium/__init__.py | 374 +++++++++++++++++++++++++++++++++++++++++----
setup.py | 2 +-
test/test_pysodium.py | 241 ++++++++++++++++++++++++-----
6 files changed, 739 insertions(+), 77 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index 8013662..2cc0fc1 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pysodium
-Version: 0.6.14
+Version: 0.7.0-0
Summary: python libsodium wrapper
Home-page: https://github.com/stef/pysodium
Author: Stefan Marsiske
@@ -23,9 +23,10 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
crypto_aead_chacha20poly1305_encrypt(message, ad, nonce, key)
crypto_aead_chacha20poly1305_ietf_decrypt(ciphertext, ad, nonce, key)
crypto_aead_chacha20poly1305_ietf_encrypt(message, ad, nonce, key)
+ crypto_aead_xchacha20poly1305_ietf_decrypt(ciphertext, ad, nonce, key)
+ crypto_aead_xchacha20poly1305_ietf_encrypt(message, ad, nonce, key)
crypto_auth(message, key)
- crypto_auth(tag, message, key)
- crypto_auth_verify(h, m, k=b'')
+ crypto_auth_verify(tag, message, key)
crypto_box_afternm(msg, nonce, k)
crypto_box_beforenm(pk, sk)
crypto_box_detached(msg, nonce, pk, sk)
@@ -57,6 +58,12 @@ 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_secretstream_xchacha20poly1305_keygen():
+ crypto_secretstream_xchacha20poly1305_init_push(key):
+ crypto_secretstream_xchacha20poly1305_init_pull(header, key):
+ crypto_secretstream_xchacha20poly1305_rekey(state):
+ crypto_secretstream_xchacha20poly1305_push(state, message, ad, tag):
+ crypto_secretstream_xchacha20poly1305_pull(state, ciphertext, ad):
crypto_sign_init()
crypto_sign_update(state, m)
crypto_sign_final_create(state, sk)
@@ -82,11 +89,15 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
```
crypto_aead_chacha20poly1305_ABYTES
crypto_aead_chacha20poly1305_KEYBYTES
- crypto_aead_chacha20poly1305_NONCEBYTES
+ crypto_aead_chacha20poly1305_NPUBBYTES
crypto_aead_chacha20poly1305_ietf_KEYBYTES
- crypto_aead_chacha20poly1305_ietf_NONCEBYTES
+ crypto_aead_chacha20poly1305_ietf_NPUBBYTES
+ crypto_aead_xchacha20poly1305_ietf_KEYBYTES
+ crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
+ crypto_aead_xchacha20poly1305_ietf_ABYTES
crypto_auth_BYTES
crypto_auth_KEYBYTES
+ crypto_box_BEFORENMBYTES
crypto_box_BOXZEROBYTES
crypto_box_MACBYTES
crypto_box_NONCEBYTES
@@ -95,7 +106,11 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
crypto_box_SECRETKEYBYTES
crypto_box_SEEDBYTES
crypto_box_ZEROBYTES
+ crypto_generichash_KEYBYTES_MAX
crypto_generichash_BYTES
+ crypto_generichash_BYTES_MAX
+ crypto_generichash_BYTES_MIN
+ crypto_generichash_STATEBYTES
crypto_generichash_blake2b_BYTES
crypto_generichash_blake2b_BYTES_MAX
crypto_generichash_blake2b_BYTES_MIN
@@ -108,22 +123,53 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
crypto_kx_SECRETKEYBYTES
crypto_kx_SESSIONKEYBYTES
crypto_pwhash_ALG_DEFAULT
+ crypto_pwhash_ALG_ARGON2I13
+ crypto_pwhash_ALG_ARGON2ID13
+ crypto_pwhash_BYTES_MAX
+ crypto_pwhash_BYTES_MIN
+ crypto_pwhash_MEMLIMIT_MAX
+ crypto_pwhash_MEMLIMIT_MIN
crypto_pwhash_MEMLIMIT_INTERACTIVE
crypto_pwhash_MEMLIMIT_MODERATE
crypto_pwhash_MEMLIMIT_SENSITIVE
+ crypto_pwhash_OPSLIMIT_MAX
+ crypto_pwhash_OPSLIMIT_MIN
crypto_pwhash_OPSLIMIT_INTERACTIVE
crypto_pwhash_OPSLIMIT_MODERATE
crypto_pwhash_OPSLIMIT_SENSITIVE
+ crypto_pwhash_PASSWD_MAX
+ crypto_pwhash_PASSWD_MIN
+ crypto_pwhash_argon2i_MEMLIMIT_INTERACTIVE
+ crypto_pwhash_argon2i_MEMLIMIT_MODERATE
+ crypto_pwhash_argon2i_MEMLIMIT_SENSITIVE
+ crypto_pwhash_argon2i_OPSLIMIT_INTERACTIVE
+ crypto_pwhash_argon2i_OPSLIMIT_MODERATE
+ crypto_pwhash_argon2i_OPSLIMIT_SENSITIVE
+ crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE
+ crypto_pwhash_argon2id_MEMLIMIT_MODERATE
+ crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE
+ crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE
+ crypto_pwhash_argon2id_OPSLIMIT_MODERATE
+ crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE
crypto_pwhash_SALTBYTES
crypto_pwhash_STRBYTES
+ crypto_pwhash_scryptsalsa208sha256_BYTES_MAX
+ crypto_pwhash_scryptsalsa208sha256_BYTES_MIN
+ crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX
+ crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN
crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE
crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE
+ crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX
+ crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN
crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE
crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE
+ crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX
+ crypto_pwhash_scryptsalsa208sha256_PASSWD_MIN
crypto_pwhash_scryptsalsa208sha256_SALTBYTES
crypto_pwhash_scryptsalsa208sha256_STRBYTES
crypto_pwhash_scryptsalsa208sha256_STRPREFIX
crypto_scalarmult_BYTES
+ crypto_scalarmult_SCALARBYTES
crypto_scalarmult_curve25519_BYTES
crypto_secretbox_BOXZEROBYTES
crypto_secretbox_KEYBYTES
@@ -131,6 +177,15 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
crypto_secretbox_MACBYTES
crypto_secretbox_NONCEBYTES
crypto_secretbox_ZEROBYTES
+ crypto_secretstream_xchacha20poly1305_STATEBYTES
+ crypto_secretstream_xchacha20poly1305_ABYTES
+ crypto_secretstream_xchacha20poly1305_HEADERBYTES
+ crypto_secretstream_xchacha20poly1305_KEYBYTES
+ crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX
+ crypto_secretstream_xchacha20poly1305_TAG_MESSAGE
+ crypto_secretstream_xchacha20poly1305_TAG_PUSH
+ crypto_secretstream_xchacha20poly1305_TAG_REKEY
+ crypto_secretstream_xchacha20poly1305_TAG_FINAL
crypto_sign_BYTES
crypto_sign_PUBLICKEYBYTES
crypto_sign_SECRETKEYBYTES
@@ -139,6 +194,8 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
crypto_sign_ed25519_SECRETKEYBYTES
crypto_stream_KEYBYTES
crypto_stream_NONCEBYTES
+ crypto_stream_chacha20_NONCEBYTES
+ crypto_stream_chacha20_KEYBYTES
```
diff --git a/README.md b/README.md
index 7d551e2..eb1eec2 100644
--- a/README.md
+++ b/README.md
@@ -15,9 +15,10 @@ crypto_aead_chacha20poly1305_encrypt_detached(message, ad, nonce, key)
crypto_aead_chacha20poly1305_encrypt(message, ad, nonce, key)
crypto_aead_chacha20poly1305_ietf_decrypt(ciphertext, ad, nonce, key)
crypto_aead_chacha20poly1305_ietf_encrypt(message, ad, nonce, key)
+crypto_aead_xchacha20poly1305_ietf_decrypt(ciphertext, ad, nonce, key)
+crypto_aead_xchacha20poly1305_ietf_encrypt(message, ad, nonce, key)
crypto_auth(message, key)
-crypto_auth(tag, message, key)
-crypto_auth_verify(h, m, k=b'')
+crypto_auth_verify(tag, message, key)
crypto_box_afternm(msg, nonce, k)
crypto_box_beforenm(pk, sk)
crypto_box_detached(msg, nonce, pk, sk)
@@ -49,6 +50,12 @@ crypto_scalarmult_curve25519_base(n)
crypto_scalarmult_curve25519(n, p)
crypto_secretbox(msg, nonce, k)
crypto_secretbox_open(c, nonce, k)
+crypto_secretstream_xchacha20poly1305_keygen():
+crypto_secretstream_xchacha20poly1305_init_push(key):
+crypto_secretstream_xchacha20poly1305_init_pull(header, key):
+crypto_secretstream_xchacha20poly1305_rekey(state):
+crypto_secretstream_xchacha20poly1305_push(state, message, ad, tag):
+crypto_secretstream_xchacha20poly1305_pull(state, ciphertext, ad):
crypto_sign_init()
crypto_sign_update(state, m)
crypto_sign_final_create(state, sk)
@@ -74,11 +81,15 @@ Constants:
```
crypto_aead_chacha20poly1305_ABYTES
crypto_aead_chacha20poly1305_KEYBYTES
-crypto_aead_chacha20poly1305_NONCEBYTES
+crypto_aead_chacha20poly1305_NPUBBYTES
crypto_aead_chacha20poly1305_ietf_KEYBYTES
-crypto_aead_chacha20poly1305_ietf_NONCEBYTES
+crypto_aead_chacha20poly1305_ietf_NPUBBYTES
+crypto_aead_xchacha20poly1305_ietf_KEYBYTES
+crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
+crypto_aead_xchacha20poly1305_ietf_ABYTES
crypto_auth_BYTES
crypto_auth_KEYBYTES
+crypto_box_BEFORENMBYTES
crypto_box_BOXZEROBYTES
crypto_box_MACBYTES
crypto_box_NONCEBYTES
@@ -87,7 +98,11 @@ crypto_box_SEALBYTES
crypto_box_SECRETKEYBYTES
crypto_box_SEEDBYTES
crypto_box_ZEROBYTES
+crypto_generichash_KEYBYTES_MAX
crypto_generichash_BYTES
+crypto_generichash_BYTES_MAX
+crypto_generichash_BYTES_MIN
+crypto_generichash_STATEBYTES
crypto_generichash_blake2b_BYTES
crypto_generichash_blake2b_BYTES_MAX
crypto_generichash_blake2b_BYTES_MIN
@@ -100,22 +115,53 @@ crypto_kx_PUBLICKEYBYTES
crypto_kx_SECRETKEYBYTES
crypto_kx_SESSIONKEYBYTES
crypto_pwhash_ALG_DEFAULT
+crypto_pwhash_ALG_ARGON2I13
+crypto_pwhash_ALG_ARGON2ID13
+crypto_pwhash_BYTES_MAX
+crypto_pwhash_BYTES_MIN
+crypto_pwhash_MEMLIMIT_MAX
+crypto_pwhash_MEMLIMIT_MIN
crypto_pwhash_MEMLIMIT_INTERACTIVE
crypto_pwhash_MEMLIMIT_MODERATE
crypto_pwhash_MEMLIMIT_SENSITIVE
+crypto_pwhash_OPSLIMIT_MAX
+crypto_pwhash_OPSLIMIT_MIN
crypto_pwhash_OPSLIMIT_INTERACTIVE
crypto_pwhash_OPSLIMIT_MODERATE
crypto_pwhash_OPSLIMIT_SENSITIVE
+crypto_pwhash_PASSWD_MAX
+crypto_pwhash_PASSWD_MIN
+crypto_pwhash_argon2i_MEMLIMIT_INTERACTIVE
+crypto_pwhash_argon2i_MEMLIMIT_MODERATE
+crypto_pwhash_argon2i_MEMLIMIT_SENSITIVE
+crypto_pwhash_argon2i_OPSLIMIT_INTERACTIVE
+crypto_pwhash_argon2i_OPSLIMIT_MODERATE
+crypto_pwhash_argon2i_OPSLIMIT_SENSITIVE
+crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE
+crypto_pwhash_argon2id_MEMLIMIT_MODERATE
+crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE
+crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE
+crypto_pwhash_argon2id_OPSLIMIT_MODERATE
+crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE
crypto_pwhash_SALTBYTES
crypto_pwhash_STRBYTES
+crypto_pwhash_scryptsalsa208sha256_BYTES_MAX
+crypto_pwhash_scryptsalsa208sha256_BYTES_MIN
+crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX
+crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN
crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE
crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE
+crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX
+crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN
crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE
crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE
+crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX
+crypto_pwhash_scryptsalsa208sha256_PASSWD_MIN
crypto_pwhash_scryptsalsa208sha256_SALTBYTES
crypto_pwhash_scryptsalsa208sha256_STRBYTES
crypto_pwhash_scryptsalsa208sha256_STRPREFIX
crypto_scalarmult_BYTES
+crypto_scalarmult_SCALARBYTES
crypto_scalarmult_curve25519_BYTES
crypto_secretbox_BOXZEROBYTES
crypto_secretbox_KEYBYTES
@@ -123,6 +169,15 @@ crypto_secretbox_KEYBYTES
crypto_secretbox_MACBYTES
crypto_secretbox_NONCEBYTES
crypto_secretbox_ZEROBYTES
+crypto_secretstream_xchacha20poly1305_STATEBYTES
+crypto_secretstream_xchacha20poly1305_ABYTES
+crypto_secretstream_xchacha20poly1305_HEADERBYTES
+crypto_secretstream_xchacha20poly1305_KEYBYTES
+crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX
+crypto_secretstream_xchacha20poly1305_TAG_MESSAGE
+crypto_secretstream_xchacha20poly1305_TAG_PUSH
+crypto_secretstream_xchacha20poly1305_TAG_REKEY
+crypto_secretstream_xchacha20poly1305_TAG_FINAL
crypto_sign_BYTES
crypto_sign_PUBLICKEYBYTES
crypto_sign_SECRETKEYBYTES
@@ -131,6 +186,8 @@ crypto_sign_ed25519_PUBLICKEYBYTES
crypto_sign_ed25519_SECRETKEYBYTES
crypto_stream_KEYBYTES
crypto_stream_NONCEBYTES
+crypto_stream_chacha20_NONCEBYTES
+crypto_stream_chacha20_KEYBYTES
```
diff --git a/pysodium.egg-info/PKG-INFO b/pysodium.egg-info/PKG-INFO
index 8013662..2cc0fc1 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.14
+Version: 0.7.0-0
Summary: python libsodium wrapper
Home-page: https://github.com/stef/pysodium
Author: Stefan Marsiske
@@ -23,9 +23,10 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
crypto_aead_chacha20poly1305_encrypt(message, ad, nonce, key)
crypto_aead_chacha20poly1305_ietf_decrypt(ciphertext, ad, nonce, key)
crypto_aead_chacha20poly1305_ietf_encrypt(message, ad, nonce, key)
+ crypto_aead_xchacha20poly1305_ietf_decrypt(ciphertext, ad, nonce, key)
+ crypto_aead_xchacha20poly1305_ietf_encrypt(message, ad, nonce, key)
crypto_auth(message, key)
- crypto_auth(tag, message, key)
- crypto_auth_verify(h, m, k=b'')
+ crypto_auth_verify(tag, message, key)
crypto_box_afternm(msg, nonce, k)
crypto_box_beforenm(pk, sk)
crypto_box_detached(msg, nonce, pk, sk)
@@ -57,6 +58,12 @@ 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_secretstream_xchacha20poly1305_keygen():
+ crypto_secretstream_xchacha20poly1305_init_push(key):
+ crypto_secretstream_xchacha20poly1305_init_pull(header, key):
+ crypto_secretstream_xchacha20poly1305_rekey(state):
+ crypto_secretstream_xchacha20poly1305_push(state, message, ad, tag):
+ crypto_secretstream_xchacha20poly1305_pull(state, ciphertext, ad):
crypto_sign_init()
crypto_sign_update(state, m)
crypto_sign_final_create(state, sk)
@@ -82,11 +89,15 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
```
crypto_aead_chacha20poly1305_ABYTES
crypto_aead_chacha20poly1305_KEYBYTES
- crypto_aead_chacha20poly1305_NONCEBYTES
+ crypto_aead_chacha20poly1305_NPUBBYTES
crypto_aead_chacha20poly1305_ietf_KEYBYTES
- crypto_aead_chacha20poly1305_ietf_NONCEBYTES
+ crypto_aead_chacha20poly1305_ietf_NPUBBYTES
+ crypto_aead_xchacha20poly1305_ietf_KEYBYTES
+ crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
+ crypto_aead_xchacha20poly1305_ietf_ABYTES
crypto_auth_BYTES
crypto_auth_KEYBYTES
+ crypto_box_BEFORENMBYTES
crypto_box_BOXZEROBYTES
crypto_box_MACBYTES
crypto_box_NONCEBYTES
@@ -95,7 +106,11 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
crypto_box_SECRETKEYBYTES
crypto_box_SEEDBYTES
crypto_box_ZEROBYTES
+ crypto_generichash_KEYBYTES_MAX
crypto_generichash_BYTES
+ crypto_generichash_BYTES_MAX
+ crypto_generichash_BYTES_MIN
+ crypto_generichash_STATEBYTES
crypto_generichash_blake2b_BYTES
crypto_generichash_blake2b_BYTES_MAX
crypto_generichash_blake2b_BYTES_MIN
@@ -108,22 +123,53 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
crypto_kx_SECRETKEYBYTES
crypto_kx_SESSIONKEYBYTES
crypto_pwhash_ALG_DEFAULT
+ crypto_pwhash_ALG_ARGON2I13
+ crypto_pwhash_ALG_ARGON2ID13
+ crypto_pwhash_BYTES_MAX
+ crypto_pwhash_BYTES_MIN
+ crypto_pwhash_MEMLIMIT_MAX
+ crypto_pwhash_MEMLIMIT_MIN
crypto_pwhash_MEMLIMIT_INTERACTIVE
crypto_pwhash_MEMLIMIT_MODERATE
crypto_pwhash_MEMLIMIT_SENSITIVE
+ crypto_pwhash_OPSLIMIT_MAX
+ crypto_pwhash_OPSLIMIT_MIN
crypto_pwhash_OPSLIMIT_INTERACTIVE
crypto_pwhash_OPSLIMIT_MODERATE
crypto_pwhash_OPSLIMIT_SENSITIVE
+ crypto_pwhash_PASSWD_MAX
+ crypto_pwhash_PASSWD_MIN
+ crypto_pwhash_argon2i_MEMLIMIT_INTERACTIVE
+ crypto_pwhash_argon2i_MEMLIMIT_MODERATE
+ crypto_pwhash_argon2i_MEMLIMIT_SENSITIVE
+ crypto_pwhash_argon2i_OPSLIMIT_INTERACTIVE
+ crypto_pwhash_argon2i_OPSLIMIT_MODERATE
+ crypto_pwhash_argon2i_OPSLIMIT_SENSITIVE
+ crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE
+ crypto_pwhash_argon2id_MEMLIMIT_MODERATE
+ crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE
+ crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE
+ crypto_pwhash_argon2id_OPSLIMIT_MODERATE
+ crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE
crypto_pwhash_SALTBYTES
crypto_pwhash_STRBYTES
+ crypto_pwhash_scryptsalsa208sha256_BYTES_MAX
+ crypto_pwhash_scryptsalsa208sha256_BYTES_MIN
+ crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX
+ crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN
crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE
crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE
+ crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX
+ crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN
crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE
crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE
+ crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX
+ crypto_pwhash_scryptsalsa208sha256_PASSWD_MIN
crypto_pwhash_scryptsalsa208sha256_SALTBYTES
crypto_pwhash_scryptsalsa208sha256_STRBYTES
crypto_pwhash_scryptsalsa208sha256_STRPREFIX
crypto_scalarmult_BYTES
+ crypto_scalarmult_SCALARBYTES
crypto_scalarmult_curve25519_BYTES
crypto_secretbox_BOXZEROBYTES
crypto_secretbox_KEYBYTES
@@ -131,6 +177,15 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
crypto_secretbox_MACBYTES
crypto_secretbox_NONCEBYTES
crypto_secretbox_ZEROBYTES
+ crypto_secretstream_xchacha20poly1305_STATEBYTES
+ crypto_secretstream_xchacha20poly1305_ABYTES
+ crypto_secretstream_xchacha20poly1305_HEADERBYTES
+ crypto_secretstream_xchacha20poly1305_KEYBYTES
+ crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX
+ crypto_secretstream_xchacha20poly1305_TAG_MESSAGE
+ crypto_secretstream_xchacha20poly1305_TAG_PUSH
+ crypto_secretstream_xchacha20poly1305_TAG_REKEY
+ crypto_secretstream_xchacha20poly1305_TAG_FINAL
crypto_sign_BYTES
crypto_sign_PUBLICKEYBYTES
crypto_sign_SECRETKEYBYTES
@@ -139,6 +194,8 @@ Description: This is a very simple wrapper around libsodium masquerading as nacl
crypto_sign_ed25519_SECRETKEYBYTES
crypto_stream_KEYBYTES
crypto_stream_NONCEBYTES
+ crypto_stream_chacha20_NONCEBYTES
+ crypto_stream_chacha20_KEYBYTES
```
diff --git a/pysodium/__init__.py b/pysodium/__init__.py
index 910a02d..f69d49a 100755
--- a/pysodium/__init__.py
+++ b/pysodium/__init__.py
@@ -97,6 +97,7 @@ sodium.crypto_pwhash_scryptsalsa208sha256_strprefix.restype = ctypes.c_char_p
crypto_auth_KEYBYTES = sodium.crypto_auth_keybytes()
crypto_auth_BYTES = sodium.crypto_auth_bytes()
crypto_box_NONCEBYTES = sodium.crypto_box_noncebytes()
+crypto_box_BEFORENMBYTES = sodium.crypto_box_beforenmbytes()
crypto_box_PUBLICKEYBYTES = sodium.crypto_box_publickeybytes()
crypto_box_SECRETKEYBYTES = sodium.crypto_box_secretkeybytes()
crypto_box_ZEROBYTES = sodium.crypto_box_zerobytes()
@@ -117,9 +118,16 @@ crypto_sign_ed25519_SECRETKEYBYTES = sodium.crypto_sign_ed25519_secretkeybytes()
crypto_sign_ed25519_PUBLICKEYBYTES = sodium.crypto_sign_ed25519_publickeybytes()
crypto_stream_KEYBYTES = sodium.crypto_stream_keybytes()
crypto_stream_NONCEBYTES = sodium.crypto_stream_noncebytes()
+crypto_stream_chacha20_NONCEBYTES = sodium.crypto_stream_chacha20_noncebytes()
+crypto_stream_chacha20_KEYBYTES = sodium.crypto_stream_chacha20_keybytes()
+crypto_generichash_KEYBYTES_MAX = sodium.crypto_generichash_keybytes_max()
crypto_generichash_BYTES = sodium.crypto_generichash_bytes()
+crypto_generichash_BYTES_MIN = sodium.crypto_generichash_bytes_min()
+crypto_generichash_BYTES_MAX = sodium.crypto_generichash_bytes_max()
+crypto_generichash_STATEBYTES = sodium.crypto_generichash_statebytes()
crypto_scalarmult_curve25519_BYTES = sodium.crypto_scalarmult_curve25519_bytes()
crypto_scalarmult_BYTES = sodium.crypto_scalarmult_bytes()
+crypto_scalarmult_SCALARBYTES = sodium.crypto_scalarmult_curve25519_scalarbytes()
crypto_generichash_blake2b_KEYBYTES_MAX = sodium.crypto_generichash_blake2b_keybytes_max()
crypto_generichash_blake2b_BYTES = sodium.crypto_generichash_blake2b_bytes()
crypto_generichash_blake2b_BYTES_MIN = sodium.crypto_generichash_blake2b_bytes_min()
@@ -136,13 +144,27 @@ crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE = sodium.crypto_pwhash_scr
crypto_hash_sha256_BYTES = sodium.crypto_hash_sha256_bytes()
crypto_hash_sha512_BYTES = sodium.crypto_hash_sha512_bytes()
crypto_aead_chacha20poly1305_KEYBYTES = sodium.crypto_aead_chacha20poly1305_keybytes()
-crypto_aead_chacha20poly1305_NONCEBYTES = sodium.crypto_aead_chacha20poly1305_npubbytes()
+crypto_aead_chacha20poly1305_NPUBBYTES = sodium.crypto_aead_chacha20poly1305_npubbytes()
+crypto_aead_chacha20poly1305_NONCEBYTES = crypto_aead_chacha20poly1305_NPUBBYTES
crypto_aead_chacha20poly1305_ABYTES = sodium.crypto_aead_chacha20poly1305_abytes()
+
if sodium_version_check(1, 0, 9):
crypto_aead_chacha20poly1305_ietf_KEYBYTES = sodium.crypto_aead_chacha20poly1305_ietf_keybytes()
- crypto_aead_chacha20poly1305_ietf_NONCEBYTES = sodium.crypto_aead_chacha20poly1305_ietf_npubbytes()
+ crypto_aead_chacha20poly1305_ietf_NPUBBYTES = sodium.crypto_aead_chacha20poly1305_ietf_npubbytes()
crypto_pwhash_SALTBYTES = sodium.crypto_pwhash_saltbytes()
crypto_pwhash_STRBYTES = sodium.crypto_pwhash_strbytes()
+ sodium.crypto_pwhash_bytes_max.restype=ctypes.c_uint
+ sodium.crypto_pwhash_opslimit_max.restype=ctypes.c_uint
+ sodium.crypto_pwhash_memlimit_max.restype=ctypes.c_uint
+ sodium.crypto_pwhash_passwd_max.restype=ctypes.c_uint
+ crypto_pwhash_BYTES_MAX = sodium.crypto_pwhash_bytes_max()
+ crypto_pwhash_BYTES_MIN = sodium.crypto_pwhash_bytes_min()
+ crypto_pwhash_MEMLIMIT_MAX = sodium.crypto_pwhash_memlimit_max()
+ crypto_pwhash_MEMLIMIT_MIN = sodium.crypto_pwhash_memlimit_min()
+ crypto_pwhash_OPSLIMIT_MAX = sodium.crypto_pwhash_opslimit_max()
+ crypto_pwhash_OPSLIMIT_MIN = sodium.crypto_pwhash_opslimit_min()
+ crypto_pwhash_PASSWD_MAX = sodium.crypto_pwhash_passwd_max()
+ crypto_pwhash_PASSWD_MIN = sodium.crypto_pwhash_passwd_min()
crypto_pwhash_OPSLIMIT_INTERACTIVE = sodium.crypto_pwhash_opslimit_interactive()
crypto_pwhash_MEMLIMIT_INTERACTIVE = sodium.crypto_pwhash_memlimit_interactive()
crypto_pwhash_OPSLIMIT_MODERATE = sodium.crypto_pwhash_opslimit_moderate()
@@ -150,12 +172,71 @@ if sodium_version_check(1, 0, 9):
crypto_pwhash_OPSLIMIT_SENSITIVE = sodium.crypto_pwhash_opslimit_sensitive()
crypto_pwhash_MEMLIMIT_SENSITIVE = sodium.crypto_pwhash_memlimit_sensitive()
crypto_pwhash_ALG_DEFAULT = sodium.crypto_pwhash_alg_default()
+ crypto_pwhash_ALG_ARGON2I13 = sodium.crypto_pwhash_alg_argon2i13()
+ crypto_pwhash_argon2i_OPSLIMIT_INTERACTIVE = sodium.crypto_pwhash_argon2i_opslimit_interactive()
+ crypto_pwhash_argon2i_MEMLIMIT_INTERACTIVE = sodium.crypto_pwhash_argon2i_memlimit_interactive()
+ crypto_pwhash_argon2i_OPSLIMIT_MODERATE = sodium.crypto_pwhash_argon2i_opslimit_moderate()
+ crypto_pwhash_argon2i_MEMLIMIT_MODERATE = sodium.crypto_pwhash_argon2i_memlimit_moderate()
+ crypto_pwhash_argon2i_OPSLIMIT_SENSITIVE = sodium.crypto_pwhash_argon2i_opslimit_sensitive()
+ crypto_pwhash_argon2i_MEMLIMIT_SENSITIVE = sodium.crypto_pwhash_argon2i_memlimit_sensitive()
else:
crypto_pwhash_ALG_DEFAULT = None
+ crypto_aead_chacha20poly1305_ietf_KEYBYTES = 32
+ crypto_aead_chacha20poly1305_ietf_NPUBBYTES = 12
+
+crypto_aead_chacha20poly1305_ietf_NONCEBYTES = crypto_aead_chacha20poly1305_ietf_NPUBBYTES
+
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()
+ crypto_aead_xchacha20poly1305_ietf_KEYBYTES = sodium.crypto_aead_xchacha20poly1305_ietf_keybytes()
+ crypto_aead_xchacha20poly1305_ietf_NPUBBYTES = sodium.crypto_aead_xchacha20poly1305_ietf_npubbytes()
+ crypto_aead_xchacha20poly1305_ietf_NONCEBYTES = crypto_aead_xchacha20poly1305_ietf_NPUBBYTES
+ crypto_aead_xchacha20poly1305_ietf_ABYTES = sodium.crypto_aead_xchacha20poly1305_ietf_abytes()
+ sodium.crypto_pwhash_scryptsalsa208sha256_bytes_max.restype=ctypes.c_uint
+ sodium.crypto_pwhash_scryptsalsa208sha256_opslimit_max.restype=ctypes.c_uint
+ sodium.crypto_pwhash_scryptsalsa208sha256_memlimit_max.restype=ctypes.c_ulonglong
+ sodium.crypto_pwhash_scryptsalsa208sha256_passwd_max.restype=ctypes.c_uint
+ crypto_pwhash_scryptsalsa208sha256_BYTES_MAX = sodium.crypto_pwhash_scryptsalsa208sha256_bytes_max()
+ crypto_pwhash_scryptsalsa208sha256_BYTES_MIN = sodium.crypto_pwhash_scryptsalsa208sha256_bytes_min()
+ crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX = sodium.crypto_pwhash_scryptsalsa208sha256_memlimit_max()
+ crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN = sodium.crypto_pwhash_scryptsalsa208sha256_memlimit_min()
+ crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX = sodium.crypto_pwhash_scryptsalsa208sha256_opslimit_max()
+ crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN = sodium.crypto_pwhash_scryptsalsa208sha256_opslimit_min()
+ crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX = sodium.crypto_pwhash_scryptsalsa208sha256_passwd_max()
+ crypto_pwhash_scryptsalsa208sha256_PASSWD_MIN = sodium.crypto_pwhash_scryptsalsa208sha256_passwd_min()
+else:
+ crypto_pwhash_scryptsalsa208sha256_BYTES_MIN = 16
+ crypto_pwhash_scryptsalsa208sha256_BYTES_MAX = 4294967264
+ crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX = 68719476736
+ crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN = 16777216
+ crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN = 32768
+ crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX =4294967295
+ crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX = 4294967295
+ crypto_pwhash_scryptsalsa208sha256_PASSWD_MIN = 0
+
+if sodium_version_check(1, 0, 13):
+ crypto_pwhash_ALG_ARGON2ID13 = sodium.crypto_pwhash_alg_argon2id13()
+ crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE = sodium.crypto_pwhash_argon2id_opslimit_interactive()
+ crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE = sodium.crypto_pwhash_argon2id_memlimit_interactive()
+ crypto_pwhash_argon2id_OPSLIMIT_MODERATE = sodium.crypto_pwhash_argon2id_opslimit_moderate()
+ crypto_pwhash_argon2id_MEMLIMIT_MODERATE = sodium.crypto_pwhash_argon2id_memlimit_moderate()
+ crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE = sodium.crypto_pwhash_argon2id_opslimit_sensitive()
+ crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE = sodium.crypto_pwhash_argon2id_memlimit_sensitive()
+
+if sodium_version_check(1, 0, 15):
+ crypto_secretstream_xchacha20poly1305_STATEBYTES = sodium.crypto_secretstream_xchacha20poly1305_statebytes()
+ crypto_secretstream_xchacha20poly1305_ABYTES = sodium.crypto_secretstream_xchacha20poly1305_abytes()
+ crypto_secretstream_xchacha20poly1305_HEADERBYTES = sodium.crypto_secretstream_xchacha20poly1305_headerbytes()
+ crypto_secretstream_xchacha20poly1305_KEYBYTES = sodium.crypto_secretstream_xchacha20poly1305_keybytes()
+ crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX = sodium.crypto_secretstream_xchacha20poly1305_messagebytes_max()
+ crypto_secretstream_xchacha20poly1305_TAG_MESSAGE = sodium.crypto_secretstream_xchacha20poly1305_tag_message()
+ crypto_secretstream_xchacha20poly1305_TAG_PUSH = sodium.crypto_secretstream_xchacha20poly1305_tag_push()
+ crypto_secretstream_xchacha20poly1305_TAG_REKEY = sodium.crypto_secretstream_xchacha20poly1305_tag_rekey()
+ crypto_secretstream_xchacha20poly1305_TAG_FINAL = sodium.crypto_secretstream_xchacha20poly1305_tag_final()
+
+sodium_init = sodium.sodium_init
class CryptoSignState(ctypes.Structure):
_pack_ = 1
@@ -182,6 +263,10 @@ def pad_buf(buf, length, name = 'buf'):
return buf
def crypto_scalarmult_curve25519(n, p):
+ if None in (n,p):
+ raise ValueError("invalid parameters")
+ if len(n) != crypto_scalarmult_SCALARBYTES: raise ValueError("truncated scalar")
+ if len(p) != crypto_scalarmult_BYTES: raise ValueError("truncated point")
buf = ctypes.create_string_buffer(crypto_scalarmult_BYTES)
__check(sodium.crypto_scalarmult_curve25519(buf, n, p))
return buf.raw
@@ -190,12 +275,15 @@ def crypto_scalarmult_curve25519(n, p):
def crypto_scalarmult_curve25519_base(n):
if n is None:
raise ValueError("invalid parameters")
+ if len(n) != crypto_scalarmult_SCALARBYTES: raise ValueError("truncated scalar")
buf = ctypes.create_string_buffer(crypto_scalarmult_BYTES)
__check(sodium.crypto_scalarmult_curve25519_base(ctypes.byref(buf), n))
return buf.raw
# crypto_stream_chacha20_xor(unsigned char *c, const unsigned char *m, unsigned long long mlen, const unsigned char *n, const unsigned char *k)
def crypto_stream_chacha20_xor(message, nonce, key):
+ if len(nonce) != crypto_stream_chacha20_NONCEBYTES: raise ValueError("truncated nonce")
+ if len(key) != crypto_stream_chacha20_KEYBYTES: raise ValueError("truncated key")
mlen = ctypes.c_longlong(len(message))
@@ -208,6 +296,8 @@ def crypto_stream_chacha20_xor(message, nonce, key):
# crypto_aead_chacha20poly1305_encrypt(unsigned char *c, unsigned long long *clen, 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);
def crypto_aead_chacha20poly1305_encrypt(message, ad, nonce, key):
+ if len(nonce) != crypto_aead_chacha20poly1305_NONCEBYTES: raise ValueError("truncated nonce")
+ if len(key) != crypto_aead_chacha20poly1305_KEYBYTES: raise ValueError("truncated key")
mlen = ctypes.c_ulonglong(len(message))
adlen = ctypes.c_ulonglong(len(ad)) if ad is not None else ctypes.c_ulonglong(0)
@@ -221,6 +311,8 @@ def crypto_aead_chacha20poly1305_encrypt(message, ad, nonce, key):
# crypto_aead_chacha20poly1305_decrypt(unsigned char *m, unsigned long long *mlen, unsigned char *nsec, const unsigned char *c, unsigned long long clen, const unsigned char *ad, unsigned long long adlen, const unsigned char *npub, const unsigned char *k)
def crypto_aead_chacha20poly1305_decrypt(ciphertext, ad, nonce, key):
+ if len(nonce) != crypto_aead_chacha20poly1305_NONCEBYTES: raise ValueError("truncated nonce")
+ if len(key) != crypto_aead_chacha20poly1305_KEYBYTES: raise ValueError("truncated key")
m = ctypes.create_string_buffer(len(ciphertext) - 16)
mlen = ctypes.c_ulonglong(0)
@@ -233,6 +325,8 @@ 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 """
+ if len(nonce) != crypto_aead_chacha20poly1305_NONCEBYTES: raise ValueError("truncated nonce")
+ if len(key) != crypto_aead_chacha20poly1305_KEYBYTES: raise ValueError("truncated key")
mlen = ctypes.c_ulonglong(len(message))
adlen = ctypes.c_ulonglong(len(ad)) if ad is not None else ctypes.c_ulonglong(0)
@@ -247,7 +341,8 @@ 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(nonce) != crypto_aead_chacha20poly1305_NONCEBYTES: raise ValueError("truncated nonce")
+ if len(key) != crypto_aead_chacha20poly1305_KEYBYTES: raise ValueError("truncated key")
if len(mac) != crypto_aead_chacha20poly1305_ABYTES:
raise ValueError("mac length != %i" % crypto_aead_chacha20poly1305_ABYTES)
@@ -260,6 +355,8 @@ def crypto_aead_chacha20poly1305_decrypt_detached(ciphertext, mac, ad, nonce, ke
# 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):
+ if len(nonce) != crypto_aead_chacha20poly1305_ietf_NONCEBYTES: raise ValueError("truncated nonce")
+ if len(key) != crypto_aead_chacha20poly1305_ietf_KEYBYTES: raise ValueError("truncated key")
mlen = ctypes.c_ulonglong(len(message))
adlen = ctypes.c_ulonglong(len(ad)) if ad is not None else ctypes.c_ulonglong(0)
@@ -272,6 +369,8 @@ def crypto_aead_chacha20poly1305_ietf_encrypt(message, ad, nonce, key):
# crypto_aead_chacha20poly1305_ietf_decrypt(unsigned char *m, unsigned long long *mlen, unsigned char *nsec, const unsigned char *c, unsigned long long clen, const unsigned char *ad, unsigned long long adlen, const unsigned char *npub, const unsigned char *k)
@sodium_version(1, 0, 4)
def crypto_aead_chacha20poly1305_ietf_decrypt(ciphertext, ad, nonce, key):
+ if len(nonce) != crypto_aead_chacha20poly1305_ietf_NONCEBYTES: raise ValueError("truncated nonce")
+ if len(key) != crypto_aead_chacha20poly1305_ietf_KEYBYTES: raise ValueError("truncated key")
m = ctypes.create_string_buffer(len(ciphertext) - 16)
mlen = ctypes.c_ulonglong(0)
@@ -280,6 +379,46 @@ def crypto_aead_chacha20poly1305_ietf_decrypt(ciphertext, ad, nonce, key):
__check(sodium.crypto_aead_chacha20poly1305_ietf_decrypt(m, ctypes.byref(mlen), None, ciphertext, clen, ad, adlen, nonce, key))
return m.raw
+#crypto_aead_xchacha20poly1305_ietf_encrypt(ciphertext, &ciphertext_len,
+# message, message_len,
+# additional_data, additional_data_len,
+# null, nonce, key);
+ at sodium_version(1, 0, 12)
+def crypto_aead_xchacha20poly1305_ietf_encrypt(message, ad, nonce, key):
+ if len(nonce) != crypto_aead_xchacha20poly1305_ietf_NPUBBYTES: raise ValueError("truncated nonce")
+ if len(key) != crypto_aead_xchacha20poly1305_ietf_KEYBYTES: raise ValueError("truncated key")
+ 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 + 16)
+ clen = ctypes.c_ulonglong(0)
+
+ __check(sodium.crypto_aead_xchacha20poly1305_ietf_encrypt(c, ctypes.byref(clen),
+ message, mlen,
+ ad, adlen,
+ None, nonce, key))
+ return c.raw
+
+#crypto_aead_xchacha20poly1305_ietf_decrypt(decrypted, &decrypted_len,
+# null,
+# ciphertext, ciphertext_len,
+# additional_data, additional_data_len,
+# nonce, key);
+ at sodium_version(1, 0, 12)
+def crypto_aead_xchacha20poly1305_ietf_decrypt(ciphertext, ad, nonce, key):
+ if len(nonce) != crypto_aead_xchacha20poly1305_ietf_NPUBBYTES: raise ValueError("truncated nonce")
+ if len(key) != crypto_aead_xchacha20poly1305_ietf_KEYBYTES: raise ValueError("truncated key")
+
+ m = ctypes.create_string_buffer(len(ciphertext) - 16)
+ mlen = ctypes.c_ulonglong(0)
+ clen = ctypes.c_ulonglong(len(ciphertext))
+ adlen = ctypes.c_ulonglong(len(ad)) if ad is not None else ctypes.c_ulonglong(0)
+ __check(sodium.crypto_aead_xchacha20poly1305_ietf_decrypt(m, ctypes.byref(mlen),
+ None,
+ ciphertext, clen,
+ ad, adlen,
+ nonce, key))
+ return m.raw
+
# crypto_auth(unsigned char *out, const unsigned char *in, unsigned long long inlen, const unsigned char *k)
def crypto_auth(m, k=b''):
if m is None:
@@ -305,19 +444,21 @@ 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 = ctypes.create_string_buffer(sodium.crypto_generichash_statebytes())
+ state = ctypes.create_string_buffer(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):
+ if len(state) != crypto_generichash_STATEBYTES: raise ValueError("invalid state")
__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):
+ if len(state) != crypto_generichash_STATEBYTES: raise ValueError("invalid state")
buf = ctypes.create_string_buffer(outlen)
__check(sodium.crypto_generichash_final(ctypes.byref(state), buf, ctypes.c_size_t(outlen)))
return buf.raw
@@ -326,7 +467,7 @@ def crypto_generichash_blake2b_salt_personal(message, outlen = crypto_generichas
keylen = len(key)
if keylen != 0 and not crypto_generichash_blake2b_BYTES_MIN <= keylen <= crypto_generichash_blake2b_KEYBYTES_MAX:
- raise ValueError("%d <= len(key) <= %d - %d recieved" % (crypto_generichash_blake2b_BYTES_MIN, crypto_generichash_blake2b_KEYBYTES_MAX, keylen))
+ raise ValueError("%d <= len(key) <= %d - %d received" % (crypto_generichash_blake2b_BYTES_MIN, crypto_generichash_blake2b_KEYBYTES_MAX, keylen))
salt = pad_buf(salt, crypto_generichash_blake2b_SALTBYTES, 'salt')
personal = pad_buf(personal, crypto_generichash_blake2b_PERSONALBYTES, 'personal')
@@ -357,6 +498,8 @@ def crypto_box_keypair():
def crypto_box_seed_keypair(seed):
if seed is None:
raise ValueError("invalid parameters")
+ if len(seed) != crypto_box_SEEDBYTES: raise ValueError("invalid seed size")
+
pk = ctypes.create_string_buffer(crypto_box_PUBLICKEYBYTES)
sk = ctypes.create_string_buffer(crypto_box_SECRETKEYBYTES)
__check(sodium.crypto_box_seed_keypair(pk, sk, seed))
@@ -365,6 +508,8 @@ def crypto_box_seed_keypair(seed):
def crypto_box_beforenm(pk, sk):
if pk is None or sk is None:
raise ValueError("invalid parameters")
+ if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError("pk incorrect size")
+ if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError("sk incorrect size")
c = ctypes.create_string_buffer(crypto_secretbox_KEYBYTES)
__check(sodium.crypto_box_beforenm(c, pk, sk))
return c.raw
@@ -372,6 +517,9 @@ def crypto_box_beforenm(pk, sk):
def crypto_box(msg, nonce, pk, sk):
if None in (msg, nonce, pk, sk):
raise ValueError("invalid parameters")
+ if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError("pk incorrect size")
+ if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError("sk incorrect size")
+ if len(nonce) != crypto_box_NONCEBYTES: raise ValueError("nonce incorrect size")
c = ctypes.create_string_buffer(crypto_box_MACBYTES + len(msg))
__check(sodium.crypto_box_easy(c, msg, ctypes.c_ulonglong(len(msg)), nonce, pk, sk))
return c.raw
@@ -379,6 +527,8 @@ def crypto_box(msg, nonce, pk, sk):
def crypto_box_afternm(msg, nonce, k):
if None in (msg, nonce, k):
raise ValueError("invalid parameters")
+ if len(k) != crypto_box_BEFORENMBYTES: raise ValueError("k incorrect size")
+ if len(nonce) != crypto_box_NONCEBYTES: raise ValueError("nonce incorrect size")
c = ctypes.create_string_buffer(crypto_box_MACBYTES + len(msg))
__check(sodium.crypto_box_easy_afternm(c, msg, ctypes.c_ulonglong(len(msg)), nonce, k))
return c.raw
@@ -386,6 +536,9 @@ def crypto_box_afternm(msg, nonce, k):
def crypto_box_open(c, nonce, pk, sk):
if None in (c, nonce, pk, sk):
raise ValueError("invalid parameters")
+ if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError("pk incorrect size")
+ if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError("sk incorrect size")
+ if len(nonce) != crypto_box_NONCEBYTES: raise ValueError("nonce incorrect size")
msg = ctypes.create_string_buffer(len(c) - crypto_box_MACBYTES)
__check(sodium.crypto_box_open_easy(msg, c, ctypes.c_ulonglong(len(c)), nonce, pk, sk))
return msg.raw
@@ -393,6 +546,8 @@ def crypto_box_open(c, nonce, pk, sk):
def crypto_box_open_afternm(c, nonce, k):
if None in (c, nonce, k):
raise ValueError("invalid parameters")
+ if len(k) != crypto_box_BEFORENMBYTES: raise ValueError("k incorrect size")
+ if len(nonce) != crypto_box_NONCEBYTES: raise ValueError("nonce incorrect size")
msg = ctypes.create_string_buffer(len(c) - crypto_box_MACBYTES)
__check(sodium.crypto_box_open_easy_afternm(msg, c, ctypes.c_ulonglong(len(c)), nonce, k))
return msg.raw
@@ -400,6 +555,8 @@ def crypto_box_open_afternm(c, nonce, k):
def crypto_secretbox(msg, nonce, k):
if None in (msg, nonce, k):
raise ValueError("invalid parameters")
+ if len(k) != crypto_secretbox_KEYBYTES: raise ValueError("k incorrect size")
+ if len(nonce) != crypto_box_NONCEBYTES: raise ValueError("nonce incorrect size")
padded = b"\x00" * crypto_secretbox_ZEROBYTES + msg
c = ctypes.create_string_buffer(len(padded))
__check(sodium.crypto_secretbox(c, padded, ctypes.c_ulonglong(len(padded)), nonce, k))
@@ -409,6 +566,8 @@ def crypto_secretbox(msg, nonce, k):
def crypto_secretbox_open(c, nonce, k):
if None in (c, nonce, k):
raise ValueError("invalid parameters")
+ if len(k) != crypto_secretbox_KEYBYTES: raise ValueError("k incorrect size")
+ if len(nonce) != crypto_box_NONCEBYTES: raise ValueError("nonce incorrect size")
padded = b"\x00" * crypto_secretbox_BOXZEROBYTES + c
msg = ctypes.create_string_buffer(len(padded))
__check(sodium.crypto_secretbox_open(msg, padded, ctypes.c_ulonglong(len(padded)), nonce, k))
@@ -421,6 +580,7 @@ def crypto_secretbox_open(c, nonce, k):
def crypto_box_seal(msg, k):
if msg is None or k is None:
raise ValueError("invalid parameters")
+ if len(k) != crypto_box_PUBLICKEYBYTES: raise ValueError("k incorrect size")
c = ctypes.create_string_buffer(len(msg)+crypto_box_SEALBYTES)
__check(sodium.crypto_box_seal(c, msg, ctypes.c_ulonglong(len(msg)), k))
return c.raw
@@ -433,6 +593,8 @@ def crypto_box_seal(msg, k):
def crypto_box_seal_open(c, pk, sk):
if None in (c, pk, sk):
raise ValueError("invalid parameters")
+ if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError("pk incorrect size")
+ if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError("sk incorrect size")
msg = ctypes.create_string_buffer(len(c)-crypto_box_SEALBYTES)
__check(sodium.crypto_box_seal_open(msg, c, ctypes.c_ulonglong(len(c)), pk, sk))
return msg.raw
@@ -444,12 +606,14 @@ def crypto_box_seal_open(c, pk, sk):
# const unsigned char *sk);
def crypto_box_detached(msg, nonce, pk, sk):
- if None in (msg, nonce, pk, sk):
- raise ValueError("invalid parameters")
- c = ctypes.create_string_buffer(len(msg))
- mac = ctypes.create_string_buffer(crypto_box_MACBYTES)
- __check(sodium.crypto_box_detached(c, mac, msg.encode(), ctypes.c_ulonglong(len(msg)), nonce, pk, sk))
- return c.raw, mac.raw
+ if None in (msg, nonce, pk, sk): raise ValueError("invalid parameters")
+ if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError("pk incorrect size")
+ if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError("sk incorrect size")
+ if len(nonce) != crypto_box_NONCEBYTES: raise ValueError("nonce incorrect size")
+ c = ctypes.create_string_buffer(len(msg))
+ mac = ctypes.create_string_buffer(crypto_box_MACBYTES)
+ __check(sodium.crypto_box_detached(c, mac, msg, ctypes.c_ulonglong(len(msg)), nonce, pk, sk))
+ return c.raw, mac.raw
# int crypto_box_open_detached(unsigned char *m, const unsigned char *c,
# const unsigned char *mac,
@@ -461,9 +625,124 @@ def crypto_box_detached(msg, nonce, pk, sk):
def crypto_box_open_detached(c, mac, nonce, pk, sk):
if None in (c, mac, nonce, pk, sk):
raise ValueError("invalid parameters")
+ if len(pk) != crypto_box_PUBLICKEYBYTES: raise ValueError("pk incorrect size")
+ if len(sk) != crypto_box_SECRETKEYBYTES: raise ValueError("sk incorrect size")
+ if len(nonce) != crypto_box_NONCEBYTES: raise ValueError("nonce incorrect size")
msg = ctypes.create_string_buffer(len(c))
__check(sodium.crypto_box_open_detached(msg, c, mac, ctypes.c_ulonglong(len(c)), nonce, pk, sk))
- return msg.raw.decode()
+ return msg.raw
+
+
+# void crypto_secretstream_xchacha20poly1305_keygen (unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
+ at sodium_version(1, 0, 15)
+def crypto_secretstream_xchacha20poly1305_keygen():
+ key = ctypes.create_string_buffer(crypto_secretstream_xchacha20poly1305_KEYBYTES)
+ sodium.crypto_secretstream_xchacha20poly1305_keygen(ctypes.byref(key))
+ return key.raw
+
+
+# int crypto_secretstream_xchacha20poly1305_init_push(crypto_secretstream_xchacha20poly1305_state *state,
+# unsigned char out[crypto_secretstream_xchacha20poly1305_HEADERBYTES],
+# const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
+ at sodium_version(1, 0, 15)
+def crypto_secretstream_xchacha20poly1305_init_push(key):
+ if key == None:
+ raise ValueError("invalid parameters")
+ if not (len(key) == crypto_secretstream_xchacha20poly1305_KEYBYTES): raise ValueError("Truncated key")
+
+ state = ctypes.create_string_buffer(crypto_secretstream_xchacha20poly1305_STATEBYTES)
+ header = ctypes.create_string_buffer(crypto_secretstream_xchacha20poly1305_HEADERBYTES)
+ __check(sodium.crypto_secretstream_xchacha20poly1305_init_push(state, header, key))
+ return state.raw, header.raw
+
+# int crypto_secretstream_xchacha20poly1305_init_pull(crypto_secretstream_xchacha20poly1305_state *state,
+# const unsigned char in[crypto_secretstream_xchacha20poly1305_HEADERBYTES],
+# const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES])
+ at sodium_version(1, 0, 15)
+def crypto_secretstream_xchacha20poly1305_init_pull(header, key):
+ if None in (header, key):
+ raise ValueError("invalid parameters")
+ if not (len(header) == crypto_secretstream_xchacha20poly1305_HEADERBYTES): raise ValueError("Truncated header")
+ if not (len(key) == crypto_secretstream_xchacha20poly1305_KEYBYTES): raise ValueError("Truncated key")
+
+ state = ctypes.create_string_buffer(crypto_secretstream_xchacha20poly1305_STATEBYTES)
+ __check(sodium.crypto_secretstream_xchacha20poly1305_init_pull(state, header, key))
+ return state.raw
+
+#void crypto_secretstream_xchacha20poly1305_rekey (crypto_secretstream_xchacha20poly1305_state *state)
+ at sodium_version(1, 0, 15)
+def crypto_secretstream_xchacha20poly1305_rekey(state):
+ if state == None:
+ raise ValueError("invalid parameters")
+ if not (len(state) == crypto_secretstream_xchacha20poly1305_STATEBYTES): raise ValueError("Truncated state")
+
+ sodium.crypto_secretstream_xchacha20poly1305_rekey(state)
+
+#int crypto_secretstream_xchacha20poly1305_push (crypto_secretstream_xchacha20poly1305_state *state,
+# unsigned char *out,
+# unsigned long long *outlen_p,
+# const unsigned char *m,
+# unsigned long long mlen,
+# const unsigned char *ad,
+# unsigned long long adlen,
+# unsigned char tag)
+
+ at sodium_version(1, 0, 15)
+def crypto_secretstream_xchacha20poly1305_push(state, message, ad, tag):
+ if None in (state, message):
+ raise ValueError("invalid parameters")
+ if not (len(state) == crypto_secretstream_xchacha20poly1305_STATEBYTES): raise ValueError("Truncated state")
+
+ 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 + crypto_secretstream_xchacha20poly1305_ABYTES)
+ clen = ctypes.c_ulonglong(0)
+
+ __check(sodium.crypto_secretstream_xchacha20poly1305_push(
+ state, # crypto_secretstream_xchacha20poly1305_state *state,
+ c, # unsigned char *out
+ ctypes.byref(clen), # unsigned long long *outlen_p,
+ message, # const unsigned char *m,
+ mlen, # unsigned long long mlen,
+ ad, # const unsigned char *ad,
+ adlen, # unsigned long long adlen,
+ tag)) # unsigned char tag)
+ return c.raw
+
+
+#crypto_secretstream_xchacha20poly1305_pull (crypto_secretstream_xchacha20poly1305_state *state,
+# unsigned char *m,
+# unsigned long long *mlen_p,
+# unsigned char *tag_p,
+# const unsigned char *in,
+# unsigned long long inlen,
+# const unsigned char *ad,
+# unsigned long long adlen)
+ at sodium_version(1, 0, 15)
+def crypto_secretstream_xchacha20poly1305_pull(state, ciphertext, ad):
+ if None in (state, ciphertext):
+ raise ValueError("invalid parameters")
+ if not (len(state) == crypto_secretstream_xchacha20poly1305_STATEBYTES): raise ValueError("Truncated state")
+ if len(ciphertext) < crypto_secretstream_xchacha20poly1305_ABYTES:
+ raise ValueError("truncated cyphertext")
+
+ m = ctypes.create_string_buffer(len(ciphertext) - crypto_secretstream_xchacha20poly1305_ABYTES)
+ mlen = ctypes.c_ulonglong(0)
+ tag = ctypes.c_ubyte(0)
+ clen = ctypes.c_ulonglong(len(ciphertext))
+ adlen = ctypes.c_ulonglong(len(ad)) if ad is not None else ctypes.c_ulonglong(0)
+
+ __check(sodium.crypto_secretstream_xchacha20poly1305_pull(
+ state,
+ m, # char *m,
+ ctypes.byref(mlen), # long long *mlen_p,
+ ctypes.byref(tag), # char *tag_p,
+ ciphertext, # unsigned char *in,
+ clen, # long long inlen,
+ ad, # unsigned char *ad,
+ adlen # long long adlen)
+ ))
+ return m.raw, tag.value
def crypto_sign_keypair():
pk = ctypes.create_string_buffer(crypto_sign_PUBLICKEYBYTES)
@@ -473,6 +752,7 @@ def crypto_sign_keypair():
def crypto_sign_seed_keypair(seed):
+ if len(seed) != crypto_sign_SEEDBYTES: raise ValueError("invalid seed size")
pk = ctypes.create_string_buffer(crypto_sign_PUBLICKEYBYTES)
sk = ctypes.create_string_buffer(crypto_sign_SECRETKEYBYTES)
__check(sodium.crypto_sign_seed_keypair(pk, sk, seed))
@@ -481,6 +761,8 @@ def crypto_sign_seed_keypair(seed):
def crypto_sign(m, sk):
if m is None or sk is None:
raise ValueError("invalid parameters")
+ if not (len(sk) == crypto_sign_SECRETKEYBYTES): raise ValueError('Truncated secret key')
+
smsg = ctypes.create_string_buffer(len(m) + crypto_sign_BYTES)
smsglen = ctypes.c_ulonglong()
__check(sodium.crypto_sign(smsg, ctypes.byref(smsglen), m, ctypes.c_ulonglong(len(m)), sk))
@@ -490,6 +772,7 @@ def crypto_sign(m, sk):
def crypto_sign_detached(m, sk):
if m is None or sk is None:
raise ValueError("invalid parameters")
+ if not (len(sk) == crypto_sign_SECRETKEYBYTES): raise ValueError('Truncated secret key')
sig = ctypes.create_string_buffer(crypto_sign_BYTES)
... 572 lines suppressed ...
--
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