Mercurial > hg > php_nacl
annotate nacl.c @ 5:df71d49a6f98
Fixes to support crypto_sign_edwards25519sha512batch
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Fri, 18 Mar 2011 17:41:40 +0100 |
parents | 81aaf4ba1eaa |
children | ded86f4d6275 |
rev | line source |
---|---|
0 | 1 /* Copyright 2010 Ivo Smits <Ivo@UCIS.nl>. All rights reserved. |
2 Redistribution and use in source and binary forms, with or without modification, are | |
3 permitted provided that the following conditions are met: | |
4 | |
5 1. Redistributions of source code must retain the above copyright notice, this list of | |
6 conditions and the following disclaimer. | |
7 | |
8 2. Redistributions in binary form must reproduce the above copyright notice, this list | |
9 of conditions and the following disclaimer in the documentation and/or other materials | |
10 provided with the distribution. | |
11 | |
12 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
13 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
14 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR | |
15 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
16 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
17 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |
18 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
19 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
20 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
21 | |
22 The views and conclusions contained in the software and documentation are those of the | |
23 authors and should not be interpreted as representing official policies, either expressed | |
24 or implied, of Ivo Smits.*/ | |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 #include "config.h" | |
28 #endif | |
2
04384d01b1d7
Added build script, changed header location
Ivo Smits <Ivo@UCIS.nl>
parents:
1
diff
changeset
|
29 |
04384d01b1d7
Added build script, changed header location
Ivo Smits <Ivo@UCIS.nl>
parents:
1
diff
changeset
|
30 #include "nacl/crypto_box_curve25519xsalsa20poly1305.h" |
04384d01b1d7
Added build script, changed header location
Ivo Smits <Ivo@UCIS.nl>
parents:
1
diff
changeset
|
31 #include "nacl/crypto_scalarmult_curve25519.h" |
5
df71d49a6f98
Fixes to support crypto_sign_edwards25519sha512batch
Ivo Smits <Ivo@UCIS.nl>
parents:
4
diff
changeset
|
32 #include "nacl/crypto_sign_edwards25519sha512batch.h" |
0 | 33 |
34 #include "php.h" | |
35 #include "php_ini.h" | |
36 #include "php_nacl.h" | |
37 | |
38 static function_entry nacl_functions[] = { | |
4
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
39 PHP_FE(nacl_crypto_box_curve25519xsalsa20poly1305, NULL) |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
40 PHP_FE(nacl_crypto_box_curve25519xsalsa20poly1305_open, NULL) |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
41 PHP_FE(nacl_crypto_box_curve25519xsalsa20poly1305_getpublickey, NULL) |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
42 PHP_FE(nacl_crypto_box_curve25519xsalsa20poly1305_beforenm, NULL) |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
43 PHP_FE(nacl_crypto_box_curve25519xsalsa20poly1305_afternm, NULL) |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
44 PHP_FE(nacl_crypto_box_curve25519xsalsa20poly1305_open_afternm, NULL) |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
45 PHP_FE(nacl_crypto_sign_edwards25519sha512batch, NULL) |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
46 PHP_FE(nacl_crypto_sign_edwards25519sha512batch_open, NULL) |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
47 // PHP_FE(nacl_crypto_sign_edwards25519sha512batch_keypair, NULL) |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
48 {NULL, NULL, NULL} |
0 | 49 }; |
50 | |
51 zend_module_entry nacl_module_entry = { | |
52 #if ZEND_MODULE_API_NO >= 20010901 | |
53 STANDARD_MODULE_HEADER, | |
54 #endif | |
55 PHP_NACL_EXTNAME, | |
56 nacl_functions, | |
57 PHP_MINIT(nacl), | |
58 NULL, | |
59 NULL, | |
60 NULL, | |
61 NULL, | |
62 #if ZEND_MODULE_API_NO >= 20010901 | |
63 PHP_NACL_VERSION, | |
64 #endif | |
65 STANDARD_MODULE_PROPERTIES | |
66 }; | |
67 | |
68 #ifdef COMPILE_DL_NACL | |
69 ZEND_GET_MODULE(nacl) | |
70 #endif | |
71 | |
72 PHP_MINIT_FUNCTION(nacl) { | |
73 REGISTER_LONG_CONSTANT("NACL_CRYPTO_BOX_curve25519xsalsa20poly1305_PUBLICKEYBYTES", crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES, CONST_CS | CONST_PERSISTENT); | |
74 REGISTER_LONG_CONSTANT("NACL_CRYPTO_BOX_curve25519xsalsa20poly1305_SECRETKEYBYTES", crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES, CONST_CS | CONST_PERSISTENT); | |
75 REGISTER_LONG_CONSTANT("NACL_CRYPTO_BOX_curve25519xsalsa20poly1305_BEFORENMBYTES", crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES, CONST_CS | CONST_PERSISTENT); | |
76 REGISTER_LONG_CONSTANT("NACL_CRYPTO_BOX_curve25519xsalsa20poly1305_NONCEBYTES", crypto_box_curve25519xsalsa20poly1305_NONCEBYTES, CONST_CS | CONST_PERSISTENT); | |
77 REGISTER_LONG_CONSTANT("NACL_CRYPTO_BOX_curve25519xsalsa20poly1305_ZEROBYTES", crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, CONST_CS | CONST_PERSISTENT); | |
78 REGISTER_LONG_CONSTANT("NACL_CRYPTO_BOX_curve25519xsalsa20poly1305_BOXZEROBYTES", crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES, CONST_CS | CONST_PERSISTENT); | |
4
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
79 REGISTER_LONG_CONSTANT("NACL_CRYPTO_SIGN_edwards25519sha512batch_BYTES", crypto_sign_edwards25519sha512batch_BYTES, CONST_CS | CONST_PERSISTENT); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
80 REGISTER_LONG_CONSTANT("NACL_CRYPTO_SIGN_edwards25519sha512batch_PUBLICKEYBYTES", crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES, CONST_CS | CONST_PERSISTENT); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
81 REGISTER_LONG_CONSTANT("NACL_CRYPTO_SIGN_edwards25519sha512batch_SECRETKEYBYTES", crypto_sign_edwards25519sha512batch_SECRETKEYBYTES, CONST_CS | CONST_PERSISTENT); |
0 | 82 } |
83 | |
84 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305) { //(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *) | |
85 char *m, *n, *pk, *sk; | |
86 int lm, ln, lpk, lsk; | |
1
84e0f7ead583
Changed the order of function arguments to match those of the original code
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
87 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssss", &m, &lm, &n, &ln, &pk, &lpk, &sk, &lsk) == FAILURE) RETURN_NULL(); |
0 | 88 if (ln != crypto_box_curve25519xsalsa20poly1305_NONCEBYTES) RETURN_FALSE; |
89 if (lpk != crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES) RETURN_FALSE; | |
90 if (lsk != crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES) RETURN_FALSE; | |
91 int mlen = lm + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES; | |
92 char* mb = ecalloc(mlen, 1); | |
93 char* cb = ecalloc(mlen, 1); | |
94 memcpy(mb + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, m, lm); | |
95 int ret = crypto_box_curve25519xsalsa20poly1305(cb, mb, mlen, n, pk, sk); | |
96 int clen = mlen - crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES; | |
97 char* c = emalloc(clen); | |
98 memcpy(c, cb + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES, clen); | |
99 efree(mb); | |
100 efree(cb); | |
101 if (ret == 0) RETURN_STRINGL(c, clen, 0); | |
102 efree(c); | |
103 RETURN_FALSE; | |
104 } | |
105 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305_open) { //(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *) | |
106 char *c, *n, *pk, *sk; | |
107 int lc, ln, lpk, lsk; | |
1
84e0f7ead583
Changed the order of function arguments to match those of the original code
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
108 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssss", &c, &lc, &n, &ln, &pk, &lpk, &sk, &lsk) == FAILURE) RETURN_NULL(); |
0 | 109 if (ln != crypto_box_curve25519xsalsa20poly1305_NONCEBYTES) RETURN_FALSE; |
110 if (lpk != crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES) RETURN_FALSE; | |
111 if (lsk != crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES) RETURN_FALSE; | |
112 int clen = lc + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES; | |
113 char* mb = ecalloc(clen, 1); | |
114 char* cb = ecalloc(clen, 1); | |
115 memcpy(cb + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES, c, lc); | |
116 int ret = crypto_box_curve25519xsalsa20poly1305_open(mb, cb, clen, n, pk, sk); | |
117 int mlen = clen - crypto_box_curve25519xsalsa20poly1305_ZEROBYTES; | |
118 char* m = emalloc(mlen); | |
119 memcpy(m, mb + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, mlen); | |
120 efree(mb); | |
121 efree(cb); | |
122 if (ret == 0) RETURN_STRINGL(m, mlen, 0); | |
123 efree(m); | |
124 RETURN_FALSE; | |
125 } | |
126 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305_beforenm) { //(unsigned char *,const unsigned char *,const unsigned char *) | |
127 char *pk, *sk; | |
128 int lpk, lsk; | |
129 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &pk, &lpk, &sk, &lsk) == FAILURE) RETURN_NULL(); | |
130 if (lpk != crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES) RETURN_FALSE; | |
131 if (lsk != crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES) RETURN_FALSE; | |
132 char* k = emalloc(crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES); | |
133 crypto_box_curve25519xsalsa20poly1305_beforenm(k, pk, sk); | |
134 RETURN_STRINGL(k, crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES, 0); | |
135 } | |
136 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305_afternm) { //(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *) | |
137 char *m, *n, *k; | |
138 int lm, ln, lk; | |
1
84e0f7ead583
Changed the order of function arguments to match those of the original code
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
139 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &m, &lm, &n, &ln, &k, &lk) == FAILURE) RETURN_NULL(); |
0 | 140 if (ln != crypto_box_curve25519xsalsa20poly1305_NONCEBYTES) RETURN_FALSE; |
141 if (lk != crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES) RETURN_FALSE; | |
142 int mlen = lm + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES; | |
143 char* mb = ecalloc(mlen, 1); | |
144 char* cb = ecalloc(mlen, 1); | |
145 memcpy(mb + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, m, lm); | |
146 int ret = crypto_box_curve25519xsalsa20poly1305_afternm(cb, mb, mlen, n, k); | |
147 int clen = mlen - crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES; | |
148 char* c = emalloc(clen); | |
149 memcpy(c, cb + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES, clen); | |
150 efree(mb); | |
151 efree(cb); | |
152 if (ret == 0) RETURN_STRINGL(c, clen, 0); | |
153 efree(c); | |
154 RETURN_FALSE; | |
155 } | |
156 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305_open_afternm) { //(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *) | |
157 char *c, *n, *k; | |
158 int lc, ln, lk; | |
1
84e0f7ead583
Changed the order of function arguments to match those of the original code
Ivo Smits <Ivo@UCIS.nl>
parents:
0
diff
changeset
|
159 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &c, &lc, &n, &ln, &k, &lk) == FAILURE) RETURN_NULL(); |
0 | 160 if (ln != crypto_box_curve25519xsalsa20poly1305_NONCEBYTES) RETURN_FALSE; |
161 if (lk != crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES) RETURN_FALSE; | |
162 int clen = lc + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES; | |
163 char* mb = ecalloc(clen, 1); | |
164 char* cb = ecalloc(clen, 1); | |
165 memcpy(cb + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES, c, lc); | |
166 int ret = crypto_box_curve25519xsalsa20poly1305_open_afternm(mb, cb, clen, n, k); | |
167 int mlen = clen - crypto_box_curve25519xsalsa20poly1305_ZEROBYTES; | |
168 char* m = emalloc(mlen); | |
169 memcpy(m, mb + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, mlen); | |
170 efree(mb); | |
171 efree(cb); | |
172 if (ret == 0) RETURN_STRINGL(m, mlen, 0); | |
173 efree(m); | |
174 RETURN_FALSE; | |
175 } | |
176 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305_getpublickey) { | |
177 char base[32] = {9}; | |
178 char *sk; | |
179 int lsk; | |
180 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &sk, &lsk) == FAILURE) RETURN_NULL(); | |
181 if (lsk != crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES) RETURN_FALSE; | |
182 char* pk = emalloc(crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES); | |
183 crypto_scalarmult_curve25519(pk, sk, base); | |
184 RETURN_STRINGL(pk, crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES, 0); | |
185 } | |
4
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
186 PHP_FUNCTION(nacl_crypto_sign_edwards25519sha512batch) { //(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
187 char *m, *sk; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
188 int lm, lsk; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
189 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &m, &lm, &sk, &lsk) == FAILURE) RETURN_NULL(); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
190 if (lsk != crypto_sign_edwards25519sha512batch_SECRETKEYBYTES) RETURN_FALSE; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
191 int smlen = lm + crypto_sign_edwards25519sha512batch_BYTES; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
192 char* smb = emalloc(smlen); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
193 int ret = crypto_sign_edwards25519sha512batch(smb, &smlen, m, lm, sk); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
194 char* sm = emalloc(smlen); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
195 memcpy(sm, smb, smlen); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
196 efree(smb); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
197 if (ret == 0) RETURN_STRINGL(sm, smlen, 0); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
198 efree(sm); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
199 RETURN_FALSE; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
200 } |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
201 PHP_FUNCTION(nacl_crypto_sign_edwards25519sha512batch_open) { //(unsigned char *,unsigned long long *,const unsigned char *,unsigned long long,const unsigned char *); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
202 char *sm, *pk; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
203 int lsm, lpk; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
204 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &sm, &lsm, &pk, &lpk) == FAILURE) RETURN_NULL(); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
205 if (lpk != crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES) RETURN_FALSE; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
206 int mlen = lsm; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
207 char* mb = emalloc(mlen); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
208 int ret = crypto_sign_edwards25519sha512batch_open(mb, &mlen, sm, lsm, pk); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
209 char* m = emalloc(mlen); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
210 memcpy(m, mb, mlen); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
211 efree(mb); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
212 if (ret == 0) RETURN_STRINGL(m, mlen, 0); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
213 efree(m); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
214 RETURN_FALSE; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
215 } |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
216 //extern int crypto_sign_edwards25519sha512batch_ref_keypair(unsigned char *,unsigned char *); |