| /optee_os/core/lib/libtomcrypt/src/pk/asn1/der/sequence/ |
| H A D | der_encode_sequence_ex.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 27 unsigned long size, x, y, z, i; in der_encode_sequence_ex() local 35 y = 0; z = 0; in der_encode_sequence_ex() 36 if (der_length_sequence_ex(list, inlen, &y, &z) != CRYPT_OK) return CRYPT_INVALID_ARG; in der_encode_sequence_ex() 49 y = *outlen - x; in der_encode_sequence_ex() 50 if ((err = der_encode_asn1_length(z, &out[x], &y)) != CRYPT_OK) { in der_encode_sequence_ex() 56 *outlen -= x; in der_encode_sequence_ex() 68 z = *outlen; in der_encode_sequence_ex() 69 if ((err = der_encode_boolean(*((int *)data), out + x, &z)) != CRYPT_OK) { in der_encode_sequence_ex() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/pk/asn1/der/custom_type/ |
| H A D | der_encode_custom_type.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 17 root-ltc_asn1_list where the type is defined. 30 unsigned long size, x, y, z, i, inlen, id_len; in der_encode_custom_type() local 38 y = 0; z = 0; in der_encode_custom_type() 39 if (der_length_custom_type(root, &y, &z) != CRYPT_OK) return CRYPT_INVALID_ARG; in der_encode_custom_type() 53 if (root->pc == LTC_ASN1_PC_PRIMITIVE) { in der_encode_custom_type() 60 x -= 1; in der_encode_custom_type() 62 list = root->data; in der_encode_custom_type() 63 inlen = root->size; in der_encode_custom_type() [all …]
|
| H A D | der_decode_custom_type.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 28 Extended-decode a Custom type 50 unsigned long size, x, y, z, blksize; in der_decode_custom_type_ex() local 71 if (root->type != LTC_ASN1_CUSTOM_TYPE) { in der_decode_custom_type_ex() 76 if (root->pc == LTC_ASN1_PC_PRIMITIVE) { in der_decode_custom_type_ex() 89 if ((ident.type != root->type) || in der_decode_custom_type_ex() 90 (ident.klass != root->klass) || in der_decode_custom_type_ex() 91 (ident.pc != root->pc) || in der_decode_custom_type_ex() 92 (ident.tag != root->tag)) { in der_decode_custom_type_ex() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/pk/asn1/der/choice/ |
| H A D | der_decode_choice.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 23 unsigned long size, x, z; in der_decode_choice() local 48 if (der_length_boolean(&z) == CRYPT_OK) { in der_decode_choice() 50 *inlen = z; in der_decode_choice() 58 if (der_length_integer(data, &z) == CRYPT_OK) { in der_decode_choice() 60 *inlen = z; in der_decode_choice() 68 if (der_length_short_integer(*(unsigned long*)data, &z) == CRYPT_OK) { in der_decode_choice() 70 *inlen = z; in der_decode_choice() 78 if (der_length_bit_string(size, &z) == CRYPT_OK) { in der_decode_choice() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/ciphers/ |
| H A D | xtea.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 49 skey->xtea.A[x] = (sum + K[sum&3]) & 0xFFFFFFFFUL; in xtea_setup() 51 skey->xtea.B[x] = (sum + K[(sum>>11)&3]) & 0xFFFFFFFFUL; in xtea_setup() 70 ulong32 y, z; in xtea_ecb_encrypt() local 78 LOAD32H(z, &pt[4]); in xtea_ecb_encrypt() 80 y = (y + ((((z<<4)^(z>>5)) + z) ^ skey->xtea.A[r])) & 0xFFFFFFFFUL; in xtea_ecb_encrypt() 81 z = (z + ((((y<<4)^(y>>5)) + y) ^ skey->xtea.B[r])) & 0xFFFFFFFFUL; in xtea_ecb_encrypt() 83 y = (y + ((((z<<4)^(z>>5)) + z) ^ skey->xtea.A[r+1])) & 0xFFFFFFFFUL; in xtea_ecb_encrypt() 84 z = (z + ((((y<<4)^(y>>5)) + y) ^ skey->xtea.B[r+1])) & 0xFFFFFFFFUL; in xtea_ecb_encrypt() [all …]
|
| H A D | cast5.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 387 #define GB(x, i) ((unsigned char)((x[(15-i)>>2])>>(unsigned)(8*((15-i)&3)))) 389 #define GB(x, i) (((x[(15-i)>>2])>>(unsigned)(8*((15-i)&3)))&255) 406 ulong32 x[4], z[4]; in s_cast5_setup() local 431 LOAD32H(x[3-y],buf+4*y); in s_cast5_setup() 435 … z[3] = x[3] ^ S5[GB(x, 0xD)] ^ S6[GB(x, 0xF)] ^ S7[GB(x, 0xC)] ^ S8[GB(x, 0xE)] ^ S7[GB(x, 0x8)]; in s_cast5_setup() 436 … z[2] = x[1] ^ S5[GB(z, 0x0)] ^ S6[GB(z, 0x2)] ^ S7[GB(z, 0x1)] ^ S8[GB(z, 0x3)] ^ S8[GB(x, 0xA)]; in s_cast5_setup() 437 … z[1] = x[0] ^ S5[GB(z, 0x7)] ^ S6[GB(z, 0x6)] ^ S7[GB(z, 0x5)] ^ S8[GB(z, 0x4)] ^ S5[GB(x, 0x9)]; in s_cast5_setup() 438 … z[0] = x[2] ^ S5[GB(z, 0xA)] ^ S6[GB(z, 0x9)] ^ S7[GB(z, 0xb)] ^ S8[GB(z, 0x8)] ^ S6[GB(x, 0xB)]; in s_cast5_setup() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/pk/ecc/ |
| H A D | ltc_ecc_projective_add_point.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 25 void *t1, *t2, *x, *y, *z; in ltc_ecc_projective_add_point() local 34 if ((err = mp_init_multi(&t1, &t2, &x, &y, &z, LTC_NULL)) != CRYPT_OK) { in ltc_ecc_projective_add_point() 52 if ((mp_cmp(P->x, Q->x) == LTC_MP_EQ) && (mp_cmp(P->z, Q->z) == LTC_MP_EQ)) { in ltc_ecc_projective_add_point() 53 if (mp_cmp(P->y, Q->y) == LTC_MP_EQ) { in ltc_ecc_projective_add_point() 55 mp_clear_multi(t1, t2, x, y, z, LTC_NULL); in ltc_ecc_projective_add_point() 58 if ((err = mp_sub(modulus, Q->y, t1)) != CRYPT_OK) { goto done; } in ltc_ecc_projective_add_point() 59 if (mp_cmp(P->y, t1) == LTC_MP_EQ) { in ltc_ecc_projective_add_point() 60 /* here Q = -P >>> Result = the point at infinity */ in ltc_ecc_projective_add_point() [all …]
|
| H A D | ltc_ecc_points.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 25 &p->x, &p->y, &p->z, LTC_NULL) != CRYPT_OK) { in ltc_ecc_new_point() 39 …mp_clear_multi(p->x, p->y, p->z, LTC_NULL); /* note: p->z may be NULL but that's ok with this func… in ltc_ecc_del_point() 44 int ltc_ecc_set_point_xyz(ltc_mp_digit x, ltc_mp_digit y, ltc_mp_digit z, ecc_point *p) in ltc_ecc_set_point_xyz() argument 47 if ((err = ltc_mp.set_int(p->x, x)) != CRYPT_OK) return err; in ltc_ecc_set_point_xyz() 48 if ((err = ltc_mp.set_int(p->y, y)) != CRYPT_OK) return err; in ltc_ecc_set_point_xyz() 49 if ((err = ltc_mp.set_int(p->z, z)) != CRYPT_OK) return err; in ltc_ecc_set_point_xyz() 56 if ((err = ltc_mp.copy(src->x, dst->x)) != CRYPT_OK) return err; in ltc_ecc_copy_point() 57 if ((err = ltc_mp.copy(src->y, dst->y)) != CRYPT_OK) return err; in ltc_ecc_copy_point() [all …]
|
| H A D | ltc_ecc_map.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 29 if (mp_iszero(P->z)) { in ltc_ecc_map() 37 /* first map z back to normal */ in ltc_ecc_map() 38 if ((err = mp_montgomery_reduce(P->z, modulus, mp)) != CRYPT_OK) { goto done; } in ltc_ecc_map() 40 /* get 1/z */ in ltc_ecc_map() 41 if ((err = mp_invmod(P->z, modulus, t1)) != CRYPT_OK) { goto done; } in ltc_ecc_map() 43 /* get 1/z^2 and 1/z^3 */ in ltc_ecc_map() 50 if ((err = mp_mul(P->x, t2, P->x)) != CRYPT_OK) { goto done; } in ltc_ecc_map() 51 if ((err = mp_montgomery_reduce(P->x, modulus, mp)) != CRYPT_OK) { goto done; } in ltc_ecc_map() [all …]
|
| H A D | ltc_ecc_projective_dbl_point.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 9 * in Jacobian coordinates it becomes: y^2 = x^3 + a*x*z^4 + b*z^6 12 * Xr = M^2 - 2*S 13 * Yr = M * (S - Xr) - 8*T 20 * SPECIAL CASE: when a == -3 we can compute M as 21 * M = 3 * (Xp^2 - Zp^4) = 3 * (Xp + Zp^2) * (Xp - Zp^2) 65 /* t1 = Z * Z */ in ltc_ecc_projective_dbl_point() 66 if ((err = mp_sqr(R->z, t1)) != CRYPT_OK) { goto done; } in ltc_ecc_projective_dbl_point() 68 /* Z = Y * Z */ in ltc_ecc_projective_dbl_point() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/pk/asn1/der/short_integer/ |
| H A D | der_encode_short_integer.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 14 Store a short integer in the range (0,2^32-1) 22 unsigned long len, x, y, z; in der_encode_short_integer() local 42 z = 0; in der_encode_short_integer() 45 ++z; in der_encode_short_integer() 50 if (z == 0) { in der_encode_short_integer() 51 z = 1; in der_encode_short_integer() 55 z += (num&(1UL<<((z<<3) - 1))) ? 1 : 0; in der_encode_short_integer() 57 /* adjust the number so the msB is non-zero */ in der_encode_short_integer() [all …]
|
| H A D | der_length_short_integer.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 20 unsigned long z, y; in der_length_short_integer() local 29 z = 0; in der_length_short_integer() 32 ++z; in der_length_short_integer() 37 if (z == 0) { in der_length_short_integer() 38 z = 1; in der_length_short_integer() 39 } else if ((num&(1UL<<((z<<3) - 1))) != 0) { in der_length_short_integer() 41 ++z; in der_length_short_integer() 44 if ((err = der_length_asn1_length(z, &y)) != CRYPT_OK) { in der_length_short_integer() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/encauth/ccm/ |
| H A D | ccm_memory.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 47 unsigned long len, L, x, y, z, CTRlen; in ccm_memory() local 73 if (cipher_descriptor[cipher]->block_length != 16) { in ccm_memory() 83 if (cipher_descriptor[cipher]->accel_ccm_memory != NULL) { in ccm_memory() 84 return cipher_descriptor[cipher]->accel_ccm_memory( in ccm_memory() 108 if ((15 - noncelen) > L) { in ccm_memory() 109 L = 15 - noncelen; in ccm_memory() 123 if ((err = cipher_descriptor[cipher]->setup(key, keylen, 0, skey)) != CRYPT_OK) { in ccm_memory() 143 (((*taglen - 2)>>1)<<3) | in ccm_memory() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/pk/asn1/der/utf8/ |
| H A D | der_decode_utf8_string.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 25 unsigned long x, y, z, len; in der_decode_utf8_string() local 44 y = inlen - x; in der_decode_utf8_string() 50 if (len > (inlen - x)) { in der_decode_utf8_string() 57 https://tools.ietf.org/html/rfc3629#section-3 in der_decode_utf8_string() 76 /* determine z, the number of leading ones. in der_decode_utf8_string() 77 this is done by left-shifting tmp, which clears the ms-bits */ in der_decode_utf8_string() 78 for (z = 0; (tmp & 0x80) && (z <= 4); z++, tmp = (tmp << 1) & 0xFF); in der_decode_utf8_string() 80 /* z should be in {0,2,3,4} */ in der_decode_utf8_string() [all …]
|
| /optee_os/lib/libutils/isoc/arch/arm/softfloat/source/ |
| H A D | s_shiftRightJam128Extra.c | 1 // SPDX-License-Identifier: BSD-3-Clause 5 This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic 49 struct uint128_extra z; in softfloat_shiftRightJam128Extra() local 51 negCount = -count; in softfloat_shiftRightJam128Extra() 53 z.v.v64 = a64>>count; in softfloat_shiftRightJam128Extra() 54 z.v.v0 = a64<<(negCount & 63) | a0>>count; in softfloat_shiftRightJam128Extra() 55 z.extra = a0<<(negCount & 63); in softfloat_shiftRightJam128Extra() 57 z.v.v64 = 0; in softfloat_shiftRightJam128Extra() 59 z.v.v0 = a64; in softfloat_shiftRightJam128Extra() 60 z.extra = a0; in softfloat_shiftRightJam128Extra() [all …]
|
| H A D | s_normSubnormalF128Sig.c | 1 // SPDX-License-Identifier: BSD-3-Clause 5 This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic 46 struct exp32_sig128 z; in softfloat_normSubnormalF128Sig() local 49 shiftCount = softfloat_countLeadingZeros64( sig0 ) - 15; in softfloat_normSubnormalF128Sig() 50 z.exp = -63 - shiftCount; in softfloat_normSubnormalF128Sig() 52 z.sig.v64 = sig0>>-shiftCount; in softfloat_normSubnormalF128Sig() 53 z.sig.v0 = sig0<<(shiftCount & 63); in softfloat_normSubnormalF128Sig() 55 z.sig.v64 = sig0<<shiftCount; in softfloat_normSubnormalF128Sig() 56 z.sig.v0 = 0; in softfloat_normSubnormalF128Sig() 59 shiftCount = softfloat_countLeadingZeros64( sig64 ) - 15; in softfloat_normSubnormalF128Sig() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/pk/asn1/der/object_identifier/ |
| H A D | der_length_object_identifier.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 34 unsigned long y, z, t, wordbuf; in der_length_object_identifier() local 51 z = 0; in der_length_object_identifier() 55 z += t/7 + ((t%7) ? 1 : 0) + (wordbuf == 0 ? 1 : 0); in der_length_object_identifier() 56 if (y < nwords - 1) { in der_length_object_identifier() 63 if (z < 128) { in der_length_object_identifier() 64 z += 2; in der_length_object_identifier() 65 } else if (z < 256) { in der_length_object_identifier() 66 z += 3; in der_length_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 39 z = 0; 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() 53 if ((err = der_encode_asn1_length(z, out + x, &y)) != CRYPT_OK) { in der_encode_object_identifier() 71 /* now swap bytes y...x-1 */ in der_encode_object_identifier() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/math/ |
| H A D | tfm_desc.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 78 /* ---- trivial ---- */ 91 return A->used > 0 ? A->dp[0] : 0; in get_int() 99 return (n >= A->used || n < 0) ? 0 : A->dp[n]; in get_digit() 107 return A->used; in get_digit_count() 156 /* ---- conversions ---- */ 262 /* sqrtmod_prime - NOT SUPPORTED */ 440 fp_copy(P->x, R->x); in tfm_ecc_projective_dbl_point() 441 fp_copy(P->y, R->y); in tfm_ecc_projective_dbl_point() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/pk/asn1/der/integer/ |
| H A D | der_length_integer.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 20 unsigned long z, len; in der_length_integer() local 41 z = mp_count_bits(num); in der_length_integer() 42 z = z + (8 - (z & 7)); in der_length_integer() 43 if (((mp_cnt_lsb(num)+1)==mp_count_bits(num)) && ((mp_count_bits(num)&7)==0)) --z; in der_length_integer() 44 len = z >> 3; in der_length_integer() 47 if ((err = der_length_asn1_length(len, &z)) != CRYPT_OK) { in der_length_integer() 50 *outlen = 1 + z + len; in der_length_integer()
|
| /optee_os/core/lib/libtomcrypt/src/mac/pmac/ |
| H A D | pmac_process.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 24 unsigned char Z[MAXBLOCKSIZE]; in pmac_process() local 28 if ((err = cipher_is_valid(pmac->cipher_idx)) != CRYPT_OK) { in pmac_process() 32 if ((pmac->buflen > (int)sizeof(pmac->block)) || (pmac->buflen < 0) || in pmac_process() 33 (pmac->block_len > (int)sizeof(pmac->block)) || (pmac->buflen > pmac->block_len)) { in pmac_process() 38 if (pmac->buflen == 0 && inlen > 16) { in pmac_process() 40 for (x = 0; x < (inlen - 16); x += 16) { in pmac_process() 43 …*(LTC_FAST_TYPE_PTR_CAST(&Z[y])) = *(LTC_FAST_TYPE_PTR_CAST(&in[y])) ^ *(LTC_FAST_TYPE_PTR_CAST(&p… in pmac_process() 45 … if ((err = cipher_descriptor[pmac->cipher_idx]->ecb_encrypt(Z, Z, &pmac->key)) != CRYPT_OK) { in pmac_process() [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. 20 #define FOLDP 4 /* where to insert non-linear feedback */ 44 #define STEP(R,z) \ argument 45 …R[OFF(z,0)] = R[OFF(z,15)] ^ R[OFF(z,4)] ^ (R[OFF(z,0)] << 8) ^ Multab[(R[OFF(z,0)] >> 24) & 0xFF]; 55 R[i-1] = R[i]; in cycle() 57 R[N-1] = t; in cycle() 60 /* Return a non-linear function of some parts of the register. 62 #define NLFUNC(st,z) \ argument [all …]
|
| /optee_os/core/lib/libtomcrypt/src/encauth/ocb/ |
| H A D | ocb_encrypt.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 21 unsigned char Z[MAXBLOCKSIZE], tmp[MAXBLOCKSIZE]; in ocb_encrypt() local 27 if ((err = cipher_is_valid(ocb->cipher)) != CRYPT_OK) { in ocb_encrypt() 30 if (ocb->block_len != cipher_descriptor[ocb->cipher].block_length) { in ocb_encrypt() 35 for (x = 0; x < ocb->block_len; x++) { in ocb_encrypt() 36 ocb->checksum[x] ^= pt[x]; in ocb_encrypt() 39 /* Get Z[i] value */ in ocb_encrypt() 40 ocb_shift_xor(ocb, Z); in ocb_encrypt() 42 /* xor pt in, encrypt, xor Z out */ in ocb_encrypt() [all …]
|
| H A D | ocb_decrypt.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 21 unsigned char Z[MAXBLOCKSIZE], tmp[MAXBLOCKSIZE]; in ocb_decrypt() local 29 if ((err = cipher_is_valid(ocb->cipher)) != CRYPT_OK) { in ocb_decrypt() 32 LTC_ARGCHK(cipher_descriptor[ocb->cipher]->ecb_decrypt != NULL); in ocb_decrypt() 35 if (ocb->block_len != cipher_descriptor[ocb->cipher]->block_length) { in ocb_decrypt() 39 /* Get Z[i] value */ in ocb_decrypt() 40 ocb_shift_xor(ocb, Z); in ocb_decrypt() 42 /* xor ct in, encrypt, xor Z out */ in ocb_decrypt() 43 for (x = 0; x < ocb->block_len; x++) { in ocb_decrypt() [all …]
|
| H A D | s_ocb_done.c | 1 /* LibTomCrypt, modular cryptographic library -- Tom St Denis */ 2 /* SPDX-License-Identifier: Unlicense */ 35 unsigned char *Z, *Y, *X; in s_ocb_done() local 43 if ((err = cipher_is_valid(ocb->cipher)) != CRYPT_OK) { in s_ocb_done() 46 if (ocb->block_len != cipher_descriptor[ocb->cipher]->block_length || in s_ocb_done() 47 (int)ptlen > ocb->block_len || (int)ptlen < 0) { in s_ocb_done() 52 Z = XMALLOC(MAXBLOCKSIZE); in s_ocb_done() 55 if (X == NULL || Y == NULL || Z == NULL) { in s_ocb_done() 62 if (Z != NULL) { in s_ocb_done() 63 XFREE(Z); in s_ocb_done() [all …]
|