1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.netty.internal.tcnative;
18
19
20
21
22 public final class SessionTicketKey {
23
24
25
26 public static final int NAME_SIZE = 16;
27
28
29
30 public static final int HMAC_KEY_SIZE = 16;
31
32
33
34 public static final int AES_KEY_SIZE = 16;
35
36
37
38 public static final int TICKET_KEY_SIZE = NAME_SIZE + HMAC_KEY_SIZE + AES_KEY_SIZE;
39
40
41 final byte[] name;
42 final byte[] hmacKey;
43 final byte[] aesKey;
44
45
46
47
48
49
50
51 public SessionTicketKey(byte[] name, byte[] hmacKey, byte[] aesKey) {
52 if (name == null || name.length != NAME_SIZE) {
53 throw new IllegalArgumentException("Length of name should be " + NAME_SIZE);
54 }
55 if (hmacKey == null || hmacKey.length != HMAC_KEY_SIZE) {
56 throw new IllegalArgumentException("Length of hmacKey should be " + HMAC_KEY_SIZE);
57 }
58 if (aesKey == null || aesKey.length != AES_KEY_SIZE) {
59 throw new IllegalArgumentException("Length of aesKey should be " + AES_KEY_SIZE);
60 }
61 this.name = name;
62 this.hmacKey = hmacKey;
63 this.aesKey = aesKey;
64 }
65
66
67
68
69
70
71 public byte[] getName() {
72 return name.clone();
73 }
74
75
76
77
78
79 public byte[] getHmacKey() {
80 return hmacKey.clone();
81 }
82
83
84
85
86
87 public byte[] getAesKey() {
88 return aesKey.clone();
89 }
90 }