Project

General

Profile

Bug #9659 ยป 003-digest-openssl-md5-use-evp-api.patch

View differences:

ext/digest/md5/md5ossl.c
2 2

  
3 3
#include "md5ossl.h"
4 4

  
5
void
6
MD5_Finish(MD5_CTX *pctx, unsigned char *digest)
5
int
6
rb_digest_md5osslevp_Init(EVP_MD_CTX *pctx)
7 7
{
8
    MD5_Final(digest, pctx);
8
  return EVP_DigestInit_ex(pctx, EVP_md5(), NULL);
9
}
10

  
11
int
12
rb_digest_md5osslevp_Finish(EVP_MD_CTX *pctx, unsigned char *digest)
13
{
14
  /* if EVP_DigestFinal_ex fails, we ignore that */
15
  return EVP_DigestFinal_ex(pctx, digest, NULL);
9 16
}
ext/digest/md5/md5ossl.h
4 4
#define MD5OSSL_H_INCLUDED
5 5

  
6 6
#include <stddef.h>
7
#include <openssl/md5.h>
7
#include <openssl/evp.h>
8 8

  
9
#define MD5_BLOCK_LENGTH	MD5_CBLOCK
9
#define MD5_Init   rb_digest_md5osslevp_Init
10
#define MD5_Update EVP_DigestUpdate
11
#define MD5_Finish rb_digest_md5osslevp_Finish
12
#define MD5_CTX    EVP_MD_CTX
10 13

  
11
void MD5_Finish(MD5_CTX *pctx, unsigned char *digest);
14
/* We should use EVP_MD_size(3) and EVP_MD_block_size(3), but the
15
   advantage of these is that they are flexible across digest
16
   algorithms and we are fixing the digest algorithm here; and these
17
   numbers must be constants because the rb_digest_metadata_t
18
   structure is declared const. Simplest way is to write literals. */
19
#define MD5_BLOCK_LENGTH		64
20
#define MD5_DIGEST_LENGTH		16
21

  
22
int MD5_Init(MD5_CTX *pctx);
23
int MD5_Finish(MD5_CTX *pctx, unsigned char *digest);
12 24

  
13 25
#endif