Aditya Deshpande | 045b370 | 2023-02-20 17:08:30 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Driver entry points for p256-m |
| 3 | */ |
| 4 | /* |
| 5 | * Copyright The Mbed TLS Contributors |
| 6 | * SPDX-License-Identifier: Apache-2.0 |
| 7 | * |
| 8 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | * not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | * |
| 14 | * Unless required by applicable law or agreed to in writing, software |
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | * See the License for the specific language governing permissions and |
| 18 | * limitations under the License. |
| 19 | */ |
| 20 | |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 21 | #include "mbedtls/platform.h" |
| 22 | #include "p256-m_driver_entrypoints.h" |
| 23 | #include "p256-m/p256-m.h" |
| 24 | #include "psa/crypto.h" |
| 25 | #include "psa_crypto_driver_wrappers.h" |
Aditya Deshpande | 7b9934d | 2023-04-18 17:00:17 +0100 | [diff] [blame] | 26 | #include <stddef.h> |
Manuel Pégourié-Gonnard | 5424cf2 | 2023-08-07 10:56:12 +0200 | [diff] [blame] | 27 | #include <string.h> |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 28 | |
| 29 | #if defined(MBEDTLS_P256M_EXAMPLE_DRIVER_ENABLED) |
| 30 | |
Aditya Deshpande | 641cb89 | 2023-04-19 03:31:10 +0100 | [diff] [blame] | 31 | /* INFORMATION ON PSA KEY EXPORT FORMATS: |
| 32 | * |
| 33 | * PSA exports SECP256R1 keys in two formats: |
| 34 | * 1. Keypair format: 32 byte string which is just the private key (public key |
| 35 | * can be calculated from the private key) |
| 36 | * 2. Public Key format: A leading byte 0x04 (indicating uncompressed format), |
| 37 | * followed by the 64 byte public key. This results in a |
| 38 | * total of 65 bytes. |
| 39 | * |
| 40 | * p256-m's internal format for private keys matches PSA. Its format for public |
| 41 | * keys is only 64 bytes; the same as PSA but without the leading byte (0x04). |
| 42 | * Hence, when passing public keys from PSA to p256-m, the leading byte is |
| 43 | * removed. |
| 44 | */ |
| 45 | |
| 46 | /* Convert between p256-m and PSA error codes */ |
| 47 | static psa_status_t p256_to_psa_error(int ret) |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 48 | { |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 49 | switch (ret) { |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 50 | case P256_SUCCESS: |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 51 | return PSA_SUCCESS; |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 52 | case P256_INVALID_PUBKEY: |
| 53 | case P256_INVALID_PRIVKEY: |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 54 | return PSA_ERROR_INVALID_ARGUMENT; |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 55 | case P256_INVALID_SIGNATURE: |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 56 | return PSA_ERROR_INVALID_SIGNATURE; |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 57 | case P256_RANDOM_FAILED: |
| 58 | default: |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 59 | return PSA_ERROR_GENERIC_ERROR; |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 60 | } |
| 61 | } |
| 62 | |
Manuel Pégourié-Gonnard | 5424cf2 | 2023-08-07 10:56:12 +0200 | [diff] [blame] | 63 | psa_status_t p256_transparent_import_key(const psa_key_attributes_t *attributes, |
| 64 | const uint8_t *data, |
| 65 | size_t data_length, |
| 66 | uint8_t *key_buffer, |
| 67 | size_t key_buffer_size, |
| 68 | size_t *key_buffer_length, |
| 69 | size_t *bits) |
| 70 | { |
| 71 | /* Check the key size */ |
| 72 | if (*bits != 0 && *bits != 256) { |
| 73 | return PSA_ERROR_NOT_SUPPORTED; |
| 74 | } |
| 75 | |
| 76 | /* Validate the key (and its type and size) */ |
| 77 | psa_key_type_t type = psa_get_key_type(attributes); |
| 78 | if (type == PSA_KEY_TYPE_ECC_PUBLIC_KEY(PSA_ECC_FAMILY_SECP_R1)) { |
| 79 | if (data_length != 65) { |
| 80 | return *bits == 0 ? PSA_ERROR_NOT_SUPPORTED : PSA_ERROR_INVALID_ARGUMENT; |
| 81 | } |
| 82 | if (p256_validate_pubkey(data + 1) != P256_SUCCESS) { |
| 83 | return PSA_ERROR_INVALID_ARGUMENT; |
| 84 | } |
| 85 | } else if (type == PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1)) { |
| 86 | if (data_length != 32) { |
| 87 | return *bits == 0 ? PSA_ERROR_NOT_SUPPORTED : PSA_ERROR_INVALID_ARGUMENT; |
| 88 | } |
| 89 | if (p256_validate_privkey(data) != P256_SUCCESS) { |
| 90 | return PSA_ERROR_INVALID_ARGUMENT; |
| 91 | } |
| 92 | } else { |
| 93 | return PSA_ERROR_NOT_SUPPORTED; |
| 94 | } |
| 95 | *bits = 256; |
| 96 | |
| 97 | /* We only support the export format for input, so just copy. */ |
| 98 | if (key_buffer_size < data_length) { |
| 99 | return PSA_ERROR_BUFFER_TOO_SMALL; |
| 100 | } |
| 101 | memcpy(key_buffer, data, data_length); |
| 102 | *key_buffer_length = data_length; |
| 103 | |
| 104 | return PSA_SUCCESS; |
| 105 | } |
| 106 | |
Manuel Pégourié-Gonnard | 18d7142 | 2023-08-07 11:18:05 +0200 | [diff] [blame] | 107 | psa_status_t p256_transparent_export_public_key(const psa_key_attributes_t *attributes, |
| 108 | const uint8_t *key_buffer, |
| 109 | size_t key_buffer_size, |
| 110 | uint8_t *data, |
| 111 | size_t data_size, |
| 112 | size_t *data_length) |
| 113 | { |
| 114 | /* Is this the right curve? */ |
| 115 | size_t bits = psa_get_key_bits(attributes); |
| 116 | psa_key_type_t type = psa_get_key_type(attributes); |
| 117 | if (bits != 256 || type != PSA_KEY_TYPE_ECC_KEY_PAIR(PSA_ECC_FAMILY_SECP_R1)) { |
| 118 | return PSA_ERROR_NOT_SUPPORTED; |
| 119 | } |
| 120 | |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 121 | /* Validate sizes, as p256-m expects fixed-size buffers */ |
Manuel Pégourié-Gonnard | 18d7142 | 2023-08-07 11:18:05 +0200 | [diff] [blame] | 122 | if (key_buffer_size != 32) { |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 123 | return PSA_ERROR_CORRUPTION_DETECTED; |
Manuel Pégourié-Gonnard | 18d7142 | 2023-08-07 11:18:05 +0200 | [diff] [blame] | 124 | } |
| 125 | if (data_size < 65) { |
| 126 | return PSA_ERROR_BUFFER_TOO_SMALL; |
| 127 | } |
| 128 | |
| 129 | /* Output public key in the PSA export format */ |
| 130 | data[0] = 0x04; |
| 131 | int ret = p256_public_from_private(data + 1, key_buffer); |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 132 | if (ret == P256_SUCCESS) { |
| 133 | *data_length = 65; |
Manuel Pégourié-Gonnard | 18d7142 | 2023-08-07 11:18:05 +0200 | [diff] [blame] | 134 | } |
Manuel Pégourié-Gonnard | 18d7142 | 2023-08-07 11:18:05 +0200 | [diff] [blame] | 135 | |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 136 | return p256_to_psa_error(ret); |
Manuel Pégourié-Gonnard | 18d7142 | 2023-08-07 11:18:05 +0200 | [diff] [blame] | 137 | } |
| 138 | |
Aditya Deshpande | 695e44b | 2023-01-23 14:59:29 +0000 | [diff] [blame] | 139 | psa_status_t p256_transparent_generate_key( |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 140 | const psa_key_attributes_t *attributes, |
| 141 | uint8_t *key_buffer, |
| 142 | size_t key_buffer_size, |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 143 | size_t *key_buffer_length) |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 144 | { |
| 145 | /* We don't use this argument, but the specification mandates the signature |
| 146 | * of driver entry-points. (void) used to avoid compiler warning. */ |
| 147 | (void) attributes; |
| 148 | |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 149 | /* Validate sizes, as p256-m expects fixed-size buffers */ |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 150 | if (key_buffer_size != 32) { |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 151 | return PSA_ERROR_BUFFER_TOO_SMALL; |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 152 | } |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 153 | |
| 154 | /* |
| 155 | * p256-m's keypair generation function outputs both public and private |
| 156 | * keys. Allocate a buffer to which the public key will be written. The |
| 157 | * private key will be written to key_buffer, which is passed to this |
| 158 | * function as an argument. */ |
Aditya Deshpande | 7b9934d | 2023-04-18 17:00:17 +0100 | [diff] [blame] | 159 | uint8_t public_key_buffer[64]; |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 160 | |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 161 | int ret = p256_gen_keypair(key_buffer, public_key_buffer); |
| 162 | if (ret == P256_SUCCESS) { |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 163 | *key_buffer_length = 32; |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 164 | } |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 165 | |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 166 | return p256_to_psa_error(ret); |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 167 | } |
| 168 | |
Aditya Deshpande | 695e44b | 2023-01-23 14:59:29 +0000 | [diff] [blame] | 169 | psa_status_t p256_transparent_key_agreement( |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 170 | const psa_key_attributes_t *attributes, |
| 171 | const uint8_t *key_buffer, |
| 172 | size_t key_buffer_size, |
| 173 | psa_algorithm_t alg, |
| 174 | const uint8_t *peer_key, |
| 175 | size_t peer_key_length, |
| 176 | uint8_t *shared_secret, |
| 177 | size_t shared_secret_size, |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 178 | size_t *shared_secret_length) |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 179 | { |
| 180 | /* We don't use these arguments, but the specification mandates the |
| 181 | * sginature of driver entry-points. (void) used to avoid compiler |
| 182 | * warning. */ |
| 183 | (void) attributes; |
| 184 | (void) alg; |
| 185 | |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 186 | /* Validate sizes, as p256-m expects fixed-size buffers */ |
| 187 | if (key_buffer_size != 32 || peer_key_length != 65) { |
| 188 | return PSA_ERROR_INVALID_ARGUMENT; |
| 189 | } |
| 190 | if (shared_secret_size < 32) { |
| 191 | return PSA_ERROR_BUFFER_TOO_SMALL; |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 192 | } |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 193 | |
Aditya Deshpande | 641cb89 | 2023-04-19 03:31:10 +0100 | [diff] [blame] | 194 | /* We add 1 to peer_key pointer to omit the leading byte of the public key |
| 195 | * representation (0x04). See information about PSA key formats at the top |
| 196 | * of the file. */ |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 197 | int ret = p256_ecdh_shared_secret(shared_secret, key_buffer, peer_key + 1); |
| 198 | if (ret == P256_SUCCESS) { |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 199 | *shared_secret_length = 32; |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 200 | } |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 201 | |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 202 | return p256_to_psa_error(ret); |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 203 | } |
| 204 | |
Aditya Deshpande | 695e44b | 2023-01-23 14:59:29 +0000 | [diff] [blame] | 205 | psa_status_t p256_transparent_sign_hash( |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 206 | const psa_key_attributes_t *attributes, |
| 207 | const uint8_t *key_buffer, |
| 208 | size_t key_buffer_size, |
| 209 | psa_algorithm_t alg, |
| 210 | const uint8_t *hash, |
| 211 | size_t hash_length, |
| 212 | uint8_t *signature, |
| 213 | size_t signature_size, |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 214 | size_t *signature_length) |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 215 | { |
| 216 | /* We don't use these arguments, but the specification mandates the |
| 217 | * sginature of driver entry-points. (void) used to avoid compiler |
| 218 | * warning. */ |
| 219 | (void) attributes; |
| 220 | (void) alg; |
| 221 | |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 222 | /* Validate sizes, as p256-m expects fixed-size buffers */ |
| 223 | if (key_buffer_size != 32) { |
| 224 | return PSA_ERROR_CORRUPTION_DETECTED; |
| 225 | } |
| 226 | if (signature_size < 64) { |
| 227 | return PSA_ERROR_BUFFER_TOO_SMALL; |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 228 | } |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 229 | |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 230 | int ret = p256_ecdsa_sign(signature, key_buffer, hash, hash_length); |
| 231 | if (ret == P256_SUCCESS) { |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 232 | *signature_length = 64; |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 233 | } |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 234 | |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 235 | return p256_to_psa_error(ret); |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /* This function expects the key buffer to contain a 65 byte public key, |
| 239 | * as exported by psa_export_public_key() */ |
Aditya Deshpande | 695e44b | 2023-01-23 14:59:29 +0000 | [diff] [blame] | 240 | static psa_status_t p256_verify_hash_with_public_key( |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 241 | const uint8_t *key_buffer, |
| 242 | size_t key_buffer_size, |
| 243 | const uint8_t *hash, |
| 244 | size_t hash_length, |
| 245 | const uint8_t *signature, |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 246 | size_t signature_length) |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 247 | { |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 248 | /* Validate sizes, as p256-m expects fixed-size buffers */ |
| 249 | if (key_buffer_size != 65 || *key_buffer != 0x04) { |
| 250 | return PSA_ERROR_CORRUPTION_DETECTED; |
| 251 | } |
| 252 | if (signature_length != 64) { |
| 253 | return PSA_ERROR_INVALID_SIGNATURE; |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 254 | } |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 255 | |
Aditya Deshpande | 641cb89 | 2023-04-19 03:31:10 +0100 | [diff] [blame] | 256 | /* We add 1 to public_key_buffer pointer to omit the leading byte of the |
| 257 | * public key representation (0x04). See information about PSA key formats |
| 258 | * at the top of the file. */ |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 259 | const uint8_t *public_key_buffer = key_buffer + 1; |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 260 | int ret = p256_ecdsa_verify(signature, public_key_buffer, hash, hash_length); |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 261 | |
Manuel Pégourié-Gonnard | f0251e0 | 2023-08-08 12:23:42 +0200 | [diff] [blame^] | 262 | return p256_to_psa_error(ret); |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 263 | } |
| 264 | |
Aditya Deshpande | 695e44b | 2023-01-23 14:59:29 +0000 | [diff] [blame] | 265 | psa_status_t p256_transparent_verify_hash( |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 266 | const psa_key_attributes_t *attributes, |
| 267 | const uint8_t *key_buffer, |
| 268 | size_t key_buffer_size, |
| 269 | psa_algorithm_t alg, |
| 270 | const uint8_t *hash, |
| 271 | size_t hash_length, |
| 272 | const uint8_t *signature, |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 273 | size_t signature_length) |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 274 | { |
| 275 | /* We don't use this argument, but the specification mandates the signature |
| 276 | * of driver entry-points. (void) used to avoid compiler warning. */ |
| 277 | (void) alg; |
| 278 | |
| 279 | psa_status_t status; |
Aditya Deshpande | 7b9934d | 2023-04-18 17:00:17 +0100 | [diff] [blame] | 280 | uint8_t public_key_buffer[65]; |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 281 | size_t public_key_buffer_size = 65; |
Aditya Deshpande | 7b9934d | 2023-04-18 17:00:17 +0100 | [diff] [blame] | 282 | |
| 283 | size_t public_key_length = 65; |
| 284 | /* As p256-m doesn't require dynamic allocation, we want to avoid it in |
| 285 | * the entrypoint functions as well. psa_driver_wrapper_export_public_key() |
| 286 | * requires size_t*, so we use a pointer to a stack variable. */ |
| 287 | size_t *public_key_length_ptr = &public_key_length; |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 288 | |
Aditya Deshpande | 641cb89 | 2023-04-19 03:31:10 +0100 | [diff] [blame] | 289 | /* The contents of key_buffer may either be the 32 byte private key |
| 290 | * (keypair format), or 0x04 followed by the 64 byte public key (public |
| 291 | * key format). To ensure the key is in the latter format, the public key |
| 292 | * is exported. */ |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 293 | status = psa_driver_wrapper_export_public_key( |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 294 | attributes, |
| 295 | key_buffer, |
| 296 | key_buffer_size, |
| 297 | public_key_buffer, |
| 298 | public_key_buffer_size, |
Aditya Deshpande | 7b9934d | 2023-04-18 17:00:17 +0100 | [diff] [blame] | 299 | public_key_length_ptr); |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 300 | if (status != PSA_SUCCESS) { |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 301 | goto exit; |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 302 | } |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 303 | |
Aditya Deshpande | 695e44b | 2023-01-23 14:59:29 +0000 | [diff] [blame] | 304 | status = p256_verify_hash_with_public_key( |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 305 | public_key_buffer, |
| 306 | public_key_buffer_size, |
| 307 | hash, |
| 308 | hash_length, |
| 309 | signature, |
| 310 | signature_length); |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 311 | |
| 312 | exit: |
Aditya Deshpande | ac363d8 | 2023-03-21 18:56:31 +0000 | [diff] [blame] | 313 | return status; |
Aditya Deshpande | e41f7e4 | 2023-01-12 16:29:02 +0000 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | #endif /* MBEDTLS_P256M_EXAMPLE_DRIVER_ENABLED */ |