hpke.mx raw

   1  // Minimal HPKE stubs for crypto/tls ECH support.
   2  // ECH (Encrypted Client Hello) is optional; these stubs allow TLS to compile.
   3  package hpke
   4  
   5  import "errors"
   6  
   7  type KDF interface {
   8  	ID() uint16
   9  }
  10  
  11  type AEAD interface {
  12  	ID() uint16
  13  }
  14  
  15  type KEM interface {
  16  	GenerateKey() (PrivateKey, error)
  17  	NewPrivateKey([]byte) (PrivateKey, error)
  18  	NewPublicKey([]byte) (PublicKey, error)
  19  	DeriveKeyPair(ikm []byte) (PrivateKey, error)
  20  }
  21  
  22  type PublicKey interface {
  23  	Bytes() []byte
  24  }
  25  
  26  type PrivateKey interface {
  27  	PublicKey() PublicKey
  28  	Bytes() []byte
  29  }
  30  
  31  type Sender struct{}
  32  
  33  func (s *Sender) Seal(aad, plaintext []byte) ([]byte, error) {
  34  	return nil, errors.New("hpke: not implemented")
  35  }
  36  
  37  type Recipient struct{}
  38  
  39  func (r *Recipient) Open(aad, ciphertext []byte) ([]byte, error) {
  40  	return nil, errors.New("hpke: not implemented")
  41  }
  42  
  43  func NewSender(pk PublicKey, kdf KDF, aead AEAD, info []byte) (enc []byte, s *Sender, err error) {
  44  	return nil, nil, errors.New("hpke: not implemented")
  45  }
  46  
  47  func NewRecipient(enc []byte, k PrivateKey, kdf KDF, aead AEAD, info []byte) (*Recipient, error) {
  48  	return nil, errors.New("hpke: not implemented")
  49  }
  50  
  51  func NewKEM(id uint16) (KEM, error)  { return nil, errors.New("hpke: KEM not implemented") }
  52  func NewKDF(id uint16) (KDF, error)  { return nil, errors.New("hpke: KDF not implemented") }
  53  func NewAEAD(id uint16) (AEAD, error) { return nil, errors.New("hpke: AEAD not implemented") }
  54