@@ -405,7 +405,8 @@ void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx );
405
405
* In future versions, the caller will be required to call
406
406
* mbedtls_cipher_init() on the structure first.
407
407
*/
408
- int mbedtls_cipher_setup ( mbedtls_cipher_context_t * ctx , const mbedtls_cipher_info_t * cipher_info );
408
+ int mbedtls_cipher_setup ( mbedtls_cipher_context_t * ctx ,
409
+ const mbedtls_cipher_info_t * cipher_info );
409
410
410
411
/**
411
412
* \brief This function returns the block size of the given cipher.
@@ -415,7 +416,8 @@ int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_in
415
416
* \return The size of the blocks of the cipher.
416
417
* \return 0 if \p ctx has not been initialized.
417
418
*/
418
- static inline unsigned int mbedtls_cipher_get_block_size ( const mbedtls_cipher_context_t * ctx )
419
+ static inline unsigned int mbedtls_cipher_get_block_size (
420
+ const mbedtls_cipher_context_t * ctx )
419
421
{
420
422
if ( NULL == ctx || NULL == ctx -> cipher_info )
421
423
return 0 ;
@@ -432,7 +434,8 @@ static inline unsigned int mbedtls_cipher_get_block_size( const mbedtls_cipher_c
432
434
* \return The mode of operation.
433
435
* \return #MBEDTLS_MODE_NONE if \p ctx has not been initialized.
434
436
*/
435
- static inline mbedtls_cipher_mode_t mbedtls_cipher_get_cipher_mode ( const mbedtls_cipher_context_t * ctx )
437
+ static inline mbedtls_cipher_mode_t mbedtls_cipher_get_cipher_mode (
438
+ const mbedtls_cipher_context_t * ctx )
436
439
{
437
440
if ( NULL == ctx || NULL == ctx -> cipher_info )
438
441
return MBEDTLS_MODE_NONE ;
@@ -450,7 +453,8 @@ static inline mbedtls_cipher_mode_t mbedtls_cipher_get_cipher_mode( const mbedtl
450
453
* \return \c 0 for ciphers not using an IV or a nonce.
451
454
* \return The actual size if an IV has been set.
452
455
*/
453
- static inline int mbedtls_cipher_get_iv_size ( const mbedtls_cipher_context_t * ctx )
456
+ static inline int mbedtls_cipher_get_iv_size (
457
+ const mbedtls_cipher_context_t * ctx )
454
458
{
455
459
if ( NULL == ctx || NULL == ctx -> cipher_info )
456
460
return 0 ;
@@ -469,7 +473,8 @@ static inline int mbedtls_cipher_get_iv_size( const mbedtls_cipher_context_t *ct
469
473
* \return The type of the cipher.
470
474
* \return #MBEDTLS_CIPHER_NONE if \p ctx has not been initialized.
471
475
*/
472
- static inline mbedtls_cipher_type_t mbedtls_cipher_get_type ( const mbedtls_cipher_context_t * ctx )
476
+ static inline mbedtls_cipher_type_t mbedtls_cipher_get_type (
477
+ const mbedtls_cipher_context_t * ctx )
473
478
{
474
479
if ( NULL == ctx || NULL == ctx -> cipher_info )
475
480
return MBEDTLS_CIPHER_NONE ;
@@ -486,7 +491,8 @@ static inline mbedtls_cipher_type_t mbedtls_cipher_get_type( const mbedtls_ciphe
486
491
* \return The name of the cipher.
487
492
* \return NULL if \p ctx has not been not initialized.
488
493
*/
489
- static inline const char * mbedtls_cipher_get_name ( const mbedtls_cipher_context_t * ctx )
494
+ static inline const char * mbedtls_cipher_get_name (
495
+ const mbedtls_cipher_context_t * ctx )
490
496
{
491
497
if ( NULL == ctx || NULL == ctx -> cipher_info )
492
498
return 0 ;
@@ -503,7 +509,8 @@ static inline const char *mbedtls_cipher_get_name( const mbedtls_cipher_context_
503
509
* \return #MBEDTLS_KEY_LENGTH_NONE if ctx \p has not been
504
510
* initialized.
505
511
*/
506
- static inline int mbedtls_cipher_get_key_bitlen ( const mbedtls_cipher_context_t * ctx )
512
+ static inline int mbedtls_cipher_get_key_bitlen (
513
+ const mbedtls_cipher_context_t * ctx )
507
514
{
508
515
if ( NULL == ctx || NULL == ctx -> cipher_info )
509
516
return MBEDTLS_KEY_LENGTH_NONE ;
@@ -519,7 +526,8 @@ static inline int mbedtls_cipher_get_key_bitlen( const mbedtls_cipher_context_t
519
526
* \return The type of operation: #MBEDTLS_ENCRYPT or #MBEDTLS_DECRYPT.
520
527
* \return #MBEDTLS_OPERATION_NONE if \p ctx has not been initialized.
521
528
*/
522
- static inline mbedtls_operation_t mbedtls_cipher_get_operation ( const mbedtls_cipher_context_t * ctx )
529
+ static inline mbedtls_operation_t mbedtls_cipher_get_operation (
530
+ const mbedtls_cipher_context_t * ctx )
523
531
{
524
532
if ( NULL == ctx || NULL == ctx -> cipher_info )
525
533
return MBEDTLS_OPERATION_NONE ;
@@ -543,8 +551,10 @@ static inline mbedtls_operation_t mbedtls_cipher_get_operation( const mbedtls_ci
543
551
* parameter-verification failure.
544
552
* \return A cipher-specific error code on failure.
545
553
*/
546
- int mbedtls_cipher_setkey ( mbedtls_cipher_context_t * ctx , const unsigned char * key ,
547
- int key_bitlen , const mbedtls_operation_t operation );
554
+ int mbedtls_cipher_setkey ( mbedtls_cipher_context_t * ctx ,
555
+ const unsigned char * key ,
556
+ int key_bitlen ,
557
+ const mbedtls_operation_t operation );
548
558
549
559
#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING )
550
560
/**
@@ -562,7 +572,8 @@ int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *k
562
572
* \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if the cipher mode
563
573
* does not support padding.
564
574
*/
565
- int mbedtls_cipher_set_padding_mode ( mbedtls_cipher_context_t * ctx , mbedtls_cipher_padding_t mode );
575
+ int mbedtls_cipher_set_padding_mode ( mbedtls_cipher_context_t * ctx ,
576
+ mbedtls_cipher_padding_t mode );
566
577
#endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */
567
578
568
579
/**
@@ -582,7 +593,7 @@ int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_ciph
582
593
* parameter-verification failure.
583
594
*/
584
595
int mbedtls_cipher_set_iv ( mbedtls_cipher_context_t * ctx ,
585
- const unsigned char * iv , size_t iv_len );
596
+ const unsigned char * iv , size_t iv_len );
586
597
587
598
/**
588
599
* \brief This function resets the cipher state.
@@ -597,16 +608,16 @@ int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx );
597
608
598
609
#if defined(MBEDTLS_GCM_C ) || defined(MBEDTLS_CHACHAPOLY_C )
599
610
/**
600
- * \brief This function adds additional data for AEAD ciphers.
601
- * Currently supported with GCM and ChaCha20+Poly1305.
602
- * Must be called exactly once, after mbedtls_cipher_reset().
611
+ * \brief This function adds additional data for AEAD ciphers.
612
+ * Currently supported with GCM and ChaCha20+Poly1305.
613
+ * Must be called exactly once, after mbedtls_cipher_reset().
603
614
*
604
- * \param ctx The generic cipher context.
605
- * \param ad The additional data to use.
606
- * \param ad_len the Length of \p ad.
615
+ * \param ctx The generic cipher context.
616
+ * \param ad The additional data to use.
617
+ * \param ad_len the Length of \p ad.
607
618
*
608
- * \return \c 0 on success.
609
- * \return A specific error code on failure.
619
+ * \return \c 0 on success.
620
+ * \return A specific error code on failure.
610
621
*/
611
622
int mbedtls_cipher_update_ad ( mbedtls_cipher_context_t * ctx ,
612
623
const unsigned char * ad , size_t ad_len );
@@ -643,8 +654,10 @@ int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx,
643
654
* unsupported mode for a cipher.
644
655
* \return A cipher-specific error code on failure.
645
656
*/
646
- int mbedtls_cipher_update ( mbedtls_cipher_context_t * ctx , const unsigned char * input ,
647
- size_t ilen , unsigned char * output , size_t * olen );
657
+ int mbedtls_cipher_update ( mbedtls_cipher_context_t * ctx ,
658
+ const unsigned char * input ,
659
+ size_t ilen , unsigned char * output ,
660
+ size_t * olen );
648
661
649
662
/**
650
663
* \brief The generic cipher finalization function. If data still
@@ -736,27 +749,27 @@ int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx,
736
749
737
750
#if defined(MBEDTLS_CIPHER_MODE_AEAD )
738
751
/**
739
- * \brief The generic autenticated encryption (AEAD) function.
740
- *
741
- * \param ctx The generic cipher context.
742
- * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers.
743
- * \param iv_len The IV length for ciphers with variable-size IV.
744
- * This parameter is discarded by ciphers with fixed-size IV.
745
- * \param ad The additional data to authenticate.
746
- * \param ad_len The length of \p ad.
747
- * \param input The buffer holding the input data.
748
- * \param ilen The length of the input data.
749
- * \param output The buffer for the output data.
750
- * Must be able to hold at least \p ilen.
751
- * \param olen The length of the output data, to be updated with the
752
- * actual number of Bytes written.
753
- * \param tag The buffer for the authentication tag.
754
- * \param tag_len The desired length of the authentication tag.
755
- *
756
- * \return \c 0 on success.
757
- * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on
758
- * parameter-verification failure.
759
- * \return A cipher-specific error code on failure.
752
+ * \brief The generic autenticated encryption (AEAD) function.
753
+ *
754
+ * \param ctx The generic cipher context.
755
+ * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers.
756
+ * \param iv_len The IV length for ciphers with variable-size IV.
757
+ * This parameter is discarded by ciphers with fixed-size IV.
758
+ * \param ad The additional data to authenticate.
759
+ * \param ad_len The length of \p ad.
760
+ * \param input The buffer holding the input data.
761
+ * \param ilen The length of the input data.
762
+ * \param output The buffer for the output data.
763
+ * Must be able to hold at least \p ilen.
764
+ * \param olen The length of the output data, to be updated with the
765
+ * actual number of Bytes written.
766
+ * \param tag The buffer for the authentication tag.
767
+ * \param tag_len The desired length of the authentication tag.
768
+ *
769
+ * \return \c 0 on success.
770
+ * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on
771
+ * parameter-verification failure.
772
+ * \return A cipher-specific error code on failure.
760
773
*/
761
774
int mbedtls_cipher_auth_encrypt ( mbedtls_cipher_context_t * ctx ,
762
775
const unsigned char * iv , size_t iv_len ,
@@ -766,32 +779,32 @@ int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx,
766
779
unsigned char * tag , size_t tag_len );
767
780
768
781
/**
769
- * \brief The generic autenticated decryption (AEAD) function.
770
- *
771
- * \note If the data is not authentic, then the output buffer
772
- * is zeroed out to prevent the unauthentic plaintext being
773
- * used, making this interface safer.
774
- *
775
- * \param ctx The generic cipher context.
776
- * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers.
777
- * \param iv_len The IV length for ciphers with variable-size IV.
778
- * This parameter is discarded by ciphers with fixed-size IV.
779
- * \param ad The additional data to be authenticated.
780
- * \param ad_len The length of \p ad.
781
- * \param input The buffer holding the input data.
782
- * \param ilen The length of the input data.
783
- * \param output The buffer for the output data.
784
- * Must be able to hold at least \p ilen.
785
- * \param olen The length of the output data, to be updated with the
786
- * actual number of Bytes written.
787
- * \param tag The buffer holding the authentication tag.
788
- * \param tag_len The length of the authentication tag.
789
- *
790
- * \return \c 0 on success.
791
- * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on
792
- * parameter-verification failure.
793
- * \return #MBEDTLS_ERR_CIPHER_AUTH_FAILED if data is not authentic.
794
- * \return A cipher-specific error code on failure.
782
+ * \brief The generic autenticated decryption (AEAD) function.
783
+ *
784
+ * \note If the data is not authentic, then the output buffer
785
+ * is zeroed out to prevent the unauthentic plaintext being
786
+ * used, making this interface safer.
787
+ *
788
+ * \param ctx The generic cipher context.
789
+ * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers.
790
+ * \param iv_len The IV length for ciphers with variable-size IV.
791
+ * This parameter is discarded by ciphers with fixed-size IV.
792
+ * \param ad The additional data to be authenticated.
793
+ * \param ad_len The length of \p ad.
794
+ * \param input The buffer holding the input data.
795
+ * \param ilen The length of the input data.
796
+ * \param output The buffer for the output data.
797
+ * Must be able to hold at least \p ilen.
798
+ * \param olen The length of the output data, to be updated with the
799
+ * actual number of Bytes written.
800
+ * \param tag The buffer holding the authentication tag.
801
+ * \param tag_len The length of the authentication tag.
802
+ *
803
+ * \return \c 0 on success.
804
+ * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on
805
+ * parameter-verification failure.
806
+ * \return #MBEDTLS_ERR_CIPHER_AUTH_FAILED if data is not authentic.
807
+ * \return A cipher-specific error code on failure.
795
808
*/
796
809
int mbedtls_cipher_auth_decrypt ( mbedtls_cipher_context_t * ctx ,
797
810
const unsigned char * iv , size_t iv_len ,
0 commit comments