View Javadoc
1   /*
2    * Copyright 2015 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty5.handler.ssl;
17  
18  import io.netty.internal.tcnative.SessionTicketKey;
19  
20  /**
21   * Session Ticket Key
22   */
23  public final class OpenSslSessionTicketKey {
24  
25      /**
26       * Size of session ticket key name
27       */
28      public static final int NAME_SIZE = SessionTicketKey.NAME_SIZE;
29      /**
30       * Size of session ticket key HMAC key
31       */
32      public static final int HMAC_KEY_SIZE = SessionTicketKey.HMAC_KEY_SIZE;
33      /**
34       * Size of session ticket key AES key
35       */
36      public static final int AES_KEY_SIZE = SessionTicketKey.AES_KEY_SIZE;
37      /**
38       * Size of session ticker key
39       */
40      public static final int TICKET_KEY_SIZE = SessionTicketKey.TICKET_KEY_SIZE;
41  
42      final SessionTicketKey key;
43  
44      /**
45       * Construct a OpenSslSessionTicketKey.
46       *
47       * @param name the name of the session ticket key
48       * @param hmacKey the HMAC key of the session ticket key
49       * @param aesKey the AES key of the session ticket key
50       */
51      public OpenSslSessionTicketKey(byte[] name, byte[] hmacKey, byte[] aesKey) {
52          key = new SessionTicketKey(name.clone(), hmacKey.clone(), aesKey.clone());
53      }
54  
55      /**
56       * Get name.
57       * @return the name of the session ticket key
58       */
59      public byte[] name() {
60          return key.getName().clone();
61      }
62  
63      /**
64       * Get HMAC key.
65       * @return the HMAC key of the session ticket key
66       */
67      public byte[] hmacKey() {
68          return key.getHmacKey().clone();
69      }
70  
71      /**
72       * Get AES Key.
73       * @return the AES key of the session ticket key
74       */
75      public byte[] aesKey() {
76          return key.getAesKey().clone();
77      }
78  }