Commit b085820e authored by Antonin Coulibaly's avatar Antonin Coulibaly
Browse files

FT(Tag) Implement a tag integrity checker

parent 3038afa1
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -464,6 +464,15 @@ class PDU extends stream.Readable {
        return this._command.header.connectionID.toNumber();
    }

    /**
     * Gets the tag
     *
     * @returns {Buffer} - the tag.
     */
    getTag() {
        return this.getSlice(this._command.body.keyValue.tag);
    }

    /**
     * Test the HMAC integrity between the actual instance and the given HMAC
     * @param {Buffer} hmac - the non instance hmac to compare
@@ -475,6 +484,15 @@ class PDU extends stream.Readable {
        return this.getHMAC().equals(hmac);
    }

    /**
     * Test the Tag integrity between the actual instance and the given tag
     * @param {Buffer} tag - the non instance tag to compare
     * @returns {Boolean} - whether tag matches or not
     */
    checkTagIntegrity(tag) {
        return this.getTag().equals(tag);
    }

    /*
     * Internal implementation of the `stream.Readable` class.
     */