Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
poly1305.c File Reference
Poly1305 authentication algorithm. More...
Go to the source code of this file.
Functions | |
static void | poly1305_process (mbedtls_poly1305_context *ctx, size_t nblocks, const unsigned char *input, uint32_t needs_padding) |
Process blocks with Poly1305. | |
static void | poly1305_compute_mac (const mbedtls_poly1305_context *ctx, unsigned char mac[16]) |
Compute the Poly1305 MAC. | |
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
Poly1305 authentication algorithm.
Copyright (C) 2006-2016, ARM Limited, All Rights Reserved SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This file is part of mbed TLS (https://tls.mbed.org)
Definition in file poly1305.c.
Function Documentation
int mbedtls_poly1305_finish | ( | mbedtls_poly1305_context * | ctx, |
unsigned char | mac[16] | ||
) |
This function generates the Poly1305 Message Authentication Code (MAC).
- Parameters:
-
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.
- Returns:
0
on success.- A negative error code on failure.
Definition at line 393 of file poly1305.c.
void mbedtls_poly1305_free | ( | mbedtls_poly1305_context * | ctx ) |
This function releases and clears the specified Poly1305 context.
- Parameters:
-
ctx The Poly1305 context to clear. This may be NULL
, in which case this function is a no-op. If it is notNULL
, it must point to an initialized Poly1305 context.
Definition at line 290 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:
-
ctx The Poly1305 context to initialize. This must not be NULL
.
Definition at line 283 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:
-
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.
- Returns:
0
on success.- A negative error code on failure.
Definition at line 420 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 528 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:
-
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.
- Returns:
0
on success.- A negative error code on failure.
Definition at line 298 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:
-
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`.
- Returns:
0
on success.- A negative error code on failure.
Definition at line 329 of file poly1305.c.
static void poly1305_compute_mac | ( | const mbedtls_poly1305_context * | ctx, |
unsigned char | mac[16] | ||
) | [static] |
Compute the Poly1305 MAC.
- Parameters:
-
ctx The Poly1305 context. mac The buffer to where the MAC is written. Must be big enough to contain the 16-byte MAC.
Definition at line 214 of file poly1305.c.
static void poly1305_process | ( | mbedtls_poly1305_context * | ctx, |
size_t | nblocks, | ||
const unsigned char * | input, | ||
uint32_t | needs_padding | ||
) | [static] |
Process blocks with Poly1305.
- Parameters:
-
ctx The Poly1305 context. nblocks Number of blocks to process. Note that this function only processes full blocks. input Buffer containing the input block(s). needs_padding Set to 0 if the padding bit has already been applied to the input data before calling this function. Otherwise, set this parameter to 1.
Definition at line 106 of file poly1305.c.
Generated on Tue Jul 12 2022 13:55:17 by
