Skip to content

Commit 57bfe90

Browse files
committed
obfuscation: add encode/decode to onion obfuscator
1 parent 18bf661 commit 57bfe90

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

obfuscation.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ func (o *OnionErrorEncrypter) EncryptError(initial bool, data []byte) []byte {
6969
return onionEncrypt(o.sharedSecret, data)
7070
}
7171

72+
// Encode writes the encrypter's shared secret to the provided io.Writer.
73+
func (o *OnionErrorEncrypter) Encode(w io.Writer) error {
74+
_, err := w.Write(o.sharedSecret[:])
75+
return err
76+
}
77+
78+
// Decode restores the encrypter's share secret from the provided io.Reader.
79+
func (o *OnionErrorEncrypter) Decode(r io.Reader) error {
80+
_, err := io.ReadFull(r, o.sharedSecret[:])
81+
return err
82+
}
83+
7284
// Circuit is used encapsulate the data which is needed for data deobfuscation.
7385
type Circuit struct {
7486
// SessionKey is the key which have been used during generation of the

0 commit comments

Comments
 (0)