Package com.nimbusds.jose.crypto.impl
Class HMAC
- java.lang.Object
-
- com.nimbusds.jose.crypto.impl.HMAC
-
-
Constructor Summary
Constructors Constructor Description HMAC()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static byte[]
compute(String alg, byte[] secret, byte[] message, Provider provider)
Deprecated.static byte[]
compute(String alg, SecretKey secretKey, byte[] message, Provider provider)
Computes a Hash-based Message Authentication Code (HMAC) for the specified secret key and message.static byte[]
compute(SecretKey secretKey, byte[] message, Provider provider)
Computes a Hash-based Message Authentication Code (HMAC) for the specified secret key and message.static Mac
getInitMac(String alg, SecretKey secretKey, Provider provider)
Gets an initialised Message Authentication Code (MAC) service instance.static Mac
getInitMac(SecretKey secretKey, Provider provider)
Gets an initialised Message Authentication Code (MAC) service instance.
-
-
-
Constructor Detail
-
HMAC
public HMAC()
-
-
Method Detail
-
getInitMac
public static Mac getInitMac(SecretKey secretKey, Provider provider) throws JOSEException
Gets an initialised Message Authentication Code (MAC) service instance.- Parameters:
secretKey
- The secret key, with the appropriate HMAC algorithm. Must not benull
.provider
- The JCA provider, ornull
to use the default one.- Returns:
- The MAC service instance.
- Throws:
JOSEException
- If the algorithm is not supported or the MAC secret key is invalid.
-
getInitMac
public static Mac getInitMac(String alg, SecretKey secretKey, Provider provider) throws JOSEException
Gets an initialised Message Authentication Code (MAC) service instance.- Parameters:
alg
- The Java Cryptography Architecture (JCA) HMAC algorithm name. Must not benull
.secretKey
- The secret key. Its algorithm name is ignored. Must not benull
.provider
- The JCA provider, ornull
to use the default one.- Returns:
- The MAC service instance.
- Throws:
JOSEException
- If the algorithm is not supported or the MAC secret key is invalid.
-
compute
@Deprecated public static byte[] compute(String alg, byte[] secret, byte[] message, Provider provider) throws JOSEException
Deprecated.Computes a Hash-based Message Authentication Code (HMAC) for the specified secret and message.- Parameters:
alg
- The Java Cryptography Architecture (JCA) HMAC algorithm name. Must not benull
.secret
- The secret. Must not benull
.message
- The message. Must not benull
.provider
- The JCA provider, ornull
to use the default one.- Returns:
- The computed HMAC.
- Throws:
JOSEException
- If the algorithm is not supported or the MAC secret key is invalid.
-
compute
public static byte[] compute(String alg, SecretKey secretKey, byte[] message, Provider provider) throws JOSEException
Computes a Hash-based Message Authentication Code (HMAC) for the specified secret key and message.- Parameters:
alg
- The Java Cryptography Architecture (JCA) HMAC algorithm name. Must not benull
.secretKey
- The secret key. Its algorithm name is ignored. Must not benull
.message
- The message. Must not benull
.provider
- The JCA provider, ornull
to use the default one.- Returns:
- The computed HMAC.
- Throws:
JOSEException
- If the algorithm is not supported or the MAC secret key is invalid.
-
compute
public static byte[] compute(SecretKey secretKey, byte[] message, Provider provider) throws JOSEException
Computes a Hash-based Message Authentication Code (HMAC) for the specified secret key and message.- Parameters:
secretKey
- The secret key, with the appropriate HMAC algorithm. Must not benull
.message
- The message. Must not benull
.provider
- The JCA provider, ornull
to use the default one.- Returns:
- A MAC service instance.
- Throws:
JOSEException
- If the algorithm is not supported or the MAC secret key is invalid.
-
-