private static function getRSAESOAEP(RSAKey $key, string $c, Hash $hash): string
    {
        $c = self::convertOctetStringToInteger($c);
        $m = self::getRSADP($key, $c);
        $em = self::convertIntegerToOctetString($m, $key->getModulusLength());
        $lHash = $hash->hash('');
        $maskedSeed = \mb_substr($em, 1, $hash->getLength(), '8bit');
        $maskedDB = \mb_substr($em, $hash->getLength() + 1, null, '8bit');
        $seedMask = self::getMGF1($maskedDB, $hash->getLength(), $hash/*MGF*/);
        $seed = (string) ($maskedSeed ^ $seedMask);
        $dbMask = self::getMGF1($seed, $key->getModulusLength() - $hash->getLength() - 1, $hash/*MGF*/);
        $db = $maskedDB ^ $dbMask;
        $lHash2 = \mb_substr($db, 0, $hash->getLength(), '8bit');
        $m = \mb_substr($db, $hash->getLength(), null, '8bit');
        if (!\hash_equals($lHash, $lHash2)) {
            throw new \RuntimeException();
        }
        $m = \ltrim($m, \chr(0));
        if (1 !== \ord($m[0])) {
            throw new \RuntimeException();
        }

        return \mb_substr($m, 1, null, '8bit');
    }
private static function getRSAESOAEP(RSAKey $key, string $c, Hash $hash): string
    {
        $c = self::convertOctetStringToInteger($c);
        $m = self::getRSADP($key, $c);
        $em = self::convertIntegerToOctetString($m, $key->getModulusLength());
        $lHash = $hash->hash('');
        $maskedSeed = \mb_substr($em, 1, $hash->getLength(), '8bit');
        $maskedDB = \mb_substr($em, $hash->getLength() + 1, null, '8bit');
        $seedMask = self::getMGF1($maskedDB, $hash->getLength(), $hash/*MGF*/);
        $seed = (string) ($maskedSeed ^ $seedMask);
        $dbMask = self::getMGF1($seed, $key->getModulusLength() - $hash->getLength() - 1, $hash/*MGF*/);
        $db = $maskedDB ^ $dbMask;
        $lHash2 = \mb_substr($db, 0, $hash->getLength(), '8bit');
        $m = \mb_substr($db, $hash->getLength(), null, '8bit');
        if (!\hash_equals($lHash, $lHash2)) {
            throw new \RuntimeException();
        }
        $m = \ltrim($m, \chr(0));
        if (1 !== \ord($m[0])) {
            throw new \RuntimeException();
        }

        return \mb_substr($m, 1, null, '8bit');
    }
private static function getRSAESOAEP ( RSAKey $ key , string $ c , Hash $ hash ) : string { $ c = self :: convertOctetStringToInteger ( $ c ) ; $ m = self :: getRSADP ( $ key , $ c ) ; $ em = self :: convertIntegerToOctetString ( $ m , $ key -> getModulusLength ( ) ) ; $ lHash = $ hash -> hash ( '' ) ; $ maskedSeed = \ mb_substr ( $ em , 1 , $ hash -> getLength ( ) , '8bit' ) ; $ maskedDB = \ mb_substr ( $ em , $ hash -> getLength ( ) + 1 , null , '8bit' ) ; $ seedMask = self :: getMGF1 ( $ maskedDB , $ hash -> getLength ( ) , $ hash /*MGF*/ ) ; $ seed = ( string ) ( $ maskedSeed ^ $ seedMask ) ; $ dbMask = self :: getMGF1 ( $ seed , $ key -> getModulusLength ( ) - $ hash -> getLength ( ) - 1 , $ hash /*MGF*/ ) ; $ db = $ maskedDB ^ $ dbMask ; $ lHash2 = \ mb_substr ( $ db , 0 , $ hash -> getLength ( ) , '8bit' ) ; $ m = \ mb_substr ( $ db , $ hash -> getLength ( ) , null , '8bit' ) ; if ( ! \ hash_equals ( $ lHash , $ lHash2 ) ) { throw new \ RuntimeException ( ) ; } $ m = \ ltrim ( $ m , \ chr ( 0 ) ) ; if ( 1 !== \ ord ( $ m [ 0 ] ) ) { throw new \ RuntimeException ( ) ; } return \ mb_substr ( $ m , 1 , null , '8bit' ) ; }
RSAES-OAEP-DECRYPT.
RSAES - OAEP - DECRYPT .