Imports #
"crypto"
"crypto/aes"
"crypto/cipher"
"crypto/ecdh"
"crypto/internal/fips140/hkdf"
"crypto/rand"
"errors"
"internal/byteorder"
"math/bits"
"golang.org/x/crypto/chacha20poly1305"
"crypto"
"crypto/aes"
"crypto/cipher"
"crypto/ecdh"
"crypto/internal/fips140/hkdf"
"crypto/rand"
"errors"
"internal/byteorder"
"math/bits"
"golang.org/x/crypto/chacha20poly1305"
const AEAD_AES_128_GCM = 0x0001
const AEAD_AES_256_GCM = 0x0002
const AEAD_ChaCha20Poly1305 = 0x0003
const DHKEM_X25519_HKDF_SHA256 = 0x0020
const KDF_HKDF_SHA256 = 0x0001
var SupportedAEADs = map[uint16]struct{...}{...}
var SupportedKDFs = map[uint16]func() *hkdfKDF{...}
var SupportedKEMs = map[uint16]struct{...}{...}
var aesGCMNew = *ast.FuncLit
testingOnlyGenerateKey is only used during testing, to provide a fixed test key to use when checking the RFC 9180 vectors.
var testingOnlyGenerateKey func() (*ecdh.PrivateKey, error)
type AEADID uint16
type KDFID uint16
type KemID uint16
type Receipient struct {
*context
}
type Sender struct {
*context
}
type context struct {
aead cipher.AEAD
sharedSecret []byte
suiteID []byte
key []byte
baseNonce []byte
exporterSecret []byte
seqNum uint128
}
dhKEM implements the KEM specified in RFC 9180, Section 4.1.
type dhKEM struct {
dh ecdh.Curve
kdf hkdfKDF
suiteID []byte
nSecret uint16
}
type hkdfKDF struct {
hash crypto.Hash
}
type uint128 struct {
hi uint64
lo uint64
}
func (dh *dhKEM) Decap(encPubEph []byte, secRecipient *ecdh.PrivateKey) ([]byte, error)
func (dh *dhKEM) Encap(pubRecipient *ecdh.PublicKey) (sharedSecret []byte, encapPub []byte, err error)
func (dh *dhKEM) ExtractAndExpand(dhKey []byte, kemContext []byte) []byte
func (kdf *hkdfKDF) LabeledExpand(suiteID []byte, randomKey []byte, label string, info []byte, length uint16) []byte
func (kdf *hkdfKDF) LabeledExtract(sid []byte, salt []byte, label string, inputKey []byte) []byte
func (r *Receipient) Open(aad []byte, ciphertext []byte) ([]byte, error)
func ParseHPKEPrivateKey(kemID uint16, bytes []byte) (*ecdh.PrivateKey, error)
func ParseHPKEPublicKey(kemID uint16, bytes []byte) (*ecdh.PublicKey, error)
func (s *Sender) Seal(aad []byte, plaintext []byte) ([]byte, error)
func SetupReceipient(kemID uint16, kdfID uint16, aeadID uint16, priv *ecdh.PrivateKey, info []byte, encPubEph []byte) (*Receipient, error)
func SetupSender(kemID uint16, kdfID uint16, aeadID uint16, pub *ecdh.PublicKey, info []byte) ([]byte, *Sender, error)
func (u uint128) addOne() uint128
func (u uint128) bitLen() int
func (u uint128) bytes() []byte
func (ctx *context) incrementNonce()
func newContext(sharedSecret []byte, kemID uint16, kdfID uint16, aeadID uint16, info []byte) (*context, error)
func newDHKem(kemID uint16) (*dhKEM, error)
func (ctx *context) nextNonce() []byte
func suiteID(kemID uint16, kdfID uint16, aeadID uint16) []byte
Generated with Arrow