View | Details | Raw Unified | Return to bug 232218 | Differences between
and this patch

Collapse All | Expand All

(-)sysutils/ori/Makefile (-1 / +1 lines)
Lines 3-9 Link Here
3
3
4
PORTNAME=	ori
4
PORTNAME=	ori
5
PORTVERSION=	0.8.1
5
PORTVERSION=	0.8.1
6
PORTREVISION=	16
6
PORTREVISION=	17
7
CATEGORIES=	sysutils net
7
CATEGORIES=	sysutils net
8
MASTER_SITES=	http://cdn.bitbucket.org/orifs/ori/downloads/
8
MASTER_SITES=	http://cdn.bitbucket.org/orifs/ori/downloads/
9
9
(-)sysutils/ori/files/patch-liboriutil_key.cc (+36 lines)
Line 0 Link Here
1
--- liboriutil/key.cc.orig	2018-10-13 04:39:33 UTC
2
+++ liboriutil/key.cc
3
@@ -131,13 +131,13 @@ PublicKey::verify(const string &blob,
4
                   const string &digest) const
5
 {
6
     int err;
7
-    EVP_MD_CTX ctx;
8
+    EVP_MD_CTX *ctx = EVP_MD_CTX_new();
9
 
10
     assert(x509 != NULL && key != NULL);
11
 
12
-    EVP_VerifyInit(&ctx, EVP_sha256());
13
-    EVP_VerifyUpdate(&ctx, blob.data(), blob.size());
14
-    err = EVP_VerifyFinal(&ctx, (const unsigned char *)digest.data(),
15
+    EVP_VerifyInit(ctx, EVP_sha256());
16
+    EVP_VerifyUpdate(ctx, blob.data(), blob.size());
17
+    err = EVP_VerifyFinal(ctx, (const unsigned char *)digest.data(),
18
                           digest.length(), key);
19
     if (err != 1)
20
     {
21
@@ -185,11 +185,11 @@ PrivateKey::sign(const string &blob) const
22
     int err;
23
     unsigned int sigLen = SIGBUF_LEN;
24
     char sigBuf[SIGBUF_LEN];
25
-    EVP_MD_CTX ctx;
26
+    EVP_MD_CTX *ctx = NULL;
27
 
28
-    EVP_SignInit(&ctx, EVP_sha256());
29
-    EVP_SignUpdate(&ctx, blob.data(), blob.size());
30
-    err = EVP_SignFinal(&ctx, (unsigned char *)sigBuf, &sigLen, key);
31
+    EVP_SignInit(ctx, EVP_sha256());
32
+    EVP_SignUpdate(ctx, blob.data(), blob.size());
33
+    err = EVP_SignFinal(ctx, (unsigned char *)sigBuf, &sigLen, key);
34
     if (err != 1)
35
     {
36
         ERR_print_errors_fp(stderr);
(-)sysutils/ori/files/patch-liboriutil_oricrypt.cc (+64 lines)
Line 0 Link Here
1
--- liboriutil/oricrypt.cc.orig	2018-10-13 04:42:24 UTC
2
+++ liboriutil/oricrypt.cc
3
@@ -155,12 +155,12 @@ OriCrypt_Encrypt(const string &plaintext, const string
4
     unsigned char keyData[32];
5
     unsigned char ivData[32];
6
     unsigned char *buf;
7
-    EVP_CIPHER_CTX ctx;
8
+    EVP_CIPHER_CTX *ctx = NULL;
9
     string ciphertext;
10
 
11
     // Generate random salt and prepend it
12
     // XXX: PKCS#5 implementation in OpenSSL uses RAND_pseudo_bytes
13
-    RAND_pseudo_bytes(salt, PKCS5_SALT_LEN);
14
+    RAND_bytes(salt, PKCS5_SALT_LEN);
15
     ciphertext.assign((const char *)&salt, PKCS5_SALT_LEN);
16
 
17
     bits = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha256(), salt,
18
@@ -173,13 +173,13 @@ OriCrypt_Encrypt(const string &plaintext, const string
19
     clen = plaintext.size() + AES_BLOCK_SIZE;
20
     buf = new unsigned char[clen];
21
 
22
-    EVP_CIPHER_CTX_init(&ctx);
23
-    EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, keyData, ivData);
24
-    EVP_EncryptUpdate(&ctx, buf, &clen,
25
+    EVP_CIPHER_CTX_init(ctx);
26
+    EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, keyData, ivData);
27
+    EVP_EncryptUpdate(ctx, buf, &clen,
28
                       (const unsigned char *)plaintext.data(),
29
                       plaintext.size());
30
-    EVP_EncryptFinal_ex(&ctx, buf+clen, &flen);
31
-    EVP_CIPHER_CTX_cleanup(&ctx);
32
+    EVP_EncryptFinal_ex(ctx, buf+clen, &flen);
33
+    EVP_CIPHER_CTX_free(ctx);
34
 
35
     ciphertext.append((const char *)buf, clen+flen);
36
     delete buf;
37
@@ -199,7 +199,7 @@ OriCrypt_Decrypt(const string &ciphertext, const strin
38
     unsigned char keyData[32];
39
     unsigned char ivData[32];
40
     unsigned char *buf;
41
-    EVP_CIPHER_CTX ctx;
42
+    EVP_CIPHER_CTX *ctx = NULL;
43
     string plaintext;
44
 
45
     if (ciphertext.size() <= PKCS5_SALT_LEN)
46
@@ -217,13 +217,13 @@ OriCrypt_Decrypt(const string &ciphertext, const strin
47
     plen = ciphertext.size() + AES_BLOCK_SIZE;
48
     buf = new unsigned char[plen];
49
 
50
-    EVP_CIPHER_CTX_init(&ctx);
51
-    EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, keyData, ivData);
52
-    EVP_DecryptUpdate(&ctx, buf, &plen,
53
+    EVP_CIPHER_CTX_init(ctx);
54
+    EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, keyData, ivData);
55
+    EVP_DecryptUpdate(ctx, buf, &plen,
56
                       (const unsigned char *)ciphertext.data() + PKCS5_SALT_LEN,
57
                       ciphertext.size() - PKCS5_SALT_LEN);
58
-    EVP_DecryptFinal_ex(&ctx, buf+plen, &flen);
59
-    EVP_CIPHER_CTX_cleanup(&ctx);
60
+    EVP_DecryptFinal_ex(ctx, buf+plen, &flen);
61
+    EVP_CIPHER_CTX_free(ctx);
62
 
63
     plaintext.assign((const char *)buf, plen+flen);
64
     delete buf;

Return to bug 232218