Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hpke: Address always nil parameter. #425

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hpke/hybridkem.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (h hybridKEM) DeriveKeyPair(seed []byte) (kem.PublicKey, kem.PrivateKey) {
}

outputSeedSize := h.kemA.SeedSize() + h.kemB.SeedSize()
dkpPrk := h.labeledExtract(nil, []byte("dkp_prk"), seed)
dkpPrk := h.labeledExtract([]byte(""), []byte("dkp_prk"), seed)
bytes := h.labeledExpand(
dkpPrk,
[]byte("sk"),
Expand Down
3 changes: 1 addition & 2 deletions hpke/kembase.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (k kemBase) getSuiteID() (sid [5]byte) {
}

func (k kemBase) extractExpand(dh, kemCtx []byte) []byte {
eaePkr := k.labeledExtract(nil, []byte("eae_prk"), dh)
eaePkr := k.labeledExtract([]byte(""), []byte("eae_prk"), dh)
return k.labeledExpand(
eaePkr,
[]byte("shared_secret"),
Expand All @@ -49,7 +49,6 @@ func (k kemBase) extractExpand(dh, kemCtx []byte) []byte {
)
}

// nolint:unparam
func (k kemBase) labeledExtract(salt, label, info []byte) []byte {
suiteID := k.getSuiteID()
labeledIKM := append(append(append(append(
Expand Down
2 changes: 1 addition & 1 deletion hpke/shortkem.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (s shortKEM) DeriveKeyPair(seed []byte) (kem.PublicKey, kem.PrivateKey) {
bitmask = 0x01
}

dkpPrk := s.labeledExtract(nil, []byte("dkp_prk"), seed)
dkpPrk := s.labeledExtract([]byte(""), []byte("dkp_prk"), seed)
var bytes []byte
ctr := 0
for skBig := new(big.Int); skBig.Sign() == 0 || skBig.Cmp(s.Params().N) >= 0; ctr++ {
Expand Down
2 changes: 1 addition & 1 deletion hpke/xkem.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (x xKEM) DeriveKeyPair(seed []byte) (kem.PublicKey, kem.PrivateKey) {
panic(kem.ErrSeedSize)
}
sk := &xKEMPrivKey{scheme: x, priv: make([]byte, x.size)}
dkpPrk := x.labeledExtract(nil, []byte("dkp_prk"), seed)
dkpPrk := x.labeledExtract([]byte(""), []byte("dkp_prk"), seed)
bytes := x.labeledExpand(
dkpPrk,
[]byte("sk"),
Expand Down