code: public byte[] getKey() {
      if (result == null) {
        return null;
      }
      if (result.getKeyData().size() < KEY_LENGTH) {
        throw new IllegalStateException("Could not get enough key data from the handshake.");
      }
      byte[] key = new byte[KEY_LENGTH];
      result.getKeyData().copyTo(key, 0, 0, KEY_LENGTH);
      return key;
    }
docs: Returns the resulting key of the handshake, if the handshake is completed. Note that the key
  data returned from the handshake may be more than the key length required for the record
  protocol, thus we need to truncate to the right size.