rbnacl 3.4.0 → 4.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.rubocop.yml +23 -18
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +8 -17
  6. data/CHANGES.md +21 -2
  7. data/Gemfile +1 -1
  8. data/README.md +29 -18
  9. data/Rakefile +1 -0
  10. data/lib/rbnacl.rb +11 -1
  11. data/lib/rbnacl/aead/aead.rb +143 -0
  12. data/lib/rbnacl/aead/chacha20poly1305.rb +42 -0
  13. data/lib/rbnacl/aead/chacha20poly1305_ietf.rb +44 -0
  14. data/lib/rbnacl/auth.rb +2 -0
  15. data/lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb +5 -1
  16. data/lib/rbnacl/boxes/curve25519xsalsa20poly1305/private_key.rb +1 -0
  17. data/lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb +1 -0
  18. data/lib/rbnacl/group_elements/curve25519.rb +2 -0
  19. data/lib/rbnacl/hash.rb +2 -0
  20. data/lib/rbnacl/hash/blake2b.rb +2 -0
  21. data/lib/rbnacl/hash/sha256.rb +2 -0
  22. data/lib/rbnacl/hash/sha512.rb +2 -0
  23. data/lib/rbnacl/hmac/sha256.rb +2 -0
  24. data/lib/rbnacl/hmac/sha512.rb +2 -0
  25. data/lib/rbnacl/hmac/sha512256.rb +2 -0
  26. data/lib/rbnacl/init.rb +2 -0
  27. data/lib/rbnacl/key_comparator.rb +2 -0
  28. data/lib/rbnacl/one_time_auths/poly1305.rb +2 -0
  29. data/lib/rbnacl/password_hash.rb +55 -4
  30. data/lib/rbnacl/password_hash/argon2.rb +202 -0
  31. data/lib/rbnacl/password_hash/scrypt.rb +5 -1
  32. data/lib/rbnacl/random.rb +4 -1
  33. data/lib/rbnacl/secret_boxes/xsalsa20poly1305.rb +2 -0
  34. data/lib/rbnacl/self_test.rb +3 -2
  35. data/lib/rbnacl/serializable.rb +2 -0
  36. data/lib/rbnacl/signatures/ed25519.rb +2 -0
  37. data/lib/rbnacl/signatures/ed25519/signing_key.rb +2 -0
  38. data/lib/rbnacl/signatures/ed25519/verify_key.rb +2 -0
  39. data/lib/rbnacl/simple_box.rb +2 -0
  40. data/lib/rbnacl/sodium.rb +11 -0
  41. data/lib/rbnacl/sodium/version.rb +14 -4
  42. data/lib/rbnacl/test_vectors.rb +47 -1
  43. data/lib/rbnacl/util.rb +4 -1
  44. data/lib/rbnacl/version.rb +2 -1
  45. data/rbnacl.gemspec +20 -20
  46. data/spec/rbnacl/aead/chacha20poly1305_ietf_spec.rb +16 -0
  47. data/spec/rbnacl/aead/chacha20poly1305_orig_spec.rb +14 -0
  48. data/spec/rbnacl/authenticators/poly1305_spec.rb +1 -1
  49. data/spec/rbnacl/boxes/curve25519xsalsa20poly1305/private_key_spec.rb +1 -1
  50. data/spec/rbnacl/boxes/curve25519xsalsa20poly1305/public_key_spec.rb +1 -1
  51. data/spec/rbnacl/boxes/curve25519xsalsa20poly1305_spec.rb +1 -1
  52. data/spec/rbnacl/group_element_spec.rb +1 -1
  53. data/spec/rbnacl/hash/blake2b_spec.rb +2 -2
  54. data/spec/rbnacl/hash_spec.rb +1 -1
  55. data/spec/rbnacl/hmac/sha256_spec.rb +1 -1
  56. data/spec/rbnacl/hmac/sha512256_spec.rb +1 -1
  57. data/spec/rbnacl/hmac/sha512_spec.rb +1 -1
  58. data/spec/rbnacl/password_hash/argon2_spec.rb +44 -0
  59. data/spec/rbnacl/password_hash/scrypt_spec.rb +1 -1
  60. data/spec/rbnacl/random_spec.rb +2 -0
  61. data/spec/rbnacl/secret_box_spec.rb +1 -1
  62. data/spec/rbnacl/signatures/ed25519/signing_key_spec.rb +1 -1
  63. data/spec/rbnacl/signatures/ed25519/verify_key_spec.rb +2 -0
  64. data/spec/rbnacl/simple_box_spec.rb +1 -1
  65. data/spec/rbnacl/util_spec.rb +5 -3
  66. data/spec/shared/aead.rb +82 -0
  67. data/spec/shared/authenticator.rb +2 -0
  68. data/spec/shared/box.rb +1 -0
  69. data/spec/shared/key_equality.rb +2 -0
  70. data/spec/shared/serializable.rb +1 -0
  71. data/spec/spec_helper.rb +3 -0
  72. data/tasks/rspec.rake +3 -0
  73. data/tasks/rubocop.rake +3 -0
  74. metadata +25 -43
  75. data/bascule.asc +0 -449
  76. data/bascule.cert +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcf4ccd28c18cf4c35fbdaf0b6a477e76611dde0
4
- data.tar.gz: 9e6e95385b32259c3de1a5be583e20f910ba3f9d
3
+ metadata.gz: c2f871a780f690af1d6c71ee6ac966a31c04e955
4
+ data.tar.gz: efb865e57cce84746c469fe9a5aba80e825fac3f
5
5
  SHA512:
6
- metadata.gz: 06843ef90fb734f7b2003adf225f78701682766c45fc5f786e4ee2e09347f7b3827df96fa14e39a3347eb097db168327f58e8867f483cbfd07fcc6dbb0870849
7
- data.tar.gz: 5afb3ed48547db7e6883478654fe4c06065aa2fec84e43ce78d6f950d3cc439130039aad2eb34240bfe1026ed4939efa10878dc31ec5a0faadc67af6f6adfa5c
6
+ metadata.gz: 5f6d7c58f9873cc194eca83fc1acae8554dba2624d98d7bc5c505ed99071119c9af40d77038f7c4ab015465fcdeda22c33910258bfb235d9335b53d4740be7e2
7
+ data.tar.gz: 471154df784020f8762d7ef3c41f4ae026764f87b720be581e9e0d8efc26c6ba41944d532015b54423f74b411b264c633ebac39065c18fa6843f216f2481c7f6
data/.rspec CHANGED
@@ -3,3 +3,4 @@
3
3
  --backtrace
4
4
  --order random
5
5
  --warnings
6
+ --require spec_helper
@@ -1,10 +1,31 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ Include:
4
+ - '**/Rakefile'
5
+ Exclude:
6
+ - 'spec/**/*'
7
+ - 'vendor/**/*'
8
+ - 'lib/rbnacl/test_vectors.rb'
9
+
10
+ #
11
+ # Metrics
12
+ #
13
+
14
+ Metrics/AbcSize:
15
+ Max: 20
16
+
17
+ Metrics/ClassLength:
18
+ Max: 150
19
+
20
+ Metrics/MethodLength:
21
+ Max: 25
22
+
1
23
  #
2
24
  # Style
3
25
  #
4
26
 
5
- # TODO: turn this down
6
27
  LineLength:
7
- Max: 150
28
+ Max: 128
8
29
 
9
30
  Style/StringLiterals:
10
31
  EnforcedStyle: double_quotes
@@ -14,19 +35,3 @@ Style/SpaceBeforeFirstArg:
14
35
 
15
36
  Style/GlobalVars:
16
37
  Enabled: false
17
-
18
- #
19
- # Metrics
20
- #
21
-
22
- Metrics/MethodLength:
23
- Max: 22
24
-
25
- Metrics/AbcSize:
26
- Max: 20
27
-
28
- AllCops:
29
- Include:
30
- - '**/Rakefile'
31
- Exclude:
32
- - 'spec/**/*'
@@ -0,0 +1 @@
1
+ 2.3.3
@@ -1,33 +1,24 @@
1
1
  language: ruby
2
2
  sudo: false
3
+ cache: bundler
3
4
  script: bundle exec rake ci
5
+ bundler_args: --without development
6
+
4
7
  branches:
5
8
  only:
6
9
  - master
7
10
 
8
- bundler_args: --without development
9
-
10
11
  rvm:
11
- - 2.0.0
12
- - 2.1.10
13
- - 2.2.5
14
- - 2.3.1
15
- - ruby-head
16
- - jruby
17
- - jruby-9.0.5.0
18
- - jruby-head
19
- - rbx-2
12
+ - jruby-9.1.6.0
13
+ - 2.2.6
14
+ - 2.3.3
20
15
 
21
16
  env:
22
- - LIBSODIUM_VERSION=1.0.0 # Minimum supported
23
- - LIBSODIUM_VERSION=1.0.8 # Latest released
17
+ - LIBSODIUM_VERSION=1.0.0 # Minimum supported
18
+ - LIBSODIUM_VERSION=1.0.11 # Latest released
24
19
 
25
20
  matrix:
26
21
  fast_finish: true
27
- allow_failures:
28
- - rvm: ruby-head
29
- - rvm: jruby-head
30
- - rvm: rbx-2
31
22
 
32
23
  notifications:
33
24
  irc: "irc.freenode.org#cryptosphere"
data/CHANGES.md CHANGED
@@ -1,12 +1,27 @@
1
+ 4.0.0.pre (2016-12-04)
2
+ ----------------------
3
+
4
+ * [#141](https://github.com/cryptosphere/rbnacl/pull/141)
5
+ Add wrappers for ChaCha20Poly1305 AEAD ciphers.
6
+ ([@aadavids])
7
+
8
+ * [#142](https://github.com/cryptosphere/rbnacl/pull/142)
9
+ Added support for Argon2 password hash.
10
+ ([@elijh])
11
+
12
+ * [#143](https://github.com/cryptosphere/rbnacl/pull/143)
13
+ Require Ruby 2.2.6+.
14
+ ([@tarcieri])
15
+
1
16
  3.4.0 (2015-05-07)
2
17
  ------------------
3
18
  * [#135](https://github.com/cryptosphere/rbnacl/pull/135)
4
19
  Expose RbNaCl::Signatures::Ed25519#keypair_bytes.
5
- (@grempe)
20
+ ([@grempe])
6
21
 
7
22
  * [#137](https://github.com/cryptosphere/rbnacl/pull/137)
8
23
  Expose HMAC-SHA512 (with 64-byte keys)
9
- (@mwpastore)
24
+ ([@mwpastore])
10
25
 
11
26
  3.3.0 (2015-12-29)
12
27
  ------------------
@@ -82,3 +97,7 @@
82
97
 
83
98
  [@namelessjon]: https://github.com/namelessjon
84
99
  [@tarcieri]: https://github.com/tarcieri
100
+ [@aadavids]: https://github.com/aadavids
101
+ [@grempe]: https://github.com/grempe
102
+ [@mwpastore]: https://github.com/mwpastore
103
+ [@elijh]: https://github.com/elijh
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ end
8
8
 
9
9
  group :test do
10
10
  gem "rspec"
11
- gem "rubocop", "0.39.0"
11
+ gem "rubocop", "0.46.0"
12
12
  gem "coveralls", require: false
13
13
  gem "rbnacl-libsodium", ENV["LIBSODIUM_VERSION"]
14
14
  end
data/README.md CHANGED
@@ -6,6 +6,11 @@
6
6
  [![Coverage Status](https://coveralls.io/repos/cryptosphere/rbnacl/badge.svg?branch=master)](https://coveralls.io/r/cryptosphere/rbnacl)
7
7
  [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/cryptosphere/rbnacl/blob/master/LICENSE.txt)
8
8
 
9
+ _NOTE: This is the 4.x **development** branch of RbNaCl. For the 3.x **stable**
10
+ branch, please see:_
11
+
12
+ https://github.com/cryptosphere/rbnacl/tree/3-x-stable
13
+
9
14
  A Ruby binding to the state-of-the-art [Networking and Cryptography][nacl]
10
15
  library by [Daniel J. Bernstein][djb]. This is **NOT** Google Native Client.
11
16
  This is a crypto library.
@@ -53,11 +58,29 @@ For more information on NaCl's goals, see Dan Bernstein's presentation
53
58
 
54
59
  ## Supported platforms
55
60
 
56
- You can use RbNaCl anywhere you can get libsodium installed (see below).
57
- RbNaCl is continuously integration tested on the following Ruby VMs:
61
+ You can use RbNaCl on platforms libsodium is supported (see below).
62
+
63
+ This library aims to support and is [tested against][travis] the following Ruby
64
+ versions:
65
+
66
+ * Ruby 2.2.6+
67
+ * Ruby 2.3.0+
68
+ * JRuby 9.1.6.0+
69
+
70
+ If something doesn't work on one of these versions, it's a bug.
71
+
72
+ This library may inadvertently work (or seem to work) on other Ruby versions,
73
+ however support will only be provided for the versions listed above.
58
74
 
59
- * MRI 2.0, 2.1, 2.2, 2.3
60
- * JRuby 1.7, 9000
75
+ If you would like this library to support another Ruby version or
76
+ implementation, you may volunteer to be a maintainer. Being a maintainer
77
+ entails making sure all tests run and pass on that implementation. When
78
+ something breaks on your implementation, you will be responsible for providing
79
+ patches in a timely fashion. If critical issues for a particular implementation
80
+ exist at the time of a major release, support for that Ruby version may be
81
+ dropped.
82
+
83
+ [travis]: http://travis-ci.org/cryptosphere/rbnacl
61
84
 
62
85
  ## Installation
63
86
 
@@ -72,7 +95,7 @@ To use RbNaCl, you will need to install libsodium:
72
95
 
73
96
  https://github.com/jedisct1/libsodium
74
97
 
75
- At least version `1.0.0` is recommended.
98
+ At least version `1.0.0` is required.
76
99
 
77
100
  For OS X users, libsodium is available via homebrew and can be installed with:
78
101
 
@@ -139,19 +162,6 @@ information.
139
162
  [hashes]: https://github.com/cryptosphere/rbnacl/wiki/Hash-Functions
140
163
  [rdoc]: http://rubydoc.info/github/cryptosphere/rbnacl/master/frames
141
164
 
142
- ## Reporting Security Problems
143
-
144
- If you have discovered a bug in RbNaCl of a sensitive nature, i.e.
145
- one which can compromise the security of RbNaCl users, you can
146
- report it securely by sending a GPG encrypted message. Please use
147
- the following key:
148
-
149
- https://raw.github.com/cryptosphere/rbnacl/master/bascule.asc
150
-
151
- The key fingerprint is (or should be):
152
-
153
- `9148 85A2 6242 1628 B6AA AB45 4CB9 B3D0 BACC 8B71`
154
-
155
165
  ## Learn More
156
166
 
157
167
  While NaCl has designed to be easier-than-usual to use for a crypto
@@ -163,6 +173,7 @@ interested in learning more about how NaCl works, it's recommended
163
173
  that you read them:
164
174
 
165
175
  * [Cryptography in NaCl](http://cr.yp.to/highspeed/naclcrypto-20090310.pdf)
176
+ * [Salsa20 Design](https://cr.yp.to/snuffle/design.pdf)
166
177
  * [Curve25519: new Diffie-Hellman speed records](http://cr.yp.to/ecdh/curve25519-20060209.pdf)
167
178
  * [Ed25519: High-speed high-security signatures](http://ed25519.cr.yp.to/ed25519-20110926.pdf)
168
179
 
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/gem_tasks"
2
3
 
3
4
  Dir[File.expand_path("../tasks/**/*.rake", __FILE__)].each { |task| load task }
@@ -1,4 +1,6 @@
1
1
  # encoding: binary
2
+ # frozen_string_literal: true
3
+
2
4
  require "rbnacl/version"
3
5
  require "rbnacl/sodium"
4
6
  require "rbnacl/sodium/version"
@@ -10,6 +12,7 @@ require "rbnacl/random"
10
12
  require "rbnacl/simple_box"
11
13
  require "rbnacl/test_vectors"
12
14
  require "rbnacl/init"
15
+ require "rbnacl/aead/aead"
13
16
 
14
17
  # NaCl/libsodium for Ruby
15
18
  module RbNaCl
@@ -63,15 +66,22 @@ module RbNaCl
63
66
  require "rbnacl/hash/sha512"
64
67
  require "rbnacl/hash/blake2b"
65
68
 
66
- # Password hash function: scrypt
69
+ # Password hash functions
67
70
  require "rbnacl/password_hash"
68
71
  require "rbnacl/password_hash/scrypt"
72
+ if RbNaCl::Sodium::Version::ARGON2_SUPPORTED
73
+ require "rbnacl/password_hash/argon2"
74
+ end
69
75
 
70
76
  # HMAC: SHA256/512 and SHA512256
71
77
  require "rbnacl/hmac/sha256"
72
78
  require "rbnacl/hmac/sha512256"
73
79
  require "rbnacl/hmac/sha512"
74
80
 
81
+ # AEAD: ChaCha20-Poly1305
82
+ require "rbnacl/aead/chacha20poly1305"
83
+ require "rbnacl/aead/chacha20poly1305_ietf"
84
+
75
85
  #
76
86
  # Bind aliases used by the public API
77
87
  #
@@ -0,0 +1,143 @@
1
+ # encoding: binary
2
+ # frozen_string_literal: true
3
+
4
+ module RbNaCl
5
+ module AEAD
6
+ # Authenticated Encryption with Additional Data
7
+ #
8
+ # This construction encrypts a message, and computes an authentication
9
+ # tag for the encrypted message and some optional additional data
10
+ #
11
+ # RbNaCl provides wrappers for both ChaCha20-Poly1305 AEAD implementations
12
+ # in libsodium: the original, and the IETF version.
13
+ class GenericAEAD
14
+ # Number of bytes in a valid key
15
+ KEYBYTES = 0
16
+
17
+ # Number of bytes in a valid nonce
18
+ NPUBBYTES = 0
19
+
20
+ attr_reader :key
21
+ private :key
22
+
23
+ # Create a new AEAD using the IETF chacha20poly1305 construction
24
+ #
25
+ # Sets up AEAD with a secret key for encrypting and decrypting messages.
26
+ #
27
+ # @param key [String] The key to encrypt and decrypt with
28
+ #
29
+ # @raise [RbNaCl::LengthError] on invalid keys
30
+ #
31
+ # @return [RbNaCl::AEAD::Chacha20Poly1305IETF] The new AEAD construct, ready to use
32
+ def initialize(key)
33
+ @key = Util.check_string(key, key_bytes, "Secret key")
34
+ end
35
+
36
+ # Encrypts and authenticates a message with additional authenticated data
37
+ #
38
+ # @param nonce [String] An 8-byte string containing the nonce.
39
+ # @param message [String] The message to be encrypted.
40
+ # @param additional_data [String] The additional authenticated data
41
+ #
42
+ # @raise [RbNaCl::LengthError] If the nonce is not valid
43
+ # @raise [RbNaCl::CryptoError] If the ciphertext cannot be authenticated.
44
+ #
45
+ # @return [String] The encrypted message with the authenticator tag appended
46
+ def encrypt(nonce, message, additional_data)
47
+ Util.check_length(nonce, nonce_bytes, "Nonce")
48
+
49
+ ciphertext_len = Util.zeros(1)
50
+ ciphertext = Util.zeros(data_len(message) + tag_bytes)
51
+
52
+ success = do_encrypt(ciphertext, ciphertext_len, nonce, message, additional_data)
53
+ raise CryptoError, "Encryption failed" unless success
54
+ ciphertext
55
+ end
56
+
57
+ # Decrypts and verifies an encrypted message with additional authenticated data
58
+ #
59
+ # @param nonce [String] An 8-byte string containing the nonce.
60
+ # @param ciphertext [String] The message to be decrypted.
61
+ # @param additional_data [String] The additional authenticated data
62
+ #
63
+ # @raise [RbNaCl::LengthError] If the nonce is not valid
64
+ # @raise [RbNaCl::CryptoError] If the ciphertext cannot be authenticated.
65
+ #
66
+ # @return [String] The decrypted message
67
+ def decrypt(nonce, ciphertext, additional_data)
68
+ Util.check_length(nonce, nonce_bytes, "Nonce")
69
+
70
+ message_len = Util.zeros(1)
71
+ message = Util.zeros(data_len(ciphertext) - tag_bytes)
72
+
73
+ success = do_decrypt(message, message_len, nonce, ciphertext, additional_data)
74
+ raise CryptoError, "Decryption failed. Ciphertext failed verification." unless success
75
+ message
76
+ end
77
+
78
+ # The crypto primitive for this aead instance
79
+ #
80
+ # @return [Symbol] The primitive used
81
+ def primitive
82
+ self.class.primitive
83
+ end
84
+
85
+ # The nonce bytes for the AEAD class
86
+ #
87
+ # @return [Integer] The number of bytes in a valid nonce
88
+ def self.nonce_bytes
89
+ self::NPUBBYTES
90
+ end
91
+
92
+ # The nonce bytes for the AEAD instance
93
+ #
94
+ # @return [Integer] The number of bytes in a valid nonce
95
+ def nonce_bytes
96
+ self.class.nonce_bytes
97
+ end
98
+
99
+ # The key bytes for the AEAD class
100
+ #
101
+ # @return [Integer] The number of bytes in a valid key
102
+ def self.key_bytes
103
+ self::KEYBYTES
104
+ end
105
+
106
+ # The key bytes for the AEAD instance
107
+ #
108
+ # @return [Integer] The number of bytes in a valid key
109
+ def key_bytes
110
+ self.class.key_bytes
111
+ end
112
+
113
+ # The number bytes in the tag or authenticator from this AEAD class
114
+ #
115
+ # @return [Integer] number of tag bytes
116
+ def self.tag_bytes
117
+ self::ABYTES
118
+ end
119
+
120
+ # The number of bytes in the tag or authenticator for this AEAD instance
121
+ #
122
+ # @return [Integer] number of tag bytes
123
+ def tag_bytes
124
+ self.class.tag_bytes
125
+ end
126
+
127
+ private
128
+
129
+ def data_len(data)
130
+ return 0 if data.nil?
131
+ data.bytesize
132
+ end
133
+
134
+ def do_encrypt(_ciphertext, _ciphertext_len, _nonce, _message, _additional_data)
135
+ raise NotImplementedError
136
+ end
137
+
138
+ def do_decrypt(_message, _message_len, _nonce, _ciphertext, _additional_data)
139
+ raise NotImplementedError
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: binary
2
+ # frozen_string_literal: true
3
+
4
+ module RbNaCl
5
+ module AEAD
6
+ # This class contains wrappers for the original libsodium implementation of
7
+ # Authenticated Encryption with Additional Data using ChaCha20-Poly1305
8
+ class Chacha20Poly1305 < GenericAEAD
9
+ extend Sodium
10
+
11
+ sodium_type :aead
12
+ sodium_primitive :chacha20poly1305
13
+ sodium_constant :KEYBYTES
14
+ sodium_constant :NPUBBYTES
15
+ sodium_constant :ABYTES
16
+
17
+ sodium_function :aead_chacha20poly1305_encrypt,
18
+ :crypto_aead_chacha20poly1305_encrypt,
19
+ [:pointer, :pointer, :pointer, :ulong_long, :pointer, :ulong_long, :pointer, :pointer, :pointer]
20
+
21
+ sodium_function :aead_chacha20poly1305_decrypt,
22
+ :crypto_aead_chacha20poly1305_decrypt,
23
+ [:pointer, :pointer, :pointer, :pointer, :ulong_long, :pointer, :ulong_long, :pointer, :pointer]
24
+
25
+ private
26
+
27
+ def do_encrypt(ciphertext, ciphertext_len, nonce, message, additional_data)
28
+ self.class.aead_chacha20poly1305_encrypt(ciphertext, ciphertext_len,
29
+ message, data_len(message),
30
+ additional_data, data_len(additional_data),
31
+ nil, nonce, @key)
32
+ end
33
+
34
+ def do_decrypt(message, message_len, nonce, ciphertext, additional_data)
35
+ self.class.aead_chacha20poly1305_decrypt(message, message_len, nil,
36
+ ciphertext, data_len(ciphertext),
37
+ additional_data, data_len(additional_data),
38
+ nonce, @key)
39
+ end
40
+ end
41
+ end
42
+ end