AlgorithmParameters
open class AlgorithmParameters
kotlin.Any | |
↳ | java.security.AlgorithmParameters |
This class is used as an opaque representation of cryptographic parameters.
An AlgorithmParameters
object for managing the parameters for a particular algorithm can be obtained by calling one of the getInstance
factory methods (static methods that return instances of a given class).
Once an AlgorithmParameters
object is obtained, it must be initialized via a call to init
, using an appropriate parameter specification or parameter encoding.
A transparent parameter specification is obtained from an AlgorithmParameters
object via a call to getParameterSpec
, and a byte encoding of the parameters is obtained via a call to getEncoded
.
Android provides the following AlgorithmParameters
algorithms:
Algorithm | Supported API Levels |
---|---|
AES | 1+ |
BLOWFISH | 10+ |
ChaCha20 | 28+ |
DES | 1+ |
DESede | 1+ |
DH | 1+ |
DSA | 1+ |
EC | 26+ |
GCM | 22+ |
IES | 1-8 |
OAEP | 1+ |
PBEwithHmacSHA1AndAES_128 | 26+ |
PBEwithHmacSHA1AndAES_256 | 26+ |
PBEwithHmacSHA224AndAES_128 | 26+ |
PBEwithHmacSHA224AndAES_256 | 26+ |
PBEwithHmacSHA256AndAES_128 | 26+ |
PBEwithHmacSHA256AndAES_256 | 26+ |
PBEwithHmacSHA384AndAES_128 | 26+ |
PBEwithHmacSHA384AndAES_256 | 26+ |
PBEwithHmacSHA512AndAES_128 | 26+ |
PBEwithHmacSHA512AndAES_256 | 26+ |
PKCS12PBE | 1+ |
PSS | 1-8,24+ |
Summary
Protected constructors | |
---|---|
AlgorithmParameters(paramSpi: AlgorithmParametersSpi!, provider: Provider!, algorithm: String!) Creates an AlgorithmParameters object. |
Public methods | |
---|---|
String! |
Returns the name of the algorithm associated with this parameter object. |
ByteArray! |
Returns the parameters in their primary encoding format. |
ByteArray! |
getEncoded(format: String!) Returns the parameters encoded in the specified scheme. |
open static AlgorithmParameters! |
getInstance(algorithm: String!) Returns a parameter object for the specified algorithm. |
open static AlgorithmParameters! |
getInstance(algorithm: String!, provider: String!) Returns a parameter object for the specified algorithm. |
open static AlgorithmParameters! |
getInstance(algorithm: String!, provider: Provider!) Returns a parameter object for the specified algorithm. |
T |
getParameterSpec(paramSpec: Class<T>!) Returns a (transparent) specification of this parameter object. |
Provider! |
Returns the provider of this parameter object. |
Unit |
init(paramSpec: AlgorithmParameterSpec!) Initializes this parameter object using the parameters specified in |
Unit |
Imports the specified parameters and decodes them according to the primary decoding format for parameters. |
Unit |
Imports the parameters from |
String |
toString() Returns a formatted string describing the parameters. |
Protected constructors
AlgorithmParameters
protected AlgorithmParameters(
paramSpi: AlgorithmParametersSpi!,
provider: Provider!,
algorithm: String!)
Creates an AlgorithmParameters object.
Parameters | |
---|---|
paramSpi |
AlgorithmParametersSpi!: the delegate |
provider |
Provider!: the provider |
algorithm |
String!: the algorithm |
Public methods
getAlgorithm
fun getAlgorithm(): String!
Returns the name of the algorithm associated with this parameter object.
Return | |
---|---|
String! |
the algorithm name. |
getEncoded
fun getEncoded(): ByteArray!
Returns the parameters in their primary encoding format. The primary encoding format for parameters is ASN.1, if an ASN.1 specification for this type of parameters exists.
Return | |
---|---|
ByteArray! |
the parameters encoded using their primary encoding format. |
Exceptions | |
---|---|
java.io.IOException |
on encoding errors, or if this parameter object has not been initialized. |
getEncoded
fun getEncoded(format: String!): ByteArray!
Returns the parameters encoded in the specified scheme. If format
is null, the primary encoding format for parameters is used. The primary encoding format is ASN.1, if an ASN.1 specification for these parameters exists.
Parameters | |
---|---|
format |
String!: the name of the encoding format. |
Return | |
---|---|
ByteArray! |
the parameters encoded using the specified encoding scheme. |
Exceptions | |
---|---|
java.io.IOException |
on encoding errors, or if this parameter object has not been initialized. |
getInstance
open static fun getInstance(algorithm: String!): AlgorithmParameters!
Returns a parameter object for the specified algorithm.
This method traverses the list of registered security Providers, starting with the most preferred Provider. A new AlgorithmParameters object encapsulating the AlgorithmParametersSpi implementation from the first Provider that supports the specified algorithm is returned.
Note that the list of registered providers may be retrieved via the Security.getProviders()
method.
The returned parameter object must be initialized via a call to init
, using an appropriate parameter specification or parameter encoding.
Parameters | |
---|---|
algorithm |
String!: the name of the algorithm requested. |
Return | |
---|---|
AlgorithmParameters! |
the new parameter object |
Exceptions | |
---|---|
java.security.NoSuchAlgorithmException |
if no Provider supports an AlgorithmParametersSpi implementation for the specified algorithm |
java.lang.NullPointerException |
if algorithm is null on Android 14 or above |
See Also
getInstance
open static fun getInstance(
algorithm: String!,
provider: String!
): AlgorithmParameters!
Returns a parameter object for the specified algorithm.
A new AlgorithmParameters object encapsulating the AlgorithmParametersSpi implementation from the specified provider is returned. The specified provider must be registered in the security provider list.
Note that the list of registered providers may be retrieved via the Security.getProviders()
method.
The returned parameter object must be initialized via a call to init
, using an appropriate parameter specification or parameter encoding.
Parameters | |
---|---|
algorithm |
String!: the name of the algorithm requested. |
provider |
String!: the name of the provider. |
Return | |
---|---|
AlgorithmParameters! |
the new parameter object |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if the provider name is null or empty |
java.security.NoSuchAlgorithmException |
if an AlgorithmParametersSpi implementation for the specified algorithm is not available from the specified provider |
java.security.NoSuchProviderException |
if the specified provider is not registered in the security provider list |
java.lang.NullPointerException |
if algorithm is null on Android 14 or above |
See Also
getInstance
open static fun getInstance(
algorithm: String!,
provider: Provider!
): AlgorithmParameters!
Returns a parameter object for the specified algorithm.
A new AlgorithmParameters object encapsulating the AlgorithmParametersSpi implementation from the specified Provider object is returned. Note that the specified Provider object does not have to be registered in the provider list.
The returned parameter object must be initialized via a call to init
, using an appropriate parameter specification or parameter encoding.
Parameters | |
---|---|
algorithm |
String!: the name of the algorithm requested. |
provider |
Provider!: the name of the provider. |
Return | |
---|---|
AlgorithmParameters! |
the new parameter object |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if the provider is null |
java.security.NoSuchAlgorithmException |
if an AlgorithmParameterGeneratorSpi implementation for the specified algorithm is not available from the specified Provider object |
java.lang.NullPointerException |
if algorithm is null on Android 14 or above |
See Also
getParameterSpec
fun <T : AlgorithmParameterSpec!> getParameterSpec(paramSpec: Class<T>!): T
Returns a (transparent) specification of this parameter object. paramSpec
identifies the specification class in which the parameters should be returned. It could, for example, be DSAParameterSpec.class
, to indicate that the parameters should be returned in an instance of the DSAParameterSpec
class.
Parameters | |
---|---|
<T> |
the type of the parameter specification to be returrned |
paramSpec |
Class<T>!: the specification class in which the parameters should be returned. |
Return | |
---|---|
T |
the parameter specification. |
Exceptions | |
---|---|
java.security.spec.InvalidParameterSpecException |
if the requested parameter specification is inappropriate for this parameter object, or if this parameter object has not been initialized. |
getProvider
fun getProvider(): Provider!
Returns the provider of this parameter object.
Return | |
---|---|
Provider! |
the provider of this parameter object |
init
fun init(paramSpec: AlgorithmParameterSpec!): Unit
Initializes this parameter object using the parameters specified in paramSpec
.
Parameters | |
---|---|
paramSpec |
AlgorithmParameterSpec!: the parameter specification. |
Exceptions | |
---|---|
java.security.spec.InvalidParameterSpecException |
if the given parameter specification is inappropriate for the initialization of this parameter object, or if this parameter object has already been initialized. |
init
fun init(params: ByteArray!): Unit
Imports the specified parameters and decodes them according to the primary decoding format for parameters. The primary decoding format for parameters is ASN.1, if an ASN.1 specification for this type of parameters exists.
Parameters | |
---|---|
params |
ByteArray!: the encoded parameters. |
Exceptions | |
---|---|
java.io.IOException |
on decoding errors, or if this parameter object has already been initialized. |
init
fun init(
params: ByteArray!,
format: String!
): Unit
Imports the parameters from params
and decodes them according to the specified decoding scheme. If format
is null, the primary decoding format for parameters is used. The primary decoding format is ASN.1, if an ASN.1 specification for these parameters exists.
Parameters | |
---|---|
params |
ByteArray!: the encoded parameters. |
format |
String!: the name of the decoding scheme. |
Exceptions | |
---|---|
java.io.IOException |
on decoding errors, or if this parameter object has already been initialized. |
toString
fun toString(): String
Returns a formatted string describing the parameters.
Return | |
---|---|
String |
a formatted string describing the parameters, or null if this parameter object has not been initialized. |