Add validation to IpSecConfig algorithm setters
Adds checks to ensure that users can only set the correct types of algorithms for the Authentication, Encryption and Authenticated Encryption algorithms. Bug: 65223935 Test: Added tests in IpSecConfigTest, and passed on aosp_marlin-eng Change-Id: I462c77d9eb5710b8d03a48866453649d3b6fc6bf
This commit is contained in:
@@ -231,6 +231,31 @@ public final class IpSecAlgorithm implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public boolean isAuthentication() {
|
||||
switch (getName()) {
|
||||
// Fallthrough
|
||||
case AUTH_HMAC_MD5:
|
||||
case AUTH_HMAC_SHA1:
|
||||
case AUTH_HMAC_SHA256:
|
||||
case AUTH_HMAC_SHA384:
|
||||
case AUTH_HMAC_SHA512:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public boolean isEncryption() {
|
||||
return getName().equals(CRYPT_AES_CBC);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public boolean isAead() {
|
||||
return getName().equals(AUTH_CRYPT_AES_GCM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder()
|
||||
|
||||
Reference in New Issue
Block a user