Class Kwp

  • All Implemented Interfaces:
    KeyWrap

    @Deprecated
    public class Kwp
    extends java.lang.Object
    implements KeyWrap
    Deprecated.
    Tink does not support KeyWrap anymore. This implementation was fallback code for old providers that did not implement KWP. It implements the same functionality as Cipher.getInstance("AESWRAPPAD");. Some provider use a different algorithm name: Cipher.getInstance("AES/KWP/NoPadding");.
    Implements the key wrapping primitive KWP defined in NIST SP 800 38f. The same encryption mode is also defined in RFC 5649. The NIST document is used here as a primary reference, since it contains a security analysis and further recommendations. In particular, Section 8 of NIST SP 800 38f suggests that the allowed key sizes may be restricted. The implementation in this class requires that the key sizes are in the range MIN_WRAP_KEY_SIZE and MAX_WRAP_KEY_SIZE.

    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 Summary

      Constructors 
      Constructor Description
      Kwp​(byte[] key)
      Deprecated.
      Construct a new Instance for KWP.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      byte[] unwrap​(byte[] data)
      Deprecated.
      Unwraps a wrapped key.
      byte[] wrap​(byte[] data)
      Deprecated.
      Wraps some key material data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Kwp

        public Kwp​(byte[] key)
            throws java.security.GeneralSecurityException
        Deprecated.
        Construct a new Instance for KWP.
        Parameters:
        key - the wrapping key. This is an AES key. Supported key sizes are 128 and 256 bits.
        Throws:
        java.security.GeneralSecurityException
    • Method Detail

      • wrap

        public byte[] wrap​(byte[] data)
                    throws java.security.GeneralSecurityException
        Deprecated.
        Wraps some key material data.
        Specified by:
        wrap in interface KeyWrap
        Parameters:
        data - the key to wrap.
        Returns:
        the wrapped key
        Throws:
        java.security.GeneralSecurityException
      • unwrap

        public byte[] unwrap​(byte[] data)
                      throws java.security.GeneralSecurityException
        Deprecated.
        Unwraps a wrapped key.
        Specified by:
        unwrap in interface KeyWrap
        Throws:
        java.security.GeneralSecurityException - if data fails the integrity check.