BOLOS TEE
bolos_sodium.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * BOLOS TEE
4 * (c) 2016 Ledger
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 ********************************************************************************/
18 
19 /*
20  * libsodium Copyright (c) 2013-2016
21  * Frank Denis <j at pureftpd dot org>
22  *
23  * Permission to use, copy, modify, and/or distribute this software for any
24  * purpose with or without fee is hereby granted, provided that the above
25  * copyright notice and this permission notice appear in all copies.
26  *
27  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
28  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
29  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
30  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
31  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
32  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
33  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
34  */
35 
48 #ifndef __BOLOS_SODIUM_H__
49 
50 #define __BOLOS_SODIUM_H__
51 
52 #define crypto_secretbox_MACBYTES 16
53 #define crypto_secretbox_NONCEBYTES 24
54 #define crypto_secretbox_KEYBYTES 32
55 #define crypto_auth_KEYBYTES 32
56 #define crypto_auth_BYTES 32
57 #define crypto_box_PUBLICKEYBYTES 32
58 #define crypto_box_SECRETKEYBYTES 32
59 #define crypto_box_NONCEBYTES 24
60 #define crypto_box_MACBYTES 16
61 #define crypto_box_SEALBYTES (crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES)
62 #define crypto_sign_PUBLICKEYBYTES 32
63 #define crypto_sign_SECRETKEYBYTES 64
64 #define crypto_sign_BYTES 64
65 
87 int crypto_secretbox_easy(unsigned char *c, const unsigned char *m,
88  unsigned long mlen, const unsigned char *n,
89  const unsigned char *k);
90 
112 int crypto_secretbox_open_easy(unsigned char *m, const unsigned char *c,
113  unsigned long clen, const unsigned char *n,
114  const unsigned char *k);
115 
134 int crypto_auth(unsigned char *out, const unsigned char *in,
135  unsigned long inlen, const unsigned char *k);
136 
137 
156 int crypto_auth_verify(const unsigned char *h, const unsigned char *in,
157  unsigned long inlen, const unsigned char *k);
158 
159 
172 int crypto_box_keypair(unsigned char *pk, unsigned char *sk);
173 
198 int crypto_box_easy(unsigned char *c, const unsigned char *m,
199  unsigned long mlen, const unsigned char *n,
200  const unsigned char *pk, const unsigned char *sk);
201 
202 
227 int crypto_box_open_easy(unsigned char *m, const unsigned char *c,
228  unsigned long clen, const unsigned char *n,
229  const unsigned char *pk, const unsigned char *sk);
230 
249 int crypto_box_seal(unsigned char *c, const unsigned char *m,
250  unsigned long mlen, const unsigned char *pk);
251 
273 int crypto_box_seal_open(unsigned char *m, const unsigned char *c,
274  unsigned long clen,
275  const unsigned char *pk, const unsigned char *sk);
276 
277 
290 int crypto_sign_keypair(unsigned char *pk, unsigned char *sk);
291 
313 int crypto_sign(unsigned char *sm, unsigned long *smlen_p,
314  const unsigned char *m, unsigned long mlen,
315  const unsigned char *sk);
316 
338 int crypto_sign_open(unsigned char *m, unsigned long *mlen_p,
339  const unsigned char *sm, unsigned long smlen,
340  const unsigned char *pk);
341 
342 
343 #endif //__BOLOS_SODIUM_H__
344 
int crypto_auth_verify(const unsigned char *h, const unsigned char *in, unsigned long inlen, const unsigned char *k)
Verify an authentication (HMAC) of a message generated by crypto_auth.
int crypto_box_open_easy(unsigned char *m, const unsigned char *c, unsigned long clen, const unsigned char *n, const unsigned char *pk, const unsigned char *sk)
Decrypt a message encrypted by crypto_box_easy.
int crypto_box_easy(unsigned char *c, const unsigned char *m, unsigned long mlen, const unsigned char *n, const unsigned char *pk, const unsigned char *sk)
Authenticated Encryption (X25519 + XSalsa20 + Poly1305) of a message using an asymmetric keypair...
int crypto_sign(unsigned char *sm, unsigned long *smlen_p, const unsigned char *m, unsigned long mlen, const unsigned char *sk)
Generate a Combined Signature (Ed25519) of a message using an asymmetric keypair. ...
int crypto_sign_open(unsigned char *m, unsigned long *mlen_p, const unsigned char *sm, unsigned long smlen, const unsigned char *pk)
Unwrap a message wrapped by crypto_sign.
int crypto_box_seal_open(unsigned char *m, const unsigned char *c, unsigned long clen, const unsigned char *pk, const unsigned char *sk)
Decrypt a message encrypted by crypto_box_seal.
int crypto_secretbox_easy(unsigned char *c, const unsigned char *m, unsigned long mlen, const unsigned char *n, const unsigned char *k)
Authenticated Encryption (XSalsa20 + Poly1305) of a message using a symmetric key.
int crypto_sign_keypair(unsigned char *pk, unsigned char *sk)
Generate a keypair to be used for Signature with crypto_sign functions.
int crypto_secretbox_open_easy(unsigned char *m, const unsigned char *c, unsigned long clen, const unsigned char *n, const unsigned char *k)
Decrypt a message encrypted by crypto_secretbox_easy.
int crypto_auth(unsigned char *out, const unsigned char *in, unsigned long inlen, const unsigned char *k)
Compute an authentication (HMAC) of a message using a symmetric key.
int crypto_box_seal(unsigned char *c, const unsigned char *m, unsigned long mlen, const unsigned char *pk)
Anonymous encryption (X25519, XSalsa20, Poly1305) of a message using an asymmetric keypair...
int crypto_box_keypair(unsigned char *pk, unsigned char *sk)
Generate a keypair to be used for Authenticated Encryption with crypto_box functions.