@@ -20,7 +20,7 @@ fn bcrypt_hash(hpass: &[u8], hsalt: &[u8], output: &mut [u8, ..32]) {
20
20
}
21
21
22
22
let mut buf = [ 0u32 , ..8 ] ;
23
- read_u32v_be( buf, bytes ! ( "OxychromaticBlowfishSwatDynamite" ) ) ;
23
+ read_u32v_be( buf, b "OxychromaticBlowfishSwatDynamite") ;
24
24
25
25
for i in range_step( 0 u, 8 , 2 ) {
26
26
for _ in range( 0 , 64 ) {
@@ -166,76 +166,76 @@ mod test {
166
166
#[ test]
167
167
fn test_openbsd_vectors ( ) {
168
168
struct Test {
169
- password : & ' static [ u8 ] ,
170
- salt : & ' static [ u8 ] ,
169
+ password : Vec < u8 > ,
170
+ salt : Vec < u8 > ,
171
171
rounds : uint ,
172
- out : & ' static [ u8 ] ,
172
+ out : Vec < u8 > ,
173
173
}
174
174
175
175
let tests = vec ! (
176
176
Test {
177
- password: bytes! ( "password" ) ,
178
- salt: bytes! ( "salt" ) ,
177
+ password: Vec :: from_slice ( b "password") ,
178
+ salt: Vec :: from_slice ( b "salt") ,
179
179
rounds: 4 ,
180
- out: bytes! (
180
+ out: vec! [
181
181
0x5b , 0xbf , 0x0c , 0xc2 , 0x93 , 0x58 , 0x7f , 0x1c , 0x36 , 0x35 , 0x55 , 0x5c , 0x27 , 0x79 , 0x65 , 0x98 ,
182
- 0xd4 , 0x7e , 0x57 , 0x90 , 0x71 , 0xbf , 0x42 , 0x7e , 0x9d , 0x8f , 0xbe , 0x84 , 0x2a , 0xba , 0x34 , 0xd9 ) ,
182
+ 0xd4 , 0x7e , 0x57 , 0x90 , 0x71 , 0xbf , 0x42 , 0x7e , 0x9d , 0x8f , 0xbe , 0x84 , 0x2a , 0xba , 0x34 , 0xd9 ] ,
183
183
} , Test {
184
- password: bytes! ( "password" ) ,
185
- salt: bytes! { 0 } ,
184
+ password: Vec :: from_slice ( b "password") ,
185
+ salt: vec! [ 0 ] ,
186
186
rounds: 4 ,
187
- out: bytes! ( 0xc1 , 0x2b , 0x56 , 0x62 , 0x35 , 0xee , 0xe0 , 0x4c , 0x21 , 0x25 , 0x98 , 0x97 , 0x0a , 0x57 , 0x9a , 0x67 ) ,
187
+ out: vec! [ 0xc1 , 0x2b , 0x56 , 0x62 , 0x35 , 0xee , 0xe0 , 0x4c , 0x21 , 0x25 , 0x98 , 0x97 , 0x0a , 0x57 , 0x9a , 0x67 ] ,
188
188
} , Test {
189
- password: bytes! { 0 } ,
190
- salt: bytes! ( "salt" ) ,
189
+ password: vec! [ 0 ] ,
190
+ salt: Vec :: from_slice ( b "salt") ,
191
191
rounds: 4 ,
192
- out: bytes! ( 0x60 , 0x51 , 0xbe , 0x18 , 0xc2 , 0xf4 , 0xf8 , 0x2c , 0xbf , 0x0e , 0xfe , 0xe5 , 0x47 , 0x1b , 0x4b , 0xb9 ) ,
192
+ out: vec! [ 0x60 , 0x51 , 0xbe , 0x18 , 0xc2 , 0xf4 , 0xf8 , 0x2c , 0xbf , 0x0e , 0xfe , 0xe5 , 0x47 , 0x1b , 0x4b , 0xb9 ] ,
193
193
} , Test {
194
- password: bytes! ( "password\x00 " ) ,
195
- salt: bytes! ( "salt\x00 " ) ,
194
+ password: Vec :: from_slice ( b "password\x00 ") ,
195
+ salt: Vec :: from_slice ( b "salt\x00 ") ,
196
196
rounds: 4 ,
197
- out: bytes! (
197
+ out: vec! [
198
198
0x74 , 0x10 , 0xe4 , 0x4c , 0xf4 , 0xfa , 0x07 , 0xbf , 0xaa , 0xc8 , 0xa9 , 0x28 , 0xb1 , 0x72 , 0x7f , 0xac ,
199
- 0x00 , 0x13 , 0x75 , 0xe7 , 0xbf , 0x73 , 0x84 , 0x37 , 0x0f , 0x48 , 0xef , 0xd1 , 0x21 , 0x74 , 0x30 , 0x50 ) ,
199
+ 0x00 , 0x13 , 0x75 , 0xe7 , 0xbf , 0x73 , 0x84 , 0x37 , 0x0f , 0x48 , 0xef , 0xd1 , 0x21 , 0x74 , 0x30 , 0x50 ] ,
200
200
} , Test {
201
- password: bytes! ( "pass\x00 wor" ) ,
202
- salt: bytes! ( "sa\x00 l" ) ,
201
+ password: Vec :: from_slice ( b "pass\x00 wor") ,
202
+ salt: Vec :: from_slice ( b "sa\x00 l") ,
203
203
rounds: 4 ,
204
- out: bytes! ( 0xc2 , 0xbf , 0xfd , 0x9d , 0xb3 , 0x8f , 0x65 , 0x69 , 0xef , 0xef , 0x43 , 0x72 , 0xf4 , 0xde , 0x83 , 0xc0 ) ,
204
+ out: vec! [ 0xc2 , 0xbf , 0xfd , 0x9d , 0xb3 , 0x8f , 0x65 , 0x69 , 0xef , 0xef , 0x43 , 0x72 , 0xf4 , 0xde , 0x83 , 0xc0 ] ,
205
205
} , Test {
206
- password: bytes! ( "pass\x00 word" ) ,
207
- salt: bytes! ( "sa\x00 lt" ) ,
206
+ password: Vec :: from_slice ( b "pass\x00 word") ,
207
+ salt: Vec :: from_slice ( b "sa\x00 lt") ,
208
208
rounds: 4 ,
209
- out: bytes! ( 0x4b , 0xa4 , 0xac , 0x39 , 0x25 , 0xc0 , 0xe8 , 0xd7 , 0xf0 , 0xcd , 0xb6 , 0xbb , 0x16 , 0x84 , 0xa5 , 0x6f ) ,
209
+ out: vec! [ 0x4b , 0xa4 , 0xac , 0x39 , 0x25 , 0xc0 , 0xe8 , 0xd7 , 0xf0 , 0xcd , 0xb6 , 0xbb , 0x16 , 0x84 , 0xa5 , 0x6f ] ,
210
210
} , Test {
211
- password: bytes! ( "password" ) ,
212
- salt: bytes! ( "salt" ) ,
211
+ password: Vec :: from_slice ( b "password") ,
212
+ salt: Vec :: from_slice ( b "salt") ,
213
213
rounds: 8 ,
214
- out: bytes! (
214
+ out: vec! [
215
215
0xe1 , 0x36 , 0x7e , 0xc5 , 0x15 , 0x1a , 0x33 , 0xfa , 0xac , 0x4c , 0xc1 , 0xc1 , 0x44 , 0xcd , 0x23 , 0xfa ,
216
216
0x15 , 0xd5 , 0x54 , 0x84 , 0x93 , 0xec , 0xc9 , 0x9b , 0x9b , 0x5d , 0x9c , 0x0d , 0x3b , 0x27 , 0xbe , 0xc7 ,
217
217
0x62 , 0x27 , 0xea , 0x66 , 0x08 , 0x8b , 0x84 , 0x9b , 0x20 , 0xab , 0x7a , 0xa4 , 0x78 , 0x01 , 0x02 , 0x46 ,
218
- 0xe7 , 0x4b , 0xba , 0x51 , 0x72 , 0x3f , 0xef , 0xa9 , 0xf9 , 0x47 , 0x4d , 0x65 , 0x08 , 0x84 , 0x5e , 0x8d ) ,
218
+ 0xe7 , 0x4b , 0xba , 0x51 , 0x72 , 0x3f , 0xef , 0xa9 , 0xf9 , 0x47 , 0x4d , 0x65 , 0x08 , 0x84 , 0x5e , 0x8d ] ,
219
219
} , Test {
220
- password: bytes! ( "password" ) ,
221
- salt: bytes! ( "salt" ) ,
220
+ password: Vec :: from_slice ( b "password") ,
221
+ salt: Vec :: from_slice ( b "salt") ,
222
222
rounds: 42 ,
223
- out: bytes! ( 0x83 , 0x3c , 0xf0 , 0xdc , 0xf5 , 0x6d , 0xb6 , 0x56 , 0x08 , 0xe8 , 0xf0 , 0xdc , 0x0c , 0xe8 , 0x82 , 0xbd ) ,
223
+ out: vec! [ 0x83 , 0x3c , 0xf0 , 0xdc , 0xf5 , 0x6d , 0xb6 , 0x56 , 0x08 , 0xe8 , 0xf0 , 0xdc , 0x0c , 0xe8 , 0x82 , 0xbd ] ,
224
224
} , Test {
225
- password: bytes! ( "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." ) ,
226
- salt: bytes! ( "salis\x00 " ) ,
225
+ password: Vec :: from_slice ( b "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.") ,
226
+ salt: Vec :: from_slice ( b "salis\x00 ") ,
227
227
rounds: 8 ,
228
- out: bytes! ( 0x10 , 0x97 , 0x8b , 0x07 , 0x25 , 0x3d , 0xf5 , 0x7f , 0x71 , 0xa1 , 0x62 , 0xeb , 0x0e , 0x8a , 0xd3 , 0x0a ) ,
228
+ out: vec! [ 0x10 , 0x97 , 0x8b , 0x07 , 0x25 , 0x3d , 0xf5 , 0x7f , 0x71 , 0xa1 , 0x62 , 0xeb , 0x0e , 0x8a , 0xd3 , 0x0a ] ,
229
229
} , Test {
230
- password: bytes! ( 0x0d , 0xb3 , 0xac , 0x94 , 0xb3 , 0xee , 0x53 , 0x28 , 0x4f , 0x4a , 0x22 , 0x89 , 0x3b , 0x3c , 0x24 , 0xae ) ,
231
- salt: bytes! ( 0x3a , 0x62 , 0xf0 , 0xf0 , 0xdb , 0xce , 0xf8 , 0x23 , 0xcf , 0xcc , 0x85 , 0x48 , 0x56 , 0xea , 0x10 , 0x28 ) ,
230
+ password: vec! [ 0x0d , 0xb3 , 0xac , 0x94 , 0xb3 , 0xee , 0x53 , 0x28 , 0x4f , 0x4a , 0x22 , 0x89 , 0x3b , 0x3c , 0x24 , 0xae ] ,
231
+ salt: vec! [ 0x3a , 0x62 , 0xf0 , 0xf0 , 0xdb , 0xce , 0xf8 , 0x23 , 0xcf , 0xcc , 0x85 , 0x48 , 0x56 , 0xea , 0x10 , 0x28 ] ,
232
232
rounds: 8 ,
233
- out: bytes! ( 0x20 , 0x44 , 0x38 , 0x17 , 0x5e , 0xee , 0x7c , 0xe1 , 0x36 , 0xc9 , 0x1b , 0x49 , 0xa6 , 0x79 , 0x23 , 0xff ) ,
233
+ out: vec! [ 0x20 , 0x44 , 0x38 , 0x17 , 0x5e , 0xee , 0x7c , 0xe1 , 0x36 , 0xc9 , 0x1b , 0x49 , 0xa6 , 0x79 , 0x23 , 0xff ] ,
234
234
} , Test {
235
- password: bytes! ( 0x0d , 0xb3 , 0xac , 0x94 , 0xb3 , 0xee , 0x53 , 0x28 , 0x4f , 0x4a , 0x22 , 0x89 , 0x3b , 0x3c , 0x24 , 0xae ) ,
236
- salt: bytes! ( 0x3a , 0x62 , 0xf0 , 0xf0 , 0xdb , 0xce , 0xf8 , 0x23 , 0xcf , 0xcc , 0x85 , 0x48 , 0x56 , 0xea , 0x10 , 0x28 ) ,
235
+ password: vec! [ 0x0d , 0xb3 , 0xac , 0x94 , 0xb3 , 0xee , 0x53 , 0x28 , 0x4f , 0x4a , 0x22 , 0x89 , 0x3b , 0x3c , 0x24 , 0xae ] ,
236
+ salt: vec! [ 0x3a , 0x62 , 0xf0 , 0xf0 , 0xdb , 0xce , 0xf8 , 0x23 , 0xcf , 0xcc , 0x85 , 0x48 , 0x56 , 0xea , 0x10 , 0x28 ] ,
237
237
rounds: 8 ,
238
- out: bytes! (
238
+ out: vec! [
239
239
0x20 , 0x54 , 0xb9 , 0xff , 0xf3 , 0x4e , 0x37 , 0x21 , 0x44 , 0x03 , 0x34 , 0x74 , 0x68 , 0x28 , 0xe9 , 0xed ,
240
240
0x38 , 0xde , 0x4b , 0x72 , 0xe0 , 0xa6 , 0x9a , 0xdc , 0x17 , 0x0a , 0x13 , 0xb5 , 0xe8 , 0xd6 , 0x46 , 0x38 ,
241
241
0x5e , 0xa4 , 0x03 , 0x4a , 0xe6 , 0xd2 , 0x66 , 0x00 , 0xee , 0x23 , 0x32 , 0xc5 , 0xed , 0x40 , 0xad , 0x55 ,
@@ -251,14 +251,14 @@ mod test {
251
251
0x3f , 0x54 , 0x8d , 0x5e , 0xeb , 0xa4 , 0x21 , 0x13 , 0x97 , 0xe2 , 0xfb , 0x06 , 0x2e , 0x52 , 0x6e , 0x1d ,
252
252
0x68 , 0xf4 , 0x6a , 0x4c , 0xe2 , 0x56 , 0x18 , 0x5b , 0x4b , 0xad , 0xc2 , 0x68 , 0x5f , 0xbe , 0x78 , 0xe1 ,
253
253
0xc7 , 0x65 , 0x7b , 0x59 , 0xf8 , 0x3a , 0xb9 , 0xab , 0x80 , 0xcf , 0x93 , 0x18 , 0xd6 , 0xad , 0xd1 , 0xf5 ,
254
- 0x93 , 0x3f , 0x12 , 0xd6 , 0xf3 , 0x61 , 0x82 , 0xc8 , 0xe8 , 0x11 , 0x5f , 0x68 , 0x03 , 0x0a , 0x12 , 0x44 ) ,
254
+ 0x93 , 0x3f , 0x12 , 0xd6 , 0xf3 , 0x61 , 0x82 , 0xc8 , 0xe8 , 0x11 , 0x5f , 0x68 , 0x03 , 0x0a , 0x12 , 0x44 ] ,
255
255
} ,
256
256
) ;
257
257
258
258
for t in tests. iter ( ) {
259
259
let mut out = Vec :: from_elem ( t. out . len ( ) , 0u8 ) ;
260
- bcrypt_pbkdf ( t. password , t. salt , t. rounds , out. as_mut_slice ( ) ) ;
261
- assert_eq ! ( out. as_slice ( ) , t. out. as_slice ( ) ) ;
260
+ bcrypt_pbkdf ( t. password . as_slice ( ) , t. salt . as_slice ( ) , t. rounds , out. as_mut_slice ( ) ) ;
261
+ assert_eq ! ( out, t. out) ;
262
262
}
263
263
}
264
264
}
0 commit comments