package crypto

import (
	
	

	

	
)

func ( int) int { return 16 + (16 - ( % 16)) }

// encryptMessage encrypts plaintext using AES-IGE.
func ( Cipher) ( AuthKey,  *bin.Buffer) (EncryptedMessage, error) {
	 := len(.Buf)
	.Buf = append(.Buf, make([]byte, countPadding())...)
	if ,  := io.ReadFull(.rand, .Buf[:]);  != nil {
		return EncryptedMessage{}, 
	}

	 := MessageKey(.Value, .Buf, .encryptSide)
	,  := Keys(.Value, , .encryptSide)
	,  := aes.NewCipher([:])
	if  != nil {
		return EncryptedMessage{}, 
	}
	 := EncryptedMessage{
		AuthKeyID:     .ID,
		MsgKey:        ,
		EncryptedData: make([]byte, len(.Buf)),
	}
	ige.EncryptBlocks(, [:], .EncryptedData, .Buf)
	return , nil
}

// Encrypt encrypts EncryptedMessageData using AES-IGE to given buffer.
func ( Cipher) ( AuthKey,  EncryptedMessageData,  *bin.Buffer) error {
	.Reset()
	if  := .EncodeWithoutCopy();  != nil {
		return 
	}

	,  := .encryptMessage(, )
	if  != nil {
		return 
	}

	.Reset()
	if  := .Encode();  != nil {
		return 
	}

	return nil
}