Skip to content

Commit 86f18ea

Browse files
committed
Merge pull request #78 from DaGenix/remove-owned-vec
Remove all uses of ~[]
2 parents 8cf2430 + 9a821a9 commit 86f18ea

File tree

13 files changed

+348
-352
lines changed

13 files changed

+348
-352
lines changed

src/rust-crypto-util/tool.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#![license = "MIT/ASL2"]
88
#![crate_id = "github.com/DaGenix/rust-crypto#rust-crypto-util:0.1"]
99

10-
#![allow(deprecated_owned_vector)]
11-
1210
extern crate getopts;
1311
extern crate rust_crypto = "rust-crypto";
1412

@@ -71,7 +69,7 @@ fn run_scrypt(matches: &Matches) {
7169
fn main() {
7270
let args: Vec<String> = os::args().iter().map(|x| x.to_string()).collect();
7371

74-
let opts = ~[
72+
let opts = vec![
7573
// General parameters:
7674
optflag("h", "help", "Print help"),
7775

@@ -85,7 +83,7 @@ fn main() {
8583
optflag("", "rawoutput", "Use raw output mode"),
8684
];
8785

88-
let matches = match getopts(args.tail(), opts) {
86+
let matches = match getopts(args.tail(), opts.as_slice()) {
8987
Ok(m) => { m }
9088
Err(f) => { fail!(f.to_err_msg()) }
9189
};

src/rust-crypto/aes.rs

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -393,115 +393,115 @@ mod test {
393393
// http://www.inconteam.com/software-development/41-encryption/55-aes-test-vectors
394394

395395
struct Test {
396-
key: ~[u8],
397-
data: ~[TestData]
396+
key: Vec<u8>,
397+
data: Vec<TestData>
398398
}
399399

400400
struct TestData {
401-
plain: ~[u8],
402-
cipher: ~[u8]
401+
plain: Vec<u8>,
402+
cipher: Vec<u8>
403403
}
404404

405-
fn tests128() -> ~[Test] {
406-
return ~[
405+
fn tests128() -> Vec<Test> {
406+
return vec![
407407
Test {
408-
key: ~[0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
408+
key: vec![0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
409409
0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c],
410-
data: ~[
410+
data: vec![
411411
TestData {
412-
plain: ~[0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
412+
plain: vec![0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
413413
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a],
414-
cipher: ~[0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60,
414+
cipher: vec![0x3a, 0xd7, 0x7b, 0xb4, 0x0d, 0x7a, 0x36, 0x60,
415415
0xa8, 0x9e, 0xca, 0xf3, 0x24, 0x66, 0xef, 0x97]
416416
},
417417
TestData {
418-
plain: ~[0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
418+
plain: vec![0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
419419
0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51],
420-
cipher: ~[0xf5, 0xd3, 0xd5, 0x85, 0x03, 0xb9, 0x69, 0x9d,
420+
cipher: vec![0xf5, 0xd3, 0xd5, 0x85, 0x03, 0xb9, 0x69, 0x9d,
421421
0xe7, 0x85, 0x89, 0x5a, 0x96, 0xfd, 0xba, 0xaf]
422422
},
423423
TestData {
424-
plain: ~[0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
424+
plain: vec![0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
425425
0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef],
426-
cipher: ~[0x43, 0xb1, 0xcd, 0x7f, 0x59, 0x8e, 0xce, 0x23,
426+
cipher: vec![0x43, 0xb1, 0xcd, 0x7f, 0x59, 0x8e, 0xce, 0x23,
427427
0x88, 0x1b, 0x00, 0xe3, 0xed, 0x03, 0x06, 0x88]
428428
},
429429
TestData {
430-
plain: ~[0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
430+
plain: vec![0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
431431
0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10],
432-
cipher: ~[0x7b, 0x0c, 0x78, 0x5e, 0x27, 0xe8, 0xad, 0x3f,
432+
cipher: vec![0x7b, 0x0c, 0x78, 0x5e, 0x27, 0xe8, 0xad, 0x3f,
433433
0x82, 0x23, 0x20, 0x71, 0x04, 0x72, 0x5d, 0xd4]
434434
}
435435
]
436436
}
437437
];
438438
}
439439

440-
fn tests192() -> ~[Test] {
441-
return ~[
440+
fn tests192() -> Vec<Test> {
441+
return vec![
442442
Test {
443-
key: ~[0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, 0xc8, 0x10, 0xf3, 0x2b,
443+
key: vec![0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, 0xc8, 0x10, 0xf3, 0x2b,
444444
0x80, 0x90, 0x79, 0xe5, 0x62, 0xf8, 0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b],
445-
data: ~[
445+
data: vec![
446446
TestData {
447-
plain: ~[0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
447+
plain: vec![0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
448448
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a],
449-
cipher: ~[0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f,
449+
cipher: vec![0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f,
450450
0xf7, 0x12, 0xa2, 0x14, 0x57, 0x1f, 0xa5, 0xcc]
451451
},
452452
TestData {
453-
plain: ~[0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
453+
plain: vec![0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
454454
0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51],
455-
cipher: ~[0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad,
455+
cipher: vec![0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad,
456456
0x77, 0x34, 0xec, 0xb3, 0xec, 0xee, 0x4e, 0xef]
457457
},
458458
TestData {
459-
plain: ~[0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
459+
plain: vec![0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
460460
0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef],
461-
cipher: ~[0xef, 0x7a, 0xfd, 0x22, 0x70, 0xe2, 0xe6, 0x0a,
461+
cipher: vec![0xef, 0x7a, 0xfd, 0x22, 0x70, 0xe2, 0xe6, 0x0a,
462462
0xdc, 0xe0, 0xba, 0x2f, 0xac, 0xe6, 0x44, 0x4e]
463463
},
464464
TestData {
465-
plain: ~[0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
465+
plain: vec![0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
466466
0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10],
467-
cipher: ~[0x9a, 0x4b, 0x41, 0xba, 0x73, 0x8d, 0x6c, 0x72,
467+
cipher: vec![0x9a, 0x4b, 0x41, 0xba, 0x73, 0x8d, 0x6c, 0x72,
468468
0xfb, 0x16, 0x69, 0x16, 0x03, 0xc1, 0x8e, 0x0e]
469469
}
470470
]
471471
}
472472
];
473473
}
474474

475-
fn tests256() -> ~[Test] {
476-
return ~[
475+
fn tests256() -> Vec<Test> {
476+
return vec![
477477
Test {
478-
key: ~[0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
478+
key: vec![0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe,
479479
0x2b, 0x73, 0xae, 0xf0, 0x85, 0x7d, 0x77, 0x81,
480480
0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7,
481481
0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4],
482-
data: ~[
482+
data: vec![
483483
TestData {
484-
plain: ~[0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
484+
plain: vec![0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96,
485485
0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a],
486-
cipher: ~[0xf3, 0xee, 0xd1, 0xbd, 0xb5, 0xd2, 0xa0, 0x3c,
486+
cipher: vec![0xf3, 0xee, 0xd1, 0xbd, 0xb5, 0xd2, 0xa0, 0x3c,
487487
0x06, 0x4b, 0x5a, 0x7e, 0x3d, 0xb1, 0x81, 0xf8]
488488
},
489489
TestData {
490-
plain: ~[0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
490+
plain: vec![0xae, 0x2d, 0x8a, 0x57, 0x1e, 0x03, 0xac, 0x9c,
491491
0x9e, 0xb7, 0x6f, 0xac, 0x45, 0xaf, 0x8e, 0x51],
492-
cipher: ~[0x59, 0x1c, 0xcb, 0x10, 0xd4, 0x10, 0xed, 0x26,
492+
cipher: vec![0x59, 0x1c, 0xcb, 0x10, 0xd4, 0x10, 0xed, 0x26,
493493
0xdc, 0x5b, 0xa7, 0x4a, 0x31, 0x36, 0x28, 0x70]
494494
},
495495
TestData {
496-
plain: ~[0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
496+
plain: vec![0x30, 0xc8, 0x1c, 0x46, 0xa3, 0x5c, 0xe4, 0x11,
497497
0xe5, 0xfb, 0xc1, 0x19, 0x1a, 0x0a, 0x52, 0xef],
498-
cipher: ~[0xb6, 0xed, 0x21, 0xb9, 0x9c, 0xa6, 0xf4, 0xf9,
498+
cipher: vec![0xb6, 0xed, 0x21, 0xb9, 0x9c, 0xa6, 0xf4, 0xf9,
499499
0xf1, 0x53, 0xe7, 0xb1, 0xbe, 0xaf, 0xed, 0x1d]
500500
},
501501
TestData {
502-
plain: ~[0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
502+
plain: vec![0xf6, 0x9f, 0x24, 0x45, 0xdf, 0x4f, 0x9b, 0x17,
503503
0xad, 0x2b, 0x41, 0x7b, 0xe6, 0x6c, 0x37, 0x10],
504-
cipher: ~[0x23, 0x30, 0x4b, 0x7a, 0x39, 0xf9, 0xf3, 0xff,
504+
cipher: vec![0x23, 0x30, 0x4b, 0x7a, 0x39, 0xf9, 0xf3, 0xff,
505505
0x06, 0x7d, 0x8d, 0x8f, 0x9e, 0x24, 0xec, 0xc7]
506506
}
507507
]
@@ -512,10 +512,10 @@ mod test {
512512
fn run_test<E: BlockEncryptor, D: BlockDecryptor>(enc: &mut E, dec: &mut D, test: &Test) {
513513
let mut tmp = [0u8, ..16];
514514
for data in test.data.iter() {
515-
enc.encrypt_block(data.plain, tmp);
516-
assert!(tmp == data.cipher);
517-
dec.decrypt_block(data.cipher, tmp);
518-
assert!(tmp == data.plain);
515+
enc.encrypt_block(data.plain.as_slice(), tmp);
516+
assert!(tmp == data.cipher.as_slice());
517+
dec.decrypt_block(data.cipher.as_slice(), tmp);
518+
assert!(tmp == data.plain.as_slice());
519519
}
520520
}
521521

@@ -526,8 +526,8 @@ mod test {
526526
if util::supports_aesni() {
527527
let tests = tests128();
528528
for t in tests.iter() {
529-
let mut enc = aesni::AesNi128Encryptor::new(t.key);
530-
let mut dec = aesni::AesNi128Decryptor::new(t.key);
529+
let mut enc = aesni::AesNi128Encryptor::new(t.key.as_slice());
530+
let mut dec = aesni::AesNi128Decryptor::new(t.key.as_slice());
531531
run_test(&mut enc, &mut dec, t);
532532
}
533533
}
@@ -540,8 +540,8 @@ mod test {
540540
if util::supports_aesni() {
541541
let tests = tests192();
542542
for t in tests.iter() {
543-
let mut enc = aesni::AesNi192Encryptor::new(t.key);
544-
let mut dec = aesni::AesNi192Decryptor::new(t.key);
543+
let mut enc = aesni::AesNi192Encryptor::new(t.key.as_slice());
544+
let mut dec = aesni::AesNi192Decryptor::new(t.key.as_slice());
545545
run_test(&mut enc, &mut dec, t);
546546
}
547547
}
@@ -554,8 +554,8 @@ mod test {
554554
if util::supports_aesni() {
555555
let tests = tests256();
556556
for t in tests.iter() {
557-
let mut enc = aesni::AesNi256Encryptor::new(t.key);
558-
let mut dec = aesni::AesNi256Decryptor::new(t.key);
557+
let mut enc = aesni::AesNi256Encryptor::new(t.key.as_slice());
558+
let mut dec = aesni::AesNi256Decryptor::new(t.key.as_slice());
559559
run_test(&mut enc, &mut dec, t);
560560
}
561561
}
@@ -565,8 +565,8 @@ mod test {
565565
fn test_aessafe_128() {
566566
let tests = tests128();
567567
for t in tests.iter() {
568-
let mut enc = aessafe::AesSafe128Encryptor::new(t.key);
569-
let mut dec = aessafe::AesSafe128Decryptor::new(t.key);
568+
let mut enc = aessafe::AesSafe128Encryptor::new(t.key.as_slice());
569+
let mut dec = aessafe::AesSafe128Decryptor::new(t.key.as_slice());
570570
run_test(&mut enc, &mut dec, t);
571571
}
572572
}
@@ -575,8 +575,8 @@ mod test {
575575
fn test_aessafe_192() {
576576
let tests = tests192();
577577
for t in tests.iter() {
578-
let mut enc = aessafe::AesSafe192Encryptor::new(t.key);
579-
let mut dec = aessafe::AesSafe192Decryptor::new(t.key);
578+
let mut enc = aessafe::AesSafe192Encryptor::new(t.key.as_slice());
579+
let mut dec = aessafe::AesSafe192Decryptor::new(t.key.as_slice());
580580
run_test(&mut enc, &mut dec, t);
581581
}
582582
}
@@ -585,8 +585,8 @@ mod test {
585585
fn test_aessafe_256() {
586586
let tests = tests256();
587587
for t in tests.iter() {
588-
let mut enc = aessafe::AesSafe256Encryptor::new(t.key);
589-
let mut dec = aessafe::AesSafe256Decryptor::new(t.key);
588+
let mut enc = aessafe::AesSafe256Encryptor::new(t.key.as_slice());
589+
let mut dec = aessafe::AesSafe256Decryptor::new(t.key.as_slice());
590590
run_test(&mut enc, &mut dec, t);
591591
}
592592
}

0 commit comments

Comments
 (0)