public class Kwp extends Object implements KeyWrap
The minimum of 16 bytes has been chosen, because 128 bit keys are the smallest key sizes used in tink. Additionally, wrapping short keys with KWP does not use the function W and hence prevents using security arguments based on the assumption that W is strong pseudorandom. (I.e. one consequence of using a strong pseudorandom permutation as an underlying function is that leaking partial information about decrypted bytes is not useful for an attack.)
The upper bound for the key size is somewhat arbitrary. Setting an upper bound is motivated by the analysis in section A.4 of NIST SP 800 38f: forgeries of long messages is simpler than forgeries of short message.
Constructor and Description |
---|
Kwp(byte[] key)
Construct a new Instance for KWP.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
unwrap(byte[] data)
Unwraps a wrapped key.
|
byte[] |
wrap(byte[] data)
Wraps some key material
data . |
public Kwp(byte[] key) throws GeneralSecurityException
key
- the wrapping key. This is an AES key.
Supported key sizes are 128 and 256 bits.GeneralSecurityException
public byte[] wrap(byte[] data) throws GeneralSecurityException
data
.wrap
in interface KeyWrap
data
- the key to wrap.GeneralSecurityException
public byte[] unwrap(byte[] data) throws GeneralSecurityException
unwrap
in interface KeyWrap
GeneralSecurityException
- if data
fails the integrity check.