|
23 | 23 | * See ESP32 Technical Reference Manual - RSA Accelerator Chapter |
24 | 24 | * |
25 | 25 | * esp_mp_exptmod() Large Number Modular Exponentiation Z = X^Y mod M |
26 | | - * esp_mp_mulmod() Large Number Modular Multiplication Z = X × Y mod M |
27 | | - * esp_mp_mul() Large Number Multiplication Z = X × Y |
| 26 | + * esp_mp_mulmod() Large Number Modular Multiplication Z = X * Y mod M |
| 27 | + * esp_mp_mul() Large Number Multiplication Z = X * Y |
28 | 28 | * |
29 | 29 | * The ESP32 RSA Accelerator supports operand lengths of: |
30 | | - * N ∈ {512, 1024, 1536, 2048, 2560, 3072, 3584, 4096} bits. The bit length |
| 30 | + * N in {512, 1024, 1536, 2048, 2560, 3072, 3584, 4096} bits. The bit length |
31 | 31 | * of arguments Z, X, Y , M, and r can be any one from the N set, but all |
32 | 32 | * numbers in a calculation must be of the same length. |
33 | 33 | * |
34 | | - * The bit length of M′ is always 32. |
| 34 | + * The bit length of M' is always 32. |
35 | 35 | * |
36 | 36 | * Also, beware: "we have uint32_t == unsigned long for both Xtensa and RISC-V" |
37 | 37 | * see https://github.com/espressif/esp-idf/issues/9511#issuecomment-1207342464 |
@@ -1285,8 +1285,8 @@ int esp_mp_mul(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* Z) |
1285 | 1285 | Zs = Xs + Ys; |
1286 | 1286 |
|
1287 | 1287 | /* RSA Accelerator only supports Large Number Multiplication |
1288 | | - * with operand length N = 32 × x, |
1289 | | - * where x ∈ {1, 2, 3, . . . , 64} */ |
| 1288 | + * with operand length N = 32 * x, |
| 1289 | + * where x in {1, 2, 3, . . . , 64} */ |
1290 | 1290 | if (Xs > 64 || Ys > 64) { |
1291 | 1291 | return MP_HW_FALLBACK; /* TODO add count metric on size fallback */ |
1292 | 1292 | } |
@@ -1334,7 +1334,7 @@ int esp_mp_mul(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* Z) |
1334 | 1334 |
|
1335 | 1335 | /* Y (left-extend) |
1336 | 1336 | * Accelerator supports large-number multiplication with only |
1337 | | - * four operand lengths of N ∈ {512, 1024, 1536, 2048} */ |
| 1337 | + * four operand lengths of N in {512, 1024, 1536, 2048} */ |
1338 | 1338 | left_pad_offset = maxWords_sz << 2; |
1339 | 1339 | if (left_pad_offset <= 512 >> 3) { |
1340 | 1340 | left_pad_offset = 512 >> 3; /* 64 bytes (16 words) */ |
@@ -1583,10 +1583,10 @@ int esp_mp_mul(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* Z) |
1583 | 1583 | * 0 => no interrupt; 1 => interrupt on completion. */ |
1584 | 1584 | DPORT_REG_WRITE(RSA_INT_ENA_REG, 0); |
1585 | 1585 | /* 2. Write number of words required for result. */ |
1586 | | - /* see 21.3.3 Write (/N16 − 1) to the RSA_MODE_REG register */ |
| 1586 | + /* see 21.3.3 Write (/N16 - 1) to the RSA_MODE_REG register */ |
1587 | 1587 | DPORT_REG_WRITE(RSA_MODE_REG, (hwWords_sz * 2 - 1)); |
1588 | 1588 |
|
1589 | | - /* 3. Write Xi and Yi for ∈ {0, 1, . . . , n − 1} to memory blocks |
| 1589 | + /* 3. Write Xi and Yi for {0, 1, . . . , n - 1} to memory blocks |
1590 | 1590 | * RSA_X_MEM and RSA_Z_MEM |
1591 | 1591 | * Maximum is 64 words (64*8*4 = 2048 bits) */ |
1592 | 1592 | esp_mpint_to_memblock(RSA_X_MEM, |
@@ -1796,7 +1796,7 @@ int esp_mp_mul(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* Z) |
1796 | 1796 | * |
1797 | 1797 | * See 24.3.3 of the ESP32 Technical Reference Manual |
1798 | 1798 | * |
1799 | | - * Z = X × Y mod M */ |
| 1799 | + * Z = X * Y mod M */ |
1800 | 1800 | int esp_mp_mulmod(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* M, MATH_INT_T* Z) |
1801 | 1801 | { |
1802 | 1802 | struct esp_mp_helper mph[1]; /* we'll save some values in this mp helper */ |
@@ -1839,7 +1839,7 @@ int esp_mp_mulmod(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* M, MATH_INT_T* Z) |
1839 | 1839 | /* do we have an even moduli? */ |
1840 | 1840 | if ((M->dp[0] & 1) == 0) { |
1841 | 1841 | #ifndef NO_ESP_MP_MUL_EVEN_ALT_CALC |
1842 | | - /* Z = X × Y mod M in mixed HW & SW*/ |
| 1842 | + /* Z = X * Y mod M in mixed HW & SW*/ |
1843 | 1843 | ret = esp_mp_mul(X, Y, tmpZ); /* HW X * Y */ |
1844 | 1844 | if (ret == MP_OKAY) { |
1845 | 1845 | /* z = tmpZ mod M, 0 <= Z < M */ |
@@ -1973,13 +1973,13 @@ int esp_mp_mulmod(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* M, MATH_INT_T* Z) |
1973 | 1973 | * or until the RSA_INTR interrupt is generated. |
1974 | 1974 | * (Or until the INTER interrupt is generated.) |
1975 | 1975 | * 6. Write 1 to RSA_INTERRUPT_REG to clear the interrupt. |
1976 | | - * 7. Write Yi (i ∈ [0, n) ∩ N) to RSA_X_MEM |
| 1976 | + * 7. Write Yi (i in [0, n) intersect N) to RSA_X_MEM |
1977 | 1977 | * Users need to write to the memory block only according to the length |
1978 | 1978 | * of the number. Data beyond this length is ignored. |
1979 | 1979 | * 8. Write 1 to RSA_MULT_START_REG |
1980 | 1980 | * 9. Wait for the second operation to be completed. |
1981 | 1981 | * Poll INTERRUPT_REG until it reads 1. |
1982 | | - * 10. Read the Zi (i ∈ [0, n) ∩ N) from RSA_Z_MEM |
| 1982 | + * 10. Read the Zi (i in [0, n) intersect N) from RSA_Z_MEM |
1983 | 1983 | * 11. Write 1 to RSA_INTERUPT_REG to clear the interrupt. |
1984 | 1984 | * |
1985 | 1985 | * post: Release the HW engine |
@@ -2500,15 +2500,15 @@ int esp_mp_mulmod(MATH_INT_T* X, MATH_INT_T* Y, MATH_INT_T* M, MATH_INT_T* Z) |
2500 | 2500 | * ESP32S3, Section 20.3.1, https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf |
2501 | 2501 | * |
2502 | 2502 | * The operation is based on Montgomery multiplication. Aside from the |
2503 | | - * arguments X, Y , and M, two additional ones are needed —r and M′ |
| 2503 | + * arguments X, Y , and M, two additional ones are needed -r and M' |
2504 | 2504 | .* These arguments are calculated in advance by software. |
2505 | 2505 | .* |
2506 | | -.* The RSA Accelerator supports operand lengths of N ∈ {512, 1024, 1536, 2048, |
2507 | | -.* 2560, 3072, 3584, 4096} bits on the ESP32 and N ∈ [32, 4096] bits |
| 2506 | +.* The RSA Accelerator supports operand lengths of N in {512, 1024, 1536, 2048, |
| 2507 | +.* 2560, 3072, 3584, 4096} bits on the ESP32 and N in [32, 4096] bits |
2508 | 2508 | * on the ESP32s3. |
2509 | 2509 | .* The bit length of arguments Z, X, Y , M, and r can be any one from |
2510 | 2510 | * the N set, but all numbers in a calculation must be of the same length. |
2511 | | -.* The bit length of M′ is always 32. |
| 2511 | +.* The bit length of M' is always 32. |
2512 | 2512 | .* |
2513 | 2513 | * Z = (X ^ Y) mod M : Espressif generic notation |
2514 | 2514 | * Y = (G ^ X) mod P : wolfSSL DH reference notation */ |
|
0 commit comments