version 1.1, 2010/03/04 18:30:46
|
version 1.11, 2017/01/18 15:44:16
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.12 |
RPL/2 (R) version 4.1.26 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2017 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 30
|
Line 30
|
int |
int |
main(int argc, char *argv[]) |
main(int argc, char *argv[]) |
{ |
{ |
EVP_MD_CTX contexte; |
EVP_MD_CTX *contexte; |
|
|
int in_fd; |
int in_fd; |
|
|
Line 58 main(int argc, char *argv[])
|
Line 58 main(int argc, char *argv[])
|
|
|
if (stat(fichier, &stat_buf) != 0) |
if (stat(fichier, &stat_buf) != 0) |
{ |
{ |
|
fprintf(stderr, "stat() failed\n"); |
|
perror("stat"); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
Line 65 main(int argc, char *argv[])
|
Line 67 main(int argc, char *argv[])
|
|
|
if ((chaine = malloc(taille_fichier)) == NULL) |
if ((chaine = malloc(taille_fichier)) == NULL) |
{ |
{ |
|
fprintf(stderr, "malloc() failed\n"); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
if ((in_fd = open(fichier, 0, O_RDONLY)) < 0) |
if ((in_fd = open(fichier, 0, O_RDONLY)) < 0) |
{ |
{ |
|
fprintf(stderr, "open() failed\n"); |
|
perror("open"); |
free(chaine); |
free(chaine); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
if ((octets_lus = read(in_fd, chaine, taille_fichier)) != taille_fichier) |
if ((octets_lus = read(in_fd, chaine, taille_fichier)) != taille_fichier) |
{ |
{ |
|
# ifndef OS2 |
|
// Sur des fichiers binaires et sous OS/2, le nombre d'octets lus peut |
|
// être inférieur à la taille du fichier sur le disque. |
|
|
|
fprintf(stderr, "read() failed\n"); |
|
fprintf(stderr, "Meditation: %d < %d\n", (int) octets_lus, |
|
(int) taille_fichier); |
|
perror("read"); |
close(in_fd); |
close(in_fd); |
free(chaine); |
free(chaine); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
|
# endif |
} |
} |
|
|
close(in_fd); |
close(in_fd); |
|
|
if (EVP_DigestInit(&contexte, EVP_sum()) != 1) |
if ((contexte = EVP_MD_CTX_new()) == NULL) |
{ |
{ |
|
fprintf(stderr, "EVP_MD_CTX_new() failed\n"); |
close(in_fd); |
close(in_fd); |
free(chaine); |
free(chaine); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
if (EVP_DigestUpdate(&contexte, chaine, taille_fichier) != 1) |
if (EVP_DigestInit(contexte, EVP_sum()) != 1) |
{ |
{ |
|
fprintf(stderr, "EVP_DigestInit() failed\n"); |
|
EVP_MD_CTX_free(contexte); |
close(in_fd); |
close(in_fd); |
free(chaine); |
free(chaine); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
if (EVP_DigestFinal_ex(&contexte, somme, &longueur_somme) != 1) |
if (EVP_DigestUpdate(contexte, chaine, taille_fichier) != 1) |
{ |
{ |
|
fprintf(stderr, "EVP_DigestUpdate() failed\n"); |
|
EVP_MD_CTX_free(contexte); |
close(in_fd); |
close(in_fd); |
free(chaine); |
free(chaine); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
EVP_MD_CTX_cleanup(&contexte); |
if (EVP_DigestFinal_ex(contexte, somme, &longueur_somme) != 1) |
|
{ |
|
fprintf(stderr, "EVP_DigestFinal_ex() failed\n"); |
|
EVP_MD_CTX_free(contexte); |
|
close(in_fd); |
|
free(chaine); |
|
exit(EXIT_FAILURE); |
|
} |
|
|
|
EVP_MD_CTX_free(contexte); |
free(chaine); |
free(chaine); |
|
|
for(i = 0; i < longueur_somme; i++) |
for(i = 0; i < longueur_somme; i++) |