poly1305.h
mbedtls/private_access.h
mbedtls/build_info.h
stdint.h
stddef.h
chachapoly.h
mbedtls/build_info.h
mbedtls/check_config.h
mbedtls/config_adjust_legacy_crypto.h
mbedtls/config_adjust_psa_from_legacy.h
mbedtls/config_adjust_psa_superset_legacy.h
mbedtls/config_adjust_ssl.h
mbedtls/config_adjust_x509.h
mbedtls/config_psa.h
mbedtls/mbedtls_config.h
poly1305.h
mbedtls/private_access.h
psa/crypto_adjust_auto_enabled.h
psa/crypto_adjust_config_dependencies.h
psa/crypto_adjust_config_key_pair_types.h
psa/crypto_adjust_config_synonyms.h
psa/crypto_legacy.h
limits.h
stddef.h
stdint.h
chachapoly.h
debug.h
net_sockets.h
oid.h
pk.h
pkcs7.h
poly1305.h
psa_util.h
ssl.h
ssl_cache.h
ssl_ciphersuites.h
ssl_cookie.h
ssl_ticket.h
x509.h
x509_crl.h
x509_crt.h
x509_csr.h
crypto.h
crypto_builtin_composites.h
crypto_driver_contexts_composites.h
crypto_struct.h
mbedtls_poly1305_context
MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA
-0x0057

Invalid input parameter(s).

struct mbedtls_poly1305_context typedef struct mbedtls_poly1305_context mbedtls_poly1305_context mbedtls_poly1305_context
void void mbedtls_poly1305_init (mbedtls_poly1305_context *ctx) mbedtls_poly1305_init mbedtls_poly1305_context * ctx

This function initializes the specified Poly1305 context.

It must be the first API called before using the context. It is usually followed by a call to \c mbedtls_poly1305_starts(), then one or more calls to \c mbedtls_poly1305_update(), then one call to \c mbedtls_poly1305_finish(), then finally \c mbedtls_poly1305_free().

ctx

The Poly1305 context to initialize. This must not be `NULL`.

void void mbedtls_poly1305_free (mbedtls_poly1305_context *ctx) mbedtls_poly1305_free mbedtls_poly1305_context * ctx

This function releases and clears the specified Poly1305 context.

ctx

The Poly1305 context to clear. This may be `NULL`, in which case this function is a no-op. If it is not `NULL`, it must point to an initialized Poly1305 context.

int int mbedtls_poly1305_starts (mbedtls_poly1305_context *ctx, const unsigned char key[32]) mbedtls_poly1305_starts mbedtls_poly1305_context * ctx const unsigned char key [32]

This function sets the one-time authentication key.

The key must be unique and unpredictable for each invocation of Poly1305.

ctx

The Poly1305 context to which the key should be bound. This must be initialized.

key

The buffer containing the `32` Byte (`256` Bit) key.

`0` on success.

A negative error code on failure.

int int mbedtls_poly1305_update (mbedtls_poly1305_context *ctx, const unsigned char *input, size_t ilen) mbedtls_poly1305_update mbedtls_poly1305_context * ctx const unsigned char * input size_t ilen

This functions feeds an input buffer into an ongoing Poly1305 computation.

It is called between `mbedtls_cipher_poly1305_starts()` and `mbedtls_cipher_poly1305_finish()`. It can be called repeatedly to process a stream of data.

ctx

The Poly1305 context to use for the Poly1305 operation. This must be initialized and bound to a key.

ilen

The length of the input data in Bytes. Any value is accepted.

input

The buffer holding the input data. This pointer can be `NULL` if `ilen == 0`.

`0` on success.

A negative error code on failure.

int int mbedtls_poly1305_finish (mbedtls_poly1305_context *ctx, unsigned char mac[16]) mbedtls_poly1305_finish mbedtls_poly1305_context * ctx unsigned char mac [16]

This function generates the Poly1305 Message Authentication Code (MAC).

ctx

The Poly1305 context to use for the Poly1305 operation. This must be initialized and bound to a key.

mac

The buffer to where the MAC is written. This must be a writable buffer of length `16` Bytes.

`0` on success.

A negative error code on failure.

int int mbedtls_poly1305_mac (const unsigned char key[32], const unsigned char *input, size_t ilen, unsigned char mac[16]) mbedtls_poly1305_mac const unsigned char key [32] const unsigned char * input size_t ilen unsigned char mac [16]

This function calculates the Poly1305 MAC of the input buffer with the provided key.

The key must be unique and unpredictable for each invocation of Poly1305.

key

The buffer containing the `32` Byte (`256` Bit) key.

ilen

The length of the input data in Bytes. Any value is accepted.

input

The buffer holding the input data. This pointer can be `NULL` if `ilen == 0`.

mac

The buffer to where the MAC is written. This must be a writable buffer of length `16` Bytes.

`0` on success.

A negative error code on failure.

int int mbedtls_poly1305_self_test (int verbose) mbedtls_poly1305_self_test int verbose

The Poly1305 checkup routine.

`0` on success.

`1` on failure.

This file contains Poly1305 definitions and functions.

Poly1305 is a one-time message authenticator that can be used to authenticate messages. Poly1305-AES was created by Daniel Bernstein https://cr.yp.to/mac/poly1305-20050329.pdf The generic Poly1305 algorithm (not tied to AES) was also standardized in RFC 7539.

Daniel King damaki.gh@gmail.com

    /*
    *CopyrightTheMbedTLSContributors
    *SPDX-License-Identifier:Apache-2.0ORGPL-2.0-or-later
    */

    #ifndefMBEDTLS_POLY1305_H
    #defineMBEDTLS_POLY1305_H
    #include"mbedtls/private_access.h"

    #include"mbedtls/build_info.h"

    #include<stdint.h>
    #include<stddef.h>

    #defineMBEDTLS_ERR_POLY1305_BAD_INPUT_DATA-0x0057

    #ifdef__cplusplus
    extern"C"{
    #endif

    #if!defined(MBEDTLS_POLY1305_ALT)

    typedefstructmbedtls_poly1305_context{
    uint32_tMBEDTLS_PRIVATE(r)[4];
    uint32_tMBEDTLS_PRIVATE(s)[4];
    uint32_tMBEDTLS_PRIVATE(acc)[5];
    uint8_tMBEDTLS_PRIVATE(queue)[16];
    size_tMBEDTLS_PRIVATE(queue_len);
    }
    mbedtls_poly1305_context;

    #else/*MBEDTLS_POLY1305_ALT*/
    #include"poly1305_alt.h"
    #endif/*MBEDTLS_POLY1305_ALT*/

    voidmbedtls_poly1305_init(mbedtls_poly1305_context*ctx);

    voidmbedtls_poly1305_free(mbedtls_poly1305_context*ctx);

    intmbedtls_poly1305_starts(mbedtls_poly1305_context*ctx,
    constunsignedcharkey[32]);

    intmbedtls_poly1305_update(mbedtls_poly1305_context*ctx,
    constunsignedchar*input,
    size_tilen);

    intmbedtls_poly1305_finish(mbedtls_poly1305_context*ctx,
    unsignedcharmac[16]);

    intmbedtls_poly1305_mac(constunsignedcharkey[32],
    constunsignedchar*input,
    size_tilen,
    unsignedcharmac[16]);

    #ifdefined(MBEDTLS_SELF_TEST)
    intmbedtls_poly1305_self_test(intverbose);
    #endif/*MBEDTLS_SELF_TEST*/

    #ifdef__cplusplus
    }
    #endif

    #endif/*MBEDTLS_POLY1305_H*/