ARM Shanghai IoT Team (Internal) / newMiniTLS-GPL

Fork of MiniTLS-GPL by Donatien Garnier

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ltc.h Source File

ltc.h

Go to the documentation of this file.
00001 /*
00002 MiniTLS - A super trimmed down TLS/SSL Library for embedded devices
00003 Author: Donatien Garnier
00004 Copyright (C) 2013-2014 AppNearMe Ltd
00005 
00006 This program is free software; you can redistribute it and/or
00007 modify it under the terms of the GNU General Public License
00008 as published by the Free Software Foundation; either version 2
00009 of the License, or (at your option) any later version.
00010 
00011 This program is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with this program; if not, write to the Free Software
00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019 *//**
00020  * \file ltc.h
00021  * \copyright Copyright (c) AppNearMe Ltd 2013
00022  * \author Donatien Garnier
00023  */
00024 
00025 #ifndef LTC_H_
00026 #define LTC_H_
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 #include "core/fwk.h"
00033 #include "crypto/crypto_ecc.h"
00034 #include "crypto/crypto_math.h"
00035 
00036 
00037 /*
00038  Config
00039  * */
00040 /* ECC */
00041 #define LTC_MECC
00042 #define MPI
00043 
00044 #define ECC_BUF_SIZE 256 //FIXME should it be *that* big?
00045 
00046 /* use Shamir's trick for point mul (speeds up signature verification) */
00047 //#define LTC_ECC_SHAMIR -- nope, consumes too much memory
00048 
00049 #define LTC_ECC_TIMING_RESISTANT
00050 
00051 #define zeromem(buf,size) memset((buf), 0, (size))
00052 
00053 typedef crypto_ecc_point_t ecc_point;
00054 
00055 /* low level functions */
00056 int ltc_init_multi(void *a, ...);
00057 void ltc_deinit_multi(void *a, ...);
00058 #if 0
00059 ecc_point *ltc_ecc_new_point(void);
00060 void       ltc_ecc_del_point(ecc_point *p);
00061 #endif
00062 int        ltc_ecc_is_valid_idx(int n);
00063 
00064 /* point ops (mp == montgomery digit) */
00065 /* R = 2P */
00066 int ltc_ecc_projective_dbl_point(ecc_point *P, ecc_point *R, void *modulus, void *mp);
00067 
00068 /* R = P + Q */
00069 int ltc_ecc_projective_add_point(ecc_point *P, ecc_point *Q, ecc_point *R, void *modulus, void *mp);
00070 
00071 
00072 /* R = kG */
00073 int ltc_ecc_mulmod(void *k, ecc_point *G, ecc_point *R, void *modulus, int map);
00074 
00075 #ifdef LTC_ECC_SHAMIR
00076 /* kA*A + kB*B = C */
00077 int ltc_ecc_mul2add(ecc_point *A, void *kA,
00078                     ecc_point *B, void *kB,
00079                     ecc_point *C,
00080                          void *modulus);
00081 #endif
00082 
00083 
00084 /* map P to affine from projective */
00085 int ltc_ecc_map(ecc_point *P, void *modulus, void *mp);
00086 
00087 #define LTC_ARGCHK(x)
00088 
00089 
00090 #ifdef __cplusplus
00091 }
00092 #endif
00093 
00094 #endif /* LTC_H_ */