Skip to content

Commit

Permalink
Address always nil parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
armfazh committed Apr 12, 2023
1 parent 2475a3f commit c7845aa
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
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

0 comments on commit c7845aa

Please sign in to comment.