--- rpl/src/instructions_c8.c 2013/02/27 16:26:45 1.5 +++ rpl/src/instructions_c8.c 2020/01/10 11:15:44 1.34 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.12 - Copyright (C) 1989-2013 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.32 + Copyright (C) 1989-2020 Dr. BERTRAND Joël This file is part of RPL/2. @@ -43,6 +43,10 @@ instruction_cipher(struct_processus *s_e int longueur_clef; + integer8 longueur_clef_binaire; + integer8 longueur_iv_binaire; + integer8 longueur_message; + integer8 longueur_message_chiffre; integer8 nombre_cycles; logical1 encodage; @@ -51,10 +55,6 @@ instruction_cipher(struct_processus *s_e logical8 sel; - long longueur_clef_binaire; - long longueur_iv_binaire; - long longueur_message; - struct_liste_chainee *l_element_courant; struct_objet *s_objet_argument_1; @@ -75,8 +75,6 @@ instruction_cipher(struct_processus *s_e unsigned char *message_chiffre; unsigned char *tampon; - unsigned int longueur_message_chiffre; - if ((*s_etat_processus).affichage_arguments == 'Y') { printf("\n CIPHER "); @@ -96,8 +94,7 @@ instruction_cipher(struct_processus *s_e printf("-> 1: { \"cipher type\" \"generated key\" \"iv\" }\n\n"); printf(" 2: \"text\"\n", d_CHN); - printf(" 1: %s { \"direction\" \"cipher type\" \"key\" \"iv\" }\n", - d_LST); + printf(" 1: { \"direction\" \"cipher type\" \"key\" \"iv\" }\n"); printf("-> 2: \"encrypted or decrypted text\"\n", d_CHN); printf(" 1: { \"direction\" \"cipher type\" \"key\" " "\"updated iv\" }\n\n", d_LST); @@ -245,11 +242,6 @@ instruction_cipher(struct_processus *s_e printf(" Digest algorithms:\n\n"); } -# ifndef OPENSSL_NO_SHA - printf(" - DSS\n"); - printf(" - DSS1\n"); - printf(" - ECDSA\n"); -# endif # ifndef OPENSSL_NO_MD2 printf(" - MD2\n"); # endif @@ -265,18 +257,11 @@ instruction_cipher(struct_processus *s_e # ifndef OPENSSL_NO_RIPEMD printf(" - RIPEMD160\n"); # endif -# ifndef OPENSSL_NO_SHA - printf(" - SHA\n"); printf(" - SHA1\n"); -# endif -# ifndef OPENSSL_NO_SHA256 printf(" - SHA224\n"); printf(" - SHA256\n"); -# endif -# ifndef OPENSSL_NO_SHA512 printf(" - SHA384\n"); printf(" - SHA512\n"); -# endif # ifndef OPENSSL_NO_WHIRLPOOL printf(" - WHIRLPOOL\n"); # endif @@ -353,8 +338,9 @@ instruction_cipher(struct_processus *s_e return; } - if ((instruction = conversion_majuscule((unsigned char *) - (*(*l_element_courant).donnee).objet)) == NULL) + if ((instruction = conversion_majuscule(s_etat_processus, + (unsigned char *) (*(*l_element_courant).donnee).objet)) + == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -417,7 +403,8 @@ instruction_cipher(struct_processus *s_e // Test de la validité de la somme de contrôle. - if ((fonction = conversion_majuscule(controle)) == NULL) + if ((fonction = conversion_majuscule(s_etat_processus, controle)) + == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -427,144 +414,6 @@ instruction_cipher(struct_processus *s_e switch(fonction[0]) { - case 'D': - { - switch(fonction[1]) - { - case 'S': // ds - { - switch(fonction[2]) - { -# ifndef OPENSSL_NO_SHA - case 'S': // dss - { - switch(fonction[3]) - { - case d_code_fin_chaine: - { - EVP_sum = EVP_dss(); - break; - } - - case '1': // dss1 - { - if (fonction[4] == - d_code_fin_chaine) - { - EVP_sum = EVP_dss1(); - } - else - { - somme_invalide = d_vrai; - } - - break; - } - - default: - { - somme_invalide = d_vrai; - break; - } - } - - break; - } -# endif - - default: - { - somme_invalide = d_vrai; - break; - } - } - - break; - } - - default: - { - somme_invalide = d_vrai; - break; - } - } - - break; - } - - case 'E': - { - switch(fonction[1]) - { - case 'C': // ec - { - switch(fonction[2]) - { - case 'D': // ecd - { - switch(fonction[3]) - { - case 'S': // ecds - { - switch(fonction[4]) - { -# ifndef OPENSSL_NO_SHA - case 'A': // ecdsa - { - if (fonction[5] == - d_code_fin_chaine) - { - EVP_sum = EVP_ecdsa(); - } - else - { - somme_invalide = d_vrai; - } - - break; - } -# endif - - default: - { - somme_invalide = d_vrai; - break; - } - } - - break; - } - - default: - { - somme_invalide = d_vrai; - break; - } - } - - break; - } - - default: - { - somme_invalide = d_vrai; - break; - } - } - - break; - } - - default: - { - somme_invalide = d_vrai; - break; - } - } - - break; - } - case 'M': { switch(fonction[1]) @@ -696,17 +545,10 @@ instruction_cipher(struct_processus *s_e { switch(fonction[2]) { -# ifndef OPENSSL_NO_SHA case 'A': { switch(fonction[3]) { - case d_code_fin_chaine: - { - EVP_sum = EVP_sha(); - break; - } - case '1': // sha1 { if (fonction[4] == @@ -722,7 +564,6 @@ instruction_cipher(struct_processus *s_e break; } -# ifndef OPENSSL_NO_SHA256 case '2': // sha2 { switch(fonction[4]) @@ -800,9 +641,7 @@ instruction_cipher(struct_processus *s_e break; } -# endif -# ifndef OPENSSL_NO_SHA512 case '3': // sha3 { switch(fonction[4]) @@ -894,7 +733,6 @@ instruction_cipher(struct_processus *s_e break; } -# endif default: { @@ -905,7 +743,6 @@ instruction_cipher(struct_processus *s_e break; } -# endif default: { @@ -1106,7 +943,8 @@ instruction_cipher(struct_processus *s_e return; } - if ((tampon = conversion_majuscule(algorithme_chiffrement)) == NULL) + if ((tampon = conversion_majuscule(s_etat_processus, + algorithme_chiffrement)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -1474,14 +1312,14 @@ instruction_cipher(struct_processus *s_e if (generation_clef == d_vrai) { - if ((iv = malloc(EVP_CIPHER_iv_length(EVP_chiffrement) + if ((iv = malloc(((size_t) EVP_CIPHER_iv_length(EVP_chiffrement)) * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } - if ((clef = malloc(EVP_CIPHER_key_length(EVP_chiffrement) + if ((clef = malloc(((size_t) EVP_CIPHER_key_length(EVP_chiffrement)) * sizeof(unsigned char))) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -1490,9 +1328,10 @@ instruction_cipher(struct_processus *s_e longueur_clef = EVP_BytesToKey(EVP_chiffrement, EVP_sum, (unsigned char *) &sel, (unsigned char *) - (*s_objet_argument_2).objet, longueur_chaine(s_etat_processus, + (*s_objet_argument_2).objet, + (int) longueur_chaine(s_etat_processus, (unsigned char *) (*s_objet_argument_2).objet), - nombre_cycles, clef, iv); + (int) nombre_cycles, clef, iv); if (longueur_clef != EVP_CIPHER_key_length(EVP_chiffrement)) { @@ -1671,7 +1510,8 @@ instruction_cipher(struct_processus *s_e return; } - if ((message_chiffre = chiffrement(EVP_chiffrement, encodage, message, + if ((message_chiffre = chiffrement(s_etat_processus, + EVP_chiffrement, encodage, message, longueur_message, clef_binaire, longueur_clef_binaire, iv_binaire, &longueur_message_chiffre)) == NULL) { @@ -1756,7 +1596,8 @@ instruction_cipher(struct_processus *s_e } if (((*(*l_element_courant).donnee).objet = - conversion_majuscule(algorithme_chiffrement)) == NULL) + conversion_majuscule(s_etat_processus, algorithme_chiffrement)) + == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return;