~ubuntu-branches/ubuntu/saucy/clamav/saucy-backports

« back to all changes in this revision

Viewing changes to shared/cdiff.c

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-07-15 01:08:10 UTC
  • mfrom: (0.35.47 sid)
  • Revision ID: package-import@ubuntu.com-20140715010810-ru66ek4fun2iseba
Tags: 0.98.4+dfsg-2~ubuntu13.10.1
No-change backport to saucy (LP: #1341962)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <unistd.h>
33
33
#endif
34
34
 
 
35
#include <openssl/ssl.h>
 
36
#include <openssl/err.h>
 
37
#include "libclamav/crypto.h"
 
38
 
35
39
#include "shared/misc.h"
36
40
#include "shared/output.h"
37
41
#include "shared/cdiff.h"
38
 
#include "libclamav/sha256.h"
39
42
 
40
43
#include "libclamav/str.h"
41
44
#include "libclamav/others.h"
764
767
        int end, i, n;
765
768
        struct stat sb;
766
769
        int desc;
767
 
        SHA256_CTX sha256ctx;
 
770
        EVP_MD_CTX *sha256ctx;
768
771
        unsigned char digest[32];
769
772
        int sum, bread;
770
773
#define DSIGBUFF 350
848
851
            return -1;
849
852
        }
850
853
 
851
 
        sha256_init(&sha256ctx);
 
854
    sha256ctx = EVP_MD_CTX_create();
 
855
    if (!(sha256ctx)) {
 
856
        close(desc);
 
857
        free(line);
 
858
        free(lbuf);
 
859
        return -1;
 
860
    }
 
861
 
 
862
        EVP_DigestInit_ex(sha256ctx, EVP_sha256(), NULL);
852
863
        sum = 0;
853
864
        while((bread = read(desc, buff, FILEBUFF)) > 0) {
854
865
            if(sum + bread >= end) {
855
 
                sha256_update(&sha256ctx, (unsigned char *) buff, end - sum);
 
866
                EVP_DigestUpdate(sha256ctx, (unsigned char *) buff, end - sum);
856
867
                break;
857
868
            } else {
858
 
                sha256_update(&sha256ctx, (unsigned char *) buff, bread);
 
869
                EVP_DigestUpdate(sha256ctx, (unsigned char *) buff, bread);
859
870
            }
860
871
            sum += bread;
861
872
        }
862
 
        sha256_final(&sha256ctx, digest);
 
873
        EVP_DigestFinal_ex(sha256ctx, digest, NULL);
 
874
    EVP_MD_CTX_destroy(sha256ctx);
863
875
 
864
876
        if(cli_versig2(digest, dsig, PSS_NSTR, PSS_ESTR) != CL_SUCCESS) {
865
877
            logg("!cdiff_apply: Incorrect digital signature\n");