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