Skip to content

Commit

Permalink
chore: Fix algorithm mismatch error
Browse files Browse the repository at this point in the history
Signed-off-by: SamoKopecky <[email protected]>
  • Loading branch information
SamoKopecky committed May 4, 2023
1 parent 18f4957 commit 8545289
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions network/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ func (s *Stream) serverKeyEnc() {
ci := ClientInit{}
ci.parse(s.readPacket())
payload := ci.payload()

if ci.kemType != kem.Id || ci.signType != sign.Id {
errorReason := "Config algorithm mismtatch"
errorMsg := Error{errorReason}
s.Send(errorMsg.build(), ErrorT)
log.Fatal().
Int("kem id", int(kem.Id)).
Int("received kem id", int(ci.kemType)).
Int("sign id", int(sign.Id)).
Int("received sign id", int(ci.signType)).
Msg(errorReason)
}

signature := ci.sig
log.Debug().Msg("Verifing signature")
if !sign.F.Verify(pk, payload, signature) {
Expand All @@ -66,18 +79,6 @@ func (s *Stream) serverKeyEnc() {
log.Fatal().Msg(errorReason)
}

if ci.kemType != kem.Id || ci.signType != sign.Id {
errorReason := "Config algorithm mismtatch"
errorMsg := Error{errorReason}
s.Send(errorMsg.build(), ErrorT)
log.Fatal().
Int("kem id", int(kem.Id)).
Int("received kem id", int(ci.kemType)).
Int("sign id", int(sign.Id)).
Int("received sign id", int(ci.signType)).
Msg(errorReason)
}

log.Debug().Msg("Encapsulating shared key")
c, key := kem.F.Enc(myio.Copy(ci.eK))

Expand Down

0 comments on commit 8545289

Please sign in to comment.