mirror of
https://github.com/number571/go-peer.git
synced 2026-09-14 11:05:42 +05:00
update
This commit is contained in:
parent
b80e6ccf10
commit
4fdcab32db
@ -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()
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="code lines: 12546"><title>code lines: 12546</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="96" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="57" height="20" fill="#555"/><rect x="57" width="40" height="20" fill="#4682b4"/><rect width="96" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="295" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">code lines</text><text x="295" y="140" transform="scale(.1)" fill="#fff" textLength="510">code lines</text><text aria-hidden="true" x="770" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="320">12546</text><text x="770" y="140" transform="scale(.1)" fill="#fff" textLength="320">12546</text></g></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="code lines: 12547"><title>code lines: 12547</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="96" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="57" height="20" fill="#555"/><rect x="57" width="40" height="20" fill="#4682b4"/><rect width="96" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="295" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">code lines</text><text x="295" y="140" transform="scale(.1)" fill="#fff" textLength="510">code lines</text><text aria-hidden="true" x="770" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="320">12547</text><text x="770" y="140" transform="scale(.1)" fill="#fff" textLength="320">12547</text></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in New Issue
Block a user