version 1.42, 2013/02/25 19:14:01
|
version 1.44, 2013/02/26 19:56:14
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.12 |
RPL/2 (R) version 4.1.12 |
Copyright (C) 1989-2012 Dr. BERTRAND Joël |
Copyright (C) 1989-2013 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 634 instruction_digest(struct_processus *s_e
|
Line 634 instruction_digest(struct_processus *s_e
|
|
|
unsigned long longueur_clef; |
unsigned long longueur_clef; |
unsigned long longueur_clef_attendue; |
unsigned long longueur_clef_attendue; |
|
unsigned long longueur_clef_max; |
|
unsigned long longueur_clef_min; |
|
|
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
|
|
Line 672 instruction_digest(struct_processus *s_e
|
Line 674 instruction_digest(struct_processus *s_e
|
printf(" - AES-192-CBC\n"); |
printf(" - AES-192-CBC\n"); |
printf(" - AES-256-CBC\n"); |
printf(" - AES-256-CBC\n"); |
# endif |
# endif |
|
# ifndef OPENSSL_NO_CAMELLIA |
|
printf(" - CAMELLIA-128-CBC\n"); |
|
printf(" - CAMELLIA-192-CBC\n"); |
|
printf(" - CAMELLIA-256-CBC\n"); |
|
# endif |
|
# ifndef OPENSSL_NO_DES |
|
printf(" - DES-CBC\n"); |
|
printf(" - DES-EDE-CBC\n"); |
|
printf(" - DES-EDE3-CB\n"); |
|
printf(" - DESX-CBC\n"); |
|
# endif |
# ifndef OPENSSL_NO_SHA |
# ifndef OPENSSL_NO_SHA |
printf(" - DSS\n"); |
printf(" - DSS\n"); |
printf(" - DSS1\n"); |
printf(" - DSS1\n"); |
printf(" - ECDSA\n"); |
printf(" - ECDSA\n"); |
# endif |
# endif |
|
# ifndef OPENSSL_NO_IDEA |
|
printf(" - IDEA-CBC\n"); |
|
# endif |
# ifndef OPENSSL_NO_MD2 |
# ifndef OPENSSL_NO_MD2 |
printf(" - MD2\n"); |
printf(" - MD2\n"); |
# endif |
# endif |
Line 689 instruction_digest(struct_processus *s_e
|
Line 705 instruction_digest(struct_processus *s_e
|
# ifndef OPENSSL_NO_MDC2 |
# ifndef OPENSSL_NO_MDC2 |
printf(" - MDC2\n"); |
printf(" - MDC2\n"); |
# endif |
# endif |
|
# ifndef OPENSSL_NO_RC2 |
|
printf(" - RC2-CBC\n"); |
|
printf(" - RC2-40-CBC\n"); |
|
printf(" - RC2-64-CBC\n"); |
|
# endif |
# ifndef OPENSSL_NO_RIPEMD |
# ifndef OPENSSL_NO_RIPEMD |
printf(" - RIPEMD160\n"); |
printf(" - RIPEMD160\n"); |
# endif |
# endif |
Line 1976 instruction_digest(struct_processus *s_e
|
Line 1997 instruction_digest(struct_processus *s_e
|
{ |
{ |
// Le chiffrement est de type CBC-MAC |
// Le chiffrement est de type CBC-MAC |
|
|
/* |
|
* const EVP_CIPHER *EVP_des_cbc(void); |
|
* const EVP_CIPHER *EVP_des_ede_cbc(void); |
|
* const EVP_CIPHER *EVP_des_ede3_cbc(void); |
|
* const EVP_CIPHER *EVP_desx_cbc(void); |
|
* const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void); |
|
* const EVP_CIPHER *EVP_idea_cbc(void); |
|
* const EVP_CIPHER *EVP_rc2_cbc(void); |
|
* const EVP_CIPHER *EVP_rc2_40_cbc(void); |
|
* const EVP_CIPHER *EVP_rc2_64_cbc(void); |
|
* const EVP_CIPHER *EVP_bf_cbc(void); |
|
* const EVP_CIPHER *EVP_cast5_cbc(void); |
|
* const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); |
|
* const EVP_CIPHER *EVP_aes_128_cbc(void); |
|
* const EVP_CIPHER *EVP_aes_192_cbc(void); |
|
* const EVP_CIPHER *EVP_aes_256_cbc(void); |
|
* const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void); |
|
* const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void); |
|
* const EVP_CIPHER *EVP_camellia_128_cbc(void); |
|
* const EVP_CIPHER *EVP_camellia_192_cbc(void); |
|
* const EVP_CIPHER *EVP_camellia_256_cbc(void); |
|
* const EVP_CIPHER *EVP_seed_cbc(void); |
|
*/ |
|
|
|
if (strncmp(fonction, "AES", 3) == 0) |
if (strncmp(fonction, "AES", 3) == 0) |
{ |
{ |
# ifdef OPENSSL_NO_AES |
# ifdef OPENSSL_NO_AES |
|
|
free(fonction); |
free(fonction); |
|
|
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_1); |
Line 2010 instruction_digest(struct_processus *s_e
|
Line 2008 instruction_digest(struct_processus *s_e
|
|
|
(*s_etat_processus).erreur_execution = |
(*s_etat_processus).erreur_execution = |
d_ex_chiffrement_indisponible; |
d_ex_chiffrement_indisponible; |
|
return; |
|
|
# else |
# else |
|
|
if (strcmp(fonction, "AES-128-CBC") == 0) |
if (strcmp(fonction, "AES-128-CBC") == 0) |
Line 2042 instruction_digest(struct_processus *s_e
|
Line 2042 instruction_digest(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
if ((chaine = formateur_flux(s_etat_processus, (unsigned char *) |
# endif |
(*s_objet_argument_2).objet, &longueur_chaine)) == NULL) |
} |
|
else if (strncmp(fonction, "DES", 3) == 0) |
|
{ |
|
# ifdef OPENSSL_NO_DES |
|
|
|
free(fonction); |
|
|
|
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_chiffrement_indisponible; |
|
return; |
|
|
|
# else |
|
|
|
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 |
{ |
{ |
free(fonction); |
free(fonction); |
|
|
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); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_chiffrement_indisponible; |
return; |
return; |
} |
} |
|
# endif |
|
} |
|
else if (strncmp(fonction, "CAMELLIA", 8) == 0) |
|
{ |
|
# ifdef OPENSSL_NO_CAMELLIA |
|
|
|
free(fonction); |
|
|
|
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
l_element_courant = (*s_objet_argument_1).objet; |
(*s_etat_processus).erreur_execution = |
l_element_courant = (*l_element_courant).suivant; |
d_ex_chiffrement_indisponible; |
|
return; |
|
|
|
# else |
|
|
if ((clef = formateur_flux(s_etat_processus, (unsigned char *) |
if (strcmp(fonction, "CAMELLIA-128-CBC") == 0) |
(*(*l_element_courant).donnee).objet, &longueur_clef)) |
{ |
== NULL) |
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 |
{ |
{ |
free(fonction); |
free(fonction); |
free(chaine); |
|
|
|
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); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_chiffrement_indisponible; |
return; |
return; |
} |
} |
|
# endif |
|
} |
|
else if (strncmp(fonction, "RC2", 3) == 0) |
|
{ |
|
# ifdef OPENSSL_NO_RC2 |
|
|
if (longueur_clef != longueur_clef_attendue) |
free(fonction); |
|
|
|
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_chiffrement_indisponible; |
|
return; |
|
|
|
# else |
|
|
|
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 |
{ |
{ |
free(fonction); |
free(fonction); |
free(chaine); |
|
free(clef); |
|
|
|
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); |
|
|
(*s_etat_processus).erreur_execution = |
(*s_etat_processus).erreur_execution = |
d_ex_longueur_clef_chiffrement; |
d_ex_chiffrement_indisponible; |
return; |
return; |
} |
} |
|
# endif |
|
} |
|
else if (strncmp(fonction, "IDEA", 4) == 0) |
|
{ |
|
# ifdef OPENSSL_NO_IDEA |
|
|
if ((vecteur_initialisation = malloc(longueur_clef * |
free(fonction); |
sizeof(unsigned char))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
memset(vecteur_initialisation, 0, longueur_clef); |
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
if ((tampon = chiffrement(EVP_chiffrement, d_vrai, |
(*s_etat_processus).erreur_execution = |
chaine, longueur_chaine, clef, longueur_clef, |
d_ex_chiffrement_indisponible; |
vecteur_initialisation, longueur_clef, |
return; |
longueur_somme, &longueur_tampon)) == NULL) |
|
|
# else |
|
|
|
if (strcmp(fonction, "IDEA-CBC") == 0) |
|
{ |
|
EVP_chiffrement = EVP_idea_cbc(); |
|
longueur_clef_attendue = 16; |
|
longueur_somme = IDEA_BLOCK; |
|
} |
|
else |
{ |
{ |
free(fonction); |
free(fonction); |
free(vecteur_initialisation); |
|
free(chaine); |
liberation(s_etat_processus, s_objet_argument_1); |
free(clef); |
liberation(s_etat_processus, s_objet_argument_2); |
|
|
(*s_etat_processus).erreur_execution = |
(*s_etat_processus).erreur_execution = |
d_ex_chiffrement; |
d_ex_chiffrement_indisponible; |
return; |
return; |
} |
} |
|
# endif |
|
} |
|
else |
|
{ |
|
free(fonction); |
|
|
free(vecteur_initialisation); |
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_chiffrement_indisponible; |
|
return; |
|
} |
|
|
|
if ((chaine = formateur_flux(s_etat_processus, (unsigned char *) |
|
(*s_objet_argument_2).objet, &longueur_chaine)) == NULL) |
|
{ |
|
free(fonction); |
|
|
|
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
|
return; |
|
} |
|
|
|
l_element_courant = (*s_objet_argument_1).objet; |
|
l_element_courant = (*l_element_courant).suivant; |
|
|
|
if ((clef = formateur_flux(s_etat_processus, (unsigned char *) |
|
(*(*l_element_courant).donnee).objet, &longueur_clef)) |
|
== NULL) |
|
{ |
|
free(fonction); |
free(chaine); |
free(chaine); |
free(clef); |
|
|
|
if ((s_objet_resultat = allocation(s_etat_processus, CHN)) |
liberation(s_etat_processus, s_objet_argument_1); |
== NULL) |
liberation(s_etat_processus, s_objet_argument_2); |
|
return; |
|
} |
|
|
|
if (longueur_clef_attendue != 0) |
|
{ |
|
if (longueur_clef != longueur_clef_attendue) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
free(fonction); |
d_es_allocation_memoire; |
free(chaine); |
|
free(clef); |
|
|
|
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_longueur_clef_chiffrement; |
return; |
return; |
} |
} |
|
} |
if (((*s_objet_resultat).objet = analyse_flux(s_etat_processus, |
else |
&(tampon[longueur_tampon - longueur_somme]), |
{ |
longueur_somme)) == NULL) |
if ((longueur_clef < longueur_clef_min) && |
|
(longueur_clef > longueur_clef_max)) |
{ |
{ |
free(tampon); |
|
free(fonction); |
free(fonction); |
|
free(chaine); |
|
free(clef); |
|
|
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); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_longueur_clef_chiffrement; |
return; |
return; |
} |
} |
|
} |
|
|
free(tampon); |
if ((vecteur_initialisation = malloc(longueur_clef * |
|
sizeof(unsigned char))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
# endif |
memset(vecteur_initialisation, 0, longueur_clef); |
|
|
|
if ((tampon = chiffrement(EVP_chiffrement, d_vrai, |
|
chaine, longueur_chaine, clef, longueur_clef, |
|
vecteur_initialisation, longueur_clef, |
|
longueur_somme, &longueur_tampon)) == NULL) |
|
{ |
|
free(fonction); |
|
free(vecteur_initialisation); |
|
free(chaine); |
|
free(clef); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_chiffrement; |
|
return; |
} |
} |
else |
|
|
free(vecteur_initialisation); |
|
free(chaine); |
|
free(clef); |
|
|
|
if ((s_objet_resultat = allocation(s_etat_processus, CHN)) |
|
== NULL) |
{ |
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (((*s_objet_resultat).objet = analyse_flux(s_etat_processus, |
|
&(tampon[longueur_tampon - longueur_somme]), |
|
longueur_somme)) == NULL) |
|
{ |
|
free(tampon); |
free(fonction); |
free(fonction); |
|
|
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); |
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_chiffrement_indisponible; |
|
return; |
return; |
} |
} |
|
|
|
free(tampon); |
free(fonction); |
free(fonction); |
} |
} |
else |
else |