| 1 | /******************************************************************************* |
| 2 | Copyright (c) 2023-2024, Intel Corporation |
| 3 | |
| 4 | Redistribution and use in source and binary forms, with or without |
| 5 | modification, are permitted provided that the following conditions are met: |
| 6 | |
| 7 | * Redistributions of source code must retain the above copyright notice, |
| 8 | this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above copyright |
| 10 | notice, this list of conditions and the following disclaimer in the |
| 11 | documentation and/or other materials provided with the distribution. |
| 12 | * Neither the name of Intel Corporation nor the names of its contributors |
| 13 | may be used to endorse or promote products derived from this software |
| 14 | without specific prior written permission. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | *******************************************************************************/ |
| 27 | |
| 28 | #include "intel-ipsec-mb.h"cxx . . $ `<file>/lib/intel-ipsec-mb.h`/ |
| 29 | #include "include/error.h"cxx . . $ `<file>/lib/include/error.h`/ |
| 30 | |
| 31 | IMB_DLL_EXPORTcxx . . $ `lib/intel-ipsec-mb.h:54:9`! void |
| 32 | imb_quic_hp_aes_ecbcxx . . $ imb_quic_hp_aes_ecb(16736bb65e0c9762).(IMB_MGRcxx . . $ IMB_MGR# *state, const void *exp_key_data, void *dst_ptr_array[], |
| 33 | const void *const src_ptr_array[], const uint64_tcxx . . $ uint64_t# num_packets, |
| 34 | const IMB_KEY_SIZE_BYTEScxx . . $ IMB_KEY_SIZE_BYTES# key_size) |
| 35 | { |
| 36 | #ifdef SAFE_PARAMcxx . . $ `<built-in>:422:9`! |
| 37 | uint64_tcxx . . $ uint64_t# i; |
| 38 | |
| 39 | if (state == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 40 | imb_set_errnocxx . . $ imb_set_errno(beec41fcb78e7267).(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, IMB_ERR_NULL_MBMGRcxx . . $ IMB_ERR_NULL_MBMGR.); |
| 41 | return; |
| 42 | } |
| 43 | if (exp_key_data == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 44 | imb_set_errnocxx . . $ imb_set_errno(beec41fcb78e7267).(state, IMB_ERR_NULL_EXP_KEYcxx . . $ IMB_ERR_NULL_EXP_KEY.); |
| 45 | return; |
| 46 | } |
| 47 | if (dst_ptr_array == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 48 | imb_set_errnocxx . . $ imb_set_errno(beec41fcb78e7267).(state, IMB_ERR_NULL_DSTcxx . . $ IMB_ERR_NULL_DST.); |
| 49 | return; |
| 50 | } |
| 51 | if (src_ptr_array == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 52 | imb_set_errnocxx . . $ imb_set_errno(beec41fcb78e7267).(state, IMB_ERR_NULL_SRCcxx . . $ IMB_ERR_NULL_SRC.); |
| 53 | return; |
| 54 | } |
| 55 | for (i = 0; i < num_packets; i++) { |
| 56 | if (dst_ptr_array[i] == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 57 | imb_set_errnocxx . . $ imb_set_errno(beec41fcb78e7267).(state, IMB_ERR_NULL_DSTcxx . . $ IMB_ERR_NULL_DST.); |
| 58 | return; |
| 59 | } |
| 60 | if (src_ptr_array[i] == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) { |
| 61 | imb_set_errnocxx . . $ imb_set_errno(beec41fcb78e7267).(state, IMB_ERR_NULL_SRCcxx . . $ IMB_ERR_NULL_SRC.); |
| 62 | return; |
| 63 | } |
| 64 | } |
| 65 | #endif /* SAFE_PARAM */ |
| 66 | |
| 67 | switch (key_size) { |
| 68 | case IMB_KEY_128_BYTEScxx . . $ IMB_KEY_128_BYTES.: |
| 69 | state->aes_ecb_128_quiccxx . . $ IMB_MGR#aes_ecb_128_quic.(src_ptr_array, exp_key_data, dst_ptr_array, num_packets); |
| 70 | break; |
| 71 | case IMB_KEY_256_BYTEScxx . . $ IMB_KEY_256_BYTES.: |
| 72 | state->aes_ecb_256_quiccxx . . $ IMB_MGR#aes_ecb_256_quic.(src_ptr_array, exp_key_data, dst_ptr_array, num_packets); |
| 73 | break; |
| 74 | /* AES-192 is not supported by QUIC */ |
| 75 | case IMB_KEY_192_BYTEScxx . . $ IMB_KEY_192_BYTES.: |
| 76 | default: |
| 77 | imb_set_errnocxx . . $ imb_set_errno(beec41fcb78e7267).(state, IMB_ERR_KEY_LENcxx . . $ IMB_ERR_KEY_LEN.); |
| 78 | return; |
| 79 | }; |
| 80 | |
| 81 | imb_set_errnocxx . . $ imb_set_errno(beec41fcb78e7267).(state, 0); |
| 82 | } |