Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
number571 committed Oct 24, 2024
1 parent b80e6cc commit 4fdcab3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (p *sClient) encryptWithParams(

data := joiner.NewBytesJoiner32([][]byte{pMsg, rand.GetBytes(pPadd)})
hash := hashing.NewHMACHasher(salt, bytes.Join(
[][]byte{pkid, pRecv.ToBytes(), data},
[][]byte{pkid, pRecv.GetHasher().ToBytes(), data},
[]byte{},
)).ToBytes()

Expand Down Expand Up @@ -146,6 +146,7 @@ func (p *sClient) DecryptMessage(pMapPubKeys asymmetric.IMapPubKeys, pMsg []byte
data = decSlice[4]
)

// Get public key from map by pkid (hash)
sPubKey := pMapPubKeys.GetPubKey(pkid)
if sPubKey == nil {
return nil, nil, ErrDecodePublicKey
Expand All @@ -154,13 +155,13 @@ func (p *sClient) DecryptMessage(pMapPubKeys asymmetric.IMapPubKeys, pMsg []byte
// Validate received hash with generated hash.
check := hashing.NewHMACHasher(salt, bytes.Join(
[][]byte{
sPubKey.ToBytes(),
p.fPrivKey.GetPubKey().ToBytes(),
sPubKey.GetHasher().ToBytes(),
p.fPrivKey.GetPubKey().GetHasher().ToBytes(),
data,
},
[]byte{},
)).ToBytes()
if bytes.Equal(check, hash) {
if !bytes.Equal(check, hash) {
return nil, nil, ErrInvalidDataHash
}

Expand Down
2 changes: 1 addition & 1 deletion test/result/badge_codelines.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4fdcab3

Please sign in to comment.