ruby-paseto 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +8 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +549 -0
- data/lib/paseto/asn1/algorithm_identifier.rb +17 -0
- data/lib/paseto/asn1/curve_private_key.rb +22 -0
- data/lib/paseto/asn1/ec_private_key.rb +27 -0
- data/lib/paseto/asn1/ecdsa_full_r.rb +26 -0
- data/lib/paseto/asn1/ecdsa_sig_value.rb +23 -0
- data/lib/paseto/asn1/ecdsa_signature.rb +49 -0
- data/lib/paseto/asn1/ed25519_identifier.rb +15 -0
- data/lib/paseto/asn1/named_curve.rb +17 -0
- data/lib/paseto/asn1/one_asymmetric_key.rb +32 -0
- data/lib/paseto/asn1/private_key.rb +17 -0
- data/lib/paseto/asn1/private_key_algorithm_identifier.rb +17 -0
- data/lib/paseto/asn1/public_key.rb +17 -0
- data/lib/paseto/asn1/subject_public_key_info.rb +28 -0
- data/lib/paseto/asn1.rb +101 -0
- data/lib/paseto/asymmetric_key.rb +100 -0
- data/lib/paseto/configuration/box.rb +23 -0
- data/lib/paseto/configuration/decode_configuration.rb +68 -0
- data/lib/paseto/configuration.rb +18 -0
- data/lib/paseto/interface/i_d.rb +23 -0
- data/lib/paseto/interface/key.rb +113 -0
- data/lib/paseto/interface/pbkd.rb +83 -0
- data/lib/paseto/interface/pie.rb +59 -0
- data/lib/paseto/interface/pke.rb +86 -0
- data/lib/paseto/interface/serializer.rb +19 -0
- data/lib/paseto/interface/version.rb +161 -0
- data/lib/paseto/interface/wrapper.rb +20 -0
- data/lib/paseto/operations/i_d.rb +48 -0
- data/lib/paseto/operations/id/i_dv3.rb +20 -0
- data/lib/paseto/operations/id/i_dv4.rb +20 -0
- data/lib/paseto/operations/pbkd/p_b_k_dv3.rb +85 -0
- data/lib/paseto/operations/pbkd/p_b_k_dv4.rb +94 -0
- data/lib/paseto/operations/pbkw.rb +73 -0
- data/lib/paseto/operations/pke/p_k_ev3.rb +97 -0
- data/lib/paseto/operations/pke/p_k_ev4.rb +95 -0
- data/lib/paseto/operations/pke.rb +57 -0
- data/lib/paseto/operations/wrap.rb +29 -0
- data/lib/paseto/paserk.rb +55 -0
- data/lib/paseto/paserk_types.rb +46 -0
- data/lib/paseto/protocol/version3.rb +100 -0
- data/lib/paseto/protocol/version4.rb +99 -0
- data/lib/paseto/result.rb +9 -0
- data/lib/paseto/serializer/optional_json.rb +30 -0
- data/lib/paseto/serializer/raw.rb +23 -0
- data/lib/paseto/sodium/curve_25519.rb +46 -0
- data/lib/paseto/sodium/safe_ed25519_loader.rb +19 -0
- data/lib/paseto/sodium/stream/base.rb +82 -0
- data/lib/paseto/sodium/stream/x_cha_cha20_xor.rb +31 -0
- data/lib/paseto/sodium.rb +5 -0
- data/lib/paseto/symmetric_key.rb +119 -0
- data/lib/paseto/token.rb +127 -0
- data/lib/paseto/token_types.rb +29 -0
- data/lib/paseto/util.rb +105 -0
- data/lib/paseto/v3/local.rb +63 -0
- data/lib/paseto/v3/public.rb +204 -0
- data/lib/paseto/v4/local.rb +56 -0
- data/lib/paseto/v4/public.rb +169 -0
- data/lib/paseto/validator.rb +154 -0
- data/lib/paseto/verifiers/footer.rb +30 -0
- data/lib/paseto/verifiers/payload.rb +42 -0
- data/lib/paseto/verify.rb +48 -0
- data/lib/paseto/version.rb +6 -0
- data/lib/paseto/versions.rb +25 -0
- data/lib/paseto/wrappers/pie/pie_v3.rb +72 -0
- data/lib/paseto/wrappers/pie/pie_v4.rb +72 -0
- data/lib/paseto/wrappers/pie.rb +71 -0
- data/lib/paseto.rb +99 -0
- data/paseto.gemspec +58 -0
- data/sorbet/config +3 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +1083 -0
- data/sorbet/rbi/gems/docile@1.4.0.rbi +376 -0
- data/sorbet/rbi/gems/ffi@1.15.5.rbi +1994 -0
- data/sorbet/rbi/gems/io-console@0.5.11.rbi +8 -0
- data/sorbet/rbi/gems/irb@1.5.1.rbi +342 -0
- data/sorbet/rbi/gems/json@2.6.3.rbi +1541 -0
- data/sorbet/rbi/gems/multi_json@1.15.0.rbi +267 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
- data/sorbet/rbi/gems/oj@3.13.23.rbi +603 -0
- data/sorbet/rbi/gems/openssl@3.0.1.rbi +1735 -0
- data/sorbet/rbi/gems/parallel@1.22.1.rbi +277 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +407 -0
- data/sorbet/rbi/gems/rake@13.0.6.rbi +3021 -0
- data/sorbet/rbi/gems/rbnacl@7.1.1.rbi +3218 -0
- data/sorbet/rbi/gems/regexp_parser@2.6.1.rbi +3481 -0
- data/sorbet/rbi/gems/reline@0.3.1.rbi +8 -0
- data/sorbet/rbi/gems/rexml@3.2.5.rbi +4717 -0
- data/sorbet/rbi/gems/rspec-core@3.12.0.rbi +10887 -0
- data/sorbet/rbi/gems/rspec-expectations@3.12.0.rbi +8090 -0
- data/sorbet/rbi/gems/rspec-mocks@3.12.0.rbi +5300 -0
- data/sorbet/rbi/gems/rspec-support@3.12.0.rbi +1617 -0
- data/sorbet/rbi/gems/rspec@3.12.0.rbi +88 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.11.0.rbi +1239 -0
- data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +219 -0
- data/sorbet/rbi/gems/simplecov@0.21.2.rbi +2135 -0
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +8 -0
- data/sorbet/rbi/gems/thor@1.2.1.rbi +3956 -0
- data/sorbet/rbi/gems/timecop@0.9.6.rbi +350 -0
- data/sorbet/rbi/gems/unicode-display_width@2.3.0.rbi +48 -0
- data/sorbet/rbi/gems/webrick@1.7.0.rbi +2555 -0
- data/sorbet/rbi/gems/yard-sorbet@0.7.0.rbi +391 -0
- data/sorbet/rbi/gems/yard@0.9.28.rbi +17816 -0
- data/sorbet/rbi/gems/zeitwerk@2.6.6.rbi +950 -0
- data/sorbet/rbi/shims/multi_json.rbi +19 -0
- data/sorbet/rbi/shims/openssl.rbi +111 -0
- data/sorbet/rbi/shims/rbnacl.rbi +65 -0
- data/sorbet/rbi/shims/zeitwerk.rbi +6 -0
- data/sorbet/rbi/todo.rbi +7 -0
- data/sorbet/tapioca/config.yml +30 -0
- data/sorbet/tapioca/require.rb +12 -0
- metadata +376 -0
|
@@ -0,0 +1,3218 @@
|
|
|
1
|
+
# typed: true
|
|
2
|
+
|
|
3
|
+
# DO NOT EDIT MANUALLY
|
|
4
|
+
# This is an autogenerated file for types exported from the `rbnacl` gem.
|
|
5
|
+
# Please instead update this file by running `bin/tapioca gem rbnacl`.
|
|
6
|
+
|
|
7
|
+
# NaCl/libsodium for Ruby
|
|
8
|
+
#
|
|
9
|
+
# source://rbnacl//lib/rbnacl/version.rb#5
|
|
10
|
+
module RbNaCl; end
|
|
11
|
+
|
|
12
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#5
|
|
13
|
+
module RbNaCl::AEAD; end
|
|
14
|
+
|
|
15
|
+
# Abstract base class for Authenticated Encryption with Additional Data
|
|
16
|
+
#
|
|
17
|
+
# This construction encrypts a message, and computes an authentication
|
|
18
|
+
# tag for the encrypted message and some optional additional data
|
|
19
|
+
#
|
|
20
|
+
# RbNaCl provides wrappers for both ChaCha20-Poly1305 AEAD implementations
|
|
21
|
+
# in libsodium: the original, and the IETF version.
|
|
22
|
+
#
|
|
23
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#13
|
|
24
|
+
class RbNaCl::AEAD::Base
|
|
25
|
+
# Create a new AEAD using the IETF chacha20poly1305 construction
|
|
26
|
+
#
|
|
27
|
+
# Sets up AEAD with a secret key for encrypting and decrypting messages.
|
|
28
|
+
#
|
|
29
|
+
# @param key [String] The key to encrypt and decrypt with
|
|
30
|
+
# @raise [RbNaCl::LengthError] on invalid keys
|
|
31
|
+
# @return [RbNaCl::AEAD::Chacha20Poly1305IETF] The new AEAD construct, ready to use
|
|
32
|
+
#
|
|
33
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#32
|
|
34
|
+
def initialize(key); end
|
|
35
|
+
|
|
36
|
+
# Decrypts and verifies an encrypted message with additional authenticated data
|
|
37
|
+
#
|
|
38
|
+
# @param nonce [String] An 8-byte string containing the nonce.
|
|
39
|
+
# @param ciphertext [String] The message to be decrypted.
|
|
40
|
+
# @param additional_data [String] The additional authenticated data
|
|
41
|
+
# @raise [RbNaCl::LengthError] If the nonce is not valid
|
|
42
|
+
# @raise [RbNaCl::CryptoError] If the ciphertext cannot be authenticated.
|
|
43
|
+
# @return [String] The decrypted message
|
|
44
|
+
#
|
|
45
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#68
|
|
46
|
+
def decrypt(nonce, ciphertext, additional_data); end
|
|
47
|
+
|
|
48
|
+
# Encrypts and authenticates a message with additional authenticated data
|
|
49
|
+
#
|
|
50
|
+
# @param nonce [String] An 8-byte string containing the nonce.
|
|
51
|
+
# @param message [String] The message to be encrypted.
|
|
52
|
+
# @param additional_data [String] The additional authenticated data
|
|
53
|
+
# @raise [RbNaCl::LengthError] If the nonce is not valid
|
|
54
|
+
# @raise [RbNaCl::CryptoError] If the ciphertext cannot be authenticated.
|
|
55
|
+
# @return [String] The encrypted message with the authenticator tag appended
|
|
56
|
+
#
|
|
57
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#46
|
|
58
|
+
def encrypt(nonce, message, additional_data); end
|
|
59
|
+
|
|
60
|
+
# The key bytes for the AEAD instance
|
|
61
|
+
#
|
|
62
|
+
# @return [Integer] The number of bytes in a valid key
|
|
63
|
+
#
|
|
64
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#111
|
|
65
|
+
def key_bytes; end
|
|
66
|
+
|
|
67
|
+
# The nonce bytes for the AEAD instance
|
|
68
|
+
#
|
|
69
|
+
# @return [Integer] The number of bytes in a valid nonce
|
|
70
|
+
#
|
|
71
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#97
|
|
72
|
+
def nonce_bytes; end
|
|
73
|
+
|
|
74
|
+
# The crypto primitive for this aead instance
|
|
75
|
+
#
|
|
76
|
+
# @return [Symbol] The primitive used
|
|
77
|
+
#
|
|
78
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#83
|
|
79
|
+
def primitive; end
|
|
80
|
+
|
|
81
|
+
# The number of bytes in the tag or authenticator for this AEAD instance
|
|
82
|
+
#
|
|
83
|
+
# @return [Integer] number of tag bytes
|
|
84
|
+
#
|
|
85
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#125
|
|
86
|
+
def tag_bytes; end
|
|
87
|
+
|
|
88
|
+
private
|
|
89
|
+
|
|
90
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#131
|
|
91
|
+
def data_len(data); end
|
|
92
|
+
|
|
93
|
+
# @raise [NotImplementedError]
|
|
94
|
+
#
|
|
95
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#141
|
|
96
|
+
def do_decrypt(_message, _message_len, _nonce, _ciphertext, _additional_data); end
|
|
97
|
+
|
|
98
|
+
# @raise [NotImplementedError]
|
|
99
|
+
#
|
|
100
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#137
|
|
101
|
+
def do_encrypt(_ciphertext, _ciphertext_len, _nonce, _message, _additional_data); end
|
|
102
|
+
|
|
103
|
+
# Returns the value of attribute key.
|
|
104
|
+
#
|
|
105
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#20
|
|
106
|
+
def key; end
|
|
107
|
+
|
|
108
|
+
class << self
|
|
109
|
+
# The key bytes for the AEAD class
|
|
110
|
+
#
|
|
111
|
+
# @return [Integer] The number of bytes in a valid key
|
|
112
|
+
#
|
|
113
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#104
|
|
114
|
+
def key_bytes; end
|
|
115
|
+
|
|
116
|
+
# The nonce bytes for the AEAD class
|
|
117
|
+
#
|
|
118
|
+
# @return [Integer] The number of bytes in a valid nonce
|
|
119
|
+
#
|
|
120
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#90
|
|
121
|
+
def nonce_bytes; end
|
|
122
|
+
|
|
123
|
+
# The number bytes in the tag or authenticator from this AEAD class
|
|
124
|
+
#
|
|
125
|
+
# @return [Integer] number of tag bytes
|
|
126
|
+
#
|
|
127
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#118
|
|
128
|
+
def tag_bytes; end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Number of bytes in a valid key
|
|
133
|
+
#
|
|
134
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#15
|
|
135
|
+
RbNaCl::AEAD::Base::KEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
136
|
+
|
|
137
|
+
# Number of bytes in a valid nonce
|
|
138
|
+
#
|
|
139
|
+
# source://rbnacl//lib/rbnacl/aead/base.rb#18
|
|
140
|
+
RbNaCl::AEAD::Base::NPUBBYTES = T.let(T.unsafe(nil), Integer)
|
|
141
|
+
|
|
142
|
+
# This class contains wrappers for the IETF implementation of
|
|
143
|
+
# Authenticated Encryption with Additional Data using ChaCha20-Poly1305
|
|
144
|
+
#
|
|
145
|
+
# source://rbnacl//lib/rbnacl/aead/chacha20poly1305_ietf.rb#8
|
|
146
|
+
class RbNaCl::AEAD::ChaCha20Poly1305IETF < ::RbNaCl::AEAD::Base
|
|
147
|
+
extend ::RbNaCl::Sodium
|
|
148
|
+
extend ::FFI::Library
|
|
149
|
+
|
|
150
|
+
def crypto_aead_chacha20poly1305_ietf_abytes(*_arg0); end
|
|
151
|
+
def crypto_aead_chacha20poly1305_ietf_decrypt(*_arg0); end
|
|
152
|
+
def crypto_aead_chacha20poly1305_ietf_encrypt(*_arg0); end
|
|
153
|
+
def crypto_aead_chacha20poly1305_ietf_keybytes(*_arg0); end
|
|
154
|
+
def crypto_aead_chacha20poly1305_ietf_npubbytes(*_arg0); end
|
|
155
|
+
|
|
156
|
+
private
|
|
157
|
+
|
|
158
|
+
# source://rbnacl//lib/rbnacl/aead/chacha20poly1305_ietf.rb#35
|
|
159
|
+
def do_decrypt(message, message_len, nonce, ciphertext, additional_data); end
|
|
160
|
+
|
|
161
|
+
# source://rbnacl//lib/rbnacl/aead/chacha20poly1305_ietf.rb#28
|
|
162
|
+
def do_encrypt(ciphertext, ciphertext_len, nonce, message, additional_data); end
|
|
163
|
+
|
|
164
|
+
class << self
|
|
165
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
166
|
+
def aead_chacha20poly1305_ietf_decrypt(*args); end
|
|
167
|
+
|
|
168
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
169
|
+
def aead_chacha20poly1305_ietf_encrypt(*args); end
|
|
170
|
+
|
|
171
|
+
def crypto_aead_chacha20poly1305_ietf_abytes(*_arg0); end
|
|
172
|
+
def crypto_aead_chacha20poly1305_ietf_decrypt(*_arg0); end
|
|
173
|
+
def crypto_aead_chacha20poly1305_ietf_encrypt(*_arg0); end
|
|
174
|
+
def crypto_aead_chacha20poly1305_ietf_keybytes(*_arg0); end
|
|
175
|
+
def crypto_aead_chacha20poly1305_ietf_npubbytes(*_arg0); end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
180
|
+
RbNaCl::AEAD::ChaCha20Poly1305IETF::ABYTES = T.let(T.unsafe(nil), Integer)
|
|
181
|
+
|
|
182
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
183
|
+
RbNaCl::AEAD::ChaCha20Poly1305IETF::KEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
184
|
+
|
|
185
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
186
|
+
RbNaCl::AEAD::ChaCha20Poly1305IETF::NPUBBYTES = T.let(T.unsafe(nil), Integer)
|
|
187
|
+
|
|
188
|
+
# This class contains wrappers for the original libsodium implementation of
|
|
189
|
+
# Authenticated Encryption with Additional Data using ChaCha20-Poly1305
|
|
190
|
+
#
|
|
191
|
+
# source://rbnacl//lib/rbnacl/aead/chacha20poly1305_legacy.rb#8
|
|
192
|
+
class RbNaCl::AEAD::ChaCha20Poly1305Legacy < ::RbNaCl::AEAD::Base
|
|
193
|
+
extend ::RbNaCl::Sodium
|
|
194
|
+
extend ::FFI::Library
|
|
195
|
+
|
|
196
|
+
def crypto_aead_chacha20poly1305_abytes(*_arg0); end
|
|
197
|
+
def crypto_aead_chacha20poly1305_decrypt(*_arg0); end
|
|
198
|
+
def crypto_aead_chacha20poly1305_encrypt(*_arg0); end
|
|
199
|
+
def crypto_aead_chacha20poly1305_keybytes(*_arg0); end
|
|
200
|
+
def crypto_aead_chacha20poly1305_npubbytes(*_arg0); end
|
|
201
|
+
|
|
202
|
+
private
|
|
203
|
+
|
|
204
|
+
# source://rbnacl//lib/rbnacl/aead/chacha20poly1305_legacy.rb#34
|
|
205
|
+
def do_decrypt(message, message_len, nonce, ciphertext, additional_data); end
|
|
206
|
+
|
|
207
|
+
# source://rbnacl//lib/rbnacl/aead/chacha20poly1305_legacy.rb#27
|
|
208
|
+
def do_encrypt(ciphertext, ciphertext_len, nonce, message, additional_data); end
|
|
209
|
+
|
|
210
|
+
class << self
|
|
211
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
212
|
+
def aead_chacha20poly1305_decrypt(*args); end
|
|
213
|
+
|
|
214
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
215
|
+
def aead_chacha20poly1305_encrypt(*args); end
|
|
216
|
+
|
|
217
|
+
def crypto_aead_chacha20poly1305_abytes(*_arg0); end
|
|
218
|
+
def crypto_aead_chacha20poly1305_decrypt(*_arg0); end
|
|
219
|
+
def crypto_aead_chacha20poly1305_encrypt(*_arg0); end
|
|
220
|
+
def crypto_aead_chacha20poly1305_keybytes(*_arg0); end
|
|
221
|
+
def crypto_aead_chacha20poly1305_npubbytes(*_arg0); end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
226
|
+
RbNaCl::AEAD::ChaCha20Poly1305Legacy::ABYTES = T.let(T.unsafe(nil), Integer)
|
|
227
|
+
|
|
228
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
229
|
+
RbNaCl::AEAD::ChaCha20Poly1305Legacy::KEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
230
|
+
|
|
231
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
232
|
+
RbNaCl::AEAD::ChaCha20Poly1305Legacy::NPUBBYTES = T.let(T.unsafe(nil), Integer)
|
|
233
|
+
|
|
234
|
+
# This class contains wrappers for the IETF implementation of
|
|
235
|
+
# Authenticated Encryption with Additional Data using ChaCha20-Poly1305
|
|
236
|
+
#
|
|
237
|
+
# source://rbnacl//lib/rbnacl/aead/xchacha20poly1305_ietf.rb#8
|
|
238
|
+
class RbNaCl::AEAD::XChaCha20Poly1305IETF < ::RbNaCl::AEAD::Base
|
|
239
|
+
extend ::RbNaCl::Sodium
|
|
240
|
+
extend ::FFI::Library
|
|
241
|
+
|
|
242
|
+
def crypto_aead_xchacha20poly1305_ietf_abytes(*_arg0); end
|
|
243
|
+
def crypto_aead_xchacha20poly1305_ietf_decrypt(*_arg0); end
|
|
244
|
+
def crypto_aead_xchacha20poly1305_ietf_encrypt(*_arg0); end
|
|
245
|
+
def crypto_aead_xchacha20poly1305_ietf_keybytes(*_arg0); end
|
|
246
|
+
def crypto_aead_xchacha20poly1305_ietf_npubbytes(*_arg0); end
|
|
247
|
+
|
|
248
|
+
private
|
|
249
|
+
|
|
250
|
+
# source://rbnacl//lib/rbnacl/aead/xchacha20poly1305_ietf.rb#35
|
|
251
|
+
def do_decrypt(message, message_len, nonce, ciphertext, additional_data); end
|
|
252
|
+
|
|
253
|
+
# source://rbnacl//lib/rbnacl/aead/xchacha20poly1305_ietf.rb#28
|
|
254
|
+
def do_encrypt(ciphertext, ciphertext_len, nonce, message, additional_data); end
|
|
255
|
+
|
|
256
|
+
class << self
|
|
257
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
258
|
+
def aead_xchacha20poly1305_ietf_decrypt(*args); end
|
|
259
|
+
|
|
260
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
261
|
+
def aead_xchacha20poly1305_ietf_encrypt(*args); end
|
|
262
|
+
|
|
263
|
+
def crypto_aead_xchacha20poly1305_ietf_abytes(*_arg0); end
|
|
264
|
+
def crypto_aead_xchacha20poly1305_ietf_decrypt(*_arg0); end
|
|
265
|
+
def crypto_aead_xchacha20poly1305_ietf_encrypt(*_arg0); end
|
|
266
|
+
def crypto_aead_xchacha20poly1305_ietf_keybytes(*_arg0); end
|
|
267
|
+
def crypto_aead_xchacha20poly1305_ietf_npubbytes(*_arg0); end
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
272
|
+
RbNaCl::AEAD::XChaCha20Poly1305IETF::ABYTES = T.let(T.unsafe(nil), Integer)
|
|
273
|
+
|
|
274
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
275
|
+
RbNaCl::AEAD::XChaCha20Poly1305IETF::KEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
276
|
+
|
|
277
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
278
|
+
RbNaCl::AEAD::XChaCha20Poly1305IETF::NPUBBYTES = T.let(T.unsafe(nil), Integer)
|
|
279
|
+
|
|
280
|
+
# Secret Key Authenticators
|
|
281
|
+
#
|
|
282
|
+
# These provide a means of verifying the integrity of a message, but only
|
|
283
|
+
# with the knowledge of a shared key. This can be a preshared key, or one
|
|
284
|
+
# that is derived through some cryptographic protocol.
|
|
285
|
+
#
|
|
286
|
+
# source://rbnacl//lib/rbnacl/auth.rb#10
|
|
287
|
+
class RbNaCl::Auth
|
|
288
|
+
# A new authenticator, ready for auth and verification
|
|
289
|
+
#
|
|
290
|
+
# @param key [#to_str] the key used for authenticators, 32 bytes.
|
|
291
|
+
# @return [Auth] a new instance of Auth
|
|
292
|
+
#
|
|
293
|
+
# source://rbnacl//lib/rbnacl/auth.rb#23
|
|
294
|
+
def initialize(key); end
|
|
295
|
+
|
|
296
|
+
# Compute authenticator for message
|
|
297
|
+
#
|
|
298
|
+
# @param message [#to_str] the message to authenticate
|
|
299
|
+
# @return [String] the authenticator as raw bytes
|
|
300
|
+
#
|
|
301
|
+
# source://rbnacl//lib/rbnacl/auth.rb#56
|
|
302
|
+
def auth(message); end
|
|
303
|
+
|
|
304
|
+
# The number of key bytes for this Auth instance
|
|
305
|
+
#
|
|
306
|
+
# @return [Integer] number of key bytes
|
|
307
|
+
#
|
|
308
|
+
# source://rbnacl//lib/rbnacl/auth.rb#95
|
|
309
|
+
def key_bytes; end
|
|
310
|
+
|
|
311
|
+
# The crypto primitive for this authenticator instance
|
|
312
|
+
#
|
|
313
|
+
# @return [Symbol] The primitive used
|
|
314
|
+
#
|
|
315
|
+
# source://rbnacl//lib/rbnacl/auth.rb#81
|
|
316
|
+
def primitive; end
|
|
317
|
+
|
|
318
|
+
# The number of bytes in the tag or authenticator for this Auth instance
|
|
319
|
+
#
|
|
320
|
+
# @return [Integer] number of tag bytes
|
|
321
|
+
#
|
|
322
|
+
# source://rbnacl//lib/rbnacl/auth.rb#109
|
|
323
|
+
def tag_bytes; end
|
|
324
|
+
|
|
325
|
+
# Verifies the given authenticator with the message.
|
|
326
|
+
#
|
|
327
|
+
# @param authenticator [#to_str] to be checked
|
|
328
|
+
# @param message [#to_str] the message to be authenticated
|
|
329
|
+
# @raise [BadAuthenticatorError] if the tag isn't valid
|
|
330
|
+
# @raise [LengthError] if the tag is of the wrong length
|
|
331
|
+
# @return [Boolean] Was it valid?
|
|
332
|
+
#
|
|
333
|
+
# source://rbnacl//lib/rbnacl/auth.rb#72
|
|
334
|
+
def verify(authenticator, message); end
|
|
335
|
+
|
|
336
|
+
private
|
|
337
|
+
|
|
338
|
+
# @raise [NotImplementedError]
|
|
339
|
+
#
|
|
340
|
+
# source://rbnacl//lib/rbnacl/auth.rb#115
|
|
341
|
+
def compute_authenticator(_authenticator, _message); end
|
|
342
|
+
|
|
343
|
+
# Returns the value of attribute key.
|
|
344
|
+
#
|
|
345
|
+
# source://rbnacl//lib/rbnacl/auth.rb#17
|
|
346
|
+
def key; end
|
|
347
|
+
|
|
348
|
+
# @raise [NotImplementedError]
|
|
349
|
+
#
|
|
350
|
+
# source://rbnacl//lib/rbnacl/auth.rb#119
|
|
351
|
+
def verify_message(_authenticator, _message); end
|
|
352
|
+
|
|
353
|
+
class << self
|
|
354
|
+
# Compute authenticator for message
|
|
355
|
+
#
|
|
356
|
+
# @param key [#to_str] the key used for the authenticator
|
|
357
|
+
# @param message [#to_str] message to construct an authenticator for
|
|
358
|
+
# @return [String] The authenticator, as raw bytes
|
|
359
|
+
#
|
|
360
|
+
# source://rbnacl//lib/rbnacl/auth.rb#33
|
|
361
|
+
def auth(key, message); end
|
|
362
|
+
|
|
363
|
+
# The number of key bytes for this Auth class
|
|
364
|
+
#
|
|
365
|
+
# @return [Integer] number of key bytes
|
|
366
|
+
#
|
|
367
|
+
# source://rbnacl//lib/rbnacl/auth.rb#88
|
|
368
|
+
def key_bytes; end
|
|
369
|
+
|
|
370
|
+
# The number bytes in the tag or authenticator from this Auth class
|
|
371
|
+
#
|
|
372
|
+
# @return [Integer] number of tag bytes
|
|
373
|
+
#
|
|
374
|
+
# source://rbnacl//lib/rbnacl/auth.rb#102
|
|
375
|
+
def tag_bytes; end
|
|
376
|
+
|
|
377
|
+
# Verifies the given authenticator with the message.
|
|
378
|
+
#
|
|
379
|
+
# @param key [#to_str] the key used for the authenticator
|
|
380
|
+
# @param authenticator [#to_str] to be checked
|
|
381
|
+
# @param message [#to_str] the message to be authenticated
|
|
382
|
+
# @raise [BadAuthenticatorError] if the tag isn't valid
|
|
383
|
+
# @raise [LengthError] if the tag is of the wrong length
|
|
384
|
+
# @return [Boolean] Was it valid?
|
|
385
|
+
#
|
|
386
|
+
# source://rbnacl//lib/rbnacl/auth.rb#47
|
|
387
|
+
def verify(key, authenticator, message); end
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
# Number of bytes in a valid authenticator
|
|
392
|
+
#
|
|
393
|
+
# source://rbnacl//lib/rbnacl/auth.rb#15
|
|
394
|
+
RbNaCl::Auth::BYTES = T.let(T.unsafe(nil), Integer)
|
|
395
|
+
|
|
396
|
+
# Number of bytes in a valid key
|
|
397
|
+
#
|
|
398
|
+
# source://rbnacl//lib/rbnacl/auth.rb#12
|
|
399
|
+
RbNaCl::Auth::KEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
400
|
+
|
|
401
|
+
# The authenticator was forged or otherwise corrupt
|
|
402
|
+
#
|
|
403
|
+
# source://rbnacl//lib/rbnacl.rb#48
|
|
404
|
+
class RbNaCl::BadAuthenticatorError < ::RbNaCl::CryptoError; end
|
|
405
|
+
|
|
406
|
+
# The signature was forged or otherwise corrupt
|
|
407
|
+
#
|
|
408
|
+
# source://rbnacl//lib/rbnacl.rb#45
|
|
409
|
+
class RbNaCl::BadSignatureError < ::RbNaCl::CryptoError; end
|
|
410
|
+
|
|
411
|
+
# Bind aliases used by the public API
|
|
412
|
+
#
|
|
413
|
+
# source://rbnacl//lib/rbnacl.rb#96
|
|
414
|
+
RbNaCl::Box = RbNaCl::Boxes::Curve25519XSalsa20Poly1305
|
|
415
|
+
|
|
416
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb#5
|
|
417
|
+
module RbNaCl::Boxes; end
|
|
418
|
+
|
|
419
|
+
# The Box class boxes and unboxes messages between a pair of keys
|
|
420
|
+
#
|
|
421
|
+
# This class uses the given public and secret keys to derive a shared key,
|
|
422
|
+
# which is used with the nonce given to encrypt the given messages and
|
|
423
|
+
# decrypt the given ciphertexts. The same shared key will generated from
|
|
424
|
+
# both pairing of keys, so given two keypairs belonging to alice (pkalice,
|
|
425
|
+
# skalice) and bob(pkbob, skbob), the key derived from (pkalice, skbob) with
|
|
426
|
+
# equal that from (pkbob, skalice). This is how the system works:
|
|
427
|
+
#
|
|
428
|
+
# It is VITALLY important that the nonce is a nonce, i.e. it is a number used
|
|
429
|
+
# only once for any given pair of keys. If you fail to do this, you
|
|
430
|
+
# compromise the privacy of the the messages encrypted. Also, bear in mind
|
|
431
|
+
# the property mentioned just above. Give your nonces a different prefix, or
|
|
432
|
+
# have one side use an odd counter and one an even counter. Just make sure
|
|
433
|
+
# they are different.
|
|
434
|
+
#
|
|
435
|
+
# The ciphertexts generated by this class include a 16-byte authenticator which
|
|
436
|
+
# is checked as part of the decryption. An invalid authenticator will cause
|
|
437
|
+
# the unbox function to raise. The authenticator is not a signature. Once
|
|
438
|
+
# you've looked in the box, you've demonstrated the ability to create
|
|
439
|
+
# arbitrary valid messages, so messages you send are repudiable. For
|
|
440
|
+
# non-repudiable messages, sign them before or after encryption.
|
|
441
|
+
#
|
|
442
|
+
# @example
|
|
443
|
+
# # On bob's system
|
|
444
|
+
# bobkey = RbNaCl::PrivateKey.generate
|
|
445
|
+
# #=> #<RbNaCl::PrivateKey ...>
|
|
446
|
+
#
|
|
447
|
+
# # send bobkey.public_key to alice
|
|
448
|
+
# # receive alice's public key, alicepk
|
|
449
|
+
# # NB: This is actually the hard part of the system. How to do it securely
|
|
450
|
+
# # is left as an exercise to for the reader.
|
|
451
|
+
# alice_pubkey = "..."
|
|
452
|
+
#
|
|
453
|
+
# # make a box
|
|
454
|
+
# alicebob_box = RbNaCl::Box.new(alice_pubkey, bobkey)
|
|
455
|
+
# #=> #<RbNaCl::Box ...>
|
|
456
|
+
#
|
|
457
|
+
# # encrypt a message to alice
|
|
458
|
+
# cipher_text = alicebob_box.box("A bad example of a nonce", "Hello, Alice!")
|
|
459
|
+
# #=> "..." # a string of bytes, 29 bytes long
|
|
460
|
+
#
|
|
461
|
+
# # send ["A bad example of a nonce", cipher_text] to alice
|
|
462
|
+
# # note that nonces don't have to be secret
|
|
463
|
+
# # receive [nonce, cipher_text_to_bob] from alice
|
|
464
|
+
#
|
|
465
|
+
# # decrypt the reply
|
|
466
|
+
# # Alice has been a little more sensible than bob, and has a random nonce
|
|
467
|
+
# # that is too fiddly to type here. But there are other choices than just
|
|
468
|
+
# # random
|
|
469
|
+
# plain_text = alicebob_box.open(nonce, cipher_text_to_bob)
|
|
470
|
+
# #=> "Hey there, Bob!"
|
|
471
|
+
#
|
|
472
|
+
# # we have a new message!
|
|
473
|
+
# # But Eve has tampered with this message, by flipping some bytes around!
|
|
474
|
+
# # [nonce2, cipher_text_to_bob_honest_love_eve]
|
|
475
|
+
# alicebob_box.open(nonce2, cipher_text_to_bob_honest_love_eve)
|
|
476
|
+
#
|
|
477
|
+
# # BOOM!
|
|
478
|
+
# # Bob gets a RbNaCl::CryptoError to deal with!
|
|
479
|
+
#
|
|
480
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb#66
|
|
481
|
+
class RbNaCl::Boxes::Curve25519XSalsa20Poly1305
|
|
482
|
+
extend ::RbNaCl::Sodium
|
|
483
|
+
extend ::FFI::Library
|
|
484
|
+
|
|
485
|
+
# Create a new Box
|
|
486
|
+
#
|
|
487
|
+
# Sets up the Box for deriving the shared key and encrypting and
|
|
488
|
+
# decrypting messages.
|
|
489
|
+
#
|
|
490
|
+
# @param public_key [String, RbNaCl::PublicKey] The public key to encrypt to
|
|
491
|
+
# @param private_key [String, RbNaCl::PrivateKey] The private key to encrypt with
|
|
492
|
+
# @raise [RbNaCl::LengthError] on invalid keys
|
|
493
|
+
# @return [RbNaCl::Box] The new Box, ready to use
|
|
494
|
+
#
|
|
495
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb#101
|
|
496
|
+
def initialize(public_key, private_key); end
|
|
497
|
+
|
|
498
|
+
# Encrypts a message
|
|
499
|
+
#
|
|
500
|
+
# Encrypts the message with the given nonce to the keypair set up when
|
|
501
|
+
# initializing the class. Make sure the nonce is unique for any given
|
|
502
|
+
# keypair, or you might as well just send plain text.
|
|
503
|
+
#
|
|
504
|
+
# This function takes care of the padding required by the NaCL C API.
|
|
505
|
+
#
|
|
506
|
+
# @param nonce [String] A 24-byte string containing the nonce.
|
|
507
|
+
# @param message [String] The message to be encrypted.
|
|
508
|
+
# @raise [RbNaCl::LengthError] If the nonce is not valid
|
|
509
|
+
# @return [String] The ciphertext without the nonce prepended (BINARY encoded)
|
|
510
|
+
#
|
|
511
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb#121
|
|
512
|
+
def box(nonce, message); end
|
|
513
|
+
|
|
514
|
+
def crypto_box_curve25519xsalsa20poly1305_afternm(*_arg0); end
|
|
515
|
+
def crypto_box_curve25519xsalsa20poly1305_beforenm(*_arg0); end
|
|
516
|
+
def crypto_box_curve25519xsalsa20poly1305_beforenmbytes(*_arg0); end
|
|
517
|
+
def crypto_box_curve25519xsalsa20poly1305_boxzerobytes(*_arg0); end
|
|
518
|
+
def crypto_box_curve25519xsalsa20poly1305_noncebytes(*_arg0); end
|
|
519
|
+
def crypto_box_curve25519xsalsa20poly1305_open_afternm(*_arg0); end
|
|
520
|
+
def crypto_box_curve25519xsalsa20poly1305_publickeybytes(*_arg0); end
|
|
521
|
+
def crypto_box_curve25519xsalsa20poly1305_secretkeybytes(*_arg0); end
|
|
522
|
+
def crypto_box_curve25519xsalsa20poly1305_zerobytes(*_arg0); end
|
|
523
|
+
|
|
524
|
+
# Decrypts a ciphertext
|
|
525
|
+
#
|
|
526
|
+
# Decrypts the ciphertext with the given nonce using the keypair setup when
|
|
527
|
+
# initializing the class.
|
|
528
|
+
#
|
|
529
|
+
# This function takes care of the padding required by the NaCL C API.
|
|
530
|
+
#
|
|
531
|
+
# @param nonce [String] A 24-byte string containing the nonce.
|
|
532
|
+
# @param ciphertext [String] The message to be decrypted.
|
|
533
|
+
# @raise [RbNaCl::LengthError] If the nonce is not valid
|
|
534
|
+
# @raise [RbNaCl::CryptoError] If the ciphertext cannot be authenticated.
|
|
535
|
+
# @return [String] The decrypted message (BINARY encoded)
|
|
536
|
+
#
|
|
537
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb#147
|
|
538
|
+
def decrypt(nonce, ciphertext); end
|
|
539
|
+
|
|
540
|
+
# Encrypts a message
|
|
541
|
+
#
|
|
542
|
+
# Encrypts the message with the given nonce to the keypair set up when
|
|
543
|
+
# initializing the class. Make sure the nonce is unique for any given
|
|
544
|
+
# keypair, or you might as well just send plain text.
|
|
545
|
+
#
|
|
546
|
+
# This function takes care of the padding required by the NaCL C API.
|
|
547
|
+
#
|
|
548
|
+
# @param nonce [String] A 24-byte string containing the nonce.
|
|
549
|
+
# @param message [String] The message to be encrypted.
|
|
550
|
+
# @raise [RbNaCl::LengthError] If the nonce is not valid
|
|
551
|
+
# @return [String] The ciphertext without the nonce prepended (BINARY encoded)
|
|
552
|
+
#
|
|
553
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb#121
|
|
554
|
+
def encrypt(nonce, message); end
|
|
555
|
+
|
|
556
|
+
# The nonce bytes for the box instance
|
|
557
|
+
#
|
|
558
|
+
# @return [Integer] The number of bytes in a valid nonce
|
|
559
|
+
#
|
|
560
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb#176
|
|
561
|
+
def nonce_bytes; end
|
|
562
|
+
|
|
563
|
+
# Decrypts a ciphertext
|
|
564
|
+
#
|
|
565
|
+
# Decrypts the ciphertext with the given nonce using the keypair setup when
|
|
566
|
+
# initializing the class.
|
|
567
|
+
#
|
|
568
|
+
# This function takes care of the padding required by the NaCL C API.
|
|
569
|
+
#
|
|
570
|
+
# @param nonce [String] A 24-byte string containing the nonce.
|
|
571
|
+
# @param ciphertext [String] The message to be decrypted.
|
|
572
|
+
# @raise [RbNaCl::LengthError] If the nonce is not valid
|
|
573
|
+
# @raise [RbNaCl::CryptoError] If the ciphertext cannot be authenticated.
|
|
574
|
+
# @return [String] The decrypted message (BINARY encoded)
|
|
575
|
+
#
|
|
576
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb#147
|
|
577
|
+
def open(nonce, ciphertext); end
|
|
578
|
+
|
|
579
|
+
# The crypto primitive for the box class
|
|
580
|
+
#
|
|
581
|
+
# @return [Symbol] The primitive used
|
|
582
|
+
#
|
|
583
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb#162
|
|
584
|
+
def primitive; end
|
|
585
|
+
|
|
586
|
+
private
|
|
587
|
+
|
|
588
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb#182
|
|
589
|
+
def beforenm; end
|
|
590
|
+
|
|
591
|
+
class << self
|
|
592
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
593
|
+
def box_curve25519xsalsa20poly1305_afternm(*args); end
|
|
594
|
+
|
|
595
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
596
|
+
def box_curve25519xsalsa20poly1305_beforenm(*args); end
|
|
597
|
+
|
|
598
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
599
|
+
def box_curve25519xsalsa20poly1305_open_afternm(*args); end
|
|
600
|
+
|
|
601
|
+
def crypto_box_curve25519xsalsa20poly1305_afternm(*_arg0); end
|
|
602
|
+
def crypto_box_curve25519xsalsa20poly1305_beforenm(*_arg0); end
|
|
603
|
+
def crypto_box_curve25519xsalsa20poly1305_beforenmbytes(*_arg0); end
|
|
604
|
+
def crypto_box_curve25519xsalsa20poly1305_boxzerobytes(*_arg0); end
|
|
605
|
+
def crypto_box_curve25519xsalsa20poly1305_noncebytes(*_arg0); end
|
|
606
|
+
def crypto_box_curve25519xsalsa20poly1305_open_afternm(*_arg0); end
|
|
607
|
+
def crypto_box_curve25519xsalsa20poly1305_publickeybytes(*_arg0); end
|
|
608
|
+
def crypto_box_curve25519xsalsa20poly1305_secretkeybytes(*_arg0); end
|
|
609
|
+
def crypto_box_curve25519xsalsa20poly1305_zerobytes(*_arg0); end
|
|
610
|
+
|
|
611
|
+
# The nonce bytes for the box class
|
|
612
|
+
#
|
|
613
|
+
# @return [Integer] The number of bytes in a valid nonce
|
|
614
|
+
#
|
|
615
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305.rb#169
|
|
616
|
+
def nonce_bytes; end
|
|
617
|
+
end
|
|
618
|
+
end
|
|
619
|
+
|
|
620
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
621
|
+
RbNaCl::Boxes::Curve25519XSalsa20Poly1305::BEFORENMBYTES = T.let(T.unsafe(nil), Integer)
|
|
622
|
+
|
|
623
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
624
|
+
RbNaCl::Boxes::Curve25519XSalsa20Poly1305::BOXZEROBYTES = T.let(T.unsafe(nil), Integer)
|
|
625
|
+
|
|
626
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
627
|
+
RbNaCl::Boxes::Curve25519XSalsa20Poly1305::NONCEBYTES = T.let(T.unsafe(nil), Integer)
|
|
628
|
+
|
|
629
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
630
|
+
RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PRIVATEKEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
631
|
+
|
|
632
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
633
|
+
RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PUBLICKEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
634
|
+
|
|
635
|
+
# RbNaCl::Box private key. Keep it safe
|
|
636
|
+
#
|
|
637
|
+
# This class generates and stores NaCL private keys, as well as providing a
|
|
638
|
+
# reference to the public key associated with this private key, if that's
|
|
639
|
+
# provided.
|
|
640
|
+
#
|
|
641
|
+
# Note that the documentation for NaCl refers to this as a secret key, but in
|
|
642
|
+
# this library its a private key, to avoid confusing the issue with the
|
|
643
|
+
# SecretBox, which does symmetric encryption.
|
|
644
|
+
#
|
|
645
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/private_key.rb#16
|
|
646
|
+
class RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PrivateKey
|
|
647
|
+
include ::Comparable
|
|
648
|
+
include ::RbNaCl::KeyComparator
|
|
649
|
+
include ::RbNaCl::Serializable
|
|
650
|
+
extend ::RbNaCl::Sodium
|
|
651
|
+
extend ::FFI::Library
|
|
652
|
+
|
|
653
|
+
# Initializes a new PrivateKey for key operations.
|
|
654
|
+
#
|
|
655
|
+
# Takes the (optionally encoded) private key bytes. This class can then be
|
|
656
|
+
# used for various key operations, including deriving the corresponding
|
|
657
|
+
# PublicKey
|
|
658
|
+
#
|
|
659
|
+
# @param private_key [String] The private key
|
|
660
|
+
# @raise [TypeError] If the key is nil
|
|
661
|
+
# @raise [RbNaCl::LengthError] If the key is not valid after decoding.
|
|
662
|
+
# @return A new PrivateKey
|
|
663
|
+
#
|
|
664
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/private_key.rb#44
|
|
665
|
+
def initialize(private_key); end
|
|
666
|
+
|
|
667
|
+
def crypto_box_curve25519xsalsa20poly1305_keypair(*_arg0); end
|
|
668
|
+
|
|
669
|
+
# The crypto primitive this PrivateKey is to be used for.
|
|
670
|
+
#
|
|
671
|
+
# @return [Symbol] The primitive
|
|
672
|
+
#
|
|
673
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/private_key.rb#77
|
|
674
|
+
def primitive; end
|
|
675
|
+
|
|
676
|
+
# the public key associated with this private key
|
|
677
|
+
#
|
|
678
|
+
# @return [PublicKey] the key
|
|
679
|
+
#
|
|
680
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/private_key.rb#70
|
|
681
|
+
def public_key; end
|
|
682
|
+
|
|
683
|
+
# The raw bytes of the key
|
|
684
|
+
#
|
|
685
|
+
# @return [String] the raw bytes.
|
|
686
|
+
#
|
|
687
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/private_key.rb#63
|
|
688
|
+
def to_bytes; end
|
|
689
|
+
|
|
690
|
+
class << self
|
|
691
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
692
|
+
def box_curve25519xsalsa20poly1305_keypair(*args); end
|
|
693
|
+
|
|
694
|
+
def crypto_box_curve25519xsalsa20poly1305_keypair(*_arg0); end
|
|
695
|
+
|
|
696
|
+
# Generates a new keypair
|
|
697
|
+
#
|
|
698
|
+
# @raise [RbNaCl::CryptoError] if key generation fails, due to insufficient randomness.
|
|
699
|
+
# @return [RbNaCl::PrivateKey] A new private key, with the associated public key also set.
|
|
700
|
+
#
|
|
701
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/private_key.rb#53
|
|
702
|
+
def generate; end
|
|
703
|
+
end
|
|
704
|
+
end
|
|
705
|
+
|
|
706
|
+
# The size of the key, in bytes
|
|
707
|
+
#
|
|
708
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/private_key.rb#30
|
|
709
|
+
RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PrivateKey::BYTES = T.let(T.unsafe(nil), Integer)
|
|
710
|
+
|
|
711
|
+
# RbNaCl::Box public key. Send it (securely!) to your friends.
|
|
712
|
+
#
|
|
713
|
+
# This class stores the NaCL public key, and provides some convenience
|
|
714
|
+
# functions for working with it.
|
|
715
|
+
#
|
|
716
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb#11
|
|
717
|
+
class RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey
|
|
718
|
+
include ::Comparable
|
|
719
|
+
include ::RbNaCl::KeyComparator
|
|
720
|
+
include ::RbNaCl::Serializable
|
|
721
|
+
|
|
722
|
+
# Initializes a new PublicKey for key operations.
|
|
723
|
+
#
|
|
724
|
+
# Takes the (optionally encoded) public key bytes. This can be shared with
|
|
725
|
+
# many people and used to establish key pairs with their private key, for
|
|
726
|
+
# the exchanging of messages using a RbNaCl::Box
|
|
727
|
+
#
|
|
728
|
+
# @param public_key [String] The public key
|
|
729
|
+
# @raise [RbNaCl::LengthError] If the key is not valid after decoding.
|
|
730
|
+
# @return A new PublicKey
|
|
731
|
+
#
|
|
732
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb#29
|
|
733
|
+
def initialize(public_key); end
|
|
734
|
+
|
|
735
|
+
# The crypto primitive this PublicKey is to be used for.
|
|
736
|
+
#
|
|
737
|
+
# @return [Symbol] The primitive
|
|
738
|
+
#
|
|
739
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb#50
|
|
740
|
+
def primitive; end
|
|
741
|
+
|
|
742
|
+
# The raw bytes of the key
|
|
743
|
+
#
|
|
744
|
+
# @return [String] the raw bytes.
|
|
745
|
+
#
|
|
746
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb#36
|
|
747
|
+
def to_bytes; end
|
|
748
|
+
|
|
749
|
+
class << self
|
|
750
|
+
# The crypto primitive the PublicKey class is to be used for
|
|
751
|
+
#
|
|
752
|
+
# @return [Symbol] The primitive
|
|
753
|
+
#
|
|
754
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb#43
|
|
755
|
+
def primitive; end
|
|
756
|
+
end
|
|
757
|
+
end
|
|
758
|
+
|
|
759
|
+
# The size of the key, in bytes
|
|
760
|
+
#
|
|
761
|
+
# source://rbnacl//lib/rbnacl/boxes/curve25519xsalsa20poly1305/public_key.rb#16
|
|
762
|
+
RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey::BYTES = T.let(T.unsafe(nil), Integer)
|
|
763
|
+
|
|
764
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
765
|
+
RbNaCl::Boxes::Curve25519XSalsa20Poly1305::ZEROBYTES = T.let(T.unsafe(nil), Integer)
|
|
766
|
+
|
|
767
|
+
# Sealed boxes are designed to anonymously send messages to a recipient
|
|
768
|
+
# given its public key.
|
|
769
|
+
#
|
|
770
|
+
# Only the recipient can decrypt these messages, using its private key.
|
|
771
|
+
# While the recipient can verify the integrity of the message, it cannot
|
|
772
|
+
# verify the identity of the sender.
|
|
773
|
+
#
|
|
774
|
+
# A message is encrypted using an ephemeral key pair, whose secret part
|
|
775
|
+
# is destroyed right after the encryption process.
|
|
776
|
+
#
|
|
777
|
+
# Without knowing the secret key used for a given message, the sender
|
|
778
|
+
# cannot decrypt its own message later. And without additional data,
|
|
779
|
+
# a message cannot be correlated with the identity of its sender.
|
|
780
|
+
#
|
|
781
|
+
# source://rbnacl//lib/rbnacl/boxes/sealed.rb#19
|
|
782
|
+
class RbNaCl::Boxes::Sealed
|
|
783
|
+
extend ::RbNaCl::Sodium
|
|
784
|
+
extend ::FFI::Library
|
|
785
|
+
|
|
786
|
+
# WARNING: you should strongly prefer the from_private_key/from_public_key class methods.
|
|
787
|
+
#
|
|
788
|
+
# Create a new Sealed Box
|
|
789
|
+
#
|
|
790
|
+
# Sets up the Box for deriving the shared key and encrypting and
|
|
791
|
+
# decrypting messages.
|
|
792
|
+
#
|
|
793
|
+
# @param public_key [String, RbNaCl::PublicKey] The public key to encrypt to
|
|
794
|
+
# @param private_key [String, RbNaCl::PrivateKey] The private key to decrypt with
|
|
795
|
+
# @raise [RbNaCl::LengthError] on invalid keys
|
|
796
|
+
# @return [RbNaCl::SealedBox] The new Box, ready to use
|
|
797
|
+
#
|
|
798
|
+
# source://rbnacl//lib/rbnacl/boxes/sealed.rb#47
|
|
799
|
+
def initialize(public_key, private_key = T.unsafe(nil)); end
|
|
800
|
+
|
|
801
|
+
# Encrypts a message
|
|
802
|
+
#
|
|
803
|
+
# @param message [String] The message to be encrypted.
|
|
804
|
+
# @raise [RbNaCl::CryptoError] If the encrytion fails.
|
|
805
|
+
# @return [String] The ciphertext (BINARY encoded)
|
|
806
|
+
#
|
|
807
|
+
# source://rbnacl//lib/rbnacl/boxes/sealed.rb#92
|
|
808
|
+
def box(message); end
|
|
809
|
+
|
|
810
|
+
def crypto_box_seal(*_arg0); end
|
|
811
|
+
def crypto_box_seal_open(*_arg0); end
|
|
812
|
+
def crypto_box_sealbytes(*_arg0); end
|
|
813
|
+
|
|
814
|
+
# Decrypts a ciphertext
|
|
815
|
+
#
|
|
816
|
+
# @param ciphertext [String] The message to be decrypted.
|
|
817
|
+
# @raise [RbNaCl::CryptoError] If no private key is available.
|
|
818
|
+
# @raise [RbNaCl::CryptoError] If the ciphertext cannot be authenticated.
|
|
819
|
+
# @return [String] The decrypted message (BINARY encoded)
|
|
820
|
+
#
|
|
821
|
+
# source://rbnacl//lib/rbnacl/boxes/sealed.rb#113
|
|
822
|
+
def decrypt(ciphertext); end
|
|
823
|
+
|
|
824
|
+
# Encrypts a message
|
|
825
|
+
#
|
|
826
|
+
# @param message [String] The message to be encrypted.
|
|
827
|
+
# @raise [RbNaCl::CryptoError] If the encrytion fails.
|
|
828
|
+
# @return [String] The ciphertext (BINARY encoded)
|
|
829
|
+
#
|
|
830
|
+
# source://rbnacl//lib/rbnacl/boxes/sealed.rb#92
|
|
831
|
+
def encrypt(message); end
|
|
832
|
+
|
|
833
|
+
# Decrypts a ciphertext
|
|
834
|
+
#
|
|
835
|
+
# @param ciphertext [String] The message to be decrypted.
|
|
836
|
+
# @raise [RbNaCl::CryptoError] If no private key is available.
|
|
837
|
+
# @raise [RbNaCl::CryptoError] If the ciphertext cannot be authenticated.
|
|
838
|
+
# @return [String] The decrypted message (BINARY encoded)
|
|
839
|
+
#
|
|
840
|
+
# source://rbnacl//lib/rbnacl/boxes/sealed.rb#113
|
|
841
|
+
def open(ciphertext); end
|
|
842
|
+
|
|
843
|
+
# The crypto primitive for the box class
|
|
844
|
+
#
|
|
845
|
+
# @return [Symbol] The primitive used
|
|
846
|
+
#
|
|
847
|
+
# source://rbnacl//lib/rbnacl/boxes/sealed.rb#131
|
|
848
|
+
def primitive; end
|
|
849
|
+
|
|
850
|
+
class << self
|
|
851
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
852
|
+
def box_seal(*args); end
|
|
853
|
+
|
|
854
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
855
|
+
def box_seal_open(*args); end
|
|
856
|
+
|
|
857
|
+
def crypto_box_seal(*_arg0); end
|
|
858
|
+
def crypto_box_seal_open(*_arg0); end
|
|
859
|
+
def crypto_box_sealbytes(*_arg0); end
|
|
860
|
+
|
|
861
|
+
# Create a new Sealed Box for encrypting
|
|
862
|
+
#
|
|
863
|
+
# Sets up the Box for encryoption of new messages.
|
|
864
|
+
#
|
|
865
|
+
# @param private_key [String, RbNaCl::PrivateKey] The private key to decrypt with
|
|
866
|
+
# @raise [RbNaCl::LengthError] on invalid keys
|
|
867
|
+
# @return [RbNaCl::SealedBox] The new Box, ready to use
|
|
868
|
+
#
|
|
869
|
+
# source://rbnacl//lib/rbnacl/boxes/sealed.rb#68
|
|
870
|
+
def from_private_key(private_key); end
|
|
871
|
+
|
|
872
|
+
# Create a new Sealed Box for decrypting
|
|
873
|
+
#
|
|
874
|
+
# Sets up the Box for decrytoption of new messages.
|
|
875
|
+
#
|
|
876
|
+
# @param public_key [String, RbNaCl::PublicKey] The public key to encrypt to
|
|
877
|
+
# @raise [RbNaCl::LengthError] on invalid keys
|
|
878
|
+
# @return [RbNaCl::SealedBox] The new Box, ready to use
|
|
879
|
+
#
|
|
880
|
+
# source://rbnacl//lib/rbnacl/boxes/sealed.rb#81
|
|
881
|
+
def from_public_key(public_key); end
|
|
882
|
+
end
|
|
883
|
+
end
|
|
884
|
+
|
|
885
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
886
|
+
RbNaCl::Boxes::Sealed::SEALBYTES = T.let(T.unsafe(nil), Integer)
|
|
887
|
+
|
|
888
|
+
# Oh no, something went wrong!
|
|
889
|
+
#
|
|
890
|
+
# This indicates a failure in the operation of a cryptographic primitive such
|
|
891
|
+
# as authentication failing on an attempt to decrypt a ciphertext. Classes
|
|
892
|
+
# in the library may define more specific subclasses.
|
|
893
|
+
#
|
|
894
|
+
# source://rbnacl//lib/rbnacl.rb#30
|
|
895
|
+
class RbNaCl::CryptoError < ::StandardError; end
|
|
896
|
+
|
|
897
|
+
# source://rbnacl//lib/rbnacl.rb#103
|
|
898
|
+
RbNaCl::GroupElement = RbNaCl::GroupElements::Curve25519
|
|
899
|
+
|
|
900
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#5
|
|
901
|
+
module RbNaCl::GroupElements; end
|
|
902
|
+
|
|
903
|
+
# Points provide the interface to NaCl's Curve25519 high-speed elliptic
|
|
904
|
+
# curve cryptography, which can be used for implementing Diffie-Hellman
|
|
905
|
+
# and other forms of public key cryptography (e.g. RbNaCl::Box)
|
|
906
|
+
#
|
|
907
|
+
# Objects of the Point class represent points on Edwards curves. NaCl
|
|
908
|
+
# defines a base point (the "standard group element") which we can
|
|
909
|
+
# multiply by an arbitrary integer. This is how NaCl computes public
|
|
910
|
+
# keys from private keys.
|
|
911
|
+
#
|
|
912
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#14
|
|
913
|
+
class RbNaCl::GroupElements::Curve25519
|
|
914
|
+
include ::Comparable
|
|
915
|
+
include ::RbNaCl::KeyComparator
|
|
916
|
+
include ::RbNaCl::Serializable
|
|
917
|
+
extend ::RbNaCl::Sodium
|
|
918
|
+
extend ::FFI::Library
|
|
919
|
+
|
|
920
|
+
# Creates a new Point from the given serialization
|
|
921
|
+
#
|
|
922
|
+
# @param point [String] location of a group element (32-bytes)
|
|
923
|
+
# @raise [CryptoError]
|
|
924
|
+
# @return [RbNaCl::Point] the Point at this location
|
|
925
|
+
#
|
|
926
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#47
|
|
927
|
+
def initialize(point); end
|
|
928
|
+
|
|
929
|
+
def crypto_scalarmult_curve25519(*_arg0); end
|
|
930
|
+
|
|
931
|
+
# Multiply the given integer by this point
|
|
932
|
+
# This ordering is a bit confusing because traditionally the point
|
|
933
|
+
# would be the right-hand operand.
|
|
934
|
+
#
|
|
935
|
+
# @param integer [String] value to multiply with this Point (32-bytes)
|
|
936
|
+
# @raise [CryptoError]
|
|
937
|
+
# @return [RbNaCl::Point] result as a Point object
|
|
938
|
+
#
|
|
939
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#64
|
|
940
|
+
def mult(integer); end
|
|
941
|
+
|
|
942
|
+
# Return the point serialized as bytes
|
|
943
|
+
#
|
|
944
|
+
# @return [String] 32-byte string representing this point
|
|
945
|
+
#
|
|
946
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#78
|
|
947
|
+
def to_bytes; end
|
|
948
|
+
|
|
949
|
+
class << self
|
|
950
|
+
# NaCl's standard base point for all Curve25519 public keys
|
|
951
|
+
#
|
|
952
|
+
# @return [RbNaCl::Point] standard base point (a.k.a. standard group element)
|
|
953
|
+
#
|
|
954
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#87
|
|
955
|
+
def base; end
|
|
956
|
+
|
|
957
|
+
# Returns the value of attribute base_point.
|
|
958
|
+
#
|
|
959
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#92
|
|
960
|
+
def base_point; end
|
|
961
|
+
|
|
962
|
+
def crypto_scalarmult_curve25519(*_arg0); end
|
|
963
|
+
|
|
964
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
965
|
+
def scalarmult_curve25519(*args); end
|
|
966
|
+
end
|
|
967
|
+
end
|
|
968
|
+
|
|
969
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#38
|
|
970
|
+
RbNaCl::GroupElements::Curve25519::BYTES = T.let(T.unsafe(nil), Integer)
|
|
971
|
+
|
|
972
|
+
# Degenerate key (all-zeroes, results in an all-zero shared secret)
|
|
973
|
+
#
|
|
974
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#22
|
|
975
|
+
RbNaCl::GroupElements::Curve25519::DEGENERATE_KEY = T.let(T.unsafe(nil), String)
|
|
976
|
+
|
|
977
|
+
# Number of bytes in a scalar on this curve
|
|
978
|
+
#
|
|
979
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#37
|
|
980
|
+
RbNaCl::GroupElements::Curve25519::SCALARBYTES = T.let(T.unsafe(nil), Integer)
|
|
981
|
+
|
|
982
|
+
# NaCl's Curve25519 base point (a.k.a. standard group element), serialized as hex
|
|
983
|
+
#
|
|
984
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#16
|
|
985
|
+
RbNaCl::GroupElements::Curve25519::STANDARD_GROUP_ELEMENT = T.let(T.unsafe(nil), String)
|
|
986
|
+
|
|
987
|
+
# Order of the standard group
|
|
988
|
+
#
|
|
989
|
+
# source://rbnacl//lib/rbnacl/group_elements/curve25519.rb#19
|
|
990
|
+
RbNaCl::GroupElements::Curve25519::STANDARD_GROUP_ORDER = T.let(T.unsafe(nil), Integer)
|
|
991
|
+
|
|
992
|
+
# source://rbnacl//lib/rbnacl/hmac/sha256.rb#5
|
|
993
|
+
module RbNaCl::HMAC; end
|
|
994
|
+
|
|
995
|
+
# Computes an authenticator as HMAC-SHA-256
|
|
996
|
+
#
|
|
997
|
+
# The authenticator can be used at a later time to verify the provenance of
|
|
998
|
+
# the message by recomputing the HMAC over the message and then comparing it to
|
|
999
|
+
# the provided authenticator. The class provides methods for generating
|
|
1000
|
+
# signatures and also has a constant-time implementation for checking them.
|
|
1001
|
+
#
|
|
1002
|
+
# This is a secret key authenticator, i.e. anyone who can verify signatures
|
|
1003
|
+
# can also create them.
|
|
1004
|
+
#
|
|
1005
|
+
# @see http://nacl.cr.yp.to/auth.html
|
|
1006
|
+
#
|
|
1007
|
+
# source://rbnacl//lib/rbnacl/hmac/sha256.rb#17
|
|
1008
|
+
class RbNaCl::HMAC::SHA256 < ::RbNaCl::Auth
|
|
1009
|
+
extend ::RbNaCl::Sodium
|
|
1010
|
+
extend ::FFI::Library
|
|
1011
|
+
|
|
1012
|
+
# Create instance without checking key length
|
|
1013
|
+
#
|
|
1014
|
+
# RFC 2104 HMAC
|
|
1015
|
+
# The key for HMAC can be of any length.
|
|
1016
|
+
#
|
|
1017
|
+
# see https://tools.ietf.org/html/rfc2104#section-3
|
|
1018
|
+
#
|
|
1019
|
+
# @return [SHA256] a new instance of SHA256
|
|
1020
|
+
#
|
|
1021
|
+
# source://rbnacl//lib/rbnacl/hmac/sha256.rb#43
|
|
1022
|
+
def initialize(key); end
|
|
1023
|
+
|
|
1024
|
+
def crypto_auth_hmacsha256_bytes(*_arg0); end
|
|
1025
|
+
def crypto_auth_hmacsha256_final(*_arg0); end
|
|
1026
|
+
def crypto_auth_hmacsha256_init(*_arg0); end
|
|
1027
|
+
def crypto_auth_hmacsha256_keybytes(*_arg0); end
|
|
1028
|
+
def crypto_auth_hmacsha256_update(*_arg0); end
|
|
1029
|
+
|
|
1030
|
+
# Return the authenticator, as raw bytes
|
|
1031
|
+
#
|
|
1032
|
+
# @return [String] The authenticator, as raw bytes
|
|
1033
|
+
#
|
|
1034
|
+
# source://rbnacl//lib/rbnacl/hmac/sha256.rb#64
|
|
1035
|
+
def digest; end
|
|
1036
|
+
|
|
1037
|
+
# Return the authenticator, as hex string
|
|
1038
|
+
#
|
|
1039
|
+
# @return [String] The authenticator, as hex string
|
|
1040
|
+
#
|
|
1041
|
+
# source://rbnacl//lib/rbnacl/hmac/sha256.rb#71
|
|
1042
|
+
def hexdigest; end
|
|
1043
|
+
|
|
1044
|
+
# Compute authenticator for message
|
|
1045
|
+
#
|
|
1046
|
+
# source://rbnacl//lib/rbnacl/hmac/sha256.rb#54
|
|
1047
|
+
def update(message); end
|
|
1048
|
+
|
|
1049
|
+
private
|
|
1050
|
+
|
|
1051
|
+
# source://rbnacl//lib/rbnacl/hmac/sha256.rb#77
|
|
1052
|
+
def compute_authenticator(authenticator, message); end
|
|
1053
|
+
|
|
1054
|
+
# libsodium crypto_auth_hmacsha256_verify works only for 32 byte keys
|
|
1055
|
+
# ref: https://github.com/jedisct1/libsodium/blob/master/src/libsodium/crypto_auth/hmacsha256/auth_hmacsha256.c#L109
|
|
1056
|
+
#
|
|
1057
|
+
# source://rbnacl//lib/rbnacl/hmac/sha256.rb#87
|
|
1058
|
+
def verify_message(authenticator, message); end
|
|
1059
|
+
|
|
1060
|
+
class << self
|
|
1061
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1062
|
+
def auth_hmacsha256_final(*args); end
|
|
1063
|
+
|
|
1064
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1065
|
+
def auth_hmacsha256_init(*args); end
|
|
1066
|
+
|
|
1067
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1068
|
+
def auth_hmacsha256_update(*args); end
|
|
1069
|
+
|
|
1070
|
+
def crypto_auth_hmacsha256_bytes(*_arg0); end
|
|
1071
|
+
def crypto_auth_hmacsha256_final(*_arg0); end
|
|
1072
|
+
def crypto_auth_hmacsha256_init(*_arg0); end
|
|
1073
|
+
def crypto_auth_hmacsha256_keybytes(*_arg0); end
|
|
1074
|
+
def crypto_auth_hmacsha256_update(*_arg0); end
|
|
1075
|
+
end
|
|
1076
|
+
end
|
|
1077
|
+
|
|
1078
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1079
|
+
RbNaCl::HMAC::SHA256::BYTES = T.let(T.unsafe(nil), Integer)
|
|
1080
|
+
|
|
1081
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1082
|
+
RbNaCl::HMAC::SHA256::KEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
1083
|
+
|
|
1084
|
+
# The crypto_auth_hmacsha256_state struct representation
|
|
1085
|
+
# ref: jedisct1/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha256.h
|
|
1086
|
+
#
|
|
1087
|
+
# source://rbnacl//lib/rbnacl/hmac/sha256.rb#95
|
|
1088
|
+
class RbNaCl::HMAC::SHA256::SHA256State < ::FFI::Struct; end
|
|
1089
|
+
|
|
1090
|
+
# The crypto_hash_sha256_state struct representation
|
|
1091
|
+
# ref: jedisct1/libsodium/src/libsodium/include/sodium/crypto_hash_sha256.h
|
|
1092
|
+
#
|
|
1093
|
+
# source://rbnacl//lib/rbnacl/hmac/sha256.rb#103
|
|
1094
|
+
class RbNaCl::HMAC::SHA256::State < ::FFI::Struct; end
|
|
1095
|
+
|
|
1096
|
+
# Computes an authenticator as HMAC-SHA-512
|
|
1097
|
+
#
|
|
1098
|
+
# The authenticator can be used at a later time to verify the provenance of
|
|
1099
|
+
# the message by recomputing the HMAC over the message and then comparing it to
|
|
1100
|
+
# the provided authenticator. The class provides methods for generating
|
|
1101
|
+
# signatures and also has a constant-time implementation for checking them.
|
|
1102
|
+
#
|
|
1103
|
+
# This is a secret key authenticator, i.e. anyone who can verify signatures
|
|
1104
|
+
# can also create them.
|
|
1105
|
+
#
|
|
1106
|
+
# @see http://nacl.cr.yp.to/auth.html
|
|
1107
|
+
#
|
|
1108
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512.rb#17
|
|
1109
|
+
class RbNaCl::HMAC::SHA512 < ::RbNaCl::Auth
|
|
1110
|
+
extend ::RbNaCl::Sodium
|
|
1111
|
+
extend ::FFI::Library
|
|
1112
|
+
|
|
1113
|
+
# Create instance without checking key length
|
|
1114
|
+
#
|
|
1115
|
+
# RFC 2104 HMAC
|
|
1116
|
+
# The key for HMAC can be of any length.
|
|
1117
|
+
#
|
|
1118
|
+
# see https://tools.ietf.org/html/rfc2104#section-3
|
|
1119
|
+
#
|
|
1120
|
+
# @return [SHA512] a new instance of SHA512
|
|
1121
|
+
#
|
|
1122
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512.rb#43
|
|
1123
|
+
def initialize(key); end
|
|
1124
|
+
|
|
1125
|
+
def crypto_auth_hmacsha512_bytes(*_arg0); end
|
|
1126
|
+
def crypto_auth_hmacsha512_final(*_arg0); end
|
|
1127
|
+
def crypto_auth_hmacsha512_init(*_arg0); end
|
|
1128
|
+
def crypto_auth_hmacsha512_keybytes(*_arg0); end
|
|
1129
|
+
def crypto_auth_hmacsha512_update(*_arg0); end
|
|
1130
|
+
|
|
1131
|
+
# Return the authenticator, as raw bytes
|
|
1132
|
+
#
|
|
1133
|
+
# @return [String] The authenticator, as raw bytes
|
|
1134
|
+
#
|
|
1135
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512.rb#64
|
|
1136
|
+
def digest; end
|
|
1137
|
+
|
|
1138
|
+
# Return the authenticator, as hex string
|
|
1139
|
+
#
|
|
1140
|
+
# @return [String] The authenticator, as hex string
|
|
1141
|
+
#
|
|
1142
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512.rb#71
|
|
1143
|
+
def hexdigest; end
|
|
1144
|
+
|
|
1145
|
+
# Compute authenticator for message
|
|
1146
|
+
#
|
|
1147
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512.rb#54
|
|
1148
|
+
def update(message); end
|
|
1149
|
+
|
|
1150
|
+
private
|
|
1151
|
+
|
|
1152
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512.rb#77
|
|
1153
|
+
def compute_authenticator(authenticator, message); end
|
|
1154
|
+
|
|
1155
|
+
# libsodium crypto_auth_hmacsha512_verify works only for 32 byte keys
|
|
1156
|
+
# ref: https://github.com/jedisct1/libsodium/blob/master/src/libsodium/crypto_auth/hmacsha512/auth_hmacsha512.c#L109
|
|
1157
|
+
#
|
|
1158
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512.rb#87
|
|
1159
|
+
def verify_message(authenticator, message); end
|
|
1160
|
+
|
|
1161
|
+
class << self
|
|
1162
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1163
|
+
def auth_hmacsha512_final(*args); end
|
|
1164
|
+
|
|
1165
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1166
|
+
def auth_hmacsha512_init(*args); end
|
|
1167
|
+
|
|
1168
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1169
|
+
def auth_hmacsha512_update(*args); end
|
|
1170
|
+
|
|
1171
|
+
def crypto_auth_hmacsha512_bytes(*_arg0); end
|
|
1172
|
+
def crypto_auth_hmacsha512_final(*_arg0); end
|
|
1173
|
+
def crypto_auth_hmacsha512_init(*_arg0); end
|
|
1174
|
+
def crypto_auth_hmacsha512_keybytes(*_arg0); end
|
|
1175
|
+
def crypto_auth_hmacsha512_update(*_arg0); end
|
|
1176
|
+
end
|
|
1177
|
+
end
|
|
1178
|
+
|
|
1179
|
+
# Computes an authenticator as HMAC-SHA-512 truncated to 256-bits
|
|
1180
|
+
#
|
|
1181
|
+
# The authenticator can be used at a later time to verify the provenance of
|
|
1182
|
+
# the message by recomputing the HMAC over the message and then comparing it to
|
|
1183
|
+
# the provided authenticator. The class provides methods for generating
|
|
1184
|
+
# signatures and also has a constant-time implementation for checking them.
|
|
1185
|
+
#
|
|
1186
|
+
# This is a secret key authenticator, i.e. anyone who can verify signatures
|
|
1187
|
+
# can also create them.
|
|
1188
|
+
#
|
|
1189
|
+
# @see http://nacl.cr.yp.to/auth.html
|
|
1190
|
+
#
|
|
1191
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512256.rb#17
|
|
1192
|
+
class RbNaCl::HMAC::SHA512256 < ::RbNaCl::Auth
|
|
1193
|
+
extend ::RbNaCl::Sodium
|
|
1194
|
+
extend ::FFI::Library
|
|
1195
|
+
|
|
1196
|
+
# Create instance without checking key length
|
|
1197
|
+
#
|
|
1198
|
+
# RFC 2104 HMAC
|
|
1199
|
+
# The key for HMAC can be of any length.
|
|
1200
|
+
#
|
|
1201
|
+
# see https://tools.ietf.org/html/rfc2104#section-3
|
|
1202
|
+
#
|
|
1203
|
+
# @return [SHA512256] a new instance of SHA512256
|
|
1204
|
+
#
|
|
1205
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512256.rb#43
|
|
1206
|
+
def initialize(key); end
|
|
1207
|
+
|
|
1208
|
+
def crypto_auth_hmacsha512256_bytes(*_arg0); end
|
|
1209
|
+
def crypto_auth_hmacsha512256_final(*_arg0); end
|
|
1210
|
+
def crypto_auth_hmacsha512256_init(*_arg0); end
|
|
1211
|
+
def crypto_auth_hmacsha512256_keybytes(*_arg0); end
|
|
1212
|
+
def crypto_auth_hmacsha512256_update(*_arg0); end
|
|
1213
|
+
|
|
1214
|
+
# Return the authenticator, as raw bytes
|
|
1215
|
+
#
|
|
1216
|
+
# @return [String] The authenticator, as raw bytes
|
|
1217
|
+
#
|
|
1218
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512256.rb#64
|
|
1219
|
+
def digest; end
|
|
1220
|
+
|
|
1221
|
+
# Return the authenticator, as hex string
|
|
1222
|
+
#
|
|
1223
|
+
# @return [String] The authenticator, as hex string
|
|
1224
|
+
#
|
|
1225
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512256.rb#71
|
|
1226
|
+
def hexdigest; end
|
|
1227
|
+
|
|
1228
|
+
# Compute authenticator for message
|
|
1229
|
+
#
|
|
1230
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512256.rb#54
|
|
1231
|
+
def update(message); end
|
|
1232
|
+
|
|
1233
|
+
private
|
|
1234
|
+
|
|
1235
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512256.rb#77
|
|
1236
|
+
def compute_authenticator(authenticator, message); end
|
|
1237
|
+
|
|
1238
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512256.rb#85
|
|
1239
|
+
def verify_message(authenticator, message); end
|
|
1240
|
+
|
|
1241
|
+
class << self
|
|
1242
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1243
|
+
def auth_hmacsha512256_final(*args); end
|
|
1244
|
+
|
|
1245
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1246
|
+
def auth_hmacsha512256_init(*args); end
|
|
1247
|
+
|
|
1248
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1249
|
+
def auth_hmacsha512256_update(*args); end
|
|
1250
|
+
|
|
1251
|
+
def crypto_auth_hmacsha512256_bytes(*_arg0); end
|
|
1252
|
+
def crypto_auth_hmacsha512256_final(*_arg0); end
|
|
1253
|
+
def crypto_auth_hmacsha512256_init(*_arg0); end
|
|
1254
|
+
def crypto_auth_hmacsha512256_keybytes(*_arg0); end
|
|
1255
|
+
def crypto_auth_hmacsha512256_update(*_arg0); end
|
|
1256
|
+
end
|
|
1257
|
+
end
|
|
1258
|
+
|
|
1259
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1260
|
+
RbNaCl::HMAC::SHA512256::BYTES = T.let(T.unsafe(nil), Integer)
|
|
1261
|
+
|
|
1262
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1263
|
+
RbNaCl::HMAC::SHA512256::KEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
1264
|
+
|
|
1265
|
+
# The crypto_auth_hmacsha512256_state struct representation
|
|
1266
|
+
# ref: jedisct1/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512256.h
|
|
1267
|
+
#
|
|
1268
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512256.rb#93
|
|
1269
|
+
class RbNaCl::HMAC::SHA512256::SHA512256State < ::FFI::Struct; end
|
|
1270
|
+
|
|
1271
|
+
# The crypto_hash_sha512_state struct representation
|
|
1272
|
+
# ref: jedisct1/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h
|
|
1273
|
+
#
|
|
1274
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512256.rb#101
|
|
1275
|
+
class RbNaCl::HMAC::SHA512256::State < ::FFI::Struct; end
|
|
1276
|
+
|
|
1277
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1278
|
+
RbNaCl::HMAC::SHA512::BYTES = T.let(T.unsafe(nil), Integer)
|
|
1279
|
+
|
|
1280
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1281
|
+
RbNaCl::HMAC::SHA512::KEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
1282
|
+
|
|
1283
|
+
# The crypto_auth_hmacsha512_state struct representation
|
|
1284
|
+
# ref: jedisct1/libsodium/src/libsodium/include/sodium/crypto_auth_hmacsha512.h
|
|
1285
|
+
#
|
|
1286
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512.rb#95
|
|
1287
|
+
class RbNaCl::HMAC::SHA512::SHA512State < ::FFI::Struct; end
|
|
1288
|
+
|
|
1289
|
+
# The crypto_hash_sha512_state struct representation
|
|
1290
|
+
# ref: jedisct1/libsodium/src/libsodium/include/sodium/crypto_hash_sha512.h
|
|
1291
|
+
#
|
|
1292
|
+
# source://rbnacl//lib/rbnacl/hmac/sha512.rb#103
|
|
1293
|
+
class RbNaCl::HMAC::SHA512::State < ::FFI::Struct; end
|
|
1294
|
+
|
|
1295
|
+
# Cryptographic hash functions
|
|
1296
|
+
#
|
|
1297
|
+
# Cryptographic hash functions take a variable length message and compute a
|
|
1298
|
+
# fixed length string, the message digest. Even a small change in the input
|
|
1299
|
+
# data should produce a large change in the digest, and it is 'very difficult'
|
|
1300
|
+
# to create two messages with the same digest.
|
|
1301
|
+
#
|
|
1302
|
+
# A cryptographic hash can be used for checking the integrity of data, but
|
|
1303
|
+
# there is no secret involved in the hashing, so anyone can create the hash of
|
|
1304
|
+
# a given message.
|
|
1305
|
+
#
|
|
1306
|
+
# RbNaCl provides the SHA-256,SHA-512 as well as the Blake2b hash functions.
|
|
1307
|
+
#
|
|
1308
|
+
# source://rbnacl//lib/rbnacl/hash.rb#17
|
|
1309
|
+
module RbNaCl::Hash
|
|
1310
|
+
class << self
|
|
1311
|
+
# Returns the Blake2b hash of the given data
|
|
1312
|
+
#
|
|
1313
|
+
# There's no streaming done, just pass in the data and be done with it.
|
|
1314
|
+
# This method returns a 64-byte hash by default.
|
|
1315
|
+
#
|
|
1316
|
+
# @option options
|
|
1317
|
+
# @option options
|
|
1318
|
+
# @option options
|
|
1319
|
+
# @option options
|
|
1320
|
+
# @param data [String] The data, as a collection of bytes
|
|
1321
|
+
# @param options [Hash] a customizable set of options
|
|
1322
|
+
# @raise [CryptoError] If the hashing fails for some reason.
|
|
1323
|
+
# @return [String] The Blake2b hash digest as raw bytes
|
|
1324
|
+
#
|
|
1325
|
+
# source://rbnacl//lib/rbnacl/hash.rb#65
|
|
1326
|
+
def blake2b(data, options = T.unsafe(nil)); end
|
|
1327
|
+
|
|
1328
|
+
# Returns the SHA-256 hash of the given data
|
|
1329
|
+
#
|
|
1330
|
+
# There's no streaming done, just pass in the data and be done with it.
|
|
1331
|
+
#
|
|
1332
|
+
# @param data [#to_str] The data, as a collection of bytes
|
|
1333
|
+
# @raise [CryptoError] If the hashing fails for some reason.
|
|
1334
|
+
# @return [String] The SHA-256 hash digest as raw bytes
|
|
1335
|
+
#
|
|
1336
|
+
# source://rbnacl//lib/rbnacl/hash.rb#27
|
|
1337
|
+
def sha256(data); end
|
|
1338
|
+
|
|
1339
|
+
# Returns the SHA-512 hash of the given data
|
|
1340
|
+
#
|
|
1341
|
+
# There's no streaming done, just pass in the data and be done with it.
|
|
1342
|
+
#
|
|
1343
|
+
# @param data [#to_str] The data, as a collection of bytes
|
|
1344
|
+
# @raise [CryptoError] If the hashing fails for some reason.
|
|
1345
|
+
# @return [String] The SHA-512 hash digest as raw bytes
|
|
1346
|
+
#
|
|
1347
|
+
# source://rbnacl//lib/rbnacl/hash.rb#43
|
|
1348
|
+
def sha512(data); end
|
|
1349
|
+
end
|
|
1350
|
+
end
|
|
1351
|
+
|
|
1352
|
+
# The Blake2b hash function
|
|
1353
|
+
#
|
|
1354
|
+
# Blake2b is based on Blake, a SHA3 finalist which was snubbed in favor of
|
|
1355
|
+
# Keccak, a much slower hash function but one sufficiently different from
|
|
1356
|
+
# SHA2 to let the SHA3 judges panel sleep easy. Back in the real world,
|
|
1357
|
+
# it'd be great if we can calculate hashes quickly if possible.
|
|
1358
|
+
#
|
|
1359
|
+
# Blake2b provides for up to 64-bit digests and also supports a keyed mode
|
|
1360
|
+
# similar to HMAC
|
|
1361
|
+
#
|
|
1362
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#15
|
|
1363
|
+
class RbNaCl::Hash::Blake2b
|
|
1364
|
+
extend ::RbNaCl::Sodium
|
|
1365
|
+
extend ::FFI::Library
|
|
1366
|
+
|
|
1367
|
+
# Create a new Blake2b hash object
|
|
1368
|
+
#
|
|
1369
|
+
# @option opts
|
|
1370
|
+
# @option opts
|
|
1371
|
+
# @option opts
|
|
1372
|
+
# @option opts
|
|
1373
|
+
# @param opts [Hash] Blake2b configuration
|
|
1374
|
+
# @raise [RbNaCl::LengthError] Invalid length specified for one or more options
|
|
1375
|
+
# @return [RbNaCl::Hash::Blake2b] A Blake2b hasher object
|
|
1376
|
+
#
|
|
1377
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#127
|
|
1378
|
+
def initialize(opts = T.unsafe(nil)); end
|
|
1379
|
+
|
|
1380
|
+
# Reentrant version of Blake2b digest calculation method
|
|
1381
|
+
#
|
|
1382
|
+
# @param message [String] Message to be hashed
|
|
1383
|
+
#
|
|
1384
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#152
|
|
1385
|
+
def <<(message); end
|
|
1386
|
+
|
|
1387
|
+
def crypto_generichash_blake2b_bytes_max(*_arg0); end
|
|
1388
|
+
def crypto_generichash_blake2b_bytes_min(*_arg0); end
|
|
1389
|
+
def crypto_generichash_blake2b_final(*_arg0); end
|
|
1390
|
+
def crypto_generichash_blake2b_init_salt_personal(*_arg0); end
|
|
1391
|
+
def crypto_generichash_blake2b_keybytes_max(*_arg0); end
|
|
1392
|
+
def crypto_generichash_blake2b_keybytes_min(*_arg0); end
|
|
1393
|
+
def crypto_generichash_blake2b_personalbytes(*_arg0); end
|
|
1394
|
+
def crypto_generichash_blake2b_salt_personal(*_arg0); end
|
|
1395
|
+
def crypto_generichash_blake2b_saltbytes(*_arg0); end
|
|
1396
|
+
def crypto_generichash_blake2b_update(*_arg0); end
|
|
1397
|
+
|
|
1398
|
+
# Finalize digest calculation, return cached digest if any
|
|
1399
|
+
#
|
|
1400
|
+
# @raise [CryptoError]
|
|
1401
|
+
# @return [String] Blake2b digest of the string as raw bytes
|
|
1402
|
+
#
|
|
1403
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#162
|
|
1404
|
+
def digest; end
|
|
1405
|
+
|
|
1406
|
+
# Initialize state for Blake2b hash calculation,
|
|
1407
|
+
# this will be called automatically from #update if needed
|
|
1408
|
+
#
|
|
1409
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#140
|
|
1410
|
+
def reset; end
|
|
1411
|
+
|
|
1412
|
+
# Reentrant version of Blake2b digest calculation method
|
|
1413
|
+
#
|
|
1414
|
+
# @param message [String] Message to be hashed
|
|
1415
|
+
#
|
|
1416
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#152
|
|
1417
|
+
def update(message); end
|
|
1418
|
+
|
|
1419
|
+
class << self
|
|
1420
|
+
def crypto_generichash_blake2b_bytes_max(*_arg0); end
|
|
1421
|
+
def crypto_generichash_blake2b_bytes_min(*_arg0); end
|
|
1422
|
+
def crypto_generichash_blake2b_final(*_arg0); end
|
|
1423
|
+
def crypto_generichash_blake2b_init_salt_personal(*_arg0); end
|
|
1424
|
+
def crypto_generichash_blake2b_keybytes_max(*_arg0); end
|
|
1425
|
+
def crypto_generichash_blake2b_keybytes_min(*_arg0); end
|
|
1426
|
+
def crypto_generichash_blake2b_personalbytes(*_arg0); end
|
|
1427
|
+
def crypto_generichash_blake2b_salt_personal(*_arg0); end
|
|
1428
|
+
def crypto_generichash_blake2b_saltbytes(*_arg0); end
|
|
1429
|
+
def crypto_generichash_blake2b_update(*_arg0); end
|
|
1430
|
+
|
|
1431
|
+
# Calculate a Blake2b digest
|
|
1432
|
+
#
|
|
1433
|
+
# @option opts
|
|
1434
|
+
# @option opts
|
|
1435
|
+
# @option opts
|
|
1436
|
+
# @option opts
|
|
1437
|
+
# @param message [String] Message to be hashed
|
|
1438
|
+
# @param options [Hash] Blake2b configuration
|
|
1439
|
+
# @param opts [Hash] a customizable set of options
|
|
1440
|
+
# @raise [RbNaCl::LengthError] Invalid length specified for one or more options
|
|
1441
|
+
# @return [String] Blake2b digest of the string as raw bytes
|
|
1442
|
+
#
|
|
1443
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#60
|
|
1444
|
+
def digest(message, options); end
|
|
1445
|
+
|
|
1446
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1447
|
+
def generichash_blake2b(*args); end
|
|
1448
|
+
|
|
1449
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1450
|
+
def generichash_blake2b_final(*args); end
|
|
1451
|
+
|
|
1452
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1453
|
+
def generichash_blake2b_init(*args); end
|
|
1454
|
+
|
|
1455
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1456
|
+
def generichash_blake2b_update(*args); end
|
|
1457
|
+
|
|
1458
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#109
|
|
1459
|
+
def new(opts = T.unsafe(nil)); end
|
|
1460
|
+
|
|
1461
|
+
private
|
|
1462
|
+
|
|
1463
|
+
# Validate and sanitize values for Blake2b configuration
|
|
1464
|
+
#
|
|
1465
|
+
# @option opts
|
|
1466
|
+
# @option opts
|
|
1467
|
+
# @option opts
|
|
1468
|
+
# @option opts
|
|
1469
|
+
# @param options [Hash] Blake2b configuration
|
|
1470
|
+
# @param opts [Hash] a customizable set of options
|
|
1471
|
+
# @raise [RbNaCl::LengthError] Invalid length specified for one or more options
|
|
1472
|
+
# @return [Hash] opts Configuration hash with sanitized values
|
|
1473
|
+
#
|
|
1474
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#82
|
|
1475
|
+
def validate_opts(opts); end
|
|
1476
|
+
end
|
|
1477
|
+
end
|
|
1478
|
+
|
|
1479
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1480
|
+
RbNaCl::Hash::Blake2b::BYTES_MAX = T.let(T.unsafe(nil), Integer)
|
|
1481
|
+
|
|
1482
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1483
|
+
RbNaCl::Hash::Blake2b::BYTES_MIN = T.let(T.unsafe(nil), Integer)
|
|
1484
|
+
|
|
1485
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#43
|
|
1486
|
+
RbNaCl::Hash::Blake2b::EMPTY_PERSONAL = T.let(T.unsafe(nil), String)
|
|
1487
|
+
|
|
1488
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#44
|
|
1489
|
+
RbNaCl::Hash::Blake2b::EMPTY_SALT = T.let(T.unsafe(nil), String)
|
|
1490
|
+
|
|
1491
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1492
|
+
RbNaCl::Hash::Blake2b::KEYBYTES_MAX = T.let(T.unsafe(nil), Integer)
|
|
1493
|
+
|
|
1494
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1495
|
+
RbNaCl::Hash::Blake2b::KEYBYTES_MIN = T.let(T.unsafe(nil), Integer)
|
|
1496
|
+
|
|
1497
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1498
|
+
RbNaCl::Hash::Blake2b::PERSONALBYTES = T.let(T.unsafe(nil), Integer)
|
|
1499
|
+
|
|
1500
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1501
|
+
RbNaCl::Hash::Blake2b::SALTBYTES = T.let(T.unsafe(nil), Integer)
|
|
1502
|
+
|
|
1503
|
+
# The crypto_generichash_blake2b_state struct representation
|
|
1504
|
+
# ref: jedisct1/libsodium/blob/c87df74c7b5969f4/src/libsodium/include/sodium/crypto_generichash_blake2b.h#L23-L25
|
|
1505
|
+
#
|
|
1506
|
+
# source://rbnacl//lib/rbnacl/hash/blake2b.rb#174
|
|
1507
|
+
class RbNaCl::Hash::Blake2b::State < ::FFI::Struct; end
|
|
1508
|
+
|
|
1509
|
+
# Provides a binding for the SHA256 function in libsodium
|
|
1510
|
+
#
|
|
1511
|
+
# source://rbnacl//lib/rbnacl/hash/sha256.rb#7
|
|
1512
|
+
module RbNaCl::Hash::SHA256
|
|
1513
|
+
extend ::RbNaCl::Sodium
|
|
1514
|
+
extend ::FFI::Library
|
|
1515
|
+
|
|
1516
|
+
def crypto_hash_sha256(*_arg0); end
|
|
1517
|
+
def crypto_hash_sha256_bytes(*_arg0); end
|
|
1518
|
+
|
|
1519
|
+
class << self
|
|
1520
|
+
def crypto_hash_sha256(*_arg0); end
|
|
1521
|
+
def crypto_hash_sha256_bytes(*_arg0); end
|
|
1522
|
+
|
|
1523
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1524
|
+
def hash_sha256(*args); end
|
|
1525
|
+
end
|
|
1526
|
+
end
|
|
1527
|
+
|
|
1528
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1529
|
+
RbNaCl::Hash::SHA256::BYTES = T.let(T.unsafe(nil), Integer)
|
|
1530
|
+
|
|
1531
|
+
# Provides the binding for the SHA512 hash function
|
|
1532
|
+
#
|
|
1533
|
+
# source://rbnacl//lib/rbnacl/hash/sha512.rb#7
|
|
1534
|
+
module RbNaCl::Hash::SHA512
|
|
1535
|
+
extend ::RbNaCl::Sodium
|
|
1536
|
+
extend ::FFI::Library
|
|
1537
|
+
|
|
1538
|
+
def crypto_hash_sha512(*_arg0); end
|
|
1539
|
+
def crypto_hash_sha512_bytes(*_arg0); end
|
|
1540
|
+
|
|
1541
|
+
class << self
|
|
1542
|
+
def crypto_hash_sha512(*_arg0); end
|
|
1543
|
+
def crypto_hash_sha512_bytes(*_arg0); end
|
|
1544
|
+
|
|
1545
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1546
|
+
def hash_sha512(*args); end
|
|
1547
|
+
end
|
|
1548
|
+
end
|
|
1549
|
+
|
|
1550
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1551
|
+
RbNaCl::Hash::SHA512::BYTES = T.let(T.unsafe(nil), Integer)
|
|
1552
|
+
|
|
1553
|
+
# An incorrect primitive has been passed to a method
|
|
1554
|
+
#
|
|
1555
|
+
# This indicates that an attempt has been made to use something (probably a key)
|
|
1556
|
+
# with an incorrect primitive
|
|
1557
|
+
#
|
|
1558
|
+
# source://rbnacl//lib/rbnacl.rb#42
|
|
1559
|
+
class RbNaCl::IncorrectPrimitiveError < ::ArgumentError; end
|
|
1560
|
+
|
|
1561
|
+
# Defines the libsodium init function
|
|
1562
|
+
#
|
|
1563
|
+
# source://rbnacl//lib/rbnacl/init.rb#6
|
|
1564
|
+
module RbNaCl::Init
|
|
1565
|
+
extend ::FFI::Library
|
|
1566
|
+
|
|
1567
|
+
def sodium_init(*_arg0); end
|
|
1568
|
+
|
|
1569
|
+
class << self
|
|
1570
|
+
def sodium_init(*_arg0); end
|
|
1571
|
+
end
|
|
1572
|
+
end
|
|
1573
|
+
|
|
1574
|
+
# Implements comparisons of keys
|
|
1575
|
+
#
|
|
1576
|
+
# This permits both timing invariant equality tests, as well as
|
|
1577
|
+
# lexicographical sorting.
|
|
1578
|
+
#
|
|
1579
|
+
# source://rbnacl//lib/rbnacl/key_comparator.rb#9
|
|
1580
|
+
module RbNaCl::KeyComparator
|
|
1581
|
+
include ::Comparable
|
|
1582
|
+
|
|
1583
|
+
# spaceship operator
|
|
1584
|
+
#
|
|
1585
|
+
# @param other [KeyComparator, #to_str] The thing to compare
|
|
1586
|
+
# @return [0] if the keys are equal
|
|
1587
|
+
# @return [1] if the key is larger than the other key
|
|
1588
|
+
# @return [-1] if the key is smaller than the other key
|
|
1589
|
+
# @return [nil] if comparison doesn't make sense
|
|
1590
|
+
#
|
|
1591
|
+
# source://rbnacl//lib/rbnacl/key_comparator.rb#19
|
|
1592
|
+
def <=>(other); end
|
|
1593
|
+
|
|
1594
|
+
# equality operator
|
|
1595
|
+
#
|
|
1596
|
+
# The equality operator is explicity defined, despite including Comparable
|
|
1597
|
+
# and having a spaceship operator, so that if equality tests are desired,
|
|
1598
|
+
# they can be timing invariant, without any chance that the further
|
|
1599
|
+
# comparisons for greater than and less than can leak information. Maybe
|
|
1600
|
+
# this is too paranoid, but I don't know how ruby works under the hood with
|
|
1601
|
+
# comparable.
|
|
1602
|
+
#
|
|
1603
|
+
# @param other [KeyComparator, #to_str] The thing to compare
|
|
1604
|
+
# @return [true] if the keys are equal
|
|
1605
|
+
# @return [false] if they keys are not equal
|
|
1606
|
+
#
|
|
1607
|
+
# source://rbnacl//lib/rbnacl/key_comparator.rb#43
|
|
1608
|
+
def ==(other); end
|
|
1609
|
+
|
|
1610
|
+
private
|
|
1611
|
+
|
|
1612
|
+
# source://rbnacl//lib/rbnacl/key_comparator.rb#56
|
|
1613
|
+
def compare32(other); end
|
|
1614
|
+
end
|
|
1615
|
+
|
|
1616
|
+
# Something, probably a key, is the wrong length
|
|
1617
|
+
#
|
|
1618
|
+
# This indicates some argument with an expected length was not that length.
|
|
1619
|
+
# Since this is probably a cryptographic key, you should check that!
|
|
1620
|
+
#
|
|
1621
|
+
# source://rbnacl//lib/rbnacl.rb#36
|
|
1622
|
+
class RbNaCl::LengthError < ::ArgumentError; end
|
|
1623
|
+
|
|
1624
|
+
# source://rbnacl//lib/rbnacl.rb#104
|
|
1625
|
+
RbNaCl::OneTimeAuth = RbNaCl::OneTimeAuths::Poly1305
|
|
1626
|
+
|
|
1627
|
+
# source://rbnacl//lib/rbnacl/one_time_auths/poly1305.rb#5
|
|
1628
|
+
module RbNaCl::OneTimeAuths; end
|
|
1629
|
+
|
|
1630
|
+
# Computes an authenticator using poly1305
|
|
1631
|
+
#
|
|
1632
|
+
# The authenticator can be used at a later time to verify the provenance of
|
|
1633
|
+
# the message by recomputing the tag over the message and then comparing it to
|
|
1634
|
+
# the provided authenticator. The class provides methods for generating
|
|
1635
|
+
# signatures and also has a constant-time implementation for checking them.
|
|
1636
|
+
#
|
|
1637
|
+
# As the name suggests, this is a **ONE TIME** authenticator. Computing an
|
|
1638
|
+
# authenticator for two messages using the same key probably gives an
|
|
1639
|
+
# attacker enough information to forge further authenticators for the same
|
|
1640
|
+
# key.
|
|
1641
|
+
#
|
|
1642
|
+
# This is a secret key authenticator, i.e. anyone who can verify signatures
|
|
1643
|
+
# can also create them.
|
|
1644
|
+
#
|
|
1645
|
+
# @see http://nacl.cr.yp.to/onetimeauth.html
|
|
1646
|
+
#
|
|
1647
|
+
# source://rbnacl//lib/rbnacl/one_time_auths/poly1305.rb#22
|
|
1648
|
+
class RbNaCl::OneTimeAuths::Poly1305 < ::RbNaCl::Auth
|
|
1649
|
+
extend ::RbNaCl::Sodium
|
|
1650
|
+
extend ::FFI::Library
|
|
1651
|
+
|
|
1652
|
+
def crypto_onetimeauth_poly1305(*_arg0); end
|
|
1653
|
+
def crypto_onetimeauth_poly1305_bytes(*_arg0); end
|
|
1654
|
+
def crypto_onetimeauth_poly1305_keybytes(*_arg0); end
|
|
1655
|
+
def crypto_onetimeauth_poly1305_verify(*_arg0); end
|
|
1656
|
+
|
|
1657
|
+
private
|
|
1658
|
+
|
|
1659
|
+
# source://rbnacl//lib/rbnacl/one_time_auths/poly1305.rb#40
|
|
1660
|
+
def compute_authenticator(authenticator, message); end
|
|
1661
|
+
|
|
1662
|
+
# source://rbnacl//lib/rbnacl/one_time_auths/poly1305.rb#44
|
|
1663
|
+
def verify_message(authenticator, message); end
|
|
1664
|
+
|
|
1665
|
+
class << self
|
|
1666
|
+
def crypto_onetimeauth_poly1305(*_arg0); end
|
|
1667
|
+
def crypto_onetimeauth_poly1305_bytes(*_arg0); end
|
|
1668
|
+
def crypto_onetimeauth_poly1305_keybytes(*_arg0); end
|
|
1669
|
+
def crypto_onetimeauth_poly1305_verify(*_arg0); end
|
|
1670
|
+
|
|
1671
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1672
|
+
def onetimeauth_poly1305(*args); end
|
|
1673
|
+
|
|
1674
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1675
|
+
def onetimeauth_poly1305_verify(*args); end
|
|
1676
|
+
end
|
|
1677
|
+
end
|
|
1678
|
+
|
|
1679
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1680
|
+
RbNaCl::OneTimeAuths::Poly1305::BYTES = T.let(T.unsafe(nil), Integer)
|
|
1681
|
+
|
|
1682
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1683
|
+
RbNaCl::OneTimeAuths::Poly1305::KEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
1684
|
+
|
|
1685
|
+
# Password hashing functions
|
|
1686
|
+
#
|
|
1687
|
+
# These hash functions are designed specifically for the purposes of securely
|
|
1688
|
+
# storing passwords in a way that they can be checked against a supplied
|
|
1689
|
+
# password but an attacker who obtains a hash cannot easily reverse them back
|
|
1690
|
+
# into the original password.
|
|
1691
|
+
#
|
|
1692
|
+
# Unlike normal hash functions, which are intentionally designed to hash data
|
|
1693
|
+
# as quickly as they can while remaining secure, password hashing functions
|
|
1694
|
+
# are intentionally designed to be slow so they are hard for attackers to
|
|
1695
|
+
# brute force.
|
|
1696
|
+
#
|
|
1697
|
+
# All password hashing functions take a "salt" value which should be randomly
|
|
1698
|
+
# generated on a per-password basis (using RbNaCl::Random, accept no
|
|
1699
|
+
# substitutes)
|
|
1700
|
+
#
|
|
1701
|
+
# All of them also take a CPU work factor, which increases the amount of
|
|
1702
|
+
# computation needed to produce the digest.
|
|
1703
|
+
#
|
|
1704
|
+
# source://rbnacl//lib/rbnacl/password_hash.rb#23
|
|
1705
|
+
module RbNaCl::PasswordHash
|
|
1706
|
+
class << self
|
|
1707
|
+
# argon2: state of the art in the design of memory-hard hashing functions
|
|
1708
|
+
# (default digest algorithm).
|
|
1709
|
+
#
|
|
1710
|
+
# @param password [String] to be hashed
|
|
1711
|
+
# @param salt [String] to make the digest unique
|
|
1712
|
+
# @param opslimit [Integer] the CPU cost (3..10)
|
|
1713
|
+
# @param memlimit [Integer] the memory cost, in bytes
|
|
1714
|
+
# @param digest_size [Integer] of the output
|
|
1715
|
+
# @raise [CryptoError] If calculating the digest fails for some reason.
|
|
1716
|
+
# @return [String] The argon2 digest as raw bytes
|
|
1717
|
+
#
|
|
1718
|
+
# source://rbnacl//lib/rbnacl/password_hash.rb#51
|
|
1719
|
+
def argon2(password, salt, opslimit, memlimit, digest_size = T.unsafe(nil)); end
|
|
1720
|
+
|
|
1721
|
+
# argon2_str: crypt-style password digest
|
|
1722
|
+
#
|
|
1723
|
+
# @param password [String] to be hashed
|
|
1724
|
+
# @param opslimit [Integer] the CPU cost (3..10)
|
|
1725
|
+
# @param memlimit [Integer] the memory cost, in bytes
|
|
1726
|
+
# @raise [CryptoError] If calculating the digest fails for some reason.
|
|
1727
|
+
# @return [String] The argon2i digest as crypt-style string
|
|
1728
|
+
#
|
|
1729
|
+
# source://rbnacl//lib/rbnacl/password_hash.rb#94
|
|
1730
|
+
def argon2_str(password, opslimit = T.unsafe(nil), memlimit = T.unsafe(nil)); end
|
|
1731
|
+
|
|
1732
|
+
# argon2_valid?: verify crypt-style password digest
|
|
1733
|
+
#
|
|
1734
|
+
# @param password [String] to verify
|
|
1735
|
+
# @param str_digest [String] to verify
|
|
1736
|
+
# @return [Boolean] true if digest was created using password
|
|
1737
|
+
#
|
|
1738
|
+
# source://rbnacl//lib/rbnacl/password_hash.rb#104
|
|
1739
|
+
def argon2_valid?(password, str_digest); end
|
|
1740
|
+
|
|
1741
|
+
# argon2i: argon2, using argon2i digest algorithm.
|
|
1742
|
+
#
|
|
1743
|
+
# @param password [String] to be hashed
|
|
1744
|
+
# @param salt [String] to make the digest unique
|
|
1745
|
+
# @param opslimit [Integer] the CPU cost (3..10)
|
|
1746
|
+
# @param memlimit [Integer] the memory cost, in bytes
|
|
1747
|
+
# @param digest_size [Integer] of the output
|
|
1748
|
+
# @raise [CryptoError] If calculating the digest fails for some reason.
|
|
1749
|
+
# @return [String] The argon2i digest as raw bytes
|
|
1750
|
+
#
|
|
1751
|
+
# source://rbnacl//lib/rbnacl/password_hash.rb#66
|
|
1752
|
+
def argon2i(password, salt, opslimit, memlimit, digest_size = T.unsafe(nil)); end
|
|
1753
|
+
|
|
1754
|
+
# argon2id: argon2, using argon2id digest algorithm.
|
|
1755
|
+
#
|
|
1756
|
+
# @param password [String] to be hashed
|
|
1757
|
+
# @param salt [String] to make the digest unique
|
|
1758
|
+
# @param opslimit [Integer] the CPU cost (3..10)
|
|
1759
|
+
# @param memlimit [Integer] the memory cost, in bytes
|
|
1760
|
+
# @param digest_size [Integer] of the output
|
|
1761
|
+
# @raise [CryptoError] If calculating the digest fails for some reason.
|
|
1762
|
+
# @return [String] The argon2id digest as raw bytes
|
|
1763
|
+
#
|
|
1764
|
+
# source://rbnacl//lib/rbnacl/password_hash.rb#81
|
|
1765
|
+
def argon2id(password, salt, opslimit, memlimit, digest_size = T.unsafe(nil)); end
|
|
1766
|
+
|
|
1767
|
+
# scrypt: the original sequential memory-hard password hashing function.
|
|
1768
|
+
#
|
|
1769
|
+
# @param password [String] to be hashed
|
|
1770
|
+
# @param salt [String] to make the digest unique
|
|
1771
|
+
# @param opslimit [Integer] the CPU cost (e.g. 2**20)
|
|
1772
|
+
# @param memlimit [Integer] the memory cost (e.g. 2**24)
|
|
1773
|
+
# @param digest_size [Integer] of the output
|
|
1774
|
+
# @raise [CryptoError] If calculating the digest fails for some reason.
|
|
1775
|
+
# @return [String] The scrypt digest as raw bytes
|
|
1776
|
+
#
|
|
1777
|
+
# source://rbnacl//lib/rbnacl/password_hash.rb#35
|
|
1778
|
+
def scrypt(password, salt, opslimit, memlimit, digest_size = T.unsafe(nil)); end
|
|
1779
|
+
|
|
1780
|
+
protected
|
|
1781
|
+
|
|
1782
|
+
# @return [Boolean]
|
|
1783
|
+
#
|
|
1784
|
+
# source://rbnacl//lib/rbnacl/password_hash.rb#111
|
|
1785
|
+
def argon2_supported?; end
|
|
1786
|
+
end
|
|
1787
|
+
end
|
|
1788
|
+
|
|
1789
|
+
# Since version 1.0.9, Sodium provides a password hashing scheme called
|
|
1790
|
+
# Argon2. Argon2 summarizes the state of the art in the design of memory-
|
|
1791
|
+
# hard functions. It aims at the highest memory filling rate and effective
|
|
1792
|
+
# use of multiple computing units, while still providing defense against
|
|
1793
|
+
# tradeoff attacks. It prevents ASICs from having a significant advantage
|
|
1794
|
+
# over software implementations.
|
|
1795
|
+
#
|
|
1796
|
+
# source://rbnacl//lib/rbnacl/password_hash/argon2.rb#12
|
|
1797
|
+
class RbNaCl::PasswordHash::Argon2
|
|
1798
|
+
extend ::RbNaCl::Sodium
|
|
1799
|
+
extend ::FFI::Library
|
|
1800
|
+
|
|
1801
|
+
# Create a new Argon2 password hash object
|
|
1802
|
+
#
|
|
1803
|
+
# opslimit and memlimit may be an integer, or one of the following
|
|
1804
|
+
# symbols:
|
|
1805
|
+
#
|
|
1806
|
+
# [:interactive] Suitable for interactive online operations. This
|
|
1807
|
+
# requires 32 Mb of dedicated RAM.
|
|
1808
|
+
# [:moderate] A compromise between interactive and sensitive. This
|
|
1809
|
+
# requires 128 Mb of dedicated RAM, and takes about 0.7
|
|
1810
|
+
# seconds on a 2.8 Ghz Core i7 CPU.
|
|
1811
|
+
# [:sensitive] For highly sensitive and non-interactive operations. This
|
|
1812
|
+
# requires 128 Mb of dedicated RAM, and takes about 0.7
|
|
1813
|
+
# seconds on a 2.8 Ghz Core i7 CPU
|
|
1814
|
+
#
|
|
1815
|
+
# @param opslimit [Integer] the CPU cost (1..10)
|
|
1816
|
+
# @param memlimit [Integer] the memory cost (e.g. 2**24)
|
|
1817
|
+
# @param digest_size [Integer] the byte length of the resulting digest
|
|
1818
|
+
# @return [RbNaCl::PasswordHash::Argon2] An Argon2 password hasher object
|
|
1819
|
+
#
|
|
1820
|
+
# source://rbnacl//lib/rbnacl/password_hash/argon2.rb#95
|
|
1821
|
+
def initialize(opslimit, memlimit, digest_size = T.unsafe(nil)); end
|
|
1822
|
+
|
|
1823
|
+
def crypto_pwhash(*_arg0); end
|
|
1824
|
+
def crypto_pwhash_alg_argon2i13(*_arg0); end
|
|
1825
|
+
def crypto_pwhash_alg_argon2id13(*_arg0); end
|
|
1826
|
+
def crypto_pwhash_alg_default(*_arg0); end
|
|
1827
|
+
def crypto_pwhash_memlimit_interactive(*_arg0); end
|
|
1828
|
+
def crypto_pwhash_memlimit_max(*_arg0); end
|
|
1829
|
+
def crypto_pwhash_memlimit_min(*_arg0); end
|
|
1830
|
+
def crypto_pwhash_memlimit_moderate(*_arg0); end
|
|
1831
|
+
def crypto_pwhash_memlimit_sensitive(*_arg0); end
|
|
1832
|
+
def crypto_pwhash_opslimit_interactive(*_arg0); end
|
|
1833
|
+
def crypto_pwhash_opslimit_max(*_arg0); end
|
|
1834
|
+
def crypto_pwhash_opslimit_min(*_arg0); end
|
|
1835
|
+
def crypto_pwhash_opslimit_moderate(*_arg0); end
|
|
1836
|
+
def crypto_pwhash_opslimit_sensitive(*_arg0); end
|
|
1837
|
+
def crypto_pwhash_saltbytes(*_arg0); end
|
|
1838
|
+
def crypto_pwhash_str(*_arg0); end
|
|
1839
|
+
def crypto_pwhash_str_verify(*_arg0); end
|
|
1840
|
+
def crypto_pwhash_strbytes(*_arg0); end
|
|
1841
|
+
|
|
1842
|
+
# Calculate an Argon2 digest for a given password and salt
|
|
1843
|
+
#
|
|
1844
|
+
# @param password [String] to be hashed
|
|
1845
|
+
# @param salt [String] to make the digest unique
|
|
1846
|
+
# @param digest [Symbol] algorithm to use (may be :argon2i or :argon2id)
|
|
1847
|
+
# if nil, the default is determined by libsodium
|
|
1848
|
+
# (argon2i for libsodium < 1.0.15, and argon2id for
|
|
1849
|
+
# libsodium >= 1.0.15).
|
|
1850
|
+
# @raise [ArgumentError]
|
|
1851
|
+
# @return [String] scrypt digest of the string as raw bytes
|
|
1852
|
+
#
|
|
1853
|
+
# source://rbnacl//lib/rbnacl/password_hash/argon2.rb#111
|
|
1854
|
+
def digest(password, salt, algo = T.unsafe(nil)); end
|
|
1855
|
+
|
|
1856
|
+
# Calculate an Argon2 digest in the form of a crypt-style string.
|
|
1857
|
+
# The resulting string encodes the parameters and salt.
|
|
1858
|
+
#
|
|
1859
|
+
# @param password [String] to be hashed
|
|
1860
|
+
# @raise [ArgumentError]
|
|
1861
|
+
# @return [String] argon2 digest string
|
|
1862
|
+
#
|
|
1863
|
+
# source://rbnacl//lib/rbnacl/password_hash/argon2.rb#143
|
|
1864
|
+
def digest_str(password); end
|
|
1865
|
+
|
|
1866
|
+
class << self
|
|
1867
|
+
def crypto_pwhash(*_arg0); end
|
|
1868
|
+
def crypto_pwhash_alg_argon2i13(*_arg0); end
|
|
1869
|
+
def crypto_pwhash_alg_argon2id13(*_arg0); end
|
|
1870
|
+
def crypto_pwhash_alg_default(*_arg0); end
|
|
1871
|
+
def crypto_pwhash_memlimit_interactive(*_arg0); end
|
|
1872
|
+
def crypto_pwhash_memlimit_max(*_arg0); end
|
|
1873
|
+
def crypto_pwhash_memlimit_min(*_arg0); end
|
|
1874
|
+
def crypto_pwhash_memlimit_moderate(*_arg0); end
|
|
1875
|
+
def crypto_pwhash_memlimit_sensitive(*_arg0); end
|
|
1876
|
+
def crypto_pwhash_opslimit_interactive(*_arg0); end
|
|
1877
|
+
def crypto_pwhash_opslimit_max(*_arg0); end
|
|
1878
|
+
def crypto_pwhash_opslimit_min(*_arg0); end
|
|
1879
|
+
def crypto_pwhash_opslimit_moderate(*_arg0); end
|
|
1880
|
+
def crypto_pwhash_opslimit_sensitive(*_arg0); end
|
|
1881
|
+
def crypto_pwhash_saltbytes(*_arg0); end
|
|
1882
|
+
def crypto_pwhash_str(*_arg0); end
|
|
1883
|
+
def crypto_pwhash_str_verify(*_arg0); end
|
|
1884
|
+
def crypto_pwhash_strbytes(*_arg0); end
|
|
1885
|
+
|
|
1886
|
+
# Clamps digest size between 16..4294967295
|
|
1887
|
+
#
|
|
1888
|
+
# @raise [LengthError] if the value is out of range
|
|
1889
|
+
# @return [Integer] digest_size a valid value for digest size
|
|
1890
|
+
#
|
|
1891
|
+
# source://rbnacl//lib/rbnacl/password_hash/argon2.rb#215
|
|
1892
|
+
def digest_size_value(digest_size); end
|
|
1893
|
+
|
|
1894
|
+
# Compares a password with a digest string
|
|
1895
|
+
#
|
|
1896
|
+
# @param password [String] to be hashed
|
|
1897
|
+
# @param digest_string [String] to compare to
|
|
1898
|
+
# @raise [ArgumentError]
|
|
1899
|
+
# @return [boolean] true if password matches digest_string
|
|
1900
|
+
#
|
|
1901
|
+
# source://rbnacl//lib/rbnacl/password_hash/argon2.rb#164
|
|
1902
|
+
def digest_str_verify(password, digest_string); end
|
|
1903
|
+
|
|
1904
|
+
# Clamps memlimit between 8192 bytes and 4 TB (eg. 2**32)
|
|
1905
|
+
#
|
|
1906
|
+
# @param memlimit, [Integer] in bytes
|
|
1907
|
+
# @raise [ArgumentError] if the value is out of range
|
|
1908
|
+
# @return [Integer] memlimit a valid value for memlimit
|
|
1909
|
+
#
|
|
1910
|
+
# source://rbnacl//lib/rbnacl/password_hash/argon2.rb#199
|
|
1911
|
+
def memlimit_value(memlimit); end
|
|
1912
|
+
|
|
1913
|
+
# Clamps opslimit to an acceptable range (3..10)
|
|
1914
|
+
#
|
|
1915
|
+
# @param opslimit [Integer] value to be checked
|
|
1916
|
+
# @raise [ArgumentError] if the value is out of range
|
|
1917
|
+
# @return [Integer] opslimit a valid value for opslimit
|
|
1918
|
+
#
|
|
1919
|
+
# source://rbnacl//lib/rbnacl/password_hash/argon2.rb#181
|
|
1920
|
+
def opslimit_value(opslimit); end
|
|
1921
|
+
|
|
1922
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#60
|
|
1923
|
+
def pwhash(*args); end
|
|
1924
|
+
|
|
1925
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1926
|
+
def pwhash_str(*args); end
|
|
1927
|
+
|
|
1928
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
1929
|
+
def pwhash_str_verify(*args); end
|
|
1930
|
+
end
|
|
1931
|
+
end
|
|
1932
|
+
|
|
1933
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1934
|
+
RbNaCl::PasswordHash::Argon2::ALG_ARGON2I13 = T.let(T.unsafe(nil), Integer)
|
|
1935
|
+
|
|
1936
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1937
|
+
RbNaCl::PasswordHash::Argon2::ALG_ARGON2ID13 = T.let(T.unsafe(nil), Integer)
|
|
1938
|
+
|
|
1939
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1940
|
+
RbNaCl::PasswordHash::Argon2::ALG_DEFAULT = T.let(T.unsafe(nil), Integer)
|
|
1941
|
+
|
|
1942
|
+
# source://rbnacl//lib/rbnacl/password_hash/argon2.rb#35
|
|
1943
|
+
RbNaCl::PasswordHash::Argon2::ARGON2_MAX_OUTLEN = T.let(T.unsafe(nil), Integer)
|
|
1944
|
+
|
|
1945
|
+
# source://rbnacl//lib/rbnacl/password_hash/argon2.rb#34
|
|
1946
|
+
RbNaCl::PasswordHash::Argon2::ARGON2_MIN_OUTLEN = T.let(T.unsafe(nil), Integer)
|
|
1947
|
+
|
|
1948
|
+
# source://rbnacl//lib/rbnacl/password_hash/argon2.rb#55
|
|
1949
|
+
RbNaCl::PasswordHash::Argon2::ARGON_ERROR_CODES = T.let(T.unsafe(nil), Hash)
|
|
1950
|
+
|
|
1951
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1952
|
+
RbNaCl::PasswordHash::Argon2::MEMLIMIT_INTERACTIVE = T.let(T.unsafe(nil), Integer)
|
|
1953
|
+
|
|
1954
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1955
|
+
RbNaCl::PasswordHash::Argon2::MEMLIMIT_MAX = T.let(T.unsafe(nil), Integer)
|
|
1956
|
+
|
|
1957
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1958
|
+
RbNaCl::PasswordHash::Argon2::MEMLIMIT_MIN = T.let(T.unsafe(nil), Integer)
|
|
1959
|
+
|
|
1960
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1961
|
+
RbNaCl::PasswordHash::Argon2::MEMLIMIT_MODERATE = T.let(T.unsafe(nil), Integer)
|
|
1962
|
+
|
|
1963
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1964
|
+
RbNaCl::PasswordHash::Argon2::MEMLIMIT_SENSITIVE = T.let(T.unsafe(nil), Integer)
|
|
1965
|
+
|
|
1966
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1967
|
+
RbNaCl::PasswordHash::Argon2::OPSLIMIT_INTERACTIVE = T.let(T.unsafe(nil), Integer)
|
|
1968
|
+
|
|
1969
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1970
|
+
RbNaCl::PasswordHash::Argon2::OPSLIMIT_MAX = T.let(T.unsafe(nil), Integer)
|
|
1971
|
+
|
|
1972
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1973
|
+
RbNaCl::PasswordHash::Argon2::OPSLIMIT_MIN = T.let(T.unsafe(nil), Integer)
|
|
1974
|
+
|
|
1975
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1976
|
+
RbNaCl::PasswordHash::Argon2::OPSLIMIT_MODERATE = T.let(T.unsafe(nil), Integer)
|
|
1977
|
+
|
|
1978
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1979
|
+
RbNaCl::PasswordHash::Argon2::OPSLIMIT_SENSITIVE = T.let(T.unsafe(nil), Integer)
|
|
1980
|
+
|
|
1981
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1982
|
+
RbNaCl::PasswordHash::Argon2::SALTBYTES = T.let(T.unsafe(nil), Integer)
|
|
1983
|
+
|
|
1984
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
1985
|
+
RbNaCl::PasswordHash::Argon2::STRBYTES = T.let(T.unsafe(nil), Integer)
|
|
1986
|
+
|
|
1987
|
+
# The scrypt sequential memory hard password hashing function
|
|
1988
|
+
#
|
|
1989
|
+
# scrypt is a password hash (or password based KDF). That is to say, where
|
|
1990
|
+
# most hash functions are designed to be fast because hashing is often a
|
|
1991
|
+
# bottleneck, scrypt is slow by design, because it's trying to "strengthen"
|
|
1992
|
+
# the password by combining it with a random "salt" value then perform a
|
|
1993
|
+
# series of operation on the result which are slow enough to defeat
|
|
1994
|
+
# brute-force password cracking attempts.
|
|
1995
|
+
#
|
|
1996
|
+
# scrypt is similar to the bcrypt and pbkdf2 password hashes in that it's
|
|
1997
|
+
# designed to strengthen passwords, but includes a new design element
|
|
1998
|
+
# called "sequential memory hardness" which helps defeat attempts by
|
|
1999
|
+
# attackers to compensate for their lack of memory (since they're typically
|
|
2000
|
+
# on GPUs or FPGAs) with additional computation.
|
|
2001
|
+
#
|
|
2002
|
+
# source://rbnacl//lib/rbnacl/password_hash/scrypt.rb#20
|
|
2003
|
+
class RbNaCl::PasswordHash::SCrypt
|
|
2004
|
+
extend ::RbNaCl::Sodium
|
|
2005
|
+
extend ::FFI::Library
|
|
2006
|
+
|
|
2007
|
+
# Create a new SCrypt password hash object
|
|
2008
|
+
#
|
|
2009
|
+
# @param opslimit [Integer] the CPU cost (e.g. 2**20)
|
|
2010
|
+
# @param memlimit [Integer] the memory cost (e.g. 2**24)
|
|
2011
|
+
# @return [RbNaCl::PasswordHash::SCrypt] An SCrypt password hasher object
|
|
2012
|
+
#
|
|
2013
|
+
# source://rbnacl//lib/rbnacl/password_hash/scrypt.rb#37
|
|
2014
|
+
def initialize(opslimit, memlimit, digest_size = T.unsafe(nil)); end
|
|
2015
|
+
|
|
2016
|
+
def crypto_pwhash_scryptsalsa208sha256(*_arg0); end
|
|
2017
|
+
def crypto_pwhash_scryptsalsa208sha256_saltbytes(*_arg0); end
|
|
2018
|
+
|
|
2019
|
+
# Calculate an scrypt digest for a given password and salt
|
|
2020
|
+
#
|
|
2021
|
+
# @param password [String] to be hashed
|
|
2022
|
+
# @param salt [String] to make the digest unique
|
|
2023
|
+
# @raise [CryptoError]
|
|
2024
|
+
# @return [String] scrypt digest of the string as raw bytes
|
|
2025
|
+
#
|
|
2026
|
+
# source://rbnacl//lib/rbnacl/password_hash/scrypt.rb#55
|
|
2027
|
+
def digest(password, salt); end
|
|
2028
|
+
|
|
2029
|
+
class << self
|
|
2030
|
+
def crypto_pwhash_scryptsalsa208sha256(*_arg0); end
|
|
2031
|
+
def crypto_pwhash_scryptsalsa208sha256_saltbytes(*_arg0); end
|
|
2032
|
+
|
|
2033
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
2034
|
+
def scrypt(*args); end
|
|
2035
|
+
end
|
|
2036
|
+
end
|
|
2037
|
+
|
|
2038
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
2039
|
+
RbNaCl::PasswordHash::SCrypt::SALTBYTES = T.let(T.unsafe(nil), Integer)
|
|
2040
|
+
|
|
2041
|
+
# source://rbnacl//lib/rbnacl.rb#97
|
|
2042
|
+
RbNaCl::PrivateKey = RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PrivateKey
|
|
2043
|
+
|
|
2044
|
+
# source://rbnacl//lib/rbnacl.rb#98
|
|
2045
|
+
RbNaCl::PublicKey = RbNaCl::Boxes::Curve25519XSalsa20Poly1305::PublicKey
|
|
2046
|
+
|
|
2047
|
+
# Functions for random number generation
|
|
2048
|
+
#
|
|
2049
|
+
# This uses the underlying source of random number generation on the OS, so
|
|
2050
|
+
# /dev/urandom on UNIX-like systems, and the MS crypto providor on windows.
|
|
2051
|
+
#
|
|
2052
|
+
# source://rbnacl//lib/rbnacl/random.rb#9
|
|
2053
|
+
module RbNaCl::Random
|
|
2054
|
+
extend ::RbNaCl::Sodium
|
|
2055
|
+
extend ::FFI::Library
|
|
2056
|
+
|
|
2057
|
+
def randombytes_buf(*_arg0); end
|
|
2058
|
+
|
|
2059
|
+
class << self
|
|
2060
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
2061
|
+
def c_random_bytes(*args); end
|
|
2062
|
+
|
|
2063
|
+
# Returns a string of random bytes
|
|
2064
|
+
#
|
|
2065
|
+
# @param n [Integer] number of random bytes desired
|
|
2066
|
+
# @return [String] random bytes.
|
|
2067
|
+
#
|
|
2068
|
+
# source://rbnacl//lib/rbnacl/random.rb#23
|
|
2069
|
+
def random_bytes(n = T.unsafe(nil)); end
|
|
2070
|
+
|
|
2071
|
+
def randombytes_buf(*_arg0); end
|
|
2072
|
+
end
|
|
2073
|
+
end
|
|
2074
|
+
|
|
2075
|
+
# Backwards compatibility with the old RandomNonceBox name
|
|
2076
|
+
#
|
|
2077
|
+
# source://rbnacl//lib/rbnacl/simple_box.rb#116
|
|
2078
|
+
RbNaCl::RandomNonceBox = RbNaCl::SimpleBox
|
|
2079
|
+
|
|
2080
|
+
# source://rbnacl//lib/rbnacl.rb#99
|
|
2081
|
+
RbNaCl::SealedBox = RbNaCl::Boxes::Sealed
|
|
2082
|
+
|
|
2083
|
+
# source://rbnacl//lib/rbnacl.rb#100
|
|
2084
|
+
RbNaCl::SecretBox = RbNaCl::SecretBoxes::XSalsa20Poly1305
|
|
2085
|
+
|
|
2086
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#5
|
|
2087
|
+
module RbNaCl::SecretBoxes; end
|
|
2088
|
+
|
|
2089
|
+
# The SecretBox class boxes and unboxes messages
|
|
2090
|
+
#
|
|
2091
|
+
# This class uses the given secret key to encrypt and decrypt messages.
|
|
2092
|
+
#
|
|
2093
|
+
# It is VITALLY important that the nonce is a nonce, i.e. it is a number used
|
|
2094
|
+
# only once for any given pair of keys. If you fail to do this, you
|
|
2095
|
+
# compromise the privacy of the messages encrypted. Give your nonces a
|
|
2096
|
+
# different prefix, or have one side use an odd counter and one an even counter.
|
|
2097
|
+
# Just make sure they are different.
|
|
2098
|
+
#
|
|
2099
|
+
# The ciphertexts generated by this class include a 16-byte authenticator which
|
|
2100
|
+
# is checked as part of the decryption. An invalid authenticator will cause
|
|
2101
|
+
# the unbox function to raise. The authenticator is not a signature. Once
|
|
2102
|
+
# you've looked in the box, you've demonstrated the ability to create
|
|
2103
|
+
# arbitrary valid messages, so messages you send are repudiable. For
|
|
2104
|
+
# non-repudiable messages, sign them before or after encryption.
|
|
2105
|
+
#
|
|
2106
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#22
|
|
2107
|
+
class RbNaCl::SecretBoxes::XSalsa20Poly1305
|
|
2108
|
+
extend ::RbNaCl::Sodium
|
|
2109
|
+
extend ::FFI::Library
|
|
2110
|
+
|
|
2111
|
+
# Create a new SecretBox
|
|
2112
|
+
#
|
|
2113
|
+
# Sets up the Box with a secret key fro encrypting and decrypting messages.
|
|
2114
|
+
#
|
|
2115
|
+
# @param key [String] The key to encrypt and decrypt with
|
|
2116
|
+
# @raise [RbNaCl::LengthError] on invalid keys
|
|
2117
|
+
# @return [RbNaCl::SecretBox] The new Box, ready to use
|
|
2118
|
+
#
|
|
2119
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#49
|
|
2120
|
+
def initialize(key); end
|
|
2121
|
+
|
|
2122
|
+
# Encrypts a message
|
|
2123
|
+
#
|
|
2124
|
+
# Encrypts the message with the given nonce to the key set up when
|
|
2125
|
+
# initializing the class. Make sure the nonce is unique for any given
|
|
2126
|
+
# key, or you might as well just send plain text.
|
|
2127
|
+
#
|
|
2128
|
+
# This function takes care of the padding required by the NaCL C API.
|
|
2129
|
+
#
|
|
2130
|
+
# @param nonce [String] A 24-byte string containing the nonce.
|
|
2131
|
+
# @param message [String] The message to be encrypted.
|
|
2132
|
+
# @raise [RbNaCl::LengthError] If the nonce is not valid
|
|
2133
|
+
# @return [String] The ciphertext without the nonce prepended (BINARY encoded)
|
|
2134
|
+
#
|
|
2135
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#67
|
|
2136
|
+
def box(nonce, message); end
|
|
2137
|
+
|
|
2138
|
+
def crypto_secretbox_xsalsa20poly1305(*_arg0); end
|
|
2139
|
+
def crypto_secretbox_xsalsa20poly1305_boxzerobytes(*_arg0); end
|
|
2140
|
+
def crypto_secretbox_xsalsa20poly1305_keybytes(*_arg0); end
|
|
2141
|
+
def crypto_secretbox_xsalsa20poly1305_noncebytes(*_arg0); end
|
|
2142
|
+
def crypto_secretbox_xsalsa20poly1305_open(*_arg0); end
|
|
2143
|
+
def crypto_secretbox_xsalsa20poly1305_zerobytes(*_arg0); end
|
|
2144
|
+
|
|
2145
|
+
# Decrypts a ciphertext
|
|
2146
|
+
#
|
|
2147
|
+
# Decrypts the ciphertext with the given nonce using the key setup when
|
|
2148
|
+
# initializing the class.
|
|
2149
|
+
#
|
|
2150
|
+
# This function takes care of the padding required by the NaCL C API.
|
|
2151
|
+
#
|
|
2152
|
+
# @param nonce [String] A 24-byte string containing the nonce.
|
|
2153
|
+
# @param ciphertext [String] The message to be decrypted.
|
|
2154
|
+
# @raise [RbNaCl::LengthError] If the nonce is not valid
|
|
2155
|
+
# @raise [RbNaCl::CryptoError] If the ciphertext cannot be authenticated.
|
|
2156
|
+
# @return [String] The decrypted message (BINARY encoded)
|
|
2157
|
+
#
|
|
2158
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#93
|
|
2159
|
+
def decrypt(nonce, ciphertext); end
|
|
2160
|
+
|
|
2161
|
+
# Encrypts a message
|
|
2162
|
+
#
|
|
2163
|
+
# Encrypts the message with the given nonce to the key set up when
|
|
2164
|
+
# initializing the class. Make sure the nonce is unique for any given
|
|
2165
|
+
# key, or you might as well just send plain text.
|
|
2166
|
+
#
|
|
2167
|
+
# This function takes care of the padding required by the NaCL C API.
|
|
2168
|
+
#
|
|
2169
|
+
# @param nonce [String] A 24-byte string containing the nonce.
|
|
2170
|
+
# @param message [String] The message to be encrypted.
|
|
2171
|
+
# @raise [RbNaCl::LengthError] If the nonce is not valid
|
|
2172
|
+
# @return [String] The ciphertext without the nonce prepended (BINARY encoded)
|
|
2173
|
+
#
|
|
2174
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#67
|
|
2175
|
+
def encrypt(nonce, message); end
|
|
2176
|
+
|
|
2177
|
+
# The key bytes for the SecretBox instance
|
|
2178
|
+
#
|
|
2179
|
+
# @return [Integer] The number of bytes in a valid key
|
|
2180
|
+
#
|
|
2181
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#136
|
|
2182
|
+
def key_bytes; end
|
|
2183
|
+
|
|
2184
|
+
# The nonce bytes for the SecretBox instance
|
|
2185
|
+
#
|
|
2186
|
+
# @return [Integer] The number of bytes in a valid nonce
|
|
2187
|
+
#
|
|
2188
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#122
|
|
2189
|
+
def nonce_bytes; end
|
|
2190
|
+
|
|
2191
|
+
# Decrypts a ciphertext
|
|
2192
|
+
#
|
|
2193
|
+
# Decrypts the ciphertext with the given nonce using the key setup when
|
|
2194
|
+
# initializing the class.
|
|
2195
|
+
#
|
|
2196
|
+
# This function takes care of the padding required by the NaCL C API.
|
|
2197
|
+
#
|
|
2198
|
+
# @param nonce [String] A 24-byte string containing the nonce.
|
|
2199
|
+
# @param ciphertext [String] The message to be decrypted.
|
|
2200
|
+
# @raise [RbNaCl::LengthError] If the nonce is not valid
|
|
2201
|
+
# @raise [RbNaCl::CryptoError] If the ciphertext cannot be authenticated.
|
|
2202
|
+
# @return [String] The decrypted message (BINARY encoded)
|
|
2203
|
+
#
|
|
2204
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#93
|
|
2205
|
+
def open(nonce, ciphertext); end
|
|
2206
|
+
|
|
2207
|
+
# The crypto primitive for the SecretBox instance
|
|
2208
|
+
#
|
|
2209
|
+
# @return [Symbol] The primitive used
|
|
2210
|
+
#
|
|
2211
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#108
|
|
2212
|
+
def primitive; end
|
|
2213
|
+
|
|
2214
|
+
class << self
|
|
2215
|
+
def crypto_secretbox_xsalsa20poly1305(*_arg0); end
|
|
2216
|
+
def crypto_secretbox_xsalsa20poly1305_boxzerobytes(*_arg0); end
|
|
2217
|
+
def crypto_secretbox_xsalsa20poly1305_keybytes(*_arg0); end
|
|
2218
|
+
def crypto_secretbox_xsalsa20poly1305_noncebytes(*_arg0); end
|
|
2219
|
+
def crypto_secretbox_xsalsa20poly1305_open(*_arg0); end
|
|
2220
|
+
def crypto_secretbox_xsalsa20poly1305_zerobytes(*_arg0); end
|
|
2221
|
+
|
|
2222
|
+
# The key bytes for the SecretBox class
|
|
2223
|
+
#
|
|
2224
|
+
# @return [Integer] The number of bytes in a valid key
|
|
2225
|
+
#
|
|
2226
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#129
|
|
2227
|
+
def key_bytes; end
|
|
2228
|
+
|
|
2229
|
+
# The nonce bytes for the SecretBox class
|
|
2230
|
+
#
|
|
2231
|
+
# @return [Integer] The number of bytes in a valid nonce
|
|
2232
|
+
#
|
|
2233
|
+
# source://rbnacl//lib/rbnacl/secret_boxes/xsalsa20poly1305.rb#115
|
|
2234
|
+
def nonce_bytes; end
|
|
2235
|
+
|
|
2236
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
2237
|
+
def secretbox_xsalsa20poly1305(*args); end
|
|
2238
|
+
|
|
2239
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
2240
|
+
def secretbox_xsalsa20poly1305_open(*args); end
|
|
2241
|
+
end
|
|
2242
|
+
end
|
|
2243
|
+
|
|
2244
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
2245
|
+
RbNaCl::SecretBoxes::XSalsa20Poly1305::BOXZEROBYTES = T.let(T.unsafe(nil), Integer)
|
|
2246
|
+
|
|
2247
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
2248
|
+
RbNaCl::SecretBoxes::XSalsa20Poly1305::KEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
2249
|
+
|
|
2250
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
2251
|
+
RbNaCl::SecretBoxes::XSalsa20Poly1305::NONCEBYTES = T.let(T.unsafe(nil), Integer)
|
|
2252
|
+
|
|
2253
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
2254
|
+
RbNaCl::SecretBoxes::XSalsa20Poly1305::ZEROBYTES = T.let(T.unsafe(nil), Integer)
|
|
2255
|
+
|
|
2256
|
+
# Self-test performed at startup
|
|
2257
|
+
#
|
|
2258
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#11
|
|
2259
|
+
module RbNaCl::SelfTest
|
|
2260
|
+
private
|
|
2261
|
+
|
|
2262
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#31
|
|
2263
|
+
def box_common_test(box); end
|
|
2264
|
+
|
|
2265
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#18
|
|
2266
|
+
def box_test; end
|
|
2267
|
+
|
|
2268
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#51
|
|
2269
|
+
def digital_signature_test; end
|
|
2270
|
+
|
|
2271
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#94
|
|
2272
|
+
def hmac_test(klass, tag); end
|
|
2273
|
+
|
|
2274
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#26
|
|
2275
|
+
def secret_box_test; end
|
|
2276
|
+
|
|
2277
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#87
|
|
2278
|
+
def sha256_test; end
|
|
2279
|
+
|
|
2280
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#14
|
|
2281
|
+
def vector(name); end
|
|
2282
|
+
|
|
2283
|
+
class << self
|
|
2284
|
+
# @raise [SelfTestFailure]
|
|
2285
|
+
#
|
|
2286
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#31
|
|
2287
|
+
def box_common_test(box); end
|
|
2288
|
+
|
|
2289
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#18
|
|
2290
|
+
def box_test; end
|
|
2291
|
+
|
|
2292
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#51
|
|
2293
|
+
def digital_signature_test; end
|
|
2294
|
+
|
|
2295
|
+
# @raise [SelfTestFailure]
|
|
2296
|
+
#
|
|
2297
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#94
|
|
2298
|
+
def hmac_test(klass, tag); end
|
|
2299
|
+
|
|
2300
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#26
|
|
2301
|
+
def secret_box_test; end
|
|
2302
|
+
|
|
2303
|
+
# @raise [SelfTestFailure]
|
|
2304
|
+
#
|
|
2305
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#87
|
|
2306
|
+
def sha256_test; end
|
|
2307
|
+
|
|
2308
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#14
|
|
2309
|
+
def vector(name); end
|
|
2310
|
+
end
|
|
2311
|
+
end
|
|
2312
|
+
|
|
2313
|
+
# source://rbnacl//lib/rbnacl/self_test.rb#8
|
|
2314
|
+
class RbNaCl::SelfTestFailure < ::RbNaCl::CryptoError; end
|
|
2315
|
+
|
|
2316
|
+
# Serialization features shared across all "key-like" classes
|
|
2317
|
+
#
|
|
2318
|
+
# source://rbnacl//lib/rbnacl/serializable.rb#6
|
|
2319
|
+
module RbNaCl::Serializable
|
|
2320
|
+
# Inspect this key
|
|
2321
|
+
#
|
|
2322
|
+
# @return [String] a string representing this key
|
|
2323
|
+
#
|
|
2324
|
+
# source://rbnacl//lib/rbnacl/serializable.rb#18
|
|
2325
|
+
def inspect; end
|
|
2326
|
+
|
|
2327
|
+
# source://rbnacl//lib/rbnacl/serializable.rb#7
|
|
2328
|
+
def to_s; end
|
|
2329
|
+
|
|
2330
|
+
# source://rbnacl//lib/rbnacl/serializable.rb#11
|
|
2331
|
+
def to_str; end
|
|
2332
|
+
end
|
|
2333
|
+
|
|
2334
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519.rb#5
|
|
2335
|
+
module RbNaCl::Signatures; end
|
|
2336
|
+
|
|
2337
|
+
# The EdDSA signature system implemented using the Ed25519 elliptic curve
|
|
2338
|
+
#
|
|
2339
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519.rb#7
|
|
2340
|
+
module RbNaCl::Signatures::Ed25519
|
|
2341
|
+
extend ::RbNaCl::Sodium
|
|
2342
|
+
extend ::FFI::Library
|
|
2343
|
+
|
|
2344
|
+
def crypto_sign_ed25519_bytes(*_arg0); end
|
|
2345
|
+
def crypto_sign_ed25519_publickeybytes(*_arg0); end
|
|
2346
|
+
def crypto_sign_ed25519_secretkeybytes(*_arg0); end
|
|
2347
|
+
def crypto_sign_ed25519_seedbytes(*_arg0); end
|
|
2348
|
+
|
|
2349
|
+
class << self
|
|
2350
|
+
def crypto_sign_ed25519_bytes(*_arg0); end
|
|
2351
|
+
def crypto_sign_ed25519_publickeybytes(*_arg0); end
|
|
2352
|
+
def crypto_sign_ed25519_secretkeybytes(*_arg0); end
|
|
2353
|
+
def crypto_sign_ed25519_seedbytes(*_arg0); end
|
|
2354
|
+
end
|
|
2355
|
+
end
|
|
2356
|
+
|
|
2357
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
2358
|
+
RbNaCl::Signatures::Ed25519::SEEDBYTES = T.let(T.unsafe(nil), Integer)
|
|
2359
|
+
|
|
2360
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
2361
|
+
RbNaCl::Signatures::Ed25519::SIGNATUREBYTES = T.let(T.unsafe(nil), Integer)
|
|
2362
|
+
|
|
2363
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
2364
|
+
RbNaCl::Signatures::Ed25519::SIGNINGKEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
2365
|
+
|
|
2366
|
+
# Private key for producing digital signatures using the Ed25519 algorithm.
|
|
2367
|
+
# Ed25519 provides a 128-bit security level, that is to say, all known attacks
|
|
2368
|
+
# take at least 2^128 operations, providing the same security level as
|
|
2369
|
+
# AES-128, NIST P-256, and RSA-3072.
|
|
2370
|
+
#
|
|
2371
|
+
# Signing keys are produced from a 32-byte (256-bit) random seed value.
|
|
2372
|
+
# This value can be passed into the SigningKey constructor as a String
|
|
2373
|
+
# whose bytesize is 32.
|
|
2374
|
+
#
|
|
2375
|
+
# The public VerifyKey can be computed from the private 32-byte seed value
|
|
2376
|
+
# as well, eliminating the need to store a "keypair".
|
|
2377
|
+
#
|
|
2378
|
+
# SigningKey produces 64-byte (512-bit) signatures. The signatures are
|
|
2379
|
+
# deterministic: signing the same message will always produce the same
|
|
2380
|
+
# signature. This prevents "entropy failure" seen in other signature
|
|
2381
|
+
# algorithms like DSA and ECDSA, where poor random number generators can
|
|
2382
|
+
# leak enough information to recover the private key.
|
|
2383
|
+
#
|
|
2384
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/signing_key.rb#24
|
|
2385
|
+
class RbNaCl::Signatures::Ed25519::SigningKey
|
|
2386
|
+
include ::Comparable
|
|
2387
|
+
include ::RbNaCl::KeyComparator
|
|
2388
|
+
include ::RbNaCl::Serializable
|
|
2389
|
+
extend ::RbNaCl::Sodium
|
|
2390
|
+
extend ::FFI::Library
|
|
2391
|
+
|
|
2392
|
+
# Create a SigningKey from a seed value
|
|
2393
|
+
#
|
|
2394
|
+
# @param seed [String] Random 32-byte value (i.e. private key)
|
|
2395
|
+
# @return [RbNaCl::SigningKey] Key which can sign messages
|
|
2396
|
+
#
|
|
2397
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/signing_key.rb#55
|
|
2398
|
+
def initialize(seed); end
|
|
2399
|
+
|
|
2400
|
+
def crypto_sign_ed25519(*_arg0); end
|
|
2401
|
+
def crypto_sign_ed25519_seed_keypair(*_arg0); end
|
|
2402
|
+
|
|
2403
|
+
# Return the raw 64 byte value of this key
|
|
2404
|
+
#
|
|
2405
|
+
# @return [String] The signature key bytes. Left half is 32-byte
|
|
2406
|
+
# curve25519 private scalar, right half is 32-byte group element
|
|
2407
|
+
#
|
|
2408
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/signing_key.rb#102
|
|
2409
|
+
def keypair_bytes; end
|
|
2410
|
+
|
|
2411
|
+
# The crypto primitive this SigningKey class uses for signatures
|
|
2412
|
+
#
|
|
2413
|
+
# @return [Symbol] The primitive
|
|
2414
|
+
#
|
|
2415
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/signing_key.rb#109
|
|
2416
|
+
def primitive; end
|
|
2417
|
+
|
|
2418
|
+
# Sign a message using this key
|
|
2419
|
+
#
|
|
2420
|
+
# @param message [String] Message to be signed by this key
|
|
2421
|
+
# @return [String] Signature as bytes
|
|
2422
|
+
#
|
|
2423
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/signing_key.rb#75
|
|
2424
|
+
def sign(message); end
|
|
2425
|
+
|
|
2426
|
+
# Sign a message using this key, attaching the signature to the message
|
|
2427
|
+
#
|
|
2428
|
+
# @param message [String] Message to be signed by this key
|
|
2429
|
+
# @return [String] Signature and the message as bytes
|
|
2430
|
+
#
|
|
2431
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/signing_key.rb#84
|
|
2432
|
+
def sign_attached(message); end
|
|
2433
|
+
|
|
2434
|
+
# The size of signatures generated by the SigningKey instance
|
|
2435
|
+
#
|
|
2436
|
+
# @return [Integer] The number of bytes in a signature
|
|
2437
|
+
#
|
|
2438
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/signing_key.rb#123
|
|
2439
|
+
def signature_bytes; end
|
|
2440
|
+
|
|
2441
|
+
# Return the raw seed value of this key
|
|
2442
|
+
#
|
|
2443
|
+
# @return [String] seed used to create this key
|
|
2444
|
+
#
|
|
2445
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/signing_key.rb#94
|
|
2446
|
+
def to_bytes; end
|
|
2447
|
+
|
|
2448
|
+
# Returns the value of attribute verify_key.
|
|
2449
|
+
#
|
|
2450
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/signing_key.rb#41
|
|
2451
|
+
def verify_key; end
|
|
2452
|
+
|
|
2453
|
+
class << self
|
|
2454
|
+
def crypto_sign_ed25519(*_arg0); end
|
|
2455
|
+
def crypto_sign_ed25519_seed_keypair(*_arg0); end
|
|
2456
|
+
|
|
2457
|
+
# Generate a random SigningKey
|
|
2458
|
+
#
|
|
2459
|
+
# @return [RbNaCl::SigningKey] Freshly-generated random SigningKey
|
|
2460
|
+
#
|
|
2461
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/signing_key.rb#46
|
|
2462
|
+
def generate; end
|
|
2463
|
+
|
|
2464
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
2465
|
+
def sign_ed25519(*args); end
|
|
2466
|
+
|
|
2467
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
2468
|
+
def sign_ed25519_seed_keypair(*args); end
|
|
2469
|
+
|
|
2470
|
+
# The size of signatures generated by the SigningKey class
|
|
2471
|
+
#
|
|
2472
|
+
# @return [Integer] The number of bytes in a signature
|
|
2473
|
+
#
|
|
2474
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/signing_key.rb#116
|
|
2475
|
+
def signature_bytes; end
|
|
2476
|
+
end
|
|
2477
|
+
end
|
|
2478
|
+
|
|
2479
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#44
|
|
2480
|
+
RbNaCl::Signatures::Ed25519::VERIFYKEYBYTES = T.let(T.unsafe(nil), Integer)
|
|
2481
|
+
|
|
2482
|
+
# The public key counterpart to an Ed25519 SigningKey for producing digital
|
|
2483
|
+
# signatures. Like the name says, VerifyKeys can be used to verify that a
|
|
2484
|
+
# given digital signature is authentic.
|
|
2485
|
+
#
|
|
2486
|
+
# For more information on the Ed25519 digital signature system, please see
|
|
2487
|
+
# the SigningKey documentation.
|
|
2488
|
+
#
|
|
2489
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/verify_key.rb#13
|
|
2490
|
+
class RbNaCl::Signatures::Ed25519::VerifyKey
|
|
2491
|
+
include ::Comparable
|
|
2492
|
+
include ::RbNaCl::KeyComparator
|
|
2493
|
+
include ::RbNaCl::Serializable
|
|
2494
|
+
extend ::RbNaCl::Sodium
|
|
2495
|
+
extend ::FFI::Library
|
|
2496
|
+
|
|
2497
|
+
# Create a new VerifyKey object from a public key.
|
|
2498
|
+
#
|
|
2499
|
+
# @param key [String] Ed25519 public key
|
|
2500
|
+
# @return [RbNaCl::VerifyKey] Key which can verify messages
|
|
2501
|
+
#
|
|
2502
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/verify_key.rb#31
|
|
2503
|
+
def initialize(key); end
|
|
2504
|
+
|
|
2505
|
+
def crypto_sign_ed25519_open(*_arg0); end
|
|
2506
|
+
|
|
2507
|
+
# The crypto primitive this VerifyKey class uses for signatures
|
|
2508
|
+
#
|
|
2509
|
+
# @return [Symbol] The primitive
|
|
2510
|
+
#
|
|
2511
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/verify_key.rb#85
|
|
2512
|
+
def primitive; end
|
|
2513
|
+
|
|
2514
|
+
# The size of signatures verified by the VerifyKey instance
|
|
2515
|
+
#
|
|
2516
|
+
# @return [Integer] The number of bytes in a signature
|
|
2517
|
+
#
|
|
2518
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/verify_key.rb#99
|
|
2519
|
+
def signature_bytes; end
|
|
2520
|
+
|
|
2521
|
+
# Return the raw key in byte format
|
|
2522
|
+
#
|
|
2523
|
+
# @return [String] raw key as bytes
|
|
2524
|
+
#
|
|
2525
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/verify_key.rb#78
|
|
2526
|
+
def to_bytes; end
|
|
2527
|
+
|
|
2528
|
+
# Verify a signature for a given message
|
|
2529
|
+
#
|
|
2530
|
+
# Raises if the signature is invalid.
|
|
2531
|
+
#
|
|
2532
|
+
# @param signature [String] Alleged signature to be checked
|
|
2533
|
+
# @param message [String] Message to be authenticated
|
|
2534
|
+
# @raise [BadSignatureError] if the signature check fails
|
|
2535
|
+
# @raise [LengthError] if the signature is of the wrong length
|
|
2536
|
+
# @return [Boolean] was the signature authentic?
|
|
2537
|
+
#
|
|
2538
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/verify_key.rb#47
|
|
2539
|
+
def verify(signature, message); end
|
|
2540
|
+
|
|
2541
|
+
# Verify a signature for a given signed message
|
|
2542
|
+
#
|
|
2543
|
+
# Raises if the signature is invalid.
|
|
2544
|
+
#
|
|
2545
|
+
# @param signed_message [String] Message combined with signature to be authenticated
|
|
2546
|
+
# @raise [BadSignatureError] if the signature check fails
|
|
2547
|
+
# @return [Boolean] was the signature authentic?
|
|
2548
|
+
#
|
|
2549
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/verify_key.rb#62
|
|
2550
|
+
def verify_attached(signed_message); end
|
|
2551
|
+
|
|
2552
|
+
class << self
|
|
2553
|
+
def crypto_sign_ed25519_open(*_arg0); end
|
|
2554
|
+
|
|
2555
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
2556
|
+
def sign_ed25519_open(*args); end
|
|
2557
|
+
|
|
2558
|
+
# The size of signatures verified by the VerifyKey class
|
|
2559
|
+
#
|
|
2560
|
+
# @return [Integer] The number of bytes in a signature
|
|
2561
|
+
#
|
|
2562
|
+
# source://rbnacl//lib/rbnacl/signatures/ed25519/verify_key.rb#92
|
|
2563
|
+
def signature_bytes; end
|
|
2564
|
+
end
|
|
2565
|
+
end
|
|
2566
|
+
|
|
2567
|
+
# source://rbnacl//lib/rbnacl.rb#101
|
|
2568
|
+
RbNaCl::SigningKey = RbNaCl::Signatures::Ed25519::SigningKey
|
|
2569
|
+
|
|
2570
|
+
# The simplest nonce strategy that could possibly work
|
|
2571
|
+
#
|
|
2572
|
+
# This class implements the simplest possible nonce generation strategy to
|
|
2573
|
+
# wrap a RbNaCl::Box or RbNaCl::SecretBox. A 24-byte random nonce is used
|
|
2574
|
+
# for the encryption and is prepended to the message. When it is time to
|
|
2575
|
+
# open the box, the message is split into nonce and ciphertext, and then the
|
|
2576
|
+
# box is decrypted.
|
|
2577
|
+
#
|
|
2578
|
+
# Thanks to the size of the nonce, the chance of a collision is negligible. For
|
|
2579
|
+
# example, after encrypting 2^64 messages, the odds of their having been
|
|
2580
|
+
# repeated nonce is approximately 2^-64. As an additional convenience, the
|
|
2581
|
+
# ciphertexts may be encoded or decoded by any of the encoders implemented in
|
|
2582
|
+
# the library.
|
|
2583
|
+
#
|
|
2584
|
+
# The resulting ciphertexts are 40 bytes longer than the plain text (24 byte
|
|
2585
|
+
# nonce plus a 16 byte authenticator). This might be annoying if you're
|
|
2586
|
+
# encrypting tweets, but for files represents a fairly small overhead.
|
|
2587
|
+
#
|
|
2588
|
+
# Some caveats:
|
|
2589
|
+
#
|
|
2590
|
+
# * If your random source is broken, so is the security of the messages. You
|
|
2591
|
+
# have bigger problems than just this library at that point, but it's worth
|
|
2592
|
+
# saying.
|
|
2593
|
+
# * The confidentiality of your messages is assured with this strategy, but
|
|
2594
|
+
# there is no protection against messages being reordered and replayed by an
|
|
2595
|
+
# active adversary.
|
|
2596
|
+
#
|
|
2597
|
+
# source://rbnacl//lib/rbnacl/simple_box.rb#34
|
|
2598
|
+
class RbNaCl::SimpleBox
|
|
2599
|
+
extend ::Forwardable
|
|
2600
|
+
|
|
2601
|
+
# Create a new SimpleBox
|
|
2602
|
+
#
|
|
2603
|
+
# @param box [SecretBox, Box] the SecretBox or Box to use.
|
|
2604
|
+
# @return [SimpleBox] Ready for use
|
|
2605
|
+
#
|
|
2606
|
+
# source://rbnacl//lib/rbnacl/simple_box.rb#43
|
|
2607
|
+
def initialize(box); end
|
|
2608
|
+
|
|
2609
|
+
# Encrypts the message with a random nonce
|
|
2610
|
+
#
|
|
2611
|
+
# Encrypts the message with a random nonce, then returns the ciphertext with
|
|
2612
|
+
# the nonce prepended. Optionally encodes the message using an encoder.
|
|
2613
|
+
#
|
|
2614
|
+
# @param message [String] The message to encrypt
|
|
2615
|
+
# @return [String] The enciphered message
|
|
2616
|
+
#
|
|
2617
|
+
# source://rbnacl//lib/rbnacl/simple_box.rb#80
|
|
2618
|
+
def box(message); end
|
|
2619
|
+
|
|
2620
|
+
# Decrypts the ciphertext with a random nonce
|
|
2621
|
+
#
|
|
2622
|
+
# Takes a ciphertext, optionally decodes it, then splits the nonce off the
|
|
2623
|
+
# front and uses this to decrypt. Returns the message.
|
|
2624
|
+
#
|
|
2625
|
+
# @param enciphered_message [String] The message to decrypt.
|
|
2626
|
+
# @raise [CryptoError] If the message has been tampered with.
|
|
2627
|
+
# @return [String] The decoded message
|
|
2628
|
+
#
|
|
2629
|
+
# source://rbnacl//lib/rbnacl/simple_box.rb#97
|
|
2630
|
+
def decrypt(enciphered_message); end
|
|
2631
|
+
|
|
2632
|
+
# Encrypts the message with a random nonce
|
|
2633
|
+
#
|
|
2634
|
+
# Encrypts the message with a random nonce, then returns the ciphertext with
|
|
2635
|
+
# the nonce prepended. Optionally encodes the message using an encoder.
|
|
2636
|
+
#
|
|
2637
|
+
# @param message [String] The message to encrypt
|
|
2638
|
+
# @return [String] The enciphered message
|
|
2639
|
+
#
|
|
2640
|
+
# source://rbnacl//lib/rbnacl/simple_box.rb#80
|
|
2641
|
+
def encrypt(message); end
|
|
2642
|
+
|
|
2643
|
+
# source://forwardable/1.3.2/forwardable.rb#229
|
|
2644
|
+
def nonce_bytes(*args, **_arg1, &block); end
|
|
2645
|
+
|
|
2646
|
+
# Decrypts the ciphertext with a random nonce
|
|
2647
|
+
#
|
|
2648
|
+
# Takes a ciphertext, optionally decodes it, then splits the nonce off the
|
|
2649
|
+
# front and uses this to decrypt. Returns the message.
|
|
2650
|
+
#
|
|
2651
|
+
# @param enciphered_message [String] The message to decrypt.
|
|
2652
|
+
# @raise [CryptoError] If the message has been tampered with.
|
|
2653
|
+
# @return [String] The decoded message
|
|
2654
|
+
#
|
|
2655
|
+
# source://rbnacl//lib/rbnacl/simple_box.rb#97
|
|
2656
|
+
def open(enciphered_message); end
|
|
2657
|
+
|
|
2658
|
+
# source://forwardable/1.3.2/forwardable.rb#229
|
|
2659
|
+
def primitive(*args, **_arg1, &block); end
|
|
2660
|
+
|
|
2661
|
+
private
|
|
2662
|
+
|
|
2663
|
+
# source://rbnacl//lib/rbnacl/simple_box.rb#109
|
|
2664
|
+
def extract_nonce(bytes); end
|
|
2665
|
+
|
|
2666
|
+
# source://rbnacl//lib/rbnacl/simple_box.rb#105
|
|
2667
|
+
def generate_nonce; end
|
|
2668
|
+
|
|
2669
|
+
class << self
|
|
2670
|
+
# Use a pair of keys to create a SimpleBox
|
|
2671
|
+
#
|
|
2672
|
+
# This is a convenience method. It takes a pair of keys and instantiates a
|
|
2673
|
+
# Box under the hood, then returns the new SimpleBox.
|
|
2674
|
+
#
|
|
2675
|
+
# @param public_key [PublicKey, String] The RbNaCl public key, as class or string
|
|
2676
|
+
# @param private_key [PrivateKey, String] The RbNaCl private key, as class or string
|
|
2677
|
+
# @return [SimpleBox] Ready for use
|
|
2678
|
+
#
|
|
2679
|
+
# source://rbnacl//lib/rbnacl/simple_box.rb#68
|
|
2680
|
+
def from_keypair(public_key, private_key); end
|
|
2681
|
+
|
|
2682
|
+
# Use a secret key to create a SimpleBox
|
|
2683
|
+
#
|
|
2684
|
+
# This is a convenience method. It takes a secret key and instantiates a
|
|
2685
|
+
# SecretBox under the hood, then returns the new SimpleBox.
|
|
2686
|
+
#
|
|
2687
|
+
# @param secret_key [String] The secret key, 32 bytes long.
|
|
2688
|
+
# @return [SimpleBox] Ready for use
|
|
2689
|
+
#
|
|
2690
|
+
# source://rbnacl//lib/rbnacl/simple_box.rb#55
|
|
2691
|
+
def from_secret_key(secret_key); end
|
|
2692
|
+
end
|
|
2693
|
+
end
|
|
2694
|
+
|
|
2695
|
+
# Provides helpers for defining the libsodium bindings
|
|
2696
|
+
#
|
|
2697
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#8
|
|
2698
|
+
module RbNaCl::Sodium
|
|
2699
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#28
|
|
2700
|
+
def primitive; end
|
|
2701
|
+
|
|
2702
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#32
|
|
2703
|
+
def sodium_constant(constant, name: T.unsafe(nil), fallback: T.unsafe(nil)); end
|
|
2704
|
+
|
|
2705
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#47
|
|
2706
|
+
def sodium_function(name, function, arguments); end
|
|
2707
|
+
|
|
2708
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#57
|
|
2709
|
+
def sodium_function_with_return_code(name, function, arguments); end
|
|
2710
|
+
|
|
2711
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#20
|
|
2712
|
+
def sodium_primitive(primitive = T.unsafe(nil)); end
|
|
2713
|
+
|
|
2714
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#14
|
|
2715
|
+
def sodium_type(type = T.unsafe(nil)); end
|
|
2716
|
+
|
|
2717
|
+
class << self
|
|
2718
|
+
# @private
|
|
2719
|
+
#
|
|
2720
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#9
|
|
2721
|
+
def extended(klass); end
|
|
2722
|
+
end
|
|
2723
|
+
end
|
|
2724
|
+
|
|
2725
|
+
# libsodium version API
|
|
2726
|
+
#
|
|
2727
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#9
|
|
2728
|
+
module RbNaCl::Sodium::Version
|
|
2729
|
+
extend ::RbNaCl::Sodium
|
|
2730
|
+
extend ::FFI::Library
|
|
2731
|
+
|
|
2732
|
+
def sodium_version_string(*_arg0); end
|
|
2733
|
+
|
|
2734
|
+
class << self
|
|
2735
|
+
def sodium_version_string(*_arg0); end
|
|
2736
|
+
|
|
2737
|
+
# Determine if a given feature is supported based on Sodium version
|
|
2738
|
+
#
|
|
2739
|
+
# @return [Boolean]
|
|
2740
|
+
#
|
|
2741
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#31
|
|
2742
|
+
def supported_version?(version); end
|
|
2743
|
+
end
|
|
2744
|
+
end
|
|
2745
|
+
|
|
2746
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#28
|
|
2747
|
+
RbNaCl::Sodium::Version::ARGON2ID_SUPPORTED = T.let(T.unsafe(nil), TrueClass)
|
|
2748
|
+
|
|
2749
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#27
|
|
2750
|
+
RbNaCl::Sodium::Version::ARGON2_SUPPORTED = T.let(T.unsafe(nil), TrueClass)
|
|
2751
|
+
|
|
2752
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#20
|
|
2753
|
+
RbNaCl::Sodium::Version::INSTALLED_VERSION = T.let(T.unsafe(nil), Array)
|
|
2754
|
+
|
|
2755
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#18
|
|
2756
|
+
RbNaCl::Sodium::Version::MAJOR = T.let(T.unsafe(nil), Integer)
|
|
2757
|
+
|
|
2758
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#10
|
|
2759
|
+
RbNaCl::Sodium::Version::MINIMUM_LIBSODIUM_VERSION = T.let(T.unsafe(nil), Array)
|
|
2760
|
+
|
|
2761
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#11
|
|
2762
|
+
RbNaCl::Sodium::Version::MINIMUM_LIBSODIUM_VERSION_FOR_ARGON2 = T.let(T.unsafe(nil), Array)
|
|
2763
|
+
|
|
2764
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#12
|
|
2765
|
+
RbNaCl::Sodium::Version::MINIMUM_LIBSODIUM_VERSION_FOR_ARGON2ID = T.let(T.unsafe(nil), Array)
|
|
2766
|
+
|
|
2767
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#18
|
|
2768
|
+
RbNaCl::Sodium::Version::MINOR = T.let(T.unsafe(nil), Integer)
|
|
2769
|
+
|
|
2770
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#18
|
|
2771
|
+
RbNaCl::Sodium::Version::PATCH = T.let(T.unsafe(nil), Integer)
|
|
2772
|
+
|
|
2773
|
+
# source://rbnacl//lib/rbnacl/sodium/version.rb#17
|
|
2774
|
+
RbNaCl::Sodium::Version::STRING = T.let(T.unsafe(nil), String)
|
|
2775
|
+
|
|
2776
|
+
# Reference library of test vectors used to verify the software is correct
|
|
2777
|
+
#
|
|
2778
|
+
# source://rbnacl//lib/rbnacl/test_vectors.rb#8
|
|
2779
|
+
RbNaCl::TEST_VECTORS = T.let(T.unsafe(nil), Hash)
|
|
2780
|
+
|
|
2781
|
+
# Various utility functions
|
|
2782
|
+
#
|
|
2783
|
+
# source://rbnacl//lib/rbnacl/util.rb#6
|
|
2784
|
+
module RbNaCl::Util
|
|
2785
|
+
extend ::RbNaCl::Sodium
|
|
2786
|
+
extend ::FFI::Library
|
|
2787
|
+
|
|
2788
|
+
def crypto_verify_16(*_arg0); end
|
|
2789
|
+
def crypto_verify_32(*_arg0); end
|
|
2790
|
+
def crypto_verify_64(*_arg0); end
|
|
2791
|
+
|
|
2792
|
+
private
|
|
2793
|
+
|
|
2794
|
+
# Hex encodes a message
|
|
2795
|
+
#
|
|
2796
|
+
# @param bytes [String] The bytes to encode
|
|
2797
|
+
# @return [String] Tasty, tasty hexadecimal
|
|
2798
|
+
#
|
|
2799
|
+
# source://rbnacl//lib/rbnacl/util.rb#277
|
|
2800
|
+
def bin2hex(bytes); end
|
|
2801
|
+
|
|
2802
|
+
# Check a passed in string, convertion if necessary
|
|
2803
|
+
#
|
|
2804
|
+
# This method will check the key, and raise error
|
|
2805
|
+
# if argument is not a string, and if it's empty string.
|
|
2806
|
+
#
|
|
2807
|
+
# RFC 2104 HMAC
|
|
2808
|
+
# The key for HMAC can be of any length (keys longer than B bytes are
|
|
2809
|
+
# first hashed using H). However, less than L bytes is strongly
|
|
2810
|
+
# discouraged as it would decrease the security strength of the
|
|
2811
|
+
# function. Keys longer than L bytes are acceptable but the extra
|
|
2812
|
+
# length would not significantly increase the function strength. (A
|
|
2813
|
+
# longer key may be advisable if the randomness of the key is
|
|
2814
|
+
# considered weak.)
|
|
2815
|
+
#
|
|
2816
|
+
# see https://tools.ietf.org/html/rfc2104#section-3
|
|
2817
|
+
#
|
|
2818
|
+
# @param string [#to_str] The input string
|
|
2819
|
+
# @raise [ArgumentError] If we cannot convert to a string with #to_str
|
|
2820
|
+
# @raise [RbNaCl::LengthError] If the string is empty
|
|
2821
|
+
#
|
|
2822
|
+
# source://rbnacl//lib/rbnacl/util.rb#140
|
|
2823
|
+
def check_hmac_key(string, _description); end
|
|
2824
|
+
|
|
2825
|
+
# Check the length of the passed in string
|
|
2826
|
+
#
|
|
2827
|
+
# In several places through the codebase we have to be VERY strict with
|
|
2828
|
+
# what length of string we accept. This method supports that.
|
|
2829
|
+
#
|
|
2830
|
+
# @param string [String] The string to compare
|
|
2831
|
+
# @param length [Integer] The desired length
|
|
2832
|
+
# @param description [String] Description of the string (used in the error)
|
|
2833
|
+
# @raise [RbNaCl::LengthError] If the string is not the right length
|
|
2834
|
+
#
|
|
2835
|
+
# source://rbnacl//lib/rbnacl/util.rb#83
|
|
2836
|
+
def check_length(string, length, description); end
|
|
2837
|
+
|
|
2838
|
+
# Check a passed in string, converting the argument if necessary
|
|
2839
|
+
#
|
|
2840
|
+
# In several places through the codebase we have to be VERY strict with
|
|
2841
|
+
# the strings we accept. This method supports that.
|
|
2842
|
+
#
|
|
2843
|
+
# @param string [#to_str] The input string
|
|
2844
|
+
# @param length [Integer] The only acceptable length of the string
|
|
2845
|
+
# @param description [String] Description of the string (used in the error)
|
|
2846
|
+
# @raise [ArgumentError] If we cannot convert to a string with #to_str
|
|
2847
|
+
# @raise [RbNaCl::LengthError] If the string is not the right length
|
|
2848
|
+
#
|
|
2849
|
+
# source://rbnacl//lib/rbnacl/util.rb#111
|
|
2850
|
+
def check_string(string, length, description); end
|
|
2851
|
+
|
|
2852
|
+
# Check a passed string is it valid
|
|
2853
|
+
#
|
|
2854
|
+
# Raise an error if passed argument is invalid
|
|
2855
|
+
#
|
|
2856
|
+
# @param string [#to_str] The input string
|
|
2857
|
+
# @raise [TypeError] If string cannot convert to a string with #to_str
|
|
2858
|
+
# @raise [EncodingError] If string have wrong encoding
|
|
2859
|
+
#
|
|
2860
|
+
# source://rbnacl//lib/rbnacl/util.rb#162
|
|
2861
|
+
def check_string_validation(string); end
|
|
2862
|
+
|
|
2863
|
+
# Hex decodes a message
|
|
2864
|
+
#
|
|
2865
|
+
# @param hex [String] hex to decode.
|
|
2866
|
+
# @return [String] crisp and clean bytes
|
|
2867
|
+
#
|
|
2868
|
+
# source://rbnacl//lib/rbnacl/util.rb#286
|
|
2869
|
+
def hex2bin(hex); end
|
|
2870
|
+
|
|
2871
|
+
# Prepends a message with zeros
|
|
2872
|
+
#
|
|
2873
|
+
# Many functions require a string with some zeros prepended.
|
|
2874
|
+
#
|
|
2875
|
+
# @param n [Integer] The number of zeros to prepend
|
|
2876
|
+
# @param message [String] The string to be prepended
|
|
2877
|
+
# @return [String] a bunch of zeros
|
|
2878
|
+
#
|
|
2879
|
+
# source://rbnacl//lib/rbnacl/util.rb#37
|
|
2880
|
+
def prepend_zeros(n, message); end
|
|
2881
|
+
|
|
2882
|
+
# Remove zeros from the start of a message
|
|
2883
|
+
#
|
|
2884
|
+
# Many functions require a string with some zeros prepended, then need them removing after.
|
|
2885
|
+
# Note: this modifies the passed in string
|
|
2886
|
+
#
|
|
2887
|
+
# @param n [Integer] The number of zeros to remove
|
|
2888
|
+
# @param message [String] The string to be slice
|
|
2889
|
+
# @return [String] less a bunch of zeros
|
|
2890
|
+
#
|
|
2891
|
+
# source://rbnacl//lib/rbnacl/util.rb#50
|
|
2892
|
+
def remove_zeros(n, message); end
|
|
2893
|
+
|
|
2894
|
+
# Compare two 16 byte strings in constant time
|
|
2895
|
+
#
|
|
2896
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
2897
|
+
# application. Note that many of the functions (such as OneTime#verify)
|
|
2898
|
+
# use this method under the hood already.
|
|
2899
|
+
#
|
|
2900
|
+
# @param one [String] String #1
|
|
2901
|
+
# @param two [String] String #2
|
|
2902
|
+
# @return [Boolean] Well, are they equal?
|
|
2903
|
+
#
|
|
2904
|
+
# source://rbnacl//lib/rbnacl/util.rb#248
|
|
2905
|
+
def verify16(one, two); end
|
|
2906
|
+
|
|
2907
|
+
# Compare two 16 byte strings in constant time
|
|
2908
|
+
#
|
|
2909
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
2910
|
+
# application. Note that many of the functions (such as OneTime#verify)
|
|
2911
|
+
# use this method under the hood already.
|
|
2912
|
+
#
|
|
2913
|
+
# @param one [String] String #1
|
|
2914
|
+
# @param two [String] String #2
|
|
2915
|
+
# @raise [ArgumentError] If the strings are not equal in length
|
|
2916
|
+
# @return [Boolean] Well, are they equal?
|
|
2917
|
+
#
|
|
2918
|
+
# source://rbnacl//lib/rbnacl/util.rb#266
|
|
2919
|
+
def verify16!(one, two); end
|
|
2920
|
+
|
|
2921
|
+
# Compare two 32 byte strings in constant time
|
|
2922
|
+
#
|
|
2923
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
2924
|
+
# application. Note that many of the functions (such as HmacSha256#verify)
|
|
2925
|
+
# use this method under the hood already.
|
|
2926
|
+
#
|
|
2927
|
+
# @param one [String] String #1
|
|
2928
|
+
# @param two [String] String #2
|
|
2929
|
+
# @return [Boolean] Well, are they equal?
|
|
2930
|
+
#
|
|
2931
|
+
# source://rbnacl//lib/rbnacl/util.rb#214
|
|
2932
|
+
def verify32(one, two); end
|
|
2933
|
+
|
|
2934
|
+
# Compare two 32 byte strings in constant time
|
|
2935
|
+
#
|
|
2936
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
2937
|
+
# application. Note that many of the functions (such as HmacSha256#verify)
|
|
2938
|
+
# use this method under the hood already.
|
|
2939
|
+
#
|
|
2940
|
+
# @param one [String] String #1
|
|
2941
|
+
# @param two [String] String #2
|
|
2942
|
+
# @raise [ArgumentError] If the strings are not equal in length
|
|
2943
|
+
# @return [Boolean] Well, are they equal?
|
|
2944
|
+
#
|
|
2945
|
+
# source://rbnacl//lib/rbnacl/util.rb#232
|
|
2946
|
+
def verify32!(one, two); end
|
|
2947
|
+
|
|
2948
|
+
# Compare two 64 byte strings in constant time
|
|
2949
|
+
#
|
|
2950
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
2951
|
+
# application. Note that many of the functions (such as HmacSha512#verify)
|
|
2952
|
+
# use this method under the hood already.
|
|
2953
|
+
#
|
|
2954
|
+
# @param one [String] String #1
|
|
2955
|
+
# @param two [String] String #2
|
|
2956
|
+
# @return [Boolean] Well, are they equal?
|
|
2957
|
+
#
|
|
2958
|
+
# source://rbnacl//lib/rbnacl/util.rb#180
|
|
2959
|
+
def verify64(one, two); end
|
|
2960
|
+
|
|
2961
|
+
# Compare two 64 byte strings in constant time
|
|
2962
|
+
#
|
|
2963
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
2964
|
+
# application. Note that many of the functions (such as HmacSha512#verify)
|
|
2965
|
+
# use this method under the hood already.
|
|
2966
|
+
#
|
|
2967
|
+
# @param one [String] String #1
|
|
2968
|
+
# @param two [String] String #2
|
|
2969
|
+
# @raise [ArgumentError] If the strings are not equal in length
|
|
2970
|
+
# @return [Boolean] Well, are they equal?
|
|
2971
|
+
#
|
|
2972
|
+
# source://rbnacl//lib/rbnacl/util.rb#198
|
|
2973
|
+
def verify64!(one, two); end
|
|
2974
|
+
|
|
2975
|
+
# Pad a string out to n characters with zeros
|
|
2976
|
+
#
|
|
2977
|
+
# @param n [Integer] The length of the resulting string
|
|
2978
|
+
# @param message [String] the message to be padded
|
|
2979
|
+
# @raise [RbNaCl::LengthError] If the string is too long
|
|
2980
|
+
# @return [String] A string, n bytes long
|
|
2981
|
+
#
|
|
2982
|
+
# source://rbnacl//lib/rbnacl/util.rb#62
|
|
2983
|
+
def zero_pad(n, message); end
|
|
2984
|
+
|
|
2985
|
+
# Returns a string of n zeros
|
|
2986
|
+
#
|
|
2987
|
+
# Lots of the functions require us to create strings to pass into functions of a specified size.
|
|
2988
|
+
#
|
|
2989
|
+
# @param n [Integer] the size of the string to make
|
|
2990
|
+
# @return [String] A nice collection of zeros
|
|
2991
|
+
#
|
|
2992
|
+
# source://rbnacl//lib/rbnacl/util.rb#22
|
|
2993
|
+
def zeros(n = T.unsafe(nil)); end
|
|
2994
|
+
|
|
2995
|
+
class << self
|
|
2996
|
+
# Hex encodes a message
|
|
2997
|
+
#
|
|
2998
|
+
# @param bytes [String] The bytes to encode
|
|
2999
|
+
# @return [String] Tasty, tasty hexadecimal
|
|
3000
|
+
#
|
|
3001
|
+
# source://rbnacl//lib/rbnacl/util.rb#277
|
|
3002
|
+
def bin2hex(bytes); end
|
|
3003
|
+
|
|
3004
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
3005
|
+
def c_verify16(*args); end
|
|
3006
|
+
|
|
3007
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
3008
|
+
def c_verify32(*args); end
|
|
3009
|
+
|
|
3010
|
+
# source://rbnacl//lib/rbnacl/sodium.rb#50
|
|
3011
|
+
def c_verify64(*args); end
|
|
3012
|
+
|
|
3013
|
+
# Check a passed in string, convertion if necessary
|
|
3014
|
+
#
|
|
3015
|
+
# This method will check the key, and raise error
|
|
3016
|
+
# if argument is not a string, and if it's empty string.
|
|
3017
|
+
#
|
|
3018
|
+
# RFC 2104 HMAC
|
|
3019
|
+
# The key for HMAC can be of any length (keys longer than B bytes are
|
|
3020
|
+
# first hashed using H). However, less than L bytes is strongly
|
|
3021
|
+
# discouraged as it would decrease the security strength of the
|
|
3022
|
+
# function. Keys longer than L bytes are acceptable but the extra
|
|
3023
|
+
# length would not significantly increase the function strength. (A
|
|
3024
|
+
# longer key may be advisable if the randomness of the key is
|
|
3025
|
+
# considered weak.)
|
|
3026
|
+
#
|
|
3027
|
+
# see https://tools.ietf.org/html/rfc2104#section-3
|
|
3028
|
+
#
|
|
3029
|
+
# @param string [#to_str] The input string
|
|
3030
|
+
# @raise [ArgumentError] If we cannot convert to a string with #to_str
|
|
3031
|
+
# @raise [RbNaCl::LengthError] If the string is empty
|
|
3032
|
+
#
|
|
3033
|
+
# source://rbnacl//lib/rbnacl/util.rb#140
|
|
3034
|
+
def check_hmac_key(string, _description); end
|
|
3035
|
+
|
|
3036
|
+
# Check the length of the passed in string
|
|
3037
|
+
#
|
|
3038
|
+
# In several places through the codebase we have to be VERY strict with
|
|
3039
|
+
# what length of string we accept. This method supports that.
|
|
3040
|
+
#
|
|
3041
|
+
# @param string [String] The string to compare
|
|
3042
|
+
# @param length [Integer] The desired length
|
|
3043
|
+
# @param description [String] Description of the string (used in the error)
|
|
3044
|
+
# @raise [RbNaCl::LengthError] If the string is not the right length
|
|
3045
|
+
#
|
|
3046
|
+
# source://rbnacl//lib/rbnacl/util.rb#83
|
|
3047
|
+
def check_length(string, length, description); end
|
|
3048
|
+
|
|
3049
|
+
# Check a passed in string, converting the argument if necessary
|
|
3050
|
+
#
|
|
3051
|
+
# In several places through the codebase we have to be VERY strict with
|
|
3052
|
+
# the strings we accept. This method supports that.
|
|
3053
|
+
#
|
|
3054
|
+
# @param string [#to_str] The input string
|
|
3055
|
+
# @param length [Integer] The only acceptable length of the string
|
|
3056
|
+
# @param description [String] Description of the string (used in the error)
|
|
3057
|
+
# @raise [ArgumentError] If we cannot convert to a string with #to_str
|
|
3058
|
+
# @raise [RbNaCl::LengthError] If the string is not the right length
|
|
3059
|
+
#
|
|
3060
|
+
# source://rbnacl//lib/rbnacl/util.rb#111
|
|
3061
|
+
def check_string(string, length, description); end
|
|
3062
|
+
|
|
3063
|
+
# Check a passed string is it valid
|
|
3064
|
+
#
|
|
3065
|
+
# Raise an error if passed argument is invalid
|
|
3066
|
+
#
|
|
3067
|
+
# @param string [#to_str] The input string
|
|
3068
|
+
# @raise [TypeError] If string cannot convert to a string with #to_str
|
|
3069
|
+
# @raise [EncodingError] If string have wrong encoding
|
|
3070
|
+
#
|
|
3071
|
+
# source://rbnacl//lib/rbnacl/util.rb#162
|
|
3072
|
+
def check_string_validation(string); end
|
|
3073
|
+
|
|
3074
|
+
def crypto_verify_16(*_arg0); end
|
|
3075
|
+
def crypto_verify_32(*_arg0); end
|
|
3076
|
+
def crypto_verify_64(*_arg0); end
|
|
3077
|
+
|
|
3078
|
+
# Hex decodes a message
|
|
3079
|
+
#
|
|
3080
|
+
# @param hex [String] hex to decode.
|
|
3081
|
+
# @return [String] crisp and clean bytes
|
|
3082
|
+
#
|
|
3083
|
+
# source://rbnacl//lib/rbnacl/util.rb#286
|
|
3084
|
+
def hex2bin(hex); end
|
|
3085
|
+
|
|
3086
|
+
# Prepends a message with zeros
|
|
3087
|
+
#
|
|
3088
|
+
# Many functions require a string with some zeros prepended.
|
|
3089
|
+
#
|
|
3090
|
+
# @param n [Integer] The number of zeros to prepend
|
|
3091
|
+
# @param message [String] The string to be prepended
|
|
3092
|
+
# @return [String] a bunch of zeros
|
|
3093
|
+
#
|
|
3094
|
+
# source://rbnacl//lib/rbnacl/util.rb#37
|
|
3095
|
+
def prepend_zeros(n, message); end
|
|
3096
|
+
|
|
3097
|
+
# Remove zeros from the start of a message
|
|
3098
|
+
#
|
|
3099
|
+
# Many functions require a string with some zeros prepended, then need them removing after.
|
|
3100
|
+
# Note: this modifies the passed in string
|
|
3101
|
+
#
|
|
3102
|
+
# @param n [Integer] The number of zeros to remove
|
|
3103
|
+
# @param message [String] The string to be slice
|
|
3104
|
+
# @return [String] less a bunch of zeros
|
|
3105
|
+
#
|
|
3106
|
+
# source://rbnacl//lib/rbnacl/util.rb#50
|
|
3107
|
+
def remove_zeros(n, message); end
|
|
3108
|
+
|
|
3109
|
+
# Compare two 16 byte strings in constant time
|
|
3110
|
+
#
|
|
3111
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
3112
|
+
# application. Note that many of the functions (such as OneTime#verify)
|
|
3113
|
+
# use this method under the hood already.
|
|
3114
|
+
#
|
|
3115
|
+
# @param one [String] String #1
|
|
3116
|
+
# @param two [String] String #2
|
|
3117
|
+
# @return [Boolean] Well, are they equal?
|
|
3118
|
+
#
|
|
3119
|
+
# source://rbnacl//lib/rbnacl/util.rb#248
|
|
3120
|
+
def verify16(one, two); end
|
|
3121
|
+
|
|
3122
|
+
# Compare two 16 byte strings in constant time
|
|
3123
|
+
#
|
|
3124
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
3125
|
+
# application. Note that many of the functions (such as OneTime#verify)
|
|
3126
|
+
# use this method under the hood already.
|
|
3127
|
+
#
|
|
3128
|
+
# @param one [String] String #1
|
|
3129
|
+
# @param two [String] String #2
|
|
3130
|
+
# @raise [ArgumentError] If the strings are not equal in length
|
|
3131
|
+
# @return [Boolean] Well, are they equal?
|
|
3132
|
+
#
|
|
3133
|
+
# source://rbnacl//lib/rbnacl/util.rb#266
|
|
3134
|
+
def verify16!(one, two); end
|
|
3135
|
+
|
|
3136
|
+
# Compare two 32 byte strings in constant time
|
|
3137
|
+
#
|
|
3138
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
3139
|
+
# application. Note that many of the functions (such as HmacSha256#verify)
|
|
3140
|
+
# use this method under the hood already.
|
|
3141
|
+
#
|
|
3142
|
+
# @param one [String] String #1
|
|
3143
|
+
# @param two [String] String #2
|
|
3144
|
+
# @return [Boolean] Well, are they equal?
|
|
3145
|
+
#
|
|
3146
|
+
# source://rbnacl//lib/rbnacl/util.rb#214
|
|
3147
|
+
def verify32(one, two); end
|
|
3148
|
+
|
|
3149
|
+
# Compare two 32 byte strings in constant time
|
|
3150
|
+
#
|
|
3151
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
3152
|
+
# application. Note that many of the functions (such as HmacSha256#verify)
|
|
3153
|
+
# use this method under the hood already.
|
|
3154
|
+
#
|
|
3155
|
+
# @param one [String] String #1
|
|
3156
|
+
# @param two [String] String #2
|
|
3157
|
+
# @raise [ArgumentError] If the strings are not equal in length
|
|
3158
|
+
# @return [Boolean] Well, are they equal?
|
|
3159
|
+
#
|
|
3160
|
+
# source://rbnacl//lib/rbnacl/util.rb#232
|
|
3161
|
+
def verify32!(one, two); end
|
|
3162
|
+
|
|
3163
|
+
# Compare two 64 byte strings in constant time
|
|
3164
|
+
#
|
|
3165
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
3166
|
+
# application. Note that many of the functions (such as HmacSha512#verify)
|
|
3167
|
+
# use this method under the hood already.
|
|
3168
|
+
#
|
|
3169
|
+
# @param one [String] String #1
|
|
3170
|
+
# @param two [String] String #2
|
|
3171
|
+
# @return [Boolean] Well, are they equal?
|
|
3172
|
+
#
|
|
3173
|
+
# source://rbnacl//lib/rbnacl/util.rb#180
|
|
3174
|
+
def verify64(one, two); end
|
|
3175
|
+
|
|
3176
|
+
# Compare two 64 byte strings in constant time
|
|
3177
|
+
#
|
|
3178
|
+
# This should help to avoid timing attacks for string comparisons in your
|
|
3179
|
+
# application. Note that many of the functions (such as HmacSha512#verify)
|
|
3180
|
+
# use this method under the hood already.
|
|
3181
|
+
#
|
|
3182
|
+
# @param one [String] String #1
|
|
3183
|
+
# @param two [String] String #2
|
|
3184
|
+
# @raise [ArgumentError] If the strings are not equal in length
|
|
3185
|
+
# @return [Boolean] Well, are they equal?
|
|
3186
|
+
#
|
|
3187
|
+
# source://rbnacl//lib/rbnacl/util.rb#198
|
|
3188
|
+
def verify64!(one, two); end
|
|
3189
|
+
|
|
3190
|
+
# Pad a string out to n characters with zeros
|
|
3191
|
+
#
|
|
3192
|
+
# @param n [Integer] The length of the resulting string
|
|
3193
|
+
# @param message [String] the message to be padded
|
|
3194
|
+
# @raise [RbNaCl::LengthError] If the string is too long
|
|
3195
|
+
# @return [String] A string, n bytes long
|
|
3196
|
+
#
|
|
3197
|
+
# source://rbnacl//lib/rbnacl/util.rb#62
|
|
3198
|
+
def zero_pad(n, message); end
|
|
3199
|
+
|
|
3200
|
+
# Returns a string of n zeros
|
|
3201
|
+
#
|
|
3202
|
+
# Lots of the functions require us to create strings to pass into functions of a specified size.
|
|
3203
|
+
#
|
|
3204
|
+
# @param n [Integer] the size of the string to make
|
|
3205
|
+
# @return [String] A nice collection of zeros
|
|
3206
|
+
#
|
|
3207
|
+
# source://rbnacl//lib/rbnacl/util.rb#22
|
|
3208
|
+
def zeros(n = T.unsafe(nil)); end
|
|
3209
|
+
end
|
|
3210
|
+
end
|
|
3211
|
+
|
|
3212
|
+
# The library's version
|
|
3213
|
+
#
|
|
3214
|
+
# source://rbnacl//lib/rbnacl/version.rb#7
|
|
3215
|
+
RbNaCl::VERSION = T.let(T.unsafe(nil), String)
|
|
3216
|
+
|
|
3217
|
+
# source://rbnacl//lib/rbnacl.rb#102
|
|
3218
|
+
RbNaCl::VerifyKey = RbNaCl::Signatures::Ed25519::VerifyKey
|