Package at.favre.lib.hkdf
Class HkdfMacFactory.Default
- java.lang.Object
-
- at.favre.lib.hkdf.HkdfMacFactory.Default
-
- All Implemented Interfaces:
HkdfMacFactory
- Enclosing interface:
- HkdfMacFactory
public static final class HkdfMacFactory.Default extends Object implements HkdfMacFactory
Default implementation
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface at.favre.lib.hkdf.HkdfMacFactory
HkdfMacFactory.Default
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MaccreateInstance(SecretKey key)Creates a new instance of Hmac with given key, i.e.SecretKeycreateSecretKey(byte[] rawKeyMaterial)Creates a secret key from a byte raw key material to be used withHkdfMacFactory.createInstance(SecretKey)intgetMacLengthBytes()Get the length of the mac output in bytesstatic HkdfMacFactoryhmacSha1()Deprecated.sha1 with HMAC should be fine, but not recommended for new protocols; see https://crypto.stackexchange.com/questions/26510/why-is-hmac-sha1-still-considered-securestatic HkdfMacFactoryhmacSha256()Creates a factory creating HMAC with SHA-256static HkdfMacFactoryhmacSha512()Creates a factory creating HMAC with SHA-512
-
-
-
Constructor Detail
-
Default
public Default(String macAlgorithmName)
Creates a mac factory- Parameters:
macAlgorithmName- as used byMac.getInstance(String)
-
Default
public Default(String macAlgorithmName, Provider provider)
Creates a mac factory- Parameters:
macAlgorithmName- as used byMac.getInstance(String)provider- the security provider, seeMac.getInstance(String, Provider); may be null to use default
-
-
Method Detail
-
hmacSha256
public static HkdfMacFactory hmacSha256()
Creates a factory creating HMAC with SHA-256- Returns:
- factory
-
hmacSha512
public static HkdfMacFactory hmacSha512()
Creates a factory creating HMAC with SHA-512- Returns:
- factory
-
hmacSha1
@Deprecated public static HkdfMacFactory hmacSha1()
Deprecated.sha1 with HMAC should be fine, but not recommended for new protocols; see https://crypto.stackexchange.com/questions/26510/why-is-hmac-sha1-still-considered-secureCreates a factory creating HMAC with SHA-1- Returns:
- factory
-
createInstance
public Mac createInstance(SecretKey key)
Description copied from interface:HkdfMacFactoryCreates a new instance of Hmac with given key, i.e. it must already be initialized withMac.init(Key).- Specified by:
createInstancein interfaceHkdfMacFactory- Parameters:
key- the key used, must not be null- Returns:
- a new mac instance
-
getMacLengthBytes
public int getMacLengthBytes()
Description copied from interface:HkdfMacFactoryGet the length of the mac output in bytes- Specified by:
getMacLengthBytesin interfaceHkdfMacFactory- Returns:
- the length of mac output in bytes
-
createSecretKey
public SecretKey createSecretKey(byte[] rawKeyMaterial)
Description copied from interface:HkdfMacFactoryCreates a secret key from a byte raw key material to be used withHkdfMacFactory.createInstance(SecretKey)- Specified by:
createSecretKeyin interfaceHkdfMacFactory- Parameters:
rawKeyMaterial- the raw key- Returns:
- wrapped as secret key instance or null if input is null or empty
-
-