def pkcs_emsa_pkcs1_v1_5_encode(M, emLen, h):
 hLen = _hashFuncParams[h][0]
 hFunc = _hashFuncParams[h][2]
 H = hFunc(M)
 hLeadingDigestInfo = _hashFuncParams[h][3]
 T = (hLeadingDigestInfo + H)
 tLen = len(T)
 if (emLen < (tLen + 11)):
  _warning('pkcs_emsa_pkcs1_v1_5_encode:intended encoded message length too short')
  return None
 PS = ('\xff' * ((emLen - tLen) - 3))
 EM = (((('\x00' + '\x01') + PS) + '\x00') + T)
 return EM

def pkcs_emsa_pkcs1_v1_5_encode ( M , emLen , h ) : hLen = _hashFuncParams [ h ] [ 0 ] hFunc = _hashFuncParams [ h ] [ 2 ] H = hFunc ( M ) hLeadingDigestInfo = _hashFuncParams [ h ] [ 3 ] T = ( hLeadingDigestInfo + H ) tLen = len ( T ) if ( emLen < ( tLen + 11 ) ) : _warning ( 'pkcs_emsa_pkcs1_v1_5_encode:intended encoded message length too short' ) return None PS = ( '\xff' * ( ( emLen - tLen ) - 3 ) ) EM = ( ( ( ( '\x00' + '\x01' ) + PS ) + '\x00' ) + T ) return EM
implements emsa-pkcs1-v1_5-encode() function described in sect .