Top Description Inners Methods
at.favre.lib.crypto

public Interface HkdfMacFactory

Known Direct Implementers
at.favre.lib.crypto.HkdfMacFactory.Default
Imports
javax.crypto.Mac, .SecretKey, javax.crypto.spec.SecretKeySpec, java.security.Key, .NoSuchAlgorithmException, .Provider

Factory class for creating Mac hashers

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
HkdfMacFactory.Default

Default implementation

Method Summary

Modifier and TypeMethod and Description
public Mac

Returns:

a new mac instance
createInstance
(SecretKey
the key used, must not be null
key
)

Creates a new instance of Hmac with given key, i.e. it must already be initialized with Mac#init(Key).

public SecretKey

Returns:

wrapped as secret key instance or null if input is null or empty
createSecretKey
(byte[]
the raw key
rawKeyMaterial
)

Creates a secret key from a byte raw key material to be used with createInstance(SecretKey)

public int

Returns:

the length of mac output in bytes
getMacLengthBytes
()

Get the length of the mac output in bytes

Method Detail

createInstanceback to summary
public Mac createInstance(SecretKey key)

Creates a new instance of Hmac with given key, i.e. it must already be initialized with Mac#init(Key).

Parameters
key:SecretKey

the key used, must not be null

Returns:Mac

a new mac instance

createSecretKeyback to summary
public SecretKey createSecretKey(byte[] rawKeyMaterial)

Creates a secret key from a byte raw key material to be used with createInstance(SecretKey)

Parameters
rawKeyMaterial:byte[]

the raw key

Returns:SecretKey

wrapped as secret key instance or null if input is null or empty

getMacLengthBytesback to summary
public int getMacLengthBytes()

Get the length of the mac output in bytes

Returns:int

the length of mac output in bytes

at.favre.lib.crypto back to summary

public final Class HkdfMacFactory.Default

extends Object
implements HkdfMacFactory
Class Inheritance
All Implemented Interfaces
at.favre.lib.crypto.HkdfMacFactory
Annotations
@SuppressWarnings:WeakerAccess

Default implementation

Field Summary

Modifier and TypeField and Description
private final String
private final Provider

Constructor Summary

AccessConstructor and Description
public
Default(String macAlgorithmName)

Creates a mac factory

public
Default(String macAlgorithmName, Provider
the security provider, see Mac#getInstance(String, Provider); may be null to use default
provider
)

Creates a mac factory

Method Summary

Modifier and TypeMethod and Description
public Mac
createInstance(SecretKey
the key used, must not be null
key
)

Implements at.favre.lib.crypto.HkdfMacFactory.createInstance.

Creates a new instance of Hmac with given key, i.e. it must already be initialized with Mac#init(Key).

private Mac
public SecretKey
createSecretKey(byte[]
the raw key
rawKeyMaterial
)

Implements at.favre.lib.crypto.HkdfMacFactory.createSecretKey.

Creates a secret key from a byte raw key material to be used with createInstance(SecretKey)

public int
getMacLengthBytes()

Implements at.favre.lib.crypto.HkdfMacFactory.getMacLengthBytes.

Get the length of the mac output in bytes

public static HkdfMacFactory

Returns:

factory
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-secure

Creates a factory creating HMAC with SHA-1

public static HkdfMacFactory

Returns:

factory
hmacSha256
()

Creates a factory creating HMAC with SHA-256

public static HkdfMacFactory

Returns:

factory
hmacSha512
()

Creates a factory creating HMAC with SHA-512

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

macAlgorithmNameback to summary
private final String macAlgorithmName
providerback to summary
private final Provider provider

Constructor Detail

Defaultback to summary
public Default(String macAlgorithmName)

Creates a mac factory

Parameters
macAlgorithmName:String

as used by Mac#getInstance(String)

Defaultback to summary
public Default(String macAlgorithmName, Provider provider)

Creates a mac factory

Parameters
macAlgorithmName:String

as used by Mac#getInstance(String)

provider:Provider

the security provider, see Mac#getInstance(String, Provider); may be null to use default

Method Detail

createInstanceback to summary
public Mac createInstance(SecretKey key)

Implements at.favre.lib.crypto.HkdfMacFactory.createInstance.

Doc from at.favre.lib.crypto.HkdfMacFactory.createInstance.

Creates a new instance of Hmac with given key, i.e. it must already be initialized with Mac#init(Key).

Parameters
key:SecretKey

the key used, must not be null

Returns:Mac

a new mac instance

Annotations
@Override
createMacInstanceback to summary
private Mac createMacInstance()
createSecretKeyback to summary
public SecretKey createSecretKey(byte[] rawKeyMaterial)

Implements at.favre.lib.crypto.HkdfMacFactory.createSecretKey.

Doc from at.favre.lib.crypto.HkdfMacFactory.createSecretKey.

Creates a secret key from a byte raw key material to be used with createInstance(SecretKey)

Parameters
rawKeyMaterial:byte[]

the raw key

Returns:SecretKey

wrapped as secret key instance or null if input is null or empty

Annotations
@Override
getMacLengthBytesback to summary
public int getMacLengthBytes()

Implements at.favre.lib.crypto.HkdfMacFactory.getMacLengthBytes.

Doc from at.favre.lib.crypto.HkdfMacFactory.getMacLengthBytes.

Get the length of the mac output in bytes

Returns:int

the length of mac output in bytes

Annotations
@Override
hmacSha1back to summary
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-secure

Creates a factory creating HMAC with SHA-1

Returns:HkdfMacFactory

factory

Annotations
@Deprecated
hmacSha256back to summary
public static HkdfMacFactory hmacSha256()

Creates a factory creating HMAC with SHA-256

Returns:HkdfMacFactory

factory

hmacSha512back to summary
public static HkdfMacFactory hmacSha512()

Creates a factory creating HMAC with SHA-512

Returns:HkdfMacFactory

factory