@@ -121,14 +121,16 @@ typedef struct mbedtls_aes_xts_context
121
121
* It must be the first API called before using
122
122
* the context.
123
123
*
124
- * \param ctx The AES context to initialize.
124
+ * \param ctx The AES context to initialize. This must not be \c NULL.
125
125
*/
126
126
void mbedtls_aes_init ( mbedtls_aes_context * ctx );
127
127
128
128
/**
129
129
* \brief This function releases and clears the specified AES context.
130
130
*
131
131
* \param ctx The AES context to clear.
132
+ * If this is \c NULL, this function does nothing.
133
+ * Otherwise, the context must have been at least initialized.
132
134
*/
133
135
void mbedtls_aes_free ( mbedtls_aes_context * ctx );
134
136
@@ -139,14 +141,16 @@ void mbedtls_aes_free( mbedtls_aes_context *ctx );
139
141
* It must be the first API called before using
140
142
* the context.
141
143
*
142
- * \param ctx The AES XTS context to initialize.
144
+ * \param ctx The AES XTS context to initialize. This must not be \c NULL.
143
145
*/
144
146
void mbedtls_aes_xts_init ( mbedtls_aes_xts_context * ctx );
145
147
146
148
/**
147
149
* \brief This function releases and clears the specified AES XTS context.
148
150
*
149
151
* \param ctx The AES XTS context to clear.
152
+ * If this is \c NULL, this function does nothing.
153
+ * Otherwise, the context must have been at least initialized.
150
154
*/
151
155
void mbedtls_aes_xts_free ( mbedtls_aes_xts_context * ctx );
152
156
#endif /* MBEDTLS_CIPHER_MODE_XTS */
@@ -155,7 +159,9 @@ void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx );
155
159
* \brief This function sets the encryption key.
156
160
*
157
161
* \param ctx The AES context to which the key should be bound.
162
+ * It must be initialized.
158
163
* \param key The encryption key.
164
+ * This must be a readable buffer of size \p keybits bits.
159
165
* \param keybits The size of data passed in bits. Valid options are:
160
166
* <ul><li>128 bits</li>
161
167
* <li>192 bits</li>
@@ -171,7 +177,9 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
171
177
* \brief This function sets the decryption key.
172
178
*
173
179
* \param ctx The AES context to which the key should be bound.
180
+ * It must be initialized.
174
181
* \param key The decryption key.
182
+ * This must be a readable buffer of size \p keybits bits.
175
183
* \param keybits The size of data passed. Valid options are:
176
184
* <ul><li>128 bits</li>
177
185
* <li>192 bits</li>
@@ -189,8 +197,10 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
189
197
* sets the encryption key.
190
198
*
191
199
* \param ctx The AES XTS context to which the key should be bound.
200
+ * It must be initialized.
192
201
* \param key The encryption key. This is comprised of the XTS key1
193
202
* concatenated with the XTS key2.
203
+ * This must be a readable buffer of size \p keybits bits.
194
204
* \param keybits The size of \p key passed in bits. Valid options are:
195
205
* <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
196
206
* <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
@@ -207,8 +217,10 @@ int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx,
207
217
* sets the decryption key.
208
218
*
209
219
* \param ctx The AES XTS context to which the key should be bound.
220
+ * It must be initialized.
210
221
* \param key The decryption key. This is comprised of the XTS key1
211
222
* concatenated with the XTS key2.
223
+ * This must be a readable buffer of size \p keybits bits.
212
224
* \param keybits The size of \p key passed in bits. Valid options are:
213
225
* <ul><li>256 bits (each of key1 and key2 is a 128-bit key)</li>
214
226
* <li>512 bits (each of key1 and key2 is a 256-bit key)</li></ul>
@@ -234,10 +246,13 @@ int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx,
234
246
* call to this API with the same context.
235
247
*
236
248
* \param ctx The AES context to use for encryption or decryption.
249
+ * It must be initialized and bound to a key.
237
250
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
238
251
* #MBEDTLS_AES_DECRYPT.
239
- * \param input The 16-Byte buffer holding the input data.
240
- * \param output The 16-Byte buffer holding the output data.
252
+ * \param input The buffer holding the input data.
253
+ * It must be readable and at least \c 16 Bytes long.
254
+ * \param output The buffer where the output data will be written.
255
+ * It must be writeable and at least \c 16 Bytes long.
241
256
242
257
* \return \c 0 on success.
243
258
*/
@@ -260,8 +275,8 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
260
275
* mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called
261
276
* before the first call to this API with the same context.
262
277
*
263
- * \note This function operates on aligned blocks, that is, the input size
264
- * must be a multiple of the AES block size of 16 Bytes.
278
+ * \note This function operates on full blocks, that is, the input size
279
+ * must be a multiple of the AES block size of \c 16 Bytes.
265
280
*
266
281
* \note Upon exit, the content of the IV is updated so that you can
267
282
* call the same function again on the next
@@ -272,13 +287,17 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
272
287
*
273
288
*
274
289
* \param ctx The AES context to use for encryption or decryption.
290
+ * It must be initialized and bound to a key.
275
291
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
276
292
* #MBEDTLS_AES_DECRYPT.
277
293
* \param length The length of the input data in Bytes. This must be a
278
- * multiple of the block size (16 Bytes).
294
+ * multiple of the block size (\c 16 Bytes).
279
295
* \param iv Initialization vector (updated after use).
296
+ * It must be a readable and writeable buffer of \c 16 Bytes.
280
297
* \param input The buffer holding the input data.
298
+ * It must be readable and of size \p length Bytes.
281
299
* \param output The buffer holding the output data.
300
+ * It must be writeable and of size \p length Bytes.
282
301
*
283
302
* \return \c 0 on success.
284
303
* \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
@@ -306,25 +325,26 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
306
325
* returns #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH.
307
326
*
308
327
* \param ctx The AES XTS context to use for AES XTS operations.
328
+ * It must be initialized and bound to a key.
309
329
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
310
330
* #MBEDTLS_AES_DECRYPT.
311
- * \param length The length of a data unit in bytes . This can be any
331
+ * \param length The length of a data unit in Bytes . This can be any
312
332
* length between 16 bytes and 2^24 bytes inclusive
313
333
* (between 1 and 2^20 block cipher blocks).
314
334
* \param data_unit The address of the data unit encoded as an array of 16
315
335
* bytes in little-endian format. For disk encryption, this
316
336
* is typically the index of the block device sector that
317
337
* contains the data.
318
338
* \param input The buffer holding the input data (which is an entire
319
- * data unit). This function reads \p length bytes from \p
339
+ * data unit). This function reads \p length Bytes from \p
320
340
* input.
321
341
* \param output The buffer holding the output data (which is an entire
322
- * data unit). This function writes \p length bytes to \p
342
+ * data unit). This function writes \p length Bytes to \p
323
343
* output.
324
344
*
325
345
* \return \c 0 on success.
326
346
* \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH if \p length is
327
- * smaller than an AES block in size (16 bytes ) or if \p
347
+ * smaller than an AES block in size (16 Bytes ) or if \p
328
348
* length is larger than 2^20 blocks (16 MiB).
329
349
*/
330
350
int mbedtls_aes_crypt_xts ( mbedtls_aes_xts_context * ctx ,
@@ -360,13 +380,18 @@ int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx,
360
380
*
361
381
*
362
382
* \param ctx The AES context to use for encryption or decryption.
383
+ * It must be initialized and bound to a key.
363
384
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
364
385
* #MBEDTLS_AES_DECRYPT.
365
- * \param length The length of the input data.
386
+ * \param length The length of the input data in Bytes .
366
387
* \param iv_off The offset in IV (updated after use).
388
+ * It must point to a valid \c size_t.
367
389
* \param iv The initialization vector (updated after use).
390
+ * It must be a readable and writeable buffer of \c 16 Bytes.
368
391
* \param input The buffer holding the input data.
392
+ * It must be readable and of size \p length Bytes.
369
393
* \param output The buffer holding the output data.
394
+ * It must be writeable and of size \p length Bytes.
370
395
*
371
396
* \return \c 0 on success.
372
397
*/
@@ -401,12 +426,16 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
401
426
*
402
427
*
403
428
* \param ctx The AES context to use for encryption or decryption.
429
+ * It must be initialized and bound to a key.
404
430
* \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or
405
431
* #MBEDTLS_AES_DECRYPT
406
432
* \param length The length of the input data.
407
433
* \param iv The initialization vector (updated after use).
434
+ * It must be a readable and writeable buffer of \c 16 Bytes.
408
435
* \param input The buffer holding the input data.
436
+ * It must be readable and of size \p length Bytes.
409
437
* \param output The buffer holding the output data.
438
+ * It must be writeable and of size \p length Bytes.
410
439
*
411
440
* \return \c 0 on success.
412
441
*/
@@ -451,11 +480,16 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
451
480
* will compromise security.
452
481
*
453
482
* \param ctx The AES context to use for encryption or decryption.
483
+ * It must be initialized and bound to a key.
454
484
* \param length The length of the input data.
455
485
* \param iv_off The offset in IV (updated after use).
486
+ * It must point to a valid \c size_t.
456
487
* \param iv The initialization vector (updated after use).
488
+ * It must be a readable and writeable buffer of \c 16 Bytes.
457
489
* \param input The buffer holding the input data.
490
+ * It must be readable and of size \p length Bytes.
458
491
* \param output The buffer holding the output data.
492
+ * It must be writeable and of size \p length Bytes.
459
493
*
460
494
* \return \c 0 on success.
461
495
*/
@@ -527,15 +561,21 @@ int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx,
527
561
* securely discarded as soon as it's no longer needed.
528
562
*
529
563
* \param ctx The AES context to use for encryption or decryption.
564
+ * It must be initialized and bound to a key.
530
565
* \param length The length of the input data.
531
566
* \param nc_off The offset in the current \p stream_block, for
532
567
* resuming within the current cipher stream. The
533
568
* offset pointer should be 0 at the start of a stream.
569
+ * It must point to a valid \c size_t.
534
570
* \param nonce_counter The 128-bit nonce and counter.
571
+ * It must be a readable-writeable buffer of \c 16 Bytes.
535
572
* \param stream_block The saved stream block for resuming. This is
536
573
* overwritten by the function.
574
+ * It must be a readable-writeable buffer of \c 16 Bytes.
537
575
* \param input The buffer holding the input data.
576
+ * It must be readable and of size \p length Bytes.
538
577
* \param output The buffer holding the output data.
578
+ * It must be writeable and of size \p length Bytes.
539
579
*
540
580
* \return \c 0 on success.
541
581
*/
@@ -588,7 +628,7 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx,
588
628
* \brief Deprecated internal AES block encryption function
589
629
* without return value.
590
630
*
591
- * \deprecated Superseded by mbedtls_aes_encrypt_ext() in 2.5.0.
631
+ * \deprecated Superseded by mbedtls_internal_aes_encrypt()
592
632
*
593
633
* \param ctx The AES context to use for encryption.
594
634
* \param input Plaintext block.
@@ -602,7 +642,7 @@ MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
602
642
* \brief Deprecated internal AES block decryption function
603
643
* without return value.
604
644
*
605
- * \deprecated Superseded by mbedtls_aes_decrypt_ext() in 2.5.0.
645
+ * \deprecated Superseded by mbedtls_internal_aes_decrypt()
606
646
*
607
647
* \param ctx The AES context to use for decryption.
608
648
* \param input Ciphertext block.
@@ -615,6 +655,8 @@ MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
615
655
#undef MBEDTLS_DEPRECATED
616
656
#endif /* !MBEDTLS_DEPRECATED_REMOVED */
617
657
658
+
659
+ #if defined(MBEDTLS_SELF_TEST )
618
660
/**
619
661
* \brief Checkup routine.
620
662
*
@@ -623,6 +665,8 @@ MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
623
665
*/
624
666
int mbedtls_aes_self_test ( int verbose );
625
667
668
+ #endif /* MBEDTLS_SELF_TEST */
669
+
626
670
#ifdef __cplusplus
627
671
}
628
672
#endif
0 commit comments