Stay organized with collections
Save and categorize content based on your preferences.
ChaCha20ParameterSpec
class ChaCha20ParameterSpec : AlgorithmParameterSpec
This class specifies the parameters used with the ChaCha20 algorithm.
The parameters consist of a 12-byte nonce and an initial counter value expressed as a 32-bit integer.
This class can be used to initialize a Cipher
object that implements the ChaCha20 algorithm.
Summary
Public constructors |
Constructs a parameter set for ChaCha20 from the given nonce and counter.
|
Public methods |
Int |
Returns the configured counter value.
|
ByteArray! |
Returns the nonce value.
|
Public constructors
ChaCha20ParameterSpec
ChaCha20ParameterSpec(
nonce: ByteArray!,
counter: Int)
Constructs a parameter set for ChaCha20 from the given nonce and counter.
Parameters |
nonce |
ByteArray!: a 12-byte nonce value |
counter |
Int: the initial counter value |
Exceptions |
java.lang.NullPointerException |
if nonce is null |
java.lang.IllegalArgumentException |
if nonce is not 12 bytes in length |
Public methods
getCounter
fun getCounter(): Int
Returns the configured counter value.
Return |
Int |
the counter value |
getNonce
fun getNonce(): ByteArray!
Returns the nonce value.
Return |
ByteArray! |
the nonce value. This method returns a new array each time this method is called. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-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 2025-02-10 UTC."],[],[],null,["# ChaCha20ParameterSpec\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nChaCha20ParameterSpec\n=====================\n\n```\nclass ChaCha20ParameterSpec : AlgorithmParameterSpec\n```\n\n|---|----------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [javax.crypto.spec.ChaCha20ParameterSpec](#) |\n\nThis class specifies the parameters used with the [*ChaCha20*](https://tools.ietf.org/html/rfc7539) algorithm.\n\nThe parameters consist of a 12-byte nonce and an initial counter value expressed as a 32-bit integer.\n\nThis class can be used to initialize a `Cipher` object that implements the *ChaCha20* algorithm.\n\nSummary\n-------\n\n| Public constructors ||\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [ChaCha20ParameterSpec](#ChaCha20ParameterSpec(kotlin.ByteArray,%20kotlin.Int))`(`nonce:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!`, `counter:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Constructs a parameter set for ChaCha20 from the given nonce and counter. |\n\n| Public methods ||\n|------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getCounter](#getCounter())`()` Returns the configured counter value. |\n| [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)! | [getNonce](#getNonce())`()` Returns the nonce value. |\n\nPublic constructors\n-------------------\n\n### ChaCha20ParameterSpec\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nChaCha20ParameterSpec(\n nonce: ByteArray!, \n counter: Int)\n```\n\nConstructs a parameter set for ChaCha20 from the given nonce and counter.\n\n| Parameters ||\n|-----------|-----------------------------------------------------------------------------------------------------------------|\n| `nonce` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!: a 12-byte nonce value |\n| `counter` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the initial counter value |\n\n| Exceptions ||\n|--------------------------------------|--------------------------------------|\n| `java.lang.NullPointerException` | if `nonce` is `null` |\n| `java.lang.IllegalArgumentException` | if `nonce` is not 12 bytes in length |\n\nPublic methods\n--------------\n\n### getCounter\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getCounter(): Int\n```\n\nReturns the configured counter value.\n\n| Return ||\n|----------------------------------------------------------------------------|-------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the counter value |\n\n### getNonce\n\nAdded in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getNonce(): ByteArray!\n```\n\nReturns the nonce value.\n\n| Return ||\n|------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------|\n| [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)! | the nonce value. This method returns a new array each time this method is called. |"]]