def __init__(self, security_policy): self._sequence_number = 0 self._peer_sequence_number = None self._incoming_parts = [] self._security_policy = security_policy self._policies = [] self.channel = auto.OpenSecureChannelResult() self._old_tokens = [] self._open = False self._max_chunk_size = 65536
def open(self, params, server): """ called on server side to open secure channel """ if not self._open or params.RequestType == auto.SecurityTokenRequestType.Issue: self._open = True self.channel = auto.OpenSecureChannelResult() self.channel.SecurityToken.TokenId = 13 # random value self.channel.SecurityToken.ChannelId = server.get_new_channel_id() self.channel.SecurityToken.RevisedLifetime = params.RequestedLifetime else: self._old_tokens.append(self.channel.SecurityToken.TokenId) self.channel.SecurityToken.TokenId += 1 self.channel.SecurityToken.CreatedAt = datetime.utcnow() self.channel.SecurityToken.RevisedLifetime = params.RequestedLifetime self.channel.ServerNonce = utils.create_nonce( self._security_policy.symmetric_key_size) self._security_policy.make_symmetric_key(self.channel.ServerNonce, params.ClientNonce) return self.channel