# GCMParameterSpec

public class **GCMParameterSpec** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
implements [AlgorithmParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/java/security/spec/AlgorithmParameterSpec.html) Specifies the set of parameters required by a `https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/Cipher.html` 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://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/Cipher.html`

### Public Constructor Summary

|---|---|
|   | [GCMParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/spec/GCMParameterSpec.html#GCMParameterSpec(int,%20byte[]))(int tLen, byte\[\] src) Constructs a GCMParameterSpec using the specified authentication tag bit-length and IV buffer. |
|   | [GCMParameterSpec](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/spec/GCMParameterSpec.html#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 Method Summary

|---|---|
| byte\[\] | [getIV](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/spec/GCMParameterSpec.html#getIV())() Returns the Initialization Vector (IV). |
| int | [getTLen](https://developers.google.com/j2objc/javadoc/jre/reference/javax/crypto/spec/GCMParameterSpec.html#getTLen())() Returns the authentication tag length. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Public Constructors

#### public
**GCMParameterSpec**
(int tLen, byte\[\] src)

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

##### Parameters

| tLen | the authentication tag length (in bits) |
| src | the IV source buffer. The contents of the buffer are copied to protect against subsequent modification. |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if `tLen` is negative, or `src` is null. |
|---|---|

#### 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.

##### Parameters

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

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | 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

#### public byte\[\]
**getIV**
()

Returns the Initialization Vector (IV).

##### Returns

- the IV. Creates a new array each time this method is called.

#### public int
**getTLen**
()

Returns the authentication tag length.

##### Returns

- the authentication tag length (in bits)