| /optee_os/core/mm/ |
| H A D | pgt_cache.c | 1 // SPDX-License-Identifier: BSD-2-Clause 73 assert(pgt && pgt->parent); in free_pgt() 74 parent = pgt->parent; in free_pgt() 75 assert(parent->num_used <= PGT_PARENT_TBL_COUNT && in free_pgt() 76 parent->num_used > 0); in free_pgt() 77 if (parent->num_used == PGT_PARENT_TBL_COUNT) in free_pgt() 79 parent->num_used--; in free_pgt() 81 if (!parent->num_used && SLIST_NEXT(SLIST_FIRST(&parent_list), link)) { in free_pgt() 87 tee_mm_free(parent->mm); in free_pgt() 90 SLIST_INSERT_HEAD(&parent->pgt_cache, pgt, link); in free_pgt() [all …]
|
| /optee_os/lib/libmbedtls/mbedtls/library/ |
| H A D | asn1parse.c | 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 28 int mbedtls_asn1_get_len(unsigned char **p, in mbedtls_asn1_get_len() argument 32 if ((end - *p) < 1) { in mbedtls_asn1_get_len() 36 if ((**p & 0x80) == 0) { in mbedtls_asn1_get_len() 37 *len = *(*p)++; in mbedtls_asn1_get_len() 39 int n = (**p) & 0x7F; in mbedtls_asn1_get_len() 43 if ((end - *p) <= n) { in mbedtls_asn1_get_len() 47 (*p)++; in mbedtls_asn1_get_len() 48 while (n--) { in mbedtls_asn1_get_len() 49 *len = (*len << 8) | **p; in mbedtls_asn1_get_len() [all …]
|
| H A D | bignum_core.h | 6 * modules should use the high-level modular bignum interface (bignum_mod.h) 9 * This module is about processing non-negative integers with a fixed upper 10 * bound that's of the form 2^n-1 where n is a multiple of #biL. 19 * - **Overflow**: some functions indicate overflow from the range 20 * [0, 2^n-1] by returning carry parameters, while others operate 23 * - **Bignum parameters**: Bignums are passed as pointers to an array of 25 * - Bignum parameters called \p A, \p B, ... are inputs, and are 27 * - For operations modulo some number, the modulus is called \p N 28 * and is input-only. 29 * - Bignum parameters called \p X, \p Y are outputs or input-output. [all …]
|
| H A D | asn1write.c | 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 24 int mbedtls_asn1_write_len(unsigned char **p, const unsigned char *start, size_t len) in mbedtls_asn1_write_len() argument 40 if (required > (*p - start)) { in mbedtls_asn1_write_len() 45 *--(*p) = MBEDTLS_BYTE_0(len); in mbedtls_asn1_write_len() 50 *--(*p) = (unsigned char) (0x80 + required - 1); in mbedtls_asn1_write_len() 56 int mbedtls_asn1_write_tag(unsigned char **p, const unsigned char *start, unsigned char tag) in mbedtls_asn1_write_tag() argument 58 if (*p - start < 1) { in mbedtls_asn1_write_tag() 62 *--(*p) = tag; in mbedtls_asn1_write_tag() 69 static int mbedtls_asn1_write_len_and_tag(unsigned char **p, in mbedtls_asn1_write_len_and_tag() argument 76 MBEDTLS_ASN1_CHK_ADD(len, mbedtls_asn1_write_len(p, start, len)); in mbedtls_asn1_write_len_and_tag() [all …]
|
| H A D | bignum_mod.h | 9 * - **Modulus parameters**: the modulus is passed as a pointer to a structure 13 * named \c N and is usually input-only. Functions which take a parameter 15 * - **Bignum parameters**: Bignums are passed as pointers to an array of 19 * - Bignum parameters called \c A, \c B, ... are inputs and are not 22 * - Bignum parameters called \c X, \c Y, ... are outputs or input-output. 23 * The initial bignum value of output-only parameters is ignored, but 25 * functions (typically constant-flow) require that the limbs in an 27 * - Bignum parameters called \c p are inputs used to set up a modulus or 29 * - \c T is a temporary storage area. The initial content of such a 31 * - Some functions use different names, such as \c r for the residue. [all …]
|
| H A D | bignum_mod_raw.h | 2 * Low-level modular bignum functions 4 * This interface should only be used by the higher-level modular bignum 6 * modules should use the high-level modular bignum interface (bignum_mod.h) 9 * This is a low-level interface to operations on integers modulo which 11 * the wrong size. The functions in bignum_mod.h provide a higher-level 17 * - **Modulus parameters**: the modulus is passed as a pointer to a structure 21 * named \c N and is usually input-only. 22 * - **Bignum parameters**: Bignums are passed as pointers to an array of 24 * - Bignum parameters called \c A, \c B, ... are inputs, and are not 26 * - Bignum parameters called \c X, \c Y are outputs or input-output. [all …]
|
| H A D | constant_time_internal.h | 2 * Constant-time functions 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 20 /* The constant-time interface provides various operations that are likely 21 * to result in constant-time code that does not branch or use conditional 27 * - boolean operations 34 * - conditional data selection 40 * - block memory operations 47 * be able to prove anything about its value at compile-time. 53 * not-larger integer types). 55 * For Arm (32-bit, 64-bit and Thumb), x86 and x86-64, assembly implementations [all …]
|
| H A D | x509.c | 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 8 * The ITU-T X.509 standard defines a certificate format for PKI. 14 * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf 15 * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf 63 int mbedtls_x509_get_serial(unsigned char **p, const unsigned char *end, in mbedtls_x509_get_serial() argument 68 if ((end - *p) < 1) { in mbedtls_x509_get_serial() 73 if (**p != (MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_PRIMITIVE | 2) && in mbedtls_x509_get_serial() 74 **p != MBEDTLS_ASN1_INTEGER) { in mbedtls_x509_get_serial() 79 serial->tag = *(*p)++; in mbedtls_x509_get_serial() 81 if ((ret = mbedtls_asn1_get_len(p, end, &serial->len)) != 0) { in mbedtls_x509_get_serial() [all …]
|
| H A D | pkcs7.c | 3 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 40 static int pkcs7_get_next_content_len(unsigned char **p, unsigned char *end, in pkcs7_get_next_content_len() argument 45 ret = mbedtls_asn1_get_tag(p, end, len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_next_content_len() 49 } else if ((size_t) (end - *p) != *len) { in pkcs7_get_next_content_len() 61 static int pkcs7_get_version(unsigned char **p, unsigned char *end, int *ver) in pkcs7_get_version() argument 65 ret = mbedtls_asn1_get_int(p, end, ver); in pkcs7_get_version() 84 static int pkcs7_get_content_info_type(unsigned char **p, unsigned char *end, in pkcs7_get_content_info_type() argument 90 unsigned char *start = *p; in pkcs7_get_content_info_type() 92 ret = mbedtls_asn1_get_tag(p, end, &len, MBEDTLS_ASN1_CONSTRUCTED in pkcs7_get_content_info_type() 95 *p = start; in pkcs7_get_content_info_type() [all …]
|
| H A D | psa_crypto_core_common.h | 8 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 18 * (`p + n` has undefined behavior when `p` is null, even when `n == 0`. 22 * \param p Pointer to a buffer of at least n bytes. 23 * This may be \p NULL if \p n is zero. 25 * \return Pointer to offset \p n in the buffer \p p. 27 * buffer is at least \p n + 1. 30 unsigned char *p, size_t n) in psa_crypto_buffer_offset() 32 return p == NULL ? NULL : p + n; in psa_crypto_buffer_offset() 35 /** Return an offset into a read-only buffer. 39 * \param p Pointer to a buffer of at least n bytes. [all …]
|
| H A D | x509_crl.c | 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 8 * The ITU-T X.509 standard defines a certificate format for PKI. 14 * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf 15 * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf 51 static int x509_crl_get_version(unsigned char **p, in x509_crl_get_version() argument 57 if ((ret = mbedtls_asn1_get_int(p, end, ver)) != 0) { in x509_crl_get_version() 73 * list of extensions is well-formed and abort on critical extensions (that 76 static int x509_get_crl_ext(unsigned char **p, in x509_get_crl_ext() argument 82 if (*p == end) { in x509_get_crl_ext() 88 * -- if present, version MUST be v2 in x509_get_crl_ext() [all …]
|
| H A D | x509_csr.c | 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 8 * The ITU-T X.509 standard defines a certificate format for PKI. 14 * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf 15 * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf 43 static int x509_csr_get_version(unsigned char **p, in x509_csr_get_version() argument 49 if ((ret = mbedtls_asn1_get_int(p, end, ver)) != 0) { in x509_csr_get_version() 65 unsigned char **p, const unsigned char *end, in x509_csr_parse_extensions() argument 73 while (*p < end) { in x509_csr_parse_extensions() 79 if ((ret = mbedtls_asn1_get_tag(p, end, &len, in x509_csr_parse_extensions() 84 end_ext_data = *p + len; in x509_csr_parse_extensions() [all …]
|
| H A D | bignum_mod.c | 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 27 mbedtls_mpi_uint *p, in mbedtls_mpi_mod_residue_setup() argument 30 if (p_limbs != N->limbs || !mbedtls_mpi_core_lt_ct(p, N->p, N->limbs)) { in mbedtls_mpi_mod_residue_setup() 34 r->limbs = N->limbs; in mbedtls_mpi_mod_residue_setup() 35 r->p = p; in mbedtls_mpi_mod_residue_setup() 46 r->limbs = 0; in mbedtls_mpi_mod_residue_release() 47 r->p = NULL; in mbedtls_mpi_mod_residue_release() 56 N->p = NULL; in mbedtls_mpi_mod_modulus_init() 57 N->limbs = 0; in mbedtls_mpi_mod_modulus_init() 58 N->bits = 0; in mbedtls_mpi_mod_modulus_init() [all …]
|
| H A D | rsa_alt_helpers.h | 4 * \brief Context-independent RSA helper functions 6 * This module declares some RSA-related helper functions useful when 13 * End-users of Mbed TLS who are not providing their own alternative RSA 23 * (1) Parameter-generating helpers. These are: 24 * - mbedtls_rsa_deduce_primes 25 * - mbedtls_rsa_deduce_private_exponent 26 * - mbedtls_rsa_deduce_crt 30 * (2) Parameter-checking helpers. These are: 31 * - mbedtls_rsa_validate_params 32 * - mbedtls_rsa_validate_crt [all …]
|
| H A D | x509_create.c | 5 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 34 * MBEDTLS_ASN1_UTF8_STRING for UTF-8. */ 37 #define ADD_STRLEN(s) s, sizeof(s) - 1 105 for (cur = x509_attrs; cur->name != NULL; cur++) { in x509_attr_descr_from_name() 106 if (cur->name_len == name_len && in x509_attr_descr_from_name() 107 strncmp(cur->name, name, name_len) == 0) { in x509_attr_descr_from_name() 112 if (cur->name == NULL) { in x509_attr_descr_from_name() 121 return ('0' <= c && c <= '9') ? (c - '0') : in hex_to_int() 122 ('a' <= c && c <= 'f') ? (c - 'a' + 10) : in hex_to_int() 123 ('A' <= c && c <= 'F') ? (c - 'A' + 10) : -1; in hex_to_int() [all …]
|
| /optee_os/core/pta/tests/ |
| H A D | invoke.c | 1 // SPDX-License-Identifier: BSD-2-Clause 35 paddr_t p = 0; in test_v2p2v() local 42 p = virt_to_phys(va); in test_v2p2v() 45 if (!p) in test_v2p2v() 48 if (to_ta_session(session)->clnt_id.login == TEE_LOGIN_TRUSTED_APP) { in test_v2p2v() 49 v = phys_to_virt(p, MEM_AREA_TS_VASPACE, size); in test_v2p2v() 51 v = phys_to_virt(p, MEM_AREA_NSEC_SHM, size); in test_v2p2v() 53 v = phys_to_virt(p, MEM_AREA_SDP_MEM, size); in test_v2p2v() 55 v = phys_to_virt(p, MEM_AREA_SHM_VASPACE, size); in test_v2p2v() 66 EMSG("va %p -> pa 0x%" PRIxPA " -> va %p", va, p, v); in test_v2p2v() [all …]
|
| /optee_os/lib/libmbedtls/mbedtls/include/mbedtls/ |
| H A D | asn1write.h | 8 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 46 * \param p The reference to the current position pointer. 47 * \param start The start of the buffer, for bounds-checking. 50 * \return The number of bytes written to \p p on success. 53 int mbedtls_asn1_write_len(unsigned char **p, const unsigned char *start, 60 * \param p The reference to the current position pointer. 61 * \param start The start of the buffer, for bounds-checking. 64 * \return The number of bytes written to \p p on success. 67 int mbedtls_asn1_write_tag(unsigned char **p, const unsigned char *start, 77 * \param p The reference to the current position pointer. [all …]
|
| H A D | asn1.h | 8 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 37 #define MBEDTLS_ERR_ASN1_OUT_OF_DATA -0x0060 39 #define MBEDTLS_ERR_ASN1_UNEXPECTED_TAG -0x0062 41 #define MBEDTLS_ERR_ASN1_INVALID_LENGTH -0x0064 43 #define MBEDTLS_ERR_ASN1_LENGTH_MISMATCH -0x0066 45 #define MBEDTLS_ERR_ASN1_INVALID_DATA -0x0068 47 #define MBEDTLS_ERR_ASN1_ALLOC_FAILED -0x006A 49 #define MBEDTLS_ERR_ASN1_BUF_TOO_SMALL -0x006C 58 * - 0x02 -- tag indicating INTEGER 59 * - 0x01 -- length in octets [all …]
|
| H A D | ccm.h | 7 * CCM combines Counter mode encryption with CBC-MAC authentication 8 * for 128-bit block ciphers. 11 * <ul><li>Payload - data that is both authenticated and encrypted.</li> 12 * <li>Associated data (Adata) - data that is authenticated but not 14 * <li>Nonce - A unique value that is assigned to the payload and the 18 * http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf 19 * RFC 3610 "Counter with CBC-MAC (CCM)" 25 * IEEE 802.15.4 - IEEE Standard for Local and metropolitan area networks 26 * Integer representation is fixed most-significant-octet-first order and 27 * the representation of octets is most-significant-bit-first order. This is [all …]
|
| /optee_os/core/include/ |
| H A D | io.h | 1 /* SPDX-License-Identifier: BSD-2-Clause */ 3 * Copyright (c) 2014-2019, Linaro Limited 22 #define READ_ONCE(p) __compiler_atomic_load(&(p)) argument 23 #define WRITE_ONCE(p, v) __compiler_atomic_store(&(p), (v)) argument 80 static inline uint64_t get_be64(const void *p) in get_be64() argument 82 return TEE_U64_FROM_BIG_ENDIAN(*(const uint64_t *)p); in get_be64() 85 static inline void put_be64(void *p, uint64_t val) in put_be64() argument 87 *(uint64_t *)p = TEE_U64_TO_BIG_ENDIAN(val); in put_be64() 90 static inline uint32_t get_be32(const void *p) in get_be32() argument 92 return TEE_U32_FROM_BIG_ENDIAN(*(const uint32_t *)p); in get_be32() [all …]
|
| /optee_os/lib/libutils/ext/include/ |
| H A D | atomic.h | 1 /* SPDX-License-Identifier: BSD-2-Clause */ 3 * Copyright (c) 2016-2019, Linaro Limited 15 static inline bool atomic_cas_uint(unsigned int *p, unsigned int *oval, in atomic_cas_uint() argument 18 return __compiler_compare_and_swap(p, oval, nval); in atomic_cas_uint() 21 static inline bool atomic_cas_u32(uint32_t *p, uint32_t *oval, uint32_t nval) in atomic_cas_u32() argument 23 return __compiler_compare_and_swap(p, oval, nval); in atomic_cas_u32() 26 static inline int atomic_load_int(int *p) in atomic_load_int() argument 28 return __compiler_atomic_load(p); in atomic_load_int() 31 static inline short int atomic_load_short(short int *p) in atomic_load_short() argument 33 return __compiler_atomic_load(p); in atomic_load_short() [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) 12 static void s_pi1(ulong32 *p) in s_pi1() argument 14 p[1] ^= p[0]; in s_pi1() 17 static void s_pi2(ulong32 *p, const ulong32 *k) in s_pi2() argument 20 t = (p[1] + k[0]) & 0xFFFFFFFFUL; in s_pi2() 21 t = (ROL(t, 1) + t - 1) & 0xFFFFFFFFUL; in s_pi2() 23 p[0] ^= t; in s_pi2() 26 static void s_pi3(ulong32 *p, const ulong32 *k) in s_pi3() argument [all …]
|
| /optee_os/core/drivers/crypto/versal/ |
| H A D | rsa.c | 1 // SPDX-License-Identifier: BSD-2-Clause 26 crypto_bignum_bn2bin(from, to + size - len); in crypto_bignum_bn2bin_pad() 31 struct rsa_public_key *p = rsa_data->key.key; in do_encrypt() local 41 switch (rsa_data->rsa_id) { in do_encrypt() 43 return sw_crypto_acipher_rsaes_encrypt(rsa_data->algo, in do_encrypt() 44 rsa_data->key.key, in do_encrypt() 45 rsa_data->label.data, in do_encrypt() 46 rsa_data->label.length, in do_encrypt() 47 rsa_data->mgf_algo, in do_encrypt() 48 rsa_data->message.data, in do_encrypt() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/pk/ecc/ |
| H A D | ltc_ecc_points.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 19 ecc_point *p; in ltc_ecc_new_point() local 20 p = XCALLOC(1, sizeof(*p)); in ltc_ecc_new_point() 21 if (p == NULL) { in ltc_ecc_new_point() 25 &p->x, &p->y, &p->z, LTC_NULL) != CRYPT_OK) { in ltc_ecc_new_point() 26 XFREE(p); in ltc_ecc_new_point() 29 return p; in ltc_ecc_new_point() 33 @param p The point to free 35 void ltc_ecc_del_point(ecc_point *p) in ltc_ecc_del_point() argument [all …]
|
| /optee_os/lib/libutee/arch/arm/gprof/ |
| H A D | gprof.c | 1 // SPDX-License-Identifier: (BSD-2-Clause AND BSD-3-Clause) 34 *- 115 static uint32_t _gprof_file_id; /* File id returned by tee-supplicant */ 123 return pc - (unsigned long)__text_start + sizeof(struct ta_head); in adjust_pc() 130 struct gmonparam *p = &_gmonparam; in __utee_gprof_init() local 145 p->lowpc = ROUNDDOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER)); in __utee_gprof_init() 146 p->highpc = ROUNDUP(highpc, HISTFRACTION * sizeof(HISTCOUNTER)); in __utee_gprof_init() 147 p->textsize = p->highpc - p->lowpc; in __utee_gprof_init() 148 p->kcountsize = ROUNDUP(p->textsize / HISTFRACTION, sizeof(*p->froms)); in __utee_gprof_init() 149 p->hashfraction = HASHFRACTION; in __utee_gprof_init() [all …]
|