mbed TLS v3.1.0
crypto.h
Go to the documentation of this file.
1 
5 /*
6  * Copyright The Mbed TLS Contributors
7  * SPDX-License-Identifier: Apache-2.0
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License"); you may
10  * not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef PSA_CRYPTO_H
23 #define PSA_CRYPTO_H
24 
25 #include "crypto_platform.h"
26 
27 #include <stddef.h>
28 
29 #ifdef __DOXYGEN_ONLY__
30 /* This __DOXYGEN_ONLY__ block contains mock definitions for things that
31  * must be defined in the crypto_platform.h header. These mock definitions
32  * are present in this file as a convenience to generate pretty-printed
33  * documentation that includes those definitions. */
34 
40 #endif /* __DOXYGEN_ONLY__ */
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /* The file "crypto_types.h" declares types that encode errors,
47  * algorithms, key types, policies, etc. */
48 #include "crypto_types.h"
49 
57 #define PSA_CRYPTO_API_VERSION_MAJOR 1
58 
62 #define PSA_CRYPTO_API_VERSION_MINOR 0
63 
66 /* The file "crypto_values.h" declares macros to build and analyze values
67  * of integral types defined in "crypto_types.h". */
68 #include "crypto_values.h"
69 
103 
119 
140 static void psa_set_key_id( psa_key_attributes_t *attributes,
141  mbedtls_svc_key_id_t key );
142 
143 #ifdef MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
144 
158 static void mbedtls_set_key_owner_id( psa_key_attributes_t *attributes,
159  mbedtls_key_owner_id_t owner );
160 #endif
161 
187 static void psa_set_key_lifetime(psa_key_attributes_t *attributes,
188  psa_key_lifetime_t lifetime);
189 
203  const psa_key_attributes_t *attributes);
204 
216  const psa_key_attributes_t *attributes);
217 
234 static void psa_set_key_usage_flags(psa_key_attributes_t *attributes,
235  psa_key_usage_t usage_flags);
236 
248  const psa_key_attributes_t *attributes);
249 
280 static void psa_set_key_algorithm(psa_key_attributes_t *attributes,
281  psa_algorithm_t alg);
282 
283 
295  const psa_key_attributes_t *attributes);
296 
311 static void psa_set_key_type(psa_key_attributes_t *attributes,
312  psa_key_type_t type);
313 
314 
329 static void psa_set_key_bits(psa_key_attributes_t *attributes,
330  size_t bits);
331 
342 static psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes);
343 
354 static size_t psa_get_key_bits(const psa_key_attributes_t *attributes);
355 
385  psa_key_attributes_t *attributes);
386 
400 
429 
522  const psa_key_attributes_t *attributes,
523  mbedtls_svc_key_id_t *target_key);
524 
525 
572 
653  const uint8_t *data,
654  size_t data_length,
655  mbedtls_svc_key_id_t *key);
656 
657 
658 
748  uint8_t *data,
749  size_t data_size,
750  size_t *data_length);
751 
823  uint8_t *data,
824  size_t data_size,
825  size_t *data_length);
826 
827 
828 
868  const uint8_t *input,
869  size_t input_length,
870  uint8_t *hash,
871  size_t hash_size,
872  size_t *hash_length);
873 
904  const uint8_t *input,
905  size_t input_length,
906  const uint8_t *hash,
907  size_t hash_length);
908 
938 
948 
999  psa_algorithm_t alg);
1000 
1026  const uint8_t *input,
1027  size_t input_length);
1028 
1073  uint8_t *hash,
1074  size_t hash_size,
1075  size_t *hash_length);
1076 
1115  const uint8_t *hash,
1116  size_t hash_length);
1117 
1144 
1174 psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation,
1175  psa_hash_operation_t *target_operation);
1176 
1226  psa_algorithm_t alg,
1227  const uint8_t *input,
1228  size_t input_length,
1229  uint8_t *mac,
1230  size_t mac_size,
1231  size_t *mac_length);
1232 
1267  psa_algorithm_t alg,
1268  const uint8_t *input,
1269  size_t input_length,
1270  const uint8_t *mac,
1271  size_t mac_length);
1272 
1303 
1313 
1375  psa_algorithm_t alg);
1376 
1438  psa_algorithm_t alg);
1439 
1468  const uint8_t *input,
1469  size_t input_length);
1470 
1518  uint8_t *mac,
1519  size_t mac_size,
1520  size_t *mac_length);
1521 
1562  const uint8_t *mac,
1563  size_t mac_length);
1564 
1591 
1638  psa_algorithm_t alg,
1639  const uint8_t *input,
1640  size_t input_length,
1641  uint8_t *output,
1642  size_t output_size,
1643  size_t *output_length);
1644 
1685  psa_algorithm_t alg,
1686  const uint8_t *input,
1687  size_t input_length,
1688  uint8_t *output,
1689  size_t output_size,
1690  size_t *output_length);
1691 
1721 
1731 
1794  psa_algorithm_t alg);
1795 
1858  psa_algorithm_t alg);
1859 
1895  uint8_t *iv,
1896  size_t iv_size,
1897  size_t *iv_length);
1898 
1937  const uint8_t *iv,
1938  size_t iv_length);
1939 
1979  const uint8_t *input,
1980  size_t input_length,
1981  uint8_t *output,
1982  size_t output_size,
1983  size_t *output_length);
1984 
2032  uint8_t *output,
2033  size_t output_size,
2034  size_t *output_length);
2035 
2062 
2131  psa_algorithm_t alg,
2132  const uint8_t *nonce,
2133  size_t nonce_length,
2134  const uint8_t *additional_data,
2135  size_t additional_data_length,
2136  const uint8_t *plaintext,
2137  size_t plaintext_length,
2138  uint8_t *ciphertext,
2139  size_t ciphertext_size,
2140  size_t *ciphertext_length);
2141 
2204  psa_algorithm_t alg,
2205  const uint8_t *nonce,
2206  size_t nonce_length,
2207  const uint8_t *additional_data,
2208  size_t additional_data_length,
2209  const uint8_t *ciphertext,
2210  size_t ciphertext_length,
2211  uint8_t *plaintext,
2212  size_t plaintext_size,
2213  size_t *plaintext_length);
2214 
2244 
2254 
2323  psa_algorithm_t alg);
2324 
2390  psa_algorithm_t alg);
2391 
2429  uint8_t *nonce,
2430  size_t nonce_size,
2431  size_t *nonce_length);
2432 
2470  const uint8_t *nonce,
2471  size_t nonce_length);
2472 
2516  size_t ad_length,
2517  size_t plaintext_length);
2518 
2565  const uint8_t *input,
2566  size_t input_length);
2567 
2651  const uint8_t *input,
2652  size_t input_length,
2653  uint8_t *output,
2654  size_t output_size,
2655  size_t *output_length);
2656 
2739  uint8_t *ciphertext,
2740  size_t ciphertext_size,
2741  size_t *ciphertext_length,
2742  uint8_t *tag,
2743  size_t tag_size,
2744  size_t *tag_length);
2745 
2824  uint8_t *plaintext,
2825  size_t plaintext_size,
2826  size_t *plaintext_length,
2827  const uint8_t *tag,
2828  size_t tag_length);
2829 
2856 
2922  psa_algorithm_t alg,
2923  const uint8_t * input,
2924  size_t input_length,
2925  uint8_t * signature,
2926  size_t signature_size,
2927  size_t * signature_length );
2928 
2974  psa_algorithm_t alg,
2975  const uint8_t * input,
2976  size_t input_length,
2977  const uint8_t * signature,
2978  size_t signature_length );
2979 
3027  psa_algorithm_t alg,
3028  const uint8_t *hash,
3029  size_t hash_length,
3030  uint8_t *signature,
3031  size_t signature_size,
3032  size_t *signature_length);
3033 
3078  psa_algorithm_t alg,
3079  const uint8_t *hash,
3080  size_t hash_length,
3081  const uint8_t *signature,
3082  size_t signature_length);
3083 
3136  psa_algorithm_t alg,
3137  const uint8_t *input,
3138  size_t input_length,
3139  const uint8_t *salt,
3140  size_t salt_length,
3141  uint8_t *output,
3142  size_t output_size,
3143  size_t *output_length);
3144 
3197  psa_algorithm_t alg,
3198  const uint8_t *input,
3199  size_t input_length,
3200  const uint8_t *salt,
3201  size_t salt_length,
3202  uint8_t *output,
3203  size_t output_size,
3204  size_t *output_length);
3205 
3242 
3252 
3313  psa_key_derivation_operation_t *operation,
3314  psa_algorithm_t alg);
3315 
3337  const psa_key_derivation_operation_t *operation,
3338  size_t *capacity);
3339 
3366  psa_key_derivation_operation_t *operation,
3367  size_t capacity);
3368 
3376 #define PSA_KEY_DERIVATION_UNLIMITED_CAPACITY ((size_t)(-1))
3377 
3421  psa_key_derivation_operation_t *operation,
3423  const uint8_t *data,
3424  size_t data_length);
3425 
3466  psa_key_derivation_operation_t *operation,
3468  uint64_t value);
3469 
3535  psa_key_derivation_operation_t *operation,
3537  mbedtls_svc_key_id_t key);
3538 
3605  psa_key_derivation_operation_t *operation,
3607  mbedtls_svc_key_id_t private_key,
3608  const uint8_t *peer_key,
3609  size_t peer_key_length);
3610 
3653  psa_key_derivation_operation_t *operation,
3654  uint8_t *output,
3655  size_t output_length);
3656 
3804  const psa_key_attributes_t *attributes,
3805  psa_key_derivation_operation_t *operation,
3806  mbedtls_svc_key_id_t *key);
3807 
3863  psa_key_derivation_operation_t *operation,
3864  const uint8_t *expected_output,
3865  size_t output_length);
3866 
3928  psa_key_derivation_operation_t *operation,
3929  psa_key_id_t expected);
3930 
3955  psa_key_derivation_operation_t *operation);
3956 
4009  mbedtls_svc_key_id_t private_key,
4010  const uint8_t *peer_key,
4011  size_t peer_key_length,
4012  uint8_t *output,
4013  size_t output_size,
4014  size_t *output_length);
4015 
4046 psa_status_t psa_generate_random(uint8_t *output,
4047  size_t output_size);
4048 
4094  mbedtls_svc_key_id_t *key);
4095 
4098 #ifdef __cplusplus
4099 }
4100 #endif
4101 
4102 /* The file "crypto_sizes.h" contains definitions for size calculation
4103  * macros whose definitions are implementation-specific. */
4104 #include "crypto_sizes.h"
4105 
4106 /* The file "crypto_struct.h" contains definitions for
4107  * implementation-specific structs that are declared above. */
4108 #include "crypto_struct.h"
4109 
4110 /* The file "crypto_extra.h" contains vendor-specific definitions. This
4111  * can include vendor-defined algorithms, extra functions, etc. */
4112 #include "crypto_extra.h"
4113 
4114 #endif /* PSA_CRYPTO_H */
void psa_reset_key_attributes(psa_key_attributes_t *attributes)
psa_status_t psa_cipher_update(psa_cipher_operation_t *operation, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
psa_status_t psa_aead_encrypt_setup(psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
psa_status_t psa_cipher_encrypt_setup(psa_cipher_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
psa_status_t psa_generate_random(uint8_t *output, size_t output_size)
Generate random bytes.
psa_status_t psa_sign_message(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *signature, size_t signature_size, size_t *signature_length)
Sign a message with a private key. For hash-and-sign algorithms, this includes the hashing step...
psa_status_t psa_key_derivation_verify_bytes(psa_key_derivation_operation_t *operation, const uint8_t *expected_output, size_t output_length)
psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation, uint8_t *mac, size_t mac_size, size_t *mac_length)
psa_status_t psa_asymmetric_encrypt(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *salt, size_t salt_length, uint8_t *output, size_t output_size, size_t *output_length)
Encrypt a short message with a public key.
static psa_key_derivation_operation_t psa_key_derivation_operation_init(void)
psa_status_t psa_key_derivation_set_capacity(psa_key_derivation_operation_t *operation, size_t capacity)
psa_status_t psa_cipher_decrypt_setup(psa_cipher_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
psa_status_t psa_key_derivation_abort(psa_key_derivation_operation_t *operation)
psa_status_t psa_key_derivation_input_integer(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, uint64_t value)
psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation, const uint8_t *mac, size_t mac_length)
static void psa_set_key_bits(psa_key_attributes_t *attributes, size_t bits)
psa_status_t psa_key_derivation_verify_key(psa_key_derivation_operation_t *operation, psa_key_id_t expected)
psa_status_t psa_export_public_key(mbedtls_svc_key_id_t key, uint8_t *data, size_t data_size, size_t *data_length)
Export a public key or the public part of a key pair in binary format.
psa_status_t psa_cipher_encrypt(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
PSA cryptography module: type aliases.
psa_status_t psa_mac_abort(psa_mac_operation_t *operation)
uint16_t psa_key_derivation_step_t
Encoding of the step of a key derivation.
Definition: crypto_types.h:380
psa_status_t psa_export_key(mbedtls_svc_key_id_t key, uint8_t *data, size_t data_size, size_t *data_length)
Export a key in binary format.
PSA cryptography module: Mbed TLS structured type implementations.
PSA cryptography module: Mbed TLS vendor extensions.
uint32_t psa_key_id_t
Definition: crypto_types.h:225
psa_status_t psa_hash_compute(psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *hash, size_t hash_size, size_t *hash_length)
static psa_algorithm_t psa_get_key_algorithm(const psa_key_attributes_t *attributes)
static void psa_set_key_usage_flags(psa_key_attributes_t *attributes, psa_key_usage_t usage_flags)
int32_t mbedtls_key_owner_id_t
psa_status_t psa_hash_update(psa_hash_operation_t *operation, const uint8_t *input, size_t input_length)
static void psa_set_key_lifetime(psa_key_attributes_t *attributes, psa_key_lifetime_t lifetime)
static psa_hash_operation_t psa_hash_operation_init(void)
psa_status_t psa_raw_key_agreement(psa_algorithm_t alg, mbedtls_svc_key_id_t private_key, const uint8_t *peer_key, size_t peer_key_length, uint8_t *output, size_t output_size, size_t *output_length)
psa_status_t psa_aead_set_nonce(psa_aead_operation_t *operation, const uint8_t *nonce, size_t nonce_length)
static psa_key_lifetime_t psa_get_key_lifetime(const psa_key_attributes_t *attributes)
psa_status_t psa_key_derivation_get_capacity(const psa_key_derivation_operation_t *operation, size_t *capacity)
psa_status_t psa_mac_compute(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *mac, size_t mac_size, size_t *mac_length)
static void psa_set_key_type(psa_key_attributes_t *attributes, psa_key_type_t type)
psa_status_t psa_aead_finish(psa_aead_operation_t *operation, uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length, uint8_t *tag, size_t tag_size, size_t *tag_length)
static void psa_set_key_id(psa_key_attributes_t *attributes, mbedtls_svc_key_id_t key)
static size_t psa_get_key_bits(const psa_key_attributes_t *attributes)
psa_status_t psa_asymmetric_decrypt(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *salt, size_t salt_length, uint8_t *output, size_t output_size, size_t *output_length)
Decrypt a short message with a private key.
PSA cryptography module: macros to build and analyze integer values.
psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation, uint8_t *output, size_t output_size, size_t *output_length)
psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation, const uint8_t *input, size_t input_length)
psa_status_t psa_hash_verify(psa_hash_operation_t *operation, const uint8_t *hash, size_t hash_length)
psa_status_t psa_aead_set_lengths(psa_aead_operation_t *operation, size_t ad_length, size_t plaintext_length)
psa_status_t psa_mac_sign_setup(psa_mac_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
static void mbedtls_set_key_owner_id(psa_key_attributes_t *attributes, mbedtls_key_owner_id_t owner)
psa_status_t psa_verify_hash(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, const uint8_t *signature, size_t signature_length)
Verify the signature of a hash or short message using a public key.
psa_status_t psa_sign_hash(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *hash, size_t hash_length, uint8_t *signature, size_t signature_size, size_t *signature_length)
Sign a hash or short message with a private key.
psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation, psa_hash_operation_t *target_operation)
psa_status_t psa_generate_key(const psa_key_attributes_t *attributes, mbedtls_svc_key_id_t *key)
Generate a key or key pair.
psa_status_t psa_purge_key(mbedtls_svc_key_id_t key)
psa_status_t psa_copy_key(mbedtls_svc_key_id_t source_key, const psa_key_attributes_t *attributes, mbedtls_svc_key_id_t *target_key)
psa_status_t psa_get_key_attributes(mbedtls_svc_key_id_t key, psa_key_attributes_t *attributes)
psa_status_t psa_key_derivation_key_agreement(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, mbedtls_svc_key_id_t private_key, const uint8_t *peer_key, size_t peer_key_length)
uint32_t psa_algorithm_t
Encoding of a cryptographic algorithm.
Definition: crypto_types.h:106
psa_status_t psa_cipher_set_iv(psa_cipher_operation_t *operation, const uint8_t *iv, size_t iv_length)
psa_status_t psa_aead_generate_nonce(psa_aead_operation_t *operation, uint8_t *nonce, size_t nonce_size, size_t *nonce_length)
psa_status_t psa_cipher_decrypt(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
static psa_cipher_operation_t psa_cipher_operation_init(void)
psa_status_t psa_hash_setup(psa_hash_operation_t *operation, psa_algorithm_t alg)
PSA cryptography module: Mbed TLS platform definitions.
psa_status_t psa_cipher_generate_iv(psa_cipher_operation_t *operation, uint8_t *iv, size_t iv_size, size_t *iv_length)
uint32_t psa_key_usage_t
Encoding of permitted usage on a key.
Definition: crypto_types.h:251
static void psa_set_key_algorithm(psa_key_attributes_t *attributes, psa_algorithm_t alg)
uint16_t psa_key_type_t
Encoding of a key type.
Definition: crypto_types.h:74
psa_status_t psa_crypto_init(void)
Library initialization.
psa_status_t psa_key_derivation_output_bytes(psa_key_derivation_operation_t *operation, uint8_t *output, size_t output_length)
static psa_aead_operation_t psa_aead_operation_init(void)
psa_status_t psa_key_derivation_input_bytes(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, const uint8_t *data, size_t data_length)
PSA cryptography module: Mbed TLS buffer size macros.
static psa_key_type_t psa_get_key_type(const psa_key_attributes_t *attributes)
psa_status_t psa_aead_verify(psa_aead_operation_t *operation, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length, const uint8_t *tag, size_t tag_length)
static psa_key_usage_t psa_get_key_usage_flags(const psa_key_attributes_t *attributes)
psa_status_t psa_key_derivation_input_key(psa_key_derivation_operation_t *operation, psa_key_derivation_step_t step, mbedtls_svc_key_id_t key)
psa_status_t psa_import_key(const psa_key_attributes_t *attributes, const uint8_t *data, size_t data_length, mbedtls_svc_key_id_t *key)
Import a key in binary format.
psa_status_t psa_hash_abort(psa_hash_operation_t *operation)
static psa_key_attributes_t psa_key_attributes_init(void)
psa_status_t psa_aead_decrypt(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *nonce, size_t nonce_length, const uint8_t *additional_data, size_t additional_data_length, const uint8_t *ciphertext, size_t ciphertext_length, uint8_t *plaintext, size_t plaintext_size, size_t *plaintext_length)
psa_status_t psa_destroy_key(mbedtls_svc_key_id_t key)
Destroy a key.
psa_status_t psa_aead_decrypt_setup(psa_aead_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
psa_status_t psa_key_derivation_setup(psa_key_derivation_operation_t *operation, psa_algorithm_t alg)
static mbedtls_svc_key_id_t psa_get_key_id(const psa_key_attributes_t *attributes)
psa_status_t psa_verify_message(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *signature, size_t signature_length)
Verify the signature of a message with a public key, using a hash-and-sign verification algorithm...
psa_status_t psa_aead_abort(psa_aead_operation_t *operation)
psa_status_t psa_aead_update(psa_aead_operation_t *operation, const uint8_t *input, size_t input_length, uint8_t *output, size_t output_size, size_t *output_length)
psa_status_t psa_aead_encrypt(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *nonce, size_t nonce_length, const uint8_t *additional_data, size_t additional_data_length, const uint8_t *plaintext, size_t plaintext_length, uint8_t *ciphertext, size_t ciphertext_size, size_t *ciphertext_length)
uint32_t psa_key_lifetime_t
Definition: crypto_types.h:147
psa_status_t psa_mac_verify(mbedtls_svc_key_id_t key, psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *mac, size_t mac_length)
static psa_mac_operation_t psa_mac_operation_init(void)
psa_status_t psa_key_derivation_output_key(const psa_key_attributes_t *attributes, psa_key_derivation_operation_t *operation, mbedtls_svc_key_id_t *key)
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:63
psa_status_t psa_mac_update(psa_mac_operation_t *operation, const uint8_t *input, size_t input_length)
psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation)
psa_status_t psa_hash_compare(psa_algorithm_t alg, const uint8_t *input, size_t input_length, const uint8_t *hash, size_t hash_length)
psa_status_t psa_mac_verify_setup(psa_mac_operation_t *operation, mbedtls_svc_key_id_t key, psa_algorithm_t alg)
psa_status_t psa_hash_finish(psa_hash_operation_t *operation, uint8_t *hash, size_t hash_size, size_t *hash_length)