Crypt-JWT

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


    Mandatory. Accepts a string (raw bytes), a HASH ref, or an ARRAY ref.
    HASH ref and ARRAY ref payloads are serialized as JSON strings; string
    payloads are passed through verbatim.

        my $token = encode_jwt(payload=>"any raw data",  key=>$k, alg=>'HS256');
        my $token = encode_jwt(payload=>{a=>1, b=>2},    key=>$k, alg=>'HS256');
        my $token = encode_jwt(payload=>[11,22,33,44],   key=>$k, alg=>'HS256');

- alg

    The 'alg' header value is mandatory for both JWE and JWS tokens.

    Supported JWE 'alg' algorithms:

        dir
        A128KW
        A192KW
        A256KW
        A128GCMKW
        A192GCMKW
        A256GCMKW
        PBES2-HS256+A128KW
        PBES2-HS384+A192KW
        PBES2-HS512+A256KW
        RSA-OAEP
        RSA-OAEP-256
        RSA1_5
        ECDH-ES+A128KW
        ECDH-ES+A192KW
        ECDH-ES+A256KW
        ECDH-ES

    Supported JWS algorithms:

        none   ...  no integrity (NOTE: disabled by default)
        HS256  ...  HMAC+SHA256 integrity
        HS384  ...  HMAC+SHA384 integrity
        HS512  ...  HMAC+SHA512 integrity
        RS256  ...  RSA+PKCS1-V1_5 + SHA256 signature
        RS384  ...  RSA+PKCS1-V1_5 + SHA384 signature
        RS512  ...  RSA+PKCS1-V1_5 + SHA512 signature
        PS256  ...  RSA+PSS + SHA256 signature
        PS384  ...  RSA+PSS + SHA384 signature
        PS512  ...  RSA+PSS + SHA512 signature
        ES256  ...  ECDSA + SHA256 signature
        ES256K ...  ECDSA + SHA256 signature
        ES384  ...  ECDSA + SHA384 signature
        ES512  ...  ECDSA + SHA512 signature
        EdDSA  ...  Ed25519 signature

- enc

    The 'enc' header is mandatory for JWE tokens.

    Supported 'enc' algorithms:

        A128GCM
        A192GCM
        A256GCM
        A128CBC-HS256
        A192CBC-HS384
        A256CBC-HS512

- key

    A key used for token encryption (JWE) or token signing (JWS). The value depends on `alg` token header value.

        JWS alg header      key value
        ------------------  ----------------------------------
        none                no key required
        HS256               string (raw octets) of any length (or perl HASH ref with JWK, kty=>'oct')
        HS384               same as HS256
        HS512               same as HS256
        RS256               private RSA key, perl HASH ref with JWK key structure,
                            a reference to SCALAR string with PEM or DER or JSON/JWK data,
                            object: Crypt::PK::RSA, Crypt::OpenSSL::RSA, Crypt::X509 or Crypt::OpenSSL::X509
        RS384               private RSA key, see RS256
        RS512               private RSA key, see RS256
        PS256               private RSA key, see RS256
        PS384               private RSA key, see RS256
        PS512               private RSA key, see RS256
        ES256               private ECC key, perl HASH ref with JWK key structure,
                            a reference to SCALAR string with PEM or DER or JSON/JWK data,
                            an instance of Crypt::PK::ECC
        ES256K              private ECC key, see ES256
        ES384               private ECC key, see ES256
        ES512               private ECC key, see ES256
        EdDSA               private Ed25519 key

        JWE alg header      key value
        ------------------  ----------------------------------
        dir                 string (raw octets) or perl HASH ref with JWK, kty=>'oct', length depends on 'enc' algorithm
        A128KW              string (raw octets) 16 bytes (or perl HASH ref with JWK, kty=>'oct')
        A192KW              string (raw octets) 24 bytes (or perl HASH ref with JWK, kty=>'oct')
        A256KW              string (raw octets) 32 bytes (or perl HASH ref with JWK, kty=>'oct')
        A128GCMKW           string (raw octets) 16 bytes (or perl HASH ref with JWK, kty=>'oct')
        A192GCMKW           string (raw octets) 24 bytes (or perl HASH ref with JWK, kty=>'oct')
        A256GCMKW           string (raw octets) 32 bytes (or perl HASH ref with JWK, kty=>'oct')
        PBES2-HS256+A128KW  string (raw octets) of any length (or perl HASH ref with JWK, kty=>'oct')
        PBES2-HS384+A192KW  string (raw octets) of any length (or perl HASH ref with JWK, kty=>'oct')
        PBES2-HS512+A256KW  string (raw octets) of any length (or perl HASH ref with JWK, kty=>'oct')
        RSA-OAEP            public RSA key, perl HASH ref with JWK key structure,
                            a reference to SCALAR string with PEM or DER or JSON/JWK data,
                            an instance of Crypt::PK::RSA or Crypt::OpenSSL::RSA
        RSA-OAEP-256        public RSA key, see RSA-OAEP
        RSA1_5              public RSA key, see RSA-OAEP
        ECDH-ES             public ECC or X25519 key, perl HASH ref with JWK key structure,
                            a reference to SCALAR string with PEM or DER or JSON/JWK data,
                            an instance of Crypt::PK::ECC
        ECDH-ES+A128KW      public ECC or X25519 key, see ECDH-ES
        ECDH-ES+A192KW      public ECC or X25519 key, see ECDH-ES
        ECDH-ES+A256KW      public ECC or X25519 key, see ECDH-ES

- keypass

    Optional. When the `key` parameter is an encrypted private RSA or ECC
    key (PEM/DER), this parameter holds the password used to decrypt it.

- allow\_none

    `1` - allow JWS with `none` 'alg' header value (which means that token has no signature), **BEWARE: DANGEROUS, INSECURE.**



( run in 0.885 second using v1.01-cache-2.11-cpan-e1769b4cff6 )