Diff for /rpl/src/chiffrement.c between versions 1.43 and 1.45

version 1.43, 2024/07/04 08:38:47 version 1.45, 2025/04/15 10:17:49
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.1.36    RPL/2 (R) version 4.1.36
   Copyright (C) 1989-2024 Dr. BERTRAND Joël    Copyright (C) 1989-2025 Dr. BERTRAND Joël
   
   This file is part of RPL/2.    This file is part of RPL/2.
   
Line 41  chiffrement(struct_processus *s_etat_pro Line 41  chiffrement(struct_processus *s_etat_pro
         unsigned char *message, integer8 longueur_message,          unsigned char *message, integer8 longueur_message,
         unsigned char *clef, integer8 longueur_clef,          unsigned char *clef, integer8 longueur_clef,
         unsigned char *vecteur_initialisation,          unsigned char *vecteur_initialisation,
         integer8 *longueur_message_chiffre)          integer8 *longueur_message_chiffre,
           unsigned char padding)
 {  {
     int                         longueur_bloc_de_chiffrement;      int                         longueur_bloc_de_chiffrement;
     int                         longueur_message_1;      int                         longueur_message_1;
Line 75  chiffrement(struct_processus *s_etat_pro Line 76  chiffrement(struct_processus *s_etat_pro
     {      {
         nombre_blocs++;          nombre_blocs++;
     }      }
       else if (padding == 'N')
       {
           // Pas de padding si la longueur du message est un multiple
           // entier de la longueur du bloc.
   
           EVP_CIPHER_CTX_set_padding(contexte, 0);
       }
   
     (*longueur_message_chiffre) = nombre_blocs * longueur_bloc_de_chiffrement;      (*longueur_message_chiffre) = nombre_blocs * longueur_bloc_de_chiffrement;
   
     // On prévoit une zone de garde pour EVP_CipherFinal_ex() en espérant      if (padding == 'Y')
     // qu'il ne faille pas plus qu'une longueur de bloc de chiffrement.  
     if ((message_chiffre = malloc(((size_t) ((*longueur_message_chiffre)  
             + longueur_bloc_de_chiffrement)) *  
             sizeof(unsigned char))) == NULL)  
     {      {
         EVP_CIPHER_CTX_free(contexte);          // On prévoit une zone de garde pour EVP_CipherFinal_ex() qui rajoute
         return(NULL);          // TOUJOURS un bloc complet même s'il la taille chiffrée par
           // EVP_CipherUpdate() est un nombre exact de blocs !
   
           if ((message_chiffre = malloc(((size_t) ((*longueur_message_chiffre)
                   + longueur_bloc_de_chiffrement)) *
                   sizeof(unsigned char))) == NULL)
           {
               EVP_CIPHER_CTX_free(contexte);
               return(NULL);
           }
       }
       else
       {
           if ((message_chiffre = malloc(((size_t) (*longueur_message_chiffre)
                   ) * sizeof(unsigned char))) == NULL)
           {
               EVP_CIPHER_CTX_free(contexte);
               return(NULL);
           }
     }      }
   
     if (EVP_CipherUpdate(contexte, message_chiffre, &longueur_message_1,      if (EVP_CipherUpdate(contexte, message_chiffre, &longueur_message_1,

Removed from v.1.43  
changed lines
  Added in v.1.45


CVSweb interface <joel.bertrand@systella.fr>