A gateway device for relaying a message between a plurality of domains and manages domain keys corresponding to each of the plurality of domains, the gateway device being configured to: receiving a first message corresponding to a first domain of the plurality of domains including a first message authentication code, MAC, and first data from the first domain; wherein the first message further includes ID information for identifying the first message and for locating the first domain; determining if the first MAC was generated using a first domain key associated with the first domain by determining whether the first message is a message target of MAC replacement based on MAC replacement determination information associated with the ID information; when determining that the first message is a message target of MAC replacement: - acquiring the first domain key that was used to calculate the first MAC based on the ID information and verifying the first MAC using the first domain key, - upon successful verification of the first MAC, acquiring a destination domain from the plurality of domains of the first message and a second domain key associated with the destination domain based on the ID information, - calculating a second MAC using the second domain key and generating a second message for the destination domain by combining the first data and the second MAC, - transmitting the second message to the destination domain, when determining that the first message is not a message target of MAC replacement: - determining if the first MAC was generated using an inter-domain key that is shared between the plurality of domains based on the ID information, in response to determining that the first MAC was generated using the inter-domain key that is shared between the plurality of domains, acquiring a destination domain of the first message based on the ID information and sending the first message to the destination domain, in response to determining that the first MAC was not generated using the inter-domain key that is shared between the plurality of domains, terminating the process. receiving a first message corresponding to a first domain of the plurality of domains including a first message authentication code, MAC, and first data from the first domain; wherein the first message further includes ID information for identifying the first message and for locating the first domain; determining if the first MAC was generated using a first domain key associated with the first domain by determining whether the first message is a message target of MAC replacement based on MAC replacement determination information associated with the ID information; when determining that the first message is a message target of MAC replacement: - acquiring the first domain key that was used to calculate the first MAC based on the ID information and verifying the first MAC using the first domain key, - upon successful verification of the first MAC, acquiring a destination domain from the plurality of domains of the first message and a second domain key associated with the destination domain based on the ID information, - calculating a second MAC using the second domain key and generating a second message for the destination domain by combining the first data and the second MAC, - transmitting the second message to the destination domain, - acquiring the first domain key that was used to calculate the first MAC based on the ID information and verifying the first MAC using the first domain key, - upon successful verification of the first MAC, acquiring a destination domain from the plurality of domains of the first message and a second domain key associated with the destination domain based on the ID information, - calculating a second MAC using the second domain key and generating a second message for the destination domain by combining the first data and the second MAC, - transmitting the second message to the destination domain, when determining that the first message is not a message target of MAC replacement: - determining if the first MAC was generated using an inter-domain key that is shared between the plurality of domains based on the ID information, - determining if the first MAC was generated using an inter-domain key that is shared between the plurality of domains based on the ID information, in response to determining that the first MAC was generated using the inter-domain key that is shared between the plurality of domains, acquiring a destination domain of the first message based on the ID information and sending the first message to the destination domain, in response to determining that the first MAC was not generated using the inter-domain key that is shared between the plurality of domains, terminating the process.