An Message Integrity Code, MIC, generation and verification method in Device-to-Device, D2D communications comprising: transmitting, by an announcing User Equipment, UE, a first discovery request message to a Proximity Service ProSe function entity in a Home Public Land Mobile Network, HPLMN, corresponding to the announcing UE; generating, by the ProSe function entity in the HPLMN corresponding to the announcing UE, a private key and a public key of the announcing UE; when the ProSe function entity in the HPLMN corresponding to the announcing UE receives the first discovery request message from the announcing UE; transmitting, by the ProSe function entity in the HPLMN corresponding to the announcing UE, the public key to a ProSe function entity in a Visited Public Land Mobile Network, VPLMN; receiving, by the announcing UE, a first discovery response message transmitted by the ProSe function entity in the HPLMN corresponding to the announcing UE, wherein the first discovery response message carries a private key, a current time, and a time window; using, by the announcing UE, the private key to conduct a digital signature on the current time and the time window, so as to generate a Message Integrity Code, MIC; transmitting, by a monitoring UE, a second discovery request to a ProSe function entity in a HPLMN corresponding to the monitoring UE; transmitting, by the ProSe function entity in a HPLMN corresponding to the monitoring UE, a monitoring request to the ProSe function entity in a VPLMN; receiving, by the ProSe function entity in a HPLMN corresponding to the monitoring UE, a monitoring response message from the ProSe function entity in a VPLMN containing the public key of the announcing UE; transmitting, by the ProSe function entity in the HPLMN corresponding to the monitoring UE, a second discovery response message containing the public key of the announcing UE; receiving, by the monitoring UE, the second discovery response message before receiving, by the monitoring UE, a discovery announcement message from the announcing UE, wherein the discovery announcement message carries the MIC, the current time and the time window; and verifying, by the monitoring UE, the correctness of the MIC by using the public key, so as to determine whether a discovery process is successful. transmitting, by an announcing User Equipment, UE, a first discovery request message to a Proximity Service ProSe function entity in a Home Public Land Mobile Network, HPLMN, corresponding to the announcing UE; generating, by the ProSe function entity in the HPLMN corresponding to the announcing UE, a private key and a public key of the announcing UE; when the ProSe function entity in the HPLMN corresponding to the announcing UE receives the first discovery request message from the announcing UE; transmitting, by the ProSe function entity in the HPLMN corresponding to the announcing UE, the public key to a ProSe function entity in a Visited Public Land Mobile Network, VPLMN; receiving, by the announcing UE, a first discovery response message transmitted by the ProSe function entity in the HPLMN corresponding to the announcing UE, wherein the first discovery response message carries a private key, a current time, and a time window; using, by the announcing UE, the private key to conduct a digital signature on the current time and the time window, so as to generate a Message Integrity Code, MIC; transmitting, by a monitoring UE, a second discovery request to a ProSe function entity in a HPLMN corresponding to the monitoring UE; transmitting, by the ProSe function entity in a HPLMN corresponding to the monitoring UE, a monitoring request to the ProSe function entity in a VPLMN; receiving, by the ProSe function entity in a HPLMN corresponding to the monitoring UE, a monitoring response message from the ProSe function entity in a VPLMN containing the public key of the announcing UE; transmitting, by the ProSe function entity in the HPLMN corresponding to the monitoring UE, a second discovery response message containing the public key of the announcing UE; receiving, by the monitoring UE, the second discovery response message before receiving, by the monitoring UE, a discovery announcement message from the announcing UE, wherein the discovery announcement message carries the MIC, the current time and the time window; and verifying, by the monitoring UE, the correctness of the MIC by using the public key, so as to determine whether a discovery process is successful.