@@ -952,6 +952,14 @@ typedef uint32_t psa_pake_primitive_t;
952952 */
953953#define PSA_PAKE_STEP_ZK_PROOF ((psa_pake_step_t) 0x03)
954954
955+ struct psa_pake_cipher_suite_s {
956+ psa_algorithm_t algorithm ;
957+ psa_pake_primitive_type_t type ;
958+ psa_pake_family_t family ;
959+ uint16_t bits ;
960+ psa_algorithm_t hash ;
961+ };
962+
955963/** The type of the data structure for PAKE cipher suites.
956964 *
957965 * This is an implementation-defined \c struct. Applications should not
@@ -1057,6 +1065,79 @@ static psa_algorithm_t psa_pake_cs_get_hash(
10571065static void psa_pake_cs_set_hash (psa_pake_cipher_suite_t * cipher_suite ,
10581066 psa_algorithm_t hash );
10591067
1068+ struct psa_crypto_driver_pake_inputs_s {
1069+ uint8_t * MBEDTLS_PRIVATE (password );
1070+ size_t MBEDTLS_PRIVATE (password_len );
1071+ uint8_t * MBEDTLS_PRIVATE (user );
1072+ size_t MBEDTLS_PRIVATE (user_len );
1073+ uint8_t * MBEDTLS_PRIVATE (peer );
1074+ size_t MBEDTLS_PRIVATE (peer_len );
1075+ psa_key_attributes_t MBEDTLS_PRIVATE (attributes );
1076+ psa_pake_cipher_suite_t MBEDTLS_PRIVATE (cipher_suite );
1077+ };
1078+
1079+ /** The type of input values for PAKE operations. */
1080+ typedef struct psa_crypto_driver_pake_inputs_s psa_crypto_driver_pake_inputs_t ;
1081+
1082+ typedef enum psa_jpake_round {
1083+ PSA_JPAKE_FIRST = 0 ,
1084+ PSA_JPAKE_SECOND = 1 ,
1085+ PSA_JPAKE_FINISHED = 2
1086+ } psa_jpake_round_t ;
1087+
1088+ typedef enum psa_jpake_io_mode {
1089+ PSA_JPAKE_INPUT = 0 ,
1090+ PSA_JPAKE_OUTPUT = 1
1091+ } psa_jpake_io_mode_t ;
1092+
1093+ struct psa_jpake_computation_stage_s {
1094+ /* The J-PAKE round we are currently on */
1095+ psa_jpake_round_t MBEDTLS_PRIVATE (round );
1096+ /* The 'mode' we are currently in (inputting or outputting) */
1097+ psa_jpake_io_mode_t MBEDTLS_PRIVATE (io_mode );
1098+ /* The number of completed inputs so far this round */
1099+ uint8_t MBEDTLS_PRIVATE (inputs );
1100+ /* The number of completed outputs so far this round */
1101+ uint8_t MBEDTLS_PRIVATE (outputs );
1102+ /* The next expected step (KEY_SHARE, ZK_PUBLIC or ZK_PROOF) */
1103+ psa_pake_step_t MBEDTLS_PRIVATE (step );
1104+ };
1105+
1106+ /** The type of computation stage for J-PAKE operations. */
1107+ typedef struct psa_jpake_computation_stage_s psa_jpake_computation_stage_t ;
1108+
1109+ struct psa_pake_operation_s {
1110+ #if defined(MBEDTLS_PSA_CRYPTO_CLIENT ) && !defined(MBEDTLS_PSA_CRYPTO_C )
1111+ mbedtls_psa_client_handle_t handle ;
1112+ #else
1113+ /** Unique ID indicating which driver got assigned to do the
1114+ * operation. Since driver contexts are driver-specific, swapping
1115+ * drivers halfway through the operation is not supported.
1116+ * ID values are auto-generated in psa_crypto_driver_wrappers.h
1117+ * ID value zero means the context is not valid or not assigned to
1118+ * any driver (i.e. none of the driver contexts are active). */
1119+ unsigned int MBEDTLS_PRIVATE (id );
1120+ /* Algorithm of the PAKE operation */
1121+ psa_algorithm_t MBEDTLS_PRIVATE (alg );
1122+ /* A primitive of type compatible with algorithm */
1123+ psa_pake_primitive_t MBEDTLS_PRIVATE (primitive );
1124+ /* Stage of the PAKE operation: waiting for the setup, collecting inputs
1125+ * or computing. */
1126+ uint8_t MBEDTLS_PRIVATE (stage );
1127+ /* Holds computation stage of the PAKE algorithms. */
1128+ union {
1129+ uint8_t MBEDTLS_PRIVATE (dummy );
1130+ #if defined(PSA_WANT_ALG_JPAKE )
1131+ psa_jpake_computation_stage_t MBEDTLS_PRIVATE (jpake );
1132+ #endif
1133+ } MBEDTLS_PRIVATE (computation_stage );
1134+ union {
1135+ psa_driver_pake_context_t MBEDTLS_PRIVATE (ctx );
1136+ psa_crypto_driver_pake_inputs_t MBEDTLS_PRIVATE (inputs );
1137+ } MBEDTLS_PRIVATE (data );
1138+ #endif
1139+ };
1140+
10601141/** The type of the state data structure for PAKE operations.
10611142 *
10621143 * Before calling any function on a PAKE operation object, the application
@@ -1087,12 +1168,6 @@ static void psa_pake_cs_set_hash(psa_pake_cipher_suite_t *cipher_suite,
10871168 * Implementation details can change in future versions without notice. */
10881169typedef struct psa_pake_operation_s psa_pake_operation_t ;
10891170
1090- /** The type of input values for PAKE operations. */
1091- typedef struct psa_crypto_driver_pake_inputs_s psa_crypto_driver_pake_inputs_t ;
1092-
1093- /** The type of computation stage for J-PAKE operations. */
1094- typedef struct psa_jpake_computation_stage_s psa_jpake_computation_stage_t ;
1095-
10961171/** Return an initial value for a PAKE operation object.
10971172 */
10981173static psa_pake_operation_t psa_pake_operation_init (void );
@@ -1754,14 +1829,6 @@ psa_status_t psa_pake_abort(psa_pake_operation_t *operation);
17541829 { 0 }, { { 0 } } }
17551830#endif
17561831
1757- struct psa_pake_cipher_suite_s {
1758- psa_algorithm_t algorithm ;
1759- psa_pake_primitive_type_t type ;
1760- psa_pake_family_t family ;
1761- uint16_t bits ;
1762- psa_algorithm_t hash ;
1763- };
1764-
17651832static inline psa_algorithm_t psa_pake_cs_get_algorithm (
17661833 const psa_pake_cipher_suite_t * cipher_suite )
17671834{
@@ -1823,17 +1890,6 @@ static inline void psa_pake_cs_set_hash(psa_pake_cipher_suite_t *cipher_suite,
18231890 }
18241891}
18251892
1826- struct psa_crypto_driver_pake_inputs_s {
1827- uint8_t * MBEDTLS_PRIVATE (password );
1828- size_t MBEDTLS_PRIVATE (password_len );
1829- uint8_t * MBEDTLS_PRIVATE (user );
1830- size_t MBEDTLS_PRIVATE (user_len );
1831- uint8_t * MBEDTLS_PRIVATE (peer );
1832- size_t MBEDTLS_PRIVATE (peer_len );
1833- psa_key_attributes_t MBEDTLS_PRIVATE (attributes );
1834- psa_pake_cipher_suite_t MBEDTLS_PRIVATE (cipher_suite );
1835- };
1836-
18371893typedef enum psa_crypto_driver_pake_step {
18381894 PSA_JPAKE_STEP_INVALID = 0 , /* Invalid step */
18391895 PSA_JPAKE_X1_STEP_KEY_SHARE = 1 , /* Round 1: input/output key share (for ephemeral private key X1).*/
@@ -1850,67 +1906,11 @@ typedef enum psa_crypto_driver_pake_step {
18501906 PSA_JPAKE_X4S_STEP_ZK_PROOF = 12 /* Round 2: input Schnorr NIZKP proof for the X4S key (from peer) */
18511907} psa_crypto_driver_pake_step_t ;
18521908
1853- typedef enum psa_jpake_round {
1854- PSA_JPAKE_FIRST = 0 ,
1855- PSA_JPAKE_SECOND = 1 ,
1856- PSA_JPAKE_FINISHED = 2
1857- } psa_jpake_round_t ;
1858-
1859- typedef enum psa_jpake_io_mode {
1860- PSA_JPAKE_INPUT = 0 ,
1861- PSA_JPAKE_OUTPUT = 1
1862- } psa_jpake_io_mode_t ;
1863-
1864- struct psa_jpake_computation_stage_s {
1865- /* The J-PAKE round we are currently on */
1866- psa_jpake_round_t MBEDTLS_PRIVATE (round );
1867- /* The 'mode' we are currently in (inputting or outputting) */
1868- psa_jpake_io_mode_t MBEDTLS_PRIVATE (io_mode );
1869- /* The number of completed inputs so far this round */
1870- uint8_t MBEDTLS_PRIVATE (inputs );
1871- /* The number of completed outputs so far this round */
1872- uint8_t MBEDTLS_PRIVATE (outputs );
1873- /* The next expected step (KEY_SHARE, ZK_PUBLIC or ZK_PROOF) */
1874- psa_pake_step_t MBEDTLS_PRIVATE (step );
1875- };
1876-
18771909#define PSA_JPAKE_EXPECTED_INPUTS (round ) ((round) == PSA_JPAKE_FINISHED ? 0 : \
18781910 ((round) == PSA_JPAKE_FIRST ? 2 : 1))
18791911#define PSA_JPAKE_EXPECTED_OUTPUTS (round ) ((round) == PSA_JPAKE_FINISHED ? 0 : \
18801912 ((round) == PSA_JPAKE_FIRST ? 2 : 1))
18811913
1882- struct psa_pake_operation_s {
1883- #if defined(MBEDTLS_PSA_CRYPTO_CLIENT ) && !defined(MBEDTLS_PSA_CRYPTO_C )
1884- mbedtls_psa_client_handle_t handle ;
1885- #else
1886- /** Unique ID indicating which driver got assigned to do the
1887- * operation. Since driver contexts are driver-specific, swapping
1888- * drivers halfway through the operation is not supported.
1889- * ID values are auto-generated in psa_crypto_driver_wrappers.h
1890- * ID value zero means the context is not valid or not assigned to
1891- * any driver (i.e. none of the driver contexts are active). */
1892- unsigned int MBEDTLS_PRIVATE (id );
1893- /* Algorithm of the PAKE operation */
1894- psa_algorithm_t MBEDTLS_PRIVATE (alg );
1895- /* A primitive of type compatible with algorithm */
1896- psa_pake_primitive_t MBEDTLS_PRIVATE (primitive );
1897- /* Stage of the PAKE operation: waiting for the setup, collecting inputs
1898- * or computing. */
1899- uint8_t MBEDTLS_PRIVATE (stage );
1900- /* Holds computation stage of the PAKE algorithms. */
1901- union {
1902- uint8_t MBEDTLS_PRIVATE (dummy );
1903- #if defined(PSA_WANT_ALG_JPAKE )
1904- psa_jpake_computation_stage_t MBEDTLS_PRIVATE (jpake );
1905- #endif
1906- } MBEDTLS_PRIVATE (computation_stage );
1907- union {
1908- psa_driver_pake_context_t MBEDTLS_PRIVATE (ctx );
1909- psa_crypto_driver_pake_inputs_t MBEDTLS_PRIVATE (inputs );
1910- } MBEDTLS_PRIVATE (data );
1911- #endif
1912- };
1913-
19141914static inline struct psa_pake_cipher_suite_s psa_pake_cipher_suite_init (void )
19151915{
19161916 const struct psa_pake_cipher_suite_s v = PSA_PAKE_CIPHER_SUITE_INIT ;
0 commit comments