VOL-4934: MIC (AES-128) calculation bugfix for Extended Message set frames
Change-Id: I5035f9c146c736325184313dfba3aa3c5e1dba72
diff --git a/VERSION b/VERSION
index b1b25a5..5859406 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.2.2
+2.2.3
diff --git a/omci.go b/omci.go
index f778382..f14c781 100644
--- a/omci.go
+++ b/omci.go
@@ -198,18 +198,23 @@
}
func calculateMicAes128(data []byte) (uint32, error) {
- // See if upstream or downstream
+ // See if upstream or downstream. OMCI header should have been validated before this call
var downstreamCDir = [...]byte{0x01}
var upstreamCDir = [...]byte{0x02}
tid := binary.BigEndian.Uint16(data[0:2])
+
+ var length = 44
+ if DeviceIdent(data[3]) == ExtendedIdent {
+ length = 10 + int(binary.BigEndian.Uint16(data[8:10]))
+ }
var sum []byte
var err error
if (data[2]&me.AK) == me.AK || tid == 0 {
- sum, err = aes.Sum(append(upstreamCDir[:], data[:44]...), omciIK, 4)
+ sum, err = aes.Sum(append(upstreamCDir[:], data[:length]...), omciIK, 4)
} else {
- sum, err = aes.Sum(append(downstreamCDir[:], data[:44]...), omciIK, 4)
+ sum, err = aes.Sum(append(downstreamCDir[:], data[:length]...), omciIK, 4)
}
if err != nil {
return 0, err