__init__.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. # Copyright 2013 Donald Stufft and individual contributors
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from __future__ import absolute_import, division, print_function
  15. from nacl.bindings.crypto_box import (
  16. crypto_box, crypto_box_BEFORENMBYTES, crypto_box_BOXZEROBYTES,
  17. crypto_box_NONCEBYTES, crypto_box_PUBLICKEYBYTES,
  18. crypto_box_SECRETKEYBYTES, crypto_box_ZEROBYTES, crypto_box_afternm,
  19. crypto_box_beforenm, crypto_box_keypair, crypto_box_open,
  20. crypto_box_open_afternm,
  21. )
  22. from nacl.bindings.crypto_generichash import (
  23. crypto_generichash_BYTES, crypto_generichash_BYTES_MAX,
  24. crypto_generichash_BYTES_MIN, crypto_generichash_KEYBYTES,
  25. crypto_generichash_KEYBYTES_MAX, crypto_generichash_KEYBYTES_MIN,
  26. crypto_generichash_PERSONALBYTES, crypto_generichash_SALTBYTES,
  27. crypto_generichash_STATEBYTES,
  28. generichash_blake2b_final as crypto_generichash_blake2b_final,
  29. generichash_blake2b_init as crypto_generichash_blake2b_init,
  30. generichash_blake2b_salt_personal as
  31. crypto_generichash_blake2b_salt_personal,
  32. generichash_blake2b_state_copy as crypto_generichash_blake2b_state_copy,
  33. generichash_blake2b_update as crypto_generichash_blake2b_update
  34. )
  35. from nacl.bindings.crypto_hash import (
  36. crypto_hash, crypto_hash_BYTES, crypto_hash_sha256,
  37. crypto_hash_sha256_BYTES, crypto_hash_sha512, crypto_hash_sha512_BYTES,
  38. )
  39. from nacl.bindings.crypto_pwhash import (
  40. crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE,
  41. crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE,
  42. crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE,
  43. crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE,
  44. crypto_pwhash_scryptsalsa208sha256_SALTBYTES,
  45. crypto_pwhash_scryptsalsa208sha256_STRBYTES,
  46. crypto_pwhash_scryptsalsa208sha256_ll,
  47. crypto_pwhash_scryptsalsa208sha256_str,
  48. crypto_pwhash_scryptsalsa208sha256_str_verify,
  49. nacl_bindings_pick_scrypt_params,
  50. )
  51. from nacl.bindings.crypto_scalarmult import (
  52. crypto_scalarmult, crypto_scalarmult_BYTES, crypto_scalarmult_SCALARBYTES,
  53. crypto_scalarmult_base
  54. )
  55. from nacl.bindings.crypto_secretbox import (
  56. crypto_secretbox, crypto_secretbox_BOXZEROBYTES, crypto_secretbox_KEYBYTES,
  57. crypto_secretbox_NONCEBYTES, crypto_secretbox_ZEROBYTES,
  58. crypto_secretbox_open
  59. )
  60. from nacl.bindings.crypto_shorthash import (
  61. BYTES as crypto_shorthash_siphash24_BYTES,
  62. KEYBYTES as crypto_shorthash_siphash24_KEYBYTES,
  63. crypto_shorthash_siphash24
  64. )
  65. from nacl.bindings.crypto_sign import (
  66. crypto_sign, crypto_sign_BYTES, crypto_sign_PUBLICKEYBYTES,
  67. crypto_sign_SECRETKEYBYTES, crypto_sign_SEEDBYTES,
  68. crypto_sign_ed25519_pk_to_curve25519, crypto_sign_ed25519_sk_to_curve25519,
  69. crypto_sign_keypair, crypto_sign_open, crypto_sign_seed_keypair
  70. )
  71. from nacl.bindings.randombytes import randombytes
  72. from nacl.bindings.sodium_core import sodium_init
  73. from nacl.bindings.utils import sodium_memcmp
  74. __all__ = [
  75. "crypto_box_SECRETKEYBYTES",
  76. "crypto_box_PUBLICKEYBYTES",
  77. "crypto_box_NONCEBYTES",
  78. "crypto_box_ZEROBYTES",
  79. "crypto_box_BOXZEROBYTES",
  80. "crypto_box_BEFORENMBYTES",
  81. "crypto_box_keypair",
  82. "crypto_box",
  83. "crypto_box_open",
  84. "crypto_box_beforenm",
  85. "crypto_box_afternm",
  86. "crypto_box_open_afternm",
  87. "crypto_hash_BYTES",
  88. "crypto_hash_sha256_BYTES",
  89. "crypto_hash_sha512_BYTES",
  90. "crypto_hash",
  91. "crypto_hash_sha256",
  92. "crypto_hash_sha512",
  93. "crypto_generichash_BYTES",
  94. "crypto_generichash_BYTES_MIN",
  95. "crypto_generichash_BYTES_MAX",
  96. "crypto_generichash_KEYBYTES",
  97. "crypto_generichash_KEYBYTES_MIN",
  98. "crypto_generichash_KEYBYTES_MAX",
  99. "crypto_generichash_SALTBYTES",
  100. "crypto_generichash_PERSONALBYTES",
  101. "crypto_generichash_STATEBYTES",
  102. "crypto_generichash_blake2b_salt_personal",
  103. "crypto_generichash_blake2b_init",
  104. "crypto_generichash_blake2b_update",
  105. "crypto_generichash_blake2b_final",
  106. "crypto_generichash_blake2b_state_copy",
  107. "crypto_scalarmult_BYTES",
  108. "crypto_scalarmult_SCALARBYTES",
  109. "crypto_scalarmult",
  110. "crypto_scalarmult_base",
  111. "crypto_secretbox_KEYBYTES",
  112. "crypto_secretbox_NONCEBYTES",
  113. "crypto_secretbox_ZEROBYTES",
  114. "crypto_secretbox_BOXZEROBYTES",
  115. "crypto_secretbox",
  116. "crypto_secretbox_open",
  117. "crypto_shorthash_siphash24_BYTES",
  118. "crypto_shorthash_siphash24_KEYBYTES",
  119. "crypto_shorthash_siphash24",
  120. "crypto_sign_BYTES",
  121. "crypto_sign_SEEDBYTES",
  122. "crypto_sign_PUBLICKEYBYTES",
  123. "crypto_sign_SECRETKEYBYTES",
  124. "crypto_sign_keypair",
  125. "crypto_sign_seed_keypair",
  126. "crypto_sign",
  127. "crypto_sign_open",
  128. "crypto_sign_ed25519_pk_to_curve25519",
  129. "crypto_sign_ed25519_sk_to_curve25519",
  130. "crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE",
  131. "crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE",
  132. "crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE",
  133. "crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE",
  134. "crypto_pwhash_scryptsalsa208sha256_SALTBYTES",
  135. "crypto_pwhash_scryptsalsa208sha256_STRBYTES",
  136. "crypto_pwhash_scryptsalsa208sha256_ll",
  137. "crypto_pwhash_scryptsalsa208sha256_str",
  138. "crypto_pwhash_scryptsalsa208sha256_str_verify",
  139. "nacl_bindings_pick_scrypt_params",
  140. "randombytes",
  141. "sodium_init",
  142. "sodium_memcmp",
  143. ]
  144. # Initialize Sodium
  145. sodium_init()