(self, M)
return C
Implements RSAES-PKCS1-V1_5-ENCRYPT() function described in section
        7.2.1 of RFC 3447.

        Input:
           M: message to be encrypted, an octet string of length mLen, where
              mLen <= k - 11 (k denotes the length in octets of the key modulus)

        Output:
           ciphertext, an octet string of length k

        On error, None is returned.
Implements RSAES-PKCS1-V1_5-ENCRYPT() function described in section
        7.2.1 of RFC 3447.
Implements RSAES - PKCS1 - V1_5 - ENCRYPT () function described in section 7 . 2 . 1 of RFC 3447 .
def _rsaes_pkcs1_v1_5_encrypt(self, M):
        """
        Implements RSAES-PKCS1-V1_5-ENCRYPT() function described in section
        7.2.1 of RFC 3447.

        Input:
           M: message to be encrypted, an octet string of length mLen, where
              mLen <= k - 11 (k denotes the length in octets of the key modulus)

        Output:
           ciphertext, an octet string of length k

        On error, None is returned.
        """

        # 1) Length checking
        mLen = len(M)
        k = self.modulusLen / 8
        if mLen > k - 11:
            warning("Key._rsaes_pkcs1_v1_5_encrypt(): message too "
                    "long (%d > %d - 11)" % (mLen, k))
            return None

        # 2) EME-PKCS1-v1_5 encoding
        PS = zerofree_randstring(k - mLen - 3)      # 2.a)
        EM = '\x00' + '\x02' + PS + '\x00' + M      # 2.b)

        # 3) RSA encryption
        m = pkcs_os2ip(EM)                          # 3.a)
        c = self._rsaep(m)                          # 3.b)
        C = pkcs_i2osp(c, k)                        # 3.c)

        return C
def _rsaes_pkcs1_v1_5_encrypt ( self , M ) : # 1) Length checking mLen = len ( M ) k = self . modulusLen / 8 if mLen > k - 11 : warning ( "Key._rsaes_pkcs1_v1_5_encrypt(): message too " "long (%d > %d - 11)" % ( mLen , k ) ) return None # 2) EME-PKCS1-v1_5 encoding PS = zerofree_randstring ( k - mLen - 3 ) # 2.a) EM = '\x00' + '\x02' + PS + '\x00' + M # 2.b) # 3) RSA encryption m = pkcs_os2ip ( EM ) # 3.a) c = self . _rsaep ( m ) # 3.b) C = pkcs_i2osp ( c , k ) # 3.c) return C