(self, C, h=None, mgf=None, L=None)
return M
Internal method providing RSAES-OAEP-DECRYPT as defined in Sect.
        7.1.2 of RFC 3447. Not intended to be used directly. Please, see
        encrypt() method for type "OAEP".


        Input:
           C  : ciphertext to be decrypted, an octet string of length k, where
                k = 2*hLen + 2 (k denotes the length in octets of the RSA modulus
                and hLen the length in octets of the hash function output)
           h  : hash function name (in 'md2', 'md4', 'md5', 'sha1', 'tls',
                'sha256', 'sha384'). 'sha1' is used if none is provided.
           mgf: the mask generation function f : seed, maskLen -> mask
           L  : optional label whose association with the message is to be
                verified; the default value for L, if not provided is the empty
                string.

        Output:
           message, an octet string of length k mLen, where mLen <= k - 2*hLen - 2

        On error, None is returned.
Internal method providing RSAES-OAEP-DECRYPT as defined in Sect.
        7.1.2 of RFC 3447. Not intended to be used directly. Please, see
        encrypt() method for type "OAEP".
Internal method providing RSAES - OAEP - DECRYPT as defined in Sect . 7 . 1 . 2 of RFC 3447 . Not intended to be used directly . Please see encrypt () method for type OAEP .
def _rsaes_oaep_decrypt(self, C, h=None, mgf=None, L=None):
        """
        Internal method providing RSAES-OAEP-DECRYPT as defined in Sect.
        7.1.2 of RFC 3447. Not intended to be used directly. Please, see
        encrypt() method for type "OAEP".


        Input:
           C  : ciphertext to be decrypted, an octet string of length k, where
                k = 2*hLen + 2 (k denotes the length in octets of the RSA modulus
                and hLen the length in octets of the hash function output)
           h  : hash function name (in 'md2', 'md4', 'md5', 'sha1', 'tls',
                'sha256', 'sha384'). 'sha1' is used if none is provided.
           mgf: the mask generation function f : seed, maskLen -> mask
           L  : optional label whose association with the message is to be
                verified; the default value for L, if not provided is the empty
                string.

        Output:
           message, an octet string of length k mLen, where mLen <= k - 2*hLen - 2

        On error, None is returned.
        """
        # The steps below are the one described in Sect. 7.1.2 of RFC 3447.

        # 1) Length Checking
                                                    # 1.a) is not done
        if h is None:
            h = "sha1"
        if not _hashFuncParams.has_key(h):
            warning("Key._rsaes_oaep_decrypt(): unknown hash function %s.", h)
            return None
        hLen = _hashFuncParams[h][0]
        hFun = _hashFuncParams[h][1]
        k = self.modulusLen / 8
        cLen = len(C)
        if cLen != k:                               # 1.b)
            warning("Key._rsaes_oaep_decrypt(): decryption error. "
                    "(cLen != k)")
            return None
        if k < 2*hLen + 2:
            warning("Key._rsaes_oaep_decrypt(): decryption error. "
                    "(k < 2*hLen + 2)")
            return None

        # 2) RSA decryption
        c = pkcs_os2ip(C)                           # 2.a)
        m = self._rsadp(c)                          # 2.b)
        EM = pkcs_i2osp(m, k)                       # 2.c)

        # 3) EME-OAEP decoding
        if L is None:                               # 3.a)
            L = ""
        lHash = hFun(L)
        Y = EM[:1]                                  # 3.b)
        if Y != '\x00':
            warning("Key._rsaes_oaep_decrypt(): decryption error. "
                    "(Y is not zero)")
            return None
        maskedSeed = EM[1:1+hLen]
        maskedDB = EM[1+hLen:]
        if mgf is None:
            mgf = lambda x,y: pkcs_mgf1(x, y, h)
        seedMask = mgf(maskedDB, hLen)              # 3.c)
        seed = strxor(maskedSeed, seedMask)         # 3.d)
        dbMask = mgf(seed, k - hLen - 1)            # 3.e)
        DB = strxor(maskedDB, dbMask)               # 3.f)

        # I am aware of the note at the end of 7.1.2 regarding error
        # conditions reporting but the one provided below are for _local_
        # debugging purposes. --arno

        lHashPrime = DB[:hLen]                      # 3.g)
        tmp = DB[hLen:].split('\x01', 1)
        if len(tmp) != 2:
            warning("Key._rsaes_oaep_decrypt(): decryption error. "
                    "(0x01 separator not found)")
            return None
        PS, M = tmp
        if PS != '\x00'*len(PS):
            warning("Key._rsaes_oaep_decrypt(): decryption error. "
                    "(invalid padding string)")
            return None
        if lHash != lHashPrime:
            warning("Key._rsaes_oaep_decrypt(): decryption error. "
                    "(invalid hash)")
            return None            
        return M
def _rsaes_oaep_decrypt ( self , C , h = None , mgf = None , L = None ) : # The steps below are the one described in Sect. 7.1.2 of RFC 3447. # 1) Length Checking # 1.a) is not done if h is None : h = "sha1" if not _hashFuncParams . has_key ( h ) : warning ( "Key._rsaes_oaep_decrypt(): unknown hash function %s." , h ) return None hLen = _hashFuncParams [ h ] [ 0 ] hFun = _hashFuncParams [ h ] [ 1 ] k = self . modulusLen / 8 cLen = len ( C ) if cLen != k : # 1.b) warning ( "Key._rsaes_oaep_decrypt(): decryption error. " "(cLen != k)" ) return None if k < 2 * hLen + 2 : warning ( "Key._rsaes_oaep_decrypt(): decryption error. " "(k < 2*hLen + 2)" ) return None # 2) RSA decryption c = pkcs_os2ip ( C ) # 2.a) m = self . _rsadp ( c ) # 2.b) EM = pkcs_i2osp ( m , k ) # 2.c) # 3) EME-OAEP decoding if L is None : # 3.a) L = "" lHash = hFun ( L ) Y = EM [ : 1 ] # 3.b) if Y != '\x00' : warning ( "Key._rsaes_oaep_decrypt(): decryption error. " "(Y is not zero)" ) return None maskedSeed = EM [ 1 : 1 + hLen ] maskedDB = EM [ 1 + hLen : ] if mgf is None : mgf = lambda x , y : pkcs_mgf1 ( x , y , h ) seedMask = mgf ( maskedDB , hLen ) # 3.c) seed = strxor ( maskedSeed , seedMask ) # 3.d) dbMask = mgf ( seed , k - hLen - 1 ) # 3.e) DB = strxor ( maskedDB , dbMask ) # 3.f) # I am aware of the note at the end of 7.1.2 regarding error # conditions reporting but the one provided below are for _local_ # debugging purposes. --arno lHashPrime = DB [ : hLen ] # 3.g) tmp = DB [ hLen : ] . split ( '\x01' , 1 ) if len ( tmp ) != 2 : warning ( "Key._rsaes_oaep_decrypt(): decryption error. " "(0x01 separator not found)" ) return None PS , M = tmp if PS != '\x00' * len ( PS ) : warning ( "Key._rsaes_oaep_decrypt(): decryption error. " "(invalid padding string)" ) return None if lHash != lHashPrime : warning ( "Key._rsaes_oaep_decrypt(): decryption error. " "(invalid hash)" ) return None return M