Mercurial > hg > php_nacl
annotate nacl.c @ 4:81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Fri, 18 Mar 2011 16:58:48 +0100 |
parents | 04384d01b1d7 |
children | df71d49a6f98 |
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" |
0 | 32 |
33 #include "php.h" | |
34 #include "php_ini.h" | |
35 #include "php_nacl.h" | |
36 | |
37 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
|
38 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
|
39 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
|
40 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 // 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
|
47 {NULL, NULL, NULL} |
0 | 48 }; |
49 | |
50 zend_module_entry nacl_module_entry = { | |
51 #if ZEND_MODULE_API_NO >= 20010901 | |
52 STANDARD_MODULE_HEADER, | |
53 #endif | |
54 PHP_NACL_EXTNAME, | |
55 nacl_functions, | |
56 PHP_MINIT(nacl), | |
57 NULL, | |
58 NULL, | |
59 NULL, | |
60 NULL, | |
61 #if ZEND_MODULE_API_NO >= 20010901 | |
62 PHP_NACL_VERSION, | |
63 #endif | |
64 STANDARD_MODULE_PROPERTIES | |
65 }; | |
66 | |
67 #ifdef COMPILE_DL_NACL | |
68 ZEND_GET_MODULE(nacl) | |
69 #endif | |
70 | |
71 PHP_MINIT_FUNCTION(nacl) { | |
72 REGISTER_LONG_CONSTANT("NACL_CRYPTO_BOX_curve25519xsalsa20poly1305_PUBLICKEYBYTES", crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES, CONST_CS | CONST_PERSISTENT); | |
73 REGISTER_LONG_CONSTANT("NACL_CRYPTO_BOX_curve25519xsalsa20poly1305_SECRETKEYBYTES", crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES, CONST_CS | CONST_PERSISTENT); | |
74 REGISTER_LONG_CONSTANT("NACL_CRYPTO_BOX_curve25519xsalsa20poly1305_BEFORENMBYTES", crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES, CONST_CS | CONST_PERSISTENT); | |
75 REGISTER_LONG_CONSTANT("NACL_CRYPTO_BOX_curve25519xsalsa20poly1305_NONCEBYTES", crypto_box_curve25519xsalsa20poly1305_NONCEBYTES, CONST_CS | CONST_PERSISTENT); | |
76 REGISTER_LONG_CONSTANT("NACL_CRYPTO_BOX_curve25519xsalsa20poly1305_ZEROBYTES", crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, CONST_CS | CONST_PERSISTENT); | |
77 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
|
78 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
|
79 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
|
80 REGISTER_LONG_CONSTANT("NACL_CRYPTO_SIGN_edwards25519sha512batch_SECRETKEYBYTES", crypto_sign_edwards25519sha512batch_SECRETKEYBYTES, CONST_CS | CONST_PERSISTENT); |
0 | 81 } |
82 | |
83 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305) { //(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *) | |
84 char *m, *n, *pk, *sk; | |
85 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
|
86 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssss", &m, &lm, &n, &ln, &pk, &lpk, &sk, &lsk) == FAILURE) RETURN_NULL(); |
0 | 87 if (ln != crypto_box_curve25519xsalsa20poly1305_NONCEBYTES) RETURN_FALSE; |
88 if (lpk != crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES) RETURN_FALSE; | |
89 if (lsk != crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES) RETURN_FALSE; | |
90 int mlen = lm + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES; | |
91 char* mb = ecalloc(mlen, 1); | |
92 char* cb = ecalloc(mlen, 1); | |
93 memcpy(mb + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, m, lm); | |
94 int ret = crypto_box_curve25519xsalsa20poly1305(cb, mb, mlen, n, pk, sk); | |
95 int clen = mlen - crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES; | |
96 char* c = emalloc(clen); | |
97 memcpy(c, cb + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES, clen); | |
98 efree(mb); | |
99 efree(cb); | |
100 if (ret == 0) RETURN_STRINGL(c, clen, 0); | |
101 efree(c); | |
102 RETURN_FALSE; | |
103 } | |
104 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305_open) { //(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *,const unsigned char *) | |
105 char *c, *n, *pk, *sk; | |
106 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
|
107 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssss", &c, &lc, &n, &ln, &pk, &lpk, &sk, &lsk) == FAILURE) RETURN_NULL(); |
0 | 108 if (ln != crypto_box_curve25519xsalsa20poly1305_NONCEBYTES) RETURN_FALSE; |
109 if (lpk != crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES) RETURN_FALSE; | |
110 if (lsk != crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES) RETURN_FALSE; | |
111 int clen = lc + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES; | |
112 char* mb = ecalloc(clen, 1); | |
113 char* cb = ecalloc(clen, 1); | |
114 memcpy(cb + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES, c, lc); | |
115 int ret = crypto_box_curve25519xsalsa20poly1305_open(mb, cb, clen, n, pk, sk); | |
116 int mlen = clen - crypto_box_curve25519xsalsa20poly1305_ZEROBYTES; | |
117 char* m = emalloc(mlen); | |
118 memcpy(m, mb + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, mlen); | |
119 efree(mb); | |
120 efree(cb); | |
121 if (ret == 0) RETURN_STRINGL(m, mlen, 0); | |
122 efree(m); | |
123 RETURN_FALSE; | |
124 } | |
125 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305_beforenm) { //(unsigned char *,const unsigned char *,const unsigned char *) | |
126 char *pk, *sk; | |
127 int lpk, lsk; | |
128 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &pk, &lpk, &sk, &lsk) == FAILURE) RETURN_NULL(); | |
129 if (lpk != crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES) RETURN_FALSE; | |
130 if (lsk != crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES) RETURN_FALSE; | |
131 char* k = emalloc(crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES); | |
132 crypto_box_curve25519xsalsa20poly1305_beforenm(k, pk, sk); | |
133 RETURN_STRINGL(k, crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES, 0); | |
134 } | |
135 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305_afternm) { //(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *) | |
136 char *m, *n, *k; | |
137 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
|
138 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &m, &lm, &n, &ln, &k, &lk) == FAILURE) RETURN_NULL(); |
0 | 139 if (ln != crypto_box_curve25519xsalsa20poly1305_NONCEBYTES) RETURN_FALSE; |
140 if (lk != crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES) RETURN_FALSE; | |
141 int mlen = lm + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES; | |
142 char* mb = ecalloc(mlen, 1); | |
143 char* cb = ecalloc(mlen, 1); | |
144 memcpy(mb + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, m, lm); | |
145 int ret = crypto_box_curve25519xsalsa20poly1305_afternm(cb, mb, mlen, n, k); | |
146 int clen = mlen - crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES; | |
147 char* c = emalloc(clen); | |
148 memcpy(c, cb + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES, clen); | |
149 efree(mb); | |
150 efree(cb); | |
151 if (ret == 0) RETURN_STRINGL(c, clen, 0); | |
152 efree(c); | |
153 RETURN_FALSE; | |
154 } | |
155 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305_open_afternm) { //(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *) | |
156 char *c, *n, *k; | |
157 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
|
158 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &c, &lc, &n, &ln, &k, &lk) == FAILURE) RETURN_NULL(); |
0 | 159 if (ln != crypto_box_curve25519xsalsa20poly1305_NONCEBYTES) RETURN_FALSE; |
160 if (lk != crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES) RETURN_FALSE; | |
161 int clen = lc + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES; | |
162 char* mb = ecalloc(clen, 1); | |
163 char* cb = ecalloc(clen, 1); | |
164 memcpy(cb + crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES, c, lc); | |
165 int ret = crypto_box_curve25519xsalsa20poly1305_open_afternm(mb, cb, clen, n, k); | |
166 int mlen = clen - crypto_box_curve25519xsalsa20poly1305_ZEROBYTES; | |
167 char* m = emalloc(mlen); | |
168 memcpy(m, mb + crypto_box_curve25519xsalsa20poly1305_ZEROBYTES, mlen); | |
169 efree(mb); | |
170 efree(cb); | |
171 if (ret == 0) RETURN_STRINGL(m, mlen, 0); | |
172 efree(m); | |
173 RETURN_FALSE; | |
174 } | |
175 PHP_FUNCTION(nacl_crypto_box_curve25519xsalsa20poly1305_getpublickey) { | |
176 char base[32] = {9}; | |
177 char *sk; | |
178 int lsk; | |
179 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &sk, &lsk) == FAILURE) RETURN_NULL(); | |
180 if (lsk != crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES) RETURN_FALSE; | |
181 char* pk = emalloc(crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES); | |
182 crypto_scalarmult_curve25519(pk, sk, base); | |
183 RETURN_STRINGL(pk, crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES, 0); | |
184 } | |
4
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 efree(smb); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
196 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
|
197 efree(sm); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
198 RETURN_FALSE; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
199 } |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
200 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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 efree(mb); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
211 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
|
212 efree(m); |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
213 RETURN_FALSE; |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
214 } |
81aaf4ba1eaa
Added partial untested support for sign_edwards25519sha512batch, replaced some whitespaces with tabs
Ivo Smits <Ivo@UCIS.nl>
parents:
2
diff
changeset
|
215 //extern int crypto_sign_edwards25519sha512batch_ref_keypair(unsigned char *,unsigned char *); |