Todd Ouska / CyaSSL

Dependents:   cyassl-client Sync

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ctc_rsa.h Source File

ctc_rsa.h

00001 /* ctc_rsa.h
00002  *
00003  * Copyright (C) 2006-2009 Sawtooth Consulting Ltd.
00004  *
00005  * This file is part of CyaSSL.
00006  *
00007  * CyaSSL is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 2 of the License, or
00010  * (at your option) any later version.
00011  *
00012  * CyaSSL is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00020  */
00021 
00022 
00023 #ifndef CTAO_CRYPT_RSA_H
00024 #define CTAO_CRYPT_RSA_H
00025 
00026 #include "types.h"
00027 #include "integer.h"
00028 #include "random.h"
00029 
00030 #ifdef __cplusplus
00031     extern "C" {
00032 #endif
00033 
00034 
00035 enum {
00036     RSA_PUBLIC   = 0,
00037     RSA_PRIVATE  = 1
00038 };
00039 
00040 /* RSA */
00041 typedef struct RsaKey {
00042     mp_int n, e, d, p, q, dP, dQ, u;
00043     int   type;                               /* public or private */
00044     void* heap;                               /* for user memory overrides */
00045 } RsaKey;
00046 
00047 
00048 void InitRsaKey(RsaKey* key, void*);
00049 void FreeRsaKey(RsaKey* key);
00050 
00051 int  RsaPublicEncrypt(const byte* in, word32 inLen, byte* out, word32 outLen,
00052                       RsaKey* key, RNG* rng);
00053 int  RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out, RsaKey* key);
00054 int  RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out, word32 outLen,
00055                        RsaKey* key);
00056 int  RsaSSL_Sign(const byte* in, word32 inLen, byte* out, word32 outLen,
00057                  RsaKey* key, RNG* rng);
00058 int  RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out, RsaKey* key);
00059 int  RsaSSL_Verify(const byte* in, word32 inLen, byte* out, word32 outLen,
00060                    RsaKey* key);
00061 
00062 int  RsaEncryptSize(RsaKey* key);
00063 
00064 #ifdef CYASSL_KEY_GEN
00065     int MakeRsaKey(RsaKey* key, int size, long e, RNG* rng);
00066 #endif
00067 
00068 
00069 #ifdef __cplusplus
00070     } /* extern "C" */
00071 #endif
00072 
00073 #endif /* CTAO_CRYPT_RSA_H */
00074