Kenji Arai / TYBLE16_mbedlized_os5_several_examples_1st

Dependencies:   nRF51_Vdd TextLCD BME280

Embed: (wiki syntax)

« Back to documentation index

poly1305.h File Reference

poly1305.h File Reference

This file contains Poly1305 definitions and functions. More...

Go to the source code of this file.

Functions

void mbedtls_poly1305_init (mbedtls_poly1305_context *ctx)
 This function initializes the specified Poly1305 context.
void mbedtls_poly1305_free (mbedtls_poly1305_context *ctx)
 This function releases and clears the specified Poly1305 context.
int mbedtls_poly1305_starts (mbedtls_poly1305_context *ctx, const unsigned char key[32])
 This function sets the one-time authentication key.
int 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.
int mbedtls_poly1305_finish (mbedtls_poly1305_context *ctx, unsigned char mac[16])
 This function generates the Poly1305 Message Authentication Code (MAC).
int 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.
int mbedtls_poly1305_self_test (int verbose)
 The Poly1305 checkup routine.

Detailed Description

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.

Author:
Daniel King <damaki.gh@gmail.com>

Definition in file poly1305.h.


Function Documentation

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

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

Parameters:
ctxThe Poly1305 context to use for the Poly1305 operation.
macThe buffer to where the MAC is written. Must be big enough to hold the 16-byte MAC.
Returns:
0 on success.
MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA if ctx or mac are NULL.

Definition at line 398 of file poly1305.c.

void mbedtls_poly1305_free ( mbedtls_poly1305_context *  ctx )

This function releases and clears the specified Poly1305 context.

Parameters:
ctxThe Poly1305 context to clear.

Definition at line 285 of file poly1305.c.

void 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 mbedtls_poly1305_starts(), then one or more calls to mbedtls_poly1305_update(), then one call to mbedtls_poly1305_finish(), then finally mbedtls_poly1305_free().

Parameters:
ctxThe Poly1305 context to initialize.

Definition at line 277 of file poly1305.c.

int 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.

Warning:
The key must be unique and unpredictable for each invocation of Poly1305.
Parameters:
keyThe buffer containing the 256-bit key.
ilenThe length of the input data (in bytes). Any value is accepted.
inputThe buffer holding the input data. This pointer can be NULL if ilen == 0.
macThe buffer to where the MAC is written. Must be big enough to hold the 16-byte MAC.
Returns:
0 on success.
MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA if key, input, or mac are NULL.

Definition at line 427 of file poly1305.c.

int mbedtls_poly1305_self_test ( int  verbose )

The Poly1305 checkup routine.

Returns:
0 on success.
1 on failure.

Definition at line 532 of file poly1305.c.

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

This function sets the one-time authentication key.

Warning:
The key must be unique and unpredictable for each invocation of Poly1305.
Parameters:
ctxThe Poly1305 context to which the key should be bound.
keyThe buffer containing the 256-bit key.
Returns:
0 on success.
MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA if ctx or key are NULL.

Definition at line 293 of file poly1305.c.

int 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.

Parameters:
ctxThe Poly1305 context to use for the Poly1305 operation.
ilenThe length of the input data (in bytes). Any value is accepted.
inputThe buffer holding the input data. This pointer can be NULL if ilen == 0.
Returns:
0 on success.
MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA if ctx or input are NULL.

Definition at line 326 of file poly1305.c.