mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
crypto/internal/hpke: rename Receipient to Recipient
receipient -> recipient Change-Id: I9ed5937acf0f3808283e35221f8b4f41408eee7c GitHub-Last-Rev: 0ed5ff7a46808d5311af3620b6577734a1e557f4 GitHub-Pull-Request: golang/go#73131 Reviewed-on: https://go-review.googlesource.com/c/go/+/662175 Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Auto-Submit: Filippo Valsorda <filippo@golang.org> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
This commit is contained in:
parent
c8b589e266
commit
760f22848d
@ -144,7 +144,7 @@ type Sender struct {
|
|||||||
*context
|
*context
|
||||||
}
|
}
|
||||||
|
|
||||||
type Receipient struct {
|
type Recipient struct {
|
||||||
*context
|
*context
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ func SetupSender(kemID, kdfID, aeadID uint16, pub *ecdh.PublicKey, info []byte)
|
|||||||
return encapsulatedKey, &Sender{context}, nil
|
return encapsulatedKey, &Sender{context}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetupReceipient(kemID, kdfID, aeadID uint16, priv *ecdh.PrivateKey, info, encPubEph []byte) (*Receipient, error) {
|
func SetupRecipient(kemID, kdfID, aeadID uint16, priv *ecdh.PrivateKey, info, encPubEph []byte) (*Recipient, error) {
|
||||||
kem, err := newDHKem(kemID)
|
kem, err := newDHKem(kemID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -274,7 +274,7 @@ func SetupReceipient(kemID, kdfID, aeadID uint16, priv *ecdh.PrivateKey, info, e
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Receipient{context}, nil
|
return &Recipient{context}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *context) nextNonce() []byte {
|
func (ctx *context) nextNonce() []byte {
|
||||||
@ -300,7 +300,7 @@ func (s *Sender) Seal(aad, plaintext []byte) ([]byte, error) {
|
|||||||
return ciphertext, nil
|
return ciphertext, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Receipient) Open(aad, ciphertext []byte) ([]byte, error) {
|
func (r *Recipient) Open(aad, ciphertext []byte) ([]byte, error) {
|
||||||
plaintext, err := r.aead.Open(nil, r.nextNonce(), ciphertext, aad)
|
plaintext, err := r.aead.Open(nil, r.nextNonce(), ciphertext, aad)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -126,7 +126,7 @@ func TestRFC9180Vectors(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
receipient, err := SetupReceipient(
|
recipient, err := SetupRecipient(
|
||||||
uint16(kemID),
|
uint16(kemID),
|
||||||
uint16(kdfID),
|
uint16(kdfID),
|
||||||
uint16(aeadID),
|
uint16(aeadID),
|
||||||
@ -138,7 +138,7 @@ func TestRFC9180Vectors(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ctx := range []*context{sender.context, receipient.context} {
|
for _, ctx := range []*context{sender.context, recipient.context} {
|
||||||
expectedSharedSecret := mustDecodeHex(t, setup["shared_secret"])
|
expectedSharedSecret := mustDecodeHex(t, setup["shared_secret"])
|
||||||
if !bytes.Equal(ctx.sharedSecret, expectedSharedSecret) {
|
if !bytes.Equal(ctx.sharedSecret, expectedSharedSecret) {
|
||||||
t.Errorf("unexpected shared secret, got: %x, want %x", ctx.sharedSecret, expectedSharedSecret)
|
t.Errorf("unexpected shared secret, got: %x, want %x", ctx.sharedSecret, expectedSharedSecret)
|
||||||
@ -164,7 +164,7 @@ func TestRFC9180Vectors(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
sender.seqNum = uint128{lo: uint64(seqNum)}
|
sender.seqNum = uint128{lo: uint64(seqNum)}
|
||||||
receipient.seqNum = uint128{lo: uint64(seqNum)}
|
recipient.seqNum = uint128{lo: uint64(seqNum)}
|
||||||
expectedNonce := mustDecodeHex(t, enc["nonce"])
|
expectedNonce := mustDecodeHex(t, enc["nonce"])
|
||||||
computedNonce := sender.nextNonce()
|
computedNonce := sender.nextNonce()
|
||||||
if !bytes.Equal(computedNonce, expectedNonce) {
|
if !bytes.Equal(computedNonce, expectedNonce) {
|
||||||
@ -181,7 +181,7 @@ func TestRFC9180Vectors(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expectedPlaintext := mustDecodeHex(t, enc["pt"])
|
expectedPlaintext := mustDecodeHex(t, enc["pt"])
|
||||||
plaintext, err := receipient.Open(mustDecodeHex(t, enc["aad"]), mustDecodeHex(t, enc["ct"]))
|
plaintext, err := recipient.Open(mustDecodeHex(t, enc["aad"]), mustDecodeHex(t, enc["ct"]))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,7 @@ func decodeInnerClientHello(outer *clientHelloMsg, encoded []byte) (*clientHello
|
|||||||
return inner, nil
|
return inner, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func decryptECHPayload(context *hpke.Receipient, hello, payload []byte) ([]byte, error) {
|
func decryptECHPayload(context *hpke.Recipient, hello, payload []byte) ([]byte, error) {
|
||||||
outerAAD := bytes.Replace(hello[4:], payload, make([]byte, len(payload)), 1)
|
outerAAD := bytes.Replace(hello[4:], payload, make([]byte, len(payload)), 1)
|
||||||
return context.Open(outerAAD, payload)
|
return context.Open(outerAAD, payload)
|
||||||
}
|
}
|
||||||
@ -613,7 +613,7 @@ func (c *Conn) processECHClientHello(outer *clientHelloMsg) (*clientHelloMsg, *e
|
|||||||
return nil, nil, fmt.Errorf("tls: invalid EncryptedClientHelloKeys PrivateKey: %s", err)
|
return nil, nil, fmt.Errorf("tls: invalid EncryptedClientHelloKeys PrivateKey: %s", err)
|
||||||
}
|
}
|
||||||
info := append([]byte("tls ech\x00"), echKey.Config...)
|
info := append([]byte("tls ech\x00"), echKey.Config...)
|
||||||
hpkeContext, err := hpke.SetupReceipient(hpke.DHKEM_X25519_HKDF_SHA256, echCiphersuite.KDFID, echCiphersuite.AEADID, echPriv, info, encap)
|
hpkeContext, err := hpke.SetupRecipient(hpke.DHKEM_X25519_HKDF_SHA256, echCiphersuite.KDFID, echCiphersuite.AEADID, echPriv, info, encap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// attempt next trial decryption
|
// attempt next trial decryption
|
||||||
continue
|
continue
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
const maxClientPSKIdentities = 5
|
const maxClientPSKIdentities = 5
|
||||||
|
|
||||||
type echServerContext struct {
|
type echServerContext struct {
|
||||||
hpkeContext *hpke.Receipient
|
hpkeContext *hpke.Recipient
|
||||||
configID uint8
|
configID uint8
|
||||||
ciphersuite echCipher
|
ciphersuite echCipher
|
||||||
transcript hash.Hash
|
transcript hash.Hash
|
||||||
|
Loading…
x
Reference in New Issue
Block a user