tweetnacl 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +674 -0
- data/README.md +70 -0
- data/Rakefile +18 -0
- data/ext/tweetnacl/extconf.rb +2 -0
- data/ext/tweetnacl/randombytes.c +23 -0
- data/ext/tweetnacl/randombytes.h +4 -0
- data/ext/tweetnacl/rbext.c +92 -0
- data/ext/tweetnacl/tweetnacl.c +811 -0
- data/ext/tweetnacl/tweetnacl.h +272 -0
- data/test/test_helper.rb +9 -0
- data/test/tweetnacl_crypto_box_key_pair_test.rb +16 -0
- data/test/tweetnacl_crypto_box_open_test.rb +54 -0
- data/test/tweetnacl_crypto_box_test.rb +64 -0
- data/tweetnacl.gemspec +25 -0
- metadata +123 -0
@@ -0,0 +1,272 @@
|
|
1
|
+
#ifndef TWEETNACL_H
|
2
|
+
#define TWEETNACL_H
|
3
|
+
#define crypto_auth_PRIMITIVE "hmacsha512256"
|
4
|
+
#define crypto_auth crypto_auth_hmacsha512256
|
5
|
+
#define crypto_auth_verify crypto_auth_hmacsha512256_verify
|
6
|
+
#define crypto_auth_BYTES crypto_auth_hmacsha512256_BYTES
|
7
|
+
#define crypto_auth_KEYBYTES crypto_auth_hmacsha512256_KEYBYTES
|
8
|
+
#define crypto_auth_IMPLEMENTATION crypto_auth_hmacsha512256_IMPLEMENTATION
|
9
|
+
#define crypto_auth_VERSION crypto_auth_hmacsha512256_VERSION
|
10
|
+
#define crypto_auth_hmacsha512256_tweet_BYTES 32
|
11
|
+
#define crypto_auth_hmacsha512256_tweet_KEYBYTES 32
|
12
|
+
extern int crypto_auth_hmacsha512256_tweet(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
|
13
|
+
extern int crypto_auth_hmacsha512256_tweet_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
|
14
|
+
#define crypto_auth_hmacsha512256_tweet_VERSION "-"
|
15
|
+
#define crypto_auth_hmacsha512256 crypto_auth_hmacsha512256_tweet
|
16
|
+
#define crypto_auth_hmacsha512256_verify crypto_auth_hmacsha512256_tweet_verify
|
17
|
+
#define crypto_auth_hmacsha512256_BYTES crypto_auth_hmacsha512256_tweet_BYTES
|
18
|
+
#define crypto_auth_hmacsha512256_KEYBYTES crypto_auth_hmacsha512256_tweet_KEYBYTES
|
19
|
+
#define crypto_auth_hmacsha512256_VERSION crypto_auth_hmacsha512256_tweet_VERSION
|
20
|
+
#define crypto_auth_hmacsha512256_IMPLEMENTATION "crypto_auth/hmacsha512256/tweet"
|
21
|
+
#define crypto_box_PRIMITIVE "curve25519xsalsa20poly1305"
|
22
|
+
#define crypto_box crypto_box_curve25519xsalsa20poly1305
|
23
|
+
#define crypto_box_open crypto_box_curve25519xsalsa20poly1305_open
|
24
|
+
#define crypto_box_keypair crypto_box_curve25519xsalsa20poly1305_keypair
|
25
|
+
#define crypto_box_beforenm crypto_box_curve25519xsalsa20poly1305_beforenm
|
26
|
+
#define crypto_box_afternm crypto_box_curve25519xsalsa20poly1305_afternm
|
27
|
+
#define crypto_box_open_afternm crypto_box_curve25519xsalsa20poly1305_open_afternm
|
28
|
+
#define crypto_box_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES
|
29
|
+
#define crypto_box_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES
|
30
|
+
#define crypto_box_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES
|
31
|
+
#define crypto_box_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_NONCEBYTES
|
32
|
+
#define crypto_box_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ZEROBYTES
|
33
|
+
#define crypto_box_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES
|
34
|
+
#define crypto_box_IMPLEMENTATION crypto_box_curve25519xsalsa20poly1305_IMPLEMENTATION
|
35
|
+
#define crypto_box_VERSION crypto_box_curve25519xsalsa20poly1305_VERSION
|
36
|
+
#define crypto_box_curve25519xsalsa20poly1305_tweet_PUBLICKEYBYTES 32
|
37
|
+
#define crypto_box_curve25519xsalsa20poly1305_tweet_SECRETKEYBYTES 32
|
38
|
+
#define crypto_box_curve25519xsalsa20poly1305_tweet_BEFORENMBYTES 32
|
39
|
+
#define crypto_box_curve25519xsalsa20poly1305_tweet_NONCEBYTES 24
|
40
|
+
#define crypto_box_curve25519xsalsa20poly1305_tweet_ZEROBYTES 32
|
41
|
+
#define crypto_box_curve25519xsalsa20poly1305_tweet_BOXZEROBYTES 16
|
42
|
+
extern int crypto_box_curve25519xsalsa20poly1305_tweet(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *);
|
43
|
+
extern int crypto_box_curve25519xsalsa20poly1305_tweet_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *);
|
44
|
+
extern int crypto_box_curve25519xsalsa20poly1305_tweet_keypair(unsigned char *,unsigned char *);
|
45
|
+
extern int crypto_box_curve25519xsalsa20poly1305_tweet_beforenm(unsigned char *,const unsigned char *,const unsigned char *);
|
46
|
+
extern int crypto_box_curve25519xsalsa20poly1305_tweet_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
|
47
|
+
extern int crypto_box_curve25519xsalsa20poly1305_tweet_open_afternm(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
|
48
|
+
#define crypto_box_curve25519xsalsa20poly1305_tweet_VERSION "-"
|
49
|
+
#define crypto_box_curve25519xsalsa20poly1305 crypto_box_curve25519xsalsa20poly1305_tweet
|
50
|
+
#define crypto_box_curve25519xsalsa20poly1305_open crypto_box_curve25519xsalsa20poly1305_tweet_open
|
51
|
+
#define crypto_box_curve25519xsalsa20poly1305_keypair crypto_box_curve25519xsalsa20poly1305_tweet_keypair
|
52
|
+
#define crypto_box_curve25519xsalsa20poly1305_beforenm crypto_box_curve25519xsalsa20poly1305_tweet_beforenm
|
53
|
+
#define crypto_box_curve25519xsalsa20poly1305_afternm crypto_box_curve25519xsalsa20poly1305_tweet_afternm
|
54
|
+
#define crypto_box_curve25519xsalsa20poly1305_open_afternm crypto_box_curve25519xsalsa20poly1305_tweet_open_afternm
|
55
|
+
#define crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_tweet_PUBLICKEYBYTES
|
56
|
+
#define crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_tweet_SECRETKEYBYTES
|
57
|
+
#define crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_tweet_BEFORENMBYTES
|
58
|
+
#define crypto_box_curve25519xsalsa20poly1305_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_tweet_NONCEBYTES
|
59
|
+
#define crypto_box_curve25519xsalsa20poly1305_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_tweet_ZEROBYTES
|
60
|
+
#define crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_tweet_BOXZEROBYTES
|
61
|
+
#define crypto_box_curve25519xsalsa20poly1305_VERSION crypto_box_curve25519xsalsa20poly1305_tweet_VERSION
|
62
|
+
#define crypto_box_curve25519xsalsa20poly1305_IMPLEMENTATION "crypto_box/curve25519xsalsa20poly1305/tweet"
|
63
|
+
#define crypto_core_PRIMITIVE "salsa20"
|
64
|
+
#define crypto_core crypto_core_salsa20
|
65
|
+
#define crypto_core_OUTPUTBYTES crypto_core_salsa20_OUTPUTBYTES
|
66
|
+
#define crypto_core_INPUTBYTES crypto_core_salsa20_INPUTBYTES
|
67
|
+
#define crypto_core_KEYBYTES crypto_core_salsa20_KEYBYTES
|
68
|
+
#define crypto_core_CONSTBYTES crypto_core_salsa20_CONSTBYTES
|
69
|
+
#define crypto_core_IMPLEMENTATION crypto_core_salsa20_IMPLEMENTATION
|
70
|
+
#define crypto_core_VERSION crypto_core_salsa20_VERSION
|
71
|
+
#define crypto_core_salsa20_tweet_OUTPUTBYTES 64
|
72
|
+
#define crypto_core_salsa20_tweet_INPUTBYTES 16
|
73
|
+
#define crypto_core_salsa20_tweet_KEYBYTES 32
|
74
|
+
#define crypto_core_salsa20_tweet_CONSTBYTES 16
|
75
|
+
extern int crypto_core_salsa20_tweet(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *);
|
76
|
+
#define crypto_core_salsa20_tweet_VERSION "-"
|
77
|
+
#define crypto_core_salsa20 crypto_core_salsa20_tweet
|
78
|
+
#define crypto_core_salsa20_OUTPUTBYTES crypto_core_salsa20_tweet_OUTPUTBYTES
|
79
|
+
#define crypto_core_salsa20_INPUTBYTES crypto_core_salsa20_tweet_INPUTBYTES
|
80
|
+
#define crypto_core_salsa20_KEYBYTES crypto_core_salsa20_tweet_KEYBYTES
|
81
|
+
#define crypto_core_salsa20_CONSTBYTES crypto_core_salsa20_tweet_CONSTBYTES
|
82
|
+
#define crypto_core_salsa20_VERSION crypto_core_salsa20_tweet_VERSION
|
83
|
+
#define crypto_core_salsa20_IMPLEMENTATION "crypto_core/salsa20/tweet"
|
84
|
+
#define crypto_core_hsalsa20_tweet_OUTPUTBYTES 32
|
85
|
+
#define crypto_core_hsalsa20_tweet_INPUTBYTES 16
|
86
|
+
#define crypto_core_hsalsa20_tweet_KEYBYTES 32
|
87
|
+
#define crypto_core_hsalsa20_tweet_CONSTBYTES 16
|
88
|
+
extern int crypto_core_hsalsa20_tweet(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *);
|
89
|
+
#define crypto_core_hsalsa20_tweet_VERSION "-"
|
90
|
+
#define crypto_core_hsalsa20 crypto_core_hsalsa20_tweet
|
91
|
+
#define crypto_core_hsalsa20_OUTPUTBYTES crypto_core_hsalsa20_tweet_OUTPUTBYTES
|
92
|
+
#define crypto_core_hsalsa20_INPUTBYTES crypto_core_hsalsa20_tweet_INPUTBYTES
|
93
|
+
#define crypto_core_hsalsa20_KEYBYTES crypto_core_hsalsa20_tweet_KEYBYTES
|
94
|
+
#define crypto_core_hsalsa20_CONSTBYTES crypto_core_hsalsa20_tweet_CONSTBYTES
|
95
|
+
#define crypto_core_hsalsa20_VERSION crypto_core_hsalsa20_tweet_VERSION
|
96
|
+
#define crypto_core_hsalsa20_IMPLEMENTATION "crypto_core/hsalsa20/tweet"
|
97
|
+
#define crypto_hashblocks_PRIMITIVE "sha512"
|
98
|
+
#define crypto_hashblocks crypto_hashblocks_sha512
|
99
|
+
#define crypto_hashblocks_STATEBYTES crypto_hashblocks_sha512_STATEBYTES
|
100
|
+
#define crypto_hashblocks_BLOCKBYTES crypto_hashblocks_sha512_BLOCKBYTES
|
101
|
+
#define crypto_hashblocks_IMPLEMENTATION crypto_hashblocks_sha512_IMPLEMENTATION
|
102
|
+
#define crypto_hashblocks_VERSION crypto_hashblocks_sha512_VERSION
|
103
|
+
#define crypto_hashblocks_sha512_tweet_STATEBYTES 64
|
104
|
+
#define crypto_hashblocks_sha512_tweet_BLOCKBYTES 128
|
105
|
+
extern int crypto_hashblocks_sha512_tweet(unsigned char *,const unsigned char *,unsigned long long);
|
106
|
+
#define crypto_hashblocks_sha512_tweet_VERSION "-"
|
107
|
+
#define crypto_hashblocks_sha512 crypto_hashblocks_sha512_tweet
|
108
|
+
#define crypto_hashblocks_sha512_STATEBYTES crypto_hashblocks_sha512_tweet_STATEBYTES
|
109
|
+
#define crypto_hashblocks_sha512_BLOCKBYTES crypto_hashblocks_sha512_tweet_BLOCKBYTES
|
110
|
+
#define crypto_hashblocks_sha512_VERSION crypto_hashblocks_sha512_tweet_VERSION
|
111
|
+
#define crypto_hashblocks_sha512_IMPLEMENTATION "crypto_hashblocks/sha512/tweet"
|
112
|
+
#define crypto_hashblocks_sha256_tweet_STATEBYTES 32
|
113
|
+
#define crypto_hashblocks_sha256_tweet_BLOCKBYTES 64
|
114
|
+
extern int crypto_hashblocks_sha256_tweet(unsigned char *,const unsigned char *,unsigned long long);
|
115
|
+
#define crypto_hashblocks_sha256_tweet_VERSION "-"
|
116
|
+
#define crypto_hashblocks_sha256 crypto_hashblocks_sha256_tweet
|
117
|
+
#define crypto_hashblocks_sha256_STATEBYTES crypto_hashblocks_sha256_tweet_STATEBYTES
|
118
|
+
#define crypto_hashblocks_sha256_BLOCKBYTES crypto_hashblocks_sha256_tweet_BLOCKBYTES
|
119
|
+
#define crypto_hashblocks_sha256_VERSION crypto_hashblocks_sha256_tweet_VERSION
|
120
|
+
#define crypto_hashblocks_sha256_IMPLEMENTATION "crypto_hashblocks/sha256/tweet"
|
121
|
+
#define crypto_hash_PRIMITIVE "sha512"
|
122
|
+
#define crypto_hash crypto_hash_sha512
|
123
|
+
#define crypto_hash_BYTES crypto_hash_sha512_BYTES
|
124
|
+
#define crypto_hash_IMPLEMENTATION crypto_hash_sha512_IMPLEMENTATION
|
125
|
+
#define crypto_hash_VERSION crypto_hash_sha512_VERSION
|
126
|
+
#define crypto_hash_sha512_tweet_BYTES 64
|
127
|
+
extern int crypto_hash_sha512_tweet(unsigned char *,const unsigned char *,unsigned long long);
|
128
|
+
#define crypto_hash_sha512_tweet_VERSION "-"
|
129
|
+
#define crypto_hash_sha512 crypto_hash_sha512_tweet
|
130
|
+
#define crypto_hash_sha512_BYTES crypto_hash_sha512_tweet_BYTES
|
131
|
+
#define crypto_hash_sha512_VERSION crypto_hash_sha512_tweet_VERSION
|
132
|
+
#define crypto_hash_sha512_IMPLEMENTATION "crypto_hash/sha512/tweet"
|
133
|
+
#define crypto_hash_sha256_tweet_BYTES 32
|
134
|
+
extern int crypto_hash_sha256_tweet(unsigned char *,const unsigned char *,unsigned long long);
|
135
|
+
#define crypto_hash_sha256_tweet_VERSION "-"
|
136
|
+
#define crypto_hash_sha256 crypto_hash_sha256_tweet
|
137
|
+
#define crypto_hash_sha256_BYTES crypto_hash_sha256_tweet_BYTES
|
138
|
+
#define crypto_hash_sha256_VERSION crypto_hash_sha256_tweet_VERSION
|
139
|
+
#define crypto_hash_sha256_IMPLEMENTATION "crypto_hash/sha256/tweet"
|
140
|
+
#define crypto_onetimeauth_PRIMITIVE "poly1305"
|
141
|
+
#define crypto_onetimeauth crypto_onetimeauth_poly1305
|
142
|
+
#define crypto_onetimeauth_verify crypto_onetimeauth_poly1305_verify
|
143
|
+
#define crypto_onetimeauth_BYTES crypto_onetimeauth_poly1305_BYTES
|
144
|
+
#define crypto_onetimeauth_KEYBYTES crypto_onetimeauth_poly1305_KEYBYTES
|
145
|
+
#define crypto_onetimeauth_IMPLEMENTATION crypto_onetimeauth_poly1305_IMPLEMENTATION
|
146
|
+
#define crypto_onetimeauth_VERSION crypto_onetimeauth_poly1305_VERSION
|
147
|
+
#define crypto_onetimeauth_poly1305_tweet_BYTES 16
|
148
|
+
#define crypto_onetimeauth_poly1305_tweet_KEYBYTES 32
|
149
|
+
extern int crypto_onetimeauth_poly1305_tweet(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
|
150
|
+
extern int crypto_onetimeauth_poly1305_tweet_verify(const unsigned char *,const unsigned char *,unsigned long long,const unsigned char *);
|
151
|
+
#define crypto_onetimeauth_poly1305_tweet_VERSION "-"
|
152
|
+
#define crypto_onetimeauth_poly1305 crypto_onetimeauth_poly1305_tweet
|
153
|
+
#define crypto_onetimeauth_poly1305_verify crypto_onetimeauth_poly1305_tweet_verify
|
154
|
+
#define crypto_onetimeauth_poly1305_BYTES crypto_onetimeauth_poly1305_tweet_BYTES
|
155
|
+
#define crypto_onetimeauth_poly1305_KEYBYTES crypto_onetimeauth_poly1305_tweet_KEYBYTES
|
156
|
+
#define crypto_onetimeauth_poly1305_VERSION crypto_onetimeauth_poly1305_tweet_VERSION
|
157
|
+
#define crypto_onetimeauth_poly1305_IMPLEMENTATION "crypto_onetimeauth/poly1305/tweet"
|
158
|
+
#define crypto_scalarmult_PRIMITIVE "curve25519"
|
159
|
+
#define crypto_scalarmult crypto_scalarmult_curve25519
|
160
|
+
#define crypto_scalarmult_base crypto_scalarmult_curve25519_base
|
161
|
+
#define crypto_scalarmult_BYTES crypto_scalarmult_curve25519_BYTES
|
162
|
+
#define crypto_scalarmult_SCALARBYTES crypto_scalarmult_curve25519_SCALARBYTES
|
163
|
+
#define crypto_scalarmult_IMPLEMENTATION crypto_scalarmult_curve25519_IMPLEMENTATION
|
164
|
+
#define crypto_scalarmult_VERSION crypto_scalarmult_curve25519_VERSION
|
165
|
+
#define crypto_scalarmult_curve25519_tweet_BYTES 32
|
166
|
+
#define crypto_scalarmult_curve25519_tweet_SCALARBYTES 32
|
167
|
+
extern int crypto_scalarmult_curve25519_tweet(unsigned char *,const unsigned char *,const unsigned char *);
|
168
|
+
extern int crypto_scalarmult_curve25519_tweet_base(unsigned char *,const unsigned char *);
|
169
|
+
#define crypto_scalarmult_curve25519_tweet_VERSION "-"
|
170
|
+
#define crypto_scalarmult_curve25519 crypto_scalarmult_curve25519_tweet
|
171
|
+
#define crypto_scalarmult_curve25519_base crypto_scalarmult_curve25519_tweet_base
|
172
|
+
#define crypto_scalarmult_curve25519_BYTES crypto_scalarmult_curve25519_tweet_BYTES
|
173
|
+
#define crypto_scalarmult_curve25519_SCALARBYTES crypto_scalarmult_curve25519_tweet_SCALARBYTES
|
174
|
+
#define crypto_scalarmult_curve25519_VERSION crypto_scalarmult_curve25519_tweet_VERSION
|
175
|
+
#define crypto_scalarmult_curve25519_IMPLEMENTATION "crypto_scalarmult/curve25519/tweet"
|
176
|
+
#define crypto_secretbox_PRIMITIVE "xsalsa20poly1305"
|
177
|
+
#define crypto_secretbox crypto_secretbox_xsalsa20poly1305
|
178
|
+
#define crypto_secretbox_open crypto_secretbox_xsalsa20poly1305_open
|
179
|
+
#define crypto_secretbox_KEYBYTES crypto_secretbox_xsalsa20poly1305_KEYBYTES
|
180
|
+
#define crypto_secretbox_NONCEBYTES crypto_secretbox_xsalsa20poly1305_NONCEBYTES
|
181
|
+
#define crypto_secretbox_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ZEROBYTES
|
182
|
+
#define crypto_secretbox_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES
|
183
|
+
#define crypto_secretbox_IMPLEMENTATION crypto_secretbox_xsalsa20poly1305_IMPLEMENTATION
|
184
|
+
#define crypto_secretbox_VERSION crypto_secretbox_xsalsa20poly1305_VERSION
|
185
|
+
#define crypto_secretbox_xsalsa20poly1305_tweet_KEYBYTES 32
|
186
|
+
#define crypto_secretbox_xsalsa20poly1305_tweet_NONCEBYTES 24
|
187
|
+
#define crypto_secretbox_xsalsa20poly1305_tweet_ZEROBYTES 32
|
188
|
+
#define crypto_secretbox_xsalsa20poly1305_tweet_BOXZEROBYTES 16
|
189
|
+
extern int crypto_secretbox_xsalsa20poly1305_tweet(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
|
190
|
+
extern int crypto_secretbox_xsalsa20poly1305_tweet_open(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
|
191
|
+
#define crypto_secretbox_xsalsa20poly1305_tweet_VERSION "-"
|
192
|
+
#define crypto_secretbox_xsalsa20poly1305 crypto_secretbox_xsalsa20poly1305_tweet
|
193
|
+
#define crypto_secretbox_xsalsa20poly1305_open crypto_secretbox_xsalsa20poly1305_tweet_open
|
194
|
+
#define crypto_secretbox_xsalsa20poly1305_KEYBYTES crypto_secretbox_xsalsa20poly1305_tweet_KEYBYTES
|
195
|
+
#define crypto_secretbox_xsalsa20poly1305_NONCEBYTES crypto_secretbox_xsalsa20poly1305_tweet_NONCEBYTES
|
196
|
+
#define crypto_secretbox_xsalsa20poly1305_ZEROBYTES crypto_secretbox_xsalsa20poly1305_tweet_ZEROBYTES
|
197
|
+
#define crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_tweet_BOXZEROBYTES
|
198
|
+
#define crypto_secretbox_xsalsa20poly1305_VERSION crypto_secretbox_xsalsa20poly1305_tweet_VERSION
|
199
|
+
#define crypto_secretbox_xsalsa20poly1305_IMPLEMENTATION "crypto_secretbox/xsalsa20poly1305/tweet"
|
200
|
+
#define crypto_sign_PRIMITIVE "ed25519"
|
201
|
+
#define crypto_sign crypto_sign_ed25519
|
202
|
+
#define crypto_sign_open crypto_sign_ed25519_open
|
203
|
+
#define crypto_sign_keypair crypto_sign_ed25519_keypair
|
204
|
+
#define crypto_sign_BYTES crypto_sign_ed25519_BYTES
|
205
|
+
#define crypto_sign_PUBLICKEYBYTES crypto_sign_ed25519_PUBLICKEYBYTES
|
206
|
+
#define crypto_sign_SECRETKEYBYTES crypto_sign_ed25519_SECRETKEYBYTES
|
207
|
+
#define crypto_sign_IMPLEMENTATION crypto_sign_ed25519_IMPLEMENTATION
|
208
|
+
#define crypto_sign_VERSION crypto_sign_ed25519_VERSION
|
209
|
+
#define crypto_sign_ed25519_tweet_BYTES 64
|
210
|
+
#define crypto_sign_ed25519_tweet_PUBLICKEYBYTES 32
|
211
|
+
#define crypto_sign_ed25519_tweet_SECRETKEYBYTES 64
|
212
|
+
extern int crypto_sign_ed25519_tweet(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
|
213
|
+
extern int crypto_sign_ed25519_tweet_open(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *);
|
214
|
+
extern int crypto_sign_ed25519_tweet_keypair(unsigned char *,unsigned char *);
|
215
|
+
#define crypto_sign_ed25519_tweet_VERSION "-"
|
216
|
+
#define crypto_sign_ed25519 crypto_sign_ed25519_tweet
|
217
|
+
#define crypto_sign_ed25519_open crypto_sign_ed25519_tweet_open
|
218
|
+
#define crypto_sign_ed25519_keypair crypto_sign_ed25519_tweet_keypair
|
219
|
+
#define crypto_sign_ed25519_BYTES crypto_sign_ed25519_tweet_BYTES
|
220
|
+
#define crypto_sign_ed25519_PUBLICKEYBYTES crypto_sign_ed25519_tweet_PUBLICKEYBYTES
|
221
|
+
#define crypto_sign_ed25519_SECRETKEYBYTES crypto_sign_ed25519_tweet_SECRETKEYBYTES
|
222
|
+
#define crypto_sign_ed25519_VERSION crypto_sign_ed25519_tweet_VERSION
|
223
|
+
#define crypto_sign_ed25519_IMPLEMENTATION "crypto_sign/ed25519/tweet"
|
224
|
+
#define crypto_stream_PRIMITIVE "xsalsa20"
|
225
|
+
#define crypto_stream crypto_stream_xsalsa20
|
226
|
+
#define crypto_stream_xor crypto_stream_xsalsa20_xor
|
227
|
+
#define crypto_stream_KEYBYTES crypto_stream_xsalsa20_KEYBYTES
|
228
|
+
#define crypto_stream_NONCEBYTES crypto_stream_xsalsa20_NONCEBYTES
|
229
|
+
#define crypto_stream_IMPLEMENTATION crypto_stream_xsalsa20_IMPLEMENTATION
|
230
|
+
#define crypto_stream_VERSION crypto_stream_xsalsa20_VERSION
|
231
|
+
#define crypto_stream_xsalsa20_tweet_KEYBYTES 32
|
232
|
+
#define crypto_stream_xsalsa20_tweet_NONCEBYTES 24
|
233
|
+
extern int crypto_stream_xsalsa20_tweet(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
|
234
|
+
extern int crypto_stream_xsalsa20_tweet_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
|
235
|
+
#define crypto_stream_xsalsa20_tweet_VERSION "-"
|
236
|
+
#define crypto_stream_xsalsa20 crypto_stream_xsalsa20_tweet
|
237
|
+
#define crypto_stream_xsalsa20_xor crypto_stream_xsalsa20_tweet_xor
|
238
|
+
#define crypto_stream_xsalsa20_KEYBYTES crypto_stream_xsalsa20_tweet_KEYBYTES
|
239
|
+
#define crypto_stream_xsalsa20_NONCEBYTES crypto_stream_xsalsa20_tweet_NONCEBYTES
|
240
|
+
#define crypto_stream_xsalsa20_VERSION crypto_stream_xsalsa20_tweet_VERSION
|
241
|
+
#define crypto_stream_xsalsa20_IMPLEMENTATION "crypto_stream/xsalsa20/tweet"
|
242
|
+
#define crypto_stream_salsa20_tweet_KEYBYTES 32
|
243
|
+
#define crypto_stream_salsa20_tweet_NONCEBYTES 8
|
244
|
+
extern int crypto_stream_salsa20_tweet(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
|
245
|
+
extern int crypto_stream_salsa20_tweet_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
|
246
|
+
#define crypto_stream_salsa20_tweet_VERSION "-"
|
247
|
+
#define crypto_stream_salsa20 crypto_stream_salsa20_tweet
|
248
|
+
#define crypto_stream_salsa20_xor crypto_stream_salsa20_tweet_xor
|
249
|
+
#define crypto_stream_salsa20_KEYBYTES crypto_stream_salsa20_tweet_KEYBYTES
|
250
|
+
#define crypto_stream_salsa20_NONCEBYTES crypto_stream_salsa20_tweet_NONCEBYTES
|
251
|
+
#define crypto_stream_salsa20_VERSION crypto_stream_salsa20_tweet_VERSION
|
252
|
+
#define crypto_stream_salsa20_IMPLEMENTATION "crypto_stream/salsa20/tweet"
|
253
|
+
#define crypto_verify_PRIMITIVE "16"
|
254
|
+
#define crypto_verify crypto_verify_16
|
255
|
+
#define crypto_verify_BYTES crypto_verify_16_BYTES
|
256
|
+
#define crypto_verify_IMPLEMENTATION crypto_verify_16_IMPLEMENTATION
|
257
|
+
#define crypto_verify_VERSION crypto_verify_16_VERSION
|
258
|
+
#define crypto_verify_16_tweet_BYTES 16
|
259
|
+
extern int crypto_verify_16_tweet(const unsigned char *,const unsigned char *);
|
260
|
+
#define crypto_verify_16_tweet_VERSION "-"
|
261
|
+
#define crypto_verify_16 crypto_verify_16_tweet
|
262
|
+
#define crypto_verify_16_BYTES crypto_verify_16_tweet_BYTES
|
263
|
+
#define crypto_verify_16_VERSION crypto_verify_16_tweet_VERSION
|
264
|
+
#define crypto_verify_16_IMPLEMENTATION "crypto_verify/16/tweet"
|
265
|
+
#define crypto_verify_32_tweet_BYTES 32
|
266
|
+
extern int crypto_verify_32_tweet(const unsigned char *,const unsigned char *);
|
267
|
+
#define crypto_verify_32_tweet_VERSION "-"
|
268
|
+
#define crypto_verify_32 crypto_verify_32_tweet
|
269
|
+
#define crypto_verify_32_BYTES crypto_verify_32_tweet_BYTES
|
270
|
+
#define crypto_verify_32_VERSION crypto_verify_32_tweet_VERSION
|
271
|
+
#define crypto_verify_32_IMPLEMENTATION "crypto_verify/32/tweet"
|
272
|
+
#endif
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TweetNaClCryptoBoxKeyPairTest < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
@t = TweetNaCl.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown; end
|
9
|
+
|
10
|
+
def test_generate_a_keypair
|
11
|
+
pk, sk = @t.crypto_box_keypair
|
12
|
+
|
13
|
+
assert_equal 32, pk.length
|
14
|
+
assert_equal 32, sk.length
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TweetNaClCryptoBoxOpenTest < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
@t = TweetNaCl.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown; end
|
9
|
+
|
10
|
+
def test_foo
|
11
|
+
assert true
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def test_crypto_box_open_require_cipher_to_decrypt
|
16
|
+
set = false
|
17
|
+
begin
|
18
|
+
@t.crypto_box_open(nil, nil, nil, nil)
|
19
|
+
rescue Exception => e
|
20
|
+
set = true
|
21
|
+
end
|
22
|
+
assert set, "A cipher is required"
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_crypto_box_open_require_public_key
|
26
|
+
set = false
|
27
|
+
begin
|
28
|
+
@t.crypto_box_open("foo", nil, "foo", nil)
|
29
|
+
rescue ArgumentError => e
|
30
|
+
set = true
|
31
|
+
end
|
32
|
+
assert set, "A public key is required"
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_crypto_box_open_require_secret_key
|
36
|
+
set = false
|
37
|
+
begin
|
38
|
+
@t.crypto_box_open("foo", "foo", "foo", nil)
|
39
|
+
rescue ArgumentError => e
|
40
|
+
set = true
|
41
|
+
end
|
42
|
+
assert set, "A secret key is required"
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_crypto_box_open_nonce_not_correct_length
|
46
|
+
set = false
|
47
|
+
begin
|
48
|
+
@t.crypto_box("foo", "bar", "pk", "sk")
|
49
|
+
rescue ArgumentError => e
|
50
|
+
set = true
|
51
|
+
end
|
52
|
+
assert set, "Incorrect nonce length should have raised ArgumentError"
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TweetNaClCryptoBoxTest < MiniTest::Test
|
4
|
+
def setup
|
5
|
+
@t = TweetNaCl.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def teardown; end
|
9
|
+
|
10
|
+
def test_crypto_box
|
11
|
+
input = "hello world"
|
12
|
+
nonce = "*" * 24
|
13
|
+
expected_cipher = "0000000000000000FBC937C3F136E09FA8A45C58C15E801394F5BB74CE8D538FE3D726"
|
14
|
+
pk = "\x60\xF0\x23\x07\xDF\xB6\x8B\xBB\x15\xE2\x92\x59\x05\x1B\x2D\xF8\xC8\x59\xDB\x5B\xDE\x97\xFA\xE8\x9B\x5F\xE5\x62\x63\x11\xD6\x56"
|
15
|
+
sk = "\xBE\x38\x7C\x59\xD1\x81\x0B\xCC\x8E\xD8\x90\xDB\x3D\xF9\x80\x63\x9E\xD2\x54\x44\xFB\x4D\xD1\x92\xB6\xC6\x75\x53\xF9\x76\x9F\xCF"
|
16
|
+
|
17
|
+
cipher = @t.crypto_box(input, nonce, pk, sk)
|
18
|
+
|
19
|
+
output = @t.crypto_box_open(cipher, nonce, pk, sk)
|
20
|
+
|
21
|
+
assert_equal input, output
|
22
|
+
assert_equal expected_cipher, cipher.hd
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_crypto_box_require_message_to_cipher
|
26
|
+
set = false
|
27
|
+
begin
|
28
|
+
@t.crypto_box(nil, "bar", "pk", "sk")
|
29
|
+
rescue ArgumentError => e
|
30
|
+
set = true
|
31
|
+
end
|
32
|
+
assert set, "A message is required"
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_crypto_box_require_public_key
|
36
|
+
set = false
|
37
|
+
begin
|
38
|
+
@t.crypto_box("foo", "bar", nil, "sk")
|
39
|
+
rescue ArgumentError => e
|
40
|
+
set = true
|
41
|
+
end
|
42
|
+
assert set, "A public key is required"
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_crypto_box_require_secret_key
|
46
|
+
set = false
|
47
|
+
begin
|
48
|
+
@t.crypto_box("foo", "bar", "pk", nil)
|
49
|
+
rescue ArgumentError => e
|
50
|
+
set = true
|
51
|
+
end
|
52
|
+
assert set, "A secret key is required"
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_crypto_box_nonce_not_correct_length
|
56
|
+
set = false
|
57
|
+
begin
|
58
|
+
@t.crypto_box("foo", "bar", "pk", "sk")
|
59
|
+
rescue ArgumentError => e
|
60
|
+
set = true
|
61
|
+
end
|
62
|
+
assert set, "Incorrect nonce length should have raised ArgumentError"
|
63
|
+
end
|
64
|
+
end
|
data/tweetnacl.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$:<< 'lib'
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "tweetnacl"
|
5
|
+
spec.version = "0.0.1"
|
6
|
+
spec.authors = ["Franck Verrot"]
|
7
|
+
spec.email = ["franck@verrot.fr"]
|
8
|
+
spec.homepage = "https://github.com/franckverrot/clamav-client"
|
9
|
+
spec.license = "GPLv3"
|
10
|
+
|
11
|
+
spec.summary = "TweetNaCl for Ruby"
|
12
|
+
spec.description = "TweetNaCl is a C-extension built on top of the official TweetNaCl distribution"
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
14
|
+
|
15
|
+
spec.extensions << "ext/tweetnacl/extconf.rb"
|
16
|
+
|
17
|
+
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "rake-compiler"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "minitest"
|
25
|
+
end
|