Working end to end with in-memory data store.
This commit is contained in:
parent
320dc46010
commit
426500df45
7 changed files with 313 additions and 27 deletions
17
internal/server/client/encryption.go
Normal file
17
internal/server/client/encryption.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"crypto/ecdh"
|
||||
|
||||
"github.com/AYM1607/ccclip/pkg/api"
|
||||
"github.com/AYM1607/ccclip/pkg/crypto"
|
||||
)
|
||||
|
||||
func encryptForAll(plaintext string, pvk *ecdh.PrivateKey, devices []*api.Device) map[string][]byte {
|
||||
res := map[string][]byte{}
|
||||
for _, d := range devices {
|
||||
key := crypto.NewSharedKey(pvk, crypto.PublicKeyFromBytes(d.PublicKey), crypto.SendDirection)
|
||||
res[d.ID] = crypto.Encrypt(key, []byte(plaintext))
|
||||
}
|
||||
return res
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue