summaryrefslogtreecommitdiffstats
path: root/crypto-upstream.patch
blob: b7b010b7c78029a828d88f32bdc89fb44c3fe554 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
From ee493a2737fd29a8ff8c8e3dec7c6fa46822ef05 Mon Sep 17 00:00:00 2001
From: Jakub Zelenka <bukka@php.net>
Date: Wed, 6 Jan 2016 14:40:54 +0000
Subject: [PATCH] Split name codes for Hash and MAC alg not found

It prevents constant redefinition error
---
 crypto_hash.c                     | 8 ++++----
 tests/CMAC___construct_basic.phpt | 2 +-
 tests/HMAC___construct_basic.phpt | 2 +-
 tests/Hash___construct_basic.phpt | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/crypto_hash.c b/crypto_hash.c
index 7fc0ded..2ce172a 100644
--- a/crypto_hash.c
+++ b/crypto_hash.c
@@ -29,7 +29,7 @@
 PHP_CRYPTO_EXCEPTION_DEFINE(Hash)
 PHP_CRYPTO_ERROR_INFO_BEGIN(Hash)
 PHP_CRYPTO_ERROR_INFO_ENTRY(
-	ALGORITHM_NOT_FOUND,
+	HASH_ALGORITHM_NOT_FOUND,
 	"Hash algorithm '%s' not found"
 )
 PHP_CRYPTO_ERROR_INFO_ENTRY(
@@ -134,7 +134,7 @@ static const zend_function_entry php_crypto_hash_object_methods[] = {
 PHP_CRYPTO_EXCEPTION_DEFINE(MAC)
 PHP_CRYPTO_ERROR_INFO_BEGIN(MAC)
 PHP_CRYPTO_ERROR_INFO_ENTRY(
-	ALGORITHM_NOT_FOUND,
+	MAC_ALGORITHM_NOT_FOUND,
 	"MAC algorithm '%s' not found"
 )
 PHP_CRYPTO_ERROR_INFO_ENTRY(
@@ -609,7 +609,7 @@ PHP_CRYPTO_METHOD(Hash, __construct)
 
 	digest = EVP_get_digestbyname(algorithm);
 	if (!digest) {
-		php_crypto_error_ex(PHP_CRYPTO_ERROR_ARGS(Hash, ALGORITHM_NOT_FOUND), algorithm);
+		php_crypto_error_ex(PHP_CRYPTO_ERROR_ARGS(Hash, HASH_ALGORITHM_NOT_FOUND), algorithm);
 	} else {
 		PHP_CRYPTO_HASH_ALG(PHPC_THIS) = digest;
 	}
@@ -787,6 +787,6 @@ PHP_CRYPTO_METHOD(MAC, __construct)
 	return;
 
 php_crypto_mac_alg_not_found:
-	php_crypto_error_ex(PHP_CRYPTO_ERROR_ARGS(MAC, ALGORITHM_NOT_FOUND), algorithm);
+	php_crypto_error_ex(PHP_CRYPTO_ERROR_ARGS(MAC, MAC_ALGORITHM_NOT_FOUND), algorithm);
 	efree(algorithm_uc);
 }
diff --git a/tests/CMAC___construct_basic.phpt b/tests/CMAC___construct_basic.phpt
index abd58a3..77a66c6 100644
--- a/tests/CMAC___construct_basic.phpt
+++ b/tests/CMAC___construct_basic.phpt
@@ -28,7 +28,7 @@ try {
 	$cmac = new Crypto\CMAC($key, 'nnn');
 }
 catch (Crypto\MACException $e) {
-	if ($e->getCode() === Crypto\MACException::ALGORITHM_NOT_FOUND) {
+	if ($e->getCode() === Crypto\MACException::MAC_ALGORITHM_NOT_FOUND) {
 		echo "NOT FOUND\n";
 	}
 }
diff --git a/tests/HMAC___construct_basic.phpt b/tests/HMAC___construct_basic.phpt
index 09a4d11..0200091 100644
--- a/tests/HMAC___construct_basic.phpt
+++ b/tests/HMAC___construct_basic.phpt
@@ -11,7 +11,7 @@ try {
 	$hmac = new Crypto\HMAC('key', 'nnn');
 }
 catch (Crypto\MACException $e) {
-	if ($e->getCode() === Crypto\MACException::ALGORITHM_NOT_FOUND) {
+	if ($e->getCode() === Crypto\MACException::MAC_ALGORITHM_NOT_FOUND) {
 		echo "NOT FOUND\n";
 	}
 }
diff --git a/tests/Hash___construct_basic.phpt b/tests/Hash___construct_basic.phpt
index 0755703..ac8b0f5 100644
--- a/tests/Hash___construct_basic.phpt
+++ b/tests/Hash___construct_basic.phpt
@@ -11,7 +11,7 @@ try {
 	$hash = new Crypto\Hash('nnn');	
 }
 catch (Crypto\HashException $e) {
-	if ($e->getCode() === Crypto\HashException::ALGORITHM_NOT_FOUND) {
+	if ($e->getCode() === Crypto\HashException::HASH_ALGORITHM_NOT_FOUND) {
 		echo "NOT FOUND\n";
 	}
 }