cya_u
Fork of CyaSSL-forEncrypt by
ctc_rsa.h@2:d0516dc143b1, 2017-05-10 (annotated)
- Committer:
- vbahl2
- Date:
- Wed May 10 18:20:47 2017 +0000
- Revision:
- 2:d0516dc143b1
- Parent:
- 0:5045d2638c29
updated
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
toddouska | 0:5045d2638c29 | 1 | /* ctc_rsa.h |
toddouska | 0:5045d2638c29 | 2 | * |
toddouska | 0:5045d2638c29 | 3 | * Copyright (C) 2006-2009 Sawtooth Consulting Ltd. |
toddouska | 0:5045d2638c29 | 4 | * |
toddouska | 0:5045d2638c29 | 5 | * This file is part of CyaSSL. |
toddouska | 0:5045d2638c29 | 6 | * |
toddouska | 0:5045d2638c29 | 7 | * CyaSSL is free software; you can redistribute it and/or modify |
toddouska | 0:5045d2638c29 | 8 | * it under the terms of the GNU General Public License as published by |
toddouska | 0:5045d2638c29 | 9 | * the Free Software Foundation; either version 2 of the License, or |
toddouska | 0:5045d2638c29 | 10 | * (at your option) any later version. |
toddouska | 0:5045d2638c29 | 11 | * |
toddouska | 0:5045d2638c29 | 12 | * CyaSSL is distributed in the hope that it will be useful, |
toddouska | 0:5045d2638c29 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
toddouska | 0:5045d2638c29 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
toddouska | 0:5045d2638c29 | 15 | * GNU General Public License for more details. |
toddouska | 0:5045d2638c29 | 16 | * |
toddouska | 0:5045d2638c29 | 17 | * You should have received a copy of the GNU General Public License |
toddouska | 0:5045d2638c29 | 18 | * along with this program; if not, write to the Free Software |
toddouska | 0:5045d2638c29 | 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
toddouska | 0:5045d2638c29 | 20 | */ |
toddouska | 0:5045d2638c29 | 21 | |
toddouska | 0:5045d2638c29 | 22 | |
toddouska | 0:5045d2638c29 | 23 | #ifndef CTAO_CRYPT_RSA_H |
toddouska | 0:5045d2638c29 | 24 | #define CTAO_CRYPT_RSA_H |
toddouska | 0:5045d2638c29 | 25 | |
toddouska | 0:5045d2638c29 | 26 | #include "types.h" |
toddouska | 0:5045d2638c29 | 27 | #include "integer.h" |
toddouska | 0:5045d2638c29 | 28 | #include "random.h" |
toddouska | 0:5045d2638c29 | 29 | |
toddouska | 0:5045d2638c29 | 30 | #ifdef __cplusplus |
toddouska | 0:5045d2638c29 | 31 | extern "C" { |
toddouska | 0:5045d2638c29 | 32 | #endif |
toddouska | 0:5045d2638c29 | 33 | |
toddouska | 0:5045d2638c29 | 34 | |
toddouska | 0:5045d2638c29 | 35 | enum { |
toddouska | 0:5045d2638c29 | 36 | RSA_PUBLIC = 0, |
toddouska | 0:5045d2638c29 | 37 | RSA_PRIVATE = 1 |
toddouska | 0:5045d2638c29 | 38 | }; |
toddouska | 0:5045d2638c29 | 39 | |
toddouska | 0:5045d2638c29 | 40 | /* RSA */ |
toddouska | 0:5045d2638c29 | 41 | typedef struct RsaKey { |
toddouska | 0:5045d2638c29 | 42 | mp_int n, e, d, p, q, dP, dQ, u; |
toddouska | 0:5045d2638c29 | 43 | int type; /* public or private */ |
toddouska | 0:5045d2638c29 | 44 | void* heap; /* for user memory overrides */ |
toddouska | 0:5045d2638c29 | 45 | } RsaKey; |
toddouska | 0:5045d2638c29 | 46 | |
toddouska | 0:5045d2638c29 | 47 | |
toddouska | 0:5045d2638c29 | 48 | void InitRsaKey(RsaKey* key, void*); |
toddouska | 0:5045d2638c29 | 49 | void FreeRsaKey(RsaKey* key); |
toddouska | 0:5045d2638c29 | 50 | |
toddouska | 0:5045d2638c29 | 51 | int RsaPublicEncrypt(const byte* in, word32 inLen, byte* out, word32 outLen, |
toddouska | 0:5045d2638c29 | 52 | RsaKey* key, RNG* rng); |
toddouska | 0:5045d2638c29 | 53 | int RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out, RsaKey* key); |
toddouska | 0:5045d2638c29 | 54 | int RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out, word32 outLen, |
toddouska | 0:5045d2638c29 | 55 | RsaKey* key); |
toddouska | 0:5045d2638c29 | 56 | int RsaSSL_Sign(const byte* in, word32 inLen, byte* out, word32 outLen, |
toddouska | 0:5045d2638c29 | 57 | RsaKey* key, RNG* rng); |
toddouska | 0:5045d2638c29 | 58 | int RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out, RsaKey* key); |
toddouska | 0:5045d2638c29 | 59 | int RsaSSL_Verify(const byte* in, word32 inLen, byte* out, word32 outLen, |
toddouska | 0:5045d2638c29 | 60 | RsaKey* key); |
toddouska | 0:5045d2638c29 | 61 | |
toddouska | 0:5045d2638c29 | 62 | int RsaEncryptSize(RsaKey* key); |
toddouska | 0:5045d2638c29 | 63 | |
toddouska | 0:5045d2638c29 | 64 | #ifdef CYASSL_KEY_GEN |
toddouska | 0:5045d2638c29 | 65 | int MakeRsaKey(RsaKey* key, int size, long e, RNG* rng); |
toddouska | 0:5045d2638c29 | 66 | #endif |
toddouska | 0:5045d2638c29 | 67 | |
toddouska | 0:5045d2638c29 | 68 | |
toddouska | 0:5045d2638c29 | 69 | #ifdef __cplusplus |
toddouska | 0:5045d2638c29 | 70 | } /* extern "C" */ |
toddouska | 0:5045d2638c29 | 71 | #endif |
toddouska | 0:5045d2638c29 | 72 | |
toddouska | 0:5045d2638c29 | 73 | #endif /* CTAO_CRYPT_RSA_H */ |
toddouska | 0:5045d2638c29 | 74 |