def generate(self, key_size=DEFAULT_AES_KEY_SIZE):
        """
        Generate a new AES key with the corresponding HMAC key.

        :rtype: :class:`AESKey`
        """
        if key_size < MINIMUM_AES_KEY_SIZE:
            raise ValueError("Unsafe key size: %s" % (key_size))

        aes_key_bytes = os.urandom(int(key_size / 8))
        aes_key_string = Base64WSEncode(aes_key_bytes)

        hmac_key_bytes = os.urandom(int(key_size / 8))
        hmac_key_string = Base64WSEncode(hmac_key_bytes)

        return AESKey(
            aes_key_string=aes_key_string,
            hmac_key_string=hmac_key_string,
            hmac_key_size=key_size,
            mode="CBC",
            size=key_size,
        )

        Generate a new AES key with the corresponding HMAC key.

        :rtype: :class:`AESKey`
        
st2common/st2common/util/crypto.py