forked from brix/crypto-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
x64-word-test.js
99 lines (74 loc) · 3.86 KB
/
x64-word-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
YUI.add('x64-word-test', function (Y) {
var C = CryptoJS;
Y.Test.Runner.add(new Y.Test.Case({
name: 'X64Word',
testInit: function () {
var word = C.x64.Word.create(0x00010203, 0x04050607);
Y.Assert.areEqual(0x00010203, word.high, 'word.high');
Y.Assert.areEqual(0x04050607, word.low, 'word.low');
}
// testNot: function () {
// var word = C.x64.Word.create(0x00010203, 0x04050607).not();
// Y.Assert.areEqual(~0x00010203, word.high, 'word.high');
// Y.Assert.areEqual(~0x04050607, word.low, 'word.low');
// },
// testAnd: function () {
// var word1 = C.x64.Word.create(0x00010203, 0x04050607);
// var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
// var anded = word1.and(word2);
// Y.Assert.areEqual(0x00010203 & 0x18191a1b, anded.high, 'word.high');
// Y.Assert.areEqual(0x04050607 & 0x1c1d1e1f, anded.low, 'word.low');
// },
// testOr: function () {
// var word1 = C.x64.Word.create(0x00010203, 0x04050607);
// var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
// var ored = word1.or(word2);
// Y.Assert.areEqual(0x00010203 | 0x18191a1b, ored.high, 'word.high');
// Y.Assert.areEqual(0x04050607 | 0x1c1d1e1f, ored.low, 'word.low');
// },
// testXor: function () {
// var word1 = C.x64.Word.create(0x00010203, 0x04050607);
// var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
// var xored = word1.xor(word2);
// Y.Assert.areEqual(0x00010203 ^ 0x18191a1b, xored.high, 'word.high');
// Y.Assert.areEqual(0x04050607 ^ 0x1c1d1e1f, xored.low, 'word.low');
// },
// testShiftL25: function () {
// var word = C.x64.Word.create(0x00010203, 0x04050607).shiftL(25);
// Y.Assert.areEqual(0x06080a0c, word.high, 'word.high');
// Y.Assert.areEqual(0x0e000000, word.low, 'word.low');
// },
// testShiftL32: function () {
// var word = C.x64.Word.create(0x00010203, 0x04050607).shiftL(32);
// Y.Assert.areEqual(0x04050607, word.high, 'word.high');
// Y.Assert.areEqual(0x00000000, word.low, 'word.low');
// },
// testShiftR7: function () {
// var word = C.x64.Word.create(0x00010203, 0x04050607).shiftR(7);
// Y.Assert.areEqual(0x00000204, word.high, 'word.high');
// Y.Assert.areEqual(0x06080A0C, word.low, 'word.low');
// },
// testShiftR32: function () {
// var word = C.x64.Word.create(0x00010203, 0x04050607).shiftR(32);
// Y.Assert.areEqual(0x00000000, word.high, 'word.high');
// Y.Assert.areEqual(0x00010203, word.low, 'word.low');
// },
// testRotL: function () {
// var word = C.x64.Word.create(0x00010203, 0x04050607).rotL(25);
// Y.Assert.areEqual(0x06080a0c, word.high, 'word.high');
// Y.Assert.areEqual(0x0e000204, word.low, 'word.low');
// },
// testRotR: function () {
// var word = C.x64.Word.create(0x00010203, 0x04050607).rotR(7);
// Y.Assert.areEqual(0x0e000204, word.high, 'word.high');
// Y.Assert.areEqual(0x06080a0c, word.low, 'word.low');
// },
// testAdd: function () {
// var word1 = C.x64.Word.create(0x00010203, 0x04050607);
// var word2 = C.x64.Word.create(0x18191a1b, 0x1c1d1e1f);
// var added = word1.add(word2);
// Y.Assert.areEqual(0x181a1c1e, added.high, 'word.high');
// Y.Assert.areEqual(0x20222426, added.low, 'word.low');
// }
}));
}, '$Rev$');