003 File Manager
Current Path:
/usr/src/contrib/bearssl/src/symcipher
usr
/
src
/
contrib
/
bearssl
/
src
/
symcipher
/
📁
..
📄
aes_big_cbcdec.c
(2.09 KB)
📄
aes_big_cbcenc.c
(2.04 KB)
📄
aes_big_ctr.c
(2.27 KB)
📄
aes_big_ctrcbc.c
(3.81 KB)
📄
aes_big_dec.c
(9.29 KB)
📄
aes_big_enc.c
(6.34 KB)
📄
aes_common.c
(3.86 KB)
📄
aes_ct.c
(6.91 KB)
📄
aes_ct64.c
(8.83 KB)
📄
aes_ct64_cbcdec.c
(2.89 KB)
📄
aes_ct64_cbcenc.c
(2.56 KB)
📄
aes_ct64_ctr.c
(3.13 KB)
📄
aes_ct64_ctrcbc.c
(10.98 KB)
📄
aes_ct64_dec.c
(4.11 KB)
📄
aes_ct64_enc.c
(3.03 KB)
📄
aes_ct_cbcdec.c
(3.13 KB)
📄
aes_ct_cbcenc.c
(2.68 KB)
📄
aes_ct_ctr.c
(3.03 KB)
📄
aes_ct_ctrcbc.c
(10.39 KB)
📄
aes_ct_dec.c
(4.63 KB)
📄
aes_ct_enc.c
(2.89 KB)
📄
aes_pwr8.c
(8.85 KB)
📄
aes_pwr8_cbcdec.c
(14.52 KB)
📄
aes_pwr8_cbcenc.c
(8.8 KB)
📄
aes_pwr8_ctr.c
(15.47 KB)
📄
aes_pwr8_ctrcbc.c
(22.02 KB)
📄
aes_small_cbcdec.c
(2.1 KB)
📄
aes_small_cbcenc.c
(2.06 KB)
📄
aes_small_ctr.c
(2.29 KB)
📄
aes_small_ctrcbc.c
(3.86 KB)
📄
aes_small_dec.c
(5.04 KB)
📄
aes_small_enc.c
(3.12 KB)
📄
aes_x86ni.c
(5.94 KB)
📄
aes_x86ni_cbcdec.c
(6.48 KB)
📄
aes_x86ni_cbcenc.c
(3.39 KB)
📄
aes_x86ni_ctr.c
(6.47 KB)
📄
aes_x86ni_ctrcbc.c
(16.84 KB)
📄
chacha20_ct.c
(2.96 KB)
📄
chacha20_sse2.c
(5.7 KB)
📄
des_ct.c
(12.14 KB)
📄
des_ct_cbcdec.c
(2.45 KB)
📄
des_ct_cbcenc.c
(2.11 KB)
📄
des_support.c
(4.01 KB)
📄
des_tab.c
(10.24 KB)
📄
des_tab_cbcdec.c
(2.38 KB)
📄
des_tab_cbcenc.c
(2.04 KB)
📄
poly1305_ctmul.c
(7.2 KB)
📄
poly1305_ctmul32.c
(8.23 KB)
📄
poly1305_ctmulq.c
(11.32 KB)
📄
poly1305_i15.c
(5.32 KB)
Editing: des_support.c
/* * Copyright (c) 2016 Thomas Pornin <pornin@bolet.org> * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "inner.h" /* see inner.h */ void br_des_do_IP(uint32_t *xl, uint32_t *xr) { /* * Permutation algorithm is initially from Richard Outerbridge; * implementation here is adapted from Crypto++ "des.cpp" file * (which is in public domain). */ uint32_t l, r, t; l = *xl; r = *xr; t = ((l >> 4) ^ r) & (uint32_t)0x0F0F0F0F; r ^= t; l ^= t << 4; t = ((l >> 16) ^ r) & (uint32_t)0x0000FFFF; r ^= t; l ^= t << 16; t = ((r >> 2) ^ l) & (uint32_t)0x33333333; l ^= t; r ^= t << 2; t = ((r >> 8) ^ l) & (uint32_t)0x00FF00FF; l ^= t; r ^= t << 8; t = ((l >> 1) ^ r) & (uint32_t)0x55555555; r ^= t; l ^= t << 1; *xl = l; *xr = r; } /* see inner.h */ void br_des_do_invIP(uint32_t *xl, uint32_t *xr) { /* * See br_des_do_IP(). */ uint32_t l, r, t; l = *xl; r = *xr; t = ((l >> 1) ^ r) & 0x55555555; r ^= t; l ^= t << 1; t = ((r >> 8) ^ l) & 0x00FF00FF; l ^= t; r ^= t << 8; t = ((r >> 2) ^ l) & 0x33333333; l ^= t; r ^= t << 2; t = ((l >> 16) ^ r) & 0x0000FFFF; r ^= t; l ^= t << 16; t = ((l >> 4) ^ r) & 0x0F0F0F0F; r ^= t; l ^= t << 4; *xl = l; *xr = r; } /* see inner.h */ void br_des_keysched_unit(uint32_t *skey, const void *key) { uint32_t xl, xr, kl, kr; int i; xl = br_dec32be(key); xr = br_dec32be((const unsigned char *)key + 4); /* * Permutation PC-1 is quite similar to the IP permutation. * Definition of IP (in FIPS 46-3 notations) is: * 58 50 42 34 26 18 10 2 * 60 52 44 36 28 20 12 4 * 62 54 46 38 30 22 14 6 * 64 56 48 40 32 24 16 8 * 57 49 41 33 25 17 9 1 * 59 51 43 35 27 19 11 3 * 61 53 45 37 29 21 13 5 * 63 55 47 39 31 23 15 7 * * Definition of PC-1 is: * 57 49 41 33 25 17 9 1 * 58 50 42 34 26 18 10 2 * 59 51 43 35 27 19 11 3 * 60 52 44 36 * 63 55 47 39 31 23 15 7 * 62 54 46 38 30 22 14 6 * 61 53 45 37 29 21 13 5 * 28 20 12 4 */ br_des_do_IP(&xl, &xr); kl = ((xr & (uint32_t)0xFF000000) >> 4) | ((xl & (uint32_t)0xFF000000) >> 12) | ((xr & (uint32_t)0x00FF0000) >> 12) | ((xl & (uint32_t)0x00FF0000) >> 20); kr = ((xr & (uint32_t)0x000000FF) << 20) | ((xl & (uint32_t)0x0000FF00) << 4) | ((xr & (uint32_t)0x0000FF00) >> 4) | ((xl & (uint32_t)0x000F0000) >> 16); /* * For each round, rotate the two 28-bit words kl and kr. * The extraction of the 48-bit subkey (PC-2) is not done yet. */ for (i = 0; i < 16; i ++) { if ((1 << i) & 0x8103) { kl = (kl << 1) | (kl >> 27); kr = (kr << 1) | (kr >> 27); } else { kl = (kl << 2) | (kl >> 26); kr = (kr << 2) | (kr >> 26); } kl &= (uint32_t)0x0FFFFFFF; kr &= (uint32_t)0x0FFFFFFF; skey[(i << 1) + 0] = kl; skey[(i << 1) + 1] = kr; } } /* see inner.h */ void br_des_rev_skey(uint32_t *skey) { int i; for (i = 0; i < 16; i += 2) { uint32_t t; t = skey[i + 0]; skey[i + 0] = skey[30 - i]; skey[30 - i] = t; t = skey[i + 1]; skey[i + 1] = skey[31 - i]; skey[31 - i] = t; } }
Upload File
Create Folder