1 /* 2 * Copyright (C) 2023 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 android.telephony; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.os.Parcel; 22 import android.os.Parcelable; 23 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.RetentionPolicy; 26 import java.util.Objects; 27 28 /** 29 * A single occurrence capturing a notable change to previously reported 30 * cryptography algorithms for a given network and network event. 31 * 32 * @hide 33 */ 34 public final class SecurityAlgorithmUpdate implements Parcelable { 35 private static final String TAG = "SecurityAlgorithmUpdate"; 36 37 private @ConnectionEvent int mConnectionEvent; 38 private @SecurityAlgorithm int mEncryption; 39 private @SecurityAlgorithm int mIntegrity; 40 private boolean mIsUnprotectedEmergency; 41 SecurityAlgorithmUpdate(@onnectionEvent int connectionEvent, @SecurityAlgorithm int encryption, @SecurityAlgorithm int integrity, boolean isUnprotectedEmergency)42 public SecurityAlgorithmUpdate(@ConnectionEvent int connectionEvent, 43 @SecurityAlgorithm int encryption, @SecurityAlgorithm int integrity, 44 boolean isUnprotectedEmergency) { 45 mConnectionEvent = connectionEvent; 46 mEncryption = encryption; 47 mIntegrity = integrity; 48 mIsUnprotectedEmergency = isUnprotectedEmergency; 49 } 50 SecurityAlgorithmUpdate(Parcel in)51 private SecurityAlgorithmUpdate(Parcel in) { 52 readFromParcel(in); 53 } 54 getConnectionEvent()55 public @ConnectionEvent int getConnectionEvent() { 56 return mConnectionEvent; 57 } 58 getEncryption()59 public @SecurityAlgorithm int getEncryption() { 60 return mEncryption; 61 } 62 getIntegrity()63 public @SecurityAlgorithm int getIntegrity() { 64 return mIntegrity; 65 } 66 isUnprotectedEmergency()67 public boolean isUnprotectedEmergency() { 68 return mIsUnprotectedEmergency; 69 } 70 71 @Override describeContents()72 public int describeContents() { 73 return 0; 74 } 75 76 @Override writeToParcel(Parcel out, int flags)77 public void writeToParcel(Parcel out, int flags) { 78 out.writeInt(mConnectionEvent); 79 out.writeInt(mEncryption); 80 out.writeInt(mIntegrity); 81 out.writeBoolean(mIsUnprotectedEmergency); 82 } 83 readFromParcel(@onNull Parcel in)84 private void readFromParcel(@NonNull Parcel in) { 85 mConnectionEvent = in.readInt(); 86 mEncryption = in.readInt(); 87 mIntegrity = in.readInt(); 88 mIsUnprotectedEmergency = in.readBoolean(); 89 } 90 91 public static final Parcelable.Creator<SecurityAlgorithmUpdate> CREATOR = 92 new Parcelable.Creator<SecurityAlgorithmUpdate>() { 93 public SecurityAlgorithmUpdate createFromParcel(Parcel in) { 94 return new SecurityAlgorithmUpdate(in); 95 } 96 97 public SecurityAlgorithmUpdate[] newArray(int size) { 98 return new SecurityAlgorithmUpdate[size]; 99 } 100 }; 101 102 @Override toString()103 public String toString() { 104 return TAG + ":{ mConnectionEvent = " + mConnectionEvent + " mEncryption = " + mEncryption 105 + " mIntegrity = " + mIntegrity + " mIsUnprotectedEmergency = " 106 + mIsUnprotectedEmergency; 107 } 108 109 @Override equals(Object o)110 public boolean equals(Object o) { 111 if (this == o) return true; 112 if (!(o instanceof SecurityAlgorithmUpdate)) return false; 113 SecurityAlgorithmUpdate that = (SecurityAlgorithmUpdate) o; 114 return mConnectionEvent == that.mConnectionEvent 115 && mEncryption == that.mEncryption 116 && mIntegrity == that.mIntegrity 117 && mIsUnprotectedEmergency == that.mIsUnprotectedEmergency; 118 } 119 120 @Override hashCode()121 public int hashCode() { 122 return Objects.hash(mConnectionEvent, mEncryption, mIntegrity, mIsUnprotectedEmergency); 123 } 124 125 public static final int CONNECTION_EVENT_CS_SIGNALLING_GSM = 0; 126 public static final int CONNECTION_EVENT_PS_SIGNALLING_GPRS = 1; 127 public static final int CONNECTION_EVENT_CS_SIGNALLING_3G = 2; 128 public static final int CONNECTION_EVENT_PS_SIGNALLING_3G = 3; 129 public static final int CONNECTION_EVENT_NAS_SIGNALLING_LTE = 4; 130 public static final int CONNECTION_EVENT_AS_SIGNALLING_LTE = 5; 131 public static final int CONNECTION_EVENT_VOLTE_SIP = 6; 132 public static final int CONNECTION_EVENT_VOLTE_SIP_SOS = 7; 133 public static final int CONNECTION_EVENT_VOLTE_RTP = 8; 134 public static final int CONNECTION_EVENT_VOLTE_RTP_SOS = 9; 135 public static final int CONNECTION_EVENT_NAS_SIGNALLING_5G = 10; 136 public static final int CONNECTION_EVENT_AS_SIGNALLING_5G = 11; 137 public static final int CONNECTION_EVENT_VONR_SIP = 12; 138 public static final int CONNECTION_EVENT_VONR_SIP_SOS = 13; 139 public static final int CONNECTION_EVENT_VONR_RTP = 14; 140 public static final int CONNECTION_EVENT_VONR_RTP_SOS = 15; 141 142 /** @hide */ 143 @Retention(RetentionPolicy.SOURCE) 144 @IntDef(prefix = {"CONNECTION_EVENT_"}, value = {CONNECTION_EVENT_CS_SIGNALLING_GSM, 145 CONNECTION_EVENT_PS_SIGNALLING_GPRS, CONNECTION_EVENT_CS_SIGNALLING_3G, 146 CONNECTION_EVENT_PS_SIGNALLING_3G, CONNECTION_EVENT_NAS_SIGNALLING_LTE, 147 CONNECTION_EVENT_AS_SIGNALLING_LTE, CONNECTION_EVENT_VOLTE_SIP, 148 CONNECTION_EVENT_VOLTE_SIP_SOS, CONNECTION_EVENT_VOLTE_RTP, 149 CONNECTION_EVENT_VOLTE_RTP_SOS, CONNECTION_EVENT_NAS_SIGNALLING_5G, 150 CONNECTION_EVENT_AS_SIGNALLING_5G, CONNECTION_EVENT_VONR_SIP, 151 CONNECTION_EVENT_VONR_SIP_SOS, CONNECTION_EVENT_VONR_RTP, 152 CONNECTION_EVENT_VONR_RTP_SOS}) 153 public @interface ConnectionEvent { 154 } 155 156 public static final int SECURITY_ALGORITHM_A50 = 0; 157 public static final int SECURITY_ALGORITHM_A51 = 1; 158 public static final int SECURITY_ALGORITHM_A52 = 2; 159 public static final int SECURITY_ALGORITHM_A53 = 3; 160 public static final int SECURITY_ALGORITHM_A54 = 4; 161 public static final int SECURITY_ALGORITHM_GEA0 = 14; 162 public static final int SECURITY_ALGORITHM_GEA1 = 15; 163 public static final int SECURITY_ALGORITHM_GEA2 = 16; 164 public static final int SECURITY_ALGORITHM_GEA3 = 17; 165 public static final int SECURITY_ALGORITHM_GEA4 = 18; 166 public static final int SECURITY_ALGORITHM_GEA5 = 19; 167 public static final int SECURITY_ALGORITHM_UEA0 = 29; 168 public static final int SECURITY_ALGORITHM_UEA1 = 30; 169 public static final int SECURITY_ALGORITHM_UEA2 = 31; 170 public static final int SECURITY_ALGORITHM_EEA0 = 41; 171 public static final int SECURITY_ALGORITHM_EEA1 = 42; 172 public static final int SECURITY_ALGORITHM_EEA2 = 43; 173 public static final int SECURITY_ALGORITHM_EEA3 = 44; 174 public static final int SECURITY_ALGORITHM_NEA0 = 55; 175 public static final int SECURITY_ALGORITHM_NEA1 = 56; 176 public static final int SECURITY_ALGORITHM_NEA2 = 57; 177 public static final int SECURITY_ALGORITHM_NEA3 = 58; 178 public static final int SECURITY_ALGORITHM_SIP_NO_IPSEC_CONFIG = 66; 179 public static final int SECURITY_ALGORITHM_IMS_NULL = 67; 180 public static final int SECURITY_ALGORITHM_SIP_NULL = 68; 181 public static final int SECURITY_ALGORITHM_AES_GCM = 69; 182 public static final int SECURITY_ALGORITHM_AES_GMAC = 70; 183 public static final int SECURITY_ALGORITHM_AES_CBC = 71; 184 public static final int SECURITY_ALGORITHM_DES_EDE3_CBC = 72; 185 public static final int SECURITY_ALGORITHM_AES_EDE3_CBC = 73; 186 public static final int SECURITY_ALGORITHM_HMAC_SHA1_96 = 74; 187 public static final int SECURITY_ALGORITHM_HMAC_MD5_96 = 75; 188 public static final int SECURITY_ALGORITHM_RTP = 85; 189 public static final int SECURITY_ALGORITHM_SRTP_NULL = 86; 190 public static final int SECURITY_ALGORITHM_SRTP_AES_COUNTER = 87; 191 public static final int SECURITY_ALGORITHM_SRTP_AES_F8 = 88; 192 public static final int SECURITY_ALGORITHM_SRTP_HMAC_SHA1 = 89; 193 public static final int SECURITY_ALGORITHM_ENCR_AES_GCM_16 = 99; 194 public static final int SECURITY_ALGORITHM_ENCR_AES_CBC = 100; 195 public static final int SECURITY_ALGORITHM_AUTH_HMAC_SHA2_256_128 = 101; 196 public static final int SECURITY_ALGORITHM_UNKNOWN = 113; 197 public static final int SECURITY_ALGORITHM_OTHER = 114; 198 public static final int SECURITY_ALGORITHM_ORYX = 124; 199 200 /** @hide */ 201 @Retention(RetentionPolicy.SOURCE) 202 @IntDef(prefix = {"CONNECTION_EVENT_"}, value = {SECURITY_ALGORITHM_A50, SECURITY_ALGORITHM_A51, 203 SECURITY_ALGORITHM_A52, SECURITY_ALGORITHM_A53, 204 SECURITY_ALGORITHM_A54, SECURITY_ALGORITHM_GEA0, SECURITY_ALGORITHM_GEA1, 205 SECURITY_ALGORITHM_GEA2, SECURITY_ALGORITHM_GEA3, SECURITY_ALGORITHM_GEA4, 206 SECURITY_ALGORITHM_GEA5, SECURITY_ALGORITHM_UEA0, SECURITY_ALGORITHM_UEA1, 207 SECURITY_ALGORITHM_UEA2, SECURITY_ALGORITHM_EEA0, SECURITY_ALGORITHM_EEA1, 208 SECURITY_ALGORITHM_EEA2, SECURITY_ALGORITHM_EEA3, SECURITY_ALGORITHM_NEA0, 209 SECURITY_ALGORITHM_NEA1, SECURITY_ALGORITHM_NEA2, SECURITY_ALGORITHM_NEA3, 210 SECURITY_ALGORITHM_SIP_NO_IPSEC_CONFIG, SECURITY_ALGORITHM_IMS_NULL, 211 SECURITY_ALGORITHM_SIP_NULL, SECURITY_ALGORITHM_AES_GCM, 212 SECURITY_ALGORITHM_AES_GMAC, SECURITY_ALGORITHM_AES_CBC, 213 SECURITY_ALGORITHM_DES_EDE3_CBC, SECURITY_ALGORITHM_AES_EDE3_CBC, 214 SECURITY_ALGORITHM_HMAC_SHA1_96, SECURITY_ALGORITHM_HMAC_MD5_96, 215 SECURITY_ALGORITHM_RTP, SECURITY_ALGORITHM_SRTP_NULL, 216 SECURITY_ALGORITHM_SRTP_AES_COUNTER, SECURITY_ALGORITHM_SRTP_AES_F8, 217 SECURITY_ALGORITHM_SRTP_HMAC_SHA1, SECURITY_ALGORITHM_ENCR_AES_GCM_16, 218 SECURITY_ALGORITHM_ENCR_AES_CBC, SECURITY_ALGORITHM_AUTH_HMAC_SHA2_256_128, 219 SECURITY_ALGORITHM_UNKNOWN, SECURITY_ALGORITHM_OTHER, SECURITY_ALGORITHM_ORYX}) 220 public @interface SecurityAlgorithm { 221 } 222 223 } 224