Bence Szépkúti | 700ee44 | 2020-05-26 00:33:31 +0200 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2018-2019, ARM Limited, All Rights Reserved |
| 3 | * |
| 4 | * This file is part of mbed TLS (https://tls.mbed.org) |
| 5 | */ |
| 6 | |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 7 | #include "psa/crypto.h" |
| 8 | #include <string.h> |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 9 | #include <stdio.h> |
Jaeden Amero | db29ab5 | 2019-02-12 16:40:27 +0000 | [diff] [blame] | 10 | #include <stdlib.h> |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 11 | |
| 12 | #define ASSERT( predicate ) \ |
| 13 | do \ |
| 14 | { \ |
| 15 | if( ! ( predicate ) ) \ |
| 16 | { \ |
Jaeden Amero | fa30c33 | 2018-12-21 18:42:18 +0000 | [diff] [blame] | 17 | printf( "\tassertion failed at %s:%d - '%s'\r\n", \ |
| 18 | __FILE__, __LINE__, #predicate); \ |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 19 | goto exit; \ |
| 20 | } \ |
| 21 | } while ( 0 ) |
| 22 | |
| 23 | #define ASSERT_STATUS( actual, expected ) \ |
| 24 | do \ |
| 25 | { \ |
| 26 | if( ( actual ) != ( expected ) ) \ |
| 27 | { \ |
Jaeden Amero | fa30c33 | 2018-12-21 18:42:18 +0000 | [diff] [blame] | 28 | printf( "\tassertion failed at %s:%d - " \ |
| 29 | "actual:%d expected:%d\r\n", __FILE__, __LINE__, \ |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 30 | (psa_status_t) actual, (psa_status_t) expected ); \ |
| 31 | goto exit; \ |
| 32 | } \ |
| 33 | } while ( 0 ) |
| 34 | |
itayzafrir | 18ac331 | 2018-07-17 09:28:11 +0300 | [diff] [blame] | 35 | #if !defined(MBEDTLS_PSA_CRYPTO_C) || !defined(MBEDTLS_AES_C) || \ |
| 36 | !defined(MBEDTLS_CIPHER_MODE_CBC) || !defined(MBEDTLS_CIPHER_MODE_CTR) || \ |
| 37 | !defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) |
| 38 | int main( void ) |
| 39 | { |
Jaeden Amero | fa30c33 | 2018-12-21 18:42:18 +0000 | [diff] [blame] | 40 | printf( "MBEDTLS_PSA_CRYPTO_C and/or MBEDTLS_AES_C and/or " |
| 41 | "MBEDTLS_CIPHER_MODE_CBC and/or MBEDTLS_CIPHER_MODE_CTR " |
| 42 | "and/or MBEDTLS_CIPHER_MODE_WITH_PADDING " |
| 43 | "not defined.\r\n" ); |
itayzafrir | 18ac331 | 2018-07-17 09:28:11 +0300 | [diff] [blame] | 44 | return( 0 ); |
| 45 | } |
| 46 | #else |
| 47 | |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 48 | static psa_status_t cipher_operation( psa_cipher_operation_t *operation, |
| 49 | const uint8_t * input, |
| 50 | size_t input_size, |
| 51 | size_t part_size, |
| 52 | uint8_t * output, |
| 53 | size_t output_size, |
| 54 | size_t *output_len ) |
| 55 | { |
| 56 | psa_status_t status; |
| 57 | size_t bytes_to_write = 0, bytes_written = 0, len = 0; |
| 58 | |
| 59 | *output_len = 0; |
| 60 | while( bytes_written != input_size ) |
| 61 | { |
| 62 | bytes_to_write = ( input_size - bytes_written > part_size ? |
| 63 | part_size : |
| 64 | input_size - bytes_written ); |
| 65 | |
| 66 | status = psa_cipher_update( operation, input + bytes_written, |
| 67 | bytes_to_write, output + *output_len, |
| 68 | output_size - *output_len, &len ); |
| 69 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 70 | |
| 71 | bytes_written += bytes_to_write; |
| 72 | *output_len += len; |
| 73 | } |
| 74 | |
| 75 | status = psa_cipher_finish( operation, output + *output_len, |
| 76 | output_size - *output_len, &len ); |
| 77 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 78 | *output_len += len; |
| 79 | |
| 80 | exit: |
| 81 | return( status ); |
| 82 | } |
| 83 | |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 84 | static psa_status_t cipher_encrypt( psa_key_handle_t key_handle, |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 85 | psa_algorithm_t alg, |
| 86 | uint8_t * iv, |
| 87 | size_t iv_size, |
| 88 | const uint8_t * input, |
| 89 | size_t input_size, |
| 90 | size_t part_size, |
| 91 | uint8_t * output, |
| 92 | size_t output_size, |
| 93 | size_t *output_len ) |
| 94 | { |
| 95 | psa_status_t status; |
Jaeden Amero | b281f74 | 2019-02-20 10:40:20 +0000 | [diff] [blame] | 96 | psa_cipher_operation_t operation = PSA_CIPHER_OPERATION_INIT; |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 97 | size_t iv_len = 0; |
| 98 | |
| 99 | memset( &operation, 0, sizeof( operation ) ); |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 100 | status = psa_cipher_encrypt_setup( &operation, key_handle, alg ); |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 101 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 102 | |
| 103 | status = psa_cipher_generate_iv( &operation, iv, iv_size, &iv_len ); |
| 104 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 105 | |
| 106 | status = cipher_operation( &operation, input, input_size, part_size, |
| 107 | output, output_size, output_len ); |
| 108 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 109 | |
| 110 | exit: |
| 111 | psa_cipher_abort( &operation ); |
| 112 | return( status ); |
| 113 | } |
| 114 | |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 115 | static psa_status_t cipher_decrypt( psa_key_handle_t key_handle, |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 116 | psa_algorithm_t alg, |
| 117 | const uint8_t * iv, |
| 118 | size_t iv_size, |
| 119 | const uint8_t * input, |
| 120 | size_t input_size, |
| 121 | size_t part_size, |
| 122 | uint8_t * output, |
| 123 | size_t output_size, |
| 124 | size_t *output_len ) |
| 125 | { |
| 126 | psa_status_t status; |
Jaeden Amero | b281f74 | 2019-02-20 10:40:20 +0000 | [diff] [blame] | 127 | psa_cipher_operation_t operation = PSA_CIPHER_OPERATION_INIT; |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 128 | |
| 129 | memset( &operation, 0, sizeof( operation ) ); |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 130 | status = psa_cipher_decrypt_setup( &operation, key_handle, alg ); |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 131 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 132 | |
| 133 | status = psa_cipher_set_iv( &operation, iv, iv_size ); |
| 134 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 135 | |
| 136 | status = cipher_operation( &operation, input, input_size, part_size, |
| 137 | output, output_size, output_len ); |
| 138 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 139 | |
| 140 | exit: |
| 141 | psa_cipher_abort( &operation ); |
| 142 | return( status ); |
| 143 | } |
| 144 | |
| 145 | static psa_status_t |
| 146 | cipher_example_encrypt_decrypt_aes_cbc_nopad_1_block( void ) |
| 147 | { |
| 148 | enum { |
| 149 | block_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( PSA_KEY_TYPE_AES ), |
| 150 | key_bits = 256, |
| 151 | part_size = block_size, |
| 152 | }; |
Gilles Peskine | daea26f | 2018-08-21 14:02:45 +0200 | [diff] [blame] | 153 | const psa_algorithm_t alg = PSA_ALG_CBC_NO_PADDING; |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 154 | |
| 155 | psa_status_t status; |
Gilles Peskine | dfea0a25 | 2019-04-18 13:39:40 +0200 | [diff] [blame] | 156 | psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 157 | psa_key_handle_t key_handle = 0; |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 158 | size_t output_len = 0; |
| 159 | uint8_t iv[block_size]; |
| 160 | uint8_t input[block_size]; |
| 161 | uint8_t encrypt[block_size]; |
| 162 | uint8_t decrypt[block_size]; |
| 163 | |
| 164 | status = psa_generate_random( input, sizeof( input ) ); |
| 165 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 166 | |
Gilles Peskine | dfea0a25 | 2019-04-18 13:39:40 +0200 | [diff] [blame] | 167 | psa_set_key_usage_flags( &attributes, |
| 168 | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT ); |
| 169 | psa_set_key_algorithm( &attributes, alg ); |
| 170 | psa_set_key_type( &attributes, PSA_KEY_TYPE_AES ); |
Gilles Peskine | 3a4f1f8 | 2019-04-26 13:49:28 +0200 | [diff] [blame] | 171 | psa_set_key_bits( &attributes, key_bits ); |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 172 | |
Gilles Peskine | 35ef36b | 2019-05-16 19:42:05 +0200 | [diff] [blame] | 173 | status = psa_generate_key( &attributes, &key_handle ); |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 174 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 175 | |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 176 | status = cipher_encrypt( key_handle, alg, iv, sizeof( iv ), |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 177 | input, sizeof( input ), part_size, |
| 178 | encrypt, sizeof( encrypt ), &output_len ); |
| 179 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 180 | |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 181 | status = cipher_decrypt( key_handle, alg, iv, sizeof( iv ), |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 182 | encrypt, output_len, part_size, |
| 183 | decrypt, sizeof( decrypt ), &output_len ); |
| 184 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 185 | |
| 186 | status = memcmp( input, decrypt, sizeof( input ) ); |
| 187 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 188 | |
| 189 | exit: |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 190 | psa_destroy_key( key_handle ); |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 191 | return( status ); |
| 192 | } |
| 193 | |
itayzafrir | a2d0804 | 2018-07-12 10:27:58 +0300 | [diff] [blame] | 194 | static psa_status_t cipher_example_encrypt_decrypt_aes_cbc_pkcs7_multi( void ) |
| 195 | { |
| 196 | enum { |
| 197 | block_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( PSA_KEY_TYPE_AES ), |
| 198 | key_bits = 256, |
| 199 | input_size = 100, |
| 200 | part_size = 10, |
| 201 | }; |
| 202 | |
Gilles Peskine | daea26f | 2018-08-21 14:02:45 +0200 | [diff] [blame] | 203 | const psa_algorithm_t alg = PSA_ALG_CBC_PKCS7; |
itayzafrir | a2d0804 | 2018-07-12 10:27:58 +0300 | [diff] [blame] | 204 | |
| 205 | psa_status_t status; |
Gilles Peskine | dfea0a25 | 2019-04-18 13:39:40 +0200 | [diff] [blame] | 206 | psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 207 | psa_key_handle_t key_handle = 0; |
itayzafrir | a2d0804 | 2018-07-12 10:27:58 +0300 | [diff] [blame] | 208 | size_t output_len = 0; |
| 209 | uint8_t iv[block_size], input[input_size], |
| 210 | encrypt[input_size + block_size], decrypt[input_size + block_size]; |
| 211 | |
| 212 | status = psa_generate_random( input, sizeof( input ) ); |
| 213 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 214 | |
Gilles Peskine | dfea0a25 | 2019-04-18 13:39:40 +0200 | [diff] [blame] | 215 | psa_set_key_usage_flags( &attributes, |
| 216 | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT ); |
| 217 | psa_set_key_algorithm( &attributes, alg ); |
| 218 | psa_set_key_type( &attributes, PSA_KEY_TYPE_AES ); |
Gilles Peskine | 3a4f1f8 | 2019-04-26 13:49:28 +0200 | [diff] [blame] | 219 | psa_set_key_bits( &attributes, key_bits ); |
itayzafrir | a2d0804 | 2018-07-12 10:27:58 +0300 | [diff] [blame] | 220 | |
Gilles Peskine | 35ef36b | 2019-05-16 19:42:05 +0200 | [diff] [blame] | 221 | status = psa_generate_key( &attributes, &key_handle ); |
itayzafrir | a2d0804 | 2018-07-12 10:27:58 +0300 | [diff] [blame] | 222 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 223 | |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 224 | status = cipher_encrypt( key_handle, alg, iv, sizeof( iv ), |
itayzafrir | a2d0804 | 2018-07-12 10:27:58 +0300 | [diff] [blame] | 225 | input, sizeof( input ), part_size, |
| 226 | encrypt, sizeof( encrypt ), &output_len ); |
| 227 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 228 | |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 229 | status = cipher_decrypt( key_handle, alg, iv, sizeof( iv ), |
itayzafrir | a2d0804 | 2018-07-12 10:27:58 +0300 | [diff] [blame] | 230 | encrypt, output_len, part_size, |
| 231 | decrypt, sizeof( decrypt ), &output_len ); |
| 232 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 233 | |
| 234 | status = memcmp( input, decrypt, sizeof( input ) ); |
| 235 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 236 | |
| 237 | exit: |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 238 | psa_destroy_key( key_handle ); |
itayzafrir | a2d0804 | 2018-07-12 10:27:58 +0300 | [diff] [blame] | 239 | return( status ); |
| 240 | } |
| 241 | |
itayzafrir | 44b09d2 | 2018-07-12 13:06:41 +0300 | [diff] [blame] | 242 | static psa_status_t cipher_example_encrypt_decrypt_aes_ctr_multi( void ) |
| 243 | { |
| 244 | enum { |
| 245 | block_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( PSA_KEY_TYPE_AES ), |
| 246 | key_bits = 256, |
| 247 | input_size = 100, |
| 248 | part_size = 10, |
| 249 | }; |
| 250 | const psa_algorithm_t alg = PSA_ALG_CTR; |
| 251 | |
| 252 | psa_status_t status; |
Gilles Peskine | dfea0a25 | 2019-04-18 13:39:40 +0200 | [diff] [blame] | 253 | psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT; |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 254 | psa_key_handle_t key_handle = 0; |
itayzafrir | 44b09d2 | 2018-07-12 13:06:41 +0300 | [diff] [blame] | 255 | size_t output_len = 0; |
| 256 | uint8_t iv[block_size], input[input_size], encrypt[input_size], |
| 257 | decrypt[input_size]; |
| 258 | |
| 259 | status = psa_generate_random( input, sizeof( input ) ); |
| 260 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 261 | |
Gilles Peskine | dfea0a25 | 2019-04-18 13:39:40 +0200 | [diff] [blame] | 262 | psa_set_key_usage_flags( &attributes, |
| 263 | PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT ); |
| 264 | psa_set_key_algorithm( &attributes, alg ); |
| 265 | psa_set_key_type( &attributes, PSA_KEY_TYPE_AES ); |
Gilles Peskine | 3a4f1f8 | 2019-04-26 13:49:28 +0200 | [diff] [blame] | 266 | psa_set_key_bits( &attributes, key_bits ); |
itayzafrir | 44b09d2 | 2018-07-12 13:06:41 +0300 | [diff] [blame] | 267 | |
Gilles Peskine | 35ef36b | 2019-05-16 19:42:05 +0200 | [diff] [blame] | 268 | status = psa_generate_key( &attributes, &key_handle ); |
itayzafrir | 44b09d2 | 2018-07-12 13:06:41 +0300 | [diff] [blame] | 269 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 270 | |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 271 | status = cipher_encrypt( key_handle, alg, iv, sizeof( iv ), |
itayzafrir | 44b09d2 | 2018-07-12 13:06:41 +0300 | [diff] [blame] | 272 | input, sizeof( input ), part_size, |
| 273 | encrypt, sizeof( encrypt ), &output_len ); |
| 274 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 275 | |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 276 | status = cipher_decrypt( key_handle, alg, iv, sizeof( iv ), |
itayzafrir | 44b09d2 | 2018-07-12 13:06:41 +0300 | [diff] [blame] | 277 | encrypt, output_len, part_size, |
| 278 | decrypt, sizeof( decrypt ), &output_len ); |
| 279 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 280 | |
| 281 | status = memcmp( input, decrypt, sizeof( input ) ); |
| 282 | ASSERT_STATUS( status, PSA_SUCCESS ); |
| 283 | |
| 284 | exit: |
Gilles Peskine | b0edfb5 | 2018-12-03 16:24:51 +0100 | [diff] [blame] | 285 | psa_destroy_key( key_handle ); |
itayzafrir | 44b09d2 | 2018-07-12 13:06:41 +0300 | [diff] [blame] | 286 | return( status ); |
| 287 | } |
| 288 | |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 289 | static void cipher_examples( void ) |
| 290 | { |
| 291 | psa_status_t status; |
| 292 | |
Jaeden Amero | fa30c33 | 2018-12-21 18:42:18 +0000 | [diff] [blame] | 293 | printf( "cipher encrypt/decrypt AES CBC no padding:\r\n" ); |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 294 | status = cipher_example_encrypt_decrypt_aes_cbc_nopad_1_block( ); |
| 295 | if( status == PSA_SUCCESS ) |
Jaeden Amero | fa30c33 | 2018-12-21 18:42:18 +0000 | [diff] [blame] | 296 | printf( "\tsuccess!\r\n" ); |
itayzafrir | a2d0804 | 2018-07-12 10:27:58 +0300 | [diff] [blame] | 297 | |
Jaeden Amero | fa30c33 | 2018-12-21 18:42:18 +0000 | [diff] [blame] | 298 | printf( "cipher encrypt/decrypt AES CBC PKCS7 multipart:\r\n" ); |
itayzafrir | a2d0804 | 2018-07-12 10:27:58 +0300 | [diff] [blame] | 299 | status = cipher_example_encrypt_decrypt_aes_cbc_pkcs7_multi( ); |
| 300 | if( status == PSA_SUCCESS ) |
Jaeden Amero | fa30c33 | 2018-12-21 18:42:18 +0000 | [diff] [blame] | 301 | printf( "\tsuccess!\r\n" ); |
itayzafrir | 44b09d2 | 2018-07-12 13:06:41 +0300 | [diff] [blame] | 302 | |
Jaeden Amero | fa30c33 | 2018-12-21 18:42:18 +0000 | [diff] [blame] | 303 | printf( "cipher encrypt/decrypt AES CTR multipart:\r\n" ); |
itayzafrir | 44b09d2 | 2018-07-12 13:06:41 +0300 | [diff] [blame] | 304 | status = cipher_example_encrypt_decrypt_aes_ctr_multi( ); |
| 305 | if( status == PSA_SUCCESS ) |
Jaeden Amero | fa30c33 | 2018-12-21 18:42:18 +0000 | [diff] [blame] | 306 | printf( "\tsuccess!\r\n" ); |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 307 | } |
| 308 | |
Jaeden Amero | 44a59ab | 2019-02-11 13:24:47 +0000 | [diff] [blame] | 309 | #if defined(MBEDTLS_CHECK_PARAMS) |
| 310 | #include "mbedtls/platform_util.h" |
| 311 | void mbedtls_param_failed( const char *failure_condition, |
| 312 | const char *file, |
| 313 | int line ) |
| 314 | { |
Jaeden Amero | fa30c33 | 2018-12-21 18:42:18 +0000 | [diff] [blame] | 315 | printf( "%s:%i: Input param failed - %s\n", |
Jaeden Amero | 44a59ab | 2019-02-11 13:24:47 +0000 | [diff] [blame] | 316 | file, line, failure_condition ); |
Jaeden Amero | fa30c33 | 2018-12-21 18:42:18 +0000 | [diff] [blame] | 317 | exit( EXIT_FAILURE ); |
Jaeden Amero | 44a59ab | 2019-02-11 13:24:47 +0000 | [diff] [blame] | 318 | } |
| 319 | #endif |
| 320 | |
itayzafrir | a3ff8a6 | 2018-07-10 10:10:21 +0300 | [diff] [blame] | 321 | int main( void ) |
| 322 | { |
itayzafrir | 1036670 | 2018-07-11 13:44:41 +0300 | [diff] [blame] | 323 | ASSERT( psa_crypto_init( ) == PSA_SUCCESS ); |
| 324 | cipher_examples( ); |
| 325 | exit: |
| 326 | mbedtls_psa_crypto_free( ); |
itayzafrir | a3ff8a6 | 2018-07-10 10:10:21 +0300 | [diff] [blame] | 327 | return( 0 ); |
| 328 | } |
itayzafrir | 18ac331 | 2018-07-17 09:28:11 +0300 | [diff] [blame] | 329 | #endif /* MBEDTLS_PSA_CRYPTO_C && MBEDTLS_AES_C && MBEDTLS_CIPHER_MODE_CBC && |
| 330 | MBEDTLS_CIPHER_MODE_CTR && MBEDTLS_CIPHER_MODE_WITH_PADDING */ |