1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://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, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.wifi.util; 18 19 import com.android.internal.util.Preconditions; 20 21 import java.util.Arrays; 22 import java.util.Objects; 23 24 /** 25 * A class to store data created by {@link WifiConfigStoreEncryptionUtil}. 26 */ 27 public class EncryptedData { 28 private final byte[] mEncryptedData; 29 private final byte[] mIv; 30 EncryptedData(byte[] encryptedData, byte[] iv)31 public EncryptedData(byte[] encryptedData, byte[] iv) { 32 Preconditions.checkNotNull(encryptedData); 33 Preconditions.checkNotNull(iv); 34 mEncryptedData = encryptedData; 35 mIv = iv; 36 } 37 getEncryptedData()38 public byte[] getEncryptedData() { 39 return mEncryptedData; 40 } 41 getIv()42 public byte[] getIv() { 43 return mIv; 44 } 45 46 @Override equals(Object other)47 public boolean equals(Object other) { 48 if (!(other instanceof EncryptedData)) return false; 49 EncryptedData otherEncryptedData = (EncryptedData) other; 50 return Arrays.equals(this.mEncryptedData, otherEncryptedData.mEncryptedData) 51 && Arrays.equals(this.mIv, otherEncryptedData.mIv); 52 } 53 54 @Override hashCode()55 public int hashCode() { 56 return Objects.hash(Arrays.hashCode(mEncryptedData), Arrays.hashCode(mIv)); 57 } 58 } 59