
ngtcp2_crypto_verify_regular_token2
===================================

Synopsis
--------

*#include <ngtcp2/ngtcp2_crypto.h>*

.. function:: ngtcp2_ssize ngtcp2_crypto_verify_regular_token2( void *data, size_t max_datalen, const uint8_t *token, size_t tokenlen, const uint8_t *secret, size_t secretlen, const ngtcp2_sockaddr *remote_addr, ngtcp2_socklen remote_addrlen, ngtcp2_duration timeout, ngtcp2_tstamp ts)

    
    `ngtcp2_crypto_verify_regular_token2` verifies a regular token
    stored in the buffer pointed by *token* of length *tokenlen*.
    *secret* of length *secretlen* is a keying material to generate
    keys to decrypt the token.  *remote_addr* of length
    *remote_addrlen* is an address of client.  *timeout* is the period
    during which the token is valid.  *ts* is the current timestamp.
    *data* is the pointer to the buffer of length at least
    *max_datalen* bytes.  If the token is verified successfully, the
    opaque data embedded in the token is copied to the buffer pointed
    by *data*.
    
    If *tokenlen* is less than
    :macro:`NGTCP2_CRYPTO_MAX_REGULAR_TOKENLEN`, this function returns
    :macro:`NGTCP2_CRYPTO_ERR_UNREADABLE_TOKEN`.
    
    If the length of opaque data is larger than *max_datalen*, the
    verification still succeeds, but nothing is written to the buffer
    pointed by *data*, and this function returns 0.  In other words,
    the opaque data is discarded.
    
    This function returns the number of the opaque data written to the
    buffer pointed by *data* if it succeeds, or one of the following
    negative error codes:
    
    :macro:`NGTCP2_CRYPTO_ERR_UNREADABLE_TOKEN`
        A token is badly formatted; or verifying the integrity
        protection failed.
    :macro:`NGTCP2_CRYPTO_ERR_VERIFY_TOKEN`
        A token validity has expired.
    :macro:`NGTCP2_CRYPTO_ERR_INTERNAL`
        Internal error occurred.
