-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathsecp256k1_ec_privkey_tweak_add_error1.phpt
54 lines (46 loc) · 1.4 KB
/
secp256k1_ec_privkey_tweak_add_error1.phpt
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
--TEST--
secp256k1_ec_privkey_tweak_add errors if invalid values are incorrect size
--SKIPIF--
<?php
if (!extension_loaded("secp256k1")) print "skip extension not loaded";
?>
--FILE--
<?php
$context = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
$chars31 = str_repeat("A", 31);
$chars32 = str_repeat("A", 32);
$chars33 = str_repeat("A", 33);
$chars0 = "";
try {
$result = secp256k1_ec_privkey_tweak_add($context, $chars32, $chars33);
} catch (\Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
$result = secp256k1_ec_privkey_tweak_add($context, $chars32, $chars31);
} catch (\Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
$result = secp256k1_ec_privkey_tweak_add($context, $chars32, $chars32);
echo $result . PHP_EOL;
} catch (\Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
$result = secp256k1_ec_privkey_tweak_add($context, $chars33, $chars32);
} catch (\Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
$result = secp256k1_ec_privkey_tweak_add($context, $chars0, $chars32);
} catch (\Exception $e) {
echo $e->getMessage() . PHP_EOL;
}
?>
--EXPECT--
secp256k1_ec_privkey_tweak_add(): Parameter 3 should be 32 bytes
secp256k1_ec_privkey_tweak_add(): Parameter 3 should be 32 bytes
1
secp256k1_ec_privkey_tweak_add(): Parameter 2 should be 32 bytes
secp256k1_ec_privkey_tweak_add(): Parameter 2 should be 32 bytes