def encodeDERTRequest(negoTypes = [], authInfo = None, pubKeyAuth = None):
    """
    @summary: create TSRequest from list of Type
    @param negoTypes: {list(Type)}
    @param authInfo: {str} authentication info TSCredentials encrypted with authentication protocol
    @param pubKeyAuth: {str} public key encrypted with authentication protocol
    @return: {str} TRequest der encoded
    """
    negoData = NegoData().subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 1))
    
    #fill nego data tokens
    i = 0
    for negoType in negoTypes:
        s = Stream()
        s.writeType(negoType)
        negoToken = NegoToken()
        negoToken.setComponentByPosition(0, s.getvalue())
        negoData.setComponentByPosition(i, negoToken)
        i += 1
        
    request = TSRequest()
    request.setComponentByName("version", univ.Integer(2).subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 0)))
    
    if i > 0:
        request.setComponentByName("negoTokens", negoData)
    
    if not authInfo is None:
        request.setComponentByName("authInfo", univ.OctetString(authInfo).subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 2)))
    
    if not pubKeyAuth is None:
        request.setComponentByName("pubKeyAuth", univ.OctetString(pubKeyAuth).subtype(explicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatConstructed, 3))) 
        
    return der_encoder.encode(request)
def encodeDERTRequest ( negoTypes = [ ] , authInfo = None , pubKeyAuth = None ) : negoData = NegoData ( ) . subtype ( explicitTag = tag . Tag ( tag . tagClassContext , tag . tagFormatConstructed , 1 ) ) i = 0 for negoType in negoTypes : s = Stream ( ) s . writeType ( negoType ) negoToken = NegoToken ( ) negoToken . setComponentByPosition ( 0 , s . getvalue ( ) ) negoData . setComponentByPosition ( i , negoToken ) i += 1 request = TSRequest ( ) request . setComponentByName ( "version" , univ . Integer ( 2 ) . subtype ( explicitTag = tag . Tag ( tag . tagClassContext , tag . tagFormatConstructed , 0 ) ) ) if i > 0 : request . setComponentByName ( "negoTokens" , negoData ) if not authInfo is None : request . setComponentByName ( "authInfo" , univ . OctetString ( authInfo ) . subtype ( explicitTag = tag . Tag ( tag . tagClassContext , tag . tagFormatConstructed , 2 ) ) ) if not pubKeyAuth is None : request . setComponentByName ( "pubKeyAuth" , univ . OctetString ( pubKeyAuth ) . subtype ( explicitTag = tag . Tag ( tag . tagClassContext , tag . tagFormatConstructed , 3 ) ) ) return der_encoder . encode ( request )
@summary: create TSRequest from list of Type
    @param negoTypes: {list(Type)}
    @param authInfo: {str} authentication info TSCredentials encrypted with authentication protocol
    @param pubKeyAuth: {str} public key encrypted with authentication protocol
    @return: {str} TRequest der encoded