Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/javax/crypto/spec/GCMParameterSpec#pubctors) \| [Methods](https://developer.android.com/reference/javax/crypto/spec/GCMParameterSpec#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/javax/crypto/spec/GCMParameterSpec#inhmethods)

# GCMParameterSpec

` public class GCMParameterSpec `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/security/spec/AlgorithmParameterSpec `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | javax.crypto.spec.GCMParameterSpec |

<br />

*** ** * ** ***

Specifies the set of parameters required by a `https://developer.android.com/reference/javax/crypto/Cipher` using the Galois/Counter Mode (GCM) mode.

Simple block cipher modes (such as CBC) generally require only an initialization vector (such as `IvParameterSpec`), but GCM needs these parameters:

- `IV`: Initialization Vector (IV)
- `tLen`: length (in bits) of authentication tag T

In addition to the parameters described here, other GCM inputs/output (Additional Authenticated Data (AAD), Keys, block ciphers, plain/ciphertext and authentication tags) are handled in the `Cipher` class.

Please see [RFC 5116](http://www.ietf.org/rfc/rfc5116.txt) for more information on the Authenticated Encryption with Associated Data (AEAD) algorithm, and [NIST Special Publication 800-38D](http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf), "NIST Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC."

The GCM specification states that `tLen` may only have the values {128, 120, 112, 104, 96}, or {64, 32} for certain applications. Other values can be specified for this class, but not all CSP implementations will support them.
**See also:**

- `https://developer.android.com/reference/javax/crypto/Cipher`

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/crypto/spec/GCMParameterSpec#GCMParameterSpec(int,%20byte[])(int tLen, byte[] src) ` Constructs a GCMParameterSpec using the specified authentication tag bit-length and IV buffer. |
| ` https://developer.android.com/reference/javax/crypto/spec/GCMParameterSpec#GCMParameterSpec(int,%20byte[],%20int,%20int)(int tLen, byte[] src, int offset, int len) ` Constructs a GCMParameterSpec object using the specified authentication tag bit-length and a subset of the specified buffer as the IV. |

| ### Public methods ||
|---|---|
| ` byte[]` | ` https://developer.android.com/reference/javax/crypto/spec/GCMParameterSpec#getIV()() ` Returns the Initialization Vector (IV). |
| ` int` | ` https://developer.android.com/reference/javax/crypto/spec/GCMParameterSpec#getTLen()() ` Returns the authentication tag length. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### GCMParameterSpec

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public GCMParameterSpec (int tLen, 
                byte[] src)
```

Constructs a GCMParameterSpec using the specified authentication tag bit-length and IV buffer.

<br />

| Parameters ||
|---|---|
| `tLen` | `int`: the authentication tag length (in bits) <br /> |
| `src` | `byte`: the IV source buffer. The contents of the buffer are copied to protect against subsequent modification. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `tLen` is negative, or `src` is null. |

### GCMParameterSpec

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public GCMParameterSpec (int tLen, 
                byte[] src, 
                int offset, 
                int len)
```

Constructs a GCMParameterSpec object using the specified authentication tag bit-length and a subset of the specified buffer as the IV.

<br />

| Parameters ||
|---|---|
| `tLen` | `int`: the authentication tag length (in bits) <br /> |
| `src` | `byte`: the IV source buffer. The contents of the buffer are copied to protect against subsequent modification. <br /> |
| `offset` | `int`: the offset in `src` where the IV starts <br /> |
| `len` | `int`: the number of IV bytes <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `tLen` is negative, `src` is null, `len` or `offset` is negative, or the sum of `offset` and `len` is greater than the length of the `src` byte array. |

## Public methods

### getIV

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public byte[] getIV ()
```

Returns the Initialization Vector (IV).

<br />

| Returns ||
|---|---|
| `byte[]` | the IV. Creates a new array each time this method is called. <br /> |

### getTLen

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getTLen ()
```

Returns the authentication tag length.

<br />

| Returns ||
|---|---|
| `int` | the authentication tag length (in bits) <br /> |