Diff for /rpl/src/instructions_c8.c between versions 1.29 and 1.41

version 1.29, 2018/05/30 09:27:34 version 1.41, 2025/04/15 10:17:52
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.1.29    RPL/2 (R) version 4.1.36
   Copyright (C) 1989-2018 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 59  instruction_cipher(struct_processus *s_e Line 59  instruction_cipher(struct_processus *s_e
   
     struct_objet                    *s_objet_argument_1;      struct_objet                    *s_objet_argument_1;
     struct_objet                    *s_objet_argument_2;      struct_objet                    *s_objet_argument_2;
       struct_objet                    *s_objet_padding;
     struct_objet                    *s_objet_resultat_1;      struct_objet                    *s_objet_resultat_1;
     struct_objet                    *s_objet_resultat_2;      struct_objet                    *s_objet_resultat_2;
   
Line 73  instruction_cipher(struct_processus *s_e Line 74  instruction_cipher(struct_processus *s_e
     unsigned char                   *iv_binaire;      unsigned char                   *iv_binaire;
     unsigned char                   *message;      unsigned char                   *message;
     unsigned char                   *message_chiffre;      unsigned char                   *message_chiffre;
       unsigned char                   padding;
     unsigned char                   *tampon;      unsigned char                   *tampon;
   
     if ((*s_etat_processus).affichage_arguments == 'Y')      if ((*s_etat_processus).affichage_arguments == 'Y')
Line 94  instruction_cipher(struct_processus *s_e Line 96  instruction_cipher(struct_processus *s_e
         printf("->  1: { \"cipher type\" \"generated key\" \"iv\" }\n\n");          printf("->  1: { \"cipher type\" \"generated key\" \"iv\" }\n\n");
   
         printf("    2: \"text\"\n", d_CHN);          printf("    2: \"text\"\n", d_CHN);
         printf("    1: { \"direction\" \"cipher type\" \"key\" \"iv\" }\n");          printf("    1: { \"direction\" \"cipher type\" \"key\" \"iv\" "
                   "padding }\n");
         printf("->  2: \"encrypted or decrypted text\"\n", d_CHN);          printf("->  2: \"encrypted or decrypted text\"\n", d_CHN);
         printf("    1: { \"direction\" \"cipher type\" \"key\" "          printf("    1: { \"direction\" \"cipher type\" \"key\" "
                 "\"updated iv\" }\n\n", d_LST);                  "\"updated iv\" padding }\n\n", d_LST);
   
         if ((*s_etat_processus).langue == 'F')          if ((*s_etat_processus).langue == 'F')
         {          {
Line 280  instruction_cipher(struct_processus *s_e Line 283  instruction_cipher(struct_processus *s_e
         printf("    \"password\" { \"KEY\" \"DES-EDE-OFB\" \"SHA1\" "          printf("    \"password\" { \"KEY\" \"DES-EDE-OFB\" \"SHA1\" "
                 "# 0h 3 } CIPHER\n");                  "# 0h 3 } CIPHER\n");
         printf("    \"text\" { \"ENCRYPT\" \"AES-128-CBC\" \"key\" "          printf("    \"text\" { \"ENCRYPT\" \"AES-128-CBC\" \"key\" "
                 "\"iv\" } CIPHER\n");                  "\"iv\" \"PADDING\" } CIPHER\n");
         printf("    \"text\" { \"DECRYPT\" \"AES-128-EBC\" \"key\" "          printf("    \"text\" { \"DECRYPT\" \"AES-128-EBC\" \"key\" "
                 "\"iv\" } CIPHER\n");                  "\"iv\" \"NO PADDING\" } CIPHER\n");
         return;          return;
     }      }
     else if ((*s_etat_processus).test_instruction == 'Y')      else if ((*s_etat_processus).test_instruction == 'Y')
Line 352  instruction_cipher(struct_processus *s_e Line 355  instruction_cipher(struct_processus *s_e
   
             free(instruction);              free(instruction);
   
               s_objet_padding = NULL;
             l_element_courant = (*l_element_courant).suivant;              l_element_courant = (*l_element_courant).suivant;
   
             if (l_element_courant == NULL)              if (l_element_courant == NULL)
Line 922  instruction_cipher(struct_processus *s_e Line 926  instruction_cipher(struct_processus *s_e
   
             iv = (unsigned char *) (*(*l_element_courant).donnee).objet;              iv = (unsigned char *) (*(*l_element_courant).donnee).objet;
   
               // On attend le drapeau concernant le padding.
   
               if ((l_element_courant = (*l_element_courant).suivant) == NULL)
               {
                   liberation(s_etat_processus, s_objet_argument_1);
                   liberation(s_etat_processus, s_objet_argument_2);
   
                   (*s_etat_processus).erreur_execution =
                           d_ex_manque_argument;
                   return;
               }
   
               if ((*(*l_element_courant).donnee).type != CHN)
               {
                   liberation(s_etat_processus, s_objet_argument_1);
                   liberation(s_etat_processus, s_objet_argument_2);
   
                   (*s_etat_processus).erreur_execution =
                           d_ex_erreur_type_argument;
                   return;
               }
   
               tampon = conversion_majuscule(s_etat_processus,
                       (unsigned char *) (*(*l_element_courant).donnee).objet);
   
               if (strcmp(tampon, "PADDING") == 0)
               {
                   padding = 'Y';
               }
               else if (strcmp(tampon, "NO PADDING") == 0)
               {
                   padding = 'N';
               }
               else
               {
                   free(tampon);
   
                   liberation(s_etat_processus, s_objet_argument_1);
                   liberation(s_etat_processus, s_objet_argument_2);
   
                   (*s_etat_processus).erreur_execution = d_ex_argument_invalide;
                   return;
               }
   
               free(tampon);
   
               s_objet_padding = copie_objet(s_etat_processus,
                       (*l_element_courant).donnee, 'P');
   
             if ((*l_element_courant).suivant != NULL)              if ((*l_element_courant).suivant != NULL)
             {              {
                 liberation(s_etat_processus, s_objet_argument_1);                  liberation(s_etat_processus, s_objet_argument_1);
Line 1513  instruction_cipher(struct_processus *s_e Line 1566  instruction_cipher(struct_processus *s_e
         if ((message_chiffre = chiffrement(s_etat_processus,          if ((message_chiffre = chiffrement(s_etat_processus,
                 EVP_chiffrement, encodage, message,                  EVP_chiffrement, encodage, message,
                 longueur_message, clef_binaire, longueur_clef_binaire,                  longueur_message, clef_binaire, longueur_clef_binaire,
                 iv_binaire, &longueur_message_chiffre)) == NULL)                  iv_binaire, &longueur_message_chiffre, padding)) == NULL)
         {          {
             free(clef_binaire);              free(clef_binaire);
             free(iv_binaire);              free(iv_binaire);
Line 1640  instruction_cipher(struct_processus *s_e Line 1693  instruction_cipher(struct_processus *s_e
         }          }
   
         l_element_courant = (*l_element_courant).suivant;          l_element_courant = (*l_element_courant).suivant;
         (*l_element_courant).suivant = NULL;  
   
         if (((*l_element_courant).donnee = allocation(s_etat_processus, CHN))          if (((*l_element_courant).donnee = allocation(s_etat_processus, CHN))
                 == NULL)                  == NULL)
Line 1657  instruction_cipher(struct_processus *s_e Line 1709  instruction_cipher(struct_processus *s_e
                   
         free(iv_binaire);          free(iv_binaire);
   
           // Padding
   
           if (((*l_element_courant).suivant = allocation_maillon(
                   s_etat_processus)) == NULL)
           {
               (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
               return;
           }
   
           l_element_courant = (*l_element_courant).suivant;
           (*l_element_courant).donnee = s_objet_padding;
           (*l_element_courant).suivant = NULL;
   
         liberation(s_etat_processus, s_objet_argument_1);          liberation(s_etat_processus, s_objet_argument_1);
         liberation(s_etat_processus, s_objet_argument_2);          liberation(s_etat_processus, s_objet_argument_2);
   

Removed from v.1.29  
changed lines
  Added in v.1.41


CVSweb interface <joel.bertrand@systella.fr>