-
Notifications
You must be signed in to change notification settings - Fork 15
/
CipherInfo.js
67 lines (52 loc) · 1.72 KB
/
CipherInfo.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
"use strict";
var dtls = require( './dtls' );
var CipherSuite = function( id, keyExchange, cipher, mac, prf ) {
this.id = id;
this.keyExchange = keyExchange;
this.cipher = cipher;
this.mac = mac;
this.prf = prf || dtls.PRFAlgorithm.tlsPrfSha256;
};
var Cipher = function( algorithm, type, keyMaterial, ivSize, blockSize ) {
this.algorithm = algorithm;
this.type = type;
this.keyMaterial = keyMaterial;
this.ivSize = ivSize;
this.blockSize = blockSize;
};
var Mac = function( algorithm, length, keyLength ) {
this.algorithm = algorithm;
this.length = length;
this.keyLength = keyLength;
};
var cipher = {
none: new Cipher( dtls.BulkCipherAlgorithm.none,
dtls.CipherType.stream, 0, 0, 0 ),
rc4_128: new Cipher( dtls.BulkCipherAlgorithm.rc4,
dtls.CipherType.stream, 16, 0, 0 ),
des3_ede_cbc: new Cipher( dtls.BulkCipherAlgorithm.des3,
dtls.CipherType.block, 24, 8, 8 ),
aes_128_cbc: new Cipher( dtls.BulkCipherAlgorithm.aes,
dtls.CipherType.block, 16, 16, 16 ),
aes_256_cbc: new Cipher( dtls.BulkCipherAlgorithm.aes,
dtls.CipherType.block, 32, 16, 16 )
};
var mac = {
none: new Mac( dtls.MACAlgorithm.none, 0, 0 ),
md5: new Mac( dtls.MACAlgorithm.hmac_md5, 16, 16 ),
sha: new Mac( dtls.MACAlgorithm.hmac_sha1, 20, 20 ),
sha256: new Mac( dtls.MACAlgorithm.hmac_sha256, 32, 32 ),
};
var suites = {
TLS_RSA_WITH_AES_128_CBC_SHA: new CipherSuite(
0x002f, dtls.KeyExchange.rsa, cipher.aes_128_cbc, mac.sha ),
};
var suitesById = {};
for( var s in suites ) {
suites[s].name = s;
suitesById[ suites[s].id ] = suites[s];
}
suites.get = function( id ) {
return suitesById[ id ];
};
module.exports = suites;