Lines Matching +full:- +full:z
2 * \brief Multi-precision integer library, ESP-IDF hardware accelerated parts
6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
7 * Additions Copyright (C) 2016-2020, Espressif Systems (Shanghai) PTE Ltd
8 * SPDX-License-Identifier: Apache-2.0
14 * http://www.apache.org/licenses/LICENSE-2.0
44 /* newlib locks lazy initialize on ESP-IDF */ in esp_mpi_enable_hardware_hw_op()
76 uint32_t copy_words = MIN(hw_words, mpi->n); in mpi_to_mem_block()
80 pbase[i] = mpi->p[i]; in mpi_to_mem_block()
98 assert(x->n >= num_words); in mem_block_to_mpi()
101 esp_dport_access_read_buffer(x->p, mem_base, num_words); in mem_block_to_mpi()
105 for (size_t i = num_words; i < x->n; i++) { in mem_block_to_mpi()
106 x->p[i] = 0; in mem_block_to_mpi()
137 void esp_mpi_read_result_hw_op(mbedtls_mpi *Z, size_t z_words) in esp_mpi_read_result_hw_op() argument
140 mem_block_to_mpi(Z, RSA_MEM_Z_BLOCK_BASE, z_words); in esp_mpi_read_result_hw_op()
143 /* Z = (X * Y) mod M */
152 /* "mode" register loaded with number of 512-bit blocks, minus 1 */ in esp_mpi_mul_mpi_mod_hw_op()
153 DPORT_REG_WRITE(RSA_MULT_MODE_REG, (hw_words / 16) - 1); in esp_mpi_mul_mpi_mod_hw_op()
167 /* Z = X * Y */
170 /* Copy X (right-extended) & Y (left-extended) to memory block */ in esp_mpi_mul_mpi_hw_op()
173 /* NB: as Y is left-extended, we don't zero the bottom words_mult words of Y block. in esp_mpi_mul_mpi_hw_op()
179 /* "mode" register loaded with number of 512-bit blocks in result, in esp_mpi_mul_mpi_hw_op()
180 plus 7 (for range 9-12). (this is ((N~ / 32) - 1) + 8)) in esp_mpi_mul_mpi_hw_op()
189 int esp_mont_hw_op(mbedtls_mpi *Z, const mbedtls_mpi *X, const mbedtls_mpi *Y, const mbedtls_mpi *M, in esp_mont_hw_op() argument
194 // Note Z may be the same pointer as X or Y in esp_mont_hw_op()
201 DPORT_REG_WRITE(RSA_MULT_MODE_REG, hw_words / 16 - 1); in esp_mont_hw_op()
208 Z->s = 1; // The sign of Z will be = M->s (but M->s is always 1) in esp_mont_hw_op()
209 MBEDTLS_MPI_CHK( mbedtls_mpi_grow(Z, hw_words) ); in esp_mont_hw_op()
214 mem_block_to_mpi(Z, RSA_MEM_Z_BLOCK_BASE, hw_words); in esp_mont_hw_op()
217 /* from HAC 14.36 - 3. If Z >= M then Z = Z - M */ in esp_mont_hw_op()
218 if (mbedtls_mpi_cmp_mpi(Z, M) >= 0) { in esp_mont_hw_op()
219 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(Z, Z, M)); in esp_mont_hw_op()
227 /* Special-case of mbedtls_mpi_mult_mpi(), where we use hardware montgomery mod
236 * Modulus is chosen with M=(2^num_bits - 1) (ie M=R-1), so output
248 /* M = 2^num_words - 1, so block is entirely FF */ in esp_mpi_mult_mpi_failover_mod_mult_hw_op()
255 /* "mode" register loaded with number of 512-bit blocks, minus 1 */ in esp_mpi_mult_mpi_failover_mod_mult_hw_op()
256 DPORT_REG_WRITE(RSA_MULT_MODE_REG, (hw_words / 16) - 1); in esp_mpi_mult_mpi_failover_mod_mult_hw_op()