LCOV - code coverage report
Current view: top level - builds/gnutls/coverage/gnutls-git/lib/nettle/backport - siv-cmac-aes256.c (source / functions) Hit Total Coverage
Test: GnuTLS-3.6.14 Code Coverage Lines: 10 10 100.0 %
Date: 2020-10-30 04:50:48 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* siv-cmac-aes256.c
       2             : 
       3             :    AES-SIV, RFC5297
       4             : 
       5             :    Copyright (C) 2017 Nikos Mavrogiannopoulos
       6             : 
       7             :    This file is part of GNU Nettle.
       8             : 
       9             :    GNU Nettle is free software: you can redistribute it and/or
      10             :    modify it under the terms of either:
      11             : 
      12             :      * the GNU Lesser General Public License as published by the Free
      13             :        Software Foundation; either version 3 of the License, or (at your
      14             :        option) any later version.
      15             : 
      16             :    or
      17             : 
      18             :      * the GNU General Public License as published by the Free
      19             :        Software Foundation; either version 2 of the License, or (at your
      20             :        option) any later version.
      21             : 
      22             :    or both in parallel, as here.
      23             : 
      24             :    GNU Nettle is distributed in the hope that it will be useful,
      25             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      26             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      27             :    General Public License for more details.
      28             : 
      29             :    You should have received copies of the GNU General Public License and
      30             :    the GNU Lesser General Public License along with this program.  If
      31             :    not, see http://www.gnu.org/licenses/.
      32             : */
      33             : 
      34             : #if HAVE_CONFIG_H
      35             : # include "config.h"
      36             : #endif
      37             : 
      38             : #include <string.h>
      39             : 
      40             : #include <nettle/aes.h>
      41             : #include "siv-cmac.h"
      42             : #ifdef HAVE_NETTLE_CMAC128_UPDATE
      43             : #include <nettle/cmac.h>
      44             : #else
      45             : #include "cmac.h"
      46             : #endif
      47             : #include <nettle/ctr.h>
      48             : #include <nettle/memxor.h>
      49             : #include <nettle/memops.h>
      50             : 
      51             : void
      52          10 : siv_cmac_aes256_set_key(struct siv_cmac_aes256_ctx *ctx, const uint8_t *key)
      53             : {
      54          10 :   siv_cmac_set_key(&ctx->cmac_key, &ctx->cmac_cipher, &ctx->ctr_cipher, &nettle_aes256, key);
      55          10 : }
      56             : 
      57             : void
      58          15 : siv_cmac_aes256_encrypt_message(const struct siv_cmac_aes256_ctx *ctx,
      59             :                                 size_t nlength, const uint8_t *nonce,
      60             :                                 size_t alength, const uint8_t *adata,
      61             :                                 size_t clength, uint8_t *dst, const uint8_t *src)
      62             : {
      63          15 :   siv_cmac_encrypt_message(&ctx->cmac_key, &ctx->cmac_cipher,
      64          15 :                            &nettle_aes256, &ctx->ctr_cipher,
      65             :                            nlength, nonce, alength, adata,
      66             :                            clength, dst, src);
      67          15 : }
      68             : 
      69             : int
      70          10 : siv_cmac_aes256_decrypt_message(const struct siv_cmac_aes256_ctx *ctx,
      71             :                                 size_t nlength, const uint8_t *nonce,
      72             :                                 size_t alength, const uint8_t *adata,
      73             :                                 size_t mlength, uint8_t *dst, const uint8_t *src)
      74             : {
      75          20 :   return siv_cmac_decrypt_message(&ctx->cmac_key, &ctx->cmac_cipher,
      76          10 :                                   &nettle_aes256, &ctx->ctr_cipher,
      77             :                                   nlength, nonce, alength, adata,
      78             :                                   mlength, dst, src);
      79             : }

Generated by: LCOV version 1.14