Skip to content

Commit eb1855a

Browse files
committed
Typeset all mathematical equations and symbols as :math:
1 parent 83cec43 commit eb1855a

8 files changed

Lines changed: 75 additions & 71 deletions

File tree

doc/crypto/api/keys/management.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ When creating a key, the attributes for the new key are specified in a `psa_key_
155155

156156
The following type-specific considerations apply:
157157

158-
* For RSA keys (`PSA_KEY_TYPE_RSA_KEY_PAIR`), the public exponent is 65537. The modulus is a product of two probabilistic primes between 2^{n-1} and 2^n where n is the bit size specified in the attributes.
158+
* For RSA keys (`PSA_KEY_TYPE_RSA_KEY_PAIR`), the public exponent is 65537. The modulus is a product of two probabilistic primes between :math:`2^{n-1}` and :math:`2^n` where :math:`n` is the bit size specified in the attributes.
159159

160160
.. function:: psa_copy_key
161161

@@ -626,29 +626,29 @@ This section defines the format of the key data that an implementation is requir
626626

627627
The key data is the content of the ``privateKey`` field of the ``ECPrivateKey`` format defined by :RFC-title:`5915`.
628628

629-
This is a ``ceiling(m/8)``-byte string in big-endian order where ``m`` is the key size in bits.
629+
This is a :math:`\lceil{m/8}\rceil`-byte string in big-endian order, where :math:`m` is the key size in bits.
630630

631631
* - Weierstrass Elliptic curve public key
632632
- :code:`PSA_KEY_TYPE_ECC_PUBLIC_KEY(ecc_family)`, where ``ecc_family`` designates a Weierstrass curve family.
633633

634634
The key data is the uncompressed representation of an elliptic curve point as an octet string defined in :cite-title:`SEC1` §2.3.3.
635-
If ``m`` is the bit size associated with the curve, i.e. the bit size of ``q`` for a curve over ``F_q``, then the representation consists of:
635+
If :math:`m` is the bit size associated with the curve, i.e. the bit size of :math:`q` for a curve over :math:`\mathbb{F}_q`, then the representation of point :math:`P` consists of:
636636

637637
* The byte ``0x04``;
638-
* ``x_P`` as a ``ceiling(m/8)``-byte string, big-endian;
639-
* ``y_P`` as a ``ceiling(m/8)``-byte string, big-endian.
638+
* :math:`x_P` as a :math:`\lceil{m/8}\rceil`-byte string, big-endian;
639+
* :math:`y_P` as a :math:`\lceil{m/8}\rceil`-byte string, big-endian.
640640

641641
* - Montgomery Elliptic curve key pair
642642
- :code:`PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_MONTGOMERY)`
643643

644644
The key data is the scalar value of the 'private key' in little-endian order as defined by :RFC-title:`7748#6`. The value must have the forced bits set to zero or one as specified by ``decodeScalar25519()`` and ``decodeScalar448()`` in :RFC:`7748#5`.
645645

646-
This is a ``ceiling(m/8)``-byte string where ``m`` is the key size in bits. This is 32 bytes for Curve25519, and 56 bytes for Curve448.
646+
This is a :math:`\lceil{m/8}\rceil`-byte string where :math:`m` is the key size in bits. This is 32 bytes for Curve25519, and 56 bytes for Curve448.
647647

648648
* - Montgomery Elliptic curve public key
649649
- :code:`PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_MONTGOMERY)`
650650

651-
The key data is the scalar value of the 'public key' in little-endian order as defined by :RFC-title:`7748#6`. This is a ``ceiling(m/8)``-byte string where ``m`` is the key size in bits.
651+
The key data is the scalar value of the 'public key' in little-endian order as defined by :RFC-title:`7748#6`. This is a :math:`\lceil{m/8}\rceil`-byte string where :math:`m` is the key size in bits.
652652

653653
* This is 32 bytes for Curve25519, computed as ``X25519(private_key, 9)``.
654654
* This is 56 bytes for Curve448, computed as ``X448(private_key, 5)``.
@@ -670,9 +670,9 @@ This section defines the format of the key data that an implementation is requir
670670
* - Finite-field Diffie-Hellman key pair
671671
- :code:`PSA_KEY_TYPE_DH_KEY_PAIR(dh_family)` where ``dh_family`` designates any Diffie-Hellman family.
672672

673-
The key data is the representation of the private key ``x`` as a big-endian byte string. The length of the byte string is the private key size in bytes, and leading zeroes are not stripped.
673+
The key data is the representation of the private key :math:`x` as a big-endian byte string. The length of the byte string is the private key size in bytes, and leading zeroes are not stripped.
674674

675675
* - Finite-field Diffie-Hellman public key
676676
- :code:`PSA_KEY_TYPE_DH_PUBLIC_KEY(dh_family)` where ``dh_family`` designates any Diffie-Hellman family.
677677

678-
The key data is the representation of the public key ``y = g^x mod p`` as a big-endian byte string. The length of the byte string is the length of the base prime ``p`` in bytes.
678+
The key data is the representation of the public key :math:`y = g^x\!\mod p` as a big-endian byte string. The length of the byte string is the length of the base prime :math:`p` in bytes.

doc/crypto/api/keys/types.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ Elliptic Curve keys
495495
.. summary::
496496
Elliptic curve key pair: both the private and public key.
497497

498-
The size of an elliptic curve key is the bit size associated with the curve, that is, the bit size of *q* for a curve over a field *F*\ :sub:`q`. See the documentation of each Elliptic curve family for details.
498+
The size of an elliptic curve key is the bit size associated with the curve, that is, the bit size of :math:`q`` for a curve over a field :math:`\mathbb{F}_q`. See the documentation of each Elliptic curve family for details.
499499

500500
.. param:: curve
501501
A value of type `psa_ecc_family_t` that identifies the ECC curve family to be used.

doc/crypto/api/ops/aead.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ AEAD algorithms
5858

5959
To use `PSA_ALG_CCM` with a multi-part AEAD operation, the application must call `psa_aead_set_lengths()` before providing the nonce, the additional data and plaintext to the operation.
6060

61-
CCM requires a nonce of between 7 and 13 bytes in length. The length of the nonce affects the maximum length of the plaintext than can be encrypted or decrypted. If the nonce has length *N*, then the plaintext length *pLen* is encoded in *L* = 15 - *N* octets, this requires that *pLen* < 2\ :sup:`8L`.
61+
CCM requires a nonce of between 7 and 13 bytes in length. The length of the nonce affects the maximum length of the plaintext than can be encrypted or decrypted. If the nonce has length :math:`N`, then the plaintext length :math:`pLen` is encoded in :math:`L = 15 - N` octets, this requires that :math:`pLen < 2^{8L}`.
6262

63-
The value for *L* that is used with `PSA_ALG_CCM` depends on the function used to provide the nonce:
63+
The value for :math:`L` that is used with `PSA_ALG_CCM` depends on the function used to provide the nonce:
6464

65-
* A call to `psa_aead_encrypt()`, `psa_aead_decrypt()`, or `psa_aead_set_nonce()` will set *L* to 15 - ``nonce_length``. If the plaintext length cannot be encoded in *L* octets, then a :code:`PSA_ERROR_INVALID_ARGUMENT` error is returned.
65+
* A call to `psa_aead_encrypt()`, `psa_aead_decrypt()`, or `psa_aead_set_nonce()` will set :math:`L = 15 - \mathtt{nonce\_length}`. If the plaintext length cannot be encoded in :math:`L` octets, then a :code:`PSA_ERROR_INVALID_ARGUMENT` error is returned.
6666

67-
* A call to `psa_aead_generate_nonce()` on a multi-part cipher operation will select *L* as the smallest integer >= 2 where *pLen* < 2\ :sup:`8L`, with *pLen* being the ``plaintext_length`` provided to `psa_aead_set_lengths()`. The call to `psa_aead_generate_nonce()` will generate and return a random nonce of length 15 - *L* bytes.
67+
* A call to `psa_aead_generate_nonce()` on a multi-part cipher operation will select the smallest integer :math:`L \geq 2`, where :math:`pLen < 2^{8L}`, with :math:`pLen` being the ``plaintext_length`` provided to `psa_aead_set_lengths()`. The call to `psa_aead_generate_nonce()` will generate and return a random nonce of length :math:`15 - L` bytes.
6868

6969
CCM supports authentication tag sizes of 4, 6, 8, 10, 12, 14, and 16 bytes. The default tag length is 16. Shortened tag lengths can be requested using :code:`PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, tag_length)`, where ``tag_length`` is a valid CCM tag length.
7070

doc/crypto/api/ops/ciphers.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Cipher algorithms
119119

120120
A counter block value must only be used once across all messages encrypted using the same key value. This is typically achieved by splitting the counter block into a nonce, which is unique among all message encrypted with the key, and a counter which is incremented for each block of a message.
121121

122-
For example, when using AES-CTR encryption, which uses a 16-byte block, the application can provide a 12-byte nonce when setting the IV. This leaves 4 bytes for the counter, allowing up to 2^32 blocks (64GB) of message data to be encrypted in each message.
122+
For example, when using AES-CTR encryption, which uses a 16-byte block, the application can provide a 12-byte nonce when setting the IV. This leaves 4 bytes for the counter, allowing up to :math:`2^{32}` blocks (64GB) of message data to be encrypted in each message.
123123

124124
The first counter block is constructed from the initialization vector (IV). The initial counter block is is constructed in the following ways:
125125

@@ -129,7 +129,7 @@ Cipher algorithms
129129

130130
* A call to `psa_cipher_generate_iv()` on a multi-part cipher operation will generate and return a random counter block value.
131131

132-
* A call to `psa_cipher_set_iv()` on a multi-part cipher operation requires an IV that is between ``1`` and *n* bytes in length, where *n* is the cipher block length. The counter block is initialized using the IV, and padded with zero bytes up to the block length.
132+
* A call to `psa_cipher_set_iv()` on a multi-part cipher operation requires an IV that is between ``1`` and :math:`n` bytes in length, where :math:`n` is the cipher block length. The counter block is initialized using the IV, and padded with zero bytes up to the block length.
133133

134134
During the counter block update operation, the counter block is treated as a single big-endian encoded integer and the update operation increments this integer by ``1``.
135135

@@ -170,15 +170,15 @@ Cipher algorithms
170170

171171
The Zigbee message encryption algorithm is based on CCM*. This is detailed in :cite-title:`ZIGBEE` §B.1.1 and §A.
172172

173-
* For unauthenticated messages when *M* = 0 --- the `PSA_ALG_CCM_STAR_NO_TAG` algorithm is used with an AES-128 key in a multi-part cipher operation. The 13-byte IV must be constructed as specified in `[ZIGBEE]`, and provided to the operation using `psa_cipher_set_iv()`.
173+
* For unauthenticated messages --- when tag length :math:`M = 0` --- the `PSA_ALG_CCM_STAR_NO_TAG` algorithm is used with an AES-128 key in a multi-part cipher operation. The 13-byte IV must be constructed as specified in `[ZIGBEE]`, and provided to the operation using `psa_cipher_set_iv()`.
174174

175175
.. note::
176176

177177
An implementation of Zigbee cannot use the single-part `psa_cipher_encrypt()` function, as this generates a random IV, which is not valid for the Zigbee protocol.
178178

179-
* For authenticated messages when *M* ∈ {4, 8, 16} --- the :code:`PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, tag_length)` algorithm is used with an AES-128 key, where ``tag_length`` is the required value of *M*. The 13-byte nonce must be constructed as specified in `[ZIGBEE]`.
179+
* For authenticated messages --- when tag length :math:`M \in \{4, 8, 16\}` --- the :code:`PSA_ALG_AEAD_WITH_SHORTENED_TAG(PSA_ALG_CCM, tag_length)` algorithm is used with an AES-128 key, where ``tag_length`` is the required value of :math:`M`. The 13-byte nonce must be constructed as specified in `[ZIGBEE]`.
180180

181-
As the default tag length for CCM is 16, then `PSA_ALG_CCM` algorithm can be used when *M* = 16.
181+
As the default tag length for CCM is 16, then `PSA_ALG_CCM` algorithm can be used when :math:`M = 16`.
182182

183183
* To enable a single AES-128 key to be used for both the `PSA_ALG_CCM_STAR_NO_TAG` cipher and `PSA_ALG_CCM` AEAD algorithm, the key can be defined with the wildcard `PSA_ALG_CCM_STAR_ANY_TAG` permitted algorithm.
184184

@@ -206,7 +206,7 @@ Cipher algorithms
206206
.. note::
207207
The cipher block length can be determined using `PSA_BLOCK_CIPHER_BLOCK_LENGTH()`.
208208

209-
The CFB block cipher mode is defined in :cite-title:`SP800-38A`, using a segment size *s* equal to the block size *b*. The definition in `[SP800-38A]` is extended to allow an incomplete final block of input, in which case the algorithm discards the final bytes of the key stream when encrypting or decrypting the final partial block.
209+
The CFB block cipher mode is defined in :cite-title:`SP800-38A`, using a segment size :math:`s` equal to the block size :math:`b`. The definition in `[SP800-38A]` is extended to allow an incomplete final block of input, in which case the algorithm discards the final bytes of the key stream when encrypting or decrypting the final partial block.
210210

211211
.. subsection:: Compatible key types
212212

doc/crypto/api/ops/hashes.rst

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Hash algorithms
8181

8282
This is the cryptographic hash function based on the Merkle-Damgård construction over a Matyas-Meyer-Oseas one-way compression function and the AES-128 block cipher, with the parametrization defined in :cite-title:`ZIGBEE` §B.6.
8383

84-
This hash function can operate on input strings of up to 2\ :sup:`32` - 1 bits.
84+
This hash function can operate on input strings of up to :math:`2^{32} - 1` bits.
8585

8686
.. note::
8787

@@ -780,35 +780,37 @@ Hash suspend state format
780780

781781
The hash suspend state has the following format:
782782

783-
*hash-suspend-state* = *algorithm* || *input-length* || *hash-state* || *unprocessed-input*
783+
.. math::
784+
785+
hash\_suspend\_state = algorithm\ ||\ input\_length\ ||\ hash\_state\ ||\ unprocessed\_input
784786
785787
The fields in the hash suspend state are defined as follows:
786788

787-
*algorithm*
789+
:math:`algorithm`
788790
A big-endian 32-bit unsigned integer.
789791

790792
The |API| algorithm identifier value.
791793

792-
The byte length of the *algorithm* field can be evaluated using `PSA_HASH_SUSPEND_ALGORITHM_FIELD_LENGTH`.
794+
The byte length of the :math:`algorithm` field can be evaluated using `PSA_HASH_SUSPEND_ALGORITHM_FIELD_LENGTH`.
793795

794-
*input-length*
796+
:math:`input\_length`
795797
A big-endian unsigned integer
796798

797799
The content of this field is algorithm-specific:
798800

799-
* For MD2, this is the number of bytes in the *unprocessed-input*.
800-
* For all other hash algorithms, this is the total number of bytes of input to the hash computation. This includes the *unprocessed-input* bytes.
801+
* For MD2, this is the number of bytes in :math:`unprocessed\_input`.
802+
* For all other hash algorithms, this is the total number of bytes of input to the hash computation. This includes the :math:`unprocessed\_input` bytes.
801803

802804
The size of this field is algorithm-specific:
803805

804-
* For MD2: *input-length* is an 8-bit unsigned integer.
805-
* For MD4, MD5, RIPEMD-160, SHA-1, SHA-224, and SHA-256: *input-length* is a 64-bit unsigned integer.
806-
* For SHA-512/224, SHA-512/256, SHA-384, and SHA-512: *input-length* is a 128-bit unsigned integer.
806+
* For MD2: :math:`input\_length` is an 8-bit unsigned integer.
807+
* For MD4, MD5, RIPEMD-160, SHA-1, SHA-224, and SHA-256: :math:`input\_length` is a 64-bit unsigned integer.
808+
* For SHA-512/224, SHA-512/256, SHA-384, and SHA-512: :math:`input\_length` is a 128-bit unsigned integer.
807809

808-
The length, in bytes, of the *input-length* field can be calculated using :code:`PSA_HASH_SUSPEND_INPUT_LENGTH_FIELD_LENGTH(alg)` where ``alg`` is a hash algorithm.
810+
The length, in bytes, of the :math:`input\_length` field can be calculated using :code:`PSA_HASH_SUSPEND_INPUT_LENGTH_FIELD_LENGTH(alg)` where ``alg`` is a hash algorithm.
809811
See :secref:`hash-suspend-state-constants`.
810812

811-
*hash-state*
813+
:math:`hash\_state`
812814
An array of bytes
813815

814816
Algorithm-specific intermediate hash state:
@@ -821,17 +823,19 @@ The fields in the hash suspend state are defined as follows:
821823
* For SHA-512/224, SHA-512/256, SHA-384, and SHA-512: 8x 64-bit integers, in big-endian encoding.
822824

823825
The length of this field is specific to the algorithm.
824-
The length, in bytes, of the *hash-state* field can be calculated using :code:`PSA_HASH_SUSPEND_HASH_STATE_FIELD_LENGTH(alg)` where ``alg`` is a hash algorithm.
826+
The length, in bytes, of the :math:`hash\_state` field can be calculated using :code:`PSA_HASH_SUSPEND_HASH_STATE_FIELD_LENGTH(alg)` where ``alg`` is a hash algorithm.
825827
See :secref:`hash-suspend-state-constants`.
826828

827-
*unprocessed-input*
828-
0 to (*hash-block-size*-1) bytes
829+
:math:`unprocessed\_input`
830+
:math:`0\ \text{to}\ (hash\_block\_size - 1)` bytes
831+
832+
A partial block of unprocessed input data. This is between zero and :math:`hash\_block\_size - 1` bytes of data, the length can be calculated by:
829833

830-
A partial block of unprocessed input data. This is between zero and *hash-block-size*-1 bytes of data, the length can be calculated by:
834+
.. math::
831835
832-
``length(``\ *unprocessed-input*\ ``)`` ``=`` *input-length* ``%`` *hash-block-size*.
836+
\text{length}(unprocessed\_input) = input\_length \mod hash\_block\_size.
833837
834-
The *hash-block-size* is specific to the algorithm.
838+
The value of :math:`hash\_block\_size` is specific to the hash algorithm.
835839
The size of a hash block can be calculated using :code:`PSA_HASH_BLOCK_LENGTH(alg)` where ``alg`` is a hash algorithm.
836840
See :secref:`hash-suspend-state-constants`.
837841

@@ -842,18 +846,18 @@ Hash suspend state field sizes
842846

843847
The following table defines the algorithm-specific field lengths for the hash suspend state returned by `psa_hash_suspend()`. All of the field lengths are in bytes. To compute the field lengths for algorithm ``alg``, use the following expressions:
844848

845-
* :code:`PSA_HASH_SUSPEND_ALGORITHM_FIELD_LENGTH` returns the length of the *algorithm* field.
846-
* :code:`PSA_HASH_SUSPEND_INPUT_LENGTH_FIELD_LENGTH(alg)` returns the length of the *input-length* field.
847-
* :code:`PSA_HASH_SUSPEND_HASH_STATE_FIELD_LENGTH(alg)` returns the length of the *hash-state* field.
848-
* :code:`PSA_HASH_BLOCK_LENGTH(alg)-1` is the maximum length of the *unprocessed-bytes* field.
849+
* :code:`PSA_HASH_SUSPEND_ALGORITHM_FIELD_LENGTH` returns the length of the :math:`algorithm` field.
850+
* :code:`PSA_HASH_SUSPEND_INPUT_LENGTH_FIELD_LENGTH(alg)` returns the length of the :math:`input\_length` field.
851+
* :code:`PSA_HASH_SUSPEND_HASH_STATE_FIELD_LENGTH(alg)` returns the length of the :math:`hash\_state` field.
852+
* :code:`PSA_HASH_BLOCK_LENGTH(alg) - 1` is the maximum length of the :math:`unprocessed\_bytes` field.
849853
* :code:`PSA_HASH_SUSPEND_OUTPUT_SIZE(alg)` returns the maximum size of the hash suspend state.
850854

851855
.. csv-table::
852856
:header-rows: 1
853857
:widths: auto
854858
:align: left
855859

856-
Hash algorithm, *input-length* size (bytes), *hash-state* length (bytes), *unprocessed-bytes* length (bytes)
860+
Hash algorithm, :math:`input\_length` size (bytes), :math:`hash\_state` length (bytes), :math:`unprocessed\_bytes` length (bytes)
857861
`PSA_ALG_MD2`, 1, 64, 0 -- 15
858862
`PSA_ALG_MD4`, 8, 16, 0 -- 63
859863
`PSA_ALG_MD5`, 8, 16, 0 -- 63

0 commit comments

Comments
 (0)