package crypto

import (
	
	
	
	
	

	
	
	
	
)

//RFC: 3961 Section 6.3

// Des3CbcSha1Kd implements Kerberos encryption type des3-cbc-hmac-sha1-kd
type Des3CbcSha1Kd struct {
}

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

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

// GetKeyByteSize returns the number of bytes for key of this etype.
func ( Des3CbcSha1Kd) () int {
	return 24
}

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

// GetHashFunc returns the hash function for this etype.
func ( Des3CbcSha1Kd) () func() hash.Hash {
	return sha1.New
}

// GetMessageBlockByteSize returns the block size for the etype's messages.
func ( Des3CbcSha1Kd) () int {
	//For traditional CBC mode with padding, it would be the underlying cipher's block size
	return des.BlockSize
}

// GetDefaultStringToKeyParams returns the default key derivation parameters in string form.
func ( Des3CbcSha1Kd) () string {
	var  string
	return 
}

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

// GetHMACBitLength returns the bit count size of the integrity hash.
func ( Des3CbcSha1Kd) () int {
	return .GetHashFunc()().Size() * 8
}

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

// StringToKey returns a key derived from the string provided.
func ( Des3CbcSha1Kd) ( string,  string,  string) ([]byte, error) {
	if  != "" {
		return []byte{}, errors.New("s2kparams must be an empty string")
	}
	return rfc3961.DES3StringToKey(, , )
}

// RandomToKey returns a key from the bytes provided.
func ( Des3CbcSha1Kd) ( []byte) []byte {
	return rfc3961.DES3RandomToKey()
}

// DeriveRandom generates data needed for key generation.
func ( Des3CbcSha1Kd) (,  []byte) ([]byte, error) {
	,  := rfc3961.DeriveRandom(, , )
	return , 
}

// DeriveKey derives a key from the protocol key based on the usage value.
func ( Des3CbcSha1Kd) (,  []byte) ([]byte, error) {
	,  := .DeriveRandom(, )
	if  != nil {
		return nil, 
	}
	return .RandomToKey(), nil
}

// EncryptData encrypts the data provided.
func ( Des3CbcSha1Kd) (,  []byte) ([]byte, []byte, error) {
	return rfc3961.DES3EncryptData(, , )
}

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

// DecryptData decrypts the data provided.
func ( Des3CbcSha1Kd) (,  []byte) ([]byte, error) {
	return rfc3961.DES3DecryptData(, , )
}

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

// VerifyIntegrity checks the integrity of the plaintext message.
func ( Des3CbcSha1Kd) (, ,  []byte,  uint32) bool {
	return rfc3961.VerifyIntegrity(, , , , )
}

// GetChecksumHash returns a keyed checksum hash of the bytes provided.
func ( Des3CbcSha1Kd) (,  []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 ( Des3CbcSha1Kd) (, ,  []byte,  uint32) bool {
	,  := .GetChecksumHash(, , )
	if  != nil {
		return false
	}
	return hmac.Equal(, )
}