| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Licensed to the Apache Software Foundation (ASF) under one or more | 2 * Copyright 2016 The Netty Project |
| 3 * contributor license agreements. See the NOTICE file distributed with | |
| 4 * this work for additional information regarding copyright ownership. | |
| 5 * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 6 * (the "License"); you may not use this file except in compliance with | |
| 7 * the License. You may obtain a copy of the License at | |
| 8 * | 3 * |
| 9 * http://www.apache.org/licenses/LICENSE-2.0 | 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: |
| 10 * | 7 * |
| 11 * Unless required by applicable law or agreed to in writing, software | 8 * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 * distributed under the License is distributed on an "AS IS" BASIS, | 9 * |
| 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 10 * Unless required by applicable law or agreed to in writing, software |
| 14 * See the License for the specific language governing permissions and | 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 * limitations under the License. | 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. |
| 16 */ | 15 */ |
| 17 | 16 |
| 18 package org.apache.tomcat.jni; | 17 package io.netty.internal.tcnative; |
| 19 | 18 |
| 20 /** | 19 /** |
| 21 * Session Ticket Key | 20 * Session Ticket Key |
| 22 */ | 21 */ |
| 23 public final class SessionTicketKey { | 22 public final class SessionTicketKey { |
| 24 /** | 23 /** |
| 25 * Size of session ticket key name | 24 * Size of session ticket key name |
| 26 */ | 25 */ |
| 27 public static final int NAME_SIZE = 16; | 26 public static final int NAME_SIZE = 16; |
| 28 /** | 27 /** |
| 29 * Size of session ticket key HMAC key | 28 * Size of session ticket key HMAC key |
| 30 */ | 29 */ |
| 31 public static final int HMAC_KEY_SIZE = 16; | 30 public static final int HMAC_KEY_SIZE = 16; |
| 32 /** | 31 /** |
| 33 * Size of session ticket key AES key | 32 * Size of session ticket key AES key |
| 34 */ | 33 */ |
| 35 public static final int AES_KEY_SIZE = 16; | 34 public static final int AES_KEY_SIZE = 16; |
| 36 /** | 35 /** |
| 37 * Size of session ticker key | 36 * Size of session ticket key |
| 38 */ | 37 */ |
| 39 public static final int TICKET_KEY_SIZE = NAME_SIZE + HMAC_KEY_SIZE + AES_KE
Y_SIZE; | 38 public static final int TICKET_KEY_SIZE = NAME_SIZE + HMAC_KEY_SIZE + AES_KE
Y_SIZE; |
| 40 | 39 |
| 41 private final byte[] name; | 40 // package private so we can access these in SSLContext without calling clon
e() on the byte[]. |
| 42 private final byte[] hmacKey; | 41 final byte[] name; |
| 43 private final byte[] aesKey; | 42 final byte[] hmacKey; |
| 43 final byte[] aesKey; |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * Construct SesionTicketKey. | 46 * Construct SessionTicketKey. |
| 47 * @param name the name of the session ticket key | 47 * @param name the name of the session ticket key |
| 48 * @param hmacKey the HMAC key 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 | 49 * @param aesKey the AES key of the session ticket key |
| 50 */ | 50 */ |
| 51 public SessionTicketKey(byte[] name, byte[] hmacKey, byte[] aesKey) { | 51 public SessionTicketKey(byte[] name, byte[] hmacKey, byte[] aesKey) { |
| 52 if (name == null || name.length != NAME_SIZE) { | 52 if (name == null || name.length != NAME_SIZE) { |
| 53 throw new IllegalArgumentException("Length of name should be 16"); | 53 throw new IllegalArgumentException("Length of name should be " + NAM
E_SIZE); |
| 54 } | 54 } |
| 55 if (hmacKey == null || hmacKey.length != HMAC_KEY_SIZE) { | 55 if (hmacKey == null || hmacKey.length != HMAC_KEY_SIZE) { |
| 56 throw new IllegalArgumentException("Length of hmacKey should be 16")
; | 56 throw new IllegalArgumentException("Length of hmacKey should be " +
HMAC_KEY_SIZE); |
| 57 } | 57 } |
| 58 if (aesKey == null || aesKey.length != AES_KEY_SIZE) { | 58 if (aesKey == null || aesKey.length != AES_KEY_SIZE) { |
| 59 throw new IllegalArgumentException("Length of aesKey should be 16"); | 59 throw new IllegalArgumentException("Length of aesKey should be " + A
ES_KEY_SIZE); |
| 60 } | 60 } |
| 61 this.name = name; | 61 this.name = name; |
| 62 this.hmacKey = hmacKey; | 62 this.hmacKey = hmacKey; |
| 63 this.aesKey = aesKey; | 63 this.aesKey = aesKey; |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * Get name. | 67 * Get name. |
| 68 * |
| 68 * @return the name of the session ticket key | 69 * @return the name of the session ticket key |
| 69 */ | 70 */ |
| 70 public byte[] getName() { | 71 public byte[] getName() { |
| 71 return name; | 72 return name.clone(); |
| 72 } | 73 } |
| 73 | 74 |
| 74 /** | 75 /** |
| 75 * Get HMAC key. | 76 * Get HMAC key. |
| 76 * @return the HMAC key of the session ticket key | 77 * @return the HMAC key of the session ticket key |
| 77 */ | 78 */ |
| 78 public byte[] getHmacKey() { | 79 public byte[] getHmacKey() { |
| 79 return hmacKey; | 80 return hmacKey.clone(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 /** | 83 /** |
| 83 * Get AES Key. | 84 * Get AES Key. |
| 84 * @return the AES key of the session ticket key | 85 * @return the AES key of the session ticket key |
| 85 */ | 86 */ |
| 86 public byte[] getAesKey() { | 87 public byte[] getAesKey() { |
| 87 return aesKey; | 88 return aesKey.clone(); |
| 88 } | 89 } |
| 89 } | 90 } |
| OLD | NEW |