Class HKDFParameterSpec.Builder
- Enclosing interface:
- HKDFParameterSpecPREVIEW
Builder is a preview API of the Java platform.
Builder builds Extract and ExtractThenExpand
 objects.
 
 The Builder is initialized via the ofExtract method of
 HKDFParameterSpec. As stated in the class description,
 addIKM and/or addSalt may be called as needed. Finally,
 an object is "built" by calling either extractOnly or
 thenExpand for Extract and ExtractThenExpand
 use-cases respectively. Note that the Builder is not
 thread-safe.
- Since:
- 24
- 
Method SummaryModifier and TypeMethodDescriptionaddIKM(byte[] ikm) Adds input keying material (IKM) to the builder.Adds input keying material (IKM) to the builder.addSalt(byte[] salt) Adds a salt to the builder.Adds a salt to the builder.Builds anExtractobject from the current state of theBuilder.thenExpand(byte[] info, int length) Builds anExtractThenExpandobject from the current state of theBuilder.
- 
Method Details- 
extractOnlyBuilds anExtractobject from the current state of theBuilder.- Returns:
- an immutable Extractobject
 
- 
thenExpandBuilds anExtractThenExpandobject from the current state of theBuilder.- Implementation Note:
- HKDF implementations will enforce that the length is not greater than 255 * HMAC length. HKDF implementations will also enforce that a {code null} info value is treated as zero-length byte array.
- Parameters:
- info- the optional context and application specific information (may be- null); the byte array is cloned to prevent subsequent modification
- length- the length of the output keying material (must be greater than 0)
- Returns:
- an immutable ExtractThenExpandobject
- Throws:
- IllegalArgumentException- if- lengthis not greater than 0
 
- 
addIKMAdds input keying material (IKM) to the builder.Users may call addIKMmultiple times when the input keying material value is to be assembled piece-meal or if part of the IKM is to be supplied by a hardware crypto device. Theikms()method of theExtractorExtractThenExpandobject that is subsequently built returns the assembled input keying material as a list ofSecretKeyobjects.- Parameters:
- ikm- the input keying material (IKM) value
- Returns:
- this builder
- Throws:
- NullPointerException- if the- ikmargument is null
 
- 
addIKMAdds input keying material (IKM) to the builder. Note that anikmbyte array of length zero will be discarded.Users may call addIKMmultiple times when the input keying material value is to be assembled piece-meal or if part of the IKM is to be supplied by a hardware crypto device. Theikms()method of theExtractorExtractThenExpandobject that is subsequently built returns the assembled input keying material as a list ofSecretKeyobjects.- Parameters:
- ikm- the input keying material (IKM) value; the- ikmbyte array will be converted to a- SecretKeySpec, which means that the byte array will be cloned inside the- SecretKeySpecconstructor
- Returns:
- this builder
- Throws:
- NullPointerException- if the- ikmargument is null
 
- 
addSaltAdds a salt to the builder.Users may call addSaltmultiple times when the salt value is to be assembled piece-meal or if part of the salt is to be supplied by a hardware crypto device. Thesalts()method of theExtractorExtractThenExpandobject that is subsequently built returns the assembled salt as a list ofSecretKeyobjects.- Parameters:
- salt- the salt value
- Returns:
- this builder
- Throws:
- NullPointerException- if the- saltis null
 
- 
addSaltAdds a salt to the builder. Note that asaltbyte array of length zero will be discarded.Users may call addSaltmultiple times when the salt value is to be assembled piece-meal or if part of the salt is to be supplied by a hardware crypto device. Thesalts()method of theExtractorExtractThenExpandobject that is subsequently built returns the assembled salt as a list ofSecretKeyobjects.- Parameters:
- salt- the salt value; the- saltbyte array will be converted to a- SecretKeySpec, which means that the byte array will be cloned inside the- SecretKeySpecconstructor
- Returns:
- this builder
- Throws:
- NullPointerException- if the- saltis null
 
 
- 
Builderwhen preview features are enabled.