Skip to content

Commit 83645ef

Browse files
committed
remove panics [squash]
Length checks are already carried out at the entry points into fat error encryption/decryption.
1 parent 8d8737e commit 83645ef

File tree

2 files changed

+0
-16
lines changed

2 files changed

+0
-16
lines changed

fat_error_decrypt.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,6 @@ const (
154154
)
155155

156156
func (o *OnionFatErrorDecrypter) shiftHmacsLeft(hmacs []byte) {
157-
if len(hmacs) != o.allHmacsLen {
158-
panic("invalid hmac block length")
159-
}
160-
161157
srcIdx := o.maxHops
162158
destIdx := 1
163159
copyLen := o.maxHops - 1
@@ -174,10 +170,6 @@ func (o *OnionFatErrorDecrypter) shiftHmacsLeft(hmacs []byte) {
174170
}
175171

176172
func (o *OnionFatErrorDecrypter) shiftPayloadsLeft(payloads []byte) {
177-
if len(payloads) != o.allPayloadsLen {
178-
panic("invalid payload block length")
179-
}
180-
181173
copy(payloads, payloads[o.payloadLen:o.maxHops*o.payloadLen])
182174
}
183175

fat_error_encrypt.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ type OnionFatErrorEncrypter struct {
2626
}
2727

2828
func (o *OnionFatErrorEncrypter) shiftHmacsRight(hmacs []byte) {
29-
if len(hmacs) != o.allHmacsLen {
30-
panic("invalid hmac block length")
31-
}
32-
3329
srcIdx := o.totalHmacs - 2
3430
destIdx := o.totalHmacs - 1
3531
copyLen := 1
@@ -47,10 +43,6 @@ func (o *OnionFatErrorEncrypter) shiftHmacsRight(hmacs []byte) {
4743
}
4844

4945
func (o *OnionFatErrorEncrypter) shiftPayloadsRight(payloads []byte) {
50-
if len(payloads) != o.allPayloadsLen {
51-
panic("invalid payload block length")
52-
}
53-
5446
copy(payloads[o.payloadLen:], payloads)
5547
}
5648

0 commit comments

Comments
 (0)