-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCipher.cpp
69 lines (61 loc) · 1.02 KB
/
Cipher.cpp
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
//
// cipher.cpp
// browser-cc
//
// Created by Nissassin Seventeen on 10/6/15.
// Copyright (c) 2015 Nissassin Seventeen. All rights reserved.
//
#include "Cipher.hpp"
Cipher::Format Cipher::getFormat() const {
return format;
}
int Cipher::getKeyMaterial() const {
return keyMaterial;
}
size_t Cipher::getIVSize() const {
return ivSize;
}
;
size_t Cipher::getBlockSize() const {
return blockSize;
}
Cipher::Cipher(CipherType type) {
setType(type);
}
;
void Cipher::setType(CipherType type) {
this->type = type;
switch (type) {
case CIPHER_NULL:
format = STREAM;
keyMaterial = 0;
ivSize = 0;
blockSize = -1;
break;
case RC4_128:
format = STREAM;
keyMaterial = 16;
ivSize = 0;
break;
case _3DES_EDE_CBC:
format = BLOCK;
keyMaterial = 24;
ivSize = 8;
blockSize = 8;
break;
case AES_128_CBC:
format = BLOCK;
keyMaterial = 16;
ivSize = 16;
blockSize = 16;
break;
case AES_256_CBC:
format = BLOCK;
keyMaterial = 32;
ivSize = 16;
blockSize = 16;
break;
default:
break;
}
}