package crypto

import (
	
	
	
	

	
	
	
	
)

// RFC https://tools.ietf.org/html/rfc8009

// Aes256CtsHmacSha384192 implements Kerberos encryption type aes256-cts-hmac-sha384-192
type Aes256CtsHmacSha384192 struct {
}

// GetETypeID returns the EType ID number.
func ( Aes256CtsHmacSha384192) () int32 {
	return etypeID.AES256_CTS_HMAC_SHA384_192
}

// GetHashID returns the checksum type ID number.
func ( Aes256CtsHmacSha384192) () int32 {
	return chksumtype.HMAC_SHA384_192_AES256
}

// GetKeyByteSize returns the number of bytes for key of this etype.
func ( Aes256CtsHmacSha384192) () int {
	return 192 / 8
}

// GetKeySeedBitLength returns the number of bits for the seed for key generation.
func ( Aes256CtsHmacSha384192) () int {
	return .GetKeyByteSize() * 8
}

// GetHashFunc returns the hash function for this etype.
func ( Aes256CtsHmacSha384192) () func() hash.Hash {
	return sha512.New384
}

// GetMessageBlockByteSize returns the block size for the etype's messages.
func ( Aes256CtsHmacSha384192) () int {
	return 1
}

// GetDefaultStringToKeyParams returns the default key derivation parameters in string form.
func ( Aes256CtsHmacSha384192) () string {
	return "00008000"
}

// GetConfounderByteSize returns the byte count for confounder to be used during cryptographic operations.
func ( Aes256CtsHmacSha384192) () int {
	return aes.BlockSize
}

// GetHMACBitLength returns the bit count size of the integrity hash.
func ( Aes256CtsHmacSha384192) () int {
	return 192
}

// GetCypherBlockBitLength returns the bit count size of the cypher block.
func ( Aes256CtsHmacSha384192) () int {
	return aes.BlockSize * 8
}

// StringToKey returns a key derived from the string provided.
func ( Aes256CtsHmacSha384192) ( string,  string,  string) ([]byte, error) {
	 := rfc8009.GetSaltP(, "aes256-cts-hmac-sha384-192")
	return rfc8009.StringToKey(, , , )
}

// RandomToKey returns a key from the bytes provided.
func ( Aes256CtsHmacSha384192) ( []byte) []byte {
	return rfc8009.RandomToKey()
}

// EncryptData encrypts the data provided.
func ( Aes256CtsHmacSha384192) (,  []byte) ([]byte, []byte, error) {
	return rfc8009.EncryptData(, , )
}

// EncryptMessage encrypts the message provided and concatenates it with the integrity hash to create an encrypted message.
func ( Aes256CtsHmacSha384192) (,  []byte,  uint32) ([]byte, []byte, error) {
	return rfc8009.EncryptMessage(, , , )
}

// DecryptData decrypts the data provided.
func ( Aes256CtsHmacSha384192) (,  []byte) ([]byte, error) {
	return rfc8009.DecryptData(, , )
}

// DecryptMessage decrypts the message provided and verifies the integrity of the message.
func ( Aes256CtsHmacSha384192) (,  []byte,  uint32) ([]byte, error) {
	return rfc8009.DecryptMessage(, , , )
}

// DeriveKey derives a key from the protocol key based on the usage value.
func ( Aes256CtsHmacSha384192) (,  []byte) ([]byte, error) {
	return rfc8009.DeriveKey(, , ), nil
}

// DeriveRandom generates data needed for key generation.
func ( Aes256CtsHmacSha384192) (,  []byte) ([]byte, error) {
	return rfc8009.DeriveRandom(, , )
}

// VerifyIntegrity checks the integrity of the ciphertext message.
// As the hash is calculated over the iv concatenated with the AES cipher output not the plaintext the pt value to this
// interface method is not use. Pass any []byte.
func ( Aes256CtsHmacSha384192) (, ,  []byte,  uint32) bool {
	// We don't need ib just there for the interface
	return rfc8009.VerifyIntegrity(, , , )
}

// GetChecksumHash returns a keyed checksum hash of the bytes provided.
func ( Aes256CtsHmacSha384192) (,  []byte,  uint32) ([]byte, error) {
	return common.GetHash(, , common.GetUsageKc(), )
}

// VerifyChecksum compares the checksum of the message bytes is the same as the checksum provided.
func ( Aes256CtsHmacSha384192) (, ,  []byte,  uint32) bool {
	,  := .GetChecksumHash(, , )
	if  != nil {
		return false
	}
	return hmac.Equal(, )
}