--- rpl/src/instructions_d6.c 2013/02/26 19:56:14 1.44 +++ rpl/src/instructions_d6.c 2013/02/27 14:12:57 1.45 @@ -1474,7 +1474,6 @@ instruction_digest(struct_processus *s_e case d_code_fin_chaine: { EVP_sum = EVP_dss(); - longueur_bloc = SHA_CBLOCK; break; } @@ -1483,7 +1482,6 @@ instruction_digest(struct_processus *s_e if (fonction[4] == d_code_fin_chaine) { EVP_sum = EVP_dss1(); - longueur_bloc = SHA_CBLOCK; } else { @@ -1547,7 +1545,6 @@ instruction_digest(struct_processus *s_e d_code_fin_chaine) { EVP_sum = EVP_ecdsa(); - longueur_bloc = SHA_CBLOCK; } else { @@ -1612,7 +1609,6 @@ instruction_digest(struct_processus *s_e if (fonction[3] == d_code_fin_chaine) { EVP_sum = EVP_md2(); - longueur_bloc = MD2_BLOCK; } else { @@ -1629,7 +1625,6 @@ instruction_digest(struct_processus *s_e if (fonction[3] == d_code_fin_chaine) { EVP_sum = EVP_md4(); - longueur_bloc = MD4_CBLOCK; } else { @@ -1646,7 +1641,6 @@ instruction_digest(struct_processus *s_e if (fonction[3] == d_code_fin_chaine) { EVP_sum = EVP_md5(); - longueur_bloc = MD5_CBLOCK; } else { @@ -1667,7 +1661,6 @@ instruction_digest(struct_processus *s_e if (fonction[4] == d_code_fin_chaine) { EVP_sum = EVP_mdc2(); - longueur_bloc = MDC2_BLOCK; } else { @@ -1714,7 +1707,6 @@ instruction_digest(struct_processus *s_e if (strcmp(fonction, "RIPEMD160") == 0) { EVP_sum = EVP_ripemd160(); - longueur_bloc = RIPEMD160_CBLOCK; } else { @@ -1741,7 +1733,6 @@ instruction_digest(struct_processus *s_e case d_code_fin_chaine: { EVP_sum = EVP_sha(); - longueur_bloc = SHA_CBLOCK; break; } @@ -1750,7 +1741,6 @@ instruction_digest(struct_processus *s_e if (fonction[4] == d_code_fin_chaine) { EVP_sum = EVP_sha1(); - longueur_bloc = SHA_CBLOCK; } else { @@ -1776,8 +1766,6 @@ instruction_digest(struct_processus *s_e { EVP_sum = EVP_sha224(); - longueur_bloc = - SHA256_CBLOCK; } else { @@ -1809,8 +1797,6 @@ instruction_digest(struct_processus *s_e { EVP_sum = EVP_sha256(); - longueur_bloc = - SHA256_CBLOCK; } else { @@ -1858,8 +1844,6 @@ instruction_digest(struct_processus *s_e { EVP_sum = EVP_sha384(); - longueur_bloc = - SHA512_CBLOCK; } else { @@ -1905,8 +1889,6 @@ instruction_digest(struct_processus *s_e { EVP_sum = EVP_sha512(); - longueur_bloc = - SHA512_CBLOCK; } else { @@ -1975,7 +1957,6 @@ instruction_digest(struct_processus *s_e if (strcmp(fonction, "WHIRLPOOL") == 0) { EVP_sum = EVP_whirlpool(); - longueur_bloc = WHIRLPOOL_BBLOCK / 8; } else { @@ -2015,20 +1996,14 @@ instruction_digest(struct_processus *s_e if (strcmp(fonction, "AES-128-CBC") == 0) { EVP_chiffrement = EVP_aes_128_cbc(); - longueur_clef_attendue = 16; - longueur_somme = AES_BLOCK_SIZE; } else if (strcmp(fonction, "AES-192-CBC") == 0) { EVP_chiffrement = EVP_aes_192_cbc(); - longueur_clef_attendue = 24; - longueur_somme = AES_BLOCK_SIZE; } else if (strcmp(fonction, "AES-256-CBC") == 0) { EVP_chiffrement = EVP_aes_256_cbc(); - longueur_clef_attendue = 32; - longueur_somme = AES_BLOCK_SIZE; } else { @@ -2042,6 +2017,9 @@ instruction_digest(struct_processus *s_e return; } + longueur_clef_attendue = EVP_CIPHER_key_length(EVP_chiffrement); + longueur_somme = EVP_CIPHER_block_size(EVP_chiffrement); + # endif } else if (strncmp(fonction, "DES", 3) == 0) @@ -2062,26 +2040,18 @@ instruction_digest(struct_processus *s_e if (strcmp(fonction, "DES-CBC") == 0) { EVP_chiffrement = EVP_des_cbc(); - longueur_clef_attendue = 7; - longueur_somme = 8; } else if (strcmp(fonction, "DES-EDE-CBC") == 0) { EVP_chiffrement = EVP_des_ede_cbc(); - longueur_clef_attendue = 7; - longueur_somme = 8; } else if (strcmp(fonction, "DES-EDE3-CBC") == 0) { EVP_chiffrement = EVP_des_ede3_cbc(); - longueur_clef_attendue = 7; - longueur_somme = 8; } else if (strcmp(fonction, "DESX-CBC") == 0) { EVP_chiffrement = EVP_desx_cbc(); - longueur_clef_attendue = 7; - longueur_somme = 8; } else { @@ -2094,6 +2064,10 @@ instruction_digest(struct_processus *s_e d_ex_chiffrement_indisponible; return; } + + longueur_clef_attendue = EVP_CIPHER_key_length(EVP_chiffrement); + longueur_somme = EVP_CIPHER_block_size(EVP_chiffrement); + # endif } else if (strncmp(fonction, "CAMELLIA", 8) == 0) @@ -2114,20 +2088,14 @@ instruction_digest(struct_processus *s_e if (strcmp(fonction, "CAMELLIA-128-CBC") == 0) { EVP_chiffrement = EVP_camellia_128_cbc(); - longueur_clef_attendue = 16; - longueur_somme = CAMELLIA_BLOCK_SIZE; } else if (strcmp(fonction, "CAMELLIA-192-CBC") == 0) { EVP_chiffrement = EVP_camellia_192_cbc(); - longueur_clef_attendue = 24; - longueur_somme = CAMELLIA_BLOCK_SIZE; } else if (strcmp(fonction, "CAMELLIA-256-CBC") == 0) { EVP_chiffrement = EVP_camellia_256_cbc(); - longueur_clef_attendue = 32; - longueur_somme = CAMELLIA_BLOCK_SIZE; } else { @@ -2140,6 +2108,10 @@ instruction_digest(struct_processus *s_e d_ex_chiffrement_indisponible; return; } + + longueur_clef_attendue = EVP_CIPHER_key_length(EVP_chiffrement); + longueur_somme = EVP_CIPHER_block_size(EVP_chiffrement); + # endif } else if (strncmp(fonction, "RC2", 3) == 0) @@ -2160,26 +2132,14 @@ instruction_digest(struct_processus *s_e if (strcmp(fonction, "RC2-CBC") == 0) { EVP_chiffrement = EVP_rc2_cbc(); - longueur_clef_attendue = 0; - longueur_clef_min = 1; - longueur_clef_max = 16; - longueur_somme = RC2_BLOCK; } else if (strcmp(fonction, "RC2-40-CBC") == 0) { EVP_chiffrement = EVP_rc2_40_cbc(); - longueur_clef_attendue = 0; - longueur_clef_min = 1; - longueur_clef_max = 16; - longueur_somme = RC2_BLOCK; } else if (strcmp(fonction, "RC2-64-CBC") == 0) { EVP_chiffrement = EVP_rc2_64_cbc(); - longueur_clef_attendue = 0; - longueur_clef_min = 1; - longueur_clef_max = 16; - longueur_somme = RC2_BLOCK; } else { @@ -2192,6 +2152,12 @@ instruction_digest(struct_processus *s_e d_ex_chiffrement_indisponible; return; } + + longueur_clef_attendue = 0; + longueur_clef_min = 1; + longueur_clef_max = 16; + longueur_somme = EVP_CIPHER_block_size(EVP_chiffrement); + # endif } else if (strncmp(fonction, "IDEA", 4) == 0) @@ -2212,8 +2178,6 @@ instruction_digest(struct_processus *s_e if (strcmp(fonction, "IDEA-CBC") == 0) { EVP_chiffrement = EVP_idea_cbc(); - longueur_clef_attendue = 16; - longueur_somme = IDEA_BLOCK; } else { @@ -2226,6 +2190,10 @@ instruction_digest(struct_processus *s_e d_ex_chiffrement_indisponible; return; } + + longueur_clef_attendue = EVP_CIPHER_key_length(EVP_chiffrement); + longueur_somme = EVP_CIPHER_block_size(EVP_chiffrement); + # endif } else @@ -2312,8 +2280,7 @@ instruction_digest(struct_processus *s_e if ((tampon = chiffrement(EVP_chiffrement, d_vrai, chaine, longueur_chaine, clef, longueur_clef, - vecteur_initialisation, longueur_clef, - longueur_somme, &longueur_tampon)) == NULL) + vecteur_initialisation, &longueur_tampon)) == NULL) { free(fonction); free(vecteur_initialisation); @@ -2363,6 +2330,8 @@ instruction_digest(struct_processus *s_e l_element_courant = (*s_objet_argument_1).objet; l_element_courant = (*l_element_courant).suivant; + longueur_bloc = EVP_MD_block_size(EVP_sum); + if ((clef = formateur_flux(s_etat_processus, (unsigned char *) (*(*l_element_courant).donnee).objet, &longueur_clef)) == NULL)