31 lines
916 B
Go
31 lines
916 B
Go
package aesCommon
|
|
|
|
import (
|
|
"github.com/go-playground/validator/v10"
|
|
)
|
|
|
|
// AesCipher contains a general AES structure/methods common for all AES types.
|
|
type AesCipher struct {
|
|
// Key contains the encryption Key.
|
|
Key []byte `validate:"skip"`
|
|
/*
|
|
IV contains the IV, or initialization vector.
|
|
It may also/instead refer to the nonce (number-used-once), depending on the algorithm.
|
|
*/
|
|
IV []byte `validate:"skip"`
|
|
/*
|
|
KeyLen is the length of key used (in bytes) (int(AesCipher.Bits) / 8).
|
|
|
|
Must be one of 16 (128-bit), 24 (192-bit), or 32 (256-bit).
|
|
*/
|
|
KeyLen int `validate:"oneof=16 24 32"`
|
|
// Bits is the full bit length of AesCipher.KeyLen (in bits) (AesCipher.KeyLen * 8)
|
|
Bits aesBitSize `validate:"skip"`
|
|
}
|
|
|
|
// aesBitSize is not exportable to ensure fixed size selections.
|
|
type aesBitSize int
|
|
|
|
// validate is used to validate the AesCipher.KeyLen.
|
|
var validate *validator.Validate = validator.New()
|