Lines Matching refs:key

149      * Public key
156 * Private key
482 $key = $x509['tbsCertificate']['subjectPublicKeyInfo'];
483 $key = ASN1::encodeDER($key, Maps\SubjectPublicKeyInfo::MAP);
486 chunk_split(base64_encode($key), 64) .
641 foreach ($extensions as $key => $value) {
643 $extensions[$key] = $newext;
984 If the keyUsage extension is present, then the subject public key
994 The cA boolean indicates whether the certified public key may be used
996 then the keyCertSign bit in the key usage extension MUST NOT be
999 is not asserted, then the certified public key MUST NOT be used to
1044 foreach ($name as $key => $value) {
1047 switch ($key) {
1400 $key = RSA::loadFormat('PSS', $publicKey);
1403 $key = RSA::loadFormat('PKCS8', $publicKey);
1414 $key = $key
1424 $key = EC::loadFormat('PKCS8', $publicKey);
1427 $key = EC::loadFormat('PKCS8', $publicKey);
1434 $key = $key
1442 $key = DSA::loadFormat('PKCS8', $publicKey);
1447 $key = $key
1455 throw new UnsupportedAlgorithmException('Public key algorithm unsupported');
1458 return $key->verify($signatureSubject, $signature);
2074 foreach ($chain as $key => $value) {
2075 $chain[$key] = new X509();
2076 $chain[$key]->loadX509($value);
2092 * Set public key
2096 * @param PublicKey $key
2099 public function setPublicKey(PublicKey $key)
2101 $this->publicKey = $key;
2105 * Set private key
2109 * @param PrivateKey $key
2111 public function setPrivateKey(PrivateKey $key)
2113 $this->privateKey = $key;
2129 * Gets the public key
2158 $key = $keyinfo['subjectPublicKey'];
2162 return RSA::loadFormat('PSS', $key);
2164 return RSA::loadFormat('PKCS8', $key)->withPadding(RSA::SIGNATURE_PKCS1);
2168 return EC::loadFormat('PKCS8', $key);
2170 return DSA::loadFormat('PKCS8', $key);
2234 $key = $csr['certificationRequestInfo']['subjectPKInfo'];
2235 $key = ASN1::encodeDER($key, Maps\SubjectPublicKeyInfo::MAP);
2238 chunk_split(base64_encode($key), 64) .
2343 $key = $spkac['publicKeyAndChallenge']['spki'];
2344 $key = ASN1::encodeDER($key, Maps\SubjectPublicKeyInfo::MAP);
2347 chunk_split(base64_encode($key), 64) .
2543 * $issuer's private key needs to be loaded.
2545 * a CSR or something with the DN and public key explicitly set.
2814 // "A challenge string that is submitted along with the public key. Defaults to an empty string if not specified."
2815 // both Firefox and OpenSSL ("openssl spkac -key private.key") behave this way
2843 * $issuer's private key needs to be loaded.
2972 * Identify signature algorithm from key settings
2974 * @param PrivateKey $key
2978 private static function identifySignatureAlgorithm(PrivateKey $key)
2980 if ($key instanceof RSA) {
2981 if ($key->getPadding() & RSA::SIGNATURE_PSS) {
2982 $r = PSS::load($key->withPassword()->toString('PSS'));
2988 switch ($key->getHash()) {
2996 return ['algorithm' => $key->getHash() . 'WithRSAEncryption'];
3001 if ($key instanceof DSA) {
3002 switch ($key->getHash()) {
3006 return ['algorithm' => 'id-dsa-with-' . $key->getHash()];
3011 if ($key instanceof EC) {
3012 switch ($key->getCurve()) {
3015 return ['algorithm' => 'id-' . $key->getCurve()];
3017 switch ($key->getHash()) {
3023 return ['algorithm' => 'ecdsa-with-' . strtoupper($key->getHash())];
3028 throw new UnsupportedAlgorithmException('The only supported public key classes are: RSA, DSA, EC');
3222 foreach ($attributes as $key => $value) {
3224 $path = "$pth/$key/value/0";
3229 $key = count($attributes);
3231 $path = "$pth/$key/value/0";
3263 foreach ($extensions as $key => $value) {
3265 unset($extensions[$key]);
3296 foreach ($extensions as $key => $value) {
3346 foreach ($extensions as $key => $value) {
3352 $extensions[$key] = $newext;
3429 foreach ($attributes as $key => $attribute) {
3441 unset($attributes[$key]);
3445 unset($attributes[$key]['value'][$disposition]);
3446 $attributes[$key]['value'] = array_values($attributes[$key]['value']);
3482 foreach ($attributes as $key => $attribute) {
3552 foreach ($attributes as $key => $attribute) {
3557 $last = $key;
3563 $attributes[$key]['value'][$disposition] = $value;
3584 * Sets the subject key identifier
3600 * Compute a public key identifier.
3602 * Although key identifiers may be set to any unique value, this function
3603 * computes key identifiers from public key according to the two
3605 * Highly polymorphic: try to accept all possible forms of key:
3607 * - \phpseclib3\File\X509 object with public or private key defined
3612 * @param mixed $key optional
3614 * @return string binary key identifier
3616 public function computeKeyIdentifier($key = null, $method = 1)
3618 if (is_null($key)) {
3619 $key = $this;
3623 case is_string($key):
3625 case is_array($key) && isset($key['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']):
3626 return $this->computeKeyIdentifier($key['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'], $method);
3627 case is_array($key) && isset($key['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']):
3628 return $this->computeKeyIdentifier($key['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'], $method);
3629 case !is_object($key):
3631 case $key instanceof Element:
3632 // Assume the element is a bitstring-packed key.
3633 $decoded = ASN1::decodeBER($key->element);
3641 // If the key is private, compute identifier from its corresponding public key.
3642 $key = PublicKeyLoader::load($raw);
3643 if ($key instanceof PrivateKey) { // If private.
3644 return $this->computeKeyIdentifier($key, $method);
3646 $key = $raw; // Is a public key.
3648 case $key instanceof X509:
3649 if (isset($key->publicKey)) {
3650 return $this->computeKeyIdentifier($key->publicKey, $method);
3652 if (isset($key->privateKey)) {
3653 return $this->computeKeyIdentifier($key->privateKey, $method);
3655 if (isset($key->currentCert['tbsCertificate']) || isset($key->currentCert['certificationRequestInfo'])) {
3656 return $this->computeKeyIdentifier($key->currentCert, $method);
3659 default: // Should be a key object (i.e.: \phpseclib3\Crypt\RSA).
3660 $key = $key->getPublicKey();
3665 $key = ASN1::extractBER($key);
3667 // Now we have the key string: compute its sha-1 sum.
3669 $hash = $hash->hash($key);
3680 * Format a public key as appropriate