The branch, master has been updated via 20b9cae63d5 lib:crypto: Build intel aes-ni only if GnuTLS doesn't provide AES CMAC via 6713617724b lib:crypto: Only build AES code if we need AES CMAC via 337c51c9f50 lib:crypto: Remove our implementation of AES GCM via c3250ff7ab6 lib:crypto: Remove our implementation of AES CCM from bc0c876a9eb pidl:NDR/Parser: only include structs in ndr_interface_public_struct
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 20b9cae63d5a5881cc6100a2533fab683cc307aa Author: Andreas Schneider <a...@samba.org> Date: Tue Dec 10 18:06:29 2019 +0100 lib:crypto: Build intel aes-ni only if GnuTLS doesn't provide AES CMAC Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org> Autobuild-Date(master): Tue Dec 10 20:30:57 UTC 2019 on sn-devel-184 commit 6713617724bfe4cba633f0e61052a703c4ca9f3e Author: Andreas Schneider <a...@samba.org> Date: Tue Dec 10 18:03:57 2019 +0100 lib:crypto: Only build AES code if we need AES CMAC Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 337c51c9f503adef58c9b875bfb4f522cfb7d9ae Author: Andreas Schneider <a...@samba.org> Date: Tue Dec 10 18:01:43 2019 +0100 lib:crypto: Remove our implementation of AES GCM We require GnuTLS >= 3.4.7 which provides AES GCM. Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit c3250ff7ab66fb45c9b5a66c7e3a9453fb22777b Author: Andreas Schneider <a...@samba.org> Date: Tue Dec 10 17:52:36 2019 +0100 lib:crypto: Remove our implementation of AES CCM We require GnuTLS >= 3.4.7 which provides AES CCM. Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> ----------------------------------------------------------------------- Summary of changes: lib/crypto/aes_ccm_128.c | 198 --------------------- lib/crypto/aes_ccm_128.h | 58 ------- lib/crypto/aes_ccm_128_test.c | 377 ---------------------------------------- lib/crypto/aes_gcm_128.c | 208 ---------------------- lib/crypto/aes_gcm_128.h | 55 ------ lib/crypto/aes_gcm_128_test.c | 295 ------------------------------- lib/crypto/crypto.h | 2 - lib/crypto/wscript_build | 28 +-- source4/torture/local/local.c | 6 - third_party/aesni-intel/wscript | 3 +- 10 files changed, 6 insertions(+), 1224 deletions(-) delete mode 100644 lib/crypto/aes_ccm_128.c delete mode 100644 lib/crypto/aes_ccm_128.h delete mode 100644 lib/crypto/aes_ccm_128_test.c delete mode 100644 lib/crypto/aes_gcm_128.c delete mode 100644 lib/crypto/aes_gcm_128.h delete mode 100644 lib/crypto/aes_gcm_128_test.c Changeset truncated at 500 lines: diff --git a/lib/crypto/aes_ccm_128.c b/lib/crypto/aes_ccm_128.c deleted file mode 100644 index 0cbc05567a8..00000000000 --- a/lib/crypto/aes_ccm_128.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - AES-CCM-128 (rfc 3610) - - Copyright (C) Stefan Metzmacher 2012 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include "replace.h" -#include "lib/crypto/aes.h" -#include "lib/crypto/aes_ccm_128.h" -#include "lib/util/byteorder.h" - -#define M_ ((AES_CCM_128_M - 2) / 2) -#define L_ (AES_CCM_128_L - 1) - -void aes_ccm_128_init(struct aes_ccm_128_context *ctx, - const uint8_t K[AES_BLOCK_SIZE], - const uint8_t N[AES_CCM_128_NONCE_SIZE], - size_t a_total, size_t m_total) -{ - ZERO_STRUCTP(ctx); - - AES_set_encrypt_key(K, 128, &ctx->aes_key); - memcpy(ctx->nonce, N, AES_CCM_128_NONCE_SIZE); - ctx->a_remain = a_total; - ctx->m_remain = m_total; - - /* - * prepare B_0 - */ - ctx->B_i[0] = L_; - ctx->B_i[0] += 8 * M_; - if (a_total > 0) { - ctx->B_i[0] += 64; - } - memcpy(&ctx->B_i[1], ctx->nonce, AES_CCM_128_NONCE_SIZE); - RSIVAL(ctx->B_i, (AES_BLOCK_SIZE - AES_CCM_128_L), m_total); - - /* - * prepare X_1 - */ - AES_encrypt(ctx->B_i, ctx->X_i, &ctx->aes_key); - - /* - * prepare B_1 - */ - ZERO_STRUCT(ctx->B_i); - if (a_total >= UINT32_MAX) { - RSSVAL(ctx->B_i, 0, 0xFFFF); - RSBVAL(ctx->B_i, 2, (uint64_t)a_total); - ctx->B_i_ofs = 10; - } else if (a_total >= 0xFF00) { - RSSVAL(ctx->B_i, 0, 0xFFFE); - RSIVAL(ctx->B_i, 2, a_total); - ctx->B_i_ofs = 6; - } else if (a_total > 0) { - RSSVAL(ctx->B_i, 0, a_total); - ctx->B_i_ofs = 2; - } - - /* - * prepare A_i - */ - ctx->A_i[0] = L_; - memcpy(&ctx->A_i[1], ctx->nonce, AES_CCM_128_NONCE_SIZE); - - ctx->S_i_ofs = AES_BLOCK_SIZE; -} - -void aes_ccm_128_update(struct aes_ccm_128_context *ctx, - const uint8_t *v, size_t v_len) -{ - size_t *remain; - - if (v_len == 0) { - return; - } - - if (ctx->a_remain > 0) { - remain = &ctx->a_remain; - } else { - remain = &ctx->m_remain; - } - - if (unlikely(v_len > *remain)) { - abort(); - } - - if (ctx->B_i_ofs > 0) { - size_t n = MIN(AES_BLOCK_SIZE - ctx->B_i_ofs, v_len); - - memcpy(&ctx->B_i[ctx->B_i_ofs], v, n); - v += n; - v_len -= n; - ctx->B_i_ofs += n; - *remain -= n; - } - - if ((ctx->B_i_ofs == AES_BLOCK_SIZE) || (*remain == 0)) { - aes_block_xor(ctx->X_i, ctx->B_i, ctx->B_i); - AES_encrypt(ctx->B_i, ctx->X_i, &ctx->aes_key); - ctx->B_i_ofs = 0; - } - - while (v_len >= AES_BLOCK_SIZE) { - aes_block_xor(ctx->X_i, v, ctx->B_i); - AES_encrypt(ctx->B_i, ctx->X_i, &ctx->aes_key); - v += AES_BLOCK_SIZE; - v_len -= AES_BLOCK_SIZE; - *remain -= AES_BLOCK_SIZE; - } - - if (v_len > 0) { - ZERO_STRUCT(ctx->B_i); - memcpy(ctx->B_i, v, v_len); - ctx->B_i_ofs += v_len; - *remain -= v_len; - v = NULL; - v_len = 0; - } - - if (*remain > 0) { - return; - } - - if (ctx->B_i_ofs > 0) { - aes_block_xor(ctx->X_i, ctx->B_i, ctx->B_i); - AES_encrypt(ctx->B_i, ctx->X_i, &ctx->aes_key); - ctx->B_i_ofs = 0; - } -} - -static inline void aes_ccm_128_S_i(struct aes_ccm_128_context *ctx, - uint8_t S_i[AES_BLOCK_SIZE], - size_t i) -{ - RSIVAL(ctx->A_i, (AES_BLOCK_SIZE - AES_CCM_128_L), i); - AES_encrypt(ctx->A_i, S_i, &ctx->aes_key); -} - -void aes_ccm_128_crypt(struct aes_ccm_128_context *ctx, - uint8_t *m, size_t m_len) -{ - while (m_len > 0) { - if (ctx->S_i_ofs == AES_BLOCK_SIZE) { - ctx->S_i_ctr += 1; - aes_ccm_128_S_i(ctx, ctx->S_i, ctx->S_i_ctr); - ctx->S_i_ofs = 0; - } - - if (likely(ctx->S_i_ofs == 0 && m_len >= AES_BLOCK_SIZE)) { - aes_block_xor(m, ctx->S_i, m); - m += AES_BLOCK_SIZE; - m_len -= AES_BLOCK_SIZE; - ctx->S_i_ctr += 1; - aes_ccm_128_S_i(ctx, ctx->S_i, ctx->S_i_ctr); - continue; - } - - m[0] ^= ctx->S_i[ctx->S_i_ofs]; - m += 1; - m_len -= 1; - ctx->S_i_ofs += 1; - } -} - -void aes_ccm_128_digest(struct aes_ccm_128_context *ctx, - uint8_t digest[AES_BLOCK_SIZE]) -{ - if (unlikely(ctx->a_remain != 0)) { - abort(); - } - if (unlikely(ctx->m_remain != 0)) { - abort(); - } - - /* prepare S_0 */ - aes_ccm_128_S_i(ctx, ctx->S_i, 0); - - /* - * note X_i is T here - */ - aes_block_xor(ctx->X_i, ctx->S_i, digest); - - ZERO_STRUCTP(ctx); -} diff --git a/lib/crypto/aes_ccm_128.h b/lib/crypto/aes_ccm_128.h deleted file mode 100644 index 1382ee704b9..00000000000 --- a/lib/crypto/aes_ccm_128.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - AES-CCM-128 (rfc 3610) - - Copyright (C) Stefan Metzmacher 2012 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef LIB_CRYPTO_AES_CCM_128_H -#define LIB_CRYPTO_AES_CCM_128_H - -#define AES_CCM_128_M 16 -#define AES_CCM_128_L 4 -#define AES_CCM_128_NONCE_SIZE (15 - AES_CCM_128_L) - -struct aes_ccm_128_context { - AES_KEY aes_key; - - uint8_t nonce[AES_CCM_128_NONCE_SIZE]; - - size_t a_remain; - size_t m_remain; - - uint64_t __align; - - uint8_t X_i[AES_BLOCK_SIZE]; - uint8_t B_i[AES_BLOCK_SIZE]; - uint8_t A_i[AES_BLOCK_SIZE]; - uint8_t S_i[AES_BLOCK_SIZE]; - - size_t B_i_ofs; - size_t S_i_ofs; - size_t S_i_ctr; -}; - -void aes_ccm_128_init(struct aes_ccm_128_context *ctx, - const uint8_t K[AES_BLOCK_SIZE], - const uint8_t N[AES_CCM_128_NONCE_SIZE], - size_t a_total, size_t m_total); -void aes_ccm_128_update(struct aes_ccm_128_context *ctx, - const uint8_t *v, size_t v_len); -void aes_ccm_128_crypt(struct aes_ccm_128_context *ctx, - uint8_t *m, size_t m_len); -void aes_ccm_128_digest(struct aes_ccm_128_context *ctx, - uint8_t digest[AES_BLOCK_SIZE]); - -#endif /* LIB_CRYPTO_AES_CCM_128_H */ diff --git a/lib/crypto/aes_ccm_128_test.c b/lib/crypto/aes_ccm_128_test.c deleted file mode 100644 index 67745e3e1ae..00000000000 --- a/lib/crypto/aes_ccm_128_test.c +++ /dev/null @@ -1,377 +0,0 @@ -/* - AES-CCM-128 tests - - Copyright (C) Stefan Metzmacher 2015 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ -#include "replace.h" -#include "../lib/util/samba_util.h" -#include "lib/crypto/aes.h" -#include "lib/crypto/aes_ccm_128.h" -#include "lib/crypto/aes_test.h" - -#ifndef AES_CCM_128_ONLY_TESTVECTORS -struct torture_context; -bool torture_local_crypto_aes_ccm_128(struct torture_context *torture); - -/* - This uses our own test values as we rely on a 11 byte nonce - and the values from rfc rfc3610 use 13 byte nonce. -*/ -bool torture_local_crypto_aes_ccm_128(struct torture_context *tctx) -{ - bool ret = true; - uint32_t i; - struct aes_mode_testvector testarray[] = { -#endif /* AES_CCM_128_ONLY_TESTVECTORS */ -#define AES_CCM_128_TESTVECTOR(_k, _n, _a, _p, _c, _t) \ - AES_MODE_TESTVECTOR(aes_ccm_128, _k, _n, _a, _p, _c, _t) - - AES_CCM_128_TESTVECTOR( - /* K */ - "8BF9FBC2B8149484FF11AB1F3A544FF6", - /* N */ - "010000000000000077F7A8", - /* A */ - "010000000000000077F7A80000000000" - "A8000000000001004100002C00980000", - /* P */ - "FE534D4240000100000000000B00811F" - "00000000000000000600000000000000" - "00000000010000004100002C00980000" - "00000000000000000000000000000000" - "3900000094010600FFFFFFFFFFFFFFFF" - "FFFFFFFFFFFFFFFF7800000030000000" - "000000007800000000000000FFFF0000" - "0100000000000000" - "03005C003100370032002E0033003100" - "2E0039002E003100380033005C006E00" - "650074006C006F0067006F006E000000", - /* C */ - "25985364BF9AF90EB0B9C8FB55B7C446" - "780F310F1EC4677726BFBF34E38E6408" - "057EE228814F11CBAAB794A79F7A1F78" - "2DE73B7477985360A02D35A7A347ABF7" - "9F18DD8687767423BB08F18642B6EFEE" - "8B1543D83091AF5952F58BB4BD89FF6B" - "0206E7170481C7BC61F06653D0CF10F7" - "C78380389382C276" - "7B8BF34D687A5C3D4F783F926F7755C0" - "2D44C30848C69CFDD8E54395F1881611" - "E5502285870A7179068923105190C837", - /* T */ - "3C11F652F8EA5600C8607D2E0FEAFD42" - ), - AES_CCM_128_TESTVECTOR( - /* K */ - "f9fdca4ac64fe7f014de0f43039c7571", - /* N */ - "5a8aa485c316e947125478", - /* A */ - "3796cf51b8726652a4204733b8fbb047" - "cf00fb91a9837e22ec22b1a268f88e2c", - /* P */ - "a265480ca88d5f536db0dc6abc40faf0" - "d05be7a9669777682345647586786983", - /* C */ - "65F8D8422006FB77FB7CCEFDFFF93729" - "B3EFCB06A0FAF3A2ABAB485723373F53", - /* T */ - "2C62BD82AD231887A7B326E1E045BC91" - ), - AES_CCM_128_TESTVECTOR( - /* K */ - "197afb02ffbd8f699dacae87094d5243", - /* N */ - "5a8aa485c316e947125478", - /* A */ - "", - /* P */ - "3796cf51b8726652a4204733b8fbb047" - "cf00fb91a9837e22", - /* C */ - "CA53910394115C5DAB5D7250F04D6A27" - "2BCFA4329528F3AC", - /* T */ - "38E3A318F9BA88D4DD2FAF3521820001" - ), - AES_CCM_128_TESTVECTOR( - /* K */ - "90929a4b0ac65b350ad1591611fe4829", - /* N */ - "5a8aa485c316e9403aff85", - /* A */ - "", - /* P */ - "a16a2e741f1cd9717285b6d882c1fc53" - "655e9773761ad697", - /* C */ - "ACA5E98D2784D131AE76E3C8BF9C3988" - "35C0206C71893F26", - /* T */ - "AE67C0EA38C5383BFDC7967F4E9D1678" - ), - AES_CCM_128_TESTVECTOR( - /* K */ - "f9fdca4ac64fe7f014de0f43039c7571", - /* N */ - "5a8aa485c316e947125478", - /* A */ - "3796cf51b8726652a4204733b8fbb047" - "cf00fb91a9837e22ec22b1a268f88e2c", - /* P */ - "a265480ca88d5f536db0dc6abc40faf0" - "d05be7a966977768", - /* C */ - "65F8D8422006FB77FB7CCEFDFFF93729" - "B3EFCB06A0FAF3A2", - /* T */ - "03C6E244586AFAB9B60D9F6DBDF7EB1A" - ), - AES_CCM_128_TESTVECTOR( - /* K */ - "26511fb51fcfa75cb4b44da75a6e5a0e", - /* N */ - "5a8aa485c316e9403aff85", - /* A */ - "a16a2e741f1cd9717285b6d882c1fc53" - "655e9773761ad697a7ee6410184c7982", - /* P */ - "8739b4bea1a099fe547499cbc6d1b13d" - "849b8084c9b6acc5", - /* C */ - "D31F9FC23674D5272125375E0A2F5365" - "41B1FAF1DD68C819", - /* T */ - "4F315233A76C4DD99972561C5158AB3B" - ), - AES_CCM_128_TESTVECTOR( - /* K */ - "f9fdca4ac64fe7f014de0f43039c7571", - /* N */ - "5a8aa485c316e947125478", - /* A */ - "3796cf51b8726652a4204733b8fbb047" - "cf00fb91a9837e22ec22b1a268", - /* P */ - "a265480ca88d5f536db0dc6abc40faf0" - "d05be7a9669777682376345745", - /* C */ - "65F8D8422006FB77FB7CCEFDFFF93729" - "B3EFCB06A0FAF3A2AB981875E0", - /* T */ - "EA93AAEDA607226E9E79D2EE5C4B62F8" - ), - AES_CCM_128_TESTVECTOR( - /* K */ - "26511fb51fcfa75cb4b44da75a6e5a0e", - /* N */ - "5a8aa485c316e9403aff85", - /* A */ - "a16a2e741f1cd9717285b6d882c1fc53" - "65", - /* P */ - "8739b4bea1a099fe547499cbc6d1b13d" - "84", - /* C */ - "D31F9FC23674D5272125375E0A2F5365" - "41", - /* T */ - "036F58DA2372B29BD0E01C58A0E7F9EE" - ), - AES_CCM_128_TESTVECTOR( - /* K */ - "00000000000000000000000000000000", - /* N */ - "0000000000000000000000", - /* A */ - "", - /* P */ - "00", - /* C */ - "2E", - /* T */ - "61787D2C432A58293B73D01154E61B6B" - ), - AES_CCM_128_TESTVECTOR( - /* K */ - "00000000000000000000000000000000", - /* N */ - "0000000000000000000000", - /* A */ - "00", - /* P */ - "00", - /* C */ - "2E", - /* T */ - "E4284A0E813F0FFA146CF59F9ADAFBD7" - ), -#ifndef AES_CCM_128_ONLY_TESTVECTORS - }; - - for (i=0; i < ARRAY_SIZE(testarray); i++) { - struct aes_ccm_128_context ctx; -- Samba Shared Repository