| /optee_os/lib/libmbedtls/mbedtls/library/ |
| H A D | bn_mul.h | 4 * \brief Multi-precision integer library 8 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 16 * . IA-32 (386+) . AMD64 / EM64T 17 * . IA-32 (SSE2) . Motorola 68000 18 * . PowerPC, 32-bit . MicroBlaze 19 * . PowerPC, 64-bit . TriCore 51 #else /* 64-bits */ 71 /* *INDENT-OFF* */ 74 /* armcc5 --gnu defines __GNUC__ but doesn't support GNU's extended asm */ 86 * instead of using a fixed register, was implemented on x86/x86-64 [all …]
|
| H A D | aesni.c | 2 * AES-NI support functions 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 9 …* [AES-WP] https://www.intel.com/content/www/us/en/developer/articles/tool/intel-advanced-encrypti… 10 …CLMUL-WP] https://www.intel.com/content/www/us/en/develop/download/intel-carry-less-multiplication… 47 * AES-NI support detection routine 53 * https://github.com/Mbed-TLS/mbedtls/issues/9840 in mbedtls_aesni_has_support() 58 * (See example 8-1 in Sewell et al., "x86-TSO: A Rigorous and Usable in mbedtls_aesni_has_support() 75 asm ("movl $1, %%eax \n\t" in mbedtls_aesni_has_support() 76 "cpuid \n\t" in mbedtls_aesni_has_support() 91 * AES-NI AES-ECB block en(de)cryption [all …]
|
| H A D | padlock.c | 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 29 static int flags = -1; in mbedtls_padlock_has_support() 32 if (flags == -1) { in mbedtls_padlock_has_support() 33 asm ("movl %%ebx, %0 \n\t" in mbedtls_padlock_has_support() 34 "movl $0xC0000000, %%eax \n\t" in mbedtls_padlock_has_support() 35 "cpuid \n\t" in mbedtls_padlock_has_support() 36 "cmpl $0xC0000001, %%eax \n\t" in mbedtls_padlock_has_support() 37 "movl $0, %%edx \n\t" in mbedtls_padlock_has_support() 38 "jb 1f \n\t" in mbedtls_padlock_has_support() 39 "movl $0xC0000001, %%eax \n\t" in mbedtls_padlock_has_support() [all …]
|
| H A D | constant_time_impl.h | 2 * Constant-time functions 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 28 * This appears to behave as if the declaration-without-definition was not present 29 * (except for warnings if gcc -Wredundant-decls or similar is used). 31 * Disable -Wredundant-decls so that gcc does not warn about this. This is re-enabled 36 #pragma GCC diagnostic ignored "-Wredundant-decls" 39 /* armcc5 --gnu defines __GNUC__ but doesn't support GNU's extended asm */ 58 * Core const-time primitives 106 * although we don't actually care about setting the flags. 109 * syntax afterwards - otherwise old versions of gcc seem to apply [all …]
|
| H A D | hkdf.c | 2 * HKDF implementation -- RFC 5869 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 74 unsigned char t[MBEDTLS_MD_MAX_SIZE]; in mbedtls_hkdf_expand() local 111 memset(t, 0, hash_len); in mbedtls_hkdf_expand() 114 * Compute T = T(1) | T(2) | T(3) | ... | T(N) in mbedtls_hkdf_expand() 115 * Where T(N) is defined in RFC 5869 Section 2.3 in mbedtls_hkdf_expand() 126 ret = mbedtls_md_hmac_update(&ctx, t, t_len); in mbedtls_hkdf_expand() 136 /* The constant concatenated to the end of each T(n) is a single octet. in mbedtls_hkdf_expand() 143 ret = mbedtls_md_hmac_finish(&ctx, t); in mbedtls_hkdf_expand() 148 num_to_copy = i != n ? hash_len : okm_len - where; in mbedtls_hkdf_expand() [all …]
|
| H A D | bignum_mod_raw.c | 2 * Low-level modular bignum functions 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 31 mbedtls_mpi_core_cond_assign(X, A, N->limbs, mbedtls_ct_bool(assign)); in mbedtls_mpi_mod_raw_cond_assign() 39 mbedtls_mpi_core_cond_swap(X, Y, N->limbs, mbedtls_ct_bool(swap)); in mbedtls_mpi_mod_raw_cond_swap() 52 ret = mbedtls_mpi_core_read_le(X, N->limbs, in mbedtls_mpi_mod_raw_read() 56 ret = mbedtls_mpi_core_read_be(X, N->limbs, in mbedtls_mpi_mod_raw_read() 67 if (!mbedtls_mpi_core_lt_ct(X, N->p, N->limbs)) { in mbedtls_mpi_mod_raw_read() 85 return mbedtls_mpi_core_write_le(A, N->limbs, in mbedtls_mpi_mod_raw_write() 88 return mbedtls_mpi_core_write_be(A, N->limbs, in mbedtls_mpi_mod_raw_write() 100 mbedtls_mpi_uint c = mbedtls_mpi_core_sub(X, A, B, N->limbs); in mbedtls_mpi_mod_raw_sub() [all …]
|
| H A D | sha3.c | 2 * FIPS-202 compliant SHA3 implementation 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 8 * The SHA-3 Secure Hash Standard was published by NIST in 2015. 24 * these; the defaults here should give sensible trade-offs for gcc and clang on aarch64 and 25 * x86-64. 28 #define MBEDTLS_SHA3_THETA_UNROLL 0 //no-check-names 32 #define MBEDTLS_SHA3_CHI_UNROLL 0 //no-check-names 34 #define MBEDTLS_SHA3_CHI_UNROLL 1 //no-check-names 38 #define MBEDTLS_SHA3_PI_UNROLL 1 //no-check-names 41 #define MBEDTLS_SHA3_RHO_UNROLL 1 //no-check-names [all …]
|
| H A D | bignum_core.c | 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 39 mbedtls_mpi_uint mask = (mbedtls_mpi_uint) 1 << (biL - 1); in mbedtls_mpi_core_clz() 58 for (i = ((int) A_limbs) - 1; i >= 0; i--) { in mbedtls_mpi_core_bitlen() 60 j = biL - mbedtls_mpi_core_clz(A[i]); in mbedtls_mpi_core_bitlen() 93 * - adapt byte-order in each limb in mbedtls_mpi_core_bigendian_to_host() 94 * - swap the limbs themselves. in mbedtls_mpi_core_bigendian_to_host() 100 for (cur_limb_left = A, cur_limb_right = A + (A_limbs - 1); in mbedtls_mpi_core_bigendian_to_host() 102 cur_limb_left++, cur_limb_right--) { in mbedtls_mpi_core_bigendian_to_host() 138 for (size_t i = limbs; i > 0; i--) { in mbedtls_mpi_core_lt_ct() 140 * If B[i - 1] < A[i - 1] then A < B is false and the result must in mbedtls_mpi_core_lt_ct() [all …]
|
| /optee_os/lib/libutils/ext/include/ |
| H A D | speculation_barrier.h | 1 /* SPDX-License-Identifier: BSL-1.0 */ 4 Boost Software License - Version 1.0 - August 17th, 2003 10 Software, and to permit third-parties to whom the Software is furnished to do 17 solely in the form of machine-executable object code generated by a source 22 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 66 upper-bound comparison. We need to cast __high to an \ 74 "cmp\t%[__c], %[__l]\n\t" \ 75 "bcc\t.ns%=\n\t" \ 76 "ldr" __sz "\t%" __w "[__v], %[__p]\n" \ 77 ".ns%=:\n\t" \ [all …]
|
| /optee_os/core/lib/libtomcrypt/src/ciphers/ |
| H A D | multi2.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 6 Multi-2 implementation (not public domain, hence the default disable) 19 ulong32 t; in s_pi2() local 20 t = (p[1] + k[0]) & 0xFFFFFFFFUL; in s_pi2() 21 t = (ROL(t, 1) + t - 1) & 0xFFFFFFFFUL; in s_pi2() 22 t = (ROL(t, 4) ^ t) & 0xFFFFFFFFUL; in s_pi2() 23 p[0] ^= t; in s_pi2() 28 ulong32 t; in s_pi3() local 29 t = p[0] + k[1]; in s_pi3() [all …]
|
| H A D | camellia.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 179 #define loc(i) ((8-i)*8) in F() 198 out[x] = (in[(x+w)&15] << b) | (in[(x+w+1)&15] >> (8 - b)); in rot_128() 204 unsigned char T[48], kA[16], kB[16], kR[16], kL[16]; in camellia_setup() local 217 skey->camellia.R = (keylen == 16) ? 18 : 24; in camellia_setup() 219 if (num_rounds != 0 && num_rounds != skey->camellia.R) { in camellia_setup() 226 T[x] = key[x]; in camellia_setup() 227 T[x + 16] = 0; in camellia_setup() 231 T[x] = key[x]; in camellia_setup() [all …]
|
| /optee_os/core/arch/riscv/kernel/ |
| H A D | abort.c | 1 // SPDX-License-Identifier: BSD-2-Clause 3 * Copyright 2022-2023 NXP 4 * Copyright (c) 2015-2022, Linaro Limited 34 .fp = ai->regs->s0, in __print_stack_unwind() 35 .pc = ai->regs->epc, in __print_stack_unwind() 86 core_pos = thread_get_tsd()->abort_core; in __print_abort_info() 91 EMSG_RAW("%s %s-abort at address 0x%" PRIxVA "%s", in __print_abort_info() 92 ctx, abort_type_to_str(ai->abort_type), ai->va, in __print_abort_info() 93 fault_to_str(ai->abort_type, ai->fault_descr)); in __print_abort_info() 94 EMSG_RAW("cpu\t#%zu", core_pos); in __print_abort_info() [all …]
|
| /optee_os/scripts/ |
| H A D | ts_bin_to_c.py | 2 # SPDX-License-Identifier: BSD-2-Clause 5 # Copyright (c) 2020-2023, Arm Limited. 25 parser.add_argument('--out', required=True, 29 '--ta', 32 'such as: 8aaaf200-2450-11e4-abe2-0002a5d5c51b.stripped.elf') 35 '--sp', 38 'such as: 8aaaf200-2450-11e4-abe2-0002a5d5c51b.stripped.elf') 41 '--compress', 48 '--manifest', 75 offs = s2.header['sh_offset'] - s2.header['sh_addr'] [all …]
|
| H A D | arm32_sysreg.py | 2 # SPDX-License-Identifier: BSD-2-Clause 25 print('\t# ' + descr) 26 print('\t.macro read_' + reg_name.lower() + ' reg0, reg1') 28 print('\t.endm') 34 print('\t# ' + descr) 35 print('\t.macro write_' + reg_name.lower() + ' reg0, reg1') 37 print('\t.endm') 43 print('\t# ' + descr) 44 print('\t.macro read_' + reg_name.lower() + ' reg') 46 print('\t.endm') [all …]
|
| /optee_os/core/lib/libtomcrypt/src/stream/sober128/ |
| H A D | sober128_stream.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 7 Implementation of SOBER-128 by Tom St Denis. 16 /* don't change these... */ 20 #define FOLDP 4 /* where to insert non-linear feedback */ 24 ulong32 t; in BYTE2WORD() local 25 LOAD32L(t, b); in BYTE2WORD() 26 return t; in BYTE2WORD() 31 ulong32 t; in XORWORD() local 32 LOAD32L(t, in); in XORWORD() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/misc/hkdf/ |
| H A D | hkdf.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 22 zero filled key. Unless blocksize < hashLen (which wouldn't make any in hkdf_extract() 40 unsigned char *T, *dat; in hkdf_expand() local 48 hashsize = hash_descriptor[hash_idx]->hashsize; in hkdf_expand() 60 T = XMALLOC(Tlen); /* Replace with static buffer? */ in hkdf_expand() 61 if (T == NULL) { in hkdf_expand() 65 XMEMCPY(T + hashsize, info, infolen); in hkdf_expand() 68 /* HMAC data T(1) doesn't include a previous hash value */ in hkdf_expand() 69 dat = T + hashsize; in hkdf_expand() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/pk/asn1/der/object_identifier/ |
| H A D | der_decode_object_identifier.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 22 unsigned long x, y, t, len; in der_decode_object_identifier() local 47 y = inlen - x; in der_decode_object_identifier() 53 if ((len == 0) || (len > (inlen - x))) { in der_decode_object_identifier() 59 t = 0; in der_decode_object_identifier() 60 while (len--) { in der_decode_object_identifier() 61 t = (t << 7) | (in[x] & 0x7F); in der_decode_object_identifier() 63 /* store t */ in der_decode_object_identifier() 68 if (t <= 79) { in der_decode_object_identifier() [all …]
|
| H A D | der_encode_object_identifier.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 13 @param words The words to encode (upto 32-bits each) 22 unsigned long i, x, y, z, t, mask, wordbuf; in der_encode_object_identifier() local 42 t = der_object_identifier_bits(wordbuf); in der_encode_object_identifier() 43 z += t/7 + ((t%7) ? 1 : 0) + (wordbuf == 0 ? 1 : 0); in der_encode_object_identifier() 44 if (y < nwords - 1) { in der_encode_object_identifier() 52 y = *outlen - x; in der_encode_object_identifier() 62 t = wordbuf & 0xFFFFFFFF; in der_encode_object_identifier() 63 if (t) { in der_encode_object_identifier() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/pk/ec25519/ |
| H A D | tweetnacl.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 33 return (1 & ((d - 1) >> 8)) - 1; in vn() 54 o[(i+1)*(i<15)]+=c-1+37*(c-1)*(i==15); in car25519() 55 o[i]-=c<<16; in car25519() 61 i64 t,i,c=~(b-1); in sel25519() local 63 t= c&(p[i]^q[i]); in sel25519() 64 p[i]^=t; in sel25519() 65 q[i]^=t; in sel25519() 72 gf m,t; in pack25519() local [all …]
|
| /optee_os/core/lib/libtomcrypt/src/modes/xts/ |
| H A D | xts_decrypt.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 11 static int s_tweak_uncrypt(const unsigned char *C, unsigned char *P, unsigned char *T, const symmet… in s_tweak_uncrypt() argument 19 …C_FAST_TYPE_PTR_CAST(&P[x])) = *(LTC_FAST_TYPE_PTR_CAST(&C[x])) ^ *(LTC_FAST_TYPE_PTR_CAST(&T[x])); in s_tweak_uncrypt() 23 P[x] = C[x] ^ T[x]; in s_tweak_uncrypt() 27 err = cipher_descriptor[xts->cipher]->ecb_decrypt(P, P, &xts->key1); in s_tweak_uncrypt() 31 *(LTC_FAST_TYPE_PTR_CAST(&P[x])) ^= *(LTC_FAST_TYPE_PTR_CAST(&T[x])); in s_tweak_uncrypt() 35 P[x] = P[x] ^ T[x]; in s_tweak_uncrypt() 40 xts_mult_x(T); in s_tweak_uncrypt() 49 @param tweak [in] The 128--bit encryption tweak (e.g. sector number) [all …]
|
| H A D | xts_encrypt.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 11 static int s_tweak_crypt(const unsigned char *P, unsigned char *C, unsigned char *T, const symmetri… in s_tweak_crypt() argument 19 …C_FAST_TYPE_PTR_CAST(&C[x])) = *(LTC_FAST_TYPE_PTR_CAST(&P[x])) ^ *(LTC_FAST_TYPE_PTR_CAST(&T[x])); in s_tweak_crypt() 23 C[x] = P[x] ^ T[x]; in s_tweak_crypt() 27 if ((err = cipher_descriptor[xts->cipher]->ecb_encrypt(C, C, &xts->key1)) != CRYPT_OK) { in s_tweak_crypt() 33 *(LTC_FAST_TYPE_PTR_CAST(&C[x])) ^= *(LTC_FAST_TYPE_PTR_CAST(&T[x])); in s_tweak_crypt() 37 C[x] = C[x] ^ T[x]; in s_tweak_crypt() 42 xts_mult_x(T); in s_tweak_crypt() 51 @param tweak [in] The 128--bit encryption tweak (e.g. sector number) [all …]
|
| /optee_os/core/tee/ |
| H A D | tee_time_generic.c | 1 // SPDX-License-Identifier: BSD-2-Clause 69 TEE_Time t; in tee_time_get_ta_time() local 76 res = tee_time_get_sys_time(&t); in tee_time_get_ta_time() 81 TEE_TIME_ADD(t, *offs, t2); in tee_time_get_ta_time() 84 if (TEE_TIME_LT(t2, t)) in tee_time_get_ta_time() 87 TEE_TIME_SUB(t, *offs, t2); in tee_time_get_ta_time() 90 if (TEE_TIME_LE(t, t2)) in tee_time_get_ta_time() 102 TEE_Time t; in tee_time_set_ta_time() local 105 if (time->millis >= TEE_TIME_MILLIS_BASE) in tee_time_set_ta_time() 108 res = tee_time_get_sys_time(&t); in tee_time_set_ta_time() [all …]
|
| H A D | tee_cryp_hkdf.c | 1 // SPDX-License-Identifier: BSD-2-Clause 45 * "PRK = HMAC-Hash(salt, IKM)" in hkdf_extract() 105 * T = T(1) | T(2) | T(3) | ... | T(N) in hkdf_expand() 106 * OKM = first L octets of T in hkdf_expand() 107 * T(0) = empty string (zero length) in hkdf_expand() 108 * T(1) = HMAC-Hash(PRK, T(0) | info | 0x01) in hkdf_expand() 109 * T(2) = HMAC-Hash(PRK, T(1) | info | 0x02) in hkdf_expand() 110 * T(3) = HMAC-Hash(PRK, T(2) | info | 0x03) in hkdf_expand() 134 memcpy(okm + where, tn, (i < n) ? hash_len : (okm_len - where)); in hkdf_expand()
|
| /optee_os/lib/libmbedtls/core/ |
| H A D | sm2-pke.c | 1 // SPDX-License-Identifier: BSD-2-Clause 3 * Copyright (c) 2019-2021 Huawei Technologies Co., Ltd 7 #include <crypto/sm2-kdf.h> 18 #include "sm2-pke.h" 34 mres = mbedtls_mpi_read_binary(&p->X, ptr, SM2_INT_SIZE_BYTES); in sm2_uncompressed_bytes_to_point() 40 mres = mbedtls_mpi_read_binary(&p->Y, ptr, SM2_INT_SIZE_BYTES); in sm2_uncompressed_bytes_to_point() 44 mres = mbedtls_mpi_lset(&p->Z, 1); in sm2_uncompressed_bytes_to_point() 58 * GM/T 0003.1‒2012 Part 1 Section 4.2.9 83 max_size - 1, consumed); in sm2_bytes_to_point() 107 * GM/T 0003.1‒2012 Part 4 Section 7.1 [all …]
|
| /optee_os/core/lib/libtomcrypt/src/misc/base32/ |
| H A D | base32_decode.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 23 ulong64 t = 0; in base32_decode() local 31 …13/*N*/,14/*O*/,15/*P*/,16/*Q*/,17/*R*/,18/*S*/,19/*T*/,20/*U*/,21/*V*/,22/*W*/,23/*X*/,24/*Y*/,25… in base32_decode() 37 …23/*N*/,24/*O*/,25/*P*/,26/*Q*/,27/*R*/,28/*S*/,29/*T*/,30/*U*/,31/*V*/,99/*W*/,99/*X*/,99/*Y*/,99… in base32_decode() 43 …2/*N*/,16/*O*/,13/*P*/,14/*Q*/, 4/*R*/,22/*S*/,17/*T*/,19/*U*/,99/*V*/,20/*W*/,15/*X*/, 0/*Y*/,23/… in base32_decode() 49 …21/*N*/, 0/*O*/,22/*P*/,23/*Q*/,24/*R*/,25/*S*/,26/*T*/,99/*U*/,27/*V*/,28/*W*/,29/*X*/,30/*Y*/,31… in base32_decode() 60 while (inlen > 0 && in[inlen-1] == '=') inlen--; in base32_decode() 86 if ((c >= 'a') && (c <= 'z')) c -= 32; in base32_decode() 87 if (c < '0' || c > 'Z' || map[c-'0'] > 31) { in base32_decode() [all …]
|