IpSecAlgorithm

public final class IpSecAlgorithm
extends Object implements Parcelable

java.lang.Object
   ↳ android.net.IpSecAlgorithm


This class represents a single algorithm that can be used by an IpSecTransform.

Summary

Constants

String AUTH_CRYPT_AES_GCM

AES-GCM Authentication/Integrity + Encryption/Ciphering Algorithm.

String AUTH_HMAC_MD5

MD5 HMAC Authentication/Integrity Algorithm.

String AUTH_HMAC_SHA1

SHA1 HMAC Authentication/Integrity Algorithm.

String AUTH_HMAC_SHA256

SHA256 HMAC Authentication/Integrity Algorithm.

String AUTH_HMAC_SHA384

SHA384 HMAC Authentication/Integrity Algorithm.

String AUTH_HMAC_SHA512

SHA512 HMAC Authentication/Integrity Algorithm.

String CRYPT_AES_CBC

AES-CBC Encryption/Ciphering Algorithm.

Inherited constants

Fields

public static final Creator<IpSecAlgorithm> CREATOR

Parcelable Creator

Public constructors

IpSecAlgorithm(String algorithm, byte[] key)

Creates an IpSecAlgorithm of one of the supported types.

IpSecAlgorithm(String algorithm, byte[] key, int truncLenBits)

Creates an IpSecAlgorithm of one of the supported types.

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

byte[] getKey()

Get the key for this algorithm

String getName()

Get the algorithm name

int getTruncationLengthBits()

Get the truncation length of this algorithm, in bits

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel out, int flags)

Write to parcel

Inherited methods

Constants

AUTH_CRYPT_AES_GCM

added in API level 28
public static final String AUTH_CRYPT_AES_GCM

AES-GCM Authentication/Integrity + Encryption/Ciphering Algorithm.

Valid lengths for keying material are {160, 224, 288}.

As per RFC4106 (Section 8.1), keying material consists of a 128, 192, or 256 bit AES key followed by a 32-bit salt. RFC compliance requires that the salt must be unique per invocation with the same key.

Valid ICV (truncation) lengths are {64, 96, 128}.

Constant Value: "rfc4106(gcm(aes))"

AUTH_HMAC_MD5

added in API level 28
public static final String AUTH_HMAC_MD5

MD5 HMAC Authentication/Integrity Algorithm. This algorithm is not recommended for use in new applications and is provided for legacy compatibility with 3gpp infrastructure.

Keys for this algorithm must be 128 bits in length.

Valid truncation lengths are multiples of 8 bits from 96 to 128.

Constant Value: "hmac(md5)"

AUTH_HMAC_SHA1

added in API level 28
public static final String AUTH_HMAC_SHA1

SHA1 HMAC Authentication/Integrity Algorithm. This algorithm is not recommended for use in new applications and is provided for legacy compatibility with 3gpp infrastructure.

Keys for this algorithm must be 160 bits in length.

Valid truncation lengths are multiples of 8 bits from 96 to 160.

Constant Value: "hmac(sha1)"

AUTH_HMAC_SHA256

added in API level 28
public static final String AUTH_HMAC_SHA256

SHA256 HMAC Authentication/Integrity Algorithm.

Keys for this algorithm must be 256 bits in length.

Valid truncation lengths are multiples of 8 bits from 96 to 256.

Constant Value: "hmac(sha256)"

AUTH_HMAC_SHA384

added in API level 28
public static final String AUTH_HMAC_SHA384

SHA384 HMAC Authentication/Integrity Algorithm.

Keys for this algorithm must be 384 bits in length.

Valid truncation lengths are multiples of 8 bits from 192 to 384.

Constant Value: "hmac(sha384)"

AUTH_HMAC_SHA512

added in API level 28
public static final String AUTH_HMAC_SHA512

SHA512 HMAC Authentication/Integrity Algorithm.

Keys for this algorithm must be 512 bits in length.

Valid truncation lengths are multiples of 8 bits from 256 to 512.

Constant Value: "hmac(sha512)"

CRYPT_AES_CBC

added in API level 28
public static final String CRYPT_AES_CBC

AES-CBC Encryption/Ciphering Algorithm.

Valid lengths for this key are {128, 192, 256}.

Constant Value: "cbc(aes)"

Fields

CREATOR

added in API level 28
public static final Creator<IpSecAlgorithm> CREATOR

Parcelable Creator

Public constructors

IpSecAlgorithm

added in API level 28
public IpSecAlgorithm (String algorithm, 
                byte[] key)

Creates an IpSecAlgorithm of one of the supported types. Supported algorithm names are defined as constants in this class.

For algorithms that produce an integrity check value, the truncation length is a required parameter. See IpSecAlgorithm(String, byte[], int)

Parameters
algorithm String: name of the algorithm.

This value must never be null.

key byte: key padded to a multiple of 8 bits.

This value must never be null.

IpSecAlgorithm

added in API level 28
public IpSecAlgorithm (String algorithm, 
                byte[] key, 
                int truncLenBits)

Creates an IpSecAlgorithm of one of the supported types. Supported algorithm names are defined as constants in this class.

This constructor only supports algorithms that use a truncation length. i.e. Authentication and Authenticated Encryption algorithms.

Parameters
algorithm String: name of the algorithm.

This value must never be null.

key byte: key padded to a multiple of 8 bits.

This value must never be null.

truncLenBits int: number of bits of output hash to use.

Public methods

describeContents

added in API level 28
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

getKey

added in API level 28
public byte[] getKey ()

Get the key for this algorithm

Returns
byte[]

This value will never be null.

getName

added in API level 28
public String getName ()

Get the algorithm name

Returns
String

This value will never be null.

getTruncationLengthBits

added in API level 28
public int getTruncationLengthBits ()

Get the truncation length of this algorithm, in bits

Returns
int

toString

added in API level 28
public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

This value will never be null.

writeToParcel

added in API level 28
public void writeToParcel (Parcel out, 
                int flags)

Write to parcel

Parameters
out Parcel: The Parcel in which the object should be written.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.