GCMParameterSpec
Stay organized with collections
Save and categorize content based on your preferences.
Specifies the set of parameters required by a 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
for more information on the Authenticated Encryption with
Associated Data (AEAD) algorithm, and
NIST Special Publication 800-38D, "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.
Public Constructor Summary
|
GCMParameterSpec(int tLen, byte[] src)
Constructs a GCMParameterSpec using the specified authentication
tag bit-length and IV buffer.
|
|
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.
|
Public Method Summary
byte[]
|
getIV()
Returns the Initialization Vector (IV).
|
int
|
getTLen()
Returns the authentication tag length.
|
Inherited Method Summary
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals( Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
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()
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
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(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(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()
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. |
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 |
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)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eGCMParameterSpec\u003c/code\u003e defines parameters for Galois/Counter Mode (GCM) used with \u003ccode\u003eCipher\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt requires an Initialization Vector (IV) and an authentication tag length (\u003ccode\u003etLen\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003etLen\u003c/code\u003e values are typically {128, 120, 112, 104, 96} or {64, 32} bits.\u003c/p\u003e\n"],["\u003cp\u003eOther GCM inputs like AAD, keys, and ciphertext are handled by the \u003ccode\u003eCipher\u003c/code\u003e class.\u003c/p\u003e\n"]]],[],null,["public class **GCMParameterSpec** extends [Object](../../../../reference/java/lang/Object.html) \nimplements [AlgorithmParameterSpec](../../../../reference/java/security/spec/AlgorithmParameterSpec.html) \nSpecifies the set of parameters required by a [Cipher](../../../../reference/javax/crypto/Cipher.html) using the Galois/Counter Mode (GCM) mode.\n\n\nSimple block cipher modes (such as CBC) generally require only an\ninitialization vector (such as `IvParameterSpec`),\nbut GCM needs these parameters:\n\n- `IV`: Initialization Vector (IV)\n- `tLen`: length (in bits) of authentication tag T\n\n\nIn addition to the parameters described here, other GCM inputs/output\n(Additional Authenticated Data (AAD), Keys, block ciphers,\nplain/ciphertext and authentication tags) are handled in the `Cipher` class.\n\n\nPlease see [RFC 5116](http://www.ietf.org/rfc/rfc5116.txt) for more information on the Authenticated Encryption with\nAssociated 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\nCipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC.\"\n\n\nThe GCM specification states that `tLen` may only have the\nvalues {128, 120, 112, 104, 96}, or {64, 32} for certain\napplications. Other values can be specified for this class, but not\nall CSP implementations will support them. \n\nSee Also\n\n- [Cipher](../../../../reference/javax/crypto/Cipher.html) \n\nPublic Constructor Summary\n\n|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [GCMParameterSpec](../../../../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. |\n| | [GCMParameterSpec](../../../../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. |\n\nPublic Method Summary\n\n|----------|-----------------------------------------------------------------------------------------------------------------------------|\n| byte\\[\\] | [getIV](../../../../reference/javax/crypto/spec/GCMParameterSpec.html#getIV())() Returns the Initialization Vector (IV). |\n| int | [getTLen](../../../../reference/javax/crypto/spec/GCMParameterSpec.html#getTLen())() Returns the authentication tag length. |\n\nInherited Method Summary \nFrom class [java.lang.Object](../../../../reference/java/lang/Object.html) \n\n|----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Object](../../../../reference/java/lang/Object.html) | [clone](../../../../reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |\n| boolean | [equals](../../../../reference/java/lang/Object.html#equals(java.lang.Object))([Object](../../../../reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |\n| void | [finalize](../../../../reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |\n| final [Class](../../../../reference/java/lang/Class.html)\\\u003c?\\\u003e | [getClass](../../../../reference/java/lang/Object.html#getClass())() Returns the unique instance of [Class](../../../../reference/java/lang/Class.html) that represents this object's class. |\n| int | [hashCode](../../../../reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |\n| final void | [notify](../../../../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. |\n| final void | [notifyAll](../../../../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. |\n| [String](../../../../reference/java/lang/String.html) | [toString](../../../../reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |\n| final void | [wait](../../../../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. |\n| final void | [wait](../../../../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. |\n| final void | [wait](../../../../reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |\n\nPublic Constructors \n\npublic\n**GCMParameterSpec**\n(int tLen, byte\\[\\] src) \nConstructs a GCMParameterSpec using the specified authentication\ntag bit-length and IV buffer. \n\nParameters\n\n| tLen | the authentication tag length (in bits) |\n| src | the IV source buffer. The contents of the buffer are copied to protect against subsequent modification. |\n|------|---------------------------------------------------------------------------------------------------------|\n\nThrows\n\n| [IllegalArgumentException](../../../../reference/java/lang/IllegalArgumentException.html) | if `tLen` is negative, or `src` is null. |\n|-------------------------------------------------------------------------------------------|------------------------------------------|\n\npublic\n**GCMParameterSpec**\n(int tLen, byte\\[\\] src, int offset, int len) \nConstructs a GCMParameterSpec object using the specified\nauthentication tag bit-length and a subset of the specified\nbuffer as the IV. \n\nParameters\n\n| tLen | the authentication tag length (in bits) |\n| src | the IV source buffer. The contents of the buffer are copied to protect against subsequent modification. |\n| offset | the offset in `src` where the IV starts |\n| len | the number of IV bytes |\n|--------|---------------------------------------------------------------------------------------------------------|\n\nThrows\n\n| [IllegalArgumentException](../../../../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. |\n|-------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|\n\nPublic Methods \n\npublic byte\\[\\]\n**getIV**\n() \nReturns the Initialization Vector (IV). \n\nReturns\n\n- the IV. Creates a new array each time this method is called. \n\npublic int\n**getTLen**\n() \nReturns the authentication tag length. \n\nReturns\n\n- the authentication tag length (in bits)"]]