Signer/Ecdsa.php

lcobucci/jwt · src/Signer/Ecdsa.php · php · BSD-3-Clause
auth

Provides ECDSA signing and verification for JWTs.

// Source: https://github.com/lcobucci/jwt | License: BSD-3-Clause | Copyright 2014, Luís Cobucci
// Provided via justclaw.it.com; keep this notice with the code.
<?php
declare(strict_types=1);

namespace Lcobucci\JWT\Signer;

use Lcobucci\JWT\Signer\Ecdsa\ConversionFailed;
use Lcobucci\JWT\Signer\Ecdsa\MultibyteStringConverter;
use Lcobucci\JWT\Signer\Ecdsa\SignatureConverter;

use const OPENSSL_KEYTYPE_EC;

abstract readonly class Ecdsa extends OpenSSL
{
    public function __construct(
        private SignatureConverter $converter = new MultibyteStringConverter(),
    ) {
    }

    final public function sign(string $payload, Key $key): string
    {
        return $this->converter->fromAsn1(
            $this->createSignature($key, $payload),
            $this->pointLength(),
        );

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key