Get shared secret from user public key and server private key.

@param string $userPublicKey

@return string
164437
private function getSharedSecret($userPublicKey)
    {
        $userPublicKeyPoint = $this->serializer->unserialize($this->curve, bin2hex($userPublicKey));
        $userPublicKeyObject = $this->generator->getPublicKeyFrom(
            $userPublicKeyPoint->getX(),
            $userPublicKeyPoint->getY(),
            $this->generator->getOrder()
        );

        $point = $userPublicKeyObject->getPoint()->mul($this->privateKey->getSecret())->getX();

        return hex2bin($this->adapter->decHex((string) $point));
    }
1010776
public static function factory($url, $privateKey = null, $publicKey = null) {
        $url = parent::factory($url);
        $user = self::getUserFromUrl($url->getPath());

        $query = $url->getQuery();
        $currentPublicKey = $query->get('publicKey') ?: false;
        $pubKeysDiffer = $currentPublicKey && $currentPublicKey !== $publicKey;

        if ($privateKey) {
            $url->setPrivateKey($privateKey);

            // If the user and the current public key are the same, remove the public key
            // as it is implied from the user. We can't do this unless we can generate a
            // new accessToken, however, so don't do this unless we have a private key
            if ($user && $user === $currentPublicKey) {
                $url->getQuery()->remove('publicKey');
            }
        }

        // Override the public key if needed, replacing any old public key
        if ($publicKey && ($user !== $publicKey || $pubKeysDiffer)) {
            $url->getQuery()->set('publicKey', $publicKey);
        }

        return $url;
    }
1058567
func (key *Key) GetPublicKey() (*rsa.PublicKey, error) {
	modulus, err := key.GetModulus()
	if err != nil {
		return nil, err
	}
	exponent, err := key.GetExponent()
	if err != nil {
		return nil, err
	}
	pk := &rsa.PublicKey{
		N: new(big.Int).SetBytes(modulus),
		E: int(exponent),
	}
	return pk, nil
}
815046
public function getPublicKey($client_id = '0')
    {

        $result = $this->client->getItem(array(
            "TableName"=> $this->config['public_key_table'],
            "Key" => array('client_id'   => array('S' => $client_id))
        ));
        if ($result->count()==0) {
            return false ;
        }
        $token = $this->dynamo2array($result);

        return $token['public_key'];

    }
225228
public function getPublicKey($client_id = null)
    {
        if (isset($this->keys[$client_id])) {
            return $this->keys[$client_id]['public_key'];
        }

        // use a global encryption pair
        if (isset($this->keys['public_key'])) {
            return $this->keys['public_key'];
        }

        return false;
    }
424365
public static function getUserACL($userId)
    {
        global $PPHP;
        $db = $PPHP['db'];

        $flat = $db->selectArray(
            "
            SELECT action, objectType, objectId
            FROM acl_users
            WHERE userId=?
            ",
            array($userId)
        );
        return is_array($flat) ? $flat : array();
    }
319892
private function getUserKey(PKEncryptionEnabledUserInterface $user)
    {
        $pkiKey = $this->findKeyByUser($user);

        if (!$pkiKey) {
            $userId = $user->getId();
            $userClass = $this->getUserClass($user);

            $pkiKey = new PKIPrivateKey();
            $pkiKey->setUserClass($userClass);
            $pkiKey->setUserId($userId);
        }

        return $pkiKey;
    }
498107
public function getTokenForPublicKey($publicKey)
    {
        if (!$this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $publicKey)) {
            return false;
        }
        
        // Get the access entity
        $accessEntity = $this->accessControlManager->getAccessEntityForName(self::ACCESS_ENTITY_TYPE, $publicKey);

        if ($accessEntity === false) {
            return false;
        }
        
        return $accessEntity;
    }
1023511
public function getPublicKey()
    {
        if (!$this->xml) {
            return false;
        }
        $RSAPUBK = $this->xml->getElementsByTagName('RSAPUBK')->item(0);
        return $RSAPUBK ? $RSAPUBK->nodeValue : false;
    }
271009
public function setPublicKey(\OAuth2\ServerBundle\Entity\ClientPublicKey $public_key = null)
    {
        $this->public_key = $public_key;

        return $this;
    }
877036
public function getKeyUrl($publicKey) {
        $url = sprintf($this->getBaseUrl() . '/keys/%s', $publicKey);

        return Http\KeyUrl::factory(
            $url,
            $this->getConfig('privateKey'),
            $this->getPublicKey()
        );
    }
1024334
public function getPublicKey() {
        return (
            $this->headers->get('X-Imbo-PublicKey', null) ?:
            $this->query->get('publicKey', null) ?:
            ($this->route ? $this->route->get('user') : null)
        );
    }
233064
function getPublicKey()
    {
        if (isset($this->publicKey)) {
            return $this->publicKey;
        }

        if (isset($this->currentCert) && is_array($this->currentCert)) {
            foreach (array('tbsCertificate/subjectPublicKeyInfo', 'certificationRequestInfo/subjectPKInfo') as $path) {
                $keyinfo = $this->_subArray($this->currentCert, $path);
                if (!empty($keyinfo)) {
                    break;
                }
            }
        }
        if (empty($keyinfo)) {
            return false;
        }

        $key = $keyinfo['subjectPublicKey'];

        switch ($keyinfo['algorithm']['algorithm']) {
            case 'rsaEncryption':
                $publicKey = new RSA();
                $publicKey->loadKey($key);
                $publicKey->setPublicKey();
                break;
            default:
                return false;
        }

        return $publicKey;
    }
950850
public function exportPublicKey(PublicKey $publicKey)
    {
        if (!$publicKey instanceof VirgilPublicKey) {
            throw new VirgilCryptoException("instance of VirgilPublicKey expected");
        }

        return $this->virgilCrypto->exportPublicKey($publicKey);
    }
924282
protected byte[] getPublicKey(KeyPair keyPair) {
        DHPublicKey incomingPublicKey = (DHPublicKey) keyPair.getPublic();
        BigInteger dhY = incomingPublicKey.getY();
        if (log.isDebugEnabled()) {
            log.debug("Public key: {}", Hex.encodeHexString(BigIntegers.asUnsignedByteArray(dhY)));
        }
        return Arrays.copyOfRange(BigIntegers.asUnsignedByteArray(dhY), 0, KEY_LENGTH);
    }
990417
public function getPublicKey()
    {
        /** @var string $cacheKey */
        if(empty($this->_publicKey) && !empty($this->jwkUrl))
        {
            if(Yii::$app->cache)
            {
                $cacheKey = "JWK_".sha1($this->jwkUrl);
                $jwk = Yii::$app->cache->get($cacheKey);
            }

            if(empty($jwk))
            {
                $res = $this->createRequest()
                    ->setMethod('GET')
                    ->setUrl($this->jwkUrl)
                    ->send();
                if(!empty($res)) {
                    $jwk = $res->getContent();
                    if(!empty($jwk) && Yii::$app->cache)
                        Yii::$app->cache->set($cacheKey, $jwk, self::PUBLIC_KEY_EXPIRE_DURATION);
                } else {
                    throw new UnauthorizedHttpException("Can\'t get public key");
                }
            }
            if(!empty($jwk))
                $this->_publicKey = JWK::parseKeySet($jwk);
        }
        return $this->_publicKey;
    }
468586
private function getHexFingerprintFromSshPublicKey ($publickey)
    {
        $content = explode(' ', $publickey, 3);
        return implode(':', str_split(md5(base64_decode($content[1])), 2));
    }