def createSecurityLayer(self, mode: ParserMode, isVirtualChannel: bool) -> SecurityLayer: """ Create a security layer. :param mode: the mode of the security layer (client or server) :param isVirtualChannel: True if the security layer is for a virtual channel, False if it's for slow-path data. """ if self.useTLS: layer = TLSSecurityLayer() layer.securityHeaderExpected = not isVirtualChannel return layer else: crypter = self.crypters[mode] return SecurityLayer.create(self.securitySettings.encryptionMethod, crypter)
def createSecurityLayer(self): encryptionMethod = self.serverData.security.encryptionMethod if self.useTLS: return TLSSecurityLayer() else: return SecurityLayer.create(encryptionMethod, self.crypter)