2026-03-14 15:39:21 +08:00
|
|
|
package symm
|
|
|
|
|
|
|
|
|
|
// CipherOptions provides a unified configuration for symmetric APIs.
|
2026-03-18 13:43:18 +08:00
|
|
|
// For AEAD modes (GCM/CCM), Nonce must be set explicitly.
|
2026-03-14 15:39:21 +08:00
|
|
|
type CipherOptions struct {
|
|
|
|
|
Mode string
|
|
|
|
|
Padding string
|
|
|
|
|
IV []byte
|
|
|
|
|
Nonce []byte
|
|
|
|
|
AAD []byte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func normalizeCipherOptions(opts *CipherOptions) CipherOptions {
|
|
|
|
|
if opts == nil {
|
|
|
|
|
return CipherOptions{}
|
|
|
|
|
}
|
|
|
|
|
return *opts
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func nonceFromOptions(opts CipherOptions) []byte {
|
2026-03-18 13:43:18 +08:00
|
|
|
return opts.Nonce
|
2026-03-14 15:39:21 +08:00
|
|
|
}
|