12d4583c4SAdrian Chadd /*- 22d4583c4SAdrian Chadd * SPDX-License-Identifier: BSD-2-Clause 32d4583c4SAdrian Chadd * 42d4583c4SAdrian Chadd * Copyright (c) 2012, Jouni Malinen <j@w1.fi> 52d4583c4SAdrian Chadd * All rights reserved. 62d4583c4SAdrian Chadd * 72d4583c4SAdrian Chadd * Galois/Counter Mode (GCM) and GMAC with AES 82d4583c4SAdrian Chadd * 92d4583c4SAdrian Chadd * Redistribution and use in source and binary forms, with or without 102d4583c4SAdrian Chadd * modification, are permitted provided that the following conditions 112d4583c4SAdrian Chadd * are met: 122d4583c4SAdrian Chadd * 1. Redistributions of source code must retain the above copyright 132d4583c4SAdrian Chadd * notice, this list of conditions and the following disclaimer. 142d4583c4SAdrian Chadd * 2. Redistributions in binary form must reproduce the above copyright 152d4583c4SAdrian Chadd * notice, this list of conditions and the following disclaimer in the 162d4583c4SAdrian Chadd * documentation and/or other materials provided with the distribution. 172d4583c4SAdrian Chadd * 182d4583c4SAdrian Chadd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 192d4583c4SAdrian Chadd * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 202d4583c4SAdrian Chadd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 212d4583c4SAdrian Chadd * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 222d4583c4SAdrian Chadd * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 232d4583c4SAdrian Chadd * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 242d4583c4SAdrian Chadd * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 252d4583c4SAdrian Chadd * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 262d4583c4SAdrian Chadd * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 272d4583c4SAdrian Chadd * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 282d4583c4SAdrian Chadd */ 292d4583c4SAdrian Chadd #ifndef __IEEE80211_CRYPTO_GCM_H__ 302d4583c4SAdrian Chadd #define __IEEE80211_CRYPTO_GCM_H__ 312d4583c4SAdrian Chadd 322d4583c4SAdrian Chadd #if defined(__KERNEL__) || defined(_KERNEL) 332d4583c4SAdrian Chadd 342d4583c4SAdrian Chadd #include <crypto/rijndael/rijndael.h> 352d4583c4SAdrian Chadd 362d4583c4SAdrian Chadd #define AES_BLOCK_LEN 16 372d4583c4SAdrian Chadd 382d4583c4SAdrian Chadd /* 392d4583c4SAdrian Chadd * buffer is 2x the AES_BLOCK_LEN, but the AAD contents may be variable 402d4583c4SAdrian Chadd * and are padded. 412d4583c4SAdrian Chadd */ 422d4583c4SAdrian Chadd #define GCM_AAD_LEN (AES_BLOCK_LEN * 2) 432d4583c4SAdrian Chadd 442d4583c4SAdrian Chadd /* GCMP is always 128 bit / 16 byte MIC */ 452d4583c4SAdrian Chadd #define GCMP_MIC_LEN 16 462d4583c4SAdrian Chadd 472d4583c4SAdrian Chadd void ieee80211_crypto_aes_gcm_ae(rijndael_ctx *aes, const uint8_t *iv, 482d4583c4SAdrian Chadd size_t iv_len, const uint8_t *plain, size_t plain_len, 492d4583c4SAdrian Chadd const uint8_t *aad, size_t aad_len, uint8_t *crypt, uint8_t *tag); 502d4583c4SAdrian Chadd 512d4583c4SAdrian Chadd int ieee80211_crypto_aes_gcm_ad(rijndael_ctx *aes, const uint8_t *iv, 522d4583c4SAdrian Chadd size_t iv_len, const uint8_t *crypt, size_t crypt_len, 532d4583c4SAdrian Chadd const uint8_t *aad, size_t aad_len, const uint8_t *tag, 542d4583c4SAdrian Chadd uint8_t *plain); 552d4583c4SAdrian Chadd 562d4583c4SAdrian Chadd #endif /* __KERNEL__ */ 572d4583c4SAdrian Chadd 582d4583c4SAdrian Chadd #endif /* __IEEE80211_CRYPTO_GCM_H__ */ 59