--- rpl/src/instructions_d6.c 2013/03/20 17:11:44 1.48 +++ rpl/src/instructions_d6.c 2017/01/18 15:44:19 1.66 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.13 - Copyright (C) 1989-2013 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.26 + Copyright (C) 1989-2017 Dr. BERTRAND Joël This file is part of RPL/2. @@ -605,7 +605,7 @@ instruction_diag_fleche(struct_processus void instruction_digest(struct_processus *s_etat_processus) { - EVP_MD_CTX contexte; + EVP_MD_CTX *contexte; const EVP_MD *EVP_sum; const EVP_CIPHER *EVP_chiffrement; @@ -684,11 +684,6 @@ instruction_digest(struct_processus *s_e printf(" - DES-EDE3-CB\n"); printf(" - DESX-CBC\n"); # endif -# ifndef OPENSSL_NO_SHA - printf(" - DSS\n"); - printf(" - DSS1\n"); - printf(" - ECDSA\n"); -# endif # ifndef OPENSSL_NO_IDEA printf(" - IDEA-CBC\n"); # endif @@ -712,18 +707,11 @@ instruction_digest(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 @@ -778,15 +766,11 @@ instruction_digest(struct_processus *s_e ((*s_objet_argument_2).type == CHN)) { // Liste des sommes disponibles : - // - EVP_dss - // - EVP_dss1 - // - EVP_ecdsa // - EVP_md2 // - EVP_md4 // - EVP_md5 // - EVP_mdc2 // - EVP_ripemd160 - // - EVP_sha // - EVP_sha1 // - EVP_sha224 // - EVP_sha256 @@ -794,8 +778,8 @@ instruction_digest(struct_processus *s_e // - EVP_sha512 // - EVP_whirlpool - if ((fonction = conversion_majuscule((unsigned char *) - (*s_objet_argument_1).objet)) == NULL) + if ((fonction = conversion_majuscule(s_etat_processus, + (unsigned char *) (*s_objet_argument_1).objet)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -805,143 +789,6 @@ instruction_digest(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]) @@ -1072,17 +919,10 @@ instruction_digest(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] == d_code_fin_chaine) @@ -1097,7 +937,6 @@ instruction_digest(struct_processus *s_e break; } -# ifndef OPENSSL_NO_SHA256 case '2': // sha2 { switch(fonction[4]) @@ -1173,9 +1012,7 @@ instruction_digest(struct_processus *s_e break; } -# endif -# ifndef OPENSSL_NO_SHA512 case '3': // sha3 { switch(fonction[4]) @@ -1265,7 +1102,6 @@ instruction_digest(struct_processus *s_e break; } -# endif default: { @@ -1276,7 +1112,6 @@ instruction_digest(struct_processus *s_e break; } -# endif default: { @@ -1333,9 +1168,18 @@ instruction_digest(struct_processus *s_e return; } - if (EVP_DigestInit(&contexte, EVP_sum) != 1) + if ((contexte = EVP_MD_CTX_new()) == NULL) { - EVP_MD_CTX_cleanup(&contexte); + liberation(s_etat_processus, s_objet_argument_1); + liberation(s_etat_processus, s_objet_argument_2); + + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + if (EVP_DigestInit(contexte, EVP_sum) != 1) + { + EVP_MD_CTX_free(contexte); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -1347,7 +1191,7 @@ instruction_digest(struct_processus *s_e if ((chaine = formateur_flux(s_etat_processus, (unsigned char *) (*s_objet_argument_2).objet, &longueur_chaine)) == NULL) { - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_free(contexte); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -1355,10 +1199,10 @@ instruction_digest(struct_processus *s_e return; } - if (EVP_DigestUpdate(&contexte, chaine, (size_t) longueur_chaine) != 1) + if (EVP_DigestUpdate(contexte, chaine, (size_t) longueur_chaine) != 1) { free(chaine); - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_free(contexte); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -1367,10 +1211,10 @@ instruction_digest(struct_processus *s_e return; } - if (EVP_DigestFinal_ex(&contexte, somme, &longueur_somme) != 1) + if (EVP_DigestFinal_ex(contexte, somme, &longueur_somme) != 1) { free(chaine); - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_free(contexte); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -1380,7 +1224,7 @@ instruction_digest(struct_processus *s_e } free(chaine); - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_free(contexte); if ((s_objet_resultat = allocation(s_etat_processus, CHN)) == NULL) { @@ -1446,8 +1290,9 @@ instruction_digest(struct_processus *s_e l_element_courant = (*s_objet_argument_1).objet; - if ((fonction = conversion_majuscule((unsigned char *) - (*(*l_element_courant).donnee).objet)) == NULL) + if ((fonction = conversion_majuscule(s_etat_processus, + (unsigned char *) (*(*l_element_courant).donnee).objet)) + == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -1457,143 +1302,6 @@ instruction_digest(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]) @@ -1724,17 +1432,10 @@ instruction_digest(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] == d_code_fin_chaine) @@ -1749,7 +1450,6 @@ instruction_digest(struct_processus *s_e break; } -# ifndef OPENSSL_NO_SHA256 case '2': // sha2 { switch(fonction[4]) @@ -1825,9 +1525,7 @@ instruction_digest(struct_processus *s_e break; } -# endif -# ifndef OPENSSL_NO_SHA512 case '3': // sha3 { switch(fonction[4]) @@ -1917,7 +1615,6 @@ instruction_digest(struct_processus *s_e break; } -# endif default: { @@ -1928,7 +1625,6 @@ instruction_digest(struct_processus *s_e break; } -# endif default: { @@ -2277,7 +1973,7 @@ instruction_digest(struct_processus *s_e memset(vecteur_initialisation, 0, (size_t) longueur_clef); - if ((tampon = chiffrement(EVP_chiffrement, d_vrai, + if ((tampon = chiffrement(s_etat_processus, EVP_chiffrement, d_vrai, chaine, longueur_chaine, clef, longueur_clef, vecteur_initialisation, &longueur_tampon)) == NULL) { @@ -2384,8 +2080,6 @@ instruction_digest(struct_processus *s_e if ((chaine = formateur_flux(s_etat_processus, (unsigned char *) (*s_objet_argument_2).objet, &longueur_chaine)) == NULL) { - EVP_MD_CTX_cleanup(&contexte); - liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -2403,13 +2097,22 @@ instruction_digest(struct_processus *s_e memcpy(tampon + longueur_bloc, chaine, (size_t) longueur_chaine); longueur_tampon = longueur_bloc + longueur_chaine; - if (EVP_DigestInit(&contexte, EVP_sum) != 1) + if ((contexte = EVP_MD_CTX_new()) == NULL) + { + liberation(s_etat_processus, s_objet_argument_1); + liberation(s_etat_processus, s_objet_argument_2); + + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + if (EVP_DigestInit(contexte, EVP_sum) != 1) { free(tampon); free(clef); free(chaine); - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_free(contexte); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -2418,14 +2121,14 @@ instruction_digest(struct_processus *s_e return; } - if (EVP_DigestUpdate(&contexte, tampon, (size_t) longueur_tampon) + if (EVP_DigestUpdate(contexte, tampon, (size_t) longueur_tampon) != 1) { free(tampon); free(clef); free(chaine); - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_free(contexte); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -2436,10 +2139,10 @@ instruction_digest(struct_processus *s_e free(tampon); - if (EVP_DigestFinal_ex(&contexte, somme, &longueur_somme) != 1) + if (EVP_DigestFinal_ex(contexte, somme, &longueur_somme) != 1) { free(chaine); - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_free(contexte); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -2448,7 +2151,7 @@ instruction_digest(struct_processus *s_e return; } - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_reset(contexte); for(i = 0; i < longueur_bloc; i++) { @@ -2466,13 +2169,13 @@ instruction_digest(struct_processus *s_e memcpy(tampon + longueur_bloc, somme, (size_t) longueur_somme); longueur_tampon = longueur_bloc + longueur_somme; - if (EVP_DigestInit(&contexte, EVP_sum) != 1) + if (EVP_DigestInit(contexte, EVP_sum) != 1) { free(tampon); free(clef); free(chaine); - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_free(contexte); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -2481,14 +2184,14 @@ instruction_digest(struct_processus *s_e return; } - if (EVP_DigestUpdate(&contexte, tampon, (size_t) longueur_tampon) + if (EVP_DigestUpdate(contexte, tampon, (size_t) longueur_tampon) != 1) { free(tampon); free(clef); free(chaine); - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_free(contexte); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -2499,10 +2202,10 @@ instruction_digest(struct_processus *s_e free(tampon); - if (EVP_DigestFinal_ex(&contexte, somme, &longueur_somme) != 1) + if (EVP_DigestFinal_ex(contexte, somme, &longueur_somme) != 1) { free(chaine); - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_free(contexte); liberation(s_etat_processus, s_objet_argument_1); liberation(s_etat_processus, s_objet_argument_2); @@ -2511,7 +2214,7 @@ instruction_digest(struct_processus *s_e return; } - EVP_MD_CTX_cleanup(&contexte); + EVP_MD_CTX_free(contexte); free(chaine); free(clef);