A method for generating a key in a communication system, comprising: generating, by an authentication credential repository and processing function network element, a cipher key, CK, and an integrity key, IK, based on a root key; generating, by the authentication credential repository and processing function network element, an intermediate key based on the CK, the IK and an operator type identifier; sending, by the authentication credential repository and processing function network element, the intermediate key to an authentication server; receiving, by the authentication server, the intermediate key; generating, by the authentication server, an anchor key based on the intermediate key; sending, by the authentication server, the anchor key to an access and mobility control function network element; generating, by the access and mobility control function network element, a key, Kamf, based on the anchor key; generating, by the access and mobility control function network element, a base station key based on the Kamf in a 3GPP access mode; sending, by the access and mobility control function network element, the base station key to a base station; receiving, by the base station, the base station key; and based on the base station key, generating, by the base station, a user plane cipher key for performing encryption protection on user plane data, a user plane integrity key for performing integrity protection on the user plane data, a control plane cipher key for performing encryption protection on control plane data, and a control plane integrity key for performing integrity protection on the control plane data. generating, by an authentication credential repository and processing function network element, a cipher key, CK, and an integrity key, IK, based on a root key; generating, by the authentication credential repository and processing function network element, an intermediate key based on the CK, the IK and an operator type identifier; sending, by the authentication credential repository and processing function network element, the intermediate key to an authentication server; receiving, by the authentication server, the intermediate key; generating, by the authentication server, an anchor key based on the intermediate key; sending, by the authentication server, the anchor key to an access and mobility control function network element; generating, by the access and mobility control function network element, a key, Kamf, based on the anchor key; generating, by the access and mobility control function network element, a base station key based on the Kamf in a 3GPP access mode; sending, by the access and mobility control function network element, the base station key to a base station; receiving, by the base station, the base station key; and based on the base station key, generating, by the base station, a user plane cipher key for performing encryption protection on user plane data, a user plane integrity key for performing integrity protection on the user plane data, a control plane cipher key for performing encryption protection on control plane data, and a control plane integrity key for performing integrity protection on the control plane data.